@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,772 @@
1
+ # Viewer — generation pipeline, mermaid rules, scope record
2
+
3
+ Read when generating or regenerating the viewer (after ARCHITECTURE.md,
4
+ companions, and the LikeC4 model all validate clean). Defines the exact
5
+ pipeline, the mermaid styling rules every diagram must follow, and what v1
6
+ deliberately does not ship.
7
+
8
+ ## 1. Pipeline
9
+
10
+ Four steps, in order — each feeds the next:
11
+
12
+ 1. **Write the palette config, then generate the LikeC4 webcomponent bundle.**
13
+ ```
14
+ node scripts/likec4-config.mjs --out <dir> # writes <dir>/likec4.config.json
15
+ node scripts/likec4-gen.mjs --dir <dir> --out <bundle> # validate, then generate
16
+ ```
17
+
18
+ Both steps refuse rather than warn, because both failures they cover are
19
+ silent:
20
+
21
+ | Skipped | What ships |
22
+ |---|---|
23
+ | the config | LikeC4's default blue diagrams beside teal mermaid ones. The model is valid, generates clean, exits 0 |
24
+ | validation | a bundle built from a model that never parsed. `gen webcomponent` produced 2.2 MB from a workspace carrying 194 errors, silently, exit 0 |
25
+
26
+ The palette is the plugin's job rather than the model's — see `likec4.md`
27
+ §"Declare no colours at all". `likec4-gen.mjs` checks the config is present
28
+ *before* spending a LikeC4 run, then runs `likec4 validate` and `likec4 gen
29
+ webcomponent` in that order, aborting if validation fails
30
+ (`scripts/lib/likec4-steps.mjs`). Calling `npx likec4 gen webcomponent`
31
+ directly skips both gates; there is no reason to.
32
+
33
+ `render.mjs` is the backstop, not the gate: it refuses a bundle whose theme
34
+ palette is missing or off (`scripts/lib/validate-palette.mjs`), which is one
35
+ whole render too late to be the first thing that notices. It reads the
36
+ **resolved node colour** rather than grepping for the brand hex — a model
37
+ declaring its own colour leaves that hex in the bundle's colour registry,
38
+ defined and never painted, so a grep reports success on an all-blue bundle.
39
+
40
+ `--webcomponent-prefix c4` is **mandatory** and `likec4-gen.mjs` supplies it.
41
+ It pins the custom-element tag to `<c4-view>`, which the renderer emits and
42
+ the viewer template expects. LikeC4's own default prefix is `likec4`;
43
+ omitting the flag yields `<likec4-view>` instead, and every diagram renders
44
+ blank with no error (`likec4.md` §3 covers the same fact for model
45
+ generation).
46
+
47
+ 2. **Build one mermaid + `@mermaid-js/layout-elk` bundle with esbuild.**
48
+
49
+ The bundle is spliced into the template as inline `<script>` text
50
+ (`scripts/lib/embed.mjs`), not loaded as a file, so it must leave
51
+ **top-level `mermaid` and `elkLayouts` bindings** in that script's scope.
52
+ The template's init line runs immediately after the splice point:
53
+ ```js
54
+ mermaid.registerLayoutLoaders(elkLayouts);
55
+ mermaid.initialize({ theme: 'base', themeVariables: ..., layout: 'elk' });
56
+ ```
57
+ Miss either binding and this throws a `ReferenceError` that takes the whole
58
+ page, not just the diagrams.
59
+
60
+ **No published file satisfies that**, which is what this step used to ask
61
+ for. Mermaid 11.x ships code-split ESM: `dist/mermaid.esm.mjs` is an entry
62
+ that `import`s ~40 sibling chunks, so no single file on disk carries the
63
+ library — and an inlined `export` statement has nothing to bind to anyway.
64
+ A bundling step is not an optimisation here, it is the only way to get one
65
+ file. Two dependencies, three commands:
66
+
67
+ ```
68
+ npm i mermaid@^11.16.0 @mermaid-js/layout-elk@^0.2.2
69
+ ```
70
+ ```js
71
+ // entry.mjs — the assignment IS the deliverable; esbuild would otherwise
72
+ // scope both imports inside the IIFE where the init line cannot see them.
73
+ import mermaid from 'mermaid';
74
+ import elkLayouts from '@mermaid-js/layout-elk';
75
+ globalThis.mermaid = mermaid;
76
+ globalThis.elkLayouts = elkLayouts;
77
+ ```
78
+ ```
79
+ npx esbuild@0.25.12 entry.mjs --bundle --format=iife --minify \
80
+ --legal-comments=none --outfile=mermaid-bundle.js
81
+ ```
82
+
83
+ `--format=iife` is the load-bearing flag: `esm` re-emits the `export`s that
84
+ cannot bind, and `cjs` emits a `module.exports` no browser will honour.
85
+ `--legal-comments=none` matters because the default hoists licence comments
86
+ to the top of the file, where any `</script` inside one would close the
87
+ template's script tag early.
88
+
89
+ Measured on mermaid 11.16.0 + layout-elk 0.2.2 + esbuild 0.25.12: **4.7 MB**,
90
+ `node --check` clean, zero `</script` literals, and both bindings resolve
91
+ after the splice. Check those four before rendering — a bundle that fails
92
+ any of them produces a blank page with one console error.
93
+
94
+ **Never a CDN URL in the output.** The viewer must work fully offline, and
95
+ `scripts/test/offline.test.mjs` fails the render if a remote URL survives.
96
+
97
+ 3. **Render the pages.**
98
+ ```
99
+ node scripts/render.mjs \
100
+ --root <target> \
101
+ --arch <ARCHITECTURE.md> \
102
+ --docs <companions+ADRs> \
103
+ --out dist/ \
104
+ --likec4-bundle <path> \
105
+ --mermaid-bundle <path> \
106
+ --theme assets/mermaid-theme.json
107
+ ```
108
+ Renders ARCHITECTURE.md and every companion/ADR page to HTML, injects
109
+ heading ids (for deep links), builds the sidebar nav, embeds all seven
110
+ template slots (`TITLE`, `FONTS`, `NAV`, `DOC`, `LIKEC4_BUNDLE`,
111
+ `MERMAID_BUNDLE`, `THEME`), and writes `dist/index.html` — one
112
+ self-contained file.
113
+
114
+ **`FONTS` needs no flag.** `scripts/lib/fonts.mjs` reads the woff2 subsets
115
+ shipped in `assets/fonts/` and emits one `@font-face` per file with the bytes
116
+ inline as base64 (~136KB for five faces). Unlike the two bundles these are
117
+ fixed bytes that never need regenerating, so there is nothing for a caller to
118
+ choose and no build step to get wrong — but they are still embedded at render
119
+ time rather than committed into the template, because 136KB of base64 would
120
+ turn a readable design document into a blob with a stylesheet around it and
121
+ every later diff of that file would carry it.
122
+
123
+ The filename is the contract — `ibm-plex-{sans,mono}-latin-<weight>-normal.woff2`,
124
+ which is what `@fontsource` ships — so a weight is added by adding a file. A
125
+ directory with no matching file **throws**: returning an empty string would
126
+ ship a viewer whose CSS still names the faces, which is the silent fallback
127
+ the embedding exists to end. `assets/fonts/OFL.txt` carries the licence.
128
+
129
+ The markdown subset is headings, fenced code, likec4 view markers, tables,
130
+ **lists** (`scripts/lib/md-list.mjs` — bullet, numbered, and nested, with
131
+ the child `<ul>` inside its parent `<li>`) and paragraphs, plus inline
132
+ code/bold/link (`scripts/lib/md-inline.mjs`). Anything without a shape falls
133
+ through to the paragraph collector, which joins consecutive lines — so an
134
+ unsupported block does not fail loudly, it silently comes out as run-on
135
+ prose. Add the shape to `shapeOf` before adding the renderer. Known gap:
136
+ `*italic*` is not in the subset and reaches the page as literal asterisks.
137
+
138
+ Two shapes are chosen by measurement rather than by syntax, because the same
139
+ markdown means different things at different sizes:
140
+
141
+ | Source | Rendered as | Rule |
142
+ |---|---|---|
143
+ | consecutive `likec4:view` markers | one tab group (`md-views.mjs`) | blank lines between them only; the tab is labelled with the view id |
144
+ | 2+ runs of `**Lead-in.** prose` then one marker | one tab group, prose inside each panel (`md-flows.mjs` + `renderFlowTabs`) | §7's three flows. The prose is why they were not already a group, so it travels into the panel with its own diagram instead of being stranded above the tab bar. The bold lead-in is the tab label, and is stripped from the panel so it is not said twice. A marker with no prose in front stays `md-views`' business, or one source grows two renderings |
145
+ | 2-column table, right column averaging >60 chars | definition card grid (`md-defs.mjs`) | `Term \| Definition` is a definition list; `Property \| Value` is data and stays a table |
146
+ | ≥5-column table with ≤3 rows | one record card per row (`md-wide.mjs`) | a table's shape claims "read across these rows"; §9's eight columns describe one integration, so there is nothing to read across and every cell wraps to four lines in a 1/8th column. Both conditions, not either — a wide table with many rows is a real comparison |
147
+
148
+ Every table is **full width**, capped at the column. Content width gave each
149
+ one its own, so a page of them read as a ragged right edge against fixed
150
+ prose; the cap still has to be there or a wide one pushes past the column
151
+ instead of wrapping its cells.
152
+
153
+ A table of **7+ columns** additionally gets `.table--wide` (12px, tighter
154
+ padding), because ~110px per column is narrower than the words going into it.
155
+ `overflow-wrap: anywhere` was tried first and rejected: it is the only value
156
+ min-content sizing reads, so it does remove the sideways scroll, but it breaks
157
+ every cell mid-word (`TypeScri pt`, `obs erv ed`) — a table nobody can read is
158
+ worse than one that scrolls. With the tighter scale, all nine tables in the real
159
+ set are 891px and none scrolls sideways.
160
+
161
+ `--docs` order is the reading order and the rail order; the renderer never
162
+ sorts. The rail's section label comes from each document's parent directory
163
+ (`docs/adr/` → Decision Records), so passing ADRs interleaved with
164
+ companions splits them into repeated sections.
165
+
166
+ **Links are rewritten** (`scripts/lib/doc-links.mjs`) in a second pass, because
167
+ a link's target id comes from the target's H1 and is only known once every
168
+ document has been rendered. The viewer is a single file, so every relative
169
+ href in it is dead on arrival — a real set has dozens.
170
+
171
+ | Href | Becomes |
172
+ |---|---|
173
+ | relative path resolving to a document in the set | in-page anchor, fragment dropped |
174
+ | any other relative path — `.c4`, a directory, `/site/root` | `.ext-ref` span, path kept in `title` |
175
+ | `#anchor` | untouched |
176
+ | `https:`, `mailto:`, `//host` | untouched |
177
+
178
+ The test is "is this a relative path", not a list of extensions: a `.c4` model
179
+ or a `docs/` directory can never be a document in the set, so it is exactly as
180
+ dead as an unresolved `.md` and reads better as text. Fragments on document
181
+ links are dropped rather than resolved — heading slugs are deduped across the
182
+ whole set, so `#context` inside one ADR may have been minted as `context-7`.
183
+
184
+ Unwrapping is also a cheap link check: anything that comes out as `.ext-ref`
185
+ either lives outside the set or does not exist. In the EOS set it surfaced
186
+ three ADRs that `docs/adr/README.md` indexes but the repository never had.
187
+
188
+ 4. **Serve it.**
189
+ `node scripts/serve.mjs viewer/` — a tiny static file server, no build
190
+ step. Regenerating after a doc edit is: rerun step 3, refresh the
191
+ browser tab (step 4's server needs no restart).
192
+
193
+ ### Pinning a diagram
194
+
195
+ Diagrams are what an architecture set is *for*, and they sit inline. Scrolling to
196
+ the paragraph that explains a container scrolls the container view off the
197
+ screen, so the reader holds it in their head or scrolls back. Expand and
198
+ fullscreen both cover the prose, which answers a different question.
199
+
200
+ The pin (📌 in the diagram toolbar) docks one diagram in a 380px gutter beside
201
+ the column. One at a time — pinning a second releases the first, because the
202
+ column has one gutter to give. Escape releases it, like the expand overlay.
203
+
204
+ | Concern | How it is handled |
205
+ |---|---|
206
+ | the pane covering the prose | `body.has-pin .main` reserves `--pin-w + 56px`; the pane is `position: fixed`, so it cannot push anything itself |
207
+ | the flow collapsing when the shell leaves it | a `.diagram-slot` placeholder is inserted at the shell's pre-pin `offsetHeight` |
208
+ | the reader losing their place | reserving the gutter narrows the column, so the document reflows. The first block below the top bar is recorded and its position restored — `keepingPlace` |
209
+ | no room for a gutter | below 1200px the control is hidden **and** any existing pin is released back into the flow; a pin taken before a resize would otherwise stay welded to a viewport with no gutter |
210
+ | paper | `@media print` puts a pinned shell back to `position: static` and hides the placeholder. A fixed pane prints once, over page one |
211
+
212
+ `keepingPlace` is worth a note because it looks unnecessary and is not.
213
+ Chrome does its own scroll anchoring and absorbs the reflow when it lands in one
214
+ frame — which is what happens on the test fixture. On a real set the LikeC4
215
+ webcomponent re-fits a frame later, after anchoring has already run, and the
216
+ text under the reader moves **48px**. Measured on the 20-document EOS set, with
217
+ and without, twice. `scripts/test/browser.test.mjs` records that its own check
218
+ cannot discriminate this, and why.
219
+
220
+ ### Section explainers
221
+
222
+ Every spine heading, plus each companion's title, carries a `?` button that
223
+ opens a `<details class="help">` panel: what belongs in the section, why it
224
+ matters, and what a good instance of it looks like. The text lives in
225
+ `assets/section-help.json`, keyed `spine` and `companions`, and is spliced
226
+ into the template's `SECTION_HELP` slot at generation time
227
+ (`scripts/lib/section-help.mjs`) as `window.ARCH_DOCS_HELP`. `injectSectionHelp`
228
+ builds the button and the panel from that global at boot — none of it exists
229
+ in the static template, so nothing about the affordance is visible to a test
230
+ that only reads the template string.
231
+
232
+ The lookup keys on the heading's own text, not its slug, for two reasons
233
+ recorded next to `SPINE_TITLES` in `section-help.mjs`:
234
+
235
+ - `slugify` (`scripts/lib/validate-links.mjs`) strips `&` but leaves both
236
+ surrounding spaces, so `Goals & Scope` slugifies to `goals--scope` — a shape
237
+ nobody would guess from the JSON key `"Goals & Scope"`.
238
+ - `h2` and `h3` ids share one dedupe registry (`scripts/lib/slug-registry.mjs`)
239
+ across the whole document set. An `h3` named "Security" anywhere ahead of
240
+ §12 would take the plain `security` slug and demote the real Security
241
+ heading to `security-2`, with nothing to flag it. Heading text does not
242
+ move when an unrelated document changes; a slug can.
243
+
244
+ Scope follows `kindOf()` (`scripts/lib/doc-kinds.mjs`): only the document at
245
+ index 0 — the spine, whatever the caller names `ARCHITECTURE.md` — gets a
246
+ per-`h2` explainer, one for each of its 16 headings. The three fixed-basename
247
+ companions (`threat-model.md`, `estimation.md`, `domain-overview.md`) get
248
+ exactly one, on their `h1`, because each is a single topic rather than 16.
249
+ Everything else carries no `data-kind` at all and so gets nothing: ADRs,
250
+ because §14 Decisions already explains what a decision record is, and
251
+ repeating that at every one of fifteen records would be the same sentence
252
+ fifteen times; `CONTEXT.md` and `CONTEXT-MAP.md`, which are not spine
253
+ sections; and the interface contract, whose filename is stack-dependent
254
+ (OpenAPI, a proto file, a wire doc) and may not even reach the markdown
255
+ renderer. `h3` is out of scope everywhere, spine included.
256
+
257
+ There is no link to arc42, though the wording tracks its structure. That is
258
+ separate from why the wording is written fresh rather than quoted — the arc42
259
+ template is CC BY-SA 4.0, and copying it would attach share-alike obligations
260
+ to every document set the viewer emits. The link is missing for a narrower,
261
+ checkable reason: `scripts/test/viewer-template.test.mjs` and
262
+ `scripts/test/render.test.mjs` both assert `doesNotMatch(...,
263
+ /https?:\/\/(?!www\.w3\.org)/)`, the second against the generated HTML, so no
264
+ URL may appear in the output at all, however it clicks or navigates. A reader
265
+ who wants arc42 itself can search for it.
266
+
267
+ ### What the text assertions cannot check
268
+
269
+ `scripts/test/viewer-template.test.mjs` reads the template as a string. That
270
+ catches a missing rule; it cannot catch a rule that is present and loses to a
271
+ later one, a script that throws on boot, or a font that is embedded and never
272
+ applied — which is most of what actually goes wrong in a single-file offline
273
+ viewer.
274
+
275
+ `scripts/test/browser.test.mjs` renders the fixture set and drives a real
276
+ headless Chrome over the DevTools protocol (`lib/chrome.mjs` launches,
277
+ `lib/cdp.mjs` speaks the protocol). **No dependency was added**: Node 22+ ships
278
+ a global `WebSocket` and `fetch`, and Chrome speaks DevTools over both, so
279
+ `npm ls` still reports zero. With no Chrome on `PATH` the suite prints
280
+ `﹣ the viewer in a real browser # no chrome on PATH` and exits 0.
281
+
282
+ It asserts the things that need a layout engine: boot from `file://` with an
283
+ empty console, `document.fonts.check` for the embedded faces, the prose track
284
+ measuring narrower than the block beside it and sharing its left edge, a bounded
285
+ table scrollport with a header that stays put, the theme toggle repainting,
286
+ the rail filter's hit and empty states, one page in the layout at a time, print
287
+ revealing the whole set, and the skip link landing focus in `<main>`.
288
+
289
+ Two of these were written wrong first and passed anyway — a sticky-header check
290
+ that measured drift after a scroll that could not happen, and a left-edge check
291
+ that looked only at `p`, whose margins are re-declared after the cap. Both were
292
+ found by deleting the rule under test and watching the suite stay green. **Do
293
+ that to any check added here**; a browser test that cannot fail is worth less
294
+ than the text assertion it replaced, because it looks like more.
295
+
296
+ ## 2. Mermaid rules
297
+
298
+ Verbatim from spec §7 — every mermaid diagram (§8 Data Stores ER, §12
299
+ Security DFD) follows all of these, no exceptions:
300
+
301
+ - `theme: 'base'` only — no other mermaid theme.
302
+ - `registerLayoutLoaders` is mandatory before `initialize` — the ELK layout
303
+ loader must be registered explicitly, or mermaid silently falls back to
304
+ dagre with no warning.
305
+ - **≤10–12 nodes per diagram.** Above that, use the hybrid pattern: split
306
+ into a top-level diagram plus per-node detail diagrams, rather than one
307
+ dense diagram.
308
+ - **Never** the native `C4Context` mermaid diagram type — LikeC4 owns
309
+ architecture diagrams (§5, §7, §10); mermaid is for ER and DFD only.
310
+ - **Never** `color:` inside a `classDef` — it fights the theme's own text
311
+ color and breaks dark/light switching.
312
+ - Fonts: IBM Plex Sans (body) + IBM Plex Mono (code), matching the viewer
313
+ template's `--font-body`/`--font-mono` — and now actually present, since the
314
+ viewer embeds both (§1 step 3). Naming them here used to be a wish: neither
315
+ ships with macOS, Windows or a stock Linux desktop, so the diagrams rendered in
316
+ system-ui while the page around them did the same, and the match held only by
317
+ both missing.
318
+ - Accent colors: an approved pair only — teal `#0f766e` + slate `#475569`, as
319
+ shipped in `assets/mermaid-theme.json`. No violet-fuchsia accents.
320
+ - **Fills are solid, never semi-transparent.** They used to be 8-digit hex tints
321
+ with a dark border and dark text, which looked nothing like the LikeC4 diagram
322
+ three sections above: LikeC4 paints a solid fill with light text and there is
323
+ no way to soften it. `opacity` reaches the node data but its renderer applies
324
+ it only to compound groups, and a custom colour takes a single opaque hex —
325
+ both confirmed against LikeC4's own DSL reference. So mermaid is the renderer
326
+ that moves, and its element palette is LikeC4's derived triple exactly:
327
+
328
+ | | fill | stroke | text |
329
+ |---|---|---|---|
330
+ | `brand` | `#0f766e` | `#00524b` | `#c7ffff` |
331
+ | `muted` | `#475569` | `#263447` | `#e8f7ff` |
332
+
333
+ LikeC4 derives stroke and both contrast shades from the one hex it is given;
334
+ those derived values are recorded in the `likec4` block so mermaid can match
335
+ them. Regenerate and re-check if a LikeC4 upgrade changes the derivation.
336
+ - **Elements are one palette across both modes; chrome is two.** A solid fill
337
+ carries its own text colour, so it is legible either way — and LikeC4 does the
338
+ same: sampled pixel-for-pixel its node fill is `#0f766e` in light *and* dark.
339
+ So `themeVariables` holds the elements and nothing else. What flips is the
340
+ chrome that sits *against* the canvas — subgraph panels, edge-label chips,
341
+ prose ink — and that lives in a `light` block and a `dark` block, **merged
342
+ over** `themeVariables` rather than swapping it:
343
+
344
+ ```js
345
+ Object.assign({}, t.themeVariables, isDark() ? t.dark : t.light)
346
+ ```
347
+
348
+ Both blocks state the **same keys**, enforced by a test. Holding only `dark` is
349
+ what put black trust-boundary panels and near-black edge chips on a cream page
350
+ while the LikeC4 diagram two sections above went properly pale.
351
+ - **The chrome hexes are measured off LikeC4, not invented.** LikeC4's own render
352
+ was screenshotted in each mode and sampled pixel-for-pixel; the values are
353
+ recorded under `likec4.light` / `likec4.dark`, and a test asserts the mermaid
354
+ variables equal them:
355
+
356
+ | LikeC4 role | mermaid variable | light | dark |
357
+ |---|---|---|---|
358
+ | compound group fill | `clusterBkg` | `#dae8e7` | `#102523` |
359
+ | compound group stroke | `clusterBorder` | `#719591` | `#0c342f` |
360
+ | compound group title | `titleColor` | `#19524e` | `#93cbc5` |
361
+
362
+ Which variable paints which part was also found by rendering with marker
363
+ colours, because mermaid's fallback chain is not what it looks like. In the
364
+ ER and DFD subset:
365
+
366
+ | painted thing | variable |
367
+ |---|---|
368
+ | subgraph fill / stroke / title | `clusterBkg` / `clusterBorder` / `titleColor` |
369
+ | flowchart edge-label chip / its text | `edgeLabelBackground` / `primaryTextColor` |
370
+ | ER relationship label box / its text | `tertiaryColor` at 0.5 alpha / `primaryTextColor` |
371
+
372
+ `tertiaryTextColor`, `tertiaryBorderColor`, `relationLabelBackground`,
373
+ `relationLabelColor` and `textColor` paint **nothing** here — they are fallbacks
374
+ for keys now set explicitly, or for diagram types this subset does not use.
375
+ Setting them looks like it works and changes nothing.
376
+ - **A relation label is a word on a line, and the viewer paints it, not mermaid.**
377
+ Mermaid always draws a chip and locks its text to `primaryTextColor` — the light
378
+ ink solid teal fills need — so every chip it can paint has to be dark to stay
379
+ legible, which on a cream page is a dark blob. No theme variable can say "no
380
+ chip". Mermaid's SVG is in the page's own DOM, unlike LikeC4's shadow root, so
381
+ the viewer overrides it directly: `var(--surface)` behind, `var(--text)` in
382
+ front, both already flipping with the theme.
383
+
384
+ Surface rather than `transparent` because the label sits *on* the relation line
385
+ — transparent lets the line strike through the text. And **all three layers**,
386
+ because mermaid colours a different one per diagram type:
387
+
388
+ | layer | painted in |
389
+ |---|---|
390
+ | `div.labelBkg` | ER relationship label |
391
+ | `span.edgeLabel` | both |
392
+ | `span.edgeLabel p` | flowchart edge label |
393
+
394
+ Miss one and that diagram type keeps its blob. `!important` is required —
395
+ mermaid injects its own rules into the SVG. This is why `edgeLabelBackground`
396
+ is **absent** from the palette rather than tuned: a value there would be
397
+ overridden and only look authoritative.
398
+ - **LikeC4's relation label needs the same treatment, through its shadow root.**
399
+ It draws `div.likec4-edge-label` with a translucent dark background in *both*
400
+ modes (`--xy-edge-label-background-color`, re-declared on
401
+ `.likec4-edge-label-container` — so setting the variable on the host does not
402
+ reach it). Left alone, §10 keeps a dark chip while §12 has lost one. The root is
403
+ **open**, so `stripEdgeChips()` pushes a `<style>` inside, and because custom
404
+ properties inherit across the boundary `var(--text)` flips with the toggle on
405
+ its own. Two traps:
406
+
407
+ | trap | why |
408
+ |---|---|
409
+ | `background: transparent`, not `var(--surface)` | LikeC4 breaks its edge line around the label, so nothing needs masking and an opaque chip is a white blob over a compound panel. Mermaid routes the line *through* its label and does need the mask. |
410
+ | walk **every** nested root, and retry | the label is not in the root `c4-view` opens — a div in that root opens another, later. A shadow root cannot be observed into existence (MutationObserver does not cross the boundary), so the walk runs on a `[0, 200, 600, 1500, 3000]`ms ladder and again when the router reveals a page. |
411
+ - **`tertiaryColor` stays shared** across modes. Its only remaining consumer is
412
+ the fallback layer for diagram types this subset does not use; the ER label box
413
+ it used to paint (at 0.5 alpha) is now the viewer's.
414
+ - The `likec4` block is the palette **for both renderers**, consumed at different
415
+ times — the part to keep straight:
416
+
417
+ | | Hue | Light/dark |
418
+ |---|---|---|
419
+ | mermaid | read from the file at render time | re-render on toggle |
420
+ | LikeC4 | baked into the bundle by `gen webcomponent` from the model's `specification` (`likec4.md` §2) | `color-scheme` attribute, set on toggle |
421
+
422
+ So editing the file changes mermaid on the next render and LikeC4 only after
423
+ the model's `specification` is updated to match and the bundle regenerated.
424
+ A viewer-side CSS override is not an option: `--likec4-palette-fill` set on
425
+ `c4-view` reaches the host and is re-declared closer to the node inside the
426
+ shadow root, so the nodes keep whatever the bundle baked in.
427
+ - **Both renderers move on one toggle handler.** `syncDiagramTheme()` sets
428
+ `color-scheme` on every `<c4-view>`; without it the toggle re-rendered mermaid
429
+ and left every LikeC4 view in the mode it booted in — a light diagram on a
430
+ dark page. Splitting the two across separate handlers is how they drifted
431
+ apart in the first place.
432
+ - The renderer strips mermaid's intrinsic `width`/`height` off the SVG and
433
+ scales it to the container via its `viewBox`. Mermaid otherwise pins a
434
+ diagram to its natural size (~300px for the §8 ER), which is an unreadable
435
+ thumbnail in a full-width shell. LikeC4 needs the opposite — an explicit
436
+ box (`c4-view { height: 460px }`) to fit its view into.
437
+ - **The zoom control is also the zoom readout.** It said `1:1` at every level, so
438
+ the diagram was the only report of its own state and pressing the button was the
439
+ only way to learn what it did. It now reads `140%`, in tabular figures with a
440
+ width floor — a live number in proportional digits shoves the three buttons
441
+ beside it sideways as it counts.
442
+ - **Pan is bounded by the frame.** The bound is the overhang: how far the scaled
443
+ canvas sticks out past the viewport, so the content edges can be brought to the
444
+ frame edges and no further. Below zoom 1 there is no overhang, the limit is
445
+ zero, and the diagram parks centred. Unbounded, the canvas could be thrown clear
446
+ of the viewport and the way back was a button the reader had to already know was
447
+ a reset. Clamped inside `apply()`, the one place the transform is written, so
448
+ zoom, pan and reset all get it rather than three call sites remembering to.
449
+ - Every diagram — LikeC4 `<c4-view>` embeds and mermaid diagrams alike —
450
+ gets all four controls: zoom, pan, expand, and **fullscreen**
451
+ (`.diagram-shell` + `.diagram-toolbar` in the viewer template), and each is
452
+ reachable by pointer, by touch and by keyboard:
453
+
454
+ | input | how |
455
+ |---|---|
456
+ | mouse / touch / pen | `pointerdown` + `setPointerCapture` on the viewport. Not the mouse pair: those never fire for touch, so a diagram on a phone could be zoomed and then not moved. Capture also retires the two `document`-level listeners this added *per diagram* |
457
+ | keyboard | the viewport is `tabindex="0"` with a name that states its keys; arrows pan, `+`/`-` zoom, `0` resets |
458
+ | trackpad / wheel | `ctrl`/`meta` + wheel, which is also what a pinch reports |
459
+
460
+ - **Panning is a state, not the default** (`.is-pannable`, set by `pannable()`
461
+ when zoom > 1 or the shell is expanded or fullscreen). Two things hang on it,
462
+ and both are wrong without it: a `grab` cursor at 1:1 promises movement the
463
+ diagram cannot make, and `touch-action: none` at 1:1 swallows the page scroll
464
+ of any reader whose finger lands on a diagram on the way down the document.
465
+ The arrow keys are gated on the same class for the same reason — a reader who
466
+ tabs into a fitted diagram must not lose their scroll keys.
467
+ - **Expand needs its own Escape.** Fullscreen gets one from the browser; expand
468
+ is an ordinary `position: fixed` overlay and had no way out but the button that
469
+ opened it. One page-level handler collapses any expanded shell, restores its
470
+ `aria-pressed`, and returns focus to that button. Each shell publishes its
471
+ `sync()` as `shell.archDocsSync` so the handler can put `.is-pannable` back to
472
+ whatever that shell's own zoom says.
473
+ - **A diagram that fails to render says so.** `mermaid.render` rejects on a
474
+ syntax error; unhandled, the element keeps the source text it was seeded with,
475
+ so the reader gets a slab of mermaid DSL inside a diagram frame — which reads
476
+ as a code block somebody meant to put there. The catch drops mermaid's scratch
477
+ div (it appends one under `'d' + id` and leaves it behind) and renders
478
+ `.diagram-error` naming the failure.
479
+
480
+ ## 3. v1 scope record
481
+
482
+ Shipped: per-section and per-view deep links, dark/light toggle (persisted
483
+ in `localStorage`, and guarded — the read runs before the body paints, and a
484
+ blocked or `file://` store throws, which would take the theme and every script
485
+ after it), and a **two-level** sidebar nav (`scripts/lib/nav.mjs`) with
486
+ a substring filter, scroll-spy active state, three-part breadcrumb, and an
487
+ off-canvas drawer below 960px.
488
+
489
+ A **skip link** is the first focusable thing in the body. Reading order is
490
+ topbar, rail, prose, which is the right order to read and the wrong order to tab:
491
+ a real set puts ~120 rail links between a keyboard reader and the first sentence.
492
+ `<main>` carries `tabindex="-1"` so focus can actually land there rather than the
493
+ viewport moving and the tab position staying up in the rail — and the link joins
494
+ `.main`, the rail and the topbar in `setBehindInert`, or it stays live behind an
495
+ open record's scrim and lands the reader on a page they cannot see.
496
+
497
+ Both levels are load-bearing, and the second one is the one that is easy to
498
+ skip. A real set runs to ~20 documents and ~120 headings:
499
+
500
+ | Rail | What the reader sees |
501
+ |---|---|
502
+ | flat headings | ~120 rows of near-duplicate labels — "Status", "Context", "Decision", "Consequences" repeat once per ADR with nothing saying which ADR a link belongs to |
503
+ | one group per document | 21 rows, 17 of them ADRs — the same wall one level up, and the four documents that are not ADRs are buried in it |
504
+ | section → document → heading | 2 rows closed. `Architecture` (4 docs) opens; `Decision Records` (17) stays collapsed until asked for |
505
+
506
+ Only the first section and its first document open on load. Scroll spy opens
507
+ whatever it lands on, at both levels; the filter force-opens hits and restores
508
+ the reader's own open/closed layout from `data-was-open` when the box clears.
509
+
510
+ ### One column
511
+
512
+ Every block is the width of the reading measure or narrower — prose, tables,
513
+ code, diagrams, tab panels. Nothing breaks out.
514
+
515
+ Diagrams and wide tables used to take a 1080px track centred on the 689px prose
516
+ axis, which put their left edge ~190px outside the paragraph above them: the
517
+ reader re-found the margin on every block, and a 3x15 index needing 523px was
518
+ stretched to double its content for nothing. Three consequences worth stating:
519
+
520
+ - `table` is `width: 100%; max-width: 100%` — **one** width for every table,
521
+ because content width gave each one its own and a page of them read as a ragged
522
+ right edge against a fixed prose column. The cap is still load-bearing: without
523
+ a ceiling a wide table pushes past the column instead of wrapping its cells, and
524
+ 15 of the 18 tables in a real set grew their own sideways scrollbar. `th` cannot
525
+ be `nowrap`: a header that refuses to wrap sets a floor the cap cannot beat.
526
+ - Three tables in that set (7–8 columns) still cannot fit and scroll inside their
527
+ card. That is the floor of the design, not a bug to chase — the alternatives
528
+ are wider prose for every document or restructuring the table.
529
+ - `.table-scroll` is capped at `min(70vh, 40rem)`, and that height is what makes
530
+ the sticky `th` work at all. `overflow-x: auto` computes the *other* axis from
531
+ `visible` to `auto`, so the box is a scrollport vertically too; left unbounded
532
+ it never scrolls, and the header sticks to a box that cannot move. A 40-row
533
+ table then scrolls its own column labels away under the top bar.
534
+ - The measure is `min(96ch, 100%)`, not the classic 74ch: once every table and
535
+ diagram had to live inside the column, 74ch (689px) left 15 of 18 tables
536
+ scrolling sideways. Widen this one value to trade reading comfort for table
537
+ room. `100%` rather than `calc(100vw - var(--rail-w) - 80px)` — `.main` is
538
+ already offset by the rail and its own padding, so subtracting them again
539
+ restates the layout in a second place, and `100vw` counts the scrollbar gutter
540
+ and clipped ~15px off every block on the platforms that reserve one. There is
541
+ no narrow-desktop breakpoint, and none below 960px either: `100%` resolves
542
+ against whatever column the rail has left.
543
+ - Block links (index rows, search hits, page-bar chips) must be named against
544
+ `.main a`, which is (0,1,1) and beats a bare class. Otherwise each one grows
545
+ the prose underline meant for links inside a sentence.
546
+ - A `<c4-view>` is fitted to its box **once**, when the element boots, and only
547
+ refits on resize. The router reveals a section before the element is upgraded,
548
+ so that first fit measures a box of zero and the view renders at its natural
549
+ size, off the right edge of a 689px column. The template nudges it with a
550
+ synthetic `resize` on `customElements.whenDefined('c4-view')`.
551
+
552
+ Scrollbars are styled once, globally (`scrollbar-width: thin` plus the
553
+ `::-webkit-scrollbar` rules), because a dozen scroll containers each showing a
554
+ 15px platform slab is heavier than every hairline border in the page. The page
555
+ itself carries `overflow-x: clip` on `body` — set there rather than on `html` so
556
+ it propagates to the viewport without making `body` a clipping context, which
557
+ would trap the `position: fixed` expanded diagram.
558
+
559
+ ### Page routes
560
+
561
+ **Every document is its own page** with its own route and its own reading
562
+ progress on the top bar (`scripts/lib/doc-routes.mjs`). A 21-document scroll is
563
+ not a page: the whole-set progress line barely moved while the reader worked
564
+ through one document.
565
+
566
+ Route slugs come from the **source filename**, not the H1 — a title gets
567
+ reworded, a filename is what every other document already links to. A section's
568
+ index page takes the section slug instead, so `#/decision-records` lands on the
569
+ list rather than on a file called `index`. Collisions get the same `-2` suffix
570
+ the heading-id registry uses (`slug-registry.mjs`).
571
+
572
+ | Hash | Meaning |
573
+ |---|---|
574
+ | `#/threat-model`, `#/0004-module-layout-vertical-slices-tenant-mixin` | that document |
575
+ | `#/decision-records` | the section's index page — a drawer section, so it opens in the drawer |
576
+ | `#page-doc-adr-0004`, `#12-security` | an element — the router opens whichever page contains it |
577
+
578
+ The second form is why nothing else had to change: every anchor the renderer
579
+ already writes is a bare element id, and so is every rail link.
580
+
581
+ `routeMap` is built once in `render.mjs` and passed to **both** `buildDoc` and
582
+ `buildNav`, so the body and the rail cannot disagree about which slug opens which
583
+ page. Both rail levels route on click: `preventDefault` stops the `<summary>`
584
+ toggle and the router owns which rows are open. A row cannot be collapsed over
585
+ the page on screen, because that would leave no way back into it.
586
+
587
+ The `Document 07` eyebrow and its hairline are gone. Both existed to separate one
588
+ document from the next in a single scroll, and a CSS counter cannot count pages
589
+ that are not in the layout — it read `Document 01` on every one. Each page's bar
590
+ carries `3 / 15` and prev/next across its section instead.
591
+
592
+ ### Routed sections
593
+
594
+ Within a section, a shipped `index.md` or `README.md` makes it **routed**
595
+ (`scripts/lib/doc-sections.mjs`): the rail holds one row for the index, the index
596
+ holds the list, and one record shows at a time. Shipping an index is the opt-in —
597
+ there is no document-count threshold, because 15 records behind an index is a set
598
+ you browse while 15 records with no index is a run you read straight through.
599
+ The section holding the root architecture document never routes, or a 226-byte
600
+ `docs/architecture/README.md` would win the landing slot and hide
601
+ `ARCHITECTURE.md` behind a stub.
602
+
603
+ A record's bar gains a link back to the index; the index gets a status roll-up
604
+ and a search box.
605
+
606
+ **A decision record opens in a drawer, not as a page, and has no rail row.**
607
+ §14 Decisions already tables every ADR, so a Decision Records section in the rail
608
+ was the same set a second time — and the copy nobody asked for, since the reader
609
+ was looking at §14 when they clicked. Replacing the page also threw away the row
610
+ they came from. `render.mjs` marks anything under `adr/`, `decisions/` or `rfc/`
611
+ as `drawer: true`; `buildNav` drops those buckets entirely, `buildDoc` marks the
612
+ section `data-drawer`, and `routeMap` still gives every record its route.
613
+
614
+ | what | behaviour |
615
+ |---|---|
616
+ | clicking a §14 row | hash becomes `#/0002-multi-tenancy-shared-db-rls`, drawer slides over the page |
617
+ | Escape / scrim / × | all call `leaveRecord()`, which closes **and** sets the hash back to the host page's route |
618
+ | Back | ordinary hash navigation — the drawer state is entirely a function of the hash |
619
+ | a cold `#/0002-…` | host page is shown *first*, then the record goes over it |
620
+ | prev/next inside the drawer | walks the records without leaving the drawer |
621
+ | `‹ All records` | opens the index in the drawer, whose 15 links each swap the record in place |
622
+
623
+ The bar names the record (`ADR-0002`) and shows its status; it used to carry the
624
+ whole 90-char heading in 10.5px uppercase letter-spaced mono, which is an eyebrow
625
+ treatment applied to a paragraph — and the record's own H1 is two lines below it.
626
+ The full title stays as the dialog's `aria-label`.
627
+
628
+ **Focus is moved and given back.** `role="dialog" aria-modal="true"` was claiming
629
+ containment that nothing enforced: a keyboard reader opened a record and their next
630
+ Tab walked the page behind the scrim. `openDrawer` remembers `document.activeElement`,
631
+ focuses the close button, and sets `.inert` on `.main`, the rail and the topbar —
632
+ one property instead of a hand-rolled tab trap, and it removes them from the
633
+ accessibility tree at the same time. `closeDrawer` returns focus to the row that
634
+ opened it.
635
+
636
+ Four things that are easy to get wrong:
637
+
638
+ - **The record is moved, not cloned.** A clone duplicates every heading id in it,
639
+ and from then on `getElementById` resolves to whichever copy comes first — so
640
+ half the anchors in the drawer scroll the page behind it. `recordHome` remembers
641
+ which section each record came from so it can be put back.
642
+ - **`showPage` has to skip records** (`if (!isRecord(p)) p.hidden = …`). It hides
643
+ every page but the active one, which would hide the record currently sitting in
644
+ the drawer and open it onto nothing.
645
+ - **Record links are intercepted** so the hash is the route rather than the id.
646
+ The router resolves either form, but left alone the address bar reads
647
+ `#doc-adr-0002-multi-tenancy` while the panel says ADR 0002, and neither is what
648
+ somebody would paste. The listener is on `document`, not `.doc`, because an open
649
+ record is no longer inside `.doc` and one record links to another.
650
+ - **`inert` has to come off on close.** It is set on three elements and cleared in
651
+ `closeDrawer`, which runs on every path out — leaving it on makes the whole page
652
+ unfocusable with no visible cause.
653
+
654
+ **The status pill encodes which status it is.** It used to paint Accepted, Proposed
655
+ and Superseded identically (`--text-faint` on `--surface-3`), so the two records
656
+ still open in a set of fifteen looked like the thirteen that were settled —
657
+ `statusOf()` already extracted the leading word and nothing read it.
658
+
659
+ | status | treatment | why |
660
+ |---|---|---|
661
+ | accepted | quiet grey | most records are settled; colouring the majority says nothing |
662
+ | proposed, draft | `--state-open` ochre | still to decide — the one thing that wants attention |
663
+ | rejected | `--state-stop` brick | decided against |
664
+ | superseded, deprecated | grey, `line-through` | not severity — "this is no longer the answer", which a line says and a third hue does not |
665
+ | unrecorded | dashed outline, no fill | nothing was recorded; a filled pill would claim a value |
666
+
667
+ `--state-*` is its own scale in both themes, deliberately **not** the accent: teal
668
+ already means link, brand and diagram element everywhere else, so a status wearing
669
+ it says nothing. Both hues are warm, so they sit with the neutrals rather than
670
+ arriving from a UI kit.
671
+
672
+ **A provenance marker is not code.** `observed`, `stated`, `researched` and
673
+ `proposed` are a closed vocabulary (`validate-provenance.mjs`), written in
674
+ backticks, and they came out as `<code>` — the same accent-teal chip as `org_id`
675
+ and `docker-compose.yml`. So the accent meant two unrelated things and the most
676
+ repeated element in the set read as a snippet. `md-inline.mjs` now emits
677
+ `<span class="prov" data-prov="…">` for exact members only: `observed_at` is a
678
+ column name and `Observed` is not in the vocabulary. The treatment is an outlined
679
+ small-caps footnote — beside the sentence, not competing with it.
680
+
681
+ **The index does not trust the author's own list.** `docs/adr/README.md` in the
682
+ EOS set indexes four records by filenames the repository never had — behind a
683
+ routed section that hid the other eleven completely, with one working link on the
684
+ page. So the index's links are resolved and counted against the records the
685
+ section actually holds, and when they fall short the viewer appends a generated
686
+ `Every record` list: position, title, status, one row each, all linked. When the
687
+ author's index does link every record (`docs/adr/index.md` does) nothing is
688
+ added.
689
+
690
+ **The search is not a nicety either.** Hiding
691
+ 14 of 15 records puts them out of reach of the browser's own find, which is the
692
+ reason §3 records full-text search as unshipped. The records stay in the DOM, so
693
+ the index reads the same characters Ctrl+F would have — and can name the record
694
+ that matched instead of dropping the reader into an unlabelled slab. Statuses are
695
+ read from each record's own `## Status` section, falling back to an inline
696
+ `**Status:** …` label, and only the leading word is counted (a real status line
697
+ carries qualifiers: `Accepted — partially supersedes ADR-0008`).
698
+
699
+ One consequence worth stating plainly: a deep link into a hidden section or
700
+ record needs the router to reveal it before the scroll can land — the browser
701
+ jumps to the fragment first, so the jump is re-run after routing.
702
+
703
+ That re-run **lands instantly when the page changed and glides when it did not.**
704
+ `scroll-behavior: smooth` cannot tell the two apart, so a deep link into another
705
+ document used to animate the whole way there — through content the reader never
706
+ asked to see, and past the top of the document they did. An anchor inside the page
707
+ already on screen is a short deliberate move and keeps its glide. Reduced motion
708
+ takes even that back explicitly: passing `behavior` to `scrollIntoView` outranks
709
+ the CSS rule that used to cover it, so the media query is read in JS too.
710
+
711
+ **Printing prints the whole set.** It used to print whichever document the router
712
+ had in the layout — one of twenty-one, and inside a routed section one record of
713
+ fifteen. Every page is already in the DOM and only hidden, so `@media print`
714
+ unhides them all and drops the chrome that is navigation rather than content
715
+ (rail, top bar, page bars, drawer bar, skip link). An open record has been
716
+ *moved* into the drawer, so `#drawer` goes `position: static` for print and the
717
+ record lands at the end of the set instead of over the first page of it.
718
+
719
+ ### Searching
720
+
721
+ Three searches, over three different scopes, and together they leave nothing in
722
+ the set unreachable:
723
+
724
+ | Search | Scope | Why it exists |
725
+ |---|---|---|
726
+ | rail filter | every document's headings **and body text** | wayfinding plus phrase-finding across the set |
727
+ | index search | the records of one routed section | those records are hidden, so Ctrl+F cannot reach them |
728
+ | Ctrl/Cmd+F | the page in the layout | the browser's own, and the reason the other two stop where they do |
729
+
730
+ The rail filter used to match heading labels alone, which is wayfinding rather
731
+ than search: a reader looking for `row-level security` found it only if somebody
732
+ had made it a heading, and the other ~20 documents were reachable by no search at
733
+ all. Every page is already in the DOM, so matching the body costs one `indexOf`
734
+ per document and **no index** — the objection recorded below is to *semantic*
735
+ search, which is a different thing.
736
+
737
+ A body match promotes the whole **document**, not any one heading: the phrase is
738
+ somewhere in it, and Ctrl+F finds the line once the page is open. The row is
739
+ marked `in text` (`.is-body-hit`, taking the slot the count badge vacates while
740
+ filtering) — without it the reader types a phrase and gets back a row whose every
741
+ visible label lacks it, which reads as a bug.
742
+
743
+ Document text is captured **before** the page bars are prepended, for the same
744
+ reason the index search is: a bar contributes `‹ All records 3 / 15 ‹ Prev Next ›`
745
+ to every page, and those would otherwise match in every document at once. Records
746
+ are left out of it — they have no rail row to promote, and their section's index
747
+ already searches them.
748
+
749
+ The filter is reachable by `/` and by ⌘/Ctrl+K, and Escape clears it. Escape
750
+ stops there rather than bubbling: the same key closes the mobile rail and any
751
+ open record, and a reader clearing a search asked for neither. A second press on
752
+ an empty box hands focus back to the page.
753
+
754
+ Deliberately **not** shipped, with reasons recorded here rather than left
755
+ silent:
756
+
757
+ | Feature | Status | Reason |
758
+ |---|---|---|
759
+ | Reach tracing | not shipped | LikeC4 covers this natively for its own architecture views — a second implementation would duplicate what LikeC4 already does |
760
+ | Semantic search | not shipped | substring search over the bodies is shipped and needs no index; ranking by *meaning* would need one, and the offline single-file viewer has nowhere to put it |
761
+ | Ranked or snippet results in the rail | not shipped | the rail row is 32px and already carries a title, a chevron and a badge; the index search is where snippets fit, and it has them |
762
+
763
+ The honest-absence rule (`interview.md` §"Honest absence") applies to the
764
+ tool itself, not just to documentation facts: an unshipped feature is
765
+ recorded as unshipped, with why — never left for a reader to discover by
766
+ searching for something that isn't there.
767
+
768
+ ## 4. Port
769
+
770
+ Default port is **4173**. `scripts/lib/port.mjs`'s `findFreePort` tries
771
+ 4173 first and scans upward (4174, 4175, …) until it finds a free one —
772
+ never fails outright, never prompts to pick a port.