@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,41 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { relative } from 'node:path';
3
+ import { parseFrontmatter } from './frontmatter.mjs';
4
+ import { parseTables } from './md-tables.mjs';
5
+ import { extractLinks } from './md-links.mjs';
6
+ import { erEntities } from './er-entities.mjs';
7
+ import { extractModel } from './likec4-extract.mjs';
8
+ import { nextSlug } from './slug-registry.mjs';
9
+
10
+ export async function buildInputs({ root, archPath, modelPath, docPaths = [] }) {
11
+ const arch = await readFile(archPath, 'utf8');
12
+ const docs = await readDocs(root, [archPath, ...docPaths]);
13
+ return {
14
+ frontmatter: parseFrontmatter(arch).data ?? {},
15
+ tables: parseTables(arch),
16
+ erNames: erEntities(arch),
17
+ model: extractModel(JSON.parse(await readFile(modelPath, 'utf8'))),
18
+ links: docs.flatMap((d) => extractLinks(d.md).map((l) => ({ fromDoc: d.path, href: l.href }))),
19
+ files: docs.map((d) => d.path),
20
+ anchors: Object.fromEntries(docs.map((d) => [d.path, headingSlugs(d.md)])),
21
+ };
22
+ }
23
+
24
+ async function readDocs(root, paths) {
25
+ return Promise.all(paths.map(async (p) => ({
26
+ path: relative(root, p),
27
+ md: await readFile(p, 'utf8'),
28
+ })));
29
+ }
30
+
31
+ // Mirrors md-render.mjs exactly: only h2/h3 get an id in the viewer, deduped
32
+ // with a shared -N suffix rule (see slug-registry.mjs). Dedupe scope is per doc
33
+ // here, matching how this function is called once per doc; the renderer's
34
+ // cross-doc dedupe is a viewer-side concern (D6, out of scope).
35
+ function headingSlugs(md) {
36
+ const registry = new Map();
37
+ return md.split('\n')
38
+ .map((l) => l.match(/^(#{2,3})\s+(.*)$/))
39
+ .filter(Boolean)
40
+ .map((m) => nextSlug(m[2].trim(), registry));
41
+ }
@@ -0,0 +1,41 @@
1
+ // The palette is the plugin's, not the model's.
2
+ //
3
+ // references/likec4.md used to tell whoever wrote the .c4 to declare the brand
4
+ // colour in `specification { }`. That is a deterministic invariant carried by
5
+ // prose: a model that omits it is still valid, still generates clean, still
6
+ // exits 0 — and paints every node LikeC4's default blue next to teal mermaid
7
+ // diagrams, with no signal at any step. Which is exactly what shipped.
8
+ //
9
+ // LikeC4 reads a project config from the folder holding the .c4 sources, and
10
+ // `styles.theme.colors` overrides the built-in colour names. Since the skill
11
+ // generates the model, it owns that folder, so the palette can be written as a
12
+ // build step instead of asked for in a paragraph. The target repo keeps only
13
+ // markdown; nothing about the model has to cooperate.
14
+ //
15
+ // The built-in names are overridden rather than a custom name added: a custom
16
+ // name only applies where something references it, and `styles.defaults.color`
17
+ // only reaches elements that declare no colour of their own. Overriding the
18
+ // names themselves means output lands in-palette however the model was written.
19
+ const NEUTRALS = ['secondary', 'muted', 'gray'];
20
+
21
+ // Naming the project here is what makes a bare `likec4 export json` emit an
22
+ // array (arch-docs + default) — likec4-export.mjs pins --project to this name.
23
+ export const PROJECT_NAME = 'arch-docs';
24
+
25
+ // One hex per colour. LikeC4 derives stroke and both contrast shades from it —
26
+ // checked against 1.59.2, where #0f766e yields exactly the #00524b / #c7ffff
27
+ // that mermaid-theme.json already records. Writing those out here would be
28
+ // restating derived values as if they were ours, and they would go stale the
29
+ // first time LikeC4 changes its derivation.
30
+ export function buildLikec4Config(theme) {
31
+ const colors = { primary: theme.likec4.brand };
32
+ for (const name of NEUTRALS) colors[name] = theme.likec4.muted;
33
+ return {
34
+ name: PROJECT_NAME,
35
+ styles: {
36
+ theme: { colors },
37
+ // Pinned, so a LikeC4 default change cannot quietly move the baseline.
38
+ defaults: { color: 'primary' },
39
+ },
40
+ };
41
+ }
@@ -0,0 +1,29 @@
1
+ // A bare `likec4 export json` on a workspace whose config names a project
2
+ // emits an array of project objects. Refused here, where the shape is
3
+ // consumed, so no path into the validator runs vacuously over zero elements.
4
+ export function extractModel(raw) {
5
+ if (Array.isArray(raw) || !raw?.elements) {
6
+ throw new Error('model JSON is not a single-project object carrying .elements — export it with scripts/likec4-export.mjs');
7
+ }
8
+ return { elements: listElements(raw), deployed: listDeployed(raw) };
9
+ }
10
+
11
+ function listElements(raw) {
12
+ return Object.entries(raw.elements).map(([id, el]) => ({
13
+ id,
14
+ kind: normalizeKind(el),
15
+ title: el.title,
16
+ }));
17
+ }
18
+
19
+ function normalizeKind(el) {
20
+ return (el.tags ?? []).includes('external') ? 'external' : el.kind;
21
+ }
22
+
23
+ function listDeployed(raw) {
24
+ const out = new Set();
25
+ for (const node of Object.values(raw.deployments?.elements ?? {})) {
26
+ if (node.element) out.add(node.element);
27
+ }
28
+ return [...out];
29
+ }
@@ -0,0 +1,22 @@
1
+ // The order is the point.
2
+ //
3
+ // `likec4 gen webcomponent` is not a validation gate: it produced a 2.2 MB
4
+ // bundle from a workspace carrying 194 validation errors — duplicate element ids
5
+ // from two conflicting `specification` blocks — silently, exit 0. The bundle
6
+ // renders, the viewer builds, and the only symptom is a model that quietly is
7
+ // not the one anybody wrote.
8
+ //
9
+ // viewer.md used to say "run `npx likec4 validate <dir>` first". That is the
10
+ // same shape of defect as the palette instruction it sits next to: a
11
+ // deterministic invariant carried by a sentence, correct and unenforced. Putting
12
+ // validate in front of gen in one list makes skipping it a code change rather
13
+ // than an omission.
14
+ export function likec4Steps({ dir, out }) {
15
+ return [
16
+ ['likec4', ['validate', dir]],
17
+ // --webcomponent-prefix pins the tag to <c4-view>. Omit it and LikeC4 emits
18
+ // <likec4-view>, the template's markers never match, and every diagram
19
+ // renders blank with no error.
20
+ ['likec4', ['gen', 'webcomponent', '--webcomponent-prefix', 'c4', '--outfile', out, dir]],
21
+ ];
22
+ }
@@ -0,0 +1,20 @@
1
+ import { inline } from './md-inline.mjs';
2
+
3
+ // A two-column table whose right column runs to prose is a definition list
4
+ // wearing a table costume — 19 rows of hairline dividers where a card grid
5
+ // reads in one pass. Two columns of short values (Property | Value) is real
6
+ // tabular data and stays a table, so the test is the right column's length.
7
+ const PROSE_LEN = 60;
8
+
9
+ export function isDefinitionTable(headers, rows) {
10
+ if (headers.length !== 2 || !rows.length) return false;
11
+ const total = rows.reduce((n, row) => n + (row[1] ?? '').length, 0);
12
+ return total / rows.length > PROSE_LEN;
13
+ }
14
+
15
+ export function renderDefinitions(rows) {
16
+ const items = rows
17
+ .map(([term, def]) => `<div class="def"><dt>${inline(term)}</dt><dd>${inline(def)}</dd></div>`)
18
+ .join('');
19
+ return `<dl class="def-grid">${items}</dl>`;
20
+ }
@@ -0,0 +1,46 @@
1
+ // Consecutive view markers already tab (md-views.mjs) — but §7's three flows have
2
+ // prose between them, so they fell through as three stacked shells: ~1400px of
3
+ // scroll nobody compares across, which is the exact thing tabs exist to fix. The
4
+ // prose is why they were not a group, so the prose travels into the panel with its
5
+ // own diagram rather than being stranded above a tab bar.
6
+
7
+ const MARKER = /^<!--\s*likec4:view\s+(\S+)\s*-->$/;
8
+ const LEAD = /^\*\*(.+?)\.?\*\*/;
9
+
10
+ // A flow is prose then exactly one marker. Anything else in between — a table, a
11
+ // fence, a heading — means this is not a flow, and guessing would silently drop
12
+ // that content into a panel it does not belong in.
13
+ function readUnit(lines, i) {
14
+ const prose = [];
15
+ let j = i;
16
+ while (j < lines.length) {
17
+ const line = lines[j].trim();
18
+ if (!line) { j += 1; continue; }
19
+ const marker = line.match(MARKER);
20
+ // A marker with no prose in front of it is md-views' business, not a flow —
21
+ // taking it over would give the same source two different renderings.
22
+ if (marker) return prose.length ? { id: marker[1], prose: prose.join(' '), next: j + 1 } : null;
23
+ if (!prose.length && !LEAD.test(line)) return null;
24
+ if (line.startsWith('#') || line.startsWith('|') || line.startsWith('```')) return null;
25
+ prose.push(lines[j]);
26
+ j += 1;
27
+ }
28
+ return null;
29
+ }
30
+
31
+ export function readFlowGroup(lines, i) {
32
+ const units = [];
33
+ let j = i;
34
+ for (;;) {
35
+ const unit = readUnit(lines, j);
36
+ if (!unit) break;
37
+ units.push({ id: unit.id, prose: unit.prose, label: unit.prose.match(LEAD)[1] });
38
+ j = unit.next;
39
+ }
40
+ // The blank lines after the last marker were separation inside the group, so
41
+ // hand back the next real line rather than making the caller step over them.
42
+ while (j < lines.length && !lines[j].trim()) j += 1;
43
+ // One flow reads as prose above a diagram and must stay that way; a tab bar with
44
+ // one tab is furniture around nothing.
45
+ return units.length > 1 ? { units, next: j } : null;
46
+ }
@@ -0,0 +1,31 @@
1
+ export function escapeHtml(s) {
2
+ return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
3
+ }
4
+
5
+ // For places that show heading text as plain text (the rail, the breadcrumb,
6
+ // title attributes) — the markers are syntax, not content.
7
+ export function stripInline(text) {
8
+ return text
9
+ .replace(/`([^`]+)`/g, '$1')
10
+ .replace(/\*\*([^*]+)\*\*/g, '$1')
11
+ .replace(/\[([^\]]*)\]\([^)\s]+\)/g, '$1');
12
+ }
13
+
14
+ // Every fact in a set carries where it came from, and the four words are a closed
15
+ // vocabulary (validate-provenance.mjs). Written in backticks they came out as
16
+ // <code> in accent teal — the same chip as `org_id` and `docker-compose.yml` — so
17
+ // the accent meant two unrelated things and the most repeated element in the
18
+ // document read as a snippet of code. Matched exactly: `observed_at` is a column
19
+ // name and `Observed` is not a member of the vocabulary.
20
+ const PROVENANCE = new Set(['observed', 'stated', 'researched', 'proposed']);
21
+
22
+ const codeOrMarker = (_, body) => (PROVENANCE.has(body)
23
+ ? `<span class="prov" data-prov="${body}">${body}</span>`
24
+ : `<code>${body}</code>`);
25
+
26
+ export function inline(text) {
27
+ return escapeHtml(text)
28
+ .replace(/`([^`]+)`/g, codeOrMarker)
29
+ .replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>')
30
+ .replace(/\[([^\]]*)\]\(([^)\s]+)\)/g, '<a href="$2">$1</a>');
31
+ }
@@ -0,0 +1,7 @@
1
+ export function extractLinks(md) {
2
+ const links = [];
3
+ const re = /\[([^\]]*)\]\(([^)\s]+)\)/g;
4
+ let m;
5
+ while ((m = re.exec(md)) !== null) links.push({ text: m[1], href: m[2] });
6
+ return links;
7
+ }
@@ -0,0 +1,64 @@
1
+ import { inline } from './md-inline.mjs';
2
+ import { ITEM, shapeOf } from './md-shape.mjs';
3
+
4
+ const INDENTED = /^\s+\S/;
5
+
6
+ // A long bullet wraps in the source, and its second line matches nothing. Ending
7
+ // the list there is what turned §4 Solution Strategy — five bullets, each with a
8
+ // trailing ADR link — into five one-item lists interleaved with five indented
9
+ // paragraphs, one per orphaned link. An indented continuation belongs to the item
10
+ // above it, which is what CommonMark calls a lazy continuation — only the
11
+ // indented half of it: an unindented continuation is left alone, because this
12
+ // renderer needs no blank line before a paragraph, so absorbing it would swallow
13
+ // the next block instead of just the item's own wrapped text.
14
+ //
15
+ // Whether an indented line still counts as a continuation, rather than a block
16
+ // of its own, is read from shapeOf — the one place that already answers that
17
+ // question for every other shape a line can be. A fence, table, heading or
18
+ // marker stays its own block, indented or not; only a plain line joins.
19
+ function isContinuation(lines, i) {
20
+ return INDENTED.test(lines[i]) && shapeOf(lines, i) === 'paragraph';
21
+ }
22
+
23
+ // Indent width varies (2 or 4 spaces), so depth is only ever compared against
24
+ // its neighbours — never against an absolute level.
25
+ function itemsFrom(lines, start) {
26
+ const items = [];
27
+ let i = start;
28
+ while (i < lines.length) {
29
+ const m = lines[i].match(ITEM);
30
+ if (m) {
31
+ items.push({ depth: Math.floor(m[1].length / 2), ordered: /\d/.test(m[2]), text: m[3] });
32
+ } else if (items.length && isContinuation(lines, i)) {
33
+ items[items.length - 1].text += ` ${lines[i].trim()}`;
34
+ } else break;
35
+ i += 1;
36
+ }
37
+ return { items, next: i };
38
+ }
39
+
40
+ // A nested list belongs inside the <li> above it, not beside it, or the
41
+ // stylesheet's `li > ul` spacing never applies and screen readers lose the
42
+ // parent/child relation.
43
+ function build(items, at, depth) {
44
+ const tag = items[at].ordered ? 'ol' : 'ul';
45
+ const out = [`<${tag}>`];
46
+ let i = at;
47
+ while (i < items.length && items[i].depth >= depth) {
48
+ out.push(`<li>${inline(items[i].text)}`);
49
+ i += 1;
50
+ if (i < items.length && items[i].depth > depth) {
51
+ const sub = build(items, i, items[i].depth);
52
+ out.push(sub.html);
53
+ i = sub.next;
54
+ }
55
+ out.push('</li>');
56
+ }
57
+ out.push(`</${tag}>`);
58
+ return { html: out.join(''), next: i };
59
+ }
60
+
61
+ export function renderList(lines, start) {
62
+ const { items, next } = itemsFrom(lines, start);
63
+ return { html: build(items, 0, items[0].depth).html, next };
64
+ }
@@ -0,0 +1,127 @@
1
+ import { nextSlug } from './slug-registry.mjs';
2
+ import { escapeHtml, inline } from './md-inline.mjs';
3
+ import { renderList } from './md-list.mjs';
4
+ import { shapeOf } from './md-shape.mjs';
5
+ import { isDefinitionTable, renderDefinitions } from './md-defs.mjs';
6
+ import { isWideTable, isCrampedTable, renderWideCards } from './md-wide.mjs';
7
+ import { renderViewGroup, renderFlowTabs } from './md-views.mjs';
8
+ import { readFlowGroup } from './md-flows.mjs';
9
+
10
+ export { escapeHtml };
11
+
12
+ export function renderMarkdown(md, slugs = new Map(), docSlugs = new Map()) {
13
+ const ctx = {
14
+ lines: md.replace(/^---\n[\s\S]*?\n---\n?/, '').split('\n'),
15
+ i: 0, html: [], headings: [], slugs, docSlugs, title: null, docId: null,
16
+ };
17
+ while (ctx.i < ctx.lines.length) dispatch(ctx);
18
+ return {
19
+ html: ctx.html.join('\n'),
20
+ headings: ctx.headings,
21
+ title: ctx.title ?? ctx.headings[0]?.text ?? 'Document',
22
+ docId: ctx.docId,
23
+ };
24
+ }
25
+
26
+ function dispatch(ctx) {
27
+ const shape = shapeOf(ctx.lines, ctx.i);
28
+ if (shape === 'blank') { ctx.i += 1; return; }
29
+ if (shape === 'heading') return renderHeading(ctx);
30
+ if (shape === 'fence') return renderFence(ctx);
31
+ if (shape === 'marker') return renderMarker(ctx);
32
+ if (shape === 'table') return renderTable(ctx);
33
+ if (shape === 'list') return renderListBlock(ctx);
34
+ return renderParagraph(ctx);
35
+ }
36
+
37
+ function renderListBlock(ctx) {
38
+ const { html, next } = renderList(ctx.lines, ctx.i);
39
+ ctx.html.push(html);
40
+ ctx.i = next;
41
+ }
42
+
43
+ function renderHeading(ctx) {
44
+ const [, hashes, raw] = ctx.lines[ctx.i].match(/^(#{1,6})\s+(.*)$/);
45
+ const level = hashes.length;
46
+ const text = raw.trim();
47
+ ctx.i += 1;
48
+ if (level === 1) {
49
+ const id = `doc-${nextSlug(text, ctx.docSlugs)}`;
50
+ ctx.title ??= text;
51
+ ctx.docId ??= id;
52
+ ctx.html.push(`<h1 id="${id}" class="doc-head">${inline(text)}</h1>`);
53
+ return;
54
+ }
55
+ if (level !== 2 && level !== 3) {
56
+ ctx.html.push(`<h${level}>${inline(text)}</h${level}>`);
57
+ return;
58
+ }
59
+ const slug = nextSlug(text, ctx.slugs);
60
+ ctx.html.push(`<h${level} id="${slug}">${inline(text)}</h${level}>`);
61
+ ctx.headings.push({ level, text, slug });
62
+ }
63
+
64
+ function renderFence(ctx) {
65
+ const lang = ctx.lines[ctx.i].trim().slice(3).trim();
66
+ const code = [];
67
+ let j = ctx.i + 1;
68
+ while (j < ctx.lines.length && ctx.lines[j].trim() !== '```') { code.push(ctx.lines[j]); j += 1; }
69
+ const body = escapeHtml(code.join('\n'));
70
+ ctx.i = j + 1;
71
+ if (lang !== 'mermaid') {
72
+ ctx.html.push(`<pre><code>${body}</code></pre>`);
73
+ return;
74
+ }
75
+ ctx.html.push(`<div class="diagram-shell"><div class="mermaid-canvas">${body}</div></div>`);
76
+ }
77
+
78
+ // Collects the whole run of markers, not one: blank lines between them are
79
+ // separation in the source, not in the reader's head.
80
+ function renderMarker(ctx) {
81
+ const ids = [];
82
+ let j = ctx.i;
83
+ while (j < ctx.lines.length) {
84
+ const marker = ctx.lines[j].trim().match(/^<!--\s*likec4:view\s+(\S+)\s*-->/);
85
+ if (marker) ids.push(marker[1]);
86
+ else if (ctx.lines[j].trim()) break;
87
+ j += 1;
88
+ }
89
+ ctx.html.push(renderViewGroup(ids));
90
+ ctx.i = j;
91
+ }
92
+
93
+ function renderTable(ctx) {
94
+ const cells = (line) => line.split('|').slice(1, -1).map((c) => c.trim());
95
+ const headers = cells(ctx.lines[ctx.i]);
96
+ const rows = [];
97
+ let j = ctx.i + 2;
98
+ while (j < ctx.lines.length && ctx.lines[j].startsWith('|')) { rows.push(cells(ctx.lines[j])); j += 1; }
99
+ ctx.i = j;
100
+ if (isDefinitionTable(headers, rows)) { ctx.html.push(renderDefinitions(rows)); return; }
101
+ if (isWideTable(headers, rows)) { ctx.html.push(renderWideCards(headers, rows)); return; }
102
+ const head = `<tr>${headers.map((c) => `<th>${inline(c)}</th>`).join('')}</tr>`;
103
+ const body = rows.map((r) => `<tr>${r.map((c) => `<td>${inline(c)}</td>`).join('')}</tr>`).join('');
104
+ const cls = isCrampedTable(headers) ? ' class="table--wide"' : '';
105
+ ctx.html.push(`<table${cls}>${head}${body}</table>`);
106
+ }
107
+
108
+ // Checked before the paragraph collector, because a flow starts as one: several
109
+ // prose-then-marker units in a row are §7's three scenarios, and stacked they are
110
+ // the scroll tabs exist to remove.
111
+ function renderParagraph(ctx) {
112
+ const group = readFlowGroup(ctx.lines, ctx.i);
113
+ if (group) {
114
+ ctx.html.push(renderFlowTabs(group.units));
115
+ ctx.i = group.next;
116
+ return;
117
+ }
118
+ const collected = [];
119
+ let j = ctx.i;
120
+ while (j < ctx.lines.length && shapeOf(ctx.lines, j) === 'paragraph') {
121
+ collected.push(ctx.lines[j]);
122
+ j += 1;
123
+ }
124
+ ctx.html.push(`<p>${inline(collected.join(' '))}</p>`);
125
+ ctx.i = j;
126
+ }
127
+
@@ -0,0 +1,19 @@
1
+ export const ITEM = /^(\s*)([-*]|\d+[.)])\s+(.*)$/;
2
+
3
+ export function isListItem(line) {
4
+ return ITEM.test(line);
5
+ }
6
+
7
+ // The single source of "what kind of line is this" that both the block
8
+ // dispatcher and the list continuation rule read from. A shape added here
9
+ // is a shape every caller sees — nothing else gets to redeclare the list.
10
+ export function shapeOf(lines, i) {
11
+ const line = lines[i];
12
+ if (!line.trim()) return 'blank';
13
+ if (/^#{1,6}\s+/.test(line)) return 'heading';
14
+ if (line.trim().startsWith('```')) return 'fence';
15
+ if (/^<!--\s*likec4:view\s+\S+\s*-->/.test(line.trim())) return 'marker';
16
+ if (line.startsWith('|') && /^\|[\s|:-]+\|$/.test((lines[i + 1] ?? '').trim())) return 'table';
17
+ if (isListItem(line)) return 'list';
18
+ return 'paragraph';
19
+ }
@@ -0,0 +1,30 @@
1
+ export function parseTables(md) {
2
+ const lines = md.split('\n');
3
+ const tables = [];
4
+ let section = '';
5
+ for (let i = 0; i < lines.length; i += 1) {
6
+ if (lines[i].startsWith('#')) section = lines[i].replace(/^#+\s*/, '');
7
+ if (!isHeaderRow(lines, i)) continue;
8
+ const table = readTable(lines, i, section);
9
+ tables.push(table);
10
+ i += table.rows.length + 1;
11
+ }
12
+ return tables;
13
+ }
14
+
15
+ function isHeaderRow(lines, i) {
16
+ const next = lines[i + 1] ?? '';
17
+ return lines[i].startsWith('|') && /^\|[\s|:-]+\|$/.test(next.trim());
18
+ }
19
+
20
+ function readTable(lines, i, section) {
21
+ const rows = [];
22
+ for (let j = i + 2; j < lines.length && lines[j].startsWith('|'); j += 1) {
23
+ rows.push(cells(lines[j]));
24
+ }
25
+ return { section, headers: cells(lines[i]), rows };
26
+ }
27
+
28
+ function cells(line) {
29
+ return line.split('|').slice(1, -1).map((c) => c.trim());
30
+ }
@@ -0,0 +1,48 @@
1
+ import { escapeHtml, inline } from './md-inline.mjs';
2
+
3
+ // Consecutive view markers are one system at several zoom levels — stacked they
4
+ // are ~1900px of scroll the reader cannot compare across. Markers with prose
5
+ // between them are separate scenarios, and md-flows.mjs groups those instead,
6
+ // carrying each one's prose into its own panel.
7
+
8
+ const shell = (id) => `<div class="diagram-shell"><c4-view view-id="${id}"></c4-view></div>`;
9
+
10
+ function tab(id, label, i) {
11
+ return `<button class="view-tab" role="tab" id="tab-${id}" aria-controls="panel-${id}"`
12
+ + ` aria-selected="${i === 0}"${i ? ' tabindex="-1"' : ''}>${label}</button>`;
13
+ }
14
+
15
+ function panel(id, body, i) {
16
+ return `<div class="view-panel"${i ? ' hidden' : ''} id="panel-${id}" role="tabpanel"`
17
+ + ` aria-labelledby="tab-${id}">${body}</div>`;
18
+ }
19
+
20
+ function tabsEl(items) {
21
+ return [
22
+ '<div class="view-tabs">',
23
+ `<div class="view-tabs__bar" role="tablist">${items.map((t) => t.tab).join('')}</div>`,
24
+ items.map((t) => t.panel).join(''),
25
+ '</div>',
26
+ ].join('');
27
+ }
28
+
29
+ export function renderViewGroup(ids) {
30
+ const safe = ids.map(escapeHtml);
31
+ if (safe.length === 1) return shell(safe[0]);
32
+ return tabsEl(safe.map((id, i) => ({
33
+ tab: tab(id, id, i),
34
+ panel: panel(id, shell(id), i),
35
+ })));
36
+ }
37
+
38
+ // The lead-in is already the tab label, so it is stripped from the prose rather
39
+ // than repeated as bold text at the top of the panel it labels.
40
+ const dropLead = (prose) => prose.replace(/^\*\*.+?\*\*\s*/, '');
41
+
42
+ export function renderFlowTabs(units) {
43
+ return tabsEl(units.map((unit, i) => {
44
+ const id = escapeHtml(unit.id);
45
+ const body = `<p>${inline(dropLead(unit.prose))}</p>${shell(id)}`;
46
+ return { tab: tab(id, escapeHtml(unit.label), i), panel: panel(id, body, i) };
47
+ }));
48
+ }
@@ -0,0 +1,44 @@
1
+ import { inline } from './md-inline.mjs';
2
+
3
+ // A table's shape is a claim: these rows are comparable, read across. Eight
4
+ // columns describing one integration (§9) makes that claim about nothing — every
5
+ // cell wraps to four lines under a header there is no second row to compare
6
+ // against. Turned sideways it is what it always was, a record with fields.
7
+ //
8
+ // Both conditions, not either: a wide table with many rows is a real comparison,
9
+ // and a narrow one was never the problem.
10
+ const WIDE_COLS = 5;
11
+ const FEW_ROWS = 3;
12
+
13
+ export function isWideTable(headers, rows) {
14
+ if (!rows.length) return false;
15
+ return headers.length >= WIDE_COLS && rows.length <= FEW_ROWS;
16
+ }
17
+
18
+ // A wide table with enough rows is a real comparison and stays a table — but seven
19
+ // columns in an 891px measure is ~110px each, narrower than the words going into
20
+ // them. Tighter type buys the columns real width; breaking the words instead
21
+ // ("TypeScri pt") reads worse than the sideways scroll it removes.
22
+ const CRAMPED_COLS = 7;
23
+
24
+ export function isCrampedTable(headers) {
25
+ return headers.length >= CRAMPED_COLS;
26
+ }
27
+
28
+ // The first column is the record's name, so it heads the card instead of becoming
29
+ // a field of it — "Integration: Google OAuth" is one field too many. A row shorter
30
+ // than its header skips the rest rather than emitting empty <dd>s, which read as
31
+ // documented blanks.
32
+ function card(headers, row) {
33
+ const fields = headers.slice(1)
34
+ .map((h, i) => [h, row[i + 1]])
35
+ .filter(([, v]) => v)
36
+ .map(([h, v]) => `<div class="rec-field"><dt>${inline(h)}</dt><dd>${inline(v)}</dd></div>`)
37
+ .join('');
38
+ return `<div class="rec-card"><p class="rec-card__name">${inline(row[0] ?? '')}</p>`
39
+ + `<dl class="rec-card__fields">${fields}</dl></div>`;
40
+ }
41
+
42
+ export function renderWideCards(headers, rows) {
43
+ return `<div class="rec-cards">${rows.map((r) => card(headers, r)).join('')}</div>`;
44
+ }
@@ -0,0 +1,72 @@
1
+ import { escapeHtml, stripInline } from './md-inline.mjs';
2
+ import { bucketPages, isDrawerBucket, landingOf, slugOf } from './doc-sections.mjs';
3
+ import { labelOf } from './doc-kinds.mjs';
4
+
5
+ // The rail is two levels deep. One <details> per source document keeps the ~120
6
+ // headings of a real set from reading as a wall of near-duplicate labels
7
+ // ("Status", "Context", "Decision" once per ADR). But 21 document rows is the
8
+ // same wall one level up — 17 of them ADRs — so documents bucket into named
9
+ // sections and the whole decision-record run collapses to a single row.
10
+
11
+ const CHEVRON = '<svg class="nav-chevron" viewBox="0 0 12 12" aria-hidden="true">'
12
+ + '<path d="M4.5 2.5 L8 6 L4.5 9.5" fill="none" stroke="currentColor" stroke-width="1.5"'
13
+ + ' stroke-linecap="round" stroke-linejoin="round"/></svg>';
14
+
15
+ function link(heading) {
16
+ const cls = heading.level === 3 ? 'nav-link nav-link--sub' : 'nav-link';
17
+ const text = stripInline(heading.text);
18
+ const label = escapeHtml(text);
19
+ const filter = escapeHtml(text.toLowerCase());
20
+ return `<a class="${cls}" href="#${heading.slug}" data-label="${filter}">${label}</a>`;
21
+ }
22
+
23
+ function group(page, open, route) {
24
+ const doc = page.docId ? ` data-doc="${escapeHtml(page.docId)}"` : '';
25
+ const title = escapeHtml(stripInline(page.title));
26
+ // The row shows the short kind label where there is one; the hover title keeps
27
+ // the H1, so nothing the rail shortens is lost.
28
+ const label = escapeHtml(labelOf(page.kind) ?? stripInline(page.title));
29
+ return [
30
+ `<details class="nav-group"${route ? ` data-route="${route}"` : ''}`
31
+ + `${open ? ' open' : ''}${doc}>`,
32
+ `<summary class="nav-group__head" title="${title}">${CHEVRON}`,
33
+ `<span class="nav-group__title">${label}</span>`,
34
+ `<span class="nav-group__count">${page.headings.length}</span>`,
35
+ '</summary>',
36
+ `<div class="nav-group__body">${page.headings.map(link).join('')}</div>`,
37
+ '</details>',
38
+ ].join('');
39
+ }
40
+
41
+ // A routed section is browsed from its index page, so the rail shows that one
42
+ // document and stops. Listing all 15 records here would rebuild the wall the
43
+ // two-level rail exists to remove; the count still tells you how many there are.
44
+ function section(bucket, index, routes) {
45
+ const label = escapeHtml(bucket.label);
46
+ const landing = landingOf(bucket);
47
+ const shown = landing ? [landing] : bucket.pages;
48
+ const docs = shown.map((p, i) => group(p, index === 0 && i === 0, routes.get(p.docId))).join('');
49
+ // The section row opens its index page, or its first document when it has
50
+ // none: a row that routes nowhere is a toggle over documents not on screen.
51
+ const route = routes.get(shown[0].docId) ?? slugOf(bucket.label);
52
+ return [
53
+ `<details class="nav-sec" data-sec="${slugOf(bucket.label)}" data-route="${route}"`
54
+ + `${index === 0 ? ' open' : ''}>`,
55
+ `<summary class="nav-sec__head">${CHEVRON}`,
56
+ `<span class="nav-sec__title">${label}</span>`,
57
+ `<span class="nav-sec__count">${bucket.pages.length}</span>`,
58
+ '</summary>',
59
+ `<div class="nav-sec__body">${docs}</div>`,
60
+ '</details>',
61
+ ].join('');
62
+ }
63
+
64
+ // Drawer sections are left out rather than rendered and hidden: a record opens over
65
+ // the page the reader was already on, so a rail row for it is §14's table a second
66
+ // time — the redundancy the drawer exists to remove.
67
+ export function buildNav(pages, routes = new Map()) {
68
+ return bucketPages(pages)
69
+ .filter((b) => !isDrawerBucket(b))
70
+ .map((b, i) => section(b, i, routes))
71
+ .join('\n');
72
+ }