@xulthekl/team-flow 0.22.4

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 (405) hide show
  1. package/.agents/plugins/marketplace.json +20 -0
  2. package/.agents/skills +1 -0
  3. package/.claude/always/phase-guard.md +3 -0
  4. package/.claude-plugin/marketplace.json +20 -0
  5. package/.claude-plugin/plugin.json +31 -0
  6. package/.codex-plugin/plugin.json +45 -0
  7. package/.codexignore +6 -0
  8. package/.cursor-plugin/marketplace.json +17 -0
  9. package/.cursor-plugin/plugin.json +31 -0
  10. package/.github/copilot-instructions.md +15 -0
  11. package/.github/dependabot.yml +10 -0
  12. package/.github/plugin/marketplace.json +42 -0
  13. package/.github/workflows/ci.yml +98 -0
  14. package/.github/workflows/hol-plugin-scanner.yml +17 -0
  15. package/.opencode/INSTALL.md +61 -0
  16. package/.opencode/plugins/team-flow.js +70 -0
  17. package/AGENTS.md +280 -0
  18. package/CHANGELOG.md +635 -0
  19. package/CONTRIBUTING.md +115 -0
  20. package/GEMINI.md +14 -0
  21. package/HANDOFF.md +219 -0
  22. package/INSTALL.md +810 -0
  23. package/LICENSE +21 -0
  24. package/README.md +185 -0
  25. package/SECURITY.md +37 -0
  26. package/agents/bug-investigator.md +180 -0
  27. package/agents/change-split-auditor.md +257 -0
  28. package/agents/code-reviewer.md +171 -0
  29. package/agents/cross-change-consistency-checker.md +215 -0
  30. package/agents/prd-completeness-reviewer.md +197 -0
  31. package/agents/prototype-builder.md +230 -0
  32. package/agents/prototype-env-scout.md +156 -0
  33. package/agents/prototype-reviewer.md +226 -0
  34. package/assets/icon.svg +6 -0
  35. package/dist/index.d.ts +13 -0
  36. package/dist/index.js +5 -0
  37. package/dist/parsing/change-parser.d.ts +12 -0
  38. package/dist/parsing/change-parser.js +54 -0
  39. package/dist/parsing/requirement-blocks.d.ts +31 -0
  40. package/dist/parsing/requirement-blocks.js +192 -0
  41. package/dist/schema/base.d.ts +7 -0
  42. package/dist/schema/base.js +1 -0
  43. package/dist/schema/change.d.ts +25 -0
  44. package/dist/schema/change.js +1 -0
  45. package/dist/schema/index.d.ts +3 -0
  46. package/dist/schema/index.js +1 -0
  47. package/dist/schema/spec.d.ts +11 -0
  48. package/dist/schema/spec.js +1 -0
  49. package/dist/validation/constants.d.ts +42 -0
  50. package/dist/validation/constants.js +42 -0
  51. package/dist/validation/tokenizer.d.ts +17 -0
  52. package/dist/validation/tokenizer.js +173 -0
  53. package/dist/validation/types.d.ts +40 -0
  54. package/dist/validation/types.js +1 -0
  55. package/dist/validation/validator.d.ts +21 -0
  56. package/dist/validation/validator.js +489 -0
  57. package/docs/README_en.md +358 -0
  58. package/docs/artifact-contract.md +96 -0
  59. package/docs/decision-points.md +88 -0
  60. package/docs/e2e-integration-design.md +207 -0
  61. package/docs/examples/README.md +25 -0
  62. package/docs/examples/add-dark-mode/README.md +13 -0
  63. package/docs/examples/add-dark-mode/design.md +49 -0
  64. package/docs/examples/add-dark-mode/execution-contract.md +56 -0
  65. package/docs/examples/add-dark-mode/proposal.md +46 -0
  66. package/docs/examples/add-dark-mode/specs/ui-theme/spec.md +35 -0
  67. package/docs/examples/add-dark-mode/tasks.md +26 -0
  68. package/docs/examples/refactor-auth-boundary/README.md +15 -0
  69. package/docs/examples/refactor-auth-boundary/design.md +41 -0
  70. package/docs/examples/refactor-auth-boundary/execution-contract.md +61 -0
  71. package/docs/examples/refactor-auth-boundary/proposal.md +47 -0
  72. package/docs/examples/refactor-auth-boundary/specs/auth-boundary/spec.md +45 -0
  73. package/docs/examples/refactor-auth-boundary/tasks.md +25 -0
  74. package/docs/plans/2026-07-07-fix-batch-design.md +68 -0
  75. package/docs/plans/2026-07-20-001-refactor-skill-collaboration-protocol-plan.md +128 -0
  76. package/docs/platform-matrix.md +45 -0
  77. package/docs/prototype-design-research.md +206 -0
  78. package/docs/release-checklist.md +96 -0
  79. package/docs/showcase.html +699 -0
  80. package/docs/skill-rename-v0.8.0.md +49 -0
  81. package/docs/state-machine.md +162 -0
  82. package/gemini-extension.json +6 -0
  83. package/hooks/hooks-cursor.json +8 -0
  84. package/hooks/hooks.json +26 -0
  85. package/hooks/pre-tool-use-guard +116 -0
  86. package/hooks/session-start +14 -0
  87. package/llms.txt +51 -0
  88. package/package.json +48 -0
  89. package/plugin.json +27 -0
  90. package/prd/v1/plan.md +443 -0
  91. package/prd/v1/prd.md +580 -0
  92. package/scripts/check-update.mjs +91 -0
  93. package/scripts/check-version-consistency.mjs +345 -0
  94. package/scripts/ensure-branch.mjs +71 -0
  95. package/scripts/get-config +31 -0
  96. package/scripts/guard/checks/artifacts-exist.mjs +36 -0
  97. package/scripts/guard/checks/contract-current.mjs +33 -0
  98. package/scripts/guard/checks/contract-fresh.mjs +17 -0
  99. package/scripts/guard/checks/dp-gate-passed.mjs +35 -0
  100. package/scripts/guard/checks/dp3-approved.mjs +22 -0
  101. package/scripts/guard/checks/execution-plan-ready.mjs +40 -0
  102. package/scripts/guard/checks/execution-reviews-passed.mjs +36 -0
  103. package/scripts/guard/checks/schema-valid.mjs +63 -0
  104. package/scripts/guard/checks/specs-merged.mjs +51 -0
  105. package/scripts/guard/checks/tasks-complete.mjs +31 -0
  106. package/scripts/guard/checks/tests-passing.mjs +31 -0
  107. package/scripts/guard/design-token-guard.mjs +237 -0
  108. package/scripts/guard/guard.mjs +205 -0
  109. package/scripts/infer-workflow.mjs +136 -0
  110. package/scripts/install-amazon-q.mjs +9 -0
  111. package/scripts/install-cline.mjs +9 -0
  112. package/scripts/install-continue.mjs +9 -0
  113. package/scripts/install-cursor.mjs +265 -0
  114. package/scripts/install-git-hooks.mjs +82 -0
  115. package/scripts/install-kiro.mjs +9 -0
  116. package/scripts/install-pi.mjs +9 -0
  117. package/scripts/install-qoder.mjs +9 -0
  118. package/scripts/install-qwen.mjs +9 -0
  119. package/scripts/install-roocode.mjs +9 -0
  120. package/scripts/install-windsurf.mjs +9 -0
  121. package/scripts/install-zcode.mjs +265 -0
  122. package/scripts/lib/cmd-audit.mjs +127 -0
  123. package/scripts/lib/cmd-checkpoint.mjs +118 -0
  124. package/scripts/lib/cmd-config.mjs +88 -0
  125. package/scripts/lib/cmd-doctor.mjs +267 -0
  126. package/scripts/lib/cmd-execution.mjs +206 -0
  127. package/scripts/lib/cmd-handoff.mjs +94 -0
  128. package/scripts/lib/cmd-inject.mjs +310 -0
  129. package/scripts/lib/cmd-install-amazon-q.mjs +11 -0
  130. package/scripts/lib/cmd-install-cline.mjs +11 -0
  131. package/scripts/lib/cmd-install-continue.mjs +11 -0
  132. package/scripts/lib/cmd-install-cursor.mjs +14 -0
  133. package/scripts/lib/cmd-install-kiro.mjs +11 -0
  134. package/scripts/lib/cmd-install-pi.mjs +11 -0
  135. package/scripts/lib/cmd-install-qoder.mjs +11 -0
  136. package/scripts/lib/cmd-install-qwen.mjs +11 -0
  137. package/scripts/lib/cmd-install-roocode.mjs +11 -0
  138. package/scripts/lib/cmd-install-windsurf.mjs +11 -0
  139. package/scripts/lib/cmd-install-workbuddy.mjs +359 -0
  140. package/scripts/lib/cmd-install-zcode.mjs +14 -0
  141. package/scripts/lib/cmd-isolate.mjs +37 -0
  142. package/scripts/lib/cmd-list.mjs +71 -0
  143. package/scripts/lib/cmd-runtime.mjs +85 -0
  144. package/scripts/lib/cmd-solutions.mjs +71 -0
  145. package/scripts/lib/cmd-state.mjs +231 -0
  146. package/scripts/lib/cmd-sync.mjs +102 -0
  147. package/scripts/lib/cmd-validate.mjs +105 -0
  148. package/scripts/lib/cmd-version.mjs +148 -0
  149. package/scripts/lib/config-loader.mjs +107 -0
  150. package/scripts/lib/execution-plan.mjs +492 -0
  151. package/scripts/lib/execution-recommendation.mjs +221 -0
  152. package/scripts/lib/hash.mjs +74 -0
  153. package/scripts/lib/install.mjs +267 -0
  154. package/scripts/lib/platform-runtime-inventory.mjs +27 -0
  155. package/scripts/lib/platforms.mjs +165 -0
  156. package/scripts/lib/prototype-sync.mjs +192 -0
  157. package/scripts/lib/sdd-overlay.mjs +262 -0
  158. package/scripts/lib/shell-quote.mjs +4 -0
  159. package/scripts/lib/solutions-capture.mjs +102 -0
  160. package/scripts/lib/solutions-index-gen.mjs +112 -0
  161. package/scripts/lib/solutions-inject.mjs +77 -0
  162. package/scripts/lib/solutions-promote.mjs +145 -0
  163. package/scripts/lib/spec-paths.mjs +85 -0
  164. package/scripts/lib/state-loader.mjs +154 -0
  165. package/scripts/lint/lint-skills.mjs +149 -0
  166. package/scripts/lint/rules/behavior-consistency.mjs +56 -0
  167. package/scripts/lint/rules/dp-trigger-points.mjs +60 -0
  168. package/scripts/lint/rules/exception-handling.mjs +59 -0
  169. package/scripts/lint/rules/no-contradictory-instructions.mjs +67 -0
  170. package/scripts/lint/rules/no-redundant-checks.mjs +50 -0
  171. package/scripts/lint/rules/token-rules.mjs +122 -0
  172. package/scripts/review-package +44 -0
  173. package/scripts/task-brief +40 -0
  174. package/scripts/team-flow.mjs +164 -0
  175. package/scripts/token-baseline.mjs +158 -0
  176. package/scripts/validate-artifacts +96 -0
  177. package/scripts/verify-marketplace-release.mjs +59 -0
  178. package/skills/architecture-design/SKILL.md +140 -0
  179. package/skills/architecture-design/chapters/ch01-4a-domains.md +27 -0
  180. package/skills/architecture-design/chapters/ch02-change-cascade.md +27 -0
  181. package/skills/architecture-design/chapters/ch03-architecture-outputs.md +25 -0
  182. package/skills/architecture-design/chapters/ch04-entity-to-aggregate.md +27 -0
  183. package/skills/architecture-design/chapters/ch05-cqrs.md +32 -0
  184. package/skills/architecture-design/chapters/ch06-integration.md +54 -0
  185. package/skills/architecture-design/cheatsheet.md +51 -0
  186. package/skills/architecture-design/glossary.md +23 -0
  187. package/skills/architecture-design/patterns.md +32 -0
  188. package/skills/bug-investigator/SKILL.md +77 -0
  189. package/skills/build-executor/SKILL.md +163 -0
  190. package/skills/build-executor/implementer-prompt.md +162 -0
  191. package/skills/build-executor/references/execution-modes.md +86 -0
  192. package/skills/build-executor/task-reviewer-prompt.md +195 -0
  193. package/skills/ce-brainstorm/SKILL.md +415 -0
  194. package/skills/ce-brainstorm/references/agents/slack-researcher.md +127 -0
  195. package/skills/ce-brainstorm/references/blindspot-pass.md +70 -0
  196. package/skills/ce-brainstorm/references/brainstorm-sections.md +285 -0
  197. package/skills/ce-brainstorm/references/handoff.md +168 -0
  198. package/skills/ce-brainstorm/references/html-rendering.md +634 -0
  199. package/skills/ce-brainstorm/references/markdown-rendering.md +241 -0
  200. package/skills/ce-brainstorm/references/model-tiers.md +9 -0
  201. package/skills/ce-brainstorm/references/prd-mapping.md +71 -0
  202. package/skills/ce-brainstorm/references/product-pressure-test.md +42 -0
  203. package/skills/ce-brainstorm/references/reasoning-elevation.md +63 -0
  204. package/skills/ce-brainstorm/references/settled-decisions.md +45 -0
  205. package/skills/ce-brainstorm/references/synthesis-summary.md +282 -0
  206. package/skills/ce-brainstorm/references/universal-brainstorming.md +73 -0
  207. package/skills/ce-brainstorm/references/verdict-routing.md +26 -0
  208. package/skills/ce-brainstorm/references/visual-probes.md +158 -0
  209. package/skills/ce-brainstorm/scripts/visual-probe-server.js +418 -0
  210. package/skills/ce-compound/SKILL.md +114 -0
  211. package/skills/ce-compound/assets/resolution-template.md +94 -0
  212. package/skills/ce-compound/references/agents/best-practices-researcher.md +115 -0
  213. package/skills/ce-compound/references/agents/data-integrity-guardian.md +68 -0
  214. package/skills/ce-compound/references/agents/framework-docs-researcher.md +93 -0
  215. package/skills/ce-compound/references/agents/pattern-recognition-specialist.md +55 -0
  216. package/skills/ce-compound/references/agents/performance-oracle.md +108 -0
  217. package/skills/ce-compound/references/agents/security-sentinel.md +91 -0
  218. package/skills/ce-compound/references/agents/session-historian.md +83 -0
  219. package/skills/ce-compound/references/concepts-vocabulary.md +78 -0
  220. package/skills/ce-compound/references/full-mode-workflow.md +413 -0
  221. package/skills/ce-compound/references/grounding-validation.md +84 -0
  222. package/skills/ce-compound/references/lightweight-mode.md +53 -0
  223. package/skills/ce-compound/references/output-standards.md +182 -0
  224. package/skills/ce-compound/references/promotion-rules.md +38 -0
  225. package/skills/ce-compound/references/schema.yaml +231 -0
  226. package/skills/ce-compound/references/three-tier-index.md +55 -0
  227. package/skills/ce-compound/references/v0.5-upgrade.md +32 -0
  228. package/skills/ce-compound/references/write-flow.md +36 -0
  229. package/skills/ce-compound/references/yaml-schema.md +118 -0
  230. package/skills/ce-compound/scripts/session-history/discover-sessions.sh +130 -0
  231. package/skills/ce-compound/scripts/session-history/extract-errors.py +254 -0
  232. package/skills/ce-compound/scripts/session-history/extract-metadata.py +456 -0
  233. package/skills/ce-compound/scripts/session-history/extract-skeleton.py +575 -0
  234. package/skills/ce-compound/scripts/validate-doc-claims.py +346 -0
  235. package/skills/ce-compound/scripts/validate-frontmatter.py +137 -0
  236. package/skills/ce-ideate/SKILL.md +402 -0
  237. package/skills/ce-ideate/references/agents/issue-intelligence-analyst.md +200 -0
  238. package/skills/ce-ideate/references/agents/learnings-researcher.md +247 -0
  239. package/skills/ce-ideate/references/agents/slack-researcher.md +127 -0
  240. package/skills/ce-ideate/references/agents/web-researcher.md +121 -0
  241. package/skills/ce-ideate/references/divergent-ideation.md +89 -0
  242. package/skills/ce-ideate/references/html-rendering.md +634 -0
  243. package/skills/ce-ideate/references/ideation-sections.md +191 -0
  244. package/skills/ce-ideate/references/markdown-rendering.md +238 -0
  245. package/skills/ce-ideate/references/post-ideation-workflow.md +167 -0
  246. package/skills/ce-ideate/references/universal-ideation.md +107 -0
  247. package/skills/ce-ideate/references/web-research-cache.md +56 -0
  248. package/skills/ce-plan/SKILL.md +137 -0
  249. package/skills/ce-plan/references/agents/agent-native-planning-strategist.md +62 -0
  250. package/skills/ce-plan/references/agents/architecture-strategist.md +46 -0
  251. package/skills/ce-plan/references/agents/best-practices-researcher.md +114 -0
  252. package/skills/ce-plan/references/agents/data-integrity-guardian.md +68 -0
  253. package/skills/ce-plan/references/agents/data-migration-reviewer.md +103 -0
  254. package/skills/ce-plan/references/agents/deployment-verification-agent.md +157 -0
  255. package/skills/ce-plan/references/agents/framework-docs-researcher.md +93 -0
  256. package/skills/ce-plan/references/agents/git-history-analyzer.md +40 -0
  257. package/skills/ce-plan/references/agents/learnings-researcher.md +247 -0
  258. package/skills/ce-plan/references/agents/pattern-recognition-specialist.md +55 -0
  259. package/skills/ce-plan/references/agents/performance-oracle.md +108 -0
  260. package/skills/ce-plan/references/agents/repo-research-analyst.md +258 -0
  261. package/skills/ce-plan/references/agents/security-sentinel.md +91 -0
  262. package/skills/ce-plan/references/agents/slack-researcher.md +127 -0
  263. package/skills/ce-plan/references/agents/spec-flow-analyzer.md +80 -0
  264. package/skills/ce-plan/references/agents/web-researcher.md +121 -0
  265. package/skills/ce-plan/references/approach-altitude.md +55 -0
  266. package/skills/ce-plan/references/change-splitting.md +65 -0
  267. package/skills/ce-plan/references/completion-contract.md +33 -0
  268. package/skills/ce-plan/references/core-principles.md +40 -0
  269. package/skills/ce-plan/references/deepening-workflow.md +263 -0
  270. package/skills/ce-plan/references/dependency-graph.md +36 -0
  271. package/skills/ce-plan/references/html-rendering.md +634 -0
  272. package/skills/ce-plan/references/intake-routing.md +189 -0
  273. package/skills/ce-plan/references/markdown-rendering.md +238 -0
  274. package/skills/ce-plan/references/plan-handoff.md +150 -0
  275. package/skills/ce-plan/references/plan-sections.md +427 -0
  276. package/skills/ce-plan/references/plan-structure.md +120 -0
  277. package/skills/ce-plan/references/planning-modes.md +69 -0
  278. package/skills/ce-plan/references/reasoning-elevation.md +63 -0
  279. package/skills/ce-plan/references/research-workflow.md +165 -0
  280. package/skills/ce-plan/references/review-and-write.md +127 -0
  281. package/skills/ce-plan/references/settled-decisions.md +45 -0
  282. package/skills/ce-plan/references/synthesis-summary.md +418 -0
  283. package/skills/ce-plan/references/universal-planning.md +168 -0
  284. package/skills/ce-proof/SKILL.md +346 -0
  285. package/skills/ce-strategy/SKILL.md +97 -0
  286. package/skills/ce-strategy/references/interview.md +143 -0
  287. package/skills/ce-strategy/references/strategy-template.md +89 -0
  288. package/skills/code-reviewer/SKILL.md +84 -0
  289. package/skills/code-reviewer/code-reviewer-prompt.md +195 -0
  290. package/skills/contract-builder/SKILL.md +72 -0
  291. package/skills/design-system/SKILL.md +75 -0
  292. package/skills/design-system/references/agents/design-system-architect.md +138 -0
  293. package/skills/design-system/references/creation-flow.md +170 -0
  294. package/skills/design-system/references/preview-template.html +319 -0
  295. package/skills/design-system/references/token-derivation.md +115 -0
  296. package/skills/design-system/references/variant-schema.md +60 -0
  297. package/skills/e2e/SKILL.md +56 -0
  298. package/skills/e2e/references/test-verifier.md +40 -0
  299. package/skills/need-explorer/SKILL.md +79 -0
  300. package/skills/prototype/SKILL.md +98 -0
  301. package/skills/prototype/references/agents/design-system-architect.md +122 -0
  302. package/skills/prototype/references/checklist.md +82 -0
  303. package/skills/prototype/references/craft/accessibility-baseline.md +71 -0
  304. package/skills/prototype/references/craft/anti-ai-slop.md +87 -0
  305. package/skills/prototype/references/craft/laws-of-ux.md +60 -0
  306. package/skills/prototype/references/craft/state-coverage.md +81 -0
  307. package/skills/prototype/references/craft/typography-hierarchy.md +50 -0
  308. package/skills/prototype/references/layouts.md +223 -0
  309. package/skills/prototype/references/orchestration-flow.md +101 -0
  310. package/skills/prototype/references/prototype-scaffold/assets/design-tokens.css +19 -0
  311. package/skills/prototype/references/prototype-scaffold/components/button.html +3 -0
  312. package/skills/prototype/references/prototype-scaffold/design-system.md +7 -0
  313. package/skills/prototype/references/prototype-scaffold/flow.md +11 -0
  314. package/skills/prototype/references/prototype-scaffold/index.html +20 -0
  315. package/skills/prototype/references/prototype-scaffold/pages/index.html +11 -0
  316. package/skills/prototype/references/template.html +396 -0
  317. package/skills/release-archivist/SKILL.md +166 -0
  318. package/skills/release-archivist/references/closing-procedures.md +81 -0
  319. package/skills/session-handoff/SKILL.md +110 -0
  320. package/skills/session-handoff/references/context-extraction.md +70 -0
  321. package/skills/session-handoff/references/handoff-template.md +90 -0
  322. package/skills/session-handoff/references/skill-recommendation.md +43 -0
  323. package/skills/spec-merger/SKILL.md +66 -0
  324. package/skills/spec-writer/SKILL.md +149 -0
  325. package/skills/workflow-bootstrap/SKILL.md +148 -0
  326. package/skills/workflow-bootstrap/references/agents/codebase-recon-analyst.md +121 -0
  327. package/skills/workflow-bootstrap/references/b1-reconnaissance.md +80 -0
  328. package/skills/workflow-bootstrap/scripts/recon-probe.sh +328 -0
  329. package/skills/workflow-feedback/SKILL.md +120 -0
  330. package/skills/workflow-feedback/references/category-guide.md +121 -0
  331. package/skills/workflow-feedback/references/feedback-template.md +73 -0
  332. package/skills/workflow-feedback/references/review-mode.md +92 -0
  333. package/skills/workflow-orchestrator/SKILL.md +94 -0
  334. package/skills/workflow-orchestrator/references/feedback-loops.md +56 -0
  335. package/skills/workflow-orchestrator/references/s1-path-router.md +81 -0
  336. package/skills/workflow-orchestrator/references/s2-prd-prototype-loop.md +96 -0
  337. package/skills/workflow-orchestrator/references/s3-plan-pipeline.md +50 -0
  338. package/skills/workflow-orchestrator/references/s4-split-validate.md +108 -0
  339. package/skills/workflow-orchestrator/references/s5-monitoring.md +61 -0
  340. package/skills/workflow-orchestrator/references/state-model.md +185 -0
  341. package/skills/workflow-start/SKILL.md +147 -0
  342. package/skills/workflow-start/references/routing-rules.md +155 -0
  343. package/src/index.ts +16 -0
  344. package/src/parsing/change-parser.ts +79 -0
  345. package/src/parsing/requirement-blocks.ts +244 -0
  346. package/src/schema/base.ts +8 -0
  347. package/src/schema/change.ts +29 -0
  348. package/src/schema/index.ts +3 -0
  349. package/src/schema/spec.ts +12 -0
  350. package/src/validation/constants.ts +53 -0
  351. package/src/validation/tokenizer.ts +180 -0
  352. package/src/validation/types.ts +47 -0
  353. package/src/validation/validator.ts +552 -0
  354. package/templates/abandonment-summary.md +29 -0
  355. package/templates/design.md +37 -0
  356. package/templates/execution-contract.md +99 -0
  357. package/templates/plan.md +86 -0
  358. package/templates/prd.md +468 -0
  359. package/templates/proposal.md +37 -0
  360. package/templates/spec.md +31 -0
  361. package/templates/tasks.md +47 -0
  362. package/tests/e2e.test.mjs +266 -0
  363. package/tests/lib/cmd-audit.test.mjs +202 -0
  364. package/tests/lib/cmd-checkpoint.test.mjs +98 -0
  365. package/tests/lib/cmd-config.test.mjs +101 -0
  366. package/tests/lib/cmd-doctor.test.mjs +450 -0
  367. package/tests/lib/cmd-execution.test.mjs +647 -0
  368. package/tests/lib/cmd-handoff.test.mjs +137 -0
  369. package/tests/lib/cmd-inject.test.mjs +218 -0
  370. package/tests/lib/cmd-install-workbuddy.test.mjs +113 -0
  371. package/tests/lib/cmd-install-zcode.test.mjs +42 -0
  372. package/tests/lib/cmd-isolate.test.mjs +68 -0
  373. package/tests/lib/cmd-list.test.mjs +127 -0
  374. package/tests/lib/cmd-runtime.test.mjs +83 -0
  375. package/tests/lib/cmd-state-missing.test.mjs +65 -0
  376. package/tests/lib/cmd-state.test.mjs +365 -0
  377. package/tests/lib/cmd-sync-paths.test.mjs +84 -0
  378. package/tests/lib/cmd-validate-paths.test.mjs +90 -0
  379. package/tests/lib/config-loader.test.mjs +175 -0
  380. package/tests/lib/ensure-branch.test.mjs +59 -0
  381. package/tests/lib/execution-control-plane.test.mjs +168 -0
  382. package/tests/lib/execution-plan.test.mjs +474 -0
  383. package/tests/lib/guard-specs-merged.test.mjs +108 -0
  384. package/tests/lib/guard-tests-passing.test.mjs +112 -0
  385. package/tests/lib/guard-transitions.test.mjs +262 -0
  386. package/tests/lib/guard.test.mjs +611 -0
  387. package/tests/lib/hash.test.mjs +138 -0
  388. package/tests/lib/infer-workflow.test.mjs +161 -0
  389. package/tests/lib/install-git-hooks.test.mjs +20 -0
  390. package/tests/lib/marketplace-release-docs.test.mjs +31 -0
  391. package/tests/lib/minimality-discipline.test.mjs +37 -0
  392. package/tests/lib/model-profiles-docs.test.mjs +33 -0
  393. package/tests/lib/node20-compatibility.test.mjs +73 -0
  394. package/tests/lib/node20-test-entry.test.mjs +17 -0
  395. package/tests/lib/platform-runtime-distribution.test.mjs +150 -0
  396. package/tests/lib/raw-mode-smoke.test.mjs +42 -0
  397. package/tests/lib/sdd-overlay.test.mjs +118 -0
  398. package/tests/lib/spec-paths.test.mjs +80 -0
  399. package/tests/lib/state-loader.test.mjs +251 -0
  400. package/tests/lib/token-baseline.test.mjs +72 -0
  401. package/tests/lib/token-rules.test.mjs +94 -0
  402. package/tests/lib/verify-marketplace-release.test.mjs +128 -0
  403. package/tests/tsconfig.json +12 -0
  404. package/token-baseline.json +95 -0
  405. package/tsconfig.json +14 -0
@@ -0,0 +1,226 @@
1
+ ---
2
+ name: prototype-reviewer
3
+ description: >-
4
+ 原型 vs PRD 一致性自动评审。在原型产出后、人工评审前,独立检查原型与 PRD
5
+ 的结构化一致性(6 维度),输出分级一致性报告。只读审查,不修改任何文件。
6
+ Examples:
7
+
8
+ <example>
9
+ Context: 原型刚产出,orchestrator 需要在人工评审前做自动一致性检查。
10
+ user: "原型做好了,帮我检查一下和 PRD 是否一致"
11
+ assistant: "我来启动 prototype-reviewer agent,独立审查原型与 PRD 的 6 维度一致性。"
12
+ <commentary>
13
+ 原型自动评审是 orchestrator S2 阶段的关键门禁。prototype-reviewer 在独立上下文中运行,
14
+ 未参与 PRD/原型产出,规避锚定效应。审查报告写在 response 中,由编排层落盘。
15
+ </commentary>
16
+ </example>
17
+
18
+ <example>
19
+ Context: 原型经过修正后需要重新评审(第 2 轮)。
20
+ user: "原型修正完了,重新跑一下一致性检查"
21
+ assistant: "我启动 prototype-reviewer agent 进行第 2 轮自动评审,对比修正前后不一致项是否收敛。"
22
+ <commentary>
23
+ FAIL 后修正→重新评审,最多 3 轮。连续两轮不一致项集合无缩小则转人工,避免死循环。
24
+ </commentary>
25
+ </example>
26
+
27
+ <example>
28
+ Context: 用户想确认原型是否覆盖了 PRD 中定义的所有页面和功能。
29
+ user: "PRD 里定义了 8 个页面,原型是不是都有了?"
30
+ assistant: "让 prototype-reviewer agent 做一次 D1 页面完整性 + D2 功能覆盖的结构化检查。"
31
+ <commentary>
32
+ D1/D4 走 Pre-check(Bash 结构化预检),机械化验证页面文件存在性和导航链接完整性。
33
+ </commentary>
34
+ </example>
35
+
36
+ <example>
37
+ Context: 人工评审前想先过一遍术语和字段是否对齐。
38
+ user: "帮我看看原型里的字段名称和 PRD 定义的是否一致"
39
+ assistant: "我启动 prototype-reviewer agent 做 D3 字段一致性 + D5 术语一致性的语义对比。"
40
+ <commentary>
41
+ D3/D5 走 Deep-check(LLM 语义对比),标注为建议级,误报可被人工推翻。
42
+ </commentary>
43
+ </example>
44
+
45
+ model: inherit
46
+ color: green
47
+ tools: ["Read", "Bash", "Grep", "Glob"]
48
+ ---
49
+
50
+ You are an independent Prototype Consistency Reviewer. You check whether an HTML prototype is structurally and semantically consistent with its PRD. You produce a graded consistency report across 6 dimensions. You NEVER modify any file — your role is strictly read-only analysis.
51
+
52
+ ## The Iron Law
53
+
54
+ You are an independent reviewer. You did NOT participate in producing the PRD or the prototype. You read both artifacts fresh, compare them structurally, and report findings. You must NEVER write, edit, create, or delete any file. Your report is delivered in your response — the orchestration layer persists it to `prd/vN/prototype-auto-review.md`.
55
+
56
+ ## Inputs
57
+
58
+ | Parameter | Description |
59
+ |-----------|-------------|
60
+ | `prd_path` | PRD 文件路径(e.g., `prd/v1/prd.md`) |
61
+ | `prototype_path` | 原型目录路径(e.g., `prototype/`) |
62
+
63
+ If either path is missing or unreadable, report `FAIL` with reason `INPUT_ERROR`.
64
+
65
+ ## 6-Dimension Checklist
66
+
67
+ | Dim | Name | PRD Source | Check Content | Severity |
68
+ |-----|------|-----------|---------------|----------|
69
+ | D1 | 页面完整性 | §4 画面原型 | 每个 PRD 定义的页面是否有对应 HTML 文件 + 导航链接可达 | Critical |
70
+ | D2 | 功能覆盖 | §7 系统功能清单 | 每个 UI 功能是否有对应交互元素(按钮/表单/链接) | Critical |
71
+ | D3 | 字段一致性 | §8.4 功能模块 | PRD 定义的字段是否在对应表单/表格中体现 | Important |
72
+ | D4 | 导航一致性 | §8.2.2 画面交互 | 页面跳转关系是否与 PRD 定义的流程一致 | Important |
73
+ | D5 | 术语一致性 | §6 业务术语 + CONCEPTS.md | 原型中的标签/术语是否与 PRD 和 CONCEPTS.md 一致 | Minor |
74
+ | D6 | 状态覆盖 | §8.2.3 异常状态 | 空态/错误态/加载态是否在原型中体现 | Important |
75
+
76
+ **D6 N/A 机制**:自包含 HTML 原型用静态 mock,加载/空状态结构性无法体现时,标 `N/A` 并注明理由。N/A 不计入 Important,不阻断判定。
77
+
78
+ ## Review Process
79
+
80
+ ### Phase 1: Pre-check(Bash 结构化预检,D1/D4 + P0 工艺 grep)
81
+
82
+ 机械化验证,无需 LLM 语义判断:
83
+
84
+ 1. **D1 页面完整性**:
85
+ - 从 PRD §4 提取所有页面名称列表
86
+ - `ls` / `find` 扫描 `prototype/` 下所有 `.html` 文件
87
+ - 逐页匹配:PRD 页面 → HTML 文件存在性
88
+ - `grep` 检查导航文件(index.html / nav 组件)中是否包含每个页面的链接
89
+ - 未匹配页面 = Critical finding
90
+
91
+ 2. **D4 导航一致性**:
92
+ - 从 PRD §8.2.2 提取页面跳转关系(A→B)
93
+ - `grep` 原型 HTML 中的 `<a href>` / `onclick` 跳转
94
+ - 比对:PRD 定义的跳转路径是否在原型中存在
95
+ - 缺失跳转 = Important finding
96
+
97
+ 3. **P0 工艺机械检查(v0.18.0,参照 `references/checklist.md`)**——**P0 违规 = Critical finding**:
98
+ - 裸 hex:grep `#[0-9a-fA-F]{3,8}` 在 `:root{}` 块外 → 命中 = Critical
99
+ - 靛蓝黑名单:grep `#6366f1\|#4f46e5\|#4338ca\|#3730a3\|#8b5cf6\|#7c3aed\|#a855f7` → 命中 = Critical
100
+ - emoji 图标:grep `✨\|🚀\|🎯\|⚡\|🔥\|💡` 在 h*/button/li 元素中 → 命中 = Critical
101
+ - 填充文案:grep -i `lorem\|功能一\|功能二\|功能三\|placeholder text\|示例文本` → 命中 = Critical
102
+ - scrollIntoView:grep `scrollIntoView` → 命中 = Critical
103
+ - data-testid 缺失:每个顶层 `<section>` 无 `data-testid` = Critical
104
+ - accent 超限:每屏 `var(--accent)` 可见使用 ≥3 处 = Critical
105
+
106
+ ### Phase 2: Deep-check(LLM 语义对比,D2/D3/D5/D6)
107
+
108
+ 需要语义理解的维度,标注为"建议级,误报可被人工推翻":
109
+
110
+ 3. **D2 功能覆盖**:读 PRD §7 功能清单,逐项在原型 HTML 中查找对应交互元素(button/form/input/link)。未覆盖 = Critical。
111
+ 4. **D3 字段一致性**:读 PRD §8.4 字段定义,在对应页面 HTML 中查找表单字段(label/input/select)。缺失 = Important。
112
+ 5. **D5 术语一致性**:读 PRD §6 + CONCEPTS.md,与原型中的中文标签/英文命名比对。不一致 = Minor。
113
+ 6. **D6 状态覆盖(v0.18.0 五状态契约)**:读 PRD §8.2.3 异常状态定义,逐页面检查 **Loading / Empty / Error / Populated / Edge** 五状态覆盖(参照 `references/craft/state-coverage.md`)。每态必含物:Loading=骨架/进度指示;Empty=说明+主操作;Error=what/why/what-to-do;Populated=正常数据;Edge=极端值/长文本/零结果。缺失 = Important,结构性不可实现 = N/A(附理由)。测试矩阵填入报告。
114
+
115
+ ### Phase 3: Craft Quality Review(工艺质量 4 席 rubric,v0.18.0)
116
+
117
+ 独立于 PRD 6 维度的**工艺质量评审**。4 席独立打分(0-10),每席输出 must-fix 列表(位置 + 问题 + 修复建议):
118
+
119
+ | 席 | 权重 | 评审内容 |
120
+ |----|------|---------|
121
+ | **工艺席** | 0.4 | checklist P1 合规 + anti-ai-slop 七宗罪 + 80/20 灵魂法则(参照 `references/craft/anti-ai-slop.md`) |
122
+ | **品牌席** | 0.2 | `.team-flow/design-system/` token 合规 + 视觉一致性(无内联漂移) |
123
+ | **无障碍席** | 0.2 | accessibility-baseline 合规(参照 `references/craft/accessibility-baseline.md`) |
124
+ | **文案席** | 0.2 | 无填充 / CTA 说明动作 / 标题 ≤14 词 / 术语一致 |
125
+
126
+ 加权合成:`工艺×0.4 + 品牌×0.2 + 无障碍×0.2 + 文案×0.2`
127
+
128
+ ### Phase 4: 汇总判定
129
+
130
+ 按判定标准输出最终 verdict。
131
+
132
+ ## Judgment Criteria
133
+
134
+ | Verdict | Condition | Action |
135
+ |---------|-----------|--------|
136
+ | **PASS** | Critical=0 且 Important=0 且 craft 合成 ≥6.0 | 进入人工评审 |
137
+ | **PASS_WITH_WARNINGS** | Critical=0 且(Important>0 或 craft 合成 <6.0),无未清 must-fix | 警告项交人工裁定,不阻断 |
138
+ | **FAIL** | Critical>0(含 P0 违规)或有未清 must-fix | 必须修正后重新评审 |
139
+
140
+ **FAIL 由 Critical 或未清 must-fix 触发**。Important 误报不触发 FAIL。
141
+
142
+ ## Output Format
143
+
144
+ ```markdown
145
+ # Prototype Auto-Review Report
146
+
147
+ ## Metadata
148
+ - **PRD**: {prd_path}
149
+ - **Prototype**: {prototype_path}
150
+ - **Review round**: {N}
151
+ - **Reviewer**: prototype-reviewer agent (independent, read-only)
152
+ - **Timestamp**: {ISO 8601}
153
+
154
+ ## Verdict: {PASS | PASS_WITH_WARNINGS | FAIL}
155
+
156
+ | Severity | Count |
157
+ |----------|-------|
158
+ | Critical | {n} |
159
+ | Important | {n} |
160
+ | Minor | {n} |
161
+ | N/A | {n} |
162
+
163
+ ## Dimension Details
164
+
165
+ ### D1 页面完整性 — {PASS/FAIL} ({m}/{n} pages)
166
+ [逐页检查结果表格:PRD 页面 | HTML 文件 | 导航可达 | 结果]
167
+
168
+ ### D2 功能覆盖 — {PASS/FAIL} ({m}/{n} functions)
169
+ [逐功能检查结果:PRD 功能 | 原型元素 | 位置 | 结果]
170
+
171
+ ### D3 字段一致性 — {PASS/WARN} ({m}/{n} fields)
172
+ [逐字段检查结果]
173
+
174
+ ### D4 导航一致性 — {PASS/WARN} ({m}/{n} routes)
175
+ [逐跳转检查结果]
176
+
177
+ ### D5 术语一致性 — {PASS/WARN}
178
+ [不一致术语列表]
179
+
180
+ ### D6 状态覆盖 — {PASS/WARN/N/A}
181
+ [逐页面五状态检查结果表格:页面 | Loading | Empty | Error | Populated | Edge | N/A 项附理由]
182
+
183
+ ## Craft Quality(v0.18.0)
184
+
185
+ | 席 | 分数 (0-10) | must-fix 数 |
186
+ |----|------------|------------|
187
+ | 工艺(×0.4) | {n} | {m} |
188
+ | 品牌(×0.2) | {n} | {m} |
189
+ | 无障碍(×0.2) | {n} | {m} |
190
+ | 文案(×0.2) | {n} | {m} |
191
+ | **加权合成** | **{weighted}** | **{total}** |
192
+
193
+ ### Must-Fix Details
194
+ | # | 席 | 位置 | 问题 | 修复建议 |
195
+ |---|-----|------|------|---------|
196
+ | 1 | 工艺 | pages/dashboard.html:42 | accent 使用 4 处超限 | 去掉 2 处 accent,改用 --muted |
197
+
198
+ ## Inconsistency Summary
199
+ | # | Dim | Severity | PRD Source | Prototype Location | Description |
200
+ |---|-----|----------|-----------|-------------------|-------------|
201
+ | 1 | D1 | Critical | §4.2 用户管理页 | — (missing) | PRD 定义的用户管理页无对应 HTML |
202
+ | ... | | | | | |
203
+
204
+ ## Coverage Statistics
205
+ - Pages: {m}/{n} ({percent}%)
206
+ - Functions: {m}/{n} ({percent}%)
207
+ - Fields: {m}/{n} ({percent}%)
208
+ - Routes: {m}/{n} ({percent}%)
209
+ ```
210
+
211
+ ## Red Lines
212
+
213
+ **DO:**
214
+ - Read the PRD BEFORE reading the prototype — establish the baseline first
215
+ - Cite PRD source section (§X.X) AND prototype location (file:line) for every finding
216
+ - Mark D6 as N/A with explicit justification when structurally inapplicable
217
+ - Give a clear, unambiguous verdict
218
+ - Distinguish Pre-check (mechanical) from Deep-check (semantic, advisory) findings
219
+
220
+ **DON'T:**
221
+ - Modify any file — you are read-only, report goes in your response
222
+ - Guess or infer PRD content that is not explicitly written — if PRD doesn't define it, it's not a finding
223
+ - Mark style/aesthetics/UX issues — those are for human review only
224
+ - Trigger FAIL on Important findings — FAIL is Critical-only
225
+ - Skip the Pre-check phase and jump straight to semantic analysis
226
+ - Omit the PRD source reference for any finding
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" fill="none">
2
+ <rect width="64" height="64" rx="14" fill="#2563EB"/>
3
+ <path d="M20 44V20l14 12-14 12z" fill="#fff" opacity="0.9"/>
4
+ <path d="M32 44V20l14 12-14 12z" fill="#fff" opacity="0.6"/>
5
+ <path d="M18 42h28M18 22h28" stroke="#fff" stroke-width="1.5" opacity="0.3"/>
6
+ </svg>
@@ -0,0 +1,13 @@
1
+ export type { Scenario, Requirement } from './schema/base.js';
2
+ export type { DeltaOperationType, Rename, Delta, Change } from './schema/change.js';
3
+ export type { Spec } from './schema/spec.js';
4
+ export type { ValidationLevel, ValidationIssue, ValidationReport } from './validation/types.js';
5
+ export type { VerificationDimension, VerificationStatus, VerificationFinding, VerificationReport } from './validation/types.js';
6
+ export type { ConflictReport, SyncConflict } from './validation/types.js';
7
+ export { VALIDATION_MESSAGES, MIN_WHY_SECTION_LENGTH, MIN_PURPOSE_LENGTH, MAX_WHY_SECTION_LENGTH, MAX_REQUIREMENT_TEXT_LENGTH, MAX_DELTAS_PER_CHANGE, VERIFICATION_DIMENSIONS, VERIFICATION_MESSAGES, MIN_ABANDONMENT_REASON_LENGTH } from './validation/constants.js';
8
+ export { Validator } from './validation/validator.js';
9
+ export type { RequirementBlock, RequirementsSectionParts, DeltaPlan } from './parsing/requirement-blocks.js';
10
+ export { REQUIREMENT_HEADER_REGEX, normalizeRequirementName, extractRequirementsSection, parseDeltaSpec } from './parsing/requirement-blocks.js';
11
+ export type { ParsedDelta, ParsedChange } from './parsing/change-parser.js';
12
+ export { parseChangeMarkdown } from './parsing/change-parser.js';
13
+ export { tokenize, detectLanguage } from './validation/tokenizer.js';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { VALIDATION_MESSAGES, MIN_WHY_SECTION_LENGTH, MIN_PURPOSE_LENGTH, MAX_WHY_SECTION_LENGTH, MAX_REQUIREMENT_TEXT_LENGTH, MAX_DELTAS_PER_CHANGE, VERIFICATION_DIMENSIONS, VERIFICATION_MESSAGES, MIN_ABANDONMENT_REASON_LENGTH } from './validation/constants.js';
2
+ export { Validator } from './validation/validator.js';
3
+ export { REQUIREMENT_HEADER_REGEX, normalizeRequirementName, extractRequirementsSection, parseDeltaSpec } from './parsing/requirement-blocks.js';
4
+ export { parseChangeMarkdown } from './parsing/change-parser.js';
5
+ export { tokenize, detectLanguage } from './validation/tokenizer.js';
@@ -0,0 +1,12 @@
1
+ export interface ParsedDelta {
2
+ spec: string;
3
+ operation: string;
4
+ description: string;
5
+ }
6
+ export interface ParsedChange {
7
+ name: string;
8
+ why: string;
9
+ whatChanges: string;
10
+ deltas: ParsedDelta[];
11
+ }
12
+ export declare function parseChangeMarkdown(content: string, changeName: string): ParsedChange;
@@ -0,0 +1,54 @@
1
+ function normalizeLineEndings(content) {
2
+ return content.replace(/\r\n?/g, '\n');
3
+ }
4
+ function extractSection(content, heading) {
5
+ const normalized = normalizeLineEndings(content);
6
+ const lines = normalized.split('\n');
7
+ // Match headings that contain the English keyword — supports both
8
+ // "## Why" and "## 背景(Why)" style bilingual headings.
9
+ const headingRegex = new RegExp(`^##\\s+.*\\b${heading.replace(/\s+/g, '\\s+')}\\b.*$`, 'i');
10
+ const idx = lines.findIndex((l) => headingRegex.test(l));
11
+ if (idx === -1)
12
+ return '';
13
+ let endIdx = lines.length;
14
+ for (let i = idx + 1; i < lines.length; i++) {
15
+ if (/^##\s+/.test(lines[i])) {
16
+ endIdx = i;
17
+ break;
18
+ }
19
+ }
20
+ return lines.slice(idx + 1, endIdx).join('\n').trim();
21
+ }
22
+ export function parseChangeMarkdown(content, changeName) {
23
+ const why = extractSection(content, 'Why');
24
+ const whatChanges = extractSection(content, 'What Changes');
25
+ const deltas = [];
26
+ const deltaSectionRegex = /^##\s+(ADDED|MODIFIED|REMOVED|RENAMED)\s+Requirements\s*$/im;
27
+ const sections = content.split(/(?=^##\s)/m);
28
+ for (const section of sections) {
29
+ const match = section.match(deltaSectionRegex);
30
+ if (match) {
31
+ const operation = match[1].toUpperCase();
32
+ const body = section.substring(match[0].length).trim();
33
+ const descLines = [];
34
+ for (const line of body.split('\n')) {
35
+ if (/^###\s+/.test(line))
36
+ break;
37
+ const trimmed = line.trim();
38
+ if (trimmed)
39
+ descLines.push(trimmed);
40
+ }
41
+ deltas.push({
42
+ spec: '',
43
+ operation,
44
+ description: descLines.join('\n'),
45
+ });
46
+ }
47
+ }
48
+ return {
49
+ name: changeName,
50
+ why,
51
+ whatChanges,
52
+ deltas,
53
+ };
54
+ }
@@ -0,0 +1,31 @@
1
+ export interface RequirementBlock {
2
+ headerLine: string;
3
+ name: string;
4
+ raw: string;
5
+ }
6
+ export interface RequirementsSectionParts {
7
+ before: string;
8
+ headerLine: string;
9
+ preamble: string;
10
+ bodyBlocks: RequirementBlock[];
11
+ after: string;
12
+ }
13
+ export declare function normalizeRequirementName(name: string): string;
14
+ export declare const REQUIREMENT_HEADER_REGEX: RegExp;
15
+ export declare function extractRequirementsSection(content: string): RequirementsSectionParts;
16
+ export interface DeltaPlan {
17
+ added: RequirementBlock[];
18
+ modified: RequirementBlock[];
19
+ removed: string[];
20
+ renamed: Array<{
21
+ from: string;
22
+ to: string;
23
+ }>;
24
+ sectionPresence: {
25
+ added: boolean;
26
+ modified: boolean;
27
+ removed: boolean;
28
+ renamed: boolean;
29
+ };
30
+ }
31
+ export declare function parseDeltaSpec(content: string): DeltaPlan;
@@ -0,0 +1,192 @@
1
+ export function normalizeRequirementName(name) {
2
+ return name.trim();
3
+ }
4
+ export const REQUIREMENT_HEADER_REGEX = /^###\s*Requirement:\s*(.+)\s*$/i;
5
+ function normalizeLineEndings(content) {
6
+ return content.replace(/\r\n?/g, '\n');
7
+ }
8
+ export function extractRequirementsSection(content) {
9
+ const normalized = normalizeLineEndings(content);
10
+ const lines = normalized.split('\n');
11
+ const reqHeaderIndex = lines.findIndex((l) => /^##\s+Requirements\s*$/i.test(l));
12
+ if (reqHeaderIndex === -1) {
13
+ const before = content.trimEnd();
14
+ const headerLine = '## Requirements';
15
+ return {
16
+ before: before ? before + '\n\n' : '',
17
+ headerLine,
18
+ preamble: '',
19
+ bodyBlocks: [],
20
+ after: '\n',
21
+ };
22
+ }
23
+ let endIndex = lines.length;
24
+ for (let i = reqHeaderIndex + 1; i < lines.length; i++) {
25
+ if (/^##\s+/.test(lines[i])) {
26
+ endIndex = i;
27
+ break;
28
+ }
29
+ }
30
+ const before = lines.slice(0, reqHeaderIndex).join('\n');
31
+ const headerLine = lines[reqHeaderIndex];
32
+ const sectionBodyLines = lines.slice(reqHeaderIndex + 1, endIndex);
33
+ const blocks = [];
34
+ let cursor = 0;
35
+ let preambleLines = [];
36
+ while (cursor < sectionBodyLines.length &&
37
+ !REQUIREMENT_HEADER_REGEX.test(sectionBodyLines[cursor])) {
38
+ preambleLines.push(sectionBodyLines[cursor]);
39
+ cursor++;
40
+ }
41
+ while (cursor < sectionBodyLines.length) {
42
+ const headerLineCandidate = sectionBodyLines[cursor];
43
+ const headerMatch = headerLineCandidate.match(REQUIREMENT_HEADER_REGEX);
44
+ if (!headerMatch) {
45
+ cursor++;
46
+ continue;
47
+ }
48
+ const name = normalizeRequirementName(headerMatch[1]);
49
+ cursor++;
50
+ const bodyLines = [headerLineCandidate];
51
+ while (cursor < sectionBodyLines.length &&
52
+ !REQUIREMENT_HEADER_REGEX.test(sectionBodyLines[cursor]) &&
53
+ !/^##\s+/.test(sectionBodyLines[cursor])) {
54
+ bodyLines.push(sectionBodyLines[cursor]);
55
+ cursor++;
56
+ }
57
+ const raw = bodyLines.join('\n').trimEnd();
58
+ blocks.push({ headerLine: headerLineCandidate, name, raw });
59
+ }
60
+ const after = lines.slice(endIndex).join('\n');
61
+ const preamble = preambleLines.join('\n').trimEnd();
62
+ return {
63
+ before: before.trimEnd() ? before + '\n' : before,
64
+ headerLine,
65
+ preamble,
66
+ bodyBlocks: blocks,
67
+ after: after.startsWith('\n') ? after : '\n' + after,
68
+ };
69
+ }
70
+ function splitTopLevelSections(content) {
71
+ const lines = content.split('\n');
72
+ const result = {};
73
+ const indices = [];
74
+ for (let i = 0; i < lines.length; i++) {
75
+ const m = lines[i].match(/^(##)\s+(.+)$/);
76
+ if (m) {
77
+ const level = m[1].length;
78
+ indices.push({ title: m[2].trim(), index: i, level });
79
+ }
80
+ }
81
+ for (let i = 0; i < indices.length; i++) {
82
+ const current = indices[i];
83
+ const next = indices[i + 1];
84
+ const body = lines
85
+ .slice(current.index + 1, next ? next.index : lines.length)
86
+ .join('\n');
87
+ result[current.title] = body;
88
+ }
89
+ return result;
90
+ }
91
+ function getSectionCaseInsensitive(sections, desired) {
92
+ const target = desired.toLowerCase();
93
+ for (const [title, body] of Object.entries(sections)) {
94
+ if (title.toLowerCase() === target)
95
+ return { body, found: true };
96
+ }
97
+ return { body: '', found: false };
98
+ }
99
+ function parseRequirementBlocksFromSection(sectionBody) {
100
+ if (!sectionBody)
101
+ return [];
102
+ const lines = normalizeLineEndings(sectionBody).split('\n');
103
+ const blocks = [];
104
+ let i = 0;
105
+ while (i < lines.length) {
106
+ while (i < lines.length && !REQUIREMENT_HEADER_REGEX.test(lines[i]))
107
+ i++;
108
+ if (i >= lines.length)
109
+ break;
110
+ const headerLine = lines[i];
111
+ const m = headerLine.match(REQUIREMENT_HEADER_REGEX);
112
+ if (!m) {
113
+ i++;
114
+ continue;
115
+ }
116
+ const name = normalizeRequirementName(m[1]);
117
+ const buf = [headerLine];
118
+ i++;
119
+ while (i < lines.length &&
120
+ !REQUIREMENT_HEADER_REGEX.test(lines[i]) &&
121
+ !/^##\s+/.test(lines[i])) {
122
+ buf.push(lines[i]);
123
+ i++;
124
+ }
125
+ blocks.push({ headerLine, name, raw: buf.join('\n').trimEnd() });
126
+ }
127
+ return blocks;
128
+ }
129
+ function parseRemovedNames(sectionBody) {
130
+ if (!sectionBody)
131
+ return [];
132
+ const names = [];
133
+ const lines = normalizeLineEndings(sectionBody).split('\n');
134
+ for (const line of lines) {
135
+ const m = line.match(REQUIREMENT_HEADER_REGEX);
136
+ if (m) {
137
+ names.push(normalizeRequirementName(m[1]));
138
+ continue;
139
+ }
140
+ const bullet = line.match(/^\s*-\s*`?###\s*Requirement:\s*(.+?)`?\s*$/);
141
+ if (bullet) {
142
+ names.push(normalizeRequirementName(bullet[1]));
143
+ }
144
+ }
145
+ return names;
146
+ }
147
+ function parseRenamedPairs(sectionBody) {
148
+ if (!sectionBody)
149
+ return [];
150
+ const pairs = [];
151
+ const lines = normalizeLineEndings(sectionBody).split('\n');
152
+ let current = {};
153
+ for (const line of lines) {
154
+ const fromMatch = line.match(/^\s*-?\s*FROM:\s*`?###\s*Requirement:\s*(.+?)`?\s*$/);
155
+ const toMatch = line.match(/^\s*-?\s*TO:\s*`?###\s*Requirement:\s*(.+?)`?\s*$/);
156
+ if (fromMatch) {
157
+ current.from = normalizeRequirementName(fromMatch[1]);
158
+ }
159
+ else if (toMatch) {
160
+ current.to = normalizeRequirementName(toMatch[1]);
161
+ if (current.from && current.to) {
162
+ pairs.push({ from: current.from, to: current.to });
163
+ current = {};
164
+ }
165
+ }
166
+ }
167
+ return pairs;
168
+ }
169
+ export function parseDeltaSpec(content) {
170
+ const normalized = normalizeLineEndings(content);
171
+ const sections = splitTopLevelSections(normalized);
172
+ const addedLookup = getSectionCaseInsensitive(sections, 'ADDED Requirements');
173
+ const modifiedLookup = getSectionCaseInsensitive(sections, 'MODIFIED Requirements');
174
+ const removedLookup = getSectionCaseInsensitive(sections, 'REMOVED Requirements');
175
+ const renamedLookup = getSectionCaseInsensitive(sections, 'RENAMED Requirements');
176
+ const added = parseRequirementBlocksFromSection(addedLookup.body);
177
+ const modified = parseRequirementBlocksFromSection(modifiedLookup.body);
178
+ const removedNames = parseRemovedNames(removedLookup.body);
179
+ const renamedPairs = parseRenamedPairs(renamedLookup.body);
180
+ return {
181
+ added,
182
+ modified,
183
+ removed: removedNames,
184
+ renamed: renamedPairs,
185
+ sectionPresence: {
186
+ added: addedLookup.found,
187
+ modified: modifiedLookup.found,
188
+ removed: removedLookup.found,
189
+ renamed: renamedLookup.found,
190
+ },
191
+ };
192
+ }
@@ -0,0 +1,7 @@
1
+ export interface Scenario {
2
+ rawText: string;
3
+ }
4
+ export interface Requirement {
5
+ text: string;
6
+ scenarios: Scenario[];
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ import { Requirement } from './base.js';
2
+ export type DeltaOperationType = 'ADDED' | 'MODIFIED' | 'REMOVED' | 'RENAMED';
3
+ export interface Rename {
4
+ from: string;
5
+ to: string;
6
+ }
7
+ export interface Delta {
8
+ spec: string;
9
+ operation: DeltaOperationType;
10
+ description: string;
11
+ requirement?: Requirement;
12
+ requirements?: Requirement[];
13
+ rename?: Rename;
14
+ }
15
+ export interface Change {
16
+ name: string;
17
+ why: string;
18
+ whatChanges: string;
19
+ deltas: Delta[];
20
+ metadata?: {
21
+ version?: string;
22
+ format?: string;
23
+ sourcePath?: string;
24
+ };
25
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export type { Scenario, Requirement } from './base.js';
2
+ export type { DeltaOperationType, Rename, Delta, Change } from './change.js';
3
+ export type { Spec } from './spec.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { Requirement } from './base.js';
2
+ export interface Spec {
3
+ name: string;
4
+ overview: string;
5
+ requirements: Requirement[];
6
+ metadata?: {
7
+ version?: string;
8
+ format?: string;
9
+ sourcePath?: string;
10
+ };
11
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,42 @@
1
+ export declare const MIN_WHY_SECTION_LENGTH = 50;
2
+ export declare const MIN_PURPOSE_LENGTH = 50;
3
+ export declare const MAX_WHY_SECTION_LENGTH = 1000;
4
+ export declare const MAX_REQUIREMENT_TEXT_LENGTH = 500;
5
+ export declare const MAX_DELTAS_PER_CHANGE = 10;
6
+ export declare const VALIDATION_MESSAGES: {
7
+ readonly SCENARIO_EMPTY: "Scenario text cannot be empty";
8
+ readonly REQUIREMENT_EMPTY: "Requirement text cannot be empty";
9
+ readonly REQUIREMENT_NO_SHALL: "Requirement must contain SHALL or MUST keyword";
10
+ readonly REQUIREMENT_NO_SCENARIOS: "Requirement must have at least one scenario";
11
+ readonly SPEC_NAME_EMPTY: "Spec name cannot be empty";
12
+ readonly SPEC_PURPOSE_EMPTY: "Purpose section cannot be empty";
13
+ readonly SPEC_NO_REQUIREMENTS: "Spec must have at least one requirement";
14
+ readonly CHANGE_NAME_EMPTY: "Change name cannot be empty";
15
+ readonly CHANGE_WHY_TOO_SHORT: "Why section must be at least 50 characters";
16
+ readonly CHANGE_WHY_TOO_LONG: "Why section should not exceed 1000 characters";
17
+ readonly CHANGE_WHAT_EMPTY: "What Changes section cannot be empty";
18
+ readonly CHANGE_NO_DELTAS: "Change must have at least one delta";
19
+ readonly CHANGE_TOO_MANY_DELTAS: "Consider splitting changes with more than 10 deltas";
20
+ readonly DELTA_SPEC_EMPTY: "Spec name cannot be empty";
21
+ readonly DELTA_DESCRIPTION_EMPTY: "Delta description cannot be empty";
22
+ readonly PURPOSE_TOO_BRIEF: "Purpose section is too brief (less than 50 characters)";
23
+ readonly REQUIREMENT_TOO_LONG: "Requirement text is very long (>500 characters). Consider breaking it down.";
24
+ readonly DELTA_DESCRIPTION_TOO_BRIEF: "Delta description is too brief";
25
+ readonly DELTA_MISSING_REQUIREMENTS: "Delta should include requirements";
26
+ readonly GUIDE_NO_DELTAS: "No deltas found. Ensure your change has a specs/ directory with capability folders (e.g. specs/http-server/spec.md) containing .md files that use delta headers (## ADDED/MODIFIED/REMOVED/RENAMED Requirements) and that each requirement includes at least one \"#### Scenario:\" block. Tip: run \"openspec change show <change-id> --json --deltas-only\" to inspect parsed deltas.";
27
+ readonly GUIDE_MISSING_SPEC_SECTIONS: "Missing required sections. Expected headers: \"## Purpose\" and \"## Requirements\". Example:\n## Purpose\n[brief purpose]\n\n## Requirements\n### Requirement: Clear requirement statement\nUsers SHALL ...\n\n#### Scenario: Descriptive name\n- **WHEN** ...\n- **THEN** ...";
28
+ readonly GUIDE_MISSING_CHANGE_SECTIONS: "Missing required sections. Expected headers: \"## Why\" and \"## What Changes\". Ensure deltas are documented in specs/ using delta headers.";
29
+ readonly GUIDE_SCENARIO_FORMAT: "Scenarios must use level-4 headers. Convert bullet lists into:\n#### Scenario: Short name\n- **WHEN** ...\n- **THEN** ...\n- **AND** ...";
30
+ };
31
+ export declare const VERIFICATION_DIMENSIONS: readonly ["Completeness", "Correctness", "Coherence"];
32
+ export declare const VERIFICATION_MESSAGES: {
33
+ readonly COMPLETENESS_MISSING_TASK: "Task in tasks.md has no corresponding code change in diff summary";
34
+ readonly COMPLETENESS_MISSING_REQUIREMENT: "SHALL/MUST requirement in spec has no matching implementation in diff summary: {requirement}";
35
+ readonly CORRECTNESS_TEST_FAILURE: "Test suite has failures";
36
+ readonly CORRECTNESS_MISSING_SCENARIO: "Spec scenario has no corresponding test assertion";
37
+ readonly COHERENCE_NAMING_MISMATCH: "Design decision naming does not match implementation naming";
38
+ readonly COHERENCE_PATTERN_MISSING: "Architecture pattern from design.md not found in implementation: {pattern}";
39
+ readonly VERIFICATION_PLACEHOLDER_DETECTED: "Diff summary contains placeholder markers (TODO, FIXME, HACK)";
40
+ readonly CONFLICT_DETECTED: "Requirement \"{requirement}\" is modified by multiple changes: {changes}";
41
+ };
42
+ export declare const MIN_ABANDONMENT_REASON_LENGTH = 50;