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

@@ -41,8 +41,8 @@ Mark current phase complete and advance to next. This is the natural point where
Before transition, read project state:
```bash
cat .planning/STATE.md 2>/dev/null
cat .planning/PROJECT.md 2>/dev/null
cat .planning/STATE.md 2>/dev/null || true
cat .planning/PROJECT.md 2>/dev/null || true
```
Parse current position to verify we're transitioning the right phase.
@@ -55,8 +55,8 @@ Note accumulated context that may need updating after transition.
Check current phase has all plan summaries:
```bash
ls .planning/phases/XX-current/*-PLAN.md 2>/dev/null | sort
ls .planning/phases/XX-current/*-SUMMARY.md 2>/dev/null | sort
(ls .planning/phases/XX-current/*-PLAN.md 2>/dev/null || true) | sort
(ls .planning/phases/XX-current/*-SUMMARY.md 2>/dev/null || true) | sort
```
**Verification logic:**
@@ -69,7 +69,7 @@ ls .planning/phases/XX-current/*-SUMMARY.md 2>/dev/null | sort
<config-check>
```bash
cat .planning/config.json 2>/dev/null
cat .planning/config.json 2>/dev/null || true
```
</config-check>
@@ -151,7 +151,7 @@ Wait for user decision.
Check for lingering handoffs:
```bash
ls .planning/phases/XX-current/.continue-here*.md 2>/dev/null
ls .planning/phases/XX-current/.continue-here*.md 2>/dev/null || true
```
If found, delete them — phase is complete, handoffs are stale.
@@ -429,7 +429,7 @@ Read ROADMAP.md to get the next phase's name and goal.
**Check if next phase has CONTEXT.md:**
```bash
ls .planning/phases/*[X+1]*/*-CONTEXT.md 2>/dev/null
ls .planning/phases/*[X+1]*/*-CONTEXT.md 2>/dev/null || true
```
**If next phase exists:**