claude-code-pilot 3.1.1 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +16 -11
  3. package/bin/install.js +127 -11
  4. package/manifest.json +20 -1
  5. package/package.json +4 -3
  6. package/src/agents/a11y-architect.md +141 -0
  7. package/src/agents/code-architect.md +71 -0
  8. package/src/agents/code-explorer.md +69 -0
  9. package/src/agents/code-simplifier.md +47 -0
  10. package/src/agents/comment-analyzer.md +45 -0
  11. package/src/agents/csharp-reviewer.md +101 -0
  12. package/src/agents/dart-build-resolver.md +201 -0
  13. package/src/agents/django-build-resolver.md +252 -0
  14. package/src/agents/django-reviewer.md +169 -0
  15. package/src/agents/fastapi-reviewer.md +79 -0
  16. package/src/agents/fsharp-reviewer.md +109 -0
  17. package/src/agents/pr-test-analyzer.md +45 -0
  18. package/src/agents/silent-failure-hunter.md +50 -0
  19. package/src/agents/swift-build-resolver.md +170 -0
  20. package/src/agents/swift-reviewer.md +116 -0
  21. package/src/agents/type-design-analyzer.md +41 -0
  22. package/src/available-rules/README.md +3 -1
  23. package/src/available-rules/dart/coding-style.md +159 -0
  24. package/src/available-rules/dart/hooks.md +66 -0
  25. package/src/available-rules/dart/patterns.md +261 -0
  26. package/src/available-rules/dart/security.md +135 -0
  27. package/src/available-rules/dart/testing.md +215 -0
  28. package/src/available-rules/web/coding-style.md +105 -0
  29. package/src/available-rules/web/design-quality.md +72 -0
  30. package/src/available-rules/web/hooks.md +129 -0
  31. package/src/available-rules/web/patterns.md +88 -0
  32. package/src/available-rules/web/performance.md +73 -0
  33. package/src/available-rules/web/security.md +66 -0
  34. package/src/available-rules/web/testing.md +64 -0
  35. package/src/commands/ccp/ai-integration-phase.md +36 -0
  36. package/src/commands/ccp/audit-fix.md +33 -0
  37. package/src/commands/ccp/code-review-fix.md +52 -0
  38. package/src/commands/ccp/cost-report.md +107 -0
  39. package/src/commands/ccp/eval-review.md +32 -0
  40. package/src/commands/ccp/extract_learnings.md +22 -0
  41. package/src/commands/ccp/import.md +37 -0
  42. package/src/commands/ccp/ingest-docs.md +42 -0
  43. package/src/commands/ccp/intel.md +179 -0
  44. package/src/commands/ccp/mvp-phase.md +45 -0
  45. package/src/commands/ccp/plan-prd.md +160 -0
  46. package/src/commands/ccp/plan-review-convergence.md +58 -0
  47. package/src/commands/ccp/pr-ecc.md +184 -0
  48. package/src/commands/ccp/scan.md +26 -0
  49. package/src/commands/ccp/security-scan.md +74 -0
  50. package/src/commands/ccp/sketch-wrap-up.md +31 -0
  51. package/src/commands/ccp/sketch.md +54 -0
  52. package/src/commands/ccp/spec-phase.md +62 -0
  53. package/src/commands/ccp/spike-wrap-up.md +31 -0
  54. package/src/commands/ccp/spike.md +51 -0
  55. package/src/commands/ccp/ultraplan-phase.md +33 -0
  56. package/src/hooks/ccp-bash-hook-dispatcher.js +96 -0
  57. package/src/hooks/ccp-context-monitor.js +23 -0
  58. package/src/hooks/ccp-doc-file-warning.js +93 -0
  59. package/src/hooks/ccp-pre-bash-dispatcher.js +24 -0
  60. package/src/hooks/ccp-read-injection-scanner.js +152 -0
  61. package/src/hooks/ccp-write-gateguard.js +868 -0
  62. package/src/hooks/kit-check-update.js +59 -7
  63. package/src/hooks/run-with-flags-shell.sh +1 -0
  64. package/src/hooks/run-with-flags.js +48 -1
  65. package/src/hooks/session-end.js +88 -1
  66. package/src/lib/hook-flags.js +14 -0
  67. package/src/lib/project-detect.js +0 -2
  68. package/src/lib/shell-substitution.js +499 -0
  69. package/src/pilot/references/agent-contracts.md +79 -0
  70. package/src/pilot/references/ai-evals.md +156 -0
  71. package/src/pilot/references/ai-frameworks.md +186 -0
  72. package/src/pilot/references/doc-conflict-engine.md +91 -0
  73. package/src/pilot/references/execute-mvp-tdd.md +81 -0
  74. package/src/pilot/references/gate-prompts.md +100 -0
  75. package/src/pilot/references/gates.md +70 -0
  76. package/src/pilot/references/mandatory-initial-read.md +2 -0
  77. package/src/pilot/references/mvp-concepts.md +49 -0
  78. package/src/pilot/references/planner-graphify-auto-update.md +67 -0
  79. package/src/pilot/references/planner-human-verify-mode.md +57 -0
  80. package/src/pilot/references/planner-mvp-mode.md +53 -0
  81. package/src/pilot/references/project-skills-discovery.md +19 -0
  82. package/src/pilot/references/revision-loop.md +97 -0
  83. package/src/pilot/references/skeleton-template.md +48 -0
  84. package/src/pilot/references/sketch-interactivity.md +41 -0
  85. package/src/pilot/references/sketch-theme-system.md +94 -0
  86. package/src/pilot/references/sketch-tooling.md +45 -0
  87. package/src/pilot/references/sketch-variant-patterns.md +81 -0
  88. package/src/pilot/references/spidr-splitting.md +69 -0
  89. package/src/pilot/references/thinking-models-debug.md +44 -0
  90. package/src/pilot/references/thinking-models-execution.md +50 -0
  91. package/src/pilot/references/thinking-models-planning.md +62 -0
  92. package/src/pilot/references/thinking-models-research.md +50 -0
  93. package/src/pilot/references/thinking-models-verification.md +55 -0
  94. package/src/pilot/references/user-story-template.md +58 -0
  95. package/src/pilot/references/verify-mvp-mode.md +85 -0
  96. package/src/pilot/references/worktree-path-safety.md +89 -0
  97. package/src/pilot/templates/AI-SPEC.md +246 -0
  98. package/src/pilot/templates/spec.md +307 -0
  99. package/src/pilot/workflows/ai-integration-phase.md +284 -0
  100. package/src/pilot/workflows/audit-fix.md +175 -0
  101. package/src/pilot/workflows/code-review-fix.md +497 -0
  102. package/src/pilot/workflows/eval-review.md +155 -0
  103. package/src/pilot/workflows/extract_learnings.md +242 -0
  104. package/src/pilot/workflows/help.md +5 -0
  105. package/src/pilot/workflows/import.md +246 -0
  106. package/src/pilot/workflows/ingest-docs.md +328 -0
  107. package/src/pilot/workflows/mvp-phase.md +199 -0
  108. package/src/pilot/workflows/plan-review-convergence.md +329 -0
  109. package/src/pilot/workflows/scan.md +102 -0
  110. package/src/pilot/workflows/sketch-wrap-up.md +285 -0
  111. package/src/pilot/workflows/sketch.md +360 -0
  112. package/src/pilot/workflows/spec-phase.md +262 -0
  113. package/src/pilot/workflows/spike-wrap-up.md +306 -0
  114. package/src/pilot/workflows/spike.md +452 -0
  115. package/src/pilot/workflows/ultraplan-phase.md +189 -0
  116. package/src/skills/accessibility/SKILL.md +146 -0
  117. package/src/skills/agent-architecture-audit/SKILL.md +256 -0
  118. package/src/skills/agent-eval/SKILL.md +145 -0
  119. package/src/skills/agent-harness-design/SKILL.md +73 -0
  120. package/src/skills/agent-introspection-debugging/SKILL.md +153 -0
  121. package/src/skills/android-clean-architecture/SKILL.md +339 -0
  122. package/src/skills/angular-developer/SKILL.md +154 -0
  123. package/src/skills/angular-developer/references/angular-animations.md +160 -0
  124. package/src/skills/angular-developer/references/angular-aria.md +410 -0
  125. package/src/skills/angular-developer/references/cli.md +86 -0
  126. package/src/skills/angular-developer/references/component-harnesses.md +59 -0
  127. package/src/skills/angular-developer/references/component-styling.md +91 -0
  128. package/src/skills/angular-developer/references/components.md +117 -0
  129. package/src/skills/angular-developer/references/creating-services.md +97 -0
  130. package/src/skills/angular-developer/references/data-resolvers.md +69 -0
  131. package/src/skills/angular-developer/references/define-routes.md +67 -0
  132. package/src/skills/angular-developer/references/defining-providers.md +72 -0
  133. package/src/skills/angular-developer/references/di-fundamentals.md +120 -0
  134. package/src/skills/angular-developer/references/e2e-testing.md +56 -0
  135. package/src/skills/angular-developer/references/effects.md +83 -0
  136. package/src/skills/angular-developer/references/hierarchical-injectors.md +43 -0
  137. package/src/skills/angular-developer/references/host-elements.md +80 -0
  138. package/src/skills/angular-developer/references/injection-context.md +63 -0
  139. package/src/skills/angular-developer/references/inputs.md +101 -0
  140. package/src/skills/angular-developer/references/linked-signal.md +59 -0
  141. package/src/skills/angular-developer/references/loading-strategies.md +61 -0
  142. package/src/skills/angular-developer/references/mcp.md +108 -0
  143. package/src/skills/angular-developer/references/navigate-to-routes.md +69 -0
  144. package/src/skills/angular-developer/references/outputs.md +86 -0
  145. package/src/skills/angular-developer/references/reactive-forms.md +122 -0
  146. package/src/skills/angular-developer/references/rendering-strategies.md +44 -0
  147. package/src/skills/angular-developer/references/resource.md +77 -0
  148. package/src/skills/angular-developer/references/route-animations.md +56 -0
  149. package/src/skills/angular-developer/references/route-guards.md +52 -0
  150. package/src/skills/angular-developer/references/router-lifecycle.md +45 -0
  151. package/src/skills/angular-developer/references/router-testing.md +87 -0
  152. package/src/skills/angular-developer/references/show-routes-with-outlets.md +68 -0
  153. package/src/skills/angular-developer/references/signal-forms.md +795 -0
  154. package/src/skills/angular-developer/references/signals-overview.md +94 -0
  155. package/src/skills/angular-developer/references/tailwind-css.md +69 -0
  156. package/src/skills/angular-developer/references/template-driven-forms.md +114 -0
  157. package/src/skills/angular-developer/references/testing-fundamentals.md +65 -0
  158. package/src/skills/api-connector-builder/SKILL.md +120 -0
  159. package/src/skills/code-tour/SKILL.md +236 -0
  160. package/src/skills/compose-multiplatform-patterns/SKILL.md +299 -0
  161. package/src/skills/csharp-testing/SKILL.md +321 -0
  162. package/src/skills/dart-flutter-patterns/SKILL.md +563 -0
  163. package/src/skills/dashboard-builder/SKILL.md +108 -0
  164. package/src/skills/dotnet-patterns/SKILL.md +321 -0
  165. package/src/skills/error-handling/SKILL.md +376 -0
  166. package/src/skills/fastapi-patterns/SKILL.md +327 -0
  167. package/src/skills/flox-environments/SKILL.md +496 -0
  168. package/src/skills/frontend-design/SKILL.md +145 -0
  169. package/src/skills/frontend-slides/SKILL.md +184 -0
  170. package/src/skills/frontend-slides/STYLE_PRESETS.md +330 -0
  171. package/src/skills/fsharp-testing/SKILL.md +280 -0
  172. package/src/skills/gateguard/SKILL.md +121 -0
  173. package/src/skills/github-ops/SKILL.md +144 -0
  174. package/src/skills/hookify-rules/SKILL.md +128 -0
  175. package/src/skills/ios-icon-gen/SKILL.md +157 -0
  176. package/src/skills/ios-icon-gen/scripts/generate_icons.swift +258 -0
  177. package/src/skills/ios-icon-gen/scripts/iconify_gen.sh +235 -0
  178. package/src/skills/knowledge-ops/SKILL.md +154 -0
  179. package/src/skills/liquid-glass-design/SKILL.md +279 -0
  180. package/src/skills/make-interfaces-feel-better/SKILL.md +151 -0
  181. package/src/skills/mysql-patterns/SKILL.md +412 -0
  182. package/src/skills/nestjs-patterns/SKILL.md +230 -0
  183. package/src/skills/plan-orchestrate/SKILL.md +220 -0
  184. package/src/skills/prisma-patterns/SKILL.md +371 -0
  185. package/src/skills/production-audit/SKILL.md +206 -0
  186. package/src/skills/security-bounty-hunter/SKILL.md +99 -0
  187. package/src/skills/security-scan/references/agentshield-policy-exception/candidate-playbook.md +49 -0
  188. package/src/skills/security-scan/references/agentshield-policy-exception/report.json +35 -0
  189. package/src/skills/security-scan/references/agentshield-policy-exception/scenario.json +62 -0
  190. package/src/skills/security-scan/references/agentshield-policy-exception/trace.json +45 -0
  191. package/src/skills/security-scan/references/agentshield-policy-exception/verifier-result.json +35 -0
  192. package/src/skills/swift-actor-persistence/SKILL.md +143 -0
  193. package/src/skills/swift-protocol-di-testing/SKILL.md +190 -0
  194. package/src/skills/swiftui-patterns/SKILL.md +259 -0
  195. package/src/skills/terminal-ops/SKILL.md +109 -0
  196. package/src/skills/ui-demo/SKILL.md +465 -0
  197. package/src/skills/vite-patterns/SKILL.md +449 -0
  198. package/src/skills/windows-desktop-e2e/SKILL.md +887 -0
@@ -0,0 +1,329 @@
1
+ <purpose>
2
+ Cross-AI plan convergence loop — automates the manual chain:
3
+ gsd-plan-phase N → gsd-review N --codex → gsd-plan-phase N --reviews → gsd-review N --codex → ...
4
+ Each step runs inside an isolated Agent that calls the corresponding Skill.
5
+ Orchestrator only does: init, loop control, parse CYCLE_SUMMARY for HIGH count, stall detection, escalation.
6
+ </purpose>
7
+
8
+ <required_reading>
9
+ Read all files referenced by the invoking prompt's execution_context before starting.
10
+
11
+ @$HOME/.claude/pilot/references/revision-loop.md
12
+ @$HOME/.claude/pilot/references/gates.md
13
+ @$HOME/.claude/pilot/references/agent-contracts.md
14
+ </required_reading>
15
+
16
+ <process>
17
+
18
+ ## 1. Parse and Normalize Arguments
19
+
20
+ Extract from $ARGUMENTS: phase number, reviewer flags (`--codex`, `--gemini`, `--claude`, `--opencode`, `--ollama`, `--lm-studio`, `--llama-cpp`, `--all`), `--max-cycles N`, `--text`, `--ws`.
21
+
22
+ ```bash
23
+ PHASE=$(echo "$ARGUMENTS" | grep -oE '[0-9]+\.?[0-9]*' | head -1)
24
+
25
+ REVIEWER_FLAGS=""
26
+ echo "$ARGUMENTS" | grep -q '\-\-codex' && REVIEWER_FLAGS="$REVIEWER_FLAGS --codex"
27
+ echo "$ARGUMENTS" | grep -q '\-\-gemini' && REVIEWER_FLAGS="$REVIEWER_FLAGS --gemini"
28
+ echo "$ARGUMENTS" | grep -q '\-\-claude' && REVIEWER_FLAGS="$REVIEWER_FLAGS --claude"
29
+ echo "$ARGUMENTS" | grep -q '\-\-opencode' && REVIEWER_FLAGS="$REVIEWER_FLAGS --opencode"
30
+ echo "$ARGUMENTS" | grep -q '\-\-ollama' && REVIEWER_FLAGS="$REVIEWER_FLAGS --ollama"
31
+ echo "$ARGUMENTS" | grep -q '\-\-lm-studio' && REVIEWER_FLAGS="$REVIEWER_FLAGS --lm-studio"
32
+ echo "$ARGUMENTS" | grep -q '\-\-llama-cpp' && REVIEWER_FLAGS="$REVIEWER_FLAGS --llama-cpp"
33
+ echo "$ARGUMENTS" | grep -q '\-\-all' && REVIEWER_FLAGS="$REVIEWER_FLAGS --all"
34
+ if [ -z "$REVIEWER_FLAGS" ]; then REVIEWER_FLAGS="--codex"; fi
35
+
36
+ MAX_CYCLES=$(echo "$ARGUMENTS" | grep -oE '\-\-max-cycles\s+[0-9]+' | awk '{print $2}')
37
+ if [ -z "$MAX_CYCLES" ]; then MAX_CYCLES=3; fi
38
+
39
+ GSD_WS=""
40
+ echo "$ARGUMENTS" | grep -qE '\-\-ws\s+\S+' && GSD_WS=$(echo "$ARGUMENTS" | grep -oE '\-\-ws\s+\S+')
41
+ ```
42
+
43
+ ## 1.5. Config Gate (feature disabled by default)
44
+
45
+ ```bash
46
+ CONVERGENCE_ENABLED=$(gsd-sdk query config-get workflow.plan_review_convergence 2>/dev/null || echo "false")
47
+ ```
48
+
49
+ **If `CONVERGENCE_ENABLED` is not `"true"`:** Display and exit:
50
+
51
+ ```text
52
+ gsd-plan-review-convergence is disabled (workflow.plan_review_convergence=false).
53
+
54
+ This feature automates the plan→review→replan loop using external AI reviewers.
55
+ Enable it with:
56
+
57
+ gsd config-set workflow.plan_review_convergence true
58
+
59
+ Then re-run: /ccp:plan-review-convergence {PHASE}
60
+ ```
61
+
62
+ ## 2. Initialize
63
+
64
+ ```bash
65
+ INIT=$(node "$HOME/.claude/pilot/bin/ccp:tools.cjs" init plan-phase "$PHASE")
66
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
67
+ ```
68
+
69
+ Parse JSON for: `phase_dir`, `phase_number`, `padded_phase`, `phase_name`, `has_plans`, `plan_count`, `commit_docs`, `text_mode`, `response_language`.
70
+
71
+ **If `response_language` is set:** All user-facing output should be in `{response_language}`.
72
+
73
+ Set `TEXT_MODE=true` if `--text` is present in $ARGUMENTS OR `text_mode` from init JSON is `true`. When `TEXT_MODE` is active, replace every `AskUserQuestion` call with a plain-text numbered list and ask the user to type their choice number.
74
+
75
+ ## 3. Validate Phase + Pre-flight Gate
76
+
77
+ ```bash
78
+ PHASE_INFO=$(node "$HOME/.claude/pilot/bin/ccp:tools.cjs" roadmap get-phase "${PHASE}")
79
+ ```
80
+
81
+ **If `found` is false:** Error with available phases. Exit.
82
+
83
+ Display startup banner:
84
+
85
+ ```text
86
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
87
+ GSD ► PLAN CONVERGENCE — Phase {phase_number}
88
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
89
+
90
+ Reviewers: {REVIEWER_FLAGS}
91
+ Max cycles: {MAX_CYCLES}
92
+ ```
93
+
94
+ ## 4. Initial Planning (if no plans exist)
95
+
96
+ **If `has_plans` is true:** Skip to step 5. Display: `Plans found: {plan_count} PLAN.md files — skipping initial planning.`
97
+
98
+ **If `has_plans` is false:**
99
+
100
+ Display: `◆ No plans found — spawning initial planning agent...`
101
+
102
+ ```text
103
+ Agent(
104
+ description="Initial planning Phase {PHASE}",
105
+ prompt="Run /ccp:plan-phase for Phase {PHASE}.
106
+
107
+ Execute: Skill(skill='gsd-plan-phase', args='{PHASE} {GSD_WS}')
108
+
109
+ Complete the full planning workflow. Do NOT return until planning is complete and PLAN.md files are committed.",
110
+ mode="auto"
111
+ )
112
+ ```
113
+
114
+ After agent returns, verify plans were created:
115
+ ```bash
116
+ PLAN_COUNT=$(ls ${phase_dir}/${padded_phase}-*-PLAN.md 2>/dev/null | wc -l)
117
+ ```
118
+
119
+ If PLAN_COUNT == 0: Error — initial planning failed. Exit.
120
+
121
+ Display: `Initial planning complete: ${PLAN_COUNT} PLAN.md files created.`
122
+
123
+ ## 5. Convergence Loop
124
+
125
+ Initialize loop variables:
126
+
127
+ ```text
128
+ cycle = 0
129
+ prev_high_count = Infinity
130
+ ```
131
+
132
+ ### 5a. Review (Spawn Agent)
133
+
134
+ Increment `cycle`.
135
+
136
+ Display: `◆ Cycle {cycle}/{MAX_CYCLES} — spawning review agent...`
137
+
138
+ ```text
139
+ Agent(
140
+ description="Cross-AI review Phase {PHASE} cycle {cycle}",
141
+ prompt="Run /ccp:review for Phase {PHASE}.
142
+
143
+ Execute: Skill(skill='gsd-review', args='--phase {PHASE} {REVIEWER_FLAGS} {GSD_WS}')
144
+
145
+ Complete the full review workflow. Do NOT return until REVIEWS.md is committed.
146
+
147
+ IMPORTANT — CYCLE_SUMMARY contract (required):
148
+ Your final response MUST include a machine-readable line of exactly this form:
149
+
150
+ CYCLE_SUMMARY: current_high=<N>
151
+
152
+ Where <N> is the integer count of HIGH-severity concerns that REMAIN UNRESOLVED in this cycle's findings.
153
+
154
+ Counting rules:
155
+ INCLUDE in the count:
156
+ - Newly raised HIGHs in this cycle
157
+ - PARTIALLY RESOLVED HIGHs: concern acknowledged and a mitigation is in progress, but not yet verified/completed
158
+ - Previously raised HIGHs that are still unresolved
159
+
160
+ EXCLUDE from the count:
161
+ - FULLY RESOLVED HIGHs: concern addressed with verification complete (closed ticket, verification log, or reviewer sign-off)
162
+ - HIGH mentions in retrospective/summary tables comparing cycles
163
+ - Quoted excerpts from prior reviews referencing past HIGH items
164
+
165
+ Definitions:
166
+ PARTIALLY RESOLVED — concern acknowledged and mitigation is in progress but not yet verified/completed (e.g., open ticket exists but fix not landed).
167
+ FULLY RESOLVED — concern addressed with verification complete (closed ticket, verification log, or explicit reviewer sign-off confirming closure).
168
+
169
+ Your final response MUST also include this section immediately after the CYCLE_SUMMARY line:
170
+
171
+ ## Current HIGH Concerns
172
+ [List each unresolved HIGH with a brief description, one per bullet]
173
+ [If none: write exactly 'None.']",
174
+ mode="auto"
175
+ )
176
+ ```
177
+
178
+ After agent returns, verify REVIEWS.md exists:
179
+ ```bash
180
+ REVIEWS_FILE=$(ls ${phase_dir}/${padded_phase}-REVIEWS.md 2>/dev/null)
181
+ ```
182
+
183
+ If REVIEWS_FILE is empty: Error — review agent did not produce REVIEWS.md. Exit.
184
+
185
+ ### 5b. Extract HIGH Count from CYCLE_SUMMARY Contract
186
+
187
+ **Do NOT grep REVIEWS.md for HIGH count.** REVIEWS.md accumulates history across cycles — resolved HIGHs from prior cycles remain in the file as audit trail, inflating a raw grep count and causing false stall detection.
188
+
189
+ Parse HIGH_COUNT from the review agent's return message via the CYCLE_SUMMARY contract:
190
+
191
+ ```bash
192
+ # Extract the integer from "CYCLE_SUMMARY: current_high=N" in the agent's return message
193
+ HIGH_COUNT=$(echo "$REVIEW_AGENT_RETURN" | grep -oE 'CYCLE_SUMMARY:\s*current_high=[0-9]+' | head -1 | grep -oE '[0-9]+$')
194
+
195
+ if [ -z "$HIGH_COUNT" ]; then
196
+ # Distinguish malformed contract from completely absent contract
197
+ if echo "$REVIEW_AGENT_RETURN" | grep -q 'CYCLE_SUMMARY:'; then
198
+ echo "CYCLE_SUMMARY present but current_high is malformed — expected integer, got non-numeric value. Retry or switch reviewer."
199
+ else
200
+ echo "Review agent did not honor the CYCLE_SUMMARY contract — cannot determine HIGH count. Retry or switch reviewer."
201
+ fi
202
+ exit 1
203
+ fi
204
+
205
+ # Extract the ## Current HIGH Concerns section from the agent's return message
206
+ HIGH_LINES=$(echo "$REVIEW_AGENT_RETURN" | awk '/^## Current HIGH Concerns/{found=1; next} found && /^##/{exit} found{print}')
207
+
208
+ if [ "${HIGH_COUNT}" -gt 0 ] && [ -z "${HIGH_LINES}" ]; then
209
+ echo "⚠ Review agent's CYCLE_SUMMARY reports ${HIGH_COUNT} HIGHs but did not provide ## Current HIGH Concerns section — continuing with incomplete escalation details."
210
+ fi
211
+ ```
212
+
213
+ **If HIGH_COUNT == 0 (converged):**
214
+
215
+ ```bash
216
+ node "$HOME/.claude/pilot/bin/ccp:tools.cjs" state planned-phase --phase "${PHASE}" --name "${phase_name}" --plans "${PLAN_COUNT}"
217
+ ```
218
+
219
+ Display:
220
+ ```text
221
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
222
+ GSD ► CONVERGENCE COMPLETE ✓
223
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
224
+
225
+ Phase {phase_number} converged in {cycle} cycle(s).
226
+ No HIGH concerns remaining.
227
+
228
+ REVIEWS.md: {REVIEWS_FILE}
229
+ Next: /ccp:execute-phase {PHASE}
230
+ ```
231
+
232
+ Exit — convergence achieved.
233
+
234
+ **If HIGH_COUNT > 0:** Continue to 5c.
235
+
236
+ ### 5c. Stall Detection + Escalation Check
237
+
238
+ Display: `◆ Cycle {cycle}/{MAX_CYCLES} — {HIGH_COUNT} HIGH concerns found`
239
+
240
+ **Stall detection:** If `HIGH_COUNT >= prev_high_count`:
241
+ ```text
242
+ ⚠ Convergence stalled — HIGH concern count not decreasing
243
+ ({HIGH_COUNT} HIGH concerns, previous cycle had {prev_high_count})
244
+ ```
245
+
246
+ **Max cycles check:** If `cycle >= MAX_CYCLES`:
247
+
248
+ If `TEXT_MODE` is true, present as plain-text numbered list:
249
+ ```text
250
+ Plan convergence did not complete after {MAX_CYCLES} cycles.
251
+ {HIGH_COUNT} HIGH concerns remain:
252
+
253
+ {HIGH_LINES}
254
+
255
+ How would you like to proceed?
256
+
257
+ 1. Proceed anyway — Accept plans with remaining HIGH concerns and move to execution
258
+ 2. Manual review — Stop here, review REVIEWS.md and address concerns manually
259
+
260
+ Enter number:
261
+ ```
262
+
263
+ Otherwise use AskUserQuestion:
264
+ ```js
265
+ AskUserQuestion([
266
+ {
267
+ question: "Plan convergence did not complete after {MAX_CYCLES} cycles. {HIGH_COUNT} HIGH concerns remain:\n\n{HIGH_LINES}\n\nHow would you like to proceed?",
268
+ header: "Convergence",
269
+ multiSelect: false,
270
+ options: [
271
+ { label: "Proceed anyway", description: "Accept plans with remaining HIGH concerns and move to execution" },
272
+ { label: "Manual review", description: "Stop here — review REVIEWS.md and address concerns manually" }
273
+ ]
274
+ }
275
+ ])
276
+ ```
277
+
278
+ If "Proceed anyway": Display final status and exit.
279
+ If "Manual review":
280
+ ```text
281
+ Review the concerns in: {REVIEWS_FILE}
282
+
283
+ To replan manually: /ccp:plan-phase {PHASE} --reviews
284
+ To restart loop: /ccp:plan-review-convergence {PHASE} {REVIEWER_FLAGS}
285
+ ```
286
+ Exit workflow.
287
+
288
+ ### 5d. Replan (Spawn Agent)
289
+
290
+ **If under max cycles:**
291
+
292
+ Update `prev_high_count = HIGH_COUNT`.
293
+
294
+ Display: `◆ Spawning replan agent with review feedback...`
295
+
296
+ ```text
297
+ Agent(
298
+ description="Replan Phase {PHASE} with review feedback cycle {cycle}",
299
+ prompt="Run /ccp:plan-phase with --reviews for Phase {PHASE}.
300
+
301
+ Execute: Skill(skill='gsd-plan-phase', args='{PHASE} --reviews --skip-research {GSD_WS}')
302
+
303
+ This will replan incorporating cross-AI review feedback from REVIEWS.md.
304
+ Do NOT return until replanning is complete and updated PLAN.md files are committed.
305
+
306
+ IMPORTANT: When gsd-plan-phase outputs '## PLANNING COMPLETE', that means replanning is done. Return at that point.",
307
+ mode="auto"
308
+ )
309
+ ```
310
+
311
+ After agent returns → go back to **step 5a** (review again).
312
+
313
+ </process>
314
+
315
+ <success_criteria>
316
+ - [ ] Config gate checked before running — exits with enable instructions if workflow.plan_review_convergence is false
317
+ - [ ] Initial planning via Agent → Skill("gsd-plan-phase") if no plans exist
318
+ - [ ] Review via Agent → Skill("gsd-review") — isolated, not inline; {GSD_WS} forwarded
319
+ - [ ] Replan via Agent → Skill("gsd-plan-phase --reviews") — isolated, not inline
320
+ - [ ] Orchestrator only does: init, config gate, loop control, parse CYCLE_SUMMARY for HIGH count, stall detection, escalation
321
+ - [ ] HIGH count extracted from review agent's CYCLE_SUMMARY return message (not by grepping REVIEWS.md)
322
+ - [ ] Review agent prompt defines CYCLE_SUMMARY: current_high=<N> contract with PARTIALLY/FULLY RESOLVED definitions
323
+ - [ ] Abort with clear error if CYCLE_SUMMARY is absent; distinguish malformed from absent
324
+ - [ ] Warn if HIGH_COUNT > 0 but ## Current HIGH Concerns section is absent from return message
325
+ - [ ] Each Agent fully completes its Skill before returning
326
+ - [ ] Loop exits on: no HIGH concerns (converged) OR max cycles (escalation)
327
+ - [ ] Stall detection reported when HIGH count not decreasing
328
+ - [ ] STATE.md updated on convergence completion
329
+ </success_criteria>
@@ -0,0 +1,102 @@
1
+ <purpose>
2
+ Lightweight codebase assessment. Spawns a single gsd-codebase-mapper agent for one focus area,
3
+ producing targeted documents in `.planning/codebase/`.
4
+ </purpose>
5
+
6
+ <required_reading>
7
+ Read all files referenced by the invoking prompt's execution_context before starting.
8
+ </required_reading>
9
+
10
+ <available_agent_types>
11
+ Valid GSD subagent types (use exact names — do not fall back to 'general-purpose'):
12
+ - gsd-codebase-mapper — Maps project structure and dependencies
13
+ </available_agent_types>
14
+
15
+ <process>
16
+
17
+ ## Focus-to-Document Mapping
18
+
19
+ | Focus | Documents Produced |
20
+ |-------|-------------------|
21
+ | `tech` | STACK.md, INTEGRATIONS.md |
22
+ | `arch` | ARCHITECTURE.md, STRUCTURE.md |
23
+ | `quality` | CONVENTIONS.md, TESTING.md |
24
+ | `concerns` | CONCERNS.md |
25
+ | `tech+arch` | STACK.md, INTEGRATIONS.md, ARCHITECTURE.md, STRUCTURE.md |
26
+
27
+ ## Step 1: Parse arguments and resolve focus
28
+
29
+ Parse the user's input for `--focus <area>`. Default to `tech+arch` if not specified.
30
+
31
+ Validate that the focus is one of: `tech`, `arch`, `quality`, `concerns`, `tech+arch`.
32
+
33
+ If invalid:
34
+ ```
35
+ Unknown focus area: "{input}". Valid options: tech, arch, quality, concerns, tech+arch
36
+ ```
37
+ Exit.
38
+
39
+ ## Step 2: Check for existing documents
40
+
41
+ ```bash
42
+ INIT=$(gsd-sdk query init.map-codebase 2>/dev/null || echo "{}")
43
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
44
+ ```
45
+
46
+ Look up which documents would be produced for the selected focus (from the mapping table above).
47
+
48
+ For each target document, check if it already exists in `.planning/codebase/`:
49
+ ```bash
50
+ ls -la .planning/codebase/{DOCUMENT}.md 2>/dev/null
51
+ ```
52
+
53
+ If any exist, show their modification dates and ask:
54
+ ```
55
+ Existing documents found:
56
+ - STACK.md (modified 2026-04-03)
57
+ - INTEGRATIONS.md (modified 2026-04-01)
58
+
59
+ Overwrite with fresh scan? [y/N]
60
+ ```
61
+
62
+ If user says no, exit.
63
+
64
+ ## Step 3: Create output directory
65
+
66
+ ```bash
67
+ mkdir -p .planning/codebase
68
+ ```
69
+
70
+ ## Step 4: Spawn mapper agent
71
+
72
+ Spawn a single `gsd-codebase-mapper` agent with the selected focus area:
73
+
74
+ ```
75
+ Task(
76
+ prompt="Scan this codebase with focus: {focus}. Write results to .planning/codebase/. Produce only: {document_list}",
77
+ subagent_type="gsd-codebase-mapper",
78
+ model="{resolved_model}"
79
+ )
80
+ ```
81
+
82
+ ## Step 5: Report
83
+
84
+ ```
85
+ ## Scan Complete
86
+
87
+ **Focus:** {focus}
88
+ **Documents produced:**
89
+ {list of documents written with line counts}
90
+
91
+ Use `/ccp:map-codebase` for a comprehensive 4-area parallel scan.
92
+ ```
93
+
94
+ </process>
95
+
96
+ <success_criteria>
97
+ - [ ] Focus area correctly parsed (default: tech+arch)
98
+ - [ ] Existing documents detected with modification dates shown
99
+ - [ ] User prompted before overwriting
100
+ - [ ] Single mapper agent spawned with correct focus
101
+ - [ ] Output documents written to .planning/codebase/
102
+ </success_criteria>