forgecraft-mcp 1.4.0 → 1.7.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 (418) hide show
  1. package/LICENSE +67 -0
  2. package/README.md +527 -525
  3. package/dist/analyzers/anchors/anchor-loader.d.ts +47 -0
  4. package/dist/analyzers/anchors/anchor-loader.d.ts.map +1 -0
  5. package/dist/analyzers/anchors/anchor-loader.js +113 -0
  6. package/dist/analyzers/anchors/anchor-loader.js.map +1 -0
  7. package/dist/analyzers/anti-pattern.d.ts.map +1 -1
  8. package/dist/analyzers/anti-pattern.js +38 -26
  9. package/dist/analyzers/anti-pattern.js.map +1 -1
  10. package/dist/analyzers/completeness-helpers.d.ts +5 -0
  11. package/dist/analyzers/completeness-helpers.d.ts.map +1 -1
  12. package/dist/analyzers/completeness-helpers.js +17 -0
  13. package/dist/analyzers/completeness-helpers.js.map +1 -1
  14. package/dist/analyzers/completeness.d.ts.map +1 -1
  15. package/dist/analyzers/completeness.js +4 -4
  16. package/dist/analyzers/completeness.js.map +1 -1
  17. package/dist/analyzers/gs-scorer.d.ts +3 -1
  18. package/dist/analyzers/gs-scorer.d.ts.map +1 -1
  19. package/dist/analyzers/gs-scorer.js +5 -2
  20. package/dist/analyzers/gs-scorer.js.map +1 -1
  21. package/dist/analyzers/package-json.d.ts.map +1 -1
  22. package/dist/analyzers/package-json.js +194 -34
  23. package/dist/analyzers/package-json.js.map +1 -1
  24. package/dist/analyzers/scorers/composable-scorer.d.ts +4 -2
  25. package/dist/analyzers/scorers/composable-scorer.d.ts.map +1 -1
  26. package/dist/analyzers/scorers/composable-scorer.js +50 -2
  27. package/dist/analyzers/scorers/composable-scorer.js.map +1 -1
  28. package/dist/analyzers/scorers/executable-scorer.d.ts +3 -2
  29. package/dist/analyzers/scorers/executable-scorer.d.ts.map +1 -1
  30. package/dist/analyzers/scorers/executable-scorer.js +64 -4
  31. package/dist/analyzers/scorers/executable-scorer.js.map +1 -1
  32. package/dist/analyzers/scorers/scorer-utils.d.ts +5 -3
  33. package/dist/analyzers/scorers/scorer-utils.d.ts.map +1 -1
  34. package/dist/analyzers/scorers/scorer-utils.js +34 -9
  35. package/dist/analyzers/scorers/scorer-utils.js.map +1 -1
  36. package/dist/analyzers/scorers/self-describing-scorer.d.ts +7 -4
  37. package/dist/analyzers/scorers/self-describing-scorer.d.ts.map +1 -1
  38. package/dist/analyzers/scorers/self-describing-scorer.js +17 -18
  39. package/dist/analyzers/scorers/self-describing-scorer.js.map +1 -1
  40. package/dist/cli/help.js +51 -51
  41. package/dist/disciplines/catalog.d.ts +16 -0
  42. package/dist/disciplines/catalog.d.ts.map +1 -0
  43. package/dist/disciplines/catalog.js +196 -0
  44. package/dist/disciplines/catalog.js.map +1 -0
  45. package/dist/disciplines/runner.d.ts +13 -0
  46. package/dist/disciplines/runner.d.ts.map +1 -0
  47. package/dist/disciplines/runner.js +35 -0
  48. package/dist/disciplines/runner.js.map +1 -0
  49. package/dist/registry/composer.d.ts.map +1 -1
  50. package/dist/registry/composer.js +9 -4
  51. package/dist/registry/composer.js.map +1 -1
  52. package/dist/registry/loader-tag.d.ts.map +1 -1
  53. package/dist/registry/loader-tag.js +1 -0
  54. package/dist/registry/loader-tag.js.map +1 -1
  55. package/dist/registry/remote-gates.js +1 -1
  56. package/dist/registry/remote-gates.js.map +1 -1
  57. package/dist/registry/renderer-skeletons.js +92 -92
  58. package/dist/registry/sentinel-renderer.js +299 -20
  59. package/dist/registry/sentinel-renderer.js.map +1 -1
  60. package/dist/sentinel/detect.d.ts +41 -0
  61. package/dist/sentinel/detect.d.ts.map +1 -0
  62. package/dist/sentinel/detect.js +122 -0
  63. package/dist/sentinel/detect.js.map +1 -0
  64. package/dist/sentinel/write.d.ts +54 -0
  65. package/dist/sentinel/write.d.ts.map +1 -0
  66. package/dist/sentinel/write.js +75 -0
  67. package/dist/sentinel/write.js.map +1 -0
  68. package/dist/shared/cnt-health.d.ts +16 -0
  69. package/dist/shared/cnt-health.d.ts.map +1 -1
  70. package/dist/shared/cnt-health.js +55 -8
  71. package/dist/shared/cnt-health.js.map +1 -1
  72. package/dist/shared/config.d.ts +14 -0
  73. package/dist/shared/config.d.ts.map +1 -1
  74. package/dist/shared/config.js +45 -0
  75. package/dist/shared/config.js.map +1 -1
  76. package/dist/shared/gs-score-logger.js +6 -6
  77. package/dist/shared/hook-installer.d.ts +58 -0
  78. package/dist/shared/hook-installer.d.ts.map +1 -0
  79. package/dist/shared/hook-installer.js +316 -0
  80. package/dist/shared/hook-installer.js.map +1 -0
  81. package/dist/shared/project-gates-helpers.d.ts +9 -0
  82. package/dist/shared/project-gates-helpers.d.ts.map +1 -1
  83. package/dist/shared/project-gates-helpers.js +35 -0
  84. package/dist/shared/project-gates-helpers.js.map +1 -1
  85. package/dist/shared/types/config.d.ts +7 -1
  86. package/dist/shared/types/config.d.ts.map +1 -1
  87. package/dist/shared/types/gates.d.ts +34 -0
  88. package/dist/shared/types/gates.d.ts.map +1 -1
  89. package/dist/shared/types/project.d.ts +68 -2
  90. package/dist/shared/types/project.d.ts.map +1 -1
  91. package/dist/shared/types/project.js +1 -0
  92. package/dist/shared/types/project.js.map +1 -1
  93. package/dist/shared/types/templates.d.ts +8 -1
  94. package/dist/shared/types/templates.d.ts.map +1 -1
  95. package/dist/shared/types/verify.d.ts +51 -1
  96. package/dist/shared/types/verify.d.ts.map +1 -1
  97. package/dist/shared/types/verify.js +37 -1
  98. package/dist/shared/types/verify.js.map +1 -1
  99. package/dist/tools/add-hook.d.ts.map +1 -1
  100. package/dist/tools/add-hook.js +8 -1
  101. package/dist/tools/add-hook.js.map +1 -1
  102. package/dist/tools/add-module.js +123 -123
  103. package/dist/tools/advice-registry.d.ts.map +1 -1
  104. package/dist/tools/advice-registry.js +108 -18
  105. package/dist/tools/advice-registry.js.map +1 -1
  106. package/dist/tools/advise-session-advisor.d.ts +16 -0
  107. package/dist/tools/advise-session-advisor.d.ts.map +1 -0
  108. package/dist/tools/advise-session-advisor.js +89 -0
  109. package/dist/tools/advise-session-advisor.js.map +1 -0
  110. package/dist/tools/advise-session-signals.d.ts +21 -0
  111. package/dist/tools/advise-session-signals.d.ts.map +1 -0
  112. package/dist/tools/advise-session-signals.js +113 -0
  113. package/dist/tools/advise-session-signals.js.map +1 -0
  114. package/dist/tools/advise-session.d.ts +22 -0
  115. package/dist/tools/advise-session.d.ts.map +1 -0
  116. package/dist/tools/advise-session.js +31 -0
  117. package/dist/tools/advise-session.js.map +1 -0
  118. package/dist/tools/analyze-harness.d.ts +18 -0
  119. package/dist/tools/analyze-harness.d.ts.map +1 -0
  120. package/dist/tools/analyze-harness.js +298 -0
  121. package/dist/tools/analyze-harness.js.map +1 -0
  122. package/dist/tools/audit.d.ts.map +1 -1
  123. package/dist/tools/audit.js +19 -0
  124. package/dist/tools/audit.js.map +1 -1
  125. package/dist/tools/change-request.d.ts +53 -0
  126. package/dist/tools/change-request.d.ts.map +1 -0
  127. package/dist/tools/change-request.js +395 -0
  128. package/dist/tools/change-request.js.map +1 -0
  129. package/dist/tools/check-cascade-contracts.d.ts +13 -0
  130. package/dist/tools/check-cascade-contracts.d.ts.map +1 -1
  131. package/dist/tools/check-cascade-contracts.js +73 -2
  132. package/dist/tools/check-cascade-contracts.js.map +1 -1
  133. package/dist/tools/check-cascade-report.js +64 -64
  134. package/dist/tools/check-cascade-steps.d.ts +3 -0
  135. package/dist/tools/check-cascade-steps.d.ts.map +1 -1
  136. package/dist/tools/check-cascade-steps.js +104 -15
  137. package/dist/tools/check-cascade-steps.js.map +1 -1
  138. package/dist/tools/check-cascade.d.ts +4 -3
  139. package/dist/tools/check-cascade.d.ts.map +1 -1
  140. package/dist/tools/check-cascade.js +30 -12
  141. package/dist/tools/check-cascade.js.map +1 -1
  142. package/dist/tools/check-derivation-chain.d.ts +37 -0
  143. package/dist/tools/check-derivation-chain.d.ts.map +1 -0
  144. package/dist/tools/check-derivation-chain.js +418 -0
  145. package/dist/tools/check-derivation-chain.js.map +1 -0
  146. package/dist/tools/check-spec-consistency.d.ts +25 -0
  147. package/dist/tools/check-spec-consistency.d.ts.map +1 -0
  148. package/dist/tools/check-spec-consistency.js +339 -0
  149. package/dist/tools/check-spec-consistency.js.map +1 -0
  150. package/dist/tools/check-t4.d.ts +54 -0
  151. package/dist/tools/check-t4.d.ts.map +1 -0
  152. package/dist/tools/check-t4.js +305 -0
  153. package/dist/tools/check-t4.js.map +1 -0
  154. package/dist/tools/close-cycle.d.ts +11 -0
  155. package/dist/tools/close-cycle.d.ts.map +1 -1
  156. package/dist/tools/close-cycle.js +364 -4
  157. package/dist/tools/close-cycle.js.map +1 -1
  158. package/dist/tools/cnt-add-routing.d.ts +31 -0
  159. package/dist/tools/cnt-add-routing.d.ts.map +1 -0
  160. package/dist/tools/cnt-add-routing.js +99 -0
  161. package/dist/tools/cnt-add-routing.js.map +1 -0
  162. package/dist/tools/configure-mcp.d.ts.map +1 -1
  163. package/dist/tools/configure-mcp.js +52 -2
  164. package/dist/tools/configure-mcp.js.map +1 -1
  165. package/dist/tools/consolidate-status.d.ts +31 -0
  166. package/dist/tools/consolidate-status.d.ts.map +1 -1
  167. package/dist/tools/consolidate-status.js +105 -0
  168. package/dist/tools/consolidate-status.js.map +1 -1
  169. package/dist/tools/executable-gates.d.ts +52 -0
  170. package/dist/tools/executable-gates.d.ts.map +1 -0
  171. package/dist/tools/executable-gates.js +333 -0
  172. package/dist/tools/executable-gates.js.map +1 -0
  173. package/dist/tools/extract-adrs-from-spec.d.ts +33 -0
  174. package/dist/tools/extract-adrs-from-spec.d.ts.map +1 -0
  175. package/dist/tools/extract-adrs-from-spec.js +410 -0
  176. package/dist/tools/extract-adrs-from-spec.js.map +1 -0
  177. package/dist/tools/extract-adrs-history.d.ts +47 -0
  178. package/dist/tools/extract-adrs-history.d.ts.map +1 -0
  179. package/dist/tools/extract-adrs-history.js +265 -0
  180. package/dist/tools/extract-adrs-history.js.map +1 -0
  181. package/dist/tools/forgecraft-dispatch-extended.d.ts.map +1 -1
  182. package/dist/tools/forgecraft-dispatch-extended.js +137 -0
  183. package/dist/tools/forgecraft-dispatch-extended.js.map +1 -1
  184. package/dist/tools/forgecraft-dispatch.d.ts.map +1 -1
  185. package/dist/tools/forgecraft-dispatch.js +16 -0
  186. package/dist/tools/forgecraft-dispatch.js.map +1 -1
  187. package/dist/tools/forgecraft-schema-params.d.ts +174 -2
  188. package/dist/tools/forgecraft-schema-params.d.ts.map +1 -1
  189. package/dist/tools/forgecraft-schema-params.js +197 -0
  190. package/dist/tools/forgecraft-schema-params.js.map +1 -1
  191. package/dist/tools/forgecraft-schema.d.ts +179 -7
  192. package/dist/tools/forgecraft-schema.d.ts.map +1 -1
  193. package/dist/tools/forgecraft-schema.js +37 -0
  194. package/dist/tools/forgecraft-schema.js.map +1 -1
  195. package/dist/tools/generate-adr.js +6 -6
  196. package/dist/tools/generate-adr.js.map +1 -1
  197. package/dist/tools/generate-decision.d.ts +77 -0
  198. package/dist/tools/generate-decision.d.ts.map +1 -0
  199. package/dist/tools/generate-decision.js +162 -0
  200. package/dist/tools/generate-decision.js.map +1 -0
  201. package/dist/tools/generate-env-probe.d.ts +49 -0
  202. package/dist/tools/generate-env-probe.d.ts.map +1 -0
  203. package/dist/tools/generate-env-probe.js +365 -0
  204. package/dist/tools/generate-env-probe.js.map +1 -0
  205. package/dist/tools/generate-harness.d.ts +53 -0
  206. package/dist/tools/generate-harness.d.ts.map +1 -0
  207. package/dist/tools/generate-harness.js +395 -0
  208. package/dist/tools/generate-harness.js.map +1 -0
  209. package/dist/tools/generate-roadmap.d.ts +1 -1
  210. package/dist/tools/generate-roadmap.d.ts.map +1 -1
  211. package/dist/tools/generate-roadmap.js +38 -4
  212. package/dist/tools/generate-roadmap.js.map +1 -1
  213. package/dist/tools/generate-session-prompt.d.ts +3 -3
  214. package/dist/tools/generate-session-prompt.d.ts.map +1 -1
  215. package/dist/tools/generate-session-prompt.js +9 -1
  216. package/dist/tools/generate-session-prompt.js.map +1 -1
  217. package/dist/tools/generate-slo-probe.d.ts +53 -0
  218. package/dist/tools/generate-slo-probe.d.ts.map +1 -0
  219. package/dist/tools/generate-slo-probe.js +366 -0
  220. package/dist/tools/generate-slo-probe.js.map +1 -0
  221. package/dist/tools/layer-status-gates.d.ts +24 -0
  222. package/dist/tools/layer-status-gates.d.ts.map +1 -0
  223. package/dist/tools/layer-status-gates.js +151 -0
  224. package/dist/tools/layer-status-gates.js.map +1 -0
  225. package/dist/tools/layer-status.d.ts +126 -0
  226. package/dist/tools/layer-status.d.ts.map +1 -0
  227. package/dist/tools/layer-status.js +647 -0
  228. package/dist/tools/layer-status.js.map +1 -0
  229. package/dist/tools/list.d.ts.map +1 -1
  230. package/dist/tools/list.js +9 -5
  231. package/dist/tools/list.js.map +1 -1
  232. package/dist/tools/postcondition-coverage.d.ts +57 -0
  233. package/dist/tools/postcondition-coverage.d.ts.map +1 -0
  234. package/dist/tools/postcondition-coverage.js +256 -0
  235. package/dist/tools/postcondition-coverage.js.map +1 -0
  236. package/dist/tools/probe-runners.d.ts +21 -0
  237. package/dist/tools/probe-runners.d.ts.map +1 -0
  238. package/dist/tools/probe-runners.js +246 -0
  239. package/dist/tools/probe-runners.js.map +1 -0
  240. package/dist/tools/probe-templates.d.ts +27 -0
  241. package/dist/tools/probe-templates.d.ts.map +1 -0
  242. package/dist/tools/probe-templates.js +279 -0
  243. package/dist/tools/probe-templates.js.map +1 -0
  244. package/dist/tools/propose-session.d.ts +28 -0
  245. package/dist/tools/propose-session.d.ts.map +1 -0
  246. package/dist/tools/propose-session.js +333 -0
  247. package/dist/tools/propose-session.js.map +1 -0
  248. package/dist/tools/refresh-output.js +14 -14
  249. package/dist/tools/review-stubs.d.ts +29 -0
  250. package/dist/tools/review-stubs.d.ts.map +1 -0
  251. package/dist/tools/review-stubs.js +173 -0
  252. package/dist/tools/review-stubs.js.map +1 -0
  253. package/dist/tools/roadmap-builder.d.ts +49 -1
  254. package/dist/tools/roadmap-builder.d.ts.map +1 -1
  255. package/dist/tools/roadmap-builder.js +210 -5
  256. package/dist/tools/roadmap-builder.js.map +1 -1
  257. package/dist/tools/run-env-probe.d.ts +57 -0
  258. package/dist/tools/run-env-probe.d.ts.map +1 -0
  259. package/dist/tools/run-env-probe.js +270 -0
  260. package/dist/tools/run-env-probe.js.map +1 -0
  261. package/dist/tools/run-harness.d.ts +52 -0
  262. package/dist/tools/run-harness.d.ts.map +1 -0
  263. package/dist/tools/run-harness.js +279 -0
  264. package/dist/tools/run-harness.js.map +1 -0
  265. package/dist/tools/run-slo-probe.d.ts +50 -0
  266. package/dist/tools/run-slo-probe.d.ts.map +1 -0
  267. package/dist/tools/run-slo-probe.js +281 -0
  268. package/dist/tools/run-slo-probe.js.map +1 -0
  269. package/dist/tools/scaffold-spec-stubs.js +115 -115
  270. package/dist/tools/scaffold-templates.js +62 -62
  271. package/dist/tools/scaffold-writer.d.ts.map +1 -1
  272. package/dist/tools/scaffold-writer.js +9 -0
  273. package/dist/tools/scaffold-writer.js.map +1 -1
  274. package/dist/tools/score-rubric.d.ts +19 -0
  275. package/dist/tools/score-rubric.d.ts.map +1 -0
  276. package/dist/tools/score-rubric.js +411 -0
  277. package/dist/tools/score-rubric.js.map +1 -0
  278. package/dist/tools/session-prompt-builders.d.ts +20 -0
  279. package/dist/tools/session-prompt-builders.d.ts.map +1 -1
  280. package/dist/tools/session-prompt-builders.js +78 -5
  281. package/dist/tools/session-prompt-builders.js.map +1 -1
  282. package/dist/tools/session-prompt-sections.d.ts +4 -2
  283. package/dist/tools/session-prompt-sections.d.ts.map +1 -1
  284. package/dist/tools/session-prompt-sections.js +22 -10
  285. package/dist/tools/session-prompt-sections.js.map +1 -1
  286. package/dist/tools/setup-artifact-writers.d.ts +69 -4
  287. package/dist/tools/setup-artifact-writers.d.ts.map +1 -1
  288. package/dist/tools/setup-artifact-writers.js +681 -5
  289. package/dist/tools/setup-artifact-writers.js.map +1 -1
  290. package/dist/tools/setup-cnt-builders.d.ts.map +1 -1
  291. package/dist/tools/setup-cnt-builders.js +162 -34
  292. package/dist/tools/setup-cnt-builders.js.map +1 -1
  293. package/dist/tools/setup-monitoring.d.ts +41 -0
  294. package/dist/tools/setup-monitoring.d.ts.map +1 -0
  295. package/dist/tools/setup-monitoring.js +364 -0
  296. package/dist/tools/setup-monitoring.js.map +1 -0
  297. package/dist/tools/setup-phase1.d.ts.map +1 -1
  298. package/dist/tools/setup-phase1.js +14 -1
  299. package/dist/tools/setup-phase1.js.map +1 -1
  300. package/dist/tools/setup-phase2.d.ts +14 -0
  301. package/dist/tools/setup-phase2.d.ts.map +1 -1
  302. package/dist/tools/setup-phase2.js +130 -3
  303. package/dist/tools/setup-phase2.js.map +1 -1
  304. package/dist/tools/setup-project.d.ts +8 -0
  305. package/dist/tools/setup-project.d.ts.map +1 -1
  306. package/dist/tools/setup-project.js +52 -2
  307. package/dist/tools/setup-project.js.map +1 -1
  308. package/dist/tools/spec-parser-tags.d.ts.map +1 -1
  309. package/dist/tools/spec-parser-tags.js +1 -0
  310. package/dist/tools/spec-parser-tags.js.map +1 -1
  311. package/dist/tools/verify-formatter.d.ts.map +1 -1
  312. package/dist/tools/verify-formatter.js +15 -1
  313. package/dist/tools/verify-formatter.js.map +1 -1
  314. package/dist/tools/verify.d.ts.map +1 -1
  315. package/dist/tools/verify.js +3 -0
  316. package/dist/tools/verify.js.map +1 -1
  317. package/package.json +98 -89
  318. package/templates/analytics/instructions.yaml +37 -37
  319. package/templates/analytics/mcp-servers.yaml +11 -11
  320. package/templates/analytics/structure.yaml +25 -25
  321. package/templates/api/harness/uc-template.hurl +20 -0
  322. package/templates/api/instructions.yaml +231 -231
  323. package/templates/api/mcp-servers.yaml +22 -22
  324. package/templates/api/nfr.yaml +23 -23
  325. package/templates/api/review.yaml +103 -103
  326. package/templates/api/structure.yaml +34 -34
  327. package/templates/api/verification.yaml +132 -132
  328. package/templates/cli/instructions.yaml +31 -31
  329. package/templates/cli/mcp-servers.yaml +11 -11
  330. package/templates/cli/review.yaml +53 -53
  331. package/templates/cli/structure.yaml +16 -16
  332. package/templates/data-lineage/instructions.yaml +28 -28
  333. package/templates/data-lineage/mcp-servers.yaml +22 -22
  334. package/templates/data-pipeline/instructions.yaml +84 -84
  335. package/templates/data-pipeline/mcp-servers.yaml +13 -13
  336. package/templates/data-pipeline/nfr.yaml +39 -39
  337. package/templates/data-pipeline/structure.yaml +23 -23
  338. package/templates/docs-manifest.yaml +227 -0
  339. package/templates/fintech/hooks.yaml +55 -55
  340. package/templates/fintech/instructions.yaml +112 -112
  341. package/templates/fintech/mcp-servers.yaml +13 -13
  342. package/templates/fintech/nfr.yaml +46 -46
  343. package/templates/fintech/playbook.yaml +210 -210
  344. package/templates/fintech/verification.yaml +239 -239
  345. package/templates/game/harness/uc-template.sim.ts +29 -0
  346. package/templates/game/instructions.yaml +289 -289
  347. package/templates/game/mcp-servers.yaml +38 -38
  348. package/templates/game/nfr.yaml +64 -64
  349. package/templates/game/playbook.yaml +214 -214
  350. package/templates/game/review.yaml +97 -97
  351. package/templates/game/structure.yaml +67 -67
  352. package/templates/game/verification.yaml +174 -174
  353. package/templates/healthcare/instructions.yaml +42 -42
  354. package/templates/healthcare/mcp-servers.yaml +13 -13
  355. package/templates/healthcare/nfr.yaml +47 -47
  356. package/templates/hipaa/instructions.yaml +41 -41
  357. package/templates/hipaa/mcp-servers.yaml +13 -13
  358. package/templates/infra/instructions.yaml +104 -104
  359. package/templates/infra/mcp-servers.yaml +20 -20
  360. package/templates/infra/nfr.yaml +46 -46
  361. package/templates/infra/review.yaml +65 -65
  362. package/templates/infra/structure.yaml +25 -25
  363. package/templates/library/instructions.yaml +36 -36
  364. package/templates/library/mcp-servers.yaml +20 -20
  365. package/templates/library/review.yaml +56 -56
  366. package/templates/library/structure.yaml +19 -19
  367. package/templates/medallion-architecture/instructions.yaml +41 -41
  368. package/templates/medallion-architecture/mcp-servers.yaml +22 -22
  369. package/templates/ml/instructions.yaml +85 -85
  370. package/templates/ml/mcp-servers.yaml +11 -11
  371. package/templates/ml/nfr.yaml +39 -39
  372. package/templates/ml/structure.yaml +25 -25
  373. package/templates/ml/verification.yaml +156 -156
  374. package/templates/mobile/instructions.yaml +44 -44
  375. package/templates/mobile/mcp-servers.yaml +11 -11
  376. package/templates/mobile/nfr.yaml +49 -49
  377. package/templates/mobile/structure.yaml +27 -27
  378. package/templates/mobile/verification.yaml +121 -121
  379. package/templates/observability-xray/instructions.yaml +40 -40
  380. package/templates/observability-xray/mcp-servers.yaml +15 -15
  381. package/templates/realtime/instructions.yaml +42 -42
  382. package/templates/realtime/mcp-servers.yaml +13 -13
  383. package/templates/soc2/instructions.yaml +41 -41
  384. package/templates/soc2/mcp-servers.yaml +24 -24
  385. package/templates/social/instructions.yaml +43 -43
  386. package/templates/social/mcp-servers.yaml +24 -24
  387. package/templates/state-machine/instructions.yaml +42 -42
  388. package/templates/state-machine/mcp-servers.yaml +11 -11
  389. package/templates/tools-registry.yaml +164 -164
  390. package/templates/universal/claude-md-blocks/layer-navigation.md +20 -0
  391. package/templates/universal/claude-md-blocks/nfr-contracts.md +22 -0
  392. package/templates/universal/hooks.yaml +879 -723
  393. package/templates/universal/instructions.yaml +1692 -1692
  394. package/templates/universal/mcp-servers.yaml +50 -50
  395. package/templates/universal/nfr.yaml +197 -197
  396. package/templates/universal/reference.yaml +326 -326
  397. package/templates/universal/review.yaml +204 -204
  398. package/templates/universal/skills.yaml +262 -262
  399. package/templates/universal/structure.yaml +67 -67
  400. package/templates/universal/verification.yaml +416 -416
  401. package/templates/web-next/hooks.yaml +114 -0
  402. package/templates/web-next/instructions.yaml +106 -0
  403. package/templates/web-react/harness/uc-template.spec.ts +35 -0
  404. package/templates/web-react/hooks.yaml +156 -44
  405. package/templates/web-react/instructions.yaml +296 -207
  406. package/templates/web-react/mcp-servers.yaml +20 -20
  407. package/templates/web-react/nfr.yaml +27 -27
  408. package/templates/web-react/review.yaml +94 -94
  409. package/templates/web-react/structure.yaml +46 -46
  410. package/templates/web-react/verification.yaml +126 -126
  411. package/templates/web-static/hooks.yaml +85 -0
  412. package/templates/web-static/instructions.yaml +204 -115
  413. package/templates/web-static/mcp-servers.yaml +20 -20
  414. package/templates/web3/instructions.yaml +44 -44
  415. package/templates/web3/mcp-servers.yaml +11 -11
  416. package/templates/web3/verification.yaml +159 -159
  417. package/templates/zero-trust/instructions.yaml +41 -41
  418. package/templates/zero-trust/mcp-servers.yaml +15 -15
@@ -161,21 +161,25 @@ function buildPrdContent(projectName, aiFields) {
161
161
  ].join("\n");
162
162
  }
163
163
  /**
164
- * Write docs/use-cases.md using AI-extracted fields when available.
165
- * Never overwrites an existing use-cases.md.
164
+ * Write docs/use-cases.md from structured spec-derived use cases when available,
165
+ * or from AI-extracted fields as a fallback. Never overwrites an existing use-cases.md.
166
166
  *
167
167
  * @param projectDir - Project root directory
168
168
  * @param projectName - Project name for use case context
169
- * @param aiFields - AI-extracted problem, users, criteria
169
+ * @param aiFields - AI-extracted problem, users, criteria (fallback)
170
170
  * @param _specContent - Raw spec text (reserved for future use)
171
+ * @param useCases - Structured use cases extracted from the spec (preferred)
171
172
  * @returns True if a new use-cases.md was written
172
173
  */
173
- export function writeUseCases(projectDir, projectName, aiFields, _specContent) {
174
+ export function writeUseCases(projectDir, projectName, aiFields, _specContent, useCases) {
174
175
  const useCasesPath = join(projectDir, "docs", "use-cases.md");
175
176
  if (existsSync(useCasesPath))
176
177
  return false;
177
178
  mkdirSync(join(projectDir, "docs"), { recursive: true });
178
- writeFileSync(useCasesPath, buildUseCasesContent(projectName, aiFields), "utf-8");
179
+ const content = useCases && useCases.length > 0
180
+ ? buildStructuredUseCasesContent(projectName, useCases)
181
+ : buildUseCasesContent(projectName, aiFields);
182
+ writeFileSync(useCasesPath, content, "utf-8");
179
183
  return true;
180
184
  }
181
185
  function buildUseCasesContent(projectName, aiFields) {
@@ -224,6 +228,30 @@ function buildUseCasesContent(projectName, aiFields) {
224
228
  ].join("\n");
225
229
  return [`# Use Cases — ${projectName}`, ``, uc1, ``, uc2, ``, uc3, ``].join("\n");
226
230
  }
231
+ /**
232
+ * Build use-cases.md from structured UC data extracted by the AI from the spec.
233
+ * Produces the Precondition / Steps / Postcondition / Error Cases format that
234
+ * generate_harness and layer_status expect.
235
+ */
236
+ function buildStructuredUseCasesContent(projectName, useCases) {
237
+ const lines = [`# Use Cases — ${projectName}`, ``];
238
+ for (const uc of useCases) {
239
+ lines.push(`## ${uc.id}: ${uc.title}`, ``);
240
+ lines.push(`**Actor**: ${uc.actor}`);
241
+ lines.push(`**Precondition**: ${uc.precondition}`);
242
+ lines.push(`**Steps**:`);
243
+ uc.steps.forEach((step, i) => lines.push(` ${i + 1}. ${step}`));
244
+ lines.push(`**Postcondition**: ${uc.postcondition}`);
245
+ if (uc.errorCases && uc.errorCases.length > 0) {
246
+ lines.push(`**Error Cases**:`);
247
+ for (const ec of uc.errorCases) {
248
+ lines.push(` - ${ec.name}: ${ec.description}`);
249
+ }
250
+ }
251
+ lines.push(``);
252
+ }
253
+ return lines.join("\n");
254
+ }
227
255
  // ── Re-export deriveDefaultCascadeDecisions for convenience ──────────
228
256
  export { deriveDefaultCascadeDecisions };
229
257
  // ── Sample-outcome writer ─────────────────────────────────────────────
@@ -281,6 +309,654 @@ export function writeSampleOutcome(projectDir, toolName) {
281
309
  writeFileSync(outcomePath, content, "utf-8");
282
310
  return true;
283
311
  }
312
+ // ── Operation classification writer ──────────────────────────────────
313
+ /**
314
+ * Write docs/operation-classification.md — Tier 0–3 operation classification schema.
315
+ * Referenced by CLAUDE.md and the pre-tool-use hook.
316
+ * Never overwrites an existing file.
317
+ *
318
+ * @param projectDir - Project root
319
+ * @returns True if the file was written
320
+ */
321
+ export function writeOperationClassification(projectDir) {
322
+ const filePath = join(projectDir, "docs", "operation-classification.md");
323
+ if (existsSync(filePath))
324
+ return false;
325
+ mkdirSync(join(projectDir, "docs"), { recursive: true });
326
+ const content = [
327
+ `# Operation Classification — Tier 0–3 Gate`,
328
+ ``,
329
+ `> Referenced by CLAUDE.md and pre-tool-use hook.`,
330
+ `> Every AI-initiated operation must be classified before execution.`,
331
+ `> Tier 2+ requires human awareness. Tier 3 requires explicit authorization.`,
332
+ ``,
333
+ `## Tier 0 — Reversible (no confirmation needed)`,
334
+ ``,
335
+ `- Read operations (no side effects)`,
336
+ `- File edits with git history`,
337
+ `- Test runs (no DB side effects)`,
338
+ `- Documentation updates`,
339
+ `- Adding code / new files`,
340
+ ``,
341
+ `## Tier 1 — Recoverable with effort (warn, proceed)`,
342
+ ``,
343
+ `- \`git push\` to feature branch (can be reverted via revert commit)`,
344
+ `- Adding/updating dependencies`,
345
+ `- Environment variable changes (non-production)`,
346
+ `- Schema migrations on dev/test (reversible via rollback migration)`,
347
+ `- Config file changes`,
348
+ ``,
349
+ `## Tier 2 — Hard to recover (require human awareness)`,
350
+ ``,
351
+ `- \`git push\` to main (use PR — direct push blocked)`,
352
+ `- Full data resync / backfill operations`,
353
+ `- Schema migrations on production`,
354
+ `- Mass update queries with broad WHERE conditions`,
355
+ `- Adding dependencies >100 KB`,
356
+ `- Changing core architecture decisions (require ADR)`,
357
+ ``,
358
+ `## Tier 3 — Irreversible (blocked without FORGECRAFT_ALLOW_DESTRUCTIVE=1)`,
359
+ ``,
360
+ `- \`DROP TABLE\`, \`TRUNCATE\`, \`DELETE\` without specific WHERE`,
361
+ `- \`git push --force\` to main/master`,
362
+ `- \`rm -rf\` on source directories`,
363
+ `- Disabling security constraints (RLS, auth guards) in production`,
364
+ `- Hard delete of domain entities (use soft delete + audit log instead)`,
365
+ `- Dropping databases or clearing all data`,
366
+ ``,
367
+ `## Override Protocol`,
368
+ ``,
369
+ `For legitimate Tier 3 operations (emergency fixes, database resets):`,
370
+ `1. Document the reason in \`docs/status.md\``,
371
+ `2. Get explicit human confirmation`,
372
+ `3. Run with: \`FORGECRAFT_ALLOW_DESTRUCTIVE=1 <command>\``,
373
+ `4. Create an ADR if the operation represents a structural change`,
374
+ ].join("\n");
375
+ writeFileSync(filePath, content, "utf-8");
376
+ return true;
377
+ }
378
+ // ── Spec sub-doc stub writers ─────────────────────────────────────────
379
+ /**
380
+ * Write stub documentation files for large specs or specs with architecture/data model content.
381
+ * Creates docs/architecture.md, docs/data-model.md, docs/domain-glossary.md,
382
+ * and docs/test-architecture.md as stubs for the AI to populate from the spec.
383
+ * Never overwrites existing files.
384
+ *
385
+ * @param projectDir - Project root
386
+ * @param projectName - Project name
387
+ * @param specContent - Raw spec text (checked for size and content signals)
388
+ * @returns Array of file paths written
389
+ */
390
+ export function writeSpecSubDocStubs(projectDir, projectName, specContent) {
391
+ const written = [];
392
+ const docsDir = join(projectDir, "docs");
393
+ mkdirSync(docsDir, { recursive: true });
394
+ const specLines = specContent ? specContent.split("\n").length : 0;
395
+ const hasArchSignal = specContent
396
+ ? /architect|layer|component|infrastructure|service|repository/i.test(specContent)
397
+ : false;
398
+ const hasDataSignal = specContent
399
+ ? /entity|model|schema|table|relation|database|db\b/i.test(specContent)
400
+ : false;
401
+ // Always write if spec is large (>400 lines) or has architecture/data signals
402
+ const shouldWrite = specLines > 400 || hasArchSignal || hasDataSignal || !specContent;
403
+ if (!shouldWrite)
404
+ return written;
405
+ const architecturePath = join(docsDir, "architecture.md");
406
+ if (!existsSync(architecturePath)) {
407
+ writeFileSync(architecturePath, [
408
+ `# Architecture Overview`,
409
+ ``,
410
+ `> Extract from \`docs/PRD.md\` and the spec. Document the system architecture.`,
411
+ ``,
412
+ `## System Layers`,
413
+ ``,
414
+ `[Document the layer diagram here]`,
415
+ ``,
416
+ `## Component Diagram`,
417
+ ``,
418
+ `[Document the main components and their relationships]`,
419
+ ``,
420
+ `## Data Flow`,
421
+ ``,
422
+ `[Document how data flows through the system]`,
423
+ ``,
424
+ `## Integration Points`,
425
+ ``,
426
+ `[Document external systems and integration patterns]`,
427
+ ].join("\n"), "utf-8");
428
+ written.push("docs/architecture.md");
429
+ }
430
+ const dataModelPath = join(docsDir, "data-model.md");
431
+ if (!existsSync(dataModelPath)) {
432
+ writeFileSync(dataModelPath, [
433
+ `# Data Model`,
434
+ ``,
435
+ `> Extract from spec/PRD. Document all entities, relationships, and constraints.`,
436
+ ``,
437
+ `## Entities`,
438
+ ``,
439
+ `[List all primary entities with their fields]`,
440
+ ``,
441
+ `## Relationships`,
442
+ ``,
443
+ `[Document entity relationships]`,
444
+ ``,
445
+ `## Constraints & Invariants`,
446
+ ``,
447
+ `[Document business rules, uniqueness constraints, etc.]`,
448
+ ``,
449
+ `## Schema Notes`,
450
+ ``,
451
+ `[Naming conventions, migration strategy, etc.]`,
452
+ ].join("\n"), "utf-8");
453
+ written.push("docs/data-model.md");
454
+ }
455
+ const glossaryPath = join(docsDir, "domain-glossary.md");
456
+ if (!existsSync(glossaryPath)) {
457
+ writeFileSync(glossaryPath, [
458
+ `# Domain Glossary`,
459
+ ``,
460
+ `> Extract from spec. Define all domain terms used in code, tests, and docs.`,
461
+ `> Bilingual is fine if the team operates in two languages.`,
462
+ ``,
463
+ `| Term | Definition | Used in |`,
464
+ `|------|-----------|---------|`,
465
+ `| [term] | [definition] | [files/modules] |`,
466
+ ].join("\n"), "utf-8");
467
+ written.push("docs/domain-glossary.md");
468
+ }
469
+ const testArchPath = join(docsDir, "test-architecture.md");
470
+ if (!existsSync(testArchPath)) {
471
+ writeFileSync(testArchPath, buildTestArchitectureContent(projectName), "utf-8");
472
+ written.push("docs/test-architecture.md");
473
+ }
474
+ return written;
475
+ }
476
+ /**
477
+ * Build the test-architecture.md template content.
478
+ *
479
+ * @param _projectName - Project name (reserved for future customization)
480
+ * @returns Formatted test architecture content
481
+ */
482
+ function buildTestArchitectureContent(_projectName) {
483
+ return [
484
+ `# Test Architecture`,
485
+ ``,
486
+ `## Test Pyramid`,
487
+ ``,
488
+ `- **Unit tests** — domain logic, pure functions, no I/O`,
489
+ `- **Integration tests** — services with real adapters (DB, external APIs)`,
490
+ `- **E2E / smoke tests** — critical user journeys via Playwright or equivalent`,
491
+ ``,
492
+ `## TDD Protocol`,
493
+ ``,
494
+ `1. Write the failing test first: \`test(scope): [RED] description\``,
495
+ `2. Implement minimal code that passes: \`feat(scope): [GREEN] description\``,
496
+ `3. Refactor: \`refactor(scope): description\``,
497
+ ``,
498
+ `Never commit [GREEN] code without a [RED] commit for the same scope.`,
499
+ ``,
500
+ `## Coverage Targets`,
501
+ ``,
502
+ `- Global: ≥80%`,
503
+ `- Critical modules (auth, security, payments): ≥90%`,
504
+ `- Run: \`vitest run --coverage\``,
505
+ ``,
506
+ `## Pre-commit vs Pre-push`,
507
+ ``,
508
+ `- **Pre-commit**: \`vitest run --changed --passWithNoTests\` (affected tests only)`,
509
+ `- **Pre-push**: full test suite (\`vitest run\`)`,
510
+ ``,
511
+ `## Test Naming`,
512
+ ``,
513
+ `Adversarial naming: \`test_rejects_X\`, \`test_denies_Y\`, \`test_prevents_Z\`.`,
514
+ `Not: \`test_basic_flow\`, \`test_happy_path\`.`,
515
+ ``,
516
+ `## Test DB vs Dev DB`,
517
+ ``,
518
+ `Always use a separate test database/instance. Never run tests against dev or production.`,
519
+ ].join("\n");
520
+ }
521
+ // ── Agent definitions writer ──────────────────────────────────────────
522
+ /**
523
+ * Write generic sub-agent definitions to .claude/agents/.
524
+ * Agents are autonomous Claude Code sub-agents with specialized personas.
525
+ * Never overwrites existing files.
526
+ *
527
+ * @param projectDir - Project root
528
+ * @returns Array of agent filenames written
529
+ */
530
+ export function writeAgentDefinitions(projectDir) {
531
+ const agentsDir = join(projectDir, ".claude", "agents");
532
+ mkdirSync(agentsDir, { recursive: true });
533
+ const written = [];
534
+ const agents = [
535
+ {
536
+ filename: "test-hunter.md",
537
+ content: buildTestHunterAgent(),
538
+ },
539
+ {
540
+ filename: "spec-guardian.md",
541
+ content: buildSpecGuardianAgent(),
542
+ },
543
+ {
544
+ filename: "security-reviewer.md",
545
+ content: buildSecurityReviewerAgent(),
546
+ },
547
+ {
548
+ filename: "change-reviewer.md",
549
+ content: buildChangeReviewerAgent(),
550
+ },
551
+ ];
552
+ for (const agent of agents) {
553
+ const agentPath = join(agentsDir, agent.filename);
554
+ if (!existsSync(agentPath)) {
555
+ writeFileSync(agentPath, agent.content, "utf-8");
556
+ written.push(agent.filename);
557
+ }
558
+ }
559
+ return written;
560
+ }
561
+ function buildTestHunterAgent() {
562
+ return [
563
+ `---`,
564
+ `name: test-hunter`,
565
+ `description: >`,
566
+ ` Generates adversarial tests for a module or feature. Does NOT write happy-path`,
567
+ ` tests — that is the author's job. Finds inputs that break contracts, bypass`,
568
+ ` permissions, trigger race conditions, or violate invariants. Invoke when a module`,
569
+ ` has a base suite and needs adversarial hardening, before merging a sensitive feature,`,
570
+ ` or after a post-mortem (why didn't a test catch this?).`,
571
+ `tools: [Read, Glob, Grep, Bash]`,
572
+ `---`,
573
+ ``,
574
+ `# Test Hunter`,
575
+ ``,
576
+ `You are an attacker. Your job is NOT to verify the happy path works — the author`,
577
+ `already did that. Your job is to find the cracks.`,
578
+ ``,
579
+ `GS White Paper §4.3 _Verifiable_: "the test is a hunter, not a witness".`,
580
+ ``,
581
+ `## Principles`,
582
+ ``,
583
+ `1. **Against interfaces, never against implementation.** A test that breaks on a valid`,
584
+ ` refactor is a bad test.`,
585
+ `2. **Name the violation.** \`test_denies_X\`, \`test_rejects_X\`, \`test_survives_Y\`.`,
586
+ `3. **Cover attack classes, not examples.** One test for "leading whitespace" forces`,
587
+ ` coverage of the entire whitespace edge case class.`,
588
+ `4. **Race conditions count.** Two parallel mutations, two concurrent syncs.`,
589
+ ``,
590
+ `## Attack classes to consider`,
591
+ ``,
592
+ `- **Adversarial input**: empty, whitespace-only, very long (>1 MB), null on non-null`,
593
+ ` fields, Unicode edge cases (\\u0000, RTL, zero-width), numbers (0, -0, Infinity, NaN).`,
594
+ `- **Auth / permission bypass**: expired token, tampered claims, cross-tenant ID, anon`,
595
+ ` request to authenticated endpoint.`,
596
+ `- **Invalid state transitions**: archiving already-archived entity, deleting already-`,
597
+ ` deleted record, inconsistent field combinations (e.g., status='accepted' with rejection`,
598
+ ` fields populated).`,
599
+ `- **Idempotence**: run the same mutation twice → same result; re-sync same entity → no`,
600
+ ` duplicate.`,
601
+ `- **Race conditions**: two parallel updates to the same record; two concurrent jobs for`,
602
+ ` the same resource.`,
603
+ `- **Dirty data**: missing required fields from external API, malformed dates, negative`,
604
+ ` sizes, empty arrays where non-empty is expected.`,
605
+ ``,
606
+ `## How to work`,
607
+ ``,
608
+ `1. Read the target module and its existing test suite.`,
609
+ `2. Identify the **public contract** (exports, signatures, documented side effects).`,
610
+ `3. List applicable attack classes given the module's purpose.`,
611
+ `4. Write 5–15 targeted tests. One violation per test.`,
612
+ `5. Run the suite and report.`,
613
+ ``,
614
+ `## Output`,
615
+ ``,
616
+ `Add tests to the existing \`*.test.ts\` (or language equivalent). Then report:`,
617
+ ``,
618
+ `\`\`\`markdown`,
619
+ `# Test Hunter — <module>`,
620
+ `## Tests added (<N>)`,
621
+ `- Input adversarial: X`,
622
+ `- Auth/permissions: X`,
623
+ `- State transitions: X`,
624
+ `- Idempotence: X`,
625
+ `- Race conditions: X`,
626
+ `## Real bugs found (if any)`,
627
+ `## Not covered (and why)`,
628
+ `\`\`\``,
629
+ ].join("\n");
630
+ }
631
+ function buildSpecGuardianAgent() {
632
+ return [
633
+ `---`,
634
+ `name: spec-guardian`,
635
+ `description: >`,
636
+ ` Verifies the codebase is in sync with the spec (PRD.md, use-cases.md, ADRs,`,
637
+ ` data-model.md). Detects derivation gaps — code that contradicts the spec, spec`,
638
+ ` that has no implementation, and structural decisions without an ADR. Invoke before`,
639
+ ` cutting a release or when drift is suspected.`,
640
+ `tools: [Read, Glob, Grep, Bash]`,
641
+ `---`,
642
+ ``,
643
+ `# Spec Guardian`,
644
+ ``,
645
+ `Your job: make code and specification describe the same system. Any gap between them`,
646
+ `is a **derivation gap** (GS White Paper §6.4) and is as important as a bug.`,
647
+ ``,
648
+ `## What to check`,
649
+ ``,
650
+ `### 1. Spec → code (was it implemented?)`,
651
+ `For each section of docs/PRD.md, use-cases.md, ADRs:`,
652
+ `- Is there code that implements this decision?`,
653
+ `- If not: is it on the roadmap as pending?`,
654
+ `- If neither: 🚨 gap.`,
655
+ ``,
656
+ `### 2. Code → spec (is it documented?)`,
657
+ `For each module or structural decision in code:`,
658
+ `- Is there a spec or ADR justifying it?`,
659
+ `- If not and the decision is non-trivial: 🚨 missing ADR.`,
660
+ ``,
661
+ `### 3. Use cases → tests`,
662
+ `Each UC in use-cases.md should have test coverage. For each UC:`,
663
+ `- Do named tests exist?`,
664
+ `- If not: ⚠️ UC without coverage.`,
665
+ ``,
666
+ `### 4. ADR consistency`,
667
+ `- Are there ADRs that should be marked Superseded but aren't?`,
668
+ `- Are there structural decisions in commits that have no ADR?`,
669
+ ``,
670
+ `### 5. Conventions`,
671
+ `- Files > 300 lines (Bounded violation).`,
672
+ `- Functions > 50 lines.`,
673
+ `- Naming conventions (files: kebab-case, types: PascalCase, DB: snake_case).`,
674
+ `- Circular imports.`,
675
+ ``,
676
+ `## How to work`,
677
+ ``,
678
+ `1. Read docs/PRD.md and docs/use-cases.md.`,
679
+ `2. Run \`git log --oneline --since='7 days ago'\` for recent activity.`,
680
+ `3. For each ADR, find the corresponding implementation.`,
681
+ `4. For each module, find the spec that justifies it.`,
682
+ ``,
683
+ `## Output`,
684
+ ``,
685
+ `\`\`\`markdown`,
686
+ `# Spec Guardian — <date> — <branch>`,
687
+ `## Overall: ✅ Aligned / ⚠️ Minor drift / 🚨 Major gaps`,
688
+ `## Gaps found`,
689
+ `### 🚨 Major (block release)`,
690
+ `### ⚠️ Minor (create issue)`,
691
+ `### 🧹 Housekeeping`,
692
+ `## UC coverage`,
693
+ `| UC | Tests listed | Tests found | Status |`,
694
+ `## Missing ADRs`,
695
+ `## Next steps`,
696
+ `\`\`\``,
697
+ ].join("\n");
698
+ }
699
+ function buildSecurityReviewerAgent() {
700
+ return [
701
+ `---`,
702
+ `name: security-reviewer`,
703
+ `description: >`,
704
+ ` Reviews code changes for security issues: credential leaks, auth bypass, missing`,
705
+ ` input validation, unsafe operations, and violations of operation-classification.md.`,
706
+ ` Invoke before merging PRs that touch auth, API routes, or credential handling.`,
707
+ `tools: [Read, Glob, Grep, Bash]`,
708
+ `---`,
709
+ ``,
710
+ `# Security Reviewer`,
711
+ ``,
712
+ `Specialized reviewer for security concerns. Your output is a verdict; merging is done`,
713
+ `by a human.`,
714
+ ``,
715
+ `## What to review`,
716
+ ``,
717
+ `### 🚨 Credential leaks (zero tolerance)`,
718
+ `- No secrets committed. Check with: git grep -nE '...' on your staged files.`,
719
+ `- No \`.env\` files committed (only \`.env.example\`).`,
720
+ `- \`NEXT_PUBLIC_*\` variables contain nothing sensitive.`,
721
+ `- Service/admin credentials isolated to server-side code, never in client-side.`,
722
+ ``,
723
+ `### Auth on all endpoints`,
724
+ `For each new API route or server action:`,
725
+ `- First line calls auth check (\`requireAuth()\`, \`requireRole()\`, or equivalent).`,
726
+ `- Inputs validated with schema (Zod, Pydantic, etc.) — no assumed shape.`,
727
+ `- Outputs filtered — no leaking of internal IDs or sensitive columns.`,
728
+ ``,
729
+ `### Security constraints`,
730
+ `- Row-level or equivalent security active on data tables.`,
731
+ `- No policy/guard set to \`allow all\` without explicit justification.`,
732
+ `- Admin-only credentials not accessible from user-facing code paths.`,
733
+ ``,
734
+ `### Input validation`,
735
+ `- Path parameters validated — no \`../\` traversal possible.`,
736
+ `- Queries parameterized — no template string SQL.`,
737
+ `- File uploads: type and size checks present.`,
738
+ ``,
739
+ `### Destructive operations`,
740
+ `- Check against \`docs/operation-classification.md\`.`,
741
+ `- Any new Tier 2+ operation? Update that doc.`,
742
+ `- Any Tier 3 in automated code? 🚨 BLOCK.`,
743
+ ``,
744
+ `## How to work`,
745
+ ``,
746
+ `1. \`git diff main..HEAD --stat\` — inventory.`,
747
+ `2. Focus on auth, API routes, and credential handling.`,
748
+ `3. Cross-check with \`docs/operation-classification.md\`.`,
749
+ ``,
750
+ `## Output`,
751
+ ``,
752
+ `\`\`\`markdown`,
753
+ `# Security Review — <branch>`,
754
+ `## Verdict: ✅ APPROVE / ⚠️ APPROVE WITH CONCERNS / ❌ REQUEST CHANGES / 🚨 BLOCK`,
755
+ `## Findings`,
756
+ `### 🚨 Critical (block merge)`,
757
+ `### ❌ Must fix`,
758
+ `### ⚠️ Concerns`,
759
+ `### ✅ Good practice observed`,
760
+ `## Suggested tests`,
761
+ `\`\`\``,
762
+ ``,
763
+ `**Rule**: when in doubt, block. A conversation is cheaper than a breach.`,
764
+ ].join("\n");
765
+ }
766
+ function buildChangeReviewerAgent() {
767
+ return [
768
+ `---`,
769
+ `name: change-reviewer`,
770
+ `description: >`,
771
+ ` Reviews structural changes (new modules, refactors, schema changes) for`,
772
+ ` architecture conformance, naming conventions, layer violations, and missing ADRs.`,
773
+ ` Invoke when a PR touches architecture, data model, or adds a new domain module.`,
774
+ `tools: [Read, Glob, Grep, Bash]`,
775
+ `---`,
776
+ ``,
777
+ `# Change Reviewer`,
778
+ ``,
779
+ `Specialized reviewer for structural correctness. You catch architecture violations`,
780
+ `that regular code review misses.`,
781
+ ``,
782
+ `## What to review`,
783
+ ``,
784
+ `### Architecture conformance`,
785
+ `- Does the change respect the layer diagram in CLAUDE.md?`,
786
+ `- No imports from a higher layer (UI importing from DB, etc.).`,
787
+ `- No lateral imports between unrelated domains.`,
788
+ `- New shared utilities go to \`shared/\` — not duplicated across domains.`,
789
+ ``,
790
+ `### File bounds (GS Bounded property)`,
791
+ `- Files ≤ 300 lines.`,
792
+ `- Functions ≤ 50 lines.`,
793
+ `- One concern per file.`,
794
+ ``,
795
+ `### Naming and conventions`,
796
+ `- Files: kebab-case.ts`,
797
+ `- Types/classes: PascalCase`,
798
+ `- Variables/functions: camelCase`,
799
+ `- DB columns: snake_case`,
800
+ `- No abbreviations (except id, url, http, db, api).`,
801
+ ``,
802
+ `### ADR coverage`,
803
+ `- Does this change represent a structural decision?`,
804
+ `- If yes: is there an ADR in docs/adrs/?`,
805
+ `- If no ADR: this is a gap — flag it.`,
806
+ ``,
807
+ `### Test coverage`,
808
+ `- New business logic has unit tests.`,
809
+ `- New endpoints have integration tests.`,
810
+ `- Tests are adversarial (test_rejects_X), not just happy-path.`,
811
+ ``,
812
+ `### Idempotence and safety`,
813
+ `- New DB migrations are idempotent (IF NOT EXISTS, ON CONFLICT).`,
814
+ `- No raw string concatenation in queries.`,
815
+ `- New operations classified in docs/operation-classification.md if Tier 2+.`,
816
+ ``,
817
+ `## How to work`,
818
+ ``,
819
+ `1. \`git diff main..HEAD --stat\` — inventory of changed files.`,
820
+ `2. Read each new/modified file against the checklist above.`,
821
+ `3. Cross-check the layer diagram from CLAUDE.md.`,
822
+ `4. Check docs/adrs/ for coverage of structural decisions.`,
823
+ ``,
824
+ `## Output`,
825
+ ``,
826
+ `\`\`\`markdown`,
827
+ `# Change Review — <branch>`,
828
+ `## Verdict: ✅ APPROVE / ⚠️ NITS / ❌ REQUEST CHANGES`,
829
+ `## Changed files: <N>`,
830
+ `## Findings`,
831
+ `### ❌ Architecture violations (must fix)`,
832
+ `### ⚠️ Convention violations (should fix)`,
833
+ `### 📝 Missing ADRs`,
834
+ `### ✅ Good patterns observed`,
835
+ `## Suggested next steps`,
836
+ `\`\`\``,
837
+ ].join("\n");
838
+ }
839
+ // ── Project manifest writer ───────────────────────────────────────────
840
+ /**
841
+ * Write docs/manifest.yaml — canonical GS document taxonomy contract.
842
+ * Project-specific instance that references the canonical schema template.
843
+ * Never overwrites an existing manifest.
844
+ *
845
+ * @param projectDir - Project root
846
+ * @param projectName - Project name
847
+ * @param tags - Active project tags
848
+ * @returns True if the file was written
849
+ */
850
+ export function writeProjectManifest(projectDir, projectName, tags) {
851
+ const manifestPath = join(projectDir, "docs", "manifest.yaml");
852
+ if (existsSync(manifestPath))
853
+ return false;
854
+ mkdirSync(join(projectDir, "docs"), { recursive: true });
855
+ const projectType = inferProjectTypeFromTags(tags);
856
+ const date = new Date().toISOString().split("T")[0];
857
+ const lines = [
858
+ `# docs/manifest.yaml — GS document taxonomy contract for ${projectName}`,
859
+ `# Generated by ForgeCraft setup on ${date}`,
860
+ `# Schema: forgecraft/templates/docs-manifest.yaml`,
861
+ `#`,
862
+ `# This file declares which documents exist, where they live, and which commit`,
863
+ `# types require which doc updates. Tools (forgecraft, chronicle) read this`,
864
+ `# to enforce the doc-first cascade and avoid spec drift.`,
865
+ ``,
866
+ `schema_source: "forgecraft/templates/docs-manifest.yaml"`,
867
+ ``,
868
+ `project:`,
869
+ ` name: "${projectName}"`,
870
+ ` type: ${projectType}`,
871
+ ` release_phase: greenfield`,
872
+ ``,
873
+ `# Override canonical paths here if your layout differs from the default.`,
874
+ `# Example: documents.specs.path: docs/product/`,
875
+ `overrides: {}`,
876
+ ``,
877
+ `# Human-judgment gate — protects main from AI-only merges`,
878
+ `human_judgment:`,
879
+ ` protected_branches: [main, develop]`,
880
+ ` require_review: true`,
881
+ ` min_reviewers: 1`,
882
+ ` require_tests_pass: true`,
883
+ ` require_human_ack: true`,
884
+ ` block_ai_only_merge: true`,
885
+ ``,
886
+ `# Three-layer recording contract`,
887
+ `recording:`,
888
+ ` project:`,
889
+ ` owner: forgecraft`,
890
+ ` surface: "docs/* + .claude/hooks/*"`,
891
+ ` scope: cascade docs, gates, hooks, harness contracts`,
892
+ ` individual:`,
893
+ ` owner: chronicle`,
894
+ ` surface: "~/.chronicle/"`,
895
+ ` scope: prompt history, decisions, findings, work style`,
896
+ ];
897
+ writeFileSync(manifestPath, lines.join("\n") + "\n", "utf-8");
898
+ return true;
899
+ }
900
+ function inferProjectTypeFromTags(tags) {
901
+ if (tags.includes("WEB-NEXT") || tags.includes("WEB-REACT"))
902
+ return "app";
903
+ if (tags.includes("API"))
904
+ return "api";
905
+ if (tags.includes("CLI") && tags.includes("LIBRARY"))
906
+ return "tool";
907
+ if (tags.includes("CLI"))
908
+ return "cli";
909
+ if (tags.includes("LIBRARY"))
910
+ return "library";
911
+ return "service";
912
+ }
913
+ // ── Status writer ─────────────────────────────────────────────────────
914
+ /**
915
+ * Write docs/status.md — current project state and next steps.
916
+ * Gives AI assistants and humans a quick orientation at session start.
917
+ * Never overwrites an existing file.
918
+ *
919
+ * @param projectDir - Project root
920
+ * @param projectName - Project name
921
+ * @returns True if the file was written
922
+ */
923
+ export function writeStatusMd(projectDir, projectName) {
924
+ const statusPath = join(projectDir, "docs", "status.md");
925
+ if (existsSync(statusPath))
926
+ return false;
927
+ mkdirSync(join(projectDir, "docs"), { recursive: true });
928
+ const date = new Date().toISOString().split("T")[0];
929
+ const content = [
930
+ `# ${projectName} — Status`,
931
+ ``,
932
+ `> Last updated: ${date} (auto-generated by ForgeCraft setup)`,
933
+ `> Update this file at the end of each session. The Session Loop Invariant in CLAUDE.md`,
934
+ `> references this file for any unresolved items.`,
935
+ ``,
936
+ `## Current State`,
937
+ ``,
938
+ `<!-- FILL: brief 1-2 sentence description of the current project state -->`,
939
+ ``,
940
+ `## In Progress`,
941
+ ``,
942
+ `<!-- FILL: what is actively being worked on -->`,
943
+ ``,
944
+ `## Next`,
945
+ ``,
946
+ `<!-- FILL: first roadmap item or pending task — be specific enough to resume without re-reading everything -->`,
947
+ ``,
948
+ `## Open Issues / Blockers`,
949
+ ``,
950
+ `<!-- FILL: known issues, blockers, or technical debt that need resolution -->`,
951
+ ``,
952
+ `## Recent Decisions`,
953
+ ``,
954
+ `<!-- FILL: key decisions made recently — link to ADRs where they exist -->`,
955
+ ].join("\n");
956
+ writeFileSync(statusPath, content, "utf-8");
957
+ return true;
958
+ }
959
+ // ── Load cascade decisions ────────────────────────────────────────────
284
960
  /**
285
961
  * Load cascade decisions from forgecraft.yaml (convenience re-used in writers).
286
962
  */