@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 @@
1
+ {"_stage":"layouted","projectId":"default","project":{"id":"default","title":"default"},"specification":{"tags":{"external":{"color":"tomato"}},"elements":{"person":{"style":{}},"system":{"style":{}},"container":{"style":{}}},"relationships":{},"deployments":{"node":{"style":{}}},"customColors":{}},"elements":{"customer":{"style":{},"title":"Customer","kind":"person","id":"customer"},"shop":{"style":{},"title":"Shop","kind":"system","id":"shop"},"stripe":{"style":{},"tags":["external"],"title":"Stripe","kind":"system","id":"stripe"},"shop.web":{"style":{},"title":"Web App","kind":"container","id":"shop.web"},"shop.api":{"style":{},"title":"API","kind":"container","id":"shop.api"}},"relations":{"11d69hw":{"title":"uses","source":{"model":"customer"},"target":{"model":"shop.web"},"id":"11d69hw"},"f0g4xx":{"title":"calls","source":{"model":"shop.web"},"target":{"model":"shop.api"},"id":"f0g4xx"},"17o84if":{"title":"charges","source":{"model":"shop.api"},"target":{"model":"stripe"},"id":"17o84if"}},"globals":{"predicates":{},"dynamicPredicates":{},"styles":{}},"views":{"index":{"_type":"element","tags":null,"links":null,"_stage":"layouted","sourcePath":"model.c4","description":null,"title":"Landscape view","id":"index","autoLayout":{"direction":"TB"},"hash":"Zpkl5rIaSedzHdqyW9I3uzWmnr1xmGSuxWovoEyV_-w","bounds":{"x":0,"y":0,"width":320,"height":826},"nodes":[{"id":"customer","parent":null,"level":0,"children":[],"inEdges":[],"outEdges":["m645my"],"title":"Customer","modelRef":"customer","shape":"rectangle","color":"primary","style":{"opacity":15,"size":"md"},"tags":[],"kind":"person","x":0,"y":0,"width":320,"height":180,"labelBBox":{"x":115,"y":76,"width":91,"height":24}},{"id":"shop","parent":null,"level":0,"children":[],"inEdges":["m645my"],"outEdges":["175sj3b"],"title":"Shop","modelRef":"shop","shape":"rectangle","color":"primary","style":{"opacity":15,"size":"md"},"tags":[],"kind":"system","x":0,"y":323,"width":320,"height":180,"labelBBox":{"x":135,"y":76,"width":51,"height":24}},{"id":"stripe","parent":null,"level":0,"children":[],"inEdges":["175sj3b"],"outEdges":[],"title":"Stripe","modelRef":"stripe","shape":"rectangle","color":"primary","style":{"opacity":15,"size":"md"},"tags":["external"],"kind":"system","x":0,"y":646,"width":320,"height":180,"labelBBox":{"x":132,"y":76,"width":56,"height":24}}],"edges":[{"id":"m645my","source":"customer","target":"shop","label":"uses","points":[[160,180],[160,221],[160,270],[160,313]],"labelBBox":{"x":161,"y":241,"width":34,"height":18},"parent":null,"relations":["11d69hw"],"color":"gray","line":"dashed","head":"normal"},{"id":"175sj3b","source":"shop","target":"stripe","label":"charges","points":[[160,503],[160,544],[160,593],[160,635]],"labelBBox":{"x":161,"y":564,"width":54,"height":18},"parent":null,"relations":["17o84if"],"color":"gray","line":"dashed","head":"normal"}]}},"deployments":{"elements":{"prod":{"style":{},"kind":"node","title":"Production","id":"prod"},"prod.api":{"id":"prod.api","element":"shop.api","style":{}},"prod.web":{"id":"prod.web","element":"shop.web","style":{}}},"relations":{}},"imports":{},"manualLayouts":{}}
@@ -0,0 +1,8 @@
1
+ # Threat Model
2
+
3
+ A companion that lives beside ARCHITECTURE.md at the set root, which is where
4
+ real sets put it.
5
+
6
+ ## Threats
7
+
8
+ None — this is a fixture.
@@ -0,0 +1 @@
1
+ {"_stage":"layouted","projectId":"default","project":{"id":"default","title":"default"},"specification":{"tags":{"external":{"color":"tomato"}},"elements":{"person":{"style":{}},"system":{"style":{}},"container":{"style":{}}},"relationships":{},"deployments":{"node":{"style":{}}},"customColors":{}},"elements":{"customer":{"style":{},"title":"Customer","kind":"person","id":"customer"},"shop":{"style":{},"title":"Shop","kind":"system","id":"shop"},"stripe":{"style":{},"tags":["external"],"title":"Stripe","kind":"system","id":"stripe"},"shop.web":{"style":{},"title":"Web App","kind":"container","id":"shop.web"},"shop.api":{"style":{},"title":"API","kind":"container","id":"shop.api"}},"relations":{"14kukt8":{"title":"uses","source":{"model":"customer"},"target":{"model":"shop.web"},"id":"14kukt8"},"1r8t8el":{"title":"calls","source":{"model":"shop.web"},"target":{"model":"shop.api"},"id":"1r8t8el"},"sbe3j":{"title":"charges","source":{"model":"shop.api"},"target":{"model":"stripe"},"id":"sbe3j"}},"globals":{"predicates":{},"dynamicPredicates":{},"styles":{}},"views":{"index":{"_type":"element","tags":null,"links":null,"_stage":"layouted","sourcePath":"sample.c4","description":null,"title":"Landscape view","id":"index","autoLayout":{"direction":"TB"},"hash":"Zpkl5rIaSedzHdqyW9I3uzWmnr1xmGSuxWovoEyV_-w","bounds":{"x":0,"y":0,"width":320,"height":826},"nodes":[{"id":"customer","parent":null,"level":0,"children":[],"inEdges":[],"outEdges":["m645my"],"title":"Customer","modelRef":"customer","shape":"rectangle","color":"primary","style":{"opacity":15,"size":"md"},"tags":[],"kind":"person","x":0,"y":0,"width":320,"height":180,"labelBBox":{"x":115,"y":76,"width":91,"height":24}},{"id":"shop","parent":null,"level":0,"children":[],"inEdges":["m645my"],"outEdges":["175sj3b"],"title":"Shop","modelRef":"shop","shape":"rectangle","color":"primary","style":{"opacity":15,"size":"md"},"tags":[],"kind":"system","x":0,"y":323,"width":320,"height":180,"labelBBox":{"x":135,"y":76,"width":51,"height":24}},{"id":"stripe","parent":null,"level":0,"children":[],"inEdges":["175sj3b"],"outEdges":[],"title":"Stripe","modelRef":"stripe","shape":"rectangle","color":"primary","style":{"opacity":15,"size":"md"},"tags":["external"],"kind":"system","x":0,"y":646,"width":320,"height":180,"labelBBox":{"x":132,"y":76,"width":56,"height":24}}],"edges":[{"id":"m645my","source":"customer","target":"shop","label":"uses","points":[[160,180],[160,221],[160,270],[160,313]],"labelBBox":{"x":161,"y":241,"width":34,"height":18},"parent":null,"relations":["14kukt8"],"color":"gray","line":"dashed","head":"normal"},{"id":"175sj3b","source":"shop","target":"stripe","label":"charges","points":[[160,503],[160,544],[160,593],[160,635]],"labelBBox":{"x":161,"y":564,"width":54,"height":18},"parent":null,"relations":["sbe3j"],"color":"gray","line":"dashed","head":"normal"}]}},"deployments":{"elements":{"prod":{"style":{},"kind":"node","title":"Production","id":"prod"},"prod.api":{"id":"prod.api","element":"shop.api","style":{}}},"relations":{}},"imports":{},"manualLayouts":{}}
@@ -0,0 +1,28 @@
1
+ specification {
2
+ element person
3
+ element system
4
+ element container
5
+ deploymentNode node
6
+ tag external
7
+ }
8
+ model {
9
+ customer = person 'Customer'
10
+ shop = system 'Shop' {
11
+ web = container 'Web App'
12
+ api = container 'API'
13
+ }
14
+ stripe = system 'Stripe' {
15
+ #external
16
+ }
17
+ customer -> web 'uses'
18
+ web -> api 'calls'
19
+ api -> stripe 'charges'
20
+ }
21
+ deployment {
22
+ node prod 'Production' {
23
+ instanceOf shop.api
24
+ }
25
+ }
26
+ views {
27
+ view index { include * }
28
+ }
@@ -0,0 +1,38 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { buildFontFaces } from '../lib/fonts.mjs';
4
+
5
+ const dir = new URL('../../assets/fonts/', import.meta.url).pathname;
6
+
7
+ // Two of the three stacks degrade across a genre boundary rather than within
8
+ // one: the serif falls Iowan → Charter → Georgia and stays a book serif, but
9
+ // IBM Plex Sans falls to whatever system-ui is and IBM Plex Mono to whatever the
10
+ // platform calls monospace. Those two are the ones worth the bytes — and
11
+ // mermaid-theme.json names both, so the diagrams miss them too.
12
+ test('every shipped weight becomes an inline @font-face', () => {
13
+ const css = buildFontFaces(dir);
14
+ assert.match(css, /font-family:'IBM Plex Sans'/);
15
+ assert.match(css, /font-family:'IBM Plex Mono'/);
16
+ for (const w of [400, 500, 600]) assert.match(css, new RegExp(`font-weight:${w}`));
17
+ assert.equal((css.match(/@font-face/g) || []).length, 5, 'sans 400/500/600 + mono 400/600');
18
+ });
19
+
20
+ test('the faces carry their own bytes and fetch nothing', () => {
21
+ const css = buildFontFaces(dir);
22
+ assert.match(css, /url\(data:font\/woff2;base64,[A-Za-z0-9+/=]+\) format\('woff2'\)/);
23
+ assert.doesNotMatch(css, /https?:/);
24
+ });
25
+
26
+ // Silent fallback is exactly how the viewer came to name IBM Plex in its CSS on
27
+ // machines that have never had it.
28
+ test('a missing font directory fails loudly rather than shipping a bare stack', () => {
29
+ assert.throws(() => buildFontFaces('/nope/fonts'));
30
+ });
31
+
32
+ // A directory that exists and holds nothing usable is the same failure as one
33
+ // that does not exist, and it must read the same way — an empty string here
34
+ // would ship a viewer whose CSS names fonts it has not embedded.
35
+ test('a directory with no faces is refused rather than silently empty', () => {
36
+ assert.throws(() => buildFontFaces(new URL('./fixtures/', import.meta.url).pathname),
37
+ /woff2/i);
38
+ });
@@ -0,0 +1,27 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { parseFrontmatter } from '../lib/frontmatter.mjs';
4
+
5
+ test('parses simple key: value pairs', () => {
6
+ const md = '---\nname: shop\nmode: brownfield\n---\n# Doc';
7
+ const { data } = parseFrontmatter(md);
8
+ assert.deepEqual(data, { name: 'shop', mode: 'brownfield' });
9
+ });
10
+
11
+ test('parses JSON values for electedDocs', () => {
12
+ const md = '---\nelectedDocs: [{"name":"threat-model","elected":false,"reason":"CLI tool"}]\n---';
13
+ const { data } = parseFrontmatter(md);
14
+ assert.equal(data.electedDocs[0].reason, 'CLI tool');
15
+ });
16
+
17
+ test('returns error when no frontmatter block', () => {
18
+ const { data, error } = parseFrontmatter('# Just a doc');
19
+ assert.equal(data, null);
20
+ assert.match(error, /no frontmatter/);
21
+ });
22
+
23
+ test('returns error for a malformed line', () => {
24
+ const { data, error } = parseFrontmatter('---\nnot a pair\n---');
25
+ assert.equal(data, null);
26
+ assert.match(error, /bad line/);
27
+ });
@@ -0,0 +1,72 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { execFileSync } from 'node:child_process';
4
+ import { 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
+ import { validateLinks } from '../lib/validate-links.mjs';
9
+
10
+ const dir = new URL('./fixtures/docs-pass/', import.meta.url).pathname;
11
+
12
+ async function anchorInputs(archMd) {
13
+ const scratch = mkdtempSync(join(tmpdir(), 'analyze-requirements-inputs-'));
14
+ const archPath = join(scratch, 'ARCHITECTURE.md');
15
+ const modelPath = join(scratch, 'model.json');
16
+ writeFileSync(archPath, archMd);
17
+ writeFileSync(modelPath, JSON.stringify({ elements: [], relationships: [] }));
18
+ return buildInputs({ root: scratch, archPath, modelPath });
19
+ }
20
+
21
+ test('buildInputs assembles root-relative validator inputs', async () => {
22
+ const inputs = await buildInputs({
23
+ root: dir,
24
+ archPath: `${dir}ARCHITECTURE.md`,
25
+ modelPath: `${dir}model.json`,
26
+ docPaths: [`${dir}docs/adr/0001-sample.md`],
27
+ });
28
+ assert.ok(inputs.frontmatter.electedDocs);
29
+ assert.ok(inputs.tables.length >= 3);
30
+ assert.ok(inputs.model.elements.length > 0);
31
+ assert.deepEqual(inputs.files.sort(), ['ARCHITECTURE.md', 'docs/adr/0001-sample.md']);
32
+ assert.ok(inputs.anchors['ARCHITECTURE.md'].includes('core-components'));
33
+ assert.ok(inputs.links.some((l) => l.fromDoc === 'ARCHITECTURE.md' && l.href === 'docs/adr/0001-sample.md'));
34
+ });
35
+
36
+ test('CLI exits 0 on the passing fixture', () => {
37
+ const out = execFileSync('node', [
38
+ 'plugins/solution-architect/skills/analyze-requirements/scripts/validate.mjs',
39
+ '--root', dir,
40
+ '--arch', `${dir}ARCHITECTURE.md`, '--model', `${dir}model.json`,
41
+ '--docs', `${dir}docs/adr/0001-sample.md`,
42
+ ]).toString();
43
+ assert.match(out, /all checks passed/);
44
+ });
45
+
46
+ test('CLI exits 1 when a check fails', () => {
47
+ assert.throws(() => execFileSync('node', [
48
+ 'plugins/solution-architect/skills/analyze-requirements/scripts/validate.mjs',
49
+ '--root', dir,
50
+ '--arch', `${dir}ARCHITECTURE.md`, '--model', `${dir}model-broken.json`,
51
+ '--docs', `${dir}docs/adr/0001-sample.md`,
52
+ ]));
53
+ });
54
+
55
+ // The anchor universe validate-links checks must mirror what the renderer actually
56
+ // gives an id: h2/h3 only, deduped per doc with the same -N suffix rule. Cross-doc
57
+ // id collisions are a viewer-side concern (D6, out of scope) so dedupe here is
58
+ // scoped per doc, matching how buildInputs computes anchors one doc at a time.
59
+ test('anchors collect only h2/h3 slugs, deduped per doc like the renderer', async () => {
60
+ const inputs = await anchorInputs('# Title\n\n## Consequences\n\n#### Deep\n\n## Consequences\n');
61
+ assert.deepEqual(inputs.anchors['ARCHITECTURE.md'], ['consequences', 'consequences-2']);
62
+ });
63
+
64
+ test('rejects a link to an h1 anchor: the renderer never gives h1 an id', async () => {
65
+ const inputs = await anchorInputs('# Title\n\n[bad](#title)\n');
66
+ assert.equal(validateLinks(inputs).length, 1);
67
+ });
68
+
69
+ test('accepts a link to a deduped -2 anchor matching the renderer', async () => {
70
+ const inputs = await anchorInputs('## Consequences\n\n## Consequences\n\n[ok](#consequences-2)\n');
71
+ assert.deepEqual(validateLinks(inputs), []);
72
+ });
@@ -0,0 +1,26 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { execFileSync } from 'node:child_process';
4
+ import { readFileSync, mkdtempSync } 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/likec4-config.mjs';
9
+ const theme = JSON.parse(readFileSync(
10
+ new URL('../../assets/mermaid-theme.json', import.meta.url), 'utf8'));
11
+
12
+ // LikeC4 reads the project config from the folder holding the .c4 sources, so
13
+ // this has to land beside the model — which the skill generates, which is why
14
+ // the plugin can own it at all.
15
+ test('the CLI writes likec4.config.json beside the model', () => {
16
+ const dir = mkdtempSync(join(tmpdir(), 'analyze-requirements-c4-'));
17
+ const out = execFileSync('node', [CLI, '--out', dir], { encoding: 'utf8' }).trim();
18
+ assert.equal(out, join(dir, 'likec4.config.json'));
19
+ const cfg = JSON.parse(readFileSync(out, 'utf8'));
20
+ assert.equal(cfg.styles.theme.colors.primary, theme.likec4.brand);
21
+ assert.equal(cfg.styles.defaults.color, 'primary');
22
+ });
23
+
24
+ test('the CLI fails loudly without a target directory', () => {
25
+ assert.throws(() => execFileSync('node', [CLI], { stdio: 'pipe' }));
26
+ });
@@ -0,0 +1,74 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { readFileSync } from 'node:fs';
4
+ import { buildLikec4Config } from '../lib/likec4-config.mjs';
5
+ import { validatePalette } from '../lib/validate-palette.mjs';
6
+
7
+ const theme = JSON.parse(
8
+ readFileSync(new URL('../../assets/mermaid-theme.json', import.meta.url), 'utf8'));
9
+
10
+ // The brand invariant used to be prose in references/likec4.md, carried out by
11
+ // whoever wrote the model. A model that simply omitted it was valid, generated
12
+ // clean, and shipped LikeC4's default blue beside teal mermaid diagrams with no
13
+ // signal anywhere. The plugin owns the palette now.
14
+ test('the config is built from the one palette both renderers are cut from', () => {
15
+ const cfg = buildLikec4Config(theme);
16
+ const colors = cfg.styles.theme.colors;
17
+ assert.equal(colors.primary, theme.likec4.brand);
18
+ // secondary/muted/gray are the neutral end of the same two-colour palette.
19
+ for (const name of ['secondary', 'muted', 'gray']) {
20
+ assert.equal(colors[name], theme.likec4.muted, `${name} is off-palette`);
21
+ }
22
+ });
23
+
24
+ // LikeC4 derives stroke and both contrast shades from a single hex — verified
25
+ // against 1.59.2: #0f766e yields stroke #00524b and hiContrast #c7ffff, which
26
+ // are exactly the values mermaid-theme.json already records. Writing the
27
+ // derived values ourselves would be inventing numbers we do not own.
28
+ test('each colour is one hex, not a hand-written triple', () => {
29
+ const colors = buildLikec4Config(theme).styles.theme.colors;
30
+ for (const [name, value] of Object.entries(colors)) {
31
+ assert.equal(typeof value, 'string', `${name} should be a single hex`);
32
+ assert.match(value, /^#[0-9a-f]{6}$/i);
33
+ }
34
+ });
35
+
36
+ test('the default colour is pinned rather than left to LikeC4', () => {
37
+ assert.equal(buildLikec4Config(theme).styles.defaults.color, 'primary');
38
+ });
39
+
40
+ // Shapes taken from real likec4 1.59.2 bundles.
41
+ const NODE = (c) => `shape:\`rectangle\`,color:\`${c}\``;
42
+ const THEMED = (hex) => `primary:{elements:{fill:\`${hex}\`,stroke:\`#00524b\`,`
43
+ + `hiContrast:\`#c7ffff\`,loContrast:\`#b2ffff\`}}`;
44
+
45
+ // This is the case that actually shipped: valid model, clean generate, exit 0,
46
+ // and every node painted LikeC4 default blue. A bundle generated without the
47
+ // config carries no serialised theme at all, so its absence is the signal.
48
+ test('a bundle generated without the config is caught', () => {
49
+ const bundle = `var x=1;${NODE('primary')};${NODE('primary')}`;
50
+ const found = validatePalette({ bundle, theme });
51
+ assert.equal(found.length, 1);
52
+ assert.match(found[0], /no theme palette|likec4\.config\.json/i);
53
+ });
54
+
55
+ test('a bundle carrying the palette passes', () => {
56
+ const bundle = `${THEMED(theme.likec4.brand)};${NODE('primary')};${NODE('muted')}`;
57
+ assert.deepEqual(validatePalette({ bundle, theme }), []);
58
+ });
59
+
60
+ test('a palette that drifted from the shared hex is caught', () => {
61
+ const found = validatePalette({ bundle: `${THEMED('#3b82f6')};${NODE('primary')}`, theme });
62
+ assert.equal(found.length, 1);
63
+ assert.match(found[0], /#3b82f6/);
64
+ });
65
+
66
+ // Counting hexes cannot catch this: a model declaring its own colour leaves the
67
+ // brand hex sitting in the bundle's colour registry, defined and unpainted. The
68
+ // resolved node colour is the only thing that says what is drawn.
69
+ test('nodes painted a colour outside the palette are caught', () => {
70
+ const bundle = `${THEMED(theme.likec4.brand)};${NODE('primary')};${NODE('ownblue')}`;
71
+ const found = validatePalette({ bundle, theme });
72
+ assert.equal(found.length, 1);
73
+ assert.match(found[0], /ownblue/);
74
+ });
@@ -0,0 +1,61 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { execFileSync } from 'node:child_process';
4
+ import { writeFileSync, mkdtempSync, readFileSync, chmodSync } 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/likec4-export.mjs';
9
+
10
+ // Same stub-npx shape as likec4-gen-cli.test.mjs: the export contract is tested
11
+ // without reaching the network. The stub writes STUB_JSON to whatever follows
12
+ // --outfile, which is how the shape guard is exercised with both shapes.
13
+ function stubNpx() {
14
+ const bin = mkdtempSync(join(tmpdir(), 'analyze-requirements-bin-'));
15
+ const log = join(bin, 'calls.log');
16
+ const npx = join(bin, 'npx');
17
+ writeFileSync(npx, [
18
+ '#!/bin/sh',
19
+ `echo "$@" >> ${JSON.stringify(log)}`,
20
+ 'prev=""',
21
+ 'for a in "$@"; do',
22
+ ' [ "$prev" = "--outfile" ] && printf %s "$STUB_JSON" > "$a"',
23
+ ' prev="$a"',
24
+ 'done',
25
+ 'exit 0',
26
+ ].join('\n'));
27
+ chmodSync(npx, 0o755);
28
+ return { bin, log };
29
+ }
30
+
31
+ function runCli(bin, json, args) {
32
+ const env = { ...process.env, PATH: `${bin}:${process.env.PATH}`, STUB_JSON: json };
33
+ return execFileSync('node', [CLI, ...args], { encoding: 'utf8', env, stdio: 'pipe' });
34
+ }
35
+
36
+ const MODEL = '{"elements":{"shop":{"kind":"system","title":"Shop"}}}';
37
+
38
+ test('the export is pinned to the arch-docs project', () => {
39
+ const { bin, log } = stubNpx();
40
+ const out = join(mkdtempSync(join(tmpdir(), 'analyze-requirements-out-')), 'model.json');
41
+ runCli(bin, MODEL, ['--dir', '/m', '--out', out]);
42
+ assert.match(readFileSync(log, 'utf8'), /export json --project arch-docs/);
43
+ });
44
+
45
+ test('a single-project model with elements passes and prints the outfile', () => {
46
+ const { bin } = stubNpx();
47
+ const out = join(mkdtempSync(join(tmpdir(), 'analyze-requirements-out-')), 'model.json');
48
+ assert.equal(runCli(bin, MODEL, ['--dir', '/m', '--out', out]).trim(), out);
49
+ });
50
+
51
+ test('an array of project objects is refused with a shape error', () => {
52
+ const { bin } = stubNpx();
53
+ const out = join(mkdtempSync(join(tmpdir(), 'analyze-requirements-out-')), 'model.json');
54
+ assert.throws(() => runCli(bin, `[${MODEL}]`, ['--dir', '/m', '--out', out]), /elements/);
55
+ });
56
+
57
+ test('the CLI fails loudly without a model directory or an outfile', () => {
58
+ const { bin } = stubNpx();
59
+ assert.throws(() => runCli(bin, MODEL, ['--out', '/m.json']));
60
+ assert.throws(() => runCli(bin, MODEL, ['--dir', '/m']));
61
+ });
@@ -0,0 +1,37 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { readFileSync } from 'node:fs';
4
+ import { extractModel } from '../lib/likec4-extract.mjs';
5
+
6
+ const raw = JSON.parse(readFileSync(new URL('./fixtures/sample-model.json', import.meta.url), 'utf8'));
7
+
8
+ test('extracts elements with kind and title', () => {
9
+ const model = extractModel(raw);
10
+ const api = model.elements.find((e) => e.id === 'shop.api');
11
+ assert.equal(api.kind, 'container');
12
+ assert.equal(api.title, 'API');
13
+ });
14
+
15
+ test('collects deployed element ids from instanceOf', () => {
16
+ const model = extractModel(raw);
17
+ assert.ok(model.deployed.includes('shop.api'));
18
+ assert.ok(!model.deployed.includes('shop.web'));
19
+ });
20
+
21
+ // A bare `likec4 export json` on a workspace with a named project emits an
22
+ // array of project objects. Guarded here, where the shape is consumed, so a
23
+ // stale or hand-made model.json cannot make validation run vacuously over
24
+ // zero elements — the wrapper only protects people who used the wrapper.
25
+ test('refuses an array of project objects', () => {
26
+ assert.throws(() => extractModel([raw]), /elements/);
27
+ });
28
+
29
+ test('refuses a model carrying no elements', () => {
30
+ assert.throws(() => extractModel({}), /elements/);
31
+ });
32
+
33
+ test('normalizes #external tag to kind external', () => {
34
+ const model = extractModel(raw);
35
+ const stripe = model.elements.find((e) => e.title === 'Stripe');
36
+ assert.equal(stripe.kind, 'external');
37
+ });
@@ -0,0 +1,73 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { execFileSync } from 'node:child_process';
4
+ import { writeFileSync, mkdtempSync, readFileSync, existsSync, chmodSync } 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/likec4-gen.mjs';
9
+
10
+ // A stub `npx` on PATH, so the gate is tested without reaching the network and
11
+ // without depending on which likec4 the machine happens to resolve. It logs
12
+ // every invocation, which is how "gen never ran" is asserted rather than assumed.
13
+ function stubNpx(validateExit) {
14
+ const bin = mkdtempSync(join(tmpdir(), 'analyze-requirements-bin-'));
15
+ const log = join(bin, 'calls.log');
16
+ const npx = join(bin, 'npx');
17
+ writeFileSync(npx, [
18
+ '#!/bin/sh',
19
+ `echo "$@" >> ${JSON.stringify(log)}`,
20
+ `[ "$2" = validate ] && exit ${validateExit}`,
21
+ 'exit 0',
22
+ ].join('\n'));
23
+ chmodSync(npx, 0o755);
24
+ return { bin, log };
25
+ }
26
+
27
+ function modelDir(withConfig) {
28
+ const dir = mkdtempSync(join(tmpdir(), 'analyze-requirements-model-'));
29
+ if (withConfig) writeFileSync(join(dir, 'likec4.config.json'), '{}');
30
+ return dir;
31
+ }
32
+
33
+ function runCli(bin, args) {
34
+ const env = { ...process.env, PATH: `${bin}:${process.env.PATH}` };
35
+ return execFileSync('node', [CLI, ...args], { encoding: 'utf8', env, stdio: 'pipe' });
36
+ }
37
+
38
+ test('a model that validates clean is generated', () => {
39
+ const { bin, log } = stubNpx(0);
40
+ const dir = modelDir(true);
41
+ const out = runCli(bin, ['--dir', dir, '--out', '/b.js']).trim();
42
+ const calls = readFileSync(log, 'utf8');
43
+ assert.match(calls, new RegExp(`likec4 validate ${dir}`));
44
+ assert.match(calls, /gen webcomponent --webcomponent-prefix c4/);
45
+ assert.equal(out, '/b.js');
46
+ });
47
+
48
+ // The failure this exists for: gen exits 0 on a broken workspace, so a bundle
49
+ // gets built and rendered and nothing says the model never parsed.
50
+ test('a model that fails validation is never generated', () => {
51
+ const { bin, log } = stubNpx(1);
52
+ const dir = modelDir(true);
53
+ assert.throws(() => runCli(bin, ['--dir', dir, '--out', '/b.js']));
54
+ const calls = readFileSync(log, 'utf8');
55
+ assert.match(calls, new RegExp(`likec4 validate ${dir}`));
56
+ assert.doesNotMatch(calls, /gen webcomponent/, 'gen ran after validate failed');
57
+ });
58
+
59
+ test('the CLI fails loudly without a model directory or an outfile', () => {
60
+ const { bin } = stubNpx(0);
61
+ assert.throws(() => runCli(bin, ['--out', '/b.js']));
62
+ assert.throws(() => runCli(bin, ['--dir', modelDir(true)]));
63
+ });
64
+
65
+ // The config carries the palette, and LikeC4 reads it from the model folder. A
66
+ // run that skips it generates blue diagrams that validate and generate clean, so
67
+ // the same gate refuses it — and refuses it before spending a likec4 run, which
68
+ // is also how the test proves the check is not merely a later warning.
69
+ test('generating without the palette config is refused before likec4 runs', () => {
70
+ const { bin, log } = stubNpx(0);
71
+ assert.throws(() => runCli(bin, ['--dir', modelDir(false), '--out', '/b.js']));
72
+ assert.equal(existsSync(log), false, 'likec4 ran before the config was checked');
73
+ });
@@ -0,0 +1,32 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { likec4Steps } from '../lib/likec4-steps.mjs';
4
+
5
+ const steps = likec4Steps({ dir: '/m', out: '/b.js' });
6
+
7
+ // `likec4 gen webcomponent` is not a validation gate. It generated a 2.2 MB
8
+ // bundle from a workspace carrying 194 validation errors — duplicate element ids
9
+ // from two conflicting `specification` blocks — without a word, exit 0. Prose
10
+ // telling the next reader to run `validate` first is the same kind of invariant
11
+ // the palette bug was: correct, unenforced, and skipped in the one run that
12
+ // mattered. Order is the whole product of this module.
13
+ test('validate runs before anything is generated', () => {
14
+ const names = steps.map(([, argv]) => argv[0]);
15
+ assert.deepEqual(names, ['validate', 'gen']);
16
+ });
17
+
18
+ test('both steps address the same model directory', () => {
19
+ for (const [, argv] of steps) assert.ok(argv.includes('/m'), `${argv[0]} lost the model dir`);
20
+ });
21
+
22
+ // Omitting the prefix yields <likec4-view> instead of <c4-view>: the template's
23
+ // markers never match and every diagram renders blank, with no error anywhere.
24
+ test('the generate step pins the custom-element prefix', () => {
25
+ const [, argv] = steps[1];
26
+ assert.deepEqual(argv.slice(0, 4), ['gen', 'webcomponent', '--webcomponent-prefix', 'c4']);
27
+ assert.ok(argv.includes('--outfile') && argv.includes('/b.js'));
28
+ });
29
+
30
+ test('every step is a likec4 invocation', () => {
31
+ for (const [bin] of steps) assert.equal(bin, 'likec4');
32
+ });
@@ -0,0 +1,82 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { readFlowGroup } from '../lib/md-flows.mjs';
4
+
5
+ // §7 Runtime Behaviour is three flows, each a bold lead-in, its prose, then its
6
+ // view marker. Stacked they are ~1400px of scroll nobody compares across — the
7
+ // same reason consecutive markers already tab. Prose between the markers is what
8
+ // stopped md-views seeing them as a group, so the prose travels into the panel
9
+ // with its own diagram instead of being left behind above the tabs.
10
+ const S7 = [
11
+ '**Google OAuth login.** The browser never sees the client secret.',
12
+ '',
13
+ '<!-- likec4:view flow-oauth-login -->',
14
+ '',
15
+ '**Tenant-scoped read.** The org id in the URL is never trusted on its own.',
16
+ '',
17
+ '<!-- likec4:view flow-tenant-scoped-read -->',
18
+ '',
19
+ '**Drop to Issues during an L10.** Flag, do not discuss.',
20
+ '',
21
+ '<!-- likec4:view flow-l10-drop-to-issue -->',
22
+ '',
23
+ '## 8. Data Stores',
24
+ ];
25
+
26
+ test('a run of prose-then-marker units is one group', () => {
27
+ const group = readFlowGroup(S7, 0);
28
+ assert.ok(group, 'no group found');
29
+ assert.equal(group.units.length, 3);
30
+ assert.equal(group.units[0].id, 'flow-oauth-login');
31
+ assert.equal(group.units[2].id, 'flow-l10-drop-to-issue');
32
+ });
33
+
34
+ // The bold lead-in is the flow's name, so it is the tab label — `flow-oauth-login`
35
+ // is a view id, not something a reader picked.
36
+ test('the bold lead-in becomes the tab label, without its trailing period', () => {
37
+ const { units } = readFlowGroup(S7, 0);
38
+ assert.equal(units[0].label, 'Google OAuth login');
39
+ assert.equal(units[1].label, 'Tenant-scoped read');
40
+ assert.equal(units[2].label, 'Drop to Issues during an L10');
41
+ });
42
+
43
+ test('the prose travels with its own diagram', () => {
44
+ const { units } = readFlowGroup(S7, 0);
45
+ assert.match(units[0].prose, /never sees the client secret/);
46
+ assert.doesNotMatch(units[0].prose, /org id in the URL/);
47
+ });
48
+
49
+ test('the group consumes exactly its own lines and stops at the next heading', () => {
50
+ const { next } = readFlowGroup(S7, 0);
51
+ assert.equal(S7[next].startsWith('## '), true, `stopped at ${JSON.stringify(S7[next])}`);
52
+ });
53
+
54
+ // One flow is not a group. §12 has a single diagram with prose above it and must
55
+ // keep reading as prose above a diagram, not a tab bar with one tab.
56
+ test('a single prose-then-marker unit is not a group', () => {
57
+ const one = ['**Only flow.** Prose.', '', '<!-- likec4:view flow-a -->', '', 'After.'];
58
+ assert.equal(readFlowGroup(one, 0), null);
59
+ });
60
+
61
+ // Consecutive markers with no prose are md-views' job and already tab. This must
62
+ // not take them over, or the same source grows two different renderings.
63
+ test('bare consecutive markers are left to md-views', () => {
64
+ const bare = ['<!-- likec4:view index -->', '<!-- likec4:view containers -->'];
65
+ assert.equal(readFlowGroup(bare, 0), null);
66
+ });
67
+
68
+ test('prose with no marker after it is not a flow', () => {
69
+ const plain = ['Just a paragraph.', '', 'Another one.'];
70
+ assert.equal(readFlowGroup(plain, 0), null);
71
+ });
72
+
73
+ // A unit whose prose is interrupted by a table is not a flow — the group has to
74
+ // be prose and a diagram, or the panel silently drops content.
75
+ test('a table between prose and marker breaks the group', () => {
76
+ const mixed = [
77
+ '**A.** Prose.', '', '| h |', '|---|', '| v |', '',
78
+ '<!-- likec4:view flow-a -->', '',
79
+ '**B.** Prose.', '', '<!-- likec4:view flow-b -->',
80
+ ];
81
+ assert.equal(readFlowGroup(mixed, 0), null);
82
+ });
@@ -0,0 +1,16 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { extractLinks } from '../lib/md-links.mjs';
4
+
5
+ test('extracts links from prose and table cells', () => {
6
+ const md = 'See [ADR-7](docs/adr/0007-gate.md) and | [api](ARCHITECTURE.md#core-components) |';
7
+ const links = extractLinks(md);
8
+ assert.deepEqual(links, [
9
+ { text: 'ADR-7', href: 'docs/adr/0007-gate.md' },
10
+ { text: 'api', href: 'ARCHITECTURE.md#core-components' },
11
+ ]);
12
+ });
13
+
14
+ test('returns empty array when no links', () => {
15
+ assert.deepEqual(extractLinks('plain text'), []);
16
+ });