@v11g/agents-rock 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -0
- package/bin/agents-rock.mjs +4 -0
- package/package.json +13 -0
- package/plugins/solution-architect/.claude-plugin/plugin.json +9 -0
- package/plugins/solution-architect/skills/analyze-requirements/README.md +75 -0
- package/plugins/solution-architect/skills/analyze-requirements/SKILL.md +31 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/OFL.txt +98 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-mono-latin-600-normal.woff2 +0 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-500-normal.woff2 +0 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json +52 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/section-help.json +101 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/viewer-template.html +2389 -0
- package/plugins/solution-architect/skills/analyze-requirements/references/interview.md +53 -0
- package/plugins/solution-architect/skills/analyze-requirements/references/likec4.md +157 -0
- package/plugins/solution-architect/skills/analyze-requirements/references/project-types.md +60 -0
- package/plugins/solution-architect/skills/analyze-requirements/references/research.md +78 -0
- package/plugins/solution-architect/skills/analyze-requirements/references/viewer.md +772 -0
- package/plugins/solution-architect/skills/analyze-requirements/references/writing.md +206 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/cdp.mjs +74 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/chrome.mjs +66 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/companion-links.mjs +20 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-kinds.mjs +37 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-links.mjs +26 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-routes.mjs +27 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-sections.mjs +78 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/embed.mjs +8 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/er-entities.mjs +16 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/fonts.mjs +39 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/frontmatter.mjs +17 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/inputs.mjs +41 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-config.mjs +41 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-extract.mjs +29 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-steps.mjs +22 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-defs.mjs +20 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-flows.mjs +46 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-inline.mjs +31 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-links.mjs +7 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-list.mjs +64 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-render.mjs +127 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-shape.mjs +19 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-tables.mjs +30 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-views.mjs +48 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-wide.mjs +44 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/nav.mjs +72 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/offline.mjs +19 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/port.mjs +13 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/quality-gate.mjs +113 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/section-help.mjs +49 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/slug-registry.mjs +11 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-clusters.mjs +15 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-deployment.mjs +8 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-elections.mjs +20 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-links.mjs +23 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-model-tables.mjs +24 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-palette.mjs +34 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-provenance.mjs +20 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-tree.mjs +16 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-config.mjs +19 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-export.mjs +35 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-gen.mjs +39 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs +130 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/serve.mjs +71 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/browser.test.mjs +553 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/companion-links.test.mjs +60 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-kinds.test.mjs +41 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-links.test.mjs +104 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-routes.test.mjs +54 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-sections.test.mjs +197 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/embed.test.mjs +28 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/er-entities.test.mjs +14 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/ARCHITECTURE.md +47 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/c4-src/broken/model.c4 +27 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/c4-src/pass/model.c4 +29 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/adr/0001-sample.md +18 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/estimate.html +2 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/estimation.md +8 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/model-broken.json +1 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/model.json +1 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/threat-model.md +8 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/sample-model.json +1 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/sample.c4 +28 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fonts.test.mjs +38 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/frontmatter.test.mjs +27 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/inputs.test.mjs +72 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-config-cli.test.mjs +26 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-config.test.mjs +74 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-export-cli.test.mjs +61 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-extract.test.mjs +37 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-gen-cli.test.mjs +73 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-steps.test.mjs +32 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-flows.test.mjs +82 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-links.test.mjs +16 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-provenance.test.mjs +42 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-render.test.mjs +226 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-tables.test.mjs +30 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-views.test.mjs +76 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-wide.test.mjs +76 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/nav.test.mjs +236 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/offline.test.mjs +37 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/quality-gate.test.mjs +86 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/quality-gates.test.mjs +20 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/render.test.mjs +171 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/research-workflow.test.mjs +38 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/section-help.test.mjs +101 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/serve.test.mjs +48 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-clusters.test.mjs +46 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-deployment.test.mjs +23 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-elections.test.mjs +30 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-links.test.mjs +38 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-model-tables.test.mjs +51 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-provenance.test.mjs +28 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-tree.test.mjs +43 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/viewer-template.test.mjs +1206 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/validate.mjs +88 -0
- package/plugins/solution-architect/skills/analyze-requirements/workflows/research.js +57 -0
- package/plugins/solution-architect/skills/estimate/README.md +67 -0
- package/plugins/solution-architect/skills/estimate/SKILL.md +64 -0
- package/plugins/solution-architect/skills/estimate/assets/estimate-template.html +1128 -0
- package/plugins/solution-architect/skills/estimate/references/ai-multipliers.md +95 -0
- package/plugins/solution-architect/skills/estimate/references/interview.md +80 -0
- package/plugins/solution-architect/skills/estimate/references/slicing.md +55 -0
- package/plugins/solution-architect/skills/estimate/references/techniques.md +111 -0
- package/plugins/solution-architect/skills/estimate/references/writing.md +211 -0
- package/plugins/solution-architect/skills/estimate/scripts/compute.mjs +23 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/checks.mjs +128 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/components.mjs +19 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/estimate-math.mjs +85 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/inline.mjs +10 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/redact.mjs +30 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/roadmap.mjs +32 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/rollup.mjs +122 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/schema.mjs +128 -0
- package/plugins/solution-architect/skills/estimate/scripts/render.mjs +65 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/browser.test.mjs +623 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/compute.test.mjs +88 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/e2e.test.mjs +34 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/estimate-math.test.mjs +112 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/booking-inputs.json +58 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-fail.md +30 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-pass.md +60 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/quality-gates.test.mjs +20 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/references.test.mjs +71 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/render.test.mjs +121 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/schema.test.mjs +129 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/validate.test.mjs +72 -0
- package/plugins/solution-architect/skills/estimate/scripts/validate.mjs +20 -0
- package/plugins/solution-architect/skills/new-lead/README.md +48 -0
- package/plugins/solution-architect/skills/new-lead/SKILL.md +113 -0
- package/plugins/solution-architect/skills/new-lead/assets/dashboard/detail.html +842 -0
- package/plugins/solution-architect/skills/new-lead/assets/dashboard/index.html +655 -0
- package/plugins/solution-architect/skills/new-lead/assets/dashboard/start.sh +3 -0
- package/plugins/solution-architect/skills/new-lead/assets/dashboard/stats.mjs +98 -0
- package/plugins/solution-architect/skills/new-lead/assets/dashboard/vendor/reactflow-bundle.js +473 -0
- package/plugins/solution-architect/skills/new-lead/assets/vendor-build/entry.jsx +33 -0
- package/plugins/solution-architect/skills/new-lead/assets/vendor-build/package-lock.json +1055 -0
- package/plugins/solution-architect/skills/new-lead/assets/vendor-build/package.json +19 -0
- package/plugins/solution-architect/skills/new-lead/scripts/init-root.mjs +73 -0
- package/plugins/solution-architect/skills/new-lead/scripts/lead-upsert.mjs +31 -0
- package/plugins/solution-architect/skills/new-lead/scripts/lib/enrich.mjs +20 -0
- package/plugins/solution-architect/skills/new-lead/scripts/lib/map-nodes.mjs +124 -0
- package/plugins/solution-architect/skills/new-lead/scripts/lib/map.mjs +117 -0
- package/plugins/solution-architect/skills/new-lead/scripts/lib/port.mjs +15 -0
- package/plugins/solution-architect/skills/new-lead/scripts/lib/registry.mjs +116 -0
- package/plugins/solution-architect/skills/new-lead/scripts/serve.mjs +163 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/e2e-workspace.test.mjs +59 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/enrich.test.mjs +16 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/ARCHITECTURE.md +16 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/brief.md +4 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/index.html +11 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/proposal-non-tech.html +2 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/threat-model.html +2 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/estimation-inputs.json +6 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/estimation.json +10 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/notes.md +3 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/proposal-non-tech.md +3 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/rfp.md +3 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads.json +25 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/init-root.test.mjs +81 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/lead-upsert.test.mjs +67 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/map.test.mjs +72 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/port.test.mjs +31 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/registry-io.test.mjs +57 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/registry.test.mjs +49 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/serve.test.mjs +205 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/stats.test.mjs +92 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/validate-cli.test.mjs +24 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/vendor-bundle.test.mjs +9 -0
- package/plugins/solution-architect/skills/new-lead/scripts/validate.mjs +9 -0
- package/plugins/solution-architect/skills/proposal/README.md +36 -0
- package/plugins/solution-architect/skills/proposal/SKILL.md +58 -0
- package/plugins/solution-architect/skills/proposal/assets/proposal-template.html +82 -0
- package/plugins/solution-architect/skills/proposal/references/interview.md +63 -0
- package/plugins/solution-architect/skills/proposal/references/review.md +28 -0
- package/plugins/solution-architect/skills/proposal/references/writing.md +102 -0
- package/plugins/solution-architect/skills/proposal/scripts/derive.mjs +22 -0
- package/plugins/solution-architect/skills/proposal/scripts/lib/checks-client.mjs +75 -0
- package/plugins/solution-architect/skills/proposal/scripts/lib/checks-doc.mjs +54 -0
- package/plugins/solution-architect/skills/proposal/scripts/lib/checks.mjs +17 -0
- package/plugins/solution-architect/skills/proposal/scripts/lib/figures.mjs +43 -0
- package/plugins/solution-architect/skills/proposal/scripts/lib/jargon.mjs +9 -0
- package/plugins/solution-architect/skills/proposal/scripts/lib/sections.mjs +32 -0
- package/plugins/solution-architect/skills/proposal/scripts/render.mjs +60 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/checks-client.test.mjs +144 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/checks-doc.test.mjs +93 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/docs.test.mjs +51 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/e2e.test.mjs +30 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/figures.test.mjs +81 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-fail.md +22 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-pass.md +55 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/quality-gates.test.mjs +20 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/render.test.mjs +70 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/validate.test.mjs +40 -0
- package/plugins/solution-architect/skills/proposal/scripts/validate.mjs +20 -0
- package/src/cli/agents.mjs +12 -0
- package/src/cli/args.mjs +46 -0
- package/src/cli/install.mjs +68 -0
- package/src/cli/main.mjs +124 -0
- package/src/cli/picker.mjs +78 -0
- package/src/cli/registry.mjs +26 -0
- package/src/cli/uninstall.mjs +38 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// Deliverable gate: the estimation.md a human reads must actually reflect the
|
|
2
|
+
// estimation.json a machine computed. Rules 1-4/9 check structure, 5-6 check
|
|
3
|
+
// table rows, 7-8 cross-check the JSON against a fresh recompute.
|
|
4
|
+
import { computeEstimation } from './rollup.mjs';
|
|
5
|
+
|
|
6
|
+
const PROVENANCE = ['observed', 'stated', 'researched', 'proposed'];
|
|
7
|
+
const CONFIDENCE = ['HIGH', 'MED', 'LOW'];
|
|
8
|
+
|
|
9
|
+
// Returns the text of the section/subsection starting at heading `name`, up
|
|
10
|
+
// to (not including) the next heading of the same or shallower level.
|
|
11
|
+
function heading(md, name) {
|
|
12
|
+
const m = new RegExp(`^(#{2,4})\\s*${name}\\b.*$`, 'm').exec(md);
|
|
13
|
+
if (!m) return null;
|
|
14
|
+
const rest = md.slice(m.index + m[0].length);
|
|
15
|
+
const next = rest.search(new RegExp(`^#{1,${m[1].length}}\\s`, 'm'));
|
|
16
|
+
return rest.slice(0, next === -1 ? undefined : next);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function cells(line) {
|
|
20
|
+
return line.trim().replace(/^\|/, '').replace(/\|$/, '').split('|').map((c) => c.trim());
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Groups contiguous `| ... |` lines into tables, dropping the `| --- |`
|
|
24
|
+
// separator row, and returns each as { header, rows } of trimmed cells.
|
|
25
|
+
function tables(text) {
|
|
26
|
+
const groups = [];
|
|
27
|
+
let cur = [];
|
|
28
|
+
for (const line of (text ?? '').split('\n')) {
|
|
29
|
+
if (/^\s*\|/.test(line)) cur.push(line);
|
|
30
|
+
else if (cur.length) { groups.push(cur); cur = []; }
|
|
31
|
+
}
|
|
32
|
+
if (cur.length) groups.push(cur);
|
|
33
|
+
return groups
|
|
34
|
+
.map((g) => g.filter((l) => !/^\s*\|?[\s:|-]+\|?\s*$/.test(l)))
|
|
35
|
+
.map((g) => ({ header: cells(g[0]), rows: g.slice(1).map(cells) }));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function checkStructure(md) {
|
|
39
|
+
const out = [];
|
|
40
|
+
const summary = heading(md, 'Summary');
|
|
41
|
+
const detail = heading(md, 'Estimation detail');
|
|
42
|
+
if (summary === null) out.push('missing ## Summary section');
|
|
43
|
+
if (detail === null) out.push('missing ## Estimation detail section');
|
|
44
|
+
if (!/^###?\s*Out of scope\b/im.test(summary ?? '')) out.push('Out of scope heading missing from Summary');
|
|
45
|
+
const assumptionRows = tables(heading(md, 'Assumptions')).flatMap((t) => t.rows);
|
|
46
|
+
if (assumptionRows.length < 1) out.push('assumptions register is empty (### Assumptions needs >= 1 row)');
|
|
47
|
+
if (!/\|.*buffer.*\|/i.test(summary ?? '')) out.push('no buffer line item found in Summary (/buffer/i)');
|
|
48
|
+
const scenarioTable = tables(detail ?? '').find((t) => t.header.includes('Scenario'));
|
|
49
|
+
if (!scenarioTable || scenarioTable.rows.length < 2) out.push('scenario comparison table missing or has fewer than 2 rows');
|
|
50
|
+
if (!/calibration/i.test(detail ?? '')) out.push('no calibration line found in Estimation detail');
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Rule 5: the task table, found by its header (not position), row-checked
|
|
55
|
+
// for provenance, confidence, non-blank assumptions, and no bare 0.
|
|
56
|
+
function checkTaskRows(detail, out) {
|
|
57
|
+
const table = tables(detail).find((t) => ['Task', 'Confidence', 'Assumptions', 'src'].every((h) => t.header.includes(h)));
|
|
58
|
+
if (!table) { out.push('task table not found by header (need Task, Confidence, Assumptions, src)'); return; }
|
|
59
|
+
const srcIdx = table.header.indexOf('src');
|
|
60
|
+
const confIdx = table.header.indexOf('Confidence');
|
|
61
|
+
const assumeIdx = table.header.indexOf('Assumptions');
|
|
62
|
+
for (const row of table.rows) {
|
|
63
|
+
if (row.some((c) => c === '0')) out.push(`task row "${row[0]}": estimate cell is never 0 (use "not estimated")`);
|
|
64
|
+
if (!PROVENANCE.includes(row[srcIdx])) out.push(`task row "${row[0]}": src cell must be one of ${PROVENANCE.join('|')}`);
|
|
65
|
+
if (!CONFIDENCE.includes(row[confIdx])) out.push(`task row "${row[0]}": confidence cell must be HIGH|MED|LOW`);
|
|
66
|
+
if (!row[assumeIdx]) out.push(`task row "${row[0]}": assumptions cell must be non-empty (use literal "none")`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Rule 6: the Summary's feature/tier table — the only Summary table with a
|
|
71
|
+
// src column — every scope row's src must be stated|proposed.
|
|
72
|
+
function checkScopeRows(summary, out) {
|
|
73
|
+
const table = tables(summary).find((t) => t.header.includes('src') && !t.header.includes('Task'));
|
|
74
|
+
if (!table) { out.push('summary scope table missing'); return; }
|
|
75
|
+
const idx = table.header.indexOf('src');
|
|
76
|
+
for (const row of table.rows) {
|
|
77
|
+
if (!['stated', 'proposed'].includes(row[idx])) out.push(`scope row "${row[0]}": src must be stated|proposed`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Roadmap presence must match the inputs: a roadmap nobody asked for is
|
|
82
|
+
// invented scope, milestones without a roadmap is a silently dropped
|
|
83
|
+
// deliverable. The prose line keeps the bands honest — relative, not dated.
|
|
84
|
+
function checkRoadmap(md, estimation, out) {
|
|
85
|
+
const hasMilestones = (estimation.inputs.features ?? []).some((f) => f.milestone);
|
|
86
|
+
const section = heading(md, 'Roadmap');
|
|
87
|
+
if (!hasMilestones) {
|
|
88
|
+
if (section !== null) out.push('### Roadmap present but inputs carry no milestones');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (section === null) { out.push('missing ### Roadmap section (inputs carry milestones)'); return; }
|
|
92
|
+
if (tables(section).flatMap((t) => t.rows).length < 1) out.push('roadmap table is empty');
|
|
93
|
+
if (!/not calendar dates/i.test(section)) {
|
|
94
|
+
out.push('roadmap must state bands are relative months, not calendar dates');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function checkRows(md) {
|
|
99
|
+
const out = [];
|
|
100
|
+
checkTaskRows(heading(md, 'Estimation detail') ?? '', out);
|
|
101
|
+
checkScopeRows(heading(md, 'Summary') ?? '', out);
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Rules 7-8: the JSON side. A fresh recompute from the same inputs must
|
|
106
|
+
// deep-equal the stored computed block (catches hand-edits), and every
|
|
107
|
+
// feature's low/hours/high must be strictly ordered (or all equal, for the
|
|
108
|
+
// degenerate zero-spread case).
|
|
109
|
+
function checkNumbers(estimation) {
|
|
110
|
+
const out = [];
|
|
111
|
+
const recomputed = computeEstimation(estimation.inputs).computed;
|
|
112
|
+
if (JSON.stringify(recomputed) !== JSON.stringify(estimation.computed)) {
|
|
113
|
+
out.push('computed block does not match recomputed totals (hand-edited JSON?)');
|
|
114
|
+
}
|
|
115
|
+
for (const [id, f] of Object.entries(estimation.computed.features)) {
|
|
116
|
+
const zeroSpread = f.low === f.hours && f.hours === f.high && f.hours > 0;
|
|
117
|
+
if (!zeroSpread && !(f.low < f.hours && f.hours < f.high)) {
|
|
118
|
+
out.push(`feature ${id}: expected low < hours < high (got ${f.low}, ${f.hours}, ${f.high})`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function checkDeliverables({ md, estimation }) {
|
|
125
|
+
const out = [...checkStructure(md), ...checkRows(md), ...checkNumbers(estimation)];
|
|
126
|
+
checkRoadmap(md, estimation, out);
|
|
127
|
+
return out;
|
|
128
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Feature → container aggregation for the effort-by-container rollup. Sums
|
|
2
|
+
// each feature's expected hours into its component's top-level ancestor
|
|
3
|
+
// (two levels max, enforced by schema.mjs, so the ancestor is one parent hop).
|
|
4
|
+
// Returns undefined when inputs carry no roster — like the roadmap, absence
|
|
5
|
+
// must stay a missing key, not an empty map. Sums the displayed (rounded)
|
|
6
|
+
// per-feature hours so this table always agrees with the breakdown table.
|
|
7
|
+
export function componentHoursFor(inputs, featureHours) {
|
|
8
|
+
if (!inputs.components) return undefined;
|
|
9
|
+
const round2 = (n) => Math.round(n * 100) / 100;
|
|
10
|
+
const parentOf = Object.fromEntries(inputs.components.map((c) => [c.id, c.parent]));
|
|
11
|
+
const hours = {};
|
|
12
|
+
for (const c of inputs.components) if (!c.parent) hours[c.id] = 0;
|
|
13
|
+
for (const f of inputs.features) {
|
|
14
|
+
hours[parentOf[f.component] ?? f.component] += featureHours[f.id].hours;
|
|
15
|
+
}
|
|
16
|
+
return Object.fromEntries(Object.entries(hours)
|
|
17
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
18
|
+
.map(([id, h]) => [id, round2(h)]));
|
|
19
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Every formula the estimate ships — imported by compute.mjs at build time and
|
|
2
|
+
// inlined verbatim into estimate-template.html at render time, so the browser's
|
|
3
|
+
// what-if math and the committed numbers cannot drift apart.
|
|
4
|
+
|
|
5
|
+
export const AI_CATEGORIES = {
|
|
6
|
+
boilerplate: { min: 0.5, max: 0.8 },
|
|
7
|
+
logic: { min: 0.2, max: 0.4 },
|
|
8
|
+
novel: { min: 0.0, max: 0.1 },
|
|
9
|
+
};
|
|
10
|
+
export const SENIORITY_FACTOR = { junior: 1.15, mid: 1.0, senior: 0.85 };
|
|
11
|
+
export const HOURS_PER_MONTH = 140;
|
|
12
|
+
export const COORDINATION_TAX = 0.10;
|
|
13
|
+
export const PLAN_PRICES = { none: 0, max5x: 100, max20x: 200 };
|
|
14
|
+
export const TIER_BREAKS = [
|
|
15
|
+
{ max: 10, tier: 'S' }, { max: 17, tier: 'M' }, { max: Infinity, tier: 'L' },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
export function pert({ o, m, p }) {
|
|
19
|
+
return { e: (o + 4 * m + p) / 6, sigma: (p - o) / 6 };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function projectBuffer(sigmas) {
|
|
23
|
+
return Math.sqrt(sigmas.reduce((sum, s) => sum + s * s, 0));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function tierFor(scores) {
|
|
27
|
+
const total = Object.values(scores).reduce((a, b) => a + b, 0);
|
|
28
|
+
return { total, tier: TIER_BREAKS.find((b) => total <= b.max).tier };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const clampRed = (r) => Math.min(Math.max(r, 0), 0.9);
|
|
32
|
+
|
|
33
|
+
export function aiAdjust({ e, category, verificationPct, scale = 1 }) {
|
|
34
|
+
const { min, max } = AI_CATEGORIES[category];
|
|
35
|
+
const red = clampRed(((min + max) / 2) * scale);
|
|
36
|
+
const redMax = clampRed(max * scale);
|
|
37
|
+
const [tr, ar, ao] = [e, e * (1 - red), e * (1 - redMax)];
|
|
38
|
+
return ((ao + 2 * ar + tr) / 4) * (1 + verificationPct);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Seniority scales the base effort on every path; the AI reduction is a
|
|
42
|
+
// property of the task category alone. Scaling the reduction by seniority
|
|
43
|
+
// instead made juniors come out faster than seniors on AI plans.
|
|
44
|
+
export function taskHours({ e, seniority, plan, category, verificationPct, scale = 1 }) {
|
|
45
|
+
const base = e * SENIORITY_FACTOR[seniority];
|
|
46
|
+
return plan === 'none' ? base : aiAdjust({ e: base, category, verificationPct, scale });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// One seniority drives effort for a whole team: the most common level wins,
|
|
50
|
+
// ties go to the more senior. Rank comes from the factor values themselves
|
|
51
|
+
// (more senior = lower factor), never from key order. Lives here (not
|
|
52
|
+
// rollup.mjs) so the inlined bundle hands the page the same function the
|
|
53
|
+
// committed rollup uses.
|
|
54
|
+
export const dominantSeniority = (team) => Object.keys(SENIORITY_FACTOR)
|
|
55
|
+
.sort((a, b) => SENIORITY_FACTOR[a] - SENIORITY_FACTOR[b])
|
|
56
|
+
.map((level) => [level, team.filter((m) => m.seniority === level).length])
|
|
57
|
+
.reduce((best, cur) => (cur[1] > best[1] ? cur : best))[0];
|
|
58
|
+
|
|
59
|
+
export function riskBufferHours(risks) {
|
|
60
|
+
return risks.reduce((sum, r) => sum + r.probability * r.impactHours, 0);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function effectiveCapacity(engineers) {
|
|
64
|
+
return Math.max(1, engineers * (1 - COORDINATION_TAX * (engineers - 1)));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function scenarioRollup({ hours, team, plan }) {
|
|
68
|
+
const months = hours / (effectiveCapacity(team.length) * HOURS_PER_MONTH);
|
|
69
|
+
const laborCost = months * team.reduce((sum, t) => sum + t.rate * HOURS_PER_MONTH, 0);
|
|
70
|
+
const planCost = months * PLAN_PRICES[plan] * team.length;
|
|
71
|
+
return { months, laborCost, planCost, totalCost: laborCost + planCost };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Sequential roadmap: each milestone's band width is its share of total task
|
|
75
|
+
// hours × scenario months, so bands tile [0, months] and buffers/overhead
|
|
76
|
+
// spread proportionally instead of piling up at the end.
|
|
77
|
+
export function roadmapBands({ milestones, months }) {
|
|
78
|
+
const total = milestones.reduce((sum, m) => sum + m.hours, 0);
|
|
79
|
+
let at = 0;
|
|
80
|
+
return milestones.map((m) => {
|
|
81
|
+
const startMonths = at;
|
|
82
|
+
at += total > 0 ? (m.hours / total) * months : 0;
|
|
83
|
+
return { name: m.name, startMonths, endMonths: at };
|
|
84
|
+
});
|
|
85
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// The math module is written once as ESM and shipped twice: imported by
|
|
2
|
+
// compute.mjs, and inlined here as a plain script so the page's what-if
|
|
3
|
+
// controls run the very same formulas the committed numbers came from.
|
|
4
|
+
export function inlineModule(src) {
|
|
5
|
+
return src.replaceAll(/^export /gm, '');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function stripInternal(html) {
|
|
9
|
+
return html.replaceAll(/<!-- internal:start -->[\s\S]*?<!-- internal:end -->/g, '');
|
|
10
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// The --client-only export embeds the full estimation JSON in the page; this
|
|
2
|
+
// strips the internal money detail (rates, labor/plan cost split, per-task
|
|
3
|
+
// hours per scenario) before it ships, unless the inputs opt out via
|
|
4
|
+
// exposeRatesToClient. Assumptions/risks are left alone — those are
|
|
5
|
+
// client-facing per spec.
|
|
6
|
+
function redactScenarioTeam(team) {
|
|
7
|
+
return team.map(({ rate, ...rest }) => rest);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function redactComputedScenarios(scenarios) {
|
|
11
|
+
return Object.fromEntries(Object.entries(scenarios).map(([id, s]) => {
|
|
12
|
+
const { laborCost, planCost, taskHours, ...rest } = s;
|
|
13
|
+
return [id, rest];
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function redactForClient(estimation) {
|
|
18
|
+
if (estimation.inputs.exposeRatesToClient) return estimation;
|
|
19
|
+
return {
|
|
20
|
+
...estimation,
|
|
21
|
+
inputs: {
|
|
22
|
+
...estimation.inputs,
|
|
23
|
+
scenarios: estimation.inputs.scenarios.map((s) => ({ ...s, team: redactScenarioTeam(s.team) })),
|
|
24
|
+
},
|
|
25
|
+
computed: {
|
|
26
|
+
...estimation.computed,
|
|
27
|
+
scenarios: redactComputedScenarios(estimation.computed.scenarios),
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Feature → milestone aggregation for the roadmap. Groups features by their
|
|
2
|
+
// milestone label (order of first appearance = delivery order), sums each
|
|
3
|
+
// group's scenario task hours, and lets roadmapBands turn shares into bands.
|
|
4
|
+
// Returns undefined when no feature carries a milestone — the roadmap is
|
|
5
|
+
// optional and its absence must stay a missing key, not an empty array.
|
|
6
|
+
import { roadmapBands } from './estimate-math.mjs';
|
|
7
|
+
|
|
8
|
+
function milestonesFrom(features, taskHours) {
|
|
9
|
+
const order = [];
|
|
10
|
+
const byName = {};
|
|
11
|
+
for (const f of features) {
|
|
12
|
+
if (!f.milestone) return null;
|
|
13
|
+
if (!byName[f.milestone]) {
|
|
14
|
+
byName[f.milestone] = { name: f.milestone, features: [], hours: 0 };
|
|
15
|
+
order.push(f.milestone);
|
|
16
|
+
}
|
|
17
|
+
byName[f.milestone].features.push(f.id);
|
|
18
|
+
byName[f.milestone].hours += f.tasks.reduce((sum, t) => sum + taskHours[t.id], 0);
|
|
19
|
+
}
|
|
20
|
+
return order.map((name) => byName[name]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function roadmapFor({ features, taskHours, months }) {
|
|
24
|
+
const milestones = milestonesFrom(features, taskHours);
|
|
25
|
+
if (!milestones) return undefined;
|
|
26
|
+
return roadmapBands({ milestones, months }).map((band, i) => ({
|
|
27
|
+
milestone: band.name,
|
|
28
|
+
features: milestones[i].features,
|
|
29
|
+
startMonths: band.startMonths,
|
|
30
|
+
endMonths: band.endMonths,
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// Turns validated estimation-inputs into the estimation.json truth: PERT per
|
|
2
|
+
// task, AI-adjusted hours per (task × scenario), buffers, and cost rollups.
|
|
3
|
+
// Every map is assembled with sorted keys so repeat runs are byte-identical.
|
|
4
|
+
import {
|
|
5
|
+
pert, projectBuffer, taskHours, riskBufferHours, scenarioRollup, dominantSeniority,
|
|
6
|
+
} from './estimate-math.mjs';
|
|
7
|
+
import { roadmapFor } from './roadmap.mjs';
|
|
8
|
+
import { componentHoursFor } from './components.mjs';
|
|
9
|
+
|
|
10
|
+
function sortedMap(entries) {
|
|
11
|
+
return Object.fromEntries(entries.sort(([a], [b]) => a.localeCompare(b)));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function round2(n) {
|
|
15
|
+
return Math.round(n * 100) / 100;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function taskHoursFor(scenario, tasks) {
|
|
19
|
+
const seniority = dominantSeniority(scenario.team);
|
|
20
|
+
const entries = Object.keys(tasks).map((id) => [
|
|
21
|
+
id,
|
|
22
|
+
taskHours({
|
|
23
|
+
e: tasks[id].e, seniority, plan: scenario.plan,
|
|
24
|
+
category: tasks[id].category, verificationPct: tasks[id].verificationPct,
|
|
25
|
+
}),
|
|
26
|
+
]);
|
|
27
|
+
return sortedMap(entries);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function scenarioBlock(scenario, ctx) {
|
|
31
|
+
const taskHours = taskHoursFor(scenario, ctx.tasks);
|
|
32
|
+
const sumTaskHours = Object.values(taskHours).reduce((a, b) => a + b, 0);
|
|
33
|
+
const hours = sumTaskHours + sumTaskHours * ctx.overheadPct + ctx.spreadBufferHours + ctx.riskBufferHours;
|
|
34
|
+
const rollup = scenarioRollup({ hours, team: scenario.team, plan: scenario.plan });
|
|
35
|
+
const roadmap = roadmapFor({ features: ctx.features, taskHours, months: rollup.months })
|
|
36
|
+
?.map((b) => ({ ...b, startMonths: round2(b.startMonths), endMonths: round2(b.endMonths) }));
|
|
37
|
+
const notes = [];
|
|
38
|
+
if (scenario.team.length === 1) notes.push('bus factor: single engineer');
|
|
39
|
+
if (scenario.team.length > 3) notes.push('coordination overhead grows past 3 engineers');
|
|
40
|
+
return {
|
|
41
|
+
taskHours: sortedMap(Object.entries(taskHours).map(([id, h]) => [id, round2(h)])),
|
|
42
|
+
hours: round2(hours),
|
|
43
|
+
months: round2(rollup.months),
|
|
44
|
+
laborCost: round2(rollup.laborCost),
|
|
45
|
+
planCost: round2(rollup.planCost),
|
|
46
|
+
totalCost: round2(rollup.totalCost),
|
|
47
|
+
notes,
|
|
48
|
+
...(roadmap ? { roadmap } : {}),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const CONFIDENCE_RANK = { HIGH: 0, MED: 1, LOW: 2 };
|
|
53
|
+
|
|
54
|
+
export function criticalConfidence(features, tasks) {
|
|
55
|
+
let critical = null;
|
|
56
|
+
for (const feature of features) {
|
|
57
|
+
if (!critical || feature.hours > critical.hours) critical = feature;
|
|
58
|
+
}
|
|
59
|
+
let worst = 'HIGH';
|
|
60
|
+
for (const taskId of critical.taskIds) {
|
|
61
|
+
const confidence = tasks[taskId].confidence;
|
|
62
|
+
if (CONFIDENCE_RANK[confidence] > CONFIDENCE_RANK[worst]) worst = confidence;
|
|
63
|
+
}
|
|
64
|
+
return worst;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function buildTasks(inputs) {
|
|
68
|
+
const tasks = {};
|
|
69
|
+
for (const feature of inputs.features) {
|
|
70
|
+
for (const task of feature.tasks) {
|
|
71
|
+
const { e, sigma } = pert(task);
|
|
72
|
+
tasks[task.id] = {
|
|
73
|
+
e, sigma, o: task.o, p: task.p, category: task.category,
|
|
74
|
+
confidence: task.confidence, verificationPct: inputs.verificationPct,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return tasks;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function buildFeatures(inputs, tasks) {
|
|
82
|
+
const features = {};
|
|
83
|
+
const summaries = [];
|
|
84
|
+
for (const feature of inputs.features) {
|
|
85
|
+
const taskIds = feature.tasks.map((t) => t.id);
|
|
86
|
+
const hours = taskIds.reduce((sum, id) => sum + tasks[id].e, 0);
|
|
87
|
+
const low = feature.tasks.reduce((sum, t) => sum + t.o, 0);
|
|
88
|
+
const high = feature.tasks.reduce((sum, t) => sum + t.p, 0);
|
|
89
|
+
features[feature.id] = { hours: round2(hours), low: round2(low), high: round2(high) };
|
|
90
|
+
summaries.push({ hours, taskIds });
|
|
91
|
+
}
|
|
92
|
+
return { features: sortedMap(Object.entries(features)), summaries };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function globalBuffers(tasks, risks) {
|
|
96
|
+
const devHours = Object.values(tasks).reduce((sum, t) => sum + t.e, 0);
|
|
97
|
+
const spreadBufferHours = projectBuffer(Object.values(tasks).map((t) => t.sigma));
|
|
98
|
+
return { devHours, spreadBufferHours, riskBufferHours: riskBufferHours(risks) };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function computeEstimation(inputs) {
|
|
102
|
+
const tasks = buildTasks(inputs);
|
|
103
|
+
const { features, summaries } = buildFeatures(inputs, tasks);
|
|
104
|
+
const buffers = globalBuffers(tasks, inputs.risks);
|
|
105
|
+
const ctx = { tasks, features: inputs.features, overheadPct: inputs.overheadPct, ...buffers };
|
|
106
|
+
const scenarios = sortedMap(inputs.scenarios.map((s) => [s.id, scenarioBlock(s, ctx)]));
|
|
107
|
+
const components = componentHoursFor(inputs, features);
|
|
108
|
+
return {
|
|
109
|
+
inputs,
|
|
110
|
+
computed: {
|
|
111
|
+
tasks: sortedMap(Object.entries(tasks).map(([id, t]) => [id, { e: round2(t.e), sigma: round2(t.sigma) }])),
|
|
112
|
+
features,
|
|
113
|
+
...(components ? { components } : {}),
|
|
114
|
+
devHours: round2(buffers.devHours),
|
|
115
|
+
overheadHours: round2(buffers.devHours * inputs.overheadPct),
|
|
116
|
+
spreadBufferHours: round2(buffers.spreadBufferHours),
|
|
117
|
+
riskBufferHours: round2(buffers.riskBufferHours),
|
|
118
|
+
scenarios,
|
|
119
|
+
projectConfidence: criticalConfidence(summaries, tasks),
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// Shape checks for estimation-inputs.json — the agent writes that file, so the
|
|
2
|
+
// checks here are the contract that keeps interview output honest before any
|
|
3
|
+
// arithmetic happens. Findings are strings with the offending id in them.
|
|
4
|
+
import { AI_CATEGORIES, SENIORITY_FACTOR, PLAN_PRICES } from './estimate-math.mjs';
|
|
5
|
+
|
|
6
|
+
const PROVENANCE = ['observed', 'stated', 'researched', 'proposed'];
|
|
7
|
+
const CONFIDENCE = ['HIGH', 'MED', 'LOW'];
|
|
8
|
+
const pct = (v) => typeof v === 'number' && v >= 0 && v < 1;
|
|
9
|
+
|
|
10
|
+
function checkTask(task, out) {
|
|
11
|
+
if (!['o', 'm', 'p'].every((k) => typeof task[k] === 'number')) out.push(`task ${task.id}: o, m, p must be numbers`);
|
|
12
|
+
if (!(task.o > 0 && task.m > 0 && task.p > 0)) out.push(`task ${task.id}: estimates are never 0`);
|
|
13
|
+
if (!(task.o <= task.m && task.m <= task.p)) out.push(`task ${task.id}: expected o <= m <= p`);
|
|
14
|
+
// Object.hasOwn, never `in`: "toString" is `in` every object, and an inherited
|
|
15
|
+
// key here becomes a NaN three tasks later in compute.
|
|
16
|
+
if (!Object.hasOwn(AI_CATEGORIES, task.category)) out.push(`task ${task.id}: unknown category "${task.category}"`);
|
|
17
|
+
if (!CONFIDENCE.includes(task.confidence)) out.push(`task ${task.id}: confidence must be HIGH|MED|LOW`);
|
|
18
|
+
if (!Array.isArray(task.assumptions)) out.push(`task ${task.id}: assumptions array is required`);
|
|
19
|
+
if (!PROVENANCE.includes(task.provenance)) out.push(`task ${task.id}: provenance not in vocabulary`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function checkFeature(feature, out) {
|
|
23
|
+
// Scope items are the clear-vs-assumed split itself: only stated|proposed.
|
|
24
|
+
// (Task rows keep the full four-word vocabulary for their src column.)
|
|
25
|
+
if (!['stated', 'proposed'].includes(feature.provenance)) {
|
|
26
|
+
out.push(`feature ${feature.id}: scope provenance must be stated|proposed`);
|
|
27
|
+
}
|
|
28
|
+
if (!(feature.tasks?.length > 0)) out.push(`feature ${feature.id}: must have at least one task`);
|
|
29
|
+
for (const task of feature.tasks ?? []) checkTask(task, out);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Roadmap is all-or-nothing: a half-labeled feature list would render a
|
|
33
|
+
// half-roadmap that silently drops scope, so partial labeling is refused.
|
|
34
|
+
function checkMilestones(features, out) {
|
|
35
|
+
const withMs = features.filter((f) => f.milestone !== undefined);
|
|
36
|
+
if (withMs.length === 0) return;
|
|
37
|
+
for (const f of features) {
|
|
38
|
+
if (f.milestone === undefined) {
|
|
39
|
+
out.push(`feature ${f.id}: milestone missing (all features must carry one when any does)`);
|
|
40
|
+
} else if (!(typeof f.milestone === 'string' && f.milestone.trim())) {
|
|
41
|
+
out.push(`feature ${f.id}: milestone must be a non-empty string`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Components are all-or-nothing like milestones, and coverage is the point:
|
|
47
|
+
// a §6 component nobody planned work for is a scope hole, refused here unless
|
|
48
|
+
// the roster excuses it with an explicit notEstimated reason. Two levels max —
|
|
49
|
+
// C4 container → component — so rollups never walk a chain.
|
|
50
|
+
function checkRoster(components, out) {
|
|
51
|
+
const byId = new Map(components.map((c) => [c.id, c]));
|
|
52
|
+
if (byId.size !== components.length) out.push('component roster: duplicate ids');
|
|
53
|
+
for (const c of components) {
|
|
54
|
+
if (!(typeof c.id === 'string' && c.id.trim())) out.push('component roster: every entry needs a non-empty id');
|
|
55
|
+
if (!(typeof c.name === 'string' && c.name.trim())) out.push(`component ${c.id}: name must be a non-empty string`);
|
|
56
|
+
if (c.notEstimated !== undefined && !(typeof c.notEstimated === 'string' && c.notEstimated.trim())) {
|
|
57
|
+
out.push(`component ${c.id}: notEstimated must carry a reason`);
|
|
58
|
+
}
|
|
59
|
+
if (c.parent === undefined) continue;
|
|
60
|
+
const parent = byId.get(c.parent);
|
|
61
|
+
if (!parent) out.push(`component ${c.id}: parent "${c.parent}" not in roster`);
|
|
62
|
+
else if (parent.parent !== undefined) out.push(`component ${c.id}: parent "${c.parent}" is not top-level (two levels max)`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function checkComponentCoverage(components, features, out) {
|
|
67
|
+
const covered = new Set(features.map((f) => f.component));
|
|
68
|
+
const parents = new Set(components.map((c) => c.parent).filter(Boolean));
|
|
69
|
+
for (const c of components) {
|
|
70
|
+
if (!parents.has(c.id) && !covered.has(c.id) && c.notEstimated === undefined) {
|
|
71
|
+
out.push(`component ${c.id}: no feature covers it — tag a feature or set notEstimated with a reason`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function checkComponents(inputs, out) {
|
|
77
|
+
const features = inputs.features ?? [];
|
|
78
|
+
if (inputs.components === undefined) {
|
|
79
|
+
for (const f of features) {
|
|
80
|
+
if (f.component !== undefined) out.push(`feature ${f.id}: component set but no top-level components roster`);
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
checkRoster(inputs.components, out);
|
|
85
|
+
const ids = new Set(inputs.components.map((c) => c.id));
|
|
86
|
+
for (const f of features) {
|
|
87
|
+
if (f.component === undefined) out.push(`feature ${f.id}: component missing (all features must carry one when a roster exists)`);
|
|
88
|
+
else if (!ids.has(f.component)) out.push(`feature ${f.id}: component "${f.component}" not in roster`);
|
|
89
|
+
}
|
|
90
|
+
checkComponentCoverage(inputs.components, features, out);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function checkScenarios(inputs, out) {
|
|
94
|
+
const ids = (inputs.scenarios ?? []).map((s) => s.id);
|
|
95
|
+
if (!ids.includes(inputs.recommendedScenario)) out.push('recommendedScenario names no scenario');
|
|
96
|
+
for (const s of inputs.scenarios ?? []) {
|
|
97
|
+
if (!s.team?.length) out.push(`scenario ${s.id}: empty team`);
|
|
98
|
+
if (!Object.hasOwn(PLAN_PRICES, s.plan)) out.push(`scenario ${s.id}: unknown plan "${s.plan}"`);
|
|
99
|
+
for (const member of s.team ?? []) {
|
|
100
|
+
if (!Object.hasOwn(SENIORITY_FACTOR, member.seniority)) out.push(`scenario ${s.id}: unknown seniority "${member.seniority}"`);
|
|
101
|
+
if (!(typeof member.rate === 'number' && member.rate > 0)) out.push(`scenario ${s.id}: rate must be a positive number`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Anything compute.mjs would turn into NaN gets refused here instead: the
|
|
107
|
+
// "computed truth" contract holds only if every operand is a sane number.
|
|
108
|
+
function checkGlobals(inputs, out) {
|
|
109
|
+
if (!pct(inputs.overheadPct)) out.push('overheadPct must be a number in [0, 1)');
|
|
110
|
+
if (!pct(inputs.verificationPct)) out.push('verificationPct must be a number in [0, 1)');
|
|
111
|
+
for (const r of inputs.risks ?? []) {
|
|
112
|
+
if (!(typeof r.probability === 'number' && r.probability >= 0 && r.probability <= 1)) out.push(`risk "${r.name}": probability must be in [0, 1]`);
|
|
113
|
+
if (!(typeof r.impactHours === 'number' && r.impactHours > 0)) out.push(`risk "${r.name}": impactHours must be positive`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function checkInputs(inputs) {
|
|
118
|
+
const out = [];
|
|
119
|
+
for (const key of ['project', 'technique', 'features', 'risks', 'assumptions', 'scenarios']) {
|
|
120
|
+
if (!(key in inputs)) out.push(`missing top-level "${key}"`);
|
|
121
|
+
}
|
|
122
|
+
for (const feature of inputs.features ?? []) checkFeature(feature, out);
|
|
123
|
+
checkMilestones(inputs.features ?? [], out);
|
|
124
|
+
checkComponents(inputs, out);
|
|
125
|
+
checkScenarios(inputs, out);
|
|
126
|
+
checkGlobals(inputs, out);
|
|
127
|
+
return out;
|
|
128
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { embed } from '../../analyze-requirements/scripts/lib/embed.mjs';
|
|
4
|
+
import { buildFontFaces } from '../../analyze-requirements/scripts/lib/fonts.mjs';
|
|
5
|
+
import { escapeHtml } from '../../analyze-requirements/scripts/lib/md-inline.mjs';
|
|
6
|
+
import { checkDeliverables } from './lib/checks.mjs';
|
|
7
|
+
import { inlineModule, stripInternal } from './lib/inline.mjs';
|
|
8
|
+
import { redactForClient } from './lib/redact.mjs';
|
|
9
|
+
|
|
10
|
+
function parseArgs(argv) {
|
|
11
|
+
const args = {};
|
|
12
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
13
|
+
if (!argv[i].startsWith('--')) continue;
|
|
14
|
+
const key = argv[i].slice(2);
|
|
15
|
+
const next = argv[i + 1];
|
|
16
|
+
if (next === undefined || next.startsWith('--')) { args[key] = true; continue; }
|
|
17
|
+
args[key] = next;
|
|
18
|
+
i += 1;
|
|
19
|
+
}
|
|
20
|
+
return args;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const archFontsDir = new URL('../../analyze-requirements/assets/fonts/', import.meta.url).pathname;
|
|
24
|
+
const mathPath = new URL('./lib/estimate-math.mjs', import.meta.url).pathname;
|
|
25
|
+
const templatePath = new URL('../assets/estimate-template.html', import.meta.url).pathname;
|
|
26
|
+
|
|
27
|
+
const args = parseArgs(process.argv.slice(2));
|
|
28
|
+
const estimation = JSON.parse(readFileSync(args.json, 'utf8'));
|
|
29
|
+
const md = readFileSync(args.md, 'utf8');
|
|
30
|
+
|
|
31
|
+
// Validation blocks rendering: this is the hard rule enforced in code, not
|
|
32
|
+
// just in SKILL.md prose. No skip flag exists.
|
|
33
|
+
const findings = checkDeliverables({ md, estimation });
|
|
34
|
+
if (findings.length) {
|
|
35
|
+
console.error(findings.join('\n'));
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const dataForEmbed = args['client-only'] ? redactForClient(estimation) : estimation;
|
|
40
|
+
// Companion mode: --viewer carries the caller-known path back to the analyze-requirements
|
|
41
|
+
// viewer. It sits in the header's internal range, so the client render (which
|
|
42
|
+
// must not point at an internal document set) strips it with everything else.
|
|
43
|
+
const viewerSlot = typeof args.viewer === 'string'
|
|
44
|
+
? `<a id="viewer-link" data-internal href="${escapeHtml(args.viewer)}">architecture docs</a>`
|
|
45
|
+
: '';
|
|
46
|
+
const template = readFileSync(templatePath, 'utf8');
|
|
47
|
+
const html = embed({
|
|
48
|
+
template,
|
|
49
|
+
slots: {
|
|
50
|
+
TITLE: estimation.inputs.project,
|
|
51
|
+
FONTS: buildFontFaces(archFontsDir),
|
|
52
|
+
// Escaped so a literal </script in the JSON can't close the data tag early.
|
|
53
|
+
DATA: JSON.stringify(dataForEmbed).replaceAll('</script', '<\\/script'),
|
|
54
|
+
MATH: inlineModule(readFileSync(mathPath, 'utf8')),
|
|
55
|
+
VIEWER: viewerSlot,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const finalHtml = args['client-only']
|
|
60
|
+
? stripInternal(html).replace('<body', '<body class="view-client"')
|
|
61
|
+
: html;
|
|
62
|
+
|
|
63
|
+
const outPath = join(args.out, 'estimate.html');
|
|
64
|
+
writeFileSync(outPath, finalHtml);
|
|
65
|
+
console.log(outPath);
|