@v11g/agents-rock 1.0.7 → 1.0.9

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 (215) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/plugins/reasoning/.claude-plugin/plugin.json +1 -1
  4. package/plugins/reasoning/evals/format-handoff-folder/graders/folder-named.md +8 -0
  5. package/plugins/reasoning/evals/format-handoff-folder/graders/skill-fired.md +7 -0
  6. package/plugins/reasoning/evals/format-handoff-folder/prompt.md +9 -0
  7. package/plugins/reasoning/evals/format-ids-and-supports/graders/ids-in-chat.md +8 -0
  8. package/plugins/reasoning/evals/format-ids-and-supports/graders/skill-fired.md +7 -0
  9. package/plugins/reasoning/evals/format-ids-and-supports/graders/supports-resolve.md +11 -0
  10. package/plugins/reasoning/evals/format-ids-and-supports/prompt.md +8 -0
  11. package/plugins/reasoning/evals/format-root-candidate-status/graders/candidate-status.md +11 -0
  12. package/plugins/reasoning/evals/format-root-candidate-status/graders/skill-fired.md +7 -0
  13. package/plugins/reasoning/evals/format-root-candidate-status/prompt.md +8 -0
  14. package/plugins/reasoning/evals/format-unsaved-continues/graders/analysis-completes.md +9 -0
  15. package/plugins/reasoning/evals/format-unsaved-continues/graders/not-saved-stated.md +9 -0
  16. package/plugins/reasoning/evals/format-unsaved-continues/graders/skill-fired.md +7 -0
  17. package/plugins/reasoning/evals/format-unsaved-continues/prompt.md +8 -0
  18. package/plugins/reasoning/evals/guardrail-unavailable-framework/graders/names-closest-available.md +5 -6
  19. package/plugins/reasoning/evals/guardrail-unavailable-framework/graders/no-improvised-levels.md +4 -6
  20. package/plugins/reasoning/evals/guardrail-unavailable-framework/graders/skill-fired.md +1 -1
  21. package/plugins/reasoning/evals/guardrail-unavailable-framework/graders/states-unavailable.md +4 -5
  22. package/plugins/reasoning/evals/guardrail-unavailable-framework/graders/systemic-design-fired.md +10 -0
  23. package/plugins/reasoning/evals/guardrail-unavailable-framework/prompt.md +2 -2
  24. package/plugins/reasoning/evals/ps-interview-first-question/graders/look-in-present.md +10 -0
  25. package/plugins/reasoning/evals/ps-interview-first-question/graders/no-fixed-exits.md +11 -0
  26. package/plugins/reasoning/evals/ps-interview-first-question/graders/options-from-input.md +15 -0
  27. package/plugins/reasoning/evals/ps-interview-first-question/graders/skill-fired.md +7 -0
  28. package/plugins/reasoning/evals/ps-interview-first-question/graders/source-hint.md +11 -0
  29. package/plugins/reasoning/evals/ps-interview-first-question/graders/targets-gap.md +13 -0
  30. package/plugins/reasoning/evals/ps-interview-first-question/prompt.md +8 -0
  31. package/plugins/reasoning/evals/ps-interview-five-whys/graders/look-in-present.md +10 -0
  32. package/plugins/reasoning/evals/ps-interview-five-whys/graders/no-fixed-exits.md +11 -0
  33. package/plugins/reasoning/evals/ps-interview-five-whys/graders/options-from-input.md +11 -0
  34. package/plugins/reasoning/evals/ps-interview-five-whys/graders/skill-fired.md +7 -0
  35. package/plugins/reasoning/evals/ps-interview-five-whys/graders/source-hint.md +11 -0
  36. package/plugins/reasoning/evals/ps-interview-five-whys/graders/targets-gap.md +15 -0
  37. package/plugins/reasoning/evals/ps-interview-five-whys/prompt.md +8 -0
  38. package/plugins/reasoning/evals/ps-router-handoff/graders/no-reselection.md +11 -0
  39. package/plugins/reasoning/evals/ps-router-handoff/graders/runs-rca.md +8 -0
  40. package/plugins/reasoning/evals/ps-router-handoff/graders/skill-fired.md +7 -0
  41. package/plugins/reasoning/evals/ps-router-handoff/prompt.md +11 -0
  42. package/plugins/reasoning/evals/routing-adaptive-discriminator/graders/confidence-single-word.md +10 -0
  43. package/plugins/reasoning/evals/routing-ambiguous-feature-request/graders/confidence-single-word.md +10 -0
  44. package/plugins/reasoning/evals/routing-classify-only/graders/confidence-single-word.md +10 -0
  45. package/plugins/reasoning/evals/routing-complex-adaptive-org-change/graders/confidence-single-word.md +10 -0
  46. package/plugins/reasoning/evals/routing-complex-adaptive-org-change/graders/no-unavailability-claim.md +10 -0
  47. package/plugins/reasoning/evals/routing-complex-delivery-slowdown/graders/confidence-single-word.md +10 -0
  48. package/plugins/reasoning/evals/routing-simple-null-pointer/graders/confidence-single-word.md +10 -0
  49. package/plugins/reasoning/evals/routing-thin-input-provisional/graders/confidence-single-word.md +10 -0
  50. package/plugins/reasoning/evals/sd-default-selection/graders/dates-traced.md +15 -0
  51. package/plugins/reasoning/evals/sd-default-selection/graders/interventions-cite-entries.md +12 -0
  52. package/plugins/reasoning/evals/sd-default-selection/graders/owners-from-input.md +8 -0
  53. package/plugins/reasoning/evals/sd-default-selection/graders/plan-steps-complete.md +21 -0
  54. package/plugins/reasoning/evals/sd-default-selection/graders/selects-systemic-design.md +12 -0
  55. package/plugins/reasoning/evals/sd-default-selection/graders/skill-fired.md +7 -0
  56. package/plugins/reasoning/evals/sd-default-selection/graders/systemic-design-fired.md +10 -0
  57. package/plugins/reasoning/evals/sd-default-selection/prompt.md +11 -0
  58. package/plugins/reasoning/evals/sd-named-framework-software/graders/names-no-skill.md +11 -0
  59. package/plugins/reasoning/evals/sd-named-framework-software/graders/no-systemic-block.md +10 -0
  60. package/plugins/reasoning/evals/sd-named-framework-software/graders/systemic-design-fired.md +10 -0
  61. package/plugins/reasoning/evals/sd-named-framework-software/prompt.md +8 -0
  62. package/plugins/reasoning/evals/sd-not-software/graders/no-systemic-block.md +10 -0
  63. package/plugins/reasoning/evals/sd-not-software/graders/says-out-of-scope.md +10 -0
  64. package/plugins/reasoning/evals/sd-not-software/prompt.md +8 -0
  65. package/plugins/reasoning/evals/sd-raw-input/graders/first-question-targets-model.md +11 -0
  66. package/plugins/reasoning/evals/sd-raw-input/graders/look-in-present.md +10 -0
  67. package/plugins/reasoning/evals/sd-raw-input/graders/model-gap-blocks-stop.md +14 -0
  68. package/plugins/reasoning/evals/sd-raw-input/graders/model-in-assumptions.md +13 -0
  69. package/plugins/reasoning/evals/sd-raw-input/graders/no-fixed-exits.md +11 -0
  70. package/plugins/reasoning/evals/sd-raw-input/graders/skill-fired.md +7 -0
  71. package/plugins/reasoning/evals/sd-raw-input/graders/systemic-design-fired.md +10 -0
  72. package/plugins/reasoning/evals/sd-raw-input/prompt.md +8 -0
  73. package/plugins/reasoning/evals/sd-theory-of-change/graders/links-carry-assumptions.md +9 -0
  74. package/plugins/reasoning/evals/sd-theory-of-change/graders/no-dates.md +8 -0
  75. package/plugins/reasoning/evals/sd-theory-of-change/graders/skill-fired.md +7 -0
  76. package/plugins/reasoning/evals/sd-theory-of-change/graders/systemic-design-fired.md +10 -0
  77. package/plugins/reasoning/evals/sd-theory-of-change/graders/toc-block.md +10 -0
  78. package/plugins/reasoning/evals/sd-theory-of-change/prompt.md +8 -0
  79. package/plugins/reasoning/evals/sd-three-horizons/graders/dates-are-assumptions.md +11 -0
  80. package/plugins/reasoning/evals/sd-three-horizons/graders/owners-are-roles.md +8 -0
  81. package/plugins/reasoning/evals/sd-three-horizons/graders/skill-fired.md +7 -0
  82. package/plugins/reasoning/evals/sd-three-horizons/graders/systemic-design-fired.md +10 -0
  83. package/plugins/reasoning/evals/sd-three-horizons/graders/three-horizons-block.md +10 -0
  84. package/plugins/reasoning/evals/sd-three-horizons/prompt.md +9 -0
  85. package/plugins/reasoning/evals/st-causal-loop-unclosed/graders/edges-carry-support-labels.md +2 -2
  86. package/plugins/reasoning/evals/st-causal-loop-unclosed/graders/no-invented-delays.md +7 -4
  87. package/plugins/reasoning/evals/st-interview-first-question/graders/look-in-present.md +10 -0
  88. package/plugins/reasoning/evals/st-interview-first-question/graders/no-fixed-exits.md +11 -0
  89. package/plugins/reasoning/evals/st-interview-first-question/graders/options-from-input.md +11 -0
  90. package/plugins/reasoning/evals/st-interview-first-question/graders/skill-fired.md +7 -0
  91. package/plugins/reasoning/evals/st-interview-first-question/graders/source-hint.md +11 -0
  92. package/plugins/reasoning/evals/st-interview-first-question/graders/targets-gap.md +13 -0
  93. package/plugins/reasoning/evals/st-interview-first-question/prompt.md +8 -0
  94. package/plugins/reasoning/evals/st-selection-boundary/graders/one-block-only.md +9 -6
  95. package/plugins/reasoning/skills/problem-router/README.md +6 -0
  96. package/plugins/reasoning/skills/problem-router/SKILL.md +11 -11
  97. package/plugins/reasoning/skills/problem-router/references/contract.md +117 -16
  98. package/plugins/reasoning/skills/problem-solving/README.md +10 -0
  99. package/plugins/reasoning/skills/problem-solving/SKILL.md +15 -3
  100. package/plugins/reasoning/skills/problem-solving/references/contract.md +117 -16
  101. package/plugins/reasoning/skills/problem-solving/references/interview.md +68 -0
  102. package/plugins/reasoning/skills/systemic-design/README.md +45 -0
  103. package/plugins/reasoning/skills/systemic-design/SKILL.md +184 -0
  104. package/plugins/reasoning/skills/systemic-design/frameworks/systemic-design.md +39 -0
  105. package/plugins/reasoning/skills/systemic-design/frameworks/theory-of-change.md +34 -0
  106. package/plugins/reasoning/skills/systemic-design/frameworks/three-horizons.md +28 -0
  107. package/plugins/reasoning/skills/systemic-design/references/contract.md +205 -0
  108. package/plugins/reasoning/skills/systemic-design/references/interview.md +68 -0
  109. package/plugins/reasoning/skills/systems-thinking/README.md +13 -6
  110. package/plugins/reasoning/skills/systems-thinking/SKILL.md +18 -6
  111. package/plugins/reasoning/skills/systems-thinking/frameworks/causal-loop.md +5 -2
  112. package/plugins/reasoning/skills/systems-thinking/frameworks/leverage-points.md +16 -7
  113. package/plugins/reasoning/skills/systems-thinking/frameworks/system-map.md +4 -5
  114. package/plugins/reasoning/skills/systems-thinking/references/contract.md +117 -16
  115. package/plugins/reasoning/skills/systems-thinking/references/interview.md +68 -0
  116. package/plugins/solution-architect/.claude-plugin/plugin.json +1 -1
  117. package/plugins/solution-architect/skills/analyze-requirements/SKILL.md +3 -2
  118. package/plugins/solution-architect/skills/analyze-requirements/references/rewriting.md +108 -0
  119. package/plugins/solution-architect/skills/analyze-requirements/scripts/drift.mjs +64 -0
  120. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/cdp.mjs +4 -1
  121. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/drift.mjs +31 -0
  122. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/git-diff.mjs +27 -0
  123. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/quality-gate.mjs +16 -1
  124. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/state.mjs +52 -0
  125. package/plugins/solution-architect/skills/analyze-requirements/scripts/record.mjs +87 -0
  126. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/drift-cli.test.mjs +178 -0
  127. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/drift.test.mjs +76 -0
  128. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/git-diff.test.mjs +62 -0
  129. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/quality-gate.test.mjs +9 -0
  130. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/record-cli.test.mjs +136 -0
  131. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/rerun-safety.test.mjs +53 -0
  132. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/rewriting.test.mjs +80 -0
  133. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/state.test.mjs +123 -0
  134. package/plugins/solution-architect/skills/estimate/README.md +20 -15
  135. package/plugins/solution-architect/skills/estimate/SKILL.md +10 -6
  136. package/plugins/solution-architect/skills/estimate/assets/estimate-template-agentic.html +111 -138
  137. package/plugins/solution-architect/skills/estimate/assets/estimate-template.html +361 -247
  138. package/plugins/solution-architect/skills/estimate/assets/scores-review-template.html +5 -4
  139. package/plugins/solution-architect/skills/estimate/evals/evals.json +7 -7
  140. package/plugins/solution-architect/skills/estimate/references/agentic-estimation.md +4 -2
  141. package/plugins/solution-architect/skills/estimate/references/ai-multipliers.md +38 -82
  142. package/plugins/solution-architect/skills/estimate/references/interview.md +56 -35
  143. package/plugins/solution-architect/skills/estimate/references/scoring-guide.md +40 -4
  144. package/plugins/solution-architect/skills/estimate/references/techniques.md +29 -21
  145. package/plugins/solution-architect/skills/estimate/references/writing.md +75 -43
  146. package/plugins/solution-architect/skills/estimate/scripts/lib/checks.mjs +37 -5
  147. package/plugins/solution-architect/skills/estimate/scripts/lib/context-schema.mjs +35 -0
  148. package/plugins/solution-architect/skills/estimate/scripts/lib/estimate-math.mjs +17 -75
  149. package/plugins/solution-architect/skills/estimate/scripts/lib/inline.mjs +5 -5
  150. package/plugins/solution-architect/skills/estimate/scripts/lib/pricing.mjs +78 -0
  151. package/plugins/solution-architect/skills/estimate/scripts/lib/project-price.mjs +96 -0
  152. package/plugins/solution-architect/skills/estimate/scripts/lib/redact.mjs +67 -19
  153. package/plugins/solution-architect/skills/estimate/scripts/lib/roadmap.mjs +4 -5
  154. package/plugins/solution-architect/skills/estimate/scripts/lib/rollup.mjs +48 -73
  155. package/plugins/solution-architect/skills/estimate/scripts/lib/schema.mjs +28 -13
  156. package/plugins/solution-architect/skills/estimate/scripts/lib/score-csv.mjs +2 -2
  157. package/plugins/solution-architect/skills/estimate/scripts/lib/score-html.mjs +1 -1
  158. package/plugins/solution-architect/skills/estimate/scripts/lib/scoring.mjs +2 -2
  159. package/plugins/solution-architect/skills/estimate/scripts/render.mjs +1 -1
  160. package/plugins/solution-architect/skills/estimate/scripts/score-review.mjs +1 -1
  161. package/plugins/solution-architect/skills/estimate/scripts/test/browser-agentic.test.mjs +143 -0
  162. package/plugins/solution-architect/skills/estimate/scripts/test/browser.test.mjs +209 -50
  163. package/plugins/solution-architect/skills/estimate/scripts/test/compute.test.mjs +57 -32
  164. package/plugins/solution-architect/skills/estimate/scripts/test/e2e.test.mjs +52 -0
  165. package/plugins/solution-architect/skills/estimate/scripts/test/estimate-math.test.mjs +25 -112
  166. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/agentic-estimation-fail.md +0 -10
  167. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/agentic-estimation-pass.md +0 -10
  168. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/agentic-inputs.json +1 -7
  169. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/booking-inputs.json +11 -10
  170. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-fail.md +6 -0
  171. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-pass.md +17 -21
  172. package/plugins/solution-architect/skills/estimate/scripts/test/pricing.test.mjs +88 -0
  173. package/plugins/solution-architect/skills/estimate/scripts/test/project-price.test.mjs +93 -0
  174. package/plugins/solution-architect/skills/estimate/scripts/test/references.test.mjs +86 -24
  175. package/plugins/solution-architect/skills/estimate/scripts/test/render.test.mjs +185 -31
  176. package/plugins/solution-architect/skills/estimate/scripts/test/schema.test.mjs +114 -61
  177. package/plugins/solution-architect/skills/estimate/scripts/test/score-review.test.mjs +34 -1
  178. package/plugins/solution-architect/skills/estimate/scripts/test/validate.test.mjs +103 -9
  179. package/plugins/solution-architect/skills/estimate/scripts/test/xlsx-export.test.mjs +292 -71
  180. package/plugins/solution-architect/skills/new-lead/SKILL.md +4 -3
  181. package/plugins/solution-architect/skills/proposal/README.md +9 -7
  182. package/plugins/solution-architect/skills/proposal/SKILL.md +10 -7
  183. package/plugins/solution-architect/skills/proposal/evals/evals.json +29 -11
  184. package/plugins/solution-architect/skills/proposal/evals/fixtures/gate-check-unpriced-harborline/ARCHITECTURE.md +65 -0
  185. package/plugins/solution-architect/skills/proposal/evals/fixtures/gate-check-unpriced-harborline/brief.md +21 -0
  186. package/plugins/solution-architect/skills/proposal/evals/fixtures/gate-check-unpriced-harborline/estimation-inputs.json +126 -0
  187. package/plugins/solution-architect/skills/proposal/evals/fixtures/gate-check-unpriced-harborline/estimation.json +215 -0
  188. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-harborline-dispatch/estimation-inputs.json +224 -34
  189. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-harborline-dispatch/estimation.json +103 -114
  190. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-harborline-dispatch/estimation.md +48 -22
  191. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-meridian-dental/estimation-inputs.json +211 -33
  192. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-meridian-dental/estimation.json +102 -117
  193. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-meridian-dental/estimation.md +48 -25
  194. package/plugins/solution-architect/skills/proposal/references/interview.md +3 -6
  195. package/plugins/solution-architect/skills/proposal/references/review.md +5 -4
  196. package/plugins/solution-architect/skills/proposal/references/writing.md +33 -31
  197. package/plugins/solution-architect/skills/proposal/scripts/derive.mjs +1 -1
  198. package/plugins/solution-architect/skills/proposal/scripts/lib/checks-client.mjs +5 -22
  199. package/plugins/solution-architect/skills/proposal/scripts/lib/checks-doc.mjs +18 -8
  200. package/plugins/solution-architect/skills/proposal/scripts/lib/checks.mjs +6 -2
  201. package/plugins/solution-architect/skills/proposal/scripts/lib/figures.mjs +24 -33
  202. package/plugins/solution-architect/skills/proposal/scripts/lib/sections.mjs +1 -1
  203. package/plugins/solution-architect/skills/proposal/scripts/test/checks-client.test.mjs +50 -47
  204. package/plugins/solution-architect/skills/proposal/scripts/test/checks-doc.test.mjs +99 -40
  205. package/plugins/solution-architect/skills/proposal/scripts/test/docs.test.mjs +11 -5
  206. package/plugins/solution-architect/skills/proposal/scripts/test/e2e.test.mjs +1 -1
  207. package/plugins/solution-architect/skills/proposal/scripts/test/evals-fixtures.test.mjs +39 -0
  208. package/plugins/solution-architect/skills/proposal/scripts/test/figures.test.mjs +67 -54
  209. package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-fail.md +6 -1
  210. package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-pass.md +8 -12
  211. package/plugins/solution-architect/skills/proposal/scripts/test/render.test.mjs +1 -1
  212. package/plugins/solution-architect/skills/proposal/scripts/test/validate.test.mjs +3 -2
  213. package/plugins/reasoning/evals/guardrail-unavailable-framework/graders/names-owning-skill.md +0 -9
  214. package/plugins/reasoning/evals/routing-complex-adaptive-org-change/graders/states-systemic-design-unavailable.md +0 -15
  215. package/plugins/solution-architect/skills/estimate/scripts/lib/scenario-schema.mjs +0 -39
@@ -1,6 +1,9 @@
1
1
  // The Feature breakdown's spreadsheet export: an internal-only button that
2
- // clones the sample estimator workbook in the browser, fills tab 1 with the
3
- // currently visible rows, and keeps every tier/price formula live in-cell.
2
+ // clones the v2 estimator workbook in the browser, fills the Ballpark
3
+ // Estimator tab with every feature (never just the filtered view) and the Project Roll-up tab
4
+ // with the interviewed context levels, and leaves every one of the template's
5
+ // own formulas untouched so the workbook keeps repricing when a human edits a
6
+ // score.
4
7
  import { test } from 'node:test';
5
8
  import assert from 'node:assert/strict';
6
9
  import { mkdtempSync, readFileSync, writeFileSync } from 'node:fs';
@@ -10,30 +13,60 @@ import { join } from 'node:path';
10
13
  import { pathToFileURL } from 'node:url';
11
14
  import { findChrome } from '../../../analyze-requirements/scripts/lib/chrome.mjs';
12
15
  import { openPage } from '../../../analyze-requirements/scripts/lib/cdp.mjs';
16
+ import { loadGuide } from '../lib/scoring.mjs';
13
17
  import { readZip } from './zip.mjs';
14
18
 
15
19
  const skip = { skip: !findChrome() && 'no chrome on PATH' };
16
20
  const fixture = new URL('./fixtures/booking-inputs.json', import.meta.url).pathname;
17
21
 
22
+ const scriptsDir = new URL('..', import.meta.url).pathname;
23
+
24
+ // The deliverable gate cross-checks the document's presented range against
25
+ // the computed one, so a fixture variant that prices differently needs the
26
+ // range it actually priced. The booking fixture's own numbers are unchanged.
27
+ function pricedMd(jsonPath) {
28
+ const md = readFileSync(join(scriptsDir, 'test/fixtures/estimation-pass.md'), 'utf8');
29
+ const { presentLow, presentHigh } = JSON.parse(readFileSync(jsonPath, 'utf8')).computed.price;
30
+ return md.replace(/\| Presented range \|[^|]*\|/,
31
+ `| Presented range | $${presentLow.toLocaleString('en-US')} – $${presentHigh.toLocaleString('en-US')} |`);
32
+ }
33
+
18
34
  function buildPage(inputsPath = fixture) {
19
35
  const dir = mkdtempSync(join(tmpdir(), 'estimate-xlsx-'));
20
- const scripts = new URL('..', import.meta.url).pathname;
21
- const passMd = join(scripts, 'test/fixtures/estimation-pass.md');
22
- execFileSync('node', [join(scripts, 'compute.mjs'), '--inputs', inputsPath, '--out', join(dir, 'estimation.json')]);
23
- execFileSync('node', [join(scripts, 'render.mjs'), '--json', join(dir, 'estimation.json'), '--md', passMd, '--out', dir]);
36
+ const json = join(dir, 'estimation.json');
37
+ const md = join(dir, 'estimation.md');
38
+ execFileSync('node', [join(scriptsDir, 'compute.mjs'), '--inputs', inputsPath, '--out', json]);
39
+ writeFileSync(md, pricedMd(json));
40
+ execFileSync('node', [join(scriptsDir, 'render.mjs'), '--json', json, '--md', md, '--out', dir]);
24
41
  return pathToFileURL(join(dir, 'estimate.html')).href;
25
42
  }
26
43
 
44
+ // Writes a variant of the booking fixture to a temp file and returns its path.
45
+ function variantInputs(tag, edit) {
46
+ const inputs = JSON.parse(readFileSync(fixture, 'utf8'));
47
+ edit(inputs);
48
+ const path = join(mkdtempSync(join(tmpdir(), `estimate-xlsx-${tag}-`)), 'inputs.json');
49
+ writeFileSync(path, JSON.stringify(inputs));
50
+ return path;
51
+ }
52
+
27
53
  async function exportedFiles(page) {
28
54
  const b64 = await page.eval('window.__buildWorkbook()');
29
55
  return readZip(Buffer.from(b64, 'base64'));
30
56
  }
31
57
 
32
- const sheet1 = (files) => files.get('xl/worksheets/sheet1.xml').toString('utf8');
58
+ // v2's tab order: 1 How to Use, 2 Ballpark Estimator, 3 Scoring Guide,
59
+ // 4 Tier Reference, 5 Project Roll-up. Our two generated tabs land at 6 and 7.
60
+ const sheetXmlFor = (files, part) => files.get(`xl/worksheets/${part}`)?.toString('utf8') ?? '';
61
+ const ballpark = (files) => sheetXmlFor(files, 'sheet2.xml');
62
+ const rollup = (files) => sheetXmlFor(files, 'sheet5.xml');
63
+ const sheetTasks = (files) => sheetXmlFor(files, 'sheet6.xml');
64
+ const sheetRationale = (files) => sheetXmlFor(files, 'sheet7.xml');
65
+
33
66
  const cell = (xml, ref) => new RegExp(`<c r="${ref}"[^>]*?(?:/>|>(.*?)</c>)`, 's').exec(xml)?.[1] ?? '';
34
67
  const inlineText = (frag) => /<t[^>]*>([^<]*)<\/t>/.exec(frag)?.[1];
35
68
  const cellNumber = (frag) => Number(/<v>([^<]*)<\/v>/.exec(frag)?.[1]);
36
- const cellFormula = (frag) => /<f>([^<]*)<\/f>/.exec(frag)?.[1];
69
+ const cellFormula = (frag) => /<f[^>]*>([^<]*)<\/f>/.exec(frag)?.[1];
37
70
 
38
71
  // The workbook carries a Task Breakdown sheet and a Score Rationale sheet, so
39
72
  // the export answers for the whole section rather than for either tab.
@@ -46,24 +79,66 @@ test('the section heading carries an internal-only download button', skip, async
46
79
  } finally { page.close(); }
47
80
  });
48
81
 
49
- test('the export clones the sample workbook with its guide tabs intact', skip, async () => {
82
+ test('the workbook has seven tabs in v2 order', skip, async () => {
50
83
  const page = await openPage(buildPage());
51
84
  try {
52
85
  const files = await exportedFiles(page);
53
- for (const name of ['xl/worksheets/sheet1.xml', 'xl/worksheets/sheet2.xml',
54
- 'xl/worksheets/sheet3.xml', 'xl/styles.xml', '[Content_Types].xml']) {
86
+ for (const part of ['sheet1.xml', 'sheet2.xml', 'sheet3.xml', 'sheet4.xml', 'sheet5.xml',
87
+ 'sheet6.xml', 'sheet7.xml']) {
88
+ assert.ok(files.has(`xl/worksheets/${part}`), `${part} missing from the exported archive`);
89
+ }
90
+ for (const name of ['xl/styles.xml', 'xl/sharedStrings.xml', '[Content_Types].xml']) {
55
91
  assert.ok(files.has(name), `${name} missing from the exported archive`);
56
92
  }
57
- const workbook = files.get('xl/workbook.xml').toString('utf8');
58
- assert.match(workbook, /Scoring Guide/);
59
- assert.match(workbook, /Tier Reference/);
93
+ const wb = files.get('xl/workbook.xml').toString('utf8');
94
+ const names = [...wb.matchAll(/<sheet [^>]*name="([^"]+)"/g)].map((m) => m[1]);
95
+ assert.deepEqual(names, ['How to Use', 'Ballpark Estimator', 'Scoring Guide', 'Tier Reference',
96
+ 'Project Roll-up', 'Task Breakdown', 'Score Rationale']);
97
+ } finally { page.close(); }
98
+ });
99
+
100
+ // The template ships cached results next to every formula. Without this flag a
101
+ // reader can open a workbook whose scores are ours and whose prices are still
102
+ // the sample's — green tests, dead numbers.
103
+ test('the workbook asks the reader to recalculate on load', skip, async () => {
104
+ const page = await openPage(buildPage());
105
+ try {
106
+ const files = await exportedFiles(page);
107
+ assert.match(files.get('xl/workbook.xml').toString('utf8'), /<calcPr[^>]*fullCalcOnLoad="1"/);
108
+ // LibreOffice ignores that flag, so no formula may keep a cached result:
109
+ // then there is nothing to show but the recomputed number.
110
+ for (const n of [1, 2, 3, 4, 5]) {
111
+ const xml = sheetXmlFor(files, `sheet${n}.xml`);
112
+ assert.doesNotMatch(xml, /<\/f><v>/, `sheet${n} keeps a cached formula result`);
113
+ }
114
+ assert.match(cell(ballpark(files), 'G7'), /SUMPRODUCT/, 'the formula itself must survive');
115
+ } finally { page.close(); }
116
+ });
117
+
118
+ // The export writes cells the template already carries. If one ever goes
119
+ // missing, a String.replace that finds nothing returns its input unchanged —
120
+ // the feature name and its scores would vanish into blank cells and every
121
+ // assertion in this file would still pass. Refuse instead.
122
+ test('writing a cell the template does not carry is refused, not ignored', skip, async () => {
123
+ const page = await openPage(buildPage());
124
+ try {
125
+ assert.match(await page.eval(`(() => {
126
+ try { setCell('<c r="A1" s="3"/>', 'ZZ99', (s) => '<c r="ZZ99" s="' + s + '"/>'); }
127
+ catch (e) { return e.message; }
128
+ return 'no throw';
129
+ })()`), /no cell ZZ99/);
130
+ assert.match(await page.eval(`(() => {
131
+ try { appendCells('<row r="1"/>', 99, '<c r="A99"/>'); }
132
+ catch (e) { return e.message; }
133
+ return 'no throw';
134
+ })()`), /no row 99/);
60
135
  } finally { page.close(); }
61
136
  });
62
137
 
63
138
  test('rows land ordered by milestone with the interview scores verbatim', skip, async () => {
64
139
  const page = await openPage(buildPage());
65
140
  try {
66
- const xml = sheet1(await exportedFiles(page));
141
+ const xml = ballpark(await exportedFiles(page));
67
142
  assert.equal(inlineText(cell(xml, 'A7')), 'User can book appointment');
68
143
  assert.equal(inlineText(cell(xml, 'A8')), 'Email reminders');
69
144
  assert.deepEqual(['B', 'C', 'D', 'E', 'F'].map((c) => cellNumber(cell(xml, `${c}7`))), [3, 3, 2, 3, 3]);
@@ -71,11 +146,28 @@ test('rows land ordered by milestone with the interview scores verbatim', skip,
71
146
  } finally { page.close(); }
72
147
  });
73
148
 
74
- // Row 6 is the sample workbook's own header row — the export never writes it,
75
- // it writes scores into B–F underneath. Pin the seam: if the sample's score
149
+ // The template ships five worked sample features in rows 7-11. An export of
150
+ // two features must not leave the other three standing next to our prices.
151
+ // Their names are shared strings, so searching the sheet XML for one proves
152
+ // nothing — the reference has to be resolved through sharedStrings.xml.
153
+ test('the template\'s own sample rows are cleared past the exported features', skip, async () => {
154
+ const page = await openPage(buildPage());
155
+ try {
156
+ const files = await exportedFiles(page);
157
+ const xml = ballpark(files);
158
+ assert.deepEqual(['A7', 'A8', 'A9', 'A10', 'A11'].map((r) => nameAt(files, xml, r)),
159
+ ['User can book appointment', 'Email reminders', '', '', '']);
160
+ for (const ref of ['A9', 'A10', 'A11', 'B9', 'F11']) {
161
+ assert.equal(cell(xml, ref), '', `${ref} must be emptied, not left with sample data`);
162
+ }
163
+ assert.match(xml, /<c r="A9" s="\d+"\/>/, 'the cleared cell must keep the template style');
164
+ } finally { page.close(); }
165
+ });
166
+
167
+ // Row 6 is the template's own header row — the export never writes it, it
168
+ // writes scores into B-F underneath. Pin the seam: if the template's score
76
169
  // columns are ever reordered or renamed, every exported score lands under the
77
- // wrong heading and nothing else would notice. The sample keeps these as
78
- // shared strings, unlike the cells the export writes inline.
170
+ // wrong heading and nothing else would notice.
79
171
  function sharedText(files, frag) {
80
172
  const idx = Number(/<v>(\d+)<\/v>/.exec(frag)?.[1]);
81
173
  const items = [...files.get('xl/sharedStrings.xml').toString('utf8').matchAll(/<si>([\s\S]*?)<\/si>/g)];
@@ -84,36 +176,50 @@ function sharedText(files, frag) {
84
176
 
85
177
  const headerText = (files, frag) => inlineText(frag) ?? sharedText(files, frag);
86
178
 
87
- test('the score columns sit under the sample workbook\'s five score headers', skip, async () => {
179
+ // A name cell is either one of our inline strings or, in the pristine
180
+ // template, a shared-string reference. Resolve both; a cleared cell reads ''.
181
+ function nameAt(files, xml, ref) {
182
+ const frag = cell(xml, ref);
183
+ return frag ? headerText(files, frag) : '';
184
+ }
185
+
186
+ test('the score columns sit under the template\'s five score headers', skip, async () => {
88
187
  const page = await openPage(buildPage());
89
188
  try {
90
189
  const files = await exportedFiles(page);
91
- const xml = sheet1(files);
190
+ const xml = ballpark(files);
92
191
  assert.deepEqual(['B', 'C', 'D', 'E', 'F'].map((c) => headerText(files, cell(xml, `${c}6`))),
93
- ['TECH\nCOMPLEXITY\n(1–5)', 'FEATURE\nSIZE\n(1–5)', 'DEPEND-\nENCIES\n(1–5)',
94
- 'UNCER-\nTAINTY\n(1–5)', 'RISK\n(1–5)']);
192
+ ['TECH\nCOMPLEXITY\n(1-5)', 'FEATURE\nSIZE\n(1-5)', 'DEPEND-\nENCIES\n(1-5)',
193
+ 'UNCER-\nTAINTY\n(1-5)', 'RISK\n(1-5)']);
95
194
  } finally { page.close(); }
96
195
  });
97
196
 
98
- test('column N carries the plain-words note for sales readers', skip, async () => {
197
+ test('the five dimension weights still sum to one in the shipped template', skip, async () => {
99
198
  const page = await openPage(buildPage());
100
199
  try {
101
- const xml = sheet1(await exportedFiles(page));
102
- assert.equal(inlineText(cell(xml, 'N6')), 'WHY THIS TIER');
103
- assert.match(inlineText(cell(xml, 'N7')) ?? '', /open questions/);
104
- assert.match(xml, /<autoFilter ref="A6:N26"\/>/);
200
+ const xml = ballpark(await exportedFiles(page));
201
+ const weights = ['B5', 'C5', 'D5', 'E5', 'F5'].map((ref) => cellNumber(cell(xml, ref)));
202
+ assert.ok(Math.abs(weights.reduce((a, b) => a + b, 0) - 1) < 1e-9, weights.join(','));
203
+ assert.match(cellFormula(cell(xml, 'G5')) ?? '', /SUM\(\$B\$5:\$F\$5\)/);
105
204
  } finally { page.close(); }
106
205
  });
107
206
 
108
- const sheetRationale = (files) => files.get('xl/worksheets/sheet5.xml')?.toString('utf8') ?? '';
207
+ test('column P carries the plain-words note for sales readers', skip, async () => {
208
+ const page = await openPage(buildPage());
209
+ try {
210
+ const xml = ballpark(await exportedFiles(page));
211
+ assert.equal(inlineText(cell(xml, 'P6')), 'WHY THIS TIER');
212
+ assert.match(inlineText(cell(xml, 'P7')) ?? '', /open questions/);
213
+ } finally { page.close(); }
214
+ });
109
215
 
110
216
  test('a Score Rationale tab lists anchor, evidence and both sources per factor', skip, async () => {
111
217
  const page = await openPage(buildPage());
112
218
  try {
113
219
  const files = await exportedFiles(page);
114
220
  assert.match(files.get('xl/workbook.xml').toString('utf8'), /name="Score Rationale"/);
115
- assert.match(files.get('xl/_rels/workbook.xml.rels').toString('utf8'), /Target="worksheets\/sheet5\.xml"/);
116
- assert.match(files.get('[Content_Types].xml').toString('utf8'), /PartName="\/xl\/worksheets\/sheet5\.xml"/);
221
+ assert.match(files.get('xl/_rels/workbook.xml.rels').toString('utf8'), /Target="worksheets\/sheet7\.xml"/);
222
+ assert.match(files.get('[Content_Types].xml').toString('utf8'), /PartName="\/xl\/worksheets\/sheet7\.xml"/);
117
223
  const xml = sheetRationale(files);
118
224
  assert.deepEqual(['A1', 'B1', 'C1', 'D1', 'E1', 'F1', 'G1'].map((r) => inlineText(cell(xml, r))),
119
225
  ['FEATURE', 'FACTOR', 'SCORE', 'ANCHOR', 'EVIDENCE', 'FEATURE SOURCE', 'SCORE ORIGIN']);
@@ -133,12 +239,10 @@ test('a Score Rationale tab lists anchor, evidence and both sources per factor',
133
239
  // agent's score. The booking fixture happens to agree on both, so this pins
134
240
  // them apart: one feature the client asked for, whose score nobody touched.
135
241
  test('feature source and score origin are read from separate fields', skip, async () => {
136
- const dir = mkdtempSync(join(tmpdir(), 'estimate-xlsx-sources-'));
137
- const inputs = JSON.parse(readFileSync(fixture, 'utf8'));
138
- inputs.features[0].provenance = 'stated';
139
- inputs.features[0].scoreProvenance = 'proposed';
140
- const inputsPath = join(dir, 'inputs.json');
141
- writeFileSync(inputsPath, JSON.stringify(inputs));
242
+ const inputsPath = variantInputs('sources', (inputs) => {
243
+ inputs.features[0].provenance = 'stated';
244
+ inputs.features[0].scoreProvenance = 'proposed';
245
+ });
142
246
  const page = await openPage(buildPage(inputsPath));
143
247
  try {
144
248
  const xml = sheetRationale(await exportedFiles(page));
@@ -148,54 +252,100 @@ test('feature source and score origin are read from separate fields', skip, asyn
148
252
  } finally { page.close(); }
149
253
  });
150
254
 
151
- test('QUICK inputs export blank score cells and an empty rationale tab', skip, async () => {
152
- const dir = mkdtempSync(join(tmpdir(), 'estimate-xlsx-quick-'));
153
- const inputs = JSON.parse(readFileSync(fixture, 'utf8'));
255
+ const quickInputs = () => variantInputs('quick', (inputs) => {
154
256
  inputs.depth = 'QUICK';
155
257
  for (const f of inputs.features) {
156
258
  delete f.scores; delete f.scoreNote; delete f.scoreProvenance;
157
259
  f.tasks = [{ ...f.tasks[0], id: `${f.id}-band`, o: 60, m: 110, p: 160 }];
158
260
  }
159
- const inputsPath = join(dir, 'inputs.json');
160
- writeFileSync(inputsPath, JSON.stringify(inputs));
161
- const page = await openPage(buildPage(inputsPath));
261
+ });
262
+
263
+ test('QUICK inputs export blank score cells and an empty rationale tab', skip, async () => {
264
+ const page = await openPage(buildPage(quickInputs()));
162
265
  try {
163
266
  const files = await exportedFiles(page);
164
- const xml = sheet1(files);
267
+ const xml = ballpark(files);
165
268
  assert.equal(cell(xml, 'B7'), '', 'no score value at QUICK');
166
269
  assert.match(xml, /<c r="B7" s="\d+"\/>/);
167
270
  assert.match(sheetRationale(files), /<autoFilter ref="A1:G1"\/>/);
168
271
  } finally { page.close(); }
169
272
  });
170
273
 
171
- test('score math stays in the sheet: G-K are formulas, total row uses SUMIF', skip, async () => {
274
+ // A QUICK estimate has no scores, and this workbook prices only from scores.
275
+ // The template's G7 is IF($A7="",0,SUMPRODUCT(...)), so a named feature with
276
+ // blank B:F weighs 0 — not blank, which is what v1's COUNTA guard returned.
277
+ // That 0 runs I7 -> I37 -> Project Roll-up C6 -> C20 and every figure under
278
+ // it. Nothing about the sheet looks broken; it reads a confident, formatted
279
+ // $0. Verified in LibreOffice: I37 = 0, C20 = 0, D34 = 0. So the sheet says
280
+ // so beside the subtotal, and this pins the behaviour as a decision.
281
+ test('a QUICK export says on the roll-up that its figures read zero', skip, async () => {
282
+ const page = await openPage(buildPage(quickInputs()));
283
+ try {
284
+ const files = await exportedFiles(page);
285
+ const note = inlineText(cell(rollup(files), 'D6')) ?? '';
286
+ assert.match(note, /NOT A PRICE/);
287
+ assert.match(note, /2 of 2 features carry no scores/);
288
+ assert.match(note, /read 0/);
289
+ assert.match(note, /Score the features on the Ballpark tab/); // 0 is recoverable in-sheet
290
+ // The formulas that produce that 0 are still the template's own, so typing
291
+ // scores in really does reprice the sheet.
292
+ assert.match(cellFormula(cell(ballpark(files), 'I37')) ?? '', /SUM\(\$I\$7:\$I\$36\)/);
293
+ assert.match(cellFormula(cell(rollup(files), 'C20')) ?? '', /\$C\$6\*\$D\$16/);
294
+ } finally { page.close(); }
295
+ });
296
+
297
+ // The note is warranted, not unconditional: a fully scored export must not
298
+ // cry wolf on a tab a client may well read.
299
+ test('a fully scored export leaves the roll-up unannotated', skip, async () => {
172
300
  const page = await openPage(buildPage());
173
301
  try {
174
- const xml = sheet1(await exportedFiles(page));
175
- assert.match(cellFormula(cell(xml, 'G7')) ?? '', /SUM\(B7:F7\)/);
176
- assert.match(cellFormula(cell(xml, 'H7')) ?? '', /IF\(/);
177
- for (const ref of ['I7', 'J7', 'K7']) {
178
- assert.ok(cellFormula(cell(xml, ref)), `${ref} must hold a formula, not a baked value`);
302
+ assert.equal(cell(rollup(await exportedFiles(page)), 'D6'), '');
303
+ } finally { page.close(); }
304
+ });
305
+
306
+ // The whole point of shipping a workbook rather than a PDF: G-M are the
307
+ // template's own tier/price chain and the export must never rewrite them.
308
+ test('score math stays the template\'s: G-M are live formulas the export never touches', skip, async () => {
309
+ const page = await openPage(buildPage());
310
+ try {
311
+ const xml = ballpark(await exportedFiles(page));
312
+ assert.match(cellFormula(cell(xml, 'G7')) ?? '', /SUMPRODUCT\(\$B7:\$F7,\$B\$5:\$F\$5\)/);
313
+ for (const col of ['H', 'I', 'J', 'K', 'L', 'M']) {
314
+ assert.ok(/<f/.test(cell(xml, `${col}7`)), `${col}7 must hold a formula, not a baked value`);
179
315
  }
180
- assert.equal(inlineText(cell(xml, 'A27')), 'PROJECT TOTAL');
181
- assert.match(cellFormula(cell(xml, 'G27')) ?? '', /SUMIF\(G7:G26/);
316
+ assert.match(cell(xml, 'H7'), /Tier Reference/, 'the tier lookup must stay cross-sheet');
317
+ // ...and the blank slots below keep theirs, so a typed-in feature prices itself.
318
+ assert.ok(/<f/.test(cell(xml, 'I36')), 'the last spare row lost its formula');
182
319
  } finally { page.close(); }
183
320
  });
184
321
 
185
- test('milestone and container fill L/M under an autofiltered header', skip, async () => {
322
+ test('the template\'s FEATURE SUBTOTAL row survives the fill', skip, async () => {
186
323
  const page = await openPage(buildPage());
187
324
  try {
188
- const xml = sheet1(await exportedFiles(page));
189
- assert.equal(inlineText(cell(xml, 'L6')), 'MILESTONE');
190
- assert.equal(inlineText(cell(xml, 'M6')), 'CONTAINER');
191
- assert.equal(inlineText(cell(xml, 'L7')), 'M1 - Booking core');
192
- assert.equal(inlineText(cell(xml, 'M7')), 'Booking API');
193
- assert.equal(inlineText(cell(xml, 'M8')), 'Notification Service');
194
- assert.match(xml, /<autoFilter ref="A6:N26"\/>/);
325
+ const xml = ballpark(await exportedFiles(page));
326
+ assert.match(cellFormula(cell(xml, 'G37')) ?? '', /COUNTIF\(\$A\$7:\$A\$36/);
327
+ for (const ref of ['I37', 'K37', 'L37']) {
328
+ assert.match(cellFormula(cell(xml, ref)) ?? '', /SUM\(\$[IKL]\$7:\$[IKL]\$36\)/);
329
+ }
195
330
  } finally { page.close(); }
196
331
  });
197
332
 
198
- test('the export honours the active source filter', skip, async () => {
333
+ test('milestone and container fill N/O beside the template columns', skip, async () => {
334
+ const page = await openPage(buildPage());
335
+ try {
336
+ const xml = ballpark(await exportedFiles(page));
337
+ assert.equal(inlineText(cell(xml, 'N6')), 'MILESTONE');
338
+ assert.equal(inlineText(cell(xml, 'O6')), 'CONTAINER');
339
+ assert.equal(inlineText(cell(xml, 'N7')), 'M1 - Booking core');
340
+ assert.equal(inlineText(cell(xml, 'O7')), 'Booking API');
341
+ assert.equal(inlineText(cell(xml, 'O8')), 'Notification Service');
342
+ } finally { page.close(); }
343
+ });
344
+
345
+ // R60: the workbook prices the project from whatever rows it gets, so a
346
+ // filtered subset would quote a different total than the page and the
347
+ // proposal. The export ignores the breakdown filter.
348
+ test('the export carries every feature even with a source filter on', skip, async () => {
199
349
  const page = await openPage(buildPage());
200
350
  try {
201
351
  await page.eval(`(() => {
@@ -203,27 +353,98 @@ test('the export honours the active source filter', skip, async () => {
203
353
  sel.value = 'stated';
204
354
  sel.dispatchEvent(new Event('change', { bubbles: true }));
205
355
  })()`);
206
- const xml = sheet1(await exportedFiles(page));
207
- assert.match(xml, /User can book appointment/);
208
- assert.doesNotMatch(xml, /Email reminders/);
209
- assert.equal(inlineText(cell(xml, 'A27')), 'PROJECT TOTAL', 'total row must survive filtering');
356
+ const files = await exportedFiles(page);
357
+ const xml = ballpark(files);
358
+ assert.deepEqual(['A7', 'A8'].map((r) => nameAt(files, xml, r)),
359
+ ['User can book appointment', 'Email reminders'], 'a filtered-out feature must still export');
210
360
  } finally { page.close(); }
211
361
  });
212
362
 
213
- const sheetTasks = (files) => files.get('xl/worksheets/sheet4.xml')?.toString('utf8') ?? '';
363
+ // --- Project Roll-up: the five context levels the interview captured. The
364
+ // multiplier beside each one stays a live INDEX formula, so an edited level
365
+ // reprices the whole project inside the workbook.
366
+ test('the roll-up context cells are filled from inputs in the sheet\'s own order', skip, async () => {
367
+ // Levels cap at 4, so five distinct values are impossible; 1,2,3,4,1 leaves
368
+ // codebaseMaturity/clientDecisions as the only pair a swap could hide.
369
+ const inputsPath = variantInputs('levels', (inputs) => {
370
+ inputs.contextLevels = { codebaseMaturity: 1, stackFamiliarity: 2, specQuality: 3, compliance: 4, clientDecisions: 1 };
371
+ for (const [key, prov] of Object.entries(inputs.contextProvenance ?? {})) {
372
+ prov.level = inputs.contextLevels[key];
373
+ }
374
+ });
375
+ const page = await openPage(buildPage(inputsPath));
376
+ try {
377
+ const xml = rollup(await exportedFiles(page));
378
+ assert.deepEqual(['C11', 'C12', 'C13', 'C14', 'C15'].map((r) => cellNumber(cell(xml, r))),
379
+ [1, 2, 3, 4, 1]);
380
+ for (const ref of ['D11', 'D12', 'D13', 'D14', 'D15']) {
381
+ assert.ok(/<f/.test(cell(xml, ref)), `${ref} must stay the template's INDEX formula`);
382
+ }
383
+ assert.match(cellFormula(cell(xml, 'C6')) ?? '', /Ballpark Estimator'!\$I\$37/);
384
+ } finally { page.close(); }
385
+ });
386
+
387
+ // 2 fixture features + 31 clones = 33, three more than the 30 wired rows.
388
+ // The clones score 1/2/3/4/5, five distinct values, so B-F can only line up
389
+ // under the right headers one way — the booking fixture's 3,3,2,3,3 would
390
+ // survive a B/C or E/F swap in SCORE_KEYS.
391
+ // compute.mjs refuses a score whose anchor is not the guide's own sentence
392
+ // for that number, so the rescored clones take theirs from the guide.
393
+ const GUIDE = loadGuide();
394
+ const SCORE_ORDER = ['tech', 'size', 'deps', 'unc', 'risk'];
395
+
396
+ const overflowInputs = () => variantInputs('overflow', (inputs) => {
397
+ const base = inputs.features[0];
398
+ inputs.features.push(...Array.from({ length: 31 }, (_, i) => {
399
+ const f = { ...structuredClone(base), id: `extra${i}`, name: `Extra feature ${i}` };
400
+ f.tasks = base.tasks.map((t, j) => ({ ...structuredClone(t), id: `extra${i}-t${j}` }));
401
+ SCORE_ORDER.forEach((key, n) => { f.scores[key] = { ...f.scores[key], n: n + 1, anchor: GUIDE[key][n] }; });
402
+ return f;
403
+ }));
404
+ });
405
+
406
+ test('each score lands in its own column: five distinct values, one ordering', skip, async () => {
407
+ const page = await openPage(buildPage(overflowInputs()));
408
+ try {
409
+ const xml = ballpark(await exportedFiles(page));
410
+ assert.equal(inlineText(cell(xml, 'A8')), 'Extra feature 0');
411
+ assert.deepEqual(['B', 'C', 'D', 'E', 'F'].map((c) => cellNumber(cell(xml, `${c}8`))), [1, 2, 3, 4, 5]);
412
+ } finally { page.close(); }
413
+ });
414
+
415
+ // Patching the template in place means the Ballpark tab can hold only the
416
+ // rows the template wired: 7-36. Anything past that must be loud, because a
417
+ // silently truncated FEATURE SUBTOTAL is a wrong price on a client's desk.
418
+ test('features past the template\'s 30 scored rows are called out in the sheet', skip, async () => {
419
+ const page = await openPage(buildPage(overflowInputs()));
420
+ try {
421
+ const files = await exportedFiles(page);
422
+ const xml = ballpark(files);
423
+ assert.ok(inlineText(cell(xml, 'A36')), 'the last wired slot must be used');
424
+ const note = inlineText(cell(xml, 'A38')) ?? '';
425
+ assert.match(note, /3 more features/);
426
+ assert.match(note, /not in the subtotal/i);
427
+ assert.match(note, /Email reminders/); // the M2 feature sorts last, so it is dropped
428
+ // Nothing is lost from the workbook — the overflow still rides the other tabs.
429
+ assert.match(sheetTasks(files), /Email reminders/);
430
+ assert.match(sheetRationale(files), /Email reminders/);
431
+ // ...and the roll-up, where every figure derives from that subtotal, says so too.
432
+ assert.match(inlineText(cell(rollup(files), 'D6')) ?? '', /INCOMPLETE: 3 features did not fit/);
433
+ } finally { page.close(); }
434
+ });
214
435
 
215
436
  test('the export adds a registered Task Breakdown tab', skip, async () => {
216
437
  const page = await openPage(buildPage());
217
438
  try {
218
439
  const files = await exportedFiles(page);
219
- assert.ok(files.has('xl/worksheets/sheet4.xml'), 'sheet4.xml missing');
440
+ assert.ok(files.has('xl/worksheets/sheet6.xml'), 'sheet6.xml missing');
220
441
  assert.match(files.get('xl/workbook.xml').toString('utf8'), /name="Task Breakdown"/);
221
- assert.match(files.get('xl/_rels/workbook.xml.rels').toString('utf8'), /Target="worksheets\/sheet4\.xml"/);
222
- assert.match(files.get('[Content_Types].xml').toString('utf8'), /PartName="\/xl\/worksheets\/sheet4\.xml"/);
442
+ assert.match(files.get('xl/_rels/workbook.xml.rels').toString('utf8'), /Target="worksheets\/sheet6\.xml"/);
443
+ assert.match(files.get('[Content_Types].xml').toString('utf8'), /PartName="\/xl\/worksheets\/sheet6\.xml"/);
223
444
  } finally { page.close(); }
224
445
  });
225
446
 
226
- test('task rows carry the PERT formula in-cell and ride the feature filter', skip, async () => {
447
+ test('task rows carry the PERT formula in-cell and ignore the feature filter', skip, async () => {
227
448
  const page = await openPage(buildPage());
228
449
  try {
229
450
  await page.eval(`(() => {
@@ -238,7 +459,7 @@ test('task rows carry the PERT formula in-cell and ride the feature filter', ski
238
459
  assert.match(cellFormula(cell(xml, 'G2')) ?? '', /\(D2\+4\*E2\+F2\)\/6/);
239
460
  assert.equal(inlineText(cell(xml, 'H2')), 'HIGH');
240
461
  assert.equal(inlineText(cell(xml, 'K2')), 'Booking API');
241
- assert.doesNotMatch(xml, /Scheduled reminder jobs/, 'filtered-out feature tasks must not export');
462
+ assert.match(xml, /Scheduled reminder jobs/, 'a filtered-out feature\'s tasks must still export');
242
463
  } finally { page.close(); }
243
464
  });
244
465
 
@@ -94,12 +94,13 @@ cannot hold two entries with the same name.
94
94
 
95
95
  ## Registry sync
96
96
 
97
- Runs after `/proposal`, never after `/estimate` — `/estimate` emits several
98
- scenarios and picks none; the pick is `/proposal`'s interview.
97
+ Runs after `/proposal`, never after `/estimate` — the lead's value is the
98
+ range the proposal quotes to the client, which exists only once
99
+ `proposal-figures.json` does. The estimate produces one price and no
100
+ scenarios, so `scenario` stays `null`.
99
101
 
100
102
  | Field | Source |
101
103
  | --- | --- |
102
- | `scenario` | `proposal-figures.json` `.scenario` |
103
104
  | `value` | `.cost.low` / `.cost.high`, currency from `proposal.md` frontmatter |
104
105
  | `client` | `proposal.md` frontmatter, only when the entry's `client` is `null` |
105
106
 
@@ -15,18 +15,20 @@ Both are hard prerequisites — the skill stops without them:
15
15
  ## What it asks
16
16
 
17
17
  A short interview: who the client is, how technical they are (a non-tech
18
- client gets a jargon-free document, enforced by the validator), which
19
- staffing scenario to offer, and how long the proposal stays valid. Your
20
- firm profile is asked once and cached (`.claude/proposal-profile.json`,
21
- project or global scope — your choice).
18
+ client gets a jargon-free document, enforced by the validator), and how long
19
+ the proposal stays valid. Your firm profile is asked once and cached
20
+ (`.claude/proposal-profile.json`, project or global scope — your choice).
22
21
 
23
22
  ## What it guarantees
24
23
 
25
24
  - Every number traces to `estimation.json` — the validator recomputes the
26
25
  client-facing ranges and refuses anything hand-invented.
27
- - Exactly one scenario reaches the client, as a range.
28
- - No internal leakage: other scenarios, rates, provenance tags, and the
29
- internal risk register never appear.
26
+ - The client sees one price: the estimate's own presented range and single
27
+ number, split across milestones by effort share. An estimate with no
28
+ scored features (agentic delivery) has no price to quote, and the skill
29
+ refuses rather than send a $0.
30
+ - No internal leakage: feature scores, tiers, the pricing working, provenance
31
+ tags, and the internal risk register never appear.
30
32
  - Validation gates rendering; a fresh-eyes subagent review and your own
31
33
  sign-off gate delivery.
32
34
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: proposal
3
- description: Assemble a pre-sales client proposal from analyze-requirements and estimate outputs — interviewed client context, one offered scenario as a price range, and a print-ready client page. Use when the user asks for a proposal, a client pitch document, a quote document, or "something I can send the client".
3
+ description: Assemble a pre-sales client proposal from analyze-requirements and estimate outputs — interviewed client context, the estimate's price as a range, and a print-ready client page. Use when the user asks for a proposal, a client pitch document, a quote document, or "something I can send the client".
4
4
  ---
5
5
 
6
6
  # proposal
@@ -17,8 +17,9 @@ PDF.
17
17
  go in the document.
18
18
  2. Both prerequisites are hard: no ARCHITECTURE.md or no estimation.json →
19
19
  stop and name the skill to run (`analyze-requirements` / `estimate`).
20
- 3. One scenario reaches the client — the one picked in the interview,
21
- presented as a range. The others never leak.
20
+ 3. The client sees one price — the cost range and single-number figure the
21
+ estimate computed. No staffing plan, internal scoring, or timeline
22
+ leaks.
22
23
  4. `node scripts/validate.mjs` must exit 0 before the page renders;
23
24
  `render.mjs` re-runs the same checks and refuses on findings.
24
25
  5. Human review of proposal.md before anything is rendered for or sent to
@@ -28,11 +29,13 @@ PDF.
28
29
 
29
30
  1. **Prereq gate**: ARCHITECTURE.md and estimation.json both exist, or stop.
30
31
  2. **Interview**: follow `references/interview.md` — client context, tech
31
- level, scenario pick, validity, firm profile (with storage-scope choice).
32
+ level, validity, firm profile (with storage-scope choice).
32
33
  3. **Figures**: `node scripts/derive.mjs --estimation <dir>/estimation.json
33
- --scenario <id> --out <dir>/proposal-figures.json` — the only numbers
34
- allowed in the document.
35
- 4. **Write**: proposal.md per `references/writing.md` (ten sections,
34
+ --out <dir>/proposal-figures.json` — the only numbers allowed in the
35
+ document. It refuses an unpriced estimate (no scored features — QUICK
36
+ depth or agentic mode); stop there and name the `estimate` skill, to be
37
+ re-run with scored features. Never quote such an estimate at $0.
38
+ 4. **Write**: proposal.md per `references/writing.md` (nine sections,
36
39
  frontmatter contract, tech-level language).
37
40
  5. **Validate**: `node scripts/validate.mjs --md <dir>/proposal.md
38
41
  --estimation <dir>/estimation.json` — fix findings, re-run until clean.