@joekytc/dsh-swarm 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/README.zh-CN.md +3 -3
- package/client/BoardCard.tsx +24 -2
- package/client/ConfigSection.tsx +71 -0
- package/client/ConfigSelect.tsx +69 -0
- package/client/KanbanBoard.tsx +3 -0
- package/client/KanbanTab.tsx +4 -3
- package/client/TaskDrawer.tsx +2 -26
- package/client/WorkflowRail.tsx +3 -1
- package/client/config-store.ts +51 -0
- package/client/config.css +110 -0
- package/client/index.ts +39 -4
- package/client/kanban.css +19 -2
- package/client/session-bridge.ts +39 -0
- package/client/timeline-model.ts +10 -1
- package/client/workflow-model.ts +3 -1
- package/lib/client.js +358 -53
- package/lib/config.d.ts +8 -1
- package/lib/config.js +6 -1
- package/lib/dispatcher/agent-runner.d.ts +28 -6
- package/lib/dispatcher/agent-runner.js +175 -62
- package/lib/dispatcher/chain-auditor.js +4 -1
- package/lib/dispatcher/dispatcher.d.ts +62 -3
- package/lib/dispatcher/dispatcher.js +243 -20
- package/lib/dispatcher/session-events.d.ts +11 -15
- package/lib/dispatcher/session-events.js +17 -5
- package/lib/dispatcher/v-orchestrator.d.ts +42 -9
- package/lib/dispatcher/v-orchestrator.js +236 -28
- package/lib/domain/config-override.d.ts +38 -0
- package/lib/domain/config-override.js +101 -0
- package/lib/domain/delivery-contract.d.ts +3 -2
- package/lib/domain/delivery-contract.js +28 -16
- package/lib/domain/gate-policy.d.ts +26 -0
- package/lib/domain/gate-policy.js +44 -0
- package/lib/domain/kanban-service.d.ts +16 -3
- package/lib/domain/kanban-service.js +41 -6
- package/lib/domain/permissions.js +1 -1
- package/lib/domain/planning-checklist.d.ts +5 -0
- package/lib/domain/planning-checklist.js +80 -6
- package/lib/domain/projection.js +2 -1
- package/lib/domain/review-evidence.js +1 -1
- package/lib/domain/state-machine.js +2 -1
- package/lib/domain/types.d.ts +2 -2
- package/lib/index.js +19 -21
- package/lib/roles/clean-fs-tools.d.ts +22 -0
- package/lib/roles/clean-fs-tools.js +118 -0
- package/lib/roles/skill-installer.d.ts +6 -0
- package/lib/roles/skill-installer.js +32 -0
- package/lib/roles/toolsets.d.ts +13 -1
- package/lib/roles/toolsets.js +163 -31
- package/lib/roles/wiki-worker.d.ts +1 -0
- package/lib/roles/wiki-worker.js +10 -2
- package/lib/routes/kanban-http.d.ts +5 -2
- package/lib/routes/kanban-http.js +36 -3
- package/lib/routes/planning-driver.d.ts +3 -1
- package/lib/routes/planning-driver.js +10 -6
- package/lib/routes/prefix-router.d.ts +16 -0
- package/lib/routes/prefix-router.js +37 -2
- package/lib/services/config-provider.d.ts +42 -0
- package/lib/services/config-provider.js +94 -0
- package/lib/services/gate-runner.d.ts +24 -0
- package/lib/services/gate-runner.js +87 -0
- package/lib/services/kanban-provider.d.ts +5 -1
- package/lib/services/kanban-provider.js +40 -2
- package/lib/services/llm-catalog.d.ts +35 -0
- package/lib/services/llm-catalog.js +19 -0
- package/lib/tools/kanban-tools.js +1 -0
- package/lib/tools/main-session-tools.d.ts +17 -2
- package/lib/tools/main-session-tools.js +88 -21
- package/lib/tools/planning-tools.d.ts +4 -0
- package/lib/tools/planning-tools.js +39 -12
- package/lib/tools/prefetch-tools.js +1 -0
- package/lib/tools/spec-card-tools.js +1 -0
- package/lib/tools/wiki-tools.js +5 -4
- package/lib/wiki/kb-linkage.d.ts +9 -2
- package/lib/wiki/kb-linkage.js +3 -3
- package/lib/wiki/local-kb-client.d.ts +14 -0
- package/lib/wiki/local-kb-client.js +101 -0
- package/lib/wiki/local-kb.d.ts +6 -0
- package/lib/wiki/local-kb.js +25 -0
- package/lib/wiki/memory-recall.d.ts +14 -6
- package/lib/wiki/memory-recall.js +17 -13
- package/lib/wiki/page-path.d.ts +9 -3
- package/lib/wiki/page-path.js +29 -11
- package/lib/wiki/wiki-vault-client.d.ts +3 -3
- package/lib/wiki/wiki-vault-client.js +6 -6
- package/package.json +16 -11
- package/personas/kanban-d/preset.yml +1 -1
- package/personas/kanban-dt/agent.cordis.yml +2 -2
- package/personas/kanban-dt/preset.yml +1 -1
- package/personas/kanban-p/agent.cordis.yml +16 -0
- package/personas/kanban-p/preset.yml +1 -1
- package/personas/kanban-pt/agent.cordis.yml +38 -8
- package/personas/kanban-pt/preset.yml +1 -1
- package/personas/kanban-w/agent.cordis.yml +35 -16
- package/personas/kanban-w/preset.yml +1 -1
- package/personas/persona-dt.md +1 -1
- package/personas/persona-p.md +4 -1
- package/personas/persona-pt.md +13 -6
- package/personas/persona-w.md +11 -9
- package/skills/grill-me/SKILL.md +71 -0
- package/skills/llm-wiki-skill/.mise.toml +2 -0
- package/skills/llm-wiki-skill/.nvmrc +1 -0
- package/skills/llm-wiki-skill/AGENTS.md +173 -0
- package/skills/llm-wiki-skill/CHANGELOG.md +548 -0
- package/skills/llm-wiki-skill/CLAUDE.md +152 -0
- package/skills/llm-wiki-skill/HERMES.md +44 -0
- package/skills/llm-wiki-skill/README.en.md +261 -0
- package/skills/llm-wiki-skill/README.md +291 -0
- package/skills/llm-wiki-skill/SKILL.md +1133 -0
- package/skills/llm-wiki-skill/assets/graph-demo.gif +0 -0
- package/skills/llm-wiki-skill/assets/graph-preview.png +0 -0
- package/skills/llm-wiki-skill/deps/LICENSE-d3.txt +13 -0
- package/skills/llm-wiki-skill/deps/LICENSE-marked.txt +44 -0
- package/skills/llm-wiki-skill/deps/LICENSE-purify.txt +568 -0
- package/skills/llm-wiki-skill/deps/LICENSE-roughjs.txt +21 -0
- package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/SKILL.md +261 -0
- package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/references/config/first-time-setup.md +106 -0
- package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/cdp.ts +179 -0
- package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/constants.ts +13 -0
- package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/defuddle-converter.ts +58 -0
- package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/html-to-markdown.ts +135 -0
- package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/legacy-converter.ts +629 -0
- package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/main.ts +314 -0
- package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/markdown-conversion-shared.ts +305 -0
- package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/media-localizer.ts +317 -0
- package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/package.json +14 -0
- package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/paths.ts +29 -0
- package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/vendor/baoyu-chrome-cdp/package.json +9 -0
- package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/vendor/baoyu-chrome-cdp/src/index.test.ts +307 -0
- package/skills/llm-wiki-skill/deps/baoyu-url-to-markdown/scripts/vendor/baoyu-chrome-cdp/src/index.ts +523 -0
- package/skills/llm-wiki-skill/deps/d3.min.js +2 -0
- package/skills/llm-wiki-skill/deps/marked.min.js +6 -0
- package/skills/llm-wiki-skill/deps/purify.min.js +3 -0
- package/skills/llm-wiki-skill/deps/rough.min.js +7 -0
- package/skills/llm-wiki-skill/deps/youtube-transcript/SKILL.md +47 -0
- package/skills/llm-wiki-skill/deps/youtube-transcript/scripts/get_transcript.py +72 -0
- package/skills/llm-wiki-skill/designs/graph-edge-legibility/graph-edge-treatments.html +480 -0
- package/skills/llm-wiki-skill/docs/design/oriental-atlas/DESIGN.md +183 -0
- package/skills/llm-wiki-skill/docs/design/oriental-atlas/README.md +10 -0
- package/skills/llm-wiki-skill/docs/design/oriental-atlas/design-brief.md +170 -0
- package/skills/llm-wiki-skill/docs/design/oriental-atlas/oriental-editorial-atlas.html +1908 -0
- package/skills/llm-wiki-skill/docs/design/oriental-atlas/reviews/result-review.md +68 -0
- package/skills/llm-wiki-skill/docs/graph/2026-06-16-interaction-risk-audit.md +88 -0
- package/skills/llm-wiki-skill/docs/graph/2026-06-16-interaction-test-coverage-map.md +212 -0
- package/skills/llm-wiki-skill/docs/graph/performance/2026-06-18-phase-0-2-baseline.md +86 -0
- package/skills/llm-wiki-skill/docs/graph/performance/2026-06-18-phase-1-3-dom-svg-large-baseline.md +85 -0
- package/skills/llm-wiki-skill/docs/graph/performance/2026-06-18-phase-1-4-disposable-validation-gate.md +97 -0
- package/skills/llm-wiki-skill/docs/graph/performance/2026-06-18-phase-2-4-global-renderer-trial-matrix.md +168 -0
- package/skills/llm-wiki-skill/docs/graph/performance/2026-06-19-phase-6-1-sigma-graphology-trial.md +71 -0
- package/skills/llm-wiki-skill/docs/graph/performance/2026-06-19-phase-6-2-vis-network-trial.md +78 -0
- package/skills/llm-wiki-skill/docs/graph/performance/2026-06-19-phase-6-3-aggregation-fallback-trial.md +72 -0
- package/skills/llm-wiki-skill/docs/graph/performance/2026-06-19-phase-6-4-global-renderer-route-decision.md +94 -0
- package/skills/llm-wiki-skill/docs/graph/performance/2026-06-19-sigma-global-production-integration-result.md +102 -0
- package/skills/llm-wiki-skill/docs/graph/performance/artifacts/2026-06-18-phase-0-2/stage-4.5-offline-dense-wheel.json +9 -0
- package/skills/llm-wiki-skill/docs/graph/performance/artifacts/2026-06-18-phase-0-2/stage-4.5-offline-dense-wheel.png +0 -0
- package/skills/llm-wiki-skill/docs/graph/performance/artifacts/2026-06-18-phase-0-2/stage-4.5-offline-navigation.png +0 -0
- package/skills/llm-wiki-skill/docs/spark/2026-06-15-omp-tool-status-events-design.md +174 -0
- package/skills/llm-wiki-skill/docs/spark/2026-06-16-graph-interaction-geometry-design.md +832 -0
- package/skills/llm-wiki-skill/docs/spark/2026-06-16-graph-six-layer-architecture-design.md +577 -0
- package/skills/llm-wiki-skill/docs/spark/2026-06-17-static-renderer-coordination-split-design.md +172 -0
- package/skills/llm-wiki-skill/docs/spark/2026-06-18-large-graph-global-community-design.md +909 -0
- package/skills/llm-wiki-skill/docs/spark/2026-06-19-sigma-global-graph-renderer-design.md +360 -0
- package/skills/llm-wiki-skill/docs/spark/2026-06-20-paper-ui-port-design.md +162 -0
- package/skills/llm-wiki-skill/docs/spark/2026-06-20-paper-ui-v2-shell-alignment-design.md +384 -0
- package/skills/llm-wiki-skill/docs/spark/2026-06-21-graph-experience-completion-design.md +534 -0
- package/skills/llm-wiki-skill/docs/spark/2026-06-22-chat-auto-scroll-design.md +185 -0
- package/skills/llm-wiki-skill/docs/spark/2026-06-22-graph-community-node-visual-design.md +266 -0
- package/skills/llm-wiki-skill/docs/spark/2026-06-25-sigma-overlay-refactor-perf-design.md +170 -0
- package/skills/llm-wiki-skill/docs/spark/2026-06-26-global-sigma-community-spotlight-design.md +393 -0
- package/skills/llm-wiki-skill/docs/spark/mockups/2026-06-18-large-graph-global-community-flow.html +746 -0
- package/skills/llm-wiki-skill/install.ps1 +87 -0
- package/skills/llm-wiki-skill/install.sh +722 -0
- package/skills/llm-wiki-skill/package-lock.json +11171 -0
- package/skills/llm-wiki-skill/package.json +24 -0
- package/skills/llm-wiki-skill/packages/graph-engine/package.json +37 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/anim/.gitkeep +1 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/anim/index.ts +179 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/architecture.ts +79 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/diff.ts +121 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/facade.ts +1406 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/graph-node.ts +37 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/index.ts +25 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/layout/edge-geometry.ts +17 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/layout/index.ts +16 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/layout/spatial-index.ts +509 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/model/atlas.ts +18 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/model/index.ts +10 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/model/labels.ts +11 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/model/layout.ts +81 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/model/learning.ts +8 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/model/legacy-helpers.ts +1379 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/model/queue.ts +7 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/model/storage.ts +4 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/model/visibility.ts +9 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/.gitkeep +1 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/adapter.ts +443 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/aggregation-containers.ts +64 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/community-cloud-geometry.ts +178 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/community-wash.ts +238 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/community-washes.ts +19 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/compat-contract.ts +14 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/controller.ts +705 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/controls.ts +288 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/dom-svg-renderer.ts +180 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/edges.ts +51 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/geometry.ts +380 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/gestures.ts +673 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/graph-renderer-root.ts +387 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/hit-testing.ts +56 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/host-dom.ts +14 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/hover-card.ts +37 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/index.ts +213 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/keyboard.ts +48 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/legend.ts +25 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/minimap.ts +45 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/model.ts +1339 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/node-drag-lifecycle.ts +94 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/nodes.ts +103 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/offline-reader.ts +209 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/overlays-presenter.ts +192 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/overlays.ts +73 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/pin-position.ts +51 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/preview.ts +65 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/relation-focus.ts +91 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/render-context.ts +85 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/render-pipeline.ts +871 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/render-styles.ts +1405 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/renderer-surface.ts +75 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/search.ts +57 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/sigma-coordinates.ts +44 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/sigma-global-drag.ts +246 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/sigma-global-renderer.ts +1425 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/sigma-overlay-svg.ts +121 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/simulation-bridge.ts +59 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/state.ts +262 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/toolbar.ts +40 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/render/viewport.ts +336 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/select/.gitkeep +1 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/select/index.ts +189 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/sim/index.ts +372 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/sim/pins.ts +84 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/summary/index.ts +447 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/themes/.gitkeep +1 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/themes/index.ts +8 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/themes/tokens.ts +117 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/types/d3-quadtree.d.ts +22 -0
- package/skills/llm-wiki-skill/packages/graph-engine/src/types.ts +531 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/aggregation-fallback-trial-adapter.test.ts +115 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/aggregation-fallback-trial-adapter.ts +222 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/anim.test.ts +121 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/architecture.test.ts +63 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/community-cloud-geometry.test.ts +86 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/community-wash.test.ts +97 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/diff.test.ts +133 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/facade.test.ts +1369 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/geometry.test.ts +147 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/gestures.test.ts +768 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/graph-layout.test.ts +110 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/helpers.test.ts +287 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/interaction-contract.test.ts +106 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/keyboard.test.ts +59 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/large-fixtures.test.ts +47 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/large-graph-fixtures.ts +420 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/learning.test.ts +259 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/node-drag-lifecycle.test.ts +166 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/overlays.test.ts +115 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/preview.test.ts +56 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/queue.test.ts +114 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/relation-focus.test.ts +115 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/render-model.test.ts +1030 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/renderer-adapter-contract.test.ts +271 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/renderer-boundary.test.ts +618 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/renderer-lifecycle.test.ts +1711 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/route-continuity.test.ts +284 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/runtime-state.test.ts +281 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/search-and-legend.test.ts +124 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/select.test.ts +168 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/sigma-coordinates.test.ts +50 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/sigma-global-renderer.test.ts +2210 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/sigma-trial-adapter.test.ts +82 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/sigma-trial-adapter.ts +271 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/sim.test.ts +207 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/simulation-bridge.test.ts +96 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/spatial-index.test.ts +222 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/state.test.ts +189 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/summary-contract.test.ts +422 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/themes.test.ts +62 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/toolbar.test.ts +64 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/viewport.test.ts +213 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/vis-network-trial-adapter.test.ts +82 -0
- package/skills/llm-wiki-skill/packages/graph-engine/test/vis-network-trial-adapter.ts +186 -0
- package/skills/llm-wiki-skill/packages/graph-engine/tsconfig.json +17 -0
- package/skills/llm-wiki-skill/packages/graph-engine/vite.config.ts +15 -0
- package/skills/llm-wiki-skill/platforms/claude/CLAUDE.md +37 -0
- package/skills/llm-wiki-skill/platforms/claude/companions/llm-wiki-upgrade/SKILL.md +95 -0
- package/skills/llm-wiki-skill/platforms/codex/AGENTS.md +23 -0
- package/skills/llm-wiki-skill/platforms/hermes/README.md +31 -0
- package/skills/llm-wiki-skill/platforms/openclaw/README.md +31 -0
- package/skills/llm-wiki-skill/scripts/adapter-state.sh +424 -0
- package/skills/llm-wiki-skill/scripts/build-graph-data.sh +395 -0
- package/skills/llm-wiki-skill/scripts/build-graph-html.sh +459 -0
- package/skills/llm-wiki-skill/scripts/cache.sh +352 -0
- package/skills/llm-wiki-skill/scripts/create-source-page.sh +100 -0
- package/skills/llm-wiki-skill/scripts/delete-helper.sh +68 -0
- package/skills/llm-wiki-skill/scripts/graph-analysis.js +732 -0
- package/skills/llm-wiki-skill/scripts/hook-session-start.sh +46 -0
- package/skills/llm-wiki-skill/scripts/init-wiki.sh +95 -0
- package/skills/llm-wiki-skill/scripts/lib/source-signal-eligibility.js +158 -0
- package/skills/llm-wiki-skill/scripts/lint-fix.sh +114 -0
- package/skills/llm-wiki-skill/scripts/lint-runner.sh +217 -0
- package/skills/llm-wiki-skill/scripts/runtime-context.sh +77 -0
- package/skills/llm-wiki-skill/scripts/shared-config.sh +83 -0
- package/skills/llm-wiki-skill/scripts/source-record-contract.tsv +10 -0
- package/skills/llm-wiki-skill/scripts/source-registry.sh +349 -0
- package/skills/llm-wiki-skill/scripts/source-registry.tsv +10 -0
- package/skills/llm-wiki-skill/scripts/source-signal-coverage.js +83 -0
- package/skills/llm-wiki-skill/scripts/validate-step1.sh +144 -0
- package/skills/llm-wiki-skill/scripts/wiki-compat.sh +267 -0
- package/skills/llm-wiki-skill/setup.sh +8 -0
- package/skills/llm-wiki-skill/templates/entity-template.md +30 -0
- package/skills/llm-wiki-skill/templates/graph-styles/wash/footer.html +27 -0
- package/skills/llm-wiki-skill/templates/graph-styles/wash/graph-wash-helpers.js +1326 -0
- package/skills/llm-wiki-skill/templates/graph-styles/wash/graph-wash.js +1009 -0
- package/skills/llm-wiki-skill/templates/graph-styles/wash/header.html +2002 -0
- package/skills/llm-wiki-skill/templates/index-en-template.md +51 -0
- package/skills/llm-wiki-skill/templates/index-template.md +51 -0
- package/skills/llm-wiki-skill/templates/log-en-template.md +11 -0
- package/skills/llm-wiki-skill/templates/log-template.md +11 -0
- package/skills/llm-wiki-skill/templates/overview-en-template.md +41 -0
- package/skills/llm-wiki-skill/templates/overview-template.md +41 -0
- package/skills/llm-wiki-skill/templates/purpose-en-template.md +16 -0
- package/skills/llm-wiki-skill/templates/purpose-template.md +16 -0
- package/skills/llm-wiki-skill/templates/query-template.md +19 -0
- package/skills/llm-wiki-skill/templates/schema-template.md +185 -0
- package/skills/llm-wiki-skill/templates/source-template.md +51 -0
- package/skills/llm-wiki-skill/templates/synthesis-template.md +25 -0
- package/skills/llm-wiki-skill/templates/topic-template.md +35 -0
- package/skills/llm-wiki-skill/tests/adapter-state.sh +338 -0
- package/skills/llm-wiki-skill/tests/browser/graph-aggregation-fallback-trial.ts +737 -0
- package/skills/llm-wiki-skill/tests/browser/graph-community-node-map.mjs +255 -0
- package/skills/llm-wiki-skill/tests/browser/graph-community-wash-interactions.mjs +170 -0
- package/skills/llm-wiki-skill/tests/browser/graph-default-behavior.mjs +630 -0
- package/skills/llm-wiki-skill/tests/browser/graph-density-preview.mjs +53 -0
- package/skills/llm-wiki-skill/tests/browser/graph-html-insights.mjs +41 -0
- package/skills/llm-wiki-skill/tests/browser/graph-large-performance.ts +689 -0
- package/skills/llm-wiki-skill/tests/browser/graph-node-slim.mjs +75 -0
- package/skills/llm-wiki-skill/tests/browser/graph-offline-phase-6.mjs +660 -0
- package/skills/llm-wiki-skill/tests/browser/graph-renderer-trial-shared.ts +291 -0
- package/skills/llm-wiki-skill/tests/browser/graph-sigma-global-production.ts +1437 -0
- package/skills/llm-wiki-skill/tests/browser/graph-sigma-graphology-trial.ts +949 -0
- package/skills/llm-wiki-skill/tests/browser/graph-stage-4-5.mjs +815 -0
- package/skills/llm-wiki-skill/tests/browser/graph-vis-network-trial.ts +762 -0
- package/skills/llm-wiki-skill/tests/browser/graph-workbench-interactions.mjs +730 -0
- package/skills/llm-wiki-skill/tests/browser/validate-graph-trial-result.mjs +149 -0
- package/skills/llm-wiki-skill/tests/expected/graph-data-empty.json +60 -0
- package/skills/llm-wiki-skill/tests/expected/graph-data-sample.json +396 -0
- package/skills/llm-wiki-skill/tests/expected/graph-interactive-basic.html +1736 -0
- package/skills/llm-wiki-skill/tests/expected/lint-output.txt +44 -0
- package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/index.md +1 -0
- package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/entities/Alpha.md +10 -0
- package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/entities/Beta.md +7 -0
- package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/entities/Delta.md +8 -0
- package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/entities/Gamma.md +8 -0
- package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/queries/20260422-abc.md +10 -0
- package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/synthesis/Crystal.md +8 -0
- package/skills/llm-wiki-skill/tests/fixtures/coverage-sample-wiki/wiki/topics/Overview.md +9 -0
- package/skills/llm-wiki-skill/tests/fixtures/graph-data-empty-wiki/wiki/entities/.gitkeep +0 -0
- package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/purpose.md +3 -0
- package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/entities/Attention.md +7 -0
- package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/entities/Decoder.md +7 -0
- package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/entities/Encoder.md +7 -0
- package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/entities/GPT.md +7 -0
- package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/entities/Transformer.md +13 -0
- package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/sources/paper.md +9 -0
- package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/topics/arch.md +12 -0
- package/skills/llm-wiki-skill/tests/fixtures/graph-data-sample-wiki/wiki/topics/finetune.md +9 -0
- package/skills/llm-wiki-skill/tests/fixtures/graph-interactive-basic/wiki/graph-data.json +40 -0
- package/skills/llm-wiki-skill/tests/fixtures/graph-interactive-dense/wiki/graph-data.json +3965 -0
- package/skills/llm-wiki-skill/tests/fixtures/graph-interactive-multicomm/wiki/graph-data.json +212 -0
- package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/index.md +14 -0
- package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/entities/C++.md +6 -0
- package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/entities/Lonely.md +4 -0
- package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/entities/Other.md +8 -0
- package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/entities/Real.md +7 -0
- package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/sources/2026-01-01-test-source.md +15 -0
- package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/sources/2026-02-01-inline-img.md +12 -0
- package/skills/llm-wiki-skill/tests/fixtures/lint-sample-wiki/wiki/topics/AIbasic.md +3 -0
- package/skills/llm-wiki-skill/tests/graph-aggregation-fallback-trial.regression-1.sh +46 -0
- package/skills/llm-wiki-skill/tests/graph-analysis-helper.regression-1.sh +237 -0
- package/skills/llm-wiki-skill/tests/graph-browser-large-performance.regression-1.sh +39 -0
- package/skills/llm-wiki-skill/tests/graph-browser-stage-4-5.regression-1.sh +163 -0
- package/skills/llm-wiki-skill/tests/graph-build-failures.regression-1.sh +91 -0
- package/skills/llm-wiki-skill/tests/graph-community-node-map.regression-1.sh +107 -0
- package/skills/llm-wiki-skill/tests/graph-community-wash-interactions.regression-1.sh +35 -0
- package/skills/llm-wiki-skill/tests/graph-data-confidence-merge.regression-1.sh +309 -0
- package/skills/llm-wiki-skill/tests/graph-data-source-paths.regression-1.sh +49 -0
- package/skills/llm-wiki-skill/tests/graph-default-behavior.regression-1.sh +35 -0
- package/skills/llm-wiki-skill/tests/graph-html-a11y.regression-1.sh +50 -0
- package/skills/llm-wiki-skill/tests/graph-html-brand-link.regression-1.sh +47 -0
- package/skills/llm-wiki-skill/tests/graph-html-density.regression-1.sh +228 -0
- package/skills/llm-wiki-skill/tests/graph-html-drawer-neighbors.regression-1.sh +47 -0
- package/skills/llm-wiki-skill/tests/graph-html-insights.regression-1.sh +80 -0
- package/skills/llm-wiki-skill/tests/graph-html-long-label.regression-1.sh +92 -0
- package/skills/llm-wiki-skill/tests/graph-html-minimap.regression-1.sh +51 -0
- package/skills/llm-wiki-skill/tests/graph-html-mobile.regression-1.sh +48 -0
- package/skills/llm-wiki-skill/tests/graph-html-oriental-atlas-contract.regression-1.sh +94 -0
- package/skills/llm-wiki-skill/tests/graph-html-oriental-design-contract.regression-1.sh +82 -0
- package/skills/llm-wiki-skill/tests/graph-html-search.regression-1.sh +52 -0
- package/skills/llm-wiki-skill/tests/graph-html-styles.regression-1.sh +66 -0
- package/skills/llm-wiki-skill/tests/graph-html-toolbar.regression-1.sh +62 -0
- package/skills/llm-wiki-skill/tests/graph-offline-phase-6.regression-1.sh +51 -0
- package/skills/llm-wiki-skill/tests/graph-sigma-global-production.regression-1.sh +64 -0
- package/skills/llm-wiki-skill/tests/graph-sigma-graphology-trial.regression-1.sh +46 -0
- package/skills/llm-wiki-skill/tests/graph-vis-network-trial.regression-1.sh +46 -0
- package/skills/llm-wiki-skill/tests/graph-workbench-interactions.regression-1.sh +151 -0
- package/skills/llm-wiki-skill/tests/js/graph-wash-bootstrap.test.js +110 -0
- package/skills/llm-wiki-skill/tests/js/graph-wash-helpers.test.js +296 -0
- package/skills/llm-wiki-skill/tests/js/graph-wash-learning.test.js +260 -0
- package/skills/llm-wiki-skill/tests/js/graph-wash-queue.test.js +115 -0
- package/skills/llm-wiki-skill/tests/js/graph-wash-runtime-state.test.js +282 -0
- package/skills/llm-wiki-skill/tests/js/source-signal-coverage.test.js +48 -0
- package/skills/llm-wiki-skill/tests/js/source-signal-eligibility.test.js +202 -0
- package/skills/llm-wiki-skill/tests/lib/graph-html-engine-helpers.sh +110 -0
- package/skills/llm-wiki-skill/tests/lint-output.regression-1.sh +32 -0
- package/skills/llm-wiki-skill/tests/regression.sh +1754 -0
- package/skills/llm-wiki-skill/workbench/AGENTS.md +110 -0
- package/skills/llm-wiki-skill/workbench/CLAUDE.md +55 -0
- package/skills/llm-wiki-skill/workbench/LICENSE +21 -0
- package/skills/llm-wiki-skill/workbench/PRODUCT.md +1353 -0
- package/skills/llm-wiki-skill/workbench/README.md +30 -0
- package/skills/llm-wiki-skill/workbench/docs/current-kb-retrieval-design.md +587 -0
- package/skills/llm-wiki-skill/workbench/docs/graph-evolution-1-design.md +210 -0
- package/skills/llm-wiki-skill/workbench/docs/stage-2-design.md +1139 -0
- package/skills/llm-wiki-skill/workbench/docs/stage-3-design.md +1269 -0
- package/skills/llm-wiki-skill/workbench/docs/stage-3.5-design.md +1164 -0
- package/skills/llm-wiki-skill/workbench/docs/stage-4-design.md +504 -0
- package/skills/llm-wiki-skill/workbench/docs/stage-4.5-design.md +195 -0
- package/skills/llm-wiki-skill/workbench/docs/superpowers/specs/2026-05-28-resizable-preview-layout-design.md +165 -0
- package/skills/llm-wiki-skill/workbench/docs/superpowers/specs/2026-05-28-settings-panel-scroll-fix.md +50 -0
- package/skills/llm-wiki-skill/workbench/server/package.json +31 -0
- package/skills/llm-wiki-skill/workbench/server/src/agent.ts +457 -0
- package/skills/llm-wiki-skill/workbench/server/src/artifacts.ts +248 -0
- package/skills/llm-wiki-skill/workbench/server/src/auth.ts +164 -0
- package/skills/llm-wiki-skill/workbench/server/src/config.ts +130 -0
- package/skills/llm-wiki-skill/workbench/server/src/conversations.test.ts +159 -0
- package/skills/llm-wiki-skill/workbench/server/src/conversations.ts +270 -0
- package/skills/llm-wiki-skill/workbench/server/src/digest/batch.ts +189 -0
- package/skills/llm-wiki-skill/workbench/server/src/digest/concurrency.test.ts +36 -0
- package/skills/llm-wiki-skill/workbench/server/src/digest/concurrency.ts +31 -0
- package/skills/llm-wiki-skill/workbench/server/src/digest/subagent.ts +91 -0
- package/skills/llm-wiki-skill/workbench/server/src/extensions/artifacts.ts +81 -0
- package/skills/llm-wiki-skill/workbench/server/src/extensions/knowledge-base.ts +263 -0
- package/skills/llm-wiki-skill/workbench/server/src/extensions/new-wiki.ts +42 -0
- package/skills/llm-wiki-skill/workbench/server/src/extensions/synthesis.ts +172 -0
- package/skills/llm-wiki-skill/workbench/server/src/graph-watcher.test.ts +196 -0
- package/skills/llm-wiki-skill/workbench/server/src/graph.test.ts +113 -0
- package/skills/llm-wiki-skill/workbench/server/src/graph.ts +351 -0
- package/skills/llm-wiki-skill/workbench/server/src/index.ts +1148 -0
- package/skills/llm-wiki-skill/workbench/server/src/knowledge-bases.test.ts +30 -0
- package/skills/llm-wiki-skill/workbench/server/src/knowledge-bases.ts +321 -0
- package/skills/llm-wiki-skill/workbench/server/src/pages.test.ts +41 -0
- package/skills/llm-wiki-skill/workbench/server/src/pages.ts +160 -0
- package/skills/llm-wiki-skill/workbench/server/src/retrieval.test.ts +151 -0
- package/skills/llm-wiki-skill/workbench/server/src/retrieval.ts +427 -0
- package/skills/llm-wiki-skill/workbench/server/src/tool-status-events.test.ts +363 -0
- package/skills/llm-wiki-skill/workbench/server/src/tool-status-events.ts +616 -0
- package/skills/llm-wiki-skill/workbench/server/src/wiki-init.test.ts +19 -0
- package/skills/llm-wiki-skill/workbench/server/src/wiki-init.ts +188 -0
- package/skills/llm-wiki-skill/workbench/server/tsconfig.json +10 -0
- package/skills/llm-wiki-skill/workbench/tsconfig.json +20 -0
- package/skills/llm-wiki-skill/workbench/web/README.md +73 -0
- package/skills/llm-wiki-skill/workbench/web/components.json +21 -0
- package/skills/llm-wiki-skill/workbench/web/eslint.config.js +22 -0
- package/skills/llm-wiki-skill/workbench/web/index.html +16 -0
- package/skills/llm-wiki-skill/workbench/web/package.json +54 -0
- package/skills/llm-wiki-skill/workbench/web/src/App.tsx +1195 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/AddExternalDialog.tsx +375 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/AppearancePanel.tsx +158 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/ArtifactView.tsx +15 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/BatchDigestPanel.tsx +117 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/ChatPanel.tsx +890 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/CommandMenu.tsx +75 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/ExportButtons.tsx +58 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/GraphPanel.tsx +800 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/GraphReader.tsx +52 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/GraphSelection.tsx +100 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/GraphSummaryDrawer.tsx +269 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/MainViewTabs.tsx +69 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/MarkdownView.tsx +106 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/NewWikiDialog.tsx +103 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/RefMenu.tsx +44 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/RightDrawer.tsx +298 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/SearchPanel.tsx +165 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/SettingsPanel.tsx +320 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/Sidebar.tsx +354 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/ToolHistorySummary.tsx +111 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/ToolStatusRunway.tsx +70 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/TopBar.tsx +348 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/renderers/DownloadOnlyRenderer.tsx +88 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/renderers/HtmlRenderer.tsx +92 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/ui/button.tsx +52 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/ui/command.tsx +50 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/ui/dialog.tsx +156 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/ui/input.tsx +21 -0
- package/skills/llm-wiki-skill/workbench/web/src/components/ui/tooltip.tsx +57 -0
- package/skills/llm-wiki-skill/workbench/web/src/index.css +4204 -0
- package/skills/llm-wiki-skill/workbench/web/src/lib/api.ts +648 -0
- package/skills/llm-wiki-skill/workbench/web/src/lib/appearance.ts +114 -0
- package/skills/llm-wiki-skill/workbench/web/src/lib/drawer-layout.ts +41 -0
- package/skills/llm-wiki-skill/workbench/web/src/lib/drawer-state.ts +168 -0
- package/skills/llm-wiki-skill/workbench/web/src/lib/graph-reader.ts +25 -0
- package/skills/llm-wiki-skill/workbench/web/src/lib/graph-selection-drawer.ts +35 -0
- package/skills/llm-wiki-skill/workbench/web/src/lib/graph-selection.ts +96 -0
- package/skills/llm-wiki-skill/workbench/web/src/lib/graph-summary-actions.ts +184 -0
- package/skills/llm-wiki-skill/workbench/web/src/lib/legacy-tool-status.ts +113 -0
- package/skills/llm-wiki-skill/workbench/web/src/lib/model-roles.ts +20 -0
- package/skills/llm-wiki-skill/workbench/web/src/lib/search-filter.ts +104 -0
- package/skills/llm-wiki-skill/workbench/web/src/lib/sse.ts +72 -0
- package/skills/llm-wiki-skill/workbench/web/src/lib/tool-status-format.ts +170 -0
- package/skills/llm-wiki-skill/workbench/web/src/lib/tool-status-model.ts +392 -0
- package/skills/llm-wiki-skill/workbench/web/src/lib/utils.ts +10 -0
- package/skills/llm-wiki-skill/workbench/web/src/lib/view-status.ts +16 -0
- package/skills/llm-wiki-skill/workbench/web/src/lib/wiki-links.ts +32 -0
- package/skills/llm-wiki-skill/workbench/web/src/main.tsx +10 -0
- package/skills/llm-wiki-skill/workbench/web/test/api.test.ts +61 -0
- package/skills/llm-wiki-skill/workbench/web/test/app-shell-drawer-layout.test.tsx +48 -0
- package/skills/llm-wiki-skill/workbench/web/test/appearance-panel.test.tsx +121 -0
- package/skills/llm-wiki-skill/workbench/web/test/appearance.test.ts +262 -0
- package/skills/llm-wiki-skill/workbench/web/test/chat-host-source.test.tsx +22 -0
- package/skills/llm-wiki-skill/workbench/web/test/chat-panel-auto-scroll.test.tsx +311 -0
- package/skills/llm-wiki-skill/workbench/web/test/chat-panel-bubbles.test.tsx +48 -0
- package/skills/llm-wiki-skill/workbench/web/test/chat-panel-composer.test.tsx +86 -0
- package/skills/llm-wiki-skill/workbench/web/test/chat-panel-tool-status.test.tsx +26 -0
- package/skills/llm-wiki-skill/workbench/web/test/export-batch-paper.test.tsx +101 -0
- package/skills/llm-wiki-skill/workbench/web/test/graph-drawer-state.test.ts +257 -0
- package/skills/llm-wiki-skill/workbench/web/test/graph-panel-paper.test.tsx +200 -0
- package/skills/llm-wiki-skill/workbench/web/test/graph-reader-request.test.ts +32 -0
- package/skills/llm-wiki-skill/workbench/web/test/graph-reader.test.ts +62 -0
- package/skills/llm-wiki-skill/workbench/web/test/graph-selection-drawer.test.ts +56 -0
- package/skills/llm-wiki-skill/workbench/web/test/graph-selection.test.ts +83 -0
- package/skills/llm-wiki-skill/workbench/web/test/graph-summary-actions.test.ts +188 -0
- package/skills/llm-wiki-skill/workbench/web/test/main-view-tabs.test.tsx +34 -0
- package/skills/llm-wiki-skill/workbench/web/test/markdown-view.test.tsx +34 -0
- package/skills/llm-wiki-skill/workbench/web/test/popup-menus.test.tsx +85 -0
- package/skills/llm-wiki-skill/workbench/web/test/render.test.tsx +30 -0
- package/skills/llm-wiki-skill/workbench/web/test/render.tsx +38 -0
- package/skills/llm-wiki-skill/workbench/web/test/right-drawer-graph-summary.test.tsx +287 -0
- package/skills/llm-wiki-skill/workbench/web/test/right-drawer-interactions.test.tsx +182 -0
- package/skills/llm-wiki-skill/workbench/web/test/search-filter.test.ts +65 -0
- package/skills/llm-wiki-skill/workbench/web/test/search-panel.test.tsx +155 -0
- package/skills/llm-wiki-skill/workbench/web/test/setup-dom.ts +66 -0
- package/skills/llm-wiki-skill/workbench/web/test/sidebar-v2-source.test.ts +17 -0
- package/skills/llm-wiki-skill/workbench/web/test/sidebar.test.tsx +110 -0
- package/skills/llm-wiki-skill/workbench/web/test/tool-history-summary.test.tsx +150 -0
- package/skills/llm-wiki-skill/workbench/web/test/tool-status-format.test.ts +107 -0
- package/skills/llm-wiki-skill/workbench/web/test/tool-status-model.test.ts +324 -0
- package/skills/llm-wiki-skill/workbench/web/test/tool-status-runway.test.ts +159 -0
- package/skills/llm-wiki-skill/workbench/web/test/topbar.test.tsx +248 -0
- package/skills/llm-wiki-skill/workbench/web/test/visual/paper-ui.ts +898 -0
- package/skills/llm-wiki-skill/workbench/web/test/wiki-links.test.ts +23 -0
- package/skills/llm-wiki-skill/workbench/web/test-results/paper-ui/actual/.gitkeep +1 -0
- package/skills/llm-wiki-skill/workbench/web/test-results/paper-ui/baseline/.gitkeep +1 -0
- package/skills/llm-wiki-skill/workbench/web/tsconfig.app.json +30 -0
- package/skills/llm-wiki-skill/workbench/web/tsconfig.json +7 -0
- package/skills/llm-wiki-skill/workbench/web/tsconfig.node.json +24 -0
- package/skills/llm-wiki-skill/workbench/web/vite.config.ts +28 -0
|
@@ -0,0 +1,1195 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
resolveSelection,
|
|
4
|
+
type GraphData,
|
|
5
|
+
type GraphDiff,
|
|
6
|
+
type GraphOpenPagePayload,
|
|
7
|
+
type GraphSummaryCommand,
|
|
8
|
+
type GraphSummaryObjectRef,
|
|
9
|
+
type GraphVisibilityState,
|
|
10
|
+
type PinMap,
|
|
11
|
+
type Selection,
|
|
12
|
+
} from "@llm-wiki/graph-engine";
|
|
13
|
+
|
|
14
|
+
import { BatchDigestPanel, type BatchDigestJob } from "@/components/BatchDigestPanel";
|
|
15
|
+
import { AppearancePanel } from "@/components/AppearancePanel";
|
|
16
|
+
import { ChatPanel } from "@/components/ChatPanel";
|
|
17
|
+
import { GraphPanel } from "@/components/GraphPanel";
|
|
18
|
+
import { MainViewTabs, type MainView } from "@/components/MainViewTabs";
|
|
19
|
+
import { RightDrawer } from "@/components/RightDrawer";
|
|
20
|
+
import { SearchPanel } from "@/components/SearchPanel";
|
|
21
|
+
import { SettingsPanel } from "@/components/SettingsPanel";
|
|
22
|
+
import { Sidebar } from "@/components/Sidebar";
|
|
23
|
+
import { TopBar } from "@/components/TopBar";
|
|
24
|
+
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
25
|
+
import {
|
|
26
|
+
type ActiveContext,
|
|
27
|
+
type ConversationInfo,
|
|
28
|
+
createNewConversation,
|
|
29
|
+
type ArtifactManifest,
|
|
30
|
+
getActiveContext,
|
|
31
|
+
type KnowledgeBaseInfo,
|
|
32
|
+
listArtifacts,
|
|
33
|
+
listConversations,
|
|
34
|
+
listKnowledgeBases,
|
|
35
|
+
listRefs,
|
|
36
|
+
type ModelRef,
|
|
37
|
+
type PageRef,
|
|
38
|
+
registerExternalKnowledgeBase,
|
|
39
|
+
readPage,
|
|
40
|
+
selectConversation,
|
|
41
|
+
selectKnowledgeBase,
|
|
42
|
+
streamBatchDigest,
|
|
43
|
+
type GraphEvent,
|
|
44
|
+
type UIMessage,
|
|
45
|
+
} from "@/lib/api";
|
|
46
|
+
import {
|
|
47
|
+
artifactDrawer,
|
|
48
|
+
closedDrawer,
|
|
49
|
+
type DrawerState,
|
|
50
|
+
graphReaderDrawer,
|
|
51
|
+
graphSelectionDrawer,
|
|
52
|
+
shouldApplyGraphReaderResult,
|
|
53
|
+
wikiDrawer,
|
|
54
|
+
} from "@/lib/drawer-state";
|
|
55
|
+
import type { GraphReaderActionId } from "@/lib/graph-reader";
|
|
56
|
+
import { buildSelectionPromptPayload } from "@/lib/graph-selection";
|
|
57
|
+
import {
|
|
58
|
+
drawerForGraphSelection,
|
|
59
|
+
drawerForExcludedGraphObject,
|
|
60
|
+
drawerForGraphSummaryCommunity,
|
|
61
|
+
drawerForGraphSummaryNode,
|
|
62
|
+
drawerForUnavailableGraphObject,
|
|
63
|
+
graphOpenPagePayloadForCommand,
|
|
64
|
+
graphObjectVisibilityReason,
|
|
65
|
+
graphSelectionCommandForOpenDetail,
|
|
66
|
+
type GraphSelectionCommand,
|
|
67
|
+
} from "@/lib/graph-summary-actions";
|
|
68
|
+
import { WIKI_LINK_SEEN_EVENT } from "@/lib/wiki-links";
|
|
69
|
+
import {
|
|
70
|
+
applyAppearance,
|
|
71
|
+
mergeAppearance,
|
|
72
|
+
readAppearance,
|
|
73
|
+
writeAppearance,
|
|
74
|
+
type AppearancePrefs,
|
|
75
|
+
type ThemeMode,
|
|
76
|
+
} from "@/lib/appearance";
|
|
77
|
+
import {
|
|
78
|
+
DEFAULT_CHAT_STATUS,
|
|
79
|
+
DEFAULT_GRAPH_STATUS,
|
|
80
|
+
type ChatStatusSnapshot,
|
|
81
|
+
type GraphStatusSnapshot,
|
|
82
|
+
} from "@/lib/view-status";
|
|
83
|
+
import {
|
|
84
|
+
DEFAULT_DRAWER_WIDTH,
|
|
85
|
+
clampDrawerWidthForViewport,
|
|
86
|
+
sidebarLayoutWidth,
|
|
87
|
+
} from "@/lib/drawer-layout";
|
|
88
|
+
|
|
89
|
+
const SIDEBAR_COLLAPSED_STORAGE_KEY = "llm-wiki-agent-sidebar-collapsed";
|
|
90
|
+
const DRAWER_WIDTH_STORAGE_KEY = "llm-wiki-agent-drawer-width";
|
|
91
|
+
const MAIN_VIEW_STORAGE_KEY = "llm-wiki-agent-main-view";
|
|
92
|
+
const SEARCH_REF_LIMIT = 5000;
|
|
93
|
+
|
|
94
|
+
function drawerForGraphNodeVisibility(
|
|
95
|
+
data: GraphData | null,
|
|
96
|
+
nodeId: string,
|
|
97
|
+
current: DrawerState,
|
|
98
|
+
options: {
|
|
99
|
+
pins: PinMap;
|
|
100
|
+
visibility: GraphVisibilityState | null;
|
|
101
|
+
selection?: { kind: "node"; id: string };
|
|
102
|
+
} ,
|
|
103
|
+
): DrawerState {
|
|
104
|
+
const object = { kind: "node" as const, nodeId };
|
|
105
|
+
const summaryOptions = {
|
|
106
|
+
pins: options.pins,
|
|
107
|
+
selection: options.selection ?? { kind: "node" as const, id: nodeId },
|
|
108
|
+
searchResultIds: options.visibility?.searchResultIds ?? [],
|
|
109
|
+
temporaryObject: options.visibility?.temporaryObject ?? null,
|
|
110
|
+
};
|
|
111
|
+
if (!data?.nodes.some((node) => node.id === nodeId)) {
|
|
112
|
+
return drawerForUnavailableGraphObject(data, object, "missing-node", current, summaryOptions);
|
|
113
|
+
}
|
|
114
|
+
const reason = graphObjectVisibilityReason(data, options.visibility, object);
|
|
115
|
+
const temporaryObject = options.visibility?.temporaryObject ?? null;
|
|
116
|
+
const temporarilyShown = temporaryObject?.kind === "node" && temporaryObject.nodeId === nodeId;
|
|
117
|
+
if (reason && !temporarilyShown) {
|
|
118
|
+
return drawerForExcludedGraphObject(data, object, reason, current, summaryOptions);
|
|
119
|
+
}
|
|
120
|
+
return drawerForGraphSummaryNode(data, nodeId, current, summaryOptions);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function sameGraphDrawerTarget(left: DrawerState, right: DrawerState): boolean {
|
|
124
|
+
if (left.mode !== right.mode) return false;
|
|
125
|
+
if (left.mode === "graph-node-summary" && right.mode === "graph-node-summary") {
|
|
126
|
+
return left.payload.nodeId === right.payload.nodeId
|
|
127
|
+
&& graphSummaryCommandSignature(left.payload.commands) === graphSummaryCommandSignature(right.payload.commands);
|
|
128
|
+
}
|
|
129
|
+
if (left.mode === "graph-excluded-object" && right.mode === "graph-excluded-object") {
|
|
130
|
+
return JSON.stringify(left.payload.object) === JSON.stringify(right.payload.object)
|
|
131
|
+
&& left.payload.reason === right.payload.reason
|
|
132
|
+
&& graphSummaryCommandSignature(left.payload.commands) === graphSummaryCommandSignature(right.payload.commands);
|
|
133
|
+
}
|
|
134
|
+
if (left.mode === "graph-unavailable-object" && right.mode === "graph-unavailable-object") {
|
|
135
|
+
return JSON.stringify(left.payload.object) === JSON.stringify(right.payload.object) && left.payload.reason === right.payload.reason;
|
|
136
|
+
}
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function graphSummaryCommandSignature(commands: readonly GraphSummaryCommand[]): string {
|
|
141
|
+
return commands.map((command) => {
|
|
142
|
+
if (command.kind === "set-fixed-position") return `${command.kind}:${command.mode}:${command.nodeId}`;
|
|
143
|
+
if (command.kind === "open-detail-read") return `${command.kind}:${command.nodeId}`;
|
|
144
|
+
if (command.kind === "enter-community") return `${command.kind}:${command.communityId}`;
|
|
145
|
+
if (command.kind === "show-this-object") return `${command.kind}:${JSON.stringify(command.object)}`;
|
|
146
|
+
return command.kind;
|
|
147
|
+
}).join(",");
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function visibilityWithTemporaryObject(
|
|
151
|
+
state: GraphVisibilityState | null,
|
|
152
|
+
temporaryObject: GraphSummaryObjectRef | null,
|
|
153
|
+
): GraphVisibilityState | null {
|
|
154
|
+
if (!state && !temporaryObject) return null;
|
|
155
|
+
return {
|
|
156
|
+
searchQuery: state?.searchQuery ?? "",
|
|
157
|
+
searchResultIds: state?.searchResultIds ?? [],
|
|
158
|
+
typeFilters: state?.typeFilters ?? {},
|
|
159
|
+
temporaryObject,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function drawerAfterGraphDataRefresh(
|
|
164
|
+
current: DrawerState,
|
|
165
|
+
data: GraphData | null,
|
|
166
|
+
options: {
|
|
167
|
+
pins: PinMap;
|
|
168
|
+
visibility: GraphVisibilityState | null;
|
|
169
|
+
temporaryObject: GraphSummaryObjectRef | null;
|
|
170
|
+
},
|
|
171
|
+
): DrawerState {
|
|
172
|
+
const visibility = visibilityWithTemporaryObject(options.visibility, options.temporaryObject);
|
|
173
|
+
if (current.mode === "graph-node-summary") {
|
|
174
|
+
return drawerForGraphNodeVisibility(data, current.payload.nodeId, current, {
|
|
175
|
+
pins: options.pins,
|
|
176
|
+
visibility,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
if (current.mode === "graph-community-summary") {
|
|
180
|
+
return drawerForGraphSummaryCommunity(data, current.payload.communityId, current, {
|
|
181
|
+
pins: options.pins,
|
|
182
|
+
selection: { kind: "community", id: current.payload.communityId },
|
|
183
|
+
searchResultIds: visibility?.searchResultIds ?? [],
|
|
184
|
+
temporaryObject: visibility?.temporaryObject ?? null,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (current.mode === "graph-excluded-object" && current.payload.object.kind === "node") {
|
|
188
|
+
return drawerForGraphNodeVisibility(data, current.payload.object.nodeId, current, {
|
|
189
|
+
pins: options.pins,
|
|
190
|
+
visibility,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
if (current.mode === "graph-unavailable-object" && current.payload.object.kind === "node") {
|
|
194
|
+
return drawerForGraphNodeVisibility(data, current.payload.object.nodeId, current, {
|
|
195
|
+
pins: options.pins,
|
|
196
|
+
visibility,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
if (current.mode === "graph-unavailable-object" && current.payload.object.kind === "community") {
|
|
200
|
+
return drawerForGraphSummaryCommunity(data, current.payload.object.communityId, current, {
|
|
201
|
+
pins: options.pins,
|
|
202
|
+
selection: { kind: "community", id: current.payload.object.communityId },
|
|
203
|
+
searchResultIds: visibility?.searchResultIds ?? [],
|
|
204
|
+
temporaryObject: visibility?.temporaryObject ?? null,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return current;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function getSidebarLayoutWidth(collapsed: boolean): number {
|
|
211
|
+
if (typeof window === "undefined") return 0;
|
|
212
|
+
return sidebarLayoutWidth(collapsed, window.innerWidth);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function clampDrawerWidth(width: number, sidebarCollapsed: boolean): number {
|
|
216
|
+
if (typeof window === "undefined") return DEFAULT_DRAWER_WIDTH;
|
|
217
|
+
return clampDrawerWidthForViewport(width, {
|
|
218
|
+
viewportWidth: window.innerWidth,
|
|
219
|
+
sidebarWidth: getSidebarLayoutWidth(sidebarCollapsed),
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* 阶段一 step 8 - 阶段一完结
|
|
225
|
+
*
|
|
226
|
+
* Layout:
|
|
227
|
+
* [TopBar 预留]
|
|
228
|
+
* [Sidebar 知识库 + 对话列表] [ChatPanel/GraphPanel 主区] [RightDrawer]
|
|
229
|
+
*
|
|
230
|
+
* 切库联动:
|
|
231
|
+
* 1. POST /api/knowledge-base → 后端自动选/新建该库最近对话
|
|
232
|
+
* 2. 拿到 active 后刷新 conversations 列表
|
|
233
|
+
* 3. chatKey++ 让 ChatPanel 重挂载(载入历史消息)
|
|
234
|
+
*
|
|
235
|
+
* 切对话联动:
|
|
236
|
+
* 1. POST /api/conversations { kbPath, conversationId }
|
|
237
|
+
* 2. ChatPanel 重挂载
|
|
238
|
+
*
|
|
239
|
+
* 新建对话:
|
|
240
|
+
* 1. POST /api/conversations/new
|
|
241
|
+
* 2. 刷新 conversations 列表(含合成 stub)
|
|
242
|
+
* 3. ChatPanel 重挂载
|
|
243
|
+
*/
|
|
244
|
+
function App() {
|
|
245
|
+
const [appearance, setAppearance] = useState(readAppearance);
|
|
246
|
+
const theme: ThemeMode = appearance.theme;
|
|
247
|
+
const [sidebarCollapsed, setSidebarCollapsed] = useState(() => {
|
|
248
|
+
if (typeof window === "undefined") return false;
|
|
249
|
+
return window.localStorage.getItem(SIDEBAR_COLLAPSED_STORAGE_KEY) === "true";
|
|
250
|
+
});
|
|
251
|
+
const [drawerWidth, setDrawerWidthState] = useState(() => {
|
|
252
|
+
if (typeof window === "undefined") return DEFAULT_DRAWER_WIDTH;
|
|
253
|
+
const stored = window.localStorage.getItem(DRAWER_WIDTH_STORAGE_KEY);
|
|
254
|
+
if (!stored) return clampDrawerWidth(DEFAULT_DRAWER_WIDTH, sidebarCollapsed);
|
|
255
|
+
const raw = Number(stored);
|
|
256
|
+
return Number.isFinite(raw) ? clampDrawerWidth(raw, sidebarCollapsed) : DEFAULT_DRAWER_WIDTH;
|
|
257
|
+
});
|
|
258
|
+
const [kbs, setKbs] = useState<KnowledgeBaseInfo[]>([]);
|
|
259
|
+
const [active, setActive] = useState<ActiveContext | null>(null);
|
|
260
|
+
const [conversations, setConversations] = useState<ConversationInfo[]>([]);
|
|
261
|
+
const [sidebarError, setSidebarError] = useState<string | null>(null);
|
|
262
|
+
const [loading, setLoading] = useState(false);
|
|
263
|
+
const [chatKey, setChatKey] = useState(0);
|
|
264
|
+
const [initialMessages, setInitialMessages] = useState<UIMessage[]>([]);
|
|
265
|
+
const [settingsOpen, setSettingsOpen] = useState(false);
|
|
266
|
+
const [appearanceOpen, setAppearanceOpen] = useState(false);
|
|
267
|
+
const [searchOpen, setSearchOpen] = useState(false);
|
|
268
|
+
const [searchRefs, setSearchRefs] = useState<PageRef[]>([]);
|
|
269
|
+
const [searchRefsLoading, setSearchRefsLoading] = useState(false);
|
|
270
|
+
const [searchRefsError, setSearchRefsError] = useState<string | null>(null);
|
|
271
|
+
const [chatStatus, setChatStatus] = useState<ChatStatusSnapshot>(DEFAULT_CHAT_STATUS);
|
|
272
|
+
const [graphStatus, setGraphStatus] = useState<GraphStatusSnapshot>(DEFAULT_GRAPH_STATUS);
|
|
273
|
+
const [drawer, setDrawer] = useState<DrawerState>(() => closedDrawer());
|
|
274
|
+
const [artifacts, setArtifacts] = useState<ArtifactManifest[]>([]);
|
|
275
|
+
const [drawerFullscreen, setDrawerFullscreen] = useState(false);
|
|
276
|
+
const [batchJob, setBatchJob] = useState<BatchDigestJob | null>(null);
|
|
277
|
+
const [pendingGraphPrompt, setPendingGraphPrompt] = useState<{
|
|
278
|
+
id: string;
|
|
279
|
+
message: string;
|
|
280
|
+
displayText: string;
|
|
281
|
+
} | null>(null);
|
|
282
|
+
const [pendingInsertRef, setPendingInsertRef] = useState<{ id: string; path: string } | null>(null);
|
|
283
|
+
const [graphFocusPath, setGraphFocusPath] = useState<string | null>(null);
|
|
284
|
+
const [pendingGraphDiff, setPendingGraphDiff] = useState<GraphDiff | null>(null);
|
|
285
|
+
const [graphRefreshToken, setGraphRefreshToken] = useState(0);
|
|
286
|
+
const [graphHasPendingUpdate, setGraphHasPendingUpdate] = useState(false);
|
|
287
|
+
const [graphBuildError, setGraphBuildError] = useState<Extract<GraphEvent, { type: "graph_error" }> | null>(null);
|
|
288
|
+
const [graphData, setGraphData] = useState<GraphData | null>(null);
|
|
289
|
+
const [graphPins, setGraphPins] = useState<PinMap>({});
|
|
290
|
+
const [graphVisibilityState, setGraphVisibilityState] = useState<GraphVisibilityState | null>(null);
|
|
291
|
+
const [graphTemporaryObject, setGraphTemporaryObject] = useState<GraphSummaryObjectRef | null>(null);
|
|
292
|
+
const [selectionCommand, setSelectionCommand] = useState<GraphSelectionCommand | undefined>();
|
|
293
|
+
const [mainView, setMainView] = useState<MainView>(() => {
|
|
294
|
+
if (typeof window === "undefined") return "chat";
|
|
295
|
+
return window.localStorage.getItem(MAIN_VIEW_STORAGE_KEY) === "graph" ? "graph" : "chat";
|
|
296
|
+
});
|
|
297
|
+
const mainViewRef = useRef(mainView);
|
|
298
|
+
const graphTemporaryObjectRef = useRef<GraphSummaryObjectRef | null>(null);
|
|
299
|
+
const activeConversationId = active?.conversation.id ?? null;
|
|
300
|
+
|
|
301
|
+
useEffect(() => {
|
|
302
|
+
applyAppearance(appearance);
|
|
303
|
+
writeAppearance(appearance);
|
|
304
|
+
}, [appearance]);
|
|
305
|
+
|
|
306
|
+
const toggleTheme = useCallback(() => {
|
|
307
|
+
setAppearance((value) => mergeAppearance(value, {
|
|
308
|
+
theme: value.theme === "dark" ? "light" : "dark",
|
|
309
|
+
}));
|
|
310
|
+
}, []);
|
|
311
|
+
|
|
312
|
+
const updateAppearance = useCallback((patch: Partial<AppearancePrefs>) => {
|
|
313
|
+
setAppearance((value) => mergeAppearance(value, patch));
|
|
314
|
+
}, []);
|
|
315
|
+
|
|
316
|
+
useEffect(() => {
|
|
317
|
+
window.localStorage.setItem(SIDEBAR_COLLAPSED_STORAGE_KEY, String(sidebarCollapsed));
|
|
318
|
+
}, [sidebarCollapsed]);
|
|
319
|
+
|
|
320
|
+
useEffect(() => {
|
|
321
|
+
window.localStorage.setItem(MAIN_VIEW_STORAGE_KEY, mainView);
|
|
322
|
+
mainViewRef.current = mainView;
|
|
323
|
+
}, [mainView]);
|
|
324
|
+
|
|
325
|
+
useEffect(() => {
|
|
326
|
+
if (!active?.kb.path) return;
|
|
327
|
+
const events = new EventSource("/api/events");
|
|
328
|
+
events.addEventListener("graph_updated", (message) => {
|
|
329
|
+
const event = JSON.parse((message as MessageEvent).data) as GraphEvent;
|
|
330
|
+
if (event.type !== "graph_updated" || event.kbPath !== active.kb.path) return;
|
|
331
|
+
setGraphBuildError(null);
|
|
332
|
+
setGraphRefreshToken((token) => token + 1);
|
|
333
|
+
setPendingGraphDiff(event.diff);
|
|
334
|
+
if (mainViewRef.current !== "graph" && event.diff) setGraphHasPendingUpdate(true);
|
|
335
|
+
});
|
|
336
|
+
events.addEventListener("graph_error", (message) => {
|
|
337
|
+
const event = JSON.parse((message as MessageEvent).data) as GraphEvent;
|
|
338
|
+
if (event.type === "graph_error" && event.kbPath === active.kb.path) {
|
|
339
|
+
setSidebarError(event.message);
|
|
340
|
+
setGraphBuildError(event);
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
return () => events.close();
|
|
344
|
+
}, [active?.kb.path]);
|
|
345
|
+
|
|
346
|
+
useEffect(() => {
|
|
347
|
+
if (mainView === "graph") setGraphHasPendingUpdate(false);
|
|
348
|
+
}, [mainView]);
|
|
349
|
+
|
|
350
|
+
useEffect(() => {
|
|
351
|
+
graphTemporaryObjectRef.current = graphTemporaryObject;
|
|
352
|
+
}, [graphTemporaryObject]);
|
|
353
|
+
|
|
354
|
+
useEffect(() => {
|
|
355
|
+
const handleWikiLinkSeenEvent = (event: Event) => {
|
|
356
|
+
const path = (event as CustomEvent<string>).detail;
|
|
357
|
+
if (typeof path === "string" && path.startsWith("wiki/")) setGraphFocusPath(path);
|
|
358
|
+
};
|
|
359
|
+
window.addEventListener(WIKI_LINK_SEEN_EVENT, handleWikiLinkSeenEvent);
|
|
360
|
+
return () => window.removeEventListener(WIKI_LINK_SEEN_EVENT, handleWikiLinkSeenEvent);
|
|
361
|
+
}, []);
|
|
362
|
+
|
|
363
|
+
useEffect(() => {
|
|
364
|
+
const handleResize = () => setDrawerWidthState((width) => clampDrawerWidth(width, sidebarCollapsed));
|
|
365
|
+
handleResize();
|
|
366
|
+
window.addEventListener("resize", handleResize);
|
|
367
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
368
|
+
}, [sidebarCollapsed]);
|
|
369
|
+
|
|
370
|
+
const setDrawerWidth = useCallback((width: number) => {
|
|
371
|
+
setDrawerWidthState(() => {
|
|
372
|
+
const next = clampDrawerWidth(width, sidebarCollapsed);
|
|
373
|
+
window.localStorage.setItem(DRAWER_WIDTH_STORAGE_KEY, String(next));
|
|
374
|
+
return next;
|
|
375
|
+
});
|
|
376
|
+
}, [sidebarCollapsed]);
|
|
377
|
+
|
|
378
|
+
const refreshConversations = useCallback(async (kbPath: string) => {
|
|
379
|
+
try {
|
|
380
|
+
const items = await listConversations(kbPath);
|
|
381
|
+
setConversations(items);
|
|
382
|
+
} catch (err) {
|
|
383
|
+
setSidebarError(err instanceof Error ? err.message : String(err));
|
|
384
|
+
}
|
|
385
|
+
}, []);
|
|
386
|
+
|
|
387
|
+
const refreshAll = useCallback(async () => {
|
|
388
|
+
setLoading(true);
|
|
389
|
+
setSidebarError(null);
|
|
390
|
+
try {
|
|
391
|
+
const [items, currentActive] = await Promise.all([
|
|
392
|
+
listKnowledgeBases(),
|
|
393
|
+
getActiveContext(),
|
|
394
|
+
]);
|
|
395
|
+
setKbs(items);
|
|
396
|
+
setActive(currentActive);
|
|
397
|
+
if (currentActive) {
|
|
398
|
+
setInitialMessages(currentActive.conversation.messages);
|
|
399
|
+
setChatKey((k) => k + 1);
|
|
400
|
+
await refreshConversations(currentActive.kb.path);
|
|
401
|
+
} else {
|
|
402
|
+
setInitialMessages([]);
|
|
403
|
+
setConversations([]);
|
|
404
|
+
setArtifacts([]);
|
|
405
|
+
setGraphBuildError(null);
|
|
406
|
+
setDrawer(closedDrawer());
|
|
407
|
+
}
|
|
408
|
+
} catch (err) {
|
|
409
|
+
setSidebarError(err instanceof Error ? err.message : String(err));
|
|
410
|
+
} finally {
|
|
411
|
+
setLoading(false);
|
|
412
|
+
}
|
|
413
|
+
}, [refreshConversations]);
|
|
414
|
+
|
|
415
|
+
useEffect(() => {
|
|
416
|
+
refreshAll();
|
|
417
|
+
}, [refreshAll]);
|
|
418
|
+
|
|
419
|
+
useEffect(() => {
|
|
420
|
+
if (!activeConversationId) return;
|
|
421
|
+
let cancelled = false;
|
|
422
|
+
listArtifacts(activeConversationId)
|
|
423
|
+
.then((items) => {
|
|
424
|
+
if (cancelled) return;
|
|
425
|
+
setArtifacts(items);
|
|
426
|
+
setDrawer((current) => {
|
|
427
|
+
if (current.mode !== "artifacts") return current;
|
|
428
|
+
const activeArtifactId = current.activeArtifactId && items.some((item) => item.id === current.activeArtifactId)
|
|
429
|
+
? current.activeArtifactId
|
|
430
|
+
: items.at(-1)?.id ?? null;
|
|
431
|
+
return artifactDrawer(items, activeArtifactId);
|
|
432
|
+
});
|
|
433
|
+
})
|
|
434
|
+
.catch((err) => {
|
|
435
|
+
if (!cancelled) setSidebarError(err instanceof Error ? err.message : String(err));
|
|
436
|
+
});
|
|
437
|
+
return () => {
|
|
438
|
+
cancelled = true;
|
|
439
|
+
};
|
|
440
|
+
}, [activeConversationId]);
|
|
441
|
+
|
|
442
|
+
const applyActive = (ctx: ActiveContext) => {
|
|
443
|
+
setActive(ctx);
|
|
444
|
+
setInitialMessages(ctx.conversation.messages);
|
|
445
|
+
setChatKey((k) => k + 1);
|
|
446
|
+
setChatStatus(DEFAULT_CHAT_STATUS);
|
|
447
|
+
setGraphStatus(DEFAULT_GRAPH_STATUS);
|
|
448
|
+
setDrawer(closedDrawer());
|
|
449
|
+
setArtifacts([]);
|
|
450
|
+
setPendingGraphDiff(null);
|
|
451
|
+
setGraphBuildError(null);
|
|
452
|
+
setGraphHasPendingUpdate(false);
|
|
453
|
+
setGraphData(null);
|
|
454
|
+
setGraphPins({});
|
|
455
|
+
setSelectionCommand({ id: Math.random().toString(36).slice(2, 10), type: "clear" });
|
|
456
|
+
setGraphFocusPath(null);
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
const handleSelectKb = async (item: KnowledgeBaseInfo) => {
|
|
460
|
+
if (!item.valid) return;
|
|
461
|
+
if (item.path === active?.kb.path) return;
|
|
462
|
+
|
|
463
|
+
setSidebarError(null);
|
|
464
|
+
try {
|
|
465
|
+
const ctx = await selectKnowledgeBase(item.path);
|
|
466
|
+
applyActive(ctx);
|
|
467
|
+
await refreshConversations(item.path);
|
|
468
|
+
} catch (err) {
|
|
469
|
+
setSidebarError(err instanceof Error ? err.message : String(err));
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
const handleSelectConversation = async (item: ConversationInfo) => {
|
|
474
|
+
if (!active) return;
|
|
475
|
+
setMainView("chat");
|
|
476
|
+
if (item.id === active.conversation.id) return;
|
|
477
|
+
|
|
478
|
+
setSidebarError(null);
|
|
479
|
+
try {
|
|
480
|
+
const ctx = await selectConversation(active.kb.path, item.id);
|
|
481
|
+
applyActive(ctx);
|
|
482
|
+
await refreshConversations(active.kb.path);
|
|
483
|
+
} catch (err) {
|
|
484
|
+
setSidebarError(err instanceof Error ? err.message : String(err));
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
const handleNewConversation = async () => {
|
|
489
|
+
if (!active) return;
|
|
490
|
+
setMainView("chat");
|
|
491
|
+
setSidebarError(null);
|
|
492
|
+
try {
|
|
493
|
+
const ctx = await createNewConversation(active.kb.path);
|
|
494
|
+
applyActive(ctx);
|
|
495
|
+
await refreshConversations(active.kb.path);
|
|
496
|
+
} catch (err) {
|
|
497
|
+
setSidebarError(err instanceof Error ? err.message : String(err));
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
const handleAskSelection = async (input: { message: string; displayText: string; newConversation: boolean }) => {
|
|
502
|
+
if (!active) return;
|
|
503
|
+
setSidebarError(null);
|
|
504
|
+
try {
|
|
505
|
+
if (input.newConversation) {
|
|
506
|
+
const ctx = await createNewConversation(active.kb.path);
|
|
507
|
+
applyActive(ctx);
|
|
508
|
+
await refreshConversations(active.kb.path);
|
|
509
|
+
}
|
|
510
|
+
setMainView("chat");
|
|
511
|
+
setPendingGraphPrompt({
|
|
512
|
+
id: Math.random().toString(36).slice(2, 10),
|
|
513
|
+
message: input.message,
|
|
514
|
+
displayText: input.displayText,
|
|
515
|
+
});
|
|
516
|
+
} catch (err) {
|
|
517
|
+
setSidebarError(err instanceof Error ? err.message : String(err));
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
const handleGraphSelectionChange = useCallback((selection: Selection | null) => {
|
|
522
|
+
if (!selection) {
|
|
523
|
+
setDrawer((current) => isGraphInteractionDrawer(current) ? closedDrawer() : current);
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
if (drawer.mode === "graph-reader" && selection.nodeIds.length === 1 && drawer.payload.node.id === selection.nodeIds[0]) {
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
setDrawer((current) => drawerForGraphSelection(graphData, selection, current, {
|
|
530
|
+
pins: graphPins,
|
|
531
|
+
searchResultIds: graphVisibilityState?.searchResultIds ?? [],
|
|
532
|
+
}));
|
|
533
|
+
}, [graphData, graphPins, graphVisibilityState, drawer]);
|
|
534
|
+
|
|
535
|
+
const handleGraphVisibilityChange = useCallback((state: GraphVisibilityState | null) => {
|
|
536
|
+
setGraphVisibilityState(state);
|
|
537
|
+
const effectiveState = visibilityWithTemporaryObject(state, graphTemporaryObjectRef.current ?? state?.temporaryObject ?? null);
|
|
538
|
+
setDrawer((current) => {
|
|
539
|
+
if (current.mode === "graph-node-summary") {
|
|
540
|
+
if (
|
|
541
|
+
effectiveState?.temporaryObject?.kind === "node"
|
|
542
|
+
&& effectiveState.temporaryObject.nodeId === current.payload.nodeId
|
|
543
|
+
&& current.payload.commands.some((command) => command.kind === "clear-temporary-object-display")
|
|
544
|
+
) {
|
|
545
|
+
return current;
|
|
546
|
+
}
|
|
547
|
+
const next = drawerForGraphNodeVisibility(graphData, current.payload.nodeId, current, {
|
|
548
|
+
pins: graphPins,
|
|
549
|
+
visibility: effectiveState,
|
|
550
|
+
});
|
|
551
|
+
return sameGraphDrawerTarget(current, next) ? current : next;
|
|
552
|
+
}
|
|
553
|
+
if (current.mode === "graph-excluded-object" && current.payload.object.kind === "node") {
|
|
554
|
+
const next = drawerForGraphNodeVisibility(graphData, current.payload.object.nodeId, current, {
|
|
555
|
+
pins: graphPins,
|
|
556
|
+
visibility: effectiveState,
|
|
557
|
+
});
|
|
558
|
+
return sameGraphDrawerTarget(current, next) ? current : next;
|
|
559
|
+
}
|
|
560
|
+
return current;
|
|
561
|
+
});
|
|
562
|
+
}, [graphData, graphPins]);
|
|
563
|
+
|
|
564
|
+
const handleGraphDataChange = useCallback((nextData: GraphData | null) => {
|
|
565
|
+
setGraphData(nextData);
|
|
566
|
+
setDrawer((current) => {
|
|
567
|
+
const next = drawerAfterGraphDataRefresh(current, nextData, {
|
|
568
|
+
pins: graphPins,
|
|
569
|
+
visibility: graphVisibilityState,
|
|
570
|
+
temporaryObject: graphTemporaryObjectRef.current,
|
|
571
|
+
});
|
|
572
|
+
return sameGraphDrawerTarget(current, next) ? current : next;
|
|
573
|
+
});
|
|
574
|
+
}, [graphPins, graphVisibilityState]);
|
|
575
|
+
|
|
576
|
+
const handleGraphViewReset = useCallback(() => {
|
|
577
|
+
setGraphFocusPath(null);
|
|
578
|
+
setDrawer((current) => (
|
|
579
|
+
current.mode === "graph-reader"
|
|
580
|
+
? drawerForGraphSummaryNode(graphData, current.payload.node.id, current, { pins: graphPins })
|
|
581
|
+
: current
|
|
582
|
+
));
|
|
583
|
+
}, [graphData, graphPins]);
|
|
584
|
+
|
|
585
|
+
const handleGraphSelectionTextChange = useCallback((value: string) => {
|
|
586
|
+
setDrawer((current) => (
|
|
587
|
+
current.mode === "graph-selection"
|
|
588
|
+
? graphSelectionDrawer(current.selection, current.title, value)
|
|
589
|
+
: current
|
|
590
|
+
));
|
|
591
|
+
}, []);
|
|
592
|
+
|
|
593
|
+
const handleGraphSelectionNeighbors = useCallback(() => {
|
|
594
|
+
if (drawer.mode !== "graph-selection" || drawer.selection.nodeIds.length !== 1) return;
|
|
595
|
+
setSelectionCommand({
|
|
596
|
+
id: drawer.selection.nodeIds[0],
|
|
597
|
+
type: "neighbors",
|
|
598
|
+
});
|
|
599
|
+
}, [drawer]);
|
|
600
|
+
|
|
601
|
+
const handleGraphSelectionAsk = (actionId: string | null, newConversation: boolean) => {
|
|
602
|
+
if (!graphData || drawer.mode !== "graph-selection") return;
|
|
603
|
+
const action = actionId
|
|
604
|
+
? drawer.selection.actions?.find((item) => item.id === actionId) ?? null
|
|
605
|
+
: null;
|
|
606
|
+
const payload = buildSelectionPromptPayload(graphData, drawer.selection, action, drawer.freeText);
|
|
607
|
+
void handleAskSelection({
|
|
608
|
+
message: payload.expandedText,
|
|
609
|
+
displayText: payload.displayText,
|
|
610
|
+
newConversation,
|
|
611
|
+
});
|
|
612
|
+
setDrawer(closedDrawer());
|
|
613
|
+
setSelectionCommand({ id: Math.random().toString(36).slice(2, 10), type: "clear" });
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
const handleGraphReaderAction = (actionId: GraphReaderActionId) => {
|
|
617
|
+
if (drawer.mode !== "graph-reader") return;
|
|
618
|
+
if (actionId === "find_related_pages") {
|
|
619
|
+
setSelectionCommand({
|
|
620
|
+
id: drawer.payload.node.id,
|
|
621
|
+
type: "neighbors",
|
|
622
|
+
});
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
if (!graphData) return;
|
|
626
|
+
const selection = resolveSelection(graphData, { kind: "node", id: drawer.payload.node.id });
|
|
627
|
+
const action = selection.actions?.find((item) => item.id === actionId) ?? null;
|
|
628
|
+
const payload = buildSelectionPromptPayload(graphData, selection, action, "");
|
|
629
|
+
void handleAskSelection({
|
|
630
|
+
message: payload.expandedText,
|
|
631
|
+
displayText: payload.displayText,
|
|
632
|
+
newConversation: false,
|
|
633
|
+
});
|
|
634
|
+
setDrawer(closedDrawer());
|
|
635
|
+
setSelectionCommand({ id: Math.random().toString(36).slice(2, 10), type: "clear" });
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
const handleCloseDrawer = useCallback((reason: "button" | "escape") => {
|
|
639
|
+
setDrawer((current) => {
|
|
640
|
+
if (current.mode === "graph-reader" || current.mode === "graph-selection") {
|
|
641
|
+
setSelectionCommand({
|
|
642
|
+
id: Math.random().toString(36).slice(2, 10),
|
|
643
|
+
type: reason === "button" ? "clear-selection" : "clear",
|
|
644
|
+
});
|
|
645
|
+
setGraphFocusPath(null);
|
|
646
|
+
}
|
|
647
|
+
return closedDrawer();
|
|
648
|
+
});
|
|
649
|
+
}, []);
|
|
650
|
+
|
|
651
|
+
const handleAddExternal = async (path: string) => {
|
|
652
|
+
const { info } = await registerExternalKnowledgeBase(path);
|
|
653
|
+
await refreshAll();
|
|
654
|
+
if (info.valid) await handleSelectKb(info);
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
const handleMessageSent = async () => {
|
|
658
|
+
// 用户发了一次消息后,刷新对话列表,把 "(新对话)" stub 替换为带 firstMessage 的真实条目
|
|
659
|
+
if (active) await refreshConversations(active.kb.path);
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
const handleOpenPage = async (pagePath: string) => {
|
|
663
|
+
if (!active) return;
|
|
664
|
+
const normalizedPagePath = toRelativePagePath(pagePath, active.kb.path) ?? pagePath;
|
|
665
|
+
if (normalizedPagePath.startsWith("wiki/")) setGraphFocusPath(normalizedPagePath);
|
|
666
|
+
setDrawer(wikiDrawer(normalizedPagePath, { loading: true }));
|
|
667
|
+
try {
|
|
668
|
+
const content = await readPage(active.kb.path, normalizedPagePath);
|
|
669
|
+
setDrawer(wikiDrawer(normalizedPagePath, { content }));
|
|
670
|
+
} catch (err) {
|
|
671
|
+
setDrawer(wikiDrawer(normalizedPagePath, { error: err instanceof Error ? err.message : String(err) }));
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
const handleOpenGraphPage = useCallback(async (
|
|
676
|
+
payload: GraphOpenPagePayload,
|
|
677
|
+
options: { syncGraphFocus?: boolean } = {},
|
|
678
|
+
) => {
|
|
679
|
+
if (!active) return;
|
|
680
|
+
const syncGraphFocus = options.syncGraphFocus ?? true;
|
|
681
|
+
const normalizedPagePath = toRelativePagePath(payload.path, active.kb.path) ?? payload.path;
|
|
682
|
+
const normalizedPayload = {
|
|
683
|
+
...payload,
|
|
684
|
+
path: normalizedPagePath,
|
|
685
|
+
node: {
|
|
686
|
+
...payload.node,
|
|
687
|
+
sourcePath: toRelativePagePath(payload.node.sourcePath, active.kb.path) ?? payload.node.sourcePath,
|
|
688
|
+
},
|
|
689
|
+
};
|
|
690
|
+
if (syncGraphFocus && normalizedPagePath.startsWith("wiki/")) setGraphFocusPath(normalizedPagePath);
|
|
691
|
+
setDrawer(graphReaderDrawer(normalizedPayload, { loading: true }));
|
|
692
|
+
try {
|
|
693
|
+
const content = await readPage(active.kb.path, normalizedPagePath);
|
|
694
|
+
setDrawer((current) => (
|
|
695
|
+
shouldApplyGraphReaderResult(current, normalizedPayload)
|
|
696
|
+
? graphReaderDrawer(normalizedPayload, { content })
|
|
697
|
+
: current
|
|
698
|
+
));
|
|
699
|
+
} catch (err) {
|
|
700
|
+
setDrawer((current) => (
|
|
701
|
+
shouldApplyGraphReaderResult(current, normalizedPayload)
|
|
702
|
+
? graphReaderDrawer(normalizedPayload, { error: err instanceof Error ? err.message : String(err) })
|
|
703
|
+
: current
|
|
704
|
+
));
|
|
705
|
+
}
|
|
706
|
+
}, [active]);
|
|
707
|
+
|
|
708
|
+
const handleGraphSummaryCommand = useCallback((command: GraphSummaryCommand) => {
|
|
709
|
+
if (command.kind === "open-detail-read") {
|
|
710
|
+
const payload = graphOpenPagePayloadForCommand(graphData, command);
|
|
711
|
+
const focusCommand = graphSelectionCommandForOpenDetail(graphData, command);
|
|
712
|
+
if (focusCommand) {
|
|
713
|
+
setSelectionCommand({
|
|
714
|
+
commandId: `open-detail-${command.nodeId}-${Math.random().toString(36).slice(2, 10)}`,
|
|
715
|
+
id: focusCommand.id,
|
|
716
|
+
nodeId: focusCommand.nodeId,
|
|
717
|
+
type: "enter-community-node",
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
if (payload) void handleOpenGraphPage(payload, { syncGraphFocus: !focusCommand });
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
if (command.kind === "enter-community") {
|
|
724
|
+
setSelectionCommand({ id: command.communityId, type: "enter-community" });
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
if (command.kind === "set-fixed-position") {
|
|
728
|
+
setSelectionCommand({
|
|
729
|
+
id: `${command.mode}-${command.nodeId}-${Math.random().toString(36).slice(2, 10)}`,
|
|
730
|
+
nodeId: command.nodeId,
|
|
731
|
+
mode: command.mode,
|
|
732
|
+
type: "set-fixed-position",
|
|
733
|
+
});
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
if (command.kind === "show-this-object") {
|
|
737
|
+
graphTemporaryObjectRef.current = command.object;
|
|
738
|
+
setGraphTemporaryObject(command.object);
|
|
739
|
+
setSelectionCommand({
|
|
740
|
+
id: `show-${Math.random().toString(36).slice(2, 10)}`,
|
|
741
|
+
object: command.object,
|
|
742
|
+
type: "show-temporary-object",
|
|
743
|
+
});
|
|
744
|
+
if (command.object.kind === "node") {
|
|
745
|
+
const nodeId = command.object.nodeId;
|
|
746
|
+
const temporaryObject = command.object;
|
|
747
|
+
setDrawer((current) => {
|
|
748
|
+
const next = drawerForGraphNodeVisibility(graphData, nodeId, current, {
|
|
749
|
+
pins: graphPins,
|
|
750
|
+
visibility: {
|
|
751
|
+
searchQuery: graphVisibilityState?.searchQuery ?? "",
|
|
752
|
+
searchResultIds: graphVisibilityState?.searchResultIds ?? [],
|
|
753
|
+
typeFilters: graphVisibilityState?.typeFilters ?? {},
|
|
754
|
+
temporaryObject,
|
|
755
|
+
},
|
|
756
|
+
});
|
|
757
|
+
return sameGraphDrawerTarget(current, next) ? current : next;
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
if (command.kind === "clear-temporary-object-display") {
|
|
763
|
+
graphTemporaryObjectRef.current = null;
|
|
764
|
+
setGraphTemporaryObject(null);
|
|
765
|
+
setSelectionCommand({
|
|
766
|
+
id: `clear-temporary-${Math.random().toString(36).slice(2, 10)}`,
|
|
767
|
+
type: "clear-temporary-object-display",
|
|
768
|
+
});
|
|
769
|
+
setDrawer((current) => {
|
|
770
|
+
if (current.mode !== "graph-node-summary") return current;
|
|
771
|
+
const next = drawerForGraphNodeVisibility(graphData, current.payload.nodeId, current, {
|
|
772
|
+
pins: graphPins,
|
|
773
|
+
visibility: graphVisibilityState ? { ...graphVisibilityState, temporaryObject: null } : null,
|
|
774
|
+
});
|
|
775
|
+
return sameGraphDrawerTarget(current, next) ? current : next;
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
}, [graphData, graphPins, graphVisibilityState, handleOpenGraphPage]);
|
|
779
|
+
|
|
780
|
+
useEffect(() => {
|
|
781
|
+
if (!isGraphInteractionDrawer(drawer)) return;
|
|
782
|
+
setDrawer((current) => (
|
|
783
|
+
isGraphInteractionDrawer(current)
|
|
784
|
+
? drawerAfterGraphDataRefresh(current, graphData, {
|
|
785
|
+
pins: graphPins,
|
|
786
|
+
visibility: graphVisibilityState,
|
|
787
|
+
temporaryObject: graphTemporaryObjectRef.current,
|
|
788
|
+
})
|
|
789
|
+
: current
|
|
790
|
+
));
|
|
791
|
+
}, [drawer.mode, graphData, graphPins, graphVisibilityState]);
|
|
792
|
+
|
|
793
|
+
const handleGraphSummaryNodeSelect = useCallback((nodeId: string) => {
|
|
794
|
+
setDrawer((current) => drawerForGraphSummaryNode(graphData, nodeId, current, { pins: graphPins }));
|
|
795
|
+
}, [graphData, graphPins]);
|
|
796
|
+
|
|
797
|
+
const handleGraphSummaryNodePreview = useCallback((nodeId: string | null) => {
|
|
798
|
+
setSelectionCommand({
|
|
799
|
+
id: `${nodeId ?? "clear"}-${Math.random().toString(36).slice(2, 10)}`,
|
|
800
|
+
nodeId,
|
|
801
|
+
type: "preview-node",
|
|
802
|
+
});
|
|
803
|
+
}, []);
|
|
804
|
+
|
|
805
|
+
const handleWikiLinkSeen = useCallback((pagePath: string) => {
|
|
806
|
+
setGraphFocusPath(pagePath);
|
|
807
|
+
}, []);
|
|
808
|
+
|
|
809
|
+
const refreshArtifacts = async (conversationId: string, focusId?: string) => {
|
|
810
|
+
const items = await listArtifacts(conversationId);
|
|
811
|
+
setArtifacts(items);
|
|
812
|
+
setDrawer(artifactDrawer(items, focusId ?? items.at(-1)?.id ?? null));
|
|
813
|
+
};
|
|
814
|
+
|
|
815
|
+
const handleOpenArtifacts = () => {
|
|
816
|
+
if (artifacts.length === 0) return;
|
|
817
|
+
const current = drawer.mode === "artifacts" ? drawer.activeArtifactId : null;
|
|
818
|
+
setDrawer(artifactDrawer(
|
|
819
|
+
artifacts,
|
|
820
|
+
current && artifacts.some((item) => item.id === current) ? current : artifacts.at(-1)?.id ?? null,
|
|
821
|
+
));
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
const handleArtifactCreated = async (id: string) => {
|
|
825
|
+
if (!active) return;
|
|
826
|
+
try {
|
|
827
|
+
await refreshArtifacts(active.conversation.id, id);
|
|
828
|
+
} catch (err) {
|
|
829
|
+
setSidebarError(err instanceof Error ? err.message : String(err));
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
|
|
833
|
+
const handleStartBatchDigest = (input: {
|
|
834
|
+
kbPath: string;
|
|
835
|
+
filePaths: string[];
|
|
836
|
+
sourceScanId?: string;
|
|
837
|
+
digestModel?: ModelRef | null;
|
|
838
|
+
concurrency: 1 | 3 | 5;
|
|
839
|
+
}) => {
|
|
840
|
+
const jobId = Math.random().toString(36).slice(2, 10);
|
|
841
|
+
setBatchJob({
|
|
842
|
+
id: jobId,
|
|
843
|
+
kbPath: input.kbPath,
|
|
844
|
+
status: "running",
|
|
845
|
+
total: input.filePaths.length,
|
|
846
|
+
completed: 0,
|
|
847
|
+
failed: 0,
|
|
848
|
+
files: input.filePaths.map((filePath, index) => ({
|
|
849
|
+
index,
|
|
850
|
+
filePath,
|
|
851
|
+
status: "queued",
|
|
852
|
+
})),
|
|
853
|
+
events: [],
|
|
854
|
+
});
|
|
855
|
+
void (async () => {
|
|
856
|
+
try {
|
|
857
|
+
const stream = await streamBatchDigest(input);
|
|
858
|
+
for await (const message of stream) {
|
|
859
|
+
if (message.event === "error") {
|
|
860
|
+
const payload = JSON.parse(message.data) as { message: string };
|
|
861
|
+
throw new Error(payload.message);
|
|
862
|
+
}
|
|
863
|
+
const event = JSON.parse(message.data);
|
|
864
|
+
setBatchJob((current) => {
|
|
865
|
+
if (!current || current.id !== jobId) return current;
|
|
866
|
+
if (event.type === "start") {
|
|
867
|
+
return {
|
|
868
|
+
...current,
|
|
869
|
+
total: event.total,
|
|
870
|
+
outputDir: event.outputDir,
|
|
871
|
+
events: [...current.events, event],
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
if (event.type === "file_start") {
|
|
875
|
+
return {
|
|
876
|
+
...current,
|
|
877
|
+
current: event.filePath,
|
|
878
|
+
files: updateBatchFile(current.files, event.index, {
|
|
879
|
+
status: "running",
|
|
880
|
+
}),
|
|
881
|
+
events: [...current.events, event],
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
if (event.type === "file_progress") {
|
|
885
|
+
return {
|
|
886
|
+
...current,
|
|
887
|
+
files: updateBatchFile(current.files, event.index, {
|
|
888
|
+
status: "running",
|
|
889
|
+
chars: event.chars,
|
|
890
|
+
}),
|
|
891
|
+
events: [...current.events, event],
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
if (event.type === "file_complete") {
|
|
895
|
+
return {
|
|
896
|
+
...current,
|
|
897
|
+
completed: current.completed + 1,
|
|
898
|
+
current: event.filePath,
|
|
899
|
+
files: updateBatchFile(current.files, event.index, {
|
|
900
|
+
status: "done",
|
|
901
|
+
outputPath: event.outputPath,
|
|
902
|
+
}),
|
|
903
|
+
events: [...current.events, event],
|
|
904
|
+
};
|
|
905
|
+
}
|
|
906
|
+
if (event.type === "file_error") {
|
|
907
|
+
return {
|
|
908
|
+
...current,
|
|
909
|
+
failed: current.failed + 1,
|
|
910
|
+
current: event.filePath,
|
|
911
|
+
files: updateBatchFile(current.files, event.index, {
|
|
912
|
+
status: "error",
|
|
913
|
+
error: event.error,
|
|
914
|
+
}),
|
|
915
|
+
events: [...current.events, event],
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
if (event.type === "done") {
|
|
919
|
+
return {
|
|
920
|
+
...current,
|
|
921
|
+
status: "done",
|
|
922
|
+
completed: event.completed,
|
|
923
|
+
failed: event.failed,
|
|
924
|
+
outputDir: event.outputDir,
|
|
925
|
+
events: [...current.events, event],
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
return current;
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
} catch (err) {
|
|
932
|
+
setBatchJob((current) =>
|
|
933
|
+
current && current.id === jobId
|
|
934
|
+
? {
|
|
935
|
+
...current,
|
|
936
|
+
status: "error",
|
|
937
|
+
error: err instanceof Error ? err.message : String(err),
|
|
938
|
+
}
|
|
939
|
+
: current,
|
|
940
|
+
);
|
|
941
|
+
}
|
|
942
|
+
})();
|
|
943
|
+
};
|
|
944
|
+
|
|
945
|
+
const handleOpenBatchOutput = async (outputPath: string) => {
|
|
946
|
+
if (!batchJob) return;
|
|
947
|
+
const rel = toRelativePagePath(outputPath, batchJob.kbPath);
|
|
948
|
+
if (!rel) return;
|
|
949
|
+
setDrawer(wikiDrawer(rel, { loading: true }));
|
|
950
|
+
try {
|
|
951
|
+
const content = await readPage(batchJob.kbPath, rel);
|
|
952
|
+
setDrawer(wikiDrawer(rel, { content }));
|
|
953
|
+
} catch (err) {
|
|
954
|
+
setDrawer(wikiDrawer(rel, { error: err instanceof Error ? err.message : String(err) }));
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
const handleConfigChanged = async () => {
|
|
959
|
+
try {
|
|
960
|
+
const currentActive = await getActiveContext();
|
|
961
|
+
setActive(currentActive);
|
|
962
|
+
if (currentActive) {
|
|
963
|
+
setInitialMessages(currentActive.conversation.messages);
|
|
964
|
+
}
|
|
965
|
+
} catch (err) {
|
|
966
|
+
setSidebarError(err instanceof Error ? err.message : String(err));
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
|
|
970
|
+
const activeKnowledgeBase: KnowledgeBaseInfo | null = active?.kb
|
|
971
|
+
? kbs.find((kb) => kb.path === active.kb.path) ?? {
|
|
972
|
+
path: active.kb.path,
|
|
973
|
+
name: active.kb.name,
|
|
974
|
+
origin: "default",
|
|
975
|
+
valid: true,
|
|
976
|
+
}
|
|
977
|
+
: null;
|
|
978
|
+
|
|
979
|
+
useEffect(() => {
|
|
980
|
+
if (!active?.kb.path) {
|
|
981
|
+
setSearchRefs([]);
|
|
982
|
+
setSearchRefsError(null);
|
|
983
|
+
setSearchRefsLoading(false);
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
let cancelled = false;
|
|
987
|
+
setSearchRefsLoading(true);
|
|
988
|
+
setSearchRefsError(null);
|
|
989
|
+
listRefs(active.kb.path, "", SEARCH_REF_LIMIT)
|
|
990
|
+
.then((items) => {
|
|
991
|
+
if (!cancelled) setSearchRefs(items);
|
|
992
|
+
})
|
|
993
|
+
.catch((err) => {
|
|
994
|
+
if (!cancelled) {
|
|
995
|
+
setSearchRefs([]);
|
|
996
|
+
setSearchRefsError(err instanceof Error ? err.message : String(err));
|
|
997
|
+
}
|
|
998
|
+
})
|
|
999
|
+
.finally(() => {
|
|
1000
|
+
if (!cancelled) setSearchRefsLoading(false);
|
|
1001
|
+
});
|
|
1002
|
+
return () => {
|
|
1003
|
+
cancelled = true;
|
|
1004
|
+
};
|
|
1005
|
+
}, [active?.kb.path]);
|
|
1006
|
+
|
|
1007
|
+
useEffect(() => {
|
|
1008
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
1009
|
+
if (!(event.metaKey || event.ctrlKey) || event.key.toLowerCase() !== "k") return;
|
|
1010
|
+
if (event.defaultPrevented) return;
|
|
1011
|
+
event.preventDefault();
|
|
1012
|
+
if (activeKnowledgeBase?.valid) setSearchOpen(true);
|
|
1013
|
+
};
|
|
1014
|
+
window.addEventListener("keydown", onKeyDown);
|
|
1015
|
+
return () => window.removeEventListener("keydown", onKeyDown);
|
|
1016
|
+
}, [activeKnowledgeBase?.valid]);
|
|
1017
|
+
|
|
1018
|
+
const drawerOpen = drawer.mode !== "closed";
|
|
1019
|
+
const graphDrawerOverlay = mainView === "graph" && isGraphInteractionDrawer(drawer) && !drawerFullscreen;
|
|
1020
|
+
|
|
1021
|
+
return (
|
|
1022
|
+
<TooltipProvider delayDuration={200}>
|
|
1023
|
+
<div className="app-shell">
|
|
1024
|
+
<TopBar
|
|
1025
|
+
knowledgeBase={activeKnowledgeBase}
|
|
1026
|
+
model={active?.model ?? null}
|
|
1027
|
+
theme={theme}
|
|
1028
|
+
chatStatus={chatStatus}
|
|
1029
|
+
graphStatus={graphStatus}
|
|
1030
|
+
appearanceOpen={appearanceOpen}
|
|
1031
|
+
searchDisabled={!activeKnowledgeBase?.valid}
|
|
1032
|
+
modelDisabled={loading}
|
|
1033
|
+
newConversationDisabled={loading}
|
|
1034
|
+
onSearch={() => setSearchOpen(true)}
|
|
1035
|
+
onConfigChanged={handleConfigChanged}
|
|
1036
|
+
onNewConversation={handleNewConversation}
|
|
1037
|
+
onToggleTheme={toggleTheme}
|
|
1038
|
+
onOpenAppearance={() => setAppearanceOpen((value) => !value)}
|
|
1039
|
+
/>
|
|
1040
|
+
<div
|
|
1041
|
+
className="app-body"
|
|
1042
|
+
data-drawer-open={drawerOpen ? "true" : "false"}
|
|
1043
|
+
data-graph-drawer-overlay={graphDrawerOverlay ? "true" : "false"}
|
|
1044
|
+
>
|
|
1045
|
+
<Sidebar
|
|
1046
|
+
knowledgeBases={kbs}
|
|
1047
|
+
currentKbPath={active?.kb.path ?? null}
|
|
1048
|
+
conversations={conversations}
|
|
1049
|
+
currentConversationId={active?.conversation.id ?? null}
|
|
1050
|
+
error={sidebarError}
|
|
1051
|
+
collapsed={sidebarCollapsed}
|
|
1052
|
+
activeView={mainView}
|
|
1053
|
+
onSelectKb={handleSelectKb}
|
|
1054
|
+
onSelectConversation={handleSelectConversation}
|
|
1055
|
+
onSelectView={setMainView}
|
|
1056
|
+
onNewConversation={handleNewConversation}
|
|
1057
|
+
onOpenSettings={() => setSettingsOpen(true)}
|
|
1058
|
+
onToggleCollapsed={() => setSidebarCollapsed((value) => !value)}
|
|
1059
|
+
graphHasPendingUpdate={graphHasPendingUpdate}
|
|
1060
|
+
onAddExternal={handleAddExternal}
|
|
1061
|
+
onStartBatchDigest={handleStartBatchDigest}
|
|
1062
|
+
/>
|
|
1063
|
+
<main className="shell-main">
|
|
1064
|
+
<MainViewTabs
|
|
1065
|
+
activeView={mainView}
|
|
1066
|
+
graphHasPendingUpdate={graphHasPendingUpdate}
|
|
1067
|
+
onSelectView={setMainView}
|
|
1068
|
+
/>
|
|
1069
|
+
<div className="main-view-content">
|
|
1070
|
+
<div className={mainView === "graph" ? "chat-host chat-host-hidden" : "chat-host"}>
|
|
1071
|
+
<ChatPanel
|
|
1072
|
+
key={chatKey}
|
|
1073
|
+
hidden={mainView === "graph"}
|
|
1074
|
+
currentKnowledgeBaseName={active?.kb.name ?? null}
|
|
1075
|
+
initialMessages={initialMessages}
|
|
1076
|
+
onMessageSent={handleMessageSent}
|
|
1077
|
+
onStatusChange={setChatStatus}
|
|
1078
|
+
currentKnowledgeBasePath={active?.kb.path ?? null}
|
|
1079
|
+
onOpenPage={handleOpenPage}
|
|
1080
|
+
onWikiLinkSeen={handleWikiLinkSeen}
|
|
1081
|
+
onArtifactCreated={handleArtifactCreated}
|
|
1082
|
+
artifactCount={artifacts.length}
|
|
1083
|
+
onOpenArtifacts={handleOpenArtifacts}
|
|
1084
|
+
onStartBatchDigest={handleStartBatchDigest}
|
|
1085
|
+
pendingPrompt={pendingGraphPrompt}
|
|
1086
|
+
onPendingPromptConsumed={() => setPendingGraphPrompt(null)}
|
|
1087
|
+
pendingInsertRef={pendingInsertRef}
|
|
1088
|
+
onPendingInsertRefConsumed={() => setPendingInsertRef(null)}
|
|
1089
|
+
/>
|
|
1090
|
+
</div>
|
|
1091
|
+
{mainView === "graph" && (
|
|
1092
|
+
<GraphPanel
|
|
1093
|
+
currentKnowledgeBaseName={active?.kb.name ?? null}
|
|
1094
|
+
currentKnowledgeBasePath={active?.kb.path ?? null}
|
|
1095
|
+
theme={theme}
|
|
1096
|
+
graphBuildError={graphBuildError}
|
|
1097
|
+
onOpenPage={handleOpenGraphPage}
|
|
1098
|
+
onGraphDataChange={handleGraphDataChange}
|
|
1099
|
+
onGraphPinsChange={setGraphPins}
|
|
1100
|
+
onGraphVisibilityChange={handleGraphVisibilityChange}
|
|
1101
|
+
onSelectionChange={handleGraphSelectionChange}
|
|
1102
|
+
onStatusChange={setGraphStatus}
|
|
1103
|
+
onViewReset={handleGraphViewReset}
|
|
1104
|
+
selectionCommand={selectionCommand}
|
|
1105
|
+
focusPath={graphFocusPath}
|
|
1106
|
+
pendingDiff={pendingGraphDiff}
|
|
1107
|
+
refreshToken={graphRefreshToken}
|
|
1108
|
+
onDiffConsumed={() => setPendingGraphDiff(null)}
|
|
1109
|
+
/>
|
|
1110
|
+
)}
|
|
1111
|
+
</div>
|
|
1112
|
+
</main>
|
|
1113
|
+
<RightDrawer
|
|
1114
|
+
drawer={drawer}
|
|
1115
|
+
fullscreen={drawerFullscreen}
|
|
1116
|
+
width={drawerWidth}
|
|
1117
|
+
defaultWidth={DEFAULT_DRAWER_WIDTH}
|
|
1118
|
+
onSelectArtifact={(id) => setDrawer(artifactDrawer(artifacts, id))}
|
|
1119
|
+
onOpenPage={handleOpenPage}
|
|
1120
|
+
onWikiLinkSeen={handleWikiLinkSeen}
|
|
1121
|
+
onGraphReaderAction={handleGraphReaderAction}
|
|
1122
|
+
onGraphSummaryCommand={handleGraphSummaryCommand}
|
|
1123
|
+
onGraphSummaryNodeSelect={handleGraphSummaryNodeSelect}
|
|
1124
|
+
onGraphSummaryNodePreview={handleGraphSummaryNodePreview}
|
|
1125
|
+
onGraphSelectionTextChange={handleGraphSelectionTextChange}
|
|
1126
|
+
onGraphSelectionNeighbors={handleGraphSelectionNeighbors}
|
|
1127
|
+
onGraphSelectionAsk={handleGraphSelectionAsk}
|
|
1128
|
+
onResize={setDrawerWidth}
|
|
1129
|
+
onToggleFullscreen={() => setDrawerFullscreen((value) => !value)}
|
|
1130
|
+
onClose={handleCloseDrawer}
|
|
1131
|
+
/>
|
|
1132
|
+
</div>
|
|
1133
|
+
<SettingsPanel
|
|
1134
|
+
open={settingsOpen}
|
|
1135
|
+
onOpenChange={setSettingsOpen}
|
|
1136
|
+
onConfigChanged={handleConfigChanged}
|
|
1137
|
+
/>
|
|
1138
|
+
<BatchDigestPanel
|
|
1139
|
+
job={batchJob}
|
|
1140
|
+
onClose={() => setBatchJob(null)}
|
|
1141
|
+
onOpenOutput={handleOpenBatchOutput}
|
|
1142
|
+
/>
|
|
1143
|
+
<AppearancePanel
|
|
1144
|
+
open={appearanceOpen}
|
|
1145
|
+
value={appearance}
|
|
1146
|
+
onChange={updateAppearance}
|
|
1147
|
+
onClose={() => setAppearanceOpen(false)}
|
|
1148
|
+
/>
|
|
1149
|
+
<SearchPanel
|
|
1150
|
+
open={searchOpen}
|
|
1151
|
+
refs={searchRefs}
|
|
1152
|
+
loading={searchRefsLoading}
|
|
1153
|
+
error={searchRefsError}
|
|
1154
|
+
knowledgeBaseName={active?.kb.name ?? null}
|
|
1155
|
+
onClose={() => setSearchOpen(false)}
|
|
1156
|
+
onOpenPage={handleOpenPage}
|
|
1157
|
+
onInsertRef={(path) => {
|
|
1158
|
+
setMainView("chat");
|
|
1159
|
+
setPendingInsertRef({ id: Math.random().toString(36).slice(2, 10), path });
|
|
1160
|
+
}}
|
|
1161
|
+
/>
|
|
1162
|
+
</div>
|
|
1163
|
+
</TooltipProvider>
|
|
1164
|
+
);
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
function updateBatchFile<T extends { index: number }>(
|
|
1168
|
+
files: T[],
|
|
1169
|
+
index: number,
|
|
1170
|
+
patch: Partial<T>,
|
|
1171
|
+
): T[] {
|
|
1172
|
+
return files.map((file) => (file.index === index ? { ...file, ...patch } : file));
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
function toRelativePagePath(outputPath: string, kbPath: string): string | null {
|
|
1176
|
+
const normalizedKb = kbPath.endsWith("/") ? kbPath : `${kbPath}/`;
|
|
1177
|
+
if (outputPath.startsWith(normalizedKb)) return outputPath.slice(normalizedKb.length);
|
|
1178
|
+
if (outputPath.startsWith("wiki/")) return outputPath;
|
|
1179
|
+
return null;
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
function isGraphInteractionDrawer(drawer: DrawerState): boolean {
|
|
1183
|
+
return drawer.mode === "graph-selection"
|
|
1184
|
+
|| drawer.mode === "graph-node-summary"
|
|
1185
|
+
|| drawer.mode === "graph-community-summary"
|
|
1186
|
+
|| drawer.mode === "graph-search-results"
|
|
1187
|
+
|| drawer.mode === "graph-excluded-object"
|
|
1188
|
+
|| drawer.mode === "graph-unavailable-object"
|
|
1189
|
+
|| drawer.mode === "graph-global-overview"
|
|
1190
|
+
|| drawer.mode === "graph-loading"
|
|
1191
|
+
|| drawer.mode === "graph-empty"
|
|
1192
|
+
|| drawer.mode === "graph-error";
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
export default App;
|