@vpxa/aikit 0.1.58 → 0.1.60
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 +38 -3
- package/package.json +2 -1
- package/packages/aikit-client/dist/index.d.ts +146 -4
- package/packages/aikit-client/dist/index.js +5 -1
- package/packages/analyzers/dist/index.d.ts +309 -11
- package/packages/analyzers/dist/index.js +54 -1
- package/packages/chunker/dist/index.d.ts +451 -18
- package/packages/chunker/dist/index.js +24 -1
- package/packages/cli/dist/{commands/init/constants.js → constants-D3v4VDf0.js} +1 -1
- package/packages/cli/dist/index.js +15 -2
- package/packages/cli/dist/init-D0CiV9PX.js +7 -0
- package/packages/cli/dist/scaffold-CJwkHf-q.js +2 -0
- package/packages/cli/dist/{commands/init/templates.js → templates-DJ7EC5vw.js} +1 -1
- package/packages/cli/dist/user-HmJYNt5b.js +5 -0
- package/packages/core/dist/index.d.ts +357 -6
- package/packages/core/dist/index.js +1 -1
- package/packages/dashboard/dist/assets/{index-Cdke3KDK.js → index-C6D-PCp0.js} +7 -7
- package/packages/dashboard/dist/assets/index-C6D-PCp0.js.map +1 -0
- package/packages/dashboard/dist/index.html +1 -1
- package/packages/elicitation/dist/index.d.ts +139 -4
- package/packages/elicitation/dist/index.js +1 -1
- package/packages/embeddings/dist/index.d.ts +45 -2
- package/packages/embeddings/dist/index.js +1 -1
- package/packages/enterprise-bridge/dist/index.d.ts +275 -7
- package/packages/enterprise-bridge/dist/index.js +1 -1
- package/packages/flows/dist/index.d.ts +345 -12
- package/packages/flows/dist/index.js +15 -1
- package/packages/indexer/dist/index.d.ts +196 -6
- package/packages/indexer/dist/index.js +1 -1
- package/packages/present/dist/index.html +315 -314
- package/packages/server/dist/curated-manager-DX-_oJg0.js +5 -0
- package/packages/server/dist/index.d.ts +139 -1
- package/packages/server/dist/index.js +1 -1
- package/packages/server/dist/server-eMZ64H9b.js +1274 -0
- package/packages/store/dist/index.d.ts +316 -5
- package/packages/store/dist/index.js +90 -1
- package/packages/store/dist/lance-store-jdHZp-V4.js +1 -0
- package/packages/tools/dist/index.d.ts +2161 -61
- package/packages/tools/dist/index.js +117 -1
- package/packages/tui/dist/{App-CoMyn2kt.js → App-DobfqTPH.js} +1 -1
- package/packages/tui/dist/App.d.ts +1 -1
- package/packages/tui/dist/App.js +1 -1
- package/packages/tui/dist/{LogPanel-CDItCD0E.js → LogPanel-DGeptKim.js} +3 -3
- package/packages/tui/dist/hooks/useKBClient.d.ts +1 -1
- package/packages/tui/dist/{index-MXJeXmCf.d.ts → index-floZQwfo.d.ts} +2 -1
- package/packages/tui/dist/index.d.ts +1 -1
- package/packages/tui/dist/index.js +1 -1
- package/packages/tui/dist/panels/LogPanel.js +1 -1
- package/scaffold/definitions/bodies.mjs +47 -0
- package/scaffold/definitions/protocols.mjs +9 -0
- package/scaffold/definitions/tools.mjs +15 -0
- package/scaffold/general/agents/Debugger.agent.md +9 -0
- package/scaffold/general/agents/Documenter.agent.md +9 -0
- package/scaffold/general/agents/Frontend.agent.md +9 -0
- package/scaffold/general/agents/Implementer.agent.md +9 -0
- package/scaffold/general/agents/Orchestrator.agent.md +47 -0
- package/scaffold/general/agents/Planner.agent.md +9 -0
- package/scaffold/general/agents/Refactor.agent.md +9 -0
- package/scaffold/general/agents/Security.agent.md +9 -0
- package/scaffold/general/agents/_shared/code-agent-base.md +9 -0
- package/scaffold/general/skills/aikit/SKILL.md +71 -7
- package/scaffold/general/skills/c4-architecture/SKILL.md +87 -1
- package/scaffold/general/skills/c4-architecture/references/html-design-system.md +337 -0
- package/scaffold/general/skills/c4-architecture/references/html-template.html +627 -0
- package/scaffold/general/skills/present/SKILL.md +180 -0
- package/packages/aikit-client/dist/direct-client.d.ts +0 -37
- package/packages/aikit-client/dist/direct-client.js +0 -1
- package/packages/aikit-client/dist/mcp-client.d.ts +0 -19
- package/packages/aikit-client/dist/mcp-client.js +0 -4
- package/packages/aikit-client/dist/parsers.d.ts +0 -35
- package/packages/aikit-client/dist/parsers.js +0 -2
- package/packages/aikit-client/dist/types.d.ts +0 -62
- package/packages/aikit-client/dist/types.js +0 -1
- package/packages/analyzers/dist/blast-radius-analyzer.d.ts +0 -19
- package/packages/analyzers/dist/blast-radius-analyzer.js +0 -6
- package/packages/analyzers/dist/dependency-analyzer.d.ts +0 -32
- package/packages/analyzers/dist/dependency-analyzer.js +0 -8
- package/packages/analyzers/dist/diagram-generator.d.ts +0 -16
- package/packages/analyzers/dist/diagram-generator.js +0 -2
- package/packages/analyzers/dist/entry-point-analyzer.d.ts +0 -40
- package/packages/analyzers/dist/entry-point-analyzer.js +0 -4
- package/packages/analyzers/dist/knowledge-producer.d.ts +0 -40
- package/packages/analyzers/dist/knowledge-producer.js +0 -26
- package/packages/analyzers/dist/pattern-analyzer.d.ts +0 -15
- package/packages/analyzers/dist/pattern-analyzer.js +0 -2
- package/packages/analyzers/dist/regex-call-graph.d.ts +0 -10
- package/packages/analyzers/dist/regex-call-graph.js +0 -1
- package/packages/analyzers/dist/structure-analyzer.d.ts +0 -19
- package/packages/analyzers/dist/structure-analyzer.js +0 -4
- package/packages/analyzers/dist/symbol-analyzer.d.ts +0 -14
- package/packages/analyzers/dist/symbol-analyzer.js +0 -9
- package/packages/analyzers/dist/ts-call-graph.d.ts +0 -29
- package/packages/analyzers/dist/ts-call-graph.js +0 -1
- package/packages/analyzers/dist/types.d.ts +0 -110
- package/packages/analyzers/dist/types.js +0 -1
- package/packages/chunker/dist/call-graph-extractor.d.ts +0 -25
- package/packages/chunker/dist/call-graph-extractor.js +0 -1
- package/packages/chunker/dist/chunker-factory.d.ts +0 -19
- package/packages/chunker/dist/chunker-factory.js +0 -1
- package/packages/chunker/dist/chunker.interface.d.ts +0 -13
- package/packages/chunker/dist/chunker.interface.js +0 -1
- package/packages/chunker/dist/code-chunker.d.ts +0 -17
- package/packages/chunker/dist/code-chunker.js +0 -11
- package/packages/chunker/dist/extractors/call-extractor.d.ts +0 -24
- package/packages/chunker/dist/extractors/call-extractor.js +0 -1
- package/packages/chunker/dist/extractors/entry-point-detector.d.ts +0 -14
- package/packages/chunker/dist/extractors/entry-point-detector.js +0 -1
- package/packages/chunker/dist/extractors/import-extractor.d.ts +0 -14
- package/packages/chunker/dist/extractors/import-extractor.js +0 -1
- package/packages/chunker/dist/extractors/pattern-detector.d.ts +0 -14
- package/packages/chunker/dist/extractors/pattern-detector.js +0 -1
- package/packages/chunker/dist/extractors/scope-resolver.d.ts +0 -26
- package/packages/chunker/dist/extractors/scope-resolver.js +0 -1
- package/packages/chunker/dist/extractors/symbol-extractor.d.ts +0 -14
- package/packages/chunker/dist/extractors/symbol-extractor.js +0 -3
- package/packages/chunker/dist/extractors/types.d.ts +0 -44
- package/packages/chunker/dist/extractors/types.js +0 -1
- package/packages/chunker/dist/generic-chunker.d.ts +0 -15
- package/packages/chunker/dist/generic-chunker.js +0 -5
- package/packages/chunker/dist/markdown-chunker.d.ts +0 -17
- package/packages/chunker/dist/markdown-chunker.js +0 -3
- package/packages/chunker/dist/wasm/languages.d.ts +0 -18
- package/packages/chunker/dist/wasm/languages.js +0 -1
- package/packages/chunker/dist/wasm/query-executor.d.ts +0 -70
- package/packages/chunker/dist/wasm/query-executor.js +0 -1
- package/packages/chunker/dist/wasm/runtime.d.ts +0 -44
- package/packages/chunker/dist/wasm/runtime.js +0 -1
- package/packages/chunker/dist/wasm/types.d.ts +0 -84
- package/packages/chunker/dist/wasm/types.js +0 -1
- package/packages/chunker/dist/wasm-chunker.d.ts +0 -23
- package/packages/chunker/dist/wasm-chunker.js +0 -6
- package/packages/cli/dist/aikit-init.d.ts +0 -59
- package/packages/cli/dist/aikit-init.js +0 -1
- package/packages/cli/dist/commands/analyze.d.ts +0 -6
- package/packages/cli/dist/commands/analyze.js +0 -2
- package/packages/cli/dist/commands/context-cmds.d.ts +0 -6
- package/packages/cli/dist/commands/context-cmds.js +0 -1
- package/packages/cli/dist/commands/environment.d.ts +0 -6
- package/packages/cli/dist/commands/environment.js +0 -1
- package/packages/cli/dist/commands/execution.d.ts +0 -6
- package/packages/cli/dist/commands/execution.js +0 -1
- package/packages/cli/dist/commands/flow.d.ts +0 -6
- package/packages/cli/dist/commands/flow.js +0 -1
- package/packages/cli/dist/commands/graph.d.ts +0 -6
- package/packages/cli/dist/commands/graph.js +0 -6
- package/packages/cli/dist/commands/init/adapters.d.ts +0 -28
- package/packages/cli/dist/commands/init/adapters.js +0 -1
- package/packages/cli/dist/commands/init/config.d.ts +0 -10
- package/packages/cli/dist/commands/init/config.js +0 -3
- package/packages/cli/dist/commands/init/constants.d.ts +0 -46
- package/packages/cli/dist/commands/init/curated.d.ts +0 -7
- package/packages/cli/dist/commands/init/curated.js +0 -1
- package/packages/cli/dist/commands/init/frontmatter.d.ts +0 -79
- package/packages/cli/dist/commands/init/frontmatter.js +0 -2
- package/packages/cli/dist/commands/init/index.d.ts +0 -36
- package/packages/cli/dist/commands/init/index.js +0 -5
- package/packages/cli/dist/commands/init/manifest.d.ts +0 -72
- package/packages/cli/dist/commands/init/manifest.js +0 -1
- package/packages/cli/dist/commands/init/scaffold.d.ts +0 -58
- package/packages/cli/dist/commands/init/scaffold.js +0 -1
- package/packages/cli/dist/commands/init/templates.d.ts +0 -9
- package/packages/cli/dist/commands/init/user.d.ts +0 -61
- package/packages/cli/dist/commands/init/user.js +0 -5
- package/packages/cli/dist/commands/knowledge.d.ts +0 -6
- package/packages/cli/dist/commands/knowledge.js +0 -1
- package/packages/cli/dist/commands/search.d.ts +0 -6
- package/packages/cli/dist/commands/search.js +0 -1
- package/packages/cli/dist/commands/system.d.ts +0 -6
- package/packages/cli/dist/commands/system.js +0 -4
- package/packages/cli/dist/commands/upgrade.d.ts +0 -6
- package/packages/cli/dist/commands/upgrade.js +0 -1
- package/packages/cli/dist/commands/workspace.d.ts +0 -6
- package/packages/cli/dist/commands/workspace.js +0 -1
- package/packages/cli/dist/context.d.ts +0 -7
- package/packages/cli/dist/context.js +0 -1
- package/packages/cli/dist/helpers.d.ts +0 -55
- package/packages/cli/dist/helpers.js +0 -5
- package/packages/cli/dist/types.d.ts +0 -9
- package/packages/cli/dist/types.js +0 -1
- package/packages/core/dist/constants.d.ts +0 -74
- package/packages/core/dist/constants.js +0 -1
- package/packages/core/dist/content-detector.d.ts +0 -13
- package/packages/core/dist/content-detector.js +0 -1
- package/packages/core/dist/errors.d.ts +0 -20
- package/packages/core/dist/errors.js +0 -1
- package/packages/core/dist/global-registry.d.ts +0 -69
- package/packages/core/dist/global-registry.js +0 -1
- package/packages/core/dist/logger.d.ts +0 -32
- package/packages/core/dist/logger.js +0 -1
- package/packages/core/dist/types.d.ts +0 -149
- package/packages/core/dist/types.js +0 -1
- package/packages/dashboard/dist/assets/index-Cdke3KDK.js.map +0 -1
- package/packages/elicitation/dist/build.d.ts +0 -14
- package/packages/elicitation/dist/build.js +0 -1
- package/packages/elicitation/dist/fields.d.ts +0 -32
- package/packages/elicitation/dist/fields.js +0 -1
- package/packages/elicitation/dist/normalize.d.ts +0 -15
- package/packages/elicitation/dist/normalize.js +0 -1
- package/packages/elicitation/dist/types.d.ts +0 -88
- package/packages/elicitation/dist/types.js +0 -1
- package/packages/embeddings/dist/embedder.interface.d.ts +0 -26
- package/packages/embeddings/dist/embedder.interface.js +0 -1
- package/packages/embeddings/dist/onnx-embedder.d.ts +0 -23
- package/packages/embeddings/dist/onnx-embedder.js +0 -1
- package/packages/enterprise-bridge/dist/cache.d.ts +0 -28
- package/packages/enterprise-bridge/dist/cache.js +0 -1
- package/packages/enterprise-bridge/dist/er-client.d.ts +0 -37
- package/packages/enterprise-bridge/dist/er-client.js +0 -1
- package/packages/enterprise-bridge/dist/evolution-collector.d.ts +0 -62
- package/packages/enterprise-bridge/dist/evolution-collector.js +0 -1
- package/packages/enterprise-bridge/dist/policy-store.d.ts +0 -45
- package/packages/enterprise-bridge/dist/policy-store.js +0 -1
- package/packages/enterprise-bridge/dist/push-adapter.d.ts +0 -23
- package/packages/enterprise-bridge/dist/push-adapter.js +0 -1
- package/packages/enterprise-bridge/dist/result-merger.d.ts +0 -14
- package/packages/enterprise-bridge/dist/result-merger.js +0 -1
- package/packages/enterprise-bridge/dist/types.d.ts +0 -81
- package/packages/enterprise-bridge/dist/types.js +0 -1
- package/packages/flows/dist/adapters/claude-plugin.d.ts +0 -25
- package/packages/flows/dist/adapters/claude-plugin.js +0 -3
- package/packages/flows/dist/adapters/copilot.d.ts +0 -12
- package/packages/flows/dist/adapters/copilot.js +0 -1
- package/packages/flows/dist/adapters/index.d.ts +0 -12
- package/packages/flows/dist/adapters/index.js +0 -1
- package/packages/flows/dist/adapters/native.d.ts +0 -10
- package/packages/flows/dist/adapters/native.js +0 -1
- package/packages/flows/dist/adapters/openspec.d.ts +0 -40
- package/packages/flows/dist/adapters/openspec.js +0 -1
- package/packages/flows/dist/builtins.d.ts +0 -16
- package/packages/flows/dist/builtins.js +0 -1
- package/packages/flows/dist/foundation.d.ts +0 -20
- package/packages/flows/dist/foundation.js +0 -11
- package/packages/flows/dist/git.d.ts +0 -53
- package/packages/flows/dist/git.js +0 -2
- package/packages/flows/dist/loader.d.ts +0 -13
- package/packages/flows/dist/loader.js +0 -2
- package/packages/flows/dist/registry.d.ts +0 -23
- package/packages/flows/dist/registry.js +0 -1
- package/packages/flows/dist/state-machine.d.ts +0 -23
- package/packages/flows/dist/state-machine.js +0 -1
- package/packages/flows/dist/symlinks.d.ts +0 -17
- package/packages/flows/dist/symlinks.js +0 -1
- package/packages/flows/dist/types.d.ts +0 -127
- package/packages/flows/dist/types.js +0 -1
- package/packages/indexer/dist/file-hasher.d.ts +0 -13
- package/packages/indexer/dist/file-hasher.js +0 -1
- package/packages/indexer/dist/filesystem-crawler.d.ts +0 -29
- package/packages/indexer/dist/filesystem-crawler.js +0 -1
- package/packages/indexer/dist/graph-extractor.d.ts +0 -22
- package/packages/indexer/dist/graph-extractor.js +0 -1
- package/packages/indexer/dist/hash-cache.d.ts +0 -24
- package/packages/indexer/dist/hash-cache.js +0 -1
- package/packages/indexer/dist/incremental-indexer.d.ts +0 -73
- package/packages/indexer/dist/incremental-indexer.js +0 -1
- package/packages/indexer/dist/smart-index-scheduler.d.ts +0 -47
- package/packages/indexer/dist/smart-index-scheduler.js +0 -1
- package/packages/server/dist/api.d.ts +0 -3
- package/packages/server/dist/api.js +0 -1
- package/packages/server/dist/auto-gc.d.ts +0 -30
- package/packages/server/dist/auto-gc.js +0 -1
- package/packages/server/dist/background-task.d.ts +0 -47
- package/packages/server/dist/background-task.js +0 -1
- package/packages/server/dist/completions.d.ts +0 -14
- package/packages/server/dist/completions.js +0 -1
- package/packages/server/dist/compression-interceptor.d.ts +0 -12
- package/packages/server/dist/compression-interceptor.js +0 -1
- package/packages/server/dist/config.d.ts +0 -16
- package/packages/server/dist/cross-workspace.d.ts +0 -43
- package/packages/server/dist/cross-workspace.js +0 -1
- package/packages/server/dist/curated-manager.d.ts +0 -92
- package/packages/server/dist/curated-manager.js +0 -5
- package/packages/server/dist/dashboard-static.d.ts +0 -27
- package/packages/server/dist/elicitor.d.ts +0 -18
- package/packages/server/dist/elicitor.js +0 -1
- package/packages/server/dist/idle-timer.d.ts +0 -33
- package/packages/server/dist/idle-timer.js +0 -1
- package/packages/server/dist/mcp-logging.d.ts +0 -11
- package/packages/server/dist/mcp-logging.js +0 -1
- package/packages/server/dist/memory-monitor.d.ts +0 -37
- package/packages/server/dist/memory-monitor.js +0 -1
- package/packages/server/dist/output-schemas.d.ts +0 -244
- package/packages/server/dist/output-schemas.js +0 -1
- package/packages/server/dist/prompts.d.ts +0 -13
- package/packages/server/dist/prompts.js +0 -13
- package/packages/server/dist/replay-interceptor.d.ts +0 -23
- package/packages/server/dist/replay-interceptor.js +0 -1
- package/packages/server/dist/resource-links.d.ts +0 -34
- package/packages/server/dist/resource-links.js +0 -1
- package/packages/server/dist/resources/curated-resources.d.ts +0 -13
- package/packages/server/dist/resources/curated-resources.js +0 -2
- package/packages/server/dist/resources/resource-notifier.d.ts +0 -45
- package/packages/server/dist/resources/resource-notifier.js +0 -1
- package/packages/server/dist/resources/resources.d.ts +0 -8
- package/packages/server/dist/resources/resources.js +0 -2
- package/packages/server/dist/sampling.d.ts +0 -41
- package/packages/server/dist/sampling.js +0 -2
- package/packages/server/dist/server.d.ts +0 -63
- package/packages/server/dist/server.js +0 -3
- package/packages/server/dist/structured-content-guard.d.ts +0 -28
- package/packages/server/dist/structured-content-guard.js +0 -1
- package/packages/server/dist/task-manager.d.ts +0 -40
- package/packages/server/dist/task-manager.js +0 -1
- package/packages/server/dist/tool-metadata.d.ts +0 -38
- package/packages/server/dist/tool-metadata.js +0 -1
- package/packages/server/dist/tool-prefix.d.ts +0 -12
- package/packages/server/dist/tool-prefix.js +0 -1
- package/packages/server/dist/tool-timeout.d.ts +0 -27
- package/packages/server/dist/tool-timeout.js +0 -1
- package/packages/server/dist/tools/analyze.tools.d.ts +0 -14
- package/packages/server/dist/tools/analyze.tools.js +0 -8
- package/packages/server/dist/tools/audit.tool.d.ts +0 -8
- package/packages/server/dist/tools/audit.tool.js +0 -1
- package/packages/server/dist/tools/brainstorm.tool.d.ts +0 -7
- package/packages/server/dist/tools/brainstorm.tool.js +0 -9
- package/packages/server/dist/tools/bridge.tools.d.ts +0 -34
- package/packages/server/dist/tools/bridge.tools.js +0 -15
- package/packages/server/dist/tools/config.tool.d.ts +0 -8
- package/packages/server/dist/tools/config.tool.js +0 -12
- package/packages/server/dist/tools/context.tools.d.ts +0 -15
- package/packages/server/dist/tools/context.tools.js +0 -10
- package/packages/server/dist/tools/evolution.tools.d.ts +0 -7
- package/packages/server/dist/tools/evolution.tools.js +0 -5
- package/packages/server/dist/tools/execution.tools.d.ts +0 -14
- package/packages/server/dist/tools/execution.tools.js +0 -4
- package/packages/server/dist/tools/flow.tools.d.ts +0 -7
- package/packages/server/dist/tools/flow.tools.js +0 -16
- package/packages/server/dist/tools/forge.tools.d.ts +0 -13
- package/packages/server/dist/tools/forge.tools.js +0 -10
- package/packages/server/dist/tools/forget.tool.d.ts +0 -8
- package/packages/server/dist/tools/forget.tool.js +0 -1
- package/packages/server/dist/tools/graph.tool.d.ts +0 -7
- package/packages/server/dist/tools/graph.tool.js +0 -29
- package/packages/server/dist/tools/infra.tools.d.ts +0 -10
- package/packages/server/dist/tools/infra.tools.js +0 -5
- package/packages/server/dist/tools/list.tool.d.ts +0 -7
- package/packages/server/dist/tools/list.tool.js +0 -2
- package/packages/server/dist/tools/lookup.tool.d.ts +0 -7
- package/packages/server/dist/tools/lookup.tool.js +0 -3
- package/packages/server/dist/tools/manipulation.tools.d.ts +0 -10
- package/packages/server/dist/tools/manipulation.tools.js +0 -4
- package/packages/server/dist/tools/onboard.tool.d.ts +0 -12
- package/packages/server/dist/tools/onboard.tool.js +0 -2
- package/packages/server/dist/tools/persistence.tools.d.ts +0 -10
- package/packages/server/dist/tools/persistence.tools.js +0 -5
- package/packages/server/dist/tools/policy.tools.d.ts +0 -7
- package/packages/server/dist/tools/policy.tools.js +0 -3
- package/packages/server/dist/tools/present/browser.d.ts +0 -4
- package/packages/server/dist/tools/present/browser.js +0 -93
- package/packages/server/dist/tools/present/helpers.d.ts +0 -19
- package/packages/server/dist/tools/present/helpers.js +0 -16
- package/packages/server/dist/tools/present/html.d.ts +0 -18
- package/packages/server/dist/tools/present/html.js +0 -5
- package/packages/server/dist/tools/present/index.d.ts +0 -2
- package/packages/server/dist/tools/present/index.js +0 -1
- package/packages/server/dist/tools/present/markdown.d.ts +0 -32
- package/packages/server/dist/tools/present/markdown.js +0 -11
- package/packages/server/dist/tools/present/templates.d.ts +0 -14
- package/packages/server/dist/tools/present/templates.js +0 -472
- package/packages/server/dist/tools/present/tool.d.ts +0 -27
- package/packages/server/dist/tools/present/tool.js +0 -39
- package/packages/server/dist/tools/present-blocks.d.ts +0 -46
- package/packages/server/dist/tools/present-blocks.js +0 -27
- package/packages/server/dist/tools/present-charts.d.ts +0 -31
- package/packages/server/dist/tools/present-charts.js +0 -34
- package/packages/server/dist/tools/present-theme.d.ts +0 -14
- package/packages/server/dist/tools/present-theme.js +0 -396
- package/packages/server/dist/tools/present-utils.d.ts +0 -11
- package/packages/server/dist/tools/present-utils.js +0 -1
- package/packages/server/dist/tools/present.tool.d.ts +0 -2
- package/packages/server/dist/tools/present.tool.js +0 -1
- package/packages/server/dist/tools/produce.tool.d.ts +0 -7
- package/packages/server/dist/tools/produce.tool.js +0 -4
- package/packages/server/dist/tools/read.tool.d.ts +0 -7
- package/packages/server/dist/tools/read.tool.js +0 -2
- package/packages/server/dist/tools/reindex.tool.d.ts +0 -11
- package/packages/server/dist/tools/reindex.tool.js +0 -9
- package/packages/server/dist/tools/remember.tool.d.ts +0 -9
- package/packages/server/dist/tools/remember.tool.js +0 -4
- package/packages/server/dist/tools/replay.tool.d.ts +0 -6
- package/packages/server/dist/tools/replay.tool.js +0 -3
- package/packages/server/dist/tools/restore.tool.d.ts +0 -6
- package/packages/server/dist/tools/restore.tool.js +0 -3
- package/packages/server/dist/tools/search.tool.d.ts +0 -11
- package/packages/server/dist/tools/search.tool.js +0 -10
- package/packages/server/dist/tools/status.tool.d.ts +0 -28
- package/packages/server/dist/tools/status.tool.js +0 -3
- package/packages/server/dist/tools/update.tool.d.ts +0 -8
- package/packages/server/dist/tools/update.tool.js +0 -1
- package/packages/server/dist/tools/utility.tools.d.ts +0 -15
- package/packages/server/dist/tools/utility.tools.js +0 -13
- package/packages/server/dist/version-check.d.ts +0 -32
- package/packages/store/dist/graph-store.interface.d.ts +0 -159
- package/packages/store/dist/graph-store.interface.js +0 -1
- package/packages/store/dist/lance-store.d.ts +0 -46
- package/packages/store/dist/lance-store.js +0 -1
- package/packages/store/dist/sqlite-graph-store.d.ts +0 -57
- package/packages/store/dist/sqlite-graph-store.js +0 -90
- package/packages/store/dist/store-factory.d.ts +0 -12
- package/packages/store/dist/store-factory.js +0 -1
- package/packages/store/dist/store.interface.d.ts +0 -54
- package/packages/store/dist/store.interface.js +0 -1
- package/packages/tools/dist/audit.d.ts +0 -65
- package/packages/tools/dist/audit.js +0 -6
- package/packages/tools/dist/batch.d.ts +0 -23
- package/packages/tools/dist/batch.js +0 -1
- package/packages/tools/dist/changelog.d.ts +0 -36
- package/packages/tools/dist/changelog.js +0 -2
- package/packages/tools/dist/check.d.ts +0 -48
- package/packages/tools/dist/check.js +0 -2
- package/packages/tools/dist/checkpoint.d.ts +0 -19
- package/packages/tools/dist/checkpoint.js +0 -1
- package/packages/tools/dist/codemod.d.ts +0 -39
- package/packages/tools/dist/codemod.js +0 -2
- package/packages/tools/dist/compact.d.ts +0 -47
- package/packages/tools/dist/compact.js +0 -3
- package/packages/tools/dist/compress-output.d.ts +0 -38
- package/packages/tools/dist/compress-output.js +0 -1
- package/packages/tools/dist/compression/delta-cache.d.ts +0 -29
- package/packages/tools/dist/compression/delta-cache.js +0 -1
- package/packages/tools/dist/compression/engine.d.ts +0 -34
- package/packages/tools/dist/compression/engine.js +0 -4
- package/packages/tools/dist/compression/litm.d.ts +0 -20
- package/packages/tools/dist/compression/litm.js +0 -1
- package/packages/tools/dist/compression/mmr.d.ts +0 -24
- package/packages/tools/dist/compression/mmr.js +0 -1
- package/packages/tools/dist/compression/rules/docker.d.ts +0 -11
- package/packages/tools/dist/compression/rules/docker.js +0 -3
- package/packages/tools/dist/compression/rules/generic.d.ts +0 -11
- package/packages/tools/dist/compression/rules/generic.js +0 -3
- package/packages/tools/dist/compression/rules/git.d.ts +0 -11
- package/packages/tools/dist/compression/rules/git.js +0 -3
- package/packages/tools/dist/compression/rules/index.d.ts +0 -14
- package/packages/tools/dist/compression/rules/index.js +0 -1
- package/packages/tools/dist/compression/rules/kubectl.d.ts +0 -11
- package/packages/tools/dist/compression/rules/kubectl.js +0 -3
- package/packages/tools/dist/compression/rules/lint.d.ts +0 -11
- package/packages/tools/dist/compression/rules/lint.js +0 -3
- package/packages/tools/dist/compression/rules/npm.d.ts +0 -11
- package/packages/tools/dist/compression/rules/npm.js +0 -3
- package/packages/tools/dist/compression/rules/test-runner.d.ts +0 -11
- package/packages/tools/dist/compression/rules/test-runner.js +0 -3
- package/packages/tools/dist/compression/scoring.d.ts +0 -26
- package/packages/tools/dist/compression/scoring.js +0 -1
- package/packages/tools/dist/compression/types.d.ts +0 -61
- package/packages/tools/dist/compression/types.js +0 -1
- package/packages/tools/dist/config-extractor.d.ts +0 -9
- package/packages/tools/dist/config-extractor.js +0 -7
- package/packages/tools/dist/data-transform.d.ts +0 -12
- package/packages/tools/dist/data-transform.js +0 -1
- package/packages/tools/dist/dead-symbols.d.ts +0 -28
- package/packages/tools/dist/dead-symbols.js +0 -2
- package/packages/tools/dist/delegate.d.ts +0 -36
- package/packages/tools/dist/delegate.js +0 -1
- package/packages/tools/dist/diagram-builder.d.ts +0 -9
- package/packages/tools/dist/diagram-builder.js +0 -9
- package/packages/tools/dist/diff-parse.d.ts +0 -28
- package/packages/tools/dist/diff-parse.js +0 -3
- package/packages/tools/dist/digest.d.ts +0 -55
- package/packages/tools/dist/digest.js +0 -6
- package/packages/tools/dist/dogfood-log.d.ts +0 -49
- package/packages/tools/dist/dogfood-log.js +0 -2
- package/packages/tools/dist/encode.d.ts +0 -16
- package/packages/tools/dist/encode.js +0 -1
- package/packages/tools/dist/env-info.d.ts +0 -30
- package/packages/tools/dist/env-info.js +0 -1
- package/packages/tools/dist/eval.d.ts +0 -15
- package/packages/tools/dist/eval.js +0 -2
- package/packages/tools/dist/evidence-map.d.ts +0 -92
- package/packages/tools/dist/evidence-map.js +0 -2
- package/packages/tools/dist/file-cache.d.ts +0 -41
- package/packages/tools/dist/file-cache.js +0 -3
- package/packages/tools/dist/file-summary.d.ts +0 -52
- package/packages/tools/dist/file-summary.js +0 -2
- package/packages/tools/dist/file-walk.d.ts +0 -6
- package/packages/tools/dist/file-walk.js +0 -1
- package/packages/tools/dist/find-examples.d.ts +0 -29
- package/packages/tools/dist/find-examples.js +0 -3
- package/packages/tools/dist/find.d.ts +0 -49
- package/packages/tools/dist/find.js +0 -1
- package/packages/tools/dist/forge-classify.d.ts +0 -44
- package/packages/tools/dist/forge-classify.js +0 -2
- package/packages/tools/dist/forge-ground.d.ts +0 -61
- package/packages/tools/dist/forge-ground.js +0 -1
- package/packages/tools/dist/git-context.d.ts +0 -25
- package/packages/tools/dist/git-context.js +0 -3
- package/packages/tools/dist/graph-query.d.ts +0 -98
- package/packages/tools/dist/graph-query.js +0 -1
- package/packages/tools/dist/guide.d.ts +0 -25
- package/packages/tools/dist/guide.js +0 -1
- package/packages/tools/dist/health.d.ts +0 -16
- package/packages/tools/dist/health.js +0 -2
- package/packages/tools/dist/http-request.d.ts +0 -25
- package/packages/tools/dist/http-request.js +0 -1
- package/packages/tools/dist/lane.d.ts +0 -41
- package/packages/tools/dist/lane.js +0 -6
- package/packages/tools/dist/measure.d.ts +0 -42
- package/packages/tools/dist/measure.js +0 -2
- package/packages/tools/dist/onboard-utils.d.ts +0 -12
- package/packages/tools/dist/onboard-utils.js +0 -1
- package/packages/tools/dist/onboard.d.ts +0 -50
- package/packages/tools/dist/onboard.js +0 -18
- package/packages/tools/dist/parse-output.d.ts +0 -84
- package/packages/tools/dist/parse-output.js +0 -2
- package/packages/tools/dist/path-resolver.d.ts +0 -14
- package/packages/tools/dist/path-resolver.js +0 -1
- package/packages/tools/dist/process-manager.d.ts +0 -20
- package/packages/tools/dist/process-manager.js +0 -1
- package/packages/tools/dist/queue.d.ts +0 -40
- package/packages/tools/dist/queue.js +0 -1
- package/packages/tools/dist/regex-test.d.ts +0 -33
- package/packages/tools/dist/regex-test.js +0 -1
- package/packages/tools/dist/regex-utils.d.ts +0 -8
- package/packages/tools/dist/regex-utils.js +0 -1
- package/packages/tools/dist/rename.d.ts +0 -31
- package/packages/tools/dist/rename.js +0 -2
- package/packages/tools/dist/replay.d.ts +0 -59
- package/packages/tools/dist/replay.js +0 -4
- package/packages/tools/dist/response-envelope.d.ts +0 -43
- package/packages/tools/dist/response-envelope.js +0 -1
- package/packages/tools/dist/restore-points.d.ts +0 -22
- package/packages/tools/dist/restore-points.js +0 -1
- package/packages/tools/dist/schema-validate.d.ts +0 -25
- package/packages/tools/dist/schema-validate.js +0 -1
- package/packages/tools/dist/scope-map.d.ts +0 -51
- package/packages/tools/dist/scope-map.js +0 -1
- package/packages/tools/dist/snippet.d.ts +0 -35
- package/packages/tools/dist/snippet.js +0 -1
- package/packages/tools/dist/stash.d.ts +0 -14
- package/packages/tools/dist/stash.js +0 -1
- package/packages/tools/dist/stratum-card.d.ts +0 -30
- package/packages/tools/dist/stratum-card.js +0 -4
- package/packages/tools/dist/symbol.d.ts +0 -45
- package/packages/tools/dist/symbol.js +0 -3
- package/packages/tools/dist/synthesis-engine.d.ts +0 -13
- package/packages/tools/dist/synthesis-engine.js +0 -6
- package/packages/tools/dist/test-run.d.ts +0 -28
- package/packages/tools/dist/test-run.js +0 -2
- package/packages/tools/dist/text-utils.d.ts +0 -24
- package/packages/tools/dist/text-utils.js +0 -2
- package/packages/tools/dist/time-utils.d.ts +0 -20
- package/packages/tools/dist/time-utils.js +0 -1
- package/packages/tools/dist/trace.d.ts +0 -43
- package/packages/tools/dist/trace.js +0 -2
- package/packages/tools/dist/truncation.d.ts +0 -66
- package/packages/tools/dist/truncation.js +0 -11
- package/packages/tools/dist/watch.d.ts +0 -32
- package/packages/tools/dist/watch.js +0 -1
- package/packages/tools/dist/web-fetch.d.ts +0 -47
- package/packages/tools/dist/web-fetch.js +0 -8
- package/packages/tools/dist/web-search.d.ts +0 -25
- package/packages/tools/dist/web-search.js +0 -1
- package/packages/tools/dist/workset.d.ts +0 -47
- package/packages/tools/dist/workset.js +0 -1
- package/scaffold/__tests__/copilot-inline-shared-protocols.test.mjs +0 -39
- /package/packages/server/dist/{config.js → config-C5IU9Lau.js} +0 -0
- /package/packages/server/dist/{dashboard-static.js → dashboard-static-BfIe0Si1.js} +0 -0
- /package/packages/server/dist/{version-check.js → version-check-D4j0Pykd.js} +0 -0
|
@@ -1,6 +1,317 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { ContentType, IndexStats, KnowledgeOrigin, KnowledgeRecord, SearchResult, SourceType } from "../../core/dist/index.js";
|
|
2
|
+
|
|
3
|
+
//#region packages/store/src/graph-store.interface.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Knowledge graph store abstraction — typed nodes + edges for entity-relationship storage.
|
|
6
|
+
* Complements the vector store: vector search finds similar content,
|
|
7
|
+
* graph traversal finds connected concepts.
|
|
8
|
+
*/
|
|
9
|
+
/** A node in the knowledge graph (entity, concept, service, etc.) */
|
|
10
|
+
interface GraphNode {
|
|
11
|
+
/** Unique identifier */
|
|
12
|
+
id: string;
|
|
13
|
+
/** Node type (e.g., 'entity', 'service', 'api', 'concept', 'decision') */
|
|
14
|
+
type: string;
|
|
15
|
+
/** Display name */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Arbitrary properties */
|
|
18
|
+
properties: Record<string, unknown>;
|
|
19
|
+
/** Back-link to KnowledgeRecord.id that produced this node */
|
|
20
|
+
sourceRecordId?: string;
|
|
21
|
+
/** Source file path (for cleanup on re-index) */
|
|
22
|
+
sourcePath?: string;
|
|
23
|
+
/** ISO timestamp */
|
|
24
|
+
createdAt?: string;
|
|
25
|
+
/** Community/cluster label from community detection */
|
|
26
|
+
community?: string;
|
|
27
|
+
}
|
|
28
|
+
/** An edge connecting two nodes */
|
|
29
|
+
interface GraphEdge {
|
|
30
|
+
/** Unique identifier */
|
|
31
|
+
id: string;
|
|
32
|
+
/** Source node ID */
|
|
33
|
+
fromId: string;
|
|
34
|
+
/** Target node ID */
|
|
35
|
+
toId: string;
|
|
36
|
+
/** Relationship type (e.g., 'depends-on', 'implements', 'calls', 'affects') */
|
|
37
|
+
type: string;
|
|
38
|
+
/** Optional weight (0-1) */
|
|
39
|
+
weight?: number;
|
|
40
|
+
/** Optional confidence score (0-1) for relationship certainty */
|
|
41
|
+
confidence?: number;
|
|
42
|
+
/** Arbitrary properties */
|
|
43
|
+
properties?: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
/** Options for graph traversal */
|
|
46
|
+
interface GraphTraversalOptions {
|
|
47
|
+
/** Relationship type filter */
|
|
48
|
+
edgeType?: string;
|
|
49
|
+
/** Max traversal depth (default: 2) */
|
|
50
|
+
maxDepth?: number;
|
|
51
|
+
/** Direction: outgoing from start, incoming to start, or both */
|
|
52
|
+
direction?: 'outgoing' | 'incoming' | 'both';
|
|
53
|
+
/** Max total nodes returned (default: 50) */
|
|
54
|
+
limit?: number;
|
|
55
|
+
}
|
|
56
|
+
/** Result of a graph traversal */
|
|
57
|
+
interface GraphTraversalResult {
|
|
58
|
+
nodes: GraphNode[];
|
|
59
|
+
edges: GraphEdge[];
|
|
60
|
+
}
|
|
61
|
+
/** Graph statistics */
|
|
62
|
+
interface GraphStats {
|
|
63
|
+
nodeCount: number;
|
|
64
|
+
edgeCount: number;
|
|
65
|
+
nodeTypes: Record<string, number>;
|
|
66
|
+
edgeTypes: Record<string, number>;
|
|
67
|
+
}
|
|
68
|
+
/** Result of graph validation */
|
|
69
|
+
interface GraphValidationResult {
|
|
70
|
+
valid: boolean;
|
|
71
|
+
orphanNodes: string[];
|
|
72
|
+
danglingEdges: Array<{
|
|
73
|
+
edgeId: string;
|
|
74
|
+
missingNodeId: string;
|
|
75
|
+
}>;
|
|
76
|
+
stats: GraphStats;
|
|
77
|
+
}
|
|
78
|
+
/** Depth-grouped traversal result — nodes bucketed by distance from start */
|
|
79
|
+
interface DepthGroupedResult {
|
|
80
|
+
[depth: number]: GraphNode[];
|
|
81
|
+
}
|
|
82
|
+
/** Execution flow / process info */
|
|
83
|
+
interface ProcessInfo {
|
|
84
|
+
id: string;
|
|
85
|
+
entryNodeId: string;
|
|
86
|
+
label: string;
|
|
87
|
+
properties: Record<string, unknown>;
|
|
88
|
+
steps: string[];
|
|
89
|
+
createdAt?: string;
|
|
90
|
+
}
|
|
91
|
+
/** 360-degree symbol view — full context around a node */
|
|
92
|
+
interface Symbol360 {
|
|
93
|
+
node: GraphNode;
|
|
94
|
+
incoming: GraphEdge[];
|
|
95
|
+
outgoing: GraphEdge[];
|
|
96
|
+
community: string | null;
|
|
97
|
+
processes: ProcessInfo[];
|
|
98
|
+
}
|
|
99
|
+
/** Knowledge graph store interface */
|
|
100
|
+
interface IGraphStore {
|
|
101
|
+
/** Initialize the store (create tables, indices) */
|
|
102
|
+
initialize(): Promise<void>;
|
|
103
|
+
/** Add or update a single node */
|
|
104
|
+
upsertNode(node: GraphNode): Promise<void>;
|
|
105
|
+
/** Add or update a single edge */
|
|
106
|
+
upsertEdge(edge: GraphEdge): Promise<void>;
|
|
107
|
+
/** Batch add/update nodes */
|
|
108
|
+
upsertNodes(nodes: GraphNode[]): Promise<void>;
|
|
109
|
+
/** Batch add/update edges */
|
|
110
|
+
upsertEdges(edges: GraphEdge[]): Promise<void>;
|
|
111
|
+
/** Get a node by ID */
|
|
112
|
+
getNode(id: string): Promise<GraphNode | null>;
|
|
113
|
+
/** Get direct neighbors of a node */
|
|
114
|
+
getNeighbors(nodeId: string, options?: GraphTraversalOptions): Promise<GraphTraversalResult>;
|
|
115
|
+
/** Multi-hop traversal from a starting node */
|
|
116
|
+
traverse(startId: string, options?: GraphTraversalOptions): Promise<GraphTraversalResult>;
|
|
117
|
+
/** Find nodes by type and/or name pattern */
|
|
118
|
+
findNodes(filter: {
|
|
119
|
+
type?: string;
|
|
120
|
+
namePattern?: string;
|
|
121
|
+
sourcePath?: string;
|
|
122
|
+
limit?: number;
|
|
123
|
+
}): Promise<GraphNode[]>;
|
|
124
|
+
/** Find edges by type between optional node filters */
|
|
125
|
+
findEdges(filter: {
|
|
126
|
+
type?: string;
|
|
127
|
+
fromId?: string;
|
|
128
|
+
toId?: string;
|
|
129
|
+
limit?: number;
|
|
130
|
+
}): Promise<GraphEdge[]>;
|
|
131
|
+
/** Delete a node and all its edges */
|
|
132
|
+
deleteNode(id: string): Promise<void>;
|
|
133
|
+
/** Delete all nodes/edges originating from a source path */
|
|
134
|
+
deleteBySourcePath(sourcePath: string): Promise<number>;
|
|
135
|
+
/** Delete all nodes and edges (full reset) */
|
|
136
|
+
clear(): Promise<void>;
|
|
137
|
+
/** Get graph statistics */
|
|
138
|
+
getStats(): Promise<GraphStats>;
|
|
139
|
+
/** Validate graph integrity — check for orphan nodes and dangling edges */
|
|
140
|
+
validate(): Promise<GraphValidationResult>;
|
|
141
|
+
/** Set community label on a node */
|
|
142
|
+
setNodeCommunity(nodeId: string, community: string): Promise<void>;
|
|
143
|
+
/** Run label-propagation community detection, returns community -> nodeId[] map */
|
|
144
|
+
detectCommunities(): Promise<Record<string, string[]>>;
|
|
145
|
+
/** Trace execution flow from entry node via outgoing 'calls' edges, store as process */
|
|
146
|
+
traceProcess(entryNodeId: string, label: string): Promise<ProcessInfo>;
|
|
147
|
+
/** List processes, optionally filtered to those containing a specific node */
|
|
148
|
+
getProcesses(nodeId?: string): Promise<ProcessInfo[]>;
|
|
149
|
+
/** Delete a process and its steps */
|
|
150
|
+
deleteProcess(processId: string): Promise<void>;
|
|
151
|
+
/** Traverse with results grouped by depth: { 1: [...], 2: [...], 3: [...] } */
|
|
152
|
+
depthGroupedTraversal(startId: string, maxDepth?: number, options?: GraphTraversalOptions): Promise<DepthGroupedResult>;
|
|
153
|
+
/** Cohesion score for a community: internal edges / (internal + external edges) */
|
|
154
|
+
getCohesionScore(community: string): Promise<number>;
|
|
155
|
+
/** 360-degree view of a node: incoming, outgoing, community, processes */
|
|
156
|
+
getSymbol360(nodeId: string): Promise<Symbol360>;
|
|
157
|
+
/** Close the store */
|
|
158
|
+
close(): Promise<void>;
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region packages/store/src/store.interface.d.ts
|
|
162
|
+
/** Options for searching the store */
|
|
163
|
+
interface SearchOptions {
|
|
164
|
+
/** Maximum number of results to return */
|
|
165
|
+
limit?: number;
|
|
166
|
+
/** Minimum similarity score (0-1) */
|
|
167
|
+
minScore?: number;
|
|
168
|
+
/** Filter by content type */
|
|
169
|
+
contentType?: ContentType;
|
|
170
|
+
/** Filter by coarse source type (source, documentation, test, config, generated) */
|
|
171
|
+
sourceType?: SourceType;
|
|
172
|
+
/** Filter by origin */
|
|
173
|
+
origin?: KnowledgeOrigin;
|
|
174
|
+
/** Filter by category */
|
|
175
|
+
category?: string;
|
|
176
|
+
/** Filter by tags (any match) */
|
|
177
|
+
tags?: string[];
|
|
178
|
+
}
|
|
179
|
+
interface IKnowledgeStore {
|
|
180
|
+
/** Initialize the store (create tables, etc.) */
|
|
181
|
+
initialize(): Promise<void>;
|
|
182
|
+
/** Add or update records with their embedding vectors */
|
|
183
|
+
upsert(records: KnowledgeRecord[], vectors: Float32Array[]): Promise<void>;
|
|
184
|
+
/** Add or update records with priority over bulk indexing writes */
|
|
185
|
+
upsertInteractive(records: KnowledgeRecord[], vectors: Float32Array[]): Promise<void>;
|
|
186
|
+
/** Search by vector similarity */
|
|
187
|
+
search(queryVector: Float32Array, options?: SearchOptions): Promise<SearchResult[]>;
|
|
188
|
+
/** Get a specific record by ID */
|
|
189
|
+
getById(id: string): Promise<KnowledgeRecord | null>;
|
|
190
|
+
/** Delete records by source path (used during re-indexing) */
|
|
191
|
+
deleteBySourcePath(sourcePath: string): Promise<number>;
|
|
192
|
+
/** Delete a specific record by ID */
|
|
193
|
+
deleteById(id: string): Promise<boolean>;
|
|
194
|
+
/** Delete a specific record by ID with priority over bulk indexing writes */
|
|
195
|
+
deleteByIdInteractive(id: string): Promise<boolean>;
|
|
196
|
+
/** Get all records for a source path */
|
|
197
|
+
getBySourcePath(sourcePath: string): Promise<KnowledgeRecord[]>;
|
|
198
|
+
/** Get index statistics */
|
|
199
|
+
getStats(): Promise<IndexStats>;
|
|
200
|
+
/** List all unique source paths in the store */
|
|
201
|
+
listSourcePaths(): Promise<string[]>;
|
|
202
|
+
/** Create a full-text search index on the content column for keyword search */
|
|
203
|
+
createFtsIndex(): Promise<void>;
|
|
204
|
+
/** Full-text keyword search (requires FTS index) */
|
|
205
|
+
ftsSearch(query: string, options?: SearchOptions): Promise<SearchResult[]>;
|
|
206
|
+
/** Drop the backing table entirely — used for hard resets (e.g. dimension changes) */
|
|
207
|
+
dropTable(): Promise<void>;
|
|
208
|
+
/** Close the store connection */
|
|
209
|
+
close(): Promise<void>;
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region packages/store/src/lance-store.d.ts
|
|
213
|
+
declare class LanceStore implements IKnowledgeStore {
|
|
214
|
+
private db;
|
|
215
|
+
private table;
|
|
216
|
+
private readonly dbPath;
|
|
217
|
+
private readonly tableName;
|
|
218
|
+
private _draining;
|
|
219
|
+
private _priorityQueue;
|
|
220
|
+
private _normalQueue;
|
|
221
|
+
private _ftsReady;
|
|
222
|
+
private _ftsRecoveryAttemptAt;
|
|
223
|
+
private static readonly FTS_RECOVERY_COOLDOWN_MS;
|
|
224
|
+
private enqueueWrite;
|
|
225
|
+
private _drain;
|
|
226
|
+
constructor(options?: {
|
|
227
|
+
path?: string;
|
|
228
|
+
tableName?: string;
|
|
229
|
+
});
|
|
230
|
+
initialize(): Promise<void>;
|
|
231
|
+
upsert(records: KnowledgeRecord[], vectors: Float32Array[]): Promise<void>;
|
|
232
|
+
upsertInteractive(records: KnowledgeRecord[], vectors: Float32Array[]): Promise<void>;
|
|
233
|
+
private _upsertImpl;
|
|
234
|
+
search(queryVector: Float32Array, options?: SearchOptions): Promise<SearchResult[]>;
|
|
235
|
+
createFtsIndex(): Promise<void>;
|
|
236
|
+
private _createFtsIndexImpl;
|
|
237
|
+
ftsSearch(query: string, options?: SearchOptions): Promise<SearchResult[]>;
|
|
238
|
+
getById(id: string): Promise<KnowledgeRecord | null>;
|
|
239
|
+
deleteBySourcePath(sourcePath: string): Promise<number>;
|
|
240
|
+
private _deleteBySourcePathImpl;
|
|
241
|
+
deleteById(id: string): Promise<boolean>;
|
|
242
|
+
deleteByIdInteractive(id: string): Promise<boolean>;
|
|
243
|
+
private _deleteByIdImpl;
|
|
244
|
+
getBySourcePath(sourcePath: string): Promise<KnowledgeRecord[]>;
|
|
245
|
+
getStats(): Promise<IndexStats>;
|
|
246
|
+
listSourcePaths(): Promise<string[]>;
|
|
247
|
+
dropTable(): Promise<void>;
|
|
248
|
+
private _dropTableImpl;
|
|
249
|
+
close(): Promise<void>;
|
|
250
|
+
private buildFilterString;
|
|
251
|
+
private fromLanceRecord;
|
|
252
|
+
}
|
|
253
|
+
//#endregion
|
|
254
|
+
//#region packages/store/src/sqlite-graph-store.d.ts
|
|
255
|
+
declare class SqliteGraphStore implements IGraphStore {
|
|
256
|
+
private db;
|
|
257
|
+
private readonly dbPath;
|
|
258
|
+
private sqlFactory;
|
|
259
|
+
private dirty;
|
|
260
|
+
constructor(options?: {
|
|
261
|
+
path?: string;
|
|
262
|
+
});
|
|
263
|
+
initialize(): Promise<void>;
|
|
264
|
+
private configureDb;
|
|
265
|
+
private createTables;
|
|
266
|
+
private migrateSchema;
|
|
267
|
+
private ensureDb;
|
|
268
|
+
private persist;
|
|
269
|
+
private markDirty;
|
|
270
|
+
private flushIfDirty;
|
|
271
|
+
private query;
|
|
272
|
+
private run;
|
|
273
|
+
upsertNode(node: GraphNode): Promise<void>;
|
|
274
|
+
upsertEdge(edge: GraphEdge): Promise<void>;
|
|
275
|
+
upsertNodes(nodes: GraphNode[]): Promise<void>;
|
|
276
|
+
upsertEdges(edges: GraphEdge[]): Promise<void>;
|
|
277
|
+
getNode(id: string): Promise<GraphNode | null>;
|
|
278
|
+
getNeighbors(nodeId: string, options?: GraphTraversalOptions): Promise<GraphTraversalResult>;
|
|
279
|
+
traverse(startId: string, options?: GraphTraversalOptions): Promise<GraphTraversalResult>;
|
|
280
|
+
findNodes(filter: {
|
|
281
|
+
type?: string;
|
|
282
|
+
namePattern?: string;
|
|
283
|
+
sourcePath?: string;
|
|
284
|
+
limit?: number;
|
|
285
|
+
}): Promise<GraphNode[]>;
|
|
286
|
+
findEdges(filter: {
|
|
287
|
+
type?: string;
|
|
288
|
+
fromId?: string;
|
|
289
|
+
toId?: string;
|
|
290
|
+
limit?: number;
|
|
291
|
+
}): Promise<GraphEdge[]>;
|
|
292
|
+
deleteNode(id: string): Promise<void>;
|
|
293
|
+
deleteBySourcePath(sourcePath: string): Promise<number>;
|
|
294
|
+
clear(): Promise<void>;
|
|
295
|
+
getStats(): Promise<GraphStats>;
|
|
296
|
+
validate(): Promise<GraphValidationResult>;
|
|
297
|
+
setNodeCommunity(nodeId: string, community: string): Promise<void>;
|
|
298
|
+
detectCommunities(): Promise<Record<string, string[]>>;
|
|
299
|
+
traceProcess(entryNodeId: string, label: string): Promise<ProcessInfo>;
|
|
300
|
+
getProcesses(nodeId?: string): Promise<ProcessInfo[]>;
|
|
301
|
+
deleteProcess(processId: string): Promise<void>;
|
|
302
|
+
depthGroupedTraversal(startId: string, maxDepth?: number, options?: GraphTraversalOptions): Promise<DepthGroupedResult>;
|
|
303
|
+
getCohesionScore(community: string): Promise<number>;
|
|
304
|
+
getSymbol360(nodeId: string): Promise<Symbol360>;
|
|
305
|
+
close(): Promise<void>;
|
|
306
|
+
}
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region packages/store/src/store-factory.d.ts
|
|
309
|
+
type StoreBackend = 'lancedb' | 'sqlite-vec';
|
|
310
|
+
interface StoreConfig {
|
|
311
|
+
backend: StoreBackend;
|
|
312
|
+
path: string;
|
|
313
|
+
options?: Record<string, unknown>;
|
|
314
|
+
}
|
|
315
|
+
declare function createStore(config: StoreConfig): Promise<IKnowledgeStore>;
|
|
316
|
+
//#endregion
|
|
6
317
|
export { type DepthGroupedResult, type GraphEdge, type GraphNode, type GraphStats, type GraphTraversalOptions, type GraphTraversalResult, type GraphValidationResult, type IGraphStore, type IKnowledgeStore, LanceStore, type ProcessInfo, type SearchOptions, SqliteGraphStore, type StoreBackend, type StoreConfig, type Symbol360, createStore };
|
|
@@ -1 +1,90 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"./lance-store-jdHZp-V4.js";import{AIKIT_PATHS as t}from"../../core/dist/index.js";import{existsSync as n,mkdirSync as r,readFileSync as i,writeFileSync as a}from"node:fs";import{dirname as o,join as s}from"node:path";var c=class{db=null;dbPath;sqlFactory=null;dirty=!1;constructor(e){let n=e?.path??t.data;this.dbPath=s(n,`graph.db`)}async initialize(){let e=o(this.dbPath);n(e)||r(e,{recursive:!0});let t=(await import(`sql.js`)).default,a=await t();if(this.sqlFactory=a,n(this.dbPath)){let e=i(this.dbPath);this.db=new a.Database(e)}else this.db=new a.Database;this.configureDb(this.db),this.createTables(this.db),this.migrateSchema(this.db),this.persist()}configureDb(e){e.run(`PRAGMA journal_mode = WAL`),e.exec(`PRAGMA foreign_keys = ON;`)}createTables(e){e.run(`
|
|
2
|
+
CREATE TABLE IF NOT EXISTS nodes (
|
|
3
|
+
id TEXT PRIMARY KEY,
|
|
4
|
+
type TEXT NOT NULL,
|
|
5
|
+
name TEXT NOT NULL,
|
|
6
|
+
properties TEXT NOT NULL DEFAULT '{}',
|
|
7
|
+
source_record_id TEXT,
|
|
8
|
+
source_path TEXT,
|
|
9
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
10
|
+
community TEXT
|
|
11
|
+
)
|
|
12
|
+
`),e.run(`
|
|
13
|
+
CREATE TABLE IF NOT EXISTS edges (
|
|
14
|
+
id TEXT PRIMARY KEY,
|
|
15
|
+
from_id TEXT NOT NULL,
|
|
16
|
+
to_id TEXT NOT NULL,
|
|
17
|
+
type TEXT NOT NULL,
|
|
18
|
+
weight REAL DEFAULT 1.0,
|
|
19
|
+
confidence REAL DEFAULT 1.0,
|
|
20
|
+
properties TEXT NOT NULL DEFAULT '{}',
|
|
21
|
+
FOREIGN KEY (from_id) REFERENCES nodes(id) ON DELETE CASCADE,
|
|
22
|
+
FOREIGN KEY (to_id) REFERENCES nodes(id) ON DELETE CASCADE
|
|
23
|
+
)
|
|
24
|
+
`),e.run(`CREATE INDEX IF NOT EXISTS idx_nodes_type ON nodes(type)`),e.run(`CREATE INDEX IF NOT EXISTS idx_nodes_name ON nodes(name)`),e.run(`CREATE INDEX IF NOT EXISTS idx_nodes_source_path ON nodes(source_path)`),e.run(`CREATE INDEX IF NOT EXISTS idx_edges_from ON edges(from_id)`),e.run(`CREATE INDEX IF NOT EXISTS idx_edges_to ON edges(to_id)`),e.run(`CREATE INDEX IF NOT EXISTS idx_edges_type ON edges(type)`),e.run(`
|
|
25
|
+
CREATE TABLE IF NOT EXISTS processes (
|
|
26
|
+
id TEXT PRIMARY KEY,
|
|
27
|
+
entry_node_id TEXT NOT NULL,
|
|
28
|
+
label TEXT NOT NULL,
|
|
29
|
+
properties TEXT NOT NULL DEFAULT '{}',
|
|
30
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
31
|
+
FOREIGN KEY (entry_node_id) REFERENCES nodes(id) ON DELETE CASCADE
|
|
32
|
+
)
|
|
33
|
+
`),e.run(`
|
|
34
|
+
CREATE TABLE IF NOT EXISTS process_steps (
|
|
35
|
+
process_id TEXT NOT NULL,
|
|
36
|
+
node_id TEXT NOT NULL,
|
|
37
|
+
step_order INTEGER NOT NULL,
|
|
38
|
+
PRIMARY KEY (process_id, node_id),
|
|
39
|
+
FOREIGN KEY (process_id) REFERENCES processes(id) ON DELETE CASCADE,
|
|
40
|
+
FOREIGN KEY (node_id) REFERENCES nodes(id) ON DELETE CASCADE
|
|
41
|
+
)
|
|
42
|
+
`),e.run(`CREATE INDEX IF NOT EXISTS idx_process_steps_node ON process_steps(node_id)`)}migrateSchema(e){for(let t of[`ALTER TABLE edges ADD COLUMN confidence REAL DEFAULT 1.0`,`ALTER TABLE nodes ADD COLUMN community TEXT`])try{e.run(t)}catch{}e.run(`CREATE INDEX IF NOT EXISTS idx_nodes_community ON nodes(community)`)}ensureDb(){if(!this.db){if(!this.sqlFactory)throw Error(`Graph store not initialized — call initialize() first`);this.db=n(this.dbPath)?new this.sqlFactory.Database(i(this.dbPath)):new this.sqlFactory.Database,this.configureDb(this.db),this.createTables(this.db),this.migrateSchema(this.db)}return this.db}persist(){if(!this.db)return;let e=this.db.export();try{a(this.dbPath,Buffer.from(e))}finally{this.db.exec(`PRAGMA foreign_keys = ON;`)}this.dirty=!1}markDirty(){this.dirty=!0}flushIfDirty(){this.dirty&&this.persist()}query(e,t=[]){let n=this.ensureDb().prepare(e);n.bind(t);let r=[];try{for(;n.step();)r.push(n.getAsObject())}finally{n.free()}return r}run(e,t=[]){this.ensureDb().run(e,t)}async upsertNode(e){this.run(`INSERT INTO nodes (id, type, name, properties, source_record_id, source_path, created_at, community)
|
|
43
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
44
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
45
|
+
type = excluded.type, name = excluded.name, properties = excluded.properties,
|
|
46
|
+
source_record_id = excluded.source_record_id, source_path = excluded.source_path,
|
|
47
|
+
community = excluded.community`,[e.id,e.type,e.name,JSON.stringify(e.properties),e.sourceRecordId??null,e.sourcePath??null,e.createdAt??new Date().toISOString(),e.community??null]),this.markDirty(),this.flushIfDirty()}async upsertEdge(e){this.run(`INSERT INTO edges (id, from_id, to_id, type, weight, confidence, properties)
|
|
48
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
49
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
50
|
+
from_id = excluded.from_id, to_id = excluded.to_id,
|
|
51
|
+
type = excluded.type, weight = excluded.weight, confidence = excluded.confidence, properties = excluded.properties`,[e.id,e.fromId,e.toId,e.type,e.weight??1,e.confidence??1,JSON.stringify(e.properties??{})]),this.markDirty(),this.flushIfDirty()}async upsertNodes(e){if(e.length===0)return;let t=this.ensureDb();t.run(`BEGIN TRANSACTION`);try{for(let t of e)this.run(`INSERT INTO nodes (id, type, name, properties, source_record_id, source_path, created_at, community)
|
|
52
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
53
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
54
|
+
type = excluded.type, name = excluded.name, properties = excluded.properties,
|
|
55
|
+
source_record_id = excluded.source_record_id, source_path = excluded.source_path,
|
|
56
|
+
community = excluded.community`,[t.id,t.type,t.name,JSON.stringify(t.properties),t.sourceRecordId??null,t.sourcePath??null,t.createdAt??new Date().toISOString(),t.community??null]);t.run(`COMMIT`)}catch(e){throw t.run(`ROLLBACK`),e}this.markDirty(),this.flushIfDirty()}async upsertEdges(e){if(e.length===0)return;let t=this.ensureDb();t.run(`PRAGMA foreign_keys = OFF`),t.run(`BEGIN TRANSACTION`);try{for(let t of e)this.run(`INSERT INTO edges (id, from_id, to_id, type, weight, confidence, properties)
|
|
57
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
58
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
59
|
+
from_id = excluded.from_id, to_id = excluded.to_id,
|
|
60
|
+
type = excluded.type, weight = excluded.weight, confidence = excluded.confidence, properties = excluded.properties`,[t.id,t.fromId,t.toId,t.type,t.weight??1,t.confidence??1,JSON.stringify(t.properties??{})]);t.run(`COMMIT`)}catch(e){throw t.run(`ROLLBACK`),e}finally{t.run(`PRAGMA foreign_keys = ON`)}this.markDirty(),this.flushIfDirty()}async getNode(e){let t=this.query(`SELECT * FROM nodes WHERE id = ?`,[e]);return t.length>0?u(t[0]):null}async getNeighbors(e,t){let n=t?.direction??`both`,r=t?.edgeType,i=t?.limit??50,a=[],o=[],s=new Set;if(n===`outgoing`||n===`both`){let t=`
|
|
61
|
+
SELECT e.id AS edge_id, e.from_id, e.to_id, e.type AS edge_type, e.weight,
|
|
62
|
+
e.confidence AS edge_confidence, e.properties AS edge_props,
|
|
63
|
+
n.id AS node_id, n.type AS node_type, n.name AS node_name, n.properties AS node_props,
|
|
64
|
+
n.source_record_id AS node_src_rec, n.source_path AS node_src_path,
|
|
65
|
+
n.created_at AS node_created, n.community AS node_community
|
|
66
|
+
FROM edges e JOIN nodes n ON e.to_id = n.id WHERE e.from_id = ?`,n=[e];r&&(t+=` AND e.type = ?`,n.push(r)),t+=` LIMIT ?`,n.push(i);let c=this.query(t,n);for(let e of c)o.push(f(e)),s.has(e.node_id)||(s.add(e.node_id),a.push(p(e)))}if(n===`incoming`||n===`both`){let t=`
|
|
67
|
+
SELECT e.id AS edge_id, e.from_id, e.to_id, e.type AS edge_type, e.weight,
|
|
68
|
+
e.confidence AS edge_confidence, e.properties AS edge_props,
|
|
69
|
+
n.id AS node_id, n.type AS node_type, n.name AS node_name, n.properties AS node_props,
|
|
70
|
+
n.source_record_id AS node_src_rec, n.source_path AS node_src_path,
|
|
71
|
+
n.created_at AS node_created, n.community AS node_community
|
|
72
|
+
FROM edges e JOIN nodes n ON e.from_id = n.id WHERE e.to_id = ?`,n=[e];r&&(t+=` AND e.type = ?`,n.push(r)),t+=` LIMIT ?`,n.push(i);let c=this.query(t,n);for(let e of c)o.push(f(e)),s.has(e.node_id)||(s.add(e.node_id),a.push(p(e)))}return{nodes:a,edges:o}}async traverse(e,t){let n=t?.maxDepth??2,r=t?.direction??`both`,i=t?.edgeType,a=t?.limit??50,o=new Map,s=new Map,c=new Set,l=[{nodeId:e,depth:0}];for(;l.length>0&&o.size<a;){let e=l.shift();if(!e||c.has(e.nodeId)||e.depth>n)continue;c.add(e.nodeId);let t=await this.getNeighbors(e.nodeId,{direction:r,edgeType:i,limit:a-o.size});for(let r of t.nodes)o.has(r.id)||(o.set(r.id,r),e.depth+1<n&&l.push({nodeId:r.id,depth:e.depth+1}));for(let e of t.edges)s.set(e.id,e)}return{nodes:[...o.values()],edges:[...s.values()]}}async findNodes(e){let t=[],n=[];e.type&&(t.push(`type = ?`),n.push(e.type)),e.namePattern&&(t.push(`name LIKE ?`),n.push(`%${e.namePattern}%`)),e.sourcePath&&(t.push(`source_path = ?`),n.push(e.sourcePath));let r=t.length>0?`WHERE ${t.join(` AND `)}`:``,i=e.limit??100;return this.query(`SELECT * FROM nodes ${r} LIMIT ?`,[...n,i]).map(e=>u(e))}async findEdges(e){let t=[],n=[];e.type&&(t.push(`type = ?`),n.push(e.type)),e.fromId&&(t.push(`from_id = ?`),n.push(e.fromId)),e.toId&&(t.push(`to_id = ?`),n.push(e.toId));let r=t.length>0?`WHERE ${t.join(` AND `)}`:``,i=e.limit??100;return this.query(`SELECT * FROM edges ${r} LIMIT ?`,[...n,i]).map(e=>d(e))}async deleteNode(e){let t=this.ensureDb();t.run(`BEGIN TRANSACTION`);try{this.run(`DELETE FROM edges WHERE from_id = ? OR to_id = ?`,[e,e]),this.run(`DELETE FROM nodes WHERE id = ?`,[e]),t.run(`COMMIT`)}catch(e){throw t.run(`ROLLBACK`),e}this.markDirty(),this.flushIfDirty()}async deleteBySourcePath(e){let t=this.query(`SELECT id FROM nodes WHERE source_path = ?`,[e]);if(t.length===0)return 0;let n=this.ensureDb();n.run(`BEGIN TRANSACTION`);try{for(let e of t)this.run(`DELETE FROM edges WHERE from_id = ? OR to_id = ?`,[e.id,e.id]);this.run(`DELETE FROM nodes WHERE source_path = ?`,[e]),n.run(`COMMIT`)}catch(e){throw n.run(`ROLLBACK`),e}return this.markDirty(),this.flushIfDirty(),t.length}async clear(){this.run(`DELETE FROM process_steps`),this.run(`DELETE FROM processes`),this.run(`DELETE FROM edges`),this.run(`DELETE FROM nodes`),this.markDirty(),this.flushIfDirty()}async getStats(){let e=this.query(`SELECT COUNT(*) as count FROM nodes`)[0]?.count??0,t=this.query(`SELECT COUNT(*) as count FROM edges`)[0]?.count??0,n=this.query(`SELECT type, COUNT(*) as count FROM nodes GROUP BY type`),r={};for(let e of n)r[e.type]=e.count;let i=this.query(`SELECT type, COUNT(*) as count FROM edges GROUP BY type`),a={};for(let e of i)a[e.type]=e.count;return{nodeCount:e,edgeCount:t,nodeTypes:r,edgeTypes:a}}async validate(){let e=await this.getStats(),t=this.query(`SELECT e.id AS edgeId,
|
|
73
|
+
CASE
|
|
74
|
+
WHEN n1.id IS NULL THEN e.from_id
|
|
75
|
+
WHEN n2.id IS NULL THEN e.to_id
|
|
76
|
+
END AS missingNodeId
|
|
77
|
+
FROM edges e
|
|
78
|
+
LEFT JOIN nodes n1 ON e.from_id = n1.id
|
|
79
|
+
LEFT JOIN nodes n2 ON e.to_id = n2.id
|
|
80
|
+
WHERE n1.id IS NULL OR n2.id IS NULL`),n=this.query(`SELECT n.id AS id
|
|
81
|
+
FROM nodes n
|
|
82
|
+
LEFT JOIN edges e1 ON n.id = e1.from_id
|
|
83
|
+
LEFT JOIN edges e2 ON n.id = e2.to_id
|
|
84
|
+
WHERE e1.id IS NULL AND e2.id IS NULL`).map(e=>e.id);return{valid:t.length===0,orphanNodes:n,danglingEdges:t,stats:e}}async setNodeCommunity(e,t){this.run(`UPDATE nodes SET community = ? WHERE id = ?`,[t,e]),this.markDirty(),this.flushIfDirty()}async detectCommunities(){let e=this.query(`SELECT id FROM nodes`),t=new Map;for(let n of e)t.set(n.id,n.id);for(let n=0;n<10;n++){let n=!1,r=new Map(t);for(let i of e){let e=this.query(`SELECT to_id AS neighbor_id FROM edges WHERE from_id = ?
|
|
85
|
+
UNION
|
|
86
|
+
SELECT from_id AS neighbor_id FROM edges WHERE to_id = ?`,[i.id,i.id]),a=new Map,o=t.get(i.id)??i.id;a.set(o,1);for(let n of e){let e=t.get(n.neighbor_id)??n.neighbor_id;a.set(e,(a.get(e)??0)+1)}let s=o,c=0;for(let[e,t]of a)(t>c||t===c&&e<s)&&(c=t,s=e);o!==s&&(r.set(i.id,s),n=!0)}t.clear();for(let[e,n]of r)t.set(e,n);if(!n)break}let n=this.ensureDb();n.run(`BEGIN TRANSACTION`);try{for(let[e,n]of t)this.run(`UPDATE nodes SET community = ? WHERE id = ?`,[n,e]);n.run(`COMMIT`)}catch(e){throw n.run(`ROLLBACK`),e}this.markDirty(),this.flushIfDirty();let r={};for(let[e,n]of t)r[n]||(r[n]=[]),r[n].push(e);return r}async traceProcess(e,t){let n=[],r=new Set,i=[e];for(;i.length>0;){let e=i.shift();if(!e||r.has(e))continue;r.add(e),n.push(e);let t=this.query(`SELECT to_id FROM edges WHERE from_id = ? AND type = 'calls'`,[e]);for(let e of t)r.has(e.to_id)||i.push(e.to_id)}let a=`proc_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,o=new Date().toISOString(),s=this.ensureDb();s.run(`BEGIN TRANSACTION`);try{this.run(`INSERT INTO processes (id, entry_node_id, label, properties, created_at)
|
|
87
|
+
VALUES (?, ?, ?, '{}', ?)`,[a,e,t,o]);for(let e=0;e<n.length;e++)this.run(`INSERT INTO process_steps (process_id, node_id, step_order) VALUES (?, ?, ?)`,[a,n[e],e]);s.run(`COMMIT`)}catch(e){throw s.run(`ROLLBACK`),e}return this.markDirty(),this.flushIfDirty(),{id:a,entryNodeId:e,label:t,properties:{},steps:n,createdAt:o}}async getProcesses(e){let t;t=e?this.query(`SELECT DISTINCT p.id, p.entry_node_id, p.label, p.properties, p.created_at
|
|
88
|
+
FROM processes p
|
|
89
|
+
JOIN process_steps ps ON p.id = ps.process_id
|
|
90
|
+
WHERE ps.node_id = ?`,[e]):this.query(`SELECT * FROM processes`);let n=[];for(let e of t){let t=this.query(`SELECT node_id FROM process_steps WHERE process_id = ? ORDER BY step_order`,[e.id]);n.push({id:e.id,entryNodeId:e.entry_node_id,label:e.label,properties:l(e.properties),steps:t.map(e=>e.node_id),createdAt:e.created_at})}return n}async deleteProcess(e){let t=this.ensureDb();t.run(`BEGIN TRANSACTION`);try{this.run(`DELETE FROM process_steps WHERE process_id = ?`,[e]),this.run(`DELETE FROM processes WHERE id = ?`,[e]),t.run(`COMMIT`)}catch(e){throw t.run(`ROLLBACK`),e}this.markDirty(),this.flushIfDirty()}async depthGroupedTraversal(e,t=3,n){let r=n?.direction??`both`,i=n?.edgeType,a=n?.limit??100,o={},s=new Set;s.add(e);let c=[e];for(let e=1;e<=t;e++){let t=[],n=[];for(let e of c){let o=await this.getNeighbors(e,{direction:r,edgeType:i,limit:a});for(let e of o.nodes)s.has(e.id)||(s.add(e.id),t.push(e.id),n.push(e))}if(n.length>0&&(o[e]=n),c=t,c.length===0||s.size>=a)break}return o}async getCohesionScore(e){let t=this.query(`SELECT id FROM nodes WHERE community = ?`,[e]);if(t.length===0)return 0;let n=new Set(t.map(e=>e.id)),r=t.map(()=>`?`).join(`,`),i=t.map(e=>e.id),a=this.query(`SELECT from_id, to_id FROM edges WHERE from_id IN (${r}) OR to_id IN (${r})`,[...i,...i]);if(a.length===0)return 0;let o=0;for(let e of a)n.has(e.from_id)&&n.has(e.to_id)&&o++;return o/a.length}async getSymbol360(e){let t=await this.getNode(e);if(!t)throw Error(`Node '${e}' not found`);let n=await this.findEdges({toId:e}),r=await this.findEdges({fromId:e}),i=await this.getProcesses(e);return{node:t,incoming:n,outgoing:r,community:t.community??null,processes:i}}async close(){this.db&&=(this.flushIfDirty(),this.db.close(),null)}};function l(e){if(!e)return{};try{return JSON.parse(e)}catch{return{}}}function u(e){return{id:e.id,type:e.type,name:e.name,properties:l(e.properties),sourceRecordId:e.source_record_id??void 0,sourcePath:e.source_path??void 0,createdAt:e.created_at,community:e.community??void 0}}function d(e){return{id:e.id,fromId:e.from_id,toId:e.to_id,type:e.type,weight:e.weight??1,confidence:e.confidence??1,properties:l(e.properties)}}function f(e){return{id:e.edge_id,fromId:e.from_id,toId:e.to_id,type:e.edge_type,weight:e.weight??1,confidence:e.edge_confidence??1,properties:l(e.edge_props??`{}`)}}function p(e){return{id:e.node_id,type:e.node_type,name:e.node_name,properties:l(e.node_props??`{}`),sourceRecordId:e.node_src_rec??void 0,sourcePath:e.node_src_path??void 0,createdAt:e.node_created,community:e.node_community??void 0}}async function m(e){switch(e.backend){case`lancedb`:{let{LanceStore:t}=await import(`./lance-store-jdHZp-V4.js`).then(e=>e.n);return new t({path:e.path})}default:throw Error(`Unknown store backend: "${e.backend}". Supported: lancedb`)}}export{e as LanceStore,c as SqliteGraphStore,m as createStore};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{EMBEDDING_DEFAULTS as e,SEARCH_DEFAULTS as t,STORE_DEFAULTS as n,createLogger as r,serializeError as i,sourceTypeContentTypes as a}from"../../core/dist/index.js";import{Index as o,connect as s}from"@lancedb/lancedb";var c=Object.defineProperty,l=((e,t)=>{let n={};for(var r in e)c(n,r,{get:e[r],enumerable:!0});return t||c(n,Symbol.toStringTag,{value:`Module`}),n})({LanceStore:()=>m});function u(e){if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}const d=/^[\w.\-/ ]+$/,f=r(`store`);function p(e,t){if(!d.test(e))throw Error(`Invalid ${t} filter value: contains disallowed characters`);return e.replace(/'/g,`''`)}var m=class r{db=null;table=null;dbPath;tableName;_draining=!1;_priorityQueue=[];_normalQueue=[];_ftsReady=!1;_ftsRecoveryAttemptAt=0;static FTS_RECOVERY_COOLDOWN_MS=300*1e3;enqueueWrite(e,t=!1){return new Promise((n,r)=>{let i=async()=>{try{n(await e())}catch(e){r(e)}};t?this._priorityQueue.push(i):this._normalQueue.push(i),this._drain()})}async _drain(){if(!this._draining){this._draining=!0;try{for(;this._priorityQueue.length>0||this._normalQueue.length>0;){let e=this._priorityQueue.shift()??this._normalQueue.shift();e&&await e()}}finally{this._draining=!1}}}constructor(e){this.dbPath=e?.path??n.path,this.tableName=e?.tableName??n.tableName}async initialize(){this.db=await s(this.dbPath),(await this.db.tableNames()).includes(this.tableName)&&(this.table=await this.db.openTable(this.tableName),await this.createFtsIndex())}async upsert(e,t){if(e.length!==0){if(e.length!==t.length)throw Error(`Record count (${e.length}) does not match vector count (${t.length})`);return this.enqueueWrite(()=>this._upsertImpl(e,t))}}async upsertInteractive(e,t){if(e.length!==0){if(e.length!==t.length)throw Error(`Record count (${e.length}) does not match vector count (${t.length})`);return this.enqueueWrite(()=>this._upsertImpl(e,t),!0)}}async _upsertImpl(e,t){let n=e.map((e,n)=>({id:e.id,vector:Array.from(t[n]),content:e.content,sourcePath:e.sourcePath,contentType:e.contentType,headingPath:e.headingPath??``,chunkIndex:e.chunkIndex,totalChunks:e.totalChunks,startLine:e.startLine,endLine:e.endLine,fileHash:e.fileHash,indexedAt:e.indexedAt,origin:e.origin,tags:JSON.stringify(e.tags),category:e.category??``,version:e.version}));if(this.table){let t=[...new Set(e.map(e=>e.sourcePath))];for(let e of t)try{await this.table.delete(`sourcePath = '${p(e,`sourcePath`)}'`)}catch{}await this.table.add(n)}else try{this.table=await this.db?.createTable(this.tableName,n)??null}catch(e){if(String(e).includes(`already exists`)&&this.db)this.table=await this.db.openTable(this.tableName),await this.table.add(n);else throw e}}async search(e,n){if(!this.table)return[];let r=n?.limit??t.maxResults,i=n?.minScore??t.minScore,a=this.table.search(e).limit(r*2),o=this.buildFilterString(n);return o&&(a=a.where(o)),(await a.toArray()).map(e=>({record:this.fromLanceRecord(e),score:1-(e._distance??1)})).filter(e=>e.score>=i).slice(0,r)}async createFtsIndex(){return this.enqueueWrite(()=>this._createFtsIndexImpl())}async _createFtsIndexImpl(){if(this.table)try{await this.table.createIndex(`content`,{config:o.fts({withPosition:!0}),replace:!0}),this._ftsReady=!0,this._ftsRecoveryAttemptAt=0,f.info(`FTS index created/updated`,{column:`content`})}catch(e){f.warn(`FTS index creation failed`,i(e))}}async ftsSearch(e,n){if(!this.table)return[];if(!this._ftsReady){let e=Date.now();if(e-this._ftsRecoveryAttemptAt<r.FTS_RECOVERY_COOLDOWN_MS)return[];this._ftsRecoveryAttemptAt=e;try{await this.createFtsIndex()}catch{return[]}if(!this._ftsReady)return[]}let a=n?.limit??t.maxResults;try{let t=this.table.search(e).limit(a*2),r=this.buildFilterString(n);return r&&(t=t.where(r)),(await t.toArray()).map(e=>({record:this.fromLanceRecord(e),score:e._score??e._relevance_score??0}))}catch(e){return(e instanceof Error?e.message:String(e)).includes(`INVERTED index`)?(f.debug(`FTS search skipped — index not yet available`),this._ftsReady=!1):f.warn(`FTS search failed`,i(e)),[]}}async getById(e){if(!this.table)return null;let t=await this.table.query().where(`id = '${p(e,`id`)}'`).limit(1).toArray();return t.length===0?null:this.fromLanceRecord(t[0])}async deleteBySourcePath(e){return this.enqueueWrite(()=>this._deleteBySourcePathImpl(e))}async _deleteBySourcePathImpl(e){if(!this.table)return 0;let t=await this.getBySourcePath(e);return t.length===0?0:(await this.table.delete(`sourcePath = '${p(e,`sourcePath`)}'`),t.length)}async deleteById(e){return this.enqueueWrite(()=>this._deleteByIdImpl(e))}async deleteByIdInteractive(e){return this.enqueueWrite(()=>this._deleteByIdImpl(e),!0)}async _deleteByIdImpl(e){return!this.table||!await this.getById(e)?!1:(await this.table.delete(`id = '${p(e,`id`)}'`),!0)}async getBySourcePath(e){return this.table?(await this.table.query().where(`sourcePath = '${p(e,`sourcePath`)}'`).limit(1e3).toArray()).map(e=>this.fromLanceRecord(e)):[]}async getStats(){if(!this.table)return{totalRecords:0,totalFiles:0,contentTypeBreakdown:{},lastIndexedAt:null,storeBackend:`lancedb`,embeddingModel:e.model};let t=await this.table.countRows(),n=await this.table.query().select([`sourcePath`,`contentType`,`indexedAt`]).limit(1e5).toArray(),r={},i=new Set,a=null;for(let e of n){let t=e;r[t.contentType]=(r[t.contentType]??0)+1,i.add(t.sourcePath),(!a||t.indexedAt>a)&&(a=t.indexedAt)}return{totalRecords:t,totalFiles:i.size,contentTypeBreakdown:r,lastIndexedAt:a,storeBackend:`lancedb`,embeddingModel:e.model}}async listSourcePaths(){if(!this.table)return[];let e=await this.table.query().select([`sourcePath`]).limit(1e5).toArray();return[...new Set(e.map(e=>e.sourcePath))]}async dropTable(){return this.enqueueWrite(()=>this._dropTableImpl())}async _dropTableImpl(){if(this.db&&(await this.db.tableNames()).includes(this.tableName))for(let e=1;e<=3;e++)try{await this.db.dropTable(this.tableName);break}catch(t){if(e===3)throw t;let n=e*500;f.warn(`dropTable attempt failed, retrying`,{attempt:e,delayMs:n}),await new Promise(e=>setTimeout(e,n))}this.table=null}async close(){try{this.db&&typeof this.db.close==`function`&&await this.db.close()}catch{}this.table=null,this.db=null}buildFilterString(e){let t=[];if(e?.contentType&&t.push(`contentType = '${p(e.contentType,`contentType`)}'`),e?.sourceType){let n=a(e.sourceType);if(n.length>0){let e=n.map(e=>`'${p(e,`sourceType`)}'`).join(`, `);t.push(`contentType IN (${e})`)}}if(e?.origin&&t.push(`origin = '${p(e.origin,`origin`)}'`),e?.category&&t.push(`category = '${p(e.category,`category`)}'`),e?.tags&&e.tags.length>0){let n=e.tags.map(e=>`tags LIKE '%${p(e,`tag`)}%'`);t.push(`(${n.join(` OR `)})`)}return t.length>0?t.join(` AND `):null}fromLanceRecord(e){return{id:e.id,content:e.content,sourcePath:e.sourcePath,contentType:e.contentType,headingPath:e.headingPath||void 0,chunkIndex:e.chunkIndex,totalChunks:e.totalChunks,startLine:e.startLine,endLine:e.endLine,fileHash:e.fileHash,indexedAt:e.indexedAt,origin:e.origin,tags:u(e.tags),category:e.category||void 0,version:e.version}}};export{l as n,m as t};
|