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:
@@ -13,14 +13,16 @@ Read STATE.md before any operation to load project context.
|
||||
<process>
|
||||
|
||||
<step name="initialize" priority="first">
|
||||
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 execute-phase "${PHASE_ARG}")
|
||||
INIT=$(node ~/.claude/get-shit-done/bin/gsd-tools.js init execute-phase "${PHASE_ARG}" --include state,config)
|
||||
```
|
||||
|
||||
Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelization`, `branching_strategy`, `branch_name`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `state_exists`, `roadmap_exists`.
|
||||
|
||||
**File contents (from --include):** `state_content`, `config_content`. These are null if files don't exist.
|
||||
|
||||
**If `phase_found` is false:** Error — phase directory not found.
|
||||
**If `plan_count` is 0:** Error — no plans found in phase.
|
||||
**If `state_exists` is false but `.planning/` exists:** Offer reconstruct or continue.
|
||||
@@ -97,11 +99,13 @@ Execute each wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`
|
||||
2. **Read files and spawn agents:**
|
||||
|
||||
Content must be inlined — `@` syntax doesn't work across Task() boundaries.
|
||||
STATE and CONFIG are already loaded via `--include` in initialize step.
|
||||
|
||||
```bash
|
||||
PLAN_CONTENT=$(cat "{plan_path}")
|
||||
STATE_CONTENT=$(cat .planning/STATE.md)
|
||||
CONFIG_CONTENT=$(cat .planning/config.json 2>/dev/null)
|
||||
# Use state_content and config_content from INIT (no need to re-read)
|
||||
STATE_CONTENT=$(echo "$INIT" | jq -r '.state_content // empty')
|
||||
CONFIG_CONTENT=$(echo "$INIT" | jq -r '.config_content // empty')
|
||||
```
|
||||
|
||||
Each agent prompt:
|
||||
|
||||
Reference in New Issue
Block a user