feat(gsd-tools): frontmatter CRUD, verification suite, template fill, state progression (#485)

* feat(gsd-tools): add frontmatter CRUD, verification suite, template fill, and state progression

Four new command groups that delegate deterministic operations from AI agents to code:

- frontmatter get/set/merge/validate: Safe YAML frontmatter manipulation with schema validation
- verify plan-structure/phase-completeness/references/commits/artifacts/key-links: Structural checks agents previously burned context on
- template fill summary/plan/verification: Pre-filled document skeletons so agents only fill creative content
- state advance-plan/record-metric/update-progress/add-decision/add-blocker/resolve-blocker/record-session: Automate arithmetic and formatting in STATE.md

Adds reconstructFrontmatter() + spliceFrontmatter() helpers for safe frontmatter roundtripping,
and parseMustHavesBlock() for 3-level YAML parsing of must_haves structures.

20 new functions, ~1037 new lines.

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

* feat: wire gsd-tools commands into agents and workflows

- gsd-verifier: use `verify artifacts` and `verify key-links` instead of
  manual grep patterns for stub detection and wiring verification
- gsd-executor: use `state advance-plan`, `state update-progress`,
  `state record-metric`, `state add-decision`, `state record-session`
  instead of manual STATE.md manipulation
- gsd-plan-checker: use `verify plan-structure` and `frontmatter get`
  for structural validation and must_haves extraction
- gsd-planner: add validation step using `frontmatter validate` and
  `verify plan-structure` after writing PLAN.md
- execute-plan.md: use gsd-tools state commands for position/progress updates
- verify-phase.md: use gsd-tools for must_haves extraction and artifact/link verification

This makes the gsd-tools commands from PR #485 actually used by the system.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
TÂCHES
2026-02-08 09:28:50 -06:00
committed by GitHub
parent 4072fd2baf
commit 6a2d1f1bfb
7 changed files with 1255 additions and 82 deletions

View File

@@ -115,58 +115,38 @@ For each truth:
## Step 4: Verify Artifacts (Three Levels)
### Level 1: Existence
Use gsd-tools for artifact verification against must_haves in PLAN frontmatter:
```bash
[ -f "$path" ] && echo "EXISTS" || echo "MISSING"
ARTIFACT_RESULT=$(node ~/.claude/get-shit-done/bin/gsd-tools.js verify artifacts "$PLAN_PATH")
```
If MISSING → artifact fails, record and continue.
Parse JSON result: `{ all_passed, passed, total, artifacts: [{path, exists, issues, passed}] }`
### Level 2: Substantive
For each artifact in result:
- `exists=false` → MISSING
- `issues` contains "Only N lines" or "Missing pattern" → STUB
- `passed=true` → VERIFIED
**Line count check** — minimums by type:
- Component: 15+ lines | API route: 10+ | Hook/util: 10+ | Schema: 5+
**Artifact status mapping:**
**Stub pattern check:**
```bash
check_stubs() {
local path="$1"
local stubs=$(grep -c -E "TODO|FIXME|placeholder|not implemented|coming soon" "$path" 2>/dev/null || echo 0)
local empty=$(grep -c -E "return null|return undefined|return \{\}|return \[\]" "$path" 2>/dev/null || echo 0)
local placeholder=$(grep -c -E "will be here|placeholder|lorem ipsum" "$path" 2>/dev/null || echo 0)
local total=$((stubs + empty + placeholder))
[ "$total" -gt 0 ] && echo "STUB_PATTERNS ($total found)" || echo "NO_STUBS"
}
```
**Export check:**
```bash
grep -E "^export (default )?(function|const|class)" "$path" && echo "HAS_EXPORTS" || echo "NO_EXPORTS"
```
**Combine Level 2:**
- SUBSTANTIVE: Adequate length + no stubs + has exports
- STUB: Too short OR has stub patterns OR no exports
- PARTIAL: Mixed signals
### Level 3: Wired
**Import check:**
| exists | issues empty | Status |
| ------ | ------------ | ----------- |
| true | true | ✓ VERIFIED |
| true | false | ✗ STUB |
| false | - | ✗ MISSING |
**For wiring verification (Level 3)**, check imports/usage manually for artifacts that pass Levels 1-2:
```bash
# Import check
grep -r "import.*$artifact_name" "${search_path:-src/}" --include="*.ts" --include="*.tsx" 2>/dev/null | wc -l
```
**Usage check:**
```bash
# Usage check (beyond imports)
grep -r "$artifact_name" "${search_path:-src/}" --include="*.ts" --include="*.tsx" 2>/dev/null | grep -v "import" | wc -l
```
**Combine Level 3:**
**Wiring status:**
- WIRED: Imported AND used
- ORPHANED: Exists but not imported/used
- PARTIAL: Imported but not used (or vice versa)
@@ -184,14 +164,25 @@ grep -r "$artifact_name" "${search_path:-src/}" --include="*.ts" --include="*.ts
Key links are critical connections. If broken, the goal fails even with all artifacts present.
**For each link pattern, verify: (1) call exists, (2) response/result is used.**
Use gsd-tools for key link verification against must_haves in PLAN frontmatter:
```bash
LINKS_RESULT=$(node ~/.claude/get-shit-done/bin/gsd-tools.js verify key-links "$PLAN_PATH")
```
Parse JSON result: `{ all_verified, verified, total, links: [{from, to, via, verified, detail}] }`
For each link:
- `verified=true` → WIRED
- `verified=false` with "not found" in detail → NOT_WIRED
- `verified=false` with "Pattern not found" → PARTIAL
**Fallback patterns** (if must_haves.key_links not defined in PLAN):
### Pattern: Component → API
```bash
# Check for fetch/axios call to the API
grep -E "fetch\(['\"].*$api_path|axios\.(get|post).*$api_path" "$component" 2>/dev/null
# Check response handling
grep -A 5 "fetch\|axios" "$component" | grep -E "await|\.then|setData|setState" 2>/dev/null
```
@@ -200,9 +191,7 @@ Status: WIRED (call + response handling) | PARTIAL (call, no response use) | NOT
### Pattern: API → Database
```bash
# Check for DB query
grep -E "prisma\.$model|db\.$model|$model\.(find|create|update|delete)" "$route" 2>/dev/null
# Check result returned
grep -E "return.*json.*\w+|res\.json\(\w+" "$route" 2>/dev/null
```
@@ -211,7 +200,6 @@ Status: WIRED (query + result returned) | PARTIAL (query, static return) | NOT_W
### Pattern: Form → Handler
```bash
# Check onSubmit handler exists and has real implementation
grep -E "onSubmit=\{|handleSubmit" "$component" 2>/dev/null
grep -A 10 "onSubmit.*=" "$component" | grep -E "fetch|axios|mutate|dispatch" 2>/dev/null
```
@@ -221,7 +209,6 @@ Status: WIRED (handler + API call) | STUB (only logs/preventDefault) | NOT_WIRED
### Pattern: State → Render
```bash
# Check state exists and is rendered in JSX
grep -E "useState.*$state_var|\[$state_var," "$component" 2>/dev/null
grep -E "\{.*$state_var.*\}|\{$state_var\." "$component" 2>/dev/null
```
@@ -244,9 +231,19 @@ For each requirement: parse description → identify supporting truths/artifacts
## Step 7: Scan for Anti-Patterns
Identify files modified in this phase:
Identify files modified in this phase from SUMMARY.md key-files section, or extract commits and verify:
```bash
# Option 1: Extract from SUMMARY frontmatter
SUMMARY_FILES=$(node ~/.claude/get-shit-done/bin/gsd-tools.js summary-extract "$PHASE_DIR"/*-SUMMARY.md --fields key-files)
# Option 2: Verify commits exist (if commit hashes documented)
COMMIT_HASHES=$(grep -oE "[a-f0-9]{7,40}" "$PHASE_DIR"/*-SUMMARY.md | head -10)
if [ -n "$COMMIT_HASHES" ]; then
COMMITS_VALID=$(node ~/.claude/get-shit-done/bin/gsd-tools.js verify commits $COMMIT_HASHES)
fi
# Fallback: grep for files
grep -E "^\- \`" "$PHASE_DIR"/*-SUMMARY.md | sed 's/.*`\([^`]*\)`.*/\1/' | sort -u
```