@v11g/agents-rock 1.0.2 → 1.0.3

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 (52) hide show
  1. package/package.json +1 -1
  2. package/plugins/business-analyst/.claude-plugin/plugin.json +9 -0
  3. package/plugins/business-analyst/skills/business-analyst/README.md +20 -0
  4. package/plugins/business-analyst/skills/business-analyst/SKILL.md +69 -0
  5. package/plugins/business-analyst/skills/business-analyst/references/ai-extension.md +37 -0
  6. package/plugins/business-analyst/skills/business-analyst/references/frameworks.md +53 -0
  7. package/plugins/business-analyst/skills/business-analyst/references/interview.md +89 -0
  8. package/plugins/business-analyst/skills/business-analyst/references/review.md +25 -0
  9. package/plugins/business-analyst/skills/business-analyst/references/writing.md +102 -0
  10. package/plugins/business-analyst/skills/business-analyst/scripts/lib/checks.mjs +166 -0
  11. package/plugins/business-analyst/skills/business-analyst/scripts/lib/schema.mjs +78 -0
  12. package/plugins/business-analyst/skills/business-analyst/scripts/test/checks.test.mjs +188 -0
  13. package/plugins/business-analyst/skills/business-analyst/scripts/test/e2e.test.mjs +17 -0
  14. package/plugins/business-analyst/skills/business-analyst/scripts/test/fixtures/requirements-fail.json +205 -0
  15. package/plugins/business-analyst/skills/business-analyst/scripts/test/fixtures/requirements-pass.json +59 -0
  16. package/plugins/business-analyst/skills/business-analyst/scripts/test/fixtures/requirements-pass.md +63 -0
  17. package/plugins/business-analyst/skills/business-analyst/scripts/test/schema.test.mjs +41 -0
  18. package/plugins/business-analyst/skills/business-analyst/scripts/validate.mjs +20 -0
  19. package/plugins/solution-architect/skills/estimate/SKILL.md +13 -5
  20. package/plugins/solution-architect/skills/estimate/assets/estimate-template-agentic.html +917 -0
  21. package/plugins/solution-architect/skills/estimate/assets/estimate-template.html +430 -13
  22. package/plugins/solution-architect/skills/estimate/references/agentic-estimation.md +148 -0
  23. package/plugins/solution-architect/skills/estimate/references/ai-multipliers.md +10 -0
  24. package/plugins/solution-architect/skills/estimate/references/interview.md +20 -1
  25. package/plugins/solution-architect/skills/estimate/references/task-shapes.md +173 -0
  26. package/plugins/solution-architect/skills/estimate/references/writing.md +31 -0
  27. package/plugins/solution-architect/skills/estimate/scripts/compute.mjs +5 -1
  28. package/plugins/solution-architect/skills/estimate/scripts/lib/agentic-checks.mjs +65 -0
  29. package/plugins/solution-architect/skills/estimate/scripts/lib/baselines.mjs +107 -0
  30. package/plugins/solution-architect/skills/estimate/scripts/lib/checks.mjs +16 -7
  31. package/plugins/solution-architect/skills/estimate/scripts/lib/inline.mjs +14 -0
  32. package/plugins/solution-architect/skills/estimate/scripts/lib/measurements.mjs +59 -0
  33. package/plugins/solution-architect/skills/estimate/scripts/lib/redact.mjs +28 -5
  34. package/plugins/solution-architect/skills/estimate/scripts/lib/rollup.mjs +53 -22
  35. package/plugins/solution-architect/skills/estimate/scripts/lib/schema.mjs +52 -7
  36. package/plugins/solution-architect/skills/estimate/scripts/render.mjs +14 -3
  37. package/plugins/solution-architect/skills/estimate/scripts/test/baselines.test.mjs +120 -0
  38. package/plugins/solution-architect/skills/estimate/scripts/test/browser.test.mjs +69 -0
  39. package/plugins/solution-architect/skills/estimate/scripts/test/compute.test.mjs +44 -0
  40. package/plugins/solution-architect/skills/estimate/scripts/test/e2e.test.mjs +28 -1
  41. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/agentic-estimation-fail.md +55 -0
  42. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/agentic-estimation-pass.md +54 -0
  43. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/agentic-inputs.json +45 -0
  44. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/measurements.jsonl +20 -0
  45. package/plugins/solution-architect/skills/estimate/scripts/test/measurements.test.mjs +54 -0
  46. package/plugins/solution-architect/skills/estimate/scripts/test/references.test.mjs +25 -1
  47. package/plugins/solution-architect/skills/estimate/scripts/test/render.test.mjs +48 -1
  48. package/plugins/solution-architect/skills/estimate/scripts/test/schema.test.mjs +59 -0
  49. package/plugins/solution-architect/skills/estimate/scripts/test/validate.test.mjs +37 -0
  50. package/plugins/solution-architect/skills/estimate/scripts/test/xlsx-export.test.mjs +168 -0
  51. package/plugins/solution-architect/skills/estimate/scripts/test/zip.mjs +41 -0
  52. package/plugins/solution-architect/skills/new-lead/SKILL.md +15 -10
@@ -0,0 +1,917 @@
1
+ <!doctype html>
2
+ <!-- data-theme is stated rather than left to the browser: this page opens dark,
3
+ and the toggle flips from a known state so its first click always bites. -->
4
+ <html lang="en" data-theme="dark">
5
+ <head>
6
+ <meta charset="utf-8">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1">
8
+ <meta name="description" content="Interactive project estimate with scenario comparison">
9
+ <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Crect width='16' height='16' rx='3' fill='%230f766e'/%3E%3C/svg%3E">
10
+ <title><!-- slot:TITLE --> — Estimate</title>
11
+ <style>
12
+ <!-- slot:FONTS -->
13
+ /* color-scheme is declared, not left at `normal`: a page that never states its
14
+ scheme is the page a force-dark browser rewrites, and then the toggle flips
15
+ data-theme with nothing visible changing — the button reads as broken. Stated
16
+ per theme, forced dark is off and the native controls in the what-if rail
17
+ (number, range, select) follow the page instead of fighting it.
18
+
19
+ The light palette is unconditional and the dark one is scoped to @media screen
20
+ below, so this block doubles as the paper palette: the page opens dark on a
21
+ display, and printing it falls back here instead of spending a full-bleed page
22
+ of ink. Written as a fallback rather than as a second copy inside @media print
23
+ — a duplicated palette is a palette that drifts. */
24
+ :root {
25
+ color-scheme:light;
26
+ --bg:#f7f5f0; --ink:#1c1b18; --ink-dim:#6f6a5e;
27
+ --accent:#0f766e; --accent-ink:#0b5a54; --accent-soft:rgba(15,118,110,.08);
28
+ --warn:#b45309; --warn-soft:rgba(180,83,9,.1);
29
+ --bad:#b91c1c; --ok:#15803d; --card:#fffdf9;
30
+ --border:#e6e1d5; --border-strong:#cfc8b8;
31
+ --shadow:0 1px 2px rgba(60,55,40,.05), 0 6px 20px rgba(60,55,40,.05);
32
+ }
33
+ @media screen {
34
+ :root[data-theme="dark"] {
35
+ color-scheme:dark;
36
+ --bg:#101413; --ink:#e8e6e1; --ink-dim:#93a09b;
37
+ --accent:#3ba99f; --accent-ink:#6fd1c7; --accent-soft:rgba(59,169,159,.12);
38
+ --warn:#d98b3d; --warn-soft:rgba(217,139,61,.12);
39
+ --bad:#e5726b; --ok:#5dbb7a; --card:#181d1c;
40
+ --border:#263230; --border-strong:#3a4a46;
41
+ --shadow:0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
42
+ }
43
+ }
44
+ * { box-sizing: border-box; }
45
+ body {
46
+ font-family:'IBM Plex Sans',system-ui,sans-serif; background:var(--bg); color:var(--ink);
47
+ margin:0; line-height:1.5;
48
+ }
49
+ button {
50
+ font-family:inherit; font-size:.8rem; padding:.35rem .75rem; border-radius:.35rem;
51
+ border:1px solid var(--border-strong); background:var(--card); color:var(--ink); cursor:pointer;
52
+ transition:background-color .15s ease, border-color .15s ease, transform .1s ease;
53
+ }
54
+ button:hover { border-color:var(--accent); color:var(--accent-ink); }
55
+ button:active { transform:translateY(1px); }
56
+ /* companion-mode back-link to the arch-docs viewer; dressed as a header button */
57
+ #viewer-link {
58
+ font-size:.8rem; padding:.35rem .75rem; border-radius:.35rem;
59
+ border:1px solid var(--border-strong); color:var(--ink); text-decoration:none;
60
+ }
61
+ #viewer-link:hover { border-color:var(--accent); color:var(--accent-ink); }
62
+ :focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
63
+ /* header bar: constrained to the same column as main via padding math */
64
+ header {
65
+ position:sticky; top:0; z-index:10;
66
+ display:flex; align-items:center; gap:.6rem;
67
+ padding:.8rem max(1.25rem, calc((100% - 1160px) / 2));
68
+ border-bottom:1px solid var(--border); background:var(--card);
69
+ }
70
+ .titles { flex:1; min-width:0; }
71
+ .eyebrow {
72
+ margin:0; font-family:'IBM Plex Mono',monospace; font-size:.62rem;
73
+ letter-spacing:.08em; text-transform:uppercase; color:var(--ink-dim);
74
+ }
75
+ header h1 {
76
+ font-size:1.05rem; font-weight:600; letter-spacing:-.01em; margin:0;
77
+ white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
78
+ }
79
+ #confidence-badge {
80
+ font-family:'IBM Plex Mono',monospace; font-size:.72rem; text-transform:uppercase;
81
+ padding:.18rem .5rem; border-radius:.3rem; border:1px solid var(--border-strong);
82
+ }
83
+ #confidence-badge.high { color:var(--ok); border-color:var(--ok); background:rgba(21,128,61,.08); }
84
+ #confidence-badge.med { color:var(--warn); border-color:var(--warn); background:var(--warn-soft); }
85
+ #confidence-badge.low { color:var(--bad); border-color:var(--bad); background:rgba(185,28,28,.08); }
86
+ #confidence-badge.uncalibrated { color:var(--warn); border-color:var(--warn); background:var(--warn-soft); }
87
+ #modified-banner {
88
+ margin:0; padding:.5rem max(1.25rem, calc((100% - 1160px) / 2));
89
+ background:var(--warn-soft); color:var(--warn); font-size:.85rem;
90
+ border-bottom:1px solid var(--border);
91
+ }
92
+ #modified-banner button { margin-left:.5rem; }
93
+ main {
94
+ display:grid; grid-template-columns:1fr; gap:1.1rem;
95
+ max-width:1160px; margin:0 auto; padding:1.25rem 1.25rem 3rem;
96
+ }
97
+ .col { display:grid; gap:1.1rem; min-width:0; align-content:start; }
98
+ .col > section:empty { display:none; }
99
+ main section h2, main aside h2 {
100
+ font-size:.82rem; font-weight:600; color:var(--ink-dim);
101
+ margin:0 0 .8rem; letter-spacing:.01em;
102
+ }
103
+ /* panels: every section except the scenario card grid reads as one surface */
104
+ .col > section {
105
+ background:var(--card); border:1px solid var(--border); border-radius:.6rem;
106
+ padding:1.1rem 1.2rem; box-shadow:var(--shadow);
107
+ }
108
+ #scenario-cards { background:none; border:none; box-shadow:none; padding:0; display:flex; flex-direction:column; }
109
+ #scenario-cards .cards {
110
+ flex:1; display:grid; grid-template-columns:repeat(auto-fit, minmax(190px, 1fr)); gap:.9rem;
111
+ }
112
+ .sec-head { display:flex; align-items:center; gap:.45rem; margin:0 0 .8rem; }
113
+ .sec-head h2 { margin:0; }
114
+ details.help { position:relative; display:inline-block; line-height:1; }
115
+ details.help summary {
116
+ list-style:none; cursor:help; width:1.05rem; height:1.05rem; border-radius:50%;
117
+ border:1px solid var(--border-strong); color:var(--ink-dim); background:var(--card);
118
+ font-size:.68rem; font-weight:600; font-family:'IBM Plex Mono',monospace;
119
+ display:inline-flex; align-items:center; justify-content:center;
120
+ }
121
+ details.help summary::-webkit-details-marker { display:none; }
122
+ details.help[open] summary { color:var(--accent-ink); border-color:var(--accent); }
123
+ details.help > p {
124
+ position:absolute; z-index:20; top:1.4rem; left:0; width:270px; margin:0;
125
+ background:var(--card); border:1px solid var(--border-strong); border-radius:.45rem;
126
+ padding:.6rem .75rem; font-size:.76rem; font-weight:400; line-height:1.45;
127
+ color:var(--ink); text-transform:none; letter-spacing:normal; text-align:left;
128
+ box-shadow:var(--shadow);
129
+ }
130
+ #controls details.help > p, td details.help > p, caption details.help > p { left:auto; right:0; }
131
+ #method summary { list-style:none; display:flex; align-items:baseline; gap:.6rem; cursor:pointer; }
132
+ #method summary::-webkit-details-marker { display:none; }
133
+ #method summary h2 { margin:0; }
134
+ #method .tech { font-size:.8rem; color:var(--ink-dim); font-family:'IBM Plex Mono',monospace; }
135
+ #method .chev { margin-left:auto; color:var(--ink-dim); transition:transform .15s ease; }
136
+ #method details[open] .chev { transform:rotate(90deg); }
137
+ #method ul { margin:.8rem 0 .9rem; padding-left:1.1rem; font-size:.85rem; }
138
+ #method li { margin-bottom:.35rem; }
139
+ #method .sources { font-size:.78rem; color:var(--ink-dim); margin:0; }
140
+ #method .sources span { display:block; margin-bottom:.2rem; }
141
+ .card {
142
+ position:relative; background:var(--card); border:1px solid var(--border);
143
+ border-radius:.6rem; padding:1rem 1.1rem; box-shadow:var(--shadow);
144
+ }
145
+ /* card anatomy: header, hero (top-aligned so the months figures sit on the
146
+ same line across cards), facts pinned to the bottom. */
147
+ .scenario { display:flex; flex-direction:column; gap:.7rem; padding:1.2rem; }
148
+ .scenario h3 {
149
+ font-family:'IBM Plex Mono',monospace; font-size:.78rem; font-weight:600;
150
+ color:var(--ink-dim); margin:0; overflow-wrap:anywhere;
151
+ }
152
+ .hero { flex:1; display:flex; flex-direction:column; justify-content:flex-start; gap:.55rem; }
153
+ .hero .num {
154
+ font-size:2.2rem; font-weight:600; line-height:1.05; letter-spacing:-.02em;
155
+ font-variant-numeric:tabular-nums;
156
+ }
157
+ .hero .unit { font-size:.8rem; color:var(--ink-dim); }
158
+ .gauge { height:.45rem; background:var(--border); border-radius:.3rem; overflow:hidden; }
159
+ .gauge span { display:block; height:100%; background:var(--accent); border-radius:.3rem; }
160
+ .delta {
161
+ align-self:flex-start; font-family:'IBM Plex Mono',monospace; font-size:.68rem;
162
+ color:var(--warn); background:var(--warn-soft); padding:.14rem .45rem; border-radius:.25rem;
163
+ }
164
+ .facts {
165
+ display:grid; grid-template-columns:1fr 1fr; gap:.7rem 1.1rem;
166
+ border-top:1px solid var(--border); padding-top:.8rem; margin:0;
167
+ }
168
+ .facts dt { font-size:.66rem; text-transform:uppercase; letter-spacing:.05em; color:var(--ink-dim); }
169
+ .facts dd { margin:.1rem 0 0; font-family:'IBM Plex Mono',monospace; font-size:.86rem; }
170
+ .scenario.recommended { border-color:var(--accent); background:linear-gradient(var(--accent-soft), transparent 55%) var(--card); }
171
+ .flag {
172
+ position:absolute; top:.7rem; right:.8rem; font-size:.62rem; font-weight:600;
173
+ letter-spacing:.04em; color:var(--accent-ink); background:var(--accent-soft);
174
+ padding:.14rem .4rem; border-radius:.25rem;
175
+ }
176
+ .months { margin:.2rem 0 .9rem; font-size:.8rem; color:var(--ink-dim); }
177
+ .months .num {
178
+ display:block; font-size:2.4rem; font-weight:600; line-height:1.15;
179
+ color:var(--ink); font-variant-numeric:tabular-nums; letter-spacing:-.02em;
180
+ }
181
+ #whatif-readout dl { display:flex; gap:1.2rem; margin:0; }
182
+ #whatif-readout dt { font-size:.66rem; text-transform:uppercase; letter-spacing:.05em; color:var(--ink-dim); }
183
+ #whatif-readout dd { margin:0; font-family:'IBM Plex Mono',monospace; font-size:.88rem; }
184
+ #whatif-readout { border-top:1px solid var(--border); padding-top:.7rem; }
185
+ #whatif-readout .months { display:flex; align-items:baseline; gap:.4rem; margin:0 0 .4rem; }
186
+ #whatif-readout .months .num { font-size:1.3rem; color:var(--accent-ink); }
187
+ /* bars are styled divs — width set inline from data, no canvas, printable */
188
+ /* when the section is stretched to match the rail beside it, the bars float
189
+ to the vertical center instead of leaving a dead band at the bottom. */
190
+ #cost-bars { display:flex; flex-direction:column; }
191
+ #cost-bars .bar-group { flex:1; display:flex; flex-direction:column; justify-content:center; }
192
+ .bar-row { display:flex; align-items:center; gap:.6rem; margin-bottom:.85rem; }
193
+ .bar-label {
194
+ flex:0 0 170px; font-size:.78rem; color:var(--ink-dim);
195
+ white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
196
+ }
197
+ .bar-track { flex:1; height:1.05rem; background:var(--border); border-radius:.3rem; overflow:hidden; }
198
+ .bar-fill { display:block; height:100%; background:var(--accent); opacity:.5; border-radius:.3rem; }
199
+ .bar-fill.is-rec { opacity:1; }
200
+ .bar-val {
201
+ flex:0 0 auto; min-width:5.5rem; text-align:right;
202
+ font-family:'IBM Plex Mono',monospace; font-size:.76rem; font-variant-numeric:tabular-nums;
203
+ }
204
+ /* roadmap: Gantt-style shared axis. Every row is a flex triple (label |
205
+ track | months) with the same label/months widths as the axis strip below
206
+ it, so a given month lines up under the same x-position in every row's
207
+ track and in the axis ticks — one shared coordinate system, not a
208
+ per-row axis. */
209
+ .roadmap-chart { display:flex; flex-direction:column; }
210
+ .roadmap-row { display:flex; align-items:center; gap:.7rem; padding:.4rem 0; }
211
+ .roadmap-row + .roadmap-row { border-top:1px solid var(--border); }
212
+ .roadmap-label { flex:0 0 150px; min-width:0; display:flex; flex-direction:column; gap:.15rem; }
213
+ .roadmap-name { font-size:.82rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
214
+ .roadmap-feature-names { font-size:.7rem; color:var(--ink-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
215
+ .roadmap-track {
216
+ position:relative; flex:1; min-width:0; height:.8rem;
217
+ background:var(--border); border-radius:.3rem; overflow:hidden;
218
+ }
219
+ .roadmap-gridline { position:absolute; top:0; bottom:0; width:1px; background:var(--border-strong); opacity:.55; }
220
+ .roadmap-band {
221
+ position:absolute; top:0; height:100%; background:var(--accent); border-radius:.3rem;
222
+ display:flex; overflow:hidden; /* container segments fill it left to right */
223
+ }
224
+ .roadmap-seg { height:100%; }
225
+ .roadmap-months {
226
+ flex:0 0 auto; min-width:4.6rem; text-align:right;
227
+ font-family:'IBM Plex Mono',monospace; font-size:.72rem;
228
+ color:var(--ink-dim); font-variant-numeric:tabular-nums;
229
+ }
230
+ /* the axis mirrors the row's flex geometry (same label/months widths) so its
231
+ ticks land under the matching month position in every track above. */
232
+ .roadmap-axis {
233
+ display:flex; align-items:flex-end; gap:.7rem; height:1rem; margin-top:.6rem;
234
+ padding-top:.4rem; border-top:1px solid var(--border);
235
+ font-family:'IBM Plex Mono',monospace; font-size:.68rem; color:var(--ink-dim);
236
+ }
237
+ .roadmap-axis-spacer { flex:0 0 150px; }
238
+ .roadmap-axis-ticks { position:relative; flex:1; min-width:0; height:100%; }
239
+ .roadmap-axis-ticks span { position:absolute; transform:translateX(-50%); }
240
+ .roadmap-axis-unit { flex:0 0 auto; min-width:4.6rem; text-align:right; }
241
+ table { width:100%; border-collapse:collapse; font-size:.85rem; }
242
+ table th, table td { text-align:left; padding:.45rem .6rem; border-bottom:1px solid var(--border); }
243
+ table th { color:var(--ink-dim); font-weight:600; font-size:.76rem; }
244
+ table caption {
245
+ caption-side:top; text-align:left; font-size:.82rem; font-weight:600;
246
+ color:var(--ink-dim); padding:0 0 .6rem;
247
+ }
248
+ tbody tr { transition:background-color .15s ease; }
249
+ tbody tr:hover { background:var(--accent-soft); }
250
+ td.num, th.num { text-align:right; font-family:'IBM Plex Mono',monospace; font-variant-numeric:tabular-nums; }
251
+ .tag {
252
+ font-size:.68rem; font-weight:600; padding:.12rem .4rem; border-radius:.25rem;
253
+ background:var(--border); color:var(--ink-dim);
254
+ }
255
+ .tag.proposed { background:var(--warn-soft); color:var(--warn); }
256
+ .conf { font-weight:600; font-size:.78rem; }
257
+ tr.conf-high .conf { color:var(--ok); }
258
+ tr.conf-med .conf { color:var(--warn); }
259
+ tr.conf-low .conf { color:var(--bad); }
260
+ tr.conf-uncalibrated .conf { color:var(--warn); }
261
+ /* effort-by-container donut: slices are stroked circles (pathLength=100 turns
262
+ stroke-dasharray into percent), legend carries the exact numbers. */
263
+ #containers .pie-wrap { display:flex; flex-wrap:wrap; align-items:center; gap:1.8rem; }
264
+ #containers svg { width:172px; height:172px; flex:0 0 auto; }
265
+ #containers .pie-slice.hot { opacity:.75; }
266
+ #containers .pie-legend { list-style:none; margin:0; padding:0; display:grid; gap:.35rem; flex:1; min-width:230px; align-content:center; }
267
+ #containers .pie-legend li { display:flex; align-items:center; gap:.5rem; font-size:.82rem; }
268
+ .swatch { width:.7rem; height:.7rem; border-radius:.2rem; flex:0 0 auto; }
269
+ #containers .pie-hours { margin-left:auto; }
270
+ #containers .pie-hours, #containers .pie-share {
271
+ font-family:'IBM Plex Mono',monospace; font-size:.76rem; font-variant-numeric:tabular-nums;
272
+ }
273
+ #containers .pie-share { min-width:2.6rem; text-align:right; color:var(--ink-dim); }
274
+ #containers .pie-note { margin:.8rem 0 0; font-size:.76rem; color:var(--ink-dim); }
275
+ #containers .pie-legend li.hot { background:var(--accent-soft); border-radius:.3rem; }
276
+ .bd-scroll { overflow-x:auto; }
277
+ #detail table { min-width:720px; }
278
+ .task-assump { font-size:.76rem; color:var(--ink-dim); }
279
+ #register > div + table, #register > table + table { margin-top:1.4rem; }
280
+ /* compact rail: the team roster, the plan select, the sliders, and the
281
+ readout stack full-width. Keeps the rail near the height of the two
282
+ scenario sections beside it. */
283
+ #controls {
284
+ background:var(--card); border:1px solid var(--border); border-radius:.6rem;
285
+ padding:1.1rem 1.2rem; box-shadow:var(--shadow);
286
+ display:grid; grid-template-columns:1fr; gap:.7rem; align-content:start;
287
+ }
288
+ #controls label { display:flex; flex-direction:column; font-size:.76rem; gap:.3rem; color:var(--ink-dim); }
289
+ /* the roster: one row per engineer (seniority + rate + remove), plus add.
290
+ Styled by class — the container id is internal-only page text and must
291
+ never appear in the head CSS a client render keeps. */
292
+ #controls .team { display:flex; flex-direction:column; gap:.4rem; font-size:.76rem; color:var(--ink-dim); }
293
+ #controls .team-row { display:flex; gap:.4rem; align-items:center; }
294
+ #controls .team-row .cur { margin-right:-.15rem; }
295
+ #controls .team-row select { flex:1; min-width:0; }
296
+ #controls .team-row input { width:4.6rem; }
297
+ #controls .team button { font-size:.76rem; padding:.3rem .5rem; background:var(--bg); color:var(--ink-dim); }
298
+ #controls .team button:disabled { opacity:.4; cursor:default; }
299
+ #controls .lab { display:flex; justify-content:space-between; align-items:baseline; }
300
+ #controls output { font-family:'IBM Plex Mono',monospace; font-size:.74rem; color:var(--ink); }
301
+ #controls input, #controls select {
302
+ font:inherit; padding:.35rem .45rem; border:1px solid var(--border-strong);
303
+ border-radius:.35rem; background:var(--bg); color:var(--ink);
304
+ }
305
+ #controls input:hover, #controls select:hover { border-color:var(--accent); }
306
+ #controls input[type="range"] { padding:0; border:none; background:none; accent-color:var(--accent); }
307
+ .view-client [data\2d internal] { display:none !important; }
308
+ @media print {
309
+ header { position:static; }
310
+ header button, #viewer-link, #controls, #modified-banner, details.help { display:none; }
311
+ main { grid-template-columns:1fr; }
312
+ main > section, .card { box-shadow:none; }
313
+ }
314
+ </style>
315
+ </head>
316
+ <body>
317
+ <header>
318
+ <div class="titles">
319
+ <p class="eyebrow">Project estimate</p>
320
+ <h1><!-- slot:TITLE --></h1>
321
+ <p id="delivery-line" class="eyebrow"></p>
322
+ </div>
323
+ <span id="confidence-badge"></span>
324
+ <button id="theme-toggle" type="button">theme</button>
325
+ <!-- internal:start --><!-- slot:VIEWER --><button id="view-toggle" type="button" data-internal>client view</button><!-- internal:end -->
326
+ </header>
327
+ <p id="modified-banner" role="status" hidden>modified from committed estimate — <button id="reset" type="button">reset</button></p>
328
+ <main>
329
+ <div class="col col-wide">
330
+ <section id="method"></section>
331
+ </div>
332
+ <div class="col">
333
+ <section id="scenario-cards"></section>
334
+ <section id="cost-bars"></section>
335
+ </div>
336
+ <!-- internal:start -->
337
+ <style>
338
+ /* internal-only layout: the what-if rail sits beside the scenario sections
339
+ only — its readout (months, cost, effort) is comparable to nothing below
340
+ the cost bars, so the lower sections take the full width instead of
341
+ reserving an empty rail column. Lives in the internal range so the
342
+ client-only render collapses back to one column. @media screen so the
343
+ print rules in the head keep winning on paper. */
344
+ @media screen {
345
+ main { grid-template-columns:minmax(0, 1fr) 300px; }
346
+ .col-wide { grid-column:1 / -1; }
347
+ /* no hole under the cost bars: the scenario-cards row stretches so the
348
+ left column always ends level with the rail beside it, and the cards
349
+ stay the dominant section. */
350
+ .col:not(.col-wide) { grid-template-rows:1fr auto; }
351
+ .view-client main { grid-template-columns:1fr; }
352
+ }
353
+ @media screen and (max-width:900px) {
354
+ main { grid-template-columns:1fr; }
355
+ }
356
+ </style>
357
+ <aside class="rail" data-internal>
358
+ <div class="sec-head"><h2>What-if</h2><details class="help"><summary aria-label="explain this panel">?</summary>
359
+ <p>The levers re-run the exact same formulas as the committed numbers, in your browser. Nothing here changes the committed estimate — it answers "what would it look like if&hellip;". The readout below updates live.</p></details></div>
360
+ <div id="controls" data-internal>
361
+ <div id="ctl-team" class="team" role="group" aria-label="team"></div>
362
+ <label>claude plan <select id="ctl-plan"><option>none</option><option>max5x</option><option>max20x</option></select></label>
363
+ <label><span class="lab">risk buffer <output></output></span><input id="ctl-buffer" type="range" min="0" max="2" step="0.1"></label>
364
+ <label><span class="lab">overhead % <output></output></span><input id="ctl-overhead" type="range" min="0" max="0.6" step="0.05"></label>
365
+ <div id="whatif-readout" aria-live="polite"></div>
366
+ </div>
367
+ </aside>
368
+ <!-- internal:end -->
369
+ <div class="col col-wide">
370
+ <section id="containers"></section>
371
+ <section id="roadmap"></section>
372
+ <section id="detail"></section>
373
+ <section id="evidence"></section>
374
+ <section id="register"></section>
375
+ </div>
376
+ </main>
377
+ <script type="application/json" id="estimation-data"><!-- slot:DATA --></script>
378
+ <script>
379
+ <!-- slot:MATH -->
380
+ /* boot: parse the data island, stamp the title + confidence badge, then wire
381
+ the sections, what-if controls, and view/theme toggles. */
382
+ const DATA = JSON.parse(document.getElementById('estimation-data').textContent);
383
+ document.querySelector('header h1').textContent = DATA.inputs.project;
384
+ const confLevel = (c) => `conf-${c.toLowerCase()}`;
385
+ const badge = document.getElementById('confidence-badge');
386
+ badge.textContent = DATA.computed.projectConfidence;
387
+ badge.className = `${DATA.computed.projectConfidence.toLowerCase()} ${confLevel(DATA.computed.projectConfidence)}`;
388
+
389
+ // Header line: Delivery mode + agent/model, and how many distinct measured
390
+ // runs back this estimate — the same "baseline count" the deliverable's
391
+ // own header states.
392
+ const evidenceIds = new Set(Object.values(DATA.computed.tasks)
393
+ .flatMap((t) => (t.evidence ?? []).map((e) => e.id)));
394
+ const deliveryLine = document.getElementById('delivery-line');
395
+ if (deliveryLine) {
396
+ deliveryLine.textContent = `Delivery: agentic (${DATA.inputs.agentContext.agent} + `
397
+ + `${DATA.inputs.agentContext.model}) · Baselines: ${evidenceIds.size} measurements`;
398
+ }
399
+
400
+ // Task hours are constants from the estimation data (measured or seeded,
401
+ // never recomputed here) — only team/plan capacity and cost are live via
402
+ // the what-if rail, same as the committed rollup.
403
+ function recompute(p) {
404
+ const dev = DATA.computed.devHours;
405
+ const buffers = (DATA.computed.riskBufferHours + DATA.computed.spreadBufferHours) * p.bufferScale;
406
+ const hours = dev + dev * p.overheadPct + buffers;
407
+ return { hours, ...scenarioRollup({ hours, team: p.team, plan: p.plan }) };
408
+ }
409
+ window.__recompute = recompute;
410
+
411
+ function defaultsFromRecommended() {
412
+ const rec = DATA.inputs.scenarios.find((s) => s.id === DATA.inputs.recommendedScenario);
413
+ return {
414
+ team: rec.team.map((m) => ({ ...m })),
415
+ plan: rec.plan,
416
+ bufferScale: 1,
417
+ overheadPct: DATA.inputs.overheadPct,
418
+ };
419
+ }
420
+
421
+ // Control ids are assembled at runtime (never one static "ctl-*" literal)
422
+ // so the client-only render, which keeps this whole script but drops the
423
+ // controls markup, never carries an internal control id as page text.
424
+ const CTL_SUFFIX = { plan: 'plan', bufferScale: 'buffer', overheadPct: 'overhead' };
425
+ const CTL_KEYS = Object.keys(CTL_SUFFIX);
426
+ const ctlId = (key) => `ctl-${CTL_SUFFIX[key]}`;
427
+ // The roster container is found by its class — its id is internal-only page
428
+ // text, and the class already ships in the head CSS either way.
429
+ const teamBox = () => document.querySelector('#controls .team');
430
+ const TEAM_MAX = 8;
431
+
432
+ function setControls(values) {
433
+ CTL_KEYS.forEach((key) => {
434
+ const el = document.getElementById(ctlId(key));
435
+ if (el) el.value = values[key];
436
+ });
437
+ }
438
+
439
+ function syncOutputs() {
440
+ CTL_KEYS.forEach((key) => {
441
+ const el = document.getElementById(ctlId(key));
442
+ const out = el?.parentElement.querySelector('output');
443
+ if (out) out.textContent = el.value;
444
+ });
445
+ }
446
+
447
+ // The committed scenarios are the page's only rate table: the first rate
448
+ // seen per seniority re-seeds a row's rate when its level changes.
449
+ const RATE_BY_SENIORITY = {};
450
+ for (const s of DATA.inputs.scenarios) {
451
+ for (const m of s.team) if (m.rate != null) RATE_BY_SENIORITY[m.seniority] ??= m.rate;
452
+ }
453
+
454
+ function teamRow({ seniority, rate }) {
455
+ const row = document.createElement('div');
456
+ row.className = 'team-row';
457
+ const sel = document.createElement('select');
458
+ for (const s of Object.keys(SENIORITY_FACTOR)) sel.add(new Option(s, s));
459
+ sel.value = seniority;
460
+ const cur = Object.assign(document.createElement('span'), { className: 'cur', textContent: '$' });
461
+ const rateEl = Object.assign(document.createElement('input'),
462
+ { type: 'number', min: 10, max: 300, step: 5, value: rate });
463
+ rateEl.setAttribute('aria-label', 'hourly rate');
464
+ const del = Object.assign(document.createElement('button'),
465
+ { type: 'button', className: 'team-del', textContent: '×' });
466
+ del.setAttribute('aria-label', 'remove engineer');
467
+ row.append(sel, cur, rateEl, del);
468
+ return row;
469
+ }
470
+
471
+ function syncTeamButtons() {
472
+ const box = teamBox();
473
+ const rows = box.querySelectorAll('.team-row');
474
+ box.querySelector('.team-add').disabled = rows.length >= TEAM_MAX;
475
+ rows.forEach((r) => { r.querySelector('.team-del').disabled = rows.length <= 1; });
476
+ }
477
+
478
+ // Rebuild-from-array is the only write path (boot, reset), so reset can
479
+ // never leave stale rows behind.
480
+ function renderTeam(team) {
481
+ const box = teamBox();
482
+ if (!box) return;
483
+ box.replaceChildren(
484
+ Object.assign(document.createElement('span'), { textContent: 'team' }),
485
+ ...team.map(teamRow),
486
+ Object.assign(document.createElement('button'),
487
+ { type: 'button', className: 'team-add', textContent: '+ engineer' }),
488
+ );
489
+ syncTeamButtons();
490
+ }
491
+
492
+ function currentTeam(defaults) {
493
+ const box = teamBox();
494
+ if (!box) return defaults.team;
495
+ return [...box.querySelectorAll('.team-row')].map((r) => ({
496
+ seniority: r.querySelector('select').value,
497
+ rate: Number(r.querySelector('input').value),
498
+ }));
499
+ }
500
+
501
+ function currentParams(defaults) {
502
+ const p = { team: currentTeam(defaults) };
503
+ CTL_KEYS.forEach((key) => {
504
+ const raw = document.getElementById(ctlId(key))?.value ?? defaults[key];
505
+ p[key] = key === 'plan' ? raw : Number(raw);
506
+ });
507
+ return p;
508
+ }
509
+
510
+ const fmtMoney = (v) => `$${Math.round(v).toLocaleString()}`;
511
+
512
+ const help = (text) => `<details class="help"><summary aria-label="explain this section">?</summary><p>${text}</p></details>`;
513
+ const secHead = (title, text) => `<div class="sec-head"><h2>${title}</h2>${help(text)}</div>`;
514
+
515
+ function barRow({ label, value, max, text, cls }) {
516
+ const pct = max > 0 ? Math.round((value / max) * 100) : 0;
517
+ return `<div class="bar-row"><span class="bar-label" title="${label}">${label}</span>
518
+ <span class="bar-track"><span class="bar-fill${cls ? ` ${cls}` : ''}" style="width:${pct}%"></span></span>
519
+ <span class="bar-val">${text}</span></div>`;
520
+ }
521
+
522
+ function teamSummary(team) {
523
+ const counts = new Map();
524
+ for (const m of team) counts.set(m.seniority, (counts.get(m.seniority) ?? 0) + 1);
525
+ return [...counts].map(([s, n]) => `${n}&times; ${s}`).join(' &middot; ');
526
+ }
527
+
528
+ // Derived in-browser from committed numbers, like every bar width on the
529
+ // page — never written into the JSON.
530
+ function deltaChip(id, s) {
531
+ if (id === DATA.inputs.recommendedScenario) return '';
532
+ const rec = DATA.computed.scenarios[DATA.inputs.recommendedScenario];
533
+ if (!rec) return '';
534
+ const dm = s.months - rec.months;
535
+ const dc = s.totalCost - rec.totalCost;
536
+ return `<span class="delta">${dm >= 0 ? '+' : '-'}${Math.abs(dm).toFixed(2)} mo &middot; `
537
+ + `${dc >= 0 ? '+' : '-'}$${Math.round(Math.abs(dc)).toLocaleString()} vs recommended</span>`;
538
+ }
539
+
540
+ function scenarioCard(id, s) {
541
+ const rec = id === DATA.inputs.recommendedScenario;
542
+ const input = DATA.inputs.scenarios.find((x) => x.id === id);
543
+ const max = Math.max(...Object.values(DATA.computed.scenarios).map((x) => x.months));
544
+ return `<article class="card scenario${rec ? ' recommended' : ''}">
545
+ ${rec ? '<span class="flag">recommended</span>' : ''}<h3>${id}</h3>
546
+ <div class="hero"><div><span class="num">${s.months.toFixed(2)}</span> <span class="unit">months</span></div>
547
+ <div class="gauge"><span style="width:${Math.round((s.months / max) * 100)}%"></span></div>
548
+ ${deltaChip(id, s)}</div>
549
+ <dl class="facts"><div><dt>team</dt><dd>${teamSummary(input.team)}</dd></div>
550
+ <div><dt>claude plan</dt><dd>${input.plan}</dd></div>
551
+ <div><dt>effort</dt><dd>${s.hours.toFixed(1)}h</dd></div>
552
+ <div><dt>total cost</dt><dd>${fmtMoney(s.totalCost)}</dd></div></dl></article>`;
553
+ }
554
+
555
+ function renderCards() {
556
+ const el = document.getElementById('scenario-cards');
557
+ if (!el) return;
558
+ const entries = Object.entries(DATA.computed.scenarios);
559
+ el.innerHTML = secHead('Delivery scenarios',
560
+ 'Each card is one committed way to staff and deliver the same scope. Months and cost are '
561
+ + 'computed from the same task hours; the highlighted card is the recommended estimate. '
562
+ + 'Sandbox variations live in the what-if panel.')
563
+ + `<div class="cards">${entries.map(([id, s]) => scenarioCard(id, s)).join('')}</div>`;
564
+ }
565
+
566
+ function renderBars() {
567
+ const el = document.getElementById('cost-bars');
568
+ if (!el) return;
569
+ const entries = Object.entries(DATA.computed.scenarios);
570
+ const max = Math.max(...entries.map(([, s]) => s.totalCost));
571
+ el.innerHTML = secHead('Total cost by scenario',
572
+ 'Labor (months × team rates) plus Claude plan seats, per scenario. Bar lengths are '
573
+ + 'proportional to the most expensive scenario.')
574
+ + `<div class="bar-group">${entries.map(([id, s]) => barRow({ label: id, value: s.totalCost,
575
+ max, text: fmtMoney(s.totalCost),
576
+ cls: id === DATA.inputs.recommendedScenario ? 'is-rec' : '' })).join('')}</div>`;
577
+ }
578
+
579
+ // Containers and roadmap are generic — they price/visualize hours, never a
580
+ // task category — so they carry over unchanged. The task table and Evidence
581
+ // section below are baseline-native: every column comes from a measured or
582
+ // seeded baseline, never from a category/PERT calc.
583
+ // Two levels max (schema-enforced), so a component's container is one parent
584
+ // hop at most; a top-level id is its own container.
585
+ const COMP_PARENT = Object.fromEntries((DATA.inputs.components ?? []).map((c) => [c.id, c.parent]));
586
+ const containerOf = (id) => COMP_PARENT[id] ?? id;
587
+ // One color per top-level container, shared by the donut and the roadmap
588
+ // segments so a hue means the same container everywhere on the page.
589
+ const CT_COLORS = ['#5a9fd4', '#d97757', '#3ba99f', '#d9b95e', '#9d86c9',
590
+ '#5dbb7a', '#c47a94', '#7c8f9e', '#c98a4b', '#a8a29e'];
591
+ const CT_TOPS = (DATA.inputs.components ?? []).filter((c) => !c.parent).map((c) => c.id);
592
+ const ctColor = (id) => CT_COLORS[CT_TOPS.indexOf(id) % CT_COLORS.length];
593
+ const CT_NAMES = Object.fromEntries((DATA.inputs.components ?? []).map((c) => [c.id, c.name]));
594
+
595
+ // Slice ↔ legend row, both directions: a 2% donut slice is unhoverable-thin
596
+ // for reading, so pointing at it lights the row that names it — and pointing
597
+ // at a legend row lights its slice, so a name finds its arc just as easily.
598
+ function onPieHover(e) {
599
+ const id = e.target.closest?.('[data-ct]')?.dataset.ct;
600
+ const on = e.type === 'mouseover';
601
+ for (const el of document.querySelectorAll('#containers [data-ct]')) {
602
+ el.classList.toggle('hot', on && el.dataset.ct === id);
603
+ }
604
+ }
605
+
606
+ // Ticks are whole months (0, 1, 2…) once the span is long enough for that to
607
+ // read as a timeline; below that a whole-month grid would be a bare "0", so
608
+ // fall back to each band's own start/end. Either way ticks are computed once
609
+ // and shared by every row's gridlines and the axis strip below them — one
610
+ // coordinate system, not a per-row axis.
611
+ function roadmapTicks(total, roadmap) {
612
+ if (total >= 2) {
613
+ const whole = [];
614
+ for (let m = 0; m <= Math.floor(total); m++) whole.push(m);
615
+ return whole;
616
+ }
617
+ return [...new Set(roadmap.flatMap((b) => [b.startMonths, b.endMonths]))].sort((a, b) => a - b);
618
+ }
619
+
620
+ const tickPct = (m, total) => (total > 0 ? (m / total) * 100 : 0);
621
+
622
+ // Milestone names and feature lists are the only free text the roadmap draws, and
623
+ // they now land in an attribute as well as in the body — so both are escaped
624
+ // rather than the quote being left to break out of the title.
625
+ const esc = (s) => String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;');
626
+
627
+ // Inside a band, each top-level container the milestone touches gets a slice
628
+ // of the bar sized by its share of the milestone's hours — several colors is a
629
+ // vertical slice, one color is the horizontal-slice smell. Same palette as the
630
+ // donut. No roster → empty string, and the band keeps its solid accent fill.
631
+ function bandSegments(band) {
632
+ if (!DATA.computed.components) return '';
633
+ const compOf = Object.fromEntries(DATA.inputs.features.map((f) => [f.id, f.component]));
634
+ const names = Object.fromEntries(DATA.inputs.components.map((c) => [c.id, c.name]));
635
+ const hours = {};
636
+ for (const id of band.features) {
637
+ const c = containerOf(compOf[id]);
638
+ hours[c] = (hours[c] ?? 0) + DATA.computed.features[id].hours;
639
+ }
640
+ const sum = Object.values(hours).reduce((a, b) => a + b, 0);
641
+ return Object.entries(hours).map(([c, h]) =>
642
+ `<span class="roadmap-seg" style="width:${((h / sum) * 100).toFixed(2)}%;background:${ctColor(c)}"
643
+ title="${esc(`${names[c] ?? c} · ${h.toFixed(2)}h (${Math.round((h / sum) * 100)}%)`)}"></span>`).join('');
644
+ }
645
+
646
+ // total, names and ticks are one thing — the chart's scale, shared by every row
647
+ // and by the axis beneath them — so they travel together.
648
+ function roadmapRow(band, scale) {
649
+ const { total, names, ticks } = scale;
650
+ const left = (band.startMonths / total) * 100;
651
+ const width = ((band.endMonths - band.startMonths) / total) * 100;
652
+ const gridlines = ticks.map((m) => {
653
+ const pct = tickPct(m, total);
654
+ const style = pct <= 0 ? 'left:0' : pct >= 100 ? 'right:0' : `left:${pct}%`;
655
+ return `<span class="roadmap-gridline" style="${style}"></span>`;
656
+ }).join('');
657
+ // 150px of label column against "M1 - Foundation: the governed write path": every
658
+ // row clips, and a clipped Gantt label names nothing. Widening the column would
659
+ // cost the axis the span it needs, so each label carries its own full text as a
660
+ // hover title instead.
661
+ const feats = band.features.map((id) => names[id]);
662
+ return `<div class="roadmap-row" data-milestone="${esc(band.milestone)}">
663
+ <div class="roadmap-label"><span class="roadmap-name" title="${esc(band.milestone)}">${esc(band.milestone)}</span>
664
+ <span class="roadmap-feature-names" title="${esc(feats.join(' · '))}">${feats.map(esc).join(' &middot; ')}</span></div>
665
+ <div class="roadmap-track">${gridlines}<span class="roadmap-band" style="left:${left}%;width:${width}%">${bandSegments(band)}</span></div>
666
+ <span class="roadmap-months">${band.startMonths}&ndash;${band.endMonths} mo</span></div>`;
667
+ }
668
+
669
+ // The two edge ticks are pinned to the track's own edges instead of centered,
670
+ // so they never overhang the section.
671
+ function roadmapAxis({ total, ticks }) {
672
+ const tick = (m) => {
673
+ const pct = tickPct(m, total);
674
+ const style = pct <= 0 ? 'left:0;transform:none'
675
+ : pct >= 100 ? 'right:0;transform:none' : `left:${pct}%`;
676
+ return `<span style="${style}">${m}</span>`;
677
+ };
678
+ return `<div class="roadmap-axis"><span class="roadmap-axis-spacer"></span>
679
+ <div class="roadmap-axis-ticks">${ticks.map(tick).join('')}</div>
680
+ <span class="roadmap-axis-unit">months</span></div>`;
681
+ }
682
+
683
+ // Committed numbers only: the roadmap draws the recommended scenario as
684
+ // computed — the what-if rail owns every live number on this page.
685
+ function renderRoadmap() {
686
+ const el = document.getElementById('roadmap');
687
+ if (!el) return;
688
+ const roadmap = DATA.computed.scenarios[DATA.inputs.recommendedScenario]?.roadmap;
689
+ if (!roadmap) { el.remove(); return; }
690
+ const total = roadmap[roadmap.length - 1].endMonths;
691
+ const names = Object.fromEntries(DATA.inputs.features.map((f) => [f.id, f.name]));
692
+ const scale = { total, names, ticks: roadmapTicks(total, roadmap) };
693
+ el.innerHTML = secHead('Roadmap',
694
+ 'Sequential delivery by the recommended scenario team. Bands are relative months from '
695
+ + 'kickoff, not calendar dates; each milestone\'s width is its share of the work. Band '
696
+ + 'colors are the containers the milestone touches (same palette as the chart above).')
697
+ + `<div class="roadmap-chart">${roadmap.map((b) => roadmapRow(b, scale)).join('')}`
698
+ + `${roadmapAxis(scale)}</div>`;
699
+ }
700
+
701
+ // Committed numbers only, like every section: expected hours summed per
702
+ // top-level container (computed.components), drawn as a donut. A container
703
+ // the roster excused with notEstimated never becomes a zero-width slice —
704
+ // it keeps the honest words in the note under the chart instead.
705
+ function pieSlice([id, h], ctx) {
706
+ const share = (h / ctx.total) * 100;
707
+ const off = 25 - ctx.acc;
708
+ ctx.acc += share;
709
+ return `<circle class="pie-slice" data-ct="${esc(id)}" cx="21" cy="21" r="15.915" fill="none" pathLength="100"
710
+ stroke="${ctColor(id)}" stroke-width="7" stroke-dasharray="${share.toFixed(2)} ${(100 - share).toFixed(2)}"
711
+ stroke-dashoffset="${off.toFixed(2)}"><title>${esc(`${ctx.names[id] ?? id} · ${h}h (${Math.round(share)}%)`)}</title></circle>`;
712
+ }
713
+
714
+ function pieLegendRow([id, h], ctx) {
715
+ return `<li data-ct="${esc(id)}"><span class="swatch" style="background:${ctColor(id)}"></span>
716
+ <span>${esc(ctx.names[id] ?? id)}</span>
717
+ <span class="pie-hours">${h}h</span> <span class="pie-share">${Math.round((h / ctx.total) * 100)}%</span></li>`;
718
+ }
719
+
720
+ function pieNote() {
721
+ const excused = (DATA.inputs.components ?? []).filter((c) => c.notEstimated);
722
+ if (!excused.length) return '';
723
+ return `<p class="pie-note">Not estimated: ${excused.map((c) =>
724
+ `${esc(c.name)} (${esc(c.notEstimated)})`).join('; ')}. In the architecture, no sized work yet.</p>`;
725
+ }
726
+
727
+ function renderContainers() {
728
+ const el = document.getElementById('containers');
729
+ if (!el) return;
730
+ const comp = DATA.computed.components;
731
+ if (!comp) { el.remove(); return; }
732
+ const names = Object.fromEntries(DATA.inputs.components.map((c) => [c.id, c.name]));
733
+ const entries = Object.entries(comp).filter(([, h]) => h > 0).sort(([, a], [, b]) => b - a);
734
+ const ctx = { names, total: entries.reduce((s, [, h]) => s + h, 0), acc: 0 };
735
+ el.innerHTML = secHead('Effort by container',
736
+ 'Share of expected hours per top-level container, from the same task numbers as the '
737
+ + 'estimation detail below. The colors match the roadmap bands. A container nobody sized '
738
+ + 'is named under the chart, never drawn as a zero slice.')
739
+ + `<div class="pie-wrap"><svg viewBox="0 0 42 42" role="img" aria-label="effort share by container">
740
+ ${entries.map((e) => pieSlice(e, ctx)).join('')}</svg>
741
+ <ul class="pie-legend">${entries.map((e) => pieLegendRow(e, { ...ctx, acc: 0 })).join('')}</ul></div>${pieNote()}`;
742
+ }
743
+
744
+ // Match level: how far the ladder had to climb to find enough history —
745
+ // 1 is the tightest match (same repo + agent + model), 0 means no evidence.
746
+ const MATCH_LABELS = { 0: 'none', 1: 'repo+agent+model', 2: 'agent', 3: 'similar scope', 4: 'global shape' };
747
+
748
+ function taskRow(t, c) {
749
+ return `<tr class="${confLevel(c.confidence)}">
750
+ <td>${esc(t.id)}</td>
751
+ <td class="num">${c.minutes ?? 'not estimated'}</td>
752
+ <td class="num">${c.samples}</td>
753
+ <td>${MATCH_LABELS[c.matchLevel] ?? 'none'}</td>
754
+ <td><span class="conf">${c.confidence}</span></td>
755
+ <td class="task-assump">${esc(t.assumptions.join('; ') || 'none')}</td>
756
+ <td><span class="tag ${t.provenance}">${t.provenance}</span></td></tr>`;
757
+ }
758
+
759
+ // Committed numbers only: every row is a task, baselined from measured
760
+ // history where it exists — never a category or PERT calc.
761
+ function renderDetail() {
762
+ const el = document.getElementById('detail');
763
+ if (!el) return;
764
+ const rows = DATA.inputs.features.flatMap((f) => f.tasks)
765
+ .map((t) => taskRow(t, DATA.computed.tasks[t.id])).join('');
766
+ el.innerHTML = secHead('Estimation detail',
767
+ 'Baseline is the measured median from matched history (Match narrows from same repo + '
768
+ + 'agent + model down to a global shape). UNCALIBRATED means no matching history existed — '
769
+ + 'the number is the interview seed guess, not a measurement.')
770
+ + `<div class="bd-scroll"><table><thead><tr><th>Task</th><th class="num">Baseline (min)</th>
771
+ <th class="num">Samples</th><th>Match</th><th>Confidence</th><th>Assumptions</th><th>src</th>
772
+ </tr></thead><tbody>${rows}</tbody></table></div>`;
773
+ }
774
+
775
+ function renderEvidence() {
776
+ const el = document.getElementById('evidence');
777
+ if (!el) return;
778
+ const rows = Object.entries(DATA.computed.tasks)
779
+ .flatMap(([id, t]) => (t.evidence ?? []).map((e) => `<tr><td>${e.id}</td><td>${e.description ?? '—'}</td><td class="num">${e.minutes}</td><td>${id}</td></tr>`))
780
+ .join('');
781
+ el.innerHTML = `<table><caption>Evidence — measured runs backing the baselines ${help(
782
+ 'Every baseline is the median of these actual past executions. No row here, no number above.')}</caption>
783
+ <thead><tr><th>Id</th><th>Task</th><th class="num">Actual (min)</th><th>Backs</th></tr></thead>
784
+ <tbody>${rows}</tbody></table>`;
785
+ }
786
+
787
+ function renderRegister() {
788
+ const el = document.getElementById('register');
789
+ if (!el) return;
790
+ const riskRows = DATA.inputs.risks.map((r) => `<tr><td>${r.name}</td><td class="num">${Math.round(r.probability * 100)}%</td><td class="num">${r.impactMinutes}min</td></tr>`).join('');
791
+ el.innerHTML = `<table><caption>Risk register ${help(
792
+ 'Each risk adds probability &times; impact minutes to the risk buffer, so unlikely-but-costly '
793
+ + 'events are priced in without padding every task.')}</caption>
794
+ <thead><tr><th>Risk</th><th class="num">Probability</th><th class="num">Impact</th></tr></thead>
795
+ <tbody>${riskRows}</tbody></table>`;
796
+ }
797
+
798
+ // The method's step list is pulled into its own function purely to keep
799
+ // renderMethod under the template's function-length gate — the content is
800
+ // unchanged from a single block.
801
+ function methodSteps() {
802
+ return `<ul>
803
+ <li>Each task is classified by shape and matched against measured past executions,
804
+ narrowing from same repo + agent + model down to a global shape baseline.</li>
805
+ <li>With &ge;5 samples, duration comes from a lognormal fit of the measured
806
+ percentiles: the estimate is the distribution mean (means sum across tasks;
807
+ medians do not), the spread feeds a project-level &radic;&Sigma;&sigma;&sup2; buffer.</li>
808
+ <li>Tasks without history use the interview's seed guess and are labeled
809
+ UNCALIBRATED — never presented as measured.</li>
810
+ <li>Risks are explicit: probability &times; impact minutes, each with a stated
811
+ reason. No blanket contingency exists anywhere on this page.</li>
812
+ <li>Confidence per task comes from sample count and variance; the project badge
813
+ is the worst task confidence on the largest feature.</li>
814
+ </ul>`;
815
+ }
816
+
817
+ // The words are static; every number shown is read from inputs, never derived.
818
+ // Collapsed by default: the title row names the technique, the fold carries
819
+ // the full pipeline and sources for whoever wants them.
820
+ function renderMethod() {
821
+ const el = document.getElementById('method');
822
+ if (!el) return;
823
+ el.innerHTML = `<details class="method-fold" open><summary><h2>Method</h2>
824
+ <span class="tech">measurement-based &middot; ${DATA.inputs.agentContext.agent} + ${DATA.inputs.agentContext.model}</span>
825
+ <span class="chev" aria-hidden="true">&#9656;</span></summary>
826
+ ${methodSteps()}
827
+ <p class="sources"><span>Lognormal task durations and median-vs-mean — Erik Bernhardsson,
828
+ erikbern.com/2019/04/15/why-software-projects-take-longer-than-you-think-a-statistical-model.html.</span>
829
+ <span>Percentile-based cycle-time forecasting — Daniel Vacanti, Actionable Agile Metrics for Predictability.</span>
830
+ <span>Buffer machinery — Atomic Object, atomicobject.com/client-resources/better-custom-software-estimates.</span></p></details>`;
831
+ }
832
+
833
+ // Live feedback at the point of interaction: the sticky rail is usually on
834
+ // screen while the custom card is not, so the rail repeats the custom rollup.
835
+ function renderReadout(custom) {
836
+ const el = document.getElementById('whatif-readout');
837
+ if (!el) return;
838
+ el.innerHTML = Number.isFinite(custom.totalCost)
839
+ ? `<p class="months"><span class="num">${custom.months.toFixed(2)}</span>months</p>
840
+ <dl><div><dt>total cost</dt><dd>${fmtMoney(custom.totalCost)}</dd></div>
841
+ <div><dt>effort</dt><dd>${custom.hours.toFixed(1)}h</dd></div></dl>`
842
+ : '';
843
+ }
844
+
845
+ function renderAll(defaults) {
846
+ renderCards();
847
+ renderBars();
848
+ renderRoadmap();
849
+ renderContainers();
850
+ renderDetail();
851
+ renderEvidence();
852
+ renderRegister();
853
+ renderMethod();
854
+ renderReadout(recompute(currentParams(defaults)));
855
+ }
856
+
857
+ const defaults = defaultsFromRecommended();
858
+
859
+ function applyDefaults() {
860
+ setControls(defaults);
861
+ renderTeam(defaults.team);
862
+ syncOutputs();
863
+ renderAll(defaults);
864
+ }
865
+ applyDefaults();
866
+
867
+ function onWhatIfChange() {
868
+ syncOutputs();
869
+ renderAll(defaults);
870
+ const banner = document.getElementById('modified-banner');
871
+ if (banner) banner.hidden = false;
872
+ }
873
+
874
+ CTL_KEYS.forEach((key) => document.getElementById(ctlId(key))?.addEventListener('input', onWhatIfChange));
875
+ teamBox()?.addEventListener('input', (e) => {
876
+ if (e.target.matches('select')) {
877
+ const rate = RATE_BY_SENIORITY[e.target.value];
878
+ if (rate != null) e.target.closest('.team-row').querySelector('input').value = rate;
879
+ }
880
+ onWhatIfChange();
881
+ });
882
+ teamBox()?.addEventListener('click', (e) => {
883
+ if (e.target.matches('.team-add')) {
884
+ e.target.before(teamRow(currentTeam(defaults).at(-1)));
885
+ } else if (e.target.matches('.team-del')) {
886
+ e.target.closest('.team-row').remove();
887
+ } else return;
888
+ syncTeamButtons();
889
+ onWhatIfChange();
890
+ });
891
+
892
+ document.getElementById('reset')?.addEventListener('click', () => {
893
+ applyDefaults();
894
+ const banner = document.getElementById('modified-banner');
895
+ if (banner) banner.hidden = true;
896
+ });
897
+
898
+ document.getElementById('containers')?.addEventListener('mouseover', onPieHover);
899
+ document.getElementById('containers')?.addEventListener('mouseout', onPieHover);
900
+
901
+ document.getElementById('view-toggle')?.addEventListener('click', () => {
902
+ document.body.classList.toggle('view-client');
903
+ });
904
+
905
+ document.getElementById('theme-toggle')?.addEventListener('click', () => {
906
+ const root = document.documentElement;
907
+ root.dataset.theme = root.dataset.theme === 'dark' ? 'light' : 'dark';
908
+ });
909
+
910
+ // A collapsed <details> prints as its summary line only — force the method
911
+ // fold open on print so the paper copy still explains itself.
912
+ window.addEventListener('beforeprint', () => {
913
+ document.querySelector('#method details.method-fold')?.setAttribute('open', '');
914
+ });
915
+ </script>
916
+ </body>
917
+ </html>