@v11g/agents-rock 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/README.md +65 -0
  2. package/bin/agents-rock.mjs +4 -0
  3. package/package.json +13 -0
  4. package/plugins/solution-architect/.claude-plugin/plugin.json +9 -0
  5. package/plugins/solution-architect/skills/analyze-requirements/README.md +75 -0
  6. package/plugins/solution-architect/skills/analyze-requirements/SKILL.md +31 -0
  7. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/OFL.txt +98 -0
  8. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
  9. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-mono-latin-600-normal.woff2 +0 -0
  10. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
  11. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-500-normal.woff2 +0 -0
  12. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
  13. package/plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json +52 -0
  14. package/plugins/solution-architect/skills/analyze-requirements/assets/section-help.json +101 -0
  15. package/plugins/solution-architect/skills/analyze-requirements/assets/viewer-template.html +2389 -0
  16. package/plugins/solution-architect/skills/analyze-requirements/references/interview.md +53 -0
  17. package/plugins/solution-architect/skills/analyze-requirements/references/likec4.md +157 -0
  18. package/plugins/solution-architect/skills/analyze-requirements/references/project-types.md +60 -0
  19. package/plugins/solution-architect/skills/analyze-requirements/references/research.md +78 -0
  20. package/plugins/solution-architect/skills/analyze-requirements/references/viewer.md +772 -0
  21. package/plugins/solution-architect/skills/analyze-requirements/references/writing.md +206 -0
  22. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/cdp.mjs +74 -0
  23. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/chrome.mjs +66 -0
  24. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/companion-links.mjs +20 -0
  25. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-kinds.mjs +37 -0
  26. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-links.mjs +26 -0
  27. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-routes.mjs +27 -0
  28. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-sections.mjs +78 -0
  29. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/embed.mjs +8 -0
  30. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/er-entities.mjs +16 -0
  31. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/fonts.mjs +39 -0
  32. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/frontmatter.mjs +17 -0
  33. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/inputs.mjs +41 -0
  34. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-config.mjs +41 -0
  35. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-extract.mjs +29 -0
  36. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-steps.mjs +22 -0
  37. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-defs.mjs +20 -0
  38. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-flows.mjs +46 -0
  39. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-inline.mjs +31 -0
  40. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-links.mjs +7 -0
  41. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-list.mjs +64 -0
  42. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-render.mjs +127 -0
  43. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-shape.mjs +19 -0
  44. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-tables.mjs +30 -0
  45. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-views.mjs +48 -0
  46. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-wide.mjs +44 -0
  47. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/nav.mjs +72 -0
  48. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/offline.mjs +19 -0
  49. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/port.mjs +13 -0
  50. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/quality-gate.mjs +113 -0
  51. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/section-help.mjs +49 -0
  52. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/slug-registry.mjs +11 -0
  53. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-clusters.mjs +15 -0
  54. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-deployment.mjs +8 -0
  55. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-elections.mjs +20 -0
  56. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-links.mjs +23 -0
  57. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-model-tables.mjs +24 -0
  58. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-palette.mjs +34 -0
  59. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-provenance.mjs +20 -0
  60. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-tree.mjs +16 -0
  61. package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-config.mjs +19 -0
  62. package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-export.mjs +35 -0
  63. package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-gen.mjs +39 -0
  64. package/plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs +130 -0
  65. package/plugins/solution-architect/skills/analyze-requirements/scripts/serve.mjs +71 -0
  66. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/browser.test.mjs +553 -0
  67. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/companion-links.test.mjs +60 -0
  68. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-kinds.test.mjs +41 -0
  69. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-links.test.mjs +104 -0
  70. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-routes.test.mjs +54 -0
  71. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-sections.test.mjs +197 -0
  72. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/embed.test.mjs +28 -0
  73. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/er-entities.test.mjs +14 -0
  74. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/ARCHITECTURE.md +47 -0
  75. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/c4-src/broken/model.c4 +27 -0
  76. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/c4-src/pass/model.c4 +29 -0
  77. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/adr/0001-sample.md +18 -0
  78. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/estimate.html +2 -0
  79. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/estimation.md +8 -0
  80. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/model-broken.json +1 -0
  81. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/model.json +1 -0
  82. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/threat-model.md +8 -0
  83. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/sample-model.json +1 -0
  84. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/sample.c4 +28 -0
  85. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fonts.test.mjs +38 -0
  86. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/frontmatter.test.mjs +27 -0
  87. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/inputs.test.mjs +72 -0
  88. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-config-cli.test.mjs +26 -0
  89. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-config.test.mjs +74 -0
  90. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-export-cli.test.mjs +61 -0
  91. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-extract.test.mjs +37 -0
  92. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-gen-cli.test.mjs +73 -0
  93. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-steps.test.mjs +32 -0
  94. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-flows.test.mjs +82 -0
  95. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-links.test.mjs +16 -0
  96. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-provenance.test.mjs +42 -0
  97. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-render.test.mjs +226 -0
  98. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-tables.test.mjs +30 -0
  99. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-views.test.mjs +76 -0
  100. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-wide.test.mjs +76 -0
  101. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/nav.test.mjs +236 -0
  102. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/offline.test.mjs +37 -0
  103. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/quality-gate.test.mjs +86 -0
  104. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/quality-gates.test.mjs +20 -0
  105. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/render.test.mjs +171 -0
  106. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/research-workflow.test.mjs +38 -0
  107. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/section-help.test.mjs +101 -0
  108. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/serve.test.mjs +48 -0
  109. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-clusters.test.mjs +46 -0
  110. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-deployment.test.mjs +23 -0
  111. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-elections.test.mjs +30 -0
  112. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-links.test.mjs +38 -0
  113. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-model-tables.test.mjs +51 -0
  114. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-provenance.test.mjs +28 -0
  115. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-tree.test.mjs +43 -0
  116. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/viewer-template.test.mjs +1206 -0
  117. package/plugins/solution-architect/skills/analyze-requirements/scripts/validate.mjs +88 -0
  118. package/plugins/solution-architect/skills/analyze-requirements/workflows/research.js +57 -0
  119. package/plugins/solution-architect/skills/estimate/README.md +67 -0
  120. package/plugins/solution-architect/skills/estimate/SKILL.md +64 -0
  121. package/plugins/solution-architect/skills/estimate/assets/estimate-template.html +1128 -0
  122. package/plugins/solution-architect/skills/estimate/references/ai-multipliers.md +95 -0
  123. package/plugins/solution-architect/skills/estimate/references/interview.md +80 -0
  124. package/plugins/solution-architect/skills/estimate/references/slicing.md +55 -0
  125. package/plugins/solution-architect/skills/estimate/references/techniques.md +111 -0
  126. package/plugins/solution-architect/skills/estimate/references/writing.md +211 -0
  127. package/plugins/solution-architect/skills/estimate/scripts/compute.mjs +23 -0
  128. package/plugins/solution-architect/skills/estimate/scripts/lib/checks.mjs +128 -0
  129. package/plugins/solution-architect/skills/estimate/scripts/lib/components.mjs +19 -0
  130. package/plugins/solution-architect/skills/estimate/scripts/lib/estimate-math.mjs +85 -0
  131. package/plugins/solution-architect/skills/estimate/scripts/lib/inline.mjs +10 -0
  132. package/plugins/solution-architect/skills/estimate/scripts/lib/redact.mjs +30 -0
  133. package/plugins/solution-architect/skills/estimate/scripts/lib/roadmap.mjs +32 -0
  134. package/plugins/solution-architect/skills/estimate/scripts/lib/rollup.mjs +122 -0
  135. package/plugins/solution-architect/skills/estimate/scripts/lib/schema.mjs +128 -0
  136. package/plugins/solution-architect/skills/estimate/scripts/render.mjs +65 -0
  137. package/plugins/solution-architect/skills/estimate/scripts/test/browser.test.mjs +623 -0
  138. package/plugins/solution-architect/skills/estimate/scripts/test/compute.test.mjs +88 -0
  139. package/plugins/solution-architect/skills/estimate/scripts/test/e2e.test.mjs +34 -0
  140. package/plugins/solution-architect/skills/estimate/scripts/test/estimate-math.test.mjs +112 -0
  141. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/booking-inputs.json +58 -0
  142. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-fail.md +30 -0
  143. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-pass.md +60 -0
  144. package/plugins/solution-architect/skills/estimate/scripts/test/quality-gates.test.mjs +20 -0
  145. package/plugins/solution-architect/skills/estimate/scripts/test/references.test.mjs +71 -0
  146. package/plugins/solution-architect/skills/estimate/scripts/test/render.test.mjs +121 -0
  147. package/plugins/solution-architect/skills/estimate/scripts/test/schema.test.mjs +129 -0
  148. package/plugins/solution-architect/skills/estimate/scripts/test/validate.test.mjs +72 -0
  149. package/plugins/solution-architect/skills/estimate/scripts/validate.mjs +20 -0
  150. package/plugins/solution-architect/skills/new-lead/README.md +48 -0
  151. package/plugins/solution-architect/skills/new-lead/SKILL.md +113 -0
  152. package/plugins/solution-architect/skills/new-lead/assets/dashboard/detail.html +842 -0
  153. package/plugins/solution-architect/skills/new-lead/assets/dashboard/index.html +655 -0
  154. package/plugins/solution-architect/skills/new-lead/assets/dashboard/start.sh +3 -0
  155. package/plugins/solution-architect/skills/new-lead/assets/dashboard/stats.mjs +98 -0
  156. package/plugins/solution-architect/skills/new-lead/assets/dashboard/vendor/reactflow-bundle.js +473 -0
  157. package/plugins/solution-architect/skills/new-lead/assets/vendor-build/entry.jsx +33 -0
  158. package/plugins/solution-architect/skills/new-lead/assets/vendor-build/package-lock.json +1055 -0
  159. package/plugins/solution-architect/skills/new-lead/assets/vendor-build/package.json +19 -0
  160. package/plugins/solution-architect/skills/new-lead/scripts/init-root.mjs +73 -0
  161. package/plugins/solution-architect/skills/new-lead/scripts/lead-upsert.mjs +31 -0
  162. package/plugins/solution-architect/skills/new-lead/scripts/lib/enrich.mjs +20 -0
  163. package/plugins/solution-architect/skills/new-lead/scripts/lib/map-nodes.mjs +124 -0
  164. package/plugins/solution-architect/skills/new-lead/scripts/lib/map.mjs +117 -0
  165. package/plugins/solution-architect/skills/new-lead/scripts/lib/port.mjs +15 -0
  166. package/plugins/solution-architect/skills/new-lead/scripts/lib/registry.mjs +116 -0
  167. package/plugins/solution-architect/skills/new-lead/scripts/serve.mjs +163 -0
  168. package/plugins/solution-architect/skills/new-lead/scripts/test/e2e-workspace.test.mjs +59 -0
  169. package/plugins/solution-architect/skills/new-lead/scripts/test/enrich.test.mjs +16 -0
  170. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/ARCHITECTURE.md +16 -0
  171. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/brief.md +4 -0
  172. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/index.html +11 -0
  173. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/proposal-non-tech.html +2 -0
  174. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/threat-model.html +2 -0
  175. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/estimation-inputs.json +6 -0
  176. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/estimation.json +10 -0
  177. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/notes.md +3 -0
  178. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/proposal-non-tech.md +3 -0
  179. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/rfp.md +3 -0
  180. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads.json +25 -0
  181. package/plugins/solution-architect/skills/new-lead/scripts/test/init-root.test.mjs +81 -0
  182. package/plugins/solution-architect/skills/new-lead/scripts/test/lead-upsert.test.mjs +67 -0
  183. package/plugins/solution-architect/skills/new-lead/scripts/test/map.test.mjs +72 -0
  184. package/plugins/solution-architect/skills/new-lead/scripts/test/port.test.mjs +31 -0
  185. package/plugins/solution-architect/skills/new-lead/scripts/test/registry-io.test.mjs +57 -0
  186. package/plugins/solution-architect/skills/new-lead/scripts/test/registry.test.mjs +49 -0
  187. package/plugins/solution-architect/skills/new-lead/scripts/test/serve.test.mjs +205 -0
  188. package/plugins/solution-architect/skills/new-lead/scripts/test/stats.test.mjs +92 -0
  189. package/plugins/solution-architect/skills/new-lead/scripts/test/validate-cli.test.mjs +24 -0
  190. package/plugins/solution-architect/skills/new-lead/scripts/test/vendor-bundle.test.mjs +9 -0
  191. package/plugins/solution-architect/skills/new-lead/scripts/validate.mjs +9 -0
  192. package/plugins/solution-architect/skills/proposal/README.md +36 -0
  193. package/plugins/solution-architect/skills/proposal/SKILL.md +58 -0
  194. package/plugins/solution-architect/skills/proposal/assets/proposal-template.html +82 -0
  195. package/plugins/solution-architect/skills/proposal/references/interview.md +63 -0
  196. package/plugins/solution-architect/skills/proposal/references/review.md +28 -0
  197. package/plugins/solution-architect/skills/proposal/references/writing.md +102 -0
  198. package/plugins/solution-architect/skills/proposal/scripts/derive.mjs +22 -0
  199. package/plugins/solution-architect/skills/proposal/scripts/lib/checks-client.mjs +75 -0
  200. package/plugins/solution-architect/skills/proposal/scripts/lib/checks-doc.mjs +54 -0
  201. package/plugins/solution-architect/skills/proposal/scripts/lib/checks.mjs +17 -0
  202. package/plugins/solution-architect/skills/proposal/scripts/lib/figures.mjs +43 -0
  203. package/plugins/solution-architect/skills/proposal/scripts/lib/jargon.mjs +9 -0
  204. package/plugins/solution-architect/skills/proposal/scripts/lib/sections.mjs +32 -0
  205. package/plugins/solution-architect/skills/proposal/scripts/render.mjs +60 -0
  206. package/plugins/solution-architect/skills/proposal/scripts/test/checks-client.test.mjs +144 -0
  207. package/plugins/solution-architect/skills/proposal/scripts/test/checks-doc.test.mjs +93 -0
  208. package/plugins/solution-architect/skills/proposal/scripts/test/docs.test.mjs +51 -0
  209. package/plugins/solution-architect/skills/proposal/scripts/test/e2e.test.mjs +30 -0
  210. package/plugins/solution-architect/skills/proposal/scripts/test/figures.test.mjs +81 -0
  211. package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-fail.md +22 -0
  212. package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-pass.md +55 -0
  213. package/plugins/solution-architect/skills/proposal/scripts/test/quality-gates.test.mjs +20 -0
  214. package/plugins/solution-architect/skills/proposal/scripts/test/render.test.mjs +70 -0
  215. package/plugins/solution-architect/skills/proposal/scripts/test/validate.test.mjs +40 -0
  216. package/plugins/solution-architect/skills/proposal/scripts/validate.mjs +20 -0
  217. package/src/cli/agents.mjs +12 -0
  218. package/src/cli/args.mjs +46 -0
  219. package/src/cli/install.mjs +68 -0
  220. package/src/cli/main.mjs +124 -0
  221. package/src/cli/picker.mjs +78 -0
  222. package/src/cli/registry.mjs +26 -0
  223. package/src/cli/uninstall.mjs +38 -0
@@ -0,0 +1,236 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { buildNav } from '../lib/nav.mjs';
4
+ import { routeMap } from '../lib/doc-routes.mjs';
5
+
6
+ const page = (title, docId, headings, section) => ({ title, docId, headings, section });
7
+ const h = (level, text, slug) => ({ level, text, slug });
8
+ const count = (nav, re) => [...nav.matchAll(re)].length;
9
+
10
+ test('each document becomes one collapsible group, not a flat link list', () => {
11
+ const nav = buildNav([
12
+ page('Architecture', 'doc-architecture', [h(2, 'Goals', 'goals')]),
13
+ page('Threat Model', 'doc-threat-model', [h(2, 'Threats', 'threats')]),
14
+ ]);
15
+ assert.equal(count(nav, /class="nav-group"/g), 2);
16
+ assert.match(nav, /<summary[^>]*>[\s\S]*?Architecture[\s\S]*?<\/summary>/);
17
+ assert.match(nav, /<summary[^>]*>[\s\S]*?Threat Model[\s\S]*?<\/summary>/);
18
+ });
19
+
20
+ test('group carries its document anchor and section count', () => {
21
+ const nav = buildNav([
22
+ page('Architecture', 'doc-architecture', [h(2, 'A', 'a'), h(2, 'B', 'b'), h(3, 'C', 'c')]),
23
+ ]);
24
+ assert.match(nav, /data-doc="doc-architecture"/);
25
+ assert.match(nav, /nav-group__count[^>]*>3</);
26
+ });
27
+
28
+ test('h3 headings are marked as sub-items so the rail shows depth', () => {
29
+ const nav = buildNav([page('D', 'doc-d', [h(2, 'Parent', 'parent'), h(3, 'Child', 'child')])]);
30
+ assert.match(nav, /class="nav-link"[^>]*href="#parent"/);
31
+ assert.match(nav, /class="nav-link nav-link--sub"[^>]*href="#child"/);
32
+ });
33
+
34
+ test('the first group is open and later groups are collapsed', () => {
35
+ const nav = buildNav([
36
+ page('First', 'doc-first', [h(2, 'A', 'a')]),
37
+ page('Second', 'doc-second', [h(2, 'B', 'b')]),
38
+ ]);
39
+ const groups = nav.match(/<details class="nav-group"[^>]*>/g);
40
+ assert.match(groups[0], / open/);
41
+ assert.doesNotMatch(groups[1], / open/);
42
+ });
43
+
44
+ test('titles and labels are html-escaped', () => {
45
+ const nav = buildNav([page('A & B', 'doc-a', [h(2, '<script>x</script>', 'x')])]);
46
+ assert.match(nav, /A &amp; B/);
47
+ assert.doesNotMatch(nav, /<script>/);
48
+ assert.match(nav, /&lt;script&gt;/);
49
+ });
50
+
51
+ test('a document with no sections still renders its group', () => {
52
+ const nav = buildNav([page('Empty', 'doc-empty', [])]);
53
+ assert.match(nav, /doc-empty/);
54
+ assert.match(nav, /nav-group__count[^>]*>0</);
55
+ });
56
+
57
+ test('every section link is filterable by its plain-text label', () => {
58
+ const nav = buildNav([page('D', 'doc-d', [h(2, 'Data Stores', 'data-stores')])]);
59
+ assert.match(nav, /data-label="data stores"/);
60
+ });
61
+
62
+ // A rail of 21 document groups is no better than a rail of 120 headings: the
63
+ // 17 ADRs bury everything else. Documents bucket into named sections so the
64
+ // whole decision-record run collapses to one row.
65
+ test('documents bucket into named sections', () => {
66
+ const nav = buildNav([
67
+ page('Architecture', 'doc-a', [h(2, 'Goals', 'goals')], 'Architecture'),
68
+ page('ADR 1', 'doc-1', [h(2, 'Status', 'status')], 'Decision Records'),
69
+ page('ADR 2', 'doc-2', [h(2, 'Status', 'status-2')], 'Decision Records'),
70
+ ]);
71
+ assert.equal(count(nav, /class="nav-sec"/g), 2);
72
+ assert.equal(count(nav, /class="nav-group"/g), 3);
73
+ assert.match(nav, /nav-sec__title[^>]*>Decision Records</);
74
+ });
75
+
76
+ test('a section counts its documents, not their headings', () => {
77
+ const nav = buildNav([
78
+ page('ADR 1', 'doc-1', [h(2, 'a', 'a'), h(2, 'b', 'b')], 'Decision Records'),
79
+ page('ADR 2', 'doc-2', [h(2, 'c', 'c')], 'Decision Records'),
80
+ ]);
81
+ assert.match(nav, /nav-sec__count[^>]*>2</);
82
+ });
83
+
84
+ test('only the first section opens, so a trailing ADR block stays collapsed', () => {
85
+ const nav = buildNav([
86
+ page('Arch', 'doc-a', [h(2, 'a', 'a')], 'Architecture'),
87
+ page('ADR 1', 'doc-1', [h(2, 'b', 'b')], 'Decision Records'),
88
+ ]);
89
+ const secs = nav.match(/<details class="nav-sec"[^>]*>/g);
90
+ assert.match(secs[0], / open/);
91
+ assert.doesNotMatch(secs[1], / open/);
92
+ });
93
+
94
+ test('the open group is the first of the open section only', () => {
95
+ const nav = buildNav([
96
+ page('Arch', 'doc-a', [h(2, 'a', 'a')], 'Architecture'),
97
+ page('ADR 1', 'doc-1', [h(2, 'b', 'b')], 'Decision Records'),
98
+ page('ADR 2', 'doc-2', [h(2, 'c', 'c')], 'Decision Records'),
99
+ ]);
100
+ assert.equal(count(nav, /<details class="nav-group" open/g), 1);
101
+ });
102
+
103
+ test('pages with no section land in one default bucket', () => {
104
+ const nav = buildNav([page('A', 'doc-a', []), page('B', 'doc-b', [])]);
105
+ assert.equal(count(nav, /class="nav-sec"/g), 1);
106
+ assert.match(nav, /nav-sec__title[^>]*>Documents</);
107
+ });
108
+
109
+ test('section labels are html-escaped', () => {
110
+ const nav = buildNav([page('A', 'doc-a', [], 'R&D')]);
111
+ assert.match(nav, /nav-sec__title[^>]*>R&amp;D</);
112
+ });
113
+
114
+ // Headings carry inline markdown. The rail renders labels as plain text, so
115
+ // without stripping, a document titled with `org_id` shows its backticks in
116
+ // the sidebar and in the breadcrumb.
117
+ test('inline markdown never reaches the rail as literal syntax', () => {
118
+ const nav = buildNav([
119
+ page('ADR: `org_id` and **RLS**', 'doc-a', [h(2, 'Uses `code`', 'uses-code')], 'Decision Records'),
120
+ ]);
121
+ assert.match(nav, /nav-group__title">ADR: org_id and RLS</);
122
+ assert.match(nav, /data-label="uses code"/);
123
+ assert.doesNotMatch(nav, /`/);
124
+ assert.doesNotMatch(nav, /\*\*/);
125
+ });
126
+
127
+ // A routed section is browsed from its index page, not from the rail: 15 record
128
+ // rows in the sidebar is the wall the whole two-level design exists to remove.
129
+ test('a routed section shows only its landing document in the rail', () => {
130
+ const nav = buildNav([
131
+ { ...page('ADR 1', 'doc-1', [h(2, 'a', 'a')], 'Decision Records'), path: '/r/adr/0001.md' },
132
+ { ...page('Records', 'doc-idx', [h(2, 'b', 'b')], 'Decision Records'), path: '/r/adr/index.md' },
133
+ ]);
134
+ assert.equal(count(nav, /class="nav-group"/g), 1);
135
+ assert.match(nav, /nav-group__title">Records</);
136
+ assert.doesNotMatch(nav, /ADR 1/);
137
+ });
138
+
139
+ test('a routed section still counts every document it holds', () => {
140
+ const nav = buildNav([
141
+ { ...page('ADR 1', 'doc-1', [], 'Decision Records'), path: '/r/adr/0001.md' },
142
+ { ...page('ADR 2', 'doc-2', [], 'Decision Records'), path: '/r/adr/0002.md' },
143
+ { ...page('Records', 'doc-idx', [], 'Decision Records'), path: '/r/adr/index.md' },
144
+ ]);
145
+ assert.match(nav, /nav-sec__count[^>]*>3</);
146
+ });
147
+
148
+ test('a section with no index page keeps a group per document', () => {
149
+ const nav = buildNav([
150
+ { ...page('One', 'doc-1', [], 'Architecture'), path: '/r/a.md' },
151
+ { ...page('Two', 'doc-2', [], 'Architecture'), path: '/r/b.md' },
152
+ ]);
153
+ assert.equal(count(nav, /class="nav-group"/g), 2);
154
+ });
155
+
156
+ // The rail is the only way to change section, so every row has to name the
157
+ // route it opens — otherwise its head is a details toggle over documents that
158
+ // are not in the layout.
159
+ test('a rail section names the route it opens', () => {
160
+ const nav = buildNav([
161
+ { ...page('One', 'doc-1', [], 'Decision Records'), path: '/r/adr/0001.md' },
162
+ ]);
163
+ assert.match(nav, /class="nav-sec"[^>]*data-route="decision-records"/);
164
+ });
165
+
166
+ // The rail is the only way to change document, so every row has to name the
167
+ // route it opens — the head is no longer just a toggle over headings.
168
+ test('each document row names the route it opens', () => {
169
+ const pages = [
170
+ { ...page('One', 'doc-1', [], 'Architecture'), path: '/r/ARCHITECTURE.md' },
171
+ { ...page('Two', 'doc-2', [], 'Architecture'), path: '/r/docs/architecture/threat-model.md' },
172
+ ];
173
+ const nav = buildNav(pages, routeMap(pages));
174
+ assert.match(nav, /class="nav-group" data-route="architecture"/);
175
+ assert.match(nav, /class="nav-group" data-route="threat-model"/);
176
+ });
177
+
178
+ test('a section row routes to its index page when it has one', () => {
179
+ const pages = [
180
+ { ...page('ADR 1', 'doc-1', [], 'Decision Records'), path: '/r/adr/0001-a.md' },
181
+ { ...page('Records', 'doc-idx', [], 'Decision Records'), path: '/r/adr/index.md' },
182
+ ];
183
+ assert.match(buildNav(pages, routeMap(pages)), /class="nav-sec"[^>]*data-route="decision-records"/);
184
+ });
185
+
186
+ test('a section row routes to its first document when it has no index', () => {
187
+ const pages = [
188
+ { ...page('One', 'doc-1', [], 'Architecture'), path: '/r/ARCHITECTURE.md' },
189
+ { ...page('Two', 'doc-2', [], 'Architecture'), path: '/r/docs/architecture/threat-model.md' },
190
+ ];
191
+ assert.match(buildNav(pages, routeMap(pages)), /class="nav-sec"[^>]*data-route="architecture"/);
192
+ });
193
+
194
+ // The estimate skill's writing template mandates `# <Project> — Estimation`, so
195
+ // that H1 always arrives carrying the project prefix. A 191px rail clips it at
196
+ // the prefix, and the row then reads as a second copy of the spine's — the one
197
+ // word that distinguishes it is the word that gets cut. Companions are railed by
198
+ // kind; the full title stays on the row's hover title.
199
+ test('a companion document is railed by its kind, not its prefixed H1', () => {
200
+ const est = { ...page('Big Co — Atlas, Forge and Relay — Estimation', 'doc-est', [], 'Architecture'), kind: 'estimation' };
201
+ const nav = buildNav([est]);
202
+ assert.match(nav, /nav-group__title">Estimation</);
203
+ assert.match(nav, /title="Big Co — Atlas, Forge and Relay — Estimation"/);
204
+ });
205
+
206
+ test('the spine keeps its own title in the rail', () => {
207
+ const nav = buildNav([{ ...page('Big Co — The Planes', 'doc-a', [], 'Architecture'), kind: 'spine' }]);
208
+ assert.match(nav, /nav-group__title">Big Co — The Planes</);
209
+ });
210
+
211
+ test('an unclassified document keeps its own title in the rail', () => {
212
+ assert.match(buildNav([page('Interface Contract', 'doc-ic', [], 'Architecture')]),
213
+ /nav-group__title">Interface Contract</);
214
+ });
215
+
216
+ /* ---------- drawer sections ---------- */
217
+
218
+ // A Decision Records rail row is §14's table a second time. The records open in a
219
+ // drawer over the page the reader was already on, so the rail does not list them
220
+ // at all — leaving the row would keep exactly the redundancy the drawer removes.
221
+ const rec = (t, id) => ({ ...page(t, id, [h(2, 'Decision', 'd')], 'Decision Records'), drawer: true });
222
+
223
+ test('a drawer section is left out of the rail entirely', () => {
224
+ const nav = buildNav([
225
+ page('Architecture', 'doc-architecture', [h(2, 'Goals', 'goals')], 'Architecture'),
226
+ rec('ADR 0001', 'doc-adr-1'),
227
+ rec('ADR 0002', 'doc-adr-2'),
228
+ ]);
229
+ assert.equal(count(nav, /class="nav-sec"/g), 1);
230
+ assert.doesNotMatch(nav, /Decision Records/);
231
+ assert.doesNotMatch(nav, /doc-adr-1/);
232
+ });
233
+
234
+ test('a rail of nothing but drawer sections is empty rather than broken', () => {
235
+ assert.equal(buildNav([rec('ADR 0001', 'doc-adr-1')]).trim(), '');
236
+ });
@@ -0,0 +1,37 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { stripRemoteAssets } from '../lib/offline.mjs';
4
+
5
+ const FONT_CSS = "@font-face{font-family:IBM Plex Sans Variable;src:url(https://cdn.jsdelivr.net/x.woff2)format('woff2-variations');}";
6
+
7
+ test('replaces a remote webfont source with a local() source', () => {
8
+ const out = stripRemoteAssets(FONT_CSS);
9
+ assert.doesNotMatch(out, /url\(https?:/);
10
+ assert.match(out, /src:local\(system-ui\);/);
11
+ });
12
+
13
+ test('leaves svg fragment refs and data uris alone', () => {
14
+ const js = 'a=`url(#drop-shadow)`;b=`url("data:image/svg+xml;base64,AAA")`';
15
+ assert.equal(stripRemoteAssets(js), js);
16
+ });
17
+
18
+ test('keeps the host bundle valid whatever js quote style wraps the css', () => {
19
+ const cases = {
20
+ double: `var css = "${FONT_CSS}";`,
21
+ single: `var css = '${FONT_CSS.replace(/'/g, '"')}';`,
22
+ backtick: `var css = \`${FONT_CSS.replace(/'/g, '"')}\`;`,
23
+ };
24
+ for (const [style, src] of Object.entries(cases)) {
25
+ const out = stripRemoteAssets(src);
26
+ assert.doesNotMatch(out, /url\(https?:/, `${style}: url not stripped`);
27
+ assert.doesNotThrow(() => new Function(out), `${style}: broke the host string literal`);
28
+ }
29
+ });
30
+
31
+ test('throws if the bundle contains a literal </script> that would truncate the tag', () => {
32
+ assert.throws(() => stripRemoteAssets('var x = "</script>";'), /script/i);
33
+ });
34
+
35
+ test('catches the closing tag regardless of case (</SCRIPT>)', () => {
36
+ assert.throws(() => stripRemoteAssets('var x = "</SCRIPT>";'), /script/i);
37
+ });
@@ -0,0 +1,86 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { violations, LIMITS } from '../lib/quality-gate.mjs';
4
+
5
+ // The span counter walks braces. Braces that live inside a regex, a string or a
6
+ // comment are not structure, and counting them makes a short function measure
7
+ // long — the overshoot runs on into whatever follows it.
8
+ test('a brace escaped inside a regex does not inflate the span', () => {
9
+ const src = [
10
+ 'function short(s) {',
11
+ " return s.replace(/=>\\s*\\{/g, '');",
12
+ '}',
13
+ '',
14
+ 'function after() {',
15
+ ' return 1;',
16
+ '}',
17
+ ].join('\n');
18
+ assert.deepEqual(violations(src, { functionLines: 4 }), []);
19
+ });
20
+
21
+ test('a lone brace inside a string does not inflate the span', () => {
22
+ const src = [
23
+ 'function short() {',
24
+ " return '{';",
25
+ '}',
26
+ '',
27
+ 'function after() {',
28
+ ...Array(20).fill(' const x = 1;'),
29
+ '}',
30
+ ].join('\n');
31
+ assert.deepEqual(violations(src, { functionLines: 22 }), []);
32
+ });
33
+
34
+ test('a brace in a comment does not inflate the span', () => {
35
+ const src = [
36
+ 'function short() {',
37
+ ' // opens with { and never closes',
38
+ ' return 1;',
39
+ '}',
40
+ '',
41
+ 'function after() {',
42
+ ...Array(20).fill(' const x = 1;'),
43
+ '}',
44
+ ].join('\n');
45
+ assert.deepEqual(violations(src, { functionLines: 22 }), []);
46
+ });
47
+
48
+ // The limit is there to cap how much logic you hold in your head at once. A
49
+ // static HTML string is not logic, and neither is a comment — estimate's
50
+ // renderMethod is 30 lines of which 25 are prose inside one template literal.
51
+ test('a static template literal does not count toward function length', () => {
52
+ const src = [
53
+ 'function render() {',
54
+ ' return `',
55
+ ...Array(30).fill(' <p>static copy</p>'),
56
+ ' `;',
57
+ '}',
58
+ ].join('\n');
59
+ assert.deepEqual(violations(src, { functionLines: 22 }), []);
60
+ });
61
+
62
+ test('a long comment block does not count toward function length', () => {
63
+ const src = [
64
+ 'function short() {',
65
+ ...Array(30).fill(' // explaining at length'),
66
+ ' return 1;',
67
+ '}',
68
+ ].join('\n');
69
+ assert.deepEqual(violations(src, { functionLines: 22 }), []);
70
+ });
71
+
72
+ test('a genuinely long function is still reported', () => {
73
+ const src = ['function long() {', ...Array(30).fill(' const x = 1;'), '}'].join('\n');
74
+ assert.deepEqual(violations(src, { functionLines: 22 }), ['function of 32 lines (max 22)']);
75
+ });
76
+
77
+ test('an omitted limit skips its check', () => {
78
+ const src = ['function f(a, b, c, d) {', ' return a + b + c + d;', '}'].join('\n');
79
+ assert.deepEqual(violations(src, { functionLines: 22 }), [], 'params not checked when absent');
80
+ assert.deepEqual(violations(src, { params: 3 }), ['function with 4 params (max 3)']);
81
+ });
82
+
83
+ test('the module holds itself to the shared limits', () => {
84
+ assert.equal(LIMITS.fileLines, 200);
85
+ assert.equal(LIMITS.functionLines, 22);
86
+ });
@@ -0,0 +1,20 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { readFileSync } from 'node:fs';
4
+ import {
5
+ TEMPLATE_LIMITS, moduleFiles, templateScripts, violations,
6
+ } from '../lib/quality-gate.mjs';
7
+
8
+ const base = new URL('../..', import.meta.url).pathname;
9
+
10
+ for (const file of moduleFiles(base, ['scripts/lib', 'scripts', 'workflows'])) {
11
+ test(`gates: ${file.replace(base, '')}`, () => {
12
+ assert.deepEqual(violations(readFileSync(file, 'utf8')), []);
13
+ });
14
+ }
15
+
16
+ for (const { file, js } of templateScripts(base)) {
17
+ test(`gates: ${file.replace(base, '')}`, () => {
18
+ assert.deepEqual(violations(js, TEMPLATE_LIMITS), []);
19
+ });
20
+ }
@@ -0,0 +1,171 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { execFileSync } from 'node:child_process';
4
+ import { readFileSync, mkdtempSync, writeFileSync } from 'node:fs';
5
+ import { tmpdir } from 'node:os';
6
+ import { join } from 'node:path';
7
+
8
+ const fixtures = new URL('./fixtures/docs-pass/', import.meta.url).pathname;
9
+
10
+ // Shaped like a real likec4 1.59.2 bundle: a serialised theme carrying the
11
+ // shared brand hex, and nodes resolving to a palette colour name. render.mjs
12
+ // refuses a bundle without this, because that is precisely what a model with no
13
+ // palette generates — valid, clean, and blue.
14
+ const THEME = JSON.parse(readFileSync(
15
+ new URL('../../assets/mermaid-theme.json', import.meta.url), 'utf8'));
16
+ const LIKEC4_STUB = '/*likec4*/`@font-face{src:url(https://cdn.jsdelivr.net/f.woff2)format("woff2")}`'
17
+ + `;primary:{elements:{fill:\`${THEME.likec4.brand}\`,stroke:\`#00524b\`,`
18
+ + 'hiContrast:`#c7ffff`,loContrast:`#b2ffff`}};shape:`rectangle`,color:`primary`';
19
+
20
+ test('render.mjs produces a self-contained index.html', () => {
21
+ const out = mkdtempSync(join(tmpdir(), 'analyze-requirements-render-'));
22
+ const stub = (name, content) => { const p = join(out, name); writeFileSync(p, content); return p; };
23
+ execFileSync('node', [
24
+ 'plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs',
25
+ '--root', fixtures, '--arch', `${fixtures}ARCHITECTURE.md`,
26
+ '--docs', `${fixtures}docs/adr/0001-sample.md`,
27
+ '--out', out,
28
+ '--likec4-bundle', stub('l.js', LIKEC4_STUB),
29
+ '--mermaid-bundle', stub('m.js', '/*mermaid*/'),
30
+ '--theme', 'plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json',
31
+ ]);
32
+ const html = readFileSync(join(out, 'index.html'), 'utf8');
33
+ assert.match(html, /<h2 id="core-components">/);
34
+ assert.match(html, /href="#core-components"/);
35
+ assert.match(html, /\/\*likec4\*\//);
36
+ assert.match(html, /\/\*mermaid\*\//);
37
+ // The stacks named IBM Plex on every platform and it resolved on almost none.
38
+ // Embedded at render time rather than committed, like the two bundles above.
39
+ assert.match(html, /@font-face\{font-family:'IBM Plex Sans'/);
40
+ assert.match(html, /url\(data:font\/woff2;base64,/);
41
+ assert.doesNotMatch(html, /url\(https?:/);
42
+ // Self-contained means nothing *loads* from the network, while research.md §3
43
+ // requires every researched fact to carry a source URL as visible text. So
44
+ // rather than forbid http outright (or blocklist loadable positions, which a
45
+ // later srcset/fetch/@import would slip past), every URL in the page must
46
+ // originate in the rendered documents — bundles and template code contribute
47
+ // none, in any syntactic position. The one exception is svg's xmlns.
48
+ const docs = readFileSync(join(fixtures, 'ARCHITECTURE.md'), 'utf8')
49
+ + readFileSync(join(fixtures, 'docs/adr/0001-sample.md'), 'utf8');
50
+ for (const url of html.match(/https?:\/\/[^\s"'`)\]<]+/g) ?? []) {
51
+ assert.ok(url.startsWith('http://www.w3.org/') || docs.includes(url),
52
+ `${url} does not come from the documents — the page must stay self-contained`);
53
+ }
54
+ assert.match(html, /researched \[https:\/\/docs\.stripe\.com\/api\]/,
55
+ 'a researched fact\'s source URL must survive into the page as visible text');
56
+ // ARCHITECTURE.md heads its own section. Anything under docs/adr/ is a record:
57
+ // §14 Decisions already tables every one of them, so it opens in a drawer over
58
+ // that table and gets no rail row of its own.
59
+ assert.match(html, /nav-sec__title[^>]*>Architecture</);
60
+ assert.doesNotMatch(html, /nav-sec__title[^>]*>Decision Records</);
61
+ // Still in the document, though — a drawer needs something to show, and the
62
+ // route is what makes it linkable.
63
+ assert.match(html, /<div class="doc-section"[^>]*data-drawer/);
64
+ assert.match(html, /class="page"[^>]*data-route="0001-sample"/);
65
+ });
66
+
67
+ // A companion at the set root has no meaningful directory name — dirname is ".",
68
+ // and that string reached the rail as a section title. ARCHITECTURE.md was already
69
+ // special-cased out of this, but only by its index, so every *other* root-level
70
+ // document fell through to a row labelled ".". They belong with the spine they
71
+ // accompany.
72
+ test('root-level companions head the Architecture section, not "."', () => {
73
+ const out = mkdtempSync(join(tmpdir(), 'analyze-requirements-render-'));
74
+ const stub = (name, content) => { const p = join(out, name); writeFileSync(p, content); return p; };
75
+ execFileSync('node', [
76
+ 'plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs',
77
+ '--root', fixtures, '--arch', `${fixtures}ARCHITECTURE.md`,
78
+ '--docs', `${fixtures}threat-model.md`, `${fixtures}docs/adr/0001-sample.md`,
79
+ '--out', out,
80
+ '--likec4-bundle', stub('l.js', LIKEC4_STUB),
81
+ '--mermaid-bundle', stub('m.js', '/*mermaid*/'),
82
+ '--theme', 'plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json',
83
+ ]);
84
+ const html = readFileSync(join(out, 'index.html'), 'utf8');
85
+ // Absolute --docs took the set directory's own name; relative --docs took ".".
86
+ // Neither is a section a reader would recognise.
87
+ assert.doesNotMatch(html, /nav-sec__title[^>]*>Docs pass</);
88
+ assert.doesNotMatch(html, /data-section="\."/);
89
+ // Still reachable, under the spine's own section.
90
+ assert.match(html, /nav-sec__title[^>]*>Architecture</);
91
+ assert.match(html, /class="page"[^>]*data-route="threat-model"/);
92
+ });
93
+
94
+ // The same set, spelled the way a caller in the set directory spells it. The
95
+ // label must not depend on how the path was written — that is what made this
96
+ // invisible to the fixture and visible in a real run.
97
+ test('a root-level companion is spelling-independent', () => {
98
+ const out = mkdtempSync(join(tmpdir(), 'analyze-requirements-render-'));
99
+ const stub = (name, content) => { const p = join(out, name); writeFileSync(p, content); return p; };
100
+ const skill = new URL('../../', import.meta.url).pathname;
101
+ execFileSync('node', [
102
+ `${skill}scripts/render.mjs`,
103
+ '--root', '.', '--arch', 'ARCHITECTURE.md',
104
+ '--docs', 'threat-model.md', 'docs/adr/0001-sample.md',
105
+ '--out', out,
106
+ '--likec4-bundle', stub('l.js', LIKEC4_STUB),
107
+ '--mermaid-bundle', stub('m.js', '/*mermaid*/'),
108
+ '--theme', `${skill}assets/mermaid-theme.json`,
109
+ ], { cwd: fixtures });
110
+ const html = readFileSync(join(out, 'index.html'), 'utf8');
111
+ assert.doesNotMatch(html, /data-section="\."/);
112
+ assert.match(html, /nav-sec__title[^>]*>Architecture</);
113
+ });
114
+
115
+ // The estimation companion is the argument; the estimate skill's page beside
116
+ // it is the same numbers made interactive. The viewer links it when — and only
117
+ // when — the file exists, so an md-only run renders exactly as before.
118
+ test('the estimation companion links a sibling estimate.html', () => {
119
+ const out = mkdtempSync(join(tmpdir(), 'analyze-requirements-render-'));
120
+ const stub = (name, content) => { const p = join(out, name); writeFileSync(p, content); return p; };
121
+ execFileSync('node', [
122
+ 'plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs',
123
+ '--root', fixtures, '--arch', `${fixtures}ARCHITECTURE.md`,
124
+ '--docs', `${fixtures}docs/estimation.md`,
125
+ '--out', out,
126
+ '--likec4-bundle', stub('l.js', LIKEC4_STUB),
127
+ '--mermaid-bundle', stub('m.js', '/*mermaid*/'),
128
+ '--theme', 'plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json',
129
+ ]);
130
+ const html = readFileSync(join(out, 'index.html'), 'utf8');
131
+ assert.match(html, /class="page"[^>]*data-kind="estimation"/);
132
+ assert.match(html, /class="estimate-link"><a href="[^"]*estimate\.html"/);
133
+ });
134
+
135
+ test('render.mjs fails loudly on a missing bundle', () => {
136
+ assert.throws(() => execFileSync('node', [
137
+ 'plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs',
138
+ '--root', fixtures, '--arch', `${fixtures}ARCHITECTURE.md`,
139
+ '--out', mkdtempSync(join(tmpdir(), 'analyze-requirements-render-')),
140
+ '--likec4-bundle', '/nope/l.js', '--mermaid-bundle', '/nope/m.js',
141
+ '--theme', 'plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json',
142
+ ]));
143
+ });
144
+
145
+ test('render.mjs throws loudly if a bundle contains a literal </script>', () => {
146
+ const out = mkdtempSync(join(tmpdir(), 'analyze-requirements-render-'));
147
+ const stub = (name, content) => { const p = join(out, name); writeFileSync(p, content); return p; };
148
+ assert.throws(() => execFileSync('node', [
149
+ 'plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs',
150
+ '--root', fixtures, '--arch', `${fixtures}ARCHITECTURE.md`,
151
+ '--out', out,
152
+ '--likec4-bundle', stub('l.js', LIKEC4_STUB + 'var s = "</script>";'),
153
+ '--mermaid-bundle', stub('m.js', '/*mermaid*/'),
154
+ '--theme', 'plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json',
155
+ ]));
156
+ });
157
+
158
+ // The failure this exists for: a valid model with no palette generates a clean
159
+ // bundle, exit 0, every node LikeC4 default blue, and nothing anywhere says so.
160
+ test('render.mjs refuses a likec4 bundle with no palette', () => {
161
+ const out = mkdtempSync(join(tmpdir(), 'analyze-requirements-render-'));
162
+ const stub = (name, content) => { const p = join(out, name); writeFileSync(p, content); return p; };
163
+ assert.throws(() => execFileSync('node', [
164
+ 'plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs',
165
+ '--root', fixtures, '--arch', `${fixtures}ARCHITECTURE.md`,
166
+ '--out', out,
167
+ '--likec4-bundle', stub('l.js', '/*likec4*/;shape:`rectangle`,color:`primary`'),
168
+ '--mermaid-bundle', stub('m.js', '/*mermaid*/'),
169
+ '--theme', 'plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json',
170
+ ]), /palette|likec4\.config\.json/i);
171
+ });
@@ -0,0 +1,38 @@
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/research.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 = { phases: [], logs: [] };
11
+ const fn = new AsyncFunction('agent', 'parallel', 'pipeline', 'phase', 'log', 'args', 'budget', src);
12
+ const parallel = (thunks) => Promise.all(thunks.map((t) => t().catch(() => null)));
13
+ return fn(agentImpl, parallel, null, (p) => calls.phases.push(p), (m) => calls.logs.push(m), args,
14
+ { total: null, spent: () => 0, remaining: () => Infinity }).then((result) => ({ result, calls }));
15
+ }
16
+
17
+ const okAgent = async (prompt) => ({ facts: [{ fact: `re: ${prompt.slice(0, 20)}`, provenance: 'researched', source: 'x' }] });
18
+ const ARGS = { mode: 'greenfield', projectType: 'web', domain: 'billing', statedFacts: [{ claim: 'uses stripe' }], gaps: ['stripe'] };
19
+
20
+ test('greenfield runs all three phases and returns facts', async () => {
21
+ const { result, calls } = await run({ agentImpl: okAgent, args: ARGS });
22
+ assert.deepEqual(calls.phases, ['Domain', 'Stack', 'Design']);
23
+ assert.ok(result.domain.length > 0 && result.aspects.length > 0);
24
+ assert.equal(result.dropped.length, 0);
25
+ });
26
+
27
+ test('brownfield skips Design phase', async () => {
28
+ const { result, calls } = await run({ agentImpl: okAgent, args: { ...ARGS, mode: 'brownfield' } });
29
+ assert.ok(!calls.phases.includes('Design'));
30
+ assert.deepEqual(result.aspects, []);
31
+ });
32
+
33
+ test('failed agent lands in dropped and is logged', async () => {
34
+ const flaky = async (p) => (p.includes('Verify') ? null : okAgent(p));
35
+ const { result, calls } = await run({ agentImpl: flaky, args: { ...ARGS, mode: 'brownfield' } });
36
+ assert.equal(result.dropped.length, 1);
37
+ assert.ok(calls.logs.some((l) => l.includes('DROPPED')));
38
+ });