@v11g/agents-rock 1.0.3 → 1.0.5

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 (61) hide show
  1. package/README.md +4 -2
  2. package/package.json +1 -1
  3. package/plugins/business-analyst/.claude-plugin/plugin.json +1 -1
  4. package/plugins/business-analyst/skills/business-analyst/README.md +4 -1
  5. package/plugins/business-analyst/skills/business-analyst/SKILL.md +6 -2
  6. package/plugins/business-analyst/skills/business-analyst/scripts/test/python-parity.test.mjs +50 -0
  7. package/plugins/business-analyst/skills/business-analyst/scripts/validate.py +288 -0
  8. package/plugins/solution-architect/.claude-plugin/plugin.json +1 -1
  9. package/plugins/solution-architect/skills/analyze-requirements/assets/viewer-template.html +4 -2
  10. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/chrome.mjs +4 -1
  11. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/viewer-template.test.mjs +3 -2
  12. package/plugins/solution-architect/skills/estimate/README.md +8 -5
  13. package/plugins/solution-architect/skills/estimate/SKILL.md +9 -5
  14. package/plugins/solution-architect/skills/estimate/assets/estimate-template-agentic.html +142 -376
  15. package/plugins/solution-architect/skills/estimate/assets/estimate-template.html +610 -601
  16. package/plugins/solution-architect/skills/estimate/assets/scores-review-template.html +118 -0
  17. package/plugins/solution-architect/skills/estimate/references/ai-multipliers.md +5 -9
  18. package/plugins/solution-architect/skills/estimate/references/interview.md +121 -10
  19. package/plugins/solution-architect/skills/estimate/references/scoring-guide.md +23 -0
  20. package/plugins/solution-architect/skills/estimate/references/techniques.md +9 -2
  21. package/plugins/solution-architect/skills/estimate/references/writing.md +21 -5
  22. package/plugins/solution-architect/skills/estimate/scripts/lib/agentic-checks.mjs +1 -1
  23. package/plugins/solution-architect/skills/estimate/scripts/lib/checks.mjs +4 -30
  24. package/plugins/solution-architect/skills/estimate/scripts/lib/estimate-math.mjs +14 -10
  25. package/plugins/solution-architect/skills/estimate/scripts/lib/inline.mjs +6 -8
  26. package/plugins/solution-architect/skills/estimate/scripts/lib/md-tables.mjs +31 -0
  27. package/plugins/solution-architect/skills/estimate/scripts/lib/redact.mjs +14 -3
  28. package/plugins/solution-architect/skills/estimate/scripts/lib/rollup.mjs +5 -4
  29. package/plugins/solution-architect/skills/estimate/scripts/lib/scenario-schema.mjs +39 -0
  30. package/plugins/solution-architect/skills/estimate/scripts/lib/schema.mjs +4 -14
  31. package/plugins/solution-architect/skills/estimate/scripts/lib/score-csv.mjs +58 -0
  32. package/plugins/solution-architect/skills/estimate/scripts/lib/score-diff.mjs +30 -0
  33. package/plugins/solution-architect/skills/estimate/scripts/lib/score-html.mjs +17 -0
  34. package/plugins/solution-architect/skills/estimate/scripts/lib/scoring-checks.mjs +24 -0
  35. package/plugins/solution-architect/skills/estimate/scripts/lib/scoring-schema.mjs +48 -0
  36. package/plugins/solution-architect/skills/estimate/scripts/lib/scoring.mjs +45 -0
  37. package/plugins/solution-architect/skills/estimate/scripts/render.mjs +14 -13
  38. package/plugins/solution-architect/skills/estimate/scripts/score-review.mjs +59 -0
  39. package/plugins/solution-architect/skills/estimate/scripts/test/browser.test.mjs +403 -316
  40. package/plugins/solution-architect/skills/estimate/scripts/test/compute.test.mjs +25 -1
  41. package/plugins/solution-architect/skills/estimate/scripts/test/estimate-math.test.mjs +29 -10
  42. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/agentic-inputs.json +2 -2
  43. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/booking-inputs.json +21 -3
  44. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-fail.md +1 -1
  45. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-pass.md +4 -4
  46. package/plugins/solution-architect/skills/estimate/scripts/test/references.test.mjs +61 -6
  47. package/plugins/solution-architect/skills/estimate/scripts/test/render.test.mjs +96 -13
  48. package/plugins/solution-architect/skills/estimate/scripts/test/schema.test.mjs +105 -4
  49. package/plugins/solution-architect/skills/estimate/scripts/test/score-review.test.mjs +187 -0
  50. package/plugins/solution-architect/skills/estimate/scripts/test/scoring.test.mjs +49 -0
  51. package/plugins/solution-architect/skills/estimate/scripts/test/url-state.test.mjs +198 -0
  52. package/plugins/solution-architect/skills/estimate/scripts/test/validate.test.mjs +38 -0
  53. package/plugins/solution-architect/skills/estimate/scripts/test/xlsx-export.test.mjs +93 -28
  54. package/plugins/solution-architect/skills/new-lead/assets/dashboard/detail.html +25 -50
  55. package/plugins/solution-architect/skills/new-lead/assets/dashboard/index.html +20 -40
  56. package/plugins/solution-architect/skills/new-lead/scripts/lib/map-nodes.mjs +13 -5
  57. package/plugins/solution-architect/skills/new-lead/scripts/serve.mjs +8 -3
  58. package/plugins/solution-architect/skills/new-lead/scripts/test/map.test.mjs +4 -0
  59. package/plugins/solution-architect/skills/new-lead/scripts/test/serve.test.mjs +25 -21
  60. package/plugins/solution-architect/skills/proposal/scripts/test/checks-client.test.mjs +2 -2
  61. package/plugins/solution-architect/skills/proposal/scripts/test/figures.test.mjs +1 -1
@@ -23,7 +23,12 @@ test('golden numbers for the booking fixture', () => {
23
23
  assert.equal(computed.projectConfidence, 'MED'); // critical path = booking, worst row MED
24
24
  const rec = computed.scenarios['2eng-max5x'];
25
25
  assert.ok(rec.months > 0 && rec.totalCost > 0);
26
- assert.equal(rec.totalCost, rec.laborCost + rec.planCost);
26
+ assert.equal(rec.totalCost, rec.laborCost + rec.toolingCost);
27
+ assert.equal('planCost' in rec, false);
28
+ // Same team math as before the plan→aiAssisted rename: hours and seat cost pinned
29
+ assert.equal(computed.scenarios['3eng-noai'].hours, 145.31);
30
+ assert.equal(rec.hours, 101.35);
31
+ assert.equal(rec.toolingCost, 80.44); // 0.4022 mo × $100 × 2 seats
27
32
  // AI hours strictly below traditional on every task in an AI scenario
28
33
  for (const id of Object.keys(computed.tasks)) {
29
34
  assert.ok(rec.taskHours[id] < computed.tasks[id].e);
@@ -130,3 +135,22 @@ test('compute.mjs CLI resolves measurementsPath itself', () => {
130
135
  const estimation = JSON.parse(readFileSync(outPath, 'utf8'));
131
136
  assert.equal(estimation.computed.tasks['swap-refactor'].samples, 7);
132
137
  });
138
+
139
+ test('computed features carry the scores\' total and tier, copied not derived', () => {
140
+ const { computed } = computeEstimation(fixture());
141
+ assert.equal(computed.features.booking.scoreTotal, 14);
142
+ assert.equal(computed.features.booking.tier, 'M');
143
+ assert.equal(computed.features.reminders.scoreTotal, 11);
144
+ assert.equal(computed.features.reminders.tier, 'S');
145
+ // hours are untouched by scoring
146
+ assert.equal(computed.features.booking.hours, 69.33);
147
+ });
148
+
149
+ test('QUICK inputs get no score fields in computed features', () => {
150
+ const quick = fixture();
151
+ quick.depth = 'QUICK';
152
+ for (const f of quick.features) { delete f.scores; delete f.scoreNote; delete f.scoreProvenance; }
153
+ const { computed } = computeEstimation(quick);
154
+ assert.equal('tier' in computed.features.booking, false);
155
+ assert.equal('scoreTotal' in computed.features.booking, false);
156
+ });
@@ -26,6 +26,16 @@ test('factor scores map to tiers at the documented breaks', () => {
26
26
  assert.equal(tierFor({ complexity: 5, size: 4, dependencies: 4, uncertainty: 3, risk: 2 }).tier, 'L');
27
27
  });
28
28
 
29
+ test('tier breaks are the workbook scale: S ≤ 11, M ≤ 17, L ≤ 22, XL above', () => {
30
+ const at = (total) => tierFor({ a: total }).tier;
31
+ assert.equal(at(11), 'S');
32
+ assert.equal(at(12), 'M');
33
+ assert.equal(at(17), 'M');
34
+ assert.equal(at(18), 'L');
35
+ assert.equal(at(22), 'L');
36
+ assert.equal(at(23), 'XL');
37
+ });
38
+
29
39
  test('aiAdjust applies (AO + 2AR + TR)/4 plus verification overhead', () => {
30
40
  const e = 152 / 6; // boilerplate: red=0.65, redMax=0.8 — category only, no seniority term
31
41
  const want = ((e * 0.2 + 2 * (e * 0.35) + e) / 4) * 1.12;
@@ -39,26 +49,26 @@ test('aiAdjust clamps reduction at 0.9 for outsized scale', () => {
39
49
  });
40
50
 
41
51
  test('taskHours: seniority scales base effort on the traditional path', () => {
42
- const base = { e: 100, plan: 'none', category: 'logic', verificationPct: 0.12 };
52
+ const base = { e: 100, aiAssisted: false, category: 'logic', verificationPct: 0.12 };
43
53
  close(taskHours({ ...base, seniority: 'senior' }), 85);
44
54
  close(taskHours({ ...base, seniority: 'mid' }), 100);
45
55
  close(taskHours({ ...base, seniority: 'junior' }), 115);
46
56
  });
47
57
 
48
58
  test('taskHours: a senior is never slower than a junior, with or without AI', () => {
49
- for (const plan of ['none', 'max5x']) {
59
+ for (const aiAssisted of [false, true]) {
50
60
  for (const category of ['boilerplate', 'logic', 'novel']) {
51
- const at = (seniority) => taskHours({ e: 100, seniority, plan, category, verificationPct: 0.12 });
61
+ const at = (seniority) => taskHours({ e: 100, seniority, aiAssisted, category, verificationPct: 0.12 });
52
62
  assert.ok(at('senior') < at('mid') && at('mid') < at('junior'),
53
- `${plan}/${category}: ${at('senior')} < ${at('mid')} < ${at('junior')} violated`);
63
+ `${aiAssisted}/${category}: ${at('senior')} < ${at('mid')} < ${at('junior')} violated`);
54
64
  }
55
65
  }
56
66
  });
57
67
 
58
- test('taskHours: AI plan reduces hours versus the same seniority without AI', () => {
68
+ test('taskHours: AI assistance reduces hours versus the same seniority unaided', () => {
59
69
  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')}`);
70
+ const at = (aiAssisted) => taskHours({ e: 100, seniority, aiAssisted, category: 'boilerplate', verificationPct: 0.12 });
71
+ assert.ok(at(true) < at(false), `${seniority}: AI ${at(true)} !< ${at(false)}`);
62
72
  }
63
73
  });
64
74
 
@@ -83,15 +93,24 @@ test('capacity pays a coordination tax per added engineer, floored at one', () =
83
93
  close(effectiveCapacity(12), 1); // raw formula goes negative past 10 — floor holds
84
94
  });
85
95
 
86
- test('scenarioRollup: 1008h, 2 mid @45, max5x → 4.0mo, $51,200', () => {
96
+ test('scenarioRollup: 1008h, 2 mid @45, $100/seat tooling → 4.0mo, $51,200', () => {
87
97
  const team = [{ seniority: 'mid', rate: 45 }, { seniority: 'mid', rate: 45 }];
88
- const got = scenarioRollup({ hours: 1008, team, plan: 'max5x' });
98
+ const got = scenarioRollup({ hours: 1008, team, toolingCostPerSeat: 100 });
89
99
  close(got.months, 4);
90
100
  close(got.laborCost, 50400);
91
- close(got.planCost, 800);
101
+ close(got.toolingCost, 800);
92
102
  close(got.totalCost, 51200);
93
103
  });
94
104
 
105
+ // A null seat cost is an open gap, not free tooling — it prices as zero and
106
+ // the interview records the assumption; the math must not turn null into NaN.
107
+ test('scenarioRollup: null toolingCostPerSeat prices tooling at zero', () => {
108
+ const team = [{ seniority: 'mid', rate: 45 }];
109
+ const got = scenarioRollup({ hours: 140, team, toolingCostPerSeat: null });
110
+ close(got.toolingCost, 0);
111
+ close(got.totalCost, got.laborCost);
112
+ });
113
+
95
114
  test('roadmapBands tiles [0, months] proportionally to hours, in order', () => {
96
115
  const bands = roadmapBands({
97
116
  milestones: [{ name: 'M1', hours: 60 }, { name: 'M2', hours: 40 }],
@@ -38,8 +38,8 @@
38
38
  }
39
39
  ],
40
40
  "scenarios": [
41
- { "id": "solo", "plan": "max5x", "team": [{ "seniority": "senior", "rate": 90 }] },
42
- { "id": "pair", "plan": "max20x", "team": [{ "seniority": "senior", "rate": 90 }, { "seniority": "mid", "rate": 60 }] }
41
+ { "id": "solo", "aiAssisted": true, "toolingCostPerSeat": 100, "team": [{ "seniority": "senior", "rate": 90 }] },
42
+ { "id": "pair", "aiAssisted": true, "toolingCostPerSeat": 200, "team": [{ "seniority": "senior", "rate": 90 }, { "seniority": "mid", "rate": 60 }] }
43
43
  ],
44
44
  "recommendedScenario": "solo"
45
45
  }
@@ -3,7 +3,7 @@
3
3
  "currency": "USD",
4
4
  "technique": "three-point-pert",
5
5
  "depth": "STANDARD",
6
- "calibration": { "S": [20, 60], "M": [60, 160], "L": [160, 400] },
6
+ "calibration": { "S": [20, 60], "M": [60, 160], "L": [160, 400], "XL": [400, 800] },
7
7
  "overheadPct": 0.35,
8
8
  "verificationPct": 0.12,
9
9
  "exposeRatesToClient": false,
@@ -20,6 +20,15 @@
20
20
  "provenance": "stated",
21
21
  "component": "api",
22
22
  "milestone": "M1 - Booking core",
23
+ "scores": {
24
+ "tech": { "n": 3, "anchor": "Custom business logic, moderate algorithm complexity, multiple states", "cite": "slot conflict + cancellation rules" },
25
+ "size": { "n": 3, "anchor": "Medium feature with multiple components and backend logic", "cite": "CRUD API + rules engine" },
26
+ "deps": { "n": 2, "anchor": "One internal dependency (e.g. auth check)", "cite": "reads the user session" },
27
+ "unc": { "n": 3, "anchor": "Some open questions, design decisions to be made during build", "cite": "recurring bookings undecided" },
28
+ "risk": { "n": 3, "anchor": "Moderate impact if broken, requires testing, affects multiple users", "cite": "double booking hits every customer" }
29
+ },
30
+ "scoreNote": "Core booking rules with a few open questions; touches every customer if it breaks",
31
+ "scoreProvenance": "stated",
23
32
  "tasks": [
24
33
  { "id": "booking-api", "name": "Booking CRUD API", "category": "boilerplate",
25
34
  "o": 16, "m": 24, "p": 40, "confidence": "HIGH",
@@ -35,6 +44,15 @@
35
44
  "provenance": "proposed",
36
45
  "component": "notify.jobs",
37
46
  "milestone": "M2 - Notifications",
47
+ "scores": {
48
+ "tech": { "n": 2, "anchor": "Minor customisation of standard patterns, simple state management", "cite": "scheduled job + template" },
49
+ "size": { "n": 2, "anchor": "Small self-contained feature, simple form or display component", "cite": "one job, one template" },
50
+ "deps": { "n": 3, "anchor": "2–3 internal services or one third-party API", "cite": "transactional email provider" },
51
+ "unc": { "n": 2, "anchor": "Minor ambiguities, can be resolved with one clarifying question", "cite": "send-time rule to confirm" },
52
+ "risk": { "n": 2, "anchor": "Low stakes, easy rollback, minimal user impact", "cite": "a missed reminder is recoverable" }
53
+ },
54
+ "scoreNote": "Sends reminder emails through an outside provider; low stakes if one is missed",
55
+ "scoreProvenance": "proposed",
38
56
  "tasks": [
39
57
  { "id": "reminder-jobs", "name": "Scheduled reminder jobs", "category": "logic",
40
58
  "o": 12, "m": 20, "p": 36, "confidence": "MED",
@@ -49,9 +67,9 @@
49
67
  { "text": "single timezone", "impactIfWrong": "recompute booking-api at logic category, +30%" }
50
68
  ],
51
69
  "scenarios": [
52
- { "id": "3eng-noai", "plan": "none",
70
+ { "id": "3eng-noai", "aiAssisted": false, "toolingCostPerSeat": null,
53
71
  "team": [{ "seniority": "mid", "rate": 45 }, { "seniority": "mid", "rate": 45 }, { "seniority": "junior", "rate": 30 }] },
54
- { "id": "2eng-max5x", "plan": "max5x",
72
+ { "id": "2eng-max5x", "aiAssisted": true, "toolingCostPerSeat": 100,
55
73
  "team": [{ "seniority": "senior", "rate": 60 }, { "seniority": "mid", "rate": 45 }] }
56
74
  ],
57
75
  "recommendedScenario": "2eng-max5x"
@@ -7,7 +7,7 @@
7
7
  | User can book appointment | M | 40–120 | stated |
8
8
  | Email reminders | S | 12–36 | proposed |
9
9
 
10
- Recommended delivery: 2 engineers (1 senior, 1 mid) + Claude Code Max 5x — see detail.
10
+ Recommended delivery: 2 engineers (1 senior, 1 mid), AI-assisted — see detail.
11
11
 
12
12
  ### Assumptions
13
13
 
@@ -7,7 +7,7 @@
7
7
  | User can book appointment | M | 40–120 | stated |
8
8
  | Email reminders | S | 12–36 | proposed |
9
9
 
10
- Recommended delivery: 2 engineers (1 senior, 1 mid) + Claude Code Max 5x — see detail.
10
+ Recommended delivery: 2 engineers (1 senior, 1 mid), AI-assisted — see detail.
11
11
 
12
12
  | Line | Hours |
13
13
  | --- | --- |
@@ -49,10 +49,10 @@ Technique: three-point PERT — detailed backlog available.
49
49
 
50
50
  ### Scenario comparison
51
51
 
52
- | Scenario | Team | Plan | Months | Cost | Notes |
52
+ | Scenario | Team | AI-assisted | Months | Cost | Notes |
53
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 |
54
+ | 3eng-noai | 2 mid + 1 junior | no | 0.43 | $7,266 | — |
55
+ | 2eng-max5x | 1 senior + 1 mid | yes | 0.40 | $5,993 | recommended |
56
56
 
57
57
  ### Calibration
58
58
 
@@ -1,12 +1,12 @@
1
1
  import { test } from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
3
  import { readFileSync } from 'node:fs';
4
- import { AI_CATEGORIES, PLAN_PRICES, TIER_BREAKS } from '../lib/estimate-math.mjs';
4
+ import { AI_CATEGORIES, TIER_BREAKS } from '../lib/estimate-math.mjs';
5
5
  import { TASK_SHAPES } from '../lib/measurements.mjs';
6
6
 
7
7
  const ref = (f) => readFileSync(new URL(`../../references/${f}`, import.meta.url), 'utf8');
8
8
  const ALL = ['interview.md', 'techniques.md', 'ai-multipliers.md', 'writing.md', 'slicing.md',
9
- 'task-shapes.md', 'agentic-estimation.md'];
9
+ 'task-shapes.md', 'agentic-estimation.md', 'scoring-guide.md'];
10
10
 
11
11
  test('no reference doc carries placeholders', () => {
12
12
  for (const f of ALL) assert.doesNotMatch(ref(f), /\bTBD\b|\bTODO\b/, f);
@@ -25,7 +25,7 @@ test('techniques.md names every technique and the real tier breaks', () => {
25
25
  for (const needle of ['factor-scored tiering', 'three-point PERT', 'analogy']) {
26
26
  assert.ok(doc.includes(needle), `techniques.md missing: ${needle}`);
27
27
  }
28
- assert.ok(doc.includes('11-17 M') || doc.includes('11–17 M'), 'tier breaks must match TIER_BREAKS');
28
+ assert.ok(doc.includes('12–17 M') || doc.includes('12-17 M'), 'tier breaks must match TIER_BREAKS');
29
29
  assert.equal(TIER_BREAKS[1].max, 17); // the doc claim above is only honest while this holds
30
30
  });
31
31
 
@@ -34,10 +34,24 @@ test('ai-multipliers.md agrees with the code constants', () => {
34
34
  for (const category of Object.keys(AI_CATEGORIES)) {
35
35
  assert.ok(doc.includes(category), `ai-multipliers.md missing category: ${category}`);
36
36
  }
37
- for (const [plan, price] of Object.entries(PLAN_PRICES)) {
38
- if (plan !== 'none') assert.ok(doc.includes(String(price)), `pricing table missing ${plan}=${price}`);
39
- }
40
37
  assert.match(doc, /blanket/i, 'the blanket-multiplier prohibition must be stated');
38
+ // The Claude-plan price table lived here; seat cost is now an interview input.
39
+ assert.doesNotMatch(doc, /PLAN_PRICES|max5x|max20x/, 'vendor plan pricing must not be documented as a constant');
40
+ });
41
+
42
+ test('interview.md asks AI-assisted (default yes) and a nullable seat cost, never a Claude plan', () => {
43
+ const doc = ref('interview.md');
44
+ for (const needle of ['AI-assisted', 'toolingCostPerSeat', 'default']) {
45
+ assert.ok(doc.includes(needle), `interview.md missing: ${needle}`);
46
+ }
47
+ assert.doesNotMatch(doc, /Max 5x|Max 20x|Claude plan/);
48
+ });
49
+
50
+ test('interview.md defaults to one team and asks why when several are compared', () => {
51
+ const doc = ref('interview.md');
52
+ for (const needle of ['one team', 'recommendedReason']) {
53
+ assert.ok(doc.includes(needle), `interview.md missing: ${needle}`);
54
+ }
41
55
  });
42
56
 
43
57
  test('writing.md states every validator rule family', () => {
@@ -93,3 +107,44 @@ test('method sources are cited where techniques are recommended', () => {
93
107
  }
94
108
  }
95
109
  });
110
+
111
+ test('scoring-guide.md carries five rows of five anchors and the tier scale', () => {
112
+ const doc = ref('scoring-guide.md');
113
+ const rows = doc.split('\n').filter((l) => /^\| (Tech complexity|Feature size|Dependencies|Uncertainty|Risk) \|/.test(l));
114
+ assert.equal(rows.length, 5);
115
+ for (const r of rows) assert.equal(r.split('|').length - 2, 6, r); // label + 5 anchors
116
+ assert.match(doc, /S ≤ 11 · M 12–17 · L 18–22 · XL 23\+/);
117
+ assert.match(doc, /XL 400–800 h/);
118
+ assert.doesNotMatch(doc, /derived:/);
119
+ });
120
+
121
+ test('interview.md scores before tasks, names the three review channels and the plain-words note', () => {
122
+ const doc = ref('interview.md');
123
+ for (const needle of ['scoring-guide.md', 'scores', 'scoreNote', 'scoreProvenance', 'terminal', 'csv', 'html',
124
+ 'score-review.mjs', 'accept', 'split', 'outside', 'plain', 'needsReason', 'no reason given', 'frontend-design:frontend-design', 'window.__feedback()']) {
125
+ assert.ok(doc.includes(needle), `interview.md missing: ${needle}`);
126
+ }
127
+ assert.ok(doc.indexOf('Factor scores per feature') < doc.indexOf('Tasks + O/M/P'), 'scores come before tasks');
128
+ });
129
+
130
+ test('techniques.md says scores persist at STANDARD/DEEP and the band is a soft cross-check', () => {
131
+ const doc = ref('techniques.md');
132
+ assert.match(doc, /STANDARD\/DEEP/);
133
+ assert.match(doc, /persist/i);
134
+ assert.match(doc, /cross-check/i);
135
+ assert.match(doc, /XL 400-800h|XL 400–800 h/);
136
+ });
137
+
138
+ test('writing.md documents the score fields and the Tier rule', () => {
139
+ const doc = ref('writing.md');
140
+ for (const needle of ['`scores`', '`scoreNote`', '`scoreProvenance`', 'anchor', 'cite', 'Tier']) {
141
+ assert.ok(doc.includes(needle), `writing.md missing: ${needle}`);
142
+ }
143
+ assert.match(doc, /Tier.*must (equal|match)/);
144
+ });
145
+
146
+ test('SKILL.md points the interview at the scoring guide and the review script', () => {
147
+ const skill = readFileSync(new URL('../../SKILL.md', import.meta.url), 'utf8');
148
+ assert.match(skill, /scoring-guide\.md/);
149
+ assert.match(skill, /score-review\.mjs/);
150
+ });
@@ -4,7 +4,7 @@ import { readFileSync, writeFileSync, mkdtempSync } from 'node:fs';
4
4
  import { execFileSync } from 'node:child_process';
5
5
  import { tmpdir } from 'node:os';
6
6
  import { join } from 'node:path';
7
- import { inlineModule, stripInternal } from '../lib/inline.mjs';
7
+ import { inlineModule, extractExports, stripInternal } from '../lib/inline.mjs';
8
8
 
9
9
  const tpl = () => readFileSync(new URL('../../assets/estimate-template.html', import.meta.url), 'utf8');
10
10
  const cli = new URL('../render.mjs', import.meta.url).pathname;
@@ -16,9 +16,19 @@ const agenticPassMd = new URL('./fixtures/agentic-estimation-pass.md', import.me
16
16
  const measurementsFixture = new URL('./fixtures/measurements.jsonl', import.meta.url).pathname;
17
17
 
18
18
  function renderedPage(extra = []) {
19
+ return renderWith(() => {}, extra);
20
+ }
21
+
22
+ // Same pipeline, with the booking inputs mutated first — for pages whose
23
+ // shape depends on the scenarios (one team vs several, AI-only variants).
24
+ function renderWith(mutate, extra = []) {
19
25
  const dir = mkdtempSync(join(tmpdir(), 'estimate-render-'));
26
+ const inputs = JSON.parse(readFileSync(fixture, 'utf8'));
27
+ mutate(inputs);
28
+ const inputsPath = join(dir, 'inputs.json');
29
+ writeFileSync(inputsPath, JSON.stringify(inputs));
20
30
  const json = join(dir, 'estimation.json');
21
- execFileSync('node', [computeCli, '--inputs', fixture, '--out', json]);
31
+ execFileSync('node', [computeCli, '--inputs', inputsPath, '--out', json]);
22
32
  execFileSync('node', [cli, '--json', json, '--md', passMd, '--out', dir, ...extra]);
23
33
  return readFileSync(join(dir, 'estimate.html'), 'utf8');
24
34
  }
@@ -47,7 +57,7 @@ test('render refuses a deliverable that fails validation', () => {
47
57
 
48
58
  test('template carries exactly the five slots and no external URLs', () => {
49
59
  const markers = [...tpl().matchAll(/<!-- slot:(\w+) -->/g)].map((m) => m[1]).sort();
50
- assert.deepEqual([...new Set(markers)], ['DATA', 'FONTS', 'MATH', 'TITLE', 'VIEWER']);
60
+ assert.deepEqual([...new Set(markers)], ['DATA', 'FONTS', 'GUIDE', 'TITLE', 'VIEWER']);
51
61
  // openxmlformats URIs are XML namespace identifiers the xlsx export writes
52
62
  // into generated sheets — never fetched, so the page stays self-contained.
53
63
  assert.doesNotMatch(tpl(), /https?:\/\/(?!www\.w3\.org|schemas\.openxmlformats\.org)/);
@@ -71,18 +81,22 @@ test('the --viewer href is attribute-escaped', () => {
71
81
  assert.match(html, /href="\.\.\/a&quot;b\/index\.html"/);
72
82
  });
73
83
 
74
- test('inlineModule strips export keywords and nothing else', () => {
75
- assert.equal(inlineModule('export function f() {}\nexport const X = 1;\nconst y = 2;'),
76
- 'function f() {}\nconst X = 1;\nconst y = 2;');
77
- });
78
-
79
84
  test('rendered page is self-contained and carries parseable data', () => {
80
85
  const html = renderedPage();
81
86
  assert.doesNotMatch(html, /<!-- slot:/);
82
87
  assert.match(html, /@font-face/);
83
88
  const data = html.match(/<script type="application\/json" id="estimation-data">([\s\S]*?)<\/script>/)[1];
84
89
  assert.equal(JSON.parse(data).inputs.project, 'Booking App');
85
- assert.match(html, /function pert\(/); // math inlined, not referenced
90
+ // No formula is inlined any more: the page reads committed numbers only.
91
+ assert.doesNotMatch(html, /function pert\(/);
92
+ assert.doesNotMatch(html, /function scenarioRollup\(|function taskHours\(/);
93
+ });
94
+
95
+ test('inlineModule strips export keywords; extractExports keeps only the named blocks', () => {
96
+ assert.equal(inlineModule('export function f() {}\nexport const X = 1;\nconst y = 2;'),
97
+ 'function f() {}\nconst X = 1;\nconst y = 2;');
98
+ assert.equal(extractExports('export const A = 1;\nexport function b() {\n return A;\n}\nexport const C = 3;', ['b']),
99
+ 'export function b() {\n return A;\n}');
86
100
  });
87
101
 
88
102
  test('the page carries a method section with source attributions', () => {
@@ -92,8 +106,53 @@ test('the page carries a method section with source attributions', () => {
92
106
  assert.match(html, /kmino\.io/);
93
107
  });
94
108
 
95
- test('the method section comes first — how before how-much', () => {
96
- assert.match(tpl(), /<main>\s*<div class="col col-wide">\s*<section id="method">/);
109
+ test('the summary comes first and the method fold last — the number before the formula', () => {
110
+ assert.match(tpl(), /<main>\s*<div class="col">\s*<section id="summary">/);
111
+ assert.match(tpl(), /<section id="register"><\/section>\s*<section id="method"><\/section>\s*<\/div>\s*<\/main>/);
112
+ });
113
+
114
+ // The scenario cards, the cost bars and the what-if rail are gone: one
115
+ // Summary block states the recommended team, months and cost once.
116
+ test('the page has no scenario cards, cost bars or what-if rail', () => {
117
+ const html = renderedPage();
118
+ assert.doesNotMatch(html, /scenario-cards|cost-bars|ctl-|whatif|modified-banner|id="reset"/);
119
+ assert.match(html, /id="summary"/);
120
+ });
121
+
122
+ test('the summary names the recommended team, its AI assistance, months and cost', () => {
123
+ const html = renderedPage();
124
+ // renderer source: the label rule, and the JSON it reads from
125
+ assert.match(html, /humans unaided/);
126
+ assert.match(html, /AI-assisted/);
127
+ assert.match(html, /"recommendedScenario":"2eng-max5x"/);
128
+ });
129
+
130
+ // Only a different roster is an alternative worth a row; a same-team variant
131
+ // that differs in AI assistance collapses to one line.
132
+ test('renderer distinguishes team alternatives from AI-only variants', () => {
133
+ const html = renderedPage();
134
+ assert.match(html, /AI assistance: /); // the collapsed same-team line
135
+ assert.match(html, /<caption>Alternatives<\/caption>/); // the different-roster table
136
+ assert.match(html, /function sameTeam|const sameTeam/);
137
+ });
138
+
139
+ test('--figures adds the client-facing range line; without it there is none', () => {
140
+ const dir = mkdtempSync(join(tmpdir(), 'estimate-figures-'));
141
+ const figures = join(dir, 'proposal-figures.json');
142
+ writeFileSync(figures, JSON.stringify({ scenario: '2eng-max5x', cost: { low: 5000, high: 7000 }, months: { low: 0.3, high: 0.5 } }));
143
+ const withRange = renderedPage(['--figures', figures]);
144
+ assert.match(withRange, /"figures":\{"cost":\{"low":5000,"high":7000\},"months":\{"low":0.3,"high":0.5\}\}/);
145
+ const without = renderedPage();
146
+ assert.doesNotMatch(without, /"figures":/);
147
+ });
148
+
149
+ test('recommendedReason travels with the data', () => {
150
+ const html = renderWith((inputs) => { inputs.recommendedReason = 'client has one senior available'; });
151
+ assert.match(html, /"recommendedReason":"client has one senior available"/);
152
+ });
153
+
154
+ test('the breakdown no longer carries a Range column', () => {
155
+ assert.doesNotMatch(tpl(), /label: 'Range'/);
97
156
  });
98
157
 
99
158
  test('--client-only strips every internal range', () => {
@@ -105,11 +164,21 @@ test('--client-only strips every internal range', () => {
105
164
  test('--client-only redacts rates and cost breakdown unless exposeRatesToClient is set', () => {
106
165
  // Matched as quoted JSON keys, not bare identifiers: estimate-math.mjs is
107
166
  // inlined verbatim for the what-if engine and legitimately declares
108
- // `laborCost`/`planCost` as plain JS locals in every render, client or not.
167
+ // `laborCost`/`toolingCost` as plain JS locals in every render, client or not.
109
168
  const html = renderedPage(['--client-only']);
110
169
  assert.doesNotMatch(html, /"rate":/);
111
170
  assert.doesNotMatch(html, /"laborCost":/);
112
- assert.doesNotMatch(html, /"planCost":/);
171
+ assert.doesNotMatch(html, /"toolingCost":/);
172
+ });
173
+
174
+ // The cite is internal shorthand — ticket phrases, file names, meeting
175
+ // wording — so it never ships, rates opt-out or not. The anchor is the guide
176
+ // sentence the client can read, and it stays.
177
+ test('--client-only blanks the evidence cites and keeps the anchors', () => {
178
+ const client = renderedPage(['--client-only']);
179
+ assert.doesNotMatch(client, /slot conflict \+ cancellation rules/);
180
+ assert.match(client, /Custom business logic, moderate algorithm complexity, multiple states/);
181
+ assert.match(renderedPage(), /slot conflict \+ cancellation rules/);
113
182
  });
114
183
 
115
184
  test('--client-only keeps rates when exposeRatesToClient is true', () => {
@@ -166,3 +235,17 @@ test('agentic client render strips the measurements path, repository, and eviden
166
235
  assert.doesNotMatch(client, /Refactor A/);
167
236
  assert.doesNotMatch(client, />undefined</); // renderEvidence tolerates a stripped description
168
237
  });
238
+
239
+ test('the page never derives scores and carries the guide from the reference file', () => {
240
+ const html = renderedPage();
241
+ for (const gone of ['deriveScores', 'TECH_CATEGORY_SCORE', 'scoreTier', 'SCORE_GUIDE', 'bdModePill', 'bdMode(', 'derived:']) {
242
+ assert.equal(html.includes(gone), false, `${gone} must not be in the page`);
243
+ }
244
+ assert.match(html, /<template id="scoring-guide"><table class="guide-table">/);
245
+ assert.ok(html.includes('Payments, auth, data migrations, or PII — high business impact'));
246
+ });
247
+
248
+ test('the agentic page has no guide slot', () => {
249
+ const html = renderAgentic();
250
+ assert.doesNotMatch(html, /scoring-guide/);
251
+ });
@@ -34,14 +34,14 @@ test('zero estimates are refused — the honest absence is "not estimated"', ()
34
34
 
35
35
  test('anything compute would turn into NaN is refused up front', () => {
36
36
  const bad = fixture();
37
- bad.scenarios[1].plan = 'ghost-plan';
37
+ bad.scenarios[1].aiAssisted = 'yes';
38
38
  bad.scenarios[0].team[0].seniority = 'staff';
39
39
  bad.scenarios[0].team[1].rate = -5;
40
40
  bad.overheadPct = 1.4;
41
41
  bad.verificationPct = 'lots';
42
42
  bad.risks[0].probability = 7;
43
43
  const findings = checkInputs(bad);
44
- assert.ok(findings.some((f) => f.includes('2eng-max5x') && f.includes('plan')));
44
+ assert.ok(findings.some((f) => f.includes('2eng-max5x') && f.includes('aiAssisted')));
45
45
  assert.ok(findings.some((f) => f.includes('3eng-noai') && f.includes('seniority')));
46
46
  assert.ok(findings.some((f) => f.includes('3eng-noai') && f.includes('rate')));
47
47
  assert.ok(findings.some((f) => f.includes('overheadPct')));
@@ -67,11 +67,58 @@ test('inherited object keys do not pass the enum checks', () => {
67
67
  const bad = fixture();
68
68
  bad.features[0].tasks[0].category = 'toString';
69
69
  bad.scenarios[0].team[0].seniority = 'toString';
70
- bad.scenarios[1].plan = 'toString';
71
70
  const findings = checkInputs(bad);
72
71
  assert.ok(findings.some((f) => f.includes('booking-api') && f.includes('category')));
73
72
  assert.ok(findings.some((f) => f.includes('3eng-noai') && f.includes('seniority')));
74
- assert.ok(findings.some((f) => f.includes('2eng-max5x') && f.includes('plan')));
73
+ });
74
+
75
+ // The Claude-plan enum is gone: a scenario says whether the team has AI
76
+ // help (drives hours) and what a tooling seat costs (drives cost, nullable).
77
+ test('a legacy "plan" key is refused and the finding names its replacement', () => {
78
+ const bad = fixture();
79
+ bad.scenarios[1].plan = 'max5x';
80
+ const findings = checkInputs(bad);
81
+ assert.ok(findings.some((f) => f.includes('2eng-max5x') && f.includes('plan') && f.includes('aiAssisted')));
82
+ });
83
+
84
+ test('aiAssisted must be a boolean and toolingCostPerSeat a positive number or null', () => {
85
+ const bad = fixture();
86
+ delete bad.scenarios[0].aiAssisted;
87
+ bad.scenarios[1].toolingCostPerSeat = '100';
88
+ let findings = checkInputs(bad);
89
+ assert.ok(findings.some((f) => f.includes('3eng-noai') && f.includes('aiAssisted')));
90
+ assert.ok(findings.some((f) => f.includes('2eng-max5x') && f.includes('toolingCostPerSeat')));
91
+ const zero = fixture();
92
+ zero.scenarios[1].toolingCostPerSeat = 0;
93
+ assert.ok(checkInputs(zero).some((f) => f.includes('2eng-max5x') && f.includes('toolingCostPerSeat')));
94
+ const missing = fixture();
95
+ delete missing.scenarios[1].toolingCostPerSeat;
96
+ assert.ok(checkInputs(missing).some((f) => f.includes('2eng-max5x') && f.includes('toolingCostPerSeat')));
97
+ });
98
+
99
+ // Skipping the seat price is allowed — the client may mandate a vendor — but
100
+ // only as a recorded gap: an AI-assisted scenario with a null seat cost needs
101
+ // an assumption that says so, or the page would show a total silently missing
102
+ // a line item.
103
+ test('a null seat cost on an AI-assisted scenario needs a tooling assumption', () => {
104
+ const gap = fixture();
105
+ gap.scenarios[1].toolingCostPerSeat = null;
106
+ assert.ok(checkInputs(gap).some((f) => f.includes('2eng-max5x') && f.includes('tooling') && f.includes('assumption')));
107
+ gap.assumptions.push({ text: 'AI tooling cost per seat not yet set — client may mandate a vendor',
108
+ impactIfWrong: 'adds ~2% to total at $100-200/seat/month' });
109
+ assert.deepEqual(checkInputs(gap), []);
110
+ const unaided = fixture();
111
+ unaided.scenarios[0].toolingCostPerSeat = null; // 3eng-noai is aiAssisted: false — no gap to record
112
+ assert.deepEqual(checkInputs(unaided), []);
113
+ });
114
+
115
+ test('recommendedReason, when present, is a non-empty string', () => {
116
+ const ok = fixture();
117
+ ok.recommendedReason = 'client has one senior available';
118
+ assert.deepEqual(checkInputs(ok), []);
119
+ const bad = fixture();
120
+ bad.recommendedReason = ' ';
121
+ assert.ok(checkInputs(bad).some((f) => f.includes('recommendedReason')));
75
122
  });
76
123
 
77
124
  test('milestones are all-or-nothing across features', () => {
@@ -186,3 +233,57 @@ test('deliveryMode vocabulary is enforced; team inputs stay valid', () => {
186
233
  assert.ok(checkInputs(inputs).some((f) => f.includes('deliveryMode')));
187
234
  assert.deepEqual(checkInputs(fixture()), []); // existing booking fixture untouched
188
235
  });
236
+
237
+ const GUIDE_RISK_4 = 'Payments, auth, data migrations, or PII — high business impact';
238
+
239
+ test('scores are required at STANDARD depth, complete, 1–5, anchored to the guide, cited', () => {
240
+ const bad = fixture();
241
+ delete bad.features[1].scores;
242
+ bad.features[0].scores.risk = { n: 6, anchor: GUIDE_RISK_4, cite: 'x' };
243
+ bad.features[0].scores.tech.anchor = 'hard';
244
+ bad.features[0].scores.size.cite = '';
245
+ const findings = checkInputs(bad);
246
+ assert.ok(findings.some((f) => f.includes('reminders') && f.includes('scores object is required')));
247
+ assert.ok(findings.some((f) => f.includes('booking') && f.includes('scores.risk.n must be an integer 1–5')));
248
+ assert.ok(findings.some((f) => f.includes('booking') && f.includes('scores.tech.anchor is not the guide')));
249
+ assert.ok(findings.some((f) => f.includes('booking') && f.includes('scores.size.cite is required')));
250
+ });
251
+
252
+ test('an anchor must be the guide sentence for that factor and score, not another score', () => {
253
+ const bad = fixture();
254
+ bad.features[0].scores.risk = { n: 3, anchor: GUIDE_RISK_4, cite: 'payments' }; // risk 4's sentence on a 3
255
+ assert.ok(checkInputs(bad).some((f) => f.includes("scores.risk.anchor is not the guide's sentence for risk = 3")));
256
+ });
257
+
258
+ test('the plain-words note refuses jargon and provenance is stated|proposed', () => {
259
+ const bad = fixture();
260
+ bad.features[0].scoreNote = 'Risk 4 per ARCHITECTURE.md §6';
261
+ bad.features[1].scoreNote = '';
262
+ bad.features[1].scoreProvenance = 'observed';
263
+ const findings = checkInputs(bad);
264
+ assert.equal(findings.filter((f) => f.includes('scoreNote must be one plain sentence')).length, 2);
265
+ assert.ok(findings.some((f) => f.includes('reminders') && f.includes('scoreProvenance must be stated|proposed')));
266
+ });
267
+
268
+ test('scores must have exactly the five factors', () => {
269
+ const bad = fixture();
270
+ bad.features[0].scores.extra = { n: 1, anchor: 'x', cite: 'y' };
271
+ assert.ok(checkInputs(bad).some((f) => f.includes('exactly tech, size, deps, unc, risk')));
272
+ });
273
+
274
+ test('QUICK depth refuses persisted scores and needs no scores', () => {
275
+ const quick = fixture();
276
+ quick.depth = 'QUICK';
277
+ for (const f of quick.features) {
278
+ f.tasks = [{ ...f.tasks[0], id: `${f.id}-band`, o: 60, m: 110, p: 160 }];
279
+ }
280
+ assert.ok(checkInputs(quick).some((f) => f.includes('booking') && f.includes('scores is not persisted at QUICK depth')));
281
+ for (const f of quick.features) { delete f.scores; delete f.scoreNote; delete f.scoreProvenance; }
282
+ assert.deepEqual(checkInputs(quick), []);
283
+ });
284
+
285
+ test('depth must be one of the three named depths', () => {
286
+ const bad = fixture();
287
+ bad.depth = 'SCORING';
288
+ assert.ok(checkInputs(bad).some((f) => f === 'depth must be QUICK|STANDARD|DEEP'));
289
+ });