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,258 @@
1
+ # Architecture
2
+
3
+ How ContextDevKit works internally — for anyone extending the engine.
4
+
5
+ ## Two install locations
6
+
7
+ Claude Code reads settings, slash commands, and agents from **hardcoded** paths
8
+ under `.claude/`. Everything else — the engine, memory, scripts, providers —
9
+ lives under a single rebrandable folder, `contextkit/` (a "bounded context"
10
+ separate from your product code). The only literal reference to that folder
11
+ name is `PLATFORM_DIR` in `contextkit/runtime/config/paths.mjs`.
12
+
13
+ ```
14
+ .claude/ # fixed by Claude Code
15
+ settings.json # hook wiring (composed by the installer per level)
16
+ commands/ # 60+ slash commands, organised in domain packs
17
+ audit/ # tech-debt, security, deps, SEO/AISO
18
+ pipeline/ # DevPipeline + ship + dev-start + retro + runs
19
+ qa/ # qa-signoff, test-plan, scaffold-tests, visual-test
20
+ vcs/ # git, claim, release, worktree-new
21
+ forge/ # 14 agent-forge lifecycle commands
22
+ setup/ # setupcontextdevkit, context-doctor, context-level
23
+ *.md # daily commands at root
24
+ agents/ # 28 sub-agent archetypes (frontmatter: name + description)
25
+ .sessions/ # per-session ledgers (gitignored runtime state)
26
+ .workspace/ # per-session claim files (gitignored runtime state)
27
+ contextkit/
28
+ .env.example # optional credentials template (media-gen)
29
+ runtime/hooks/ # the four hooks + shared ledger/classification/readers
30
+ runtime/config/ # paths, defaults, zero-dep loader, settings composer, zod (opt)
31
+ runtime/git-hooks/ # pre-commit (reindex), commit-msg, pre-push (conflict block)
32
+ runtime/providers/
33
+ review/ # PR/review CLI adapters (gh ships; glab/bb adapters fit the contract)
34
+ media/ # Veo + Nano Banana image/video adapters
35
+ runtime/state/ # canonical state.json substrate for tasks + runs
36
+ tools/scripts/ # 50+ helpers (reindex, dashboard, sync-check, audits, …)
37
+ memory/ # decisions/, sessions/, business-rules/, GLOSSARY.md, generated indices
38
+ pipeline/ # DevPipeline lanes: backlog / working / testing / conclusion
39
+ workflows/playbooks/ # tanstack, landing-page, seo-aiso, tech-debt-sweep, …
40
+ squads/agent-forge/ # the L6+ "agent that builds agents"
41
+ config.json # level + ledger path lists + L5 params
42
+ ```
43
+
44
+ Claude Code's command resolver picks by **file basename** — `/qa-signoff` finds
45
+ `qa/qa-signoff.md` exactly as well as a flat `qa-signoff.md`. The packs are
46
+ pure human navigation (see [ticket 047 conclusion](../contextkit/pipeline/conclusion/047-skill-packs-by-domain-subfolders.md)).
47
+
48
+ ## The hooks (the engine)
49
+
50
+ Wired in `.claude/settings.json`, each is a `node` script fed the tool payload on
51
+ stdin. **Contract for every hook: never throw, exit 0 on error, stay silent
52
+ unless it has something to say.** A broken hook must never block real work.
53
+
54
+ | Hook | Event | File | Job |
55
+ | --- | --- | --- | --- |
56
+ | Boot context | `SessionStart` | `session-start.mjs` | git fetch + divergence; drift banner; inject latest session + `[Unreleased]` + active claims |
57
+ | Edit ledger | `PostToolUse` (Edit\|Write\|MultiEdit) | `track-edits.mjs` | append edit to per-session ledger; renew claim heartbeat; cross-claim warning |
58
+ | Drift nudge | `Stop` | `check-registration.mjs` | block stop if ≥ 2 important files changed and session unregistered; L5 archive + distill-detect nudge |
59
+ | Concurrency guard (L3) | `PreToolUse` (Edit\|Write\|MultiEdit) | `concurrency-guard.mjs` | warn when another session/external change touched the same file (no clobber) |
60
+ | Risk gate (L5) | `PreToolUse` (Edit\|Write\|MultiEdit) | `simulate-gate.mjs` | block edits to `highRiskPaths` without a covering `/simulate-impact` |
61
+
62
+ Git hooks (installed at L≥3): `pre-commit` (regenerate indices), `commit-msg`
63
+ (Conventional Commits), `pre-push` (fetch upstream + **block real conflicts** via
64
+ `git merge-tree` — the cross-machine guarantee). Worktrees are detected via the
65
+ `.git` file containing `gitdir:` and hooks install into the resolved real
66
+ `.git/hooks/`.
67
+
68
+ Shared modules:
69
+
70
+ - **`ledger.mjs`** — per-session JSON ledger (read/write/list), simulation
71
+ records, session-id resolution, `readMostRecentLedger`. One ledger file per
72
+ session so parallel chats never stomp each other (and worktrees isolate naturally).
73
+ - **`path-classification.mjs`** — `isTrackable` / `isImportant` /
74
+ `isRegistrationFile`, driven by `config.json` → `ledger.*`. **This is the seam
75
+ that makes the kit stack-agnostic.**
76
+ - **`boot-context-readers.mjs`** — pure readers for the session/changelog/
77
+ workspace artifacts.
78
+ - **`safe-io.mjs`** — atomic write (`writeFileAtomic`), defensive JSON read.
79
+
80
+ ## Configuration (zero-dependency by design)
81
+
82
+ The hot path (hooks) must run on a brand-new project with nothing installed, so
83
+ `runtime/config/load.mjs` is **plain JSON + a recursive deep-merge over
84
+ `defaults.mjs`** — no `zod`, no npm packages. Arrays replace; objects merge. A
85
+ leading UTF-8 BOM is stripped (common on Windows). On any failure it returns the
86
+ frozen defaults — config is best-effort, never fatal.
87
+
88
+ Strict validation (`runtime/config/schema.mjs`, zod) is **optional** and used
89
+ only by `/context-config`; it degrades gracefully when zod isn't present.
90
+
91
+ ## Level system
92
+
93
+ `config.json` → `level` (1–7) is the single switch. See [`LEVELS.md`](LEVELS.md)
94
+ for what each level adds.
95
+
96
+ - The **installer** and the in-project **`context-level.mjs`** both call the shared
97
+ `composeSettings(existing, level)` (`runtime/config/settings-compose.mjs`) to
98
+ rebuild the `hooks` block — preserving your own hooks, stripping previously
99
+ installed ContextDevKit entries so going down a level cleanly removes them. It is
100
+ idempotent: re-running never duplicates entries.
101
+ - Hooks also read the level at runtime and self-gate (e.g. the Stop hook only
102
+ runs L5 distill-detect when `level >= 5`), so the wiring and the behaviour can
103
+ never disagree.
104
+
105
+ ## Derived indices
106
+
107
+ `SESSIONS.md` (session index) and `WORKSPACE.md` (active claims) are **generated**
108
+ from source-of-truth files (`sessions/*.md` and `.claude/.workspace/*.json`).
109
+ This avoids merge conflicts between parallel sessions. The `pre-commit` git hook
110
+ regenerates them before each commit. Never hand-edit a generated file.
111
+
112
+ ## DevPipeline + state.json substrate
113
+
114
+ The DevPipeline (`contextkit/pipeline/`) is the execution board — tickets flow
115
+ `backlog/ → working/ → testing/ → conclusion/`. Each ticket is a markdown file
116
+ with YAML frontmatter (id, title, type, priority, severity, SLA, dependencies
117
+ DAG, complexity).
118
+
119
+ The **state.json substrate** (`runtime/state/state-io.mjs`, [ADR-0015 §C](../contextkit/memory/decisions/0015-pipeline-dsl-working-stage-and-multi-session-work-claims.md))
120
+ gives every task and pipeline run a single readable state file (`startedAt`,
121
+ `endedAt`, `lastHeartbeat`, `kind`, `status`). The `/runs` command reads from
122
+ this substrate. `pipeline-session.mjs` stamps state on start/stop;
123
+ `workspace-sync.mjs` mirrors heartbeats into the state.
124
+
125
+ The **board renderer** (`pipeline-board.mjs`) generates `devpipeline.md` and
126
+ hints `↘ blocked by N` on tickets with unresolved dependencies.
127
+
128
+ ## Provider adapters — pluggable external integrations
129
+
130
+ Two adapter directories under `runtime/providers/`, sharing the same five-point
131
+ contract: no SDK dependency, refuse-on-missing-creds, typed error, refuse-on-
132
+ content-policy (where applicable), per-process cost cap (media only).
133
+
134
+ ### Review providers (`runtime/providers/review/`)
135
+
136
+ Adapters for PR creation, review comment listing, and review comment posting.
137
+ Each adapter is a thin shell around an external CLI the user already has
138
+ installed (`gh`, `glab`, `bb`, `tea`).
139
+
140
+ ```js
141
+ export const id = 'gh';
142
+ export const cliBinary = 'gh';
143
+ export const detectsRemote = (remoteUrl) => /github\.com[:/]/.test(remoteUrl);
144
+ export async function createPullRequest({ title, body, baseBranch }) { … }
145
+ export async function listOpenReviewComments({ prNumber }) { … }
146
+ export async function postReviewComment({ prNumber, body }) { … }
147
+ ```
148
+
149
+ `detect.mjs` runs `git remote get-url origin` and picks the adapter whose
150
+ `detectsRemote` matches, then records the choice in `contextkit/config.json` →
151
+ `providers.review`. Authority: [ADR-0021](../contextkit/memory/decisions/0021-provider-strategy-review-qa.md).
152
+
153
+ ### Media providers (`runtime/providers/media/`) *(new in v1.7)*
154
+
155
+ Adapters for image and video generation via `node:fetch` against external APIs.
156
+ Two ship today: **`nano-banana`** (Imagen 3 image) and **`veo`** (Veo 3 video),
157
+ both against Google AI Studio's REST API.
158
+
159
+ ```js
160
+ export const id = 'nano-banana';
161
+ export const kind = 'image'; // or 'video'
162
+ export const envVar = 'GOOGLE_AI_API_KEY';
163
+ export const requiredEnv = ['GOOGLE_AI_API_KEY'];
164
+ export async function generate({ prompt, outPath, options }) { … }
165
+ ```
166
+
167
+ `_adapter.mjs` provides `MediaProviderError` (7 codes: `NO_CREDENTIALS`,
168
+ `CONTENT_POLICY`, `COST_CAP_REACHED`, `RATE_LIMIT`, `PROVIDER_ERROR`,
169
+ `BAD_INPUT`, `IO`), `validateAdapter`, `assertCredentials` (refuses before any
170
+ network call), and `noteCostOrThrow` (shared per-process USD tally read from
171
+ `CONTEXTDEVKIT_MEDIA_MAX_USD`). Authority: [ADR-0024](../contextkit/memory/decisions/0024-media-generation-veo-nano-banana.md).
172
+
173
+ ## Squads — sub-agent organisation
174
+
175
+ Each agent is a `.claude/agents/*.md` file with frontmatter (`name` +
176
+ `description`; optional `mcpServers` per [ADR-0019](../contextkit/memory/decisions/0019-mcp-injection-in-squads.md)).
177
+ Claude Code routes to an agent by matching the `description` to the user's
178
+ intent — so the description names the *concrete files/dirs/patterns* the agent
179
+ owns.
180
+
181
+ Squads group related agents:
182
+
183
+ | Squad | Specialists | Activated at |
184
+ |---|---|---|
185
+ | **devteam** | `architect`, `code-reviewer`, `context-keeper`, `test-engineer` | L4 |
186
+ | **qa-team** | `qa-orchestrator` + `qa-unit` / `qa-integration` / `qa-fuzzer` / `qa-perf` / `qa-e2e` | L4 |
187
+ | **design-team** | `ui-designer`, `ux-designer`, `accessibility`, **`seo-specialist`**, **`landing-architect`** | L4 |
188
+ | **security-team** | `security`, `code-security`, `infra-security` | L4 |
189
+ | **compliance-team** | `privacy-lgpd`, `governance-officer` | L4 |
190
+ | **ops-team** | `devops` | L4 |
191
+ | **agent-forge** | `forge-orchestrator`, `model-router`, `prompt-engineer`, `tool-designer`, `eval-designer`, `packager`, `rag-designer`, `agent-architect` | L6+ |
192
+
193
+ See [`SQUADS/design-team.md`](SQUADS/design-team.md) and
194
+ [`SQUADS/agent-forge.md`](SQUADS/agent-forge.md) for specialist briefings.
195
+
196
+ ## Visual surfaces — `/dashboard` + `/watch`
197
+
198
+ Two zero-dep surfaces over the kit's existing files:
199
+
200
+ - **`/dashboard`** (`dashboard.mjs` entry; `dashboard-data.mjs` reader;
201
+ `dashboard-html.mjs` renderer; `dashboard-server.mjs` `--watch` server) —
202
+ writes a self-contained HTML or serves it on `127.0.0.1:4242` (override via
203
+ `--port` or `CONTEXTDEVKIT_DASHBOARD_PORT`). Live mode uses `fs.watch` on the
204
+ platform dir with a 200 ms debouncer and pushes data via Server-Sent Events.
205
+ - **`/watch`** (`watch.mjs`) — tails the active session ledger via the runtime's
206
+ `readMostRecentLedger` (single-sourced — rule 4). `--follow` re-polls every
207
+ 500 ms; exits cleanly on SIGINT.
208
+
209
+ Both bind to `127.0.0.1` only — no remote access by design.
210
+
211
+ ## GitHub sync awareness (sync-check)
212
+
213
+ `sync-check.mjs` ([ADR-0026](../contextkit/memory/decisions/0026-github-sync-awareness-dev-flow.md))
214
+ has two modes wired into two slash commands:
215
+
216
+ - **`preflight`** (run by `/dev-start` before scope-lock) — shows ahead/behind,
217
+ recent branches, and **open PRs with CI/review status**, flagging PRs
218
+ *awaiting status* that may overlap the objective.
219
+ - **`prepr`** (run by `/git pr` before push) — re-checks divergence vs the
220
+ default branch and **detects a duplicate open PR** for the current branch.
221
+
222
+ `gh` is optional — absent or unauthed degrades to the git-only half and reports
223
+ the PR check as **skipped, never a pass** (rule 8). Offline → silent exit 0.
224
+ PR queries stay **off the `SessionStart` hot path** (rule 2 — never block
225
+ real work; network + auth would violate the never-block invariant).
226
+
227
+ ## Home-scoped state (`~/.contextdevkit/`)
228
+
229
+ ADR-0020 formalises a small home directory for cross-repo state that cannot
230
+ live in any single repo. `home.mjs` is the single owner of resolution + atomic
231
+ write contract:
232
+
233
+ - `resolveHome()` — honours `CONTEXTDEVKIT_HOME`; otherwise `~/.contextdevkit/`; lazy
234
+ `mkdirSync` on first call.
235
+ - `readHomeFile(name)` — returns `null` on absent/malformed/version mismatch;
236
+ legacy files (without `version`) are adopted on first read.
237
+ - `writeHomeFile(name, data)` — atomic via `<path>.tmp.<pid>` + `renameSync`;
238
+ stamps `version: 1`.
239
+
240
+ Used today only by `fleet.mjs` (cross-repo portfolio registry). Future
241
+ home-scoped consumers (preferences, telemetry cache) inherit the contract.
242
+
243
+ What does **NOT** belong there: ADRs, sessions, pipeline tickets, run state, no
244
+ SQLite, no daemon, no secrets. The kit reads secrets from `process.env`
245
+ exclusively (e.g. `GOOGLE_AI_API_KEY` for `/media-gen`).
246
+
247
+ ## Why this shape
248
+
249
+ - **Defense in depth.** Instructions (CLAUDE.md, slash commands) are advisory;
250
+ hooks are enforced. The two layers cover each other.
251
+ - **Reversible & inspectable.** Everything is plain files in your repo. Uninstall
252
+ by deleting `contextkit/` and the ContextDevKit block from `.claude/settings.json`.
253
+ - **No lock-in on the hot path.** Zero runtime deps for Levels 1–3. The optional
254
+ layers (`zod` for strict validation, external APIs for `/media-gen`) are all
255
+ opt-in and degrade gracefully when absent.
256
+ - **Read by basename, organised by domain.** Slash commands moved into packs
257
+ in v1.7 without breaking a single invocation — Claude Code's resolver is
258
+ path-agnostic, but humans aren't.