feat: extract repetitive bash patterns into gsd-tools commands (#472)

* feat(gsd-tools): add history-digest, atomic state operations, and summary variants

Adds new performance-focused commands to gsd-tools and introduces specialized
summary templates to reduce context tax:

- history-digest: Compiles phase summaries into structured JSON for JIT loading
- state get/patch: Enables atomic STATE.md operations instead of full rewrites
- template select: Automatically chooses optimal summary template based on plan complexity
- Adds minimal, standard, and complex summary templates

Part of the "Hydra" architecture for GSD context optimization.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* chore: add project config

* docs: define v1 requirements

* docs: create roadmap (6 phases)

* feat(history-digest): fix nested YAML parsing and add tests

- Fix extractFrontmatter() to handle nested YAML structures like
  dependency-graph.provides, tech-stack.added using stack-based parsing
- Add test infrastructure with Node test runner (npm test)
- Update gsd-planner to use digest fields directly instead of reading
  full SUMMARY.md files
- Add 6 schema validation tests covering nested fields, merging,
  malformed files, and backward compatibility

Closes: HIST-01, HIST-02, HIST-03, HIST-04

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(planner): use digest for selection, full SUMMARY for understanding

The previous commit went too far by eliminating full SUMMARY reads.
The digest is an index for smart selection, not a replacement for
understanding what actually happened.

Two-step approach:
1. Digest to score/select relevant phases (2-4 typically)
2. Full SUMMARY read for selected phases (implementation details)
3. Digest-level context retained for unselected phases

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(gsd-tools): add phases, roadmap, and phase commands

TDD implementation of three new commands to replace repetitive bash:

phases list [--type plans|summaries] [--phase N]
- Lists phase directories sorted numerically (handles decimals)
- Filter by file type or specific phase
- Replaces: ls -d .planning/phases/*/ | sort -V (22 occurrences)

roadmap get-phase <N>
- Extracts phase section from ROADMAP.md
- Returns name, goal, full section content
- Replaces: grep -A20 "Phase X:" ROADMAP.md (19 occurrences)

phase next-decimal <N>
- Calculates next decimal phase (06 → 06.1, 06.2 → 06.3)
- Handles gaps, normalizes input
- Replaces: complex bash math in insert-phase (3 occurrences)

16 new tests, all passing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: migrate agents/workflows to use gsd-tools commands

Replace inline bash patterns with centralized gsd-tools commands:

phases list:
- audit-milestone.md: ls -d .planning/phases/*/ | sort -V
- plan-milestone-gaps.md: ls -d ... | sort -V | tail -1

roadmap get-phase:
- plan-phase.md: grep -A5 "Phase X:" ROADMAP.md (2 occurrences)
- research-phase.md: grep patterns (2 occurrences)
- verify-phase.md: grep -A5 pattern
- gsd-verifier.md: grep -A5 pattern
- gsd-plan-checker.md: grep -A10 pattern
- commands/gsd/research-phase.md: grep patterns (2 occurrences)

phase next-decimal:
- insert-phase.md: complex bash decimal calculation
- decimal-phase-calculation.md: reference doc rewritten

phase-argument-parsing.md: updated to reference gsd-tools

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
TÂCHES
2026-02-08 00:44:49 -06:00
committed by GitHub
parent 3f5ab10713
commit 1b317dec45
29 changed files with 2938 additions and 84 deletions

View File

@@ -2,40 +2,45 @@
Calculate the next decimal phase number for urgent insertions.
## Find Existing Decimals
For a given integer phase, find all existing decimal phases:
## Using gsd-tools
```bash
# Find decimal phases after integer phase N (e.g., 06.1, 06.2)
AFTER_PHASE=$1 # e.g., 6
# Pad to 2 digits
PADDED=$(printf "%02d" "$AFTER_PHASE")
# Find existing decimals
EXISTING=$(ls -d .planning/phases/${PADDED}.*-* 2>/dev/null | \
xargs -I{} basename {} | \
grep -oE '^[0-9]+\.[0-9]+' | \
sort -V)
# Get next decimal phase after phase 6
node ~/.claude/get-shit-done/bin/gsd-tools.js phase next-decimal 6
```
## Calculate Next Decimal
Output:
```json
{
"found": true,
"base_phase": "06",
"next": "06.1",
"existing": []
}
```
Find the highest decimal suffix and increment:
With existing decimals:
```json
{
"found": true,
"base_phase": "06",
"next": "06.3",
"existing": ["06.1", "06.2"]
}
```
## Extract Values
```bash
if [ -z "$EXISTING" ]; then
# No decimals exist, start at .1
NEXT_DECIMAL="1"
else
# Get highest decimal suffix
MAX_SUFFIX=$(echo "$EXISTING" | tail -1 | grep -oE '\.[0-9]+$' | tr -d '.')
NEXT_DECIMAL=$((MAX_SUFFIX + 1))
fi
DECIMAL_INFO=$(node ~/.claude/get-shit-done/bin/gsd-tools.js phase next-decimal "${AFTER_PHASE}")
DECIMAL_PHASE=$(echo "$DECIMAL_INFO" | jq -r '.next')
BASE_PHASE=$(echo "$DECIMAL_INFO" | jq -r '.base_phase')
```
# Format: 06.1, 06.2, etc.
DECIMAL_PHASE="${PADDED}.${NEXT_DECIMAL}"
Or with --raw flag:
```bash
DECIMAL_PHASE=$(node ~/.claude/get-shit-done/bin/gsd-tools.js phase next-decimal "${AFTER_PHASE}" --raw)
# Returns just: 06.1
```
## Examples
@@ -45,13 +50,14 @@ DECIMAL_PHASE="${PADDED}.${NEXT_DECIMAL}"
| 06 only | 06.1 |
| 06, 06.1 | 06.2 |
| 06, 06.1, 06.2 | 06.3 |
| 06, 06.1, 06.3 (gap) | 06.4 |
## Directory Naming
Decimal phase directories use the full decimal number:
```bash
SLUG=$(echo "$DESCRIPTION" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//')
SLUG=$(node ~/.claude/get-shit-done/bin/gsd-tools.js generate-slug "$DESCRIPTION" --raw)
PHASE_DIR=".planning/phases/${DECIMAL_PHASE}-${SLUG}"
mkdir -p "$PHASE_DIR"
```

View File

@@ -9,7 +9,23 @@ From `$ARGUMENTS`:
- Extract flags (prefixed with `--`)
- Remaining text is description (for insert/add commands)
## Normalization
## Using gsd-tools
The `find-phase` command handles normalization and validation in one step:
```bash
PHASE_INFO=$(node ~/.claude/get-shit-done/bin/gsd-tools.js find-phase "${PHASE}")
```
Returns JSON with:
- `found`: true/false
- `directory`: Full path to phase directory
- `phase_number`: Normalized number (e.g., "06", "06.1")
- `phase_name`: Name portion (e.g., "foundation")
- `plans`: Array of PLAN.md files
- `summaries`: Array of SUMMARY.md files
## Manual Normalization (Legacy)
Zero-pad integer phases to 2 digits. Preserve decimal suffixes.
@@ -24,35 +40,22 @@ elif [[ "$PHASE" =~ ^([0-9]+)\.([0-9]+)$ ]]; then
fi
```
## Auto-Detection
When no phase number provided, detect the next unplanned phase:
```bash
# Find phases without PLAN.md files
for dir in .planning/phases/*/; do
if ! ls "$dir"/*-PLAN.md 2>/dev/null | head -1 >/dev/null; then
PHASE=$(basename "$dir" | grep -oE '^[0-9.]+')
break
fi
done
```
## Validation
After normalization, verify phase exists in ROADMAP.md:
Use `roadmap get-phase` to validate phase exists:
```bash
grep -q "### Phase ${PHASE}:" .planning/ROADMAP.md || {
PHASE_CHECK=$(node ~/.claude/get-shit-done/bin/gsd-tools.js roadmap get-phase "${PHASE}")
if [ "$(echo "$PHASE_CHECK" | jq -r '.found')" = "false" ]; then
echo "ERROR: Phase ${PHASE} not found in roadmap"
exit 1
}
fi
```
## Directory Lookup
Find the phase directory using the normalized phase number:
Use `find-phase` for directory lookup:
```bash
PHASE_DIR=$(ls -d .planning/phases/${PHASE}-* 2>/dev/null | head -1)
PHASE_DIR=$(node ~/.claude/get-shit-done/bin/gsd-tools.js find-phase "${PHASE}" --raw)
```