For Claude: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
Goal: Replace the current goal + mustKeep planning contract with an LLM-ready chapter-brief contract, dissolve ComposerAgent into pure utilities over time, and preserve a rule-based fallback while the new planner stabilizes.
Architecture: Keep the current writing pipeline running by introducing the new structures in parallel first. The refactor proceeds in three layers: new chapter-brief models and planning-material retrieval, new LLM planner prompt/output path with fallback to the legacy planner, then composer de-agentization and writer/runtime consumption of the brief/context package.
Tech Stack: TypeScript, Vitest, Zod, existing InkOS BaseAgent/pipeline/state utilities.
Files:
packages/core/src/models/input-governance.tspackages/core/src/__tests__/models.test.tsStep 1: Write the failing tests
ChapterBriefSchema covering:
goalchapterTypeisGoldenOpeningbeatOutlinehookPlanpropsAndSettingdormantReasonmustKeepStep 2: Run test to verify it fails
Run:
pnpm --dir packages/core exec vitest run src/__tests__/models.test.ts -t "ChapterBriefSchema"
Expected: FAIL because ChapterBriefSchema does not exist yet.
Step 3: Write minimal implementation
ChapterIntentSchema yet.Step 4: Run test to verify it passes
Run the same command and expect PASS.
Files:
packages/core/src/utils/planning-materials.tspackages/core/src/__tests__/planning-materials.test.tspackages/core/src/agents/planner.tsStep 1: Write the failing tests
gatherPlanningMaterials(...) that verifies it returns:
Step 2: Run test to verify it fails
pnpm --dir packages/core exec vitest run src/__tests__/planning-materials.test.ts
Expected: FAIL because the utility does not exist.
Step 3: Write minimal implementation
gatherPlanningMaterials(...).Step 4: Run test to verify it passes
Run the same command and expect PASS.
Files:
packages/core/src/agents/planner-prompts.tspackages/core/src/agents/planner.tspackages/core/src/__tests__/planner-prompts.test.tspackages/core/src/__tests__/planner.test.tsStep 1: Write the failing tests
mustKeepStep 2: Run tests to verify they fail
pnpm --dir packages/core exec vitest run \
src/__tests__/planner-prompts.test.ts \
src/__tests__/planner.test.ts
Expected: FAIL because the prompt builder and parser do not exist.
Step 3: Write minimal implementation
ChapterBrief only.PlannerAgent, add:
planChapterLegacy(...)planChapterWithLLM(...)PlanChapterOutput shape for now, but attach the new brief in parallel.Step 4: Run tests to verify it passes
Run the same command and expect PASS.
Files:
packages/core/src/utils/context-assembly.tspackages/core/src/utils/runtime-writer.tspackages/core/src/agents/composer.tspackages/core/src/__tests__/composer.test.tsStep 1: Write the failing tests
ComposerAgent expectations.Step 2: Run tests to verify it fails
pnpm --dir packages/core exec vitest run src/__tests__/composer.test.ts
Expected: FAIL because the new utility boundaries do not exist.
Step 3: Write minimal implementation
ComposerAgent into utility functions.ComposerAgent as a thin shim initially so pipeline call sites remain stable.Step 4: Run test to verify it passes
Run the same command and expect PASS.
Files:
packages/core/src/agents/writer.tspackages/core/src/utils/governed-context.tspackages/core/src/pipeline/runner.tspackages/core/src/pipeline/persisted-governed-plan.tspackages/core/src/__tests__/writer.test.tspackages/core/src/__tests__/pipeline-runner.test.tspackages/core/src/__tests__/persisted-governed-plan.test.tsStep 1: Write the failing tests
Step 2: Run tests to verify they fail
pnpm --dir packages/core exec vitest run \
src/__tests__/writer.test.ts \
src/__tests__/pipeline-runner.test.ts \
src/__tests__/persisted-governed-plan.test.ts
Expected: FAIL because the writer/runtime still depend on mustKeep-heavy plan data.
Step 3: Write minimal implementation
Step 4: Run tests to verify it passes
Run the same command and expect PASS.
Files:
packages/core/src/index.tspackages/core/src/agents/composer.ts (thin wrapper or delete if safe)Step 1: Verify focused suite
pnpm --dir packages/core exec vitest run \
src/__tests__/models.test.ts \
src/__tests__/planning-materials.test.ts \
src/__tests__/planner-prompts.test.ts \
src/__tests__/planner.test.ts \
src/__tests__/composer.test.ts \
src/__tests__/writer.test.ts \
src/__tests__/pipeline-runner.test.ts \
src/__tests__/persisted-governed-plan.test.ts
pnpm --dir packages/core run build
Expected: PASS.
Step 2: Commit
git add packages/core/src docs/plans/2026-04-11-planner-llm-chapter-brief-refactor.md
git commit -m "refactor(planner): introduce chapter brief planning flow"