@v11g/agents-rock 1.0.10 → 1.0.12

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 (122) hide show
  1. package/README.md +3 -2
  2. package/package.json +1 -1
  3. package/plugins/business-analyst/.claude-plugin/plugin.json +2 -2
  4. package/plugins/business-analyst/evals/draft-scope-rich/case.yaml +4 -0
  5. package/plugins/business-analyst/evals/draft-scope-rich/fixture.sh +5 -0
  6. package/plugins/business-analyst/evals/draft-scope-rich/graders/conflict-question.md +11 -0
  7. package/plugins/business-analyst/evals/draft-scope-rich/graders/keep-and-exclude.md +14 -0
  8. package/plugins/business-analyst/evals/draft-scope-rich/graders/noise-and-shape.md +13 -0
  9. package/plugins/business-analyst/evals/draft-scope-rich/graders/problem-not-solution.md +13 -0
  10. package/plugins/business-analyst/evals/draft-scope-rich/graders/share-kept.md +11 -0
  11. package/plugins/business-analyst/evals/draft-scope-rich/graders/skill-fired.md +7 -0
  12. package/plugins/business-analyst/evals/draft-scope-rich/graders/vague-word.md +13 -0
  13. package/plugins/business-analyst/evals/draft-scope-rich/inputs/C1.txt +10 -0
  14. package/plugins/business-analyst/evals/draft-scope-rich/inputs/E1.txt +5 -0
  15. package/plugins/business-analyst/evals/draft-scope-rich/inputs/E2.txt +5 -0
  16. package/plugins/business-analyst/evals/draft-scope-rich/inputs/E3.txt +5 -0
  17. package/plugins/business-analyst/evals/draft-scope-rich/prompt.md +9 -0
  18. package/plugins/business-analyst/evals/draft-scope-thin/case.yaml +4 -0
  19. package/plugins/business-analyst/evals/draft-scope-thin/fixture.sh +4 -0
  20. package/plugins/business-analyst/evals/draft-scope-thin/graders/no-invention.md +18 -0
  21. package/plugins/business-analyst/evals/draft-scope-thin/graders/skill-fired.md +7 -0
  22. package/plugins/business-analyst/evals/draft-scope-thin/inputs/E1.txt +5 -0
  23. package/plugins/business-analyst/evals/draft-scope-thin/prompt.md +8 -0
  24. package/plugins/business-analyst/skills/business-analyst/scripts/__pycache__/review_data.cpython-312.pyc +0 -0
  25. package/plugins/business-analyst/skills/business-analyst/scripts/__pycache__/review_layout.cpython-312.pyc +0 -0
  26. package/plugins/business-analyst/skills/business-analyst/scripts/__pycache__/review_page.cpython-312.pyc +0 -0
  27. package/plugins/business-analyst/skills/business-analyst/scripts/__pycache__/scope_checks.cpython-312.pyc +0 -0
  28. package/plugins/business-analyst/skills/business-analyst/scripts/__pycache__/scope_render.cpython-312.pyc +0 -0
  29. package/plugins/business-analyst/skills/business-analyst/scripts/__pycache__/validate.cpython-312.pyc +0 -0
  30. package/plugins/business-analyst/skills/draft-scope/SKILL.md +46 -0
  31. package/plugins/business-analyst/skills/draft-scope/references/credits.md +12 -0
  32. package/plugins/business-analyst/skills/draft-scope/references/draft-schema.md +44 -0
  33. package/plugins/business-analyst/skills/draft-scope/references/rules.md +24 -0
  34. package/plugins/business-analyst/skills/draft-scope/scripts/__pycache__/docx_body.cpython-312.pyc +0 -0
  35. package/plugins/business-analyst/skills/draft-scope/scripts/__pycache__/docx_flow.cpython-312.pyc +0 -0
  36. package/plugins/business-analyst/skills/draft-scope/scripts/__pycache__/docx_package.cpython-312.pyc +0 -0
  37. package/plugins/business-analyst/skills/draft-scope/scripts/__pycache__/docx_xml.cpython-312.pyc +0 -0
  38. package/plugins/business-analyst/skills/draft-scope/scripts/__pycache__/draft_quotes.cpython-312.pyc +0 -0
  39. package/plugins/business-analyst/skills/draft-scope/scripts/__pycache__/draft_rules.cpython-312.pyc +0 -0
  40. package/plugins/business-analyst/skills/draft-scope/scripts/__pycache__/draft_schema.cpython-312.pyc +0 -0
  41. package/plugins/business-analyst/skills/draft-scope/scripts/build_docx.py +36 -0
  42. package/plugins/business-analyst/skills/draft-scope/scripts/check.py +53 -0
  43. package/plugins/business-analyst/skills/draft-scope/scripts/docx_body.py +58 -0
  44. package/plugins/business-analyst/skills/draft-scope/scripts/docx_flow.py +52 -0
  45. package/plugins/business-analyst/skills/draft-scope/scripts/docx_package.py +62 -0
  46. package/plugins/business-analyst/skills/draft-scope/scripts/docx_xml.py +44 -0
  47. package/plugins/business-analyst/skills/draft-scope/scripts/draft_quotes.py +49 -0
  48. package/plugins/business-analyst/skills/draft-scope/scripts/draft_rules.py +106 -0
  49. package/plugins/business-analyst/skills/draft-scope/scripts/draft_schema.py +87 -0
  50. package/plugins/business-analyst/skills/draft-scope/scripts/test/build-docx.test.mjs +76 -0
  51. package/plugins/business-analyst/skills/draft-scope/scripts/test/check-rules.test.mjs +131 -0
  52. package/plugins/business-analyst/skills/draft-scope/scripts/test/check-shape.test.mjs +70 -0
  53. package/plugins/business-analyst/skills/draft-scope/scripts/test/fixtures/draft-pass.json +40 -0
  54. package/plugins/business-analyst/skills/draft-scope/scripts/test/fixtures/sources/C1.txt +7 -0
  55. package/plugins/business-analyst/skills/draft-scope/scripts/test/fixtures/sources/E1.txt +5 -0
  56. package/plugins/business-analyst/skills/draft-scope/scripts/test/gates.test.mjs +39 -0
  57. package/plugins/business-analyst/skills/draft-scope/scripts/test/helpers.mjs +30 -0
  58. package/plugins/business-analyst/skills/draft-scope/scripts/test/skill-files.test.mjs +59 -0
  59. package/plugins/business-analyst/skills/draft-scope/steps/assumptions.md +24 -0
  60. package/plugins/business-analyst/skills/draft-scope/steps/check.md +24 -0
  61. package/plugins/business-analyst/skills/draft-scope/steps/discover.md +53 -0
  62. package/plugins/business-analyst/skills/draft-scope/steps/draft.md +64 -0
  63. package/plugins/solution-architect/.claude-plugin/plugin.json +1 -1
  64. package/plugins/solution-architect/skills/analyze-requirements/SKILL.md +8 -7
  65. package/plugins/solution-architect/skills/analyze-requirements/assets/section-help.json +5 -5
  66. package/plugins/solution-architect/skills/analyze-requirements/assets/viewer-template.html +15 -3
  67. package/plugins/solution-architect/skills/analyze-requirements/evals/evals.json +50 -6
  68. package/plugins/solution-architect/skills/analyze-requirements/evals/fixtures/ba-package-citations/requirements.json +31 -0
  69. package/plugins/solution-architect/skills/analyze-requirements/evals/fixtures/ba-package-citations/requirements.md +17 -0
  70. package/plugins/solution-architect/skills/analyze-requirements/evals/fixtures/transcript-citations/C1-kickoff-call.txt +16 -0
  71. package/plugins/solution-architect/skills/analyze-requirements/evals/fixtures/transcript-citations/E1-intro-email.md +9 -0
  72. package/plugins/solution-architect/skills/analyze-requirements/references/extract.md +108 -0
  73. package/plugins/solution-architect/skills/analyze-requirements/references/interview.md +39 -5
  74. package/plugins/solution-architect/skills/analyze-requirements/references/project-types.md +1 -1
  75. package/plugins/solution-architect/skills/analyze-requirements/references/quality-goals.md +84 -0
  76. package/plugins/solution-architect/skills/analyze-requirements/references/research.md +1 -1
  77. package/plugins/solution-architect/skills/analyze-requirements/references/rewriting.md +7 -2
  78. package/plugins/solution-architect/skills/analyze-requirements/references/viewer.md +10 -6
  79. package/plugins/solution-architect/skills/analyze-requirements/references/writing.md +45 -3
  80. package/plugins/solution-architect/skills/analyze-requirements/scripts/ba-facts.mjs +32 -0
  81. package/plugins/solution-architect/skills/analyze-requirements/scripts/check-quotes.mjs +39 -0
  82. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/ba-package.mjs +75 -0
  83. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-links.mjs +19 -7
  84. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-routes.mjs +1 -1
  85. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/inputs.mjs +42 -11
  86. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-render.mjs +15 -4
  87. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/section-help.mjs +1 -1
  88. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/strategy-sections.mjs +30 -0
  89. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-provenance.mjs +14 -2
  90. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-quotes.mjs +55 -0
  91. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-strategy.mjs +65 -0
  92. package/plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs +18 -5
  93. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/ba-facts-cli.test.mjs +55 -0
  94. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/ba-package-cli.test.mjs +101 -0
  95. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/ba-package.test.mjs +115 -0
  96. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/browser.test.mjs +50 -2
  97. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/check-quotes-cli.test.mjs +49 -0
  98. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-links.test.mjs +49 -4
  99. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/extract-workflow.test.mjs +69 -0
  100. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/inputs.test.mjs +14 -0
  101. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-render.test.mjs +19 -5
  102. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/record-cli.test.mjs +1 -1
  103. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/render.test.mjs +69 -2
  104. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/rewriting.test.mjs +1 -1
  105. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/section-help.test.mjs +6 -0
  106. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-provenance.test.mjs +19 -0
  107. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-quotes-cli.test.mjs +58 -0
  108. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-quotes.test.mjs +81 -0
  109. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-strategy-cli.test.mjs +32 -0
  110. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-strategy.test.mjs +118 -0
  111. package/plugins/solution-architect/skills/analyze-requirements/scripts/validate.mjs +17 -6
  112. package/plugins/solution-architect/skills/analyze-requirements/workflows/extract.js +51 -0
  113. package/plugins/solution-architect/skills/estimate/workflow-based/assets/estimate-components.html +73 -9
  114. package/plugins/solution-architect/skills/estimate/workflow-based/assets/score-review.html +73 -9
  115. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/build-template.mjs +14 -1
  116. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/template/also-builds.css +3 -0
  117. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/template/also-builds.js +16 -0
  118. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/template/link-picker.css +8 -0
  119. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/template/link-picker.js +43 -0
  120. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/also-builds-browser.test.mjs +59 -0
  121. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/link-picker-browser.test.mjs +83 -0
  122. package/plugins/solution-architect/skills/estimate/workflow-based/scripts/test/stage.mjs +19 -1
@@ -0,0 +1,16 @@
1
+ // the other features a component builds: 3 or more fold to one chip and "…N more"
2
+ const ALSO_SHOWN = 1; const ALSO_FOLD = 3;
3
+ const alsoChip = (c, fold) => `<span class="cmini${fold ? ' more' : ''}" style="--sc:var(--s${sysNo(c)})" data-cap-chip="${c}" title="${esc(capById[c].name)}">${c}</span>`;
4
+ function alsoHtml(others) {
5
+ if (!others.length) return '<span class="dim">only this feature</span>';
6
+ const fold = others.length >= ALSO_FOLD;
7
+ const chips = others.map((c, i) => alsoChip(c, fold && i >= ALSO_SHOWN)).join('');
8
+ const more = fold ? `<button type="button" class="alsomore" data-also-more aria-expanded="false">…${others.length - ALSO_SHOWN} more</button>` : '';
9
+ return `also builds ${chips}${more}`;
10
+ }
11
+ function toggleAlso(b) {
12
+ const box = b.closest('.calso'); const open = box.classList.toggle('open');
13
+ b.setAttribute('aria-expanded', String(open));
14
+ b.textContent = open ? 'show less' : `…${box.querySelectorAll('.cmini.more').length} more`;
15
+ }
16
+ document.addEventListener('click', (e) => { const b = e.target.closest('[data-also-more]'); if (b) toggleAlso(b); });
@@ -0,0 +1,8 @@
1
+ .lpick { position:relative; width:100%; max-width:28rem; margin-top:.4rem; }
2
+ .lpick input { width:100%; box-sizing:border-box; font:inherit; font-size:.85rem; padding:.35rem .6rem; color:var(--ink); background:var(--sheet); border:1px dashed var(--ink-dim); border-radius:.3rem; }
3
+ .lpick input:focus { border-style:solid; border-color:var(--ink); outline:none; }
4
+ .lpick-list { position:absolute; z-index:20; left:0; right:0; top:calc(100% + .2rem); max-height:20rem; overflow:auto; background:var(--sheet); border:1px solid var(--grid); border-radius:.3rem; box-shadow:0 6px 18px rgba(0,0,0,.25); padding:.25rem 0; }
5
+ .lpick-g { font-size:.7rem; font-weight:700; text-transform:uppercase; letter-spacing:.04em; color:var(--ink-dim); padding:.35rem .7rem .15rem; }
6
+ .lpick-o { font-size:.88rem; padding:.3rem .7rem .3rem 1.3rem; cursor:pointer; }
7
+ .lpick-o.lpick-cur { background:var(--hi); }
8
+ .lpick-none { padding:.4rem .7rem; font-size:.85rem; }
@@ -0,0 +1,43 @@
1
+ // "+ Link a component": a wide search box; typing filters by component or container name
2
+ const pickerHtml = (capId) => `<div class="lpick" data-lpick="${capId}"><input type="search" data-lpick-q placeholder="+ Link a component… type to filter" aria-label="Link a component" autocomplete="off"><div class="lpick-list hide" role="listbox"></div></div>`;
3
+ const pickOpt = (b) => `<div class="lpick-o" role="option" data-lpick-id="${b.id}">${esc(b.name)}${notAsked(b.id) ? '<span class="dim"> · builds nothing yet</span>' : ''}</div>`;
4
+ function pickList(capId, q) {
5
+ const by = buildersOf(capId); const t = q.trim().toLowerCase();
6
+ const hit = (b) => !by.includes(b.id) && `${b.name} ${b.container}`.toLowerCase().includes(t);
7
+ const groups = [...new Set(COMPS.map((b) => b.container))].map((g) => [g, COMPS.filter((b) => b.container === g && hit(b))]).filter(([, bs]) => bs.length);
8
+ if (!groups.length) return '<div class="lpick-none dim">No component matches</div>';
9
+ return groups.map(([g, bs]) => `<div class="lpick-g">${esc(g)}</div>${bs.map(pickOpt).join('')}`).join('');
10
+ }
11
+ function openPick(inp) {
12
+ const box = inp.closest('.lpick'); const list = $('.lpick-list', box);
13
+ list.innerHTML = pickList(box.dataset.lpick, inp.value); list.classList.remove('hide');
14
+ $('.lpick-o', list)?.classList.add('lpick-cur');
15
+ }
16
+ function movePick(list, d) {
17
+ const os = [...list.querySelectorAll('.lpick-o')]; if (!os.length) return;
18
+ const i = os.findIndex((o) => o.classList.contains('lpick-cur'));
19
+ os.forEach((o) => o.classList.remove('lpick-cur'));
20
+ const n = os[(i + d + os.length) % os.length]; n.classList.add('lpick-cur'); n.scrollIntoView({ block: 'nearest' });
21
+ }
22
+ function pickComp(capId, bid) { links[bid] = [...links[bid], capId]; relink(); }
23
+ function onPickKey(e) {
24
+ const inp = e.target.closest?.('[data-lpick-q]'); if (!inp) return;
25
+ const box = inp.closest('.lpick'); const list = $('.lpick-list', box); const cur = $('.lpick-o.lpick-cur', list);
26
+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp') { e.preventDefault(); if (list.classList.contains('hide')) openPick(inp); else movePick(list, e.key === 'ArrowDown' ? 1 : -1); }
27
+ if (e.key === 'Enter') { e.preventDefault(); if (cur && !list.classList.contains('hide')) pickComp(box.dataset.lpick, cur.dataset.lpickId); }
28
+ if (e.key === 'Escape') { inp.value = ''; list.classList.add('hide'); }
29
+ }
30
+ const pickInput = (e) => e.target.closest?.('[data-lpick-q]');
31
+ document.addEventListener('focusin', (e) => { const q = pickInput(e); if (q) openPick(q); });
32
+ document.addEventListener('input', (e) => { const q = pickInput(e); if (q) openPick(q); });
33
+ document.addEventListener('focusout', (e) => { const q = pickInput(e); if (q) $('.lpick-list', q.closest('.lpick')).classList.add('hide'); });
34
+ document.addEventListener('keydown', onPickKey);
35
+ // mousedown would blur the box and close the list before the click lands
36
+ document.addEventListener('mousedown', (e) => { if (e.target.closest('.lpick-list')) e.preventDefault(); });
37
+ document.addEventListener('click', (e) => { const o = e.target.closest('.lpick-o'); if (o) pickComp(o.closest('.lpick').dataset.lpick, o.dataset.lpickId); });
38
+ // hovering a row moves the highlight, so mouse and keyboard never show two
39
+ document.addEventListener('mouseover', (e) => {
40
+ const o = e.target.closest?.('.lpick-o'); if (!o) return;
41
+ o.parentNode.querySelectorAll('.lpick-cur').forEach((x) => x.classList.remove('lpick-cur'));
42
+ o.classList.add('lpick-cur');
43
+ });
@@ -0,0 +1,59 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { findChrome } from '../../../../analyze-requirements/scripts/lib/chrome.mjs';
4
+ import { openPage } from '../../../../analyze-requirements/scripts/lib/cdp.mjs';
5
+ import { reviewPage, componentsPage } from './stage.mjs';
6
+
7
+ const skip = !findChrome();
8
+ const settle = () => new Promise((r) => setTimeout(r, 1500));
9
+ // office builds FEAT-001, 003, 005; adding 002 and 004 gives FEAT-001's row 4 others
10
+ const wide = (i) => i.components.find((c) => c.id === 'office').builds.push({ feature: 'FEAT-002', why: 'a' }, { feature: 'FEAT-004', why: 'b' });
11
+
12
+ const one = (i) => i.components.find((c) => c.id === 'office').builds.push({ feature: 'FEAT-002', why: 'a' });
13
+
14
+ const ROW = `document.querySelector('[data-builtby="FEAT-001"] [data-comp-chip="office"] .calso')`;
15
+ const shown = (page) => page.eval(`[...${ROW}.querySelectorAll('.cmini')].filter((x) => getComputedStyle(x).display !== 'none').map((x) => x.dataset.capChip)`);
16
+ const button = (page) => page.eval(`(() => { const b = ${ROW}.querySelector('[data-also-more]'); return b && { text: b.textContent, open: b.getAttribute('aria-expanded') }; })()`);
17
+ const toggle = (page) => page.eval(`${ROW}.querySelector('[data-also-more]').click()`);
18
+ const pinned = (page) => page.eval(`!document.getElementById('pinbar').classList.contains('hide')`);
19
+
20
+ async function foldsAndUnfolds(url) {
21
+ const page = await openPage(url);
22
+ try {
23
+ await settle();
24
+ assert.deepEqual(await shown(page), ['FEAT-003']);
25
+ assert.deepEqual(await button(page), { text: '…3 more', open: 'false' });
26
+ await toggle(page);
27
+ assert.deepEqual(await shown(page), ['FEAT-003', 'FEAT-005', 'FEAT-002', 'FEAT-004']);
28
+ assert.deepEqual(await button(page), { text: 'show less', open: 'true' });
29
+ assert.equal(await pinned(page), false);
30
+ await toggle(page);
31
+ assert.deepEqual(await shown(page), ['FEAT-003']);
32
+ assert.deepEqual(await button(page), { text: '…3 more', open: 'false' });
33
+ assert.deepEqual(page.errors, []);
34
+ } finally { await page.close(); }
35
+ }
36
+
37
+ test('score review: 3+ other features fold behind "…N more" and unfold', { skip }, () => foldsAndUnfolds(reviewPage(wide)));
38
+
39
+ test('estimate (component-based): the same fold', { skip }, () => foldsAndUnfolds(componentsPage(wide)));
40
+
41
+ test('two other features show both chips and no button', { skip }, async () => {
42
+ const page = await openPage(reviewPage());
43
+ try {
44
+ await settle();
45
+ assert.deepEqual(await shown(page), ['FEAT-003', 'FEAT-005']);
46
+ assert.equal(await button(page), null);
47
+ assert.deepEqual(page.errors, []);
48
+ } finally { await page.close(); }
49
+ });
50
+
51
+ test('exactly three other features: one chip and "…2 more"', { skip }, async () => {
52
+ const page = await openPage(reviewPage(one));
53
+ try {
54
+ await settle();
55
+ assert.deepEqual(await shown(page), ['FEAT-003']);
56
+ assert.deepEqual(await button(page), { text: '…2 more', open: 'false' });
57
+ assert.deepEqual(page.errors, []);
58
+ } finally { await page.close(); }
59
+ });
@@ -0,0 +1,83 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { findChrome } from '../../../../analyze-requirements/scripts/lib/chrome.mjs';
4
+ import { openPage } from '../../../../analyze-requirements/scripts/lib/cdp.mjs';
5
+ import { reviewPage, componentsPage } from './stage.mjs';
6
+
7
+ const skip = !findChrome();
8
+ const settle = () => new Promise((r) => setTimeout(r, 1500));
9
+ const BOX = `document.querySelector('[data-lpick="FEAT-001"]')`;
10
+ const type = (page, q) => page.eval(`(() => { const i = ${BOX}.querySelector('input'); i.value = ${JSON.stringify(q)}; i.dispatchEvent(new Event('input', { bubbles: true })); })()`);
11
+ const key = (page, k) => page.eval(`${BOX}.querySelector('input').dispatchEvent(new KeyboardEvent('keydown', { key: '${k}', bubbles: true }))`);
12
+ const options = (page) => page.eval(`[...${BOX}.querySelectorAll('.lpick-o')].map((o) => o.dataset.lpickId)`);
13
+ const current = (page) => page.eval(`${BOX}.querySelector('.lpick-o.lpick-cur')?.dataset.lpickId ?? null`);
14
+ const isOpen = (page) => page.eval(`!${BOX}.querySelector('.lpick-list').classList.contains('hide')`);
15
+ const builders = (page) => page.eval(`[...document.querySelectorAll('[data-builtby="FEAT-001"] [data-comp-chip]')].map((r) => r.dataset.compChip).sort()`);
16
+ const pinned = (page) => page.eval(`!document.getElementById('pinbar').classList.contains('hide')`);
17
+
18
+ async function onReview(fn) {
19
+ const page = await openPage(reviewPage());
20
+ try { await settle(); await fn(page); assert.deepEqual(page.errors, []); } finally { await page.close(); }
21
+ }
22
+
23
+ test('typing filters by component or container name; builders are left out', { skip }, () => onReview(async (page) => {
24
+ assert.equal(await page.eval(`${BOX}.querySelector('input').placeholder`), '+ Link a component… type to filter');
25
+ await type(page, 'BILL');
26
+ assert.deepEqual(await options(page), ['api.billing']);
27
+ assert.equal(await isOpen(page), true);
28
+ await type(page, 'worker');
29
+ assert.deepEqual((await options(page)).sort(), ['worker.drafter', 'worker.notify']);
30
+ await type(page, 'stage');
31
+ assert.deepEqual(await options(page), []);
32
+ assert.match(await page.eval(`${BOX}.querySelector('.lpick-list').textContent`), /No component matches/);
33
+ await type(page, '');
34
+ assert.deepEqual((await options(page)).sort(), ['api.billing', 'api.orders', 'ops', 'worker.drafter', 'worker.notify']);
35
+ assert.match(await page.eval(`${BOX}.querySelector('[data-lpick-id="ops"]').textContent`), /builds nothing yet/);
36
+ }));
37
+
38
+ test('arrows move the highlight, Enter links it, nothing gets pinned', { skip }, () => onReview(async (page) => {
39
+ await type(page, 'worker');
40
+ const [first, second] = await options(page);
41
+ assert.equal(await current(page), first);
42
+ await key(page, 'ArrowDown');
43
+ assert.equal(await current(page), second);
44
+ await key(page, 'ArrowUp');
45
+ assert.equal(await current(page), first);
46
+ await key(page, 'Enter');
47
+ assert.deepEqual(await builders(page), ['api.stage', first, 'office'].sort());
48
+ assert.equal(await pinned(page), false);
49
+ }));
50
+
51
+ const over = (page, sel) => page.eval(`${BOX}.querySelector('${sel}').dispatchEvent(new MouseEvent('mouseover', { bubbles: true }))`);
52
+
53
+ test('hovering the card keeps the keyboard highlight; hovering an option moves it', { skip }, () => onReview(async (page) => {
54
+ await type(page, 'worker');
55
+ const [first, second] = await options(page);
56
+ await over(page, 'input');
57
+ await over(page, '.lpick-g');
58
+ assert.equal(await current(page), first);
59
+ await over(page, `[data-lpick-id="${second}"]`);
60
+ assert.equal(await current(page), second);
61
+ await key(page, 'Enter');
62
+ assert.deepEqual(await builders(page), ['api.stage', second, 'office'].sort());
63
+ }));
64
+
65
+ test('a mouse pick links it and does not pin; Esc clears and closes', { skip }, () => onReview(async (page) => {
66
+ await type(page, 'drafter');
67
+ await page.eval(`${BOX}.querySelector('[data-lpick-id="worker.drafter"]').click()`);
68
+ assert.deepEqual(await builders(page), ['api.stage', 'office', 'worker.drafter']);
69
+ assert.equal(await pinned(page), false);
70
+ await type(page, 'bill');
71
+ await key(page, 'Escape');
72
+ assert.equal(await isOpen(page), false);
73
+ assert.equal(await page.eval(`${BOX}.querySelector('input').value`), '');
74
+ }));
75
+
76
+ test('the read-only Component-based page has no picker', { skip }, async () => {
77
+ const page = await openPage(componentsPage());
78
+ try {
79
+ await settle();
80
+ assert.equal(await page.eval(`document.querySelectorAll('.lpick, select[data-link]').length`), 0);
81
+ assert.deepEqual(page.errors, []);
82
+ } finally { await page.close(); }
83
+ });
@@ -3,7 +3,7 @@ import { execFileSync } from 'node:child_process';
3
3
  import { mkdtempSync, readFileSync, writeFileSync, copyFileSync } from 'node:fs';
4
4
  import { tmpdir } from 'node:os';
5
5
  import { join } from 'node:path';
6
- import { fileURLToPath } from 'node:url';
6
+ import { fileURLToPath, pathToFileURL } from 'node:url';
7
7
 
8
8
  export const script = (n) => fileURLToPath(new URL(`../${n}.mjs`, import.meta.url));
9
9
  const fx = (n) => fileURLToPath(new URL(`./fixtures/${n}`, import.meta.url));
@@ -30,3 +30,21 @@ export function noFlowsAt(dir) {
30
30
  for (const f of req.features.slice(2, 4)) f.steps = [];
31
31
  writeFileSync(path, JSON.stringify(req));
32
32
  }
33
+
34
+ // The score review page for the fixture lead, as a file URL.
35
+ export function reviewPage(mutate) {
36
+ const dir = mkdtempSync(join(tmpdir(), 'wf-review-'));
37
+ const inputs = JSON.parse(readFileSync(fx('inputs-pass.json'), 'utf8'));
38
+ if (mutate) mutate(inputs);
39
+ writeFileSync(join(dir, 'estimation-inputs.json'), JSON.stringify(inputs));
40
+ copyFileSync(fx('requirements.json'), join(dir, 'requirements.json'));
41
+ execFileSync('node', [script('score-review'), '--write', join(dir, 'estimation-inputs.json'), '--out', join(dir, 'review.html')]);
42
+ return pathToFileURL(join(dir, 'review.html')).href;
43
+ }
44
+
45
+ // The Component-based estimate page for the fixture lead, as a file URL.
46
+ export function componentsPage(mutate) {
47
+ const dir = staged(mutate);
48
+ execFileSync('node', [script('render'), '--inputs', join(dir, 'estimation-inputs.json'), '--json', join(dir, 'estimation.json'), '--out', join(dir, 'dist')]);
49
+ return pathToFileURL(join(dir, 'dist', 'estimate-components.html')).href;
50
+ }