@v11g/agents-rock 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/README.md +65 -0
  2. package/bin/agents-rock.mjs +4 -0
  3. package/package.json +13 -0
  4. package/plugins/solution-architect/.claude-plugin/plugin.json +9 -0
  5. package/plugins/solution-architect/skills/analyze-requirements/README.md +75 -0
  6. package/plugins/solution-architect/skills/analyze-requirements/SKILL.md +31 -0
  7. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/OFL.txt +98 -0
  8. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
  9. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-mono-latin-600-normal.woff2 +0 -0
  10. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
  11. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-500-normal.woff2 +0 -0
  12. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
  13. package/plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json +52 -0
  14. package/plugins/solution-architect/skills/analyze-requirements/assets/section-help.json +101 -0
  15. package/plugins/solution-architect/skills/analyze-requirements/assets/viewer-template.html +2389 -0
  16. package/plugins/solution-architect/skills/analyze-requirements/references/interview.md +53 -0
  17. package/plugins/solution-architect/skills/analyze-requirements/references/likec4.md +157 -0
  18. package/plugins/solution-architect/skills/analyze-requirements/references/project-types.md +60 -0
  19. package/plugins/solution-architect/skills/analyze-requirements/references/research.md +78 -0
  20. package/plugins/solution-architect/skills/analyze-requirements/references/viewer.md +772 -0
  21. package/plugins/solution-architect/skills/analyze-requirements/references/writing.md +206 -0
  22. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/cdp.mjs +74 -0
  23. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/chrome.mjs +66 -0
  24. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/companion-links.mjs +20 -0
  25. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-kinds.mjs +37 -0
  26. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-links.mjs +26 -0
  27. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-routes.mjs +27 -0
  28. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-sections.mjs +78 -0
  29. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/embed.mjs +8 -0
  30. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/er-entities.mjs +16 -0
  31. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/fonts.mjs +39 -0
  32. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/frontmatter.mjs +17 -0
  33. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/inputs.mjs +41 -0
  34. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-config.mjs +41 -0
  35. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-extract.mjs +29 -0
  36. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-steps.mjs +22 -0
  37. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-defs.mjs +20 -0
  38. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-flows.mjs +46 -0
  39. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-inline.mjs +31 -0
  40. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-links.mjs +7 -0
  41. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-list.mjs +64 -0
  42. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-render.mjs +127 -0
  43. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-shape.mjs +19 -0
  44. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-tables.mjs +30 -0
  45. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-views.mjs +48 -0
  46. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-wide.mjs +44 -0
  47. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/nav.mjs +72 -0
  48. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/offline.mjs +19 -0
  49. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/port.mjs +13 -0
  50. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/quality-gate.mjs +113 -0
  51. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/section-help.mjs +49 -0
  52. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/slug-registry.mjs +11 -0
  53. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-clusters.mjs +15 -0
  54. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-deployment.mjs +8 -0
  55. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-elections.mjs +20 -0
  56. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-links.mjs +23 -0
  57. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-model-tables.mjs +24 -0
  58. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-palette.mjs +34 -0
  59. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-provenance.mjs +20 -0
  60. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-tree.mjs +16 -0
  61. package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-config.mjs +19 -0
  62. package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-export.mjs +35 -0
  63. package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-gen.mjs +39 -0
  64. package/plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs +130 -0
  65. package/plugins/solution-architect/skills/analyze-requirements/scripts/serve.mjs +71 -0
  66. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/browser.test.mjs +553 -0
  67. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/companion-links.test.mjs +60 -0
  68. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-kinds.test.mjs +41 -0
  69. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-links.test.mjs +104 -0
  70. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-routes.test.mjs +54 -0
  71. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-sections.test.mjs +197 -0
  72. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/embed.test.mjs +28 -0
  73. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/er-entities.test.mjs +14 -0
  74. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/ARCHITECTURE.md +47 -0
  75. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/c4-src/broken/model.c4 +27 -0
  76. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/c4-src/pass/model.c4 +29 -0
  77. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/adr/0001-sample.md +18 -0
  78. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/estimate.html +2 -0
  79. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/estimation.md +8 -0
  80. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/model-broken.json +1 -0
  81. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/model.json +1 -0
  82. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/threat-model.md +8 -0
  83. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/sample-model.json +1 -0
  84. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/sample.c4 +28 -0
  85. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fonts.test.mjs +38 -0
  86. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/frontmatter.test.mjs +27 -0
  87. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/inputs.test.mjs +72 -0
  88. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-config-cli.test.mjs +26 -0
  89. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-config.test.mjs +74 -0
  90. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-export-cli.test.mjs +61 -0
  91. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-extract.test.mjs +37 -0
  92. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-gen-cli.test.mjs +73 -0
  93. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-steps.test.mjs +32 -0
  94. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-flows.test.mjs +82 -0
  95. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-links.test.mjs +16 -0
  96. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-provenance.test.mjs +42 -0
  97. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-render.test.mjs +226 -0
  98. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-tables.test.mjs +30 -0
  99. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-views.test.mjs +76 -0
  100. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-wide.test.mjs +76 -0
  101. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/nav.test.mjs +236 -0
  102. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/offline.test.mjs +37 -0
  103. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/quality-gate.test.mjs +86 -0
  104. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/quality-gates.test.mjs +20 -0
  105. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/render.test.mjs +171 -0
  106. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/research-workflow.test.mjs +38 -0
  107. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/section-help.test.mjs +101 -0
  108. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/serve.test.mjs +48 -0
  109. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-clusters.test.mjs +46 -0
  110. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-deployment.test.mjs +23 -0
  111. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-elections.test.mjs +30 -0
  112. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-links.test.mjs +38 -0
  113. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-model-tables.test.mjs +51 -0
  114. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-provenance.test.mjs +28 -0
  115. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-tree.test.mjs +43 -0
  116. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/viewer-template.test.mjs +1206 -0
  117. package/plugins/solution-architect/skills/analyze-requirements/scripts/validate.mjs +88 -0
  118. package/plugins/solution-architect/skills/analyze-requirements/workflows/research.js +57 -0
  119. package/plugins/solution-architect/skills/estimate/README.md +67 -0
  120. package/plugins/solution-architect/skills/estimate/SKILL.md +64 -0
  121. package/plugins/solution-architect/skills/estimate/assets/estimate-template.html +1128 -0
  122. package/plugins/solution-architect/skills/estimate/references/ai-multipliers.md +95 -0
  123. package/plugins/solution-architect/skills/estimate/references/interview.md +80 -0
  124. package/plugins/solution-architect/skills/estimate/references/slicing.md +55 -0
  125. package/plugins/solution-architect/skills/estimate/references/techniques.md +111 -0
  126. package/plugins/solution-architect/skills/estimate/references/writing.md +211 -0
  127. package/plugins/solution-architect/skills/estimate/scripts/compute.mjs +23 -0
  128. package/plugins/solution-architect/skills/estimate/scripts/lib/checks.mjs +128 -0
  129. package/plugins/solution-architect/skills/estimate/scripts/lib/components.mjs +19 -0
  130. package/plugins/solution-architect/skills/estimate/scripts/lib/estimate-math.mjs +85 -0
  131. package/plugins/solution-architect/skills/estimate/scripts/lib/inline.mjs +10 -0
  132. package/plugins/solution-architect/skills/estimate/scripts/lib/redact.mjs +30 -0
  133. package/plugins/solution-architect/skills/estimate/scripts/lib/roadmap.mjs +32 -0
  134. package/plugins/solution-architect/skills/estimate/scripts/lib/rollup.mjs +122 -0
  135. package/plugins/solution-architect/skills/estimate/scripts/lib/schema.mjs +128 -0
  136. package/plugins/solution-architect/skills/estimate/scripts/render.mjs +65 -0
  137. package/plugins/solution-architect/skills/estimate/scripts/test/browser.test.mjs +623 -0
  138. package/plugins/solution-architect/skills/estimate/scripts/test/compute.test.mjs +88 -0
  139. package/plugins/solution-architect/skills/estimate/scripts/test/e2e.test.mjs +34 -0
  140. package/plugins/solution-architect/skills/estimate/scripts/test/estimate-math.test.mjs +112 -0
  141. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/booking-inputs.json +58 -0
  142. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-fail.md +30 -0
  143. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-pass.md +60 -0
  144. package/plugins/solution-architect/skills/estimate/scripts/test/quality-gates.test.mjs +20 -0
  145. package/plugins/solution-architect/skills/estimate/scripts/test/references.test.mjs +71 -0
  146. package/plugins/solution-architect/skills/estimate/scripts/test/render.test.mjs +121 -0
  147. package/plugins/solution-architect/skills/estimate/scripts/test/schema.test.mjs +129 -0
  148. package/plugins/solution-architect/skills/estimate/scripts/test/validate.test.mjs +72 -0
  149. package/plugins/solution-architect/skills/estimate/scripts/validate.mjs +20 -0
  150. package/plugins/solution-architect/skills/new-lead/README.md +48 -0
  151. package/plugins/solution-architect/skills/new-lead/SKILL.md +113 -0
  152. package/plugins/solution-architect/skills/new-lead/assets/dashboard/detail.html +842 -0
  153. package/plugins/solution-architect/skills/new-lead/assets/dashboard/index.html +655 -0
  154. package/plugins/solution-architect/skills/new-lead/assets/dashboard/start.sh +3 -0
  155. package/plugins/solution-architect/skills/new-lead/assets/dashboard/stats.mjs +98 -0
  156. package/plugins/solution-architect/skills/new-lead/assets/dashboard/vendor/reactflow-bundle.js +473 -0
  157. package/plugins/solution-architect/skills/new-lead/assets/vendor-build/entry.jsx +33 -0
  158. package/plugins/solution-architect/skills/new-lead/assets/vendor-build/package-lock.json +1055 -0
  159. package/plugins/solution-architect/skills/new-lead/assets/vendor-build/package.json +19 -0
  160. package/plugins/solution-architect/skills/new-lead/scripts/init-root.mjs +73 -0
  161. package/plugins/solution-architect/skills/new-lead/scripts/lead-upsert.mjs +31 -0
  162. package/plugins/solution-architect/skills/new-lead/scripts/lib/enrich.mjs +20 -0
  163. package/plugins/solution-architect/skills/new-lead/scripts/lib/map-nodes.mjs +124 -0
  164. package/plugins/solution-architect/skills/new-lead/scripts/lib/map.mjs +117 -0
  165. package/plugins/solution-architect/skills/new-lead/scripts/lib/port.mjs +15 -0
  166. package/plugins/solution-architect/skills/new-lead/scripts/lib/registry.mjs +116 -0
  167. package/plugins/solution-architect/skills/new-lead/scripts/serve.mjs +163 -0
  168. package/plugins/solution-architect/skills/new-lead/scripts/test/e2e-workspace.test.mjs +59 -0
  169. package/plugins/solution-architect/skills/new-lead/scripts/test/enrich.test.mjs +16 -0
  170. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/ARCHITECTURE.md +16 -0
  171. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/brief.md +4 -0
  172. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/index.html +11 -0
  173. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/proposal-non-tech.html +2 -0
  174. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/threat-model.html +2 -0
  175. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/estimation-inputs.json +6 -0
  176. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/estimation.json +10 -0
  177. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/notes.md +3 -0
  178. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/proposal-non-tech.md +3 -0
  179. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/rfp.md +3 -0
  180. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads.json +25 -0
  181. package/plugins/solution-architect/skills/new-lead/scripts/test/init-root.test.mjs +81 -0
  182. package/plugins/solution-architect/skills/new-lead/scripts/test/lead-upsert.test.mjs +67 -0
  183. package/plugins/solution-architect/skills/new-lead/scripts/test/map.test.mjs +72 -0
  184. package/plugins/solution-architect/skills/new-lead/scripts/test/port.test.mjs +31 -0
  185. package/plugins/solution-architect/skills/new-lead/scripts/test/registry-io.test.mjs +57 -0
  186. package/plugins/solution-architect/skills/new-lead/scripts/test/registry.test.mjs +49 -0
  187. package/plugins/solution-architect/skills/new-lead/scripts/test/serve.test.mjs +205 -0
  188. package/plugins/solution-architect/skills/new-lead/scripts/test/stats.test.mjs +92 -0
  189. package/plugins/solution-architect/skills/new-lead/scripts/test/validate-cli.test.mjs +24 -0
  190. package/plugins/solution-architect/skills/new-lead/scripts/test/vendor-bundle.test.mjs +9 -0
  191. package/plugins/solution-architect/skills/new-lead/scripts/validate.mjs +9 -0
  192. package/plugins/solution-architect/skills/proposal/README.md +36 -0
  193. package/plugins/solution-architect/skills/proposal/SKILL.md +58 -0
  194. package/plugins/solution-architect/skills/proposal/assets/proposal-template.html +82 -0
  195. package/plugins/solution-architect/skills/proposal/references/interview.md +63 -0
  196. package/plugins/solution-architect/skills/proposal/references/review.md +28 -0
  197. package/plugins/solution-architect/skills/proposal/references/writing.md +102 -0
  198. package/plugins/solution-architect/skills/proposal/scripts/derive.mjs +22 -0
  199. package/plugins/solution-architect/skills/proposal/scripts/lib/checks-client.mjs +75 -0
  200. package/plugins/solution-architect/skills/proposal/scripts/lib/checks-doc.mjs +54 -0
  201. package/plugins/solution-architect/skills/proposal/scripts/lib/checks.mjs +17 -0
  202. package/plugins/solution-architect/skills/proposal/scripts/lib/figures.mjs +43 -0
  203. package/plugins/solution-architect/skills/proposal/scripts/lib/jargon.mjs +9 -0
  204. package/plugins/solution-architect/skills/proposal/scripts/lib/sections.mjs +32 -0
  205. package/plugins/solution-architect/skills/proposal/scripts/render.mjs +60 -0
  206. package/plugins/solution-architect/skills/proposal/scripts/test/checks-client.test.mjs +144 -0
  207. package/plugins/solution-architect/skills/proposal/scripts/test/checks-doc.test.mjs +93 -0
  208. package/plugins/solution-architect/skills/proposal/scripts/test/docs.test.mjs +51 -0
  209. package/plugins/solution-architect/skills/proposal/scripts/test/e2e.test.mjs +30 -0
  210. package/plugins/solution-architect/skills/proposal/scripts/test/figures.test.mjs +81 -0
  211. package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-fail.md +22 -0
  212. package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-pass.md +55 -0
  213. package/plugins/solution-architect/skills/proposal/scripts/test/quality-gates.test.mjs +20 -0
  214. package/plugins/solution-architect/skills/proposal/scripts/test/render.test.mjs +70 -0
  215. package/plugins/solution-architect/skills/proposal/scripts/test/validate.test.mjs +40 -0
  216. package/plugins/solution-architect/skills/proposal/scripts/validate.mjs +20 -0
  217. package/src/cli/agents.mjs +12 -0
  218. package/src/cli/args.mjs +46 -0
  219. package/src/cli/install.mjs +68 -0
  220. package/src/cli/main.mjs +124 -0
  221. package/src/cli/picker.mjs +78 -0
  222. package/src/cli/registry.mjs +26 -0
  223. package/src/cli/uninstall.mjs +38 -0
@@ -0,0 +1,88 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { execFileSync } from 'node:child_process';
4
+ import { readFileSync, writeFileSync, mkdtempSync } from 'node:fs';
5
+ import { tmpdir } from 'node:os';
6
+ import { join } from 'node:path';
7
+ import { computeEstimation } from '../lib/rollup.mjs';
8
+
9
+ const fixturePath = new URL('./fixtures/booking-inputs.json', import.meta.url).pathname;
10
+ const fixture = () => JSON.parse(readFileSync(fixturePath, 'utf8'));
11
+ const cli = new URL('../compute.mjs', import.meta.url).pathname;
12
+
13
+ test('golden numbers for the booking fixture', () => {
14
+ const { computed } = computeEstimation(fixture());
15
+ // pert(16,24,40)=25.33/σ4 · pert(24,40,80)=44/σ9.33 · pert(12,20,36)=21.33/σ4
16
+ assert.equal(computed.tasks['booking-api'].e, 25.33);
17
+ assert.equal(computed.tasks['booking-rules'].e, 44);
18
+ assert.equal(computed.tasks['reminder-jobs'].e, 21.33);
19
+ assert.equal(computed.devHours, 90.67); // round2(152/6 + 44 + 128/6)
20
+ assert.equal(computed.overheadHours, 31.73); // round2(90.6667 × 0.35)
21
+ assert.equal(computed.spreadBufferHours, 10.91); // round2(√(4² + 9.3333² + 4²))
22
+ assert.equal(computed.riskBufferHours, 12); // 0.3 × 40
23
+ assert.equal(computed.projectConfidence, 'MED'); // critical path = booking, worst row MED
24
+ const rec = computed.scenarios['2eng-max5x'];
25
+ assert.ok(rec.months > 0 && rec.totalCost > 0);
26
+ assert.equal(rec.totalCost, rec.laborCost + rec.planCost);
27
+ // AI hours strictly below traditional on every task in an AI scenario
28
+ for (const id of Object.keys(computed.tasks)) {
29
+ assert.ok(rec.taskHours[id] < computed.tasks[id].e);
30
+ }
31
+ });
32
+
33
+ test('CLI writes byte-identical output on repeat runs', () => {
34
+ const dir = mkdtempSync(join(tmpdir(), 'estimate-'));
35
+ const out = join(dir, 'estimation.json');
36
+ execFileSync('node', [cli, '--inputs', fixturePath, '--out', out]);
37
+ const first = readFileSync(out, 'utf8');
38
+ execFileSync('node', [cli, '--inputs', fixturePath, '--out', out]);
39
+ assert.equal(readFileSync(out, 'utf8'), first);
40
+ assert.deepEqual(JSON.parse(first).inputs, fixture()); // inputs echoed verbatim
41
+ });
42
+
43
+ test('CLI refuses invalid inputs, naming findings', () => {
44
+ const dir = mkdtempSync(join(tmpdir(), 'estimate-'));
45
+ const badPath = join(dir, 'bad.json');
46
+ writeFileSync(badPath, JSON.stringify({ ...fixture(), recommendedScenario: 'ghost' }));
47
+ assert.throws(
48
+ () => execFileSync('node', [cli, '--inputs', badPath, '--out', join(dir, 'x.json')], { encoding: 'utf8' }),
49
+ (err) => /recommendedScenario/.test(err.stderr ?? err.stdout ?? String(err)),
50
+ );
51
+ });
52
+
53
+ test('scenarios carry a roadmap when features have milestones', () => {
54
+ const { computed } = computeEstimation(fixture());
55
+ const roadmap = computed.scenarios['2eng-max5x'].roadmap;
56
+ assert.deepEqual(roadmap.map((b) => b.milestone), ['M1 - Booking core', 'M2 - Notifications']);
57
+ assert.deepEqual(roadmap[0].features, ['booking']);
58
+ assert.deepEqual(roadmap[1].features, ['reminders']);
59
+ assert.equal(roadmap[0].startMonths, 0);
60
+ assert.equal(roadmap[1].startMonths, roadmap[0].endMonths); // bands tile, no gap
61
+ assert.equal(roadmap[1].endMonths, computed.scenarios['2eng-max5x'].months);
62
+ // AI-adjusted shares: booking (M1) carries most of the hours
63
+ assert.ok(roadmap[0].endMonths - roadmap[0].startMonths
64
+ > roadmap[1].endMonths - roadmap[1].startMonths);
65
+ });
66
+
67
+ test('computed.components rolls feature hours into top-level containers', () => {
68
+ const { computed } = computeEstimation(fixture());
69
+ // booking (api) 69.33 · reminders (notify.jobs → notify) 21.33 · admin excused, 0
70
+ assert.deepEqual(computed.components, { admin: 0, api: 69.33, notify: 21.33 });
71
+ });
72
+
73
+ test('no roster → no components key at all', () => {
74
+ const bare = fixture();
75
+ delete bare.components;
76
+ for (const f of bare.features) delete f.component;
77
+ const { computed } = computeEstimation(bare);
78
+ assert.ok(!('components' in computed), 'components key must be absent, not empty');
79
+ });
80
+
81
+ test('no milestones → no roadmap key at all', () => {
82
+ const bare = fixture();
83
+ for (const f of bare.features) delete f.milestone;
84
+ const { computed } = computeEstimation(bare);
85
+ for (const s of Object.values(computed.scenarios)) {
86
+ assert.ok(!('roadmap' in s), 'roadmap key must be absent, not empty');
87
+ }
88
+ });
@@ -0,0 +1,34 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { mkdtempSync, readFileSync } from 'node:fs';
4
+ import { execFileSync } from 'node:child_process';
5
+ import { tmpdir } from 'node:os';
6
+ import { join } from 'node:path';
7
+ import { createServer } from '../../../analyze-requirements/scripts/serve.mjs';
8
+ import { findFreePort } from '../../../analyze-requirements/scripts/lib/port.mjs';
9
+
10
+ const scripts = new URL('..', import.meta.url).pathname;
11
+ const fixture = join(scripts, 'test/fixtures/booking-inputs.json');
12
+ const passMd = join(scripts, 'test/fixtures/estimation-pass.md');
13
+
14
+ test('SKILL.md exists with hard rules and auto-trigger description', () => {
15
+ const skill = readFileSync(new URL('../../SKILL.md', import.meta.url), 'utf8');
16
+ assert.match(skill, /^name: estimate$/m);
17
+ assert.match(skill, /^description: .*(estimate|effort|quote)/m);
18
+ assert.match(skill, /never `?0`?/); // honesty rule stated
19
+ assert.match(skill, /blanket/i); // per-task multiplier rule stated
20
+ });
21
+
22
+ test('fixture flows compute → validate → render → serve', async () => {
23
+ const dir = mkdtempSync(join(tmpdir(), 'estimate-e2e-'));
24
+ const json = join(dir, 'estimation.json');
25
+ execFileSync('node', [join(scripts, 'compute.mjs'), '--inputs', fixture, '--out', json]);
26
+ execFileSync('node', [join(scripts, 'validate.mjs'), '--md', passMd, '--json', json]); // exit 0 or throws
27
+ execFileSync('node', [join(scripts, 'render.mjs'), '--json', json, '--md', passMd, '--out', dir]);
28
+ const srv = await createServer({ dir, port: await findFreePort(4173) });
29
+ try {
30
+ const res = await fetch(`http://127.0.0.1:${srv.port}/estimate.html`);
31
+ assert.equal(res.status, 200);
32
+ assert.match(await res.text(), /Booking App/);
33
+ } finally { srv.close(); }
34
+ });
@@ -0,0 +1,112 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import {
4
+ pert, projectBuffer, tierFor, aiAdjust, riskBufferHours, effectiveCapacity,
5
+ scenarioRollup, taskHours, SENIORITY_FACTOR, roadmapBands, dominantSeniority,
6
+ } from '../lib/estimate-math.mjs';
7
+
8
+ const close = (got, want) => assert.ok(Math.abs(got - want) < 1e-9, `${got} !~ ${want}`);
9
+
10
+ test('pert: E=(O+4M+P)/6, sigma=(P-O)/6', () => {
11
+ const { e, sigma } = pert({ o: 16, m: 24, p: 40 });
12
+ close(e, 152 / 6);
13
+ close(sigma, 4);
14
+ });
15
+
16
+ test('project buffer is sqrt of summed squares, not a naive sum', () => {
17
+ close(projectBuffer([4, 3]), 5);
18
+ close(projectBuffer([]), 0);
19
+ });
20
+
21
+ test('factor scores map to tiers at the documented breaks', () => {
22
+ // user's real example: 2+3+5+3+4 = 17 → M
23
+ assert.deepEqual(tierFor({ complexity: 2, size: 3, dependencies: 5, uncertainty: 3, risk: 4 }),
24
+ { total: 17, tier: 'M' });
25
+ assert.equal(tierFor({ complexity: 1, size: 1, dependencies: 2, uncertainty: 3, risk: 3 }).tier, 'S');
26
+ assert.equal(tierFor({ complexity: 5, size: 4, dependencies: 4, uncertainty: 3, risk: 2 }).tier, 'L');
27
+ });
28
+
29
+ test('aiAdjust applies (AO + 2AR + TR)/4 plus verification overhead', () => {
30
+ const e = 152 / 6; // boilerplate: red=0.65, redMax=0.8 — category only, no seniority term
31
+ const want = ((e * 0.2 + 2 * (e * 0.35) + e) / 4) * 1.12;
32
+ close(aiAdjust({ e, category: 'boilerplate', verificationPct: 0.12, scale: 1 }), want);
33
+ });
34
+
35
+ test('aiAdjust clamps reduction at 0.9 for outsized scale', () => {
36
+ const got = aiAdjust({ e: 100, category: 'boilerplate', verificationPct: 0, scale: 1.5 });
37
+ const red = 0.9; // 0.65 × 1.5 = 0.975 → clamped
38
+ close(got, (100 * (1 - red) * 3 + 100) / 4); // redMax also clamps to 0.9 so ao == ar
39
+ });
40
+
41
+ test('taskHours: seniority scales base effort on the traditional path', () => {
42
+ const base = { e: 100, plan: 'none', category: 'logic', verificationPct: 0.12 };
43
+ close(taskHours({ ...base, seniority: 'senior' }), 85);
44
+ close(taskHours({ ...base, seniority: 'mid' }), 100);
45
+ close(taskHours({ ...base, seniority: 'junior' }), 115);
46
+ });
47
+
48
+ test('taskHours: a senior is never slower than a junior, with or without AI', () => {
49
+ for (const plan of ['none', 'max5x']) {
50
+ for (const category of ['boilerplate', 'logic', 'novel']) {
51
+ const at = (seniority) => taskHours({ e: 100, seniority, plan, category, verificationPct: 0.12 });
52
+ assert.ok(at('senior') < at('mid') && at('mid') < at('junior'),
53
+ `${plan}/${category}: ${at('senior')} < ${at('mid')} < ${at('junior')} violated`);
54
+ }
55
+ }
56
+ });
57
+
58
+ test('taskHours: AI plan reduces hours versus the same seniority without AI', () => {
59
+ for (const seniority of Object.keys(SENIORITY_FACTOR)) {
60
+ const at = (plan) => taskHours({ e: 100, seniority, plan, category: 'boilerplate', verificationPct: 0.12 });
61
+ assert.ok(at('max5x') < at('none'), `${seniority}: AI ${at('max5x')} !< ${at('none')}`);
62
+ }
63
+ });
64
+
65
+ // The what-if rail's roster needs the same dominant-seniority rule the
66
+ // committed rollup uses — shipping it in the inlined math bundle is what
67
+ // keeps the page copy and the Node copy one function.
68
+ test('dominantSeniority ships with the math bundle: count wins, ties go senior', () => {
69
+ assert.equal(dominantSeniority([
70
+ { seniority: 'junior' }, { seniority: 'junior' }, { seniority: 'senior' },
71
+ ]), 'junior');
72
+ assert.equal(dominantSeniority([{ seniority: 'senior' }, { seniority: 'junior' }]), 'senior');
73
+ });
74
+
75
+ test('risk buffer is probability times impact, summed', () => {
76
+ close(riskBufferHours([{ probability: 0.3, impactHours: 40 }, { probability: 0.5, impactHours: 16 }]), 20);
77
+ });
78
+
79
+ test('capacity pays a coordination tax per added engineer, floored at one', () => {
80
+ close(effectiveCapacity(1), 1);
81
+ close(effectiveCapacity(2), 1.8);
82
+ close(effectiveCapacity(3), 2.4);
83
+ close(effectiveCapacity(12), 1); // raw formula goes negative past 10 — floor holds
84
+ });
85
+
86
+ test('scenarioRollup: 1008h, 2 mid @45, max5x → 4.0mo, $51,200', () => {
87
+ const team = [{ seniority: 'mid', rate: 45 }, { seniority: 'mid', rate: 45 }];
88
+ const got = scenarioRollup({ hours: 1008, team, plan: 'max5x' });
89
+ close(got.months, 4);
90
+ close(got.laborCost, 50400);
91
+ close(got.planCost, 800);
92
+ close(got.totalCost, 51200);
93
+ });
94
+
95
+ test('roadmapBands tiles [0, months] proportionally to hours, in order', () => {
96
+ const bands = roadmapBands({
97
+ milestones: [{ name: 'M1', hours: 60 }, { name: 'M2', hours: 40 }],
98
+ months: 5,
99
+ });
100
+ assert.deepEqual(bands.map((b) => b.name), ['M1', 'M2']);
101
+ close(bands[0].startMonths, 0);
102
+ close(bands[0].endMonths, 3);
103
+ close(bands[1].startMonths, 3); // no gap: starts where M1 ends
104
+ close(bands[1].endMonths, 5); // last band ends at total months
105
+ });
106
+
107
+ test('roadmapBands: single milestone spans the whole project', () => {
108
+ const bands = roadmapBands({ milestones: [{ name: 'All', hours: 90 }], months: 4.2 });
109
+ assert.equal(bands.length, 1);
110
+ close(bands[0].startMonths, 0);
111
+ close(bands[0].endMonths, 4.2);
112
+ });
@@ -0,0 +1,58 @@
1
+ {
2
+ "project": "Booking App",
3
+ "currency": "USD",
4
+ "technique": "three-point-pert",
5
+ "depth": "STANDARD",
6
+ "calibration": { "S": [20, 60], "M": [60, 160], "L": [160, 400] },
7
+ "overheadPct": 0.35,
8
+ "verificationPct": 0.12,
9
+ "exposeRatesToClient": false,
10
+ "components": [
11
+ { "id": "api", "name": "Booking API" },
12
+ { "id": "notify", "name": "Notification Service" },
13
+ { "id": "notify.jobs", "name": "Reminder Jobs", "parent": "notify" },
14
+ { "id": "admin", "name": "Admin Console", "notEstimated": "out of v1 scope" }
15
+ ],
16
+ "features": [
17
+ {
18
+ "id": "booking",
19
+ "name": "User can book appointment",
20
+ "provenance": "stated",
21
+ "component": "api",
22
+ "milestone": "M1 - Booking core",
23
+ "tasks": [
24
+ { "id": "booking-api", "name": "Booking CRUD API", "category": "boilerplate",
25
+ "o": 16, "m": 24, "p": 40, "confidence": "HIGH",
26
+ "assumptions": ["single timezone"], "provenance": "stated" },
27
+ { "id": "booking-rules", "name": "Slot conflict + cancellation rules", "category": "logic",
28
+ "o": 24, "m": 40, "p": 80, "confidence": "MED",
29
+ "assumptions": ["no recurring bookings in v1"], "provenance": "proposed" }
30
+ ]
31
+ },
32
+ {
33
+ "id": "reminders",
34
+ "name": "Email reminders",
35
+ "provenance": "proposed",
36
+ "component": "notify.jobs",
37
+ "milestone": "M2 - Notifications",
38
+ "tasks": [
39
+ { "id": "reminder-jobs", "name": "Scheduled reminder jobs", "category": "logic",
40
+ "o": 12, "m": 20, "p": 36, "confidence": "MED",
41
+ "assumptions": ["transactional email provider already chosen"], "provenance": "proposed" }
42
+ ]
43
+ }
44
+ ],
45
+ "risks": [
46
+ { "name": "payment gateway sandbox delays", "probability": 0.3, "impactHours": 40 }
47
+ ],
48
+ "assumptions": [
49
+ { "text": "single timezone", "impactIfWrong": "recompute booking-api at logic category, +30%" }
50
+ ],
51
+ "scenarios": [
52
+ { "id": "3eng-noai", "plan": "none",
53
+ "team": [{ "seniority": "mid", "rate": 45 }, { "seniority": "mid", "rate": 45 }, { "seniority": "junior", "rate": 30 }] },
54
+ { "id": "2eng-max5x", "plan": "max5x",
55
+ "team": [{ "seniority": "senior", "rate": 60 }, { "seniority": "mid", "rate": 45 }] }
56
+ ],
57
+ "recommendedScenario": "2eng-max5x"
58
+ }
@@ -0,0 +1,30 @@
1
+ # Booking App — Estimation
2
+
3
+ ## Summary
4
+
5
+ | Feature | Tier | Range (h) | src |
6
+ | --- | --- | --- | --- |
7
+ | User can book appointment | M | 40–120 | stated |
8
+ | Email reminders | S | 12–36 | proposed |
9
+
10
+ Recommended delivery: 2 engineers (1 senior, 1 mid) + Claude Code Max 5x — see detail.
11
+
12
+ ### Assumptions
13
+
14
+ | Assumption | Impact if wrong |
15
+ | --- | --- |
16
+
17
+ ## Estimation detail
18
+
19
+ Technique: three-point PERT — detailed backlog available.
20
+
21
+ | Task | Category | O/M/P | E (h) | Confidence | Assumptions | src |
22
+ | --- | --- | --- | --- | --- | --- | --- |
23
+ | Booking CRUD API | boilerplate | 16/24/40 | 0 | HIGH | single timezone | stated |
24
+ | Slot conflict + cancellation rules | logic | 24/40/80 | 44 | MED | no recurring bookings in v1 |
25
+ | Scheduled reminder jobs | logic | 12/20/36 | 21.33 | MED | | proposed |
26
+
27
+ ### Calibration
28
+
29
+ Tier hour bands used: S 20-60h · M 60-160h · L 160-400h (defaults — no
30
+ delivery history supplied).
@@ -0,0 +1,60 @@
1
+ # Booking App — Estimation
2
+
3
+ ## Summary
4
+
5
+ | Feature | Tier | Range (h) | src |
6
+ | --- | --- | --- | --- |
7
+ | User can book appointment | M | 40–120 | stated |
8
+ | Email reminders | S | 12–36 | proposed |
9
+
10
+ Recommended delivery: 2 engineers (1 senior, 1 mid) + Claude Code Max 5x — see detail.
11
+
12
+ | Line | Hours |
13
+ | --- | --- |
14
+ | Development | 90.67 |
15
+ | Overhead (35%) | 31.73 |
16
+ | Risk buffer | 12 |
17
+ | Estimate-spread buffer | 10.91 |
18
+
19
+ ### Roadmap
20
+
21
+ | Milestone | Features | Months (from start) |
22
+ | --- | --- | --- |
23
+ | M1 - Booking core | User can book appointment | 0–0.3 |
24
+ | M2 - Notifications | Email reminders | 0.3–0.4 |
25
+
26
+ Sequential delivery by the recommended scenario team. Bands are relative
27
+ months, not calendar dates. Ordering: proposed.
28
+
29
+ ### Assumptions
30
+
31
+ | Assumption | Impact if wrong |
32
+ | --- | --- |
33
+ | single timezone | recompute booking-api at logic category, +30% |
34
+
35
+ ### Out of scope
36
+
37
+ - Recurring bookings
38
+ - SMS reminders
39
+
40
+ ## Estimation detail
41
+
42
+ Technique: three-point PERT — detailed backlog available.
43
+
44
+ | Task | Category | O/M/P | E (h) | Confidence | Assumptions | src |
45
+ | --- | --- | --- | --- | --- | --- | --- |
46
+ | Booking CRUD API | boilerplate | 16/24/40 | 25.33 | HIGH | single timezone | stated |
47
+ | Slot conflict + cancellation rules | logic | 24/40/80 | 44 | MED | no recurring bookings in v1 | proposed |
48
+ | Scheduled reminder jobs | logic | 12/20/36 | 21.33 | MED | provider already chosen | proposed |
49
+
50
+ ### Scenario comparison
51
+
52
+ | Scenario | Team | Plan | Months | Cost | Notes |
53
+ | --- | --- | --- | --- | --- | --- |
54
+ | 3eng-noai | 2 mid + 1 junior | none | 0.43 | $7,266 | — |
55
+ | 2eng-max5x | 1 senior + 1 mid | Max 5x | 0.40 | $5,993 | recommended |
56
+
57
+ ### Calibration
58
+
59
+ Tier hour bands used: S 20-60h · M 60-160h · L 160-400h (defaults — no
60
+ delivery history supplied).
@@ -0,0 +1,20 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { readFileSync } from 'node:fs';
4
+ import {
5
+ TEMPLATE_LIMITS, moduleFiles, templateScripts, violations,
6
+ } from '../../../analyze-requirements/scripts/lib/quality-gate.mjs';
7
+
8
+ const base = new URL('../..', import.meta.url).pathname;
9
+
10
+ for (const file of moduleFiles(base, ['scripts/lib', 'scripts'])) {
11
+ test(`gates: ${file.replace(base, '')}`, () => {
12
+ assert.deepEqual(violations(readFileSync(file, 'utf8')), []);
13
+ });
14
+ }
15
+
16
+ for (const { file, js } of templateScripts(base)) {
17
+ test(`gates: ${file.replace(base, '')}`, () => {
18
+ assert.deepEqual(violations(js, TEMPLATE_LIMITS), []);
19
+ });
20
+ }
@@ -0,0 +1,71 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { readFileSync } from 'node:fs';
4
+ import { AI_CATEGORIES, PLAN_PRICES, TIER_BREAKS } from '../lib/estimate-math.mjs';
5
+
6
+ const ref = (f) => readFileSync(new URL(`../../references/${f}`, import.meta.url), 'utf8');
7
+ const ALL = ['interview.md', 'techniques.md', 'ai-multipliers.md', 'writing.md', 'slicing.md'];
8
+
9
+ test('no reference doc carries placeholders', () => {
10
+ for (const f of ALL) assert.doesNotMatch(ref(f), /\bTBD\b|\bTODO\b/, f);
11
+ });
12
+
13
+ test('interview.md carries its five required parts', () => {
14
+ const doc = ref('interview.md');
15
+ for (const needle of ['stated', 'proposed', 'QUICK', 'STANDARD', 'DEEP',
16
+ 'confirmed scope', 'impact-if-wrong', 'calibration', 'milestone']) {
17
+ assert.ok(doc.includes(needle), `interview.md missing: ${needle}`);
18
+ }
19
+ });
20
+
21
+ test('techniques.md names every technique and the real tier breaks', () => {
22
+ const doc = ref('techniques.md');
23
+ for (const needle of ['factor-scored tiering', 'three-point PERT', 'analogy']) {
24
+ assert.ok(doc.includes(needle), `techniques.md missing: ${needle}`);
25
+ }
26
+ assert.ok(doc.includes('11-17 M') || doc.includes('11–17 M'), 'tier breaks must match TIER_BREAKS');
27
+ assert.equal(TIER_BREAKS[1].max, 17); // the doc claim above is only honest while this holds
28
+ });
29
+
30
+ test('ai-multipliers.md agrees with the code constants', () => {
31
+ const doc = ref('ai-multipliers.md');
32
+ for (const category of Object.keys(AI_CATEGORIES)) {
33
+ assert.ok(doc.includes(category), `ai-multipliers.md missing category: ${category}`);
34
+ }
35
+ for (const [plan, price] of Object.entries(PLAN_PRICES)) {
36
+ if (plan !== 'none') assert.ok(doc.includes(String(price)), `pricing table missing ${plan}=${price}`);
37
+ }
38
+ assert.match(doc, /blanket/i, 'the blanket-multiplier prohibition must be stated');
39
+ });
40
+
41
+ test('writing.md states every validator rule family', () => {
42
+ const doc = ref('writing.md');
43
+ for (const needle of ['not estimated', 'stated', 'proposed', 'Out of scope',
44
+ 'assumptions', 'buffer', 'elected', 'docs/estimate/', 'Roadmap', 'not calendar dates',
45
+ 'components', 'scope hole']) {
46
+ assert.ok(doc.includes(needle), `writing.md missing: ${needle}`);
47
+ }
48
+ });
49
+
50
+ test('slicing.md carries the vertical-slice rules and split patterns', () => {
51
+ const doc = ref('slicing.md');
52
+ for (const needle of ['Walking skeleton', 'user-visible', 'Workflow steps', 'Spike',
53
+ 'two levels', 'humanizingwork.com', 'addyosmani']) {
54
+ assert.ok(doc.includes(needle), `slicing.md missing: ${needle}`);
55
+ }
56
+ assert.ok(/## Sources/.test(doc), 'slicing.md missing Sources section');
57
+ });
58
+
59
+ test('method sources are cited where techniques are recommended', () => {
60
+ const SOURCES = {
61
+ 'techniques.md': ['atomicobject.com', 'kmino.io', 'Modular-Earth'],
62
+ 'ai-multipliers.md': ['kmino.io'],
63
+ };
64
+ for (const [f, needles] of Object.entries(SOURCES)) {
65
+ const doc = ref(f);
66
+ assert.ok(/## Sources/.test(doc), `${f} missing Sources section`);
67
+ for (const needle of needles) {
68
+ assert.ok(doc.includes(needle), `${f} missing source: ${needle}`);
69
+ }
70
+ }
71
+ });
@@ -0,0 +1,121 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { readFileSync, writeFileSync, mkdtempSync } from 'node:fs';
4
+ import { execFileSync } from 'node:child_process';
5
+ import { tmpdir } from 'node:os';
6
+ import { join } from 'node:path';
7
+ import { inlineModule, stripInternal } from '../lib/inline.mjs';
8
+
9
+ const tpl = () => readFileSync(new URL('../../assets/estimate-template.html', import.meta.url), 'utf8');
10
+ const cli = new URL('../render.mjs', import.meta.url).pathname;
11
+ const fixture = new URL('./fixtures/booking-inputs.json', import.meta.url).pathname;
12
+ const passMd = new URL('./fixtures/estimation-pass.md', import.meta.url).pathname;
13
+ const computeCli = new URL('../compute.mjs', import.meta.url).pathname;
14
+
15
+ function renderedPage(extra = []) {
16
+ const dir = mkdtempSync(join(tmpdir(), 'estimate-render-'));
17
+ const json = join(dir, 'estimation.json');
18
+ execFileSync('node', [computeCli, '--inputs', fixture, '--out', json]);
19
+ execFileSync('node', [cli, '--json', json, '--md', passMd, '--out', dir, ...extra]);
20
+ return readFileSync(join(dir, 'estimate.html'), 'utf8');
21
+ }
22
+
23
+ test('render refuses a deliverable that fails validation', () => {
24
+ const failMd = new URL('./fixtures/estimation-fail.md', import.meta.url).pathname;
25
+ const dir = mkdtempSync(join(tmpdir(), 'estimate-render-'));
26
+ const json = join(dir, 'estimation.json');
27
+ execFileSync('node', [computeCli, '--inputs', fixture, '--out', json]);
28
+ assert.throws(() => execFileSync('node', [cli, '--json', json, '--md', failMd, '--out', dir]));
29
+ });
30
+
31
+ test('template carries exactly the five slots and no external URLs', () => {
32
+ const markers = [...tpl().matchAll(/<!-- slot:(\w+) -->/g)].map((m) => m[1]).sort();
33
+ assert.deepEqual([...new Set(markers)], ['DATA', 'FONTS', 'MATH', 'TITLE', 'VIEWER']);
34
+ assert.doesNotMatch(tpl(), /https?:\/\/(?!www\.w3\.org)/);
35
+ });
36
+
37
+ // Companion mode: the analyze-requirements viewer links this page, and this page links
38
+ // back. The href is caller-supplied because only the caller knows where the
39
+ // viewer was rendered; internal-only because a client file must not point at
40
+ // an internal document set.
41
+ test('--viewer adds an internal-only back-link; client-only strips it', () => {
42
+ const withLink = renderedPage(['--viewer', '../viewer/index.html']);
43
+ assert.match(withLink, /<a id="viewer-link" data-internal href="\.\.\/viewer\/index\.html">/);
44
+ const without = renderedPage();
45
+ assert.doesNotMatch(without, /<a id="viewer-link"/);
46
+ const client = renderedPage(['--viewer', '../viewer/index.html', '--client-only']);
47
+ assert.doesNotMatch(client, /<a id="viewer-link"/);
48
+ });
49
+
50
+ test('the --viewer href is attribute-escaped', () => {
51
+ const html = renderedPage(['--viewer', '../a"b/index.html']);
52
+ assert.match(html, /href="\.\.\/a&quot;b\/index\.html"/);
53
+ });
54
+
55
+ test('inlineModule strips export keywords and nothing else', () => {
56
+ assert.equal(inlineModule('export function f() {}\nexport const X = 1;\nconst y = 2;'),
57
+ 'function f() {}\nconst X = 1;\nconst y = 2;');
58
+ });
59
+
60
+ test('rendered page is self-contained and carries parseable data', () => {
61
+ const html = renderedPage();
62
+ assert.doesNotMatch(html, /<!-- slot:/);
63
+ assert.match(html, /@font-face/);
64
+ const data = html.match(/<script type="application\/json" id="estimation-data">([\s\S]*?)<\/script>/)[1];
65
+ assert.equal(JSON.parse(data).inputs.project, 'Booking App');
66
+ assert.match(html, /function pert\(/); // math inlined, not referenced
67
+ });
68
+
69
+ test('the page carries a method section with source attributions', () => {
70
+ const html = renderedPage();
71
+ assert.match(html, /id="method"/);
72
+ assert.match(html, /atomicobject\.com/); // sources cited in the page, not only in refs
73
+ assert.match(html, /kmino\.io/);
74
+ });
75
+
76
+ test('the method section comes first — how before how-much', () => {
77
+ assert.match(tpl(), /<main>\s*<div class="col col-wide">\s*<section id="method">/);
78
+ });
79
+
80
+ test('--client-only strips every internal range', () => {
81
+ const html = renderedPage(['--client-only']);
82
+ assert.doesNotMatch(html, /data-internal|internal:start|ctl-team/);
83
+ assert.match(stripInternal('a<!-- internal:start -->X<!-- internal:end -->b'), /^ab$/);
84
+ });
85
+
86
+ test('--client-only redacts rates and cost breakdown unless exposeRatesToClient is set', () => {
87
+ // Matched as quoted JSON keys, not bare identifiers: estimate-math.mjs is
88
+ // inlined verbatim for the what-if engine and legitimately declares
89
+ // `laborCost`/`planCost` as plain JS locals in every render, client or not.
90
+ const html = renderedPage(['--client-only']);
91
+ assert.doesNotMatch(html, /"rate":/);
92
+ assert.doesNotMatch(html, /"laborCost":/);
93
+ assert.doesNotMatch(html, /"planCost":/);
94
+ });
95
+
96
+ test('--client-only keeps rates when exposeRatesToClient is true', () => {
97
+ const dir = mkdtempSync(join(tmpdir(), 'estimate-render-'));
98
+ const inputs = JSON.parse(readFileSync(fixture, 'utf8'));
99
+ inputs.exposeRatesToClient = true;
100
+ const inputsPath = join(dir, 'inputs.json');
101
+ writeFileSync(inputsPath, JSON.stringify(inputs));
102
+ const json = join(dir, 'estimation.json');
103
+ execFileSync('node', [computeCli, '--inputs', inputsPath, '--out', json]);
104
+ execFileSync('node', [cli, '--json', json, '--md', passMd, '--out', dir, '--client-only']);
105
+ const html = readFileSync(join(dir, 'estimate.html'), 'utf8');
106
+ assert.match(html, /"rate":/);
107
+ });
108
+
109
+ test('component data survives the client-only render', () => {
110
+ // deliberate: names come from the architecture doc the client already sees;
111
+ // costs stay redacted — the rollup shows hours/share only
112
+ const client = renderedPage(['--client-only']);
113
+ assert.match(client, /"components":/);
114
+ assert.match(client, /"component":"api"/);
115
+ });
116
+
117
+ test('the rendered page carries the roadmap section markup', () => {
118
+ const html = renderedPage();
119
+ assert.match(html, /id="roadmap"/);
120
+ assert.match(html, /roadmapRow|roadmap-row/); // renderer present, not stripped
121
+ });