@legionworks/facet 1.9.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 (327) hide show
  1. package/LICENSE-APACHE +202 -0
  2. package/LICENSE-MIT +23 -0
  3. package/README.md +158 -0
  4. package/dist/gallery/chunk-4g8rem85.css +656 -0
  5. package/dist/gallery/chunk-c6s9k9ty.js +5970 -0
  6. package/dist/gallery/frame/artifact.css +8424 -0
  7. package/dist/gallery/frame/chunks/abnfDiagram-N423BO3Z-jj74szbm.js +155 -0
  8. package/dist/gallery/frame/chunks/architecture-TIHT7OUA-cvdjn7dt.js +10 -0
  9. package/dist/gallery/frame/chunks/architectureDiagram-T3A2C74G-n4z77eg6.js +8675 -0
  10. package/dist/gallery/frame/chunks/blockDiagram-VBNYF7ZC-7xsqzrd1.js +3529 -0
  11. package/dist/gallery/frame/chunks/c4Diagram-5PPSVZJV-z2zjs7wx.js +2413 -0
  12. package/dist/gallery/frame/chunks/classDiagram-JCYQIIEL-ve8rngqp.js +47 -0
  13. package/dist/gallery/frame/chunks/classDiagram-v2-OCEON4UE-8cfaxb8z.js +47 -0
  14. package/dist/gallery/frame/chunks/cose-bilkent-JH36ORCC-sn92qexx.js +4822 -0
  15. package/dist/gallery/frame/chunks/cynefin-VYW2F7L2-tqjv913d.js +10 -0
  16. package/dist/gallery/frame/chunks/cynefinDiagram-MW4NZA55-c1c0dj12.js +500 -0
  17. package/dist/gallery/frame/chunks/dagre-VZM6K2ZE-7tyg4yt2.js +476 -0
  18. package/dist/gallery/frame/chunks/diagram-7IWD3JNH-y4eng9sc.js +526 -0
  19. package/dist/gallery/frame/chunks/diagram-B4RE2ZJO-rn3p7j5h.js +673 -0
  20. package/dist/gallery/frame/chunks/diagram-LBJQPF4R-w4a2cm9q.js +255 -0
  21. package/dist/gallery/frame/chunks/diagram-Q27KOJAE-aqc2v7wy.js +575 -0
  22. package/dist/gallery/frame/chunks/diagram-UB23O5K3-xncy8nyd.js +355 -0
  23. package/dist/gallery/frame/chunks/ebnfDiagram-BXEA7PRR-acwgxz16.js +175 -0
  24. package/dist/gallery/frame/chunks/erDiagram-JOGREHBK-mzp5nswt.js +1332 -0
  25. package/dist/gallery/frame/chunks/eventmodeling-45OFAUF4-sg07qr0c.js +10 -0
  26. package/dist/gallery/frame/chunks/flowDiagram-UKHOOZJN-2e5ygs44.js +29 -0
  27. package/dist/gallery/frame/chunks/ganttDiagram-PKOTCBZU-p2hhh7hr.js +2620 -0
  28. package/dist/gallery/frame/chunks/gitGraph-TEB2WS4Q-j6kw0naa.js +10 -0
  29. package/dist/gallery/frame/chunks/gitGraphDiagram-DS77QQ5N-4z9z8wjm.js +1347 -0
  30. package/dist/gallery/frame/chunks/info-DKCQHKI2-mpt80jd3.js +10 -0
  31. package/dist/gallery/frame/chunks/infoDiagram-6WML65LV-5rqm3mgg.js +65 -0
  32. package/dist/gallery/frame/chunks/ishikawaDiagram-WSZJBQD7-b51z96jy.js +975 -0
  33. package/dist/gallery/frame/chunks/journeyDiagram-NVQOT4AX-9jbfp0pk.js +1272 -0
  34. package/dist/gallery/frame/chunks/kanban-definition-27J2QSJJ-4x0vx4se.js +1116 -0
  35. package/dist/gallery/frame/chunks/katex-xfgk95tv.js +14034 -0
  36. package/dist/gallery/frame/chunks/markdown-1s5vwkf2.js +9 -0
  37. package/dist/gallery/frame/chunks/markdown-2h6bwsms.js +3239 -0
  38. package/dist/gallery/frame/chunks/markdown-2x113yh8.js +107 -0
  39. package/dist/gallery/frame/chunks/markdown-30b7rwmp.js +1943 -0
  40. package/dist/gallery/frame/chunks/markdown-356bfj4g.js +2031 -0
  41. package/dist/gallery/frame/chunks/markdown-44n9ea69.js +2406 -0
  42. package/dist/gallery/frame/chunks/markdown-56enrf2r.js +39 -0
  43. package/dist/gallery/frame/chunks/markdown-5avymm8t.js +725 -0
  44. package/dist/gallery/frame/chunks/markdown-6r4svars.js +33 -0
  45. package/dist/gallery/frame/chunks/markdown-6zz8efx2.js +24 -0
  46. package/dist/gallery/frame/chunks/markdown-7jp6prnb.js +19 -0
  47. package/dist/gallery/frame/chunks/markdown-809k7q41.js +55 -0
  48. package/dist/gallery/frame/chunks/markdown-82xmzhzd.js +1076 -0
  49. package/dist/gallery/frame/chunks/markdown-92n37gd4.js +7627 -0
  50. package/dist/gallery/frame/chunks/markdown-ag2sssf8.js +36 -0
  51. package/dist/gallery/frame/chunks/markdown-b4s7ntq2.js +19 -0
  52. package/dist/gallery/frame/chunks/markdown-c9k0fvp1.js +100 -0
  53. package/dist/gallery/frame/chunks/markdown-ceefymn8.js +125 -0
  54. package/dist/gallery/frame/chunks/markdown-d1wfbs70.js +243 -0
  55. package/dist/gallery/frame/chunks/markdown-dy5sgjhc.js +11022 -0
  56. package/dist/gallery/frame/chunks/markdown-dz3z5w30.js +30868 -0
  57. package/dist/gallery/frame/chunks/markdown-eg6ngz7y.js +30340 -0
  58. package/dist/gallery/frame/chunks/markdown-ff5wvb43.js +1149 -0
  59. package/dist/gallery/frame/chunks/markdown-ffg06nfz.js +86 -0
  60. package/dist/gallery/frame/chunks/markdown-fvfncadf.js +472 -0
  61. package/dist/gallery/frame/chunks/markdown-gvyszqpv.js +19 -0
  62. package/dist/gallery/frame/chunks/markdown-gx1p0ew0.js +88 -0
  63. package/dist/gallery/frame/chunks/markdown-gxye5frz.js +65 -0
  64. package/dist/gallery/frame/chunks/markdown-h7pzv34e.js +105 -0
  65. package/dist/gallery/frame/chunks/markdown-hab789t9.js +47 -0
  66. package/dist/gallery/frame/chunks/markdown-hjp6sj8t.js +125 -0
  67. package/dist/gallery/frame/chunks/markdown-jka64qgp.js +1993 -0
  68. package/dist/gallery/frame/chunks/markdown-k8xkn8mw.js +56 -0
  69. package/dist/gallery/frame/chunks/markdown-m7frq8x8.js +112 -0
  70. package/dist/gallery/frame/chunks/markdown-p740v4qm.js +36 -0
  71. package/dist/gallery/frame/chunks/markdown-pxfeh231.js +57 -0
  72. package/dist/gallery/frame/chunks/markdown-pzgd8z3s.js +87 -0
  73. package/dist/gallery/frame/chunks/markdown-qx3cngz2.js +1673 -0
  74. package/dist/gallery/frame/chunks/markdown-rawhfvvc.js +85 -0
  75. package/dist/gallery/frame/chunks/markdown-rd8w0ng9.js +49 -0
  76. package/dist/gallery/frame/chunks/markdown-rm2yxfjj.js +2773 -0
  77. package/dist/gallery/frame/chunks/markdown-s1jatrnk.js +993 -0
  78. package/dist/gallery/frame/chunks/markdown-sgfg5vvq.js +59 -0
  79. package/dist/gallery/frame/chunks/markdown-t4ethv9d.js +409 -0
  80. package/dist/gallery/frame/chunks/markdown-tnmabqvz.js +36 -0
  81. package/dist/gallery/frame/chunks/markdown-tvdpppw8.js +5292 -0
  82. package/dist/gallery/frame/chunks/markdown-v0x27twr.js +22 -0
  83. package/dist/gallery/frame/chunks/markdown-v14td68x.js +36 -0
  84. package/dist/gallery/frame/chunks/markdown-w6sgd54z.js +36 -0
  85. package/dist/gallery/frame/chunks/markdown-xw8dsk8b.js +2125 -0
  86. package/dist/gallery/frame/chunks/markdown-y18mve73.js +85 -0
  87. package/dist/gallery/frame/chunks/markdown-yengsms5.js +427 -0
  88. package/dist/gallery/frame/chunks/markdown-z1wc0v0d.js +1826 -0
  89. package/dist/gallery/frame/chunks/markdown-zazx9h4n.js +329 -0
  90. package/dist/gallery/frame/chunks/mermaid-de7p4v0x.js +30 -0
  91. package/dist/gallery/frame/chunks/mindmap-definition-FAOFIHXS-ra44cbem.js +1216 -0
  92. package/dist/gallery/frame/chunks/packet-7NZHBO7P-xppm5913.js +10 -0
  93. package/dist/gallery/frame/chunks/pegDiagram-VL7TDLO6-a2a4wg03.js +163 -0
  94. package/dist/gallery/frame/chunks/pie-RZYD4A2V-hnbxk152.js +10 -0
  95. package/dist/gallery/frame/chunks/pieDiagram-7S7Q4E2Y-f1vxjtmx.js +311 -0
  96. package/dist/gallery/frame/chunks/quadrantDiagram-CIZ2JOQS-ywafa6kh.js +1390 -0
  97. package/dist/gallery/frame/chunks/radar-I7S5WNFK-ewqd27se.js +10 -0
  98. package/dist/gallery/frame/chunks/railroad-3IZDKUUU-5hy4bdx3.js +10 -0
  99. package/dist/gallery/frame/chunks/railroad-abnf-AHOZXSZD-bh5sxz0d.js +10 -0
  100. package/dist/gallery/frame/chunks/railroad-ebnf-EBAXGLYW-6b9c3zeh.js +10 -0
  101. package/dist/gallery/frame/chunks/railroad-peg-LSFZ7HO6-avc8v39s.js +10 -0
  102. package/dist/gallery/frame/chunks/railroadDiagram-AXF67PYL-qc61wax4.js +131 -0
  103. package/dist/gallery/frame/chunks/requirementDiagram-LRYGKXZP-9bs4786c.js +1295 -0
  104. package/dist/gallery/frame/chunks/sankeyDiagram-W5VNT64P-awt1em8b.js +1339 -0
  105. package/dist/gallery/frame/chunks/sequenceDiagram-SI44F4Z6-qaf9mz3t.js +4324 -0
  106. package/dist/gallery/frame/chunks/sizeCapture-X5ZJPWSS-9fq685xd.js +64 -0
  107. package/dist/gallery/frame/chunks/stateDiagram-OKZ733FA-vx7a7hh0.js +456 -0
  108. package/dist/gallery/frame/chunks/stateDiagram-v2-UEYNNEHI-x4m6ws5t.js +46 -0
  109. package/dist/gallery/frame/chunks/swimlanes-SLNWSIFB-e4mxm1gh.js +8287 -0
  110. package/dist/gallery/frame/chunks/swimlanesDiagram-ULZ7WXOC-0h93e2qq.js +42 -0
  111. package/dist/gallery/frame/chunks/timeline-definition-Z64GVDOM-wp0bhbzg.js +1549 -0
  112. package/dist/gallery/frame/chunks/treeView-QDETBFTQ-hcx7n0vt.js +10 -0
  113. package/dist/gallery/frame/chunks/treemap-6X3UGDF4-av02skdw.js +10 -0
  114. package/dist/gallery/frame/chunks/vennDiagram-T6HMQDX7-pmvk1p7n.js +2566 -0
  115. package/dist/gallery/frame/chunks/wardley-OPB4EBWU-njsp6e40.js +10 -0
  116. package/dist/gallery/frame/chunks/wardleyDiagram-T6FBY63Y-eggmnv4z.js +979 -0
  117. package/dist/gallery/frame/chunks/xychartDiagram-ELKLHX3M-q40tnpe5.js +1954 -0
  118. package/dist/gallery/frame/frame.css +183 -0
  119. package/dist/gallery/frame/runtime/chart.js +42744 -0
  120. package/dist/gallery/frame/runtime/html.js +14 -0
  121. package/dist/gallery/frame/runtime/markdown.js +1403 -0
  122. package/dist/gallery/frame/runtime/mermaid.js +32 -0
  123. package/dist/gallery/frame/runtime/svg.js +14 -0
  124. package/dist/gallery/frame/runtime/tsx.js +52 -0
  125. package/dist/gallery/index.html +104 -0
  126. package/docs/reference/cli.md +163 -0
  127. package/docs/reference/export.md +106 -0
  128. package/docs/reference/html.md +215 -0
  129. package/docs/reference/http.md +85 -0
  130. package/docs/reference/mcp.md +78 -0
  131. package/docs/reference/security.md +119 -0
  132. package/docs/reference/storage.md +93 -0
  133. package/docs/reference/tsx.md +101 -0
  134. package/docs/reference/validation.md +212 -0
  135. package/package.json +89 -0
  136. package/scripts/build-gallery.ts +127 -0
  137. package/scripts/launch-netns.sh +67 -0
  138. package/skills/facet/SKILL.md +100 -0
  139. package/src/cli/client.ts +311 -0
  140. package/src/cli/commands/create.ts +49 -0
  141. package/src/cli/commands/doctor.ts +249 -0
  142. package/src/cli/commands/export.ts +179 -0
  143. package/src/cli/commands/instantiate.ts +35 -0
  144. package/src/cli/commands/list.ts +49 -0
  145. package/src/cli/commands/open.ts +75 -0
  146. package/src/cli/commands/pin.ts +39 -0
  147. package/src/cli/commands/promote.ts +49 -0
  148. package/src/cli/commands/publish.ts +122 -0
  149. package/src/cli/commands/read-back.ts +56 -0
  150. package/src/cli/commands/status.ts +114 -0
  151. package/src/cli/commands/watch.ts +146 -0
  152. package/src/cli/main.ts +522 -0
  153. package/src/cli/output.ts +106 -0
  154. package/src/cli/parser.ts +376 -0
  155. package/src/cli/presenter.ts +212 -0
  156. package/src/cli/service-metadata.ts +134 -0
  157. package/src/cli/spawn-service.ts +326 -0
  158. package/src/css.d.ts +4 -0
  159. package/src/gallery-web/app.ts +1581 -0
  160. package/src/gallery-web/export-menu.ts +121 -0
  161. package/src/gallery-web/export.ts +112 -0
  162. package/src/gallery-web/favicon.ts +54 -0
  163. package/src/gallery-web/frame/entries/chart.ts +6 -0
  164. package/src/gallery-web/frame/entries/html.ts +6 -0
  165. package/src/gallery-web/frame/entries/markdown.ts +6 -0
  166. package/src/gallery-web/frame/entries/mermaid.ts +6 -0
  167. package/src/gallery-web/frame/entries/svg.ts +6 -0
  168. package/src/gallery-web/frame/entries/tsx.ts +6 -0
  169. package/src/gallery-web/frame/frame-payload.ts +91 -0
  170. package/src/gallery-web/frame/renderer-validation.ts +13 -0
  171. package/src/gallery-web/frame/renderers/chart.ts +182 -0
  172. package/src/gallery-web/frame/renderers/dompurify-shim.ts +112 -0
  173. package/src/gallery-web/frame/renderers/html.ts +48 -0
  174. package/src/gallery-web/frame/renderers/markdown.ts +81 -0
  175. package/src/gallery-web/frame/renderers/mermaid.ts +120 -0
  176. package/src/gallery-web/frame/renderers/registry.ts +260 -0
  177. package/src/gallery-web/frame/renderers/svg.ts +393 -0
  178. package/src/gallery-web/frame/renderers/tsx.ts +61 -0
  179. package/src/gallery-web/frame/runtime.ts +501 -0
  180. package/src/gallery-web/frame/styles/artifact.css +8424 -0
  181. package/src/gallery-web/frame/styles/frame.css +183 -0
  182. package/src/gallery-web/frame/styles/html-source.css +23 -0
  183. package/src/gallery-web/frame/view-box.ts +33 -0
  184. package/src/gallery-web/frame-html.ts +72 -0
  185. package/src/gallery-web/index.html +104 -0
  186. package/src/gallery-web/session.ts +107 -0
  187. package/src/gallery-web/sse-client.ts +212 -0
  188. package/src/gallery-web/styles/app.css +420 -0
  189. package/src/gallery-web/styles/tokens.css +112 -0
  190. package/src/gallery-web/styles/verdict.css +186 -0
  191. package/src/gallery-web/swap.ts +64 -0
  192. package/src/gallery-web/theme.ts +40 -0
  193. package/src/gallery-web/view-state.ts +93 -0
  194. package/src/harness-adapters/claude-code/README.md +10 -0
  195. package/src/harness-adapters/claude-code/facet.sh +4 -0
  196. package/src/harness-adapters/codex/README.md +10 -0
  197. package/src/harness-adapters/codex/facet.sh +4 -0
  198. package/src/harness-adapters/mcp/README.md +13 -0
  199. package/src/harness-adapters/mcp/cli-bridge.ts +216 -0
  200. package/src/harness-adapters/mcp/main.ts +15 -0
  201. package/src/harness-adapters/mcp/server.ts +164 -0
  202. package/src/harness-adapters/mcp/tool-schemas.ts +53 -0
  203. package/src/harness-adapters/opencode/README.md +10 -0
  204. package/src/harness-adapters/opencode/facet.sh +4 -0
  205. package/src/runtime/compiled-entrypoints.ts +69 -0
  206. package/src/service/dispatcher.ts +717 -0
  207. package/src/service/export.ts +218 -0
  208. package/src/service/http-utils.ts +55 -0
  209. package/src/service/lexical/expectations.ts +210 -0
  210. package/src/service/lifecycle/idle-controller.ts +125 -0
  211. package/src/service/lifecycle/orphan-cleanup.ts +128 -0
  212. package/src/service/lifecycle/process-lock.ts +235 -0
  213. package/src/service/main.ts +136 -0
  214. package/src/service/process.ts +240 -0
  215. package/src/service/router-guards.ts +239 -0
  216. package/src/service/router.ts +627 -0
  217. package/src/service/security/auth.ts +168 -0
  218. package/src/service/security/host-origin.ts +138 -0
  219. package/src/service/security/http-guards.ts +13 -0
  220. package/src/service/security/leases.ts +182 -0
  221. package/src/service/security/token-store.ts +138 -0
  222. package/src/service/server.ts +356 -0
  223. package/src/service/store/database.ts +61 -0
  224. package/src/service/store/evidence-retention.ts +234 -0
  225. package/src/service/store/migrations.ts +167 -0
  226. package/src/service/store/repository-lifecycle.ts +121 -0
  227. package/src/service/store/repository.ts +732 -0
  228. package/src/service/store/schema.ts +218 -0
  229. package/src/service/stored-verdict.ts +97 -0
  230. package/src/service/stream.ts +301 -0
  231. package/src/service/verdict-enrichment.ts +45 -0
  232. package/src/shared/build/frame-bundle-plugins.ts +61 -0
  233. package/src/shared/build-mode.ts +28 -0
  234. package/src/shared/config/evidence-read.ts +98 -0
  235. package/src/shared/config/limits.ts +56 -0
  236. package/src/shared/config/paths.ts +96 -0
  237. package/src/shared/contracts/artifact-types.ts +2 -0
  238. package/src/shared/contracts/artifact.ts +98 -0
  239. package/src/shared/contracts/commands/_shared.ts +59 -0
  240. package/src/shared/contracts/commands/guards.ts +86 -0
  241. package/src/shared/contracts/commands/index.ts +204 -0
  242. package/src/shared/contracts/commands/names.ts +35 -0
  243. package/src/shared/contracts/commands/requests.ts +149 -0
  244. package/src/shared/contracts/commands/results.ts +200 -0
  245. package/src/shared/contracts/envelope.ts +140 -0
  246. package/src/shared/contracts/events.ts +41 -0
  247. package/src/shared/contracts/observed-counts.ts +19 -0
  248. package/src/shared/contracts/renderers.ts +6 -0
  249. package/src/shared/contracts/validation.ts +296 -0
  250. package/src/shared/errors/facet-error.ts +127 -0
  251. package/src/shared/errors/store-error.ts +68 -0
  252. package/src/shared/evidence-image.ts +37 -0
  253. package/src/shared/export.ts +31 -0
  254. package/src/shared/html/policy.ts +108 -0
  255. package/src/shared/html/style-vocabulary.ts +352 -0
  256. package/src/shared/logging/logger.ts +108 -0
  257. package/src/shared/logging/redact.ts +49 -0
  258. package/src/shared/security/frozen-csp.ts +13 -0
  259. package/src/shared/storage-version.ts +2 -0
  260. package/src/shared/tsx/execution.ts +29 -0
  261. package/src/shared/tsx/import-policy.ts +94 -0
  262. package/src/shared/util/dir-permissions.ts +94 -0
  263. package/src/shared/util/mermaid-nodes.ts +230 -0
  264. package/src/shared/util/process.ts +67 -0
  265. package/src/shared/util/time.ts +21 -0
  266. package/src/shared/version.ts +3 -0
  267. package/src/validation/sandbox/limits.ts +41 -0
  268. package/src/validation/sandbox/netns.ts +177 -0
  269. package/src/validation/tier0/chart.ts +177 -0
  270. package/src/validation/tier0/dom-shim.ts +54 -0
  271. package/src/validation/tier0/html.ts +408 -0
  272. package/src/validation/tier0/markdown.ts +285 -0
  273. package/src/validation/tier0/mermaid.ts +98 -0
  274. package/src/validation/tier0/runner.ts +504 -0
  275. package/src/validation/tier0/svg.ts +321 -0
  276. package/src/validation/tier0/tsx/allowlist-resolver.ts +77 -0
  277. package/src/validation/tier0/tsx/ast-policy-capabilities.ts +238 -0
  278. package/src/validation/tier0/tsx/ast-policy-shared.ts +71 -0
  279. package/src/validation/tier0/tsx/ast-policy.ts +181 -0
  280. package/src/validation/tier0/tsx/compiler.ts +156 -0
  281. package/src/validation/tier0/worker-dispatch.ts +211 -0
  282. package/src/validation/tier0/worker-entry.ts +96 -0
  283. package/src/validation/tier0/worker-input.ts +75 -0
  284. package/src/validation/tier1/browser-process.ts +147 -0
  285. package/src/validation/tier1/cdp-pipe.ts +281 -0
  286. package/src/validation/tier1/entries/chart.ts +5 -0
  287. package/src/validation/tier1/entries/html.ts +6 -0
  288. package/src/validation/tier1/entries/markdown.ts +5 -0
  289. package/src/validation/tier1/entries/mermaid.ts +5 -0
  290. package/src/validation/tier1/entries/svg.ts +5 -0
  291. package/src/validation/tier1/entries/tsx.ts +5 -0
  292. package/src/validation/tier1/frame-target.ts +162 -0
  293. package/src/validation/tier1/harness-entry.ts +261 -0
  294. package/src/validation/tier1/harness.ts +215 -0
  295. package/src/validation/tier1/isolated-probe.ts +94 -0
  296. package/src/validation/tier1/launcher.ts +177 -0
  297. package/src/validation/tier1/limits.ts +80 -0
  298. package/src/validation/tier1/nonce.ts +17 -0
  299. package/src/validation/tier1/protocol-probe.ts +519 -0
  300. package/src/validation/tier1/runner.ts +1122 -0
  301. package/src/validation/tier1/verdict.ts +246 -0
  302. package/src/validation/tier1/webp.ts +69 -0
  303. package/templates/README.md +88 -0
  304. package/templates/bar-compare.vl.json +63 -0
  305. package/templates/capacity-report.tsx +102 -0
  306. package/templates/decision-record.md +24 -0
  307. package/templates/deployment-state.mmd +40 -0
  308. package/templates/exemplar.md +91 -0
  309. package/templates/facet-story.tsx +799 -0
  310. package/templates/fleet-dashboard.html +141 -0
  311. package/templates/html-release-ledger.html +91 -0
  312. package/templates/html-status-report.html +114 -0
  313. package/templates/incident-console.tsx +147 -0
  314. package/templates/legion-boundaries.mmd +23 -0
  315. package/templates/legion-flow.mmd +15 -0
  316. package/templates/legion-sequence.mmd +14 -0
  317. package/templates/legion-state.mmd +7 -0
  318. package/templates/metric-card.svg +29 -0
  319. package/templates/observability-map.svg +101 -0
  320. package/templates/pipeline-audit.md +108 -0
  321. package/templates/release-metrics.vl.json +98 -0
  322. package/templates/service-topology.mmd +47 -0
  323. package/templates/status-report.md +32 -0
  324. package/templates/system-map.svg +53 -0
  325. package/templates/timeseries.vl.json +71 -0
  326. package/templates/tsx-interactive-counter.tsx +19 -0
  327. package/templates/tsx-status-report.tsx +31 -0
@@ -0,0 +1,476 @@
1
+ import {
2
+ layout
3
+ } from "./markdown-jka64qgp.js";
4
+ import {
5
+ adjustClustersAndEdges,
6
+ clear as clear5,
7
+ clusterDb,
8
+ findNonClusterChild,
9
+ sortNodesByHierarchy,
10
+ write
11
+ } from "./markdown-t4ethv9d.js";
12
+ import {
13
+ Graph
14
+ } from "./markdown-2h6bwsms.js";
15
+ import {
16
+ clear as clear3,
17
+ insertEdge,
18
+ insertEdgeLabel,
19
+ markers_default,
20
+ positionEdgeLabel
21
+ } from "./markdown-s1jatrnk.js";
22
+ import"./markdown-m7frq8x8.js";
23
+ import {
24
+ clear,
25
+ clear2,
26
+ insertCluster,
27
+ insertNode,
28
+ positionNode,
29
+ setNodeElem,
30
+ updateNodeBounds
31
+ } from "./markdown-tvdpppw8.js";
32
+ import {
33
+ getSubGraphTitleMargins
34
+ } from "./markdown-sgfg5vvq.js";
35
+ import"./markdown-82xmzhzd.js";
36
+ import"./markdown-c9k0fvp1.js";
37
+ import"./markdown-qx3cngz2.js";
38
+ import"./markdown-yengsms5.js";
39
+ import"./markdown-ff5wvb43.js";
40
+ import"./markdown-pzgd8z3s.js";
41
+ import {
42
+ getConfig2
43
+ } from "./markdown-92n37gd4.js";
44
+ import {
45
+ log
46
+ } from "./markdown-xw8dsk8b.js";
47
+ import {
48
+ __name
49
+ } from "./markdown-1s5vwkf2.js";
50
+ import"./markdown-dy5sgjhc.js";
51
+ import"./markdown-809k7q41.js";
52
+
53
+ // node_modules/mermaid/dist/chunks/mermaid.core/dagre-VZM6K2ZE.mjs
54
+ var clamp = /* @__PURE__ */ __name((value, min, max) => Math.max(min, Math.min(max, value)), "clamp");
55
+ var getDefaultSelfLoopSide = /* @__PURE__ */ __name((rankdir = "TB") => {
56
+ switch (rankdir) {
57
+ case "BT":
58
+ return "bottom";
59
+ case "LR":
60
+ return "right";
61
+ case "RL":
62
+ return "left";
63
+ case "TB":
64
+ default:
65
+ return "top";
66
+ }
67
+ }, "getDefaultSelfLoopSide");
68
+ var shouldMergeSelfLoopSegments = /* @__PURE__ */ __name((diagramType) => diagramType === "flowchart" || diagramType === "flowchart-v2" || diagramType === "stateDiagram", "shouldMergeSelfLoopSegments");
69
+ var getSelfLoopSide = /* @__PURE__ */ __name((graph, node, segments, originalNodeId, rankdir) => {
70
+ const layoutHints = [];
71
+ const dummyNodeIds = /* @__PURE__ */ new Set;
72
+ segments.forEach(({ start, end }) => {
73
+ if (start !== originalNodeId) {
74
+ dummyNodeIds.add(start);
75
+ }
76
+ if (end !== originalNodeId) {
77
+ dummyNodeIds.add(end);
78
+ }
79
+ });
80
+ dummyNodeIds.forEach((id) => {
81
+ const dummyNode = graph.node(id);
82
+ if (typeof dummyNode?.x === "number" && typeof dummyNode?.y === "number") {
83
+ layoutHints.push(dummyNode);
84
+ }
85
+ });
86
+ if (layoutHints.length === 0) {
87
+ segments.forEach(({ edge }) => {
88
+ (edge.points ?? []).forEach((point) => {
89
+ if (typeof point?.x === "number" && typeof point?.y === "number") {
90
+ layoutHints.push(point);
91
+ }
92
+ });
93
+ });
94
+ }
95
+ if (layoutHints.length === 0) {
96
+ return getDefaultSelfLoopSide(rankdir);
97
+ }
98
+ const center = layoutHints.reduce((acc, point) => ({
99
+ x: acc.x + point.x / layoutHints.length,
100
+ y: acc.y + point.y / layoutHints.length
101
+ }), { x: 0, y: 0 });
102
+ const dx = center.x - node.x;
103
+ const dy = center.y - node.y;
104
+ if (Math.abs(dx) > Math.abs(dy)) {
105
+ return dx > 0 ? "right" : "left";
106
+ }
107
+ if (Math.abs(dy) > 0) {
108
+ return dy > 0 ? "bottom" : "top";
109
+ }
110
+ return getDefaultSelfLoopSide(rankdir);
111
+ }, "getSelfLoopSide");
112
+ var getSelfLoopPoints = /* @__PURE__ */ __name((node, side = "top", yOffset = 0, labelWidth = 0) => {
113
+ const x = node.x;
114
+ const y = node.y - yOffset;
115
+ const halfWidth = node.width / 2;
116
+ const halfHeight = node.height / 2;
117
+ const maxSpan = Math.max(36, Math.min(100, node.width * 0.8));
118
+ const span = clamp(Math.max(labelWidth, node.width * 0.35), 36, maxSpan);
119
+ const depth = clamp(Math.min(node.width, node.height) * 0.45, 24, 48);
120
+ switch (side) {
121
+ case "bottom": {
122
+ const bottom = y + halfHeight;
123
+ return [
124
+ { x: x - span / 2, y: bottom },
125
+ { x: x - span / 2, y: bottom + depth },
126
+ { x: x + span / 2, y: bottom + depth },
127
+ { x: x + span / 2, y: bottom }
128
+ ];
129
+ }
130
+ case "right": {
131
+ const right = x + halfWidth;
132
+ return [
133
+ { x: right, y: y - span / 2 },
134
+ { x: right + depth, y: y - span / 2 },
135
+ { x: right + depth, y: y + span / 2 },
136
+ { x: right, y: y + span / 2 }
137
+ ];
138
+ }
139
+ case "left": {
140
+ const left = x - halfWidth;
141
+ return [
142
+ { x: left, y: y - span / 2 },
143
+ { x: left - depth, y: y - span / 2 },
144
+ { x: left - depth, y: y + span / 2 },
145
+ { x: left, y: y + span / 2 }
146
+ ];
147
+ }
148
+ case "top":
149
+ default: {
150
+ const top = y - halfHeight;
151
+ return [
152
+ { x: x - span / 2, y: top },
153
+ { x: x - span / 2, y: top - depth },
154
+ { x: x + span / 2, y: top - depth },
155
+ { x: x + span / 2, y: top }
156
+ ];
157
+ }
158
+ }
159
+ }, "getSelfLoopPoints");
160
+ var getSelfLoopLabelPosition = /* @__PURE__ */ __name((node, points, side = "top", yOffset = 0, label = {}) => {
161
+ const gap = 4;
162
+ const x = node.x;
163
+ const y = node.y - yOffset;
164
+ const labelWidth = label.width ?? 0;
165
+ const labelHeight = label.height ?? 0;
166
+ switch (side) {
167
+ case "bottom":
168
+ return { x, y: Math.max(...points.map((point) => point.y)) + labelHeight / 2 + gap };
169
+ case "right":
170
+ return { x: Math.max(...points.map((point) => point.x)) + labelWidth / 2 + gap, y };
171
+ case "left":
172
+ return { x: Math.min(...points.map((point) => point.x)) - labelWidth / 2 - gap, y };
173
+ case "top":
174
+ default:
175
+ return { x, y: Math.min(...points.map((point) => point.y)) - labelHeight / 2 - gap };
176
+ }
177
+ }, "getSelfLoopLabelPosition");
178
+ var getEdgesToRender = /* @__PURE__ */ __name((graph, yOffset = 0, { mergeSelfLoops = true } = {}) => {
179
+ const selfLoopEdgeGroups = /* @__PURE__ */ new Map;
180
+ const edgesToRender = [];
181
+ const rankdir = graph.graph()?.rankdir;
182
+ graph.edges().forEach((e) => {
183
+ const edge = graph.edge(e);
184
+ if (mergeSelfLoops && edge.selfLoop) {
185
+ const key = edge.selfLoop.id;
186
+ if (!selfLoopEdgeGroups.has(key)) {
187
+ selfLoopEdgeGroups.set(key, []);
188
+ }
189
+ selfLoopEdgeGroups.get(key).push({ edge, start: e.v, end: e.w });
190
+ } else {
191
+ edgesToRender.push({ edge, start: e.v, end: e.w });
192
+ }
193
+ });
194
+ selfLoopEdgeGroups.forEach((segments) => {
195
+ if (segments.length !== 3) {
196
+ segments.forEach((segment) => edgesToRender.push(segment));
197
+ return;
198
+ }
199
+ segments.sort((a, b) => a.edge.selfLoop.order - b.edge.selfLoop.order);
200
+ const [firstSegment, middleSegment, lastSegment] = segments;
201
+ const originalEdge = firstSegment.edge.originalEdge ?? middleSegment.edge.originalEdge ?? lastSegment.edge.originalEdge ?? middleSegment.edge;
202
+ const node = graph.node(originalEdge.start);
203
+ if (!node) {
204
+ segments.forEach((segment) => edgesToRender.push(segment));
205
+ return;
206
+ }
207
+ const label = {
208
+ width: middleSegment.edge.width,
209
+ height: middleSegment.edge.height
210
+ };
211
+ const side = getSelfLoopSide(graph, node, segments, originalEdge.start, rankdir);
212
+ const points = getSelfLoopPoints(node, side, yOffset, label.width ?? 0);
213
+ const labelPosition = getSelfLoopLabelPosition(node, points, side, yOffset, label);
214
+ const mergedEdge = {
215
+ ...middleSegment.edge,
216
+ ...originalEdge,
217
+ id: originalEdge.id,
218
+ points,
219
+ start: originalEdge.start,
220
+ end: originalEdge.end,
221
+ x: labelPosition.x,
222
+ y: labelPosition.y,
223
+ width: label.width,
224
+ height: label.height,
225
+ labelStyle: middleSegment.edge.labelStyle,
226
+ fromCluster: firstSegment.edge.fromCluster ?? middleSegment.edge.fromCluster ?? lastSegment.edge.fromCluster,
227
+ toCluster: firstSegment.edge.toCluster ?? middleSegment.edge.toCluster ?? lastSegment.edge.toCluster
228
+ };
229
+ delete mergedEdge.selfLoop;
230
+ delete mergedEdge.originalEdge;
231
+ edgesToRender.push({ edge: mergedEdge, start: mergedEdge.start, end: mergedEdge.end });
232
+ });
233
+ return edgesToRender;
234
+ }, "getEdgesToRender");
235
+ var recursiveRender = /* @__PURE__ */ __name(async (_elem, graph, diagramType, id, parentCluster, siteConfig) => {
236
+ log.warn("Graph in recursive render:XAX", write(graph), parentCluster);
237
+ const dir = graph.graph().rankdir;
238
+ log.trace("Dir in recursive render - dir:", dir);
239
+ const elem = _elem.insert("g").attr("class", "root");
240
+ if (!graph.nodes()) {
241
+ log.info("No nodes found for", graph);
242
+ } else {
243
+ log.info("Recursive render XXX", graph.nodes());
244
+ }
245
+ if (graph.edges().length > 0) {
246
+ log.info("Recursive edges", graph.edge(graph.edges()[0]));
247
+ }
248
+ const clusters = elem.insert("g").attr("class", "clusters");
249
+ const edgePaths = elem.insert("g").attr("class", "edgePaths");
250
+ const edgeLabels = elem.insert("g").attr("class", "edgeLabels");
251
+ const nodes = elem.insert("g").attr("class", "nodes");
252
+ const mergeSelfLoops = shouldMergeSelfLoopSegments(diagramType);
253
+ await Promise.all(graph.nodes().map(async function(v) {
254
+ const node = graph.node(v);
255
+ if (parentCluster !== undefined) {
256
+ const data = JSON.parse(JSON.stringify(parentCluster.clusterData));
257
+ log.trace(`Setting data for parent cluster XXX
258
+ Node.id = `, v, `
259
+ data=`, data.height, `
260
+ Parent cluster`, parentCluster.height);
261
+ graph.setNode(parentCluster.id, data);
262
+ if (!graph.parent(v)) {
263
+ log.trace("Setting parent", v, parentCluster.id);
264
+ graph.setParent(v, parentCluster.id, data);
265
+ }
266
+ }
267
+ log.info("(Insert) Node XXX" + v + ": " + JSON.stringify(graph.node(v)));
268
+ if (node?.clusterNode) {
269
+ log.info("Cluster identified XBX", v, node.width, graph.node(v));
270
+ const { ranksep, nodesep } = graph.graph();
271
+ node.graph.setGraph({
272
+ ...node.graph.graph(),
273
+ ranksep: ranksep + 25,
274
+ nodesep
275
+ });
276
+ const o = await recursiveRender(nodes, node.graph, diagramType, id, graph.node(v), siteConfig);
277
+ const newEl = o.elem;
278
+ updateNodeBounds(node, newEl);
279
+ node.diff = o.diff || 0;
280
+ log.info("New compound node after recursive render XAX", v, "width", node.width, "height", node.height);
281
+ setNodeElem(newEl, node);
282
+ } else {
283
+ if (graph.children(v).length > 0) {
284
+ log.trace("Cluster - the non recursive path XBX", v, node.id, node, node.width, "Graph:", graph);
285
+ log.trace(findNonClusterChild(node.id, graph));
286
+ clusterDb.set(node.id, { id: findNonClusterChild(node.id, graph), node });
287
+ } else {
288
+ log.trace("Node - the non recursive path XAX", v, nodes, graph.node(v), dir);
289
+ await insertNode(nodes, graph.node(v), { config: siteConfig, dir });
290
+ }
291
+ }
292
+ }));
293
+ const processEdges = /* @__PURE__ */ __name(async () => {
294
+ const edgePromises = graph.edges().map(async function(e) {
295
+ const edge = graph.edge(e.v, e.w, e.name);
296
+ log.info("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(e));
297
+ log.info("Edge " + e.v + " -> " + e.w + ": ", e, " ", JSON.stringify(graph.edge(e)));
298
+ log.info("Fix", clusterDb, "ids:", e.v, e.w, "Translating: ", clusterDb.get(e.v), clusterDb.get(e.w));
299
+ if (mergeSelfLoops && edge.selfLoop) {
300
+ if (edge.selfLoop.order !== 1) {
301
+ return;
302
+ }
303
+ const segmentId = edge.id;
304
+ edge.id = edge.selfLoop.id;
305
+ await insertEdgeLabel(edgeLabels, edge);
306
+ edge.id = segmentId;
307
+ return;
308
+ }
309
+ await insertEdgeLabel(edgeLabels, edge);
310
+ });
311
+ await Promise.all(edgePromises);
312
+ }, "processEdges");
313
+ await processEdges();
314
+ log.info("Graph before layout:", JSON.stringify(write(graph)));
315
+ log.info("############################################# XXX");
316
+ log.info("### Layout ### XXX");
317
+ log.info("############################################# XXX");
318
+ layout(graph);
319
+ log.info("Graph after layout:", JSON.stringify(write(graph)));
320
+ let diff = 0;
321
+ let { subGraphTitleTotalMargin } = getSubGraphTitleMargins(siteConfig);
322
+ await Promise.all(sortNodesByHierarchy(graph).map(async function(v) {
323
+ const node = graph.node(v);
324
+ log.info("Position XBX => " + v + ": (" + node.x, "," + node.y, ") width: ", node.width, " height: ", node.height);
325
+ if (node?.clusterNode) {
326
+ node.y += subGraphTitleTotalMargin;
327
+ log.info("A tainted cluster node XBX1", v, node.id, node.width, node.height, node.x, node.y, graph.parent(v));
328
+ clusterDb.get(node.id).node = node;
329
+ positionNode(node);
330
+ } else {
331
+ if (graph.children(v).length > 0) {
332
+ log.info("A pure cluster node XBX1", v, node.id, node.x, node.y, node.width, node.height, graph.parent(v));
333
+ node.height += subGraphTitleTotalMargin;
334
+ graph.node(node.parentId);
335
+ const halfPadding = node?.padding / 2 || 0;
336
+ const labelHeight = node?.labelBBox?.height || 0;
337
+ const offsetY = labelHeight - halfPadding || 0;
338
+ log.debug("OffsetY", offsetY, "labelHeight", labelHeight, "halfPadding", halfPadding);
339
+ await insertCluster(clusters, node);
340
+ clusterDb.get(node.id).node = node;
341
+ } else {
342
+ const parent = graph.node(node.parentId);
343
+ node.y += subGraphTitleTotalMargin / 2;
344
+ log.info("A regular node XBX1 - using the padding", node.id, "parent", node.parentId, node.width, node.height, node.x, node.y, "offsetY", node.offsetY, "parent", parent, parent?.offsetY, node);
345
+ positionNode(node);
346
+ }
347
+ }
348
+ }));
349
+ const edgeOffsetY = subGraphTitleTotalMargin / 2;
350
+ const edgesToRender = getEdgesToRender(graph, edgeOffsetY, { mergeSelfLoops });
351
+ edgesToRender.forEach(function({ edge, start, end }) {
352
+ log.info("Edge " + start + " -> " + end + ": " + JSON.stringify(edge), edge);
353
+ edge.points.forEach((point) => point.y += edgeOffsetY);
354
+ const startNode = graph.node(start);
355
+ const endNode = graph.node(end);
356
+ const paths = insertEdge(edgePaths, edge, clusterDb, diagramType, startNode, endNode, id);
357
+ positionEdgeLabel(edge, paths);
358
+ });
359
+ graph.nodes().forEach(function(v) {
360
+ const n = graph.node(v);
361
+ log.info(v, n.type, n.diff);
362
+ if (n.isGroup) {
363
+ diff = n.diff;
364
+ }
365
+ });
366
+ log.warn("Returning from recursive render XAX", elem, diff);
367
+ return { elem, diff };
368
+ }, "recursiveRender");
369
+ var render = /* @__PURE__ */ __name(async (data4Layout, svg) => {
370
+ const graph = new Graph({
371
+ multigraph: true,
372
+ compound: true
373
+ }).setGraph({
374
+ rankdir: data4Layout.direction,
375
+ nodesep: data4Layout.config?.nodeSpacing || data4Layout.config?.flowchart?.nodeSpacing || data4Layout.nodeSpacing,
376
+ ranksep: data4Layout.config?.rankSpacing || data4Layout.config?.flowchart?.rankSpacing || data4Layout.rankSpacing,
377
+ marginx: 8,
378
+ marginy: 8
379
+ }).setDefaultEdgeLabel(function() {
380
+ return {};
381
+ });
382
+ const element = svg.select("g");
383
+ markers_default(element, data4Layout.markers, data4Layout.type, data4Layout.diagramId);
384
+ clear2();
385
+ clear3();
386
+ clear();
387
+ clear5();
388
+ data4Layout.nodes.forEach((node) => {
389
+ graph.setNode(node.id, { ...node });
390
+ if (node.parentId) {
391
+ graph.setParent(node.id, node.parentId);
392
+ }
393
+ });
394
+ log.debug("Edges:", data4Layout.edges);
395
+ data4Layout.edges.forEach((edge) => {
396
+ if (edge.start === edge.end) {
397
+ const nodeId = edge.start;
398
+ const specialId1 = nodeId + "---" + nodeId + "---1";
399
+ const specialId2 = nodeId + "---" + nodeId + "---2";
400
+ const node = graph.node(nodeId);
401
+ graph.setNode(specialId1, {
402
+ domId: specialId1,
403
+ id: specialId1,
404
+ parentId: node.parentId,
405
+ labelStyle: "",
406
+ label: "",
407
+ padding: 0,
408
+ shape: "labelRect",
409
+ style: "",
410
+ width: 10,
411
+ height: 10
412
+ });
413
+ graph.setParent(specialId1, node.parentId);
414
+ graph.setNode(specialId2, {
415
+ domId: specialId2,
416
+ id: specialId2,
417
+ parentId: node.parentId,
418
+ labelStyle: "",
419
+ padding: 0,
420
+ shape: "labelRect",
421
+ label: "",
422
+ style: "",
423
+ width: 10,
424
+ height: 10
425
+ });
426
+ graph.setParent(specialId2, node.parentId);
427
+ const originalEdge = structuredClone(edge);
428
+ const edge1 = structuredClone(edge);
429
+ const edgeMid = structuredClone(edge);
430
+ const edge2 = structuredClone(edge);
431
+ edge1.originalEdge = originalEdge;
432
+ edge1.selfLoop = { id: originalEdge.id, order: 0 };
433
+ edgeMid.originalEdge = originalEdge;
434
+ edgeMid.selfLoop = { id: originalEdge.id, order: 1 };
435
+ edge2.originalEdge = originalEdge;
436
+ edge2.selfLoop = { id: originalEdge.id, order: 2 };
437
+ edge1.label = "";
438
+ edge1.arrowTypeEnd = "none";
439
+ edge1.endLabelLeft = "";
440
+ edge1.endLabelRight = "";
441
+ edge1.startLabelLeft = "";
442
+ edge1.id = nodeId + "-cyclic-special-1";
443
+ edgeMid.startLabelRight = "";
444
+ edgeMid.startLabelLeft = "";
445
+ edgeMid.endLabelLeft = "";
446
+ edgeMid.endLabelRight = "";
447
+ edgeMid.arrowTypeStart = "none";
448
+ edgeMid.arrowTypeEnd = "none";
449
+ edgeMid.id = nodeId + "-cyclic-special-mid";
450
+ edge2.label = "";
451
+ edge2.startLabelRight = "";
452
+ edge2.startLabelLeft = "";
453
+ edge2.arrowTypeStart = "none";
454
+ if (node.isGroup) {
455
+ edge1.fromCluster = nodeId;
456
+ edge2.toCluster = nodeId;
457
+ }
458
+ edge2.id = nodeId + "-cyclic-special-2";
459
+ edge2.arrowTypeStart = "none";
460
+ graph.setEdge(nodeId, specialId1, edge1, nodeId + "-cyclic-special-0");
461
+ graph.setEdge(specialId1, specialId2, edgeMid, nodeId + "-cyclic-special-1");
462
+ graph.setEdge(specialId2, nodeId, edge2, nodeId + "-cyclic-special-2");
463
+ } else {
464
+ graph.setEdge(edge.start, edge.end, { ...edge }, edge.id);
465
+ }
466
+ });
467
+ log.warn("Graph at first:", JSON.stringify(write(graph)));
468
+ adjustClustersAndEdges(graph);
469
+ log.warn("Graph after XAX:", JSON.stringify(write(graph)));
470
+ const siteConfig = getConfig2();
471
+ await recursiveRender(element, graph, data4Layout.type, data4Layout.diagramId, undefined, siteConfig);
472
+ }, "render");
473
+ export {
474
+ getEdgesToRender,
475
+ render
476
+ };