@mcp-graph-workflow/mcp-graph 3.0.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/LICENSE +21 -0
- package/README.md +157 -0
- package/dist/api/middleware/error-handler.d.ts +3 -0
- package/dist/api/middleware/error-handler.d.ts.map +1 -0
- package/dist/api/middleware/error-handler.js +48 -0
- package/dist/api/middleware/error-handler.js.map +1 -0
- package/dist/api/middleware/request-logger.d.ts +6 -0
- package/dist/api/middleware/request-logger.d.ts.map +1 -0
- package/dist/api/middleware/request-logger.js +19 -0
- package/dist/api/middleware/request-logger.js.map +1 -0
- package/dist/api/middleware/validate.d.ts +5 -0
- package/dist/api/middleware/validate.d.ts.map +1 -0
- package/dist/api/middleware/validate.js +23 -0
- package/dist/api/middleware/validate.js.map +1 -0
- package/dist/api/router.d.ts +11 -0
- package/dist/api/router.d.ts.map +1 -0
- package/dist/api/router.js +51 -0
- package/dist/api/router.js.map +1 -0
- package/dist/api/routes/benchmark.d.ts +4 -0
- package/dist/api/routes/benchmark.d.ts.map +1 -0
- package/dist/api/routes/benchmark.js +86 -0
- package/dist/api/routes/benchmark.js.map +1 -0
- package/dist/api/routes/capture.d.ts +3 -0
- package/dist/api/routes/capture.d.ts.map +1 -0
- package/dist/api/routes/capture.js +31 -0
- package/dist/api/routes/capture.js.map +1 -0
- package/dist/api/routes/context.d.ts +4 -0
- package/dist/api/routes/context.d.ts.map +1 -0
- package/dist/api/routes/context.js +25 -0
- package/dist/api/routes/context.js.map +1 -0
- package/dist/api/routes/docs-cache.d.ts +4 -0
- package/dist/api/routes/docs-cache.d.ts.map +1 -0
- package/dist/api/routes/docs-cache.js +79 -0
- package/dist/api/routes/docs-cache.js.map +1 -0
- package/dist/api/routes/edges.d.ts +4 -0
- package/dist/api/routes/edges.d.ts.map +1 -0
- package/dist/api/routes/edges.js +50 -0
- package/dist/api/routes/edges.js.map +1 -0
- package/dist/api/routes/events.d.ts +4 -0
- package/dist/api/routes/events.d.ts.map +1 -0
- package/dist/api/routes/events.js +37 -0
- package/dist/api/routes/events.js.map +1 -0
- package/dist/api/routes/gitnexus.d.ts +12 -0
- package/dist/api/routes/gitnexus.d.ts.map +1 -0
- package/dist/api/routes/gitnexus.js +162 -0
- package/dist/api/routes/gitnexus.js.map +1 -0
- package/dist/api/routes/graph.d.ts +4 -0
- package/dist/api/routes/graph.d.ts.map +1 -0
- package/dist/api/routes/graph.js +39 -0
- package/dist/api/routes/graph.js.map +1 -0
- package/dist/api/routes/import.d.ts +4 -0
- package/dist/api/routes/import.d.ts.map +1 -0
- package/dist/api/routes/import.js +92 -0
- package/dist/api/routes/import.js.map +1 -0
- package/dist/api/routes/insights.d.ts +4 -0
- package/dist/api/routes/insights.d.ts.map +1 -0
- package/dist/api/routes/insights.js +40 -0
- package/dist/api/routes/insights.js.map +1 -0
- package/dist/api/routes/integrations.d.ts +4 -0
- package/dist/api/routes/integrations.d.ts.map +1 -0
- package/dist/api/routes/integrations.js +85 -0
- package/dist/api/routes/integrations.js.map +1 -0
- package/dist/api/routes/knowledge.d.ts +8 -0
- package/dist/api/routes/knowledge.d.ts.map +1 -0
- package/dist/api/routes/knowledge.js +144 -0
- package/dist/api/routes/knowledge.js.map +1 -0
- package/dist/api/routes/nodes.d.ts +4 -0
- package/dist/api/routes/nodes.d.ts.map +1 -0
- package/dist/api/routes/nodes.js +123 -0
- package/dist/api/routes/nodes.js.map +1 -0
- package/dist/api/routes/project.d.ts +4 -0
- package/dist/api/routes/project.d.ts.map +1 -0
- package/dist/api/routes/project.js +70 -0
- package/dist/api/routes/project.js.map +1 -0
- package/dist/api/routes/rag.d.ts +8 -0
- package/dist/api/routes/rag.d.ts.map +1 -0
- package/dist/api/routes/rag.js +70 -0
- package/dist/api/routes/rag.js.map +1 -0
- package/dist/api/routes/search.d.ts +4 -0
- package/dist/api/routes/search.d.ts.map +1 -0
- package/dist/api/routes/search.js +25 -0
- package/dist/api/routes/search.js.map +1 -0
- package/dist/api/routes/skills.d.ts +3 -0
- package/dist/api/routes/skills.d.ts.map +1 -0
- package/dist/api/routes/skills.js +16 -0
- package/dist/api/routes/skills.js.map +1 -0
- package/dist/api/routes/stats.d.ts +4 -0
- package/dist/api/routes/stats.d.ts.map +1 -0
- package/dist/api/routes/stats.js +14 -0
- package/dist/api/routes/stats.js.map +1 -0
- package/dist/cli/commands/import-cmd.d.ts +3 -0
- package/dist/cli/commands/import-cmd.d.ts.map +1 -0
- package/dist/cli/commands/import-cmd.js +38 -0
- package/dist/cli/commands/import-cmd.js.map +1 -0
- package/dist/cli/commands/index-cmd.d.ts +3 -0
- package/dist/cli/commands/index-cmd.d.ts.map +1 -0
- package/dist/cli/commands/index-cmd.js +50 -0
- package/dist/cli/commands/index-cmd.js.map +1 -0
- package/dist/cli/commands/init.d.ts +3 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +24 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/serve.d.ts +3 -0
- package/dist/cli/commands/serve.d.ts.map +1 -0
- package/dist/cli/commands/serve.js +18 -0
- package/dist/cli/commands/serve.js.map +1 -0
- package/dist/cli/commands/stats.d.ts +3 -0
- package/dist/cli/commands/stats.d.ts.map +1 -0
- package/dist/cli/commands/stats.js +39 -0
- package/dist/cli/commands/stats.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +30 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/capture/content-extractor.d.ts +21 -0
- package/dist/core/capture/content-extractor.d.ts.map +1 -0
- package/dist/core/capture/content-extractor.js +74 -0
- package/dist/core/capture/content-extractor.js.map +1 -0
- package/dist/core/capture/validate-runner.d.ts +28 -0
- package/dist/core/capture/validate-runner.d.ts.map +1 -0
- package/dist/core/capture/validate-runner.js +42 -0
- package/dist/core/capture/validate-runner.js.map +1 -0
- package/dist/core/capture/web-capture.d.ts +20 -0
- package/dist/core/capture/web-capture.d.ts.map +1 -0
- package/dist/core/capture/web-capture.js +51 -0
- package/dist/core/capture/web-capture.js.map +1 -0
- package/dist/core/config/ai-memory-generator.d.ts +14 -0
- package/dist/core/config/ai-memory-generator.d.ts.map +1 -0
- package/dist/core/config/ai-memory-generator.js +130 -0
- package/dist/core/config/ai-memory-generator.js.map +1 -0
- package/dist/core/config/config-loader.d.ts +3 -0
- package/dist/core/config/config-loader.d.ts.map +1 -0
- package/dist/core/config/config-loader.js +48 -0
- package/dist/core/config/config-loader.js.map +1 -0
- package/dist/core/config/config-schema.d.ts +12 -0
- package/dist/core/config/config-schema.d.ts.map +1 -0
- package/dist/core/config/config-schema.js +13 -0
- package/dist/core/config/config-schema.js.map +1 -0
- package/dist/core/context/bm25-compressor.d.ts +21 -0
- package/dist/core/context/bm25-compressor.d.ts.map +1 -0
- package/dist/core/context/bm25-compressor.js +87 -0
- package/dist/core/context/bm25-compressor.js.map +1 -0
- package/dist/core/context/compact-context.d.ts +56 -0
- package/dist/core/context/compact-context.d.ts.map +1 -0
- package/dist/core/context/compact-context.js +170 -0
- package/dist/core/context/compact-context.js.map +1 -0
- package/dist/core/context/context-assembler.d.ts +43 -0
- package/dist/core/context/context-assembler.d.ts.map +1 -0
- package/dist/core/context/context-assembler.js +113 -0
- package/dist/core/context/context-assembler.js.map +1 -0
- package/dist/core/context/rag-context.d.ts +44 -0
- package/dist/core/context/rag-context.d.ts.map +1 -0
- package/dist/core/context/rag-context.js +93 -0
- package/dist/core/context/rag-context.js.map +1 -0
- package/dist/core/context/tiered-context.d.ts +35 -0
- package/dist/core/context/tiered-context.d.ts.map +1 -0
- package/dist/core/context/tiered-context.js +92 -0
- package/dist/core/context/tiered-context.js.map +1 -0
- package/dist/core/context/token-estimator.d.ts +7 -0
- package/dist/core/context/token-estimator.d.ts.map +1 -0
- package/dist/core/context/token-estimator.js +9 -0
- package/dist/core/context/token-estimator.js.map +1 -0
- package/dist/core/docs/docs-cache-store.d.ts +24 -0
- package/dist/core/docs/docs-cache-store.d.ts.map +1 -0
- package/dist/core/docs/docs-cache-store.js +61 -0
- package/dist/core/docs/docs-cache-store.js.map +1 -0
- package/dist/core/docs/docs-syncer.d.ts +13 -0
- package/dist/core/docs/docs-syncer.d.ts.map +1 -0
- package/dist/core/docs/docs-syncer.js +38 -0
- package/dist/core/docs/docs-syncer.js.map +1 -0
- package/dist/core/docs/mcp-context7-fetcher.d.ts +17 -0
- package/dist/core/docs/mcp-context7-fetcher.d.ts.map +1 -0
- package/dist/core/docs/mcp-context7-fetcher.js +87 -0
- package/dist/core/docs/mcp-context7-fetcher.js.map +1 -0
- package/dist/core/docs/stack-detector.d.ts +21 -0
- package/dist/core/docs/stack-detector.d.ts.map +1 -0
- package/dist/core/docs/stack-detector.js +101 -0
- package/dist/core/docs/stack-detector.js.map +1 -0
- package/dist/core/events/event-bus.d.ts +26 -0
- package/dist/core/events/event-bus.d.ts.map +1 -0
- package/dist/core/events/event-bus.js +47 -0
- package/dist/core/events/event-bus.js.map +1 -0
- package/dist/core/events/event-types.d.ts +71 -0
- package/dist/core/events/event-types.d.ts.map +1 -0
- package/dist/core/events/event-types.js +2 -0
- package/dist/core/events/event-types.js.map +1 -0
- package/dist/core/graph/graph-indexes.d.ts +3 -0
- package/dist/core/graph/graph-indexes.d.ts.map +1 -0
- package/dist/core/graph/graph-indexes.js +28 -0
- package/dist/core/graph/graph-indexes.js.map +1 -0
- package/dist/core/graph/graph-types.d.ts +72 -0
- package/dist/core/graph/graph-types.d.ts.map +1 -0
- package/dist/core/graph/graph-types.js +2 -0
- package/dist/core/graph/graph-types.js.map +1 -0
- package/dist/core/graph/mermaid-export.d.ts +9 -0
- package/dist/core/graph/mermaid-export.d.ts.map +1 -0
- package/dist/core/graph/mermaid-export.js +80 -0
- package/dist/core/graph/mermaid-export.js.map +1 -0
- package/dist/core/importer/import-prd.d.ts +7 -0
- package/dist/core/importer/import-prd.d.ts.map +1 -0
- package/dist/core/importer/import-prd.js +7 -0
- package/dist/core/importer/import-prd.js.map +1 -0
- package/dist/core/importer/prd-to-graph.d.ts +18 -0
- package/dist/core/importer/prd-to-graph.d.ts.map +1 -0
- package/dist/core/importer/prd-to-graph.js +195 -0
- package/dist/core/importer/prd-to-graph.js.map +1 -0
- package/dist/core/insights/bottleneck-detector.d.ts +31 -0
- package/dist/core/insights/bottleneck-detector.d.ts.map +1 -0
- package/dist/core/insights/bottleneck-detector.js +84 -0
- package/dist/core/insights/bottleneck-detector.js.map +1 -0
- package/dist/core/insights/metrics-calculator.d.ts +31 -0
- package/dist/core/insights/metrics-calculator.d.ts.map +1 -0
- package/dist/core/insights/metrics-calculator.js +78 -0
- package/dist/core/insights/metrics-calculator.js.map +1 -0
- package/dist/core/insights/skill-recommender.d.ts +21 -0
- package/dist/core/insights/skill-recommender.d.ts.map +1 -0
- package/dist/core/insights/skill-recommender.js +129 -0
- package/dist/core/insights/skill-recommender.js.map +1 -0
- package/dist/core/integrations/enriched-context.d.ts +24 -0
- package/dist/core/integrations/enriched-context.d.ts.map +1 -0
- package/dist/core/integrations/enriched-context.js +89 -0
- package/dist/core/integrations/enriched-context.js.map +1 -0
- package/dist/core/integrations/gitnexus-launcher.d.ts +62 -0
- package/dist/core/integrations/gitnexus-launcher.d.ts.map +1 -0
- package/dist/core/integrations/gitnexus-launcher.js +241 -0
- package/dist/core/integrations/gitnexus-launcher.js.map +1 -0
- package/dist/core/integrations/gitnexus-queries.d.ts +55 -0
- package/dist/core/integrations/gitnexus-queries.d.ts.map +1 -0
- package/dist/core/integrations/gitnexus-queries.js +168 -0
- package/dist/core/integrations/gitnexus-queries.js.map +1 -0
- package/dist/core/integrations/integration-orchestrator.d.ts +51 -0
- package/dist/core/integrations/integration-orchestrator.d.ts.map +1 -0
- package/dist/core/integrations/integration-orchestrator.js +118 -0
- package/dist/core/integrations/integration-orchestrator.js.map +1 -0
- package/dist/core/integrations/mcp-deps-installer.d.ts +21 -0
- package/dist/core/integrations/mcp-deps-installer.d.ts.map +1 -0
- package/dist/core/integrations/mcp-deps-installer.js +114 -0
- package/dist/core/integrations/mcp-deps-installer.js.map +1 -0
- package/dist/core/integrations/mcp-servers-config.d.ts +21 -0
- package/dist/core/integrations/mcp-servers-config.d.ts.map +1 -0
- package/dist/core/integrations/mcp-servers-config.js +58 -0
- package/dist/core/integrations/mcp-servers-config.js.map +1 -0
- package/dist/core/integrations/serena-reader.d.ts +18 -0
- package/dist/core/integrations/serena-reader.d.ts.map +1 -0
- package/dist/core/integrations/serena-reader.js +68 -0
- package/dist/core/integrations/serena-reader.js.map +1 -0
- package/dist/core/integrations/tool-status.d.ts +18 -0
- package/dist/core/integrations/tool-status.d.ts.map +1 -0
- package/dist/core/integrations/tool-status.js +97 -0
- package/dist/core/integrations/tool-status.js.map +1 -0
- package/dist/core/parser/classify.d.ts +31 -0
- package/dist/core/parser/classify.d.ts.map +1 -0
- package/dist/core/parser/classify.js +128 -0
- package/dist/core/parser/classify.js.map +1 -0
- package/dist/core/parser/extract.d.ts +21 -0
- package/dist/core/parser/extract.d.ts.map +1 -0
- package/dist/core/parser/extract.js +66 -0
- package/dist/core/parser/extract.js.map +1 -0
- package/dist/core/parser/file-reader.d.ts +13 -0
- package/dist/core/parser/file-reader.d.ts.map +1 -0
- package/dist/core/parser/file-reader.js +52 -0
- package/dist/core/parser/file-reader.js.map +1 -0
- package/dist/core/parser/normalize.d.ts +9 -0
- package/dist/core/parser/normalize.d.ts.map +1 -0
- package/dist/core/parser/normalize.js +22 -0
- package/dist/core/parser/normalize.js.map +1 -0
- package/dist/core/parser/read-file.d.ts +7 -0
- package/dist/core/parser/read-file.d.ts.map +1 -0
- package/dist/core/parser/read-file.js +17 -0
- package/dist/core/parser/read-file.js.map +1 -0
- package/dist/core/parser/read-html.d.ts +7 -0
- package/dist/core/parser/read-html.d.ts.map +1 -0
- package/dist/core/parser/read-html.js +51 -0
- package/dist/core/parser/read-html.js.map +1 -0
- package/dist/core/parser/read-pdf.d.ts +10 -0
- package/dist/core/parser/read-pdf.d.ts.map +1 -0
- package/dist/core/parser/read-pdf.js +16 -0
- package/dist/core/parser/read-pdf.js.map +1 -0
- package/dist/core/parser/segment.d.ts +13 -0
- package/dist/core/parser/segment.d.ts.map +1 -0
- package/dist/core/parser/segment.js +53 -0
- package/dist/core/parser/segment.js.map +1 -0
- package/dist/core/planner/decompose.d.ts +25 -0
- package/dist/core/planner/decompose.d.ts.map +1 -0
- package/dist/core/planner/decompose.js +100 -0
- package/dist/core/planner/decompose.js.map +1 -0
- package/dist/core/planner/dependency-chain.d.ts +20 -0
- package/dist/core/planner/dependency-chain.d.ts.map +1 -0
- package/dist/core/planner/dependency-chain.js +163 -0
- package/dist/core/planner/dependency-chain.js.map +1 -0
- package/dist/core/planner/enhanced-next.d.ts +25 -0
- package/dist/core/planner/enhanced-next.d.ts.map +1 -0
- package/dist/core/planner/enhanced-next.js +88 -0
- package/dist/core/planner/enhanced-next.js.map +1 -0
- package/dist/core/planner/lifecycle-phase.d.ts +21 -0
- package/dist/core/planner/lifecycle-phase.d.ts.map +1 -0
- package/dist/core/planner/lifecycle-phase.js +93 -0
- package/dist/core/planner/lifecycle-phase.js.map +1 -0
- package/dist/core/planner/next-task.d.ts +16 -0
- package/dist/core/planner/next-task.d.ts.map +1 -0
- package/dist/core/planner/next-task.js +146 -0
- package/dist/core/planner/next-task.js.map +1 -0
- package/dist/core/planner/planning-report.d.ts +38 -0
- package/dist/core/planner/planning-report.d.ts.map +1 -0
- package/dist/core/planner/planning-report.js +140 -0
- package/dist/core/planner/planning-report.js.map +1 -0
- package/dist/core/planner/velocity.d.ts +38 -0
- package/dist/core/planner/velocity.d.ts.map +1 -0
- package/dist/core/planner/velocity.js +92 -0
- package/dist/core/planner/velocity.js.map +1 -0
- package/dist/core/rag/capture-indexer.d.ts +16 -0
- package/dist/core/rag/capture-indexer.d.ts.map +1 -0
- package/dist/core/rag/capture-indexer.js +37 -0
- package/dist/core/rag/capture-indexer.js.map +1 -0
- package/dist/core/rag/chunk-text.d.ts +27 -0
- package/dist/core/rag/chunk-text.d.ts.map +1 -0
- package/dist/core/rag/chunk-text.js +112 -0
- package/dist/core/rag/chunk-text.js.map +1 -0
- package/dist/core/rag/docs-indexer.d.ts +18 -0
- package/dist/core/rag/docs-indexer.d.ts.map +1 -0
- package/dist/core/rag/docs-indexer.js +57 -0
- package/dist/core/rag/docs-indexer.js.map +1 -0
- package/dist/core/rag/embedding-store.d.ts +51 -0
- package/dist/core/rag/embedding-store.d.ts.map +1 -0
- package/dist/core/rag/embedding-store.js +134 -0
- package/dist/core/rag/embedding-store.js.map +1 -0
- package/dist/core/rag/rag-pipeline.d.ts +48 -0
- package/dist/core/rag/rag-pipeline.d.ts.map +1 -0
- package/dist/core/rag/rag-pipeline.js +276 -0
- package/dist/core/rag/rag-pipeline.js.map +1 -0
- package/dist/core/rag/serena-indexer.d.ts +16 -0
- package/dist/core/rag/serena-indexer.d.ts.map +1 -0
- package/dist/core/rag/serena-indexer.js +50 -0
- package/dist/core/rag/serena-indexer.js.map +1 -0
- package/dist/core/rag/serena-rag-query.d.ts +34 -0
- package/dist/core/rag/serena-rag-query.d.ts.map +1 -0
- package/dist/core/rag/serena-rag-query.js +83 -0
- package/dist/core/rag/serena-rag-query.js.map +1 -0
- package/dist/core/search/fts-search.d.ts +16 -0
- package/dist/core/search/fts-search.d.ts.map +1 -0
- package/dist/core/search/fts-search.js +62 -0
- package/dist/core/search/fts-search.js.map +1 -0
- package/dist/core/search/tfidf.d.ts +32 -0
- package/dist/core/search/tfidf.d.ts.map +1 -0
- package/dist/core/search/tfidf.js +67 -0
- package/dist/core/search/tfidf.js.map +1 -0
- package/dist/core/search/tokenizer.d.ts +9 -0
- package/dist/core/search/tokenizer.d.ts.map +1 -0
- package/dist/core/search/tokenizer.js +37 -0
- package/dist/core/search/tokenizer.js.map +1 -0
- package/dist/core/store/knowledge-store.d.ts +72 -0
- package/dist/core/store/knowledge-store.d.ts.map +1 -0
- package/dist/core/store/knowledge-store.js +166 -0
- package/dist/core/store/knowledge-store.js.map +1 -0
- package/dist/core/store/migrations.d.ts +4 -0
- package/dist/core/store/migrations.d.ts.map +1 -0
- package/dist/core/store/migrations.js +223 -0
- package/dist/core/store/migrations.js.map +1 -0
- package/dist/core/store/sqlite-store.d.ts +86 -0
- package/dist/core/store/sqlite-store.d.ts.map +1 -0
- package/dist/core/store/sqlite-store.js +707 -0
- package/dist/core/store/sqlite-store.js.map +1 -0
- package/dist/core/utils/constants.d.ts +10 -0
- package/dist/core/utils/constants.d.ts.map +1 -0
- package/dist/core/utils/constants.js +10 -0
- package/dist/core/utils/constants.js.map +1 -0
- package/dist/core/utils/errors.d.ts +20 -0
- package/dist/core/utils/errors.d.ts.map +1 -0
- package/dist/core/utils/errors.js +39 -0
- package/dist/core/utils/errors.js.map +1 -0
- package/dist/core/utils/fs.d.ts +2 -0
- package/dist/core/utils/fs.d.ts.map +1 -0
- package/dist/core/utils/fs.js +11 -0
- package/dist/core/utils/fs.js.map +1 -0
- package/dist/core/utils/id.d.ts +2 -0
- package/dist/core/utils/id.d.ts.map +1 -0
- package/dist/core/utils/id.js +6 -0
- package/dist/core/utils/id.js.map +1 -0
- package/dist/core/utils/logger.d.ts +8 -0
- package/dist/core/utils/logger.d.ts.map +1 -0
- package/dist/core/utils/logger.js +28 -0
- package/dist/core/utils/logger.js.map +1 -0
- package/dist/core/utils/platform.d.ts +18 -0
- package/dist/core/utils/platform.d.ts.map +1 -0
- package/dist/core/utils/platform.js +43 -0
- package/dist/core/utils/platform.js.map +1 -0
- package/dist/core/utils/time.d.ts +2 -0
- package/dist/core/utils/time.d.ts.map +1 -0
- package/dist/core/utils/time.js +4 -0
- package/dist/core/utils/time.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/init-project.d.ts +2 -0
- package/dist/mcp/init-project.d.ts.map +1 -0
- package/dist/mcp/init-project.js +144 -0
- package/dist/mcp/init-project.js.map +1 -0
- package/dist/mcp/lifecycle-wrapper.d.ts +26 -0
- package/dist/mcp/lifecycle-wrapper.d.ts.map +1 -0
- package/dist/mcp/lifecycle-wrapper.js +67 -0
- package/dist/mcp/lifecycle-wrapper.js.map +1 -0
- package/dist/mcp/server.d.ts +3 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +73 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/stdio.d.ts +3 -0
- package/dist/mcp/stdio.d.ts.map +1 -0
- package/dist/mcp/stdio.js +20 -0
- package/dist/mcp/stdio.js.map +1 -0
- package/dist/mcp/tools/add-node.d.ts +4 -0
- package/dist/mcp/tools/add-node.d.ts.map +1 -0
- package/dist/mcp/tools/add-node.js +83 -0
- package/dist/mcp/tools/add-node.js.map +1 -0
- package/dist/mcp/tools/bulk-update-status.d.ts +4 -0
- package/dist/mcp/tools/bulk-update-status.d.ts.map +1 -0
- package/dist/mcp/tools/bulk-update-status.js +22 -0
- package/dist/mcp/tools/bulk-update-status.js.map +1 -0
- package/dist/mcp/tools/clone-node.d.ts +4 -0
- package/dist/mcp/tools/clone-node.d.ts.map +1 -0
- package/dist/mcp/tools/clone-node.js +111 -0
- package/dist/mcp/tools/clone-node.js.map +1 -0
- package/dist/mcp/tools/context.d.ts +4 -0
- package/dist/mcp/tools/context.d.ts.map +1 -0
- package/dist/mcp/tools/context.js +30 -0
- package/dist/mcp/tools/context.js.map +1 -0
- package/dist/mcp/tools/decompose.d.ts +4 -0
- package/dist/mcp/tools/decompose.d.ts.map +1 -0
- package/dist/mcp/tools/decompose.js +25 -0
- package/dist/mcp/tools/decompose.js.map +1 -0
- package/dist/mcp/tools/delete-node.d.ts +4 -0
- package/dist/mcp/tools/delete-node.d.ts.map +1 -0
- package/dist/mcp/tools/delete-node.js +29 -0
- package/dist/mcp/tools/delete-node.js.map +1 -0
- package/dist/mcp/tools/dependencies.d.ts +4 -0
- package/dist/mcp/tools/dependencies.d.ts.map +1 -0
- package/dist/mcp/tools/dependencies.js +47 -0
- package/dist/mcp/tools/dependencies.js.map +1 -0
- package/dist/mcp/tools/edge.d.ts +4 -0
- package/dist/mcp/tools/edge.d.ts.map +1 -0
- package/dist/mcp/tools/edge.js +140 -0
- package/dist/mcp/tools/edge.js.map +1 -0
- package/dist/mcp/tools/export.d.ts +4 -0
- package/dist/mcp/tools/export.d.ts.map +1 -0
- package/dist/mcp/tools/export.js +38 -0
- package/dist/mcp/tools/export.js.map +1 -0
- package/dist/mcp/tools/import-prd.d.ts +4 -0
- package/dist/mcp/tools/import-prd.d.ts.map +1 -0
- package/dist/mcp/tools/import-prd.js +81 -0
- package/dist/mcp/tools/import-prd.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +4 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +58 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/init.d.ts +4 -0
- package/dist/mcp/tools/init.d.ts.map +1 -0
- package/dist/mcp/tools/init.js +18 -0
- package/dist/mcp/tools/init.js.map +1 -0
- package/dist/mcp/tools/list.d.ts +4 -0
- package/dist/mcp/tools/list.d.ts.map +1 -0
- package/dist/mcp/tools/list.js +56 -0
- package/dist/mcp/tools/list.js.map +1 -0
- package/dist/mcp/tools/move-node.d.ts +4 -0
- package/dist/mcp/tools/move-node.d.ts.map +1 -0
- package/dist/mcp/tools/move-node.js +110 -0
- package/dist/mcp/tools/move-node.js.map +1 -0
- package/dist/mcp/tools/next.d.ts +4 -0
- package/dist/mcp/tools/next.d.ts.map +1 -0
- package/dist/mcp/tools/next.js +32 -0
- package/dist/mcp/tools/next.js.map +1 -0
- package/dist/mcp/tools/plan-sprint.d.ts +4 -0
- package/dist/mcp/tools/plan-sprint.d.ts.map +1 -0
- package/dist/mcp/tools/plan-sprint.js +54 -0
- package/dist/mcp/tools/plan-sprint.js.map +1 -0
- package/dist/mcp/tools/rag-context.d.ts +4 -0
- package/dist/mcp/tools/rag-context.d.ts.map +1 -0
- package/dist/mcp/tools/rag-context.js +51 -0
- package/dist/mcp/tools/rag-context.js.map +1 -0
- package/dist/mcp/tools/reindex-knowledge.d.ts +4 -0
- package/dist/mcp/tools/reindex-knowledge.d.ts.map +1 -0
- package/dist/mcp/tools/reindex-knowledge.js +49 -0
- package/dist/mcp/tools/reindex-knowledge.js.map +1 -0
- package/dist/mcp/tools/search.d.ts +4 -0
- package/dist/mcp/tools/search.d.ts.map +1 -0
- package/dist/mcp/tools/search.js +41 -0
- package/dist/mcp/tools/search.js.map +1 -0
- package/dist/mcp/tools/show.d.ts +4 -0
- package/dist/mcp/tools/show.d.ts.map +1 -0
- package/dist/mcp/tools/show.js +42 -0
- package/dist/mcp/tools/show.js.map +1 -0
- package/dist/mcp/tools/snapshot.d.ts +4 -0
- package/dist/mcp/tools/snapshot.d.ts.map +1 -0
- package/dist/mcp/tools/snapshot.js +45 -0
- package/dist/mcp/tools/snapshot.js.map +1 -0
- package/dist/mcp/tools/stats.d.ts +4 -0
- package/dist/mcp/tools/stats.d.ts.map +1 -0
- package/dist/mcp/tools/stats.js +46 -0
- package/dist/mcp/tools/stats.js.map +1 -0
- package/dist/mcp/tools/sync-stack-docs.d.ts +4 -0
- package/dist/mcp/tools/sync-stack-docs.d.ts.map +1 -0
- package/dist/mcp/tools/sync-stack-docs.js +77 -0
- package/dist/mcp/tools/sync-stack-docs.js.map +1 -0
- package/dist/mcp/tools/update-node.d.ts +4 -0
- package/dist/mcp/tools/update-node.d.ts.map +1 -0
- package/dist/mcp/tools/update-node.js +45 -0
- package/dist/mcp/tools/update-node.js.map +1 -0
- package/dist/mcp/tools/update-status.d.ts +4 -0
- package/dist/mcp/tools/update-status.d.ts.map +1 -0
- package/dist/mcp/tools/update-status.js +33 -0
- package/dist/mcp/tools/update-status.js.map +1 -0
- package/dist/mcp/tools/validate-task.d.ts +4 -0
- package/dist/mcp/tools/validate-task.d.ts.map +1 -0
- package/dist/mcp/tools/validate-task.js +57 -0
- package/dist/mcp/tools/validate-task.js.map +1 -0
- package/dist/mcp/tools/velocity.d.ts +4 -0
- package/dist/mcp/tools/velocity.d.ts.map +1 -0
- package/dist/mcp/tools/velocity.js +25 -0
- package/dist/mcp/tools/velocity.js.map +1 -0
- package/dist/schemas/edge.schema.d.ts +31 -0
- package/dist/schemas/edge.schema.d.ts.map +1 -0
- package/dist/schemas/edge.schema.js +16 -0
- package/dist/schemas/edge.schema.js.map +1 -0
- package/dist/schemas/graph.schema.d.ts +102 -0
- package/dist/schemas/graph.schema.d.ts.map +1 -0
- package/dist/schemas/graph.schema.js +28 -0
- package/dist/schemas/graph.schema.js.map +1 -0
- package/dist/schemas/knowledge.schema.d.ts +29 -0
- package/dist/schemas/knowledge.schema.d.ts.map +1 -0
- package/dist/schemas/knowledge.schema.js +17 -0
- package/dist/schemas/knowledge.schema.js.map +1 -0
- package/dist/schemas/node.schema.d.ts +80 -0
- package/dist/schemas/node.schema.d.ts.map +1 -0
- package/dist/schemas/node.schema.js +38 -0
- package/dist/schemas/node.schema.js.map +1 -0
- package/dist/web/dashboard/dist/assets/benchmark-tab-BTKW3REK.js +1 -0
- package/dist/web/dashboard/dist/assets/benchmark-tab-BhbUvjLM.js +1 -0
- package/dist/web/dashboard/dist/assets/benchmark-tab-CESZcCtO.js +1 -0
- package/dist/web/dashboard/dist/assets/benchmark-tab-D64Ala80.js +1 -0
- package/dist/web/dashboard/dist/assets/benchmark-tab-DJ7HyF-u.js +1 -0
- package/dist/web/dashboard/dist/assets/benchmark-tab-DVyzQZ2d.js +1 -0
- package/dist/web/dashboard/dist/assets/benchmark-tab-XUH7yQNv.js +1 -0
- package/dist/web/dashboard/dist/assets/benchmark-tab-ZfJu1pxc.js +1 -0
- package/dist/web/dashboard/dist/assets/constants-BIEJOBya.js +1 -0
- package/dist/web/dashboard/dist/assets/gitnexus-tab-BFHEXsJm.js +312 -0
- package/dist/web/dashboard/dist/assets/gitnexus-tab-Bbp91fom.js +312 -0
- package/dist/web/dashboard/dist/assets/gitnexus-tab-C3fPSzYi.js +312 -0
- package/dist/web/dashboard/dist/assets/gitnexus-tab-Cd0k8qk3.js +312 -0
- package/dist/web/dashboard/dist/assets/gitnexus-tab-ClNGphK5.js +312 -0
- package/dist/web/dashboard/dist/assets/gitnexus-tab-Cuc-KSII.js +312 -0
- package/dist/web/dashboard/dist/assets/gitnexus-tab-DEqMBSbC.css +1 -0
- package/dist/web/dashboard/dist/assets/gitnexus-tab-DEwJXSnD.js +312 -0
- package/dist/web/dashboard/dist/assets/gitnexus-tab-DOD7xwmm.js +312 -0
- package/dist/web/dashboard/dist/assets/graph-tab-AD7csRcc.js +1 -0
- package/dist/web/dashboard/dist/assets/graph-tab-BKyDCyHH.js +1 -0
- package/dist/web/dashboard/dist/assets/graph-tab-BUAkTto0.js +1 -0
- package/dist/web/dashboard/dist/assets/graph-tab-D0F0WJES.js +1 -0
- package/dist/web/dashboard/dist/assets/graph-tab-DA16nThT.js +1 -0
- package/dist/web/dashboard/dist/assets/graph-tab-DJknUhrl.js +1 -0
- package/dist/web/dashboard/dist/assets/graph-tab-DRPfelKw.js +1 -0
- package/dist/web/dashboard/dist/assets/graph-tab-lJ2rPS4Z.js +1 -0
- package/dist/web/dashboard/dist/assets/graph-utils-BN7tt0ZS.js +23 -0
- package/dist/web/dashboard/dist/assets/graph-utils-BTV1KGUM.js +23 -0
- package/dist/web/dashboard/dist/assets/graph-utils-BZV40eAE.css +1 -0
- package/dist/web/dashboard/dist/assets/graph-utils-BkfAOVJ9.js +23 -0
- package/dist/web/dashboard/dist/assets/graph-utils-Bo7cD1sx.js +23 -0
- package/dist/web/dashboard/dist/assets/graph-utils-CI4znRl5.js +23 -0
- package/dist/web/dashboard/dist/assets/graph-utils-DrCx5m7q.js +23 -0
- package/dist/web/dashboard/dist/assets/graph-utils-KQmzMFXM.js +23 -0
- package/dist/web/dashboard/dist/assets/graph-utils-M7iOhRI-.js +23 -0
- package/dist/web/dashboard/dist/assets/index-BGMP3W6f.css +1 -0
- package/dist/web/dashboard/dist/assets/index-BVXu3x9W.js +53 -0
- package/dist/web/dashboard/dist/assets/index-B_T9j86O.js +53 -0
- package/dist/web/dashboard/dist/assets/index-Bga9WW2A.css +1 -0
- package/dist/web/dashboard/dist/assets/index-BnLPCC8R.css +1 -0
- package/dist/web/dashboard/dist/assets/index-BonF71I0.js +53 -0
- package/dist/web/dashboard/dist/assets/index-CSyjxREL.js +53 -0
- package/dist/web/dashboard/dist/assets/index-CbUKe2Fv.js +53 -0
- package/dist/web/dashboard/dist/assets/index-D9i2aVjo.js +53 -0
- package/dist/web/dashboard/dist/assets/index-DzM6oBA3.js +53 -0
- package/dist/web/dashboard/dist/assets/index-IK005MzD.js +53 -0
- package/dist/web/dashboard/dist/assets/insights-tab-B9R3HsMU.js +1 -0
- package/dist/web/dashboard/dist/assets/insights-tab-BO_cxLyV.js +1 -0
- package/dist/web/dashboard/dist/assets/insights-tab-Brn6IMfQ.js +1 -0
- package/dist/web/dashboard/dist/assets/insights-tab-C6x-aJ8p.js +1 -0
- package/dist/web/dashboard/dist/assets/insights-tab-CWUU6eDi.js +1 -0
- package/dist/web/dashboard/dist/assets/insights-tab-CapL1jP-.js +1 -0
- package/dist/web/dashboard/dist/assets/insights-tab-CeWM6zgV.js +1 -0
- package/dist/web/dashboard/dist/assets/insights-tab-xQj5e61M.js +1 -0
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-0oOO63rA.js +1 -0
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-BcWoplsM.js +1 -0
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-Bjj5KccG.js +1 -0
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-C7cKQyup.js +1 -0
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-CT4ja7Ay.js +1 -0
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-CmPHHBDQ.js +1 -0
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-DAHBiRO-.js +1 -0
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-_jmBe3MU.js +1 -0
- package/dist/web/dashboard/dist/assets/serena-tab-BVyBTaHC.js +1 -0
- package/dist/web/dashboard/dist/assets/serena-tab-CVI1GGRk.js +1 -0
- package/dist/web/dashboard/dist/assets/serena-tab-D1ki2NjT.js +1 -0
- package/dist/web/dashboard/dist/assets/serena-tab-DRrRfjpO.js +1 -0
- package/dist/web/dashboard/dist/assets/serena-tab-DvYbwR4Z.js +1 -0
- package/dist/web/dashboard/dist/assets/serena-tab-DwiZ6Jm3.js +1 -0
- package/dist/web/dashboard/dist/assets/serena-tab-L6isY0iT.js +1 -0
- package/dist/web/dashboard/dist/assets/serena-tab-ba2n0AOh.js +1 -0
- package/dist/web/dashboard/dist/index.html +13 -0
- package/package.json +86 -0
|
@@ -0,0 +1,707 @@
|
|
|
1
|
+
import Database from "better-sqlite3";
|
|
2
|
+
import { mkdirSync, existsSync, renameSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { buildIndexes } from "../graph/graph-indexes.js";
|
|
5
|
+
import { generateId } from "../utils/id.js";
|
|
6
|
+
import { now } from "../utils/time.js";
|
|
7
|
+
import { configureDb, runMigrations } from "./migrations.js";
|
|
8
|
+
import { logger } from "../utils/logger.js";
|
|
9
|
+
import { GraphNotInitializedError, ValidationError, SnapshotNotFoundError } from "../utils/errors.js";
|
|
10
|
+
import { GraphNodeSchema } from "../../schemas/node.schema.js";
|
|
11
|
+
import { GraphEdgeSchema } from "../../schemas/edge.schema.js";
|
|
12
|
+
import { z } from "zod/v4";
|
|
13
|
+
import { STORE_DIR, LEGACY_STORE_DIR, DB_FILE } from "../utils/constants.js";
|
|
14
|
+
// ── Mapping helpers ──────────────────────────────────────
|
|
15
|
+
function nodeToRow(node, projectId) {
|
|
16
|
+
return {
|
|
17
|
+
id: node.id,
|
|
18
|
+
project_id: projectId,
|
|
19
|
+
type: node.type,
|
|
20
|
+
title: node.title,
|
|
21
|
+
description: node.description ?? null,
|
|
22
|
+
status: node.status,
|
|
23
|
+
priority: node.priority,
|
|
24
|
+
xp_size: node.xpSize ?? null,
|
|
25
|
+
estimate_minutes: node.estimateMinutes ?? null,
|
|
26
|
+
tags: node.tags ? JSON.stringify(node.tags) : null,
|
|
27
|
+
parent_id: node.parentId ?? null,
|
|
28
|
+
sprint: node.sprint ?? null,
|
|
29
|
+
source_file: node.sourceRef?.file ?? null,
|
|
30
|
+
source_start_line: node.sourceRef?.startLine ?? null,
|
|
31
|
+
source_end_line: node.sourceRef?.endLine ?? null,
|
|
32
|
+
source_confidence: node.sourceRef?.confidence ?? null,
|
|
33
|
+
acceptance_criteria: node.acceptanceCriteria
|
|
34
|
+
? JSON.stringify(node.acceptanceCriteria)
|
|
35
|
+
: null,
|
|
36
|
+
blocked: node.blocked ? 1 : 0,
|
|
37
|
+
metadata: node.metadata ? JSON.stringify(node.metadata) : null,
|
|
38
|
+
created_at: node.createdAt,
|
|
39
|
+
updated_at: node.updatedAt,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function rowToNode(row) {
|
|
43
|
+
const node = {
|
|
44
|
+
id: row.id,
|
|
45
|
+
type: row.type,
|
|
46
|
+
title: row.title,
|
|
47
|
+
status: row.status,
|
|
48
|
+
priority: row.priority,
|
|
49
|
+
blocked: row.blocked === 1,
|
|
50
|
+
createdAt: row.created_at,
|
|
51
|
+
updatedAt: row.updated_at,
|
|
52
|
+
};
|
|
53
|
+
if (row.description)
|
|
54
|
+
node.description = row.description;
|
|
55
|
+
if (row.xp_size)
|
|
56
|
+
node.xpSize = row.xp_size;
|
|
57
|
+
if (row.estimate_minutes != null)
|
|
58
|
+
node.estimateMinutes = row.estimate_minutes;
|
|
59
|
+
if (row.tags)
|
|
60
|
+
node.tags = JSON.parse(row.tags);
|
|
61
|
+
if (row.parent_id)
|
|
62
|
+
node.parentId = row.parent_id;
|
|
63
|
+
if (row.sprint)
|
|
64
|
+
node.sprint = row.sprint;
|
|
65
|
+
if (row.acceptance_criteria)
|
|
66
|
+
node.acceptanceCriteria = JSON.parse(row.acceptance_criteria);
|
|
67
|
+
if (row.metadata)
|
|
68
|
+
node.metadata = JSON.parse(row.metadata);
|
|
69
|
+
if (row.source_file) {
|
|
70
|
+
const ref = { file: row.source_file };
|
|
71
|
+
if (row.source_start_line != null)
|
|
72
|
+
ref.startLine = row.source_start_line;
|
|
73
|
+
if (row.source_end_line != null)
|
|
74
|
+
ref.endLine = row.source_end_line;
|
|
75
|
+
if (row.source_confidence != null)
|
|
76
|
+
ref.confidence = row.source_confidence;
|
|
77
|
+
node.sourceRef = ref;
|
|
78
|
+
}
|
|
79
|
+
return node;
|
|
80
|
+
}
|
|
81
|
+
function edgeToRow(edge, projectId) {
|
|
82
|
+
return {
|
|
83
|
+
id: edge.id,
|
|
84
|
+
project_id: projectId,
|
|
85
|
+
from_node: edge.from,
|
|
86
|
+
to_node: edge.to,
|
|
87
|
+
relation_type: edge.relationType,
|
|
88
|
+
weight: edge.weight ?? null,
|
|
89
|
+
reason: edge.reason ?? null,
|
|
90
|
+
metadata: edge.metadata ? JSON.stringify(edge.metadata) : null,
|
|
91
|
+
created_at: edge.createdAt,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function rowToEdge(row) {
|
|
95
|
+
const edge = {
|
|
96
|
+
id: row.id,
|
|
97
|
+
from: row.from_node,
|
|
98
|
+
to: row.to_node,
|
|
99
|
+
relationType: row.relation_type,
|
|
100
|
+
createdAt: row.created_at,
|
|
101
|
+
};
|
|
102
|
+
if (row.weight != null)
|
|
103
|
+
edge.weight = row.weight;
|
|
104
|
+
if (row.reason)
|
|
105
|
+
edge.reason = row.reason;
|
|
106
|
+
if (row.metadata)
|
|
107
|
+
edge.metadata = JSON.parse(row.metadata);
|
|
108
|
+
return edge;
|
|
109
|
+
}
|
|
110
|
+
// ── SqliteStore ──────────────────────────────────────────
|
|
111
|
+
export class SqliteStore {
|
|
112
|
+
db;
|
|
113
|
+
projectId = null;
|
|
114
|
+
_eventBus = null;
|
|
115
|
+
constructor(db) {
|
|
116
|
+
this.db = db;
|
|
117
|
+
}
|
|
118
|
+
/** Attach an event bus to emit mutation events */
|
|
119
|
+
set eventBus(bus) {
|
|
120
|
+
this._eventBus = bus;
|
|
121
|
+
}
|
|
122
|
+
get eventBus() {
|
|
123
|
+
return this._eventBus;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Open (or create) a store at basePath/workflow-graph/graph.db.
|
|
127
|
+
* Pass ":memory:" for in-memory testing.
|
|
128
|
+
*
|
|
129
|
+
* Handles automatic migration from legacy `.mcp-graph/` directory:
|
|
130
|
+
* - If only `.mcp-graph/` exists → rename to `workflow-graph/`
|
|
131
|
+
* - If both exist → use `workflow-graph/`, log warning
|
|
132
|
+
* - If neither → create `workflow-graph/`
|
|
133
|
+
*/
|
|
134
|
+
static open(basePath = process.cwd()) {
|
|
135
|
+
let db;
|
|
136
|
+
if (basePath === ":memory:") {
|
|
137
|
+
db = new Database(":memory:");
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
const newDir = path.join(basePath, STORE_DIR);
|
|
141
|
+
const legacyDir = path.join(basePath, LEGACY_STORE_DIR);
|
|
142
|
+
const legacyExists = existsSync(legacyDir);
|
|
143
|
+
const newExists = existsSync(newDir);
|
|
144
|
+
if (legacyExists && !newExists) {
|
|
145
|
+
renameSync(legacyDir, newDir);
|
|
146
|
+
logger.info("Migrated store directory", { from: LEGACY_STORE_DIR, to: STORE_DIR });
|
|
147
|
+
}
|
|
148
|
+
else if (legacyExists && newExists) {
|
|
149
|
+
logger.warn("Both legacy and new store directories exist, using new", {
|
|
150
|
+
legacy: LEGACY_STORE_DIR,
|
|
151
|
+
active: STORE_DIR,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
mkdirSync(newDir, { recursive: true });
|
|
155
|
+
db = new Database(path.join(newDir, DB_FILE));
|
|
156
|
+
}
|
|
157
|
+
configureDb(db);
|
|
158
|
+
runMigrations(db);
|
|
159
|
+
const store = new SqliteStore(db);
|
|
160
|
+
// Auto-load project if one exists
|
|
161
|
+
const row = db
|
|
162
|
+
.prepare("SELECT id FROM projects LIMIT 1")
|
|
163
|
+
.get();
|
|
164
|
+
if (row)
|
|
165
|
+
store.projectId = row.id;
|
|
166
|
+
logger.info(`Store opened${basePath === ":memory:" ? " (in-memory)" : ` at ${basePath}`}`);
|
|
167
|
+
return store;
|
|
168
|
+
}
|
|
169
|
+
/** Expose the raw database instance for extension modules (e.g. DocsCacheStore). */
|
|
170
|
+
getDb() {
|
|
171
|
+
return this.db;
|
|
172
|
+
}
|
|
173
|
+
close() {
|
|
174
|
+
this.db.close();
|
|
175
|
+
}
|
|
176
|
+
// ── Project ──────────────────────────────────────
|
|
177
|
+
initProject(name) {
|
|
178
|
+
// If no name provided and project already active, return current
|
|
179
|
+
if (this.projectId && !name) {
|
|
180
|
+
return this.getProject();
|
|
181
|
+
}
|
|
182
|
+
// If name provided, check if same as current project
|
|
183
|
+
if (this.projectId && name) {
|
|
184
|
+
const current = this.getProject();
|
|
185
|
+
if (current.name === name) {
|
|
186
|
+
return current;
|
|
187
|
+
}
|
|
188
|
+
// Check if a project with this name already exists
|
|
189
|
+
const existing = this.db
|
|
190
|
+
.prepare("SELECT * FROM projects WHERE name = ?")
|
|
191
|
+
.get(name);
|
|
192
|
+
if (existing) {
|
|
193
|
+
this.projectId = existing.id;
|
|
194
|
+
logger.info("Project activated by name", { name, projectId: existing.id });
|
|
195
|
+
return {
|
|
196
|
+
id: existing.id,
|
|
197
|
+
name: existing.name,
|
|
198
|
+
createdAt: existing.created_at,
|
|
199
|
+
updatedAt: existing.updated_at,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
// No active project, or different name — create new
|
|
204
|
+
const projectName = name || "Local MCP Graph";
|
|
205
|
+
const id = generateId("proj");
|
|
206
|
+
const timestamp = now();
|
|
207
|
+
this.db
|
|
208
|
+
.prepare("INSERT INTO projects (id, name, created_at, updated_at) VALUES (?, ?, ?, ?)")
|
|
209
|
+
.run(id, projectName, timestamp, timestamp);
|
|
210
|
+
this.projectId = id;
|
|
211
|
+
logger.info(`Project initialized: ${projectName} (${id})`);
|
|
212
|
+
return { id, name: projectName, createdAt: timestamp, updatedAt: timestamp };
|
|
213
|
+
}
|
|
214
|
+
getProject() {
|
|
215
|
+
if (!this.projectId)
|
|
216
|
+
return null;
|
|
217
|
+
const row = this.db
|
|
218
|
+
.prepare("SELECT * FROM projects WHERE id = ?")
|
|
219
|
+
.get(this.projectId);
|
|
220
|
+
if (!row)
|
|
221
|
+
return null;
|
|
222
|
+
return {
|
|
223
|
+
id: row.id,
|
|
224
|
+
name: row.name,
|
|
225
|
+
createdAt: row.created_at,
|
|
226
|
+
updatedAt: row.updated_at,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
/** Alias for getProject — returns the currently active project. */
|
|
230
|
+
getActiveProject() {
|
|
231
|
+
return this.getProject();
|
|
232
|
+
}
|
|
233
|
+
/** List all projects in the database. */
|
|
234
|
+
listProjects() {
|
|
235
|
+
const rows = this.db
|
|
236
|
+
.prepare("SELECT * FROM projects ORDER BY created_at")
|
|
237
|
+
.all();
|
|
238
|
+
return rows.map((row) => ({
|
|
239
|
+
id: row.id,
|
|
240
|
+
name: row.name,
|
|
241
|
+
createdAt: row.created_at,
|
|
242
|
+
updatedAt: row.updated_at,
|
|
243
|
+
}));
|
|
244
|
+
}
|
|
245
|
+
/** Switch the active project. Throws if project ID does not exist. */
|
|
246
|
+
activateProject(projectId) {
|
|
247
|
+
const row = this.db
|
|
248
|
+
.prepare("SELECT id FROM projects WHERE id = ?")
|
|
249
|
+
.get(projectId);
|
|
250
|
+
if (!row) {
|
|
251
|
+
throw new ValidationError(`Project not found: ${projectId}`, []);
|
|
252
|
+
}
|
|
253
|
+
this.projectId = projectId;
|
|
254
|
+
logger.info("Project activated", { projectId });
|
|
255
|
+
}
|
|
256
|
+
ensureProject() {
|
|
257
|
+
if (!this.projectId) {
|
|
258
|
+
throw new GraphNotInitializedError();
|
|
259
|
+
}
|
|
260
|
+
return this.projectId;
|
|
261
|
+
}
|
|
262
|
+
// ── Nodes ────────────────────────────────────────
|
|
263
|
+
insertNode(node) {
|
|
264
|
+
try {
|
|
265
|
+
GraphNodeSchema.parse(node);
|
|
266
|
+
}
|
|
267
|
+
catch (err) {
|
|
268
|
+
if (err instanceof z.ZodError) {
|
|
269
|
+
throw new ValidationError("Invalid node", err.issues);
|
|
270
|
+
}
|
|
271
|
+
throw err;
|
|
272
|
+
}
|
|
273
|
+
const pid = this.ensureProject();
|
|
274
|
+
const row = nodeToRow(node, pid);
|
|
275
|
+
this.db
|
|
276
|
+
.prepare(`INSERT INTO nodes
|
|
277
|
+
(id, project_id, type, title, description, status, priority,
|
|
278
|
+
xp_size, estimate_minutes, tags, parent_id, sprint,
|
|
279
|
+
source_file, source_start_line, source_end_line, source_confidence,
|
|
280
|
+
acceptance_criteria, blocked, metadata, created_at, updated_at)
|
|
281
|
+
VALUES
|
|
282
|
+
(@id, @project_id, @type, @title, @description, @status, @priority,
|
|
283
|
+
@xp_size, @estimate_minutes, @tags, @parent_id, @sprint,
|
|
284
|
+
@source_file, @source_start_line, @source_end_line, @source_confidence,
|
|
285
|
+
@acceptance_criteria, @blocked, @metadata, @created_at, @updated_at)`)
|
|
286
|
+
.run(row);
|
|
287
|
+
this._eventBus?.emitTyped("node:created", { nodeId: node.id, title: node.title, nodeType: node.type });
|
|
288
|
+
}
|
|
289
|
+
getNodeById(id) {
|
|
290
|
+
this.ensureProject();
|
|
291
|
+
const row = this.db
|
|
292
|
+
.prepare("SELECT * FROM nodes WHERE id = ? AND project_id = ?")
|
|
293
|
+
.get(id, this.projectId);
|
|
294
|
+
return row ? rowToNode(row) : null;
|
|
295
|
+
}
|
|
296
|
+
getAllNodes() {
|
|
297
|
+
const pid = this.ensureProject();
|
|
298
|
+
const rows = this.db
|
|
299
|
+
.prepare("SELECT * FROM nodes WHERE project_id = ? ORDER BY created_at")
|
|
300
|
+
.all(pid);
|
|
301
|
+
return rows.map(rowToNode);
|
|
302
|
+
}
|
|
303
|
+
getNodesByType(type) {
|
|
304
|
+
const pid = this.ensureProject();
|
|
305
|
+
const rows = this.db
|
|
306
|
+
.prepare("SELECT * FROM nodes WHERE project_id = ? AND type = ? ORDER BY created_at")
|
|
307
|
+
.all(pid, type);
|
|
308
|
+
return rows.map(rowToNode);
|
|
309
|
+
}
|
|
310
|
+
getNodesByStatus(status) {
|
|
311
|
+
const pid = this.ensureProject();
|
|
312
|
+
const rows = this.db
|
|
313
|
+
.prepare("SELECT * FROM nodes WHERE project_id = ? AND status = ? ORDER BY created_at")
|
|
314
|
+
.all(pid, status);
|
|
315
|
+
return rows.map(rowToNode);
|
|
316
|
+
}
|
|
317
|
+
getChildNodes(parentId) {
|
|
318
|
+
const pid = this.ensureProject();
|
|
319
|
+
const rows = this.db
|
|
320
|
+
.prepare("SELECT * FROM nodes WHERE project_id = ? AND parent_id = ? ORDER BY created_at")
|
|
321
|
+
.all(pid, parentId);
|
|
322
|
+
return rows.map(rowToNode);
|
|
323
|
+
}
|
|
324
|
+
updateNodeStatus(id, status) {
|
|
325
|
+
const pid = this.ensureProject();
|
|
326
|
+
const timestamp = now();
|
|
327
|
+
const result = this.db
|
|
328
|
+
.prepare("UPDATE nodes SET status = ?, updated_at = ? WHERE id = ? AND project_id = ?")
|
|
329
|
+
.run(status, timestamp, id, pid);
|
|
330
|
+
if (result.changes === 0)
|
|
331
|
+
return null;
|
|
332
|
+
this._eventBus?.emitTyped("node:updated", { nodeId: id, fields: ["status"] });
|
|
333
|
+
return this.getNodeById(id);
|
|
334
|
+
}
|
|
335
|
+
updateNode(id, fields) {
|
|
336
|
+
const pid = this.ensureProject();
|
|
337
|
+
const existing = this.getNodeById(id);
|
|
338
|
+
if (!existing)
|
|
339
|
+
return null;
|
|
340
|
+
const setClauses = [];
|
|
341
|
+
const params = [];
|
|
342
|
+
if (fields.title !== undefined) {
|
|
343
|
+
setClauses.push("title = ?");
|
|
344
|
+
params.push(fields.title);
|
|
345
|
+
}
|
|
346
|
+
if (fields.description !== undefined) {
|
|
347
|
+
setClauses.push("description = ?");
|
|
348
|
+
params.push(fields.description ?? null);
|
|
349
|
+
}
|
|
350
|
+
if (fields.type !== undefined) {
|
|
351
|
+
setClauses.push("type = ?");
|
|
352
|
+
params.push(fields.type);
|
|
353
|
+
}
|
|
354
|
+
if (fields.priority !== undefined) {
|
|
355
|
+
setClauses.push("priority = ?");
|
|
356
|
+
params.push(fields.priority);
|
|
357
|
+
}
|
|
358
|
+
if (fields.xpSize !== undefined) {
|
|
359
|
+
setClauses.push("xp_size = ?");
|
|
360
|
+
params.push(fields.xpSize ?? null);
|
|
361
|
+
}
|
|
362
|
+
if (fields.estimateMinutes !== undefined) {
|
|
363
|
+
setClauses.push("estimate_minutes = ?");
|
|
364
|
+
params.push(fields.estimateMinutes ?? null);
|
|
365
|
+
}
|
|
366
|
+
if (fields.tags !== undefined) {
|
|
367
|
+
setClauses.push("tags = ?");
|
|
368
|
+
params.push(fields.tags ? JSON.stringify(fields.tags) : null);
|
|
369
|
+
}
|
|
370
|
+
if (fields.parentId !== undefined) {
|
|
371
|
+
setClauses.push("parent_id = ?");
|
|
372
|
+
params.push(fields.parentId ?? null);
|
|
373
|
+
}
|
|
374
|
+
if (fields.sprint !== undefined) {
|
|
375
|
+
setClauses.push("sprint = ?");
|
|
376
|
+
params.push(fields.sprint ?? null);
|
|
377
|
+
}
|
|
378
|
+
if (fields.blocked !== undefined) {
|
|
379
|
+
setClauses.push("blocked = ?");
|
|
380
|
+
params.push(fields.blocked ? 1 : 0);
|
|
381
|
+
}
|
|
382
|
+
if (fields.acceptanceCriteria !== undefined) {
|
|
383
|
+
setClauses.push("acceptance_criteria = ?");
|
|
384
|
+
params.push(fields.acceptanceCriteria
|
|
385
|
+
? JSON.stringify(fields.acceptanceCriteria)
|
|
386
|
+
: null);
|
|
387
|
+
}
|
|
388
|
+
if (fields.metadata !== undefined) {
|
|
389
|
+
setClauses.push("metadata = ?");
|
|
390
|
+
params.push(fields.metadata ? JSON.stringify(fields.metadata) : null);
|
|
391
|
+
}
|
|
392
|
+
if (setClauses.length === 0)
|
|
393
|
+
return existing;
|
|
394
|
+
const timestamp = now();
|
|
395
|
+
setClauses.push("updated_at = ?");
|
|
396
|
+
params.push(timestamp);
|
|
397
|
+
params.push(id, pid);
|
|
398
|
+
this.db
|
|
399
|
+
.prepare(`UPDATE nodes SET ${setClauses.join(", ")} WHERE id = ? AND project_id = ?`)
|
|
400
|
+
.run(...params);
|
|
401
|
+
this._eventBus?.emitTyped("node:updated", { nodeId: id, fields: Object.keys(fields) });
|
|
402
|
+
return this.getNodeById(id);
|
|
403
|
+
}
|
|
404
|
+
deleteNode(id) {
|
|
405
|
+
const pid = this.ensureProject();
|
|
406
|
+
logger.debug("tx:delete-node", { id });
|
|
407
|
+
return this.db.transaction(() => {
|
|
408
|
+
// Delete edges referencing this node
|
|
409
|
+
this.db
|
|
410
|
+
.prepare("DELETE FROM edges WHERE project_id = ? AND (from_node = ? OR to_node = ?)")
|
|
411
|
+
.run(pid, id, id);
|
|
412
|
+
const result = this.db
|
|
413
|
+
.prepare("DELETE FROM nodes WHERE id = ? AND project_id = ?")
|
|
414
|
+
.run(id, pid);
|
|
415
|
+
const deleted = result.changes > 0;
|
|
416
|
+
if (deleted)
|
|
417
|
+
this._eventBus?.emitTyped("node:deleted", { nodeId: id });
|
|
418
|
+
return deleted;
|
|
419
|
+
})();
|
|
420
|
+
}
|
|
421
|
+
deleteEdge(id) {
|
|
422
|
+
const pid = this.ensureProject();
|
|
423
|
+
const result = this.db
|
|
424
|
+
.prepare("DELETE FROM edges WHERE id = ? AND project_id = ?")
|
|
425
|
+
.run(id, pid);
|
|
426
|
+
const deleted = result.changes > 0;
|
|
427
|
+
if (deleted)
|
|
428
|
+
this._eventBus?.emitTyped("edge:deleted", { edgeId: id });
|
|
429
|
+
return deleted;
|
|
430
|
+
}
|
|
431
|
+
// ── Edges ────────────────────────────────────────
|
|
432
|
+
insertEdge(edge) {
|
|
433
|
+
try {
|
|
434
|
+
GraphEdgeSchema.parse(edge);
|
|
435
|
+
}
|
|
436
|
+
catch (err) {
|
|
437
|
+
if (err instanceof z.ZodError) {
|
|
438
|
+
throw new ValidationError("Invalid edge", err.issues);
|
|
439
|
+
}
|
|
440
|
+
throw err;
|
|
441
|
+
}
|
|
442
|
+
const pid = this.ensureProject();
|
|
443
|
+
const row = edgeToRow(edge, pid);
|
|
444
|
+
this.db
|
|
445
|
+
.prepare(`INSERT INTO edges
|
|
446
|
+
(id, project_id, from_node, to_node, relation_type, weight, reason, metadata, created_at)
|
|
447
|
+
VALUES
|
|
448
|
+
(@id, @project_id, @from_node, @to_node, @relation_type, @weight, @reason, @metadata, @created_at)`)
|
|
449
|
+
.run(row);
|
|
450
|
+
this._eventBus?.emitTyped("edge:created", { edgeId: edge.id, from: edge.from, to: edge.to, relationType: edge.relationType });
|
|
451
|
+
}
|
|
452
|
+
getEdgesFrom(nodeId) {
|
|
453
|
+
const pid = this.ensureProject();
|
|
454
|
+
const rows = this.db
|
|
455
|
+
.prepare("SELECT * FROM edges WHERE project_id = ? AND from_node = ?")
|
|
456
|
+
.all(pid, nodeId);
|
|
457
|
+
return rows.map(rowToEdge);
|
|
458
|
+
}
|
|
459
|
+
getEdgesTo(nodeId) {
|
|
460
|
+
const pid = this.ensureProject();
|
|
461
|
+
const rows = this.db
|
|
462
|
+
.prepare("SELECT * FROM edges WHERE project_id = ? AND to_node = ?")
|
|
463
|
+
.all(pid, nodeId);
|
|
464
|
+
return rows.map(rowToEdge);
|
|
465
|
+
}
|
|
466
|
+
getAllEdges() {
|
|
467
|
+
const pid = this.ensureProject();
|
|
468
|
+
const rows = this.db
|
|
469
|
+
.prepare("SELECT * FROM edges WHERE project_id = ? ORDER BY created_at")
|
|
470
|
+
.all(pid);
|
|
471
|
+
return rows.map(rowToEdge);
|
|
472
|
+
}
|
|
473
|
+
// ── Import cleanup ─────────────────────────────────
|
|
474
|
+
/**
|
|
475
|
+
* Check if a source file has been previously imported.
|
|
476
|
+
*/
|
|
477
|
+
hasImport(sourceFile) {
|
|
478
|
+
const pid = this.ensureProject();
|
|
479
|
+
const row = this.db
|
|
480
|
+
.prepare("SELECT 1 FROM import_history WHERE project_id = ? AND source_file = ? LIMIT 1")
|
|
481
|
+
.get(pid, sourceFile);
|
|
482
|
+
return row !== undefined;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Delete all nodes (and their edges) that were imported from a specific source file.
|
|
486
|
+
* Also removes the import history entry so re-import is clean.
|
|
487
|
+
*/
|
|
488
|
+
clearImportedNodes(sourceFile) {
|
|
489
|
+
const pid = this.ensureProject();
|
|
490
|
+
logger.debug("tx:clear-imported", { sourceFile });
|
|
491
|
+
return this.db.transaction(() => {
|
|
492
|
+
// Find node IDs from this source file
|
|
493
|
+
const nodeIds = this.db
|
|
494
|
+
.prepare("SELECT id FROM nodes WHERE project_id = ? AND source_file = ?")
|
|
495
|
+
.all(pid, sourceFile);
|
|
496
|
+
let edgesDeleted = 0;
|
|
497
|
+
for (const { id } of nodeIds) {
|
|
498
|
+
const result = this.db
|
|
499
|
+
.prepare("DELETE FROM edges WHERE project_id = ? AND (from_node = ? OR to_node = ?)")
|
|
500
|
+
.run(pid, id, id);
|
|
501
|
+
edgesDeleted += result.changes;
|
|
502
|
+
}
|
|
503
|
+
const nodesResult = this.db
|
|
504
|
+
.prepare("DELETE FROM nodes WHERE project_id = ? AND source_file = ?")
|
|
505
|
+
.run(pid, sourceFile);
|
|
506
|
+
// Clear import history for this source file
|
|
507
|
+
this.db
|
|
508
|
+
.prepare("DELETE FROM import_history WHERE project_id = ? AND source_file = ?")
|
|
509
|
+
.run(pid, sourceFile);
|
|
510
|
+
const result = { nodesDeleted: nodesResult.changes, edgesDeleted };
|
|
511
|
+
this._eventBus?.emitTyped("bulk:updated", { count: result.nodesDeleted + result.edgesDeleted, operation: "clearImportedNodes" });
|
|
512
|
+
return result;
|
|
513
|
+
})();
|
|
514
|
+
}
|
|
515
|
+
// ── Bulk ─────────────────────────────────────────
|
|
516
|
+
bulkInsert(nodes, edges) {
|
|
517
|
+
const pid = this.ensureProject();
|
|
518
|
+
logger.info(`Bulk insert: ${nodes.length} nodes, ${edges.length} edges`);
|
|
519
|
+
logger.debug("tx:bulk-insert:start");
|
|
520
|
+
this.db.transaction(() => {
|
|
521
|
+
for (const node of nodes) {
|
|
522
|
+
const row = nodeToRow(node, pid);
|
|
523
|
+
this.db
|
|
524
|
+
.prepare(`INSERT INTO nodes
|
|
525
|
+
(id, project_id, type, title, description, status, priority,
|
|
526
|
+
xp_size, estimate_minutes, tags, parent_id, sprint,
|
|
527
|
+
source_file, source_start_line, source_end_line, source_confidence,
|
|
528
|
+
acceptance_criteria, blocked, metadata, created_at, updated_at)
|
|
529
|
+
VALUES
|
|
530
|
+
(@id, @project_id, @type, @title, @description, @status, @priority,
|
|
531
|
+
@xp_size, @estimate_minutes, @tags, @parent_id, @sprint,
|
|
532
|
+
@source_file, @source_start_line, @source_end_line, @source_confidence,
|
|
533
|
+
@acceptance_criteria, @blocked, @metadata, @created_at, @updated_at)`)
|
|
534
|
+
.run(row);
|
|
535
|
+
}
|
|
536
|
+
for (const edge of edges) {
|
|
537
|
+
const row = edgeToRow(edge, pid);
|
|
538
|
+
this.db
|
|
539
|
+
.prepare(`INSERT INTO edges
|
|
540
|
+
(id, project_id, from_node, to_node, relation_type, weight, reason, metadata, created_at)
|
|
541
|
+
VALUES
|
|
542
|
+
(@id, @project_id, @from_node, @to_node, @relation_type, @weight, @reason, @metadata, @created_at)`)
|
|
543
|
+
.run(row);
|
|
544
|
+
}
|
|
545
|
+
})();
|
|
546
|
+
logger.debug("tx:bulk-insert:done");
|
|
547
|
+
this._eventBus?.emitTyped("import:completed", { nodesCreated: nodes.length, edgesCreated: edges.length });
|
|
548
|
+
}
|
|
549
|
+
// ── Snapshots ────────────────────────────────────
|
|
550
|
+
createSnapshot() {
|
|
551
|
+
const pid = this.ensureProject();
|
|
552
|
+
const doc = this.toGraphDocument();
|
|
553
|
+
const result = this.db
|
|
554
|
+
.prepare("INSERT INTO snapshots (project_id, data, created_at) VALUES (?, ?, ?)")
|
|
555
|
+
.run(pid, JSON.stringify(doc), now());
|
|
556
|
+
return result.lastInsertRowid;
|
|
557
|
+
}
|
|
558
|
+
// ── Import history ───────────────────────────────
|
|
559
|
+
recordImport(sourceFile, nodesCreated, edgesCreated) {
|
|
560
|
+
const pid = this.ensureProject();
|
|
561
|
+
this.db
|
|
562
|
+
.prepare(`INSERT INTO import_history (project_id, source_file, nodes_created, edges_created, imported_at)
|
|
563
|
+
VALUES (?, ?, ?, ?, ?)`)
|
|
564
|
+
.run(pid, sourceFile, nodesCreated, edgesCreated, now());
|
|
565
|
+
}
|
|
566
|
+
// ── Stats ────────────────────────────────────────
|
|
567
|
+
getStats() {
|
|
568
|
+
const pid = this.ensureProject();
|
|
569
|
+
const totalNodes = this.db
|
|
570
|
+
.prepare("SELECT COUNT(*) as c FROM nodes WHERE project_id = ?")
|
|
571
|
+
.get(pid).c;
|
|
572
|
+
const totalEdges = this.db
|
|
573
|
+
.prepare("SELECT COUNT(*) as c FROM edges WHERE project_id = ?")
|
|
574
|
+
.get(pid).c;
|
|
575
|
+
const byType = {};
|
|
576
|
+
const typeRows = this.db
|
|
577
|
+
.prepare("SELECT type, COUNT(*) as c FROM nodes WHERE project_id = ? GROUP BY type")
|
|
578
|
+
.all(pid);
|
|
579
|
+
for (const r of typeRows)
|
|
580
|
+
byType[r.type] = r.c;
|
|
581
|
+
const byStatus = {};
|
|
582
|
+
const statusRows = this.db
|
|
583
|
+
.prepare("SELECT status, COUNT(*) as c FROM nodes WHERE project_id = ? GROUP BY status")
|
|
584
|
+
.all(pid);
|
|
585
|
+
for (const r of statusRows)
|
|
586
|
+
byStatus[r.status] = r.c;
|
|
587
|
+
return { totalNodes, totalEdges, byType, byStatus };
|
|
588
|
+
}
|
|
589
|
+
// ── Full-text search ─────────────────────────────
|
|
590
|
+
/**
|
|
591
|
+
* Search nodes using FTS5 with BM25 ranking.
|
|
592
|
+
* Returns nodes ordered by relevance score.
|
|
593
|
+
*/
|
|
594
|
+
searchNodes(query, limit = 20) {
|
|
595
|
+
const pid = this.ensureProject();
|
|
596
|
+
// FTS5 match query — escape user input for safety
|
|
597
|
+
const rows = this.db
|
|
598
|
+
.prepare(`SELECT n.*, bm25(nodes_fts) AS score
|
|
599
|
+
FROM nodes_fts fts
|
|
600
|
+
JOIN nodes n ON n.rowid = fts.rowid
|
|
601
|
+
WHERE nodes_fts MATCH ?
|
|
602
|
+
AND n.project_id = ?
|
|
603
|
+
ORDER BY score
|
|
604
|
+
LIMIT ?`)
|
|
605
|
+
.all(query, pid, limit);
|
|
606
|
+
return rows.map((row) => ({
|
|
607
|
+
...rowToNode(row),
|
|
608
|
+
score: row.score,
|
|
609
|
+
}));
|
|
610
|
+
}
|
|
611
|
+
// ── Bulk status update ─────────────────────────
|
|
612
|
+
bulkUpdateStatus(ids, status) {
|
|
613
|
+
this.ensureProject();
|
|
614
|
+
logger.debug("tx:bulk-update-status", { count: ids.length, status });
|
|
615
|
+
const updated = [];
|
|
616
|
+
const notFound = [];
|
|
617
|
+
this.db.transaction(() => {
|
|
618
|
+
for (const id of ids) {
|
|
619
|
+
const result = this.updateNodeStatus(id, status);
|
|
620
|
+
if (result) {
|
|
621
|
+
updated.push(id);
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
notFound.push(id);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
})();
|
|
628
|
+
return { updated, notFound };
|
|
629
|
+
}
|
|
630
|
+
// ── Restore snapshot ──────────────────────────
|
|
631
|
+
restoreSnapshot(snapshotId) {
|
|
632
|
+
const pid = this.ensureProject();
|
|
633
|
+
logger.debug("tx:restore-snapshot", { snapshotId });
|
|
634
|
+
const row = this.db
|
|
635
|
+
.prepare("SELECT data FROM snapshots WHERE rowid = ? AND project_id = ?")
|
|
636
|
+
.get(snapshotId, pid);
|
|
637
|
+
if (!row) {
|
|
638
|
+
throw new SnapshotNotFoundError(snapshotId);
|
|
639
|
+
}
|
|
640
|
+
const doc = JSON.parse(row.data);
|
|
641
|
+
this.db.transaction(() => {
|
|
642
|
+
this.db.prepare("DELETE FROM edges WHERE project_id = ?").run(pid);
|
|
643
|
+
this.db.prepare("DELETE FROM nodes WHERE project_id = ?").run(pid);
|
|
644
|
+
for (const node of doc.nodes) {
|
|
645
|
+
const r = nodeToRow(node, pid);
|
|
646
|
+
this.db
|
|
647
|
+
.prepare(`INSERT INTO nodes
|
|
648
|
+
(id, project_id, type, title, description, status, priority,
|
|
649
|
+
xp_size, estimate_minutes, tags, parent_id, sprint,
|
|
650
|
+
source_file, source_start_line, source_end_line, source_confidence,
|
|
651
|
+
acceptance_criteria, blocked, metadata, created_at, updated_at)
|
|
652
|
+
VALUES
|
|
653
|
+
(@id, @project_id, @type, @title, @description, @status, @priority,
|
|
654
|
+
@xp_size, @estimate_minutes, @tags, @parent_id, @sprint,
|
|
655
|
+
@source_file, @source_start_line, @source_end_line, @source_confidence,
|
|
656
|
+
@acceptance_criteria, @blocked, @metadata, @created_at, @updated_at)`)
|
|
657
|
+
.run(r);
|
|
658
|
+
}
|
|
659
|
+
for (const edge of doc.edges) {
|
|
660
|
+
const r = edgeToRow(edge, pid);
|
|
661
|
+
this.db
|
|
662
|
+
.prepare(`INSERT INTO edges
|
|
663
|
+
(id, project_id, from_node, to_node, relation_type, weight, reason, metadata, created_at)
|
|
664
|
+
VALUES
|
|
665
|
+
(@id, @project_id, @from_node, @to_node, @relation_type, @weight, @reason, @metadata, @created_at)`)
|
|
666
|
+
.run(r);
|
|
667
|
+
}
|
|
668
|
+
})();
|
|
669
|
+
}
|
|
670
|
+
listSnapshots() {
|
|
671
|
+
const pid = this.ensureProject();
|
|
672
|
+
const rows = this.db
|
|
673
|
+
.prepare("SELECT id, created_at FROM snapshots WHERE project_id = ? ORDER BY id DESC")
|
|
674
|
+
.all(pid);
|
|
675
|
+
return rows.map((r) => ({ snapshotId: r.id, createdAt: r.created_at }));
|
|
676
|
+
}
|
|
677
|
+
// ── Bridge: materialize full GraphDocument ───────
|
|
678
|
+
toGraphDocument() {
|
|
679
|
+
const project = this.getProject();
|
|
680
|
+
if (!project) {
|
|
681
|
+
throw new GraphNotInitializedError();
|
|
682
|
+
}
|
|
683
|
+
const nodes = this.getAllNodes();
|
|
684
|
+
const edges = this.getAllEdges();
|
|
685
|
+
const indexes = buildIndexes(nodes, edges);
|
|
686
|
+
// Collect source files from import history
|
|
687
|
+
const pid = this.ensureProject();
|
|
688
|
+
const imports = this.db
|
|
689
|
+
.prepare("SELECT DISTINCT source_file FROM import_history WHERE project_id = ?")
|
|
690
|
+
.all(pid);
|
|
691
|
+
const lastImportRow = this.db
|
|
692
|
+
.prepare("SELECT imported_at FROM import_history WHERE project_id = ? ORDER BY imported_at DESC LIMIT 1")
|
|
693
|
+
.get(pid);
|
|
694
|
+
return {
|
|
695
|
+
version: "1.0.0",
|
|
696
|
+
project,
|
|
697
|
+
nodes,
|
|
698
|
+
edges,
|
|
699
|
+
indexes,
|
|
700
|
+
meta: {
|
|
701
|
+
sourceFiles: imports.map((r) => r.source_file),
|
|
702
|
+
lastImport: lastImportRow?.imported_at ?? null,
|
|
703
|
+
},
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
//# sourceMappingURL=sqlite-store.js.map
|