@joekytc/dsh-swarm 0.1.2 → 0.3.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 (603) hide show
  1. package/README.md +177 -140
  2. package/README.zh-CN.md +173 -126
  3. package/client/BoardCard.tsx +24 -2
  4. package/client/ConfigSection.tsx +162 -0
  5. package/client/ConfigSelect.tsx +71 -0
  6. package/client/KanbanBoard.tsx +3 -0
  7. package/client/KanbanTab.tsx +4 -3
  8. package/client/TaskDrawer.tsx +4 -26
  9. package/client/WorkflowRail.tsx +3 -1
  10. package/client/config-store.ts +92 -0
  11. package/client/config.css +110 -0
  12. package/client/index.ts +39 -4
  13. package/client/kanban.css +88 -2
  14. package/client/session-bridge.ts +39 -0
  15. package/client/timeline-model.ts +12 -1
  16. package/client/workflow-model.ts +3 -1
  17. package/lib/client.js +519 -56
  18. package/lib/config.d.ts +26 -2
  19. package/lib/config.js +20 -1
  20. package/lib/dispatcher/agent-runner.d.ts +37 -7
  21. package/lib/dispatcher/agent-runner.js +239 -86
  22. package/lib/dispatcher/chain-auditor.d.ts +4 -4
  23. package/lib/dispatcher/chain-auditor.js +14 -9
  24. package/lib/dispatcher/dispatcher.d.ts +69 -10
  25. package/lib/dispatcher/dispatcher.js +281 -42
  26. package/lib/dispatcher/event-waker.d.ts +1 -1
  27. package/lib/dispatcher/event-waker.js +2 -2
  28. package/lib/dispatcher/git-credentials.d.ts +2 -2
  29. package/lib/dispatcher/git-credentials.js +2 -2
  30. package/lib/dispatcher/model-candidates.d.ts +1 -1
  31. package/lib/dispatcher/model-candidates.js +1 -1
  32. package/lib/dispatcher/session-events.d.ts +12 -16
  33. package/lib/dispatcher/session-events.js +18 -6
  34. package/lib/dispatcher/target-repo.d.ts +2 -2
  35. package/lib/dispatcher/target-repo.js +3 -3
  36. package/lib/dispatcher/v-orchestrator.d.ts +44 -11
  37. package/lib/dispatcher/v-orchestrator.js +257 -49
  38. package/lib/dispatcher/watchdog.d.ts +1 -1
  39. package/lib/dispatcher/watchdog.js +2 -2
  40. package/lib/domain/config-override.d.ts +52 -0
  41. package/lib/domain/config-override.js +138 -0
  42. package/lib/domain/delivery-contract.d.ts +4 -3
  43. package/lib/domain/delivery-contract.js +30 -18
  44. package/lib/domain/delivery-evidence.d.ts +1 -1
  45. package/lib/domain/delivery-evidence.js +1 -1
  46. package/lib/domain/event-store.js +1 -1
  47. package/lib/domain/gate-policy.d.ts +26 -0
  48. package/lib/domain/gate-policy.js +44 -0
  49. package/lib/domain/im-message.d.ts +15 -0
  50. package/lib/domain/im-message.js +149 -0
  51. package/lib/domain/kanban-service.d.ts +28 -12
  52. package/lib/domain/kanban-service.js +73 -30
  53. package/lib/domain/memory.js +1 -1
  54. package/lib/domain/ocr-review.d.ts +47 -0
  55. package/lib/domain/ocr-review.js +105 -0
  56. package/lib/domain/permissions.js +6 -6
  57. package/lib/domain/planning-checklist.d.ts +5 -0
  58. package/lib/domain/planning-checklist.js +80 -6
  59. package/lib/domain/projection.js +8 -7
  60. package/lib/domain/review-evidence.js +1 -1
  61. package/lib/domain/state-machine.js +3 -2
  62. package/lib/domain/task-parents.js +1 -1
  63. package/lib/domain/types.d.ts +5 -5
  64. package/lib/index.js +28 -25
  65. package/lib/roles/clean-fs-tools.d.ts +22 -0
  66. package/lib/roles/clean-fs-tools.js +117 -0
  67. package/lib/roles/preset-installer.js +3 -3
  68. package/lib/roles/skill-installer.d.ts +6 -0
  69. package/lib/roles/skill-installer.js +32 -0
  70. package/lib/roles/toolsets.d.ts +71 -15
  71. package/lib/roles/toolsets.js +418 -68
  72. package/lib/roles/wiki-worker.d.ts +1 -0
  73. package/lib/roles/wiki-worker.js +12 -4
  74. package/lib/routes/kanban-http.d.ts +28 -2
  75. package/lib/routes/kanban-http.js +199 -6
  76. package/lib/routes/kanban-sse.d.ts +1 -1
  77. package/lib/routes/kanban-sse.js +1 -1
  78. package/lib/routes/planning-driver.d.ts +6 -2
  79. package/lib/routes/planning-driver.js +15 -7
  80. package/lib/routes/prefix-router.d.ts +19 -3
  81. package/lib/routes/prefix-router.js +40 -3
  82. package/lib/services/config-provider.d.ts +38 -0
  83. package/lib/services/config-provider.js +92 -0
  84. package/lib/services/gate-runner.d.ts +24 -0
  85. package/lib/services/gate-runner.js +87 -0
  86. package/lib/services/im-delivery.d.ts +94 -0
  87. package/lib/services/im-delivery.js +263 -0
  88. package/lib/services/kanban-provider.d.ts +6 -2
  89. package/lib/services/kanban-provider.js +41 -3
  90. package/lib/services/llm-catalog.d.ts +35 -0
  91. package/lib/services/llm-catalog.js +19 -0
  92. package/lib/services/ocr-cli.d.ts +35 -0
  93. package/lib/services/ocr-cli.js +128 -0
  94. package/lib/tools/kanban-tools.d.ts +2 -2
  95. package/lib/tools/kanban-tools.js +2 -1
  96. package/lib/tools/main-session-tools.d.ts +22 -3
  97. package/lib/tools/main-session-tools.js +135 -30
  98. package/lib/tools/ocr-review-tools.d.ts +11 -0
  99. package/lib/tools/ocr-review-tools.js +63 -0
  100. package/lib/tools/planning-tools.d.ts +8 -1
  101. package/lib/tools/planning-tools.js +44 -15
  102. package/lib/tools/prefetch-tools.js +1 -0
  103. package/lib/tools/spec-card-tools.js +1 -0
  104. package/lib/tools/wiki-tools.js +6 -5
  105. package/lib/wiki/kb-linkage.d.ts +9 -2
  106. package/lib/wiki/kb-linkage.js +3 -3
  107. package/lib/wiki/local-kb-client.d.ts +14 -0
  108. package/lib/wiki/local-kb-client.js +101 -0
  109. package/lib/wiki/local-kb.d.ts +6 -0
  110. package/lib/wiki/local-kb.js +25 -0
  111. package/lib/wiki/memory-recall.d.ts +14 -6
  112. package/lib/wiki/memory-recall.js +17 -13
  113. package/lib/wiki/page-path.d.ts +9 -3
  114. package/lib/wiki/page-path.js +33 -12
  115. package/lib/wiki/wiki-vault-client.d.ts +3 -3
  116. package/lib/wiki/wiki-vault-client.js +6 -6
  117. package/package.json +16 -11
  118. package/personas/kanban-d/agent.cordis.yml +5 -5
  119. package/personas/kanban-d/preset.yml +1 -1
  120. package/personas/kanban-dt/agent.cordis.yml +25 -7
  121. package/personas/kanban-dt/preset.yml +1 -1
  122. package/personas/kanban-p/agent.cordis.yml +19 -3
  123. package/personas/kanban-p/preset.yml +1 -1
  124. package/personas/kanban-pt/agent.cordis.yml +39 -9
  125. package/personas/kanban-pt/preset.yml +1 -1
  126. package/personas/kanban-v/agent.cordis.yml +3 -3
  127. package/personas/kanban-w/agent.cordis.yml +37 -18
  128. package/personas/kanban-w/preset.yml +1 -1
  129. package/personas/persona-d.md +1 -1
  130. package/personas/persona-dt.md +13 -5
  131. package/personas/persona-p.md +5 -2
  132. package/personas/persona-pt.md +13 -6
  133. package/personas/persona-v.md +2 -2
  134. package/personas/persona-w.md +11 -9
  135. package/personas/swarm/agent.cordis.yml +43 -0
  136. package/personas/swarm/preset.yml +5 -0
  137. package/skills/grill-me/SKILL.md +71 -0
  138. package/skills/llm-wiki-skill/.mise.toml +2 -0
  139. package/skills/llm-wiki-skill/.nvmrc +1 -0
  140. package/skills/llm-wiki-skill/AGENTS.md +173 -0
  141. package/skills/llm-wiki-skill/CHANGELOG.md +548 -0
  142. package/skills/llm-wiki-skill/CLAUDE.md +152 -0
  143. package/skills/llm-wiki-skill/HERMES.md +44 -0
  144. package/skills/llm-wiki-skill/README.en.md +261 -0
  145. package/skills/llm-wiki-skill/README.md +291 -0
  146. package/skills/llm-wiki-skill/SKILL.md +1133 -0
  147. package/skills/llm-wiki-skill/assets/graph-demo.gif +0 -0
  148. package/skills/llm-wiki-skill/assets/graph-preview.png +0 -0
  149. package/skills/llm-wiki-skill/deps/LICENSE-d3.txt +13 -0
  150. package/skills/llm-wiki-skill/deps/LICENSE-marked.txt +44 -0
  151. package/skills/llm-wiki-skill/deps/LICENSE-purify.txt +568 -0
  152. package/skills/llm-wiki-skill/deps/LICENSE-roughjs.txt +21 -0
  153. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/SKILL.md +261 -0
  154. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/references/config/first-time-setup.md +106 -0
  155. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/cdp.ts +179 -0
  156. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/constants.ts +13 -0
  157. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/defuddle-converter.ts +58 -0
  158. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/html-to-markdown.ts +135 -0
  159. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/legacy-converter.ts +629 -0
  160. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/main.ts +314 -0
  161. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/markdown-conversion-shared.ts +305 -0
  162. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/media-localizer.ts +317 -0
  163. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/package.json +14 -0
  164. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/paths.ts +29 -0
  165. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/vendor/baoyu-chrome-cdp/package.json +9 -0
  166. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/vendor/baoyu-chrome-cdp/src/index.test.ts +307 -0
  167. package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/vendor/baoyu-chrome-cdp/src/index.ts +523 -0
  168. package/skills/llm-wiki-skill/deps/d3.min.js +2 -0
  169. package/skills/llm-wiki-skill/deps/marked.min.js +6 -0
  170. package/skills/llm-wiki-skill/deps/purify.min.js +3 -0
  171. package/skills/llm-wiki-skill/deps/rough.min.js +7 -0
  172. package/skills/llm-wiki-skill/deps/youtube-transcript/SKILL.md +47 -0
  173. package/skills/llm-wiki-skill/deps/youtube-transcript/scripts/get_transcript.py +72 -0
  174. package/skills/llm-wiki-skill/designs/graph-edge-legibility/graph-edge-treatments.html +480 -0
  175. package/skills/llm-wiki-skill/docs/design/oriental-atlas/DESIGN.md +183 -0
  176. package/skills/llm-wiki-skill/docs/design/oriental-atlas/README.md +10 -0
  177. package/skills/llm-wiki-skill/docs/design/oriental-atlas/design-brief.md +170 -0
  178. package/skills/llm-wiki-skill/docs/design/oriental-atlas/oriental-editorial-atlas.html +1908 -0
  179. package/skills/llm-wiki-skill/docs/design/oriental-atlas/reviews/result-review.md +68 -0
  180. package/skills/llm-wiki-skill/docs/graph/2026-06-16-interaction-risk-audit.md +88 -0
  181. package/skills/llm-wiki-skill/docs/graph/2026-06-16-interaction-test-coverage-map.md +212 -0
  182. package/skills/llm-wiki-skill/docs/graph/performance/2026-06-18-phase-0-2-baseline.md +86 -0
  183. package/skills/llm-wiki-skill/docs/graph/performance/2026-06-18-phase-1-3-dom-svg-large-baseline.md +85 -0
  184. package/skills/llm-wiki-skill/docs/graph/performance/2026-06-18-phase-1-4-disposable-validation-gate.md +97 -0
  185. package/skills/llm-wiki-skill/docs/graph/performance/2026-06-18-phase-2-4-global-renderer-trial-matrix.md +168 -0
  186. package/skills/llm-wiki-skill/docs/graph/performance/2026-06-19-phase-6-1-sigma-graphology-trial.md +71 -0
  187. package/skills/llm-wiki-skill/docs/graph/performance/2026-06-19-phase-6-2-vis-network-trial.md +78 -0
  188. package/skills/llm-wiki-skill/docs/graph/performance/2026-06-19-phase-6-3-aggregation-fallback-trial.md +72 -0
  189. package/skills/llm-wiki-skill/docs/graph/performance/2026-06-19-phase-6-4-global-renderer-route-decision.md +94 -0
  190. package/skills/llm-wiki-skill/docs/graph/performance/2026-06-19-sigma-global-production-integration-result.md +102 -0
  191. package/skills/llm-wiki-skill/docs/graph/performance/artifacts/2026-06-18-phase-0-2/stage-4.5-offline-dense-wheel.json +9 -0
  192. package/skills/llm-wiki-skill/docs/graph/performance/artifacts/2026-06-18-phase-0-2/stage-4.5-offline-dense-wheel.png +0 -0
  193. package/skills/llm-wiki-skill/docs/graph/performance/artifacts/2026-06-18-phase-0-2/stage-4.5-offline-navigation.png +0 -0
  194. package/skills/llm-wiki-skill/docs/spark/2026-06-15-omp-tool-status-events-design.md +174 -0
  195. package/skills/llm-wiki-skill/docs/spark/2026-06-16-graph-interaction-geometry-design.md +832 -0
  196. package/skills/llm-wiki-skill/docs/spark/2026-06-16-graph-six-layer-architecture-design.md +577 -0
  197. package/skills/llm-wiki-skill/docs/spark/2026-06-17-static-renderer-coordination-split-design.md +172 -0
  198. package/skills/llm-wiki-skill/docs/spark/2026-06-18-large-graph-global-community-design.md +909 -0
  199. package/skills/llm-wiki-skill/docs/spark/2026-06-19-sigma-global-graph-renderer-design.md +360 -0
  200. package/skills/llm-wiki-skill/docs/spark/2026-06-20-paper-ui-port-design.md +162 -0
  201. package/skills/llm-wiki-skill/docs/spark/2026-06-20-paper-ui-v2-shell-alignment-design.md +384 -0
  202. package/skills/llm-wiki-skill/docs/spark/2026-06-21-graph-experience-completion-design.md +534 -0
  203. package/skills/llm-wiki-skill/docs/spark/2026-06-22-chat-auto-scroll-design.md +185 -0
  204. package/skills/llm-wiki-skill/docs/spark/2026-06-22-graph-community-node-visual-design.md +266 -0
  205. package/skills/llm-wiki-skill/docs/spark/2026-06-25-sigma-overlay-refactor-perf-design.md +170 -0
  206. package/skills/llm-wiki-skill/docs/spark/2026-06-26-global-sigma-community-spotlight-design.md +393 -0
  207. package/skills/llm-wiki-skill/docs/spark/mockups/2026-06-18-large-graph-global-community-flow.html +746 -0
  208. package/skills/llm-wiki-skill/install.ps1 +87 -0
  209. package/skills/llm-wiki-skill/install.sh +722 -0
  210. package/skills/llm-wiki-skill/package-lock.json +11171 -0
  211. package/skills/llm-wiki-skill/package.json +24 -0
  212. package/skills/llm-wiki-skill/packages/graph-engine/package.json +37 -0
  213. package/skills/llm-wiki-skill/packages/graph-engine/src/anim/.gitkeep +1 -0
  214. package/skills/llm-wiki-skill/packages/graph-engine/src/anim/index.ts +179 -0
  215. package/skills/llm-wiki-skill/packages/graph-engine/src/architecture.ts +79 -0
  216. package/skills/llm-wiki-skill/packages/graph-engine/src/diff.ts +121 -0
  217. package/skills/llm-wiki-skill/packages/graph-engine/src/facade.ts +1406 -0
  218. package/skills/llm-wiki-skill/packages/graph-engine/src/graph-node.ts +37 -0
  219. package/skills/llm-wiki-skill/packages/graph-engine/src/index.ts +25 -0
  220. package/skills/llm-wiki-skill/packages/graph-engine/src/layout/edge-geometry.ts +17 -0
  221. package/skills/llm-wiki-skill/packages/graph-engine/src/layout/index.ts +16 -0
  222. package/skills/llm-wiki-skill/packages/graph-engine/src/layout/spatial-index.ts +509 -0
  223. package/skills/llm-wiki-skill/packages/graph-engine/src/model/atlas.ts +18 -0
  224. package/skills/llm-wiki-skill/packages/graph-engine/src/model/index.ts +10 -0
  225. package/skills/llm-wiki-skill/packages/graph-engine/src/model/labels.ts +11 -0
  226. package/skills/llm-wiki-skill/packages/graph-engine/src/model/layout.ts +81 -0
  227. package/skills/llm-wiki-skill/packages/graph-engine/src/model/learning.ts +8 -0
  228. package/skills/llm-wiki-skill/packages/graph-engine/src/model/legacy-helpers.ts +1379 -0
  229. package/skills/llm-wiki-skill/packages/graph-engine/src/model/queue.ts +7 -0
  230. package/skills/llm-wiki-skill/packages/graph-engine/src/model/storage.ts +4 -0
  231. package/skills/llm-wiki-skill/packages/graph-engine/src/model/visibility.ts +9 -0
  232. package/skills/llm-wiki-skill/packages/graph-engine/src/render/.gitkeep +1 -0
  233. package/skills/llm-wiki-skill/packages/graph-engine/src/render/adapter.ts +443 -0
  234. package/skills/llm-wiki-skill/packages/graph-engine/src/render/aggregation-containers.ts +64 -0
  235. package/skills/llm-wiki-skill/packages/graph-engine/src/render/community-cloud-geometry.ts +178 -0
  236. package/skills/llm-wiki-skill/packages/graph-engine/src/render/community-wash.ts +238 -0
  237. package/skills/llm-wiki-skill/packages/graph-engine/src/render/community-washes.ts +19 -0
  238. package/skills/llm-wiki-skill/packages/graph-engine/src/render/compat-contract.ts +14 -0
  239. package/skills/llm-wiki-skill/packages/graph-engine/src/render/controller.ts +705 -0
  240. package/skills/llm-wiki-skill/packages/graph-engine/src/render/controls.ts +288 -0
  241. package/skills/llm-wiki-skill/packages/graph-engine/src/render/dom-svg-renderer.ts +180 -0
  242. package/skills/llm-wiki-skill/packages/graph-engine/src/render/edges.ts +51 -0
  243. package/skills/llm-wiki-skill/packages/graph-engine/src/render/geometry.ts +380 -0
  244. package/skills/llm-wiki-skill/packages/graph-engine/src/render/gestures.ts +673 -0
  245. package/skills/llm-wiki-skill/packages/graph-engine/src/render/graph-renderer-root.ts +387 -0
  246. package/skills/llm-wiki-skill/packages/graph-engine/src/render/hit-testing.ts +56 -0
  247. package/skills/llm-wiki-skill/packages/graph-engine/src/render/host-dom.ts +14 -0
  248. package/skills/llm-wiki-skill/packages/graph-engine/src/render/hover-card.ts +37 -0
  249. package/skills/llm-wiki-skill/packages/graph-engine/src/render/index.ts +213 -0
  250. package/skills/llm-wiki-skill/packages/graph-engine/src/render/keyboard.ts +48 -0
  251. package/skills/llm-wiki-skill/packages/graph-engine/src/render/legend.ts +25 -0
  252. package/skills/llm-wiki-skill/packages/graph-engine/src/render/minimap.ts +45 -0
  253. package/skills/llm-wiki-skill/packages/graph-engine/src/render/model.ts +1339 -0
  254. package/skills/llm-wiki-skill/packages/graph-engine/src/render/node-drag-lifecycle.ts +94 -0
  255. package/skills/llm-wiki-skill/packages/graph-engine/src/render/nodes.ts +103 -0
  256. package/skills/llm-wiki-skill/packages/graph-engine/src/render/offline-reader.ts +209 -0
  257. package/skills/llm-wiki-skill/packages/graph-engine/src/render/overlays-presenter.ts +192 -0
  258. package/skills/llm-wiki-skill/packages/graph-engine/src/render/overlays.ts +73 -0
  259. package/skills/llm-wiki-skill/packages/graph-engine/src/render/pin-position.ts +51 -0
  260. package/skills/llm-wiki-skill/packages/graph-engine/src/render/preview.ts +65 -0
  261. package/skills/llm-wiki-skill/packages/graph-engine/src/render/relation-focus.ts +91 -0
  262. package/skills/llm-wiki-skill/packages/graph-engine/src/render/render-context.ts +85 -0
  263. package/skills/llm-wiki-skill/packages/graph-engine/src/render/render-pipeline.ts +871 -0
  264. package/skills/llm-wiki-skill/packages/graph-engine/src/render/render-styles.ts +1405 -0
  265. package/skills/llm-wiki-skill/packages/graph-engine/src/render/renderer-surface.ts +75 -0
  266. package/skills/llm-wiki-skill/packages/graph-engine/src/render/search.ts +57 -0
  267. package/skills/llm-wiki-skill/packages/graph-engine/src/render/sigma-coordinates.ts +44 -0
  268. package/skills/llm-wiki-skill/packages/graph-engine/src/render/sigma-global-drag.ts +246 -0
  269. package/skills/llm-wiki-skill/packages/graph-engine/src/render/sigma-global-renderer.ts +1425 -0
  270. package/skills/llm-wiki-skill/packages/graph-engine/src/render/sigma-overlay-svg.ts +121 -0
  271. package/skills/llm-wiki-skill/packages/graph-engine/src/render/simulation-bridge.ts +59 -0
  272. package/skills/llm-wiki-skill/packages/graph-engine/src/render/state.ts +262 -0
  273. package/skills/llm-wiki-skill/packages/graph-engine/src/render/toolbar.ts +40 -0
  274. package/skills/llm-wiki-skill/packages/graph-engine/src/render/viewport.ts +336 -0
  275. package/skills/llm-wiki-skill/packages/graph-engine/src/select/.gitkeep +1 -0
  276. package/skills/llm-wiki-skill/packages/graph-engine/src/select/index.ts +189 -0
  277. package/skills/llm-wiki-skill/packages/graph-engine/src/sim/index.ts +372 -0
  278. package/skills/llm-wiki-skill/packages/graph-engine/src/sim/pins.ts +84 -0
  279. package/skills/llm-wiki-skill/packages/graph-engine/src/summary/index.ts +447 -0
  280. package/skills/llm-wiki-skill/packages/graph-engine/src/themes/.gitkeep +1 -0
  281. package/skills/llm-wiki-skill/packages/graph-engine/src/themes/index.ts +8 -0
  282. package/skills/llm-wiki-skill/packages/graph-engine/src/themes/tokens.ts +117 -0
  283. package/skills/llm-wiki-skill/packages/graph-engine/src/types/d3-quadtree.d.ts +22 -0
  284. package/skills/llm-wiki-skill/packages/graph-engine/src/types.ts +531 -0
  285. package/skills/llm-wiki-skill/packages/graph-engine/test/aggregation-fallback-trial-adapter.test.ts +115 -0
  286. package/skills/llm-wiki-skill/packages/graph-engine/test/aggregation-fallback-trial-adapter.ts +222 -0
  287. package/skills/llm-wiki-skill/packages/graph-engine/test/anim.test.ts +121 -0
  288. package/skills/llm-wiki-skill/packages/graph-engine/test/architecture.test.ts +63 -0
  289. package/skills/llm-wiki-skill/packages/graph-engine/test/community-cloud-geometry.test.ts +86 -0
  290. package/skills/llm-wiki-skill/packages/graph-engine/test/community-wash.test.ts +97 -0
  291. package/skills/llm-wiki-skill/packages/graph-engine/test/diff.test.ts +133 -0
  292. package/skills/llm-wiki-skill/packages/graph-engine/test/facade.test.ts +1369 -0
  293. package/skills/llm-wiki-skill/packages/graph-engine/test/geometry.test.ts +147 -0
  294. package/skills/llm-wiki-skill/packages/graph-engine/test/gestures.test.ts +768 -0
  295. package/skills/llm-wiki-skill/packages/graph-engine/test/graph-layout.test.ts +110 -0
  296. package/skills/llm-wiki-skill/packages/graph-engine/test/helpers.test.ts +287 -0
  297. package/skills/llm-wiki-skill/packages/graph-engine/test/interaction-contract.test.ts +106 -0
  298. package/skills/llm-wiki-skill/packages/graph-engine/test/keyboard.test.ts +59 -0
  299. package/skills/llm-wiki-skill/packages/graph-engine/test/large-fixtures.test.ts +47 -0
  300. package/skills/llm-wiki-skill/packages/graph-engine/test/large-graph-fixtures.ts +420 -0
  301. package/skills/llm-wiki-skill/packages/graph-engine/test/learning.test.ts +259 -0
  302. package/skills/llm-wiki-skill/packages/graph-engine/test/node-drag-lifecycle.test.ts +166 -0
  303. package/skills/llm-wiki-skill/packages/graph-engine/test/overlays.test.ts +115 -0
  304. package/skills/llm-wiki-skill/packages/graph-engine/test/preview.test.ts +56 -0
  305. package/skills/llm-wiki-skill/packages/graph-engine/test/queue.test.ts +114 -0
  306. package/skills/llm-wiki-skill/packages/graph-engine/test/relation-focus.test.ts +115 -0
  307. package/skills/llm-wiki-skill/packages/graph-engine/test/render-model.test.ts +1030 -0
  308. package/skills/llm-wiki-skill/packages/graph-engine/test/renderer-adapter-contract.test.ts +271 -0
  309. package/skills/llm-wiki-skill/packages/graph-engine/test/renderer-boundary.test.ts +618 -0
  310. package/skills/llm-wiki-skill/packages/graph-engine/test/renderer-lifecycle.test.ts +1711 -0
  311. package/skills/llm-wiki-skill/packages/graph-engine/test/route-continuity.test.ts +284 -0
  312. package/skills/llm-wiki-skill/packages/graph-engine/test/runtime-state.test.ts +281 -0
  313. package/skills/llm-wiki-skill/packages/graph-engine/test/search-and-legend.test.ts +124 -0
  314. package/skills/llm-wiki-skill/packages/graph-engine/test/select.test.ts +168 -0
  315. package/skills/llm-wiki-skill/packages/graph-engine/test/sigma-coordinates.test.ts +50 -0
  316. package/skills/llm-wiki-skill/packages/graph-engine/test/sigma-global-renderer.test.ts +2210 -0
  317. package/skills/llm-wiki-skill/packages/graph-engine/test/sigma-trial-adapter.test.ts +82 -0
  318. package/skills/llm-wiki-skill/packages/graph-engine/test/sigma-trial-adapter.ts +271 -0
  319. package/skills/llm-wiki-skill/packages/graph-engine/test/sim.test.ts +207 -0
  320. package/skills/llm-wiki-skill/packages/graph-engine/test/simulation-bridge.test.ts +96 -0
  321. package/skills/llm-wiki-skill/packages/graph-engine/test/spatial-index.test.ts +222 -0
  322. package/skills/llm-wiki-skill/packages/graph-engine/test/state.test.ts +189 -0
  323. package/skills/llm-wiki-skill/packages/graph-engine/test/summary-contract.test.ts +422 -0
  324. package/skills/llm-wiki-skill/packages/graph-engine/test/themes.test.ts +62 -0
  325. package/skills/llm-wiki-skill/packages/graph-engine/test/toolbar.test.ts +64 -0
  326. package/skills/llm-wiki-skill/packages/graph-engine/test/viewport.test.ts +213 -0
  327. package/skills/llm-wiki-skill/packages/graph-engine/test/vis-network-trial-adapter.test.ts +82 -0
  328. package/skills/llm-wiki-skill/packages/graph-engine/test/vis-network-trial-adapter.ts +186 -0
  329. package/skills/llm-wiki-skill/packages/graph-engine/tsconfig.json +17 -0
  330. package/skills/llm-wiki-skill/packages/graph-engine/vite.config.ts +15 -0
  331. package/skills/llm-wiki-skill/platforms/claude/CLAUDE.md +37 -0
  332. package/skills/llm-wiki-skill/platforms/claude/companions/llm-wiki-upgrade/SKILL.md +95 -0
  333. package/skills/llm-wiki-skill/platforms/codex/AGENTS.md +23 -0
  334. package/skills/llm-wiki-skill/platforms/hermes/README.md +31 -0
  335. package/skills/llm-wiki-skill/platforms/openclaw/README.md +31 -0
  336. package/skills/llm-wiki-skill/scripts/adapter-state.sh +424 -0
  337. package/skills/llm-wiki-skill/scripts/build-graph-data.sh +395 -0
  338. package/skills/llm-wiki-skill/scripts/build-graph-html.sh +459 -0
  339. package/skills/llm-wiki-skill/scripts/cache.sh +352 -0
  340. package/skills/llm-wiki-skill/scripts/create-source-page.sh +100 -0
  341. package/skills/llm-wiki-skill/scripts/delete-helper.sh +68 -0
  342. package/skills/llm-wiki-skill/scripts/graph-analysis.js +732 -0
  343. package/skills/llm-wiki-skill/scripts/hook-session-start.sh +46 -0
  344. package/skills/llm-wiki-skill/scripts/init-wiki.sh +95 -0
  345. package/skills/llm-wiki-skill/scripts/lib/source-signal-eligibility.js +158 -0
  346. package/skills/llm-wiki-skill/scripts/lint-fix.sh +114 -0
  347. package/skills/llm-wiki-skill/scripts/lint-runner.sh +217 -0
  348. package/skills/llm-wiki-skill/scripts/runtime-context.sh +77 -0
  349. package/skills/llm-wiki-skill/scripts/shared-config.sh +83 -0
  350. package/skills/llm-wiki-skill/scripts/source-record-contract.tsv +10 -0
  351. package/skills/llm-wiki-skill/scripts/source-registry.sh +349 -0
  352. package/skills/llm-wiki-skill/scripts/source-registry.tsv +10 -0
  353. package/skills/llm-wiki-skill/scripts/source-signal-coverage.js +83 -0
  354. package/skills/llm-wiki-skill/scripts/validate-step1.sh +144 -0
  355. package/skills/llm-wiki-skill/scripts/wiki-compat.sh +267 -0
  356. package/skills/llm-wiki-skill/setup.sh +8 -0
  357. package/skills/llm-wiki-skill/templates/entity-template.md +30 -0
  358. package/skills/llm-wiki-skill/templates/graph-styles/wash/footer.html +27 -0
  359. package/skills/llm-wiki-skill/templates/graph-styles/wash/graph-wash-helpers.js +1326 -0
  360. package/skills/llm-wiki-skill/templates/graph-styles/wash/graph-wash.js +1009 -0
  361. package/skills/llm-wiki-skill/templates/graph-styles/wash/header.html +2002 -0
  362. package/skills/llm-wiki-skill/templates/index-en-template.md +51 -0
  363. package/skills/llm-wiki-skill/templates/index-template.md +51 -0
  364. package/skills/llm-wiki-skill/templates/log-en-template.md +11 -0
  365. package/skills/llm-wiki-skill/templates/log-template.md +11 -0
  366. package/skills/llm-wiki-skill/templates/overview-en-template.md +41 -0
  367. package/skills/llm-wiki-skill/templates/overview-template.md +41 -0
  368. package/skills/llm-wiki-skill/templates/purpose-en-template.md +16 -0
  369. package/skills/llm-wiki-skill/templates/purpose-template.md +16 -0
  370. package/skills/llm-wiki-skill/templates/query-template.md +19 -0
  371. package/skills/llm-wiki-skill/templates/schema-template.md +185 -0
  372. package/skills/llm-wiki-skill/templates/source-template.md +51 -0
  373. package/skills/llm-wiki-skill/templates/synthesis-template.md +25 -0
  374. package/skills/llm-wiki-skill/templates/topic-template.md +35 -0
  375. package/skills/llm-wiki-skill/tests/adapter-state.sh +338 -0
  376. package/skills/llm-wiki-skill/tests/browser/graph-aggregation-fallback-trial.ts +737 -0
  377. package/skills/llm-wiki-skill/tests/browser/graph-community-node-map.mjs +255 -0
  378. package/skills/llm-wiki-skill/tests/browser/graph-community-wash-interactions.mjs +170 -0
  379. package/skills/llm-wiki-skill/tests/browser/graph-default-behavior.mjs +630 -0
  380. package/skills/llm-wiki-skill/tests/browser/graph-density-preview.mjs +53 -0
  381. package/skills/llm-wiki-skill/tests/browser/graph-html-insights.mjs +41 -0
  382. package/skills/llm-wiki-skill/tests/browser/graph-large-performance.ts +689 -0
  383. package/skills/llm-wiki-skill/tests/browser/graph-node-slim.mjs +75 -0
  384. package/skills/llm-wiki-skill/tests/browser/graph-offline-phase-6.mjs +660 -0
  385. package/skills/llm-wiki-skill/tests/browser/graph-renderer-trial-shared.ts +291 -0
  386. package/skills/llm-wiki-skill/tests/browser/graph-sigma-global-production.ts +1437 -0
  387. package/skills/llm-wiki-skill/tests/browser/graph-sigma-graphology-trial.ts +949 -0
  388. package/skills/llm-wiki-skill/tests/browser/graph-stage-4-5.mjs +815 -0
  389. package/skills/llm-wiki-skill/tests/browser/graph-vis-network-trial.ts +762 -0
  390. package/skills/llm-wiki-skill/tests/browser/graph-workbench-interactions.mjs +730 -0
  391. package/skills/llm-wiki-skill/tests/browser/validate-graph-trial-result.mjs +149 -0
  392. package/skills/llm-wiki-skill/tests/expected/graph-data-empty.json +60 -0
  393. package/skills/llm-wiki-skill/tests/expected/graph-data-sample.json +396 -0
  394. package/skills/llm-wiki-skill/tests/expected/graph-interactive-basic.html +1736 -0
  395. package/skills/llm-wiki-skill/tests/expected/lint-output.txt +44 -0
  396. package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/index.md +1 -0
  397. package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/entities/Alpha.md +10 -0
  398. package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/entities/Beta.md +7 -0
  399. package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/entities/Delta.md +8 -0
  400. package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/entities/Gamma.md +8 -0
  401. package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/queries/20260422-abc.md +10 -0
  402. package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/synthesis/Crystal.md +8 -0
  403. package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/topics/Overview.md +9 -0
  404. package/skills/llm-wiki-skill/tests/fixtures/graph-data-empty-wiki/wiki/entities/.gitkeep +0 -0
  405. package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/purpose.md +3 -0
  406. package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/entities/Attention.md +7 -0
  407. package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/entities/Decoder.md +7 -0
  408. package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/entities/Encoder.md +7 -0
  409. package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/entities/GPT.md +7 -0
  410. package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/entities/Transformer.md +13 -0
  411. package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/sources/paper.md +9 -0
  412. package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/topics/arch.md +12 -0
  413. package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/topics/finetune.md +9 -0
  414. package/skills/llm-wiki-skill/tests/fixtures/graph-interactive-basic/wiki/graph-data.json +40 -0
  415. package/skills/llm-wiki-skill/tests/fixtures/graph-interactive-dense/wiki/graph-data.json +3965 -0
  416. package/skills/llm-wiki-skill/tests/fixtures/graph-interactive-multicomm/wiki/graph-data.json +212 -0
  417. package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/index.md +14 -0
  418. package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/entities/C++.md +6 -0
  419. package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/entities/Lonely.md +4 -0
  420. package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/entities/Other.md +8 -0
  421. package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/entities/Real.md +7 -0
  422. package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/sources/2026-01-01-test-source.md +15 -0
  423. package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/sources/2026-02-01-inline-img.md +12 -0
  424. package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/topics/AIbasic.md +3 -0
  425. package/skills/llm-wiki-skill/tests/graph-aggregation-fallback-trial.regression-1.sh +46 -0
  426. package/skills/llm-wiki-skill/tests/graph-analysis-helper.regression-1.sh +237 -0
  427. package/skills/llm-wiki-skill/tests/graph-browser-large-performance.regression-1.sh +39 -0
  428. package/skills/llm-wiki-skill/tests/graph-browser-stage-4-5.regression-1.sh +163 -0
  429. package/skills/llm-wiki-skill/tests/graph-build-failures.regression-1.sh +91 -0
  430. package/skills/llm-wiki-skill/tests/graph-community-node-map.regression-1.sh +107 -0
  431. package/skills/llm-wiki-skill/tests/graph-community-wash-interactions.regression-1.sh +35 -0
  432. package/skills/llm-wiki-skill/tests/graph-data-confidence-merge.regression-1.sh +309 -0
  433. package/skills/llm-wiki-skill/tests/graph-data-source-paths.regression-1.sh +49 -0
  434. package/skills/llm-wiki-skill/tests/graph-default-behavior.regression-1.sh +35 -0
  435. package/skills/llm-wiki-skill/tests/graph-html-a11y.regression-1.sh +50 -0
  436. package/skills/llm-wiki-skill/tests/graph-html-brand-link.regression-1.sh +47 -0
  437. package/skills/llm-wiki-skill/tests/graph-html-density.regression-1.sh +228 -0
  438. package/skills/llm-wiki-skill/tests/graph-html-drawer-neighbors.regression-1.sh +47 -0
  439. package/skills/llm-wiki-skill/tests/graph-html-insights.regression-1.sh +80 -0
  440. package/skills/llm-wiki-skill/tests/graph-html-long-label.regression-1.sh +92 -0
  441. package/skills/llm-wiki-skill/tests/graph-html-minimap.regression-1.sh +51 -0
  442. package/skills/llm-wiki-skill/tests/graph-html-mobile.regression-1.sh +48 -0
  443. package/skills/llm-wiki-skill/tests/graph-html-oriental-atlas-contract.regression-1.sh +94 -0
  444. package/skills/llm-wiki-skill/tests/graph-html-oriental-design-contract.regression-1.sh +82 -0
  445. package/skills/llm-wiki-skill/tests/graph-html-search.regression-1.sh +52 -0
  446. package/skills/llm-wiki-skill/tests/graph-html-styles.regression-1.sh +66 -0
  447. package/skills/llm-wiki-skill/tests/graph-html-toolbar.regression-1.sh +62 -0
  448. package/skills/llm-wiki-skill/tests/graph-offline-phase-6.regression-1.sh +51 -0
  449. package/skills/llm-wiki-skill/tests/graph-sigma-global-production.regression-1.sh +64 -0
  450. package/skills/llm-wiki-skill/tests/graph-sigma-graphology-trial.regression-1.sh +46 -0
  451. package/skills/llm-wiki-skill/tests/graph-vis-network-trial.regression-1.sh +46 -0
  452. package/skills/llm-wiki-skill/tests/graph-workbench-interactions.regression-1.sh +151 -0
  453. package/skills/llm-wiki-skill/tests/js/graph-wash-bootstrap.test.js +110 -0
  454. package/skills/llm-wiki-skill/tests/js/graph-wash-helpers.test.js +296 -0
  455. package/skills/llm-wiki-skill/tests/js/graph-wash-learning.test.js +260 -0
  456. package/skills/llm-wiki-skill/tests/js/graph-wash-queue.test.js +115 -0
  457. package/skills/llm-wiki-skill/tests/js/graph-wash-runtime-state.test.js +282 -0
  458. package/skills/llm-wiki-skill/tests/js/source-signal-coverage.test.js +48 -0
  459. package/skills/llm-wiki-skill/tests/js/source-signal-eligibility.test.js +202 -0
  460. package/skills/llm-wiki-skill/tests/lib/graph-html-engine-helpers.sh +110 -0
  461. package/skills/llm-wiki-skill/tests/lint-output.regression-1.sh +32 -0
  462. package/skills/llm-wiki-skill/tests/regression.sh +1754 -0
  463. package/skills/llm-wiki-skill/workbench/AGENTS.md +110 -0
  464. package/skills/llm-wiki-skill/workbench/CLAUDE.md +55 -0
  465. package/skills/llm-wiki-skill/workbench/LICENSE +21 -0
  466. package/skills/llm-wiki-skill/workbench/PRODUCT.md +1353 -0
  467. package/skills/llm-wiki-skill/workbench/README.md +30 -0
  468. package/skills/llm-wiki-skill/workbench/docs/current-kb-retrieval-design.md +587 -0
  469. package/skills/llm-wiki-skill/workbench/docs/graph-evolution-1-design.md +210 -0
  470. package/skills/llm-wiki-skill/workbench/docs/stage-2-design.md +1139 -0
  471. package/skills/llm-wiki-skill/workbench/docs/stage-3-design.md +1269 -0
  472. package/skills/llm-wiki-skill/workbench/docs/stage-3.5-design.md +1164 -0
  473. package/skills/llm-wiki-skill/workbench/docs/stage-4-design.md +504 -0
  474. package/skills/llm-wiki-skill/workbench/docs/stage-4.5-design.md +195 -0
  475. package/skills/llm-wiki-skill/workbench/docs/superpowers/specs/2026-05-28-resizable-preview-layout-design.md +165 -0
  476. package/skills/llm-wiki-skill/workbench/docs/superpowers/specs/2026-05-28-settings-panel-scroll-fix.md +50 -0
  477. package/skills/llm-wiki-skill/workbench/server/package.json +31 -0
  478. package/skills/llm-wiki-skill/workbench/server/src/agent.ts +457 -0
  479. package/skills/llm-wiki-skill/workbench/server/src/artifacts.ts +248 -0
  480. package/skills/llm-wiki-skill/workbench/server/src/auth.ts +164 -0
  481. package/skills/llm-wiki-skill/workbench/server/src/config.ts +130 -0
  482. package/skills/llm-wiki-skill/workbench/server/src/conversations.test.ts +159 -0
  483. package/skills/llm-wiki-skill/workbench/server/src/conversations.ts +270 -0
  484. package/skills/llm-wiki-skill/workbench/server/src/digest/batch.ts +189 -0
  485. package/skills/llm-wiki-skill/workbench/server/src/digest/concurrency.test.ts +36 -0
  486. package/skills/llm-wiki-skill/workbench/server/src/digest/concurrency.ts +31 -0
  487. package/skills/llm-wiki-skill/workbench/server/src/digest/subagent.ts +91 -0
  488. package/skills/llm-wiki-skill/workbench/server/src/extensions/artifacts.ts +81 -0
  489. package/skills/llm-wiki-skill/workbench/server/src/extensions/knowledge-base.ts +263 -0
  490. package/skills/llm-wiki-skill/workbench/server/src/extensions/new-wiki.ts +42 -0
  491. package/skills/llm-wiki-skill/workbench/server/src/extensions/synthesis.ts +172 -0
  492. package/skills/llm-wiki-skill/workbench/server/src/graph-watcher.test.ts +196 -0
  493. package/skills/llm-wiki-skill/workbench/server/src/graph.test.ts +113 -0
  494. package/skills/llm-wiki-skill/workbench/server/src/graph.ts +351 -0
  495. package/skills/llm-wiki-skill/workbench/server/src/index.ts +1148 -0
  496. package/skills/llm-wiki-skill/workbench/server/src/knowledge-bases.test.ts +30 -0
  497. package/skills/llm-wiki-skill/workbench/server/src/knowledge-bases.ts +321 -0
  498. package/skills/llm-wiki-skill/workbench/server/src/pages.test.ts +41 -0
  499. package/skills/llm-wiki-skill/workbench/server/src/pages.ts +160 -0
  500. package/skills/llm-wiki-skill/workbench/server/src/retrieval.test.ts +151 -0
  501. package/skills/llm-wiki-skill/workbench/server/src/retrieval.ts +427 -0
  502. package/skills/llm-wiki-skill/workbench/server/src/tool-status-events.test.ts +363 -0
  503. package/skills/llm-wiki-skill/workbench/server/src/tool-status-events.ts +616 -0
  504. package/skills/llm-wiki-skill/workbench/server/src/wiki-init.test.ts +19 -0
  505. package/skills/llm-wiki-skill/workbench/server/src/wiki-init.ts +188 -0
  506. package/skills/llm-wiki-skill/workbench/server/tsconfig.json +10 -0
  507. package/skills/llm-wiki-skill/workbench/tsconfig.json +20 -0
  508. package/skills/llm-wiki-skill/workbench/web/README.md +73 -0
  509. package/skills/llm-wiki-skill/workbench/web/components.json +21 -0
  510. package/skills/llm-wiki-skill/workbench/web/eslint.config.js +22 -0
  511. package/skills/llm-wiki-skill/workbench/web/index.html +16 -0
  512. package/skills/llm-wiki-skill/workbench/web/package.json +54 -0
  513. package/skills/llm-wiki-skill/workbench/web/src/App.tsx +1195 -0
  514. package/skills/llm-wiki-skill/workbench/web/src/components/AddExternalDialog.tsx +375 -0
  515. package/skills/llm-wiki-skill/workbench/web/src/components/AppearancePanel.tsx +158 -0
  516. package/skills/llm-wiki-skill/workbench/web/src/components/ArtifactView.tsx +15 -0
  517. package/skills/llm-wiki-skill/workbench/web/src/components/BatchDigestPanel.tsx +117 -0
  518. package/skills/llm-wiki-skill/workbench/web/src/components/ChatPanel.tsx +890 -0
  519. package/skills/llm-wiki-skill/workbench/web/src/components/CommandMenu.tsx +75 -0
  520. package/skills/llm-wiki-skill/workbench/web/src/components/ExportButtons.tsx +58 -0
  521. package/skills/llm-wiki-skill/workbench/web/src/components/GraphPanel.tsx +800 -0
  522. package/skills/llm-wiki-skill/workbench/web/src/components/GraphReader.tsx +52 -0
  523. package/skills/llm-wiki-skill/workbench/web/src/components/GraphSelection.tsx +100 -0
  524. package/skills/llm-wiki-skill/workbench/web/src/components/GraphSummaryDrawer.tsx +269 -0
  525. package/skills/llm-wiki-skill/workbench/web/src/components/MainViewTabs.tsx +69 -0
  526. package/skills/llm-wiki-skill/workbench/web/src/components/MarkdownView.tsx +106 -0
  527. package/skills/llm-wiki-skill/workbench/web/src/components/NewWikiDialog.tsx +103 -0
  528. package/skills/llm-wiki-skill/workbench/web/src/components/RefMenu.tsx +44 -0
  529. package/skills/llm-wiki-skill/workbench/web/src/components/RightDrawer.tsx +298 -0
  530. package/skills/llm-wiki-skill/workbench/web/src/components/SearchPanel.tsx +165 -0
  531. package/skills/llm-wiki-skill/workbench/web/src/components/SettingsPanel.tsx +320 -0
  532. package/skills/llm-wiki-skill/workbench/web/src/components/Sidebar.tsx +354 -0
  533. package/skills/llm-wiki-skill/workbench/web/src/components/ToolHistorySummary.tsx +111 -0
  534. package/skills/llm-wiki-skill/workbench/web/src/components/ToolStatusRunway.tsx +70 -0
  535. package/skills/llm-wiki-skill/workbench/web/src/components/TopBar.tsx +348 -0
  536. package/skills/llm-wiki-skill/workbench/web/src/components/renderers/DownloadOnlyRenderer.tsx +88 -0
  537. package/skills/llm-wiki-skill/workbench/web/src/components/renderers/HtmlRenderer.tsx +92 -0
  538. package/skills/llm-wiki-skill/workbench/web/src/components/ui/button.tsx +52 -0
  539. package/skills/llm-wiki-skill/workbench/web/src/components/ui/command.tsx +50 -0
  540. package/skills/llm-wiki-skill/workbench/web/src/components/ui/dialog.tsx +156 -0
  541. package/skills/llm-wiki-skill/workbench/web/src/components/ui/input.tsx +21 -0
  542. package/skills/llm-wiki-skill/workbench/web/src/components/ui/tooltip.tsx +57 -0
  543. package/skills/llm-wiki-skill/workbench/web/src/index.css +4204 -0
  544. package/skills/llm-wiki-skill/workbench/web/src/lib/api.ts +648 -0
  545. package/skills/llm-wiki-skill/workbench/web/src/lib/appearance.ts +114 -0
  546. package/skills/llm-wiki-skill/workbench/web/src/lib/drawer-layout.ts +41 -0
  547. package/skills/llm-wiki-skill/workbench/web/src/lib/drawer-state.ts +168 -0
  548. package/skills/llm-wiki-skill/workbench/web/src/lib/graph-reader.ts +25 -0
  549. package/skills/llm-wiki-skill/workbench/web/src/lib/graph-selection-drawer.ts +35 -0
  550. package/skills/llm-wiki-skill/workbench/web/src/lib/graph-selection.ts +96 -0
  551. package/skills/llm-wiki-skill/workbench/web/src/lib/graph-summary-actions.ts +184 -0
  552. package/skills/llm-wiki-skill/workbench/web/src/lib/legacy-tool-status.ts +113 -0
  553. package/skills/llm-wiki-skill/workbench/web/src/lib/model-roles.ts +20 -0
  554. package/skills/llm-wiki-skill/workbench/web/src/lib/search-filter.ts +104 -0
  555. package/skills/llm-wiki-skill/workbench/web/src/lib/sse.ts +72 -0
  556. package/skills/llm-wiki-skill/workbench/web/src/lib/tool-status-format.ts +170 -0
  557. package/skills/llm-wiki-skill/workbench/web/src/lib/tool-status-model.ts +392 -0
  558. package/skills/llm-wiki-skill/workbench/web/src/lib/utils.ts +10 -0
  559. package/skills/llm-wiki-skill/workbench/web/src/lib/view-status.ts +16 -0
  560. package/skills/llm-wiki-skill/workbench/web/src/lib/wiki-links.ts +32 -0
  561. package/skills/llm-wiki-skill/workbench/web/src/main.tsx +10 -0
  562. package/skills/llm-wiki-skill/workbench/web/test/api.test.ts +61 -0
  563. package/skills/llm-wiki-skill/workbench/web/test/app-shell-drawer-layout.test.tsx +48 -0
  564. package/skills/llm-wiki-skill/workbench/web/test/appearance-panel.test.tsx +121 -0
  565. package/skills/llm-wiki-skill/workbench/web/test/appearance.test.ts +262 -0
  566. package/skills/llm-wiki-skill/workbench/web/test/chat-host-source.test.tsx +22 -0
  567. package/skills/llm-wiki-skill/workbench/web/test/chat-panel-auto-scroll.test.tsx +311 -0
  568. package/skills/llm-wiki-skill/workbench/web/test/chat-panel-bubbles.test.tsx +48 -0
  569. package/skills/llm-wiki-skill/workbench/web/test/chat-panel-composer.test.tsx +86 -0
  570. package/skills/llm-wiki-skill/workbench/web/test/chat-panel-tool-status.test.tsx +26 -0
  571. package/skills/llm-wiki-skill/workbench/web/test/export-batch-paper.test.tsx +101 -0
  572. package/skills/llm-wiki-skill/workbench/web/test/graph-drawer-state.test.ts +257 -0
  573. package/skills/llm-wiki-skill/workbench/web/test/graph-panel-paper.test.tsx +200 -0
  574. package/skills/llm-wiki-skill/workbench/web/test/graph-reader-request.test.ts +32 -0
  575. package/skills/llm-wiki-skill/workbench/web/test/graph-reader.test.ts +62 -0
  576. package/skills/llm-wiki-skill/workbench/web/test/graph-selection-drawer.test.ts +56 -0
  577. package/skills/llm-wiki-skill/workbench/web/test/graph-selection.test.ts +83 -0
  578. package/skills/llm-wiki-skill/workbench/web/test/graph-summary-actions.test.ts +188 -0
  579. package/skills/llm-wiki-skill/workbench/web/test/main-view-tabs.test.tsx +34 -0
  580. package/skills/llm-wiki-skill/workbench/web/test/markdown-view.test.tsx +34 -0
  581. package/skills/llm-wiki-skill/workbench/web/test/popup-menus.test.tsx +85 -0
  582. package/skills/llm-wiki-skill/workbench/web/test/render.test.tsx +30 -0
  583. package/skills/llm-wiki-skill/workbench/web/test/render.tsx +38 -0
  584. package/skills/llm-wiki-skill/workbench/web/test/right-drawer-graph-summary.test.tsx +287 -0
  585. package/skills/llm-wiki-skill/workbench/web/test/right-drawer-interactions.test.tsx +182 -0
  586. package/skills/llm-wiki-skill/workbench/web/test/search-filter.test.ts +65 -0
  587. package/skills/llm-wiki-skill/workbench/web/test/search-panel.test.tsx +155 -0
  588. package/skills/llm-wiki-skill/workbench/web/test/setup-dom.ts +66 -0
  589. package/skills/llm-wiki-skill/workbench/web/test/sidebar-v2-source.test.ts +17 -0
  590. package/skills/llm-wiki-skill/workbench/web/test/sidebar.test.tsx +110 -0
  591. package/skills/llm-wiki-skill/workbench/web/test/tool-history-summary.test.tsx +150 -0
  592. package/skills/llm-wiki-skill/workbench/web/test/tool-status-format.test.ts +107 -0
  593. package/skills/llm-wiki-skill/workbench/web/test/tool-status-model.test.ts +324 -0
  594. package/skills/llm-wiki-skill/workbench/web/test/tool-status-runway.test.ts +159 -0
  595. package/skills/llm-wiki-skill/workbench/web/test/topbar.test.tsx +248 -0
  596. package/skills/llm-wiki-skill/workbench/web/test/visual/paper-ui.ts +898 -0
  597. package/skills/llm-wiki-skill/workbench/web/test/wiki-links.test.ts +23 -0
  598. package/skills/llm-wiki-skill/workbench/web/test-results/paper-ui/actual/.gitkeep +1 -0
  599. package/skills/llm-wiki-skill/workbench/web/test-results/paper-ui/baseline/.gitkeep +1 -0
  600. package/skills/llm-wiki-skill/workbench/web/tsconfig.app.json +30 -0
  601. package/skills/llm-wiki-skill/workbench/web/tsconfig.json +7 -0
  602. package/skills/llm-wiki-skill/workbench/web/tsconfig.node.json +24 -0
  603. package/skills/llm-wiki-skill/workbench/web/vite.config.ts +28 -0
@@ -0,0 +1,1030 @@
1
+ import { describe, it } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import {
4
+ buildRenderableGraph,
5
+ edgeOpacity,
6
+ edgeRelationClass,
7
+ edgeStrokeWidth,
8
+ edgeVisualOpacity,
9
+ edgeVisualStrokeWidth,
10
+ evaluateCommunityQuality,
11
+ GRAPH_COMMUNITY_FOCUS_BUDGETS,
12
+ GRAPH_RENDER_BUDGETS,
13
+ makeEdgePath,
14
+ nodeDisplayModeForDensity,
15
+ screenEffectiveDensityMode
16
+ } from "../src/render";
17
+ import type { GraphData } from "../src/types";
18
+
19
+ function sampleGraph(): GraphData {
20
+ return {
21
+ meta: {
22
+ build_date: "2026-06-12T00:00:00.000Z",
23
+ wiki_title: "Stage 4 Demo",
24
+ total_nodes: 4,
25
+ total_edges: 3
26
+ },
27
+ nodes: [
28
+ { id: "topic", label: "主题", type: "topic", community: "c1", source_path: "wiki/topic.md", weight: 80, x: 20, y: 30 },
29
+ { id: "entity", label: "实体", type: "entity", community: "c1", source_path: "wiki/entity.md", weight: 50 },
30
+ { id: "source", label: "来源", type: "source", community: "c2", source_path: "wiki/source.md", weight: 40, x: 70, y: 60 },
31
+ { id: "island", label: "孤岛", type: "entity", community: "c3", source_path: "wiki/island.md", weight: 10 }
32
+ ],
33
+ edges: [
34
+ { id: "e1", from: "topic", to: "entity", type: "EXTRACTED", confidence: "EXTRACTED", relation_type: "实现", weight: 1 },
35
+ { id: "e2", from: "topic", to: "source", type: "INFERRED", confidence: "INFERRED", relation_type: "对比", weight: 0.5 },
36
+ { id: "missing", from: "topic", to: "missing", type: "UNVERIFIED", weight: 0.1 }
37
+ ],
38
+ learning: {
39
+ version: 1,
40
+ entry: { recommended_start_node_id: "topic", recommended_start_reason: "community_hub", default_mode: "global" },
41
+ views: {
42
+ path: { enabled: false, start_node_id: null, node_ids: [], degraded: true },
43
+ community: { enabled: false, community_id: null, label: null, node_ids: [], is_weak: false, degraded: true },
44
+ global: { enabled: true, node_ids: ["topic", "entity", "source", "island"], degraded: false }
45
+ },
46
+ communities: [
47
+ { id: "c1", label: "核心", node_count: 2, color_index: 0, recommended_start_node_id: "topic" },
48
+ { id: "c2", label: "来源", node_count: 1, color_index: 1 },
49
+ { id: "c3", label: "孤岛", node_count: 1, color_index: 2 }
50
+ ]
51
+ }
52
+ };
53
+ }
54
+
55
+ function outlierCommunityGraph(): GraphData {
56
+ const nodes = [
57
+ { id: "core-a", label: "Core A", type: "entity", community: "c1", source_path: "wiki/core-a.md", weight: 70, x: 20, y: 40 },
58
+ { id: "core-b", label: "Core B", type: "entity", community: "c1", source_path: "wiki/core-b.md", weight: 65, x: 22, y: 42 },
59
+ { id: "core-c", label: "Core C", type: "topic", community: "c1", source_path: "wiki/core-c.md", weight: 80, x: 24, y: 39 },
60
+ { id: "core-d", label: "Core D", type: "source", community: "c1", source_path: "wiki/core-d.md", weight: 55, x: 26, y: 41 },
61
+ { id: "outlier", label: "Outlier", type: "entity", community: "c1", source_path: "wiki/outlier.md", weight: 35, x: 92, y: 78 }
62
+ ];
63
+ return {
64
+ meta: {
65
+ build_date: "2026-06-12T00:00:00.000Z",
66
+ wiki_title: "Outlier Fixture",
67
+ total_nodes: nodes.length,
68
+ total_edges: 0
69
+ },
70
+ nodes,
71
+ edges: [],
72
+ learning: {
73
+ version: 1,
74
+ entry: { recommended_start_node_id: "core-c", recommended_start_reason: "community_hub", default_mode: "global" },
75
+ views: {
76
+ path: { enabled: false, start_node_id: null, node_ids: [], degraded: true },
77
+ community: { enabled: false, community_id: null, label: null, node_ids: [], is_weak: false, degraded: true },
78
+ global: { enabled: true, node_ids: nodes.map((node) => node.id), degraded: false }
79
+ },
80
+ communities: [
81
+ { id: "c1", label: "Cluster", node_count: nodes.length, color_index: 0, recommended_start_node_id: "core-c" }
82
+ ]
83
+ }
84
+ };
85
+ }
86
+
87
+ function budgetGraph(nodeCount: number, edgeCount: number): GraphData {
88
+ const nodes = Array.from({ length: nodeCount }, (_, index) => ({
89
+ id: `n${index}`,
90
+ label: `Budget node ${index}`,
91
+ type: index % 7 === 0 ? "topic" : index % 11 === 0 ? "source" : "entity",
92
+ community: "c1",
93
+ source_path: `wiki/budget/n${index}.md`,
94
+ weight: 100 - (index % 83),
95
+ x: (index * 37) % 100,
96
+ y: (index * 53) % 100
97
+ }));
98
+ const edges: NonNullable<GraphData["edges"]> = [];
99
+ for (let sourceIndex = 0; sourceIndex < nodeCount && edges.length < edgeCount; sourceIndex += 1) {
100
+ for (let targetIndex = sourceIndex + 1; targetIndex < nodeCount && edges.length < edgeCount; targetIndex += 1) {
101
+ edges.push({
102
+ id: `e${edges.length}`,
103
+ from: `n${sourceIndex}`,
104
+ to: `n${targetIndex}`,
105
+ type: "EXTRACTED",
106
+ confidence: "EXTRACTED",
107
+ relation_type: edges.length % 3 === 0 ? "实现" : "依赖",
108
+ weight: (edges.length % 10) / 10
109
+ });
110
+ }
111
+ }
112
+
113
+ return {
114
+ meta: {
115
+ build_date: "2026-06-18T00:00:00.000Z",
116
+ wiki_title: "Budget Fixture",
117
+ total_nodes: nodes.length,
118
+ total_edges: edges.length
119
+ },
120
+ nodes,
121
+ edges,
122
+ learning: {
123
+ version: 1,
124
+ entry: { recommended_start_node_id: "n0", recommended_start_reason: "budget_fixture", default_mode: "global" },
125
+ views: {
126
+ path: { enabled: false, start_node_id: null, node_ids: [], degraded: true },
127
+ community: { enabled: false, community_id: null, label: null, node_ids: [], is_weak: false, degraded: true },
128
+ global: { enabled: true, node_ids: nodes.map((node) => node.id), degraded: false }
129
+ },
130
+ communities: [
131
+ { id: "c1", label: "Budget Community", node_count: nodes.length, color_index: 0, recommended_start_node_id: "n0" }
132
+ ]
133
+ }
134
+ };
135
+ }
136
+
137
+ function densePointMapGraph(): GraphData {
138
+ const nodeCount = 2000;
139
+ const edgeTarget = 3996;
140
+ const communityCount = 16;
141
+ const nodes = Array.from({ length: nodeCount }, (_, index) => ({
142
+ id: `dense-${index}`,
143
+ label: `Dense node ${index}`,
144
+ type: index % 17 === 0 ? "topic" : index % 29 === 0 ? "source" : "entity",
145
+ community: `dense-community-${index % communityCount}`,
146
+ source_path: `wiki/dense/dense-${index}.md`,
147
+ weight: 100 - (index % 97),
148
+ x: (index * 37) % 100,
149
+ y: (index * 53) % 100
150
+ }));
151
+ const edges: NonNullable<GraphData["edges"]> = [
152
+ {
153
+ id: "dense-selected-weak",
154
+ from: "dense-1999",
155
+ to: "dense-1",
156
+ type: "INFERRED",
157
+ confidence: "INFERRED",
158
+ relation_type: "依赖",
159
+ weight: 0
160
+ },
161
+ {
162
+ id: "dense-selected-strong",
163
+ from: "dense-1999",
164
+ to: "dense-2",
165
+ type: "EXTRACTED",
166
+ confidence: "EXTRACTED",
167
+ relation_type: "实现",
168
+ weight: 1
169
+ }
170
+ ];
171
+
172
+ for (let index = 0; edges.length < edgeTarget; index += 1) {
173
+ const source = index % nodeCount;
174
+ const target = (source + 1 + (index % 113)) % nodeCount;
175
+ if (source === target) continue;
176
+ edges.push({
177
+ id: `dense-edge-${index}`,
178
+ from: `dense-${source}`,
179
+ to: `dense-${target}`,
180
+ type: index % 5 === 0 ? "INFERRED" : "EXTRACTED",
181
+ confidence: index % 5 === 0 ? "INFERRED" : "EXTRACTED",
182
+ relation_type: index % 7 === 0 ? "对比" : "依赖",
183
+ weight: (index % 11) / 10
184
+ });
185
+ }
186
+
187
+ return {
188
+ meta: {
189
+ build_date: "2026-06-21T00:00:00.000Z",
190
+ wiki_title: "Dense Point Map Fixture",
191
+ total_nodes: nodes.length,
192
+ total_edges: edges.length
193
+ },
194
+ nodes,
195
+ edges,
196
+ learning: {
197
+ version: 1,
198
+ entry: { recommended_start_node_id: "dense-0", recommended_start_reason: "dense_fixture", default_mode: "global" },
199
+ views: {
200
+ path: { enabled: false, start_node_id: null, node_ids: [], degraded: true },
201
+ community: { enabled: false, community_id: null, label: null, node_ids: [], is_weak: false, degraded: true },
202
+ global: { enabled: true, node_ids: nodes.map((node) => node.id), degraded: false }
203
+ },
204
+ communities: Array.from({ length: communityCount }, (_, index) => ({
205
+ id: `dense-community-${index}`,
206
+ label: `Dense Community ${index}`,
207
+ node_count: nodes.filter((node) => node.community === `dense-community-${index}`).length,
208
+ color_index: index,
209
+ recommended_start_node_id: index === 0 ? "dense-0" : null
210
+ }))
211
+ }
212
+ };
213
+ }
214
+
215
+ function manyTinyCommunitiesGraph(): GraphData {
216
+ const nodes = Array.from({ length: 10 }, (_, index) => ({
217
+ id: `tiny-${index}`,
218
+ label: `Tiny node ${index}`,
219
+ type: "entity",
220
+ community: `tiny-${index}`,
221
+ source_path: `wiki/tiny/${index}.md`,
222
+ weight: 20 + index,
223
+ x: (index * 11) % 100,
224
+ y: (index * 17) % 100
225
+ }));
226
+ return {
227
+ meta: {
228
+ build_date: "2026-06-18T00:00:00.000Z",
229
+ wiki_title: "Many Tiny Communities",
230
+ total_nodes: nodes.length,
231
+ total_edges: 0
232
+ },
233
+ nodes,
234
+ edges: [],
235
+ learning: {
236
+ version: 1,
237
+ entry: { recommended_start_node_id: "tiny-0", recommended_start_reason: "fixture", default_mode: "global" },
238
+ views: {
239
+ path: { enabled: false, start_node_id: null, node_ids: [], degraded: true },
240
+ community: { enabled: false, community_id: null, label: null, node_ids: [], is_weak: false, degraded: true },
241
+ global: { enabled: true, node_ids: nodes.map((node) => node.id), degraded: false }
242
+ },
243
+ communities: nodes.map((node, index) => ({
244
+ id: String(node.community),
245
+ label: `Specific topic ${index}`,
246
+ node_count: 1,
247
+ color_index: index
248
+ }))
249
+ }
250
+ };
251
+ }
252
+
253
+ function oversizedWeakCommunityGraph(): GraphData {
254
+ const nodes = Array.from({ length: 120 }, (_, index) => ({
255
+ id: `blob-${index}`,
256
+ label: `Blob node ${index}`,
257
+ type: index % 9 === 0 ? "topic" : "entity",
258
+ community: "community",
259
+ source_path: `wiki/blob/${index}.md`,
260
+ weight: 60 - (index % 30),
261
+ x: (index * 19) % 100,
262
+ y: (index * 23) % 100
263
+ }));
264
+ return {
265
+ meta: {
266
+ build_date: "2026-06-18T00:00:00.000Z",
267
+ wiki_title: "Oversized Weak Community",
268
+ total_nodes: nodes.length,
269
+ total_edges: 0
270
+ },
271
+ nodes,
272
+ edges: [],
273
+ learning: {
274
+ version: 1,
275
+ entry: { recommended_start_node_id: "blob-0", recommended_start_reason: "fixture", default_mode: "global" },
276
+ views: {
277
+ path: { enabled: false, start_node_id: null, node_ids: [], degraded: true },
278
+ community: { enabled: false, community_id: null, label: null, node_ids: [], is_weak: true, degraded: true },
279
+ global: { enabled: true, node_ids: nodes.map((node) => node.id), degraded: false }
280
+ },
281
+ communities: [
282
+ { id: "community", label: "community", node_count: nodes.length, color_index: 0, is_weak: true }
283
+ ]
284
+ }
285
+ };
286
+ }
287
+
288
+ function mixedCrossCommunityGraph(): GraphData {
289
+ const nodes = Array.from({ length: 12 }, (_, index) => ({
290
+ id: `mixed-${index}`,
291
+ label: `Mixed node ${index}`,
292
+ type: "entity",
293
+ community: index < 6 ? "left" : "right",
294
+ source_path: `wiki/mixed/${index}.md`,
295
+ weight: 30,
296
+ x: (index * 13) % 100,
297
+ y: (index * 29) % 100
298
+ }));
299
+ const edges = Array.from({ length: 8 }, (_, index) => ({
300
+ id: `mixed-edge-${index}`,
301
+ from: `mixed-${index % 6}`,
302
+ to: `mixed-${6 + (index % 6)}`,
303
+ type: "INFERRED",
304
+ confidence: "INFERRED",
305
+ relation_type: "依赖",
306
+ weight: 0.5
307
+ }));
308
+ return {
309
+ meta: {
310
+ build_date: "2026-06-18T00:00:00.000Z",
311
+ wiki_title: "Mixed Cross Community",
312
+ total_nodes: nodes.length,
313
+ total_edges: edges.length
314
+ },
315
+ nodes,
316
+ edges,
317
+ learning: {
318
+ version: 1,
319
+ entry: { recommended_start_node_id: "mixed-0", recommended_start_reason: "fixture", default_mode: "global" },
320
+ views: {
321
+ path: { enabled: false, start_node_id: null, node_ids: [], degraded: true },
322
+ community: { enabled: false, community_id: null, label: null, node_ids: [], is_weak: true, degraded: true },
323
+ global: { enabled: true, node_ids: nodes.map((node) => node.id), degraded: false }
324
+ },
325
+ communities: [
326
+ { id: "left", label: "left", node_count: 6, color_index: 0, is_weak: true },
327
+ { id: "right", label: "right", node_count: 6, color_index: 1, is_weak: true }
328
+ ]
329
+ }
330
+ };
331
+ }
332
+
333
+ describe("buildRenderableGraph", () => {
334
+ it("maps graph data to static renderable nodes, edges, communities, and minimap points", () => {
335
+ const graph = buildRenderableGraph(sampleGraph(), { theme: "shan-shui" });
336
+
337
+ assert.equal(graph.counts.totalNodes, 4);
338
+ assert.equal(graph.nodes.length, 4);
339
+ assert.equal(graph.edges.length, 2);
340
+ assert.equal(graph.communities.length, 3);
341
+ assert.equal(graph.densityMode, "card");
342
+ assert.equal(graph.nodes.find((node) => node.id === "topic")?.visualRole, "index-slip");
343
+ assert.equal(graph.edges[0].type, "extracted");
344
+ assert.equal(graph.edges[0].confidence, "extracted");
345
+ assert.equal(graph.edges[0].relationType, "实现");
346
+ assert.equal(graph.edges[0].relationClass, "relation-implementation");
347
+ assert.equal(graph.edges[1].confidence, "inferred");
348
+ assert.equal(graph.edges[1].relationType, "对比");
349
+ assert.equal(graph.edges[1].relationClass, "relation-contrast");
350
+ assert.match(graph.edges[0].path, /^M \d+ \d+ Q /);
351
+ assert.equal(graph.minimap.path, "M8 40 C34 20 54 36 76 22 C98 8 118 24 150 12");
352
+ assert.equal(graph.minimap.nodes.length, 4);
353
+ });
354
+
355
+ it("uses low-weight global edges and fuller focused relation edges", () => {
356
+ const global = buildRenderableGraph(sampleGraph(), { theme: "shan-shui" });
357
+ const focused = buildRenderableGraph(sampleGraph(), {
358
+ theme: "shan-shui",
359
+ focus: { kind: "community", id: "c1" }
360
+ });
361
+
362
+ assert.equal(global.edges.find((edge) => edge.id === "e1")?.relationClass, "relation-implementation");
363
+ assert.equal(global.edges.find((edge) => edge.id === "e2")?.relationClass, "relation-contrast");
364
+ assert.equal(focused.edges[0].relationClass, "relation-implementation");
365
+ assert.ok(focused.edges[0].strokeWidth > global.edges[0].strokeWidth, "focused relation edge should render with a fuller stroke");
366
+ assert.ok(focused.edges[0].opacity > global.edges[0].opacity, "focused relation edge should render with higher opacity");
367
+ });
368
+
369
+ it("uses pins as the cold-start coordinates when a node source path matches", () => {
370
+ const graph = buildRenderableGraph(sampleGraph(), {
371
+ theme: "shan-shui",
372
+ pins: {
373
+ "wiki/entity.md": { x: 800, y: 340, coordinateSpace: "world" }
374
+ }
375
+ });
376
+
377
+ const pinned = graph.nodes.find((node) => node.id === "entity");
378
+ assert.ok(pinned);
379
+ assert.equal(pinned.x, 80);
380
+ assert.equal(pinned.y, 50);
381
+ assert.deepEqual(pinned.point, { x: 800, y: 340 });
382
+ });
383
+
384
+ it("keeps explicit world pins readable even when coordinates look like old percentages", () => {
385
+ const graph = buildRenderableGraph(sampleGraph(), {
386
+ theme: "shan-shui",
387
+ pins: {
388
+ "wiki/entity.md": { x: 80, y: -42.5, coordinateSpace: "world" }
389
+ }
390
+ });
391
+
392
+ const pinned = graph.nodes.find((node) => node.id === "entity");
393
+ assert.ok(pinned);
394
+ assert.deepEqual(pinned.point, { x: 80, y: -42.5 });
395
+ assert.ok(graph.worldBounds.minY < 0);
396
+ });
397
+
398
+ it("continues to read migrated old percent pins with an explicit coordinate-space marker", () => {
399
+ const graph = buildRenderableGraph(sampleGraph(), {
400
+ theme: "shan-shui",
401
+ pins: {
402
+ "wiki/entity.md": { x: 80, y: 50, coordinateSpace: "legacy-percent" }
403
+ }
404
+ });
405
+
406
+ const pinned = graph.nodes.find((node) => node.id === "entity");
407
+ assert.ok(pinned);
408
+ assert.deepEqual(pinned.point, { x: 800, y: 340 });
409
+ });
410
+
411
+ it("infers wiki-relative source paths for graph data without source_path", () => {
412
+ const data = sampleGraph();
413
+ data.nodes = data.nodes.map(({ source_path: _sourcePath, ...node }) => node);
414
+ const graph = buildRenderableGraph(data, {
415
+ theme: "shan-shui",
416
+ pins: {
417
+ "wiki/topics/topic.md": { x: 900, y: 408, coordinateSpace: "world" }
418
+ }
419
+ });
420
+
421
+ const topic = graph.nodes.find((node) => node.id === "topic");
422
+ assert.ok(topic);
423
+ assert.equal(topic.sourcePath, "wiki/topics/topic.md");
424
+ assert.deepEqual(topic.point, { x: 900, y: 408 });
425
+ });
426
+
427
+ it("marks selected nodes and preserves cinnabar visual role", () => {
428
+ const graph = buildRenderableGraph(sampleGraph(), {
429
+ theme: "mo-ye",
430
+ selection: { kind: "node", id: "source" }
431
+ });
432
+
433
+ const selected = graph.nodes.find((node) => node.id === "source");
434
+ assert.ok(selected);
435
+ assert.equal(selected.selected, true);
436
+ assert.equal(selected.visualRole, "cinnabar-note");
437
+ assert.equal(graph.minimap.nodes.find((node) => node.id === "source")?.selected, true);
438
+ });
439
+
440
+ it("marks shift-style multi-node selections", () => {
441
+ const graph = buildRenderableGraph(sampleGraph(), {
442
+ theme: "shan-shui",
443
+ selection: { kind: "nodes", ids: ["topic", "source"] }
444
+ });
445
+
446
+ const selected = graph.nodes.filter((node) => node.selected).map((node) => node.id);
447
+ assert.deepEqual(selected, ["topic", "source"]);
448
+ assert.notEqual(graph.nodes.find((node) => node.id === "topic")?.displayMode, "card");
449
+ assert.equal(graph.nodes.find((node) => node.id === "source")?.visualRole, "cinnabar-note");
450
+ assert.equal(graph.minimap.nodes.filter((node) => node.selected).length, 2);
451
+ });
452
+
453
+ it("enforces zero full cards in global view even for selected, search, and pinned nodes", () => {
454
+ const data = budgetGraph(80, 1200);
455
+ const graph = buildRenderableGraph(data, {
456
+ theme: "shan-shui",
457
+ selection: { kind: "node", id: "n79" },
458
+ searchResultIds: data.nodes.map((node) => node.id),
459
+ pins: {
460
+ "wiki/budget/n79.md": { x: 900, y: 500, coordinateSpace: "world" }
461
+ }
462
+ });
463
+
464
+ assert.equal(graph.budget.view, "global");
465
+ assert.equal(graph.budget.limits.maxCards, GRAPH_RENDER_BUDGETS.global.maxCards);
466
+ assert.equal(graph.budget.usage.maxCards, 0);
467
+ assert.equal(graph.nodes.filter((node) => node.displayMode === "card").length, 0);
468
+ assert.ok(graph.nodes.find((node) => node.id === "n79")?.labelVisible, "selected and pinned node should be promoted into labels");
469
+ });
470
+
471
+ it("keeps global labels, edges, and interaction updates within budget and reports overflow", () => {
472
+ const data = budgetGraph(200, 1200);
473
+ const graph = buildRenderableGraph(data, {
474
+ theme: "shan-shui",
475
+ searchResultIds: data.nodes.map((node) => node.id)
476
+ });
477
+
478
+ assert.ok(graph.budget.usage.maxLabels <= GRAPH_RENDER_BUDGETS.global.maxLabels);
479
+ assert.ok(graph.budget.usage.maxVisibleEdges <= GRAPH_RENDER_BUDGETS.global.maxVisibleEdges);
480
+ assert.ok(graph.budget.usage.maxInteractionUpdates <= GRAPH_RENDER_BUDGETS.global.maxInteractionUpdates);
481
+ assert.equal(graph.nodes.filter((node) => node.labelVisible).length, GRAPH_RENDER_BUDGETS.global.maxLabels);
482
+ assert.equal(graph.edges.length, GRAPH_RENDER_BUDGETS.global.maxVisibleEdges);
483
+ assert.ok(graph.overflow.labels.hidden > 0);
484
+ assert.ok(graph.overflow.edges.hidden > 0);
485
+ assert.ok(graph.overflow.interactionUpdates.hidden > 0);
486
+ assert.equal(graph.overflow.labels.total, 200);
487
+ assert.equal(graph.overflow.edges.total, 1200);
488
+ });
489
+
490
+ it("keeps interaction-time detail updates inside budget while preserving anchors", () => {
491
+ const data = budgetGraph(200, 1200);
492
+ const graph = buildRenderableGraph(data, {
493
+ theme: "shan-shui",
494
+ selection: { kind: "node", id: "n199" },
495
+ searchResultIds: ["n198", "n199"],
496
+ pins: {
497
+ "wiki/budget/n197.md": { x: 850, y: 500, coordinateSpace: "world" }
498
+ }
499
+ });
500
+
501
+ assert.ok(graph.interaction.updatedObjects <= GRAPH_RENDER_BUDGETS.global.maxInteractionUpdates);
502
+ assert.ok(graph.interaction.updateCandidates < graph.overflow.interactionUpdates.total);
503
+ assert.ok(graph.interaction.edgesVisibleDuringInteraction <= graph.budget.usage.maxVisibleEdges);
504
+ assert.ok(graph.interaction.preservedNodeIds.includes("n199"), "selected node should stay traceable");
505
+ assert.ok(graph.interaction.preservedNodeIds.includes("n198"), "searched node should stay traceable");
506
+ assert.ok(graph.interaction.preservedNodeIds.includes("n197"), "pinned node should stay traceable");
507
+ assert.ok(graph.interaction.preservedNodeIds.some((id) => graph.importance.stableCoreNodeIds.includes(id)), "stable core anchors should stay traceable");
508
+ });
509
+
510
+ it("keeps focused community nodes as a lightweight map without full cards", () => {
511
+ const data = budgetGraph(80, 1200);
512
+ const graph = buildRenderableGraph(data, {
513
+ theme: "shan-shui",
514
+ focus: { kind: "community", id: "c1" },
515
+ searchResultIds: data.nodes.map((node) => node.id),
516
+ pins: {
517
+ "wiki/budget/n79.md": { x: 900, y: 500, coordinateSpace: "world" }
518
+ }
519
+ });
520
+
521
+ assert.equal(graph.budget.view, "community");
522
+ assert.equal(graph.nodes.length, 80);
523
+ assert.equal(graph.budget.limits.maxCards, 0);
524
+ assert.equal(graph.budget.usage.maxCards, 0);
525
+ assert.equal(graph.nodes.filter((node) => node.displayMode === "card").length, 0);
526
+ assert.ok(graph.nodes.find((node) => node.id === "n79")?.labelVisible, "selected/search/pinned context should still be eligible for a label");
527
+ assert.ok(graph.nodes.filter((node) => node.labelVisible).length <= graph.budget.limits.maxLabels);
528
+ assert.equal(graph.overflow.cards.total, 0);
529
+ assert.equal(graph.overflow.cards.hidden, 0);
530
+
531
+ const firstNode = graph.nodes[0];
532
+ assert.ok(firstNode.communityMapDotSize >= 9, `community map dot should keep a floor size, got ${firstNode.communityMapDotSize}`);
533
+ assert.ok(firstNode.communityMapDotSize <= 24, `community map dot should respect the importance ceiling, got ${firstNode.communityMapDotSize}`);
534
+ assert.ok(["left", "right", "top", "bottom"].includes(firstNode.communityMapLabelSide));
535
+ assert.equal(typeof firstNode.communityMapRelationLabel, "boolean");
536
+ });
537
+
538
+ it("uses the small community band as a lightweight map with sparse labels", () => {
539
+ const graph = buildRenderableGraph(budgetGraph(24, 120), {
540
+ theme: "shan-shui",
541
+ focus: { kind: "community", id: "c1" }
542
+ });
543
+
544
+ assert.equal(graph.communityFocus?.sizeBand, "small");
545
+ assert.equal(graph.communityFocus?.representation, "cards-and-labels");
546
+ assert.equal(graph.communityFocus?.completePresence, "nodes");
547
+ assert.equal(graph.nodes.length, 24);
548
+ assert.equal(graph.nodes.filter((node) => node.displayMode === "card").length, 0);
549
+ assert.ok(graph.nodes.filter((node) => node.labelVisible).length <= GRAPH_COMMUNITY_FOCUS_BUDGETS.small.maxLabels);
550
+ assert.ok(graph.nodes.some((node) => node.displayMode === "point" || node.displayMode === "overview"), "ordinary nodes should remain point-like");
551
+ });
552
+
553
+ it("uses the medium community band with all nodes present and no full cards", () => {
554
+ const graph = buildRenderableGraph(budgetGraph(120, 600), {
555
+ theme: "shan-shui",
556
+ focus: { kind: "community", id: "c1" },
557
+ searchResultIds: Array.from({ length: 120 }, (_, index) => `n${index}`)
558
+ });
559
+ const cardCount = graph.nodes.filter((node) => node.displayMode === "card").length;
560
+ const pointCount = graph.nodes.filter((node) => node.displayMode === "point" || node.displayMode === "overview").length;
561
+
562
+ assert.equal(graph.communityFocus?.sizeBand, "medium");
563
+ assert.equal(graph.communityFocus?.representation, "points-with-cards");
564
+ assert.equal(graph.nodes.length, 120);
565
+ assert.equal(cardCount, 0);
566
+ assert.ok(pointCount > 0);
567
+ assert.ok(graph.nodes.filter((node) => node.labelVisible).length <= GRAPH_COMMUNITY_FOCUS_BUDGETS.medium.maxLabels);
568
+ });
569
+
570
+ it("uses the large community band as a lightweight outline map with strict label caps", () => {
571
+ const graph = buildRenderableGraph(budgetGraph(800, 1400), {
572
+ theme: "shan-shui",
573
+ focus: { kind: "community", id: "c1" },
574
+ searchResultIds: Array.from({ length: 800 }, (_, index) => `n${index}`)
575
+ });
576
+
577
+ assert.equal(graph.communityFocus?.sizeBand, "large");
578
+ assert.equal(graph.communityFocus?.representation, "outline-with-caps");
579
+ assert.equal(graph.communityFocus?.completePresence, "outline");
580
+ assert.equal(graph.nodes.length, 800);
581
+ assert.equal(graph.nodes.filter((node) => node.displayMode === "card").length, 0);
582
+ assert.equal(graph.nodes.filter((node) => node.labelVisible).length, GRAPH_COMMUNITY_FOCUS_BUDGETS.large.maxLabels);
583
+ assert.ok(graph.edges.length > 0);
584
+ assert.ok(graph.edges.length <= GRAPH_COMMUNITY_FOCUS_BUDGETS.large.maxVisibleEdges);
585
+ });
586
+
587
+ it("uses the oversized community band as an internal-map entry without rendering every member as a card", () => {
588
+ const graph = buildRenderableGraph(budgetGraph(3000, 1200), {
589
+ theme: "shan-shui",
590
+ focus: { kind: "community", id: "c1" },
591
+ searchResultIds: Array.from({ length: 3000 }, (_, index) => `n${index}`)
592
+ });
593
+
594
+ assert.equal(graph.communityFocus?.sizeBand, "oversized");
595
+ assert.equal(graph.communityFocus?.representation, "internal-map-entry");
596
+ assert.equal(graph.communityFocus?.completePresence, "internal-map");
597
+ assert.equal(graph.nodes.length, GRAPH_COMMUNITY_FOCUS_BUDGETS.oversized.maxVisibleNodes);
598
+ assert.equal(graph.nodes.filter((node) => node.displayMode === "card").length, 0);
599
+ assert.equal(graph.nodes.filter((node) => node.labelVisible).length, GRAPH_COMMUNITY_FOCUS_BUDGETS.oversized.maxLabels);
600
+ assert.ok(graph.overflow.nodes.hidden > 0);
601
+ });
602
+
603
+ it("keeps stable core anchors unchanged when search boosts change", () => {
604
+ const data = budgetGraph(200, 1200);
605
+ const baseline = buildRenderableGraph(data, { theme: "shan-shui" });
606
+ const searched = buildRenderableGraph(data, {
607
+ theme: "shan-shui",
608
+ searchResultIds: data.nodes.slice(120).map((node) => node.id)
609
+ });
610
+
611
+ assert.deepEqual(searched.importance.stableCoreNodeIds, baseline.importance.stableCoreNodeIds);
612
+ assert.deepEqual(searched.importance.stableSkeletonEdgeIds, baseline.importance.stableSkeletonEdgeIds);
613
+ assert.ok(searched.importance.temporaryBoostNodeIds.includes("n199"));
614
+ assert.equal(searched.nodes.find((node) => node.id === "n199")?.coreAnchor, baseline.nodes.find((node) => node.id === "n199")?.coreAnchor);
615
+ });
616
+
617
+ it("lets search and selection boost visibility without rewriting stable core identity", () => {
618
+ const data = budgetGraph(200, 1200);
619
+ const baseline = buildRenderableGraph(data, { theme: "shan-shui" });
620
+ const boosted = buildRenderableGraph(data, {
621
+ theme: "shan-shui",
622
+ selection: { kind: "node", id: "n199" },
623
+ searchResultIds: ["n199"]
624
+ });
625
+ const node = boosted.nodes.find((item) => item.id === "n199");
626
+
627
+ assert.ok(node);
628
+ assert.deepEqual(boosted.importance.stableCoreNodeIds, baseline.importance.stableCoreNodeIds);
629
+ assert.equal(node.labelVisible, true);
630
+ assert.ok(node.temporaryBoost > 0);
631
+ assert.equal(node.coreAnchor, baseline.nodes.find((item) => item.id === "n199")?.coreAnchor);
632
+ });
633
+
634
+ it("keeps many search hits, many pins, and a pressured selected object inside budget caps", () => {
635
+ const data = budgetGraph(200, 1200);
636
+ const pins = Object.fromEntries(
637
+ data.nodes.slice(80).map((node) => [node.source_path || `wiki/budget/${node.id}.md`, { x: 700, y: 420, coordinateSpace: "world" as const }])
638
+ );
639
+ const graph = buildRenderableGraph(data, {
640
+ theme: "shan-shui",
641
+ selection: { kind: "node", id: "n199" },
642
+ searchResultIds: data.nodes.map((node) => node.id),
643
+ pins
644
+ });
645
+
646
+ assert.ok(graph.importance.temporaryBoostNodeIds.length > GRAPH_RENDER_BUDGETS.global.maxLabels);
647
+ assert.ok(graph.budget.usage.maxLabels <= GRAPH_RENDER_BUDGETS.global.maxLabels);
648
+ assert.ok(graph.budget.usage.maxVisibleEdges <= GRAPH_RENDER_BUDGETS.global.maxVisibleEdges);
649
+ assert.ok(graph.budget.usage.maxInteractionUpdates <= GRAPH_RENDER_BUDGETS.global.maxInteractionUpdates);
650
+ assert.equal(graph.nodes.find((node) => node.id === "n199")?.labelVisible, true);
651
+ assert.ok(graph.overflow.labels.hidden > 0);
652
+ });
653
+
654
+ it("keeps crowded accepted global graphs as sparse point maps without aggregation", () => {
655
+ const data = densePointMapGraph();
656
+ const graph = buildRenderableGraph(data, {
657
+ theme: "shan-shui",
658
+ selection: { kind: "node", id: "dense-1999" },
659
+ searchResultIds: ["dense-20", "dense-120", "dense-1220"],
660
+ pins: {
661
+ "wiki/dense/dense-40.md": { x: 860, y: 500, coordinateSpace: "world" },
662
+ "wiki/dense/dense-1440.md": { x: 920, y: 540, coordinateSpace: "world" }
663
+ },
664
+ aggregationMarkers: [
665
+ {
666
+ id: "dense-aggregation",
667
+ label: "Dense aggregation should stay hidden",
668
+ communityId: "dense-community-0",
669
+ nodeIds: data.nodes.slice(0, 200).map((node) => node.id),
670
+ totalCount: 200
671
+ }
672
+ ]
673
+ });
674
+ const selected = graph.nodes.find((node) => node.id === "dense-1999");
675
+ const searched = ["dense-20", "dense-120", "dense-1220"].map((id) => graph.nodes.find((node) => node.id === id));
676
+ const pinned = ["dense-40", "dense-1440"].map((id) => graph.nodes.find((node) => node.id === id));
677
+ const ordinaryNodes = graph.nodes.filter((node) => !node.selected && node.temporaryBoost === 0 && !node.coreAnchor);
678
+ const weakEdge = graph.edges.find((edge) => edge.id === "dense-selected-weak");
679
+ const strongEdge = graph.edges.find((edge) => edge.id === "dense-selected-strong");
680
+
681
+ assert.equal(graph.counts.visibleNodes, 2000);
682
+ assert.equal(graph.counts.totalEdges, 3996);
683
+ assert.equal(graph.budget.view, "global");
684
+ assert.equal(graph.densityMode, "overview");
685
+ assert.equal(graph.aggregationContainers.length, 0);
686
+ assert.equal(graph.budget.usage.maxCards, 0);
687
+ assert.equal(graph.nodes.filter((node) => node.displayMode === "card").length, 0);
688
+ assert.ok(ordinaryNodes.length > 1500);
689
+ assert.ok(ordinaryNodes.every((node) => node.displayMode === "overview"), "ordinary dense nodes should stay in overview point mode");
690
+ assert.ok(graph.budget.usage.maxLabels <= GRAPH_RENDER_BUDGETS.global.maxLabels);
691
+ assert.ok(graph.nodes.filter((node) => node.labelVisible).length <= GRAPH_RENDER_BUDGETS.global.maxLabels);
692
+ assert.ok(graph.nodes.filter((node) => node.labelVisible).length / graph.nodes.length <= 0.03);
693
+ assert.ok(graph.budget.usage.maxVisibleEdges <= GRAPH_RENDER_BUDGETS.global.maxVisibleEdges);
694
+ assert.ok(graph.budget.usage.maxInteractionUpdates <= GRAPH_RENDER_BUDGETS.global.maxInteractionUpdates);
695
+ assert.ok(graph.interaction.updatedObjects <= GRAPH_RENDER_BUDGETS.global.maxInteractionUpdates);
696
+ assert.ok(selected);
697
+ assert.equal(selected.selected, true);
698
+ assert.equal(selected.labelVisible, true);
699
+ assert.ok(searched.every(Boolean));
700
+ assert.ok(searched.every((node) => node?.labelVisible === true));
701
+ assert.ok(pinned.every(Boolean));
702
+ assert.ok(pinned.every((node) => node?.labelVisible === true));
703
+ assert.ok(graph.importance.stableCoreNodeIds.every((id) => graph.nodes.some((node) => node.id === id)), "core anchors should stay visible");
704
+ assert.ok(weakEdge);
705
+ assert.ok(strongEdge);
706
+ assert.ok(weakEdge.opacity < strongEdge.opacity, "weak dense edges should be faded behind strong edges");
707
+ assert.ok(weakEdge.strokeWidth < strongEdge.strokeWidth, "weak dense edges should be thinner than strong edges");
708
+ });
709
+
710
+ it("does not produce visible aggregation containers in the normal render model", () => {
711
+ const data = budgetGraph(20, 40);
712
+ const pins = {
713
+ "wiki/budget/n3.md": { x: 700, y: 420, coordinateSpace: "world" as const }
714
+ };
715
+ const graph = buildRenderableGraph(data, {
716
+ theme: "shan-shui",
717
+ selection: { kind: "node", id: "n2" },
718
+ searchResultIds: ["n1", "n4"],
719
+ pins,
720
+ aggregationMarkers: [
721
+ {
722
+ id: "agg-c1",
723
+ label: "Budget container",
724
+ communityId: "c1",
725
+ nodeIds: ["n1", "n2", "n3", "n4"],
726
+ totalCount: 12
727
+ }
728
+ ]
729
+ });
730
+
731
+ assert.deepEqual(graph.aggregationContainers, []);
732
+ });
733
+
734
+ it("marks moderate community quality without auxiliary organization modes", () => {
735
+ const graph = buildRenderableGraph(manyTinyCommunitiesGraph(), { theme: "shan-shui" });
736
+
737
+ assert.equal(graph.communityQuality.level, "moderate");
738
+ assert.equal(graph.communityQuality.boundaryCertainty, "reduced");
739
+ assert.equal(graph.communityQuality.warning, "moderate-community-quality");
740
+ assert.deepEqual(graph.communityQuality.signals.map((signal) => signal.id), ["many-tiny-communities"]);
741
+ assert.deepEqual(graph.communityQuality.auxiliaryViews, []);
742
+ });
743
+
744
+ it("lowers boundary certainty and exposes only core connectivity for poor community quality", () => {
745
+ const graph = buildRenderableGraph(oversizedWeakCommunityGraph(), { theme: "shan-shui" });
746
+
747
+ assert.equal(graph.communityQuality.level, "poor");
748
+ assert.equal(graph.communityQuality.boundaryCertainty, "low");
749
+ assert.deepEqual(graph.communityQuality.auxiliaryViews, [
750
+ { id: "core-structure-connectivity", label: "核心结构 / 连通性" }
751
+ ]);
752
+ assert.deepEqual(
753
+ graph.communityQuality.signals.map((signal) => signal.id),
754
+ ["oversized-community", "weak-community-labels", "abnormal-community-count"]
755
+ );
756
+ assert.ok(graph.communities.every((community) => community.boundaryCertainty === "low"));
757
+ assert.deepEqual(graph.communityQuality.auxiliaryViews.map((view) => view.id), ["core-structure-connectivity"]);
758
+ assert.equal(graph.communityQuality.auxiliaryViews.some((view) => /type|source|time/i.test(view.id)), false);
759
+ });
760
+
761
+ it("detects mixed cross-community edges as an explicit quality signal", () => {
762
+ const quality = evaluateCommunityQuality(mixedCrossCommunityGraph());
763
+
764
+ assert.equal(quality.level, "poor");
765
+ assert.ok(quality.signals.some((signal) => signal.id === "mixed-cross-community-edges"));
766
+ assert.deepEqual(quality.auxiliaryViews.map((view) => view.id), ["core-structure-connectivity"]);
767
+ });
768
+
769
+ it("enters a community focus view by hiding nodes outside the selected community", () => {
770
+ const graph = buildRenderableGraph(sampleGraph(), {
771
+ theme: "shan-shui",
772
+ focus: { kind: "community", id: "c1" }
773
+ });
774
+
775
+ assert.deepEqual(graph.nodes.map((node) => node.id), ["topic", "entity"]);
776
+ assert.deepEqual(graph.edges.map((edge) => edge.id), ["e1"]);
777
+ assert.equal(graph.counts.visibleNodes, 2);
778
+ assert.equal(graph.counts.totalNodes, 4);
779
+ assert.equal(graph.focus?.kind, "community");
780
+ assert.equal(graph.focus?.id, "c1");
781
+ assert.deepEqual(
782
+ communityWashStates(graph),
783
+ [["c1", true], ["c2", false], ["c3", false]]
784
+ );
785
+ });
786
+
787
+ it("filters visible nodes by graph node type and stacks with community focus", () => {
788
+ const graph = buildRenderableGraph(sampleGraph(), {
789
+ theme: "shan-shui",
790
+ focus: { kind: "community", id: "c1" },
791
+ typeFilters: {
792
+ entity: true,
793
+ topic: false,
794
+ source: true
795
+ }
796
+ });
797
+
798
+ assert.deepEqual(graph.nodes.map((node) => node.id), ["entity"]);
799
+ assert.deepEqual(graph.edges, []);
800
+ assert.equal(graph.counts.visibleNodes, 1);
801
+ assert.equal(graph.typeFilters.topic, false);
802
+ });
803
+
804
+ it("preserves community focus and type filters when positions are reapplied", () => {
805
+ const graph = buildRenderableGraph(sampleGraph(), {
806
+ theme: "shan-shui",
807
+ focus: { kind: "community", id: "c1" },
808
+ typeFilters: {
809
+ entity: true,
810
+ topic: false,
811
+ source: true
812
+ },
813
+ positions: {
814
+ topic: { x: 500, y: 500 },
815
+ entity: { x: 420, y: 320 },
816
+ source: { x: 900, y: 120 },
817
+ island: { x: 120, y: 120 }
818
+ }
819
+ });
820
+
821
+ assert.deepEqual(graph.nodes.map((node) => node.id), ["entity"]);
822
+ assert.deepEqual(graph.edges, []);
823
+ assert.equal(graph.focus?.id, "c1");
824
+ assert.equal(graph.typeFilters.topic, false);
825
+ assert.deepEqual(
826
+ communityWashStates(graph),
827
+ [["c1", true], ["c2", false], ["c3", false]]
828
+ );
829
+ });
830
+
831
+ it("keeps community wash around the member cluster instead of chasing an outlier", () => {
832
+ const graph = buildRenderableGraph(outlierCommunityGraph(), { theme: "shan-shui" });
833
+ const community = graph.communities.find((item) => item.id === "c1");
834
+
835
+ assert.ok(community?.wash);
836
+ assert.equal(community.nodeCount, 5);
837
+ assert.ok(community.wash.cx > 300, `wash center should respond toward the outlier, got ${community.wash.cx}`);
838
+ assert.ok(community.wash.cx < 430, `wash center should stay near the clustered members, got ${community.wash.cx}`);
839
+ assert.equal(community.wash.rx, 190);
840
+ assert.equal(community.wash.ry, 142.8);
841
+ });
842
+
843
+ it("keeps community membership stable when a pinned member is outside the wash cap", () => {
844
+ const graph = buildRenderableGraph(outlierCommunityGraph(), {
845
+ theme: "shan-shui",
846
+ pins: {
847
+ "wiki/outlier.md": { x: 980, y: 650 }
848
+ }
849
+ });
850
+ const community = graph.communities.find((item) => item.id === "c1");
851
+ const outlier = graph.nodes.find((node) => node.id === "outlier");
852
+
853
+ assert.ok(community?.wash);
854
+ assert.ok(outlier);
855
+ assert.equal(outlier.community, "c1");
856
+ assert.equal(community.nodeCount, 5);
857
+ assert.equal(community.wash.rx, 190);
858
+ assert.equal(community.wash.ry, 142.8);
859
+ assert.ok(outlier.point.x > community.wash.cx + community.wash.rx, "pinned member may sit outside the capped visual wash");
860
+ });
861
+
862
+ it("lets a dragged core member reshape the wash within caps without changing membership", () => {
863
+ const before = buildRenderableGraph(outlierCommunityGraph(), { theme: "shan-shui" });
864
+ const after = buildRenderableGraph(outlierCommunityGraph(), {
865
+ theme: "shan-shui",
866
+ positions: {
867
+ "core-a": { x: 980, y: 650 }
868
+ }
869
+ });
870
+ const beforeCommunity = before.communities.find((item) => item.id === "c1");
871
+ const afterCommunity = after.communities.find((item) => item.id === "c1");
872
+ const dragged = after.nodes.find((node) => node.id === "core-a");
873
+
874
+ assert.ok(beforeCommunity?.wash);
875
+ assert.ok(afterCommunity?.wash);
876
+ assert.ok(dragged);
877
+ assert.equal(dragged.community, "c1");
878
+ assert.equal(afterCommunity.nodeCount, beforeCommunity.nodeCount);
879
+ assert.notEqual(afterCommunity.wash.cx, beforeCommunity.wash.cx);
880
+ assert.ok(afterCommunity.wash.cx > beforeCommunity.wash.cx, "wash should move toward the dragged member");
881
+ assert.equal(afterCommunity.wash.rx, 190);
882
+ assert.equal(afterCommunity.wash.ry, 142.8);
883
+ });
884
+
885
+ it("preserves community focus after a member is dragged beyond the wash cap", () => {
886
+ const graph = buildRenderableGraph(outlierCommunityGraph(), {
887
+ theme: "shan-shui",
888
+ focus: { kind: "community", id: "c1" },
889
+ positions: {
890
+ outlier: { x: 980, y: 650 }
891
+ }
892
+ });
893
+ const community = graph.communities.find((item) => item.id === "c1");
894
+
895
+ assert.deepEqual(graph.nodes.map((node) => node.id).sort(), ["core-a", "core-b", "core-c", "core-d", "outlier"]);
896
+ assert.ok(community?.wash);
897
+ assert.equal(graph.focus?.id, "c1");
898
+ assert.equal(community.wash.rx, 190);
899
+ assert.equal(community.wash.ry, 142.8);
900
+ });
901
+
902
+ it("preserves live drag positions outside the old default world", () => {
903
+ const graph = buildRenderableGraph(outlierCommunityGraph(), {
904
+ theme: "shan-shui",
905
+ positions: {
906
+ outlier: { x: 1240, y: 816 }
907
+ }
908
+ });
909
+ const outlier = graph.nodes.find((node) => node.id === "outlier");
910
+
911
+ assert.ok(outlier);
912
+ assert.deepEqual(outlier.point, { x: 1240, y: 816 });
913
+ assert.equal(outlier.x, 93.939);
914
+ assert.equal(outlier.y, 91.071);
915
+ assert.equal(graph.worldBounds.maxX, 1320);
916
+ assert.equal(graph.worldBounds.maxY, 896);
917
+ assert.equal(outlier.community, "c1");
918
+ });
919
+
920
+ it("preserves pinned positions outside the old default world by expanding render bounds", () => {
921
+ const graph = buildRenderableGraph(outlierCommunityGraph(), {
922
+ theme: "shan-shui",
923
+ pins: {
924
+ "wiki/outlier.md": { x: 1240, y: 816, coordinateSpace: "world" }
925
+ }
926
+ });
927
+ const outlier = graph.nodes.find((node) => node.id === "outlier");
928
+
929
+ assert.ok(outlier);
930
+ assert.deepEqual(outlier.point, { x: 1240, y: 816 });
931
+ assert.equal(outlier.x, 93.939);
932
+ assert.equal(outlier.y, 91.071);
933
+ assert.equal(graph.worldBounds.width, 1320);
934
+ assert.equal(graph.worldBounds.height, 896);
935
+ });
936
+
937
+ it("does not let expanded render bounds enlarge the community wash cap", () => {
938
+ const graph = buildRenderableGraph(outlierCommunityGraph(), {
939
+ theme: "shan-shui",
940
+ positions: {
941
+ outlier: { x: 5000, y: 3400 }
942
+ }
943
+ });
944
+ const community = graph.communities.find((item) => item.id === "c1");
945
+ const outlier = graph.nodes.find((node) => node.id === "outlier");
946
+
947
+ assert.ok(community?.wash);
948
+ assert.ok(outlier);
949
+ assert.ok(graph.worldBounds.width > 5000, `world bounds should expand to include the outlier, got ${graph.worldBounds.width}`);
950
+ assert.ok(graph.worldBounds.height > 3400, `world bounds should expand to include the outlier, got ${graph.worldBounds.height}`);
951
+ assert.equal(community.wash.rx, 190);
952
+ assert.equal(community.wash.ry, 142.8);
953
+ assert.ok(outlier.point.x > community.wash.cx + community.wash.rx, "the node can sit outside the capped visual wash");
954
+ assert.equal(outlier.community, "c1");
955
+ });
956
+ });
957
+
958
+ function communityWashStates(graph: ReturnType<typeof buildRenderableGraph>): Array<[string, boolean]> {
959
+ return graph.communities
960
+ .map((community): [string, boolean] => [community.id, Boolean(community.wash)])
961
+ .sort(([left], [right]) => left.localeCompare(right));
962
+ }
963
+
964
+ describe("screen-effective density", () => {
965
+ it("uses viewport scale to choose the effective density mode", () => {
966
+ assert.equal(screenEffectiveDensityMode(120, 1), "compact-card");
967
+ assert.equal(screenEffectiveDensityMode(120, 2), "card");
968
+ assert.equal(screenEffectiveDensityMode(120, 0.5), "point-plus-focus");
969
+ assert.equal(screenEffectiveDensityMode(30, 0.5), "compact-card");
970
+ });
971
+
972
+ it("maps effective density to node display without changing selected cards", () => {
973
+ const node = {
974
+ selected: false,
975
+ labelVisible: false,
976
+ visualRole: "map-pin" as const
977
+ };
978
+ const labeledNode = {
979
+ selected: false,
980
+ labelVisible: true,
981
+ visualRole: "map-pin" as const
982
+ };
983
+ const selectedNode = {
984
+ selected: true,
985
+ labelVisible: false,
986
+ visualRole: "map-pin" as const
987
+ };
988
+
989
+ assert.equal(nodeDisplayModeForDensity(node, "card"), "card");
990
+ assert.equal(nodeDisplayModeForDensity(node, "compact-card"), "compact-card");
991
+ assert.equal(nodeDisplayModeForDensity(node, "point-plus-focus"), "point");
992
+ assert.equal(nodeDisplayModeForDensity(labeledNode, "point-plus-focus"), "compact-card");
993
+ assert.equal(nodeDisplayModeForDensity(selectedNode, "overview"), "card");
994
+ });
995
+ });
996
+
997
+ describe("edge drawing helpers", () => {
998
+ it("keeps graph-wash stroke strength bounds", () => {
999
+ assert.equal(edgeStrokeWidth({ weight: 0 }), 1.1);
1000
+ assert.equal(edgeStrokeWidth({ weight: 1 }), 2.9);
1001
+ assert.equal(edgeOpacity({ weight: 0 }), 0.32);
1002
+ assert.equal(edgeOpacity({ weight: 1 }), 0.76);
1003
+ });
1004
+
1005
+ it("maps relation type to a separate visual class from confidence", () => {
1006
+ assert.equal(edgeRelationClass("实现"), "relation-implementation");
1007
+ assert.equal(edgeRelationClass("依赖"), "relation-dependency");
1008
+ assert.equal(edgeRelationClass("衍生"), "relation-derivation");
1009
+ assert.equal(edgeRelationClass("对比"), "relation-contrast");
1010
+ assert.equal(edgeRelationClass("矛盾"), "relation-conflict");
1011
+ assert.equal(edgeRelationClass("未知"), "relation-dependency");
1012
+ });
1013
+
1014
+ it("keeps global relation edges subdued and focused edges fuller", () => {
1015
+ assert.equal(edgeVisualStrokeWidth({ weight: 1 }, false), 1.7);
1016
+ assert.equal(edgeVisualStrokeWidth({ weight: 1 }, true), 2.9);
1017
+ assert.equal(edgeVisualOpacity({ weight: 1 }, false), 0.42);
1018
+ assert.equal(edgeVisualOpacity({ weight: 1 }, true), 0.76);
1019
+ });
1020
+
1021
+ it("builds a curved path from atlas node coordinates", () => {
1022
+ const path = makeEdgePath(
1023
+ { id: "a", label: "A", type: "entity", kind: "概念", community: "c1", x: 10, y: 20 },
1024
+ { id: "b", label: "B", type: "entity", kind: "概念", community: "c1", x: 60, y: 70 },
1025
+ { weight: 0.5 }
1026
+ );
1027
+
1028
+ assert.equal(path, "M 100 136 Q 274 284 600 476");
1029
+ });
1030
+ });