feat: add --include flag to init commands to eliminate redundant file reads

Workflows were calling init commands to get parsed JSON metadata, then
immediately reading the same files again with cat to pass raw content
to agents. This wastes context tokens.

Changes:
- Add --include flag to init execute-phase, plan-phase, and progress
- Support includes: state, config, roadmap, requirements, context,
  research, verification, uat, project
- Update plan-phase.md to use --include (removes 6 cat calls)
- Update execute-phase.md to use --include (removes 2 cat calls)
- Update execute-plan.md to use --include (removes 2 cat calls)
- Update progress.md to use --include (removes 4 cat calls)
- Add 7 tests for --include functionality

Token savings: ~5,000-10,000 tokens per plan-phase execution,
~1,500-3,000 per other workflow executions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Lex Christopherson
2026-02-08 01:43:22 -06:00
parent ecba990933
commit fa81821df4
6 changed files with 289 additions and 40 deletions

View File

@@ -12,14 +12,16 @@ Read all files referenced by the invoking prompt's execution_context before star
## 1. Initialize
Load all context in one call:
Load all context in one call (include file contents to avoid redundant reads):
```bash
INIT=$(node ~/.claude/get-shit-done/bin/gsd-tools.js init plan-phase "$PHASE")
INIT=$(node ~/.claude/get-shit-done/bin/gsd-tools.js init plan-phase "$PHASE" --include state,roadmap,requirements,context,research,verification,uat)
```
Parse JSON for: `researcher_model`, `planner_model`, `checker_model`, `research_enabled`, `plan_checker_enabled`, `commit_docs`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `padded_phase`, `has_research`, `has_context`, `has_plans`, `plan_count`, `planning_exists`, `roadmap_exists`.
**File contents (from --include):** `state_content`, `roadmap_content`, `requirements_content`, `context_content`, `research_content`, `verification_content`, `uat_content`. These are null if files don't exist.
**If `planning_exists` is false:** Error — run `/gsd:new-project` first.
## 2. Parse and Normalize Arguments
@@ -45,13 +47,11 @@ PHASE_INFO=$(node ~/.claude/get-shit-done/bin/gsd-tools.js roadmap get-phase "${
## 4. Load CONTEXT.md
```bash
CONTEXT_CONTENT=$(cat "${PHASE_DIR}"/*-CONTEXT.md 2>/dev/null)
```
Use `context_content` from init JSON (already loaded via `--include context`).
**CRITICAL:** Store `CONTEXT_CONTENT` now — pass to researcher, planner, checker, and revision agents.
**CRITICAL:** Use `context_content` from INIT — pass to researcher, planner, checker, and revision agents.
If CONTEXT.md exists, display: `Using phase context from: ${PHASE_DIR}/*-CONTEXT.md`
If `context_content` is not null, display: `Using phase context from: ${PHASE_DIR}/*-CONTEXT.md`
## 5. Handle Research
@@ -74,7 +74,8 @@ Display banner:
```bash
PHASE_DESC=$(node ~/.claude/get-shit-done/bin/gsd-tools.js roadmap get-phase "${PHASE}" | jq -r '.section')
REQUIREMENTS=$(cat .planning/REQUIREMENTS.md 2>/dev/null | grep -A100 "## Requirements" | head -50)
# Use requirements_content from INIT (already loaded via --include requirements)
REQUIREMENTS=$(echo "$INIT" | jq -r '.requirements_content // empty' | grep -A100 "## Requirements" | head -50)
STATE_SNAP=$(node ~/.claude/get-shit-done/bin/gsd-tools.js state-snapshot)
# Extract decisions from state-snapshot JSON: jq '.decisions[] | "\(.phase): \(.summary) - \(.rationale)"'
```
@@ -129,17 +130,19 @@ ls "${PHASE_DIR}"/*-PLAN.md 2>/dev/null
**If exists:** Offer: 1) Add more plans, 2) View existing, 3) Replan from scratch.
## 7. Read Context Files
## 7. Use Context Files from INIT
Read and store for planner agent (`@` syntax doesn't work across Task() boundaries):
All file contents are already loaded via `--include` in step 1 (`@` syntax doesn't work across Task() boundaries):
```bash
STATE_CONTENT=$(cat .planning/STATE.md)
ROADMAP_CONTENT=$(cat .planning/ROADMAP.md)
REQUIREMENTS_CONTENT=$(cat .planning/REQUIREMENTS.md 2>/dev/null)
RESEARCH_CONTENT=$(cat "${PHASE_DIR}"/*-RESEARCH.md 2>/dev/null)
VERIFICATION_CONTENT=$(cat "${PHASE_DIR}"/*-VERIFICATION.md 2>/dev/null)
UAT_CONTENT=$(cat "${PHASE_DIR}"/*-UAT.md 2>/dev/null)
# Extract from INIT JSON (no need to re-read files)
STATE_CONTENT=$(echo "$INIT" | jq -r '.state_content // empty')
ROADMAP_CONTENT=$(echo "$INIT" | jq -r '.roadmap_content // empty')
REQUIREMENTS_CONTENT=$(echo "$INIT" | jq -r '.requirements_content // empty')
RESEARCH_CONTENT=$(echo "$INIT" | jq -r '.research_content // empty')
VERIFICATION_CONTENT=$(echo "$INIT" | jq -r '.verification_content // empty')
UAT_CONTENT=$(echo "$INIT" | jq -r '.uat_content // empty')
CONTEXT_CONTENT=$(echo "$INIT" | jq -r '.context_content // empty')
```
## 8. Spawn gsd-planner Agent