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,19 @@
1
+ <!--
2
+ GENERATED in Fase 1 by `prompt-engineer` from system.canonical.md. Do not hand-edit.
3
+ Google (Gemini): goes in the `systemInstruction` param. Markdown + few-shot works
4
+ well. Remember safetySettings are configured on the REQUEST, not here.
5
+ -->
6
+ # Role
7
+ {{ROLE_ONE_LINE}}
8
+
9
+ ## Context
10
+ {{STABLE_BACKGROUND}}
11
+
12
+ ## Rules
13
+ - {{AFFIRMATIVE_RULE_1}}
14
+
15
+ ## Output
16
+ {{OUTPUT_CONTRACT}}
17
+
18
+ ## Examples (few-shot)
19
+ {{FEW_SHOT}}
@@ -0,0 +1,21 @@
1
+ <!--
2
+ GENERATED in Fase 1 by `prompt-engineer` from system.canonical.md. Do not hand-edit.
3
+ Self-hosted (Ollama/vLLM): the chat template VARIES BY MODEL (Llama 3 vs Mistral vs
4
+ Qwen). Prefer the API that applies the model's chat_template automatically; otherwise
5
+ render the exact template for the target model. Tool-use reliability is below cloud —
6
+ lean on the eval golden set.
7
+ -->
8
+ # Role
9
+ {{ROLE_ONE_LINE}}
10
+
11
+ ## Context
12
+ {{STABLE_BACKGROUND}}
13
+
14
+ ## Rules
15
+ - {{AFFIRMATIVE_RULE_1}}
16
+
17
+ ## Output
18
+ {{OUTPUT_CONTRACT}}
19
+
20
+ ## Examples
21
+ {{FEW_SHOT}}
@@ -0,0 +1,20 @@
1
+ <!--
2
+ GENERATED in Fase 1 by `prompt-engineer` from system.canonical.md. Do not hand-edit.
3
+ OpenAI (GPT): this becomes the first `system` message. Use clear delimiters. Prefer
4
+ native response_format: json_schema (strict) for structured output. o-series models
5
+ take no system message — fold into the first user turn + set reasoning_effort.
6
+ -->
7
+ # Role
8
+ {{ROLE_ONE_LINE}}
9
+
10
+ ## Context
11
+ {{STABLE_BACKGROUND}}
12
+
13
+ ## Rules
14
+ - {{AFFIRMATIVE_RULE_1}}
15
+
16
+ ## Output
17
+ {{OUTPUT_CONTRACT}}
18
+
19
+ ## Examples
20
+ {{FEW_SHOT}}
@@ -0,0 +1,17 @@
1
+ # RAG config. This whole rag/ folder is present ONLY if the agent needs retrieval
2
+ # (manifest spec.capabilities.rag: true). Generated by rag-designer.
3
+ embedding:
4
+ # multilingual (PT-BR / multi) → multilingual-e5 | bge-m3
5
+ # english-only → text-embedding-3-large | voyage-3
6
+ model: {{multilingual-e5}}
7
+ dimensions: {{1024}}
8
+
9
+ index:
10
+ backend: {{faiss|pgvector|qdrant|pinecone}}
11
+ metric: cosine
12
+
13
+ retrieval:
14
+ top_k: {{8}}
15
+ min_score: {{0.30}} # drop chunks below this
16
+ hybrid_search: {{true}} # BM25 + vector
17
+ rerank: {{true}} # see retrieval/rerank.config.yaml
@@ -0,0 +1,3 @@
1
+ # The vector index is BUILT BY THE CLIENT from rag/ingestion/sources.yaml.
2
+ # It is never embarked in the Agent Package (size + freshness). This dir stays empty
3
+ # in the package; the client populates it at deploy time.
@@ -0,0 +1,6 @@
1
+ # How source documents are split before embedding.
2
+ strategy: {{recursive|semantic|fixed}}
3
+ chunk_size_tokens: {{512}}
4
+ chunk_overlap_tokens: {{64}}
5
+ respect_boundaries: [heading, paragraph] # avoid splitting mid-section
6
+ keep_metadata: [source, section, page]
@@ -0,0 +1,8 @@
1
+ # Where the knowledge content comes from. READ-ONLY specs — the index is built by the
2
+ # client (see ../index/), never embarked in the package.
3
+ sources:
4
+ - id: {{source_id}}
5
+ type: {{filesystem|url|s3|gcs|db}}
6
+ location: {{path or uri}}
7
+ include: ["**/*.{md,pdf,txt}"]
8
+ refresh: {{manual|daily|weekly}}
@@ -0,0 +1,16 @@
1
+ <!-- How the user query is turned into a retrieval query + how context is injected. -->
2
+
3
+ ## Retrieval query
4
+ {{TRANSFORM of the user input into a search query — e.g. expand acronyms, strip PII}}
5
+
6
+ ## Context injection
7
+ Inject the top-k chunks as:
8
+
9
+ ```
10
+ <context>
11
+ {{retrieved_chunks}}
12
+ </context>
13
+ ```
14
+
15
+ Instruct the model to answer ONLY from `<context>` and to say when the answer is not
16
+ present (faithfulness > fluency).
@@ -0,0 +1,6 @@
1
+ # Optional reranker — re-scores the top_k from the vector store before injection.
2
+ # Remove this file if config.yaml retrieval.rerank is false.
3
+ enabled: {{true}}
4
+ model: {{bge-reranker-v2-m3|cohere-rerank-3}}
5
+ top_n_after_rerank: {{4}}
6
+ min_score: {{0.50}}
@@ -0,0 +1,11 @@
1
+ {
2
+ "_generated": "Fase 1 by tool-designer from ../schemas.canonical.json. Do not hand-edit.",
3
+ "_format": "Anthropic `tools` array: each tool = { name, description, input_schema }. Force a tool with tool_choice: { type: 'tool', name: '...' }.",
4
+ "tools": [
5
+ {
6
+ "name": "{{tool_name}}",
7
+ "description": "{{from canonical}}",
8
+ "input_schema": { "type": "object", "properties": {}, "required": [] }
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "_generated": "Fase 1 by tool-designer from ../schemas.canonical.json. Do not hand-edit.",
3
+ "_format": "DeepSeek is OpenAI-compatible — same shape as openai.tools.json (type 'function').",
4
+ "tools": [
5
+ {
6
+ "type": "function",
7
+ "function": {
8
+ "name": "{{tool_name}}",
9
+ "description": "{{from canonical}}",
10
+ "parameters": { "type": "object", "properties": {}, "required": [] }
11
+ }
12
+ }
13
+ ]
14
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "_generated": "Fase 1 by tool-designer from ../schemas.canonical.json. Do not hand-edit.",
3
+ "_format": "Gemini `tools[].functionDeclarations[]`: { name, description, parameters }. parameters is a JSON-Schema SUBSET — not every field is supported; the generator down-converts.",
4
+ "functionDeclarations": [
5
+ {
6
+ "name": "{{tool_name}}",
7
+ "description": "{{from canonical}}",
8
+ "parameters": { "type": "object", "properties": {}, "required": [] }
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "_generated": "Fase 1 by tool-designer from ../schemas.canonical.json. Do not hand-edit.",
3
+ "_format": "Self-hosted via OpenAI-compatible endpoint — same shape as openai.tools.json. Native function calling on Llama 3.x / Mistral; reliability below cloud, so eval golden is critical.",
4
+ "tools": [
5
+ {
6
+ "type": "function",
7
+ "function": {
8
+ "name": "{{tool_name}}",
9
+ "description": "{{from canonical}}",
10
+ "parameters": { "type": "object", "properties": {}, "required": [] }
11
+ }
12
+ }
13
+ ]
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "_generated": "Fase 1 by tool-designer from ../schemas.canonical.json. Do not hand-edit.",
3
+ "_format": "OpenAI `tools` array of type 'function': { type, function: { name, description, parameters } }.",
4
+ "tools": [
5
+ {
6
+ "type": "function",
7
+ "function": {
8
+ "name": "{{tool_name}}",
9
+ "description": "{{from canonical}}",
10
+ "parameters": { "type": "object", "properties": {}, "required": [] }
11
+ }
12
+ }
13
+ ]
14
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "_note": "CANONICAL tool schemas — the source of truth. tool-designer generates the per-provider adapters under tools/adapters/ from this. Every tool description follows: what it does / when to use / when NOT to use / one example. Keep input_schema strict.",
3
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4
+ "{{tool_name}}": {
5
+ "description": "WHAT: {{what it does}}. WHEN: {{when to call}}. WHEN NOT: {{when to avoid}}. EXAMPLE: {{one concrete example}}.",
6
+ "idempotent": true,
7
+ "input_schema": {
8
+ "type": "object",
9
+ "additionalProperties": false,
10
+ "required": ["{{required_field}}"],
11
+ "properties": {
12
+ "{{required_field}}": { "type": "string", "description": "{{what it is}}" }
13
+ }
14
+ },
15
+ "error_format": {
16
+ "type": "object",
17
+ "description": "Actionable error the model can recover from.",
18
+ "properties": {
19
+ "code": { "type": "string" },
20
+ "message": { "type": "string" },
21
+ "retryable": { "type": "boolean" }
22
+ }
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,86 @@
1
+ # TanStack starter
2
+
3
+ > Minimal wiring scaffold copied by `/aidevtool-from0` when the chosen stack
4
+ > is **TanStack**. After copy, this becomes your project — there is no upgrade
5
+ > path from the kit.
6
+
7
+ ## What this gives you
8
+
9
+ - **TanStack Router** (file-based, type-safe) wired through
10
+ `@tanstack/router-plugin` for Vite. The plugin generates
11
+ `src/routeTree.gen.ts` from `src/routes/**` on every dev/build — that file
12
+ is gitignored.
13
+ - **TanStack Query** with a single `QueryClient` provider mounted in
14
+ `src/main.tsx`. The Router is given `{ queryClient }` as `context`, so route
15
+ loaders can call `context.queryClient.ensureQueryData(queryOptions)`.
16
+ - **React 19** + **Vite 6** + **TypeScript** (`strict`, `noUncheckedIndexedAccess`,
17
+ `verbatimModuleSyntax`).
18
+
19
+ ## What this does NOT give you (by design — ADR-0017)
20
+
21
+ - No invented domain (no `User`, `Product`, `Post` — just one placeholder route).
22
+ - No CSS framework / design system — the placeholder is plain HTML.
23
+ - No backend client, no auth, no DB. Those are separate decisions for separate
24
+ ADRs in your project.
25
+ - No example query — the conventions are in the playbook; write your first
26
+ query against your real backend.
27
+
28
+ ## First steps after copy
29
+
30
+ ```bash
31
+ npm install
32
+ npm run dev
33
+ ```
34
+
35
+ Then:
36
+
37
+ 1. **Replace `src/routes/index.tsx`** with your first real route.
38
+ 2. **Write your first query** following the `queryOptions` pattern from the
39
+ playbook — never `useState` for server data, never an inline `queryKey`
40
+ string. Co-locate the `queryOptions` factory next to the feature, not in a
41
+ global file.
42
+ 3. **Open an ADR in your project** (`/new-adr "<your-first-feature>"`) before
43
+ the first non-trivial route — type-safe Router params are a contract;
44
+ contracts deserve ADRs.
45
+
46
+ ## Conventions you inherit from the kit
47
+
48
+ The full conventions block lives in
49
+ [`contextkit/workflows/playbooks/tanstack.md`](../../workflows/playbooks/tanstack.md)
50
+ and was copied into your project's `CLAUDE.md` under "Stack" when this starter
51
+ was applied. The short version:
52
+
53
+ - Server state in Query, never `useState`.
54
+ - `queryOptions` is the unit of reuse.
55
+ - Cache keys are arrays, hierarchical, stable.
56
+ - Router params via `Route.useParams()` — never a generic hook.
57
+ - `staleTime` is deliberate; the default of `0` is correct only for dashboards.
58
+ - Mutations invalidate the **smallest viable** key, with a one-line comment
59
+ naming the invariant the invalidation preserves.
60
+
61
+ ## Upgrading to TanStack Start (SSR / full-stack)
62
+
63
+ This starter intentionally **omits** TanStack Start to avoid pinning to a
64
+ moving target. When you decide you need SSR + a sanctioned server story:
65
+
66
+ 1. Read the current TanStack Start docs (the API has been evolving — verify
67
+ before trusting any guide).
68
+ 2. Open an ADR in your project capturing the migration: routing model staying,
69
+ build tool changing from Vite to vinxi, deployment target.
70
+ 3. The Router conventions you already follow carry over unchanged — only the
71
+ build/runtime swap.
72
+
73
+ ## Freshness
74
+
75
+ Versions in `package.json` were chosen at the time the kit shipped the
76
+ starter. Before relying on a specific TanStack API:
77
+
78
+ ```bash
79
+ npm outdated
80
+ npm view @tanstack/react-router version
81
+ npm view @tanstack/react-query version
82
+ ```
83
+
84
+ If a major has shipped since the kit's starter was authored, the playbook's
85
+ "Freshness" section in the kit repo is the place to refresh — not your
86
+ project. Your project owns its own pinned versions from the moment of copy.
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>TanStack starter</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/main.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "tanstack-starter",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc -b && vite build",
9
+ "preview": "vite preview"
10
+ },
11
+ "dependencies": {
12
+ "@tanstack/react-query": "^5.62.0",
13
+ "@tanstack/react-router": "^1.95.0",
14
+ "react": "^19.0.0",
15
+ "react-dom": "^19.0.0"
16
+ },
17
+ "devDependencies": {
18
+ "@tanstack/router-plugin": "^1.95.0",
19
+ "@types/react": "^19.0.0",
20
+ "@types/react-dom": "^19.0.0",
21
+ "@vitejs/plugin-react": "^4.3.0",
22
+ "typescript": "^5.7.0",
23
+ "vite": "^6.0.0"
24
+ }
25
+ }
@@ -0,0 +1,40 @@
1
+ import { StrictMode } from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
4
+ import { RouterProvider, createRouter } from '@tanstack/react-router';
5
+
6
+ import { routeTree } from './routeTree.gen';
7
+
8
+ const queryClient = new QueryClient({
9
+ defaultOptions: {
10
+ queries: {
11
+ staleTime: 0,
12
+ retry: 1,
13
+ },
14
+ },
15
+ });
16
+
17
+ const router = createRouter({
18
+ routeTree,
19
+ defaultPreload: 'intent',
20
+ context: { queryClient },
21
+ });
22
+
23
+ declare module '@tanstack/react-router' {
24
+ interface Register {
25
+ router: typeof router;
26
+ }
27
+ }
28
+
29
+ const rootEl = document.getElementById('root');
30
+ if (!rootEl) {
31
+ throw new Error('Root element #root missing in index.html');
32
+ }
33
+
34
+ createRoot(rootEl).render(
35
+ <StrictMode>
36
+ <QueryClientProvider client={queryClient}>
37
+ <RouterProvider router={router} />
38
+ </QueryClientProvider>
39
+ </StrictMode>,
40
+ );
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Re-exports the Router context type so consumers (loaders, route components)
3
+ * can type-check against it without reaching into `main.tsx`.
4
+ *
5
+ * The actual `createRouter` call lives in `main.tsx` because it depends on the
6
+ * generated `routeTree.gen.ts` (produced by `@tanstack/router-plugin`).
7
+ */
8
+ import type { QueryClient } from '@tanstack/react-query';
9
+
10
+ export interface RouterContext {
11
+ queryClient: QueryClient;
12
+ }
@@ -0,0 +1,10 @@
1
+ import { Outlet, createRootRouteWithContext } from '@tanstack/react-router';
2
+ import type { RouterContext } from '../router';
3
+
4
+ export const Route = createRootRouteWithContext<RouterContext>()({
5
+ component: RootLayout,
6
+ });
7
+
8
+ function RootLayout() {
9
+ return <Outlet />;
10
+ }
@@ -0,0 +1,17 @@
1
+ import { createFileRoute } from '@tanstack/react-router';
2
+
3
+ export const Route = createFileRoute('/')({
4
+ component: IndexRoute,
5
+ });
6
+
7
+ function IndexRoute() {
8
+ return (
9
+ <main>
10
+ <h1>TanStack starter</h1>
11
+ <p>
12
+ Wiring only — no invented domain. Replace this placeholder with your
13
+ first real route. See <code>README.md</code> for the conventions.
14
+ </p>
15
+ </main>
16
+ );
17
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "Bundler",
7
+ "jsx": "react-jsx",
8
+ "strict": true,
9
+ "noUncheckedIndexedAccess": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "isolatedModules": true,
13
+ "resolveJsonModule": true,
14
+ "allowImportingTsExtensions": false,
15
+ "noEmit": true,
16
+ "verbatimModuleSyntax": true
17
+ },
18
+ "include": ["src", "vite.config.ts"]
19
+ }
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from 'vite';
2
+ import react from '@vitejs/plugin-react';
3
+ import { TanStackRouterVite } from '@tanstack/router-plugin/vite';
4
+
5
+ export default defineConfig({
6
+ plugins: [
7
+ TanStackRouterVite({ target: 'react', autoCodeSplitting: true }),
8
+ react(),
9
+ ],
10
+ });
@@ -0,0 +1,42 @@
1
+ /**
2
+ * ADR digest core — pure parsing of an ADR file into a catalog record. [ADR-0027]
3
+ *
4
+ * Turns a full ADR (~100–120 lines) into one catalog line (number · status ·
5
+ * title · one-line decision) so "read the relevant ADR(s)" becomes "scan the
6
+ * catalog, open at most one". Shared by `adr-digest.mjs` (the CLI) and
7
+ * `context-pack.mjs` (the start-of-work bundle). No I/O — callers pass the text.
8
+ */
9
+ import { firstParagraph, metaValue, section } from '../../runtime/hooks/md-extract.mjs';
10
+
11
+ /** `<NNNN>-<slug>.md` — the ADR file shape (`_TEMPLATE.md` is excluded by callers). */
12
+ export const ADR_FILENAME_RE = /^(\d{4})-([a-z0-9._-]+)\.md$/;
13
+
14
+ /**
15
+ * Parses one ADR markdown string into a catalog record.
16
+ * @returns {{ok:boolean, number:string, title:string, status:string, decision:string, slug:string}}
17
+ */
18
+ export function parseAdr(text, filename = '') {
19
+ const safe = String(text || '').replace(/^/, '');
20
+ const lines = safe.split('\n');
21
+ const fm = ADR_FILENAME_RE.exec(filename) || [];
22
+ const number = fm[1] || '';
23
+ const rawTitle = (lines.find((l) => l.startsWith('# ')) || '').slice(2).trim();
24
+ const title = rawTitle.replace(/^ADR-\d{4}\s*[:—-]\s*/i, '').trim();
25
+ // Status keyword only (drop the parenthetical / HTML-comment tail).
26
+ const status = (metaValue(lines, 'Status').split(/[\s(<]/)[0] || '').trim();
27
+ const decision = firstParagraph(section(lines, 'decision'), 140);
28
+ // `ok` means we extracted a title/decision — a structureless file shows the
29
+ // `?` "open the file" marker rather than a misleadingly blank catalog line.
30
+ const ok = Boolean(rawTitle || decision);
31
+ return { ok, number: number || '????', title, status, decision, slug: fm[2] || '' };
32
+ }
33
+
34
+ /** One catalog line for a record, or `null` when unparseable (rule 8: a `?`, never dropped). */
35
+ export function renderCatalogLine(record) {
36
+ if (!record) return null;
37
+ const number = record.number || '????';
38
+ if (!record.ok) return `- **${number}** · ? · (unparseable — open the file)`;
39
+ const status = record.status || '?';
40
+ const decision = record.decision ? ` — ${record.decision}` : '';
41
+ return `- **${number}** · ${status} · ${record.title}${decision}`;
42
+ }
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * ADR digest — compact catalog of Architecture Decision Records. [ADR-0027]
4
+ *
5
+ * Replaces "read 3–5 ADRs to find the relevant one" (~110 lines each) with a
6
+ * ~1-line-per-ADR catalog (number · status · title · one-line decision), with an
7
+ * optional keyword filter. Read the catalog, then open at most ONE full ADR.
8
+ * Read-only, zero third-party deps. Parsing is single-sourced in `adr-digest-core.mjs`.
9
+ *
10
+ * Usage:
11
+ * node contextkit/tools/scripts/adr-digest.mjs # full catalog (human)
12
+ * node contextkit/tools/scripts/adr-digest.mjs --search token # only matching ADRs
13
+ * node contextkit/tools/scripts/adr-digest.mjs --last 5 # the 5 most recent
14
+ * node contextkit/tools/scripts/adr-digest.mjs --json
15
+ */
16
+ import { readFile, readdir } from 'node:fs/promises';
17
+ import { resolve } from 'node:path';
18
+ import { pathsFor } from '../../runtime/config/paths.mjs';
19
+ import { ADR_FILENAME_RE, parseAdr, renderCatalogLine } from './adr-digest-core.mjs';
20
+
21
+ const ROOT = process.cwd();
22
+ const P = pathsFor(ROOT);
23
+ const args = process.argv.slice(2);
24
+ const flag = (name) => args.includes(name);
25
+ const opt = (name) => {
26
+ const i = args.indexOf(name);
27
+ return i >= 0 ? args[i + 1] : undefined;
28
+ };
29
+
30
+ const readSafe = (abs) => readFile(abs, 'utf-8').catch(() => null);
31
+
32
+ /** ADR filenames (excluding `_TEMPLATE.md`), newest first (zero-padded numeric sort). */
33
+ async function listAdrFiles() {
34
+ let files = [];
35
+ try {
36
+ files = await readdir(P.decisions);
37
+ } catch {
38
+ return [];
39
+ }
40
+ return files.filter((f) => ADR_FILENAME_RE.test(f) && f !== '_TEMPLATE.md').sort().reverse();
41
+ }
42
+
43
+ async function main() {
44
+ const search = opt('--search');
45
+ const limit = Number.parseInt(opt('--last') || '0', 10) || 0;
46
+
47
+ const records = [];
48
+ for (const name of await listAdrFiles()) {
49
+ const text = await readSafe(resolve(P.decisions, name));
50
+ if (text !== null) records.push(parseAdr(text, name));
51
+ }
52
+
53
+ let selected = records;
54
+ if (search) {
55
+ const query = search.toLowerCase();
56
+ selected = records.filter((r) =>
57
+ `${r.number} ${r.title} ${r.decision} ${r.status} ${r.slug}`.toLowerCase().includes(query),
58
+ );
59
+ }
60
+ if (limit > 0) selected = selected.slice(0, limit);
61
+
62
+ if (flag('--json')) {
63
+ process.stdout.write(JSON.stringify({ count: selected.length, adrs: selected }, null, 2) + '\n');
64
+ return;
65
+ }
66
+ if (selected.length === 0) {
67
+ console.log(search ? `No ADRs match "${search}".` : 'No ADRs found (contextkit/memory/decisions/).');
68
+ return;
69
+ }
70
+ console.log(`\n🏛️ ADR catalog — ${selected.length} decision(s)${search ? ` matching "${search}"` : ''}, newest first\n`);
71
+ console.log(selected.map(renderCatalogLine).join('\n'));
72
+ console.log('\nOpen a full ADR in contextkit/memory/decisions/ only when you need its full context.');
73
+ }
74
+
75
+ main().catch((err) => {
76
+ console.error('❌ adr-digest failed:', err?.message ?? err);
77
+ process.exit(1);
78
+ });