@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,115 @@
1
+ // scripts/test/ba-package.test.mjs
2
+ import { test } from 'node:test';
3
+ import assert from 'node:assert/strict';
4
+ import { isPackage, baRows, isStated, statedText, validateBaCitations } from '../lib/ba-package.mjs';
5
+
6
+ const PKG = {
7
+ schemaVersion: '1.0', updated: '2026-10-01',
8
+ requirements: [
9
+ { id: 'FR-001', text: 'Members book up to 4 courts per week.', label: 'confirmed', source: 'kickoff call 2026-09-20' },
10
+ { id: 'FR-002', text: 'Members pay a deposit online.', label: 'recommended' },
11
+ ],
12
+ nfrs: [{ id: 'NFR-001', area: 'availability', text: 'The booking page is up 99.95% of the time.', label: 'assumed' }],
13
+ integrations: [{ id: 'INT-001', system: 'Stripe', direction: 'write', label: 'confirmed', source: 'PO brief' }],
14
+ data: [{ id: 'DAT-001', entity: 'Booking', sensitivity: 'personal', volume: 'about 900 per week', label: 'confirmed' }],
15
+ constraints: [{ id: 'CON-001', text: 'Must run in AWS eu-west-1.', source: 'client IT policy' }],
16
+ assumptions: [{ id: 'ASM-001', text: 'Members log in with email.', impact: 'high', status: 'unconfirmed' }],
17
+ };
18
+ const rows = baRows(PKG);
19
+ const byId = (id) => rows.find((r) => r.id === id);
20
+
21
+ test('isPackage needs schemaVersion and a requirements array', () => {
22
+ assert.equal(isPackage(PKG), true);
23
+ assert.equal(isPackage({ name: 'x' }), false);
24
+ assert.equal(isPackage(null), false);
25
+ });
26
+
27
+ test('baRows reads each section with its fact text and section', () => {
28
+ assert.deepEqual(byId('FR-001'), {
29
+ id: 'FR-001', fact: 'Members book up to 4 courts per week.', label: 'confirmed',
30
+ source: 'kickoff call 2026-09-20', section: 'goals and scope', cite: 'FR-001 · kickoff call 2026-09-20',
31
+ });
32
+ assert.equal(byId('NFR-001').section, 'quality');
33
+ assert.equal(byId('INT-001').fact, 'Stripe (write)');
34
+ assert.equal(byId('DAT-001').fact, 'Booking, personal, about 900 per week');
35
+ });
36
+
37
+ test('a row with no source cites the package date', () => {
38
+ assert.equal(byId('DAT-001').cite, 'DAT-001 · 2026-10-01');
39
+ });
40
+
41
+ test('a constraint with a source and no label counts as confirmed', () => {
42
+ assert.equal(byId('CON-001').label, 'confirmed');
43
+ assert.equal(isStated(byId('CON-001')), true);
44
+ });
45
+
46
+ test('assumptions are never rows; assumed and recommended are not stated', () => {
47
+ assert.equal(byId('ASM-001'), undefined);
48
+ assert.equal(isStated(byId('NFR-001')), false);
49
+ assert.equal(isStated(byId('FR-002')), false);
50
+ });
51
+
52
+ const packages = new Map([['requirements.json', rows]]);
53
+ const cite = (label) => ({ label, path: 'requirements.json', quote: null });
54
+
55
+ test('a citation to a confirmed row passes', () => {
56
+ assert.deepEqual(validateBaCitations({ citations: [cite('FR-001 · kickoff call 2026-09-20')], packages }), []);
57
+ });
58
+
59
+ test('a citation to an unknown id fails', () => {
60
+ assert.deepEqual(validateBaCitations({ citations: [cite('FR-009 · x')], packages }), [
61
+ { check: 'quotes', message: 'FR-009 is not in requirements.json' },
62
+ ]);
63
+ });
64
+
65
+ test('a citation to an assumed row fails with its label', () => {
66
+ assert.deepEqual(validateBaCitations({ citations: [cite('NFR-001 · 2026-10-01')], packages }), [
67
+ { check: 'quotes', message: 'NFR-001 is assumed in requirements.json; only confirmed rows are stated' },
68
+ ]);
69
+ });
70
+
71
+ test('citations to other files are ignored', () => {
72
+ const other = { label: 'C1 · 2026-09-10', path: 'inputs/C1.txt', quote: 'x' };
73
+ assert.deepEqual(validateBaCitations({ citations: [other], packages }), []);
74
+ });
75
+
76
+ test('statedText joins the facts of confirmed rows only', () => {
77
+ assert.equal(statedText(rows), [
78
+ 'Members book up to 4 courts per week.', 'Must run in AWS eu-west-1.',
79
+ 'Stripe (write)', 'Booking, personal, about 900 per week',
80
+ ].join('\n'));
81
+ });
82
+
83
+ test('a citation whose label is not the row cite fails', () => {
84
+ assert.deepEqual(validateBaCitations({ citations: [cite('FR-001 · made-up source')], packages }), [
85
+ { check: 'quotes', message: 'FR-001 · made-up source does not match requirements.json; cite it as FR-001 · kickoff call 2026-09-20' },
86
+ ]);
87
+ });
88
+
89
+ test('a row with no label and no source is unlabelled, so proposed', () => {
90
+ const [row] = baRows({ schemaVersion: '1.0', requirements: [{ id: 'FR-7', text: 'x' }, { text: 'no id' }] });
91
+ assert.equal(row.label, 'unlabelled');
92
+ assert.equal(isStated(row), false);
93
+ });
94
+
95
+ test('a malformed package is read without throwing', () => {
96
+ const bad = { schemaVersion: '1.0', requirements: [null, 5, { id: 'FR-1', text: 'x', label: 'confirmed' }], nfrs: {} };
97
+ assert.deepEqual(baRows(bad).map((r) => r.id), ['FR-1']);
98
+ });
99
+
100
+ test('a citation to requirements.md fails when requirements.json sits beside it', () => {
101
+ const md = { label: 'FR-001 · x', path: 'requirements.md', quote: null };
102
+ assert.deepEqual(validateBaCitations({ citations: [md], packages }), [
103
+ { check: 'quotes', message: 'requirements.md is the BA package for people; cite requirements.json by row id' },
104
+ ]);
105
+ const nested = new Map([['docs/requirements.json', rows]]);
106
+ const deep = { label: 'FR-001 · x', path: 'docs/requirements.md', quote: null };
107
+ assert.equal(validateBaCitations({ citations: [deep], packages: nested }).length, 1);
108
+ });
109
+
110
+ test('a requirements.md with no json beside it is a normal input', () => {
111
+ const md = { label: 'R1 · x', path: 'requirements.md', quote: 'x' };
112
+ assert.deepEqual(validateBaCitations({ citations: [md], packages: new Map() }), []);
113
+ const other = new Map([['docs/requirements.json', rows]]);
114
+ assert.deepEqual(validateBaCitations({ citations: [md], packages: other }), []);
115
+ });
@@ -1,7 +1,7 @@
1
1
  import { test, before, after, describe } from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
3
  import { execFileSync } from 'node:child_process';
4
- import { readFileSync, mkdtempSync, writeFileSync } from 'node:fs';
4
+ import { readFileSync, mkdtempSync, writeFileSync, mkdirSync } from 'node:fs';
5
5
  import { tmpdir } from 'node:os';
6
6
  import { join } from 'node:path';
7
7
  import { openPage } from '../lib/cdp.mjs';
@@ -84,10 +84,16 @@ const REFLOW_DOC = [
84
84
  function buildViewer() {
85
85
  const out = mkdtempSync(join(tmpdir(), 'analyze-requirements-browser-'));
86
86
  const stub = (name, body) => { const p = join(out, name); writeFileSync(p, body); return p; };
87
+ mkdirSync(join(out, 'adr'));
88
+ const longAdr = stub(join('adr', '0009-long.md'), ['# ADR 0009: Long record', '', '## Context', '',
89
+ ...Array.from({ length: 40 }, (_, i) => `Context paragraph ${i + 1} keeps the record taller than the drawer.\n`),
90
+ '## Decision', '', 'Land here.', '',
91
+ // Without text below it the heading cannot reach the top: the drawer clamps.
92
+ ...Array.from({ length: 30 }, (_, i) => `Consequence paragraph ${i + 1} fills the space under the decision.\n`)].join('\n'));
87
93
  execFileSync('node', [
88
94
  'plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs',
89
95
  '--root', fixtures, '--arch', `${fixtures}ARCHITECTURE.md`,
90
- '--docs', `${fixtures}docs/adr/0001-sample.md`, stub('reflow.md', REFLOW_DOC),
96
+ '--docs', `${fixtures}docs/adr/0001-sample.md`, stub('reflow.md', REFLOW_DOC), longAdr,
91
97
  '--out', out,
92
98
  '--likec4-bundle', stub('l.js', LIKEC4_STUB),
93
99
  // Mermaid is stubbed: the diagram renderer is not what these check, and a
@@ -577,4 +583,46 @@ describe('the viewer in a real browser', { skip: findChrome() ? false : 'no chro
577
583
  test('driving the diagram and the rail logs no error', async () => {
578
584
  assert.deepEqual(page.errors, []);
579
585
  });
586
+
587
+ // openDrawer resets the scroll and the click handler rewrote the link to the
588
+ // record's route, so a link to a heading inside an ADR opened it at the top.
589
+ test('a link to a heading inside a record opens the drawer at that heading', async () => {
590
+ const r = await page.eval(`(async () => {
591
+ const h = document.querySelector('[id^="0009-long__"][id$="__decision"]');
592
+ const a = document.createElement('a');
593
+ a.href = '#' + h.id; a.textContent = 'jump';
594
+ document.querySelector('.page:not([hidden])').appendChild(a);
595
+ a.click();
596
+ await new Promise((res) => setTimeout(res, 200));
597
+ const body = document.getElementById('drawer-body');
598
+ const out = { open: document.getElementById('drawer').classList.contains('is-open'),
599
+ inDrawer: body.contains(h), scrolled: body.scrollTop > 0,
600
+ top: Math.round(h.getBoundingClientRect().top - body.getBoundingClientRect().top) };
601
+ a.remove();
602
+ document.getElementById('drawer-close').click();
603
+ await new Promise((res) => setTimeout(res, 100));
604
+ return out;
605
+ })()`);
606
+ assert.deepEqual({ open: r.open, inDrawer: r.inDrawer, scrolled: r.scrolled },
607
+ { open: true, inDrawer: true, scrolled: true });
608
+ assert.ok(r.top < 150, `heading sits ${r.top}px below the drawer top`);
609
+ });
610
+
611
+ test('a deep link to a heading inside a record opens the drawer at that heading', async () => {
612
+ const r = await page.eval(`(async () => {
613
+ const h = document.querySelector('[id^="0009-long__"][id$="__decision"]');
614
+ location.hash = '#' + h.id;
615
+ await new Promise((res) => setTimeout(res, 200));
616
+ const body = document.getElementById('drawer-body');
617
+ const out = { open: document.getElementById('drawer').classList.contains('is-open'),
618
+ inDrawer: body.contains(h), scrolled: body.scrollTop > 0,
619
+ top: Math.round(h.getBoundingClientRect().top - body.getBoundingClientRect().top) };
620
+ document.getElementById('drawer-close').click();
621
+ await new Promise((res) => setTimeout(res, 100));
622
+ return out;
623
+ })()`);
624
+ assert.deepEqual({ open: r.open, inDrawer: r.inDrawer, scrolled: r.scrolled },
625
+ { open: true, inDrawer: true, scrolled: true });
626
+ assert.ok(r.top < 150, `heading sits ${r.top}px below the drawer top`);
627
+ });
580
628
  });
@@ -0,0 +1,49 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { spawnSync } from 'node:child_process';
4
+ import { mkdtempSync, readFileSync, writeFileSync } from 'node:fs';
5
+ import { tmpdir } from 'node:os';
6
+ import { join } from 'node:path';
7
+
8
+ const CLI = 'plugins/solution-architect/skills/analyze-requirements/scripts/check-quotes.mjs';
9
+
10
+ function check(facts) {
11
+ const dir = mkdtempSync(join(tmpdir(), 'check-quotes-'));
12
+ const call = join(dir, 'C1.txt');
13
+ writeFileSync(call, 'Maya: We pay for Azure already, so it has to run there.\n');
14
+ const withPath = facts.map((f) => ({ section: 'constraints', src: 'C1', date: '2026-09-10', path: call, ...f }));
15
+ writeFileSync(join(dir, 'in.json'), JSON.stringify({ facts: withPath }));
16
+ const r = spawnSync('node', [CLI, '--facts', join(dir, 'in.json'), '--out', join(dir, 'out.json')], { encoding: 'utf8' });
17
+ return { r, out: JSON.parse(readFileSync(join(dir, 'out.json'), 'utf8')) };
18
+ }
19
+
20
+ test('all quotes found: exit 0, every fact kept', () => {
21
+ const { r, out } = check([{ fact: 'must run on Azure', quote: 'it has to run there' }]);
22
+ assert.equal(r.status, 0, r.stdout);
23
+ assert.equal(out.facts.length, 1);
24
+ assert.deepEqual(out.misses, []);
25
+ });
26
+
27
+ test('a reworded quote is a miss with the closest sentence; the rest are kept', () => {
28
+ const { r, out } = check([
29
+ { fact: 'Azure', quote: 'it has to run there' },
30
+ { fact: 'Azure', quote: 'it must run on Azure' },
31
+ ]);
32
+ assert.equal(r.status, 1);
33
+ assert.match(r.stdout, /^MISS \[C1\] "it must run on Azure" — closest: "Maya: We pay for Azure/m);
34
+ assert.equal(out.facts.length, 1);
35
+ assert.equal(out.misses[0].closest.startsWith('Maya: We pay'), true);
36
+ });
37
+
38
+ test('an unreadable input file is a miss, not a crash', () => {
39
+ const { r, out } = check([{ fact: 'x', quote: 'y', path: '/nonexistent/C9.txt', src: 'C9' }]);
40
+ assert.equal(r.status, 1);
41
+ assert.match(out.misses[0].closest, /file not readable/);
42
+ });
43
+
44
+ test('an empty or missing quote is a miss, not a pass or a crash', () => {
45
+ const { r, out } = check([{ fact: 'a', quote: '' }, { fact: 'b' }]);
46
+ assert.equal(r.status, 1);
47
+ assert.equal(out.misses.length, 2);
48
+ assert.equal(out.misses.every((m) => m.closest === 'empty quote'), true);
49
+ });
@@ -1,6 +1,6 @@
1
1
  import { test } from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
- import { rewriteDocLinks } from '../lib/doc-links.mjs';
3
+ import { rewriteDocLinks, anchorIds } from '../lib/doc-links.mjs';
4
4
 
5
5
  const ids = new Map([
6
6
  ['/repo/docs/adr/0002-rls.md', 'doc-adr-0002-multi-tenancy'],
@@ -28,9 +28,9 @@ test('a root-relative href resolves the same way', () => {
28
28
  assert.match(html, /href="#doc-adr-0002-multi-tenancy"/);
29
29
  });
30
30
 
31
- // Heading slugs are deduped across the whole set, so #context inside ADR-0002
32
- // may have been minted as context-7. The document anchor is the honest target.
33
- test('a fragment on a document link is dropped rather than guessed at', () => {
31
+ // A fragment that names no heading in the target (here: ids has no #context
32
+ // entry) falls back to the document anchor rather than a dead id.
33
+ test('an unknown fragment on a document link falls back to the document', () => {
34
34
  const html = rewriteDocLinks(
35
35
  '<p><a href="0002-rls.md#context">why</a></p>', '/repo/docs/adr/index.md', ids,
36
36
  );
@@ -102,3 +102,48 @@ test('a root-absolute path is unwrapped: a single file has no site root', () =>
102
102
  );
103
103
  assert.match(html, /class="ext-ref"/);
104
104
  });
105
+
106
+ // The author writes #q3 against the log's own headings; the renderer dedupes
107
+ // ids across the whole set, so the log's Q3 may have been minted q3-2.
108
+ test('a fragment resolves to the id its heading was minted as', () => {
109
+ const map = new Map([...ids,
110
+ ['/repo/interview-log.md', 'doc-interview-log'],
111
+ ['/repo/interview-log.md#q3', 'q3-2']]);
112
+ const html = rewriteDocLinks(
113
+ '<p><a href="interview-log.md#q3">Q3</a></p>', '/repo/ARCHITECTURE.md', map,
114
+ );
115
+ assert.match(html, /<a href="#q3-2">Q3<\/a>/);
116
+ });
117
+
118
+ // A heading with no ASCII letters slugs to '' — its key must not win over
119
+ // the document anchor, or the link renders as a dead href="#".
120
+ test('an empty minted slug falls back to the document anchor', () => {
121
+ const map = new Map([...ids,
122
+ ['/repo/notes.md', 'doc-notes'], ['/repo/notes.md#', '']]);
123
+ const html = rewriteDocLinks('<a href="notes.md#">N</a>', '/repo/ARCHITECTURE.md', map);
124
+ assert.match(html, /<a href="#doc-notes">N<\/a>/);
125
+ });
126
+
127
+ test('anchorIds maps each heading\'s own-document slug to its minted id', () => {
128
+ const page = { path: '/repo/log.md', headings: [
129
+ { level: 3, text: 'Q3', slug: 'log__q3', local: 'q3' },
130
+ { level: 3, text: 'Q3', slug: 'log__q3-2', local: 'q3-2' },
131
+ ] };
132
+ assert.deepEqual(anchorIds(page), [
133
+ ['/repo/log.md#q3', 'log__q3'],
134
+ ['/repo/log.md#q3-2', 'log__q3-2'],
135
+ ]);
136
+ });
137
+
138
+ // Inside an ADR, #context means this ADR's Context, not the spine's.
139
+ test('a same-page anchor resolves against its own document', () => {
140
+ const map = new Map([['/repo/docs/adr/0007.md#context', '0007__context']]);
141
+ const html = rewriteDocLinks('<a href="#context">C</a>', '/repo/docs/adr/0007.md', map);
142
+ assert.match(html, /<a href="#0007__context">C<\/a>/);
143
+ });
144
+
145
+ // View panels, doc heads and anything else that is not an h2/h3 keep their id.
146
+ test('a same-page anchor that names no heading is left alone', () => {
147
+ const html = rewriteDocLinks('<a href="#panel-containers">V</a>', '/repo/ARCHITECTURE.md', new Map());
148
+ assert.equal(html, '<a href="#panel-containers">V</a>');
149
+ });
@@ -0,0 +1,69 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { readFileSync } from 'node:fs';
4
+
5
+ const src = readFileSync(new URL('../../workflows/extract.js', import.meta.url), 'utf8')
6
+ .replace(/^export const meta =/m, 'const meta =');
7
+ const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor;
8
+
9
+ function run({ agentImpl, args }) {
10
+ const calls = { prompts: [], logs: [] };
11
+ const agent = (p, o) => { calls.prompts.push(p); return agentImpl(p, o); };
12
+ const fn = new AsyncFunction('agent', 'parallel', 'pipeline', 'phase', 'log', 'args', 'budget', src);
13
+ const parallel = (thunks) => Promise.all(thunks.map((t) => t().catch(() => null)));
14
+ return fn(agent, parallel, null, () => {}, (m) => calls.logs.push(m), args,
15
+ { total: null, spent: () => 0, remaining: () => Infinity }).then((result) => ({ result, calls }));
16
+ }
17
+
18
+ const FILES = [
19
+ { id: 'C1', path: '/set/inputs/C1-kickoff-call.txt', date: '2026-09-10' },
20
+ { id: 'E1', path: '/set/inputs/E1-intro-email.md', date: '2026-09-08' },
21
+ ];
22
+ const okAgent = async () => ({ facts: [{ fact: 'runs on Azure', quote: 'it has to run there', section: 'deployment and hosting' }] });
23
+
24
+ test('one agent per file; facts tagged with the file id, date and path', async () => {
25
+ const { result, calls } = await run({ agentImpl: okAgent, args: { files: FILES } });
26
+ assert.equal(calls.prompts.length, 2);
27
+ assert.deepEqual(result.facts.map((f) => [f.src, f.date, f.path]), [
28
+ ['C1', '2026-09-10', '/set/inputs/C1-kickoff-call.txt'],
29
+ ['E1', '2026-09-08', '/set/inputs/E1-intro-email.md'],
30
+ ]);
31
+ });
32
+
33
+ test('default prompt names the file, the exact-quote rule and the checklist', async () => {
34
+ const { calls } = await run({ agentImpl: okAgent, args: { files: [FILES[0]] } });
35
+ assert.match(calls.prompts[0], /\/set\/inputs\/C1-kickoff-call\.txt/);
36
+ assert.match(calls.prompts[0], /character for character/);
37
+ assert.match(calls.prompts[0], /deployment and hosting/);
38
+ });
39
+
40
+ test('question mode asks only the question', async () => {
41
+ const { calls } = await run({ agentImpl: okAgent, args: { files: [FILES[0]], question: 'what about hosting?' } });
42
+ assert.match(calls.prompts[0], /Answer only this: what about hosting\?/);
43
+ assert.doesNotMatch(calls.prompts[0], /users and actors/);
44
+ });
45
+
46
+ test('fix mode hands back the missed quotes', async () => {
47
+ const fix = [{ fact: 'Azure', quote: 'it must run on Azure', closest: 'We pay for Azure already' }];
48
+ const { calls } = await run({ agentImpl: okAgent, args: { files: [{ ...FILES[0], fix }] } });
49
+ assert.match(calls.prompts[0], /it must run on Azure/);
50
+ assert.match(calls.prompts[0], /not found in the file/);
51
+ });
52
+
53
+ test('a failed agent lands in dropped; other files still return facts', async () => {
54
+ const flaky = async (p) => (p.includes('E1-intro') ? null : okAgent());
55
+ const { result, calls } = await run({ agentImpl: flaky, args: { files: FILES } });
56
+ assert.deepEqual(result.dropped, [{ item: 'E1', reason: 'agent returned nothing' }]);
57
+ assert.equal(result.facts.length, 1);
58
+ assert.ok(calls.logs.some((l) => l.includes('DROPPED E1')));
59
+ });
60
+
61
+ test('a BA package file gets the confirmed-only rule; other files do not', async () => {
62
+ const files = [
63
+ { id: 'D1', path: '/set/requirements.md', date: '2026-10-01', ba: true },
64
+ { id: 'C1', path: '/set/inputs/C1-kickoff-call.txt', date: '2026-09-10' },
65
+ ];
66
+ const { calls } = await run({ agentImpl: okAgent, args: { files } });
67
+ assert.match(calls.prompts[0], /only rows labelled confirmed/);
68
+ assert.doesNotMatch(calls.prompts[1], /labelled confirmed/);
69
+ });
@@ -70,3 +70,17 @@ test('accepts a link to a deduped -2 anchor matching the renderer', async () =>
70
70
  const inputs = await anchorInputs('## Consequences\n\n## Consequences\n\n[ok](#consequences-2)\n');
71
71
  assert.deepEqual(validateLinks(inputs), []);
72
72
  });
73
+
74
+ // md-render skips fenced code and frontmatter; the validator must count the same
75
+ // headings, or `#setup-2` passes the check and lands nowhere in the viewer.
76
+ test('a heading inside a code fence or frontmatter is not an anchor', async () => {
77
+ const inputs = await anchorInputs('---\n## hidden\ntitle: x\n---\n## Setup\n\n```\n## Setup\n```\n\n## Setup\n');
78
+ assert.deepEqual(inputs.anchors['ARCHITECTURE.md'], ['setup', 'setup-2']);
79
+ });
80
+
81
+ // md-render closes a fence only on a bare ``` line; a ```js inside an open fence
82
+ // is content, not a closer.
83
+ test('only a bare fence line closes a fence', async () => {
84
+ const inputs = await anchorInputs('## A\n\n```md\n## A\n```js\n## B\n```\n## A\n');
85
+ assert.deepEqual(inputs.anchors['ARCHITECTURE.md'], ['a', 'a-2']);
86
+ });
@@ -5,7 +5,7 @@ import { renderMarkdown } from '../lib/md-render.mjs';
5
5
  test('renders headings with slug ids and collects them', () => {
6
6
  const { html, headings } = renderMarkdown('## Core Components\ntext');
7
7
  assert.match(html, /<h2 id="core-components">Core Components<\/h2>/);
8
- assert.deepEqual(headings, [{ level: 2, text: 'Core Components', slug: 'core-components' }]);
8
+ assert.deepEqual(headings, [{ level: 2, text: 'Core Components', slug: 'core-components', local: 'core-components' }]);
9
9
  });
10
10
 
11
11
  test('renders tables, links, mermaid fences, likec4 markers', () => {
@@ -31,8 +31,8 @@ test('makes repeated heading ids unique within a document', () => {
31
31
 
32
32
  test('keeps heading ids unique across docs sharing a slug registry', () => {
33
33
  const seen = new Map();
34
- renderMarkdown('## Considered Options', seen);
35
- const { headings } = renderMarkdown('## Considered Options', seen);
34
+ renderMarkdown('## Considered Options', { slugs: seen });
35
+ const { headings } = renderMarkdown('## Considered Options', { slugs: seen });
36
36
  assert.equal(headings[0].slug, 'considered-options-2');
37
37
  });
38
38
 
@@ -79,8 +79,8 @@ test('h1 gets a doc-prefixed id and is reported as the page title', () => {
79
79
  test('doc ids use their own namespace so section slugs keep their numbering', () => {
80
80
  const slugs = new Map();
81
81
  const docSlugs = new Map();
82
- renderMarkdown('# Related\n\n## Related', slugs, docSlugs);
83
- const second = renderMarkdown('# Related\n\n## Related', slugs, docSlugs);
82
+ renderMarkdown('# Related\n\n## Related', { slugs, docSlugs });
83
+ const second = renderMarkdown('# Related\n\n## Related', { slugs, docSlugs });
84
84
  assert.equal(second.docId, 'doc-related-2');
85
85
  assert.equal(second.headings[0].slug, 'related-2');
86
86
  });
@@ -224,3 +224,17 @@ test('view markers separated by prose stay separate diagram shells', () => {
224
224
  assert.doesNotMatch(html, /view-tabs/);
225
225
  assert.equal([...html.matchAll(/diagram-shell/g)].length, 2);
226
226
  });
227
+
228
+ test('a prefix scopes heading ids to their document', () => {
229
+ const { html, headings } = renderMarkdown('## Context\n\n## Context', { prefix: '0007-cache' });
230
+ assert.match(html, /<h2 id="0007-cache__context">Context<\/h2>/);
231
+ assert.deepEqual(headings.map((h) => [h.slug, h.local]), [
232
+ ['0007-cache__context', 'context'],
233
+ ['0007-cache__context-2', 'context-2'],
234
+ ]);
235
+ });
236
+
237
+ test('without a prefix a heading id is its bare slug', () => {
238
+ const { headings } = renderMarkdown('## Core Components');
239
+ assert.deepEqual(headings.map((h) => [h.slug, h.local]), [['core-components', 'core-components']]);
240
+ });
@@ -32,7 +32,7 @@ function run(script, args) {
32
32
  return { code: status, stdout, stderr };
33
33
  }
34
34
 
35
- // What step 5 leaves on disk: the package, and nothing recorded about it yet.
35
+ // What step 6 leaves on disk: the package, and nothing recorded about it yet.
36
36
  function packageDir() {
37
37
  const dir = mkdtempSync(join(tmpdir(), 'rerun-safety-record-'));
38
38
  mkdirSync(join(dir, 'docs', 'adr'), { recursive: true });
@@ -1,9 +1,9 @@
1
1
  import { test } from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
3
  import { execFileSync } from 'node:child_process';
4
- import { readFileSync, mkdtempSync, writeFileSync } from 'node:fs';
4
+ import { readFileSync, mkdtempSync, writeFileSync, cpSync, mkdirSync } from 'node:fs';
5
5
  import { tmpdir } from 'node:os';
6
- import { join } from 'node:path';
6
+ import { join, dirname } from 'node:path';
7
7
 
8
8
  const fixtures = new URL('./fixtures/docs-pass/', import.meta.url).pathname;
9
9
 
@@ -169,3 +169,70 @@ test('render.mjs refuses a likec4 bundle with no palette', () => {
169
169
  '--theme', 'plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json',
170
170
  ]), /palette|likec4\.config\.json/i);
171
171
  });
172
+
173
+ test('a citation to an interview answer jumps to that answer, not the spine heading of the same name', () => {
174
+ const root = mkdtempSync(join(tmpdir(), 'render-anchor-'));
175
+ cpSync(fixtures, root, { recursive: true });
176
+ const arch = join(root, 'ARCHITECTURE.md');
177
+ const log = join(root, 'interview-log.md');
178
+ writeFileSync(arch, `${readFileSync(arch, 'utf8')}\n### Q3\n\nOwner: stated [Q3 · 2026-10-14](interview-log.md#q3)\n`);
179
+ writeFileSync(log, '# Interview log\n\n### Q3\n**Answer** Confirm top 3\n');
180
+ const out = mkdtempSync(join(tmpdir(), 'render-anchor-out-'));
181
+ const stub = (name, content) => { const p = join(out, name); writeFileSync(p, content); return p; };
182
+ execFileSync('node', [
183
+ 'plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs',
184
+ '--root', root, '--arch', arch, '--docs', log, '--out', out,
185
+ '--likec4-bundle', stub('l.js', LIKEC4_STUB),
186
+ '--mermaid-bundle', stub('m.js', '/*mermaid*/'),
187
+ '--theme', 'plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json',
188
+ ]);
189
+ const html = readFileSync(join(out, 'index.html'), 'utf8');
190
+ assert.match(html, /<h3 id="q3">Q3<\/h3>/);
191
+ assert.match(html, /<h3 id="interview-log__q3">Q3<\/h3>/);
192
+ assert.match(html, /<a href="#interview-log__q3">Q3 · 2026-10-14<\/a>/);
193
+ });
194
+
195
+ test('two documents with the same file name get different id prefixes', () => {
196
+ const root = mkdtempSync(join(tmpdir(), 'render-prefix-'));
197
+ cpSync(fixtures, root, { recursive: true });
198
+ for (const d of ['a', 'b']) {
199
+ mkdirSync(join(root, d));
200
+ writeFileSync(join(root, d, 'notes.md'), `# Notes ${d}\n\n## Context\n`);
201
+ }
202
+ const out = mkdtempSync(join(tmpdir(), 'render-prefix-out-'));
203
+ const stub = (name, content) => { const p = join(out, name); writeFileSync(p, content); return p; };
204
+ execFileSync('node', [
205
+ 'plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs',
206
+ '--root', root, '--arch', join(root, 'ARCHITECTURE.md'),
207
+ '--docs', join(root, 'a', 'notes.md'), join(root, 'b', 'notes.md'), '--out', out,
208
+ '--likec4-bundle', stub('l.js', LIKEC4_STUB),
209
+ '--mermaid-bundle', stub('m.js', '/*mermaid*/'),
210
+ '--theme', 'plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json',
211
+ ]);
212
+ const html = readFileSync(join(out, 'index.html'), 'utf8');
213
+ assert.match(html, /<h2 id="notes__context">/);
214
+ assert.match(html, /<h2 id="notes-2__context">/);
215
+ });
216
+
217
+ test('a file named like a deduped slug still gets its own id prefix', () => {
218
+ const root = mkdtempSync(join(tmpdir(), 'render-prefix-'));
219
+ cpSync(fixtures, root, { recursive: true });
220
+ const names = ['a/notes.md', 'b/notes.md', 'notes-2.md'];
221
+ for (const n of names) {
222
+ mkdirSync(join(root, dirname(n)), { recursive: true });
223
+ writeFileSync(join(root, n), `# ${n}\n\n## Context\n`);
224
+ }
225
+ const out = mkdtempSync(join(tmpdir(), 'render-prefix-out-'));
226
+ const stub = (name, content) => { const p = join(out, name); writeFileSync(p, content); return p; };
227
+ execFileSync('node', [
228
+ 'plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs',
229
+ '--root', root, '--arch', join(root, 'ARCHITECTURE.md'),
230
+ '--docs', ...names.map((n) => join(root, n)), '--out', out,
231
+ '--likec4-bundle', stub('l.js', LIKEC4_STUB),
232
+ '--mermaid-bundle', stub('m.js', '/*mermaid*/'),
233
+ '--theme', 'plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json',
234
+ ]);
235
+ const html = readFileSync(join(out, 'index.html'), 'utf8');
236
+ const prefixes = new Set([...html.matchAll(/<h2 id="([^"]*)__context">/g)].map((m) => m[1]));
237
+ assert.equal(prefixes.size, 3);
238
+ });
@@ -25,7 +25,7 @@ test('the discipline tells the run to record what it wrote', () => {
25
25
  assert.match(doc, /"revision"/, 'the state file shape belongs in the reference once');
26
26
  });
27
27
 
28
- test('the skill runs the recorder at the end of step 5', () => {
28
+ test('the skill runs the recorder at the end of step 6', () => {
29
29
  assert.match(skill(), /record\.mjs/);
30
30
  });
31
31
 
@@ -99,3 +99,9 @@ test('no two spine titles collide once normalised', () => {
99
99
  const seen = new Set(SPINE_TITLES.map(normTitle));
100
100
  assert.equal(seen.size, 16, 'two spine titles normalise to the same key');
101
101
  });
102
+
103
+ test('§4 and §13 explainers describe the top-3 tie', () => {
104
+ assert.match(help.spine['Solution Strategy'].good, /goal it serves/);
105
+ assert.match(help.spine['Quality Requirements & SLOs'].what, /top three quality goals/);
106
+ assert.match(help.spine['Quality Requirements & SLOs'].good, /gives way first/);
107
+ });
@@ -26,3 +26,22 @@ test('accepts researched with a source suffix', () => {
26
26
  const t = { section: 'X', headers: ['A', 'src'], rows: [['a', 'researched [stripe docs]']] };
27
27
  assert.deepEqual(validateProvenance({ tables: [t] }), []);
28
28
  });
29
+
30
+ test('warns, never fails, on a stated row with no citation', () => {
31
+ const t = { section: 'Constraints', headers: ['C', 'src'], rows: [['azure', 'stated']] };
32
+ const out = validateProvenance({ tables: [t] });
33
+ assert.equal(out.length, 1);
34
+ assert.equal(out[0].level, 'warn');
35
+ assert.match(out[0].message, /"Constraints" row "azure": stated has no citation/);
36
+ });
37
+
38
+ test('accepts a cited stated row, with or without a quote', () => {
39
+ const t = {
40
+ section: 'Constraints', headers: ['C', 'src'],
41
+ rows: [
42
+ ['azure', 'stated [C1 · 2026-09-10](inputs/C1-kickoff-call.txt) "it has to run there"'],
43
+ ['owner', 'stated [Q2 · 2026-10-14](interview-log.md#q2)'],
44
+ ],
45
+ };
46
+ assert.deepEqual(validateProvenance({ tables: [t] }), []);
47
+ });
@@ -0,0 +1,58 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { spawnSync } from 'node:child_process';
4
+ import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';
5
+ import { tmpdir } from 'node:os';
6
+ import { join } from 'node:path';
7
+ import { buildInputs } from '../lib/inputs.mjs';
8
+
9
+ const CLI = 'plugins/solution-architect/skills/analyze-requirements/scripts/validate.mjs';
10
+ const FRONT = '---\nelectedDocs: [{"name":"threat-model","elected":false,"reason":"r"},{"name":"interface-contract","elected":false,"reason":"r"},{"name":"estimation","elected":false,"reason":"r"},{"name":"domain-overview","elected":false,"reason":"r"}]\n---\n\n';
11
+ const CALL = 'Maya: We pay for Azure already, so it has to run there.\n';
12
+
13
+ function setUp(archRel, body) {
14
+ const dir = mkdtempSync(join(tmpdir(), 'quotes-cli-'));
15
+ mkdirSync(join(dir, 'inputs'));
16
+ mkdirSync(join(dir, 'docs'));
17
+ writeFileSync(join(dir, 'inputs', 'C1-kickoff-call.txt'), CALL);
18
+ writeFileSync(join(dir, archRel), FRONT + body);
19
+ writeFileSync(join(dir, 'model.json'), JSON.stringify({ elements: {} }));
20
+ return dir;
21
+ }
22
+
23
+ const row = (cell) => `## 2 Constraints\n\n| Constraint | src |\n| --- | --- |\n| Azure | ${cell} |\n`;
24
+ const run = (dir, archRel, inputs) => spawnSync('node', [CLI, '--root', dir,
25
+ '--arch', join(dir, archRel), '--model', join(dir, 'model.json'),
26
+ ...(inputs ? ['--inputs', join(dir, 'inputs', 'C1-kickoff-call.txt')] : [])], { encoding: 'utf8' });
27
+
28
+ test('exact quote passes with no provenance warning', () => {
29
+ const dir = setUp('ARCHITECTURE.md', row('stated [C1 · 2026-09-10](inputs/C1-kickoff-call.txt) "it has to run there"'));
30
+ const r = run(dir, 'ARCHITECTURE.md', true);
31
+ assert.equal(r.status, 0, r.stdout);
32
+ assert.doesNotMatch(r.stdout, /WARN \[provenance\]/);
33
+ });
34
+
35
+ test('reworded quote fails with the closest sentence', () => {
36
+ const dir = setUp('ARCHITECTURE.md', row('stated [C1 · 2026-09-10](inputs/C1-kickoff-call.txt) "it must run on Azure"'));
37
+ const r = run(dir, 'ARCHITECTURE.md', true);
38
+ assert.equal(r.status, 1);
39
+ assert.match(r.stdout, /^FAIL \[quotes\] "it must run on Azure" not found/m);
40
+ });
41
+
42
+ test('citation to an input not passed with --inputs fails the links check', () => {
43
+ const dir = setUp('ARCHITECTURE.md', row('stated [C1 · 2026-09-10](inputs/C1-kickoff-call.txt) "it has to run there"'));
44
+ const r = run(dir, 'ARCHITECTURE.md', false);
45
+ assert.equal(r.status, 1);
46
+ assert.match(r.stdout, /^FAIL \[links\] .*target file missing/m);
47
+ });
48
+
49
+ test('citation paths resolve from a nested ARCHITECTURE.md', async () => {
50
+ const dir = setUp('docs/ARCHITECTURE.md', row('stated [C1 · 2026-09-10](../inputs/C1-kickoff-call.txt) "it has to run there"'));
51
+ const inputs = await buildInputs({
52
+ root: dir, archPath: join(dir, 'docs', 'ARCHITECTURE.md'), modelPath: join(dir, 'model.json'),
53
+ inputPaths: [join(dir, 'inputs', 'C1-kickoff-call.txt')],
54
+ });
55
+ assert.equal(inputs.citations[0].path, 'inputs/C1-kickoff-call.txt');
56
+ assert.ok(inputs.sources.has('inputs/C1-kickoff-call.txt'));
57
+ assert.ok(inputs.files.includes('inputs/C1-kickoff-call.txt'));
58
+ });