@v11g/agents-rock 1.0.4 → 1.0.6
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 +1 -1
- package/package.json +1 -1
- package/plugins/solution-architect/.claude-plugin/plugin.json +1 -1
- package/plugins/solution-architect/skills/estimate/README.md +8 -5
- package/plugins/solution-architect/skills/estimate/SKILL.md +13 -7
- package/plugins/solution-architect/skills/estimate/assets/estimate-template-agentic.html +142 -376
- package/plugins/solution-architect/skills/estimate/assets/estimate-template.html +619 -601
- package/plugins/solution-architect/skills/estimate/assets/scores-review-template.html +363 -0
- package/plugins/solution-architect/skills/estimate/references/ai-multipliers.md +5 -9
- package/plugins/solution-architect/skills/estimate/references/interview.md +132 -12
- package/plugins/solution-architect/skills/estimate/references/scoring-guide.md +23 -0
- package/plugins/solution-architect/skills/estimate/references/techniques.md +9 -2
- package/plugins/solution-architect/skills/estimate/references/writing.md +28 -5
- package/plugins/solution-architect/skills/estimate/scripts/lib/agentic-checks.mjs +1 -1
- package/plugins/solution-architect/skills/estimate/scripts/lib/checks.mjs +4 -30
- package/plugins/solution-architect/skills/estimate/scripts/lib/estimate-math.mjs +14 -10
- package/plugins/solution-architect/skills/estimate/scripts/lib/inline.mjs +6 -8
- package/plugins/solution-architect/skills/estimate/scripts/lib/md-tables.mjs +31 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/redact.mjs +14 -3
- package/plugins/solution-architect/skills/estimate/scripts/lib/rollup.mjs +5 -4
- package/plugins/solution-architect/skills/estimate/scripts/lib/scenario-schema.mjs +39 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/schema.mjs +4 -14
- package/plugins/solution-architect/skills/estimate/scripts/lib/score-csv.mjs +58 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/score-diff.mjs +30 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/score-html.mjs +17 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/scoring-checks.mjs +24 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/scoring-schema.mjs +48 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/scoring.mjs +45 -0
- package/plugins/solution-architect/skills/estimate/scripts/render.mjs +14 -13
- package/plugins/solution-architect/skills/estimate/scripts/score-review.mjs +59 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/browser.test.mjs +403 -316
- package/plugins/solution-architect/skills/estimate/scripts/test/compute.test.mjs +25 -1
- package/plugins/solution-architect/skills/estimate/scripts/test/estimate-math.test.mjs +29 -10
- package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/agentic-inputs.json +2 -2
- package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/booking-inputs.json +21 -3
- package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-fail.md +1 -1
- package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-pass.md +4 -4
- package/plugins/solution-architect/skills/estimate/scripts/test/references.test.mjs +64 -6
- package/plugins/solution-architect/skills/estimate/scripts/test/render.test.mjs +96 -13
- package/plugins/solution-architect/skills/estimate/scripts/test/schema.test.mjs +105 -4
- package/plugins/solution-architect/skills/estimate/scripts/test/score-review.test.mjs +187 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/scoring.test.mjs +49 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/url-state.test.mjs +198 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/validate.test.mjs +38 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/xlsx-export.test.mjs +114 -28
- package/plugins/solution-architect/skills/new-lead/scripts/lib/map-nodes.mjs +1 -1
- package/plugins/solution-architect/skills/proposal/scripts/test/checks-client.test.mjs +2 -2
- package/plugins/solution-architect/skills/proposal/scripts/test/figures.test.mjs +1 -1
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { mkdtempSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { execFileSync } from 'node:child_process';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { pathToFileURL } from 'node:url';
|
|
8
|
+
import { toCsv, parseCsv, fromCsv, CSV_HEADERS } from '../lib/score-csv.mjs';
|
|
9
|
+
import { diffScores, applyDiff } from '../lib/score-diff.mjs';
|
|
10
|
+
import { loadGuide } from '../lib/scoring.mjs';
|
|
11
|
+
import { findChrome } from '../../../analyze-requirements/scripts/lib/chrome.mjs';
|
|
12
|
+
import { openPage } from '../../../analyze-requirements/scripts/lib/cdp.mjs';
|
|
13
|
+
|
|
14
|
+
const cli = new URL('../score-review.mjs', import.meta.url).pathname;
|
|
15
|
+
const skip = { skip: !findChrome() && 'no chrome on PATH' };
|
|
16
|
+
|
|
17
|
+
const inputs = () => JSON.parse(readFileSync(new URL('./fixtures/booking-inputs.json', import.meta.url), 'utf8'));
|
|
18
|
+
const draft = () => {
|
|
19
|
+
const { project, features } = inputs();
|
|
20
|
+
return { project, features: features.map(({ id, name, scores, scoreNote, scoreProvenance }) => ({ id, name, scores, scoreNote, scoreProvenance })) };
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function writeDraft(mutate) {
|
|
24
|
+
const dir = mkdtempSync(join(tmpdir(), 'score-review-'));
|
|
25
|
+
const path = join(dir, 'draft.json');
|
|
26
|
+
const d = draft();
|
|
27
|
+
mutate?.(d);
|
|
28
|
+
writeFileSync(path, JSON.stringify(d));
|
|
29
|
+
return { dir, path };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// The CLI runs unattended inside the skill, so a half-written flag set has to
|
|
33
|
+
// stop it rather than quietly write the wrong file.
|
|
34
|
+
function cliFails(args) {
|
|
35
|
+
try {
|
|
36
|
+
execFileSync('node', [cli, ...args], { encoding: 'utf8', stdio: 'pipe' });
|
|
37
|
+
} catch (err) { return err; }
|
|
38
|
+
throw new Error(`expected a non-zero exit from: ${args.join(' ')}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
test('CLI: an incomplete flag set prints usage and exits 1', () => {
|
|
42
|
+
const { dir, path } = writeDraft();
|
|
43
|
+
for (const args of [
|
|
44
|
+
['--read', join(dir, 'scores.csv')],
|
|
45
|
+
['--write', path, '--format', 'pdf', '--out', join(dir, 'out.pdf')],
|
|
46
|
+
['--write', path, '--format', 'csv'],
|
|
47
|
+
]) {
|
|
48
|
+
const err = cliFails(args);
|
|
49
|
+
assert.equal(err.status, 1, args.join(' '));
|
|
50
|
+
assert.match(err.stderr, /usage:/, args.join(' '));
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('fromCsv refuses a header that lost a score column', () => {
|
|
55
|
+
const csv = toCsv(draft()).replace('deps,deps_why,deps_cite', 'dependencies,deps_why,deps_cite');
|
|
56
|
+
assert.throws(() => fromCsv(csv), /missing score columns: deps/);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('toCsv writes one row per feature with anchor and cite beside every score', () => {
|
|
60
|
+
const csv = toCsv(draft());
|
|
61
|
+
const [head, booking] = csv.trim().split('\n');
|
|
62
|
+
assert.equal(head, CSV_HEADERS.join(','));
|
|
63
|
+
assert.equal(CSV_HEADERS.length, 2 + 5 * 3 + 4); // id, feature, 5×(n, why, cite), sum, tier, why_this_tier, note
|
|
64
|
+
assert.match(booking, /^booking,User can book appointment,3,"Custom business logic, moderate algorithm complexity, multiple states",slot conflict \+ cancellation rules,3,/);
|
|
65
|
+
// the plain note has no comma, so it is not quoted; the trailing empty field is the free "note" column
|
|
66
|
+
assert.match(booking, /,14,M,Core booking rules with a few open questions; touches every customer if it breaks,$/);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('parseCsv handles quoted commas, doubled quotes and CRLF', () => {
|
|
70
|
+
assert.deepEqual(parseCsv('a,"b, c","say ""hi""",d\r\n1,2,3,4\n'), [['a', 'b, c', 'say "hi"', 'd'], ['1', '2', '3', '4']]);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('fromCsv reads numbers, the plain note and the free-text note back', () => {
|
|
74
|
+
const csv = toCsv(draft())
|
|
75
|
+
.replace(/^(booking,[^,]*,)3,/m, (m, head) => `${head}4,`)
|
|
76
|
+
.replace(/,14,M,([^,\n]*),$/m, (m, note) => `,15,L,${note},move risk up`);
|
|
77
|
+
const edited = fromCsv(csv);
|
|
78
|
+
assert.equal(edited.features[0].id, 'booking');
|
|
79
|
+
assert.equal(edited.features[0].scores.tech, 4);
|
|
80
|
+
assert.equal(edited.features[0].note, 'move risk up');
|
|
81
|
+
assert.equal(edited.features[1].scores.deps, 3);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('diffScores names exactly the cells the human changed', () => {
|
|
85
|
+
const d = draft();
|
|
86
|
+
const edited = { features: [
|
|
87
|
+
{ id: 'booking', scores: { tech: 4, size: 3, deps: 2, unc: 3, risk: 3 }, scoreNote: d.features[0].scoreNote, note: 'algorithm is fuzzy matching' },
|
|
88
|
+
{ id: 'reminders', scores: { tech: 2, size: 2, deps: 3, unc: 2, risk: 2 }, scoreNote: 'Reminder emails via an outside provider', note: '' },
|
|
89
|
+
] };
|
|
90
|
+
assert.deepEqual(diffScores(d, edited), [
|
|
91
|
+
{ id: 'booking', field: 'tech', from: 3, to: 4 },
|
|
92
|
+
{ id: 'booking', field: 'note', to: 'algorithm is fuzzy matching' },
|
|
93
|
+
{ id: 'reminders', field: 'scoreNote', from: d.features[1].scoreNote, to: 'Reminder emails via an outside provider' },
|
|
94
|
+
]);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('applyDiff re-anchors a changed score from the guide and marks the feature stated', () => {
|
|
98
|
+
const d = draft();
|
|
99
|
+
const guide = loadGuide();
|
|
100
|
+
const diff = [{ id: 'reminders', field: 'tech', from: 2, to: 4 }];
|
|
101
|
+
const features = applyDiff({ draft: d, diff, guide });
|
|
102
|
+
assert.equal(features[1].scores.tech.n, 4);
|
|
103
|
+
assert.equal(features[1].scores.tech.anchor, guide.tech[3]);
|
|
104
|
+
assert.equal(features[1].scores.tech.cite, 'scheduled job + template', 'cite is kept for the agent to revisit');
|
|
105
|
+
assert.equal(features[1].scoreProvenance, 'stated');
|
|
106
|
+
assert.equal(features[0].scoreProvenance, 'stated', 'untouched features keep their provenance');
|
|
107
|
+
assert.deepEqual(d.features[1].scores.tech.n, 2, 'draft is not mutated');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('CLI: --write csv then --read reports the diff and the re-anchored features', () => {
|
|
111
|
+
const { dir, path } = writeDraft();
|
|
112
|
+
const csvPath = join(dir, 'scores-draft.csv');
|
|
113
|
+
execFileSync('node', [cli, '--write', path, '--format', 'csv', '--out', csvPath]);
|
|
114
|
+
const edited = readFileSync(csvPath, 'utf8').replace(/^(reminders,[^,]*,)2,/m, (m, head) => `${head}4,`);
|
|
115
|
+
writeFileSync(csvPath, edited);
|
|
116
|
+
const out = JSON.parse(execFileSync('node', [cli, '--read', csvPath, '--draft', path], { encoding: 'utf8' }));
|
|
117
|
+
assert.deepEqual(out.diff, [{ id: 'reminders', field: 'tech', from: 2, to: 4 }]);
|
|
118
|
+
assert.equal(out.features[1].scores.tech.anchor, loadGuide().tech[3]);
|
|
119
|
+
assert.equal(out.features[1].scoreProvenance, 'stated');
|
|
120
|
+
// every changed score is a question the agent must put to the reviewer;
|
|
121
|
+
// the old cite is what the question is argued against
|
|
122
|
+
assert.deepEqual(out.needsReason, [{ id: 'reminders', field: 'tech', from: 2, to: 4, oldCite: 'scheduled job + template' }]);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('CLI: a rewritten plain note needs no reason — only score changes do', () => {
|
|
126
|
+
const { dir, path } = writeDraft();
|
|
127
|
+
const fb = { features: [{ id: 'booking', scores: { tech: 3, size: 3, deps: 2, unc: 3, risk: 3 }, scoreNote: 'Booking rules; a few open questions' }] };
|
|
128
|
+
const fbPath = join(dir, 'feedback.json');
|
|
129
|
+
writeFileSync(fbPath, JSON.stringify(fb));
|
|
130
|
+
const out = JSON.parse(execFileSync('node', [cli, '--read', fbPath, '--draft', path], { encoding: 'utf8' }));
|
|
131
|
+
assert.equal(out.diff.length, 1);
|
|
132
|
+
assert.equal(out.diff[0].field, 'scoreNote');
|
|
133
|
+
assert.deepEqual(out.needsReason, []);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test('CLI: --write html renders one select per score with the anchor as its title', skip, async () => {
|
|
137
|
+
const { dir, path } = writeDraft();
|
|
138
|
+
const htmlPath = join(dir, 'scores-review.html');
|
|
139
|
+
execFileSync('node', [cli, '--write', path, '--format', 'html', '--out', htmlPath]);
|
|
140
|
+
const page = await openPage(pathToFileURL(htmlPath).href);
|
|
141
|
+
try {
|
|
142
|
+
assert.deepEqual(page.errors, []);
|
|
143
|
+
assert.equal(await page.eval(`document.querySelectorAll('select[data-id][data-key]').length`), 10);
|
|
144
|
+
assert.equal(await page.eval(`document.querySelector('select[data-id="booking"][data-key="tech"]').value`), '3');
|
|
145
|
+
assert.match(await page.eval(`document.querySelector('select[data-id="booking"][data-key="tech"]').title`), /Custom business logic/);
|
|
146
|
+
assert.equal(await page.eval(`document.querySelector('[data-total="reminders"]').textContent`), '11');
|
|
147
|
+
assert.equal(await page.eval(`document.querySelector('[data-tier="reminders"]').textContent`), 'S');
|
|
148
|
+
assert.match(await page.eval(`document.querySelector('details.guide').textContent`), /Tech complexity/);
|
|
149
|
+
} finally { page.close(); }
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test('review page: changing a select updates Σ/tier live and the feedback block round-trips', skip, async () => {
|
|
153
|
+
const { dir, path } = writeDraft();
|
|
154
|
+
const htmlPath = join(dir, 'scores-review.html');
|
|
155
|
+
execFileSync('node', [cli, '--write', path, '--format', 'html', '--out', htmlPath]);
|
|
156
|
+
const page = await openPage(pathToFileURL(htmlPath).href);
|
|
157
|
+
try {
|
|
158
|
+
await page.eval(`(() => { const s = document.querySelector('select[data-id="reminders"][data-key="tech"]'); s.value = '4'; s.dispatchEvent(new Event('change', { bubbles: true })); })()`);
|
|
159
|
+
assert.equal(await page.eval(`document.querySelector('[data-total="reminders"]').textContent`), '13');
|
|
160
|
+
assert.equal(await page.eval(`document.querySelector('[data-tier="reminders"]').textContent`), 'M');
|
|
161
|
+
assert.equal(await page.eval(`document.querySelector('select[data-id="reminders"][data-key="tech"]').value`), '4',
|
|
162
|
+
'the rebuilt select shows the edited score, not the draft one');
|
|
163
|
+
assert.doesNotMatch(await page.eval(`document.querySelector('select[data-id="reminders"][data-key="tech"]').title`),
|
|
164
|
+
/Minor customisation of standard patterns/, 'the anchor for the old score must not explain the new one');
|
|
165
|
+
const feedback = JSON.parse(await page.eval(`document.getElementById('feedback').value`));
|
|
166
|
+
const fbPath = join(dir, 'feedback.json');
|
|
167
|
+
writeFileSync(fbPath, JSON.stringify(feedback));
|
|
168
|
+
const out = JSON.parse(execFileSync('node', [cli, '--read', fbPath, '--draft', path], { encoding: 'utf8' }));
|
|
169
|
+
assert.deepEqual(out.diff, [{ id: 'reminders', field: 'tech', from: 2, to: 4 }]);
|
|
170
|
+
await page.eval(`(() => { const s = document.querySelector('select[data-id="reminders"][data-key="tech"]'); s.value = '5'; s.dispatchEvent(new Event('change', { bubbles: true })); })()`);
|
|
171
|
+
assert.equal(await page.eval(`document.querySelector('select[data-id="reminders"][data-key="tech"]').value`), '5');
|
|
172
|
+
assert.match(await page.eval(`document.querySelector('select[data-id="reminders"][data-key="tech"]').className`), /hot/,
|
|
173
|
+
'a 5 is flagged after the re-render, not only on first paint');
|
|
174
|
+
} finally { page.close(); }
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test('review page: a feature id with a quote in it cannot inject attributes', skip, async () => {
|
|
178
|
+
const { dir, path } = writeDraft((d) => { d.features[1].id = 'bad" onfocus="window.__pwned=1'; });
|
|
179
|
+
const htmlPath = join(dir, 'scores-review.html');
|
|
180
|
+
execFileSync('node', [cli, '--write', path, '--format', 'html', '--out', htmlPath]);
|
|
181
|
+
const page = await openPage(pathToFileURL(htmlPath).href);
|
|
182
|
+
try {
|
|
183
|
+
assert.deepEqual(page.errors, []);
|
|
184
|
+
assert.equal(await page.eval(`document.querySelectorAll('[onfocus]').length`), 0);
|
|
185
|
+
assert.equal(await page.eval(`window.__pwned === undefined`), true);
|
|
186
|
+
} finally { page.close(); }
|
|
187
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { mkdtempSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import {
|
|
7
|
+
SCORE_FACTORS, FACTOR_LABELS, loadGuide, guideTableHtml, scoreNumbers, scoreSummary,
|
|
8
|
+
} from '../lib/scoring.mjs';
|
|
9
|
+
|
|
10
|
+
test('the guide loads five factors with five anchors each, in factor order', () => {
|
|
11
|
+
const guide = loadGuide();
|
|
12
|
+
assert.deepEqual(Object.keys(guide), SCORE_FACTORS);
|
|
13
|
+
for (const k of SCORE_FACTORS) assert.equal(guide[k].length, 5, `${k} needs 5 anchors`);
|
|
14
|
+
assert.equal(guide.risk[3], 'Payments, auth, data migrations, or PII — high business impact');
|
|
15
|
+
assert.equal(guide.deps[2], '2–3 internal services or one third-party API');
|
|
16
|
+
assert.equal(guide.size[0], 'Single UI element or micro-function, <1 day of work');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// A guide row that lost its label (or its table) would otherwise surface as
|
|
20
|
+
// "cannot read length of undefined" deep in a render.
|
|
21
|
+
test('loadGuide names the factor whose anchor row is missing', () => {
|
|
22
|
+
const src = readFileSync(new URL('../../references/scoring-guide.md', import.meta.url), 'utf8');
|
|
23
|
+
const path = join(mkdtempSync(join(tmpdir(), 'scoring-guide-')), 'scoring-guide.md');
|
|
24
|
+
writeFileSync(path, src.split('\n').filter((l) => !l.startsWith('| Risk ')).join('\n'));
|
|
25
|
+
assert.throws(() => loadGuide(path), /no 5-anchor row for risk/);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('guideTableHtml escapes and labels every row', () => {
|
|
29
|
+
const html = guideTableHtml(loadGuide());
|
|
30
|
+
assert.match(html, /<table class="guide-table">/);
|
|
31
|
+
for (const label of Object.values(FACTOR_LABELS)) assert.ok(html.includes(label), label);
|
|
32
|
+
assert.ok(html.includes('<1 day of work'), 'anchors are HTML-escaped');
|
|
33
|
+
assert.equal((html.match(/<tr>/g) ?? []).length, 6); // header + 5 rows
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const scored = {
|
|
37
|
+
id: 'f', scores: {
|
|
38
|
+
tech: { n: 3, anchor: 'a', cite: 'c' }, size: { n: 3, anchor: 'a', cite: 'c' },
|
|
39
|
+
deps: { n: 2, anchor: 'a', cite: 'c' }, unc: { n: 3, anchor: 'a', cite: 'c' },
|
|
40
|
+
risk: { n: 3, anchor: 'a', cite: 'c' },
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
test('scoreNumbers strips anchors and cites; scoreSummary sums and tiers', () => {
|
|
45
|
+
assert.deepEqual(scoreNumbers(scored.scores), { tech: 3, size: 3, deps: 2, unc: 3, risk: 3 });
|
|
46
|
+
assert.deepEqual(scoreSummary(scored), { scoreTotal: 14, tier: 'M' });
|
|
47
|
+
assert.deepEqual(scoreSummary({ id: 'q', tasks: [] }), {});
|
|
48
|
+
});
|
|
49
|
+
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { mkdtempSync } from 'node:fs';
|
|
4
|
+
import { execFileSync } from 'node:child_process';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { pathToFileURL } from 'node:url';
|
|
8
|
+
import { findChrome } from '../../../analyze-requirements/scripts/lib/chrome.mjs';
|
|
9
|
+
import { openPage } from '../../../analyze-requirements/scripts/lib/cdp.mjs';
|
|
10
|
+
|
|
11
|
+
const skip = { skip: !findChrome() && 'no chrome on PATH' };
|
|
12
|
+
const fixture = new URL('./fixtures/booking-inputs.json', import.meta.url).pathname;
|
|
13
|
+
|
|
14
|
+
function buildPage() {
|
|
15
|
+
const dir = mkdtempSync(join(tmpdir(), 'estimate-url-'));
|
|
16
|
+
const scripts = new URL('..', import.meta.url).pathname;
|
|
17
|
+
execFileSync('node', [join(scripts, 'compute.mjs'), '--inputs', fixture, '--out', join(dir, 'estimation.json')]);
|
|
18
|
+
execFileSync('node', [join(scripts, 'render.mjs'), '--json', join(dir, 'estimation.json'),
|
|
19
|
+
'--md', join(scripts, 'test/fixtures/estimation-pass.md'), '--out', dir]);
|
|
20
|
+
return pathToFileURL(join(dir, 'estimate.html')).href;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const pickOption = (key, value) => `(() => {
|
|
24
|
+
const sel = document.querySelector('#feature-table select[data-select="${key}"]');
|
|
25
|
+
sel.value = ${JSON.stringify(value)};
|
|
26
|
+
sel.dispatchEvent(new Event('change', { bubbles: true }));
|
|
27
|
+
})()`;
|
|
28
|
+
const clickTab = (tab) => `document.querySelector('#feature-table [role="tab"][data-tab="${tab}"]').click()`;
|
|
29
|
+
const click = (sel) => `document.querySelector(${JSON.stringify(sel)}).click()`;
|
|
30
|
+
const featIds = `[...document.querySelectorAll('#panel-estimate tr.feat-row')].map((r) => r.dataset.id)`;
|
|
31
|
+
const params = async (page) => Object.fromEntries(
|
|
32
|
+
new URLSearchParams(await page.eval('location.hash.slice(1)')));
|
|
33
|
+
|
|
34
|
+
test('an untouched breakdown leaves the URL clean', skip, async () => {
|
|
35
|
+
const page = await openPage(buildPage());
|
|
36
|
+
try {
|
|
37
|
+
assert.equal(await page.eval('location.hash'), '');
|
|
38
|
+
assert.deepEqual(page.errors, []);
|
|
39
|
+
} finally { page.close(); }
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('every breakdown control writes itself into the URL', skip, async () => {
|
|
43
|
+
const page = await openPage(buildPage());
|
|
44
|
+
try {
|
|
45
|
+
await page.eval(clickTab('scoring'));
|
|
46
|
+
assert.deepEqual(await params(page), { tab: 'scoring' });
|
|
47
|
+
await page.eval(pickOption('milestone', 'M2 - Notifications'));
|
|
48
|
+
await page.eval(click('#feature-table button[data-expand="all"]'));
|
|
49
|
+
await page.eval(click('#panel-scoring th button[data-sort="tier"]'));
|
|
50
|
+
assert.deepEqual(await params(page), {
|
|
51
|
+
tab: 'scoring', ms: 'M2 - Notifications', open: 'all', sort: 'scoring:tier:1',
|
|
52
|
+
});
|
|
53
|
+
assert.deepEqual(page.errors, []);
|
|
54
|
+
} finally { page.close(); }
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('a shared URL reopens the same filtered breakdown', skip, async () => {
|
|
58
|
+
const url = `${buildPage()}#tab=scoring&ms=M2%20-%20Notifications&open=all&guide=0`;
|
|
59
|
+
const page = await openPage(url);
|
|
60
|
+
try {
|
|
61
|
+
assert.equal(await page.eval(`document.querySelector('#panel-scoring').hidden`), false);
|
|
62
|
+
assert.equal(await page.eval(
|
|
63
|
+
`document.querySelector('#feature-table select[data-select="milestone"]').value`), 'M2 - Notifications');
|
|
64
|
+
assert.deepEqual(await page.eval(
|
|
65
|
+
`[...document.querySelectorAll('#panel-scoring tr.feat-row')].map((r) => r.dataset.id)`), ['reminders']);
|
|
66
|
+
assert.equal(await page.eval(`document.querySelectorAll('#panel-scoring tr.rat-row').length`), 1);
|
|
67
|
+
assert.equal(await page.eval(`document.querySelector('#feature-table details.guide').open`), false);
|
|
68
|
+
assert.deepEqual(page.errors, []);
|
|
69
|
+
} finally { page.close(); }
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('a shared URL carries the grouping, the source and one named feature', skip, async () => {
|
|
73
|
+
const url = `${buildPage()}#src=stated&group=1&open=booking&sort=estimate:name:1`;
|
|
74
|
+
const page = await openPage(url);
|
|
75
|
+
try {
|
|
76
|
+
assert.deepEqual(await page.eval(featIds), ['booking']);
|
|
77
|
+
assert.equal(await page.eval(
|
|
78
|
+
`document.querySelector('#feature-table select[data-select="prov"]').value`), 'stated');
|
|
79
|
+
assert.equal(await page.eval(
|
|
80
|
+
`document.querySelectorAll('#panel-estimate tr.feat-row[data-id="booking"] + tr.task-row').length >= 1`), true);
|
|
81
|
+
assert.deepEqual(page.errors, []);
|
|
82
|
+
} finally { page.close(); }
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// A colleague's copy can hold different features. A filter naming something
|
|
86
|
+
// that copy has never heard of would empty the table with no hint why, so an
|
|
87
|
+
// unknown value is dropped rather than applied.
|
|
88
|
+
test('values the data does not know are dropped, not applied', skip, async () => {
|
|
89
|
+
const url = `${buildPage()}#tab=nope&ms=M7%20-%20Ghost&ct=nowhere&open=missing&sort=estimate:bogus:1`;
|
|
90
|
+
const page = await openPage(url);
|
|
91
|
+
try {
|
|
92
|
+
assert.equal(await page.eval(`document.querySelector('#panel-estimate').hidden`), false);
|
|
93
|
+
assert.deepEqual(await page.eval(featIds), ['booking', 'reminders']);
|
|
94
|
+
assert.equal(await page.eval(`document.querySelectorAll('#panel-estimate tr.task-row').length`), 0);
|
|
95
|
+
// nothing survived, so the page is at its defaults — and says so
|
|
96
|
+
assert.equal(await page.eval('location.hash'), '');
|
|
97
|
+
assert.deepEqual(page.errors, []);
|
|
98
|
+
} finally { page.close(); }
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('clearing the filters clears the URL with them', skip, async () => {
|
|
102
|
+
const page = await openPage(buildPage());
|
|
103
|
+
try {
|
|
104
|
+
await page.eval(pickOption('milestone', 'M2 - Notifications'));
|
|
105
|
+
assert.deepEqual(await params(page), { ms: 'M2 - Notifications' });
|
|
106
|
+
await page.eval(click('#feature-table button[data-clear]'));
|
|
107
|
+
assert.equal(await page.eval('location.hash'), '');
|
|
108
|
+
assert.deepEqual(page.errors, []);
|
|
109
|
+
} finally { page.close(); }
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Each tab owns its sort, so the URL has to carry them apart.
|
|
113
|
+
test('the two tabs keep separate sorts in the URL', skip, async () => {
|
|
114
|
+
const page = await openPage(buildPage());
|
|
115
|
+
try {
|
|
116
|
+
await page.eval(click('#panel-estimate th button[data-sort="name"]'));
|
|
117
|
+
await page.eval(clickTab('scoring'));
|
|
118
|
+
await page.eval(click('#panel-scoring th button[data-sort="unc"]'));
|
|
119
|
+
const hash = await page.eval('location.hash.slice(1)');
|
|
120
|
+
const sorts = new URLSearchParams(hash).getAll('sort');
|
|
121
|
+
assert.deepEqual(sorts.sort(), ['estimate:name:1', 'scoring:unc:1']);
|
|
122
|
+
assert.deepEqual(page.errors, []);
|
|
123
|
+
} finally { page.close(); }
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// Pasting a different hash into the address bar, and the back button, both
|
|
127
|
+
// arrive as a hashchange — the breakdown follows it.
|
|
128
|
+
test('the breakdown follows the URL when the hash changes', skip, async () => {
|
|
129
|
+
const page = await openPage(buildPage());
|
|
130
|
+
try {
|
|
131
|
+
await page.eval(`location.hash = 'ms=M1%20-%20Booking%20core'`);
|
|
132
|
+
await page.eval(`new Promise((r) => setTimeout(r, 50))`);
|
|
133
|
+
assert.deepEqual(await page.eval(featIds), ['booking']);
|
|
134
|
+
assert.deepEqual(page.errors, []);
|
|
135
|
+
} finally { page.close(); }
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// The header toggle previews the client render. Which view you were looking
|
|
139
|
+
// at travels with the link like the filters do.
|
|
140
|
+
test('the client view toggle writes itself into the query string', skip, async () => {
|
|
141
|
+
const page = await openPage(buildPage());
|
|
142
|
+
try {
|
|
143
|
+
await page.eval(clickTab('scoring'));
|
|
144
|
+
await page.eval(`document.getElementById('view-toggle').click()`);
|
|
145
|
+
assert.equal(await page.eval('location.search'), '?view=client');
|
|
146
|
+
assert.equal(await page.eval('location.hash'), '#tab=scoring'); // the filters survive it
|
|
147
|
+
assert.deepEqual(page.errors, []);
|
|
148
|
+
} finally { page.close(); }
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test('a shared URL opens in the client view, filters and all', skip, async () => {
|
|
152
|
+
const page = await openPage(`${buildPage()}?view=client#tab=scoring&open=all`);
|
|
153
|
+
try {
|
|
154
|
+
assert.equal(await page.eval(`document.body.classList.contains('view-client')`), true);
|
|
155
|
+
assert.equal(await page.eval(
|
|
156
|
+
`getComputedStyle(document.querySelector('#panel-scoring .cite')).display`), 'none');
|
|
157
|
+
assert.equal(await page.eval(`document.querySelector('#panel-scoring').hidden`), false);
|
|
158
|
+
assert.equal(await page.eval(`document.querySelectorAll('#panel-scoring tr.rat-row').length`), 2);
|
|
159
|
+
assert.deepEqual(page.errors, []);
|
|
160
|
+
} finally { page.close(); }
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// A --client-only render has already had its internal markup stripped. A URL
|
|
164
|
+
// must never look like it can put that back, so the parameter only ever
|
|
165
|
+
// switches the preview on.
|
|
166
|
+
test('the view parameter only ever switches the preview on', skip, async () => {
|
|
167
|
+
const page = await openPage(`${buildPage()}?view=internal`);
|
|
168
|
+
try {
|
|
169
|
+
assert.equal(await page.eval(`document.body.classList.contains('view-client')`), false);
|
|
170
|
+
assert.deepEqual(page.errors, []);
|
|
171
|
+
} finally { page.close(); }
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// The toggle is itself internal, so client view used to hide the one control
|
|
175
|
+
// that leaves it — a one-way trip ending in a reload. It stays put now, and
|
|
176
|
+
// says which way it goes.
|
|
177
|
+
test('the client view can be left the way it was entered', skip, async () => {
|
|
178
|
+
const page = await openPage(buildPage());
|
|
179
|
+
const toggle = `document.getElementById('view-toggle')`;
|
|
180
|
+
try {
|
|
181
|
+
await page.eval(`${toggle}.click()`);
|
|
182
|
+
assert.notEqual(await page.eval(`getComputedStyle(${toggle}).display`), 'none');
|
|
183
|
+
assert.equal(await page.eval(`${toggle}.textContent`), 'internal view');
|
|
184
|
+
await page.eval(`${toggle}.click()`);
|
|
185
|
+
assert.equal(await page.eval(`document.body.classList.contains('view-client')`), false);
|
|
186
|
+
assert.equal(await page.eval(`${toggle}.textContent`), 'client view');
|
|
187
|
+
assert.equal(await page.eval('location.search'), '');
|
|
188
|
+
assert.deepEqual(page.errors, []);
|
|
189
|
+
} finally { page.close(); }
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test('a client-view URL labels the toggle for the way back', skip, async () => {
|
|
193
|
+
const page = await openPage(`${buildPage()}?view=client`);
|
|
194
|
+
try {
|
|
195
|
+
assert.equal(await page.eval(`document.getElementById('view-toggle').textContent`), 'internal view');
|
|
196
|
+
assert.deepEqual(page.errors, []);
|
|
197
|
+
} finally { page.close(); }
|
|
198
|
+
});
|
|
@@ -15,6 +15,15 @@ test('the pass fixture passes', () => {
|
|
|
15
15
|
checkDeliverables({ md: read('estimation-pass.md'), estimation: computeEstimation(inputs()) }), []);
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
+
// The fixtures are the worked example a reader copies from, and the skill
|
|
19
|
+
// prices seats, not a named vendor plan (references.test.mjs holds the same
|
|
20
|
+
// line for the reference docs).
|
|
21
|
+
test('neither deliverable fixture names a vendor AI plan', () => {
|
|
22
|
+
for (const f of ['estimation-pass.md', 'estimation-fail.md']) {
|
|
23
|
+
assert.doesNotMatch(read(f), /Max 5x/, f);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
18
27
|
test('each seeded violation is caught by name', () => {
|
|
19
28
|
const findings = checkDeliverables({ md: read('estimation-fail.md'), estimation: computeEstimation(inputs()) });
|
|
20
29
|
for (const needle of ['never 0', 'src', 'assumptions cell', 'assumptions register', 'buffer', 'out of scope', 'scenario', 'roadmap']) {
|
|
@@ -22,6 +31,14 @@ test('each seeded violation is caught by name', () => {
|
|
|
22
31
|
}
|
|
23
32
|
});
|
|
24
33
|
|
|
34
|
+
// One team is the default interview answer now; a comparison table with a
|
|
35
|
+
// single row is a complete deliverable, not a missing comparison.
|
|
36
|
+
test('a scenario table with one row validates', () => {
|
|
37
|
+
const md = read('estimation-pass.md').replace(/\n\| 3eng-noai \|[^\n]*/, '');
|
|
38
|
+
const findings = checkDeliverables({ md, estimation: computeEstimation(inputs()) });
|
|
39
|
+
assert.ok(!findings.some((f) => f.includes('scenario')), findings.join('\n'));
|
|
40
|
+
});
|
|
41
|
+
|
|
25
42
|
test('hand-edited totals are refused', () => {
|
|
26
43
|
const est = computeEstimation(inputs());
|
|
27
44
|
est.computed.devHours += 10;
|
|
@@ -107,3 +124,24 @@ test('missing Delivery header line is a finding', () => {
|
|
|
107
124
|
const findings = checkDeliverables({ md, estimation: agenticEstimation() });
|
|
108
125
|
assert.ok(findings.some((f) => /Delivery:/.test(f)));
|
|
109
126
|
});
|
|
127
|
+
|
|
128
|
+
test('a Summary Tier cell that disagrees with the scores is refused at STANDARD depth', () => {
|
|
129
|
+
const md = read('estimation-pass.md').replace('| User can book appointment | M |', '| User can book appointment | L |');
|
|
130
|
+
const findings = checkDeliverables({ md, estimation: computeEstimation(inputs()) });
|
|
131
|
+
assert.ok(findings.some((f) => f === 'scope row "User can book appointment": Tier L does not match scores (M)'), findings.join('\n'));
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test('the Tier column is required at STANDARD depth and ignored at QUICK', () => {
|
|
135
|
+
const noTier = read('estimation-pass.md')
|
|
136
|
+
.replace('| Feature | Tier | Range (h) | src |', '| Feature | Range (h) | src |')
|
|
137
|
+
.replace('| --- | --- | --- | --- |\n| User', '| --- | --- | --- |\n| User')
|
|
138
|
+
.replace('| User can book appointment | M | 40–120 |', '| User can book appointment | 40–120 |')
|
|
139
|
+
.replace('| Email reminders | S | 12–36 |', '| Email reminders | 12–36 |');
|
|
140
|
+
assert.ok(checkDeliverables({ md: noTier, estimation: computeEstimation(inputs()) })
|
|
141
|
+
.some((f) => f.includes('Tier column')));
|
|
142
|
+
const quick = inputs();
|
|
143
|
+
quick.depth = 'QUICK';
|
|
144
|
+
for (const f of quick.features) { delete f.scores; delete f.scoreNote; delete f.scoreProvenance; }
|
|
145
|
+
const md = read('estimation-pass.md').replace('| User can book appointment | M |', '| User can book appointment | XL |');
|
|
146
|
+
assert.ok(!checkDeliverables({ md, estimation: computeEstimation(quick) }).some((f) => f.includes('Tier')));
|
|
147
|
+
});
|