fix: Windows shell robustness, project_root detection, and hook stdin safety (#1343)

Address 4 root causes of Windows + Claude Code reliability issues:

1. Workflow shell robustness: add || true guards to informational commands
   (ls, grep, find, cat) that return non-zero on "no results", preventing
   workflow step failures under strict execution models. Guard glob loops
   with [ -e "$var" ] || continue to handle empty glob expansion.

2. Hook stdin handling: replace readFileSync('/dev/stdin') with async
   process.stdin + timeout in agent templates (gsd-verifier.md). Existing
   JS hooks already have timeout guards.

3. project_root detection: fix isInsideGitRepo() to check .git at the
   candidate parent level (not just below it), enabling correct detection
   when .git and .planning/ are siblings at the same directory level —
   the common single-repo case from a subdirectory.

4. @file: handoff: add missing @file: handlers to autonomous.md and
   manager.md workflows that call gsd-tools init but lacked the handler
   for large output payloads.

Fixes #1343

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-03-23 20:20:15 -04:00
parent ae69e6e9e4
commit 58c2b1f502
25 changed files with 314 additions and 70 deletions

View File

@@ -29,6 +29,7 @@ Bootstrap via milestone-level init:
```bash
INIT=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" init milestone-op)
if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
```
Parse JSON for: `milestone_version`, `milestone_name`, `phase_count`, `completed_phases`, `roadmap_exists`, `state_exists`, `commit_docs`.
@@ -351,9 +352,9 @@ Read project-level and prior phase context to avoid re-asking decided questions.
**Read project files:**
```bash
cat .planning/PROJECT.md 2>/dev/null
cat .planning/REQUIREMENTS.md 2>/dev/null
cat .planning/STATE.md 2>/dev/null
cat .planning/PROJECT.md 2>/dev/null || true
cat .planning/REQUIREMENTS.md 2>/dev/null || true
cat .planning/STATE.md 2>/dev/null || true
```
Extract from these:
@@ -364,7 +365,7 @@ Extract from these:
**Read all prior CONTEXT.md files:**
```bash
find .planning/phases -name "*-CONTEXT.md" 2>/dev/null | sort
(find .planning/phases -name "*-CONTEXT.md" 2>/dev/null || true) | sort
```
For each CONTEXT.md where phase number < current phase:
@@ -398,7 +399,7 @@ Lightweight codebase scan to inform grey area identification and proposals. Keep
**Check for existing codebase maps:**
```bash
ls .planning/codebase/*.md 2>/dev/null
ls .planning/codebase/*.md 2>/dev/null || true
```
**If codebase maps exist:** Read the most relevant ones (CONVENTIONS.md, STRUCTURE.md, STACK.md based on phase type). Extract reusable components, established patterns, integration points. Skip to building context below.
@@ -408,8 +409,8 @@ ls .planning/codebase/*.md 2>/dev/null
Extract key terms from the phase goal. Search for related files:
```bash
grep -rl "{term1}\|{term2}" src/ app/ --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" 2>/dev/null | head -10
ls src/components/ src/hooks/ src/lib/ src/utils/ 2>/dev/null
grep -rl "{term1}\|{term2}" src/ app/ --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" 2>/dev/null | head -10 || true
ls src/components/ src/hooks/ src/lib/ src/utils/ 2>/dev/null || true
```
Read the 3-5 most relevant files to understand existing patterns.
@@ -721,7 +722,7 @@ Skill(skill="gsd:complete-milestone", args="${milestone_version}")
After complete-milestone returns, verify it produced output:
```bash
ls .planning/milestones/v${milestone_version}-ROADMAP.md 2>/dev/null
ls .planning/milestones/v${milestone_version}-ROADMAP.md 2>/dev/null || true
```
If the archive file does not exist, go to handle_blocker: "Complete milestone did not produce expected archive files."