contextdevkit 1.8.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 (345) hide show
  1. package/CHANGELOG.md +592 -0
  2. package/LICENSE +21 -0
  3. package/README.md +401 -0
  4. package/docs/AGENT-PACKAGE-FORMAT.md +140 -0
  5. package/docs/ARCHITECTURE.md +258 -0
  6. package/docs/CHANGELOG.md +559 -0
  7. package/docs/CUSTOMIZING.md +211 -0
  8. package/docs/LEVELS.md +151 -0
  9. package/docs/ROADMAP.md +385 -0
  10. package/docs/SQUAD-PIPELINE-FORMAT.md +258 -0
  11. package/docs/SQUADS/agent-forge.md +65 -0
  12. package/docs/SQUADS/design-team.md +161 -0
  13. package/docs/token-economy-plan.md +135 -0
  14. package/install.mjs +273 -0
  15. package/instrucoes.md +274 -0
  16. package/package.json +46 -0
  17. package/templates/CLAUDE.md.tpl +133 -0
  18. package/templates/claude/agents/_TEMPLATE.md +52 -0
  19. package/templates/claude/agents/accessibility.md +36 -0
  20. package/templates/claude/agents/agent-architect.md +37 -0
  21. package/templates/claude/agents/architect.md +39 -0
  22. package/templates/claude/agents/code-reviewer.md +43 -0
  23. package/templates/claude/agents/code-security.md +59 -0
  24. package/templates/claude/agents/context-keeper.md +40 -0
  25. package/templates/claude/agents/devops.md +40 -0
  26. package/templates/claude/agents/eval-designer.md +40 -0
  27. package/templates/claude/agents/forge-orchestrator.md +42 -0
  28. package/templates/claude/agents/governance-officer.md +45 -0
  29. package/templates/claude/agents/growth.md +92 -0
  30. package/templates/claude/agents/infra-security.md +53 -0
  31. package/templates/claude/agents/landing-architect.md +154 -0
  32. package/templates/claude/agents/model-router.md +34 -0
  33. package/templates/claude/agents/packager.md +38 -0
  34. package/templates/claude/agents/privacy-lgpd.md +64 -0
  35. package/templates/claude/agents/product-owner.md +51 -0
  36. package/templates/claude/agents/prompt-engineer.md +33 -0
  37. package/templates/claude/agents/qa-e2e.md +52 -0
  38. package/templates/claude/agents/qa-fuzzer.md +24 -0
  39. package/templates/claude/agents/qa-integration.md +21 -0
  40. package/templates/claude/agents/qa-orchestrator.md +40 -0
  41. package/templates/claude/agents/qa-perf.md +40 -0
  42. package/templates/claude/agents/qa-unit.md +39 -0
  43. package/templates/claude/agents/rag-designer.md +54 -0
  44. package/templates/claude/agents/retention.md +85 -0
  45. package/templates/claude/agents/security.md +48 -0
  46. package/templates/claude/agents/seo-specialist.md +106 -0
  47. package/templates/claude/agents/test-engineer.md +48 -0
  48. package/templates/claude/agents/tool-designer.md +32 -0
  49. package/templates/claude/agents/ui-designer.md +37 -0
  50. package/templates/claude/agents/ux-designer.md +38 -0
  51. package/templates/claude/commands/README.md +95 -0
  52. package/templates/claude/commands/advise.md +80 -0
  53. package/templates/claude/commands/audit/analyze-code-ia-practices.md +75 -0
  54. package/templates/claude/commands/audit/audit.md +35 -0
  55. package/templates/claude/commands/audit/contract-check.md +21 -0
  56. package/templates/claude/commands/audit/deep-analysis.md +48 -0
  57. package/templates/claude/commands/audit/deps-audit.md +49 -0
  58. package/templates/claude/commands/audit/security-setup.md +35 -0
  59. package/templates/claude/commands/audit/seo-audit.md +63 -0
  60. package/templates/claude/commands/audit/tech-debt-sweep.md +35 -0
  61. package/templates/claude/commands/bug-hunt.md +42 -0
  62. package/templates/claude/commands/claude-md.md +36 -0
  63. package/templates/claude/commands/close-version.md +25 -0
  64. package/templates/claude/commands/context-refresh.md +19 -0
  65. package/templates/claude/commands/context-stats.md +15 -0
  66. package/templates/claude/commands/dashboard.md +66 -0
  67. package/templates/claude/commands/distill-apply.md +19 -0
  68. package/templates/claude/commands/distill-sessions.md +26 -0
  69. package/templates/claude/commands/fleet.md +47 -0
  70. package/templates/claude/commands/forge/forge-audit.md +16 -0
  71. package/templates/claude/commands/forge/forge-budget.md +16 -0
  72. package/templates/claude/commands/forge/forge-deprecate.md +16 -0
  73. package/templates/claude/commands/forge/forge-doctor.md +17 -0
  74. package/templates/claude/commands/forge/forge-eval.md +16 -0
  75. package/templates/claude/commands/forge/forge-fallback-test.md +17 -0
  76. package/templates/claude/commands/forge/forge-killswitch.md +17 -0
  77. package/templates/claude/commands/forge/forge-list.md +17 -0
  78. package/templates/claude/commands/forge/forge-new.md +41 -0
  79. package/templates/claude/commands/forge/forge-policy.md +16 -0
  80. package/templates/claude/commands/forge/forge-redteam.md +17 -0
  81. package/templates/claude/commands/forge/forge-refresh-matrix.md +20 -0
  82. package/templates/claude/commands/forge/forge-route.md +17 -0
  83. package/templates/claude/commands/forge/forge-show.md +16 -0
  84. package/templates/claude/commands/landing-page.md +71 -0
  85. package/templates/claude/commands/log-session.md +59 -0
  86. package/templates/claude/commands/media-gen.md +93 -0
  87. package/templates/claude/commands/new-adr.md +30 -0
  88. package/templates/claude/commands/pipeline/dev-start.md +64 -0
  89. package/templates/claude/commands/pipeline/pipeline.md +36 -0
  90. package/templates/claude/commands/pipeline/resume.md +70 -0
  91. package/templates/claude/commands/pipeline/retro.md +34 -0
  92. package/templates/claude/commands/pipeline/runs.md +63 -0
  93. package/templates/claude/commands/pipeline/ship.md +54 -0
  94. package/templates/claude/commands/pipeline/workflow.md +85 -0
  95. package/templates/claude/commands/playbook.md +27 -0
  96. package/templates/claude/commands/predictions-review.md +28 -0
  97. package/templates/claude/commands/qa/qa-signoff.md +24 -0
  98. package/templates/claude/commands/qa/scaffold-tests.md +27 -0
  99. package/templates/claude/commands/qa/test-plan.md +26 -0
  100. package/templates/claude/commands/qa/visual-test.md +42 -0
  101. package/templates/claude/commands/roadmap.md +48 -0
  102. package/templates/claude/commands/setup/aidevtool-from0.md +104 -0
  103. package/templates/claude/commands/setup/context-config.md +25 -0
  104. package/templates/claude/commands/setup/context-doctor.md +21 -0
  105. package/templates/claude/commands/setup/context-level.md +17 -0
  106. package/templates/claude/commands/setup/setupcontextdevkit.md +121 -0
  107. package/templates/claude/commands/simulate-impact.md +32 -0
  108. package/templates/claude/commands/squad.md +44 -0
  109. package/templates/claude/commands/state.md +21 -0
  110. package/templates/claude/commands/token-report.md +29 -0
  111. package/templates/claude/commands/tune-agents.md +35 -0
  112. package/templates/claude/commands/vcs/claim.md +18 -0
  113. package/templates/claude/commands/vcs/git.md +83 -0
  114. package/templates/claude/commands/vcs/release.md +15 -0
  115. package/templates/claude/commands/vcs/worktree-new.md +18 -0
  116. package/templates/claude/commands/watch.md +47 -0
  117. package/templates/contextkit/.env.example +36 -0
  118. package/templates/contextkit/CLAUDE.child.md.tpl +38 -0
  119. package/templates/contextkit/README.md +74 -0
  120. package/templates/contextkit/behaviors-examples.md +183 -0
  121. package/templates/contextkit/behaviors.md +116 -0
  122. package/templates/contextkit/best-practices.md +323 -0
  123. package/templates/contextkit/config.json +66 -0
  124. package/templates/contextkit/detectors/README.md +45 -0
  125. package/templates/contextkit/detectors/example-detector.mjs.example +25 -0
  126. package/templates/contextkit/instrucoes.md +114 -0
  127. package/templates/contextkit/memory/GLOSSARY.md +13 -0
  128. package/templates/contextkit/memory/SESSIONS.md +9 -0
  129. package/templates/contextkit/memory/WORKSPACE.md +7 -0
  130. package/templates/contextkit/memory/business-rules/_TEMPLATE.md +33 -0
  131. package/templates/contextkit/memory/decisions/0000-record-architecture-decisions.md +34 -0
  132. package/templates/contextkit/memory/decisions/_TEMPLATE.md +25 -0
  133. package/templates/contextkit/memory/predictions/.gitkeep +0 -0
  134. package/templates/contextkit/memory/roadmap.md +28 -0
  135. package/templates/contextkit/memory/sessions/.gitkeep +0 -0
  136. package/templates/contextkit/memory/workflows/.gitkeep +0 -0
  137. package/templates/contextkit/pipeline/backlog/.gitkeep +0 -0
  138. package/templates/contextkit/pipeline/conclusion/.gitkeep +0 -0
  139. package/templates/contextkit/pipeline/devpipeline.md +9 -0
  140. package/templates/contextkit/pipeline/testing/.gitkeep +0 -0
  141. package/templates/contextkit/pipeline/working/.gitkeep +0 -0
  142. package/templates/contextkit/review-protocol.md +214 -0
  143. package/templates/contextkit/runtime/config/defaults.mjs +215 -0
  144. package/templates/contextkit/runtime/config/levels.mjs +42 -0
  145. package/templates/contextkit/runtime/config/load.mjs +105 -0
  146. package/templates/contextkit/runtime/config/paths.mjs +92 -0
  147. package/templates/contextkit/runtime/config/presets.mjs +47 -0
  148. package/templates/contextkit/runtime/config/schema.mjs +88 -0
  149. package/templates/contextkit/runtime/config/settings-compose.mjs +55 -0
  150. package/templates/contextkit/runtime/git-hooks/commit-msg.mjs +55 -0
  151. package/templates/contextkit/runtime/git-hooks/pre-commit.mjs +47 -0
  152. package/templates/contextkit/runtime/git-hooks/pre-push.mjs +102 -0
  153. package/templates/contextkit/runtime/hooks/boot-context-readers.mjs +111 -0
  154. package/templates/contextkit/runtime/hooks/boot-signals.mjs +135 -0
  155. package/templates/contextkit/runtime/hooks/check-registration.mjs +228 -0
  156. package/templates/contextkit/runtime/hooks/concurrency-guard.mjs +110 -0
  157. package/templates/contextkit/runtime/hooks/ledger.mjs +231 -0
  158. package/templates/contextkit/runtime/hooks/md-extract.mjs +65 -0
  159. package/templates/contextkit/runtime/hooks/path-classification.mjs +62 -0
  160. package/templates/contextkit/runtime/hooks/safe-io.mjs +84 -0
  161. package/templates/contextkit/runtime/hooks/session-digest-core.mjs +85 -0
  162. package/templates/contextkit/runtime/hooks/session-start.mjs +248 -0
  163. package/templates/contextkit/runtime/hooks/simulate-gate.mjs +108 -0
  164. package/templates/contextkit/runtime/hooks/track-edits.mjs +154 -0
  165. package/templates/contextkit/runtime/providers/media/_adapter.mjs +120 -0
  166. package/templates/contextkit/runtime/providers/media/nano-banana.mjs +110 -0
  167. package/templates/contextkit/runtime/providers/media/veo.mjs +162 -0
  168. package/templates/contextkit/runtime/providers/review/_adapter.mjs +71 -0
  169. package/templates/contextkit/runtime/providers/review/detect.mjs +115 -0
  170. package/templates/contextkit/runtime/providers/review/gh.mjs +103 -0
  171. package/templates/contextkit/runtime/state/state-io.mjs +172 -0
  172. package/templates/contextkit/runtime/statusline.mjs +51 -0
  173. package/templates/contextkit/squads/README.md +115 -0
  174. package/templates/contextkit/squads/_BRIEFING.md.tpl +27 -0
  175. package/templates/contextkit/squads/agent-forge/README.md +69 -0
  176. package/templates/contextkit/squads/agent-forge/ROADMAP.md +108 -0
  177. package/templates/contextkit/squads/agent-forge/best-practices.md +89 -0
  178. package/templates/contextkit/squads/agent-forge/cli/forge-admin.mjs +132 -0
  179. package/templates/contextkit/squads/agent-forge/cli/forge-eval-cli.mjs +163 -0
  180. package/templates/contextkit/squads/agent-forge/cli/forge-new.mjs +97 -0
  181. package/templates/contextkit/squads/agent-forge/cli/forge-ops.mjs +177 -0
  182. package/templates/contextkit/squads/agent-forge/lib/architect.mjs +112 -0
  183. package/templates/contextkit/squads/agent-forge/lib/eval-designer.mjs +133 -0
  184. package/templates/contextkit/squads/agent-forge/lib/eval-runner.mjs +167 -0
  185. package/templates/contextkit/squads/agent-forge/lib/governance-officer.mjs +178 -0
  186. package/templates/contextkit/squads/agent-forge/lib/package-ops.mjs +101 -0
  187. package/templates/contextkit/squads/agent-forge/lib/packager.mjs +219 -0
  188. package/templates/contextkit/squads/agent-forge/lib/prompt-gen.mjs +122 -0
  189. package/templates/contextkit/squads/agent-forge/lib/rag-designer.mjs +102 -0
  190. package/templates/contextkit/squads/agent-forge/lib/router.mjs +165 -0
  191. package/templates/contextkit/squads/agent-forge/lib/tool-gen.mjs +113 -0
  192. package/templates/contextkit/squads/agent-forge/lib/yaml.mjs +47 -0
  193. package/templates/contextkit/squads/agent-forge/pipeline.yaml +65 -0
  194. package/templates/contextkit/squads/agent-forge/router/capability-matrix.json +112 -0
  195. package/templates/contextkit/squads/agent-forge/router/decision-rules.json +120 -0
  196. package/templates/contextkit/squads/agent-forge/templates/agent-package/.agentforgerc +12 -0
  197. package/templates/contextkit/squads/agent-forge/templates/agent-package/CHANGELOG.md +13 -0
  198. package/templates/contextkit/squads/agent-forge/templates/agent-package/LICENSE +5 -0
  199. package/templates/contextkit/squads/agent-forge/templates/agent-package/README.md +39 -0
  200. package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/go/README.md +10 -0
  201. package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/go/agent.go +14 -0
  202. package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/go/go.mod +3 -0
  203. package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/node/README.md +11 -0
  204. package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/node/index.js +53 -0
  205. package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/node/package.json +9 -0
  206. package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/python/README.md +10 -0
  207. package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/python/agent.py +16 -0
  208. package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/python/pyproject.toml +10 -0
  209. package/templates/contextkit/squads/agent-forge/templates/agent-package/evals/golden.jsonl +1 -0
  210. package/templates/contextkit/squads/agent-forge/templates/agent-package/evals/red-team.jsonl +3 -0
  211. package/templates/contextkit/squads/agent-forge/templates/agent-package/evals/rubric.yaml +14 -0
  212. package/templates/contextkit/squads/agent-forge/templates/agent-package/evals/run-eval.md +17 -0
  213. package/templates/contextkit/squads/agent-forge/templates/agent-package/evals/thresholds.yaml +18 -0
  214. package/templates/contextkit/squads/agent-forge/templates/agent-package/examples/basic.node.md +17 -0
  215. package/templates/contextkit/squads/agent-forge/templates/agent-package/examples/with-fallback.node.md +24 -0
  216. package/templates/contextkit/squads/agent-forge/templates/agent-package/examples/with-rag.python.md +20 -0
  217. package/templates/contextkit/squads/agent-forge/templates/agent-package/governance/audit.schema.json +23 -0
  218. package/templates/contextkit/squads/agent-forge/templates/agent-package/governance/compliance.policy.yaml +43 -0
  219. package/templates/contextkit/squads/agent-forge/templates/agent-package/governance/cost.policy.yaml +36 -0
  220. package/templates/contextkit/squads/agent-forge/templates/agent-package/governance/fallback-chain.yaml +16 -0
  221. package/templates/contextkit/squads/agent-forge/templates/agent-package/governance/quality.policy.yaml +43 -0
  222. package/templates/contextkit/squads/agent-forge/templates/agent-package/manifest.yaml +91 -0
  223. package/templates/contextkit/squads/agent-forge/templates/agent-package/prompts/system.anthropic.md +19 -0
  224. package/templates/contextkit/squads/agent-forge/templates/agent-package/prompts/system.canonical.md +25 -0
  225. package/templates/contextkit/squads/agent-forge/templates/agent-package/prompts/system.deepseek.md +21 -0
  226. package/templates/contextkit/squads/agent-forge/templates/agent-package/prompts/system.google.md +19 -0
  227. package/templates/contextkit/squads/agent-forge/templates/agent-package/prompts/system.ollama.md +21 -0
  228. package/templates/contextkit/squads/agent-forge/templates/agent-package/prompts/system.openai.md +20 -0
  229. package/templates/contextkit/squads/agent-forge/templates/agent-package/rag/config.yaml +17 -0
  230. package/templates/contextkit/squads/agent-forge/templates/agent-package/rag/index/.gitkeep +3 -0
  231. package/templates/contextkit/squads/agent-forge/templates/agent-package/rag/ingestion/chunker.config.yaml +6 -0
  232. package/templates/contextkit/squads/agent-forge/templates/agent-package/rag/ingestion/sources.yaml +8 -0
  233. package/templates/contextkit/squads/agent-forge/templates/agent-package/rag/retrieval/query-template.md +16 -0
  234. package/templates/contextkit/squads/agent-forge/templates/agent-package/rag/retrieval/rerank.config.yaml +6 -0
  235. package/templates/contextkit/squads/agent-forge/templates/agent-package/tools/adapters/anthropic.tools.json +11 -0
  236. package/templates/contextkit/squads/agent-forge/templates/agent-package/tools/adapters/deepseek.tools.json +14 -0
  237. package/templates/contextkit/squads/agent-forge/templates/agent-package/tools/adapters/google.tools.json +11 -0
  238. package/templates/contextkit/squads/agent-forge/templates/agent-package/tools/adapters/ollama.tools.json +14 -0
  239. package/templates/contextkit/squads/agent-forge/templates/agent-package/tools/adapters/openai.tools.json +14 -0
  240. package/templates/contextkit/squads/agent-forge/templates/agent-package/tools/schemas.canonical.json +25 -0
  241. package/templates/contextkit/starters/tanstack/README.md +86 -0
  242. package/templates/contextkit/starters/tanstack/index.html +12 -0
  243. package/templates/contextkit/starters/tanstack/package.json +25 -0
  244. package/templates/contextkit/starters/tanstack/src/main.tsx +40 -0
  245. package/templates/contextkit/starters/tanstack/src/router.tsx +12 -0
  246. package/templates/contextkit/starters/tanstack/src/routes/__root.tsx +10 -0
  247. package/templates/contextkit/starters/tanstack/src/routes/index.tsx +17 -0
  248. package/templates/contextkit/starters/tanstack/tsconfig.json +19 -0
  249. package/templates/contextkit/starters/tanstack/vite.config.ts +10 -0
  250. package/templates/contextkit/tools/scripts/adr-digest-core.mjs +42 -0
  251. package/templates/contextkit/tools/scripts/adr-digest.mjs +78 -0
  252. package/templates/contextkit/tools/scripts/agent-tuning.mjs +74 -0
  253. package/templates/contextkit/tools/scripts/aiso-audit.mjs +174 -0
  254. package/templates/contextkit/tools/scripts/audit-shared.mjs +129 -0
  255. package/templates/contextkit/tools/scripts/claim.mjs +133 -0
  256. package/templates/contextkit/tools/scripts/claude-md.mjs +123 -0
  257. package/templates/contextkit/tools/scripts/clean-drive.mjs +78 -0
  258. package/templates/contextkit/tools/scripts/context-config.mjs +111 -0
  259. package/templates/contextkit/tools/scripts/context-level.mjs +98 -0
  260. package/templates/contextkit/tools/scripts/context-pack.mjs +120 -0
  261. package/templates/contextkit/tools/scripts/contract-scan.mjs +186 -0
  262. package/templates/contextkit/tools/scripts/dashboard-data.mjs +198 -0
  263. package/templates/contextkit/tools/scripts/dashboard-html.mjs +215 -0
  264. package/templates/contextkit/tools/scripts/dashboard-server.mjs +129 -0
  265. package/templates/contextkit/tools/scripts/dashboard.mjs +107 -0
  266. package/templates/contextkit/tools/scripts/deep-analysis.mjs +62 -0
  267. package/templates/contextkit/tools/scripts/deps-audit.mjs +201 -0
  268. package/templates/contextkit/tools/scripts/detect-stack.mjs +164 -0
  269. package/templates/contextkit/tools/scripts/distill-detect.mjs +90 -0
  270. package/templates/contextkit/tools/scripts/doctor.mjs +165 -0
  271. package/templates/contextkit/tools/scripts/fleet.mjs +170 -0
  272. package/templates/contextkit/tools/scripts/generate-context.mjs +142 -0
  273. package/templates/contextkit/tools/scripts/gh-alerts.mjs +117 -0
  274. package/templates/contextkit/tools/scripts/git.mjs +97 -0
  275. package/templates/contextkit/tools/scripts/home.mjs +106 -0
  276. package/templates/contextkit/tools/scripts/mark-simulation.mjs +78 -0
  277. package/templates/contextkit/tools/scripts/media-gen.mjs +154 -0
  278. package/templates/contextkit/tools/scripts/pipeline-board.mjs +74 -0
  279. package/templates/contextkit/tools/scripts/pipeline-prioritize.mjs +68 -0
  280. package/templates/contextkit/tools/scripts/pipeline-session.mjs +99 -0
  281. package/templates/contextkit/tools/scripts/pipeline-validate.mjs +136 -0
  282. package/templates/contextkit/tools/scripts/pipeline.mjs +302 -0
  283. package/templates/contextkit/tools/scripts/playbook.mjs +123 -0
  284. package/templates/contextkit/tools/scripts/predictions-review.mjs +113 -0
  285. package/templates/contextkit/tools/scripts/release.mjs +60 -0
  286. package/templates/contextkit/tools/scripts/resume.mjs +114 -0
  287. package/templates/contextkit/tools/scripts/roadmap.mjs +86 -0
  288. package/templates/contextkit/tools/scripts/runs.mjs +116 -0
  289. package/templates/contextkit/tools/scripts/seo-audit.mjs +150 -0
  290. package/templates/contextkit/tools/scripts/session-digest.mjs +89 -0
  291. package/templates/contextkit/tools/scripts/session-reindex.mjs +91 -0
  292. package/templates/contextkit/tools/scripts/setup-complete.mjs +69 -0
  293. package/templates/contextkit/tools/scripts/squad-meta.mjs +23 -0
  294. package/templates/contextkit/tools/scripts/squad-pipeline-condition.mjs +192 -0
  295. package/templates/contextkit/tools/scripts/squad-pipeline.mjs +301 -0
  296. package/templates/contextkit/tools/scripts/squad.mjs +80 -0
  297. package/templates/contextkit/tools/scripts/stats.mjs +138 -0
  298. package/templates/contextkit/tools/scripts/sync-check.mjs +235 -0
  299. package/templates/contextkit/tools/scripts/tech-debt-detectors.mjs +76 -0
  300. package/templates/contextkit/tools/scripts/tech-debt-scan.mjs +164 -0
  301. package/templates/contextkit/tools/scripts/token-report.mjs +153 -0
  302. package/templates/contextkit/tools/scripts/visual-test.mjs +132 -0
  303. package/templates/contextkit/tools/scripts/watch.mjs +106 -0
  304. package/templates/contextkit/tools/scripts/workflow.mjs +136 -0
  305. package/templates/contextkit/tools/scripts/workspace-sync.mjs +220 -0
  306. package/templates/contextkit/tools/scripts/worktree-new.mjs +50 -0
  307. package/templates/contextkit/workflows/L1-static-loading.md +59 -0
  308. package/templates/contextkit/workflows/L2-session-ledger.md +86 -0
  309. package/templates/contextkit/workflows/L3-multi-session.md +80 -0
  310. package/templates/contextkit/workflows/L4-squads.md +68 -0
  311. package/templates/contextkit/workflows/L5-proactive.md +88 -0
  312. package/templates/contextkit/workflows/README.md +47 -0
  313. package/templates/contextkit/workflows/playbooks/distillation-cycle.md +74 -0
  314. package/templates/contextkit/workflows/playbooks/landing-page.md +197 -0
  315. package/templates/contextkit/workflows/playbooks/security-batch.md +68 -0
  316. package/templates/contextkit/workflows/playbooks/seo-aiso.md +288 -0
  317. package/templates/contextkit/workflows/playbooks/simulate-impact.md +83 -0
  318. package/templates/contextkit/workflows/playbooks/tanstack.md +164 -0
  319. package/templates/contextkit/workflows/playbooks/tech-debt-sweep.md +77 -0
  320. package/templates/docs/CHANGELOG.md.tpl +11 -0
  321. package/templates/gitattributes +3 -0
  322. package/templates/github/ISSUE_TEMPLATE/bug_report.md +30 -0
  323. package/templates/github/ISSUE_TEMPLATE/feature_request.md +22 -0
  324. package/templates/github/PULL_REQUEST_TEMPLATE.md +27 -0
  325. package/templates/github/dependabot.yml +27 -0
  326. package/templates/github/workflows/quality.yml +36 -0
  327. package/templates/github/workflows/security.yml +54 -0
  328. package/tools/install/cli.mjs +62 -0
  329. package/tools/install/fs.mjs +56 -0
  330. package/tools/install/git.mjs +114 -0
  331. package/tools/install/project.mjs +51 -0
  332. package/tools/install/uninstall.mjs +54 -0
  333. package/tools/integration-test-compozy.mjs +88 -0
  334. package/tools/integration-test-guards.mjs +269 -0
  335. package/tools/integration-test-tooling-agent-forge.mjs +189 -0
  336. package/tools/integration-test-tooling-pipeline.mjs +164 -0
  337. package/tools/integration-test-tooling.mjs +172 -0
  338. package/tools/integration-test.mjs +228 -0
  339. package/tools/it-helpers.mjs +60 -0
  340. package/tools/selfcheck-agent-forge-ops.mjs +107 -0
  341. package/tools/selfcheck-agent-forge.mjs +304 -0
  342. package/tools/selfcheck-config.mjs +80 -0
  343. package/tools/selfcheck-runtime.mjs +135 -0
  344. package/tools/selfcheck-source.mjs +326 -0
  345. package/tools/selfcheck.mjs +268 -0
@@ -0,0 +1,385 @@
1
+ # Architecture & Roadmap
2
+
3
+ An architect's view of where ContextDevKit is, what it learned from the production
4
+ system it was distilled from (the "Ruiva" project's `devAItools/`), and where it
5
+ goes next.
6
+
7
+ > **Status key.** Every roadmap item carries a marker, kept current as work moves:
8
+ > ✅ **done** (shipped/implemented) · ⏳ **in progress** (being executed in a session
9
+ > right now) · 🟡 **partial / awaiting input** (started, or blocked on external data —
10
+ > not actively in a session) · 📋 **planned** (not started) · ➖ **dropped**
11
+ > (intentionally not ported). **Process:** when a session picks up an item, mark it
12
+ > ⏳; when it ships, switch it to ✅.
13
+
14
+ ## Lineage
15
+
16
+ ContextDevKit is the **generalized, stack-agnostic distillation** of a real
17
+ single-project AI dev platform. That source system was deeply coupled to its
18
+ stack (Cloudflare Workers + Hono + Expo + Drizzle) and domain (LGPD). The kit
19
+ keeps the *engine and the discipline*, drops the *stack-specific content*, and
20
+ adds a **level system** so adoption is gradual.
21
+
22
+ ## What was ported (and how it was generalized)
23
+
24
+ | Source capability | In the kit | Generalization |
25
+ | --- | --- | --- |
26
+ | Session ledger + drift hooks | ✅ L2 | path classification is **config-driven** (any stack) |
27
+ | Boot context injection | ✅ L1 | reads kit-canonical paths; project-name auto-detected |
28
+ | Multi-session (claims, worktrees, indices) | ✅ L3 | unchanged in spirit |
29
+ | Squad of agents | ✅ L4 | shipped as stack-agnostic archetypes + `_TEMPLATE` |
30
+ | L5 simulate-impact gate | ✅ L5 | `highRiskPaths` configurable |
31
+ | Deterministic tech-debt detectors | ✅ L5 | regex detectors generalized (JS/TS/py + React) |
32
+ | Contract drift gate | ✅ L5/L6 | `contractGlobs` declares the surface; export-diff |
33
+ | Session telemetry | ✅ L6 | `stats.mjs` (drift rate, cadence, ADRs) |
34
+ | Auto-distill loop | ✅ L5/L6 | `/distill-sessions` + `/distill-apply` + `/retro` |
35
+ | Config + Zod schema | ✅ | **zero-dep loader** on the hot path; zod optional |
36
+ | Zod-coupled hooks | ➖ removed | hooks must run on a fresh project with no installs |
37
+
38
+ ## The new layer — L6: Autonomy & Insight
39
+
40
+ L1–L3 buy **context fidelity** (the platform never forgets). L4–L5 buy **quality
41
+ governance** (review, tests, gates). The missing frontier is making the platform
42
+ *act and learn*, not just remember and enforce. That's **L6**:
43
+
44
+ - **Insight** — `stats.mjs` / `/context-stats`: drift rate, cadence, ADR/agent
45
+ counts. You can't improve a practice you don't measure.
46
+ - **Autonomy** — `/ship`: an orchestrated pipeline that drives the whole squad
47
+ (architect → implement → code-review → QA → record) with human checkpoints.
48
+ This is "a full team of capable agents", coordinated, not ad hoc.
49
+ - **Learning loop** — `/retro`: turns recurring drift/debt/patterns into concrete
50
+ governance (new CLAUDE.md rules, ADRs, config tweaks). The platform gets
51
+ smarter *about this project* over time.
52
+
53
+ L6 adds no new Claude hook (same wiring as L5) — it's a **capability tier**:
54
+ commands + metrics + orchestration on top of the L5 gates.
55
+
56
+ ## Honest gaps / not yet ported
57
+
58
+ - **Contract drift: regex by default, AST optional.** The regex extractor covers the
59
+ common JS/TS forms (named/declaration exports incl. `declare`/`abstract`/generators,
60
+ `export default`, namespace re-exports `export * [as N] from`, type-only
61
+ `export type { … }`). For AST precision, install `acorn` (or set `CONTEXT_CONTRACT_PARSER`):
62
+ `contract-scan` uses it **only if importable**, so the zero-dep default holds. Residual:
63
+ still "signal, not proof" for exotic TS without a TS-aware parser. [→ ADR-0003]
64
+
65
+ _The earlier gaps have since shipped: **two-tier briefings** (v1.1.0,
66
+ `/squad brief`), **workflow docs/playbooks** (`contextkit/workflows/`), and the
67
+ **predictions review cadence** (`/predictions-review`)._
68
+
69
+ ## 1.0 — harden & prove ✅ SHIPPED (2026-05-22 · npm `contextdevkit@1.0.0`)
70
+
71
+ L6 was reached in a single quarter; **1.0 earned it by hardening, not adding
72
+ levels**:
73
+
74
+ 1. ✅ **Froze the surface.** Thin wrappers (`/state`, `/context-doctor`,
75
+ `/context-refresh`) deprecated toward `/audit`; `/release` paired with `/claim`.
76
+ 2. 🟡 **Prove the value of each level.** Tooling shipped (`/context-stats`, analysis →
77
+ backlog); still needs **real-world data** to confirm L4–L6 earn their keep —
78
+ the one item that needs *usage*, not code. *Ongoing.*
79
+ 3. ✅ **Ate our own dog food.** `install.mjs` refactored 487 → 234 (out of the RED
80
+ zone); a `tech-debt-scan --ci` gate keeps it green in CI.
81
+ 4. ✅ **Locked the public contracts.** Documented in `CONTRIBUTING.md`; changes
82
+ need an ADR + `/contract-check`.
83
+ 5. ✅ **Deepened the thin spots.** `qa-unit` / `qa-perf` / `qa-e2e` got anti-pattern
84
+ tables; `architect`↔`security` and `test-engineer`↔`qa-orchestrator` clarified.
85
+ 6. ✅ **Dependency & supply-chain control.** `/deps-audit` + the **security-team**
86
+ (`security` AppSec · `infra-security` IaC/cloud · `devops` delivery).
87
+
88
+ **Also delivered in 1.0:** standardized **WSJF (SAFe) prioritization + bug severity
89
+ (S1–S4) + SLA** with a **known-bugs map** in the DevPipeline; **`/deep-analysis`**
90
+ (global sweep → report → ADRs → backlog); an **active security-mode** boot trigger
91
+ (runs every N sessions, on by default); and the **`business-rules/`** memory folder.
92
+
93
+ ## Next — post-1.0 focus: ancestor parity
94
+
95
+ Complete the distillation from the source platform (`app-ruivo/devAItools`) — the
96
+ three pieces deliberately flattened pre-1.0 (see *Honest gaps*). **All three are now
97
+ shipped** (✅ below):
98
+
99
+ - ✅ **`memory/predictions/`** — `/simulate-impact` writes a prediction file per run;
100
+ `/predictions-review` (auto-run by `/log-session`) closes the loop, filling each
101
+ file's *Actual* section from the ledger (changed vs predicted paths, both deltas).
102
+ *Shipped: write half in v1.1.0; predicted-vs-actual review closed here.*
103
+ - ✅ **Two-tier squad briefings** — `contextkit/squads/<team>/<agent>.md` rich briefings
104
+ behind the lean `.claude/agents/` agents. *Shipped v1.1.0: `/squad brief <agent>`
105
+ scaffolds a briefing, `/squad list` shows coverage.*
106
+ - ✅ **`workflows/playbooks/`** — per-level workflow docs (L1–L5) + reusable playbooks
107
+ (tech-debt sweep, simulate-impact, distillation, security batch). *Shipped:
108
+ installed under `contextkit/workflows/`, seeded write-if-missing. The foundation for
109
+ **playbook management** (Future directions #8).*
110
+
111
+ ## Then — supply-chain & code security (deepen the security-team)
112
+
113
+ 1.0 shipped the *foundation*: the **security-team** (`security` AppSec · `infra-security`
114
+ IaC/cloud · `devops` delivery) and `/deps-audit` (lockfile/pinning + native CVE audit →
115
+ backlog). Two things are still missing — a **code-facing** lane (today's agents own
116
+ auth/secrets and the *platform*, not the code's exposure *through* its dependencies and
117
+ third-party integrations) and any **GitHub-native** automation (the kit ships no `.github/`
118
+ scaffolding). Three moves, all on the existing rails:
119
+
120
+ - ✅ **`code-security` agent** — a security-team **sub-specialist** (mirrors `infra-security`,
121
+ no overlap with the `security` AppSec lead). Lane: the code's *external* attack surface —
122
+ third-party integration code (API clients / SDK usage, webhook & callback handling,
123
+ (de)serialization of external responses), dependency **provenance / SBOM**, and SAST /
124
+ CodeQL findings. Lean agent under `.claude/agents/` + a two-tier briefing in
125
+ `contextkit/squads/security-team/`.
126
+ - ✅ **Dependency control of the system** — grow `/deps-audit` from "CVEs + loose ranges" into a
127
+ real **dependency policy**: license allow/deny + SBOM generation, lockfile-drift detection,
128
+ unmaintained / abandoned-package flags, and a scheduled (not just on-demand) sweep. Policy
129
+ lives in `contextkit/config.json` (allowed licenses, max package age, pinning rules); findings
130
+ still flow into the DevPipeline backlog like every other finding.
131
+ - ✅ **GitHub / Dependabot integration** — the kit scaffolds **`.github/dependabot.yml`** + a
132
+ **security workflow** (CodeQL + `dependency-review` on PRs + the `/deps-audit` gate),
133
+ ecosystem auto-detected, via `/security-setup` (or folded into `/setupcontextdevkit`). The
134
+ *loop-closer* (the on-brand half): a sync pulls **Dependabot / GitHub security alerts**
135
+ (`gh api`) into the **same backlog**, where the `code-security` agent triages reachability —
136
+ so GitHub's alerts become prioritized, owned tasks instead of an ignored tab.
137
+
138
+ **Stays inside the invariants:** the `.github/` files, SBOM and CodeQL run in the *project's*
139
+ CI, never on the kit's zero-dep hot path; the PR security workflow is **advisory by default**
140
+ (opt into blocking); everything is plain files (`dependabot.yml`, workflow YAML, findings
141
+ JSON) and **config-driven** (ecosystems + license policy in `config.json`).
142
+
143
+ ✅ **Shipped** — the `code-security` agent (security-team sub-specialist),
144
+ `/deps-audit` grown with license policy + CycloneDX SBOM (`--sbom`) + lockfile-drift
145
+ and a `deps` config block, `.github/` scaffolding (Dependabot + an advisory
146
+ `security.yml`), and `gh-alerts.mjs` (GitHub alerts → DevPipeline backlog) behind a
147
+ new `/security-setup`. *Deferred:* registry-backed staleness, scheduled alert-sync,
148
+ required-check enforcement.
149
+
150
+ ## L7 — Ecosystem & Scale (the former "Future directions", now shipped)
151
+
152
+ These were the *candidate L7+* items. With **v1.3.0** they ship as the **L7 capability
153
+ tier** (`/context-level 7`) — cross-cutting capabilities layered on top of L6, **no new
154
+ hook** (same pattern as L6; see ADR-0008). Items #2–#8 are the L7 set; #1 shipped earlier.
155
+
156
+ 1. ✅ **Design / Product / Ops squads** — **Shipped in v0.5.2:** `compliance-team`
157
+ (LGPD), `design-team` (UX/UI/a11y), plus `product-owner` / `devops` starters,
158
+ organized by a `contextkit/squads/` manifest with a sovereignty rule. The squad
159
+ pattern is proven; further families (docs/data/growth/support) follow it.
160
+ 2. ✅ **Fleet mode (MVP).** One control plane over many repos via `/fleet` +
161
+ `fleet.mjs` — registry at `~/.contextdevkit/fleet.json`; aggregate `stats` / `audit`
162
+ across a portfolio; detect CLAUDE.md rule drift (`propagate --check`, detect-only).
163
+ *Deferred: auto-applying rule edits across repos; remote repos.*
164
+ 3. ✅ **Outcome-driven agent tuning (MVP).** `/tune-agents` + `agent-tuning.mjs`
165
+ aggregate per-agent signals (briefing coverage, usage) and **propose** briefing
166
+ refinements (mirrors `/distill-sessions`; applies nothing). *Deferred: a closed
167
+ auto-loop + real per-agent outcome capture (PR-review / test attribution).*
168
+ 4. ✅ **Editor/CI surfaces (MVP).** Status-line widget (`statusline.mjs`, wired as
169
+ `settings.statusLine`, preserves a user's own) + a **quality CI workflow**
170
+ (`contract-scan --ci` + `tech-debt --ci`, shipped to `.github/workflows/`).
171
+ *Deferred: the Claude-driven PR-review bot (needs Claude in CI); making the
172
+ checks **required** is a branch-protection setting, not code.*
173
+ 5. ✅ **Pluggable detectors & language packs (MVP).** Drop-in detectors from
174
+ `contextkit/detectors/*.mjs` (loaded by `tech-debt-scan`) + stack **presets**
175
+ (`install.mjs --preset next|go|python`, merged into config). *Deferred: a larger
176
+ preset library.*
177
+ 6. ✅ **Diverse & visual testing harness (MVP).** `/visual-test` + `visual-test.mjs`
178
+ **scaffold** a browser-driven, visual layer (screenshot / visual-regression) for
179
+ the detected stack — **Playwright JS** (`@playwright/test`) + **Python**
180
+ (pytest-playwright); `status` detects an existing harness. Owned by `qa-e2e`
181
+ (+ `design-team` for baselines), wired into `/scaffold-tests`, `/qa-signoff`, and
182
+ the `/ship` gate. The runner is a **project** dependency (the kit scaffolds, never
183
+ bundles/runs browsers) — true to the zero-dep hot-path invariant. *Deferred:
184
+ running browsers in the kit's own CI; real baselines/diffing; a hosted diff service.*
185
+ 7. ✅ **Token economy & usage insight.** *Shipped (first cut):* `/token-report` +
186
+ `token-report.mjs` read Claude Code's local session transcripts and aggregate
187
+ **per-session token usage** (input / output / cache) and **per ISO week**, with a
188
+ configurable **budget** (`tokens.budgetPerSession`) that flags hot sessions — the
189
+ cost extension of L6 **Insight**. Read-only, local, zero-dep, aggregated counts
190
+ only. Next refinements (not yet done): per-agent/command breakdown and feeding the
191
+ data into automated optimization hints.
192
+ 8. ✅ **Playbook management.** *Shipped:* the `workflows/playbooks/` foundation is now a
193
+ **managed, runnable** layer — `playbook.mjs` + **`/playbook`** to **list** the
194
+ registry (discover what exists), **show** a procedure, and **run** one (records a
195
+ tracked entry in `contextkit/memory/playbook-runs.md`, then prints the steps to
196
+ execute). `/ship` and the squads can `run` a playbook instead of restating it.
197
+ Turns repeatable procedures into first-class, auditable assets — same "plain files,
198
+ advisory, inspectable" posture as the rest of the kit.
199
+
200
+ ## Next — DevPipeline `working/` stage + declarative squad pipelines (ADR-0015)
201
+
202
+ A single ADR opens two adjacent moves, sharing one substrate (`state.json` per
203
+ in-flight item). Inspired by a read of [opensquad](https://github.com/renatoasse/opensquad)'s
204
+ declarative pipeline, *not* a copy — the kit's zero-dep + model-router + simulate-impact
205
+ invariants reshape the grammar (no full expression eval, no vendor model names, opt-in
206
+ per squad, dry-run as a first-class mode).
207
+
208
+ - 📋 **DevPipeline gains a `working/` stage** (task **037**, ADR-0015 §B). Today
209
+ `testing/` carries two meanings — "actively being worked on" and "code written,
210
+ awaiting QA". That conflation hides cross-session conflicts: session A can be
211
+ hammering on task `031` while session B has no idea unless A manually `/claim`ed
212
+ the right paths. The new stage holds **only WIP**; `testing/` reclaims its
213
+ sign-off meaning. `/pipeline start <id>` and `/pipeline stop <id>` move tasks
214
+ in/out; the workspace record (`.claude/.workspace/<sid>.json`) gains a `tasks[]`
215
+ array so the dashboard surfaces *which session owns which task, right now*. Stale
216
+ auto-eviction (default 90m without a heartbeat) keeps the lane honest. The
217
+ pre-push hook already refuses cross-session conflicts on paths; ADR-0015 extends
218
+ it to task ids.
219
+ - 📋 **Declarative `pipeline.yaml` per squad + engine** (task **036**, ADR-0015 §A).
220
+ Optional file per squad declaring steps, `condition`, `on_reject`,
221
+ `max_review_cycles`, `model_tier`, `execution`, and `type: checkpoint`. Parsed
222
+ via `lib/yaml.mjs` (ADR-0013 optional dynamic import); engine refuses *with a
223
+ clear message* when `yaml` is absent — pipelines are opt-in, not a hot-path
224
+ feature. First consumer is `agent-forge` (Fase 6); `/ship` adopts the same DSL
225
+ when ready. Dry-run is a first-class mode — `squad-pipeline.mjs <squad>
226
+ --dry-run` prints the would-be execution order so `/simulate-impact` can map
227
+ pipeline-edit blast radius before changes ship.
228
+ - 📋 **Canonical `state.json` substrate** (task **038**, ADR-0015 §C). One schema
229
+ for both "task in flight" and "pipeline run", recording owner session/user/branch,
230
+ current step, heartbeat, retry cycles. Forge Stats v2 reads it for success rate
231
+ + retry distribution; `/runs` (task **039**) lists the last N across squads.
232
+
233
+ **Stays inside the invariants:** the DSL is opt-in per squad, hot-path stays
234
+ zero-dep (yaml only behind the sanctioned optional import), and `condition`
235
+ accepts a whitelisted grammar — no arbitrary expression evaluation.
236
+
237
+ ## Next — GitHub sync awareness in the dev flow (ADR-0026)
238
+
239
+ The boot banner already shows **branch/commit** divergence (`checkGitDivergence`)
240
+ and the 20 most-recent remote branches (`activeBranches`), and `pre-push` blocks
241
+ real conflicts. The missing layer is **PR awareness** — nothing asks GitHub
242
+ "what PRs are open, which are awaiting CI/review, is there already a PR for this
243
+ branch?". Two moments are PR-blind: starting work (`/dev-start`) and opening a
244
+ PR (`/git pr`).
245
+
246
+ - ⏳ **`sync-check.mjs` — `preflight` + `prepr` modes** (ADR-0026). One zero-dep
247
+ script. `preflight` (run by `/dev-start`, before scope-lock): ahead/behind,
248
+ recent branches, and **open PRs with CI/review status**, flagging PRs
249
+ *awaiting status* that may overlap the objective. `prepr` (run by `/git pr`,
250
+ before push): re-check divergence vs `main` and **detect a duplicate open PR**
251
+ for the current branch. `gh` is optional — absent/unauthed degrades to the
252
+ git-only half and reports the PR check as **skipped, never a pass** (Rule 8);
253
+ offline ⇒ silent exit 0.
254
+ - ⏳ **Wiring** — `/dev-start` gains a step 0 (preflight) and `/git pr` a
255
+ pre-step (prepr). PR queries stay **off** the `SessionStart` hot path (network
256
+ + `gh` auth would violate the never-block invariant, Rule 2).
257
+
258
+ **Stays inside the invariants:** zero-dep script, `gh` optional with a graceful
259
+ skip, PR discovery only in explicit opt-in commands (never the hot path), and
260
+ the script is read-only — it never creates, edits, or merges a PR.
261
+
262
+ *Deferred:* `glab` (GitLab) parity, a PR line in `/git status`, a `--watch`
263
+ checks poll, and a latency cache.
264
+
265
+ ## Token economy: the digest layer (ADR-0027) — ✅ SHIPPED (PR #41, 2026-06-03)
266
+
267
+ The kit already **measures** token usage (`/token-report` + `token-report.mjs`,
268
+ roadmap #7) but has no **reducer**. A measurement pass over the 65 command files +
269
+ the boot hook found the lever: in this kit, tokens are spent when *the AI reads
270
+ files and reasons*, and a cluster of high-value commands still makes the AI ingest
271
+ **full raw markdown** instead of a pre-digested view — the biggest single-run cost
272
+ being the periodic L5/L6 commands that read the **last ~10 session logs raw**
273
+ (~1,100–1,300 lines ≈ 13–16K tokens *before reasoning*), and the highest-frequency
274
+ cost being the **boot banner injecting 60 raw lines of the last session every
275
+ session**. ADR-0027 adds a deterministic, zero-dep **digest layer** that pre-digests
276
+ the two artifacts the AI re-reads most (session logs, ADRs) so it reasons over
277
+ compact output. Estimated **~120–200K input tokens/week** saved on an active project
278
+ (full per-command estimate + assumptions in
279
+ [docs/token-economy-plan.md](token-economy-plan.md)).
280
+
281
+ - ✅ **Shared single-source extractor** (ADR-0027 §1). Shipped as
282
+ `runtime/hooks/md-extract.mjs` (generic markdown primitives) +
283
+ `runtime/hooks/session-digest-core.mjs` (session parser) — flat-module
284
+ convention, not a `lib/digest/` dir; reused by the boot hook and the script
285
+ wrappers, no duplicated parsing (Rule 4).
286
+ - ✅ **`session-digest.mjs`** (ADR-0027 §2). Session logs → ~6-line structured
287
+ digest (`--last N` / `--id` / `--json`). Rewired `/distill-sessions` + `/retro`
288
+ to read digests, not raw logs — the **biggest single-run wins**.
289
+ - ✅ **`adr-digest.mjs`** (ADR-0027 §3). An ADR catalog (status · title · one-line
290
+ decision) + `--search`. Replaces "read 3–5 ADRs to find the relevant one" with
291
+ "read the catalog, open at most one". Wired into `/ship`, `/new-adr`
292
+ (dup-decision check), `/deep-analysis`.
293
+ - ✅ **`context-pack.mjs`** (ADR-0027 §4). One bounded "start of work" bundle
294
+ (latest-session digest + `[Unreleased]` + immutable rules + open backlog +
295
+ recent ADRs) that collapses the 3–5 sequential reads in `/dev-start`, `/state`,
296
+ `/ship` into **one script call** — fewer tokens *and* fewer round-trips.
297
+ - ✅ **Boot hook digest** (ADR-0027 §5). `session-start.mjs` emits a ~6-line
298
+ digest for "Last registered session" instead of 60 raw lines, **falling back to
299
+ the raw-truncated output on any parse miss** (Rule 2/8 — degrade, never break).
300
+ The highest-frequency saving (every session).
301
+
302
+ **Stays inside the invariants:** no new hook and no new dependency (plain scripts +
303
+ one shared pure module); digests are **deterministic extraction**, not AI-written
304
+ summaries (reproducible, free); a digest miss is a **visible raw-fallback**, never a
305
+ silent drop; each slice ships with a `selfcheck`/`integration-test` assertion and is
306
+ re-measured against `/token-report`.
307
+
308
+ *Deferred:* per-command/agent token attribution in `/token-report`; a DevPipeline
309
+ board digest for `/pipeline`; an mtime-keyed digest cache if extraction cost ever shows.
310
+
311
+ ## Next — Proactive Advisor: a six-lane improvement engine (ADR-0028)
312
+
313
+ The kit ships strong *individual* analysis surfaces but no single capability that
314
+ reads the project and — **proactively, not reactively** — surfaces improvement
315
+ suggestions **before and after each change**, classified into six lanes:
316
+ **architecture · features · deepen existing · security · UX · growth/retention**.
317
+ A sweep mapped each: architecture and security are strong and (for security)
318
+ already proactive; features and UX exist but are reactive; **two lanes have no
319
+ owner at all** — *deepen existing features* and *growth/retention* (only
320
+ acquisition exists, via `seo-specialist`). And nothing **aggregates** the lanes or
321
+ fires automatically at the end of a change.
322
+
323
+ - ✅ **Core shipped** — `/advise`, the aggregator. Two modes (`--before <objective>`
324
+ = opportunities + risks; `--after` = improvements, scoped to the changed surface),
325
+ an optional `--lane <id>` filter. It **delegates** to the owning agent per lane
326
+ (`/analyze-code-ia-practices`, `/deep-analysis`, `/roadmap`, the design-team) —
327
+ it never re-implements them — and feeds every surviving finding into the
328
+ DevPipeline backlog tagged `advise:<lane>`. It does not edit code.
329
+ - ✅ **Single-sourced taxonomy** — `advisor.lanes` in config maps each lane to an
330
+ `owner`; `deepen` and `growth` ship as declared `owner: null` **seams** that
331
+ `/advise` surfaces as *skipped — no owner*, never faked (rule 8/9).
332
+ - ✅ **Proactive trigger** — the Stop hook (`check-registration.mjs`) nudges
333
+ `/advise` after a productive session (≥ 2 important paths touched, debounced 24h,
334
+ config-gated) — the "after each implementation" moment. Mirrors the `securityMode`
335
+ posture: active by default, silent otherwise, never blocks (Rule 2).
336
+
337
+ **Stays inside the invariants:** the expensive fan-out lives in the command, never
338
+ the hot path; the Stop nudge is cheap, zero-dep, debounced, exit-0-on-error; the
339
+ lane → owner map is config-driven; unowned lanes degrade to a visible skip.
340
+
341
+ - ✅ **Both seams filled — 6/6 lanes owned.** The **`growth-team`** squad shipped
342
+ (`growth` lead + `retention`, with the shared `seo-specialist` for acquisition)
343
+ wired to `growth.owner`; and **`deepen`** got an owner — the `product-owner`
344
+ **depth lens** (maturing existing features, distinct from greenfield `features`).
345
+
346
+ *Deferred:* a `--since <ref>` diff scope for `--after`; optional two-tier briefings
347
+ for `growth` / `retention`; feeding recurring advisor findings into `/retro`.
348
+
349
+ ## Next — Behavioral discipline layer (ADR-0029)
350
+
351
+ A review of the MIT-licensed [`andrej-karpathy-skills`](https://github.com/multica-ai/andrej-karpathy-skills)
352
+ repo surfaced a clean asymmetry: the kit is strong on the **structural** layer
353
+ (*what good code looks like* — `best-practices.md`, the constitution) and on
354
+ governance, but **thin on the *behavioral* layer** (*how the agent acts while
355
+ producing the diff*). Karpathy's four principles mapped to: ✅ *Simplicity first*
356
+ (had it, §9), 🟡 *Surgical changes* (only inside `/dev-start`), 🟡 *Goal-driven*
357
+ (tools but no rule), ❌ *Think before coding* (**no rule told the agent to surface
358
+ assumptions and ask when ambiguous before coding** — the biggest gap).
359
+
360
+ - ✅ **`behaviors.md` + `behaviors-examples.md`** — the behavioral sibling of
361
+ `best-practices.md`: the four guidelines (think-before-coding · simplicity ·
362
+ surgical · goal-driven) with Do/Don't + a "Fits the kit" map, plus before/after
363
+ diffs of each anti-pattern. Credits the MIT source.
364
+ - ✅ **Constitution §8** (`CLAUDE.md.tpl`) — a concise behavioral-discipline
365
+ section pointing to `behaviors.md`; **reconciles the one tension** (refactor by
366
+ responsibility is *deliberate* via `/dev-start` / `/analyze-code-ia-practices`,
367
+ never an opportunistic side effect).
368
+ - ✅ **`behaviors.active` (default ON)** + a ~4-line boot reminder mirroring the
369
+ best-practices block; installer seeds both docs; `selfcheck` asserts each piece.
370
+
371
+ **Stays inside the invariants:** the boot reminder never blocks (Rule 2), the
372
+ guidance is single-sourced in one doc referenced by the constitution + boot
373
+ (Rule 4), and we adopted the proven four rather than inventing a fifth (Rule 9).
374
+
375
+ *Noticed, not fixed (surgical):* `best-practices.md` links to `review-protocol.md`,
376
+ which the installer's seed list doesn't copy — a pre-existing broken link, left as
377
+ a separate one-line fix.
378
+
379
+ ## Design invariants (don't regress these)
380
+
381
+ - **Zero runtime deps on the hot path.** Levels 1–3 run with nothing installed.
382
+ - **Hooks never break real work.** Exit 0 on error; silent unless they must speak.
383
+ - **Everything is plain files in the repo.** Inspectable, reversible, no lock-in.
384
+ - **Config-driven, not hardcoded.** Stack specifics live in `contextkit/config.json`.
385
+ - **Advisory by default; enforce by choice.** Gates inform; you opt into blocking.
@@ -0,0 +1,258 @@
1
+ # Squad Pipeline Format v1
2
+
3
+ > The declarative, opt-in pipeline a squad ships at
4
+ > `templates/contextkit/squads/<squad>/pipeline.yaml`. Turns the orchestrator's
5
+ > implicit choreography into a **diffable, dry-runnable, simulate-impact-
6
+ > mappable plan**. First consumer: `agent-forge` (Fase 6, [ADR-0015](../contextkit/memory/decisions/0015-pipeline-dsl-working-stage-and-multi-session-work-claims.md) Part A).
7
+ >
8
+ > **Opt-in per squad.** A squad with no `pipeline.yaml` keeps working as
9
+ > today; the engine never runs on its own. Hot-path zero-dep stays — the
10
+ > parser uses `lib/yaml.mjs` (ADR-0013 dynamic import) and refuses with an
11
+ > informative exit-0 message when `yaml` is absent.
12
+
13
+ ## Where the file lives
14
+
15
+ ```
16
+ templates/contextkit/squads/<squad>/pipeline.yaml
17
+ ```
18
+
19
+ The engine — `templates/contextkit/tools/scripts/squad-pipeline.mjs` — discovers
20
+ pipelines by walking that directory.
21
+
22
+ ## File schema
23
+
24
+ ```yaml
25
+ pipeline:
26
+ squad: <kebab-case> # must match the directory name
27
+ version: "1.0.0" # semver
28
+ description: > # multiline OK
29
+ Human-readable one-paragraph summary of the pipeline's job.
30
+ steps:
31
+ - id: <kebab-case> # unique within this pipeline
32
+ agent: <briefing-key> # matches .claude/agents/<id>.md (omit on checkpoint)
33
+ execution: inline | subagent
34
+ model_tier: fast | powerful | reasoning
35
+ condition: <expr> # optional; whitelisted grammar (see below)
36
+ on_reject: <step-id> # optional; loop back target
37
+ max_review_cycles: <int> # required when on_reject is set; hard cap
38
+ type: checkpoint # only for non-agent steps
39
+ outputFile: <repo-relative-path> # checkpoint only
40
+ ```
41
+
42
+ ### Required fields per step
43
+
44
+ | Step kind | Required | Forbidden |
45
+ |---|---|---|
46
+ | Agent step | `id`, `agent`, `execution`, `model_tier` | `type`, `outputFile` |
47
+ | Checkpoint | `id`, `type: checkpoint`, `outputFile` | `agent`, `execution`, `model_tier` |
48
+
49
+ Future step kinds (`type: render`, `type: parallel`) land behind their own
50
+ ADRs when a real use case arrives — v1 is **linear with `condition` +
51
+ `on_reject`** by deliberate choice.
52
+
53
+ ## `execution`
54
+
55
+ | Value | Meaning |
56
+ |---|---|
57
+ | `inline` | The `forge-orchestrator` (or equivalent) persona-switches into this agent in the same conversation turn. |
58
+ | `subagent` | The orchestrator spawns a background `Agent({ subagent_type })` call. Results return as a structured message. |
59
+
60
+ The engine itself never decides; it passes the value through to the
61
+ orchestrator's dispatch layer.
62
+
63
+ ## `model_tier`
64
+
65
+ ```
66
+ fast — cheap & quick (e.g. Haiku-class)
67
+ powerful — high-quality general (e.g. Sonnet-class)
68
+ reasoning — deep reasoning (e.g. Opus-class or o-series)
69
+ ```
70
+
71
+ **Vendor model names are forbidden in `pipeline.yaml`.** The engine refuses
72
+ on bare model strings (`model: claude-sonnet-4-6` and friends). The
73
+ [`model-router`](../templates/contextkit/squads/agent-forge/lib/router.mjs)
74
+ (ADR-0012 §4) is the single resolver from tier → concrete model, honouring
75
+ the capability matrix, residency constraints, and budget policy. Pipelines
76
+ declare *intent*; the router decides *implementation*.
77
+
78
+ ## `condition` — whitelisted grammar
79
+
80
+ The expression that decides whether a step runs. v1 grammar is deliberately
81
+ tiny — no arbitrary expression evaluation, no function calls, no boolean
82
+ chaining.
83
+
84
+ ```
85
+ condition := dotted_id <op> literal
86
+ | dotted_id ".length" <op> int
87
+
88
+ dotted_id := identifier ( "." identifier )*
89
+ identifier := /[a-zA-Z_][a-zA-Z0-9_]*/
90
+ op := "==" | "!=" | ">" | "<" | ">=" | "<="
91
+ literal := string | int | float | bool | "null"
92
+ string := '"' /[^"]*/ '"' # single quotes also accepted
93
+ bool := "true" | "false"
94
+ ```
95
+
96
+ ### Examples that parse
97
+
98
+ ```yaml
99
+ condition: blueprint.tools.length > 0
100
+ condition: capabilities.rag == true
101
+ condition: intent.domain == "medical"
102
+ condition: budget.monthly_cap_usd <= 100
103
+ condition: deployment.residency != null
104
+ ```
105
+
106
+ ### Examples that **refuse**
107
+
108
+ ```yaml
109
+ # function call
110
+ condition: hasTools(blueprint)
111
+
112
+ # boolean chaining
113
+ condition: blueprint.tools.length > 0 && capabilities.rag == true
114
+
115
+ # arithmetic
116
+ condition: budget.monthly_cap_usd / 30 < 5
117
+
118
+ # bare identifier (no comparison)
119
+ condition: blueprint.tools
120
+ ```
121
+
122
+ Anything outside the grammar exits 1 at parse time with `condition refused:
123
+ grammar violation at <step-id>`.
124
+
125
+ ### Evaluation rules
126
+
127
+ - `dotted_id` resolves against the pipeline **context** (the blueprint +
128
+ router decision + accumulated step outputs).
129
+ - An unknown identifier resolves to `undefined`. `undefined <op> <literal>`
130
+ is **always false** (the step does not run).
131
+ - `.length` is special-cased for arrays and strings. On non-array, non-string
132
+ values it yields `undefined` → false.
133
+ - No coercion: `"5" == 5` is **false**.
134
+
135
+ A bigger grammar (`&&`, `||`, function calls, arithmetic) is recorded as
136
+ deliberately rejected in [ADR-0015 §A.2](../contextkit/memory/decisions/0015-pipeline-dsl-working-stage-and-multi-session-work-claims.md).
137
+ Expanding it needs a new ADR with the real use case attached.
138
+
139
+ ## `on_reject` + `max_review_cycles`
140
+
141
+ Bounded retry loop. When a step's output is rejected (the rejection signal
142
+ itself is the agent's contract — typically `{ verdict: 'reject', ... }` from
143
+ an eval gate or a reviewer), the engine jumps back to `on_reject`'s target
144
+ step and re-runs forward.
145
+
146
+ ```yaml
147
+ - id: eval-gate
148
+ agent: eval-designer
149
+ execution: subagent
150
+ model_tier: powerful
151
+ on_reject: generate-prompt
152
+ max_review_cycles: 3
153
+ ```
154
+
155
+ `max_review_cycles` is a **hard cap**. The engine refuses to loop past it
156
+ and exits with:
157
+
158
+ ```
159
+ PIPELINE HALTED — manual escalation required
160
+ step: eval-gate
161
+ cycle: 3 of 3
162
+ reason: max_review_cycles reached
163
+ ```
164
+
165
+ No silent retries. A pipeline that hits the cap means the loop is not
166
+ converging; a human picks it up.
167
+
168
+ ## `type: checkpoint`
169
+
170
+ A non-agent step that **pauses execution for human approval**. The user's
171
+ decision is captured in `outputFile` (repo-relative), which subsequent steps
172
+ can `condition`-on by referencing its parsed fields.
173
+
174
+ ```yaml
175
+ - id: checkpoint-shortlist
176
+ type: checkpoint
177
+ outputFile: pipeline/data/shortlist.md
178
+ ```
179
+
180
+ The orchestrator surfaces the checkpoint by printing the step's briefing
181
+ file (looked up via the squad's directory conventions) and waiting on
182
+ stdin / a slash-command response.
183
+
184
+ ## `--dry-run`
185
+
186
+ ```
187
+ node templates/contextkit/tools/scripts/squad-pipeline.mjs <squad> --dry-run
188
+ ```
189
+
190
+ The engine walks the graph, resolves `condition` against an empty context
191
+ (every identifier → `undefined`, so every conditional step is skipped by
192
+ default), prints the would-be execution order, and **runs no agents**.
193
+
194
+ Output shape:
195
+
196
+ ```
197
+ Pipeline: agent-forge v1.0.0
198
+ ✓ validate-blueprint agent forge-orchestrator inline fast
199
+ ✓ route agent model-router inline fast
200
+ ✓ checkpoint-shortlist checkpoint
201
+ ✓ generate-prompt agent prompt-engineer inline powerful
202
+ ⊘ generate-tools agent tool-designer inline powerful (condition: blueprint.tools.length > 0 → undefined)
203
+ ✓ governance agent governance-officer inline powerful
204
+ ↺ eval-gate agent eval-designer subagent powerful (on_reject → generate-prompt, max_cycles: 3)
205
+ ✓ package agent packager inline fast
206
+ ```
207
+
208
+ `✓` runs · `⊘` skipped by condition · `↺` has retry loop.
209
+
210
+ A non-empty plan is the basic correctness check; the integration test
211
+ asserts agent-forge produces it.
212
+
213
+ ## Engine refusal modes
214
+
215
+ | Situation | Exit | Behaviour |
216
+ |---|---|---|
217
+ | `yaml` package not installed | **0** | Informative message; pipelines are opt-in, this is not an error. Squad continues without the DSL. |
218
+ | `pipeline.yaml` invalid yaml | 1 | "pipeline.yaml malformed at <line>" |
219
+ | Unknown step kind / missing required field | 1 | "step <id> missing required field <field>" |
220
+ | Vendor model name instead of `model_tier` | 1 | "step <id>: vendor model names are forbidden; use model_tier" |
221
+ | `condition` violates whitelist | 1 | "condition refused: grammar violation at <step-id>" |
222
+ | `on_reject` target does not exist | 1 | "step <id>: on_reject target '<x>' not found" |
223
+ | `on_reject` without `max_review_cycles` | 1 | "step <id>: on_reject requires max_review_cycles" |
224
+ | Bare model name in `agent` (not in briefings) | 1 | "step <id>: agent '<x>' has no briefing under .claude/agents/" |
225
+
226
+ ## Selfcheck
227
+
228
+ `checkSquadPipeline` runs in CI and validates each `pipeline.yaml`:
229
+
230
+ 1. yaml parses (skipped when `yaml` is absent, but the file is still read
231
+ as plain text for the briefing-existence check below);
232
+ 2. every `agent` resolves to an existing briefing at
233
+ `.claude/agents/<agent>.md`;
234
+ 3. every `on_reject` target exists in the same pipeline;
235
+ 4. every `condition` parses by the whitelist;
236
+ 5. `model_tier` is one of `fast` | `powerful` | `reasoning`;
237
+ 6. no vendor model names appear in the file.
238
+
239
+ ## Boundaries with the rest of the kit
240
+
241
+ - **Squad pipelines are opt-in.** No `pipeline.yaml` → squad keeps running
242
+ the way it does today.
243
+ - **Engine writes no shared state in v1.** Task 040 ([ADR-0015 Part C](../contextkit/memory/decisions/0015-pipeline-dsl-working-stage-and-multi-session-work-claims.md))
244
+ introduces `state.json` per run; until then, the engine prints to stdout
245
+ and that's it.
246
+ - **`/ship` does not adopt this yet.** Same engine, but the integration is
247
+ a follow-up after Fase 6 ships.
248
+ - **Hot-path zero-dep stays.** The dynamic import lives behind
249
+ [`lib/yaml.mjs`](../templates/contextkit/squads/agent-forge/lib/yaml.mjs);
250
+ `runtime/hooks/**` and `runtime/config/load.mjs` import nothing from
251
+ here. Pipelines are an L4+ feature.
252
+
253
+ ## Cross-references
254
+
255
+ - [ADR-0012](../contextkit/memory/decisions/0012-agent-forge-squad-for-portable-agent-packages.md) — agent-forge boundary + router as single resolver
256
+ - [ADR-0013](../contextkit/memory/decisions/0013-agent-forge-yaml-via-optional-dynamic-import.md) — sanctioned optional yaml import
257
+ - [ADR-0015](../contextkit/memory/decisions/0015-pipeline-dsl-working-stage-and-multi-session-work-claims.md) — this format's authorising ADR
258
+ - [`docs/SQUADS/agent-forge.md`](SQUADS/agent-forge.md) — first consumer