feat: delegate deterministic workflow operations to gsd-tools CLI

Add 10 new CLI commands that replace manual AI orchestration of
mechanical, deterministic operations — saving tokens and reducing
errors on the most complex GSD workflows.

New commands:
- phase add <desc> — append phase to roadmap + create directory
- phase insert <after> <desc> — insert decimal phase
- phase remove <N> [--force] — remove phase with full renumbering
- phase complete <N> — mark done, update state + roadmap, detect milestone end
- roadmap analyze — unified roadmap parser with disk status
- milestone complete <ver> [--name] — archive roadmap/requirements/audit
- validate consistency — check phase numbering and disk/roadmap sync
- progress [json|table|bar] — render progress in various formats
- todo complete <file> — move todo from pending to completed
- scaffold [context|uat|verification|phase-dir] — template generation

Updated workflows to use new CLI commands:
- remove-phase.md: 13 manual steps → 1 CLI call + confirm + commit
- add-phase.md: 6 manual steps → 1 CLI call + state update
- insert-phase.md: 7 manual steps → 1 CLI call + state update
- transition.md: roadmap/state updates delegated to phase complete
- progress.md: roadmap parsing delegated to roadmap analyze
- complete-milestone.md: archival delegated to milestone complete

75 tests passing (33 new).

https://claude.ai/code/session_01UhMGMrNGGn2bfeAi7MBphs
This commit is contained in:
Claude
2026-02-08 13:53:09 +00:00
parent 9ad7903895
commit 36f5bb3d5f
8 changed files with 2176 additions and 618 deletions

View File

@@ -17,31 +17,17 @@ Example: `/gsd:insert-phase 72 Fix critical auth bug`
-> after = 72
-> description = "Fix critical auth bug"
Validation:
If arguments missing:
```bash
if [ $# -lt 2 ]; then
echo "ERROR: Both phase number and description required"
echo "Usage: /gsd:insert-phase <after> <description>"
echo "Example: /gsd:insert-phase 72 Fix critical auth bug"
exit 1
fi
```
ERROR: Both phase number and description required
Usage: /gsd:insert-phase <after> <description>
Example: /gsd:insert-phase 72 Fix critical auth bug
```
Parse first argument as integer:
```bash
after_phase=$1
shift
description="$*"
# Validate after_phase is an integer
if ! [[ "$after_phase" =~ ^[0-9]+$ ]]; then
echo "ERROR: Phase number must be an integer"
exit 1
fi
```
Exit.
Validate first argument is an integer.
</step>
<step name="init_context">
@@ -56,111 +42,35 @@ Check `roadmap_exists` from init JSON. If false:
ERROR: No roadmap found (.planning/ROADMAP.md)
```
Exit.
Read roadmap content for parsing.
</step>
<step name="verify_target_phase">
Verify that the target phase exists in the roadmap:
1. Search for "### Phase {after_phase}:" heading
2. If not found:
```
ERROR: Phase {after_phase} not found in roadmap
Available phases: [list phase numbers]
```
Exit.
3. Verify phase is in current milestone (not completed/archived)
</step>
<step name="find_existing_decimals">
Calculate next decimal phase number:
<step name="insert_phase">
**Delegate the phase insertion to gsd-tools:**
```bash
DECIMAL_INFO=$(node ~/.claude/get-shit-done/bin/gsd-tools.js phase next-decimal "${after_phase}")
RESULT=$(node ~/.claude/get-shit-done/bin/gsd-tools.js phase insert "${after_phase}" "${description}")
```
Extract from JSON:
- `next`: The next available decimal (e.g., "06.1", "06.3")
- `existing`: Array of existing decimals (e.g., ["06.1", "06.2"])
- `base_phase`: Normalized base phase (e.g., "06")
The CLI handles:
- Verifying target phase exists in ROADMAP.md
- Calculating next decimal phase number (checking existing decimals on disk)
- Generating slug from description
- Creating the phase directory (`.planning/phases/{N.M}-{slug}/`)
- Inserting the phase entry into ROADMAP.md after the target phase with (INSERTED) marker
Store the result:
```bash
decimal_phase=$(echo "$DECIMAL_INFO" | jq -r '.next')
```
Examples:
- Phase 72 with no decimals -> next is 72.1
- Phase 72 with 72.1 -> next is 72.2
- Phase 72 with 72.1, 72.2 -> next is 72.3
</step>
<step name="generate_slug">
Convert the phase description to a kebab-case slug.
Use `generate-slug` command (init phase-op provides `phase_slug` for existing phase, but this is a new phase):
```bash
slug=$(node ~/.claude/get-shit-done/bin/gsd-tools.js generate-slug "$description" --raw)
```
Phase directory name: `{decimal-phase}-{slug}`
Example: `06.1-fix-critical-auth-bug` (phase 6 insertion)
</step>
<step name="create_phase_directory">
Create the phase directory structure:
```bash
phase_dir=".planning/phases/${decimal_phase}-${slug}"
mkdir -p "$phase_dir"
```
Confirm: "Created directory: $phase_dir"
</step>
<step name="update_roadmap">
Insert the new phase entry into the roadmap:
1. Find insertion point: immediately after Phase {after_phase}'s content (before next phase heading or "---")
2. Insert new phase heading with (INSERTED) marker:
```
### Phase {decimal_phase}: {Description} (INSERTED)
**Goal:** [Urgent work - to be planned]
**Depends on:** Phase {after_phase}
**Plans:** 0 plans
Plans:
- [ ] TBD (run /gsd:plan-phase {decimal_phase} to break down)
**Details:**
[To be added during planning]
```
3. Write updated roadmap back to file
The "(INSERTED)" marker helps identify decimal phases as urgent insertions.
Preserve all other content exactly (formatting, spacing, other phases).
Extract from result: `phase_number`, `after_phase`, `name`, `slug`, `directory`.
</step>
<step name="update_project_state">
Update STATE.md to reflect the inserted phase:
1. Read `.planning/STATE.md`
2. Under "## Accumulated Context" -> "### Roadmap Evolution" add entry:
2. Under "## Accumulated Context" → "### Roadmap Evolution" add entry:
```
- Phase {decimal_phase} inserted after Phase {after_phase}: {description} (URGENT)
```
If "Roadmap Evolution" section doesn't exist, create it.
Add note about insertion reason if appropriate.
</step>
<step name="completion">
@@ -173,7 +83,7 @@ Phase {decimal_phase} inserted after Phase {after_phase}:
- Status: Not planned yet
- Marker: (INSERTED) - indicates urgent work
Roadmap updated: {roadmap-path}
Roadmap updated: .planning/ROADMAP.md
Project state updated: .planning/STATE.md
---
@@ -211,10 +121,9 @@ Project state updated: .planning/STATE.md
<success_criteria>
Phase insertion is complete when:
- [ ] Phase directory created: `.planning/phases/{N.M}-{slug}/`
- [ ] `gsd-tools phase insert` executed successfully
- [ ] Phase directory created
- [ ] Roadmap updated with new phase entry (includes "(INSERTED)" marker)
- [ ] Phase inserted in correct position (after target phase, before next integer phase)
- [ ] STATE.md updated with roadmap evolution note
- [ ] Decimal number calculated correctly (based on existing decimals)
- [ ] User informed of next steps and dependency implications
</success_criteria>