claude-code-pilot 2.0.0 → 3.1.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 (514) hide show
  1. package/README.md +76 -97
  2. package/bin/install.js +267 -250
  3. package/manifest.json +5 -18
  4. package/package.json +5 -7
  5. package/src/agents/build-error-resolver.md +114 -0
  6. package/src/agents/ccp-advisor-researcher.md +104 -0
  7. package/src/agents/ccp-assumptions-analyzer.md +105 -0
  8. package/{gsd/agents/gsd-codebase-mapper.md → src/agents/ccp-codebase-mapper.md} +7 -7
  9. package/{gsd/agents/gsd-debugger.md → src/agents/ccp-debugger.md} +125 -8
  10. package/{gsd/agents/gsd-executor.md → src/agents/ccp-executor.md} +31 -20
  11. package/{gsd/agents/gsd-integration-checker.md → src/agents/ccp-integration-checker.md} +2 -2
  12. package/{gsd/agents/gsd-nyquist-auditor.md → src/agents/ccp-nyquist-auditor.md} +3 -3
  13. package/{gsd/agents/gsd-phase-researcher.md → src/agents/ccp-phase-researcher.md} +127 -13
  14. package/{gsd/agents/gsd-plan-checker.md → src/agents/ccp-plan-checker.md} +57 -21
  15. package/{gsd/agents/gsd-planner.md → src/agents/ccp-planner.md} +61 -23
  16. package/{gsd/agents/gsd-project-researcher.md → src/agents/ccp-project-researcher.md} +33 -6
  17. package/{gsd/agents/gsd-research-synthesizer.md → src/agents/ccp-research-synthesizer.md} +11 -11
  18. package/{gsd/agents/gsd-roadmapper.md → src/agents/ccp-roadmapper.md} +39 -10
  19. package/src/agents/ccp-ui-auditor.md +439 -0
  20. package/src/agents/ccp-ui-checker.md +300 -0
  21. package/src/agents/ccp-ui-researcher.md +357 -0
  22. package/{gsd/agents/gsd-verifier.md → src/agents/ccp-verifier.md} +81 -15
  23. package/src/agents/cpp-build-resolver.md +90 -0
  24. package/src/agents/cpp-reviewer.md +72 -0
  25. package/src/agents/database-reviewer.md +91 -0
  26. package/{ecc → src}/agents/doc-updater.md +1 -1
  27. package/src/agents/docs-lookup.md +68 -0
  28. package/src/agents/flutter-reviewer.md +243 -0
  29. package/src/agents/gan-evaluator.md +209 -0
  30. package/src/agents/gan-generator.md +131 -0
  31. package/src/agents/gan-planner.md +99 -0
  32. package/src/agents/go-build-resolver.md +94 -0
  33. package/src/agents/go-reviewer.md +76 -0
  34. package/src/agents/harness-optimizer.md +35 -0
  35. package/src/agents/java-build-resolver.md +153 -0
  36. package/src/agents/java-reviewer.md +92 -0
  37. package/src/agents/kotlin-build-resolver.md +118 -0
  38. package/src/agents/kotlin-reviewer.md +159 -0
  39. package/src/agents/loop-operator.md +36 -0
  40. package/src/agents/opensource-forker.md +198 -0
  41. package/src/agents/opensource-packager.md +249 -0
  42. package/src/agents/opensource-sanitizer.md +188 -0
  43. package/src/agents/performance-optimizer.md +446 -0
  44. package/src/agents/planner.md +212 -0
  45. package/src/agents/python-reviewer.md +98 -0
  46. package/src/agents/pytorch-build-resolver.md +120 -0
  47. package/src/agents/refactor-cleaner.md +85 -0
  48. package/src/agents/rust-build-resolver.md +148 -0
  49. package/src/agents/rust-reviewer.md +94 -0
  50. package/src/agents/typescript-reviewer.md +112 -0
  51. package/src/available-rules/README.md +80 -0
  52. package/src/available-rules/cpp/coding-style.md +44 -0
  53. package/src/available-rules/cpp/hooks.md +39 -0
  54. package/src/available-rules/cpp/patterns.md +51 -0
  55. package/src/available-rules/cpp/security.md +51 -0
  56. package/src/available-rules/cpp/testing.md +44 -0
  57. package/src/available-rules/csharp/coding-style.md +72 -0
  58. package/src/available-rules/csharp/hooks.md +25 -0
  59. package/src/available-rules/csharp/patterns.md +50 -0
  60. package/src/available-rules/csharp/security.md +58 -0
  61. package/src/available-rules/csharp/testing.md +46 -0
  62. package/src/available-rules/java/coding-style.md +114 -0
  63. package/src/available-rules/java/hooks.md +18 -0
  64. package/src/available-rules/java/patterns.md +146 -0
  65. package/src/available-rules/java/security.md +100 -0
  66. package/src/available-rules/java/testing.md +131 -0
  67. package/src/available-rules/kotlin/hooks.md +17 -0
  68. package/src/available-rules/rust/coding-style.md +151 -0
  69. package/src/available-rules/rust/hooks.md +16 -0
  70. package/src/available-rules/rust/patterns.md +168 -0
  71. package/src/available-rules/rust/security.md +141 -0
  72. package/src/available-rules/rust/testing.md +154 -0
  73. package/src/commands/ccp/add-backlog.md +76 -0
  74. package/{gsd/commands-gsd → src/commands/ccp}/add-phase.md +3 -3
  75. package/{gsd/commands-gsd → src/commands/ccp}/add-tests.md +5 -5
  76. package/{gsd/commands-gsd → src/commands/ccp}/add-todo.md +4 -4
  77. package/src/commands/ccp/aside.md +165 -0
  78. package/{gsd/commands-gsd → src/commands/ccp}/audit-milestone.md +3 -3
  79. package/src/commands/ccp/audit-uat.md +24 -0
  80. package/src/commands/ccp/autonomous.md +41 -0
  81. package/src/commands/ccp/build-fix.md +67 -0
  82. package/{gsd/commands-gsd → src/commands/ccp}/check-todos.md +3 -3
  83. package/{ecc/commands → src/commands/ccp}/checkpoint.md +12 -7
  84. package/{gsd/commands-gsd → src/commands/ccp}/cleanup.md +3 -3
  85. package/src/commands/ccp/code-review.md +45 -0
  86. package/{gsd/commands-gsd → src/commands/ccp}/complete-milestone.md +9 -9
  87. package/src/commands/ccp/context-budget.md +30 -0
  88. package/src/commands/ccp/cpp-build.md +174 -0
  89. package/src/commands/ccp/cpp-review.md +133 -0
  90. package/src/commands/ccp/cpp-test.md +252 -0
  91. package/{gsd/commands-gsd → src/commands/ccp}/debug.md +14 -9
  92. package/src/commands/ccp/discuss-phase.md +64 -0
  93. package/src/commands/ccp/do.md +30 -0
  94. package/src/commands/ccp/docs-update.md +48 -0
  95. package/src/commands/ccp/docs.md +32 -0
  96. package/src/commands/ccp/e2e.md +365 -0
  97. package/src/commands/ccp/eval.md +125 -0
  98. package/{ecc/commands → src/commands/ccp}/evolve.md +5 -5
  99. package/src/commands/ccp/execute-phase.md +59 -0
  100. package/src/commands/ccp/fast.md +30 -0
  101. package/src/commands/ccp/forensics.md +56 -0
  102. package/src/commands/ccp/go-build.md +184 -0
  103. package/src/commands/ccp/go-review.md +149 -0
  104. package/src/commands/ccp/go-test.md +269 -0
  105. package/src/commands/ccp/gradle-build.md +71 -0
  106. package/src/commands/ccp/harness-audit.md +76 -0
  107. package/{gsd/commands-gsd → src/commands/ccp}/health.md +3 -3
  108. package/{gsd/commands-gsd → src/commands/ccp}/help.md +5 -5
  109. package/{gsd/commands-gsd → src/commands/ccp}/insert-phase.md +3 -3
  110. package/src/commands/ccp/kotlin-build.md +175 -0
  111. package/src/commands/ccp/kotlin-review.md +141 -0
  112. package/src/commands/ccp/kotlin-test.md +313 -0
  113. package/{ecc/commands → src/commands/ccp}/learn.md +7 -2
  114. package/{gsd/commands-gsd → src/commands/ccp}/list-phase-assumptions.md +2 -2
  115. package/src/commands/ccp/manager.md +39 -0
  116. package/{gsd/commands-gsd → src/commands/ccp}/map-codebase.md +7 -7
  117. package/src/commands/ccp/milestone-summary.md +51 -0
  118. package/{ecc/commands → src/commands/ccp}/model-route.md +6 -1
  119. package/{gsd/commands-gsd → src/commands/ccp}/new-milestone.md +8 -8
  120. package/{gsd/commands-gsd → src/commands/ccp}/new-project.md +8 -8
  121. package/src/commands/ccp/next.md +24 -0
  122. package/src/commands/ccp/note.md +34 -0
  123. package/src/commands/ccp/orchestrate.md +232 -0
  124. package/{gsd/commands-gsd → src/commands/ccp}/pause-work.md +3 -3
  125. package/{gsd/commands-gsd → src/commands/ccp}/plan-milestone-gaps.md +5 -5
  126. package/{gsd/commands-gsd → src/commands/ccp}/plan-phase.md +9 -7
  127. package/src/commands/ccp/plan.md +115 -0
  128. package/src/commands/ccp/plant-seed.md +28 -0
  129. package/src/commands/ccp/pr-branch.md +25 -0
  130. package/src/commands/ccp/profile-user.md +46 -0
  131. package/{gsd/commands-gsd → src/commands/ccp}/progress.md +3 -3
  132. package/src/commands/ccp/prompt-optimize.md +39 -0
  133. package/src/commands/ccp/prune.md +25 -0
  134. package/src/commands/ccp/python-review.md +298 -0
  135. package/{ecc/commands → src/commands/ccp}/quality-gate.md +7 -2
  136. package/{gsd/commands-gsd → src/commands/ccp}/quick.md +10 -8
  137. package/src/commands/ccp/refactor-clean.md +85 -0
  138. package/{gsd/commands-gsd → src/commands/ccp}/remove-phase.md +3 -3
  139. package/{gsd/commands-gsd → src/commands/ccp}/research-phase.md +17 -12
  140. package/{ecc/commands → src/commands/ccp}/resume-session.md +9 -8
  141. package/{gsd/commands-gsd → src/commands/ccp}/resume-work.md +3 -3
  142. package/src/commands/ccp/review-backlog.md +61 -0
  143. package/src/commands/ccp/review.md +37 -0
  144. package/src/commands/ccp/rules-distill.md +12 -0
  145. package/src/commands/ccp/rust-build.md +188 -0
  146. package/src/commands/ccp/rust-review.md +143 -0
  147. package/src/commands/ccp/rust-test.md +309 -0
  148. package/{ecc/commands → src/commands/ccp}/save-session.md +2 -1
  149. package/src/commands/ccp/secure-phase.md +35 -0
  150. package/src/commands/ccp/session-report.md +19 -0
  151. package/{ecc/commands → src/commands/ccp}/sessions.md +39 -34
  152. package/src/commands/ccp/set-profile.md +12 -0
  153. package/{gsd/commands-gsd → src/commands/ccp}/settings.md +5 -5
  154. package/src/commands/ccp/setup-pm.md +81 -0
  155. package/{kit/commands → src/commands/ccp}/setup-refresh.md +4 -3
  156. package/{kit/commands → src/commands/ccp}/setup.md +67 -40
  157. package/src/commands/ccp/ship.md +23 -0
  158. package/src/commands/ccp/skill-create.md +172 -0
  159. package/src/commands/ccp/skill-health.md +51 -0
  160. package/src/commands/ccp/stats.md +18 -0
  161. package/src/commands/ccp/tdd.md +329 -0
  162. package/src/commands/ccp/test-coverage.md +74 -0
  163. package/src/commands/ccp/thread.md +127 -0
  164. package/{kit/commands → src/commands/ccp}/tool-guide.md +2 -1
  165. package/src/commands/ccp/ui-phase.md +34 -0
  166. package/src/commands/ccp/ui-review.md +32 -0
  167. package/src/commands/ccp/update-codemaps.md +77 -0
  168. package/src/commands/ccp/update-docs.md +89 -0
  169. package/{gsd/commands-gsd → src/commands/ccp}/update.md +5 -5
  170. package/{gsd/commands-gsd → src/commands/ccp}/validate-phase.md +3 -3
  171. package/{gsd/commands-gsd → src/commands/ccp}/verify-work.md +5 -5
  172. package/{ecc/commands → src/commands/ccp}/verify.md +5 -0
  173. package/src/commands/ccp/workstreams.md +68 -0
  174. package/{ecc → src}/examples/CLAUDE.md +4 -4
  175. package/{ecc → src}/examples/django-api-CLAUDE.md +5 -5
  176. package/{ecc → src}/examples/go-microservice-CLAUDE.md +6 -6
  177. package/{ecc → src}/examples/rust-api-CLAUDE.md +4 -4
  178. package/{ecc → src}/examples/saas-nextjs-CLAUDE.md +8 -8
  179. package/{gsd/hooks/gsd-context-monitor.js → src/hooks/ccp-context-monitor.js} +3 -3
  180. package/src/hooks/ccp-prompt-guard.js +96 -0
  181. package/{gsd/hooks/gsd-statusline.js → src/hooks/ccp-statusline.js} +7 -7
  182. package/src/hooks/ccp-workflow-guard.js +94 -0
  183. package/src/hooks/config-protection.js +141 -0
  184. package/{kit → src}/hooks/kit-check-update.js +7 -4
  185. package/src/hooks/mcp-health-check.js +620 -0
  186. package/{ecc/scripts → src}/hooks/run-with-flags-shell.sh +1 -1
  187. package/{ecc/scripts → src}/hooks/run-with-flags.js +74 -13
  188. package/src/hooks/session-end-marker.js +29 -0
  189. package/{ecc/scripts → src}/hooks/session-end.js +83 -40
  190. package/{ecc/scripts → src}/hooks/session-start.js +76 -10
  191. package/{ecc/scripts → src}/lib/hook-flags.js +8 -4
  192. package/{ecc/scripts → src}/lib/project-detect.js +2 -1
  193. package/{ecc/scripts → src}/lib/session-manager.d.ts +5 -1
  194. package/{ecc/scripts → src}/lib/session-manager.js +202 -92
  195. package/{ecc/scripts → src}/lib/utils.d.ts +23 -1
  196. package/{ecc/scripts → src}/lib/utils.js +91 -3
  197. package/{gsd/get-shit-done/bin/gsd-tools.cjs → src/pilot/bin/ccp-tools.cjs} +257 -86
  198. package/{gsd/get-shit-done → src/pilot}/bin/lib/commands.cjs +1 -1
  199. package/src/pilot/bin/lib/config.cjs +444 -0
  200. package/src/pilot/bin/lib/core.cjs +1190 -0
  201. package/src/pilot/bin/lib/init.cjs +1281 -0
  202. package/src/pilot/bin/lib/model-profiles.cjs +67 -0
  203. package/{gsd/get-shit-done → src/pilot}/bin/lib/phase.cjs +2 -2
  204. package/src/pilot/bin/lib/security.cjs +382 -0
  205. package/{gsd/get-shit-done → src/pilot}/bin/lib/state.cjs +1 -1
  206. package/src/pilot/bin/lib/uat.cjs +282 -0
  207. package/{gsd/get-shit-done → src/pilot}/bin/lib/verify.cjs +10 -10
  208. package/{gsd/get-shit-done → src/pilot}/references/continuation-format.md +16 -16
  209. package/{gsd/get-shit-done → src/pilot}/references/decimal-phase-calculation.md +5 -5
  210. package/{gsd/get-shit-done → src/pilot}/references/git-integration.md +5 -5
  211. package/{gsd/get-shit-done → src/pilot}/references/git-planning-commit.md +4 -4
  212. package/src/pilot/references/mcp-servers.json +153 -0
  213. package/{gsd/get-shit-done → src/pilot}/references/model-profile-resolution.md +2 -2
  214. package/{gsd/get-shit-done → src/pilot}/references/model-profiles.md +20 -20
  215. package/{gsd/get-shit-done → src/pilot}/references/phase-argument-parsing.md +4 -4
  216. package/{gsd/get-shit-done → src/pilot}/references/planning-config.md +15 -15
  217. package/{gsd/get-shit-done → src/pilot}/references/ui-brand.md +5 -5
  218. package/{gsd/get-shit-done → src/pilot}/references/verification-patterns.md +1 -1
  219. package/{gsd/get-shit-done → src/pilot}/templates/DEBUG.md +1 -1
  220. package/{gsd/get-shit-done → src/pilot}/templates/UAT.md +3 -3
  221. package/src/pilot/templates/UI-SPEC.md +100 -0
  222. package/{gsd/get-shit-done → src/pilot}/templates/VALIDATION.md +1 -1
  223. package/src/pilot/templates/claude-md.md +122 -0
  224. package/{gsd/get-shit-done → src/pilot}/templates/codebase/architecture.md +2 -2
  225. package/{gsd/get-shit-done → src/pilot}/templates/codebase/structure.md +13 -13
  226. package/{gsd/get-shit-done → src/pilot}/templates/context.md +4 -4
  227. package/src/pilot/templates/copilot-instructions.md +7 -0
  228. package/{gsd/get-shit-done → src/pilot}/templates/debug-subagent-prompt.md +4 -4
  229. package/src/pilot/templates/dev-preferences.md +21 -0
  230. package/{gsd/get-shit-done → src/pilot}/templates/discovery.md +2 -2
  231. package/src/pilot/templates/discussion-log.md +63 -0
  232. package/{gsd/get-shit-done → src/pilot}/templates/phase-prompt.md +12 -12
  233. package/{gsd/get-shit-done → src/pilot}/templates/planner-subagent-prompt.md +7 -7
  234. package/{gsd/get-shit-done → src/pilot}/templates/project.md +1 -1
  235. package/{gsd/get-shit-done → src/pilot}/templates/research.md +2 -2
  236. package/{gsd/get-shit-done → src/pilot}/templates/state.md +2 -2
  237. package/{gsd/get-shit-done → src/pilot}/templates/summary-complex.md +1 -1
  238. package/{gsd/get-shit-done → src/pilot}/workflows/add-phase.md +11 -11
  239. package/{gsd/get-shit-done → src/pilot}/workflows/add-tests.md +15 -15
  240. package/{gsd/get-shit-done → src/pilot}/workflows/add-todo.md +7 -7
  241. package/{gsd/get-shit-done → src/pilot}/workflows/audit-milestone.md +24 -16
  242. package/src/pilot/workflows/audit-uat.md +109 -0
  243. package/src/pilot/workflows/autonomous.md +891 -0
  244. package/{gsd/get-shit-done → src/pilot}/workflows/check-todos.md +10 -10
  245. package/{gsd/get-shit-done → src/pilot}/workflows/cleanup.md +3 -3
  246. package/{gsd/get-shit-done → src/pilot}/workflows/complete-milestone.md +19 -16
  247. package/{gsd/get-shit-done → src/pilot}/workflows/diagnose-issues.md +9 -4
  248. package/{gsd/get-shit-done → src/pilot}/workflows/discovery-phase.md +8 -8
  249. package/src/pilot/workflows/discuss-phase-assumptions.md +653 -0
  250. package/{gsd/get-shit-done → src/pilot}/workflows/discuss-phase.md +407 -49
  251. package/src/pilot/workflows/do.md +104 -0
  252. package/src/pilot/workflows/docs-update.md +1165 -0
  253. package/src/pilot/workflows/execute-phase.md +821 -0
  254. package/{gsd/get-shit-done → src/pilot}/workflows/execute-plan.md +79 -28
  255. package/src/pilot/workflows/fast.md +105 -0
  256. package/src/pilot/workflows/forensics.md +265 -0
  257. package/{gsd/get-shit-done → src/pilot}/workflows/health.md +34 -11
  258. package/src/pilot/workflows/help.md +767 -0
  259. package/{gsd/get-shit-done → src/pilot}/workflows/insert-phase.md +10 -10
  260. package/{gsd/get-shit-done → src/pilot}/workflows/list-phase-assumptions.md +4 -4
  261. package/src/pilot/workflows/manager.md +362 -0
  262. package/{gsd/get-shit-done → src/pilot}/workflows/map-codebase.md +27 -17
  263. package/src/pilot/workflows/milestone-summary.md +223 -0
  264. package/{gsd/get-shit-done → src/pilot}/workflows/new-milestone.md +135 -33
  265. package/{gsd/get-shit-done → src/pilot}/workflows/new-project.md +152 -79
  266. package/src/pilot/workflows/next.md +97 -0
  267. package/src/pilot/workflows/node-repair.md +92 -0
  268. package/src/pilot/workflows/note.md +156 -0
  269. package/src/pilot/workflows/pause-work.md +177 -0
  270. package/{gsd/get-shit-done → src/pilot}/workflows/plan-milestone-gaps.md +10 -11
  271. package/src/pilot/workflows/plan-phase.md +859 -0
  272. package/src/pilot/workflows/plant-seed.md +169 -0
  273. package/src/pilot/workflows/pr-branch.md +129 -0
  274. package/src/pilot/workflows/profile-user.md +452 -0
  275. package/{gsd/get-shit-done → src/pilot}/workflows/progress.md +95 -34
  276. package/{gsd/get-shit-done → src/pilot}/workflows/quick.md +33 -21
  277. package/{gsd/get-shit-done → src/pilot}/workflows/remove-phase.md +14 -14
  278. package/{gsd/get-shit-done → src/pilot}/workflows/research-phase.md +18 -10
  279. package/{gsd/get-shit-done → src/pilot}/workflows/resume-project.md +37 -18
  280. package/src/pilot/workflows/review.md +244 -0
  281. package/src/pilot/workflows/secure-phase.md +164 -0
  282. package/src/pilot/workflows/session-report.md +146 -0
  283. package/{gsd/get-shit-done → src/pilot}/workflows/set-profile.md +7 -7
  284. package/{gsd/get-shit-done → src/pilot}/workflows/settings.md +75 -22
  285. package/src/pilot/workflows/ship.md +228 -0
  286. package/src/pilot/workflows/stats.md +60 -0
  287. package/{gsd/get-shit-done → src/pilot}/workflows/transition.md +57 -17
  288. package/src/pilot/workflows/ui-phase.md +302 -0
  289. package/src/pilot/workflows/ui-review.md +165 -0
  290. package/{gsd/get-shit-done → src/pilot}/workflows/update.md +88 -58
  291. package/{gsd/get-shit-done → src/pilot}/workflows/validate-phase.md +24 -17
  292. package/{gsd/get-shit-done → src/pilot}/workflows/verify-phase.md +26 -15
  293. package/{gsd/get-shit-done → src/pilot}/workflows/verify-work.md +89 -37
  294. package/{ecc → src}/rules/common/agents.md +1 -0
  295. package/src/rules/common/code-review.md +124 -0
  296. package/{ecc → src}/rules/common/coding-style.md +21 -0
  297. package/src/rules/zh/README.md +108 -0
  298. package/src/rules/zh/agents.md +50 -0
  299. package/src/rules/zh/code-review.md +124 -0
  300. package/src/rules/zh/coding-style.md +48 -0
  301. package/src/rules/zh/development-workflow.md +44 -0
  302. package/src/rules/zh/git-workflow.md +24 -0
  303. package/src/rules/zh/hooks.md +30 -0
  304. package/src/rules/zh/patterns.md +31 -0
  305. package/src/rules/zh/performance.md +55 -0
  306. package/src/rules/zh/security.md +29 -0
  307. package/src/rules/zh/testing.md +29 -0
  308. package/src/skills/agentic-engineering/SKILL.md +63 -0
  309. package/src/skills/ai-first-engineering/SKILL.md +51 -0
  310. package/src/skills/ai-regression-testing/SKILL.md +385 -0
  311. package/src/skills/api-design/SKILL.md +523 -0
  312. package/src/skills/architecture-decision-records/SKILL.md +179 -0
  313. package/src/skills/autonomous-agent-harness/SKILL.md +267 -0
  314. package/src/skills/autonomous-loops/SKILL.md +610 -0
  315. package/src/skills/backend-patterns/SKILL.md +598 -0
  316. package/src/skills/benchmark/SKILL.md +87 -0
  317. package/src/skills/blueprint/SKILL.md +90 -0
  318. package/src/skills/browser-qa/SKILL.md +81 -0
  319. package/src/skills/bun-runtime/SKILL.md +84 -0
  320. package/src/skills/claude-api/SKILL.md +337 -0
  321. package/src/skills/codebase-onboarding/SKILL.md +233 -0
  322. package/src/skills/coding-standards/SKILL.md +530 -0
  323. package/src/skills/content-hash-cache-pattern/SKILL.md +161 -0
  324. package/src/skills/context-budget/SKILL.md +135 -0
  325. package/{ecc → src}/skills/continuous-learning-v2/SKILL.md +6 -6
  326. package/{ecc → src}/skills/continuous-learning-v2/agents/observer-loop.sh +1 -1
  327. package/{ecc → src}/skills/continuous-learning-v2/agents/observer.md +1 -1
  328. package/src/skills/cost-aware-llm-pipeline/SKILL.md +183 -0
  329. package/src/skills/cpp-coding-standards/SKILL.md +723 -0
  330. package/src/skills/cpp-testing/SKILL.md +324 -0
  331. package/src/skills/database-migrations/SKILL.md +429 -0
  332. package/src/skills/deep-research/SKILL.md +155 -0
  333. package/src/skills/deployment-patterns/SKILL.md +427 -0
  334. package/src/skills/design-system/SKILL.md +82 -0
  335. package/src/skills/django-patterns/SKILL.md +734 -0
  336. package/src/skills/django-security/SKILL.md +593 -0
  337. package/src/skills/django-tdd/SKILL.md +729 -0
  338. package/src/skills/django-verification/SKILL.md +469 -0
  339. package/src/skills/docker-patterns/SKILL.md +364 -0
  340. package/src/skills/documentation-lookup/SKILL.md +90 -0
  341. package/src/skills/e2e-testing/SKILL.md +326 -0
  342. package/src/skills/eval-harness/SKILL.md +270 -0
  343. package/src/skills/exa-search/SKILL.md +103 -0
  344. package/src/skills/flutter-dart-code-review/SKILL.md +435 -0
  345. package/src/skills/frontend-patterns/SKILL.md +642 -0
  346. package/src/skills/gan-style-harness/SKILL.md +278 -0
  347. package/src/skills/git-workflow/SKILL.md +715 -0
  348. package/src/skills/golang-patterns/SKILL.md +674 -0
  349. package/src/skills/golang-testing/SKILL.md +720 -0
  350. package/src/skills/hexagonal-architecture/SKILL.md +276 -0
  351. package/src/skills/iterative-retrieval/SKILL.md +211 -0
  352. package/src/skills/java-coding-standards/SKILL.md +147 -0
  353. package/src/skills/jpa-patterns/SKILL.md +151 -0
  354. package/src/skills/kotlin-coroutines-flows/SKILL.md +284 -0
  355. package/src/skills/kotlin-exposed-patterns/SKILL.md +719 -0
  356. package/src/skills/kotlin-ktor-patterns/SKILL.md +689 -0
  357. package/src/skills/kotlin-patterns/SKILL.md +711 -0
  358. package/src/skills/kotlin-testing/SKILL.md +824 -0
  359. package/src/skills/laravel-patterns/SKILL.md +415 -0
  360. package/src/skills/laravel-plugin-discovery/SKILL.md +229 -0
  361. package/src/skills/laravel-security/SKILL.md +285 -0
  362. package/src/skills/laravel-tdd/SKILL.md +283 -0
  363. package/src/skills/laravel-verification/SKILL.md +179 -0
  364. package/src/skills/mcp-server-patterns/SKILL.md +67 -0
  365. package/src/skills/nextjs-turbopack/SKILL.md +44 -0
  366. package/src/skills/nuxt4-patterns/SKILL.md +100 -0
  367. package/src/skills/opensource-pipeline/SKILL.md +255 -0
  368. package/src/skills/perl-patterns/SKILL.md +504 -0
  369. package/src/skills/perl-security/SKILL.md +503 -0
  370. package/src/skills/perl-testing/SKILL.md +475 -0
  371. package/src/skills/postgres-patterns/SKILL.md +147 -0
  372. package/src/skills/project-flow-ops/SKILL.md +111 -0
  373. package/src/skills/project-guidelines-example/SKILL.md +349 -0
  374. package/src/skills/prompt-optimizer/SKILL.md +397 -0
  375. package/src/skills/python-patterns/SKILL.md +750 -0
  376. package/src/skills/python-testing/SKILL.md +816 -0
  377. package/src/skills/pytorch-patterns/SKILL.md +396 -0
  378. package/src/skills/regex-vs-llm-structured-text/SKILL.md +220 -0
  379. package/src/skills/repo-scan/SKILL.md +78 -0
  380. package/src/skills/rules-distill/SKILL.md +264 -0
  381. package/src/skills/rules-distill/scripts/scan-rules.sh +58 -0
  382. package/src/skills/rules-distill/scripts/scan-skills.sh +129 -0
  383. package/src/skills/rust-patterns/SKILL.md +499 -0
  384. package/src/skills/rust-testing/SKILL.md +500 -0
  385. package/src/skills/safety-guard/SKILL.md +69 -0
  386. package/src/skills/search-first/SKILL.md +161 -0
  387. package/src/skills/security-review/SKILL.md +495 -0
  388. package/src/skills/security-review/cloud-infrastructure-security.md +361 -0
  389. package/src/skills/security-scan/SKILL.md +165 -0
  390. package/src/skills/springboot-patterns/SKILL.md +314 -0
  391. package/src/skills/springboot-security/SKILL.md +272 -0
  392. package/src/skills/springboot-tdd/SKILL.md +158 -0
  393. package/src/skills/springboot-verification/SKILL.md +231 -0
  394. package/src/skills/swift-concurrency-6-2/SKILL.md +216 -0
  395. package/src/skills/tdd-workflow/SKILL.md +410 -0
  396. package/src/skills/token-budget-advisor/SKILL.md +133 -0
  397. package/{ecc/skills/verification-loop-SKILL.md → src/skills/verification-loop/SKILL.md} +1 -1
  398. package/src/skills/workspace-surface-audit/SKILL.md +125 -0
  399. package/ecc/scripts/hooks/session-end-marker.js +0 -15
  400. package/gsd/LICENSE +0 -21
  401. package/gsd/commands-gsd/discuss-phase.md +0 -90
  402. package/gsd/commands-gsd/execute-phase.md +0 -41
  403. package/gsd/commands-gsd/join-discord.md +0 -18
  404. package/gsd/commands-gsd/reapply-patches.md +0 -123
  405. package/gsd/commands-gsd/set-profile.md +0 -34
  406. package/gsd/get-shit-done/bin/lib/config.cjs +0 -169
  407. package/gsd/get-shit-done/bin/lib/core.cjs +0 -492
  408. package/gsd/get-shit-done/bin/lib/init.cjs +0 -710
  409. package/gsd/get-shit-done/workflows/execute-phase.md +0 -459
  410. package/gsd/get-shit-done/workflows/help.md +0 -489
  411. package/gsd/get-shit-done/workflows/pause-work.md +0 -122
  412. package/gsd/get-shit-done/workflows/plan-phase.md +0 -560
  413. package/gsd/hooks/gsd-check-update.js +0 -81
  414. package/kit/CLAUDE.md +0 -43
  415. package/kit/commands/kit/update.md +0 -46
  416. package/kit/mcp.json +0 -10
  417. package/kit/rules/code-style.md +0 -24
  418. /package/{ecc → src}/agents/architect.md +0 -0
  419. /package/{ecc → src}/agents/code-reviewer.md +0 -0
  420. /package/{ecc → src}/agents/e2e-runner.md +0 -0
  421. /package/{ecc → src}/agents/security-reviewer.md +0 -0
  422. /package/{ecc → src}/agents/tdd-guide.md +0 -0
  423. /package/{ecc/rules → src/available-rules}/golang/coding-style.md +0 -0
  424. /package/{ecc/rules → src/available-rules}/golang/hooks.md +0 -0
  425. /package/{ecc/rules → src/available-rules}/golang/patterns.md +0 -0
  426. /package/{ecc/rules → src/available-rules}/golang/security.md +0 -0
  427. /package/{ecc/rules → src/available-rules}/golang/testing.md +0 -0
  428. /package/{ecc/rules → src/available-rules}/kotlin/coding-style.md +0 -0
  429. /package/{ecc/rules → src/available-rules}/kotlin/patterns.md +0 -0
  430. /package/{ecc/rules → src/available-rules}/kotlin/security.md +0 -0
  431. /package/{ecc/rules → src/available-rules}/kotlin/testing.md +0 -0
  432. /package/{ecc/rules → src/available-rules}/perl/coding-style.md +0 -0
  433. /package/{ecc/rules → src/available-rules}/perl/hooks.md +0 -0
  434. /package/{ecc/rules → src/available-rules}/perl/patterns.md +0 -0
  435. /package/{ecc/rules → src/available-rules}/perl/security.md +0 -0
  436. /package/{ecc/rules → src/available-rules}/perl/testing.md +0 -0
  437. /package/{ecc/rules → src/available-rules}/php/coding-style.md +0 -0
  438. /package/{ecc/rules → src/available-rules}/php/hooks.md +0 -0
  439. /package/{ecc/rules → src/available-rules}/php/patterns.md +0 -0
  440. /package/{ecc/rules → src/available-rules}/php/security.md +0 -0
  441. /package/{ecc/rules → src/available-rules}/php/testing.md +0 -0
  442. /package/{ecc/rules → src/available-rules}/python/coding-style.md +0 -0
  443. /package/{ecc/rules → src/available-rules}/python/hooks.md +0 -0
  444. /package/{ecc/rules → src/available-rules}/python/patterns.md +0 -0
  445. /package/{ecc/rules → src/available-rules}/python/security.md +0 -0
  446. /package/{ecc/rules → src/available-rules}/python/testing.md +0 -0
  447. /package/{ecc/rules → src/available-rules}/swift/coding-style.md +0 -0
  448. /package/{ecc/rules → src/available-rules}/swift/hooks.md +0 -0
  449. /package/{ecc/rules → src/available-rules}/swift/patterns.md +0 -0
  450. /package/{ecc/rules → src/available-rules}/swift/security.md +0 -0
  451. /package/{ecc/rules → src/available-rules}/swift/testing.md +0 -0
  452. /package/{ecc/rules → src/available-rules}/typescript/coding-style.md +0 -0
  453. /package/{ecc/rules → src/available-rules}/typescript/hooks.md +0 -0
  454. /package/{ecc/rules → src/available-rules}/typescript/patterns.md +0 -0
  455. /package/{ecc/rules → src/available-rules}/typescript/security.md +0 -0
  456. /package/{ecc/rules → src/available-rules}/typescript/testing.md +0 -0
  457. /package/{ecc → src}/contexts/dev.md +0 -0
  458. /package/{ecc → src}/contexts/research.md +0 -0
  459. /package/{ecc → src}/contexts/review.md +0 -0
  460. /package/{ecc → src}/examples/user-CLAUDE.md +0 -0
  461. /package/{ecc/scripts → src}/hooks/check-hook-enabled.js +0 -0
  462. /package/{ecc/scripts → src}/hooks/evaluate-session.js +0 -0
  463. /package/{ecc/scripts → src}/hooks/pre-compact.js +0 -0
  464. /package/{ecc/scripts → src}/hooks/suggest-compact.js +0 -0
  465. /package/{ecc/scripts → src}/lib/package-manager.d.ts +0 -0
  466. /package/{ecc/scripts → src}/lib/package-manager.js +0 -0
  467. /package/{ecc/scripts → src}/lib/resolve-formatter.js +0 -0
  468. /package/{ecc/scripts → src}/lib/session-aliases.d.ts +0 -0
  469. /package/{ecc/scripts → src}/lib/session-aliases.js +0 -0
  470. /package/{ecc/scripts → src}/lib/shell-split.js +0 -0
  471. /package/{gsd/get-shit-done → src/pilot}/bin/lib/frontmatter.cjs +0 -0
  472. /package/{gsd/get-shit-done → src/pilot}/bin/lib/milestone.cjs +0 -0
  473. /package/{gsd/get-shit-done → src/pilot}/bin/lib/roadmap.cjs +0 -0
  474. /package/{gsd/get-shit-done → src/pilot}/bin/lib/template.cjs +0 -0
  475. /package/{gsd/get-shit-done → src/pilot}/references/checkpoints.md +0 -0
  476. /package/{gsd/get-shit-done → src/pilot}/references/questioning.md +0 -0
  477. /package/{gsd/get-shit-done → src/pilot}/references/tdd.md +0 -0
  478. /package/{gsd/get-shit-done → src/pilot}/templates/codebase/concerns.md +0 -0
  479. /package/{gsd/get-shit-done → src/pilot}/templates/codebase/conventions.md +0 -0
  480. /package/{gsd/get-shit-done → src/pilot}/templates/codebase/integrations.md +0 -0
  481. /package/{gsd/get-shit-done → src/pilot}/templates/codebase/stack.md +0 -0
  482. /package/{gsd/get-shit-done → src/pilot}/templates/codebase/testing.md +0 -0
  483. /package/{gsd/get-shit-done → src/pilot}/templates/config.json +0 -0
  484. /package/{gsd/get-shit-done → src/pilot}/templates/continue-here.md +0 -0
  485. /package/{gsd/get-shit-done → src/pilot}/templates/milestone-archive.md +0 -0
  486. /package/{gsd/get-shit-done → src/pilot}/templates/milestone.md +0 -0
  487. /package/{gsd/get-shit-done → src/pilot}/templates/requirements.md +0 -0
  488. /package/{gsd/get-shit-done → src/pilot}/templates/research-project/ARCHITECTURE.md +0 -0
  489. /package/{gsd/get-shit-done → src/pilot}/templates/research-project/FEATURES.md +0 -0
  490. /package/{gsd/get-shit-done → src/pilot}/templates/research-project/PITFALLS.md +0 -0
  491. /package/{gsd/get-shit-done → src/pilot}/templates/research-project/STACK.md +0 -0
  492. /package/{gsd/get-shit-done → src/pilot}/templates/research-project/SUMMARY.md +0 -0
  493. /package/{gsd/get-shit-done → src/pilot}/templates/retrospective.md +0 -0
  494. /package/{gsd/get-shit-done → src/pilot}/templates/roadmap.md +0 -0
  495. /package/{gsd/get-shit-done → src/pilot}/templates/summary-minimal.md +0 -0
  496. /package/{gsd/get-shit-done → src/pilot}/templates/summary-standard.md +0 -0
  497. /package/{gsd/get-shit-done → src/pilot}/templates/summary.md +0 -0
  498. /package/{gsd/get-shit-done → src/pilot}/templates/user-setup.md +0 -0
  499. /package/{gsd/get-shit-done → src/pilot}/templates/verification-report.md +0 -0
  500. /package/{ecc → src}/rules/common/development-workflow.md +0 -0
  501. /package/{ecc → src}/rules/common/git-workflow.md +0 -0
  502. /package/{ecc → src}/rules/common/hooks.md +0 -0
  503. /package/{ecc → src}/rules/common/patterns.md +0 -0
  504. /package/{ecc → src}/rules/common/performance.md +0 -0
  505. /package/{ecc → src}/rules/common/security.md +0 -0
  506. /package/{ecc → src}/rules/common/testing.md +0 -0
  507. /package/{ecc → src}/skills/continuous-learning-v2/agents/start-observer.sh +0 -0
  508. /package/{ecc → src}/skills/continuous-learning-v2/config.json +0 -0
  509. /package/{ecc → src}/skills/continuous-learning-v2/hooks/observe.sh +0 -0
  510. /package/{ecc → src}/skills/continuous-learning-v2/scripts/detect-project.sh +0 -0
  511. /package/{ecc → src}/skills/continuous-learning-v2/scripts/instinct-cli.py +0 -0
  512. /package/{ecc → src}/skills/continuous-learning-v2/scripts/test_parse_instinct.py +0 -0
  513. /package/{ecc → src}/skills/strategic-compact/SKILL.md +0 -0
  514. /package/{ecc → src}/skills/strategic-compact/suggest-compact.sh +0 -0
@@ -0,0 +1,1281 @@
1
+ /**
2
+ * Init — Compound init commands for workflow bootstrapping
3
+ */
4
+
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+ const { loadConfig, resolveModelInternal, findPhaseInternal, getRoadmapPhaseInternal, pathExistsInternal, generateSlugInternal, getMilestoneInfo, getMilestonePhaseFilter, stripShippedMilestones, extractCurrentMilestone, normalizePhaseName, planningPaths, planningDir, planningRoot, toPosixPath, output, error, checkAgentsInstalled } = require('./core.cjs');
8
+
9
+ function getLatestCompletedMilestone(cwd) {
10
+ const milestonesPath = path.join(planningRoot(cwd), 'MILESTONES.md');
11
+ if (!fs.existsSync(milestonesPath)) return null;
12
+
13
+ try {
14
+ const content = fs.readFileSync(milestonesPath, 'utf-8');
15
+ const match = content.match(/^##\s+(v[\d.]+)\s+(.+?)\s+\(Shipped:/m);
16
+ if (!match) return null;
17
+ return {
18
+ version: match[1],
19
+ name: match[2].trim(),
20
+ };
21
+ } catch {
22
+ return null;
23
+ }
24
+ }
25
+
26
+ /**
27
+ * Inject `project_root` into an init result object.
28
+ * Workflows use this to prefix `.planning/` paths correctly when Claude's CWD
29
+ * differs from the project root (e.g., inside a sub-repo).
30
+ */
31
+ function withProjectRoot(cwd, result) {
32
+ result.project_root = cwd;
33
+ // Inject agent installation status into all init outputs.
34
+ // Workflows that spawn named subagents use this to detect when agents
35
+ // are missing and would silently fall back to general-purpose.
36
+ const agentStatus = checkAgentsInstalled();
37
+ result.agents_installed = agentStatus.agents_installed;
38
+ result.missing_agents = agentStatus.missing_agents;
39
+ return result;
40
+ }
41
+
42
+ function cmdInitExecutePhase(cwd, phase, raw) {
43
+ if (!phase) {
44
+ error('phase required for init execute-phase');
45
+ }
46
+
47
+ const config = loadConfig(cwd);
48
+ let phaseInfo = findPhaseInternal(cwd, phase);
49
+ const milestone = getMilestoneInfo(cwd);
50
+
51
+ const roadmapPhase = getRoadmapPhaseInternal(cwd, phase);
52
+
53
+ // Fallback to ROADMAP.md if no phase directory exists yet
54
+ if (!phaseInfo && roadmapPhase?.found) {
55
+ const phaseName = roadmapPhase.phase_name;
56
+ phaseInfo = {
57
+ found: true,
58
+ directory: null,
59
+ phase_number: roadmapPhase.phase_number,
60
+ phase_name: phaseName,
61
+ phase_slug: phaseName ? phaseName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') : null,
62
+ plans: [],
63
+ summaries: [],
64
+ incomplete_plans: [],
65
+ has_research: false,
66
+ has_context: false,
67
+ has_verification: false,
68
+ has_reviews: false,
69
+ };
70
+ }
71
+ const reqMatch = roadmapPhase?.section?.match(/^\*\*Requirements\*\*:[^\S\n]*([^\n]*)$/m);
72
+ const reqExtracted = reqMatch
73
+ ? reqMatch[1].replace(/[\[\]]/g, '').split(',').map(s => s.trim()).filter(Boolean).join(', ')
74
+ : null;
75
+ const phase_req_ids = (reqExtracted && reqExtracted !== 'TBD') ? reqExtracted : null;
76
+
77
+ const result = {
78
+ // Models
79
+ executor_model: resolveModelInternal(cwd, 'ccp-executor'),
80
+ verifier_model: resolveModelInternal(cwd, 'ccp-verifier'),
81
+
82
+ // Config flags
83
+ commit_docs: config.commit_docs,
84
+ sub_repos: config.sub_repos,
85
+ parallelization: config.parallelization,
86
+ context_window: config.context_window,
87
+ branching_strategy: config.branching_strategy,
88
+ phase_branch_template: config.phase_branch_template,
89
+ milestone_branch_template: config.milestone_branch_template,
90
+ verifier_enabled: config.verifier,
91
+
92
+ // Phase info
93
+ phase_found: !!phaseInfo,
94
+ phase_dir: phaseInfo?.directory || null,
95
+ phase_number: phaseInfo?.phase_number || null,
96
+ phase_name: phaseInfo?.phase_name || null,
97
+ phase_slug: phaseInfo?.phase_slug || null,
98
+ phase_req_ids,
99
+
100
+ // Plan inventory
101
+ plans: phaseInfo?.plans || [],
102
+ summaries: phaseInfo?.summaries || [],
103
+ incomplete_plans: phaseInfo?.incomplete_plans || [],
104
+ plan_count: phaseInfo?.plans?.length || 0,
105
+ incomplete_count: phaseInfo?.incomplete_plans?.length || 0,
106
+
107
+ // Branch name (pre-computed)
108
+ branch_name: config.branching_strategy === 'phase' && phaseInfo
109
+ ? config.phase_branch_template
110
+ .replace('{phase}', phaseInfo.phase_number)
111
+ .replace('{slug}', phaseInfo.phase_slug || 'phase')
112
+ : config.branching_strategy === 'milestone'
113
+ ? config.milestone_branch_template
114
+ .replace('{milestone}', milestone.version)
115
+ .replace('{slug}', generateSlugInternal(milestone.name) || 'milestone')
116
+ : null,
117
+
118
+ // Milestone info
119
+ milestone_version: milestone.version,
120
+ milestone_name: milestone.name,
121
+ milestone_slug: generateSlugInternal(milestone.name),
122
+
123
+ // File existence
124
+ state_exists: fs.existsSync(path.join(planningDir(cwd), 'STATE.md')),
125
+ roadmap_exists: fs.existsSync(path.join(planningDir(cwd), 'ROADMAP.md')),
126
+ config_exists: fs.existsSync(path.join(planningDir(cwd), 'config.json')),
127
+ // File paths
128
+ state_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'STATE.md'))),
129
+ roadmap_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'ROADMAP.md'))),
130
+ config_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'config.json'))),
131
+ };
132
+
133
+ output(withProjectRoot(cwd, result), raw);
134
+ }
135
+
136
+ function cmdInitPlanPhase(cwd, phase, raw) {
137
+ if (!phase) {
138
+ error('phase required for init plan-phase');
139
+ }
140
+
141
+ const config = loadConfig(cwd);
142
+ let phaseInfo = findPhaseInternal(cwd, phase);
143
+
144
+ const roadmapPhase = getRoadmapPhaseInternal(cwd, phase);
145
+
146
+ // Fallback to ROADMAP.md if no phase directory exists yet
147
+ if (!phaseInfo && roadmapPhase?.found) {
148
+ const phaseName = roadmapPhase.phase_name;
149
+ phaseInfo = {
150
+ found: true,
151
+ directory: null,
152
+ phase_number: roadmapPhase.phase_number,
153
+ phase_name: phaseName,
154
+ phase_slug: phaseName ? phaseName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') : null,
155
+ plans: [],
156
+ summaries: [],
157
+ incomplete_plans: [],
158
+ has_research: false,
159
+ has_context: false,
160
+ has_verification: false,
161
+ has_reviews: false,
162
+ };
163
+ }
164
+ const reqMatch = roadmapPhase?.section?.match(/^\*\*Requirements\*\*:[^\S\n]*([^\n]*)$/m);
165
+ const reqExtracted = reqMatch
166
+ ? reqMatch[1].replace(/[\[\]]/g, '').split(',').map(s => s.trim()).filter(Boolean).join(', ')
167
+ : null;
168
+ const phase_req_ids = (reqExtracted && reqExtracted !== 'TBD') ? reqExtracted : null;
169
+
170
+ const result = {
171
+ // Models
172
+ researcher_model: resolveModelInternal(cwd, 'ccp-phase-researcher'),
173
+ planner_model: resolveModelInternal(cwd, 'ccp-planner'),
174
+ checker_model: resolveModelInternal(cwd, 'ccp-plan-checker'),
175
+
176
+ // Workflow flags
177
+ research_enabled: config.research,
178
+ plan_checker_enabled: config.plan_checker,
179
+ nyquist_validation_enabled: config.nyquist_validation,
180
+ commit_docs: config.commit_docs,
181
+ text_mode: config.text_mode,
182
+
183
+ // Phase info
184
+ phase_found: !!phaseInfo,
185
+ phase_dir: phaseInfo?.directory || null,
186
+ phase_number: phaseInfo?.phase_number || null,
187
+ phase_name: phaseInfo?.phase_name || null,
188
+ phase_slug: phaseInfo?.phase_slug || null,
189
+ padded_phase: phaseInfo?.phase_number ? normalizePhaseName(phaseInfo.phase_number) : null,
190
+ phase_req_ids,
191
+
192
+ // Existing artifacts
193
+ has_research: phaseInfo?.has_research || false,
194
+ has_context: phaseInfo?.has_context || false,
195
+ has_reviews: phaseInfo?.has_reviews || false,
196
+ has_plans: (phaseInfo?.plans?.length || 0) > 0,
197
+ plan_count: phaseInfo?.plans?.length || 0,
198
+
199
+ // Environment
200
+ planning_exists: fs.existsSync(planningDir(cwd)),
201
+ roadmap_exists: fs.existsSync(path.join(planningDir(cwd), 'ROADMAP.md')),
202
+
203
+ // File paths
204
+ state_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'STATE.md'))),
205
+ roadmap_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'ROADMAP.md'))),
206
+ requirements_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'REQUIREMENTS.md'))),
207
+ };
208
+
209
+ if (phaseInfo?.directory) {
210
+ // Find *-CONTEXT.md in phase directory
211
+ const phaseDirFull = path.join(cwd, phaseInfo.directory);
212
+ try {
213
+ const files = fs.readdirSync(phaseDirFull);
214
+ const contextFile = files.find(f => f.endsWith('-CONTEXT.md') || f === 'CONTEXT.md');
215
+ if (contextFile) {
216
+ result.context_path = toPosixPath(path.join(phaseInfo.directory, contextFile));
217
+ }
218
+ const researchFile = files.find(f => f.endsWith('-RESEARCH.md') || f === 'RESEARCH.md');
219
+ if (researchFile) {
220
+ result.research_path = toPosixPath(path.join(phaseInfo.directory, researchFile));
221
+ }
222
+ const verificationFile = files.find(f => f.endsWith('-VERIFICATION.md') || f === 'VERIFICATION.md');
223
+ if (verificationFile) {
224
+ result.verification_path = toPosixPath(path.join(phaseInfo.directory, verificationFile));
225
+ }
226
+ const uatFile = files.find(f => f.endsWith('-UAT.md') || f === 'UAT.md');
227
+ if (uatFile) {
228
+ result.uat_path = toPosixPath(path.join(phaseInfo.directory, uatFile));
229
+ }
230
+ const reviewsFile = files.find(f => f.endsWith('-REVIEWS.md') || f === 'REVIEWS.md');
231
+ if (reviewsFile) {
232
+ result.reviews_path = toPosixPath(path.join(phaseInfo.directory, reviewsFile));
233
+ }
234
+ } catch { /* intentionally empty */ }
235
+ }
236
+
237
+ output(withProjectRoot(cwd, result), raw);
238
+ }
239
+
240
+ function cmdInitNewProject(cwd, raw) {
241
+ const config = loadConfig(cwd);
242
+
243
+ // Detect Brave Search API key availability
244
+ const homedir = require('os').homedir();
245
+ const braveKeyFile = path.join(homedir, '.ccp', 'brave_api_key');
246
+ const hasBraveSearch = !!(process.env.BRAVE_API_KEY || fs.existsSync(braveKeyFile));
247
+
248
+ // Detect Firecrawl API key availability
249
+ const firecrawlKeyFile = path.join(homedir, '.ccp', 'firecrawl_api_key');
250
+ const hasFirecrawl = !!(process.env.FIRECRAWL_API_KEY || fs.existsSync(firecrawlKeyFile));
251
+
252
+ // Detect Exa API key availability
253
+ const exaKeyFile = path.join(homedir, '.ccp', 'exa_api_key');
254
+ const hasExaSearch = !!(process.env.EXA_API_KEY || fs.existsSync(exaKeyFile));
255
+
256
+ // Detect existing code (cross-platform — no Unix `find` dependency)
257
+ let hasCode = false;
258
+ let hasPackageFile = false;
259
+ try {
260
+ const codeExtensions = new Set([
261
+ '.ts', '.js', '.py', '.go', '.rs', '.swift', '.java',
262
+ '.kt', '.kts', // Kotlin (Android, server-side)
263
+ '.c', '.cpp', '.h', // C/C++
264
+ '.cs', // C#
265
+ '.rb', // Ruby
266
+ '.php', // PHP
267
+ '.dart', // Dart (Flutter)
268
+ '.m', '.mm', // Objective-C / Objective-C++
269
+ '.scala', // Scala
270
+ '.groovy', // Groovy (Gradle build scripts)
271
+ '.lua', // Lua
272
+ '.r', '.R', // R
273
+ '.zig', // Zig
274
+ '.ex', '.exs', // Elixir
275
+ '.clj', // Clojure
276
+ ]);
277
+ const skipDirs = new Set(['node_modules', '.git', '.planning', '.claude', '__pycache__', 'target', 'dist', 'build']);
278
+ function findCodeFiles(dir, depth) {
279
+ if (depth > 3) return false;
280
+ let entries;
281
+ try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return false; }
282
+ for (const entry of entries) {
283
+ if (entry.isFile() && codeExtensions.has(path.extname(entry.name))) return true;
284
+ if (entry.isDirectory() && !skipDirs.has(entry.name)) {
285
+ if (findCodeFiles(path.join(dir, entry.name), depth + 1)) return true;
286
+ }
287
+ }
288
+ return false;
289
+ }
290
+ hasCode = findCodeFiles(cwd, 0);
291
+ } catch { /* intentionally empty — best-effort detection */ }
292
+
293
+ hasPackageFile = pathExistsInternal(cwd, 'package.json') ||
294
+ pathExistsInternal(cwd, 'requirements.txt') ||
295
+ pathExistsInternal(cwd, 'Cargo.toml') ||
296
+ pathExistsInternal(cwd, 'go.mod') ||
297
+ pathExistsInternal(cwd, 'Package.swift') ||
298
+ pathExistsInternal(cwd, 'build.gradle') ||
299
+ pathExistsInternal(cwd, 'build.gradle.kts') ||
300
+ pathExistsInternal(cwd, 'pom.xml') ||
301
+ pathExistsInternal(cwd, 'Gemfile') ||
302
+ pathExistsInternal(cwd, 'composer.json') ||
303
+ pathExistsInternal(cwd, 'pubspec.yaml') ||
304
+ pathExistsInternal(cwd, 'CMakeLists.txt') ||
305
+ pathExistsInternal(cwd, 'Makefile') ||
306
+ pathExistsInternal(cwd, 'build.zig') ||
307
+ pathExistsInternal(cwd, 'mix.exs') ||
308
+ pathExistsInternal(cwd, 'project.clj');
309
+
310
+ const result = {
311
+ // Models
312
+ researcher_model: resolveModelInternal(cwd, 'ccp-project-researcher'),
313
+ synthesizer_model: resolveModelInternal(cwd, 'ccp-research-synthesizer'),
314
+ roadmapper_model: resolveModelInternal(cwd, 'ccp-roadmapper'),
315
+
316
+ // Config
317
+ commit_docs: config.commit_docs,
318
+
319
+ // Existing state
320
+ project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
321
+ has_codebase_map: pathExistsInternal(cwd, '.planning/codebase'),
322
+ planning_exists: pathExistsInternal(cwd, '.planning'),
323
+
324
+ // Brownfield detection
325
+ has_existing_code: hasCode,
326
+ has_package_file: hasPackageFile,
327
+ is_brownfield: hasCode || hasPackageFile,
328
+ needs_codebase_map: (hasCode || hasPackageFile) && !pathExistsInternal(cwd, '.planning/codebase'),
329
+
330
+ // Git state
331
+ has_git: pathExistsInternal(cwd, '.git'),
332
+
333
+ // Enhanced search
334
+ brave_search_available: hasBraveSearch,
335
+ firecrawl_available: hasFirecrawl,
336
+ exa_search_available: hasExaSearch,
337
+
338
+ // File paths
339
+ project_path: '.planning/PROJECT.md',
340
+ };
341
+
342
+ output(withProjectRoot(cwd, result), raw);
343
+ }
344
+
345
+ function cmdInitNewMilestone(cwd, raw) {
346
+ const config = loadConfig(cwd);
347
+ const milestone = getMilestoneInfo(cwd);
348
+ const latestCompleted = getLatestCompletedMilestone(cwd);
349
+ const phasesDir = path.join(planningDir(cwd), 'phases');
350
+ let phaseDirCount = 0;
351
+
352
+ try {
353
+ if (fs.existsSync(phasesDir)) {
354
+ phaseDirCount = fs.readdirSync(phasesDir, { withFileTypes: true })
355
+ .filter(entry => entry.isDirectory())
356
+ .length;
357
+ }
358
+ } catch { /* intentionally empty */ }
359
+
360
+ const result = {
361
+ // Models
362
+ researcher_model: resolveModelInternal(cwd, 'ccp-project-researcher'),
363
+ synthesizer_model: resolveModelInternal(cwd, 'ccp-research-synthesizer'),
364
+ roadmapper_model: resolveModelInternal(cwd, 'ccp-roadmapper'),
365
+
366
+ // Config
367
+ commit_docs: config.commit_docs,
368
+ research_enabled: config.research,
369
+
370
+ // Current milestone
371
+ current_milestone: milestone.version,
372
+ current_milestone_name: milestone.name,
373
+ latest_completed_milestone: latestCompleted?.version || null,
374
+ latest_completed_milestone_name: latestCompleted?.name || null,
375
+ phase_dir_count: phaseDirCount,
376
+ phase_archive_path: latestCompleted ? toPosixPath(path.relative(cwd, path.join(planningRoot(cwd), 'milestones', `${latestCompleted.version}-phases`))) : null,
377
+
378
+ // File existence
379
+ project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
380
+ roadmap_exists: fs.existsSync(path.join(planningDir(cwd), 'ROADMAP.md')),
381
+ state_exists: fs.existsSync(path.join(planningDir(cwd), 'STATE.md')),
382
+
383
+ // File paths
384
+ project_path: '.planning/PROJECT.md',
385
+ roadmap_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'ROADMAP.md'))),
386
+ state_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'STATE.md'))),
387
+ };
388
+
389
+ output(withProjectRoot(cwd, result), raw);
390
+ }
391
+
392
+ function cmdInitQuick(cwd, description, raw) {
393
+ const config = loadConfig(cwd);
394
+ const now = new Date();
395
+ const slug = description ? generateSlugInternal(description)?.substring(0, 40) : null;
396
+
397
+ // Generate collision-resistant quick task ID: YYMMDD-xxx
398
+ // xxx = 2-second precision blocks since midnight, encoded as 3-char Base36 (lowercase)
399
+ // Range: 000 (00:00:00) to xbz (23:59:58), guaranteed 3 chars for any time of day.
400
+ // Provides ~2s uniqueness window per user — practically collision-free across a team.
401
+ const yy = String(now.getFullYear()).slice(-2);
402
+ const mm = String(now.getMonth() + 1).padStart(2, '0');
403
+ const dd = String(now.getDate()).padStart(2, '0');
404
+ const dateStr = yy + mm + dd;
405
+ const secondsSinceMidnight = now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds();
406
+ const timeBlocks = Math.floor(secondsSinceMidnight / 2);
407
+ const timeEncoded = timeBlocks.toString(36).padStart(3, '0');
408
+ const quickId = dateStr + '-' + timeEncoded;
409
+ const branchSlug = slug || 'quick';
410
+ const quickBranchName = config.quick_branch_template
411
+ ? config.quick_branch_template
412
+ .replace('{num}', quickId)
413
+ .replace('{quick}', quickId)
414
+ .replace('{slug}', branchSlug)
415
+ : null;
416
+
417
+ const result = {
418
+ // Models
419
+ planner_model: resolveModelInternal(cwd, 'ccp-planner'),
420
+ executor_model: resolveModelInternal(cwd, 'ccp-executor'),
421
+ checker_model: resolveModelInternal(cwd, 'ccp-plan-checker'),
422
+ verifier_model: resolveModelInternal(cwd, 'ccp-verifier'),
423
+
424
+ // Config
425
+ commit_docs: config.commit_docs,
426
+ branch_name: quickBranchName,
427
+
428
+ // Quick task info
429
+ quick_id: quickId,
430
+ slug: slug,
431
+ description: description || null,
432
+
433
+ // Timestamps
434
+ date: now.toISOString().split('T')[0],
435
+ timestamp: now.toISOString(),
436
+
437
+ // Paths
438
+ quick_dir: '.planning/quick',
439
+ task_dir: slug ? `.planning/quick/${quickId}-${slug}` : null,
440
+
441
+ // File existence
442
+ roadmap_exists: fs.existsSync(path.join(planningDir(cwd), 'ROADMAP.md')),
443
+ planning_exists: fs.existsSync(planningRoot(cwd)),
444
+
445
+ };
446
+
447
+ output(withProjectRoot(cwd, result), raw);
448
+ }
449
+
450
+ function cmdInitResume(cwd, raw) {
451
+ const config = loadConfig(cwd);
452
+
453
+ // Check for interrupted agent
454
+ let interruptedAgentId = null;
455
+ try {
456
+ interruptedAgentId = fs.readFileSync(path.join(planningRoot(cwd), 'current-agent-id.txt'), 'utf-8').trim();
457
+ } catch { /* intentionally empty */ }
458
+
459
+ const result = {
460
+ // File existence
461
+ state_exists: fs.existsSync(path.join(planningDir(cwd), 'STATE.md')),
462
+ roadmap_exists: fs.existsSync(path.join(planningDir(cwd), 'ROADMAP.md')),
463
+ project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
464
+ planning_exists: fs.existsSync(planningRoot(cwd)),
465
+
466
+ // File paths
467
+ state_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'STATE.md'))),
468
+ roadmap_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'ROADMAP.md'))),
469
+ project_path: '.planning/PROJECT.md',
470
+
471
+ // Agent state
472
+ has_interrupted_agent: !!interruptedAgentId,
473
+ interrupted_agent_id: interruptedAgentId,
474
+
475
+ // Config
476
+ commit_docs: config.commit_docs,
477
+ };
478
+
479
+ output(withProjectRoot(cwd, result), raw);
480
+ }
481
+
482
+ function cmdInitVerifyWork(cwd, phase, raw) {
483
+ if (!phase) {
484
+ error('phase required for init verify-work');
485
+ }
486
+
487
+ const config = loadConfig(cwd);
488
+ let phaseInfo = findPhaseInternal(cwd, phase);
489
+
490
+ // Fallback to ROADMAP.md if no phase directory exists yet
491
+ if (!phaseInfo) {
492
+ const roadmapPhase = getRoadmapPhaseInternal(cwd, phase);
493
+ if (roadmapPhase?.found) {
494
+ const phaseName = roadmapPhase.phase_name;
495
+ phaseInfo = {
496
+ found: true,
497
+ directory: null,
498
+ phase_number: roadmapPhase.phase_number,
499
+ phase_name: phaseName,
500
+ phase_slug: phaseName ? phaseName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') : null,
501
+ plans: [],
502
+ summaries: [],
503
+ incomplete_plans: [],
504
+ has_research: false,
505
+ has_context: false,
506
+ has_verification: false,
507
+ };
508
+ }
509
+ }
510
+
511
+ const result = {
512
+ // Models
513
+ planner_model: resolveModelInternal(cwd, 'ccp-planner'),
514
+ checker_model: resolveModelInternal(cwd, 'ccp-plan-checker'),
515
+
516
+ // Config
517
+ commit_docs: config.commit_docs,
518
+
519
+ // Phase info
520
+ phase_found: !!phaseInfo,
521
+ phase_dir: phaseInfo?.directory || null,
522
+ phase_number: phaseInfo?.phase_number || null,
523
+ phase_name: phaseInfo?.phase_name || null,
524
+
525
+ // Existing artifacts
526
+ has_verification: phaseInfo?.has_verification || false,
527
+ };
528
+
529
+ output(withProjectRoot(cwd, result), raw);
530
+ }
531
+
532
+ function cmdInitPhaseOp(cwd, phase, raw) {
533
+ const config = loadConfig(cwd);
534
+ let phaseInfo = findPhaseInternal(cwd, phase);
535
+
536
+ // If the only disk match comes from an archived milestone, prefer the
537
+ // current milestone's ROADMAP entry so discuss-phase and similar flows
538
+ // don't attach to shipped work that reused the same phase number.
539
+ if (phaseInfo?.archived) {
540
+ const roadmapPhase = getRoadmapPhaseInternal(cwd, phase);
541
+ if (roadmapPhase?.found) {
542
+ const phaseName = roadmapPhase.phase_name;
543
+ phaseInfo = {
544
+ found: true,
545
+ directory: null,
546
+ phase_number: roadmapPhase.phase_number,
547
+ phase_name: phaseName,
548
+ phase_slug: phaseName ? phaseName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') : null,
549
+ plans: [],
550
+ summaries: [],
551
+ incomplete_plans: [],
552
+ has_research: false,
553
+ has_context: false,
554
+ has_verification: false,
555
+ };
556
+ }
557
+ }
558
+
559
+ // Fallback to ROADMAP.md if no directory exists (e.g., Plans: TBD)
560
+ if (!phaseInfo) {
561
+ const roadmapPhase = getRoadmapPhaseInternal(cwd, phase);
562
+ if (roadmapPhase?.found) {
563
+ const phaseName = roadmapPhase.phase_name;
564
+ phaseInfo = {
565
+ found: true,
566
+ directory: null,
567
+ phase_number: roadmapPhase.phase_number,
568
+ phase_name: phaseName,
569
+ phase_slug: phaseName ? phaseName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') : null,
570
+ plans: [],
571
+ summaries: [],
572
+ incomplete_plans: [],
573
+ has_research: false,
574
+ has_context: false,
575
+ has_verification: false,
576
+ };
577
+ }
578
+ }
579
+
580
+ const result = {
581
+ // Config
582
+ commit_docs: config.commit_docs,
583
+ brave_search: config.brave_search,
584
+ firecrawl: config.firecrawl,
585
+ exa_search: config.exa_search,
586
+
587
+ // Phase info
588
+ phase_found: !!phaseInfo,
589
+ phase_dir: phaseInfo?.directory || null,
590
+ phase_number: phaseInfo?.phase_number || null,
591
+ phase_name: phaseInfo?.phase_name || null,
592
+ phase_slug: phaseInfo?.phase_slug || null,
593
+ padded_phase: phaseInfo?.phase_number ? normalizePhaseName(phaseInfo.phase_number) : null,
594
+
595
+ // Existing artifacts
596
+ has_research: phaseInfo?.has_research || false,
597
+ has_context: phaseInfo?.has_context || false,
598
+ has_plans: (phaseInfo?.plans?.length || 0) > 0,
599
+ has_verification: phaseInfo?.has_verification || false,
600
+ has_reviews: phaseInfo?.has_reviews || false,
601
+ plan_count: phaseInfo?.plans?.length || 0,
602
+
603
+ // File existence
604
+ roadmap_exists: fs.existsSync(path.join(planningDir(cwd), 'ROADMAP.md')),
605
+ planning_exists: fs.existsSync(planningDir(cwd)),
606
+
607
+ // File paths
608
+ state_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'STATE.md'))),
609
+ roadmap_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'ROADMAP.md'))),
610
+ requirements_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'REQUIREMENTS.md'))),
611
+ };
612
+
613
+ if (phaseInfo?.directory) {
614
+ const phaseDirFull = path.join(cwd, phaseInfo.directory);
615
+ try {
616
+ const files = fs.readdirSync(phaseDirFull);
617
+ const contextFile = files.find(f => f.endsWith('-CONTEXT.md') || f === 'CONTEXT.md');
618
+ if (contextFile) {
619
+ result.context_path = toPosixPath(path.join(phaseInfo.directory, contextFile));
620
+ }
621
+ const researchFile = files.find(f => f.endsWith('-RESEARCH.md') || f === 'RESEARCH.md');
622
+ if (researchFile) {
623
+ result.research_path = toPosixPath(path.join(phaseInfo.directory, researchFile));
624
+ }
625
+ const verificationFile = files.find(f => f.endsWith('-VERIFICATION.md') || f === 'VERIFICATION.md');
626
+ if (verificationFile) {
627
+ result.verification_path = toPosixPath(path.join(phaseInfo.directory, verificationFile));
628
+ }
629
+ const uatFile = files.find(f => f.endsWith('-UAT.md') || f === 'UAT.md');
630
+ if (uatFile) {
631
+ result.uat_path = toPosixPath(path.join(phaseInfo.directory, uatFile));
632
+ }
633
+ const reviewsFile = files.find(f => f.endsWith('-REVIEWS.md') || f === 'REVIEWS.md');
634
+ if (reviewsFile) {
635
+ result.reviews_path = toPosixPath(path.join(phaseInfo.directory, reviewsFile));
636
+ }
637
+ } catch { /* intentionally empty */ }
638
+ }
639
+
640
+ output(withProjectRoot(cwd, result), raw);
641
+ }
642
+
643
+ function cmdInitTodos(cwd, area, raw) {
644
+ const config = loadConfig(cwd);
645
+ const now = new Date();
646
+
647
+ // List todos (reuse existing logic)
648
+ const pendingDir = path.join(planningDir(cwd), 'todos', 'pending');
649
+ let count = 0;
650
+ const todos = [];
651
+
652
+ try {
653
+ const files = fs.readdirSync(pendingDir).filter(f => f.endsWith('.md'));
654
+ for (const file of files) {
655
+ try {
656
+ const content = fs.readFileSync(path.join(pendingDir, file), 'utf-8');
657
+ const createdMatch = content.match(/^created:\s*(.+)$/m);
658
+ const titleMatch = content.match(/^title:\s*(.+)$/m);
659
+ const areaMatch = content.match(/^area:\s*(.+)$/m);
660
+ const todoArea = areaMatch ? areaMatch[1].trim() : 'general';
661
+
662
+ if (area && todoArea !== area) continue;
663
+
664
+ count++;
665
+ todos.push({
666
+ file,
667
+ created: createdMatch ? createdMatch[1].trim() : 'unknown',
668
+ title: titleMatch ? titleMatch[1].trim() : 'Untitled',
669
+ area: todoArea,
670
+ path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'todos', 'pending', file))),
671
+ });
672
+ } catch { /* intentionally empty */ }
673
+ }
674
+ } catch { /* intentionally empty */ }
675
+
676
+ const result = {
677
+ // Config
678
+ commit_docs: config.commit_docs,
679
+
680
+ // Timestamps
681
+ date: now.toISOString().split('T')[0],
682
+ timestamp: now.toISOString(),
683
+
684
+ // Todo inventory
685
+ todo_count: count,
686
+ todos,
687
+ area_filter: area || null,
688
+
689
+ // Paths
690
+ pending_dir: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'todos', 'pending'))),
691
+ completed_dir: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'todos', 'completed'))),
692
+
693
+ // File existence
694
+ planning_exists: fs.existsSync(planningDir(cwd)),
695
+ todos_dir_exists: fs.existsSync(path.join(planningDir(cwd), 'todos')),
696
+ pending_dir_exists: fs.existsSync(path.join(planningDir(cwd), 'todos', 'pending')),
697
+ };
698
+
699
+ output(withProjectRoot(cwd, result), raw);
700
+ }
701
+
702
+ function cmdInitMilestoneOp(cwd, raw) {
703
+ const config = loadConfig(cwd);
704
+ const milestone = getMilestoneInfo(cwd);
705
+
706
+ // Count phases
707
+ let phaseCount = 0;
708
+ let completedPhases = 0;
709
+ const phasesDir = path.join(planningDir(cwd), 'phases');
710
+ try {
711
+ const entries = fs.readdirSync(phasesDir, { withFileTypes: true });
712
+ const dirs = entries.filter(e => e.isDirectory()).map(e => e.name);
713
+ phaseCount = dirs.length;
714
+
715
+ // Count phases with summaries (completed)
716
+ for (const dir of dirs) {
717
+ try {
718
+ const phaseFiles = fs.readdirSync(path.join(phasesDir, dir));
719
+ const hasSummary = phaseFiles.some(f => f.endsWith('-SUMMARY.md') || f === 'SUMMARY.md');
720
+ if (hasSummary) completedPhases++;
721
+ } catch { /* intentionally empty */ }
722
+ }
723
+ } catch { /* intentionally empty */ }
724
+
725
+ // Check archive
726
+ const archiveDir = path.join(planningRoot(cwd), 'archive');
727
+ let archivedMilestones = [];
728
+ try {
729
+ archivedMilestones = fs.readdirSync(archiveDir, { withFileTypes: true })
730
+ .filter(e => e.isDirectory())
731
+ .map(e => e.name);
732
+ } catch { /* intentionally empty */ }
733
+
734
+ const result = {
735
+ // Config
736
+ commit_docs: config.commit_docs,
737
+
738
+ // Current milestone
739
+ milestone_version: milestone.version,
740
+ milestone_name: milestone.name,
741
+ milestone_slug: generateSlugInternal(milestone.name),
742
+
743
+ // Phase counts
744
+ phase_count: phaseCount,
745
+ completed_phases: completedPhases,
746
+ all_phases_complete: phaseCount > 0 && phaseCount === completedPhases,
747
+
748
+ // Archive
749
+ archived_milestones: archivedMilestones,
750
+ archive_count: archivedMilestones.length,
751
+
752
+ // File existence
753
+ project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
754
+ roadmap_exists: fs.existsSync(path.join(planningDir(cwd), 'ROADMAP.md')),
755
+ state_exists: fs.existsSync(path.join(planningDir(cwd), 'STATE.md')),
756
+ archive_exists: fs.existsSync(path.join(planningRoot(cwd), 'archive')),
757
+ phases_dir_exists: fs.existsSync(path.join(planningDir(cwd), 'phases')),
758
+ };
759
+
760
+ output(withProjectRoot(cwd, result), raw);
761
+ }
762
+
763
+ function cmdInitMapCodebase(cwd, raw) {
764
+ const config = loadConfig(cwd);
765
+
766
+ // Check for existing codebase maps
767
+ const codebaseDir = path.join(planningRoot(cwd), 'codebase');
768
+ let existingMaps = [];
769
+ try {
770
+ existingMaps = fs.readdirSync(codebaseDir).filter(f => f.endsWith('.md'));
771
+ } catch { /* intentionally empty */ }
772
+
773
+ const result = {
774
+ // Models
775
+ mapper_model: resolveModelInternal(cwd, 'ccp-codebase-mapper'),
776
+
777
+ // Config
778
+ commit_docs: config.commit_docs,
779
+ search_gitignored: config.search_gitignored,
780
+ parallelization: config.parallelization,
781
+
782
+ // Paths
783
+ codebase_dir: '.planning/codebase',
784
+
785
+ // Existing maps
786
+ existing_maps: existingMaps,
787
+ has_maps: existingMaps.length > 0,
788
+
789
+ // File existence
790
+ planning_exists: pathExistsInternal(cwd, '.planning'),
791
+ codebase_dir_exists: pathExistsInternal(cwd, '.planning/codebase'),
792
+ };
793
+
794
+ output(withProjectRoot(cwd, result), raw);
795
+ }
796
+
797
+ function cmdInitManager(cwd, raw) {
798
+ const config = loadConfig(cwd);
799
+ const milestone = getMilestoneInfo(cwd);
800
+
801
+ // Use planningPaths for forward-compatibility
802
+ const paths = planningPaths(cwd);
803
+
804
+ // Validate prerequisites
805
+ if (!fs.existsSync(paths.roadmap)) {
806
+ error('No ROADMAP.md found. Run /ccp:new-milestone first.');
807
+ }
808
+ if (!fs.existsSync(paths.state)) {
809
+ error('No STATE.md found. Run /ccp:new-milestone first.');
810
+ }
811
+ const rawContent = fs.readFileSync(paths.roadmap, 'utf-8');
812
+ const content = extractCurrentMilestone(rawContent, cwd);
813
+ const phasesDir = paths.phases;
814
+ const isDirInMilestone = getMilestonePhaseFilter(cwd);
815
+
816
+ const phasePattern = /#{2,4}\s*Phase\s+(\d+[A-Z]?(?:\.\d+)*)\s*:\s*([^\n]+)/gi;
817
+ const phases = [];
818
+ let match;
819
+
820
+ while ((match = phasePattern.exec(content)) !== null) {
821
+ const phaseNum = match[1];
822
+ const phaseName = match[2].replace(/\(INSERTED\)/i, '').trim();
823
+
824
+ const sectionStart = match.index;
825
+ const restOfContent = content.slice(sectionStart);
826
+ const nextHeader = restOfContent.match(/\n#{2,4}\s+Phase\s+\d/i);
827
+ const sectionEnd = nextHeader ? sectionStart + nextHeader.index : content.length;
828
+ const section = content.slice(sectionStart, sectionEnd);
829
+
830
+ const goalMatch = section.match(/\*\*Goal(?::\*\*|\*\*:)\s*([^\n]+)/i);
831
+ const goal = goalMatch ? goalMatch[1].trim() : null;
832
+
833
+ const dependsMatch = section.match(/\*\*Depends on(?::\*\*|\*\*:)\s*([^\n]+)/i);
834
+ const depends_on = dependsMatch ? dependsMatch[1].trim() : null;
835
+
836
+ const normalized = normalizePhaseName(phaseNum);
837
+ let diskStatus = 'no_directory';
838
+ let planCount = 0;
839
+ let summaryCount = 0;
840
+ let hasContext = false;
841
+ let hasResearch = false;
842
+ let lastActivity = null;
843
+ let isActive = false;
844
+
845
+ try {
846
+ const entries = fs.readdirSync(phasesDir, { withFileTypes: true });
847
+ const dirs = entries.filter(e => e.isDirectory()).map(e => e.name).filter(isDirInMilestone);
848
+ const dirMatch = dirs.find(d => d.startsWith(normalized + '-') || d === normalized);
849
+
850
+ if (dirMatch) {
851
+ const fullDir = path.join(phasesDir, dirMatch);
852
+ const phaseFiles = fs.readdirSync(fullDir);
853
+ planCount = phaseFiles.filter(f => f.endsWith('-PLAN.md') || f === 'PLAN.md').length;
854
+ summaryCount = phaseFiles.filter(f => f.endsWith('-SUMMARY.md') || f === 'SUMMARY.md').length;
855
+ hasContext = phaseFiles.some(f => f.endsWith('-CONTEXT.md') || f === 'CONTEXT.md');
856
+ hasResearch = phaseFiles.some(f => f.endsWith('-RESEARCH.md') || f === 'RESEARCH.md');
857
+
858
+ if (summaryCount >= planCount && planCount > 0) diskStatus = 'complete';
859
+ else if (summaryCount > 0) diskStatus = 'partial';
860
+ else if (planCount > 0) diskStatus = 'planned';
861
+ else if (hasResearch) diskStatus = 'researched';
862
+ else if (hasContext) diskStatus = 'discussed';
863
+ else diskStatus = 'empty';
864
+
865
+ // Activity detection: check most recent file mtime
866
+ const now = Date.now();
867
+ let newestMtime = 0;
868
+ for (const f of phaseFiles) {
869
+ try {
870
+ const stat = fs.statSync(path.join(fullDir, f));
871
+ if (stat.mtimeMs > newestMtime) newestMtime = stat.mtimeMs;
872
+ } catch { /* intentionally empty */ }
873
+ }
874
+ if (newestMtime > 0) {
875
+ lastActivity = new Date(newestMtime).toISOString();
876
+ isActive = (now - newestMtime) < 300000; // 5 minutes
877
+ }
878
+ }
879
+ } catch { /* intentionally empty */ }
880
+
881
+ // Check ROADMAP checkbox status
882
+ const checkboxPattern = new RegExp(`-\\s*\\[(x| )\\]\\s*.*Phase\\s+${phaseNum.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[:\\s]`, 'i');
883
+ const checkboxMatch = content.match(checkboxPattern);
884
+ const roadmapComplete = checkboxMatch ? checkboxMatch[1] === 'x' : false;
885
+ if (roadmapComplete && diskStatus !== 'complete') {
886
+ diskStatus = 'complete';
887
+ }
888
+
889
+ phases.push({
890
+ number: phaseNum,
891
+ name: phaseName,
892
+ goal,
893
+ depends_on,
894
+ disk_status: diskStatus,
895
+ has_context: hasContext,
896
+ has_research: hasResearch,
897
+ plan_count: planCount,
898
+ summary_count: summaryCount,
899
+ roadmap_complete: roadmapComplete,
900
+ last_activity: lastActivity,
901
+ is_active: isActive,
902
+ });
903
+ }
904
+
905
+ // Compute display names: truncate to keep table aligned
906
+ const MAX_NAME_WIDTH = 20;
907
+ for (const phase of phases) {
908
+ if (phase.name.length > MAX_NAME_WIDTH) {
909
+ phase.display_name = phase.name.slice(0, MAX_NAME_WIDTH - 1) + '\u2026';
910
+ } else {
911
+ phase.display_name = phase.name;
912
+ }
913
+ }
914
+
915
+ // Dependency satisfaction: check if all depends_on phases are complete
916
+ const completedNums = new Set(phases.filter(p => p.disk_status === 'complete').map(p => p.number));
917
+ for (const phase of phases) {
918
+ if (!phase.depends_on || /^none$/i.test(phase.depends_on.trim())) {
919
+ phase.deps_satisfied = true;
920
+ } else {
921
+ // Parse "Phase 1, Phase 3" or "1, 3" formats
922
+ const depNums = phase.depends_on.match(/\d+(?:\.\d+)*/g) || [];
923
+ phase.deps_satisfied = depNums.every(n => completedNums.has(n));
924
+ phase.dep_phases = depNums;
925
+ }
926
+ }
927
+
928
+ // Compact dependency display for dashboard
929
+ for (const phase of phases) {
930
+ phase.deps_display = (phase.dep_phases && phase.dep_phases.length > 0)
931
+ ? phase.dep_phases.join(',')
932
+ : '\u2014';
933
+ }
934
+
935
+ // Sliding window: discuss is sequential — only the first undiscussed phase is available
936
+ let foundNextToDiscuss = false;
937
+ for (const phase of phases) {
938
+ if (!foundNextToDiscuss && (phase.disk_status === 'empty' || phase.disk_status === 'no_directory')) {
939
+ phase.is_next_to_discuss = true;
940
+ foundNextToDiscuss = true;
941
+ } else {
942
+ phase.is_next_to_discuss = false;
943
+ }
944
+ }
945
+
946
+ // Check for WAITING.json signal
947
+ let waitingSignal = null;
948
+ try {
949
+ const waitingPath = path.join(cwd, '.planning', 'WAITING.json');
950
+ if (fs.existsSync(waitingPath)) {
951
+ waitingSignal = JSON.parse(fs.readFileSync(waitingPath, 'utf-8'));
952
+ }
953
+ } catch { /* intentionally empty */ }
954
+
955
+ // Compute recommended actions (execute > plan > discuss)
956
+ const recommendedActions = [];
957
+ for (const phase of phases) {
958
+ if (phase.disk_status === 'complete') continue;
959
+
960
+ if (phase.disk_status === 'planned' && phase.deps_satisfied) {
961
+ recommendedActions.push({
962
+ phase: phase.number,
963
+ phase_name: phase.name,
964
+ action: 'execute',
965
+ reason: `${phase.plan_count} plans ready, dependencies met`,
966
+ command: `/ccp:execute-phase ${phase.number}`,
967
+ });
968
+ } else if (phase.disk_status === 'discussed' || phase.disk_status === 'researched') {
969
+ recommendedActions.push({
970
+ phase: phase.number,
971
+ phase_name: phase.name,
972
+ action: 'plan',
973
+ reason: 'Context gathered, ready for planning',
974
+ command: `/ccp:plan-phase ${phase.number}`,
975
+ });
976
+ } else if ((phase.disk_status === 'empty' || phase.disk_status === 'no_directory') && phase.is_next_to_discuss) {
977
+ recommendedActions.push({
978
+ phase: phase.number,
979
+ phase_name: phase.name,
980
+ action: 'discuss',
981
+ reason: 'Unblocked, ready to gather context',
982
+ command: `/ccp:discuss-phase ${phase.number}`,
983
+ });
984
+ }
985
+ }
986
+
987
+ // Filter recommendations: no parallel execute/plan unless phases are independent
988
+ // Two phases are "independent" if neither depends on the other (directly or transitively)
989
+ const phaseMap = new Map(phases.map(p => [p.number, p]));
990
+
991
+ function reaches(from, to, visited = new Set()) {
992
+ if (visited.has(from)) return false;
993
+ visited.add(from);
994
+ const p = phaseMap.get(from);
995
+ if (!p || !p.dep_phases || p.dep_phases.length === 0) return false;
996
+ if (p.dep_phases.includes(to)) return true;
997
+ return p.dep_phases.some(dep => reaches(dep, to, visited));
998
+ }
999
+
1000
+ function hasDepRelationship(numA, numB) {
1001
+ return reaches(numA, numB) || reaches(numB, numA);
1002
+ }
1003
+
1004
+ // Detect phases with active work (file modified in last 5 min)
1005
+ const activeExecuting = phases.filter(p =>
1006
+ p.disk_status === 'partial' ||
1007
+ (p.disk_status === 'planned' && p.is_active)
1008
+ );
1009
+ const activePlanning = phases.filter(p =>
1010
+ p.is_active && (p.disk_status === 'discussed' || p.disk_status === 'researched')
1011
+ );
1012
+
1013
+ const filteredActions = recommendedActions.filter(action => {
1014
+ if (action.action === 'execute' && activeExecuting.length > 0) {
1015
+ // Only allow if independent of ALL actively-executing phases
1016
+ return activeExecuting.every(active => !hasDepRelationship(action.phase, active.number));
1017
+ }
1018
+ if (action.action === 'plan' && activePlanning.length > 0) {
1019
+ // Only allow if independent of ALL actively-planning phases
1020
+ return activePlanning.every(active => !hasDepRelationship(action.phase, active.number));
1021
+ }
1022
+ return true;
1023
+ });
1024
+
1025
+ const completedCount = phases.filter(p => p.disk_status === 'complete').length;
1026
+ const result = {
1027
+ milestone_version: milestone.version,
1028
+ milestone_name: milestone.name,
1029
+ phases,
1030
+ phase_count: phases.length,
1031
+ completed_count: completedCount,
1032
+ in_progress_count: phases.filter(p => ['partial', 'planned', 'discussed', 'researched'].includes(p.disk_status)).length,
1033
+ recommended_actions: filteredActions,
1034
+ waiting_signal: waitingSignal,
1035
+ all_complete: completedCount === phases.length && phases.length > 0,
1036
+ project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
1037
+ roadmap_exists: true,
1038
+ state_exists: true,
1039
+ };
1040
+
1041
+ output(withProjectRoot(cwd, result), raw);
1042
+ }
1043
+
1044
+ function cmdInitProgress(cwd, raw) {
1045
+ const config = loadConfig(cwd);
1046
+ const milestone = getMilestoneInfo(cwd);
1047
+
1048
+ // Analyze phases — filter to current milestone and include ROADMAP-only phases
1049
+ const phasesDir = path.join(planningDir(cwd), 'phases');
1050
+ const phases = [];
1051
+ let currentPhase = null;
1052
+ let nextPhase = null;
1053
+
1054
+ // Build set of phases defined in ROADMAP for the current milestone
1055
+ const roadmapPhaseNums = new Set();
1056
+ const roadmapPhaseNames = new Map();
1057
+ try {
1058
+ const roadmapContent = extractCurrentMilestone(
1059
+ fs.readFileSync(path.join(planningDir(cwd), 'ROADMAP.md'), 'utf-8'), cwd
1060
+ );
1061
+ const headingPattern = /#{2,4}\s*Phase\s+(\d+[A-Z]?(?:\.\d+)*)\s*:\s*([^\n]+)/gi;
1062
+ let hm;
1063
+ while ((hm = headingPattern.exec(roadmapContent)) !== null) {
1064
+ roadmapPhaseNums.add(hm[1]);
1065
+ roadmapPhaseNames.set(hm[1], hm[2].replace(/\(INSERTED\)/i, '').trim());
1066
+ }
1067
+ } catch { /* intentionally empty */ }
1068
+
1069
+ const isDirInMilestone = getMilestonePhaseFilter(cwd);
1070
+ const seenPhaseNums = new Set();
1071
+
1072
+ try {
1073
+ const entries = fs.readdirSync(phasesDir, { withFileTypes: true });
1074
+ const dirs = entries.filter(e => e.isDirectory()).map(e => e.name)
1075
+ .filter(isDirInMilestone)
1076
+ .sort((a, b) => {
1077
+ const pa = a.match(/^(\d+[A-Z]?(?:\.\d+)*)/i);
1078
+ const pb = b.match(/^(\d+[A-Z]?(?:\.\d+)*)/i);
1079
+ if (!pa || !pb) return a.localeCompare(b);
1080
+ return parseInt(pa[1], 10) - parseInt(pb[1], 10);
1081
+ });
1082
+
1083
+ for (const dir of dirs) {
1084
+ const match = dir.match(/^(\d+[A-Z]?(?:\.\d+)*)-?(.*)/i);
1085
+ const phaseNumber = match ? match[1] : dir;
1086
+ const phaseName = match && match[2] ? match[2] : null;
1087
+ seenPhaseNums.add(phaseNumber.replace(/^0+/, '') || '0');
1088
+
1089
+ const phasePath = path.join(phasesDir, dir);
1090
+ const phaseFiles = fs.readdirSync(phasePath);
1091
+
1092
+ const plans = phaseFiles.filter(f => f.endsWith('-PLAN.md') || f === 'PLAN.md');
1093
+ const summaries = phaseFiles.filter(f => f.endsWith('-SUMMARY.md') || f === 'SUMMARY.md');
1094
+ const hasResearch = phaseFiles.some(f => f.endsWith('-RESEARCH.md') || f === 'RESEARCH.md');
1095
+
1096
+ const status = summaries.length >= plans.length && plans.length > 0 ? 'complete' :
1097
+ plans.length > 0 ? 'in_progress' :
1098
+ hasResearch ? 'researched' : 'pending';
1099
+
1100
+ const phaseInfo = {
1101
+ number: phaseNumber,
1102
+ name: phaseName,
1103
+ directory: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'phases', dir))),
1104
+ status,
1105
+ plan_count: plans.length,
1106
+ summary_count: summaries.length,
1107
+ has_research: hasResearch,
1108
+ };
1109
+
1110
+ phases.push(phaseInfo);
1111
+
1112
+ // Find current (first incomplete with plans) and next (first pending)
1113
+ if (!currentPhase && (status === 'in_progress' || status === 'researched')) {
1114
+ currentPhase = phaseInfo;
1115
+ }
1116
+ if (!nextPhase && status === 'pending') {
1117
+ nextPhase = phaseInfo;
1118
+ }
1119
+ }
1120
+ } catch { /* intentionally empty */ }
1121
+
1122
+ // Add phases defined in ROADMAP but not yet scaffolded to disk
1123
+ for (const [num, name] of roadmapPhaseNames) {
1124
+ const stripped = num.replace(/^0+/, '') || '0';
1125
+ if (!seenPhaseNums.has(stripped)) {
1126
+ const phaseInfo = {
1127
+ number: num,
1128
+ name: name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, ''),
1129
+ directory: null,
1130
+ status: 'not_started',
1131
+ plan_count: 0,
1132
+ summary_count: 0,
1133
+ has_research: false,
1134
+ };
1135
+ phases.push(phaseInfo);
1136
+ if (!nextPhase && !currentPhase) {
1137
+ nextPhase = phaseInfo;
1138
+ }
1139
+ }
1140
+ }
1141
+
1142
+ // Re-sort phases by number after adding ROADMAP-only phases
1143
+ phases.sort((a, b) => parseInt(a.number, 10) - parseInt(b.number, 10));
1144
+
1145
+ // Check for paused work
1146
+ let pausedAt = null;
1147
+ try {
1148
+ const state = fs.readFileSync(path.join(planningDir(cwd), 'STATE.md'), 'utf-8');
1149
+ const pauseMatch = state.match(/\*\*Paused At:\*\*\s*(.+)/);
1150
+ if (pauseMatch) pausedAt = pauseMatch[1].trim();
1151
+ } catch { /* intentionally empty */ }
1152
+
1153
+ const result = {
1154
+ // Models
1155
+ executor_model: resolveModelInternal(cwd, 'ccp-executor'),
1156
+ planner_model: resolveModelInternal(cwd, 'ccp-planner'),
1157
+
1158
+ // Config
1159
+ commit_docs: config.commit_docs,
1160
+
1161
+ // Milestone
1162
+ milestone_version: milestone.version,
1163
+ milestone_name: milestone.name,
1164
+
1165
+ // Phase overview
1166
+ phases,
1167
+ phase_count: phases.length,
1168
+ completed_count: phases.filter(p => p.status === 'complete').length,
1169
+ in_progress_count: phases.filter(p => p.status === 'in_progress').length,
1170
+
1171
+ // Current state
1172
+ current_phase: currentPhase,
1173
+ next_phase: nextPhase,
1174
+ paused_at: pausedAt,
1175
+ has_work_in_progress: !!currentPhase,
1176
+
1177
+ // File existence
1178
+ project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
1179
+ roadmap_exists: fs.existsSync(path.join(planningDir(cwd), 'ROADMAP.md')),
1180
+ state_exists: fs.existsSync(path.join(planningDir(cwd), 'STATE.md')),
1181
+ // File paths
1182
+ state_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'STATE.md'))),
1183
+ roadmap_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'ROADMAP.md'))),
1184
+ project_path: '.planning/PROJECT.md',
1185
+ config_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'config.json'))),
1186
+ };
1187
+
1188
+ output(withProjectRoot(cwd, result), raw);
1189
+ }
1190
+
1191
+ /**
1192
+ * Build a formatted agent skills block for injection into Task() prompts.
1193
+ *
1194
+ * Reads `config.agent_skills[agentType]` and validates each skill path exists
1195
+ * within the project root. Returns a formatted `<agent_skills>` block or empty
1196
+ * string if no skills are configured.
1197
+ *
1198
+ * @param {object} config - Loaded project config
1199
+ * @param {string} agentType - The agent type (e.g., 'ccp-executor', 'ccp-planner')
1200
+ * @param {string} projectRoot - Absolute path to project root (for path validation)
1201
+ * @returns {string} Formatted skills block or empty string
1202
+ */
1203
+ function buildAgentSkillsBlock(config, agentType, projectRoot) {
1204
+ // Lazy require: security.cjs is only needed when agent skills are configured.
1205
+ // Keeping this as a lazy require avoids circular dependency issues and reduces
1206
+ // startup cost for the common case where no agent skills are set.
1207
+ const { validatePath } = require('./security.cjs');
1208
+
1209
+ if (!config || !config.agent_skills || !agentType) return '';
1210
+
1211
+ let skillPaths = config.agent_skills[agentType];
1212
+ if (!skillPaths) return '';
1213
+
1214
+ // Normalize single string to array
1215
+ if (typeof skillPaths === 'string') skillPaths = [skillPaths];
1216
+ if (!Array.isArray(skillPaths) || skillPaths.length === 0) return '';
1217
+
1218
+ const validPaths = [];
1219
+ for (const skillPath of skillPaths) {
1220
+ if (typeof skillPath !== 'string') continue;
1221
+
1222
+ // Validate path safety — must resolve within project root
1223
+ const pathCheck = validatePath(skillPath, projectRoot);
1224
+ if (!pathCheck.safe) {
1225
+ process.stderr.write(`[agent-skills] WARNING: Skipping unsafe path "${skillPath}": ${pathCheck.error}\n`);
1226
+ continue;
1227
+ }
1228
+
1229
+ // Check that the skill directory and SKILL.md exist
1230
+ const skillMdPath = path.join(projectRoot, skillPath, 'SKILL.md');
1231
+ if (!fs.existsSync(skillMdPath)) {
1232
+ process.stderr.write(`[agent-skills] WARNING: Skill not found at "${skillPath}/SKILL.md" — skipping\n`);
1233
+ continue;
1234
+ }
1235
+
1236
+ validPaths.push(skillPath);
1237
+ }
1238
+
1239
+ if (validPaths.length === 0) return '';
1240
+
1241
+ const lines = validPaths.map(p => `- @${p}/SKILL.md`).join('\n');
1242
+ return `<agent_skills>\nRead these user-configured skills:\n${lines}\n</agent_skills>`;
1243
+ }
1244
+
1245
+ /**
1246
+ * Command: output the agent skills block for a given agent type.
1247
+ * Used by workflows: SKILLS=$(node "$TOOLS" agent-skills ccp-executor 2>/dev/null)
1248
+ */
1249
+ function cmdAgentSkills(cwd, agentType, raw) {
1250
+ if (!agentType) {
1251
+ // No agent type — output empty string silently
1252
+ output('', raw, '');
1253
+ return;
1254
+ }
1255
+
1256
+ const config = loadConfig(cwd);
1257
+ const block = buildAgentSkillsBlock(config, agentType, cwd);
1258
+ // Output raw text (not JSON) so workflows can embed it directly
1259
+ if (block) {
1260
+ process.stdout.write(block);
1261
+ }
1262
+ process.exit(0);
1263
+ }
1264
+
1265
+ module.exports = {
1266
+ cmdInitExecutePhase,
1267
+ cmdInitPlanPhase,
1268
+ cmdInitNewProject,
1269
+ cmdInitNewMilestone,
1270
+ cmdInitQuick,
1271
+ cmdInitResume,
1272
+ cmdInitVerifyWork,
1273
+ cmdInitPhaseOp,
1274
+ cmdInitTodos,
1275
+ cmdInitMilestoneOp,
1276
+ cmdInitMapCodebase,
1277
+ cmdInitProgress,
1278
+ cmdInitManager,
1279
+ buildAgentSkillsBlock,
1280
+ cmdAgentSkills,
1281
+ };