@v11g/agents-rock 1.0.9 → 1.0.11

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 (347) hide show
  1. package/README.md +3 -1
  2. package/package.json +2 -2
  3. package/plugins/business-analyst/.claude-plugin/plugin.json +2 -2
  4. package/plugins/business-analyst/evals/ba-interview-conflict/graders/conflict-quoted.md +15 -0
  5. package/plugins/business-analyst/evals/ba-interview-conflict/graders/no-internal-ids.md +9 -0
  6. package/plugins/business-analyst/evals/ba-interview-conflict/graders/one-question.md +15 -0
  7. package/plugins/business-analyst/evals/ba-interview-conflict/graders/skill-fired.md +7 -0
  8. package/plugins/business-analyst/evals/ba-interview-conflict/prompt.md +31 -0
  9. package/plugins/business-analyst/evals/ba-interview-first-turn/graders/no-internal-ids.md +9 -0
  10. package/plugins/business-analyst/evals/ba-interview-first-turn/graders/no-setup-questions.md +16 -0
  11. package/plugins/business-analyst/evals/ba-interview-first-turn/graders/one-scope-question.md +19 -0
  12. package/plugins/business-analyst/evals/ba-interview-first-turn/graders/skill-fired.md +7 -0
  13. package/plugins/business-analyst/evals/ba-interview-first-turn/prompt.md +31 -0
  14. package/plugins/business-analyst/evals/ba-review-page/case.yaml +4 -0
  15. package/plugins/business-analyst/evals/ba-review-page/fixture.sh +12 -0
  16. package/plugins/business-analyst/evals/ba-review-page/graders/decide-in-interview.md +26 -0
  17. package/plugins/business-analyst/evals/ba-review-page/graders/skill-fired.md +7 -0
  18. package/plugins/business-analyst/evals/ba-review-page/prompt.md +9 -0
  19. package/plugins/business-analyst/evals/draft-scope-rich/case.yaml +4 -0
  20. package/plugins/business-analyst/evals/draft-scope-rich/fixture.sh +5 -0
  21. package/plugins/business-analyst/evals/draft-scope-rich/graders/conflict-question.md +11 -0
  22. package/plugins/business-analyst/evals/draft-scope-rich/graders/keep-and-exclude.md +14 -0
  23. package/plugins/business-analyst/evals/draft-scope-rich/graders/noise-and-shape.md +13 -0
  24. package/plugins/business-analyst/evals/draft-scope-rich/graders/problem-not-solution.md +13 -0
  25. package/plugins/business-analyst/evals/draft-scope-rich/graders/share-kept.md +11 -0
  26. package/plugins/business-analyst/evals/draft-scope-rich/graders/skill-fired.md +7 -0
  27. package/plugins/business-analyst/evals/draft-scope-rich/graders/vague-word.md +13 -0
  28. package/plugins/business-analyst/evals/draft-scope-rich/inputs/C1.txt +10 -0
  29. package/plugins/business-analyst/evals/draft-scope-rich/inputs/E1.txt +5 -0
  30. package/plugins/business-analyst/evals/draft-scope-rich/inputs/E2.txt +5 -0
  31. package/plugins/business-analyst/evals/draft-scope-rich/inputs/E3.txt +5 -0
  32. package/plugins/business-analyst/evals/draft-scope-rich/prompt.md +9 -0
  33. package/plugins/business-analyst/evals/draft-scope-thin/case.yaml +4 -0
  34. package/plugins/business-analyst/evals/draft-scope-thin/fixture.sh +4 -0
  35. package/plugins/business-analyst/evals/draft-scope-thin/graders/no-invention.md +18 -0
  36. package/plugins/business-analyst/evals/draft-scope-thin/graders/skill-fired.md +7 -0
  37. package/plugins/business-analyst/evals/draft-scope-thin/inputs/E1.txt +5 -0
  38. package/plugins/business-analyst/evals/draft-scope-thin/prompt.md +8 -0
  39. package/plugins/business-analyst/skills/business-analyst/README.md +8 -0
  40. package/plugins/business-analyst/skills/business-analyst/SKILL.md +47 -16
  41. package/plugins/business-analyst/skills/business-analyst/assets/review-page.html +68 -0
  42. package/plugins/business-analyst/skills/business-analyst/evals/evals.json +1 -1
  43. package/plugins/business-analyst/skills/business-analyst/references/frameworks.md +3 -2
  44. package/plugins/business-analyst/skills/business-analyst/references/interview.md +156 -8
  45. package/plugins/business-analyst/skills/business-analyst/references/review.md +18 -4
  46. package/plugins/business-analyst/skills/business-analyst/references/writing.md +49 -8
  47. package/plugins/business-analyst/skills/business-analyst/scripts/__pycache__/review_data.cpython-312.pyc +0 -0
  48. package/plugins/business-analyst/skills/business-analyst/scripts/__pycache__/review_layout.cpython-312.pyc +0 -0
  49. package/plugins/business-analyst/skills/business-analyst/scripts/__pycache__/review_page.cpython-312.pyc +0 -0
  50. package/plugins/business-analyst/skills/business-analyst/scripts/__pycache__/scope_checks.cpython-312.pyc +0 -0
  51. package/plugins/business-analyst/skills/business-analyst/scripts/__pycache__/scope_render.cpython-312.pyc +0 -0
  52. package/plugins/business-analyst/skills/business-analyst/scripts/__pycache__/validate.cpython-312.pyc +0 -0
  53. package/plugins/business-analyst/skills/business-analyst/scripts/lib/checks.mjs +12 -6
  54. package/plugins/business-analyst/skills/business-analyst/scripts/lib/review-data.mjs +66 -0
  55. package/plugins/business-analyst/skills/business-analyst/scripts/lib/review-layout.mjs +53 -0
  56. package/plugins/business-analyst/skills/business-analyst/scripts/lib/review-page.mjs +78 -0
  57. package/plugins/business-analyst/skills/business-analyst/scripts/lib/scope-checks.mjs +73 -0
  58. package/plugins/business-analyst/skills/business-analyst/scripts/lib/scope-md.mjs +53 -0
  59. package/plugins/business-analyst/skills/business-analyst/scripts/lib/scope-render.mjs +72 -0
  60. package/plugins/business-analyst/skills/business-analyst/scripts/lib/scope-rules.mjs +90 -0
  61. package/plugins/business-analyst/skills/business-analyst/scripts/review.mjs +48 -0
  62. package/plugins/business-analyst/skills/business-analyst/scripts/review.py +60 -0
  63. package/plugins/business-analyst/skills/business-analyst/scripts/review_data.py +81 -0
  64. package/plugins/business-analyst/skills/business-analyst/scripts/review_layout.py +50 -0
  65. package/plugins/business-analyst/skills/business-analyst/scripts/review_page.py +115 -0
  66. package/plugins/business-analyst/skills/business-analyst/scripts/scope.mjs +24 -0
  67. package/plugins/business-analyst/skills/business-analyst/scripts/scope.py +35 -0
  68. package/plugins/business-analyst/skills/business-analyst/scripts/scope_checks.py +168 -0
  69. package/plugins/business-analyst/skills/business-analyst/scripts/scope_render.py +140 -0
  70. package/plugins/business-analyst/skills/business-analyst/scripts/test/checks.test.mjs +27 -0
  71. package/plugins/business-analyst/skills/business-analyst/scripts/test/fixtures/requirements-workflow-pass.json +78 -0
  72. package/plugins/business-analyst/skills/business-analyst/scripts/test/fixtures/requirements-workflow-pass.md +136 -0
  73. package/plugins/business-analyst/skills/business-analyst/scripts/test/python-parity.test.mjs +88 -0
  74. package/plugins/business-analyst/skills/business-analyst/scripts/test/quality-gates.test.mjs +26 -0
  75. package/plugins/business-analyst/skills/business-analyst/scripts/test/review-browser.test.mjs +106 -0
  76. package/plugins/business-analyst/skills/business-analyst/scripts/test/review-fixture.mjs +32 -0
  77. package/plugins/business-analyst/skills/business-analyst/scripts/test/review-page.test.mjs +340 -0
  78. package/plugins/business-analyst/skills/business-analyst/scripts/test/review-parity.test.mjs +79 -0
  79. package/plugins/business-analyst/skills/business-analyst/scripts/test/scope-cases.mjs +58 -0
  80. package/plugins/business-analyst/skills/business-analyst/scripts/test/scope-checks.test.mjs +31 -0
  81. package/plugins/business-analyst/skills/business-analyst/scripts/test/scope-md.test.mjs +140 -0
  82. package/plugins/business-analyst/skills/business-analyst/scripts/validate.mjs +1 -1
  83. package/plugins/business-analyst/skills/business-analyst/scripts/validate.py +17 -8
  84. package/plugins/business-analyst/skills/draft-scope/SKILL.md +46 -0
  85. package/plugins/business-analyst/skills/draft-scope/references/credits.md +12 -0
  86. package/plugins/business-analyst/skills/draft-scope/references/draft-schema.md +44 -0
  87. package/plugins/business-analyst/skills/draft-scope/references/rules.md +24 -0
  88. package/plugins/business-analyst/skills/draft-scope/scripts/__pycache__/docx_body.cpython-312.pyc +0 -0
  89. package/plugins/business-analyst/skills/draft-scope/scripts/__pycache__/docx_flow.cpython-312.pyc +0 -0
  90. package/plugins/business-analyst/skills/draft-scope/scripts/__pycache__/docx_package.cpython-312.pyc +0 -0
  91. package/plugins/business-analyst/skills/draft-scope/scripts/__pycache__/docx_xml.cpython-312.pyc +0 -0
  92. package/plugins/business-analyst/skills/draft-scope/scripts/__pycache__/draft_quotes.cpython-312.pyc +0 -0
  93. package/plugins/business-analyst/skills/draft-scope/scripts/__pycache__/draft_rules.cpython-312.pyc +0 -0
  94. package/plugins/business-analyst/skills/draft-scope/scripts/__pycache__/draft_schema.cpython-312.pyc +0 -0
  95. package/plugins/business-analyst/skills/draft-scope/scripts/build_docx.py +36 -0
  96. package/plugins/business-analyst/skills/draft-scope/scripts/check.py +53 -0
  97. package/plugins/business-analyst/skills/draft-scope/scripts/docx_body.py +58 -0
  98. package/plugins/business-analyst/skills/draft-scope/scripts/docx_flow.py +52 -0
  99. package/plugins/business-analyst/skills/draft-scope/scripts/docx_package.py +62 -0
  100. package/plugins/business-analyst/skills/draft-scope/scripts/docx_xml.py +44 -0
  101. package/plugins/business-analyst/skills/draft-scope/scripts/draft_quotes.py +49 -0
  102. package/plugins/business-analyst/skills/draft-scope/scripts/draft_rules.py +106 -0
  103. package/plugins/business-analyst/skills/draft-scope/scripts/draft_schema.py +87 -0
  104. package/plugins/business-analyst/skills/draft-scope/scripts/test/build-docx.test.mjs +76 -0
  105. package/plugins/business-analyst/skills/draft-scope/scripts/test/check-rules.test.mjs +131 -0
  106. package/plugins/business-analyst/skills/draft-scope/scripts/test/check-shape.test.mjs +70 -0
  107. package/plugins/business-analyst/skills/draft-scope/scripts/test/fixtures/draft-pass.json +40 -0
  108. package/plugins/business-analyst/skills/draft-scope/scripts/test/fixtures/sources/C1.txt +7 -0
  109. package/plugins/business-analyst/skills/draft-scope/scripts/test/fixtures/sources/E1.txt +5 -0
  110. package/plugins/business-analyst/skills/draft-scope/scripts/test/gates.test.mjs +39 -0
  111. package/plugins/business-analyst/skills/draft-scope/scripts/test/helpers.mjs +30 -0
  112. package/plugins/business-analyst/skills/draft-scope/scripts/test/skill-files.test.mjs +59 -0
  113. package/plugins/business-analyst/skills/draft-scope/steps/assumptions.md +24 -0
  114. package/plugins/business-analyst/skills/draft-scope/steps/check.md +24 -0
  115. package/plugins/business-analyst/skills/draft-scope/steps/discover.md +53 -0
  116. package/plugins/business-analyst/skills/draft-scope/steps/draft.md +64 -0
  117. package/plugins/solution-architect/.claude-plugin/plugin.json +1 -1
  118. package/plugins/solution-architect/evals/proposal-workflow/case.yaml +6 -0
  119. package/plugins/solution-architect/evals/proposal-workflow/fixture.sh +6 -0
  120. package/plugins/solution-architect/evals/proposal-workflow/graders/inputs-written.md +23 -0
  121. package/plugins/solution-architect/evals/proposal-workflow/graders/no-proposal-md.md +7 -0
  122. package/plugins/solution-architect/evals/proposal-workflow/graders/skill-fired.md +7 -0
  123. package/plugins/solution-architect/evals/proposal-workflow/graders/validate-then-render.md +16 -0
  124. package/plugins/solution-architect/evals/proposal-workflow/prompt.md +10 -0
  125. package/plugins/solution-architect/evals/workflow-gate-no-architecture/case.yaml +4 -0
  126. package/plugins/solution-architect/evals/workflow-gate-no-architecture/fixture.sh +6 -0
  127. package/plugins/solution-architect/evals/workflow-gate-no-architecture/graders/no-classic-fallback.md +10 -0
  128. package/plugins/solution-architect/evals/workflow-gate-no-architecture/graders/nothing-written.md +7 -0
  129. package/plugins/solution-architect/evals/workflow-gate-no-architecture/graders/skill-fired.md +7 -0
  130. package/plugins/solution-architect/evals/workflow-gate-no-architecture/graders/stops-at-gate.md +11 -0
  131. package/plugins/solution-architect/evals/workflow-gate-no-architecture/prompt.md +7 -0
  132. package/plugins/solution-architect/evals/workflow-happy-path/case.yaml +4 -0
  133. package/plugins/solution-architect/evals/workflow-happy-path/fixture.sh +6 -0
  134. package/plugins/solution-architect/evals/workflow-happy-path/graders/no-estimation-md.md +7 -0
  135. package/plugins/solution-architect/evals/workflow-happy-path/graders/pages-or-stop.md +16 -0
  136. package/plugins/solution-architect/evals/workflow-happy-path/graders/routed-to-workflow.md +12 -0
  137. package/plugins/solution-architect/evals/workflow-happy-path/graders/skill-fired.md +7 -0
  138. package/plugins/solution-architect/evals/workflow-happy-path/graders/three-questions-max.md +14 -0
  139. package/plugins/solution-architect/evals/workflow-happy-path/graders/workflow-or-exact-stop.md +15 -0
  140. package/plugins/solution-architect/evals/workflow-happy-path/prompt.md +9 -0
  141. package/plugins/solution-architect/skills/analyze-requirements/SKILL.md +8 -7
  142. package/plugins/solution-architect/skills/analyze-requirements/assets/section-help.json +5 -5
  143. package/plugins/solution-architect/skills/analyze-requirements/assets/viewer-template.html +26 -4
  144. package/plugins/solution-architect/skills/analyze-requirements/evals/evals.json +50 -6
  145. package/plugins/solution-architect/skills/analyze-requirements/evals/fixtures/ba-package-citations/requirements.json +31 -0
  146. package/plugins/solution-architect/skills/analyze-requirements/evals/fixtures/ba-package-citations/requirements.md +17 -0
  147. package/plugins/solution-architect/skills/analyze-requirements/evals/fixtures/transcript-citations/C1-kickoff-call.txt +16 -0
  148. package/plugins/solution-architect/skills/analyze-requirements/evals/fixtures/transcript-citations/E1-intro-email.md +9 -0
  149. package/plugins/solution-architect/skills/analyze-requirements/references/extract.md +108 -0
  150. package/plugins/solution-architect/skills/analyze-requirements/references/interview.md +39 -5
  151. package/plugins/solution-architect/skills/analyze-requirements/references/project-types.md +1 -1
  152. package/plugins/solution-architect/skills/analyze-requirements/references/quality-goals.md +84 -0
  153. package/plugins/solution-architect/skills/analyze-requirements/references/research.md +1 -1
  154. package/plugins/solution-architect/skills/analyze-requirements/references/rewriting.md +7 -2
  155. package/plugins/solution-architect/skills/analyze-requirements/references/viewer.md +10 -6
  156. package/plugins/solution-architect/skills/analyze-requirements/references/writing.md +45 -3
  157. package/plugins/solution-architect/skills/analyze-requirements/scripts/ba-facts.mjs +32 -0
  158. package/plugins/solution-architect/skills/analyze-requirements/scripts/check-quotes.mjs +39 -0
  159. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/ba-package.mjs +75 -0
  160. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-links.mjs +19 -7
  161. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-routes.mjs +1 -1
  162. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/inputs.mjs +42 -11
  163. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-render.mjs +15 -4
  164. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/section-help.mjs +1 -1
  165. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/strategy-sections.mjs +30 -0
  166. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-provenance.mjs +14 -2
  167. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-quotes.mjs +55 -0
  168. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-strategy.mjs +65 -0
  169. package/plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs +18 -5
  170. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/ba-facts-cli.test.mjs +55 -0
  171. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/ba-package-cli.test.mjs +101 -0
  172. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/ba-package.test.mjs +115 -0
  173. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/browser.test.mjs +77 -2
  174. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/check-quotes-cli.test.mjs +49 -0
  175. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-links.test.mjs +49 -4
  176. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/extract-workflow.test.mjs +69 -0
  177. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/inputs.test.mjs +14 -0
  178. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-render.test.mjs +19 -5
  179. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/record-cli.test.mjs +1 -1
  180. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/render.test.mjs +69 -2
  181. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/rewriting.test.mjs +1 -1
  182. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/section-help.test.mjs +6 -0
  183. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-provenance.test.mjs +19 -0
  184. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-quotes-cli.test.mjs +58 -0
  185. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-quotes.test.mjs +81 -0
  186. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-strategy-cli.test.mjs +32 -0
  187. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-strategy.test.mjs +118 -0
  188. package/plugins/solution-architect/skills/analyze-requirements/scripts/validate.mjs +17 -6
  189. package/plugins/solution-architect/skills/analyze-requirements/workflows/extract.js +51 -0
  190. package/plugins/solution-architect/skills/estimate/README.md +18 -3
  191. package/plugins/solution-architect/skills/estimate/SKILL.md +18 -75
  192. package/plugins/solution-architect/skills/estimate/classic/FLOW.md +77 -0
  193. package/plugins/solution-architect/skills/estimate/classic/assets/estimate-template.html +1337 -0
  194. package/plugins/solution-architect/skills/estimate/{references → classic/references}/task-shapes.md +1 -1
  195. package/plugins/solution-architect/skills/estimate/{references → classic/references}/writing.md +2 -2
  196. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/compute.mjs +1 -1
  197. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/lib/checks.mjs +1 -1
  198. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/lib/roadmap.mjs +1 -1
  199. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/lib/rollup.mjs +5 -5
  200. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/lib/schema.mjs +4 -26
  201. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/lib/score-csv.mjs +2 -2
  202. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/lib/score-html.mjs +2 -2
  203. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/render.mjs +8 -7
  204. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/score-review.mjs +3 -3
  205. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/baselines.test.mjs +3 -3
  206. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/browser-agentic.test.mjs +2 -2
  207. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/browser.test.mjs +2 -2
  208. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/compute.test.mjs +1 -1
  209. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/e2e.test.mjs +6 -6
  210. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/estimate-math.test.mjs +3 -3
  211. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/measurements.test.mjs +1 -1
  212. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/pricing.test.mjs +1 -1
  213. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/project-price.test.mjs +1 -1
  214. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/quality-gates.test.mjs +7 -1
  215. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/references.test.mjs +6 -6
  216. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/render.test.mjs +3 -3
  217. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/schema.test.mjs +1 -1
  218. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/score-review.test.mjs +6 -6
  219. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/scoring.test.mjs +1 -1
  220. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/url-state.test.mjs +2 -2
  221. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/validate.test.mjs +1 -1
  222. package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/xlsx-export.test.mjs +3 -3
  223. package/plugins/solution-architect/skills/estimate/classic/scripts/test/zip-store.test.mjs +26 -0
  224. package/plugins/solution-architect/skills/estimate/evals/evals.json +37 -2
  225. package/plugins/solution-architect/skills/estimate/evals/fixtures/workflow-sin-kowa-mini/ARCHITECTURE.md +28 -0
  226. package/plugins/solution-architect/skills/estimate/evals/fixtures/workflow-sin-kowa-mini/requirements.json +79 -0
  227. package/plugins/solution-architect/skills/estimate/evals/fixtures/workflow-sin-kowa-mini/requirements.md +141 -0
  228. package/plugins/solution-architect/skills/estimate/shared/assets/xlsx-export.js +336 -0
  229. package/plugins/solution-architect/skills/estimate/shared/lib/agentic-task-schema.mjs +24 -0
  230. package/plugins/solution-architect/skills/estimate/{scripts → shared}/lib/context-schema.mjs +2 -2
  231. package/plugins/solution-architect/skills/estimate/{scripts → shared}/lib/inline.mjs +8 -0
  232. package/plugins/solution-architect/skills/estimate/{scripts → shared}/lib/scoring-schema.mjs +1 -1
  233. package/plugins/solution-architect/skills/estimate/{scripts → shared}/lib/scoring.mjs +1 -1
  234. package/plugins/solution-architect/skills/estimate/shared/lib/zip.mjs +60 -0
  235. package/plugins/solution-architect/skills/estimate/workflow-based/FLOW.md +91 -0
  236. package/plugins/solution-architect/skills/estimate/workflow-based/assets/estimate-components.html +994 -0
  237. package/plugins/solution-architect/skills/estimate/workflow-based/assets/estimate-template.html +440 -0
  238. package/plugins/solution-architect/skills/estimate/workflow-based/assets/estimator-system.xlsx +0 -0
  239. package/plugins/solution-architect/skills/estimate/workflow-based/assets/score-review.html +838 -0
  240. package/plugins/solution-architect/skills/estimate/workflow-based/references/hidden-work-by-type.md +429 -0
  241. package/plugins/solution-architect/skills/estimate/workflow-based/references/linking.md +59 -0
  242. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/build-components-template.mjs +80 -0
  243. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/build-template.mjs +60 -0
  244. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/build-workflow-template.mjs +51 -0
  245. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/build-xlsx-template.py +144 -0
  246. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/compute.mjs +32 -0
  247. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/lib/page-html.mjs +44 -0
  248. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/lib/page-view.mjs +71 -0
  249. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/lib/pair-findings.mjs +19 -0
  250. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/lib/requirements.mjs +33 -0
  251. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/lib/rollup.mjs +66 -0
  252. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/lib/schema-components.mjs +69 -0
  253. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/lib/schema.mjs +70 -0
  254. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/lib/score-diff.mjs +54 -0
  255. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/lib/score-html.mjs +52 -0
  256. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/lib/xlsx-rows.mjs +51 -0
  257. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/render.mjs +42 -0
  258. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/score-review.mjs +46 -0
  259. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/template/arch-link.js +9 -0
  260. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/template/click.js +28 -0
  261. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/template/prelude.js +4 -0
  262. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/template/view.js +63 -0
  263. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/browser.test.mjs +127 -0
  264. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/build-pages.test.mjs +43 -0
  265. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/build-template.test.mjs +18 -0
  266. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/cli.test.mjs +48 -0
  267. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/estimator-system.test.mjs +66 -0
  268. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/fixtures/ARCHITECTURE-mini.md +31 -0
  269. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/fixtures/feedback.json +19 -0
  270. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/fixtures/inputs-pass.json +80 -0
  271. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/fixtures/measurements.jsonl +0 -0
  272. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/fixtures/requirements.json +79 -0
  273. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/page-view.test.mjs +54 -0
  274. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/pages-browser.test.mjs +209 -0
  275. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/quality-gates.test.mjs +25 -0
  276. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/render.test.mjs +54 -0
  277. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/requirements.test.mjs +33 -0
  278. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/rollup.test.mjs +80 -0
  279. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/schema.test.mjs +61 -0
  280. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/score-review.test.mjs +108 -0
  281. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/stage.mjs +32 -0
  282. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/workflow-script.test.mjs +24 -0
  283. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/xlsx-rows.test.mjs +58 -0
  284. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/validate.mjs +19 -0
  285. package/plugins/solution-architect/skills/proposal/README.md +13 -0
  286. package/plugins/solution-architect/skills/proposal/SKILL.md +8 -0
  287. package/plugins/solution-architect/skills/proposal/assets/proposal-workflow.html +143 -0
  288. package/plugins/solution-architect/skills/proposal/evals/fixtures/workflow-sin-kowa-mini/ARCHITECTURE.md +31 -0
  289. package/plugins/solution-architect/skills/proposal/evals/fixtures/workflow-sin-kowa-mini/estimation-inputs.json +468 -0
  290. package/plugins/solution-architect/skills/proposal/evals/fixtures/workflow-sin-kowa-mini/estimation.json +773 -0
  291. package/plugins/solution-architect/skills/proposal/evals/fixtures/workflow-sin-kowa-mini/measurements.jsonl +0 -0
  292. package/plugins/solution-architect/skills/proposal/evals/fixtures/workflow-sin-kowa-mini/requirements.json +79 -0
  293. package/plugins/solution-architect/skills/proposal/references/review.md +11 -0
  294. package/plugins/solution-architect/skills/proposal/references/workflow.md +88 -0
  295. package/plugins/solution-architect/skills/proposal/scripts/lib/docx-body.mjs +42 -0
  296. package/plugins/solution-architect/skills/proposal/scripts/lib/docx-package.mjs +56 -0
  297. package/plugins/solution-architect/skills/proposal/scripts/lib/docx-xml.mjs +44 -0
  298. package/plugins/solution-architect/skills/proposal/scripts/lib/workflow-checks.mjs +71 -0
  299. package/plugins/solution-architect/skills/proposal/scripts/lib/workflow-cli.mjs +46 -0
  300. package/plugins/solution-architect/skills/proposal/scripts/lib/workflow-html.mjs +39 -0
  301. package/plugins/solution-architect/skills/proposal/scripts/lib/workflow-lead.mjs +45 -0
  302. package/plugins/solution-architect/skills/proposal/scripts/lib/workflow-page.mjs +30 -0
  303. package/plugins/solution-architect/skills/proposal/scripts/lib/workflow-view.mjs +80 -0
  304. package/plugins/solution-architect/skills/proposal/scripts/render.mjs +5 -1
  305. package/plugins/solution-architect/skills/proposal/scripts/test/docx.test.mjs +68 -0
  306. package/plugins/solution-architect/skills/proposal/scripts/test/e2e.test.mjs +2 -2
  307. package/plugins/solution-architect/skills/proposal/scripts/test/evals-fixtures.test.mjs +9 -2
  308. package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-inputs-pass.json +17 -0
  309. package/plugins/solution-architect/skills/proposal/scripts/test/render.test.mjs +2 -2
  310. package/plugins/solution-architect/skills/proposal/scripts/test/validate.test.mjs +2 -2
  311. package/plugins/solution-architect/skills/proposal/scripts/test/workflow-browser.test.mjs +96 -0
  312. package/plugins/solution-architect/skills/proposal/scripts/test/workflow-checks.test.mjs +98 -0
  313. package/plugins/solution-architect/skills/proposal/scripts/test/workflow-docs.test.mjs +25 -0
  314. package/plugins/solution-architect/skills/proposal/scripts/test/workflow-render.test.mjs +75 -0
  315. package/plugins/solution-architect/skills/proposal/scripts/test/workflow-stage.mjs +15 -0
  316. package/plugins/solution-architect/skills/proposal/scripts/test/workflow-view.test.mjs +78 -0
  317. package/plugins/solution-architect/skills/proposal/scripts/validate.mjs +4 -1
  318. package/plugins/solution-architect/workflows/review-links.js +61 -0
  319. package/plugins/solution-architect/skills/estimate/assets/estimate-template.html +0 -1677
  320. /package/plugins/solution-architect/skills/estimate/{assets → classic/assets}/estimate-template-agentic.html +0 -0
  321. /package/plugins/solution-architect/skills/estimate/{assets → classic/assets}/scores-review-template.html +0 -0
  322. /package/plugins/solution-architect/skills/estimate/{references → classic/references}/agentic-estimation.md +0 -0
  323. /package/plugins/solution-architect/skills/estimate/{references → classic/references}/ai-multipliers.md +0 -0
  324. /package/plugins/solution-architect/skills/estimate/{references → classic/references}/interview.md +0 -0
  325. /package/plugins/solution-architect/skills/estimate/{references → classic/references}/scoring-guide.md +0 -0
  326. /package/plugins/solution-architect/skills/estimate/{references → classic/references}/slicing.md +0 -0
  327. /package/plugins/solution-architect/skills/estimate/{references → classic/references}/techniques.md +0 -0
  328. /package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/lib/agentic-checks.mjs +0 -0
  329. /package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/lib/components.mjs +0 -0
  330. /package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/lib/md-tables.mjs +0 -0
  331. /package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/lib/redact.mjs +0 -0
  332. /package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/lib/scoring-checks.mjs +0 -0
  333. /package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/fixtures/agentic-estimation-fail.md +0 -0
  334. /package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/fixtures/agentic-estimation-pass.md +0 -0
  335. /package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/fixtures/agentic-inputs.json +0 -0
  336. /package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/fixtures/booking-inputs.json +0 -0
  337. /package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/fixtures/estimation-fail.md +0 -0
  338. /package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/fixtures/estimation-pass.md +0 -0
  339. /package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/fixtures/measurements.jsonl +0 -0
  340. /package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/test/zip.mjs +0 -0
  341. /package/plugins/solution-architect/skills/estimate/{scripts → classic/scripts}/validate.mjs +0 -0
  342. /package/plugins/solution-architect/skills/estimate/{scripts → shared}/lib/baselines.mjs +0 -0
  343. /package/plugins/solution-architect/skills/estimate/{scripts → shared}/lib/estimate-math.mjs +0 -0
  344. /package/plugins/solution-architect/skills/estimate/{scripts → shared}/lib/measurements.mjs +0 -0
  345. /package/plugins/solution-architect/skills/estimate/{scripts → shared}/lib/pricing.mjs +0 -0
  346. /package/plugins/solution-architect/skills/estimate/{scripts → shared}/lib/project-price.mjs +0 -0
  347. /package/plugins/solution-architect/skills/estimate/{scripts → shared}/lib/score-diff.mjs +0 -0
@@ -0,0 +1,68 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title><!--@TITLE@--></title>
7
+ <style>
8
+ /* Read-only: the PO's own document, re-drawn from requirements.json. Rows the interview added are tinted. */
9
+ :root {
10
+ --bg: #ffffff; --ink: #1a1d21; --muted: #5c6470; --line: #d9dde3; --accent: #0f5c5a; --wash: #f6f7f9;
11
+ --box: #fbfcfd; --box-line: #44586a; --fl-paper: #e8ecef; --fl-line: #5d6c78; --fl-ink: #141c24; --new-bg: #fff6d6; --new-line: #e3b341;
12
+ }
13
+ @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
14
+ --bg: #11171c; --ink: #e6ecf1; --muted: #93a3b0; --line: #2c3740; --accent: #5fb8b2; --wash: #161d23;
15
+ --box: #1a2229; --box-line: #8fa8bb; --fl-paper: #11171c; --fl-line: #93a3b0; --fl-ink: #e6ecf1; --new-bg: #3a2f0b; --new-line: #bb8009; color-scheme: dark;
16
+ } }
17
+ :root[data-theme="dark"] {
18
+ --bg: #11171c; --ink: #e6ecf1; --muted: #93a3b0; --line: #2c3740; --accent: #5fb8b2; --wash: #161d23;
19
+ --box: #1a2229; --box-line: #8fa8bb; --fl-paper: #11171c; --fl-line: #93a3b0; --fl-ink: #e6ecf1; --new-bg: #3a2f0b; --new-line: #bb8009; color-scheme: dark;
20
+ }
21
+ * { box-sizing: border-box; }
22
+ body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.65 "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif; }
23
+ main { max-width: 52rem; margin: 0 auto; padding: 3rem 16px 5rem; }
24
+ h1 { font-size: 1.9rem; line-height: 1.25; letter-spacing: -.01em; margin: 0 0 .4rem; }
25
+ .byline { color: var(--muted); margin: 0 0 .3rem; }
26
+ .summary { color: var(--muted); font-size: .9rem; margin: 0 0 1.6rem; }
27
+ h2 { font-size: 1.25rem; margin-top: 2.6rem; padding-top: 1.2rem; border-top: 1px solid var(--line); color: var(--accent); }
28
+ h2 .sysno { color: var(--muted); font-weight: 500; }
29
+ p { max-width: 68ch; }
30
+ .tag { display: inline-block; font-size: 11px; font-weight: 600; line-height: 1.5; padding: 0 6px; border-radius: 4px; background: var(--new-bg); border: 1px solid var(--new-line); color: var(--ink); }
31
+ table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
32
+ th, td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
33
+ th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
34
+ td:first-child { font-weight: 600; width: 34%; }
35
+ tr.new td, li.new { background: var(--new-bg); }
36
+ tr.new td:first-child { box-shadow: inset 3px 0 var(--new-line); }
37
+ .src { display: block; font-size: .78rem; color: var(--muted); font-weight: 400; margin-top: 2px; }
38
+ ul { padding-left: 20px; }
39
+ li { margin: 4px 0; }
40
+ li.new { list-style: none; margin-left: -20px; padding: 6px 10px 6px 17px; border-left: 3px solid var(--new-line); border-radius: 0 4px 4px 0; }
41
+ /* Diagrams use the estimate page's style, so a workflow looks the same in every phase:
42
+ grey panel, square white boxes, thin grey arrows; solid for the main flow, dotted for a branch. */
43
+ .flow { overflow-x: auto; margin: 0 0 1rem; padding: 16px; background: var(--fl-paper); border: 1px solid var(--line); }
44
+ .flow-name { font-size: .85rem; font-weight: 600; color: var(--muted); margin: 1.2rem 0 .3rem; }
45
+ .grid { display: grid; grid-auto-columns: max-content; justify-items: center; align-items: center; column-gap: 0; width: max-content; }
46
+ .step { background: var(--box); border: 1px solid var(--box-line); border-radius: 0; padding: 7px 14px; font: 12px/1.35 system-ui, sans-serif; color: var(--fl-ink); text-align: center; max-width: 160px; }
47
+ .grid > .step { justify-self: stretch; }
48
+ .grid > .step:not(.alt):not(.back):not(.wide) { max-width: 172px; }
49
+ .grid > .step.wide { max-width: none; }
50
+ .step.alt, .step.back, .down { margin: 0 6px; }
51
+ .step.back { color: var(--muted); }
52
+ /* Main flow: thin solid line, small filled head touching the next box. The "→" text stays for screen readers. */
53
+ .arrow { justify-self: stretch; display: flex; align-items: center; min-width: 36px; font-size: 0; }
54
+ .arrow::before { content: ""; flex: 1; height: 1px; background: var(--fl-line); }
55
+ .arrow::after { content: ""; border: 4px solid transparent; border-right: 0; border-left-width: 7px; border-left-color: var(--fl-line); }
56
+ /* Branch: thin dotted line top to bottom, the PO's label sitting on it, same head touching the box below. */
57
+ .down { justify-self: stretch; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 52px; padding: 14px 0 18px; text-align: center; font: 11px/1.3 system-ui, sans-serif; color: var(--muted); }
58
+ .down::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 7px; width: 1px; background: repeating-linear-gradient(to bottom, var(--fl-line) 0 3px, transparent 3px 6px); }
59
+ .down::after { content: ""; position: absolute; left: calc(50% - 3.5px); bottom: 0; border: 4px solid transparent; border-bottom: 0; border-top-width: 7px; border-top-color: var(--fl-line); }
60
+ .lbl { position: relative; max-width: 160px; padding: 1px 6px; background: var(--fl-paper); }
61
+ </style>
62
+ </head>
63
+ <body>
64
+ <main>
65
+ <!--@BODY@-->
66
+ </main>
67
+ </body>
68
+ </html>
@@ -5,7 +5,7 @@
5
5
  "id": 0,
6
6
  "name": "thin-warehouse-brief-gate-check",
7
7
  "prompt": "Dana at Havenridge Logistics has been emailing us for two weeks about replacing their stock-count spreadsheet and I finally got the whole thread exported — it's in havenridge-thread.md. Sales wants something to take to her board on the 24th. Can you run discovery on this and start the requirements package in leads/havenridge/? Fair warning, it's thin — I don't think she's told us half of what we need.",
8
- "expected_output": "Extracts what the thread actually contains, then stops and asks: depth mode, and a grounded set of P1 questions quoting Dana's own lines. The supervisor-only-adjust statement (3 Sep) versus the anyone-on-the-floor statement (5 Sep) is recorded as an open contradiction, not silently reconciled. Sage 200 direction, the missing role set, budget, volumes and a real go-live date are asked for, never filled in. Any package written stays DRAFT/CLARIFICATION_REQUIRED.",
8
+ "expected_output": "Extracts what the thread actually contains, then states depth (STANDARD), asks the scope mode in one question, naming the evidence and marking no pick, and asks grounded P1 questions, one per turn quoting Dana's own lines. The supervisor-only-adjust statement (3 Sep) versus the anyone-on-the-floor statement (5 Sep) is recorded as an open contradiction, not silently reconciled. Sage 200 direction, the missing role set, budget, volumes and a real go-live date are asked for, never filled in. Any package written stays DRAFT/CLARIFICATION_REQUIRED.",
9
9
  "files": [
10
10
  "plugins/business-analyst/skills/business-analyst/evals/fixtures/thin-warehouse-brief/havenridge-thread.md"
11
11
  ],
@@ -32,8 +32,9 @@ exceptions.
32
32
 
33
33
  ## Impact mapping
34
34
  WHY (business goal) → WHO (actors) → HOW (behavior change) → WHAT
35
- (capability). A feature that maps to no WHY becomes an open question, not
36
- a requirement.
35
+ (capability). A feature that maps to no WHY is asked about, and closes
36
+ like every asked question: an answer, an "Assume …" pick, or out of
37
+ scope (interview.md §2b).
37
38
 
38
39
  ## Example mapping
39
40
  Per story: rules (blue), examples per rule (green), questions (red).
@@ -12,26 +12,98 @@ inputs first, then ask only about holes, highest impact first.
12
12
  - **P2 — high impact**: could materially change scope, complexity, or cost.
13
13
  - **P3 — detail**: safely deferred; record in the register, don't ask now.
14
14
 
15
- Triage rule: ask P1s first, in groups of at most 4 related questions per
16
- message. Never move to P2 while an easy-to-answer P1 is open.
15
+ Triage rule: ask P1s first, one question per turn, and wait for the
16
+ answer before choosing the next — each answer re-ranks the gaps. Never
17
+ move to P2 while an easy-to-answer P1 is open. Every question you ask closes
18
+ (§2b); only gaps you never ask stay open questions.
19
+
20
+ Ask through the host's question tool: `AskUserQuestion` in Claude Code,
21
+ the multiple-choice question tool on claude.ai. No such tool → ask the one
22
+ question in plain text and stop. Put the summary of what you extracted
23
+ and the frameworks picked in the message before the first question, not
24
+ inside it.
17
25
 
18
26
  ## §2 Question rules
19
27
 
20
28
  1. Never ask what the inputs already answer.
21
29
  2. Ground every question in what the client said: "You mentioned approved
22
30
  contracts are stored in SharePoint. Does the new system need to A. read
23
- from it, B. write back, C. both, D. neither?" — offer concrete options
24
- where possible.
31
+ from it, B. write back, C. both, D. neither?" In the question tool the
32
+ options are the choices (at most 4); free text arrives through "Other".
33
+ Never recommend: no option is labelled or ordered as your pick. Options
34
+ are: real answers when the input suggests them; one or more
35
+ assumptions, each of which starts with "Assume" and states its
36
+ boundary ("Assume under 1 hour offline; longer is a change request");
37
+ and "Leave <thing> out of scope". There is no "Don't know" option.
38
+ An option that rests on the input cites its input quote: the file,
39
+ the place and the exact words, copied, not paraphrased
40
+ (SinKowaProposal.docx, System 4: "dead spots inside the warehouse").
41
+ An option with no input quote cites nothing; its "Assume" already
42
+ says it is a guess. An assumption's boundary is a scale and a limit
43
+ ("hours offline: under 1"). Take the limit from the input quote first,
44
+ else the usual value for that kind of business, else the smallest
45
+ scope still safe to price; past the limit is a change request.
25
46
  3. Explain why a question matters when the answer is expensive to get.
26
47
  4. Adapt: each round of answers reprioritizes the remaining gaps.
27
48
  5. Prefer a real example over an abstract description: "walk me through
28
49
  the last time this happened" beats "how does this normally work".
29
50
  6. Challenge vague words (see the banned list in writing.md): "how fast is
30
51
  fast — what is acceptable in seconds?"
31
- 7. Distinguish **unknown** (client doesn't know yet — record the question)
52
+ 7. Distinguish **unknown** (client doesn't know yet — offer the
53
+ assumptions that bound it)
32
54
  from **undecided** (client must choose — present the options and the
33
55
  consequence of each).
34
56
  8. Contradictions are surfaced, never resolved silently (§5).
57
+ 9. Never cite register ids (`CONFLICT-`, `Q-`, `FR-`, `ASM-`, …) in a
58
+ question. They are internal until requirements.md exists, and the user
59
+ has never seen them. Point at the input instead: the document, its
60
+ section or page, and a short quote. On a re-run you may add the id in
61
+ brackets after the plain question.
62
+
63
+ ## §2a Who is answering
64
+
65
+ Never ask where an answer comes from — not up front, and not tacked onto
66
+ another question ("also say whether the client told you"). Facts from the
67
+ input documents keep the labels the evidence supports. Systems, features
68
+ and workflows an input document lists are `confirmed`, source the
69
+ document: the PO wrote that list for the estimate.
70
+ Never draft systems, workflows or features yourself. Workflows come only
71
+ from the input: a diagram, or steps it lists. A system the input gives no
72
+ steps for has no workflow, and its features have `steps: []`. A gap you
73
+ see (a missing step, a feature the evidence implies) is a question for
74
+ the user; a yes adds it. A system, feature or workflow the user asks for
75
+ in the interview is `confirmed`, source `PO in interview, <date>`: the
76
+ PO's list is decided, like an input document. Every other answer closes
77
+ per §2b.
78
+
79
+ An undecided workflow (say, one a 0.3.x package drafted) is asked with
80
+ only these options:
81
+
82
+ - the steps exactly as the input lists them, if it lists any;
83
+ - "No workflow for <system>: its features stay, on no step" — remove the
84
+ workflow and its steps from every feature; a feature left with no step
85
+ gets `steps: []`;
86
+ - the PO lists the steps through "Other".
87
+
88
+ Never offer a step order the input does not give. Leaving a workflow out
89
+ never removes a feature.
90
+
91
+ ## §2b How a question ends
92
+
93
+ Every question you ask closes one of three ways:
94
+
95
+ | The user picks | You record |
96
+ | --- | --- |
97
+ | a real answer, or one typed through "Other" | the item it settles, label `confirmed`, source the user (the client, when the user says "the client told me") |
98
+ | "Assume …" | an ASM row: the option's text, impact high for P1 / medium for P2 / low for P3, status `accepted` (the PO decided it, so it never blocks `READY_FOR_ARCHITECTURE`), source `PO in interview, <date>`; the review page shows it ★ New |
99
+ | "Leave … out of scope" | FR scope `out` (or a `scope.out` entry when there is no FR); Part 3 lists it |
100
+ | "Drop this assumption" (offered only on a question about an input assumption) | that input ASM row's status `resolved`; the review page no longer shows it. Any other answer sets the row `accepted`, its words unchanged |
101
+
102
+ The user types "don't know" (or similar) in "Other" → ask once more with
103
+ the same options and say they must pick an assumption or leave it out —
104
+ the estimate cannot price an open gap. An asked question never stays
105
+ open. Gaps you never ask (P3) stay in the open-questions register for
106
+ engineers; the review page never shows it.
35
107
 
36
108
  ## §3 Sequencing shapes
37
109
 
@@ -40,7 +112,8 @@ message. Never move to P2 while an easy-to-answer P1 is open.
40
112
  cases.
41
113
  - **Pyramid** (narrow → broad): for detailed-but-suspect inputs (a feature
42
114
  list with no why). Start from a concrete feature, climb to the goal it
43
- serves — features that climb to no goal become open questions.
115
+ serves — features that climb to no goal are asked, and close like
116
+ every asked question (§2b).
44
117
  - **Diamond** (narrow → broad → narrow): for existing-system work. Start
45
118
  from the pain point, widen to the surrounding process, narrow back to
46
119
  the change.
@@ -75,15 +148,90 @@ Work through these progressively; the depth mode decides how far.
75
148
  ## §5 Contradiction protocol
76
149
 
77
150
  When two statements conflict: record a `CONFLICT-` entry quoting both
78
- statements with their sources, present it to the user verbatim, and ask
79
- which holds (or whether both do under different conditions). Never pick an
151
+ statements with their sources. To the user, show the two quotes and where
152
+ each appears in the input ("PRD §Assumptions says … ; PRD §System 1,
153
+ Offline sync says …"), never the entry or its id, and ask which holds (or
154
+ whether both do under different conditions). Never pick an
80
155
  interpretation yourself. A conflict stays open until the client resolves
81
156
  it; open conflicts block READY_FOR_ARCHITECTURE.
82
157
 
83
158
  ## §6 Depth modes
84
159
 
160
+ Default STANDARD; never ask. Use QUICK or DEEP only when the user names it.
161
+
85
162
  - **QUICK**: layers 1, 2, 6, 7 only; P1 questions only; one interview round.
86
163
  - **STANDARD**: all layers; P1 + P2; iterate until P1s are answered or
87
164
  explicitly parked.
88
165
  - **DEEP**: all layers; P1–P3; example mapping on every complex rule;
89
166
  scenario tables for every critical FR.
167
+
168
+ ## §7 Scope mode
169
+
170
+ Ask the mode in one question through the host's question tool. In the
171
+ question text, name the cues below that the input shows ("Your PRD names
172
+ two business areas, Warehouse ops and Invoicing, and draws a to-be
173
+ workflow"), or say it shows none. Mark no option as your pick. The options
174
+ say what each mode gives:
175
+
176
+ - "Workflow: systems, their steps and features"
177
+ - "Classic: one flat list of requirements"
178
+
179
+ The cues:
180
+
181
+ 1. Two or more named business areas, each with its own features
182
+ ("Warehouse ops", "Invoicing" — the word "system" is not required).
183
+ 2. A to-be workflow, drawn as a diagram or listed as steps. An as-is
184
+ diagram alone is not a cue: classic mode records as-is workflows too.
185
+
186
+ Skip the question when the user already named a mode, or on a re-run
187
+ (keep the existing `scopeMode`). Absent means `classic`.
188
+
189
+ Workflow mode adds one question group after workflows:
190
+
191
+ 1. **Systems** — the business areas the client would name ("Warehouse
192
+ operations", not "WMS backend"). One purpose line each.
193
+ 2. **To-be workflows**: only those the input draws or lists as steps
194
+ (short step names, 2–5 words, plus side exits and loops; sub-workflows
195
+ say where they start and rejoin). A system without one is fine.
196
+ 3. **Features**: per system, what the client asked for. Each one points at
197
+ the steps it serves (`["*"]` for platform-wide ones such as login; `[]`
198
+ when its system has no workflow) and lists its FRs. Every in-scope FR
199
+ must land in a feature; an FR that fits nowhere is a question for the
200
+ user, not a new feature.
201
+
202
+ Everything here comes from the input or the user's answers. Nothing is
203
+ drafted, so every system, workflow and feature is `confirmed` before the
204
+ review page (§8 refuses anything else). A workflow that grows in the
205
+ interview keeps its id.
206
+
207
+ ## §8 PO review page (workflow mode)
208
+
209
+ After the fresh-eyes review, show the PO the scope in the shape of their
210
+ own document. Per system the page shows its purpose, the workflows the
211
+ input drew, and a feature table; then the assumptions. Rows added in the
212
+ interview carry ★ New and "Added: <source>". The page is read-only:
213
+ nothing to answer, nothing to paste. Open questions never appear on it.
214
+
215
+ 1. `node scripts/review.mjs page --json <dir>/requirements.json --out <dir>/review.html`.
216
+ Exit 1 → show its lines.
217
+ - `not decided; ask the PO in the interview` → ask that item as one
218
+ question (§2; an undecided workflow takes only the §2a options),
219
+ record the answer (§2b), and re-run.
220
+ - Any other line → fix those fields in the JSON (no ids in text the PO
221
+ sees) and re-run.
222
+ 2. Show it.
223
+ - claude.ai: present the file. It shows as a file card, and a click
224
+ opens the page beside the chat. Don't rebuild it as an artifact.
225
+ - Claude Code: give the path.
226
+
227
+ Then ask one question through the host's question tool: "Does the
228
+ review page read like your document?" Options: "Approve: go on to
229
+ requirements.md and the readiness report" and "Change something: say
230
+ what in Other". Neither is your pick. No question tool → ask it in
231
+ plain text and stop. Approve → step 11.
232
+ 3. A change (through Other, or in chat) is a re-run (SKILL.md Re-run). Ask one question per
233
+ unclear change and edit the JSON. Re-run `scope` once requirements.md
234
+ exists; before that, validate with `--json` only. Then go to step 1
235
+ again and ask again.
236
+
237
+ The user says skip or later → go to step 11.
@@ -1,15 +1,24 @@
1
1
  # Fresh-eyes review
2
2
 
3
3
  After validate.mjs passes, dispatch ONE subagent with fresh eyes over both
4
- artifacts. Give it the two file paths and this checklist verbatim. Apply
4
+ artifacts (workflow mode: over requirements.json only — the md is written
5
+ after the PO review; read "Parts 1–4" as the JSON's context, workflows,
6
+ rules and requirements). Give it the two file paths and this checklist verbatim. Apply
5
7
  its findings, re-run validate.mjs, and stop after one cycle — do not loop.
6
8
 
9
+ No subagent available (e.g. claude.ai) → run this checklist yourself and
10
+ write `Review: self-reviewed, no fresh eyes available` in the Part 5
11
+ readiness report.
12
+
7
13
  ## Checklist
8
14
 
9
15
  1. **Invented requirements**: is any `confirmed` item unsupported by a
10
- quoted source? Downgrade to `assumed` or `recommended`.
11
- 2. **Hidden solutioning**: does any FR prescribe a technology or
12
- architecture ("use SharePoint webhooks")? Rewrite as a capability.
16
+ quoted source? Downgrade to `assumed` or `recommended` (a system,
17
+ workflow or feature: raise it as an interview question instead of
18
+ downgrading it).
19
+ 2. **Hidden solutioning**: does any FR, system name or feature name
20
+ prescribe a technology or architecture ("use SharePoint webhooks",
21
+ "Order API")? Rewrite as a capability.
13
22
  3. **Vague requirements**: any FR that two reasonable readers would
14
23
  implement differently? Flag with the two readings.
15
24
  4. **Missed contradictions**: do any two statements (rules, scopes,
@@ -20,6 +29,11 @@ its findings, re-run validate.mjs, and stop after one cycle — do not loop.
20
29
  actually contain? Name the section that contradicts the score.
21
30
  7. **Traceability spot-check**: pick 3 FRs; do their traces point at
22
31
  goals/workflows/rules that genuinely motivate them?
32
+ 8. **Unbuilt steps** (workflow mode): list to-be workflow steps that no
33
+ feature points at. For each, is it work nobody has priced (add it to a
34
+ feature, or raise a question) or a person's manual act (fine as is)?
35
+ 9. **Verbatim inputs**: Input assumptions (source names an input file)
36
+ are verbatim: flag a problem, never reword them.
23
37
 
24
38
  Report findings as a list: `<artifact>:<id or section> — <problem> — <fix>`.
25
39
  No praise, no rewrites beyond the flagged items.
@@ -7,7 +7,36 @@ Two artifacts, always together, in the lead directory:
7
7
 
8
8
  The canonical json shape is `scripts/test/fixtures/requirements-pass.json` —
9
9
  copy its structure exactly; the validator enforces it. `schemaVersion` is
10
- `"1.0"`; bump only on a breaking shape change.
10
+ `"1.0"`; bump only on a breaking shape change. Workflow scope mode:
11
+ `scripts/test/fixtures/requirements-workflow-pass.json` adds `scopeMode`,
12
+ `mapLabel`, `systems`, `features`, and `label`/`source`/`steps`/`branches`
13
+ (`replaces`, `sub` optional) on to-be workflows.
14
+
15
+ Assumptions may carry `source`; one the PO picked in the interview has
16
+ `source: "PO in interview, <date>"`. Every question asked in the
17
+ interview closes as an answer, an assumption or out of scope, so
18
+ `openQuestions` holds only gaps never asked (P3), for engineers.
19
+ `systems`, `features` and to-be workflows hold only what will be built;
20
+ downstream skills read them as is. A system may have no workflow, and a
21
+ feature may have `steps: []`.
22
+ Names, `purpose`, `does`, steps, branch labels, `share`, a `PO in
23
+ interview` source, and the text of every assumption that is not
24
+ `resolved` reach the PO review page verbatim. Write them without ids
25
+ (`review.mjs page` refuses one).
26
+
27
+ A branch `label` is the input's own arrow text, copied; an arrow with no
28
+ text has no `label`. Never write one.
29
+
30
+ Every assumption the input lists is an ASM row, word for word, in the
31
+ input's order, `source` naming the file and section
32
+ (`"SinKowaProposal.docx, Assumptions"`), even when it reads like a
33
+ constraint. A vague one is asked in the interview: the PO's answer adds
34
+ a new assumption (`PO in interview, <date>`), and the input's row keeps
35
+ its words. Once the PO answers, the input row's status becomes
36
+ `accepted`; its words stay. A question about an input assumption adds
37
+ the option "Drop this assumption"; picking it sets that row's status to
38
+ `resolved`. An input assumption leaves the page only when the PO picks
39
+ to drop it (status `resolved`).
11
40
 
12
41
  ## ID conventions
13
42
 
@@ -19,14 +48,16 @@ copy its structure exactly; the validator enforces it. `schemaVersion` is
19
48
  | FR- | functional requirements | CON- | constraints (hard limits) |
20
49
  | BR- | business rules | ASM- | assumptions (unverified beliefs) |
21
50
  | SC- | scenarios | Q- | open questions |
22
- | | | CONFLICT- | contradictions |
51
+ | SYS- | systems (workflow mode) | CONFLICT- | contradictions |
52
+ | FEAT- | features (workflow mode) | | |
23
53
 
24
54
  Three digits, zero-padded (`FR-001`). IDs are stable: never renumber on
25
55
  re-run; retired items keep their id with a note rather than vanishing.
26
56
 
27
- Constraint vs assumption: a constraint is a confirmed boundary ("must run in
28
- the client's M365 tenant"); an assumption is an unverified belief ("managers
29
- authenticate through Entra"). Never file one as the other.
57
+ Constraint vs assumption: a constraint is a confirmed boundary ("must run
58
+ in the client's M365 tenant"); an assumption is an unverified belief
59
+ ("managers authenticate through Entra"). Never file one as the other; the
60
+ input's own assumptions list is the exception above.
30
61
 
31
62
  ## Label discipline
32
63
 
@@ -34,7 +65,9 @@ Every requirement, NFR, integration and data row carries
34
65
  `label: confirmed | assumed | recommended` and (where the schema asks) a
35
66
  `source`. Recommendations never render as confirmed requirements; a
36
67
  `recommended` item in scope `in` must have an open question referencing it
37
- (the validator enforces this).
68
+ (the validator enforces this). In workflow mode scope items are never
69
+ `recommended` (the page refuses undecided items); the paired-open-question
70
+ rule applies to classic-mode requirements and unasked P3 gaps.
38
71
 
39
72
  ## Ambiguous terms — banned in requirement text
40
73
 
@@ -67,10 +100,18 @@ readiness: <overall number>
67
100
  - **Part 2 — Process & Domain**: as-is workflows (mermaid flowchart when a
68
101
  workflow has more than one actor), decision points, business-rules table
69
102
  with concrete examples, exceptions, to-be capabilities, glossary of
70
- domain terms.
103
+ domain terms. Workflow mode: no to-be capabilities prose — the To-be
104
+ scope section written by `scripts/scope.mjs` replaces it (systems table,
105
+ then per system its workflows as mermaid and a feature table with ids
106
+ and a Requirements column). No ⚠ marks or "please confirm" banners: scope is decided in the
107
+ interview, and the md is written after the review page. Frontmatter
108
+ gains `scopeMode: workflow`.
71
109
  - **Part 3 — Requirements**: scope (out / future / unconfirmed — in-scope
72
110
  is the FR table itself), actors and permissions, FR table (id, text,
73
- label, scope), NFRs, data, integrations, dependencies.
111
+ label, scope; workflow mode adds a last `Feature` column — the feature
112
+ name(s) holding the FR, `—` when none; header starts
113
+ `| ID | Requirement |`, which the validator looks for), NFRs, data,
114
+ integrations, dependencies.
74
115
  - **Part 4 — Acceptance Scenarios**: per critical FR a given/when/then
75
116
  table; input → expected tables for rule-heavy requirements.
76
117
  - **Part 5 — Readiness Report**: readiness per area and overall, open
@@ -1,4 +1,7 @@
1
1
  import { REGISTERS, STATUSES, AREAS, checkSchema } from './schema.mjs';
2
+ import { scopeIds } from './scope-rules.mjs';
3
+ import { checkScope } from './scope-checks.mjs';
4
+ import { checkScopeMd } from './scope-md.mjs';
2
5
 
3
6
  const LABELED = ['requirements', 'nfrs', 'integrations', 'data'];
4
7
  const SOURCED = ['requirements', 'businessRules', 'constraints'];
@@ -104,7 +107,7 @@ export function checkReadiness(pkg) {
104
107
 
105
108
  const PARTS = ['Part 1', 'Part 2', 'Part 3', 'Part 4', 'Part 5'];
106
109
  const QUICK_PARTS = ['Part 1', 'Part 3', 'Part 5'];
107
- const ID_TOKEN = /\b(?:G|ACT|WF|FR|BR|SC|NFR|INT|DAT|CON|ASM|Q|CONFLICT)-\d{3}\b/g;
110
+ export const ID_TOKEN = /\b(?:G|ACT|WF|FR|BR|SC|NFR|INT|DAT|CON|ASM|Q|CONFLICT|SYS|FEAT)-\d{3}\b/g;
108
111
 
109
112
  function sectionBodies(md) {
110
113
  const bodies = {};
@@ -128,7 +131,7 @@ export function checkMd(pkg, md) {
128
131
  else if (!bodies[key].trim()) findings.push(`md: empty section "## ${part}"`);
129
132
  }
130
133
  const mdIds = new Set([...md.matchAll(ID_TOKEN)].map((m) => m[0]));
131
- for (const id of collectIds(pkg)) {
134
+ for (const id of [...collectIds(pkg), ...scopeIds(pkg)]) {
132
135
  if (!mdIds.has(id)) findings.push(`md: id ${id} absent from requirements.md`);
133
136
  }
134
137
  const fmStatus = md.match(/^status:\s*(\S+)/m)?.[1];
@@ -153,14 +156,17 @@ export function checkMdOrphanIds(pkg, md, ids) {
153
156
  export function checkPackage({ pkg, md }) {
154
157
  const schemaFindings = checkSchema(pkg);
155
158
  if (schemaFindings.length) return schemaFindings;
156
- const ids = collectIds(pkg);
157
- return [
159
+ const ids = new Set([...collectIds(pkg), ...scopeIds(pkg)]);
160
+ const scope = checkScope(pkg, ids);
161
+ const json = [
158
162
  ...checkDuplicates(pkg),
159
163
  ...checkRefs(pkg, ids),
160
164
  ...checkLabels(pkg),
161
165
  ...checkAmbiguity(pkg),
162
166
  ...checkReadiness(pkg),
163
- ...checkMd(pkg, md),
164
- ...checkMdOrphanIds(pkg, md, ids),
167
+ ...scope,
165
168
  ];
169
+ // A broken scope cannot be rendered, so the md compare waits for it.
170
+ if (md == null) return json;
171
+ return [...json, ...checkMd(pkg, md), ...checkMdOrphanIds(pkg, md, ids), ...(scope.length ? [] : checkScopeMd(pkg, md))];
166
172
  }
@@ -0,0 +1,66 @@
1
+ // requirements.json → what the read-only review page shows (spec R1–R4).
2
+ // Business words only: ids never reach the page.
3
+ import { ID_TOKEN } from './checks.mjs';
4
+ import { toBe } from './scope-rules.mjs';
5
+
6
+ const NEW = 'PO in interview';
7
+ const added = (r) => (typeof r.source === 'string' && r.source.startsWith(NEW) ? r.source : null);
8
+ const title = (lead) => lead.split('-').map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(' ');
9
+ const shownAssumptions = (pkg) => (pkg.assumptions ?? []).filter((a) => a.status !== 'resolved');
10
+ const flowMap = (pkg) => new Map((pkg.workflows ?? []).map((w) => [w.id, w]));
11
+
12
+ function flowData(w, flows) {
13
+ const steps = w.steps ?? [];
14
+ return {
15
+ name: w.name, steps,
16
+ branches: (w.branches ?? []).map((b) => ({ from: b.from, to: b.to, label: b.label ?? null, back: steps.includes(b.to) })),
17
+ sub: w.sub ? {
18
+ startsAt: w.sub.startsAt.slice(w.sub.startsAt.indexOf(':') + 1),
19
+ rejoins: flows.get(w.sub.rejoins)?.name ?? null, share: w.sub.share ?? null,
20
+ } : null,
21
+ };
22
+ }
23
+
24
+ export function pageData(pkg, date) {
25
+ const flows = flowMap(pkg);
26
+ const feats = new Map(pkg.features.map((f) => [f.id, f]));
27
+ const systems = pkg.systems.map((s) => ({
28
+ name: s.name, purpose: s.purpose,
29
+ flows: (s.workflows ?? []).map((id) => flowData(flows.get(id), flows)),
30
+ features: (s.features ?? []).map((id) => feats.get(id)).map((f) => ({ name: f.name, does: f.does, added: added(f) })),
31
+ }));
32
+ const assumptions = shownAssumptions(pkg).map((a) => ({ text: a.text, added: added(a) }));
33
+ return { title: title(pkg.lead), date, systems, assumptions };
34
+ }
35
+
36
+ // R2: the page shows decided scope only; the interview settles the rest.
37
+ export function undecided(pkg) {
38
+ return [...pkg.systems, ...toBe(pkg), ...pkg.features]
39
+ .filter((r) => r.label !== 'confirmed')
40
+ .map((r) => `${r.id}: not decided; ask the PO in the interview`);
41
+ }
42
+
43
+ // R3: every free text the page shows verbatim, as [record id, field, text].
44
+ function shownText(pkg) {
45
+ const flows = flowMap(pkg);
46
+ const when = (ok, row) => (ok ? [row] : []);
47
+ const flowText = (w) => [[w.id, 'name', w.name], ...(w.steps ?? []).map((x) => [w.id, 'step', x]),
48
+ ...(w.branches ?? []).flatMap((b) => [...when(!(w.steps ?? []).includes(b.to), [w.id, 'step', b.to]), [w.id, 'branch label', b.label]]),
49
+ [w.id, 'share', w.sub?.share]];
50
+ return [
51
+ ...pkg.systems.flatMap((s) => [[s.id, 'name', s.name], [s.id, 'purpose', s.purpose]]),
52
+ ...pkg.systems.flatMap((s) => (s.workflows ?? []).map((id) => flows.get(id))).flatMap(flowText),
53
+ ...pkg.features.flatMap((f) => [[f.id, 'name', f.name], [f.id, 'does', f.does], ...when(added(f), [f.id, 'source', f.source])]),
54
+ ...shownAssumptions(pkg).flatMap((a) => [[a.id, 'text', a.text], ...when(added(a), [a.id, 'source', a.source])]),
55
+ ];
56
+ }
57
+
58
+ // The page must not carry ids (R3): one finding per field that names one.
59
+ export function idLeaks(pkg) {
60
+ const out = [];
61
+ for (const [id, field, text] of shownText(pkg)) {
62
+ const ids = [...new Set(String(text ?? '').match(ID_TOKEN) ?? [])];
63
+ if (ids.length) out.push(`${id}: ${field} names an id (${ids.join(', ')}); the PO page shows it`);
64
+ }
65
+ return out;
66
+ }
@@ -0,0 +1,53 @@
1
+ // Where each box of a workflow diagram sits (spec R10). Branches form a tree
2
+ // under each main step: a step's children leave that step, a side branch's
3
+ // children leave its box, a loop back is a leaf. Siblings sit side by side;
4
+ // a parent spans its children. Grid columns are 1-based; main steps are
5
+ // separated by one arrow column. Python twin: review_layout.py.
6
+
7
+ // A node's width is its leaf count, or 1 with no children.
8
+ const width = (n) => (n.kids.length ? n.kids.reduce((s, k) => s + width(k), 0) : 1);
9
+
10
+ // Children keep JSON order; a branch is claimed once, so a cycle or a shared
11
+ // `to` never loops or draws a branch twice.
12
+ function forest(steps, branches) {
13
+ const placed = new Set();
14
+ const take = (b) => { placed.add(b); return { b, kids: [] }; };
15
+ const grow = (from) => {
16
+ const kids = branches.filter((b) => b.from === from && !placed.has(b)).map(take);
17
+ for (const k of kids) k.kids = k.b.back ? [] : grow(k.b.to);
18
+ return kids;
19
+ };
20
+ const roots = steps.map(grow);
21
+ // A branch no step reaches (a cycle between branch boxes) roots under the first step.
22
+ for (const b of branches) {
23
+ if (placed.has(b)) continue;
24
+ const n = take(b);
25
+ n.kids = b.back ? [] : grow(b.to);
26
+ roots[0].push(n);
27
+ }
28
+ return roots;
29
+ }
30
+
31
+ // Depth d draws its connector in row 2d and its box in row 2d + 1.
32
+ function place(kids, depth, col) {
33
+ let c = col;
34
+ return kids.flatMap((n) => {
35
+ const at = { b: n.b, depth, col: c, span: width(n) };
36
+ c += at.span;
37
+ return [at, ...place(n.kids, depth + 1, at.col)];
38
+ });
39
+ }
40
+
41
+ // { lanes: [{ name, col, span }], boxes: [{ b, depth, col, span }] }
42
+ export function layout(steps, branches) {
43
+ const lanes = [];
44
+ const boxes = [];
45
+ let col = 1;
46
+ forest(steps, branches).forEach((kids, i) => {
47
+ const span = width({ kids });
48
+ lanes.push({ name: steps[i], col, span });
49
+ boxes.push(...place(kids, 1, col));
50
+ col += span + 1;
51
+ });
52
+ return { lanes, boxes };
53
+ }