@joekytc/dsh-swarm 0.1.2 → 0.2.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 (567) hide show
  1. package/README.md +3 -3
  2. package/README.zh-CN.md +3 -3
  3. package/client/BoardCard.tsx +24 -2
  4. package/client/ConfigSection.tsx +71 -0
  5. package/client/ConfigSelect.tsx +69 -0
  6. package/client/KanbanBoard.tsx +3 -0
  7. package/client/KanbanTab.tsx +4 -3
  8. package/client/TaskDrawer.tsx +2 -26
  9. package/client/WorkflowRail.tsx +3 -1
  10. package/client/config-store.ts +51 -0
  11. package/client/config.css +110 -0
  12. package/client/index.ts +39 -4
  13. package/client/kanban.css +19 -2
  14. package/client/session-bridge.ts +39 -0
  15. package/client/timeline-model.ts +10 -1
  16. package/client/workflow-model.ts +3 -1
  17. package/lib/client.js +358 -53
  18. package/lib/config.d.ts +8 -1
  19. package/lib/config.js +6 -1
  20. package/lib/dispatcher/agent-runner.d.ts +28 -6
  21. package/lib/dispatcher/agent-runner.js +175 -62
  22. package/lib/dispatcher/chain-auditor.js +4 -1
  23. package/lib/dispatcher/dispatcher.d.ts +62 -3
  24. package/lib/dispatcher/dispatcher.js +243 -20
  25. package/lib/dispatcher/session-events.d.ts +11 -15
  26. package/lib/dispatcher/session-events.js +17 -5
  27. package/lib/dispatcher/v-orchestrator.d.ts +42 -9
  28. package/lib/dispatcher/v-orchestrator.js +236 -28
  29. package/lib/domain/config-override.d.ts +38 -0
  30. package/lib/domain/config-override.js +101 -0
  31. package/lib/domain/delivery-contract.d.ts +3 -2
  32. package/lib/domain/delivery-contract.js +28 -16
  33. package/lib/domain/gate-policy.d.ts +26 -0
  34. package/lib/domain/gate-policy.js +44 -0
  35. package/lib/domain/kanban-service.d.ts +16 -3
  36. package/lib/domain/kanban-service.js +41 -6
  37. package/lib/domain/permissions.js +1 -1
  38. package/lib/domain/planning-checklist.d.ts +5 -0
  39. package/lib/domain/planning-checklist.js +80 -6
  40. package/lib/domain/projection.js +2 -1
  41. package/lib/domain/review-evidence.js +1 -1
  42. package/lib/domain/state-machine.js +2 -1
  43. package/lib/domain/types.d.ts +2 -2
  44. package/lib/index.js +19 -21
  45. package/lib/roles/clean-fs-tools.d.ts +22 -0
  46. package/lib/roles/clean-fs-tools.js +118 -0
  47. package/lib/roles/skill-installer.d.ts +6 -0
  48. package/lib/roles/skill-installer.js +32 -0
  49. package/lib/roles/toolsets.d.ts +13 -1
  50. package/lib/roles/toolsets.js +163 -31
  51. package/lib/roles/wiki-worker.d.ts +1 -0
  52. package/lib/roles/wiki-worker.js +10 -2
  53. package/lib/routes/kanban-http.d.ts +5 -2
  54. package/lib/routes/kanban-http.js +36 -3
  55. package/lib/routes/planning-driver.d.ts +3 -1
  56. package/lib/routes/planning-driver.js +10 -6
  57. package/lib/routes/prefix-router.d.ts +16 -0
  58. package/lib/routes/prefix-router.js +37 -2
  59. package/lib/services/config-provider.d.ts +42 -0
  60. package/lib/services/config-provider.js +94 -0
  61. package/lib/services/gate-runner.d.ts +24 -0
  62. package/lib/services/gate-runner.js +87 -0
  63. package/lib/services/kanban-provider.d.ts +5 -1
  64. package/lib/services/kanban-provider.js +40 -2
  65. package/lib/services/llm-catalog.d.ts +35 -0
  66. package/lib/services/llm-catalog.js +19 -0
  67. package/lib/tools/kanban-tools.js +1 -0
  68. package/lib/tools/main-session-tools.d.ts +17 -2
  69. package/lib/tools/main-session-tools.js +88 -21
  70. package/lib/tools/planning-tools.d.ts +4 -0
  71. package/lib/tools/planning-tools.js +39 -12
  72. package/lib/tools/prefetch-tools.js +1 -0
  73. package/lib/tools/spec-card-tools.js +1 -0
  74. package/lib/tools/wiki-tools.js +5 -4
  75. package/lib/wiki/kb-linkage.d.ts +9 -2
  76. package/lib/wiki/kb-linkage.js +3 -3
  77. package/lib/wiki/local-kb-client.d.ts +14 -0
  78. package/lib/wiki/local-kb-client.js +101 -0
  79. package/lib/wiki/local-kb.d.ts +6 -0
  80. package/lib/wiki/local-kb.js +25 -0
  81. package/lib/wiki/memory-recall.d.ts +14 -6
  82. package/lib/wiki/memory-recall.js +17 -13
  83. package/lib/wiki/page-path.d.ts +9 -3
  84. package/lib/wiki/page-path.js +29 -11
  85. package/lib/wiki/wiki-vault-client.d.ts +3 -3
  86. package/lib/wiki/wiki-vault-client.js +6 -6
  87. package/package.json +16 -11
  88. package/personas/kanban-d/preset.yml +1 -1
  89. package/personas/kanban-dt/agent.cordis.yml +2 -2
  90. package/personas/kanban-dt/preset.yml +1 -1
  91. package/personas/kanban-p/agent.cordis.yml +16 -0
  92. package/personas/kanban-p/preset.yml +1 -1
  93. package/personas/kanban-pt/agent.cordis.yml +38 -8
  94. package/personas/kanban-pt/preset.yml +1 -1
  95. package/personas/kanban-w/agent.cordis.yml +35 -16
  96. package/personas/kanban-w/preset.yml +1 -1
  97. package/personas/persona-dt.md +1 -1
  98. package/personas/persona-p.md +4 -1
  99. package/personas/persona-pt.md +13 -6
  100. package/personas/persona-w.md +11 -9
  101. package/skills/grill-me/SKILL.md +71 -0
  102. package/skills/llm-wiki-skill/.mise.toml +2 -0
  103. package/skills/llm-wiki-skill/.nvmrc +1 -0
  104. package/skills/llm-wiki-skill/AGENTS.md +173 -0
  105. package/skills/llm-wiki-skill/CHANGELOG.md +548 -0
  106. package/skills/llm-wiki-skill/CLAUDE.md +152 -0
  107. package/skills/llm-wiki-skill/HERMES.md +44 -0
  108. package/skills/llm-wiki-skill/README.en.md +261 -0
  109. package/skills/llm-wiki-skill/README.md +291 -0
  110. package/skills/llm-wiki-skill/SKILL.md +1133 -0
  111. package/skills/llm-wiki-skill/assets/graph-demo.gif +0 -0
  112. package/skills/llm-wiki-skill/assets/graph-preview.png +0 -0
  113. package/skills/llm-wiki-skill/deps/LICENSE-d3.txt +13 -0
  114. package/skills/llm-wiki-skill/deps/LICENSE-marked.txt +44 -0
  115. package/skills/llm-wiki-skill/deps/LICENSE-purify.txt +568 -0
  116. package/skills/llm-wiki-skill/deps/LICENSE-roughjs.txt +21 -0
  117. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/SKILL.md +261 -0
  118. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/references/config/first-time-setup.md +106 -0
  119. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/cdp.ts +179 -0
  120. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/constants.ts +13 -0
  121. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/defuddle-converter.ts +58 -0
  122. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/html-to-markdown.ts +135 -0
  123. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/legacy-converter.ts +629 -0
  124. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/main.ts +314 -0
  125. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/markdown-conversion-shared.ts +305 -0
  126. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/media-localizer.ts +317 -0
  127. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/package.json +14 -0
  128. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/paths.ts +29 -0
  129. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/vendor/baoyu-chrome-cdp/package.json +9 -0
  130. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/vendor/baoyu-chrome-cdp/src/index.test.ts +307 -0
  131. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/vendor/baoyu-chrome-cdp/src/index.ts +523 -0
  132. package/skills/llm-wiki-skill/deps/d3.min.js +2 -0
  133. package/skills/llm-wiki-skill/deps/marked.min.js +6 -0
  134. package/skills/llm-wiki-skill/deps/purify.min.js +3 -0
  135. package/skills/llm-wiki-skill/deps/rough.min.js +7 -0
  136. package/skills/llm-wiki-skill/deps/youtube-transcript/SKILL.md +47 -0
  137. package/skills/llm-wiki-skill/deps/youtube-transcript/scripts/get_transcript.py +72 -0
  138. package/skills/llm-wiki-skill/designs/graph-edge-legibility/graph-edge-treatments.html +480 -0
  139. package/skills/llm-wiki-skill/docs/design/oriental-atlas/DESIGN.md +183 -0
  140. package/skills/llm-wiki-skill/docs/design/oriental-atlas/README.md +10 -0
  141. package/skills/llm-wiki-skill/docs/design/oriental-atlas/design-brief.md +170 -0
  142. package/skills/llm-wiki-skill/docs/design/oriental-atlas/oriental-editorial-atlas.html +1908 -0
  143. package/skills/llm-wiki-skill/docs/design/oriental-atlas/reviews/result-review.md +68 -0
  144. package/skills/llm-wiki-skill/docs/graph/2026-06-16-interaction-risk-audit.md +88 -0
  145. package/skills/llm-wiki-skill/docs/graph/2026-06-16-interaction-test-coverage-map.md +212 -0
  146. package/skills/llm-wiki-skill/docs/graph/performance/2026-06-18-phase-0-2-baseline.md +86 -0
  147. package/skills/llm-wiki-skill/docs/graph/performance/2026-06-18-phase-1-3-dom-svg-large-baseline.md +85 -0
  148. package/skills/llm-wiki-skill/docs/graph/performance/2026-06-18-phase-1-4-disposable-validation-gate.md +97 -0
  149. package/skills/llm-wiki-skill/docs/graph/performance/2026-06-18-phase-2-4-global-renderer-trial-matrix.md +168 -0
  150. package/skills/llm-wiki-skill/docs/graph/performance/2026-06-19-phase-6-1-sigma-graphology-trial.md +71 -0
  151. package/skills/llm-wiki-skill/docs/graph/performance/2026-06-19-phase-6-2-vis-network-trial.md +78 -0
  152. package/skills/llm-wiki-skill/docs/graph/performance/2026-06-19-phase-6-3-aggregation-fallback-trial.md +72 -0
  153. package/skills/llm-wiki-skill/docs/graph/performance/2026-06-19-phase-6-4-global-renderer-route-decision.md +94 -0
  154. package/skills/llm-wiki-skill/docs/graph/performance/2026-06-19-sigma-global-production-integration-result.md +102 -0
  155. package/skills/llm-wiki-skill/docs/graph/performance/artifacts/2026-06-18-phase-0-2/stage-4.5-offline-dense-wheel.json +9 -0
  156. package/skills/llm-wiki-skill/docs/graph/performance/artifacts/2026-06-18-phase-0-2/stage-4.5-offline-dense-wheel.png +0 -0
  157. package/skills/llm-wiki-skill/docs/graph/performance/artifacts/2026-06-18-phase-0-2/stage-4.5-offline-navigation.png +0 -0
  158. package/skills/llm-wiki-skill/docs/spark/2026-06-15-omp-tool-status-events-design.md +174 -0
  159. package/skills/llm-wiki-skill/docs/spark/2026-06-16-graph-interaction-geometry-design.md +832 -0
  160. package/skills/llm-wiki-skill/docs/spark/2026-06-16-graph-six-layer-architecture-design.md +577 -0
  161. package/skills/llm-wiki-skill/docs/spark/2026-06-17-static-renderer-coordination-split-design.md +172 -0
  162. package/skills/llm-wiki-skill/docs/spark/2026-06-18-large-graph-global-community-design.md +909 -0
  163. package/skills/llm-wiki-skill/docs/spark/2026-06-19-sigma-global-graph-renderer-design.md +360 -0
  164. package/skills/llm-wiki-skill/docs/spark/2026-06-20-paper-ui-port-design.md +162 -0
  165. package/skills/llm-wiki-skill/docs/spark/2026-06-20-paper-ui-v2-shell-alignment-design.md +384 -0
  166. package/skills/llm-wiki-skill/docs/spark/2026-06-21-graph-experience-completion-design.md +534 -0
  167. package/skills/llm-wiki-skill/docs/spark/2026-06-22-chat-auto-scroll-design.md +185 -0
  168. package/skills/llm-wiki-skill/docs/spark/2026-06-22-graph-community-node-visual-design.md +266 -0
  169. package/skills/llm-wiki-skill/docs/spark/2026-06-25-sigma-overlay-refactor-perf-design.md +170 -0
  170. package/skills/llm-wiki-skill/docs/spark/2026-06-26-global-sigma-community-spotlight-design.md +393 -0
  171. package/skills/llm-wiki-skill/docs/spark/mockups/2026-06-18-large-graph-global-community-flow.html +746 -0
  172. package/skills/llm-wiki-skill/install.ps1 +87 -0
  173. package/skills/llm-wiki-skill/install.sh +722 -0
  174. package/skills/llm-wiki-skill/package-lock.json +11171 -0
  175. package/skills/llm-wiki-skill/package.json +24 -0
  176. package/skills/llm-wiki-skill/packages/graph-engine/package.json +37 -0
  177. package/skills/llm-wiki-skill/packages/graph-engine/src/anim/.gitkeep +1 -0
  178. package/skills/llm-wiki-skill/packages/graph-engine/src/anim/index.ts +179 -0
  179. package/skills/llm-wiki-skill/packages/graph-engine/src/architecture.ts +79 -0
  180. package/skills/llm-wiki-skill/packages/graph-engine/src/diff.ts +121 -0
  181. package/skills/llm-wiki-skill/packages/graph-engine/src/facade.ts +1406 -0
  182. package/skills/llm-wiki-skill/packages/graph-engine/src/graph-node.ts +37 -0
  183. package/skills/llm-wiki-skill/packages/graph-engine/src/index.ts +25 -0
  184. package/skills/llm-wiki-skill/packages/graph-engine/src/layout/edge-geometry.ts +17 -0
  185. package/skills/llm-wiki-skill/packages/graph-engine/src/layout/index.ts +16 -0
  186. package/skills/llm-wiki-skill/packages/graph-engine/src/layout/spatial-index.ts +509 -0
  187. package/skills/llm-wiki-skill/packages/graph-engine/src/model/atlas.ts +18 -0
  188. package/skills/llm-wiki-skill/packages/graph-engine/src/model/index.ts +10 -0
  189. package/skills/llm-wiki-skill/packages/graph-engine/src/model/labels.ts +11 -0
  190. package/skills/llm-wiki-skill/packages/graph-engine/src/model/layout.ts +81 -0
  191. package/skills/llm-wiki-skill/packages/graph-engine/src/model/learning.ts +8 -0
  192. package/skills/llm-wiki-skill/packages/graph-engine/src/model/legacy-helpers.ts +1379 -0
  193. package/skills/llm-wiki-skill/packages/graph-engine/src/model/queue.ts +7 -0
  194. package/skills/llm-wiki-skill/packages/graph-engine/src/model/storage.ts +4 -0
  195. package/skills/llm-wiki-skill/packages/graph-engine/src/model/visibility.ts +9 -0
  196. package/skills/llm-wiki-skill/packages/graph-engine/src/render/.gitkeep +1 -0
  197. package/skills/llm-wiki-skill/packages/graph-engine/src/render/adapter.ts +443 -0
  198. package/skills/llm-wiki-skill/packages/graph-engine/src/render/aggregation-containers.ts +64 -0
  199. package/skills/llm-wiki-skill/packages/graph-engine/src/render/community-cloud-geometry.ts +178 -0
  200. package/skills/llm-wiki-skill/packages/graph-engine/src/render/community-wash.ts +238 -0
  201. package/skills/llm-wiki-skill/packages/graph-engine/src/render/community-washes.ts +19 -0
  202. package/skills/llm-wiki-skill/packages/graph-engine/src/render/compat-contract.ts +14 -0
  203. package/skills/llm-wiki-skill/packages/graph-engine/src/render/controller.ts +705 -0
  204. package/skills/llm-wiki-skill/packages/graph-engine/src/render/controls.ts +288 -0
  205. package/skills/llm-wiki-skill/packages/graph-engine/src/render/dom-svg-renderer.ts +180 -0
  206. package/skills/llm-wiki-skill/packages/graph-engine/src/render/edges.ts +51 -0
  207. package/skills/llm-wiki-skill/packages/graph-engine/src/render/geometry.ts +380 -0
  208. package/skills/llm-wiki-skill/packages/graph-engine/src/render/gestures.ts +673 -0
  209. package/skills/llm-wiki-skill/packages/graph-engine/src/render/graph-renderer-root.ts +387 -0
  210. package/skills/llm-wiki-skill/packages/graph-engine/src/render/hit-testing.ts +56 -0
  211. package/skills/llm-wiki-skill/packages/graph-engine/src/render/host-dom.ts +14 -0
  212. package/skills/llm-wiki-skill/packages/graph-engine/src/render/hover-card.ts +37 -0
  213. package/skills/llm-wiki-skill/packages/graph-engine/src/render/index.ts +213 -0
  214. package/skills/llm-wiki-skill/packages/graph-engine/src/render/keyboard.ts +48 -0
  215. package/skills/llm-wiki-skill/packages/graph-engine/src/render/legend.ts +25 -0
  216. package/skills/llm-wiki-skill/packages/graph-engine/src/render/minimap.ts +45 -0
  217. package/skills/llm-wiki-skill/packages/graph-engine/src/render/model.ts +1339 -0
  218. package/skills/llm-wiki-skill/packages/graph-engine/src/render/node-drag-lifecycle.ts +94 -0
  219. package/skills/llm-wiki-skill/packages/graph-engine/src/render/nodes.ts +103 -0
  220. package/skills/llm-wiki-skill/packages/graph-engine/src/render/offline-reader.ts +209 -0
  221. package/skills/llm-wiki-skill/packages/graph-engine/src/render/overlays-presenter.ts +192 -0
  222. package/skills/llm-wiki-skill/packages/graph-engine/src/render/overlays.ts +73 -0
  223. package/skills/llm-wiki-skill/packages/graph-engine/src/render/pin-position.ts +51 -0
  224. package/skills/llm-wiki-skill/packages/graph-engine/src/render/preview.ts +65 -0
  225. package/skills/llm-wiki-skill/packages/graph-engine/src/render/relation-focus.ts +91 -0
  226. package/skills/llm-wiki-skill/packages/graph-engine/src/render/render-context.ts +85 -0
  227. package/skills/llm-wiki-skill/packages/graph-engine/src/render/render-pipeline.ts +871 -0
  228. package/skills/llm-wiki-skill/packages/graph-engine/src/render/render-styles.ts +1405 -0
  229. package/skills/llm-wiki-skill/packages/graph-engine/src/render/renderer-surface.ts +75 -0
  230. package/skills/llm-wiki-skill/packages/graph-engine/src/render/search.ts +57 -0
  231. package/skills/llm-wiki-skill/packages/graph-engine/src/render/sigma-coordinates.ts +44 -0
  232. package/skills/llm-wiki-skill/packages/graph-engine/src/render/sigma-global-drag.ts +246 -0
  233. package/skills/llm-wiki-skill/packages/graph-engine/src/render/sigma-global-renderer.ts +1425 -0
  234. package/skills/llm-wiki-skill/packages/graph-engine/src/render/sigma-overlay-svg.ts +121 -0
  235. package/skills/llm-wiki-skill/packages/graph-engine/src/render/simulation-bridge.ts +59 -0
  236. package/skills/llm-wiki-skill/packages/graph-engine/src/render/state.ts +262 -0
  237. package/skills/llm-wiki-skill/packages/graph-engine/src/render/toolbar.ts +40 -0
  238. package/skills/llm-wiki-skill/packages/graph-engine/src/render/viewport.ts +336 -0
  239. package/skills/llm-wiki-skill/packages/graph-engine/src/select/.gitkeep +1 -0
  240. package/skills/llm-wiki-skill/packages/graph-engine/src/select/index.ts +189 -0
  241. package/skills/llm-wiki-skill/packages/graph-engine/src/sim/index.ts +372 -0
  242. package/skills/llm-wiki-skill/packages/graph-engine/src/sim/pins.ts +84 -0
  243. package/skills/llm-wiki-skill/packages/graph-engine/src/summary/index.ts +447 -0
  244. package/skills/llm-wiki-skill/packages/graph-engine/src/themes/.gitkeep +1 -0
  245. package/skills/llm-wiki-skill/packages/graph-engine/src/themes/index.ts +8 -0
  246. package/skills/llm-wiki-skill/packages/graph-engine/src/themes/tokens.ts +117 -0
  247. package/skills/llm-wiki-skill/packages/graph-engine/src/types/d3-quadtree.d.ts +22 -0
  248. package/skills/llm-wiki-skill/packages/graph-engine/src/types.ts +531 -0
  249. package/skills/llm-wiki-skill/packages/graph-engine/test/aggregation-fallback-trial-adapter.test.ts +115 -0
  250. package/skills/llm-wiki-skill/packages/graph-engine/test/aggregation-fallback-trial-adapter.ts +222 -0
  251. package/skills/llm-wiki-skill/packages/graph-engine/test/anim.test.ts +121 -0
  252. package/skills/llm-wiki-skill/packages/graph-engine/test/architecture.test.ts +63 -0
  253. package/skills/llm-wiki-skill/packages/graph-engine/test/community-cloud-geometry.test.ts +86 -0
  254. package/skills/llm-wiki-skill/packages/graph-engine/test/community-wash.test.ts +97 -0
  255. package/skills/llm-wiki-skill/packages/graph-engine/test/diff.test.ts +133 -0
  256. package/skills/llm-wiki-skill/packages/graph-engine/test/facade.test.ts +1369 -0
  257. package/skills/llm-wiki-skill/packages/graph-engine/test/geometry.test.ts +147 -0
  258. package/skills/llm-wiki-skill/packages/graph-engine/test/gestures.test.ts +768 -0
  259. package/skills/llm-wiki-skill/packages/graph-engine/test/graph-layout.test.ts +110 -0
  260. package/skills/llm-wiki-skill/packages/graph-engine/test/helpers.test.ts +287 -0
  261. package/skills/llm-wiki-skill/packages/graph-engine/test/interaction-contract.test.ts +106 -0
  262. package/skills/llm-wiki-skill/packages/graph-engine/test/keyboard.test.ts +59 -0
  263. package/skills/llm-wiki-skill/packages/graph-engine/test/large-fixtures.test.ts +47 -0
  264. package/skills/llm-wiki-skill/packages/graph-engine/test/large-graph-fixtures.ts +420 -0
  265. package/skills/llm-wiki-skill/packages/graph-engine/test/learning.test.ts +259 -0
  266. package/skills/llm-wiki-skill/packages/graph-engine/test/node-drag-lifecycle.test.ts +166 -0
  267. package/skills/llm-wiki-skill/packages/graph-engine/test/overlays.test.ts +115 -0
  268. package/skills/llm-wiki-skill/packages/graph-engine/test/preview.test.ts +56 -0
  269. package/skills/llm-wiki-skill/packages/graph-engine/test/queue.test.ts +114 -0
  270. package/skills/llm-wiki-skill/packages/graph-engine/test/relation-focus.test.ts +115 -0
  271. package/skills/llm-wiki-skill/packages/graph-engine/test/render-model.test.ts +1030 -0
  272. package/skills/llm-wiki-skill/packages/graph-engine/test/renderer-adapter-contract.test.ts +271 -0
  273. package/skills/llm-wiki-skill/packages/graph-engine/test/renderer-boundary.test.ts +618 -0
  274. package/skills/llm-wiki-skill/packages/graph-engine/test/renderer-lifecycle.test.ts +1711 -0
  275. package/skills/llm-wiki-skill/packages/graph-engine/test/route-continuity.test.ts +284 -0
  276. package/skills/llm-wiki-skill/packages/graph-engine/test/runtime-state.test.ts +281 -0
  277. package/skills/llm-wiki-skill/packages/graph-engine/test/search-and-legend.test.ts +124 -0
  278. package/skills/llm-wiki-skill/packages/graph-engine/test/select.test.ts +168 -0
  279. package/skills/llm-wiki-skill/packages/graph-engine/test/sigma-coordinates.test.ts +50 -0
  280. package/skills/llm-wiki-skill/packages/graph-engine/test/sigma-global-renderer.test.ts +2210 -0
  281. package/skills/llm-wiki-skill/packages/graph-engine/test/sigma-trial-adapter.test.ts +82 -0
  282. package/skills/llm-wiki-skill/packages/graph-engine/test/sigma-trial-adapter.ts +271 -0
  283. package/skills/llm-wiki-skill/packages/graph-engine/test/sim.test.ts +207 -0
  284. package/skills/llm-wiki-skill/packages/graph-engine/test/simulation-bridge.test.ts +96 -0
  285. package/skills/llm-wiki-skill/packages/graph-engine/test/spatial-index.test.ts +222 -0
  286. package/skills/llm-wiki-skill/packages/graph-engine/test/state.test.ts +189 -0
  287. package/skills/llm-wiki-skill/packages/graph-engine/test/summary-contract.test.ts +422 -0
  288. package/skills/llm-wiki-skill/packages/graph-engine/test/themes.test.ts +62 -0
  289. package/skills/llm-wiki-skill/packages/graph-engine/test/toolbar.test.ts +64 -0
  290. package/skills/llm-wiki-skill/packages/graph-engine/test/viewport.test.ts +213 -0
  291. package/skills/llm-wiki-skill/packages/graph-engine/test/vis-network-trial-adapter.test.ts +82 -0
  292. package/skills/llm-wiki-skill/packages/graph-engine/test/vis-network-trial-adapter.ts +186 -0
  293. package/skills/llm-wiki-skill/packages/graph-engine/tsconfig.json +17 -0
  294. package/skills/llm-wiki-skill/packages/graph-engine/vite.config.ts +15 -0
  295. package/skills/llm-wiki-skill/platforms/claude/CLAUDE.md +37 -0
  296. package/skills/llm-wiki-skill/platforms/claude/companions/llm-wiki-upgrade/SKILL.md +95 -0
  297. package/skills/llm-wiki-skill/platforms/codex/AGENTS.md +23 -0
  298. package/skills/llm-wiki-skill/platforms/hermes/README.md +31 -0
  299. package/skills/llm-wiki-skill/platforms/openclaw/README.md +31 -0
  300. package/skills/llm-wiki-skill/scripts/adapter-state.sh +424 -0
  301. package/skills/llm-wiki-skill/scripts/build-graph-data.sh +395 -0
  302. package/skills/llm-wiki-skill/scripts/build-graph-html.sh +459 -0
  303. package/skills/llm-wiki-skill/scripts/cache.sh +352 -0
  304. package/skills/llm-wiki-skill/scripts/create-source-page.sh +100 -0
  305. package/skills/llm-wiki-skill/scripts/delete-helper.sh +68 -0
  306. package/skills/llm-wiki-skill/scripts/graph-analysis.js +732 -0
  307. package/skills/llm-wiki-skill/scripts/hook-session-start.sh +46 -0
  308. package/skills/llm-wiki-skill/scripts/init-wiki.sh +95 -0
  309. package/skills/llm-wiki-skill/scripts/lib/source-signal-eligibility.js +158 -0
  310. package/skills/llm-wiki-skill/scripts/lint-fix.sh +114 -0
  311. package/skills/llm-wiki-skill/scripts/lint-runner.sh +217 -0
  312. package/skills/llm-wiki-skill/scripts/runtime-context.sh +77 -0
  313. package/skills/llm-wiki-skill/scripts/shared-config.sh +83 -0
  314. package/skills/llm-wiki-skill/scripts/source-record-contract.tsv +10 -0
  315. package/skills/llm-wiki-skill/scripts/source-registry.sh +349 -0
  316. package/skills/llm-wiki-skill/scripts/source-registry.tsv +10 -0
  317. package/skills/llm-wiki-skill/scripts/source-signal-coverage.js +83 -0
  318. package/skills/llm-wiki-skill/scripts/validate-step1.sh +144 -0
  319. package/skills/llm-wiki-skill/scripts/wiki-compat.sh +267 -0
  320. package/skills/llm-wiki-skill/setup.sh +8 -0
  321. package/skills/llm-wiki-skill/templates/entity-template.md +30 -0
  322. package/skills/llm-wiki-skill/templates/graph-styles/wash/footer.html +27 -0
  323. package/skills/llm-wiki-skill/templates/graph-styles/wash/graph-wash-helpers.js +1326 -0
  324. package/skills/llm-wiki-skill/templates/graph-styles/wash/graph-wash.js +1009 -0
  325. package/skills/llm-wiki-skill/templates/graph-styles/wash/header.html +2002 -0
  326. package/skills/llm-wiki-skill/templates/index-en-template.md +51 -0
  327. package/skills/llm-wiki-skill/templates/index-template.md +51 -0
  328. package/skills/llm-wiki-skill/templates/log-en-template.md +11 -0
  329. package/skills/llm-wiki-skill/templates/log-template.md +11 -0
  330. package/skills/llm-wiki-skill/templates/overview-en-template.md +41 -0
  331. package/skills/llm-wiki-skill/templates/overview-template.md +41 -0
  332. package/skills/llm-wiki-skill/templates/purpose-en-template.md +16 -0
  333. package/skills/llm-wiki-skill/templates/purpose-template.md +16 -0
  334. package/skills/llm-wiki-skill/templates/query-template.md +19 -0
  335. package/skills/llm-wiki-skill/templates/schema-template.md +185 -0
  336. package/skills/llm-wiki-skill/templates/source-template.md +51 -0
  337. package/skills/llm-wiki-skill/templates/synthesis-template.md +25 -0
  338. package/skills/llm-wiki-skill/templates/topic-template.md +35 -0
  339. package/skills/llm-wiki-skill/tests/adapter-state.sh +338 -0
  340. package/skills/llm-wiki-skill/tests/browser/graph-aggregation-fallback-trial.ts +737 -0
  341. package/skills/llm-wiki-skill/tests/browser/graph-community-node-map.mjs +255 -0
  342. package/skills/llm-wiki-skill/tests/browser/graph-community-wash-interactions.mjs +170 -0
  343. package/skills/llm-wiki-skill/tests/browser/graph-default-behavior.mjs +630 -0
  344. package/skills/llm-wiki-skill/tests/browser/graph-density-preview.mjs +53 -0
  345. package/skills/llm-wiki-skill/tests/browser/graph-html-insights.mjs +41 -0
  346. package/skills/llm-wiki-skill/tests/browser/graph-large-performance.ts +689 -0
  347. package/skills/llm-wiki-skill/tests/browser/graph-node-slim.mjs +75 -0
  348. package/skills/llm-wiki-skill/tests/browser/graph-offline-phase-6.mjs +660 -0
  349. package/skills/llm-wiki-skill/tests/browser/graph-renderer-trial-shared.ts +291 -0
  350. package/skills/llm-wiki-skill/tests/browser/graph-sigma-global-production.ts +1437 -0
  351. package/skills/llm-wiki-skill/tests/browser/graph-sigma-graphology-trial.ts +949 -0
  352. package/skills/llm-wiki-skill/tests/browser/graph-stage-4-5.mjs +815 -0
  353. package/skills/llm-wiki-skill/tests/browser/graph-vis-network-trial.ts +762 -0
  354. package/skills/llm-wiki-skill/tests/browser/graph-workbench-interactions.mjs +730 -0
  355. package/skills/llm-wiki-skill/tests/browser/validate-graph-trial-result.mjs +149 -0
  356. package/skills/llm-wiki-skill/tests/expected/graph-data-empty.json +60 -0
  357. package/skills/llm-wiki-skill/tests/expected/graph-data-sample.json +396 -0
  358. package/skills/llm-wiki-skill/tests/expected/graph-interactive-basic.html +1736 -0
  359. package/skills/llm-wiki-skill/tests/expected/lint-output.txt +44 -0
  360. package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/index.md +1 -0
  361. package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/entities/Alpha.md +10 -0
  362. package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/entities/Beta.md +7 -0
  363. package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/entities/Delta.md +8 -0
  364. package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/entities/Gamma.md +8 -0
  365. package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/queries/20260422-abc.md +10 -0
  366. package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/synthesis/Crystal.md +8 -0
  367. package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/topics/Overview.md +9 -0
  368. package/skills/llm-wiki-skill/tests/fixtures/graph-data-empty-wiki/wiki/entities/.gitkeep +0 -0
  369. package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/purpose.md +3 -0
  370. package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/entities/Attention.md +7 -0
  371. package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/entities/Decoder.md +7 -0
  372. package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/entities/Encoder.md +7 -0
  373. package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/entities/GPT.md +7 -0
  374. package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/entities/Transformer.md +13 -0
  375. package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/sources/paper.md +9 -0
  376. package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/topics/arch.md +12 -0
  377. package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/topics/finetune.md +9 -0
  378. package/skills/llm-wiki-skill/tests/fixtures/graph-interactive-basic/wiki/graph-data.json +40 -0
  379. package/skills/llm-wiki-skill/tests/fixtures/graph-interactive-dense/wiki/graph-data.json +3965 -0
  380. package/skills/llm-wiki-skill/tests/fixtures/graph-interactive-multicomm/wiki/graph-data.json +212 -0
  381. package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/index.md +14 -0
  382. package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/entities/C++.md +6 -0
  383. package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/entities/Lonely.md +4 -0
  384. package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/entities/Other.md +8 -0
  385. package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/entities/Real.md +7 -0
  386. package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/sources/2026-01-01-test-source.md +15 -0
  387. package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/sources/2026-02-01-inline-img.md +12 -0
  388. package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/topics/AIbasic.md +3 -0
  389. package/skills/llm-wiki-skill/tests/graph-aggregation-fallback-trial.regression-1.sh +46 -0
  390. package/skills/llm-wiki-skill/tests/graph-analysis-helper.regression-1.sh +237 -0
  391. package/skills/llm-wiki-skill/tests/graph-browser-large-performance.regression-1.sh +39 -0
  392. package/skills/llm-wiki-skill/tests/graph-browser-stage-4-5.regression-1.sh +163 -0
  393. package/skills/llm-wiki-skill/tests/graph-build-failures.regression-1.sh +91 -0
  394. package/skills/llm-wiki-skill/tests/graph-community-node-map.regression-1.sh +107 -0
  395. package/skills/llm-wiki-skill/tests/graph-community-wash-interactions.regression-1.sh +35 -0
  396. package/skills/llm-wiki-skill/tests/graph-data-confidence-merge.regression-1.sh +309 -0
  397. package/skills/llm-wiki-skill/tests/graph-data-source-paths.regression-1.sh +49 -0
  398. package/skills/llm-wiki-skill/tests/graph-default-behavior.regression-1.sh +35 -0
  399. package/skills/llm-wiki-skill/tests/graph-html-a11y.regression-1.sh +50 -0
  400. package/skills/llm-wiki-skill/tests/graph-html-brand-link.regression-1.sh +47 -0
  401. package/skills/llm-wiki-skill/tests/graph-html-density.regression-1.sh +228 -0
  402. package/skills/llm-wiki-skill/tests/graph-html-drawer-neighbors.regression-1.sh +47 -0
  403. package/skills/llm-wiki-skill/tests/graph-html-insights.regression-1.sh +80 -0
  404. package/skills/llm-wiki-skill/tests/graph-html-long-label.regression-1.sh +92 -0
  405. package/skills/llm-wiki-skill/tests/graph-html-minimap.regression-1.sh +51 -0
  406. package/skills/llm-wiki-skill/tests/graph-html-mobile.regression-1.sh +48 -0
  407. package/skills/llm-wiki-skill/tests/graph-html-oriental-atlas-contract.regression-1.sh +94 -0
  408. package/skills/llm-wiki-skill/tests/graph-html-oriental-design-contract.regression-1.sh +82 -0
  409. package/skills/llm-wiki-skill/tests/graph-html-search.regression-1.sh +52 -0
  410. package/skills/llm-wiki-skill/tests/graph-html-styles.regression-1.sh +66 -0
  411. package/skills/llm-wiki-skill/tests/graph-html-toolbar.regression-1.sh +62 -0
  412. package/skills/llm-wiki-skill/tests/graph-offline-phase-6.regression-1.sh +51 -0
  413. package/skills/llm-wiki-skill/tests/graph-sigma-global-production.regression-1.sh +64 -0
  414. package/skills/llm-wiki-skill/tests/graph-sigma-graphology-trial.regression-1.sh +46 -0
  415. package/skills/llm-wiki-skill/tests/graph-vis-network-trial.regression-1.sh +46 -0
  416. package/skills/llm-wiki-skill/tests/graph-workbench-interactions.regression-1.sh +151 -0
  417. package/skills/llm-wiki-skill/tests/js/graph-wash-bootstrap.test.js +110 -0
  418. package/skills/llm-wiki-skill/tests/js/graph-wash-helpers.test.js +296 -0
  419. package/skills/llm-wiki-skill/tests/js/graph-wash-learning.test.js +260 -0
  420. package/skills/llm-wiki-skill/tests/js/graph-wash-queue.test.js +115 -0
  421. package/skills/llm-wiki-skill/tests/js/graph-wash-runtime-state.test.js +282 -0
  422. package/skills/llm-wiki-skill/tests/js/source-signal-coverage.test.js +48 -0
  423. package/skills/llm-wiki-skill/tests/js/source-signal-eligibility.test.js +202 -0
  424. package/skills/llm-wiki-skill/tests/lib/graph-html-engine-helpers.sh +110 -0
  425. package/skills/llm-wiki-skill/tests/lint-output.regression-1.sh +32 -0
  426. package/skills/llm-wiki-skill/tests/regression.sh +1754 -0
  427. package/skills/llm-wiki-skill/workbench/AGENTS.md +110 -0
  428. package/skills/llm-wiki-skill/workbench/CLAUDE.md +55 -0
  429. package/skills/llm-wiki-skill/workbench/LICENSE +21 -0
  430. package/skills/llm-wiki-skill/workbench/PRODUCT.md +1353 -0
  431. package/skills/llm-wiki-skill/workbench/README.md +30 -0
  432. package/skills/llm-wiki-skill/workbench/docs/current-kb-retrieval-design.md +587 -0
  433. package/skills/llm-wiki-skill/workbench/docs/graph-evolution-1-design.md +210 -0
  434. package/skills/llm-wiki-skill/workbench/docs/stage-2-design.md +1139 -0
  435. package/skills/llm-wiki-skill/workbench/docs/stage-3-design.md +1269 -0
  436. package/skills/llm-wiki-skill/workbench/docs/stage-3.5-design.md +1164 -0
  437. package/skills/llm-wiki-skill/workbench/docs/stage-4-design.md +504 -0
  438. package/skills/llm-wiki-skill/workbench/docs/stage-4.5-design.md +195 -0
  439. package/skills/llm-wiki-skill/workbench/docs/superpowers/specs/2026-05-28-resizable-preview-layout-design.md +165 -0
  440. package/skills/llm-wiki-skill/workbench/docs/superpowers/specs/2026-05-28-settings-panel-scroll-fix.md +50 -0
  441. package/skills/llm-wiki-skill/workbench/server/package.json +31 -0
  442. package/skills/llm-wiki-skill/workbench/server/src/agent.ts +457 -0
  443. package/skills/llm-wiki-skill/workbench/server/src/artifacts.ts +248 -0
  444. package/skills/llm-wiki-skill/workbench/server/src/auth.ts +164 -0
  445. package/skills/llm-wiki-skill/workbench/server/src/config.ts +130 -0
  446. package/skills/llm-wiki-skill/workbench/server/src/conversations.test.ts +159 -0
  447. package/skills/llm-wiki-skill/workbench/server/src/conversations.ts +270 -0
  448. package/skills/llm-wiki-skill/workbench/server/src/digest/batch.ts +189 -0
  449. package/skills/llm-wiki-skill/workbench/server/src/digest/concurrency.test.ts +36 -0
  450. package/skills/llm-wiki-skill/workbench/server/src/digest/concurrency.ts +31 -0
  451. package/skills/llm-wiki-skill/workbench/server/src/digest/subagent.ts +91 -0
  452. package/skills/llm-wiki-skill/workbench/server/src/extensions/artifacts.ts +81 -0
  453. package/skills/llm-wiki-skill/workbench/server/src/extensions/knowledge-base.ts +263 -0
  454. package/skills/llm-wiki-skill/workbench/server/src/extensions/new-wiki.ts +42 -0
  455. package/skills/llm-wiki-skill/workbench/server/src/extensions/synthesis.ts +172 -0
  456. package/skills/llm-wiki-skill/workbench/server/src/graph-watcher.test.ts +196 -0
  457. package/skills/llm-wiki-skill/workbench/server/src/graph.test.ts +113 -0
  458. package/skills/llm-wiki-skill/workbench/server/src/graph.ts +351 -0
  459. package/skills/llm-wiki-skill/workbench/server/src/index.ts +1148 -0
  460. package/skills/llm-wiki-skill/workbench/server/src/knowledge-bases.test.ts +30 -0
  461. package/skills/llm-wiki-skill/workbench/server/src/knowledge-bases.ts +321 -0
  462. package/skills/llm-wiki-skill/workbench/server/src/pages.test.ts +41 -0
  463. package/skills/llm-wiki-skill/workbench/server/src/pages.ts +160 -0
  464. package/skills/llm-wiki-skill/workbench/server/src/retrieval.test.ts +151 -0
  465. package/skills/llm-wiki-skill/workbench/server/src/retrieval.ts +427 -0
  466. package/skills/llm-wiki-skill/workbench/server/src/tool-status-events.test.ts +363 -0
  467. package/skills/llm-wiki-skill/workbench/server/src/tool-status-events.ts +616 -0
  468. package/skills/llm-wiki-skill/workbench/server/src/wiki-init.test.ts +19 -0
  469. package/skills/llm-wiki-skill/workbench/server/src/wiki-init.ts +188 -0
  470. package/skills/llm-wiki-skill/workbench/server/tsconfig.json +10 -0
  471. package/skills/llm-wiki-skill/workbench/tsconfig.json +20 -0
  472. package/skills/llm-wiki-skill/workbench/web/README.md +73 -0
  473. package/skills/llm-wiki-skill/workbench/web/components.json +21 -0
  474. package/skills/llm-wiki-skill/workbench/web/eslint.config.js +22 -0
  475. package/skills/llm-wiki-skill/workbench/web/index.html +16 -0
  476. package/skills/llm-wiki-skill/workbench/web/package.json +54 -0
  477. package/skills/llm-wiki-skill/workbench/web/src/App.tsx +1195 -0
  478. package/skills/llm-wiki-skill/workbench/web/src/components/AddExternalDialog.tsx +375 -0
  479. package/skills/llm-wiki-skill/workbench/web/src/components/AppearancePanel.tsx +158 -0
  480. package/skills/llm-wiki-skill/workbench/web/src/components/ArtifactView.tsx +15 -0
  481. package/skills/llm-wiki-skill/workbench/web/src/components/BatchDigestPanel.tsx +117 -0
  482. package/skills/llm-wiki-skill/workbench/web/src/components/ChatPanel.tsx +890 -0
  483. package/skills/llm-wiki-skill/workbench/web/src/components/CommandMenu.tsx +75 -0
  484. package/skills/llm-wiki-skill/workbench/web/src/components/ExportButtons.tsx +58 -0
  485. package/skills/llm-wiki-skill/workbench/web/src/components/GraphPanel.tsx +800 -0
  486. package/skills/llm-wiki-skill/workbench/web/src/components/GraphReader.tsx +52 -0
  487. package/skills/llm-wiki-skill/workbench/web/src/components/GraphSelection.tsx +100 -0
  488. package/skills/llm-wiki-skill/workbench/web/src/components/GraphSummaryDrawer.tsx +269 -0
  489. package/skills/llm-wiki-skill/workbench/web/src/components/MainViewTabs.tsx +69 -0
  490. package/skills/llm-wiki-skill/workbench/web/src/components/MarkdownView.tsx +106 -0
  491. package/skills/llm-wiki-skill/workbench/web/src/components/NewWikiDialog.tsx +103 -0
  492. package/skills/llm-wiki-skill/workbench/web/src/components/RefMenu.tsx +44 -0
  493. package/skills/llm-wiki-skill/workbench/web/src/components/RightDrawer.tsx +298 -0
  494. package/skills/llm-wiki-skill/workbench/web/src/components/SearchPanel.tsx +165 -0
  495. package/skills/llm-wiki-skill/workbench/web/src/components/SettingsPanel.tsx +320 -0
  496. package/skills/llm-wiki-skill/workbench/web/src/components/Sidebar.tsx +354 -0
  497. package/skills/llm-wiki-skill/workbench/web/src/components/ToolHistorySummary.tsx +111 -0
  498. package/skills/llm-wiki-skill/workbench/web/src/components/ToolStatusRunway.tsx +70 -0
  499. package/skills/llm-wiki-skill/workbench/web/src/components/TopBar.tsx +348 -0
  500. package/skills/llm-wiki-skill/workbench/web/src/components/renderers/DownloadOnlyRenderer.tsx +88 -0
  501. package/skills/llm-wiki-skill/workbench/web/src/components/renderers/HtmlRenderer.tsx +92 -0
  502. package/skills/llm-wiki-skill/workbench/web/src/components/ui/button.tsx +52 -0
  503. package/skills/llm-wiki-skill/workbench/web/src/components/ui/command.tsx +50 -0
  504. package/skills/llm-wiki-skill/workbench/web/src/components/ui/dialog.tsx +156 -0
  505. package/skills/llm-wiki-skill/workbench/web/src/components/ui/input.tsx +21 -0
  506. package/skills/llm-wiki-skill/workbench/web/src/components/ui/tooltip.tsx +57 -0
  507. package/skills/llm-wiki-skill/workbench/web/src/index.css +4204 -0
  508. package/skills/llm-wiki-skill/workbench/web/src/lib/api.ts +648 -0
  509. package/skills/llm-wiki-skill/workbench/web/src/lib/appearance.ts +114 -0
  510. package/skills/llm-wiki-skill/workbench/web/src/lib/drawer-layout.ts +41 -0
  511. package/skills/llm-wiki-skill/workbench/web/src/lib/drawer-state.ts +168 -0
  512. package/skills/llm-wiki-skill/workbench/web/src/lib/graph-reader.ts +25 -0
  513. package/skills/llm-wiki-skill/workbench/web/src/lib/graph-selection-drawer.ts +35 -0
  514. package/skills/llm-wiki-skill/workbench/web/src/lib/graph-selection.ts +96 -0
  515. package/skills/llm-wiki-skill/workbench/web/src/lib/graph-summary-actions.ts +184 -0
  516. package/skills/llm-wiki-skill/workbench/web/src/lib/legacy-tool-status.ts +113 -0
  517. package/skills/llm-wiki-skill/workbench/web/src/lib/model-roles.ts +20 -0
  518. package/skills/llm-wiki-skill/workbench/web/src/lib/search-filter.ts +104 -0
  519. package/skills/llm-wiki-skill/workbench/web/src/lib/sse.ts +72 -0
  520. package/skills/llm-wiki-skill/workbench/web/src/lib/tool-status-format.ts +170 -0
  521. package/skills/llm-wiki-skill/workbench/web/src/lib/tool-status-model.ts +392 -0
  522. package/skills/llm-wiki-skill/workbench/web/src/lib/utils.ts +10 -0
  523. package/skills/llm-wiki-skill/workbench/web/src/lib/view-status.ts +16 -0
  524. package/skills/llm-wiki-skill/workbench/web/src/lib/wiki-links.ts +32 -0
  525. package/skills/llm-wiki-skill/workbench/web/src/main.tsx +10 -0
  526. package/skills/llm-wiki-skill/workbench/web/test/api.test.ts +61 -0
  527. package/skills/llm-wiki-skill/workbench/web/test/app-shell-drawer-layout.test.tsx +48 -0
  528. package/skills/llm-wiki-skill/workbench/web/test/appearance-panel.test.tsx +121 -0
  529. package/skills/llm-wiki-skill/workbench/web/test/appearance.test.ts +262 -0
  530. package/skills/llm-wiki-skill/workbench/web/test/chat-host-source.test.tsx +22 -0
  531. package/skills/llm-wiki-skill/workbench/web/test/chat-panel-auto-scroll.test.tsx +311 -0
  532. package/skills/llm-wiki-skill/workbench/web/test/chat-panel-bubbles.test.tsx +48 -0
  533. package/skills/llm-wiki-skill/workbench/web/test/chat-panel-composer.test.tsx +86 -0
  534. package/skills/llm-wiki-skill/workbench/web/test/chat-panel-tool-status.test.tsx +26 -0
  535. package/skills/llm-wiki-skill/workbench/web/test/export-batch-paper.test.tsx +101 -0
  536. package/skills/llm-wiki-skill/workbench/web/test/graph-drawer-state.test.ts +257 -0
  537. package/skills/llm-wiki-skill/workbench/web/test/graph-panel-paper.test.tsx +200 -0
  538. package/skills/llm-wiki-skill/workbench/web/test/graph-reader-request.test.ts +32 -0
  539. package/skills/llm-wiki-skill/workbench/web/test/graph-reader.test.ts +62 -0
  540. package/skills/llm-wiki-skill/workbench/web/test/graph-selection-drawer.test.ts +56 -0
  541. package/skills/llm-wiki-skill/workbench/web/test/graph-selection.test.ts +83 -0
  542. package/skills/llm-wiki-skill/workbench/web/test/graph-summary-actions.test.ts +188 -0
  543. package/skills/llm-wiki-skill/workbench/web/test/main-view-tabs.test.tsx +34 -0
  544. package/skills/llm-wiki-skill/workbench/web/test/markdown-view.test.tsx +34 -0
  545. package/skills/llm-wiki-skill/workbench/web/test/popup-menus.test.tsx +85 -0
  546. package/skills/llm-wiki-skill/workbench/web/test/render.test.tsx +30 -0
  547. package/skills/llm-wiki-skill/workbench/web/test/render.tsx +38 -0
  548. package/skills/llm-wiki-skill/workbench/web/test/right-drawer-graph-summary.test.tsx +287 -0
  549. package/skills/llm-wiki-skill/workbench/web/test/right-drawer-interactions.test.tsx +182 -0
  550. package/skills/llm-wiki-skill/workbench/web/test/search-filter.test.ts +65 -0
  551. package/skills/llm-wiki-skill/workbench/web/test/search-panel.test.tsx +155 -0
  552. package/skills/llm-wiki-skill/workbench/web/test/setup-dom.ts +66 -0
  553. package/skills/llm-wiki-skill/workbench/web/test/sidebar-v2-source.test.ts +17 -0
  554. package/skills/llm-wiki-skill/workbench/web/test/sidebar.test.tsx +110 -0
  555. package/skills/llm-wiki-skill/workbench/web/test/tool-history-summary.test.tsx +150 -0
  556. package/skills/llm-wiki-skill/workbench/web/test/tool-status-format.test.ts +107 -0
  557. package/skills/llm-wiki-skill/workbench/web/test/tool-status-model.test.ts +324 -0
  558. package/skills/llm-wiki-skill/workbench/web/test/tool-status-runway.test.ts +159 -0
  559. package/skills/llm-wiki-skill/workbench/web/test/topbar.test.tsx +248 -0
  560. package/skills/llm-wiki-skill/workbench/web/test/visual/paper-ui.ts +898 -0
  561. package/skills/llm-wiki-skill/workbench/web/test/wiki-links.test.ts +23 -0
  562. package/skills/llm-wiki-skill/workbench/web/test-results/paper-ui/actual/.gitkeep +1 -0
  563. package/skills/llm-wiki-skill/workbench/web/test-results/paper-ui/baseline/.gitkeep +1 -0
  564. package/skills/llm-wiki-skill/workbench/web/tsconfig.app.json +30 -0
  565. package/skills/llm-wiki-skill/workbench/web/tsconfig.json +7 -0
  566. package/skills/llm-wiki-skill/workbench/web/tsconfig.node.json +24 -0
  567. package/skills/llm-wiki-skill/workbench/web/vite.config.ts +28 -0
@@ -0,0 +1,2210 @@
1
+ import { describe, it } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { readFile } from "node:fs/promises";
4
+ import GraphologyGraph from "graphology";
5
+
6
+ import {
7
+ SIGMA_GLOBAL_RENDERER_BUNDLE_BOUNDARY,
8
+ SIGMA_GLOBAL_RENDERER_ROUTE_MANAGER_OWNER,
9
+ buildSigmaGlobalGraphologyGraph,
10
+ createSigmaGlobalHitProjector,
11
+ createSigmaGlobalRenderer,
12
+ sigmaGlobalEdgeStyle,
13
+ type SigmaGlobalGraphologyGraph,
14
+ type SigmaGlobalRendererRuntime,
15
+ type SigmaGlobalSigmaLike
16
+ } from "../src/render/sigma-global-renderer";
17
+ import type {
18
+ GraphRendererAdapterData
19
+ } from "../src";
20
+ import { buildGraphRendererAdapterData } from "../src";
21
+ import type { GraphData } from "../src/types";
22
+
23
+ describe("Sigma global renderer production boundary", () => {
24
+ it("records route ownership and graph-engine bundle boundary", () => {
25
+ assert.equal(SIGMA_GLOBAL_RENDERER_ROUTE_MANAGER_OWNER, "facade");
26
+ assert.deepEqual(SIGMA_GLOBAL_RENDERER_BUNDLE_BOUNDARY, {
27
+ sigma: "runtime-loaded-by-sigma-global-renderer",
28
+ graphology: "runtime-loaded-by-sigma-global-renderer",
29
+ workbench: "loads through the graph-engine ESM Sigma runtime boundary when global route manager selects Sigma",
30
+ offlineHtml: "loads through the graph-engine IIFE Sigma runtime boundary when offline global route manager selects Sigma"
31
+ });
32
+ });
33
+
34
+ it("keeps Sigma and Graphology in runtime dependencies", async () => {
35
+ const manifest = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"));
36
+ assert.equal(manifest.dependencies.sigma, "^3.0.3");
37
+ assert.equal(manifest.dependencies.graphology, "^0.26.0");
38
+ assert.equal(manifest.devDependencies.sigma, undefined);
39
+ assert.equal(manifest.devDependencies.graphology, undefined);
40
+ });
41
+
42
+ it("requires the lazy Sigma runtime boundary before creating the lifecycle", () => {
43
+ assert.throws(
44
+ () => createSigmaGlobalRenderer({} as never),
45
+ /container|runtime/
46
+ );
47
+ });
48
+
49
+ it("builds a Graphology render graph entirely from adapter output", () => {
50
+ const adapterData = adapterDataFixture();
51
+ const graph = buildSigmaGlobalGraphologyGraph(adapterData, { GraphologyGraph });
52
+
53
+ assert.equal(graph.order, 2);
54
+ assert.equal(graph.size, 1);
55
+
56
+ assert.deepEqual(graph.getNodeAttributes("render-alpha"), {
57
+ x: 111,
58
+ y: 222,
59
+ label: "Adapter Alpha",
60
+ size: 10,
61
+ color: "#ef4444",
62
+ type: "circle",
63
+ graphNodeType: "topic",
64
+ communityId: "adapter-community",
65
+ sourcePath: "adapter/alpha.md",
66
+ selected: true,
67
+ searchHit: false,
68
+ pinned: false,
69
+ communityDimmed: false,
70
+ communitySpotlightVisible: true,
71
+ aggregationIds: ["adapter-aggregation"],
72
+ labelVisible: true,
73
+ displayMode: "card",
74
+ visualRole: "landmark",
75
+ priority: 900,
76
+ drawerTarget: {
77
+ summaryKind: "node-summary",
78
+ object: { kind: "node", nodeId: "render-alpha" }
79
+ }
80
+ });
81
+ assert.deepEqual(graph.getNodeAttributes("render-beta"), {
82
+ x: 333,
83
+ y: 444,
84
+ label: "",
85
+ size: 10,
86
+ color: "#f59e0b",
87
+ type: "circle",
88
+ graphNodeType: "source",
89
+ communityId: "adapter-community",
90
+ sourcePath: "adapter/beta.md",
91
+ selected: false,
92
+ searchHit: true,
93
+ pinned: true,
94
+ communityDimmed: false,
95
+ communitySpotlightVisible: true,
96
+ aggregationIds: ["adapter-aggregation"],
97
+ labelVisible: false,
98
+ displayMode: "point",
99
+ visualRole: "map-pin",
100
+ priority: 100,
101
+ drawerTarget: {
102
+ summaryKind: "node-summary",
103
+ object: { kind: "node", nodeId: "render-beta" }
104
+ }
105
+ });
106
+ assert.deepEqual(graph.getEdgeAttributes("adapter-edge"), {
107
+ size: 1.13,
108
+ color: "rgba(49, 95, 114, 0.145)",
109
+ relationType: "depends-on-adapter",
110
+ confidence: "ADAPTER_CONFIDENCE",
111
+ weight: 0.75,
112
+ sourceCommunityId: "adapter-community",
113
+ targetCommunityId: "adapter-community"
114
+ });
115
+ assert.equal(graph.source("adapter-edge"), "render-alpha");
116
+ assert.equal(graph.target("adapter-edge"), "render-beta");
117
+ assert.deepEqual(graph.getAttribute("communities"), [
118
+ {
119
+ id: "adapter-community",
120
+ label: "Adapter Community",
121
+ color: "#123456",
122
+ nodeIds: ["render-alpha", "render-beta"],
123
+ nodeCount: 2,
124
+ selected: true,
125
+ searchResultIds: ["render-beta"],
126
+ pinnedNodeIds: ["render-beta"],
127
+ aggregationIds: ["adapter-aggregation"],
128
+ drawerTarget: {
129
+ summaryKind: "community-summary",
130
+ object: { kind: "community", communityId: "adapter-community" }
131
+ },
132
+ commands: [{ kind: "enter-community", communityId: "adapter-community", label: "进入社区" }]
133
+ }
134
+ ]);
135
+ assert.deepEqual(graph.getAttribute("aggregations"), [
136
+ {
137
+ id: "adapter-aggregation",
138
+ label: "Adapter Aggregation",
139
+ communityId: "adapter-community",
140
+ nodeIds: ["render-alpha", "render-beta"],
141
+ selectedNodeIds: ["render-alpha"],
142
+ searchResultIds: ["render-beta"],
143
+ pinnedNodeIds: ["render-beta"],
144
+ totalCount: 17,
145
+ selected: true,
146
+ color: "#abcdef",
147
+ point: { x: 222, y: 333 },
148
+ radius: 44,
149
+ drawerTarget: {
150
+ summaryKind: "community-summary",
151
+ object: { kind: "community", communityId: "adapter-community" }
152
+ },
153
+ commands: [
154
+ {
155
+ kind: "show-this-object",
156
+ object: {
157
+ kind: "aggregation",
158
+ aggregationId: "adapter-aggregation",
159
+ nodeIds: ["render-alpha", "render-beta"],
160
+ communityId: "adapter-community"
161
+ },
162
+ label: "显示这个对象"
163
+ }
164
+ ]
165
+ }
166
+ ]);
167
+ assert.deepEqual(graph.getAttribute("counts"), adapterData.counts);
168
+ assert.deepEqual(graph.getAttribute("selection"), adapterData.selection);
169
+ });
170
+
171
+ it("passes selected communities into Sigma global focus edge styling", () => {
172
+ const adapterData = adapterDataFixture({ communityCount: 3, selectedCommunityIds: ["community-1"] });
173
+ const graph = buildSigmaGlobalGraphologyGraph(
174
+ adapterData,
175
+ { GraphologyGraph },
176
+ "shan-shui",
177
+ { semanticEmphasis: false, focusHighlight: true }
178
+ );
179
+
180
+ assert.deepEqual(graph.getEdgeAttributes("adapter-edge"), {
181
+ size: 0.62,
182
+ color: "rgba(49, 95, 114, 0.05)",
183
+ relationType: "depends-on-adapter",
184
+ confidence: "ADAPTER_CONFIDENCE",
185
+ weight: 0.75,
186
+ sourceCommunityId: "adapter-community",
187
+ targetCommunityId: "adapter-community"
188
+ });
189
+ });
190
+
191
+ it("dims ordinary nodes outside the selected community while keeping priority nodes visible", () => {
192
+ const adapterData = nodeSpotlightAdapterData();
193
+ const graph = buildSigmaGlobalGraphologyGraph(adapterData, { GraphologyGraph });
194
+
195
+ assert.equal(graph.getNodeAttribute("alpha-ordinary", "communityDimmed"), false);
196
+ assert.equal(graph.getNodeAttribute("beta-ordinary", "communityDimmed"), true);
197
+ assert.equal(graph.getNodeAttribute("beta-ordinary", "color"), "rgba(18, 52, 1, 0.2)");
198
+ assert.equal(graph.getNodeAttribute("beta-ordinary", "size"), 3.6);
199
+ assert.equal(graph.getNodeAttribute("beta-search", "communityDimmed"), false);
200
+ assert.equal(graph.getNodeAttribute("beta-search", "communitySpotlightVisible"), true);
201
+ assert.equal(graph.getNodeAttribute("beta-pinned", "communityDimmed"), false);
202
+ assert.equal(graph.getNodeAttribute("alpha-selected", "communityDimmed"), false);
203
+ });
204
+
205
+ it("does not dim nodes when there is no community selection spotlight", () => {
206
+ const adapterData = nodeSpotlightAdapterData({ selectionKind: "node" });
207
+ const graph = buildSigmaGlobalGraphologyGraph(adapterData, { GraphologyGraph });
208
+
209
+ assert.equal(graph.getNodeAttribute("beta-ordinary", "communityDimmed"), false);
210
+ assert.equal(graph.getNodeAttribute("beta-ordinary", "color"), "#123401");
211
+ assert.equal(graph.getNodeAttribute("beta-ordinary", "size"), 5);
212
+ });
213
+
214
+ it("styles Sigma global edges by relation and community scope without confidence opacity", () => {
215
+ const intraNeutral = sigmaGlobalEdgeStyle(sigmaEdgeFixture({
216
+ relationType: "依赖",
217
+ sourceCommunityId: "c1",
218
+ targetCommunityId: "c1",
219
+ confidence: "EXTRACTED",
220
+ weight: 0
221
+ }), "shan-shui");
222
+ const bridgeNeutral = sigmaGlobalEdgeStyle(sigmaEdgeFixture({
223
+ relationType: "依赖",
224
+ sourceCommunityId: "c1",
225
+ targetCommunityId: "c2",
226
+ confidence: "EXTRACTED",
227
+ weight: 0
228
+ }), "shan-shui");
229
+ const contrast = sigmaGlobalEdgeStyle(sigmaEdgeFixture({
230
+ relationType: "对比",
231
+ sourceCommunityId: "c1",
232
+ targetCommunityId: "c1",
233
+ confidence: "EXTRACTED",
234
+ weight: 0.5
235
+ }), "shan-shui");
236
+ const conflictDark = sigmaGlobalEdgeStyle(sigmaEdgeFixture({
237
+ relationType: "矛盾",
238
+ sourceCommunityId: "c1",
239
+ targetCommunityId: "c2",
240
+ confidence: "EXTRACTED",
241
+ weight: 1
242
+ }), "mo-ye");
243
+ const neutralDark = sigmaGlobalEdgeStyle(sigmaEdgeFixture({
244
+ relationType: "依赖",
245
+ sourceCommunityId: "c1",
246
+ targetCommunityId: "c1",
247
+ confidence: "EXTRACTED",
248
+ weight: 0
249
+ }), "mo-ye");
250
+
251
+ assert.deepEqual(intraNeutral, { color: "rgba(49, 95, 114, 0.1)", size: 0.72 });
252
+ assert.deepEqual(bridgeNeutral, { color: "rgba(49, 95, 114, 0.34)", size: 1.1 });
253
+ assert.deepEqual(contrast, { color: "rgba(183, 121, 31, 0.54)", size: 1.55 });
254
+ assert.deepEqual(conflictDark, { color: "rgba(244, 114, 182, 0.66)", size: 2.25 });
255
+ assert.deepEqual(neutralDark, { color: "rgba(142, 135, 120, 0.1)", size: 0.72 });
256
+ });
257
+
258
+ it("keeps global confidence out of Sigma edge styling", () => {
259
+ const extracted = sigmaGlobalEdgeStyle(sigmaEdgeFixture({
260
+ relationType: "依赖",
261
+ confidence: "EXTRACTED",
262
+ weight: 0.4
263
+ }), "shan-shui");
264
+ const inferred = sigmaGlobalEdgeStyle(sigmaEdgeFixture({
265
+ relationType: "依赖",
266
+ confidence: "INFERRED",
267
+ weight: 0.4
268
+ }), "shan-shui");
269
+
270
+ assert.deepEqual(inferred, extracted);
271
+ });
272
+
273
+ it("lets semantic emphasis thin neutral edges and lift semantic edges", () => {
274
+ const style = { semanticEmphasis: true, focusHighlight: false };
275
+ const neutralBase = sigmaGlobalEdgeStyle(sigmaEdgeFixture({ relationType: "依赖", weight: 0.5 }), "shan-shui");
276
+ const neutralEmphasis = sigmaGlobalEdgeStyle(sigmaEdgeFixture({ relationType: "依赖", weight: 0.5 }), "shan-shui", style);
277
+ const contrastBase = sigmaGlobalEdgeStyle(sigmaEdgeFixture({ relationType: "对比", weight: 0.5 }), "shan-shui");
278
+ const contrastEmphasis = sigmaGlobalEdgeStyle(sigmaEdgeFixture({ relationType: "对比", weight: 0.5 }), "shan-shui", style);
279
+
280
+ assert.ok(edgeStyleAlpha(neutralEmphasis.color) < edgeStyleAlpha(neutralBase.color));
281
+ assert.ok(neutralEmphasis.size < neutralBase.size);
282
+ assert.ok(edgeStyleAlpha(contrastEmphasis.color) > edgeStyleAlpha(contrastBase.color));
283
+ assert.ok(contrastEmphasis.size > contrastBase.size);
284
+ });
285
+
286
+ it("uses focus highlight only when selected communities exist", () => {
287
+ const style = { semanticEmphasis: false, focusHighlight: true };
288
+ const selectedCommunities = new Set(["c1"]);
289
+ const touchedEdge = sigmaEdgeFixture({
290
+ relationType: "依赖",
291
+ sourceCommunityId: "c1",
292
+ targetCommunityId: "c2",
293
+ weight: 0.4
294
+ });
295
+ const untouchedEdge = sigmaEdgeFixture({
296
+ relationType: "依赖",
297
+ sourceCommunityId: "c2",
298
+ targetCommunityId: "c3",
299
+ weight: 0.4
300
+ });
301
+
302
+ const touchedBase = sigmaGlobalEdgeStyle(touchedEdge, "shan-shui");
303
+ const touchedFocused = sigmaGlobalEdgeStyle(touchedEdge, "shan-shui", style, selectedCommunities);
304
+ const untouchedBase = sigmaGlobalEdgeStyle(untouchedEdge, "shan-shui");
305
+ const untouchedFocused = sigmaGlobalEdgeStyle(untouchedEdge, "shan-shui", style, selectedCommunities);
306
+ const noSelectionFocused = sigmaGlobalEdgeStyle(untouchedEdge, "shan-shui", style, new Set());
307
+
308
+ assert.ok(edgeStyleAlpha(touchedFocused.color) >= edgeStyleAlpha(touchedBase.color));
309
+ assert.ok(touchedFocused.size >= touchedBase.size);
310
+ assert.ok(edgeStyleAlpha(untouchedFocused.color) < edgeStyleAlpha(untouchedBase.color));
311
+ assert.ok(untouchedFocused.size < untouchedBase.size);
312
+ assert.deepEqual(noSelectionFocused, untouchedBase);
313
+ });
314
+
315
+ it("treats missing community ids as non-bridge edges without accidental focus lift", () => {
316
+ const style = { semanticEmphasis: false, focusHighlight: true };
317
+ const partialCommunityEdge = sigmaEdgeFixture({
318
+ sourceCommunityId: null,
319
+ targetCommunityId: "c2",
320
+ relationType: "依赖",
321
+ weight: 0
322
+ });
323
+ const missingCommunityEdge = sigmaEdgeFixture({
324
+ sourceCommunityId: null,
325
+ targetCommunityId: null,
326
+ relationType: "依赖",
327
+ weight: 0
328
+ });
329
+
330
+ assert.deepEqual(
331
+ sigmaGlobalEdgeStyle(partialCommunityEdge, "shan-shui"),
332
+ { color: "rgba(49, 95, 114, 0.1)", size: 0.72 }
333
+ );
334
+ assert.deepEqual(
335
+ sigmaGlobalEdgeStyle(missingCommunityEdge, "shan-shui", style, new Set(["c1"])),
336
+ { color: "rgba(49, 95, 114, 0.05)", size: 0.6 }
337
+ );
338
+ });
339
+
340
+ it("keeps the production Sigma boundary on GraphRendererAdapterData instead of raw GraphData", async () => {
341
+ const source = await readFile(new URL("../src/render/sigma-global-renderer.ts", import.meta.url), "utf8");
342
+ assert.match(source, /buildSigmaGlobalGraphologyGraph\(\s*adapterData: GraphRendererAdapterData/);
343
+ assert.doesNotMatch(source, /GraphData/);
344
+ assert.doesNotMatch(source, /buildGraphRendererAdapterData/);
345
+ assert.doesNotMatch(source, /\bdata\.nodes\b/);
346
+ assert.doesNotMatch(source, /\bdata\.edges\b/);
347
+ });
348
+
349
+ it("keeps Sigma community overlay styles passive instead of visible circular controls", async () => {
350
+ const styles = await readFile(new URL("../src/render/render-styles.ts", import.meta.url), "utf8");
351
+
352
+ assert.doesNotMatch(styles, /\.sigma-global-community-wash\b/);
353
+ assert.doesNotMatch(styles, /\.sigma-global-aggregation-container\b/);
354
+ assert.match(styles, /\.sigma-global-community-label\b/);
355
+ });
356
+
357
+ it("keeps mo-ye renderer backgrounds on the shared paper texture layers", async () => {
358
+ const styles = await readFile(new URL("../src/render/render-styles.ts", import.meta.url), "utf8");
359
+ const block = styles.match(/\.llm-wiki-graph-engine\[data-theme="mo-ye"\]\s*\{[\s\S]*?background:\s*([\s\S]*?);\n\}/)?.[1] ?? "";
360
+
361
+ assert.match(block, /var\(--paper-glow/);
362
+ assert.match(block, /var\(--paper-vignette/);
363
+ assert.match(block, /var\(--paper-mottle/);
364
+ });
365
+
366
+ it("hides confidence rows only inside the Sigma global route legend", async () => {
367
+ const styles = await readFile(new URL("../src/render/render-styles.ts", import.meta.url), "utf8");
368
+ const hiddenConfidenceSelectors = [...styles.matchAll(/^\s*([^{}\n]*\.graph-edge-legend-group:has\(\.graph-edge-legend-confidence\)[^{}\n]*)\s*\{[^}]*display:\s*none/gm)]
369
+ .map((match) => match[1].replace(/\s+/g, " ").trim());
370
+
371
+ assert.match(styles, /\.sigma-global-route\s+\.graph-edge-legend-group:has\(\.graph-edge-legend-confidence\)\s*\{[\s\S]*display:\s*none/);
372
+ assert.deepEqual(hiddenConfidenceSelectors, [
373
+ ".sigma-global-route .graph-edge-legend-group:has(.graph-edge-legend-confidence)"
374
+ ]);
375
+ });
376
+
377
+ it("projects Sigma node hits before overlapping community regions", () => {
378
+ const projector = createSigmaGlobalHitProjector({
379
+ adapterData: adapterDataFixture(),
380
+ viewport: { x: 0, y: 0, scale: 1 },
381
+ viewportSize: { width: 500, height: 500 }
382
+ });
383
+
384
+ assert.deepEqual(
385
+ projector.targetFromSigmaHit({ nodeId: "render-alpha", screenPoint: { x: 111, y: 222 } }),
386
+ { kind: "node", id: "render-alpha" }
387
+ );
388
+ });
389
+
390
+ it("uses the graph spatial path for Sigma community-region hits", () => {
391
+ const projector = createSigmaGlobalHitProjector({
392
+ adapterData: adapterDataFixture(),
393
+ viewport: { x: 0, y: 0, scale: 1 },
394
+ viewportSize: { width: 500, height: 500 }
395
+ });
396
+
397
+ assert.deepEqual(
398
+ projector.targetFromSigmaHit({ screenPoint: { x: 250, y: 250 } }),
399
+ { kind: "community-wash", id: "adapter-community" }
400
+ );
401
+ });
402
+
403
+ it("renders passive community map labels instead of circular community controls", () => {
404
+ const renderer = createSigmaGlobalRenderer({
405
+ container: fakeContainer(),
406
+ adapterData: adapterDataFixture({ communityCount: 10, selectedCommunityId: "community-9" }),
407
+ theme: "shan-shui",
408
+ runtime: fakeRuntime()
409
+ });
410
+
411
+ const communityControls = renderer.overlayRoot.children.filter((child) => child.className === "sigma-global-community-wash");
412
+ const communityRegions = renderer.overlayRoot.children.filter((child) => child.className === "sigma-global-community-region");
413
+ const labels = renderer.overlayRoot.children.filter((child) => child.className === "sigma-global-community-label");
414
+
415
+ assert.equal(communityControls.length, 0);
416
+ assert.equal(communityRegions.length, 10);
417
+ assert.equal(labels.length, 8);
418
+ assert.equal(labels[0]?.dataset.communityId, "community-9");
419
+ assert.deepEqual(labels.map((label) => label.dataset.communityId), [
420
+ "community-9",
421
+ "community-10",
422
+ "community-8",
423
+ "community-7",
424
+ "community-6",
425
+ "community-5",
426
+ "community-4",
427
+ "community-3"
428
+ ]);
429
+
430
+ for (const label of labels) {
431
+ assert.notEqual(label.tagName, "button");
432
+ assert.equal(label.getAttribute("role"), null);
433
+ assert.equal(label.getAttribute("aria-hidden"), "true");
434
+ assert.equal(label.tabIndex, -1);
435
+ assert.equal(label.style.pointerEvents, "none");
436
+ }
437
+ for (const region of communityRegions) {
438
+ assert.notEqual(region.tagName, "button");
439
+ assert.equal(region.getAttribute("aria-hidden"), "true");
440
+ assert.equal(region.tabIndex, -1);
441
+ assert.equal(region.style.pointerEvents, "none");
442
+ }
443
+
444
+ renderer.destroy();
445
+ });
446
+
447
+ it("keeps all selected Sigma communities active instead of dimming later selections", () => {
448
+ const renderer = createSigmaGlobalRenderer({
449
+ container: fakeContainer(),
450
+ adapterData: adapterDataFixture({ communityCount: 3, selectedCommunityIds: ["community-1", "community-2"] }),
451
+ theme: "shan-shui",
452
+ runtime: fakeRuntime()
453
+ });
454
+
455
+ const selectedOne = renderer.overlayRoot.children.find((child) => child.dataset.communityId === "community-1");
456
+ const selectedTwo = renderer.overlayRoot.children.find((child) => child.dataset.communityId === "community-2");
457
+ const unselected = renderer.overlayRoot.children.find((child) => child.dataset.communityId === "community-3");
458
+ const labels = renderer.overlayRoot.children.filter((child) => child.className === "sigma-global-community-label");
459
+ const labelOne = labels.find((child) => child.dataset.communityId === "community-1");
460
+ const labelTwo = labels.find((child) => child.dataset.communityId === "community-2");
461
+ const labelThree = labels.find((child) => child.dataset.communityId === "community-3");
462
+
463
+ assert.equal(selectedOne?.dataset.selected, "true");
464
+ assert.equal(selectedTwo?.dataset.selected, "true");
465
+ assert.equal(unselected?.dataset.selected, "false");
466
+ assert.equal(labelOne?.dataset.dim, "false");
467
+ assert.equal(labelTwo?.dataset.dim, "false");
468
+ assert.equal(labelThree?.dataset.dim, "true");
469
+
470
+ renderer.destroy();
471
+ });
472
+
473
+ it("keeps community spotlight overlays at community level without expanding every selected node", () => {
474
+ const renderer = createSigmaGlobalRenderer({
475
+ container: fakeContainer(),
476
+ adapterData: nodeSpotlightAdapterData({ selectedCommunityId: "community-1" }),
477
+ theme: "shan-shui",
478
+ runtime: fakeRuntime()
479
+ });
480
+
481
+ const nodeTargets = renderer.overlayRoot.children
482
+ .filter((child) => child.className === "sigma-global-node-hit-target")
483
+ .map((child) => child.dataset.nodeId);
484
+
485
+ assert.deepEqual(nodeTargets.sort(), ["beta-pinned", "beta-search"]);
486
+
487
+ renderer.destroy();
488
+ });
489
+
490
+ it("renders fallback ellipse clouds and routes SVG shape clicks to community selection", () => {
491
+ const hits: unknown[] = [];
492
+ const renderer = createSigmaGlobalRenderer({
493
+ container: fakeContainer(),
494
+ adapterData: adapterDataFixture(),
495
+ theme: "shan-shui",
496
+ runtime: fakeRuntime(),
497
+ onHitTarget: (target) => hits.push(target)
498
+ });
499
+
500
+ const shape = sigmaCommunityCloudShape(renderer, "adapter-community");
501
+
502
+ assert.equal(shape?.tagName, "ellipse");
503
+ assert.equal(shape?.getAttribute("fill"), "#123456");
504
+ assert.equal(shape?.getAttribute("fill-opacity"), "0.2");
505
+ assert.match(shape?.getAttribute("filter") ?? "", /^url\(#sigma-community-cloud-blur-/);
506
+
507
+ shape?.dispatchEvent(new Event("click"));
508
+
509
+ assert.deepEqual(hits.at(-1), { kind: "community-wash", id: "adapter-community" });
510
+
511
+ renderer.destroy();
512
+ });
513
+
514
+ it("renders polygon clouds from cached community hull points", () => {
515
+ const renderer = createSigmaGlobalRenderer({
516
+ container: fakeContainer(),
517
+ adapterData: adapterDataWithPolygonCommunityCloud(),
518
+ theme: "shan-shui",
519
+ runtime: fakeRuntime()
520
+ });
521
+
522
+ const shape = sigmaCommunityCloudShape(renderer, "adapter-community");
523
+ const points = shape?.getAttribute("points") ?? "";
524
+
525
+ assert.equal(shape?.tagName, "polygon");
526
+ assert.ok(points.split(" ").length >= 3, `polygon should expose hull points, got ${points}`);
527
+
528
+ renderer.destroy();
529
+ });
530
+
531
+ it("caps polygon clouds to the computed community wash bounds", () => {
532
+ const renderer = createSigmaGlobalRenderer({
533
+ container: fakeContainer(),
534
+ adapterData: adapterDataWithPolygonCommunityOutlier(),
535
+ theme: "shan-shui",
536
+ runtime: fakeRuntime()
537
+ });
538
+
539
+ const region = sigmaCommunityRegion(renderer, "adapter-community");
540
+ const shape = sigmaCommunityCloudShape(renderer, "adapter-community");
541
+
542
+ assert.equal(shape?.tagName, "polygon");
543
+ assert.ok(Number.parseFloat(region?.style.left ?? "0") >= 170);
544
+ assert.ok(Number.parseFloat(region?.style.top ?? "0") >= 190);
545
+ assert.ok(Number.parseFloat(region?.style.width ?? "0") <= 160);
546
+ assert.ok(Number.parseFloat(region?.style.height ?? "0") <= 120);
547
+
548
+ renderer.destroy();
549
+ });
550
+
551
+ it("refreshes community cloud geometry after a node drag commits", () => {
552
+ const runtime = fakeRuntime();
553
+ const renderer = createSigmaGlobalRenderer({
554
+ container: fakeContainer(),
555
+ adapterData: adapterDataWithPolygonCommunityCloud(),
556
+ theme: "shan-shui",
557
+ runtime,
558
+ pins: {},
559
+ onPinsChanged: () => undefined
560
+ });
561
+ const sigma = runtime.instances[0];
562
+ const initialRegion = sigmaCommunityRegion(renderer, "adapter-community");
563
+ const initialLeft = Number.parseFloat(initialRegion?.style.left ?? "0");
564
+
565
+ sigma.emit("downNode", sigmaEventPayload("render-alpha", 111, 222));
566
+ sigma.emit("moveBody", sigmaEventPayload(null, 151, 222));
567
+ sigma.emit("upStage", sigmaEventPayload(null, 171, 222));
568
+
569
+ const movedRegion = sigmaCommunityRegion(renderer, "adapter-community");
570
+ const movedLeft = Number.parseFloat(movedRegion?.style.left ?? "0");
571
+
572
+ // Phase 2:region 元素按 id 复用(同一实例),拖拽提交后只更新位置/几何。
573
+ assert.equal(movedRegion, initialRegion);
574
+ assert.ok(movedLeft > initialLeft, `expected cloud to follow dragged node, got ${initialLeft} -> ${movedLeft}`);
575
+
576
+ renderer.destroy();
577
+ });
578
+
579
+ it("refreshes community cloud geometry across same-id data updates", () => {
580
+ const runtime = fakeRuntime();
581
+ const initialData = adapterDataWithPolygonCommunityCloud();
582
+ const renderer = createSigmaGlobalRenderer({
583
+ container: fakeContainer(),
584
+ adapterData: initialData,
585
+ theme: "shan-shui",
586
+ runtime
587
+ });
588
+ const sigma = runtime.instances[0];
589
+ const initialRegion = sigmaCommunityRegion(renderer, "adapter-community");
590
+ const initialLeft = Number.parseFloat(initialRegion?.style.left ?? "0");
591
+ const movedData: GraphRendererAdapterData = {
592
+ ...initialData,
593
+ nodes: initialData.nodes.map((node) => node.id === "render-alpha"
594
+ ? { ...node, point: { x: 171, y: node.point.y } }
595
+ : node)
596
+ };
597
+
598
+ renderer.update({ adapterData: movedData });
599
+
600
+ const movedRegion = sigmaCommunityRegion(renderer, "adapter-community");
601
+ const movedLeft = Number.parseFloat(movedRegion?.style.left ?? "0");
602
+
603
+ assert.equal(renderer.graph.getNodeAttribute("render-alpha", "x"), 171);
604
+ assert.equal(sigma.setGraphCalls.length, 0);
605
+ assert.equal(movedRegion, initialRegion);
606
+ assert.ok(movedLeft > initialLeft, `expected cloud to follow updated node, got ${initialLeft} -> ${movedLeft}`);
607
+
608
+ renderer.destroy();
609
+ });
610
+
611
+ it("refreshes the Sigma canvas and overlays when the host resizes", () => {
612
+ let resizeCallback: ResizeObserverCallback | null = null;
613
+ let observedElement: Element | null = null;
614
+ let disconnected = false;
615
+ class FakeResizeObserver implements ResizeObserver {
616
+ constructor(callback: ResizeObserverCallback) {
617
+ resizeCallback = callback;
618
+ }
619
+ observe(target: Element): void {
620
+ observedElement = target;
621
+ }
622
+ unobserve(): void {}
623
+ disconnect(): void {
624
+ disconnected = true;
625
+ }
626
+ }
627
+
628
+ const container = fakeContainer({ ResizeObserver: FakeResizeObserver as typeof ResizeObserver });
629
+ const runtime = fakeRuntime();
630
+ const renderer = createSigmaGlobalRenderer({
631
+ container,
632
+ adapterData: adapterDataFixture(),
633
+ theme: "shan-shui",
634
+ runtime
635
+ });
636
+ const sigma = runtime.instances[0];
637
+ let refreshCount = 0;
638
+ sigma.refresh = () => {
639
+ refreshCount += 1;
640
+ sigma.settings.refreshed = true;
641
+ };
642
+ const previousOverlayElement = renderer.overlayRoot.children[0];
643
+
644
+ assert.equal(observedElement, renderer.root);
645
+ assert.equal(sigma.settings.refreshed, undefined);
646
+
647
+ resizeCallback?.([resizeObserverEntry(480, 320)], {} as ResizeObserver);
648
+
649
+ assert.equal(sigma.settings.refreshed, true);
650
+ assert.equal(refreshCount, 1);
651
+ // Phase 2:resize 走 reposition 路径,复用已有覆盖层元素(不再重建)。
652
+ assert.equal(renderer.overlayRoot.children[0], previousOverlayElement);
653
+ const resizedOverlayElement = renderer.overlayRoot.children[0];
654
+
655
+ resizeCallback?.([resizeObserverEntry(480, 320)], {} as ResizeObserver);
656
+
657
+ assert.equal(refreshCount, 1);
658
+ assert.equal(renderer.overlayRoot.children[0], resizedOverlayElement);
659
+
660
+ renderer.destroy();
661
+ assert.equal(disconnected, true);
662
+ });
663
+
664
+ it("repositions overlays on camera updates without rebuilding DOM or rebinding listeners", () => {
665
+ const runtime = fakeRuntime();
666
+ const renderer = createSigmaGlobalRenderer({
667
+ container: fakeContainer(),
668
+ adapterData: adapterDataFixture(),
669
+ theme: "shan-shui",
670
+ runtime
671
+ });
672
+ const sigma = runtime.instances[0];
673
+
674
+ const doc = renderer.root.ownerDocument as unknown as {
675
+ createElement: (tag: string) => HTMLElement;
676
+ createElementNS: (ns: string, tag: string) => HTMLElement;
677
+ };
678
+ let created = 0;
679
+ const originalCreate = doc.createElement;
680
+ const originalCreateNS = doc.createElementNS;
681
+ doc.createElement = (tag) => {
682
+ created += 1;
683
+ return originalCreate(tag);
684
+ };
685
+ doc.createElementNS = (ns, tag) => {
686
+ created += 1;
687
+ return originalCreateNS(ns, tag);
688
+ };
689
+
690
+ const overlay = renderer.overlayRoot as unknown as { replaceChildren: (...items: HTMLElement[]) => void };
691
+ let replaced = 0;
692
+ const originalReplace = overlay.replaceChildren.bind(overlay);
693
+ overlay.replaceChildren = (...items) => {
694
+ replaced += 1;
695
+ originalReplace(...items);
696
+ };
697
+
698
+ const before = [...renderer.overlayRoot.children];
699
+ const nodeBefore = before.find((child) => child.dataset.nodeId);
700
+ assert.ok(nodeBefore, "fixture should render at least one node hit target");
701
+
702
+ sigma.emit("afterRender");
703
+ sigma.emit("afterRender");
704
+ sigma.emit("afterRender");
705
+
706
+ assert.equal(created, 0, "camera updates must not create overlay elements");
707
+ assert.equal(replaced, 0, "camera updates must not replace overlay children");
708
+ assert.equal(renderer.overlayRoot.children.length, before.length);
709
+ assert.ok(
710
+ before.every((child, index) => renderer.overlayRoot.children[index] === child),
711
+ "overlay element instances must be reused across camera updates"
712
+ );
713
+ assert.equal(
714
+ renderer.overlayRoot.children.find((child) => child.dataset.nodeId === nodeBefore?.dataset.nodeId),
715
+ nodeBefore
716
+ );
717
+
718
+ renderer.destroy();
719
+ });
720
+
721
+ it("reuses overlay elements across data updates and prunes removed communities", () => {
722
+ const runtime = fakeRuntime();
723
+ const renderer = createSigmaGlobalRenderer({
724
+ container: fakeContainer(),
725
+ adapterData: adapterDataFixture({ communityCount: 3 }),
726
+ theme: "shan-shui",
727
+ runtime
728
+ });
729
+
730
+ const regionsBefore = renderer.overlayRoot.children.filter((child) => child.className === "sigma-global-community-region");
731
+ const alphaBefore = renderer.overlayRoot.children.find((child) => child.dataset.nodeId === "render-alpha");
732
+ assert.equal(regionsBefore.length, 3);
733
+ assert.ok(alphaBefore, "alpha node hit target should render initially");
734
+
735
+ // Update: collapse to a single community (community-1..3 removed, adapter-community added),
736
+ // keep alpha qualifying for the overlay via searchHit so its element can be reused.
737
+ renderer.update({
738
+ adapterData: adapterDataFixture({ communityCount: 1, selectedNodeId: "render-beta", searchResultIds: ["render-alpha"] })
739
+ });
740
+
741
+ const regionsAfter = renderer.overlayRoot.children.filter((child) => child.className === "sigma-global-community-region");
742
+ assert.equal(regionsAfter.length, 1, "removed community regions must be pruned");
743
+ assert.equal(regionsAfter[0].dataset.communityId, "adapter-community");
744
+ assert.ok(
745
+ !renderer.overlayRoot.children.some((child) => child.dataset.communityId === "community-1"),
746
+ "stale community-1 region must be gone from the DOM"
747
+ );
748
+
749
+ const alphaAfter = renderer.overlayRoot.children.find((child) => child.dataset.nodeId === "render-alpha");
750
+ assert.equal(alphaAfter, alphaBefore, "node hit target must be reused across update, not recreated");
751
+ assert.equal(alphaAfter?.dataset.selected, "false", "reused element must refresh data-derived attributes");
752
+ assert.equal(alphaAfter?.dataset.searchHit, "true");
753
+ const betaAfter = renderer.overlayRoot.children.find((child) => child.dataset.nodeId === "render-beta");
754
+ assert.equal(betaAfter?.dataset.selected, "true");
755
+
756
+ renderer.destroy();
757
+ });
758
+
759
+ it("coalesces rapid host resize notifications into one animation frame", () => {
760
+ let resizeCallback: ResizeObserverCallback | null = null;
761
+ const animationFrames: FrameRequestCallback[] = [];
762
+ class FakeResizeObserver implements ResizeObserver {
763
+ constructor(callback: ResizeObserverCallback) {
764
+ resizeCallback = callback;
765
+ }
766
+ observe(): void {}
767
+ unobserve(): void {}
768
+ disconnect(): void {}
769
+ }
770
+
771
+ const container = fakeContainer({
772
+ ResizeObserver: FakeResizeObserver as typeof ResizeObserver,
773
+ requestAnimationFrame: (callback: FrameRequestCallback) => {
774
+ animationFrames.push(callback);
775
+ return animationFrames.length;
776
+ },
777
+ cancelAnimationFrame: () => undefined
778
+ });
779
+ const runtime = fakeRuntime();
780
+ createSigmaGlobalRenderer({
781
+ container,
782
+ adapterData: adapterDataFixture(),
783
+ theme: "shan-shui",
784
+ runtime
785
+ });
786
+ const sigma = runtime.instances[0];
787
+ let refreshCount = 0;
788
+ sigma.refresh = () => {
789
+ refreshCount += 1;
790
+ };
791
+
792
+ resizeCallback?.([resizeObserverEntry(480, 320)], {} as ResizeObserver);
793
+ resizeCallback?.([resizeObserverEntry(520, 340)], {} as ResizeObserver);
794
+ resizeCallback?.([resizeObserverEntry(560, 360)], {} as ResizeObserver);
795
+
796
+ assert.equal(refreshCount, 0);
797
+ assert.equal(animationFrames.length, 1);
798
+
799
+ animationFrames.shift()?.(0);
800
+
801
+ assert.equal(refreshCount, 1);
802
+ });
803
+
804
+ it("keeps dense accepted global data visibly mapped as a capped point map", () => {
805
+ const data = densePointMapGraph();
806
+ const adapterData = buildGraphRendererAdapterData(data, {
807
+ theme: "shan-shui",
808
+ selection: { kind: "node", id: "dense-1999" },
809
+ searchResultIds: Array.from({ length: 260 }, (_, index) => `dense-${index * 3}`),
810
+ pins: Object.fromEntries(
811
+ data.nodes.slice(300, 560).map((node, index) => [
812
+ node.source_path || `wiki/dense/${node.id}.md`,
813
+ { x: 760 + (index % 24) * 4, y: 440 + Math.floor(index / 24) * 4, coordinateSpace: "world" as const }
814
+ ])
815
+ ),
816
+ aggregationMarkers: [
817
+ {
818
+ id: "dense-aggregation",
819
+ label: "Dense aggregation should stay hidden",
820
+ communityId: "dense-community-0",
821
+ nodeIds: data.nodes.slice(0, 200).map((node) => node.id),
822
+ totalCount: 200
823
+ }
824
+ ]
825
+ });
826
+ const graph = buildSigmaGlobalGraphologyGraph(adapterData, { GraphologyGraph });
827
+ const renderer = createSigmaGlobalRenderer({
828
+ container: fakeContainer(),
829
+ adapterData,
830
+ theme: "shan-shui",
831
+ runtime: fakeRuntime()
832
+ });
833
+ const ordinarySize = graph.getNodeAttribute("dense-1000", "size");
834
+ const selectedSize = graph.getNodeAttribute("dense-1999", "size");
835
+ const searchSize = graph.getNodeAttribute("dense-0", "size");
836
+ const pinnedSize = graph.getNodeAttribute("dense-300", "size");
837
+ const weakEdge = graph.getEdgeAttributes("dense-selected-weak");
838
+ const strongEdge = graph.getEdgeAttributes("dense-selected-strong");
839
+ const labelCount = graph.filterNodes((nodeId) => graph.getNodeAttribute(nodeId, "labelVisible")).length;
840
+ const hitTargets = renderer.overlayRoot.children.filter((child) => child.className === "sigma-global-node-hit-target");
841
+ const aggregationOverlays = renderer.overlayRoot.children.filter((child) => child.className === "sigma-global-aggregation-container");
842
+
843
+ assert.equal(adapterData.renderable.counts.visibleNodes, 2000);
844
+ assert.equal(adapterData.renderable.counts.totalEdges, 3996);
845
+ assert.equal(adapterData.renderable.aggregationContainers.length, 0);
846
+ assert.equal(graph.getAttribute("aggregations").length, 1);
847
+ assert.equal(graph.order, 2000);
848
+ assert.equal(graph.size, 1000);
849
+ assert.ok(ordinarySize < selectedSize);
850
+ assert.ok(ordinarySize < searchSize);
851
+ assert.ok(ordinarySize < pinnedSize);
852
+ assert.ok(edgeStyleAlpha(weakEdge.color) < edgeStyleAlpha(strongEdge.color));
853
+ assert.ok(weakEdge.size < strongEdge.size);
854
+ assert.ok(labelCount <= adapterData.renderable.budget.limits.maxLabels);
855
+ assert.equal(aggregationOverlays.length, 0);
856
+ assert.ok(hitTargets.length <= 160, `hit target overlays should stay capped, got ${hitTargets.length}`);
857
+ assert.ok(hitTargets.some((element) => element.dataset.nodeId === "dense-1999"), "selected anchor should keep a hit target");
858
+ assert.ok(hitTargets.some((element) => element.dataset.searchHit === "true"), "search anchors should keep hit targets");
859
+ assert.ok(hitTargets.some((element) => element.dataset.pinned === "true"), "pinned anchors should keep hit targets");
860
+
861
+ renderer.destroy();
862
+ });
863
+
864
+ it("lets passive community label coordinates resolve through the underlying spatial region", () => {
865
+ const projector = createSigmaGlobalHitProjector({
866
+ adapterData: adapterDataFixture(),
867
+ viewport: { x: 0, y: 0, scale: 1 },
868
+ viewportSize: { width: 500, height: 500 }
869
+ });
870
+
871
+ assert.deepEqual(
872
+ projector.targetFromSigmaHit({ screenPoint: { x: 250, y: 216 } }),
873
+ { kind: "community-wash", id: "adapter-community" }
874
+ );
875
+ });
876
+
877
+ it("projects Sigma blank screen hits without inventing graph semantics in the callback", () => {
878
+ const projector = createSigmaGlobalHitProjector({
879
+ adapterData: adapterDataFixture(),
880
+ viewport: { x: 0, y: 0, scale: 1 },
881
+ viewportSize: { width: 500, height: 500 }
882
+ });
883
+
884
+ assert.deepEqual(
885
+ projector.targetFromSigmaHit({ screenPoint: { x: 490, y: 490 } }),
886
+ { kind: "graph-blank" }
887
+ );
888
+ });
889
+
890
+ it("creates, updates, preserves camera state, and destroys the Sigma lifecycle", () => {
891
+ const container = fakeContainer();
892
+ const runtime = fakeRuntime();
893
+ const hits: unknown[] = [];
894
+ const renderer = createSigmaGlobalRenderer({
895
+ container,
896
+ adapterData: adapterDataFixture(),
897
+ theme: "shan-shui",
898
+ runtime,
899
+ onHitTarget: (target) => hits.push(target)
900
+ });
901
+ const sigma = runtime.instances[0];
902
+
903
+ assert.equal(renderer.id, "sigma-global");
904
+ assert.equal(renderer.updateStrategy, "rebuild-graph-preserve-camera");
905
+ assert.equal(container.children.length, 1);
906
+ assert.equal(renderer.overlayRoot.children.length, 4);
907
+ assert.equal(renderer.overlayRoot.children.filter((child) => child.className === "sigma-global-node-hit-target").length, 2);
908
+ assert.equal(renderer.overlayRoot.children.filter((child) => child.className === "sigma-global-community-region").length, 1);
909
+ assert.equal(renderer.overlayRoot.children.filter((child) => child.className === "sigma-global-community-label").length, 1);
910
+ assert.equal(renderer.overlayRoot.children.filter((child) => child.className === "sigma-global-aggregation-container").length, 0);
911
+ assert.equal(sigma.graph.order, 2);
912
+
913
+ sigma.camera.setState({ x: 12, y: 34, angle: 0.25, ratio: 1.8 });
914
+ const originalGraph = renderer.graph;
915
+ const nextAdapterData = adapterDataFixture({
916
+ selectedNodeId: "render-beta",
917
+ searchResultIds: ["render-alpha"],
918
+ betaPinned: false
919
+ });
920
+ renderer.update({ adapterData: nextAdapterData, theme: "mo-ye" });
921
+
922
+ assert.equal(runtime.instances.length, 1);
923
+ assert.notEqual(originalGraph, renderer.graph);
924
+ assert.equal(sigma.graph, renderer.graph);
925
+ assert.equal(sigma.setGraphCalls.length, 1);
926
+ assert.deepEqual(sigma.camera.getState(), { x: 12, y: 34, angle: 0.25, ratio: 1.8 });
927
+ assert.equal(renderer.graph.getAttribute("selection").selectedNodeIds[0], "render-beta");
928
+ assert.equal(renderer.graph.getNodeAttribute("render-alpha", "searchHit"), true);
929
+ assert.equal(renderer.graph.getNodeAttribute("render-beta", "pinned"), false);
930
+ assert.equal(renderer.root.dataset.theme, "mo-ye");
931
+
932
+ sigma.emit("clickNode", { node: "render-beta" });
933
+ assert.deepEqual(renderer.lastHitTarget, { kind: "node", id: "render-beta" });
934
+ assert.deepEqual(hits.at(-1), { kind: "node", id: "render-beta" });
935
+
936
+ renderer.destroy();
937
+ assert.equal(sigma.killed, true);
938
+ assert.equal(container.children.length, 0);
939
+ assert.throws(() => renderer.update({ adapterData: adapterDataFixture() }), /destroyed/);
940
+
941
+ sigma.emit("clickNode", { node: "render-alpha" });
942
+ assert.deepEqual(renderer.lastHitTarget, { kind: "node", id: "render-beta" });
943
+ });
944
+
945
+ it("patches node spotlight attributes in place when community selection changes", () => {
946
+ const runtime = fakeRuntime();
947
+ const renderer = createSigmaGlobalRenderer({
948
+ container: fakeContainer(),
949
+ adapterData: nodeSpotlightAdapterData({ selectedCommunityId: "community-1" }),
950
+ theme: "shan-shui",
951
+ runtime
952
+ });
953
+ const sigma = runtime.instances[0];
954
+ const originalGraph = renderer.graph;
955
+ const overlay = renderer.overlayRoot as unknown as { replaceChildren: (...items: HTMLElement[]) => void };
956
+ let replaced = 0;
957
+ const originalReplace = overlay.replaceChildren.bind(overlay);
958
+ overlay.replaceChildren = (...items) => {
959
+ replaced += 1;
960
+ originalReplace(...items);
961
+ };
962
+ const originalChildren = [...renderer.overlayRoot.children];
963
+
964
+ assert.equal(renderer.graph.getNodeAttribute("beta-ordinary", "communityDimmed"), true);
965
+
966
+ renderer.update({
967
+ adapterData: nodeSpotlightAdapterData({ selectedCommunityId: "community-2" })
968
+ });
969
+
970
+ assert.equal(renderer.graph, originalGraph);
971
+ assert.equal(sigma.setGraphCalls.length, 0);
972
+ assert.equal(renderer.graph.getNodeAttribute("alpha-ordinary", "communityDimmed"), true);
973
+ assert.equal(renderer.graph.getNodeAttribute("beta-ordinary", "communityDimmed"), false);
974
+ assert.deepEqual(renderer.graph.getAttribute("selection").input, { kind: "community", id: "community-2" });
975
+ assert.equal(replaced, 1);
976
+ assert.equal(renderer.overlayRoot.children.length, originalChildren.length);
977
+
978
+ renderer.destroy();
979
+ });
980
+
981
+ it("animates the Sigma camera to the latest selected community spotlight in Sigma camera coordinates", () => {
982
+ const runtime = fakeRuntime({ worldScale: 200 });
983
+ const renderer = createSigmaGlobalRenderer({
984
+ container: fakeContainer(),
985
+ adapterData: nodeSpotlightAdapterData({ selectionKind: null }),
986
+ theme: "shan-shui",
987
+ runtime
988
+ });
989
+ const sigma = runtime.instances[0];
990
+
991
+ renderer.update({ adapterData: nodeSpotlightAdapterData({ selectedCommunityId: "community-1" }) });
992
+ renderer.update({ adapterData: nodeSpotlightAdapterData({ selectedCommunityId: "community-2" }) });
993
+
994
+ assert.equal(sigma.camera.animateCalls.length, 2);
995
+ assert.deepEqual(sigma.camera.animateCalls.at(0), {
996
+ state: { x: 0.48, y: 0.6, angle: 0, ratio: 0.92 },
997
+ options: { duration: 380, easing: "quadraticInOut" }
998
+ });
999
+ assert.deepEqual(sigma.camera.activeAnimationTarget, { x: 0.63, y: 0.7, angle: 0, ratio: 0.846 });
1000
+ assert.deepEqual(sigma.camera.getState(), { x: 0.63, y: 0.7, angle: 0, ratio: 0.846 });
1001
+
1002
+ renderer.destroy();
1003
+ });
1004
+
1005
+ it("sets the Sigma camera instantly when reduced motion is requested", () => {
1006
+ const runtime = fakeRuntime({ worldScale: 200 });
1007
+ const renderer = createSigmaGlobalRenderer({
1008
+ container: fakeContainer({
1009
+ matchMedia: () => ({ matches: true }) as MediaQueryList
1010
+ } as FakeDefaultView),
1011
+ adapterData: nodeSpotlightAdapterData({ selectionKind: null }),
1012
+ theme: "shan-shui",
1013
+ runtime
1014
+ });
1015
+ const sigma = runtime.instances[0];
1016
+
1017
+ renderer.update({ adapterData: nodeSpotlightAdapterData({ selectedCommunityId: "community-1" }) });
1018
+
1019
+ assert.equal(sigma.camera.animateCalls.length, 0);
1020
+ assert.deepEqual(sigma.camera.setStateCalls.at(-1), { x: 0.48, y: 0.6, angle: 0, ratio: 0.92 });
1021
+ assert.deepEqual(sigma.camera.getState(), { x: 0.48, y: 0.6, angle: 0, ratio: 0.92 });
1022
+
1023
+ renderer.destroy();
1024
+ });
1025
+
1026
+ it("does not move the Sigma camera when the selected community is already framed", () => {
1027
+ const runtime = fakeRuntime({ worldScale: 200 });
1028
+ const renderer = createSigmaGlobalRenderer({
1029
+ container: fakeContainer(),
1030
+ adapterData: nodeSpotlightAdapterData({ selectionKind: null }),
1031
+ theme: "shan-shui",
1032
+ runtime
1033
+ });
1034
+ const sigma = runtime.instances[0];
1035
+ sigma.camera.setState({ x: 0.48, y: 0.6, ratio: 0.92 });
1036
+
1037
+ renderer.update({ adapterData: nodeSpotlightAdapterData({ selectedCommunityId: "community-1" }) });
1038
+
1039
+ assert.equal(sigma.camera.animateCalls.length, 0);
1040
+ assert.deepEqual(sigma.camera.getState(), { x: 0.48, y: 0.6, angle: 0, ratio: 0.92 });
1041
+
1042
+ renderer.destroy();
1043
+ });
1044
+
1045
+ it("resets the Sigma camera back to the full global composition", () => {
1046
+ const runtime = fakeRuntime({ worldScale: 200 });
1047
+ const renderer = createSigmaGlobalRenderer({
1048
+ container: fakeContainer(),
1049
+ adapterData: nodeSpotlightAdapterData({ selectionKind: null }),
1050
+ theme: "shan-shui",
1051
+ runtime
1052
+ });
1053
+ const sigma = runtime.instances[0];
1054
+
1055
+ renderer.update({ adapterData: nodeSpotlightAdapterData({ selectedCommunityId: "community-1" }) });
1056
+ renderer.resetView();
1057
+
1058
+ assert.deepEqual(sigma.camera.setStateCalls.at(-1), { x: 0.5, y: 0.5, angle: 0, ratio: 1 });
1059
+ assert.deepEqual(sigma.camera.getState(), { x: 0.5, y: 0.5, angle: 0, ratio: 1 });
1060
+
1061
+ renderer.destroy();
1062
+ });
1063
+
1064
+ it("keeps the full graph rebuild path for theme changes", () => {
1065
+ const runtime = fakeRuntime();
1066
+ const renderer = createSigmaGlobalRenderer({
1067
+ container: fakeContainer(),
1068
+ adapterData: nodeSpotlightAdapterData({ selectedCommunityId: "community-1" }),
1069
+ theme: "shan-shui",
1070
+ runtime
1071
+ });
1072
+
1073
+ renderer.update({
1074
+ adapterData: nodeSpotlightAdapterData({ selectedCommunityId: "community-2" }),
1075
+ theme: "mo-ye"
1076
+ });
1077
+
1078
+ assert.equal(runtime.instances[0].setGraphCalls.length, 1);
1079
+
1080
+ renderer.destroy();
1081
+ });
1082
+
1083
+ it("reports Sigma initialization failure to the route layer", () => {
1084
+ const failure = new Error("webgl unavailable");
1085
+ const errors: unknown[] = [];
1086
+
1087
+ assert.throws(
1088
+ () => createSigmaGlobalRenderer({
1089
+ container: fakeContainer(),
1090
+ adapterData: adapterDataFixture(),
1091
+ theme: "shan-shui",
1092
+ runtime: fakeRuntime({ constructError: failure }),
1093
+ onFatalError: (error) => errors.push(error)
1094
+ }),
1095
+ /webgl unavailable/
1096
+ );
1097
+ assert.deepEqual(errors, [failure]);
1098
+ });
1099
+
1100
+ it("suppresses stale events after replacement and update-after-destroy", () => {
1101
+ const firstRuntime = fakeRuntime();
1102
+ const secondRuntime = fakeRuntime();
1103
+ const first = createSigmaGlobalRenderer({
1104
+ container: fakeContainer(),
1105
+ adapterData: adapterDataFixture(),
1106
+ theme: "shan-shui",
1107
+ runtime: firstRuntime
1108
+ });
1109
+ const firstSigma = firstRuntime.instances[0];
1110
+ first.destroy();
1111
+
1112
+ const second = createSigmaGlobalRenderer({
1113
+ container: fakeContainer(),
1114
+ adapterData: adapterDataFixture({ selectedNodeId: "render-beta" }),
1115
+ theme: "shan-shui",
1116
+ runtime: secondRuntime
1117
+ });
1118
+ const secondSigma = secondRuntime.instances[0];
1119
+
1120
+ firstSigma.emit("clickNode", { node: "render-alpha" });
1121
+ assert.equal(first.lastHitTarget, null);
1122
+ assert.equal(second.lastHitTarget, null);
1123
+
1124
+ secondSigma.emit("clickNode", { node: "render-beta" });
1125
+ assert.deepEqual(second.lastHitTarget, { kind: "node", id: "render-beta" });
1126
+ second.destroy();
1127
+ assert.throws(() => second.update({ adapterData: adapterDataFixture() }), /destroyed/);
1128
+ });
1129
+
1130
+ it("reports unrecoverable update and destroy errors without choosing fallback UI", () => {
1131
+ const errors: unknown[] = [];
1132
+ const runtime = fakeRuntime({ setGraphError: new Error("graph swap failed"), killError: new Error("kill failed") });
1133
+ const renderer = createSigmaGlobalRenderer({
1134
+ container: fakeContainer(),
1135
+ adapterData: adapterDataFixture(),
1136
+ theme: "shan-shui",
1137
+ runtime,
1138
+ onFatalError: (error) => errors.push(error)
1139
+ });
1140
+
1141
+ renderer.update({ adapterData: adapterDataFixture({ selectedNodeId: "render-beta" }), theme: "mo-ye" });
1142
+ renderer.destroy();
1143
+
1144
+ assert.deepEqual(errors.map((error) => String(error)), ["Error: graph swap failed", "Error: kill failed"]);
1145
+ });
1146
+
1147
+ it("drags a Sigma global node and writes a world-space pin on release", () => {
1148
+ const runtime = fakeRuntime();
1149
+ const pins: unknown[] = [];
1150
+ const renderer = createSigmaGlobalRenderer({
1151
+ container: fakeContainer(),
1152
+ adapterData: adapterDataFixture({ betaPinned: false }),
1153
+ theme: "shan-shui",
1154
+ runtime,
1155
+ pins: {},
1156
+ onPinsChanged: (nextPins) => pins.push(nextPins)
1157
+ });
1158
+ const sigma = runtime.instances[0];
1159
+ const down = sigmaEventPayload("render-alpha", 116, 228);
1160
+ const move = sigmaEventPayload(null, 156, 268);
1161
+ const up = sigmaEventPayload(null, 176, 288);
1162
+
1163
+ sigma.emit("downNode", down);
1164
+ sigma.emit("moveBody", move);
1165
+ sigma.emit("upStage", up);
1166
+
1167
+ assert.equal(down.prevented, true);
1168
+ assert.equal(move.prevented, true);
1169
+ assert.equal(up.prevented, true);
1170
+ assert.deepEqual(pins, [
1171
+ {
1172
+ "adapter/alpha.md": {
1173
+ x: 171,
1174
+ y: 282,
1175
+ coordinateSpace: "world"
1176
+ }
1177
+ }
1178
+ ]);
1179
+ assert.equal(renderer.graph.getNodeAttribute("render-alpha", "x"), 171);
1180
+ assert.equal(renderer.graph.getNodeAttribute("render-alpha", "y"), 282);
1181
+ assert.equal(renderer.graph.getNodeAttribute("render-alpha", "pinned"), true);
1182
+ assert.equal(sigma.settings.enableCameraPanning, true);
1183
+
1184
+ renderer.destroy();
1185
+ });
1186
+
1187
+ it("keeps selected search and pinned metadata intact while dragging a Sigma global node", () => {
1188
+ const runtime = fakeRuntime();
1189
+ const renderer = createSigmaGlobalRenderer({
1190
+ container: fakeContainer(),
1191
+ adapterData: adapterDataFixture({
1192
+ selectedNodeId: "render-alpha",
1193
+ searchResultIds: ["render-alpha"],
1194
+ betaPinned: true
1195
+ }),
1196
+ theme: "shan-shui",
1197
+ runtime,
1198
+ pins: {
1199
+ "adapter/beta.md": { x: 333, y: 444, coordinateSpace: "world" }
1200
+ },
1201
+ onPinsChanged: () => undefined
1202
+ });
1203
+ const sigma = runtime.instances[0];
1204
+
1205
+ sigma.emit("downNode", sigmaEventPayload("render-alpha", 111, 222));
1206
+ sigma.emit("moveBody", sigmaEventPayload(null, 141, 252));
1207
+ sigma.emit("upNode", sigmaEventPayload("render-alpha", 151, 262));
1208
+
1209
+ assert.equal(renderer.graph.getNodeAttribute("render-alpha", "selected"), true);
1210
+ assert.equal(renderer.graph.getNodeAttribute("render-alpha", "searchHit"), true);
1211
+ assert.equal(renderer.graph.getNodeAttribute("render-alpha", "pinned"), true);
1212
+ assert.equal(renderer.graph.getNodeAttribute("render-beta", "pinned"), true);
1213
+ const alphaOverlay = renderer.overlayRoot.children.find((child) => child.dataset.nodeId === "render-alpha");
1214
+ const betaOverlay = renderer.overlayRoot.children.find((child) => child.dataset.nodeId === "render-beta");
1215
+ assert.equal(alphaOverlay?.dataset.selected, "true");
1216
+ assert.equal(alphaOverlay?.dataset.searchHit, "true");
1217
+ assert.equal(alphaOverlay?.dataset.pinned, "true");
1218
+ assert.equal(betaOverlay?.dataset.pinned, "true");
1219
+
1220
+ renderer.destroy();
1221
+ });
1222
+
1223
+ it("keeps an already pinned Sigma global node pinned throughout drag", () => {
1224
+ const runtime = fakeRuntime();
1225
+ const pins: unknown[] = [];
1226
+ const renderer = createSigmaGlobalRenderer({
1227
+ container: fakeContainer(),
1228
+ adapterData: adapterDataFixture({
1229
+ selectedNodeId: "render-alpha",
1230
+ searchResultIds: ["render-alpha"],
1231
+ alphaPinned: true,
1232
+ betaPinned: true
1233
+ }),
1234
+ theme: "shan-shui",
1235
+ runtime,
1236
+ pins: {
1237
+ "adapter/alpha.md": { x: 111, y: 222, coordinateSpace: "world" },
1238
+ "adapter/beta.md": { x: 333, y: 444, coordinateSpace: "world" }
1239
+ },
1240
+ onPinsChanged: (nextPins) => pins.push(nextPins)
1241
+ });
1242
+ const sigma = runtime.instances[0];
1243
+
1244
+ sigma.emit("downNode", sigmaEventPayload("render-alpha", 111, 222));
1245
+ sigma.emit("moveBody", sigmaEventPayload(null, 151, 262));
1246
+
1247
+ assert.equal(renderer.graph.getNodeAttribute("render-alpha", "pinned"), true);
1248
+ assert.equal(renderer.overlayRoot.children.find((child) => child.dataset.nodeId === "render-alpha")?.dataset.pinned, "true");
1249
+
1250
+ sigma.emit("upStage", sigmaEventPayload(null, 171, 282));
1251
+
1252
+ assert.deepEqual(pins, [
1253
+ {
1254
+ "adapter/alpha.md": { x: 171, y: 282, coordinateSpace: "world" },
1255
+ "adapter/beta.md": { x: 333, y: 444, coordinateSpace: "world" }
1256
+ }
1257
+ ]);
1258
+ assert.equal(renderer.graph.getNodeAttribute("render-alpha", "pinned"), true);
1259
+
1260
+ renderer.destroy();
1261
+ });
1262
+
1263
+ it("cancels active Sigma node drag on destroy without stale pin writes", () => {
1264
+ const runtime = fakeRuntime();
1265
+ const pins: unknown[] = [];
1266
+ const renderer = createSigmaGlobalRenderer({
1267
+ container: fakeContainer(),
1268
+ adapterData: adapterDataFixture({ betaPinned: false }),
1269
+ theme: "shan-shui",
1270
+ runtime,
1271
+ pins: {},
1272
+ onPinsChanged: (nextPins) => pins.push(nextPins)
1273
+ });
1274
+ const sigma = runtime.instances[0];
1275
+
1276
+ sigma.emit("downNode", sigmaEventPayload("render-alpha", 111, 222));
1277
+ sigma.emit("moveBody", sigmaEventPayload(null, 151, 262));
1278
+ assert.equal(renderer.graph.getNodeAttribute("render-alpha", "x"), 151);
1279
+ assert.equal(renderer.graph.getNodeAttribute("render-alpha", "y"), 262);
1280
+
1281
+ renderer.destroy();
1282
+ sigma.emit("upStage", sigmaEventPayload(null, 171, 282));
1283
+
1284
+ assert.deepEqual(pins, []);
1285
+ assert.equal(renderer.graph.getNodeAttribute("render-alpha", "x"), 111);
1286
+ assert.equal(renderer.graph.getNodeAttribute("render-alpha", "y"), 222);
1287
+ assert.equal(sigma.listeners.get("downNode")?.size ?? 0, 0);
1288
+ assert.equal(sigma.listeners.get("moveBody")?.size ?? 0, 0);
1289
+ assert.equal(sigma.listeners.get("upStage")?.size ?? 0, 0);
1290
+ assert.equal(sigma.listeners.get("upNode")?.size ?? 0, 0);
1291
+ assert.equal(sigma.settings.enableCameraPanning, true);
1292
+ });
1293
+
1294
+ it("does not replace overlays or swallow clicks for an un-moved drag candidate", () => {
1295
+ const runtime = fakeRuntime();
1296
+ const hits: unknown[] = [];
1297
+ const renderer = createSigmaGlobalRenderer({
1298
+ container: fakeContainer(),
1299
+ adapterData: adapterDataFixture({ betaPinned: false }),
1300
+ theme: "shan-shui",
1301
+ runtime,
1302
+ pins: {},
1303
+ onHitTarget: (target) => hits.push(target)
1304
+ });
1305
+ const sigma = runtime.instances[0];
1306
+ const alphaOverlay = renderer.overlayRoot.children.find((child) => child.dataset.nodeId === "render-alpha");
1307
+
1308
+ sigma.emit("downNode", sigmaEventPayload("render-alpha", 111, 222));
1309
+ sigma.emit("upNode", sigmaEventPayload("render-alpha", 111, 222));
1310
+ sigma.emit("clickNode", sigmaEventPayload("render-alpha", 111, 222));
1311
+
1312
+ assert.equal(renderer.overlayRoot.children.find((child) => child.dataset.nodeId === "render-alpha"), alphaOverlay);
1313
+ assert.deepEqual(hits, [{ kind: "node", id: "render-alpha" }]);
1314
+
1315
+ renderer.destroy();
1316
+ });
1317
+ });
1318
+
1319
+ function adapterDataFixture(options: {
1320
+ selectedNodeId?: string;
1321
+ searchResultIds?: string[];
1322
+ alphaPinned?: boolean;
1323
+ betaPinned?: boolean;
1324
+ communityCount?: number;
1325
+ selectedCommunityId?: string;
1326
+ selectedCommunityIds?: string[];
1327
+ } = {}): GraphRendererAdapterData {
1328
+ const selectedNodeId = options.selectedNodeId ?? "render-alpha";
1329
+ const searchResultIds = options.searchResultIds ?? ["render-beta"];
1330
+ const alphaPinned = options.alphaPinned ?? false;
1331
+ const betaPinned = options.betaPinned ?? true;
1332
+ const communityCount = options.communityCount ?? 1;
1333
+ const selectedCommunityIds = options.selectedCommunityIds ?? [options.selectedCommunityId ?? "adapter-community"];
1334
+ const renderableCommunities = renderableCommunityFixture(communityCount);
1335
+ return {
1336
+ counts: {
1337
+ nodes: 2,
1338
+ edges: 1,
1339
+ communities: 1,
1340
+ hidden: 0,
1341
+ renderedNodes: 2,
1342
+ renderedEdges: 1,
1343
+ aggregationContainers: 1
1344
+ },
1345
+ selection: {
1346
+ input: { kind: "node", id: selectedNodeId },
1347
+ selectionId: `node:${selectedNodeId}`,
1348
+ selectedNodeIds: [selectedNodeId],
1349
+ selectedCommunityIds,
1350
+ containsCurrentObject: true
1351
+ },
1352
+ nodes: [
1353
+ {
1354
+ id: "render-alpha",
1355
+ object: { kind: "node", nodeId: "render-alpha" },
1356
+ label: "Adapter Alpha",
1357
+ type: "topic",
1358
+ communityId: "adapter-community",
1359
+ sourcePath: "adapter/alpha.md",
1360
+ point: { x: 111, y: 222 },
1361
+ selected: selectedNodeId === "render-alpha",
1362
+ searchHit: searchResultIds.includes("render-alpha"),
1363
+ pinHint: {
1364
+ nodeId: "render-alpha",
1365
+ wikiPath: "adapter/alpha.md",
1366
+ pinned: alphaPinned,
1367
+ position: alphaPinned ? { x: 111, y: 222, coordinateSpace: "world" } : null
1368
+ },
1369
+ aggregationIds: ["adapter-aggregation"],
1370
+ drawerTarget: {
1371
+ summaryKind: "node-summary",
1372
+ object: { kind: "node", nodeId: "render-alpha" }
1373
+ },
1374
+ render: {
1375
+ displayMode: "card",
1376
+ visualRole: "landmark",
1377
+ priority: 900,
1378
+ labelVisible: true
1379
+ }
1380
+ },
1381
+ {
1382
+ id: "render-beta",
1383
+ object: { kind: "node", nodeId: "render-beta" },
1384
+ label: "Adapter Beta",
1385
+ type: "source",
1386
+ communityId: "adapter-community",
1387
+ sourcePath: "adapter/beta.md",
1388
+ point: { x: 333, y: 444 },
1389
+ selected: selectedNodeId === "render-beta",
1390
+ searchHit: searchResultIds.includes("render-beta"),
1391
+ pinHint: {
1392
+ nodeId: "render-beta",
1393
+ wikiPath: "adapter/beta.md",
1394
+ pinned: betaPinned,
1395
+ position: betaPinned ? { x: 333, y: 444, coordinateSpace: "world" } : null
1396
+ },
1397
+ aggregationIds: ["adapter-aggregation"],
1398
+ drawerTarget: {
1399
+ summaryKind: "node-summary",
1400
+ object: { kind: "node", nodeId: "render-beta" }
1401
+ },
1402
+ render: {
1403
+ displayMode: "point",
1404
+ visualRole: "map-pin",
1405
+ priority: 100,
1406
+ labelVisible: false
1407
+ }
1408
+ }
1409
+ ],
1410
+ edges: [
1411
+ {
1412
+ id: "adapter-edge",
1413
+ sourceNodeId: "render-alpha",
1414
+ targetNodeId: "render-beta",
1415
+ sourceCommunityId: "adapter-community",
1416
+ targetCommunityId: "adapter-community",
1417
+ relationType: "depends-on-adapter",
1418
+ confidence: "ADAPTER_CONFIDENCE",
1419
+ weight: 0.75,
1420
+ render: {
1421
+ strokeWidth: 3,
1422
+ opacity: 0.42
1423
+ }
1424
+ }
1425
+ ],
1426
+ communities: [
1427
+ {
1428
+ id: "adapter-community",
1429
+ object: { kind: "community", communityId: "adapter-community" },
1430
+ label: "Adapter Community",
1431
+ nodeIds: ["render-alpha", "render-beta"],
1432
+ nodeCount: 2,
1433
+ selected: selectedCommunityIds.includes("adapter-community"),
1434
+ searchResultIds,
1435
+ pinHints: betaPinned ? [
1436
+ {
1437
+ nodeId: "render-beta",
1438
+ wikiPath: "adapter/beta.md",
1439
+ pinned: true,
1440
+ position: { x: 333, y: 444, coordinateSpace: "world" }
1441
+ }
1442
+ ] : [],
1443
+ aggregationIds: ["adapter-aggregation"],
1444
+ drawerTarget: {
1445
+ summaryKind: "community-summary",
1446
+ object: { kind: "community", communityId: "adapter-community" }
1447
+ },
1448
+ commands: [{ kind: "enter-community", communityId: "adapter-community", label: "进入社区" }]
1449
+ },
1450
+ ...renderableCommunities
1451
+ .filter((community) => community.id !== "adapter-community")
1452
+ .map((community) => ({
1453
+ id: community.id,
1454
+ object: { kind: "community" as const, communityId: community.id },
1455
+ label: community.label,
1456
+ nodeIds: [],
1457
+ nodeCount: community.nodeCount,
1458
+ selected: selectedCommunityIds.includes(community.id),
1459
+ searchResultIds: [],
1460
+ pinHints: [],
1461
+ aggregationIds: [],
1462
+ drawerTarget: {
1463
+ summaryKind: "community-summary" as const,
1464
+ object: { kind: "community" as const, communityId: community.id }
1465
+ },
1466
+ commands: [{ kind: "enter-community" as const, communityId: community.id, label: "进入社区" }]
1467
+ }))
1468
+ ],
1469
+ aggregations: [
1470
+ {
1471
+ id: "adapter-aggregation",
1472
+ object: {
1473
+ kind: "aggregation",
1474
+ aggregationId: "adapter-aggregation",
1475
+ nodeIds: ["render-alpha", "render-beta"],
1476
+ communityId: "adapter-community"
1477
+ },
1478
+ label: "Adapter Aggregation",
1479
+ communityId: "adapter-community",
1480
+ nodeIds: ["render-alpha", "render-beta"],
1481
+ selectedNodeIds: ["render-alpha"],
1482
+ searchResultIds,
1483
+ pinnedNodeIds: betaPinned ? ["render-beta"] : [],
1484
+ totalCount: 17,
1485
+ selected: true,
1486
+ pinHints: betaPinned ? [
1487
+ {
1488
+ nodeId: "render-beta",
1489
+ wikiPath: "adapter/beta.md",
1490
+ pinned: true,
1491
+ position: { x: 333, y: 444, coordinateSpace: "world" }
1492
+ }
1493
+ ] : [],
1494
+ drawerTarget: {
1495
+ summaryKind: "community-summary",
1496
+ object: { kind: "community", communityId: "adapter-community" }
1497
+ },
1498
+ commands: [
1499
+ {
1500
+ kind: "show-this-object",
1501
+ object: {
1502
+ kind: "aggregation",
1503
+ aggregationId: "adapter-aggregation",
1504
+ nodeIds: ["render-alpha", "render-beta"],
1505
+ communityId: "adapter-community"
1506
+ },
1507
+ label: "显示这个对象"
1508
+ }
1509
+ ]
1510
+ }
1511
+ ],
1512
+ renderable: {
1513
+ nodes: [],
1514
+ edges: [],
1515
+ communities: renderableCommunities,
1516
+ aggregationContainers: [
1517
+ {
1518
+ id: "adapter-aggregation",
1519
+ role: "aggregation-container",
1520
+ label: "Adapter Aggregation",
1521
+ communityId: "adapter-community",
1522
+ nodeIds: ["render-alpha", "render-beta"],
1523
+ nodeCount: 17,
1524
+ searchHitCount: 1,
1525
+ pinnedCount: betaPinned ? 1 : 0,
1526
+ selectedCount: 1,
1527
+ selected: true,
1528
+ searchResultIds,
1529
+ pinnedNodeIds: betaPinned ? ["render-beta"] : [],
1530
+ selectedNodeIds: [selectedNodeId],
1531
+ pinHints: betaPinned ? [
1532
+ {
1533
+ nodeId: "render-beta",
1534
+ wikiPath: "adapter/beta.md",
1535
+ pinned: true,
1536
+ position: { x: 333, y: 444, coordinateSpace: "world" }
1537
+ }
1538
+ ] : [],
1539
+ point: { x: 222, y: 333 },
1540
+ x: 22,
1541
+ y: 33,
1542
+ radius: 44,
1543
+ color: "#abcdef"
1544
+ }
1545
+ ],
1546
+ minimap: { path: "", nodes: [] },
1547
+ relationLegend: [],
1548
+ selectedNodeId,
1549
+ selectedCommunityId: selectedCommunityIds[0] ?? null,
1550
+ selectedNodeIds: [selectedNodeId],
1551
+ hiddenNodeIds: new Set(),
1552
+ searchResultIds,
1553
+ worldBounds: { minX: 0, maxX: 500, minY: 0, maxY: 500 },
1554
+ budgets: {
1555
+ limits: {
1556
+ maxNodes: 2,
1557
+ maxEdges: 1,
1558
+ maxLabels: 1,
1559
+ maxCards: 1,
1560
+ maxInteractionUpdates: 3,
1561
+ maxVisibleCommunities: 1
1562
+ },
1563
+ usage: {
1564
+ nodes: 2,
1565
+ edges: 1,
1566
+ labels: 1,
1567
+ cards: 1,
1568
+ interactionUpdate: 3,
1569
+ activeInteraction: 3,
1570
+ communities: 1,
1571
+ aggregationContainers: 1
1572
+ }
1573
+ },
1574
+ qualityNotice: null,
1575
+ communityFocus: null,
1576
+ communityQuality: {
1577
+ boundaryCertainty: "high",
1578
+ skeletonLabel: "stable",
1579
+ hiddenNodeCount: 0,
1580
+ hiddenEdgeCount: 0,
1581
+ stableCoreNodeIds: ["render-alpha"],
1582
+ stableSkeletonEdgeIds: ["adapter-edge"],
1583
+ temporaryBoostNodeIds: []
1584
+ }
1585
+ }
1586
+ };
1587
+ }
1588
+
1589
+ function nodeSpotlightAdapterData(options: {
1590
+ selectedCommunityId?: "community-1" | "community-2";
1591
+ selectionKind?: "community" | "node" | null;
1592
+ } = {}): GraphRendererAdapterData {
1593
+ const selectedCommunityId = options.selectedCommunityId ?? "community-1";
1594
+ const selectionKind = options.selectionKind === undefined ? "community" : options.selectionKind;
1595
+ const renderableCommunities = renderableCommunityFixture(2);
1596
+ const nodes: GraphRendererAdapterData["nodes"] = [
1597
+ spotlightNodeFixture("alpha-ordinary", "community-1", { point: { x: 10, y: 20 } }),
1598
+ spotlightNodeFixture("alpha-selected", "community-1", { selected: true, point: { x: 20, y: 30 } }),
1599
+ spotlightNodeFixture("beta-ordinary", "community-2", { point: { x: 110, y: 120 } }),
1600
+ spotlightNodeFixture("beta-search", "community-2", { searchHit: true, point: { x: 120, y: 130 } }),
1601
+ spotlightNodeFixture("beta-pinned", "community-2", { pinned: true, point: { x: 130, y: 140 } })
1602
+ ];
1603
+ const selectedNodeIds = nodes.filter((node) => node.selected).map((node) => node.id);
1604
+ const searchResultIds = nodes.filter((node) => node.searchHit).map((node) => node.id);
1605
+ const pinnedNodeIds = nodes.filter((node) => node.pinHint.pinned).map((node) => node.id);
1606
+ const selectedCommunityIds = selectionKind === "community"
1607
+ ? [selectedCommunityId]
1608
+ : selectionKind === "node"
1609
+ ? ["community-1"]
1610
+ : [];
1611
+ const selectionInput = selectionKind === "community"
1612
+ ? { kind: "community" as const, id: selectedCommunityId }
1613
+ : selectionKind === "node"
1614
+ ? { kind: "node" as const, id: "alpha-selected" }
1615
+ : null;
1616
+
1617
+ return {
1618
+ counts: {
1619
+ nodes: nodes.length,
1620
+ edges: 0,
1621
+ communities: 2,
1622
+ hidden: 0,
1623
+ renderedNodes: nodes.length,
1624
+ renderedEdges: 0,
1625
+ aggregationContainers: 0
1626
+ },
1627
+ selection: {
1628
+ input: selectionInput,
1629
+ selectionId: selectionInput ? `${selectionInput.kind}:${selectionInput.id}` : null,
1630
+ selectedNodeIds,
1631
+ selectedCommunityIds,
1632
+ containsCurrentObject: Boolean(selectionInput)
1633
+ },
1634
+ nodes,
1635
+ edges: [],
1636
+ communities: renderableCommunities.map((community) => ({
1637
+ id: community.id,
1638
+ object: { kind: "community", communityId: community.id },
1639
+ label: community.label,
1640
+ nodeIds: nodes.filter((node) => node.communityId === community.id).map((node) => node.id),
1641
+ nodeCount: nodes.filter((node) => node.communityId === community.id).length,
1642
+ selected: selectedCommunityIds.includes(community.id),
1643
+ searchResultIds: searchResultIds.filter((id) => nodes.find((node) => node.id === id)?.communityId === community.id),
1644
+ pinHints: nodes
1645
+ .filter((node) => node.communityId === community.id && node.pinHint.pinned)
1646
+ .map((node) => node.pinHint),
1647
+ aggregationIds: [],
1648
+ drawerTarget: {
1649
+ summaryKind: "community-summary",
1650
+ object: { kind: "community", communityId: community.id }
1651
+ },
1652
+ commands: [{ kind: "enter-community", communityId: community.id, label: "进入社区" }]
1653
+ })),
1654
+ aggregations: [],
1655
+ renderable: {
1656
+ nodes: [],
1657
+ edges: [],
1658
+ communities: renderableCommunities,
1659
+ aggregationContainers: [],
1660
+ minimap: { path: "", nodes: [] },
1661
+ relationLegend: [],
1662
+ selectedNodeId: selectedNodeIds[0] ?? null,
1663
+ selectedCommunityId,
1664
+ selectedNodeIds,
1665
+ hiddenNodeIds: new Set(),
1666
+ searchResultIds,
1667
+ worldBounds: { minX: 0, maxX: 200, minY: 0, maxY: 200 },
1668
+ budgets: {
1669
+ limits: {
1670
+ maxNodes: nodes.length,
1671
+ maxEdges: 0,
1672
+ maxLabels: 0,
1673
+ maxCards: 0,
1674
+ maxInteractionUpdates: nodes.length,
1675
+ maxVisibleCommunities: 2
1676
+ },
1677
+ usage: {
1678
+ nodes: nodes.length,
1679
+ edges: 0,
1680
+ labels: 0,
1681
+ cards: 0,
1682
+ interactionUpdate: nodes.length,
1683
+ activeInteraction: nodes.length,
1684
+ communities: 2,
1685
+ aggregationContainers: 0
1686
+ }
1687
+ },
1688
+ qualityNotice: null,
1689
+ communityFocus: null,
1690
+ communityQuality: {
1691
+ boundaryCertainty: "high",
1692
+ skeletonLabel: "stable",
1693
+ hiddenNodeCount: 0,
1694
+ hiddenEdgeCount: 0,
1695
+ stableCoreNodeIds: [],
1696
+ stableSkeletonEdgeIds: [],
1697
+ temporaryBoostNodeIds: []
1698
+ }
1699
+ }
1700
+ };
1701
+
1702
+ }
1703
+
1704
+ function spotlightNodeFixture(
1705
+ id: string,
1706
+ communityId: string,
1707
+ options: {
1708
+ point: { x: number; y: number };
1709
+ selected?: boolean;
1710
+ searchHit?: boolean;
1711
+ pinned?: boolean;
1712
+ }
1713
+ ): GraphRendererAdapterData["nodes"][number] {
1714
+ return {
1715
+ id,
1716
+ object: { kind: "node", nodeId: id },
1717
+ label: id,
1718
+ type: "topic",
1719
+ communityId,
1720
+ sourcePath: `spotlight/${id}.md`,
1721
+ point: options.point,
1722
+ selected: Boolean(options.selected),
1723
+ searchHit: Boolean(options.searchHit),
1724
+ pinHint: {
1725
+ nodeId: id,
1726
+ wikiPath: `spotlight/${id}.md`,
1727
+ pinned: Boolean(options.pinned),
1728
+ position: options.pinned ? { x: options.point.x, y: options.point.y, coordinateSpace: "world" } : null
1729
+ },
1730
+ aggregationIds: [],
1731
+ drawerTarget: {
1732
+ summaryKind: "node-summary",
1733
+ object: { kind: "node", nodeId: id }
1734
+ },
1735
+ render: {
1736
+ displayMode: "point",
1737
+ visualRole: "map-pin",
1738
+ priority: 10,
1739
+ labelVisible: false
1740
+ }
1741
+ };
1742
+ }
1743
+
1744
+ function sigmaEdgeFixture(
1745
+ overrides: Partial<GraphRendererAdapterData["edges"][number]> = {}
1746
+ ): GraphRendererAdapterData["edges"][number] {
1747
+ return {
1748
+ id: "style-edge",
1749
+ sourceNodeId: "style-source",
1750
+ targetNodeId: "style-target",
1751
+ sourceCommunityId: "c1",
1752
+ targetCommunityId: "c1",
1753
+ relationType: "依赖",
1754
+ confidence: "EXTRACTED",
1755
+ weight: 0,
1756
+ render: {
1757
+ strokeWidth: 1,
1758
+ opacity: 1
1759
+ },
1760
+ ...overrides
1761
+ };
1762
+ }
1763
+
1764
+ function edgeStyleAlpha(color: string): number {
1765
+ const match = color.match(/,\s*([0-9.]+)\)$/);
1766
+ return match ? Number(match[1]) : Number.NaN;
1767
+ }
1768
+
1769
+ function adapterDataWithPolygonCommunityCloud(): GraphRendererAdapterData {
1770
+ const data = adapterDataFixture({ betaPinned: false });
1771
+ const thirdNode: GraphRendererAdapterData["nodes"][number] = {
1772
+ id: "render-gamma",
1773
+ object: { kind: "node", nodeId: "render-gamma" },
1774
+ label: "Adapter Gamma",
1775
+ type: "entity",
1776
+ communityId: "adapter-community",
1777
+ sourcePath: "adapter/gamma.md",
1778
+ point: { x: 180, y: 420 },
1779
+ selected: false,
1780
+ searchHit: false,
1781
+ pinHint: {
1782
+ nodeId: "render-gamma",
1783
+ wikiPath: "adapter/gamma.md",
1784
+ pinned: false,
1785
+ position: null
1786
+ },
1787
+ aggregationIds: [],
1788
+ drawerTarget: {
1789
+ summaryKind: "node-summary",
1790
+ object: { kind: "node", nodeId: "render-gamma" }
1791
+ },
1792
+ render: {
1793
+ displayMode: "point",
1794
+ visualRole: "map-pin",
1795
+ priority: 50,
1796
+ labelVisible: false
1797
+ }
1798
+ };
1799
+
1800
+ return {
1801
+ ...data,
1802
+ counts: { ...data.counts, nodes: 3, renderedNodes: 3 },
1803
+ nodes: [...data.nodes, thirdNode],
1804
+ communities: data.communities.map((community) => community.id === "adapter-community"
1805
+ ? {
1806
+ ...community,
1807
+ nodeIds: [...community.nodeIds, thirdNode.id],
1808
+ nodeCount: community.nodeCount + 1
1809
+ }
1810
+ : community)
1811
+ };
1812
+ }
1813
+
1814
+ function adapterDataWithPolygonCommunityOutlier(): GraphRendererAdapterData {
1815
+ const data = adapterDataWithPolygonCommunityCloud();
1816
+ const outlierNode: GraphRendererAdapterData["nodes"][number] = {
1817
+ id: "render-outlier",
1818
+ object: { kind: "node", nodeId: "render-outlier" },
1819
+ label: "Adapter Outlier",
1820
+ type: "entity",
1821
+ communityId: "adapter-community",
1822
+ sourcePath: "adapter/outlier.md",
1823
+ point: { x: 1200, y: 1200 },
1824
+ selected: false,
1825
+ searchHit: false,
1826
+ pinHint: {
1827
+ nodeId: "render-outlier",
1828
+ wikiPath: "adapter/outlier.md",
1829
+ pinned: false,
1830
+ position: null
1831
+ },
1832
+ aggregationIds: [],
1833
+ drawerTarget: {
1834
+ summaryKind: "node-summary",
1835
+ object: { kind: "node", nodeId: "render-outlier" }
1836
+ },
1837
+ render: {
1838
+ displayMode: "point",
1839
+ visualRole: "map-pin",
1840
+ priority: 1,
1841
+ labelVisible: false
1842
+ }
1843
+ };
1844
+
1845
+ return {
1846
+ ...data,
1847
+ counts: { ...data.counts, nodes: 4, renderedNodes: 4 },
1848
+ nodes: [...data.nodes, outlierNode],
1849
+ communities: data.communities.map((community) => community.id === "adapter-community"
1850
+ ? {
1851
+ ...community,
1852
+ nodeIds: [...community.nodeIds, outlierNode.id],
1853
+ nodeCount: community.nodeCount + 1
1854
+ }
1855
+ : community)
1856
+ };
1857
+ }
1858
+
1859
+ function sigmaCommunityCloudShape(renderer: { overlayRoot: HTMLElement & { children: HTMLElement[] } }, communityId: string): HTMLElement | undefined {
1860
+ const region = renderer.overlayRoot.children.find((child) => child.dataset.communityId === communityId);
1861
+ const svg = region?.children[0] as HTMLElement | undefined;
1862
+ return svg?.children[0] as HTMLElement | undefined;
1863
+ }
1864
+
1865
+ function sigmaCommunityRegion(renderer: { overlayRoot: HTMLElement & { children: HTMLElement[] } }, communityId: string): HTMLElement | undefined {
1866
+ return renderer.overlayRoot.children.find((child) => child.dataset.communityId === communityId);
1867
+ }
1868
+
1869
+ function densePointMapGraph(): GraphData {
1870
+ const nodeCount = 2000;
1871
+ const edgeTarget = 3996;
1872
+ const communityCount = 16;
1873
+ const nodes = Array.from({ length: nodeCount }, (_, index) => ({
1874
+ id: `dense-${index}`,
1875
+ label: `Dense node ${index}`,
1876
+ type: index % 17 === 0 ? "topic" : index % 29 === 0 ? "source" : "entity",
1877
+ community: `dense-community-${index % communityCount}`,
1878
+ source_path: `wiki/dense/dense-${index}.md`,
1879
+ weight: 100 - (index % 97),
1880
+ x: (index * 37) % 100,
1881
+ y: (index * 53) % 100
1882
+ }));
1883
+ const edges: NonNullable<GraphData["edges"]> = [
1884
+ {
1885
+ id: "dense-selected-weak",
1886
+ from: "dense-1999",
1887
+ to: "dense-1",
1888
+ type: "INFERRED",
1889
+ confidence: "INFERRED",
1890
+ relation_type: "依赖",
1891
+ weight: 0
1892
+ },
1893
+ {
1894
+ id: "dense-selected-strong",
1895
+ from: "dense-1999",
1896
+ to: "dense-2",
1897
+ type: "EXTRACTED",
1898
+ confidence: "EXTRACTED",
1899
+ relation_type: "实现",
1900
+ weight: 1
1901
+ }
1902
+ ];
1903
+
1904
+ for (let index = 0; edges.length < edgeTarget; index += 1) {
1905
+ const source = index % nodeCount;
1906
+ const target = (source + 1 + (index % 113)) % nodeCount;
1907
+ if (source === target) continue;
1908
+ edges.push({
1909
+ id: `dense-edge-${index}`,
1910
+ from: `dense-${source}`,
1911
+ to: `dense-${target}`,
1912
+ type: index % 5 === 0 ? "INFERRED" : "EXTRACTED",
1913
+ confidence: index % 5 === 0 ? "INFERRED" : "EXTRACTED",
1914
+ relation_type: index % 7 === 0 ? "对比" : "依赖",
1915
+ weight: (index % 11) / 10
1916
+ });
1917
+ }
1918
+
1919
+ return {
1920
+ meta: {
1921
+ build_date: "2026-06-21T00:00:00.000Z",
1922
+ wiki_title: "Dense Point Map Fixture",
1923
+ total_nodes: nodes.length,
1924
+ total_edges: edges.length
1925
+ },
1926
+ nodes,
1927
+ edges,
1928
+ learning: {
1929
+ version: 1,
1930
+ entry: { recommended_start_node_id: "dense-0", recommended_start_reason: "dense_fixture", default_mode: "global" },
1931
+ views: {
1932
+ path: { enabled: false, start_node_id: null, node_ids: [], degraded: true },
1933
+ community: { enabled: false, community_id: null, label: null, node_ids: [], is_weak: false, degraded: true },
1934
+ global: { enabled: true, node_ids: nodes.map((node) => node.id), degraded: false }
1935
+ },
1936
+ communities: Array.from({ length: communityCount }, (_, index) => ({
1937
+ id: `dense-community-${index}`,
1938
+ label: `Dense Community ${index}`,
1939
+ node_count: nodes.filter((node) => node.community === `dense-community-${index}`).length,
1940
+ color_index: index,
1941
+ recommended_start_node_id: index === 0 ? "dense-0" : null
1942
+ }))
1943
+ }
1944
+ };
1945
+ }
1946
+
1947
+ function renderableCommunityFixture(count: number): GraphRendererAdapterData["renderable"]["communities"] {
1948
+ if (count <= 1) {
1949
+ return [
1950
+ {
1951
+ id: "adapter-community",
1952
+ label: "Adapter Community",
1953
+ color: "#123456",
1954
+ nodeCount: 2,
1955
+ boundaryCertainty: "high",
1956
+ wash: { cx: 250, cy: 250, rx: 80, ry: 60, opacity: 0.2 }
1957
+ }
1958
+ ];
1959
+ }
1960
+
1961
+ return Array.from({ length: count }, (_, index) => {
1962
+ const communityNumber = index + 1;
1963
+ return {
1964
+ id: `community-${communityNumber}`,
1965
+ label: `Community ${communityNumber}`,
1966
+ color: `#1234${String(index).padStart(2, "0")}`,
1967
+ nodeCount: communityNumber,
1968
+ boundaryCertainty: "high",
1969
+ wash: { cx: 80 + index * 30, cy: 120 + index * 20, rx: 35 + index, ry: 24 + index, opacity: 0.2 }
1970
+ };
1971
+ });
1972
+ }
1973
+
1974
+ type FakeDefaultView = Partial<Pick<Window, "ResizeObserver" | "requestAnimationFrame" | "cancelAnimationFrame">> & {
1975
+ matchMedia?: Window["matchMedia"];
1976
+ };
1977
+
1978
+ function fakeContainer(defaultView?: FakeDefaultView): HTMLElement & { children: HTMLElement[] } {
1979
+ const children: HTMLElement[] = [];
1980
+ const container = {
1981
+ ownerDocument: {
1982
+ createElement: (tagName: string) => fakeElement(tagName, defaultView),
1983
+ createElementNS: (_ns: string, tagName: string) => fakeElement(tagName, defaultView),
1984
+ defaultView
1985
+ },
1986
+ append: (child: HTMLElement) => {
1987
+ children.push(child);
1988
+ },
1989
+ children
1990
+ } as unknown as HTMLElement & { children: HTMLElement[] };
1991
+ containerRegistry.push(container);
1992
+ return container;
1993
+ }
1994
+
1995
+ function resizeObserverEntry(width: number, height: number): ResizeObserverEntry {
1996
+ return { contentRect: { width, height } as DOMRectReadOnly } as ResizeObserverEntry;
1997
+ }
1998
+
1999
+ function fakeElement(_tagName: string, defaultView?: FakeDefaultView): HTMLElement {
2000
+ const children: HTMLElement[] = [];
2001
+ const attributes = new Map<string, string>();
2002
+ const listeners = new Map<string, EventListenerOrEventListenerObject[]>();
2003
+ const element = {
2004
+ tagName: _tagName,
2005
+ className: "",
2006
+ dataset: {} as Record<string, string>,
2007
+ style: {} as Record<string, string>,
2008
+ children,
2009
+ tabIndex: -1,
2010
+ textContent: "",
2011
+ ownerDocument: null as unknown as Document,
2012
+ append: (...items: HTMLElement[]) => {
2013
+ children.push(...items);
2014
+ },
2015
+ prepend: (...items: HTMLElement[]) => {
2016
+ children.unshift(...items);
2017
+ },
2018
+ replaceChildren: (...items: HTMLElement[]) => {
2019
+ children.splice(0, children.length, ...items);
2020
+ },
2021
+ addEventListener: (type: string, listener: EventListenerOrEventListenerObject) => {
2022
+ const list = listeners.get(type) ?? [];
2023
+ list.push(listener);
2024
+ listeners.set(type, list);
2025
+ },
2026
+ dispatchEvent: (event: Event) => {
2027
+ for (const listener of listeners.get(event.type) ?? []) {
2028
+ if (typeof listener === "function") listener.call(element, event);
2029
+ else listener.handleEvent(event);
2030
+ }
2031
+ return true;
2032
+ },
2033
+ setAttribute: (name: string, value: string) => {
2034
+ attributes.set(name, String(value));
2035
+ },
2036
+ getAttribute: (name: string) => attributes.get(name) ?? null,
2037
+ querySelector: () => null,
2038
+ remove: () => undefined
2039
+ };
2040
+ element.ownerDocument = {
2041
+ createElement: (tagName: string) => {
2042
+ const child = fakeElement(tagName, defaultView);
2043
+ child.ownerDocument = element.ownerDocument;
2044
+ return child;
2045
+ },
2046
+ createElementNS: (_ns: string, tagName: string) => {
2047
+ const child = fakeElement(tagName, defaultView);
2048
+ child.ownerDocument = element.ownerDocument;
2049
+ return child;
2050
+ },
2051
+ defaultView
2052
+ } as unknown as Document;
2053
+ element.remove = () => {
2054
+ // The fake container owns removal by filtering on object identity below.
2055
+ for (const container of fakeContainersWith(element as unknown as HTMLElement)) {
2056
+ const index = container.children.indexOf(element as unknown as HTMLElement);
2057
+ if (index >= 0) container.children.splice(index, 1);
2058
+ }
2059
+ };
2060
+ return element as unknown as HTMLElement;
2061
+ }
2062
+
2063
+ const containerRegistry: Array<HTMLElement & { children: HTMLElement[] }> = [];
2064
+
2065
+ function fakeContainersWith(child: HTMLElement): Array<HTMLElement & { children: HTMLElement[] }> {
2066
+ return containerRegistry.filter((container) => container.children.includes(child));
2067
+ }
2068
+
2069
+ function fakeRuntime(options: {
2070
+ constructError?: Error;
2071
+ setGraphError?: Error;
2072
+ killError?: Error;
2073
+ worldScale?: number;
2074
+ } = {}): SigmaGlobalRendererRuntime & { instances: FakeSigma[] } {
2075
+ const instances: FakeSigma[] = [];
2076
+ class RuntimeSigma extends FakeSigma {
2077
+ constructor(graph: SigmaGlobalGraphologyGraph, container: HTMLElement, settings?: Record<string, unknown>) {
2078
+ if (options.constructError) throw options.constructError;
2079
+ super(graph, container, settings, options);
2080
+ instances.push(this);
2081
+ }
2082
+ }
2083
+ return {
2084
+ Sigma: RuntimeSigma,
2085
+ GraphologyGraph,
2086
+ instances
2087
+ };
2088
+ }
2089
+
2090
+ function sigmaEventPayload(node: string | null, x: number, y: number): {
2091
+ node?: string;
2092
+ event: { x: number; y: number };
2093
+ prevented: boolean;
2094
+ preventSigmaDefault: () => void;
2095
+ } {
2096
+ const payload = {
2097
+ ...(node ? { node } : {}),
2098
+ event: { x, y },
2099
+ prevented: false,
2100
+ preventSigmaDefault: () => {
2101
+ payload.prevented = true;
2102
+ }
2103
+ };
2104
+ return payload;
2105
+ }
2106
+
2107
+ class FakeSigma implements SigmaGlobalSigmaLike {
2108
+ graph: SigmaGlobalGraphologyGraph;
2109
+ readonly container: HTMLElement;
2110
+ readonly settings: Record<string, unknown>;
2111
+ readonly camera = new FakeCamera();
2112
+ readonly listeners = new Map<string, Set<(payload?: unknown) => void>>();
2113
+ readonly setGraphCalls: SigmaGlobalGraphologyGraph[] = [];
2114
+ killed = false;
2115
+
2116
+ constructor(
2117
+ graph: SigmaGlobalGraphologyGraph,
2118
+ container: HTMLElement,
2119
+ settings: Record<string, unknown> = {},
2120
+ private readonly options: { setGraphError?: Error; killError?: Error; worldScale?: number } = {}
2121
+ ) {
2122
+ this.graph = graph;
2123
+ this.container = container;
2124
+ this.settings = settings;
2125
+ }
2126
+
2127
+ getCamera(): FakeCamera {
2128
+ return this.camera;
2129
+ }
2130
+
2131
+ getGraph(): SigmaGlobalGraphologyGraph {
2132
+ return this.graph;
2133
+ }
2134
+
2135
+ setGraph(graph: SigmaGlobalGraphologyGraph): void {
2136
+ if (this.options.setGraphError) throw this.options.setGraphError;
2137
+ this.graph = graph;
2138
+ this.setGraphCalls.push(graph);
2139
+ }
2140
+
2141
+ setSetting(key: string, value: unknown): void {
2142
+ this.settings[key] = value;
2143
+ }
2144
+
2145
+ refresh(): void {
2146
+ this.settings.refreshed = true;
2147
+ }
2148
+
2149
+ viewportToGraph(point: { x: number; y: number }): { x: number; y: number } {
2150
+ const scale = this.options.worldScale ?? 1;
2151
+ return { x: point.x * scale, y: point.y * scale };
2152
+ }
2153
+
2154
+ viewportToFramedGraph(point: { x: number; y: number }): { x: number; y: number } {
2155
+ return { x: point.x, y: point.y };
2156
+ }
2157
+
2158
+ graphToViewport(point: { x: number; y: number }): { x: number; y: number } {
2159
+ const scale = this.options.worldScale ?? 1;
2160
+ return { x: point.x / scale, y: point.y / scale };
2161
+ }
2162
+
2163
+ on(event: string, listener: (payload?: unknown) => void): void {
2164
+ const listeners = this.listeners.get(event) ?? new Set();
2165
+ listeners.add(listener);
2166
+ this.listeners.set(event, listeners);
2167
+ }
2168
+
2169
+ off(event: string, listener: (payload?: unknown) => void): void {
2170
+ this.listeners.get(event)?.delete(listener);
2171
+ }
2172
+
2173
+ emit(event: string, payload?: unknown): void {
2174
+ for (const listener of this.listeners.get(event) ?? []) listener(payload);
2175
+ }
2176
+
2177
+ kill(): void {
2178
+ this.killed = true;
2179
+ if (this.options.killError) throw this.options.killError;
2180
+ }
2181
+ }
2182
+
2183
+ class FakeCamera {
2184
+ private state = { x: 0, y: 0, angle: 0, ratio: 1 };
2185
+ readonly setStateCalls: Array<Partial<{ x: number; y: number; angle: number; ratio: number }>> = [];
2186
+ readonly animateCalls: Array<{
2187
+ state: Partial<{ x: number; y: number; angle: number; ratio: number }>;
2188
+ options?: { duration?: number; easing?: string };
2189
+ }> = [];
2190
+ activeAnimationTarget: Partial<{ x: number; y: number; angle: number; ratio: number }> | null = null;
2191
+
2192
+ getState(): { x: number; y: number; angle: number; ratio: number } {
2193
+ return { ...this.state };
2194
+ }
2195
+
2196
+ setState(state: Partial<{ x: number; y: number; angle: number; ratio: number }>): void {
2197
+ this.setStateCalls.push({ ...state });
2198
+ this.state = { ...this.state, ...state };
2199
+ }
2200
+
2201
+ animate(
2202
+ state: Partial<{ x: number; y: number; angle: number; ratio: number }>,
2203
+ options?: { duration?: number; easing?: string }
2204
+ ): Promise<void> {
2205
+ this.animateCalls.push({ state: { ...state }, options: options ? { ...options } : undefined });
2206
+ this.activeAnimationTarget = { ...state };
2207
+ this.setState(state);
2208
+ return Promise.resolve();
2209
+ }
2210
+ }