forge-server 0.1.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/.claude/hooks/worktree-create.sh +64 -0
- package/.claude/hooks/worktree-remove.sh +57 -0
- package/.claude/settings.local.json +29 -0
- package/.forge/knowledge/conventions.yaml +1 -0
- package/.forge/knowledge/decisions.yaml +1 -0
- package/.forge/knowledge/gotchas.yaml +1 -0
- package/.forge/knowledge/patterns.yaml +1 -0
- package/.forge/manifest.yaml +6 -0
- package/CLAUDE.md +144 -0
- package/bin/setup-forge.sh +132 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +553 -0
- package/dist/cli.js.map +1 -0
- package/dist/context/codebase.d.ts +57 -0
- package/dist/context/codebase.d.ts.map +1 -0
- package/dist/context/codebase.js +301 -0
- package/dist/context/codebase.js.map +1 -0
- package/dist/context/injector.d.ts +147 -0
- package/dist/context/injector.d.ts.map +1 -0
- package/dist/context/injector.js +533 -0
- package/dist/context/injector.js.map +1 -0
- package/dist/context/memory.d.ts +32 -0
- package/dist/context/memory.d.ts.map +1 -0
- package/dist/context/memory.js +140 -0
- package/dist/context/memory.js.map +1 -0
- package/dist/context/session-index.d.ts +54 -0
- package/dist/context/session-index.d.ts.map +1 -0
- package/dist/context/session-index.js +265 -0
- package/dist/context/session-index.js.map +1 -0
- package/dist/context/session.d.ts +42 -0
- package/dist/context/session.d.ts.map +1 -0
- package/dist/context/session.js +121 -0
- package/dist/context/session.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/ingestion/chunker.d.ts +19 -0
- package/dist/ingestion/chunker.d.ts.map +1 -0
- package/dist/ingestion/chunker.js +189 -0
- package/dist/ingestion/chunker.js.map +1 -0
- package/dist/ingestion/embedder.d.ts +45 -0
- package/dist/ingestion/embedder.d.ts.map +1 -0
- package/dist/ingestion/embedder.js +152 -0
- package/dist/ingestion/embedder.js.map +1 -0
- package/dist/ingestion/git-analyzer.d.ts +77 -0
- package/dist/ingestion/git-analyzer.d.ts.map +1 -0
- package/dist/ingestion/git-analyzer.js +437 -0
- package/dist/ingestion/git-analyzer.js.map +1 -0
- package/dist/ingestion/indexer.d.ts +79 -0
- package/dist/ingestion/indexer.d.ts.map +1 -0
- package/dist/ingestion/indexer.js +766 -0
- package/dist/ingestion/indexer.js.map +1 -0
- package/dist/ingestion/markdown-chunker.d.ts +19 -0
- package/dist/ingestion/markdown-chunker.d.ts.map +1 -0
- package/dist/ingestion/markdown-chunker.js +243 -0
- package/dist/ingestion/markdown-chunker.js.map +1 -0
- package/dist/ingestion/markdown-knowledge.d.ts +21 -0
- package/dist/ingestion/markdown-knowledge.d.ts.map +1 -0
- package/dist/ingestion/markdown-knowledge.js +129 -0
- package/dist/ingestion/markdown-knowledge.js.map +1 -0
- package/dist/ingestion/parser.d.ts +20 -0
- package/dist/ingestion/parser.d.ts.map +1 -0
- package/dist/ingestion/parser.js +429 -0
- package/dist/ingestion/parser.js.map +1 -0
- package/dist/ingestion/watcher.d.ts +28 -0
- package/dist/ingestion/watcher.d.ts.map +1 -0
- package/dist/ingestion/watcher.js +147 -0
- package/dist/ingestion/watcher.js.map +1 -0
- package/dist/knowledge/hydrator.d.ts +37 -0
- package/dist/knowledge/hydrator.d.ts.map +1 -0
- package/dist/knowledge/hydrator.js +220 -0
- package/dist/knowledge/hydrator.js.map +1 -0
- package/dist/knowledge/registry.d.ts +129 -0
- package/dist/knowledge/registry.d.ts.map +1 -0
- package/dist/knowledge/registry.js +361 -0
- package/dist/knowledge/registry.js.map +1 -0
- package/dist/knowledge/search.d.ts +114 -0
- package/dist/knowledge/search.d.ts.map +1 -0
- package/dist/knowledge/search.js +428 -0
- package/dist/knowledge/search.js.map +1 -0
- package/dist/knowledge/store.d.ts +76 -0
- package/dist/knowledge/store.d.ts.map +1 -0
- package/dist/knowledge/store.js +230 -0
- package/dist/knowledge/store.js.map +1 -0
- package/dist/learning/confidence.d.ts +30 -0
- package/dist/learning/confidence.d.ts.map +1 -0
- package/dist/learning/confidence.js +165 -0
- package/dist/learning/confidence.js.map +1 -0
- package/dist/learning/patterns.d.ts +52 -0
- package/dist/learning/patterns.d.ts.map +1 -0
- package/dist/learning/patterns.js +290 -0
- package/dist/learning/patterns.js.map +1 -0
- package/dist/learning/trajectory.d.ts +55 -0
- package/dist/learning/trajectory.d.ts.map +1 -0
- package/dist/learning/trajectory.js +200 -0
- package/dist/learning/trajectory.js.map +1 -0
- package/dist/memory/memory-compat.d.ts +100 -0
- package/dist/memory/memory-compat.d.ts.map +1 -0
- package/dist/memory/memory-compat.js +146 -0
- package/dist/memory/memory-compat.js.map +1 -0
- package/dist/memory/observation-store.d.ts +57 -0
- package/dist/memory/observation-store.d.ts.map +1 -0
- package/dist/memory/observation-store.js +154 -0
- package/dist/memory/observation-store.js.map +1 -0
- package/dist/memory/session-tracker.d.ts +81 -0
- package/dist/memory/session-tracker.d.ts.map +1 -0
- package/dist/memory/session-tracker.js +262 -0
- package/dist/memory/session-tracker.js.map +1 -0
- package/dist/pipeline/engine.d.ts +179 -0
- package/dist/pipeline/engine.d.ts.map +1 -0
- package/dist/pipeline/engine.js +691 -0
- package/dist/pipeline/engine.js.map +1 -0
- package/dist/pipeline/events.d.ts +54 -0
- package/dist/pipeline/events.d.ts.map +1 -0
- package/dist/pipeline/events.js +157 -0
- package/dist/pipeline/events.js.map +1 -0
- package/dist/pipeline/parallel.d.ts +83 -0
- package/dist/pipeline/parallel.d.ts.map +1 -0
- package/dist/pipeline/parallel.js +277 -0
- package/dist/pipeline/parallel.js.map +1 -0
- package/dist/pipeline/state-machine.d.ts +65 -0
- package/dist/pipeline/state-machine.d.ts.map +1 -0
- package/dist/pipeline/state-machine.js +176 -0
- package/dist/pipeline/state-machine.js.map +1 -0
- package/dist/query/graph-queries.d.ts +84 -0
- package/dist/query/graph-queries.d.ts.map +1 -0
- package/dist/query/graph-queries.js +216 -0
- package/dist/query/graph-queries.js.map +1 -0
- package/dist/query/hybrid-search.d.ts +34 -0
- package/dist/query/hybrid-search.d.ts.map +1 -0
- package/dist/query/hybrid-search.js +263 -0
- package/dist/query/hybrid-search.js.map +1 -0
- package/dist/query/intent-detector.d.ts +35 -0
- package/dist/query/intent-detector.d.ts.map +1 -0
- package/dist/query/intent-detector.js +115 -0
- package/dist/query/intent-detector.js.map +1 -0
- package/dist/query/ranking.d.ts +57 -0
- package/dist/query/ranking.d.ts.map +1 -0
- package/dist/query/ranking.js +109 -0
- package/dist/query/ranking.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +291 -0
- package/dist/server.js.map +1 -0
- package/dist/storage/falkordb-store.d.ts +73 -0
- package/dist/storage/falkordb-store.d.ts.map +1 -0
- package/dist/storage/falkordb-store.js +346 -0
- package/dist/storage/falkordb-store.js.map +1 -0
- package/dist/storage/file-cache.d.ts +32 -0
- package/dist/storage/file-cache.d.ts.map +1 -0
- package/dist/storage/file-cache.js +115 -0
- package/dist/storage/file-cache.js.map +1 -0
- package/dist/storage/interfaces.d.ts +151 -0
- package/dist/storage/interfaces.d.ts.map +1 -0
- package/dist/storage/interfaces.js +7 -0
- package/dist/storage/interfaces.js.map +1 -0
- package/dist/storage/qdrant-store.d.ts +110 -0
- package/dist/storage/qdrant-store.d.ts.map +1 -0
- package/dist/storage/qdrant-store.js +467 -0
- package/dist/storage/qdrant-store.js.map +1 -0
- package/dist/storage/schema.d.ts +4 -0
- package/dist/storage/schema.d.ts.map +1 -0
- package/dist/storage/schema.js +136 -0
- package/dist/storage/schema.js.map +1 -0
- package/dist/storage/sqlite.d.ts +35 -0
- package/dist/storage/sqlite.d.ts.map +1 -0
- package/dist/storage/sqlite.js +132 -0
- package/dist/storage/sqlite.js.map +1 -0
- package/dist/tools/collaboration-tools.d.ts +111 -0
- package/dist/tools/collaboration-tools.d.ts.map +1 -0
- package/dist/tools/collaboration-tools.js +174 -0
- package/dist/tools/collaboration-tools.js.map +1 -0
- package/dist/tools/context-tools.d.ts +293 -0
- package/dist/tools/context-tools.d.ts.map +1 -0
- package/dist/tools/context-tools.js +437 -0
- package/dist/tools/context-tools.js.map +1 -0
- package/dist/tools/graph-tools.d.ts +129 -0
- package/dist/tools/graph-tools.d.ts.map +1 -0
- package/dist/tools/graph-tools.js +237 -0
- package/dist/tools/graph-tools.js.map +1 -0
- package/dist/tools/ingestion-tools.d.ts +96 -0
- package/dist/tools/ingestion-tools.d.ts.map +1 -0
- package/dist/tools/ingestion-tools.js +90 -0
- package/dist/tools/ingestion-tools.js.map +1 -0
- package/dist/tools/learning-tools.d.ts +168 -0
- package/dist/tools/learning-tools.d.ts.map +1 -0
- package/dist/tools/learning-tools.js +158 -0
- package/dist/tools/learning-tools.js.map +1 -0
- package/dist/tools/memory-tools.d.ts +183 -0
- package/dist/tools/memory-tools.d.ts.map +1 -0
- package/dist/tools/memory-tools.js +197 -0
- package/dist/tools/memory-tools.js.map +1 -0
- package/dist/tools/phase-tools.d.ts +954 -0
- package/dist/tools/phase-tools.d.ts.map +1 -0
- package/dist/tools/phase-tools.js +1215 -0
- package/dist/tools/phase-tools.js.map +1 -0
- package/dist/tools/pipeline-tools.d.ts +140 -0
- package/dist/tools/pipeline-tools.d.ts.map +1 -0
- package/dist/tools/pipeline-tools.js +162 -0
- package/dist/tools/pipeline-tools.js.map +1 -0
- package/dist/tools/registration-tools.d.ts +220 -0
- package/dist/tools/registration-tools.d.ts.map +1 -0
- package/dist/tools/registration-tools.js +391 -0
- package/dist/tools/registration-tools.js.map +1 -0
- package/dist/util/circuit-breaker.d.ts +75 -0
- package/dist/util/circuit-breaker.d.ts.map +1 -0
- package/dist/util/circuit-breaker.js +159 -0
- package/dist/util/circuit-breaker.js.map +1 -0
- package/dist/util/config.d.ts +23 -0
- package/dist/util/config.d.ts.map +1 -0
- package/dist/util/config.js +164 -0
- package/dist/util/config.js.map +1 -0
- package/dist/util/logger.d.ts +13 -0
- package/dist/util/logger.d.ts.map +1 -0
- package/dist/util/logger.js +45 -0
- package/dist/util/logger.js.map +1 -0
- package/dist/util/token-counter.d.ts +24 -0
- package/dist/util/token-counter.d.ts.map +1 -0
- package/dist/util/token-counter.js +48 -0
- package/dist/util/token-counter.js.map +1 -0
- package/dist/util/types.d.ts +525 -0
- package/dist/util/types.d.ts.map +1 -0
- package/dist/util/types.js +5 -0
- package/dist/util/types.js.map +1 -0
- package/docker-compose.yml +20 -0
- package/docs/plans/2026-02-27-swarm-coordination/architecture.md +203 -0
- package/docs/plans/2026-02-27-swarm-coordination/vision.md +57 -0
- package/docs/plans/completed/2026-02-26-forge-plugin-bundling/architecture.md +1 -0
- package/docs/plans/completed/2026-02-26-forge-plugin-bundling/vision.md +300 -0
- package/docs/plans/completed/2026-02-27-forge-swarm-learning/architecture.md +480 -0
- package/docs/plans/completed/2026-02-27-forge-swarm-learning/verification-checklist.md +462 -0
- package/docs/plans/completed/2026-02-27-git-history-atlassian/git-jira-plan.md +181 -0
- package/package.json +39 -0
- package/plugin/.claude-plugin/plugin.json +8 -0
- package/plugin/.mcp.json +15 -0
- package/plugin/README.md +134 -0
- package/plugin/agents/architect.md +367 -0
- package/plugin/agents/backend-specialist.md +263 -0
- package/plugin/agents/brainstormer.md +122 -0
- package/plugin/agents/data-specialist.md +266 -0
- package/plugin/agents/designer.md +408 -0
- package/plugin/agents/frontend-specialist.md +241 -0
- package/plugin/agents/inspector.md +406 -0
- package/plugin/agents/knowledge-keeper.md +443 -0
- package/plugin/agents/platform-engineer.md +326 -0
- package/plugin/agents/product-manager.md +268 -0
- package/plugin/agents/product-owner.md +438 -0
- package/plugin/agents/pulse-checker.md +73 -0
- package/plugin/agents/qa-strategist.md +500 -0
- package/plugin/agents/self-improver.md +310 -0
- package/plugin/agents/strategist.md +360 -0
- package/plugin/agents/supervisor.md +380 -0
- package/plugin/commands/brainstorm.md +25 -0
- package/plugin/commands/forge.md +88 -0
- package/plugin/docs/atlassian-integration.md +110 -0
- package/plugin/docs/workflow.md +126 -0
- package/plugin/skills/agent-development/.skillfish.json +10 -0
- package/plugin/skills/agent-development/SKILL.md +415 -0
- package/plugin/skills/agent-development/examples/agent-creation-prompt.md +238 -0
- package/plugin/skills/agent-development/examples/complete-agent-examples.md +427 -0
- package/plugin/skills/agent-development/references/agent-creation-system-prompt.md +207 -0
- package/plugin/skills/agent-development/references/system-prompt-design.md +411 -0
- package/plugin/skills/agent-development/references/triggering-examples.md +491 -0
- package/plugin/skills/agent-development/scripts/validate-agent.sh +217 -0
- package/plugin/skills/agent-handoff/SKILL.md +335 -0
- package/plugin/skills/anti-stub/SKILL.md +317 -0
- package/plugin/skills/brainstorm/SKILL.md +31 -0
- package/plugin/skills/debugging/SKILL.md +276 -0
- package/plugin/skills/fix/SKILL.md +62 -0
- package/plugin/skills/frontend-design/.skillfish.json +10 -0
- package/plugin/skills/frontend-design/SKILL.md +42 -0
- package/plugin/skills/gotchas/SKILL.md +61 -0
- package/plugin/skills/graph-orchestrator/SKILL.md +38 -0
- package/plugin/skills/history/SKILL.md +58 -0
- package/plugin/skills/impact/SKILL.md +59 -0
- package/plugin/skills/implementation-execution/SKILL.md +291 -0
- package/plugin/skills/index-repo/SKILL.md +55 -0
- package/plugin/skills/interviewing/SKILL.md +225 -0
- package/plugin/skills/knowledge-curation/SKILL.md +393 -0
- package/plugin/skills/learn/SKILL.md +69 -0
- package/plugin/skills/mcp-integration/.skillfish.json +10 -0
- package/plugin/skills/mcp-integration/SKILL.md +554 -0
- package/plugin/skills/mcp-integration/examples/http-server.json +20 -0
- package/plugin/skills/mcp-integration/examples/sse-server.json +19 -0
- package/plugin/skills/mcp-integration/examples/stdio-server.json +26 -0
- package/plugin/skills/mcp-integration/references/authentication.md +549 -0
- package/plugin/skills/mcp-integration/references/server-types.md +536 -0
- package/plugin/skills/mcp-integration/references/tool-usage.md +538 -0
- package/plugin/skills/nestjs/.skillfish.json +10 -0
- package/plugin/skills/nestjs/SKILL.md +669 -0
- package/plugin/skills/nestjs/drizzle-reference.md +1894 -0
- package/plugin/skills/nestjs/reference.md +1447 -0
- package/plugin/skills/nestjs/workflow-optimization.md +229 -0
- package/plugin/skills/parallel-dispatch/SKILL.md +308 -0
- package/plugin/skills/project-discovery/SKILL.md +304 -0
- package/plugin/skills/search/SKILL.md +56 -0
- package/plugin/skills/security-audit/SKILL.md +362 -0
- package/plugin/skills/skill-development/.skillfish.json +10 -0
- package/plugin/skills/skill-development/SKILL.md +637 -0
- package/plugin/skills/skill-development/references/skill-creator-original.md +209 -0
- package/plugin/skills/tdd/SKILL.md +273 -0
- package/plugin/skills/terminal-presentation/SKILL.md +395 -0
- package/plugin/skills/test-strategy/SKILL.md +365 -0
- package/plugin/skills/verification-protocol/SKILL.md +256 -0
- package/plugin/skills/visual-explainer/CHANGELOG.md +97 -0
- package/plugin/skills/visual-explainer/LICENSE +21 -0
- package/plugin/skills/visual-explainer/README.md +137 -0
- package/plugin/skills/visual-explainer/SKILL.md +352 -0
- package/plugin/skills/visual-explainer/banner.png +0 -0
- package/plugin/skills/visual-explainer/package.json +11 -0
- package/plugin/skills/visual-explainer/prompts/diff-review.md +68 -0
- package/plugin/skills/visual-explainer/prompts/fact-check.md +63 -0
- package/plugin/skills/visual-explainer/prompts/generate-slides.md +18 -0
- package/plugin/skills/visual-explainer/prompts/generate-web-diagram.md +10 -0
- package/plugin/skills/visual-explainer/prompts/plan-review.md +86 -0
- package/plugin/skills/visual-explainer/prompts/project-recap.md +61 -0
- package/plugin/skills/visual-explainer/references/css-patterns.md +1188 -0
- package/plugin/skills/visual-explainer/references/libraries.md +470 -0
- package/plugin/skills/visual-explainer/references/responsive-nav.md +212 -0
- package/plugin/skills/visual-explainer/references/slide-patterns.md +1403 -0
- package/plugin/skills/visual-explainer/templates/architecture.html +596 -0
- package/plugin/skills/visual-explainer/templates/data-table.html +540 -0
- package/plugin/skills/visual-explainer/templates/mermaid-flowchart.html +435 -0
- package/plugin/skills/visual-explainer/templates/slide-deck.html +913 -0
- package/src/cli.ts +655 -0
- package/src/context/.gitkeep +0 -0
- package/src/context/codebase.ts +393 -0
- package/src/context/injector.ts +797 -0
- package/src/context/memory.ts +187 -0
- package/src/context/session-index.ts +327 -0
- package/src/context/session.ts +152 -0
- package/src/index.ts +47 -0
- package/src/ingestion/.gitkeep +0 -0
- package/src/ingestion/chunker.ts +277 -0
- package/src/ingestion/embedder.ts +167 -0
- package/src/ingestion/git-analyzer.ts +545 -0
- package/src/ingestion/indexer.ts +984 -0
- package/src/ingestion/markdown-chunker.ts +337 -0
- package/src/ingestion/markdown-knowledge.ts +175 -0
- package/src/ingestion/parser.ts +475 -0
- package/src/ingestion/watcher.ts +182 -0
- package/src/knowledge/.gitkeep +0 -0
- package/src/knowledge/hydrator.ts +246 -0
- package/src/knowledge/registry.ts +463 -0
- package/src/knowledge/search.ts +565 -0
- package/src/knowledge/store.ts +262 -0
- package/src/learning/.gitkeep +0 -0
- package/src/learning/confidence.ts +193 -0
- package/src/learning/patterns.ts +360 -0
- package/src/learning/trajectory.ts +268 -0
- package/src/memory/.gitkeep +0 -0
- package/src/memory/memory-compat.ts +233 -0
- package/src/memory/observation-store.ts +224 -0
- package/src/memory/session-tracker.ts +332 -0
- package/src/pipeline/.gitkeep +0 -0
- package/src/pipeline/engine.ts +1139 -0
- package/src/pipeline/events.ts +253 -0
- package/src/pipeline/parallel.ts +394 -0
- package/src/pipeline/state-machine.ts +199 -0
- package/src/query/.gitkeep +0 -0
- package/src/query/graph-queries.ts +262 -0
- package/src/query/hybrid-search.ts +337 -0
- package/src/query/intent-detector.ts +131 -0
- package/src/query/ranking.ts +161 -0
- package/src/server.ts +352 -0
- package/src/storage/.gitkeep +0 -0
- package/src/storage/falkordb-store.ts +388 -0
- package/src/storage/file-cache.ts +141 -0
- package/src/storage/interfaces.ts +201 -0
- package/src/storage/qdrant-store.ts +557 -0
- package/src/storage/schema.ts +139 -0
- package/src/storage/sqlite.ts +168 -0
- package/src/tools/.gitkeep +0 -0
- package/src/tools/collaboration-tools.ts +208 -0
- package/src/tools/context-tools.ts +493 -0
- package/src/tools/graph-tools.ts +295 -0
- package/src/tools/ingestion-tools.ts +122 -0
- package/src/tools/learning-tools.ts +181 -0
- package/src/tools/memory-tools.ts +234 -0
- package/src/tools/phase-tools.ts +1452 -0
- package/src/tools/pipeline-tools.ts +188 -0
- package/src/tools/registration-tools.ts +450 -0
- package/src/util/.gitkeep +0 -0
- package/src/util/circuit-breaker.ts +193 -0
- package/src/util/config.ts +177 -0
- package/src/util/logger.ts +53 -0
- package/src/util/token-counter.ts +52 -0
- package/src/util/types.ts +710 -0
- package/tests/context/.gitkeep +0 -0
- package/tests/integration/.gitkeep +0 -0
- package/tests/knowledge/.gitkeep +0 -0
- package/tests/learning/.gitkeep +0 -0
- package/tests/pipeline/.gitkeep +0 -0
- package/tests/tools/.gitkeep +0 -0
- package/tsconfig.json +21 -0
- package/vitest.config.ts +10 -0
- package/vscode-extension/.vscodeignore +7 -0
- package/vscode-extension/README.md +43 -0
- package/vscode-extension/out/edge-collector.js +274 -0
- package/vscode-extension/out/edge-collector.js.map +1 -0
- package/vscode-extension/out/extension.js +264 -0
- package/vscode-extension/out/extension.js.map +1 -0
- package/vscode-extension/out/forge-client.js +318 -0
- package/vscode-extension/out/forge-client.js.map +1 -0
- package/vscode-extension/package-lock.json +59 -0
- package/vscode-extension/package.json +71 -0
- package/vscode-extension/src/edge-collector.ts +320 -0
- package/vscode-extension/src/extension.ts +269 -0
- package/vscode-extension/src/forge-client.ts +364 -0
- package/vscode-extension/tsconfig.json +19 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
// graph-tools.ts — Swarm Learning Phase 1
|
|
2
|
+
// MCP tool handlers for graph-based code analysis.
|
|
3
|
+
// Tools: get_impact_graph, search_logic_flow
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { QUERY_INBOUND_IMPACT, QUERY_OUTBOUND_IMPACT, QUERY_SHORTEST_PATH, } from '../query/graph-queries.js';
|
|
6
|
+
import { logger } from '../util/logger.js';
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
// Input schemas
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
export const getImpactGraphSchema = z.object({
|
|
11
|
+
symbol: z.string().min(1, 'symbol name is required'),
|
|
12
|
+
repo_id: z.string().min(1, 'repo_id is required'),
|
|
13
|
+
direction: z.enum(['inbound', 'outbound', 'both']).default('both'),
|
|
14
|
+
depth: z.number().int().min(1).max(5).default(3),
|
|
15
|
+
});
|
|
16
|
+
export const searchLogicFlowSchema = z.object({
|
|
17
|
+
from_symbol: z.string().min(1, 'from_symbol is required'),
|
|
18
|
+
to_symbol: z.string().min(1, 'to_symbol is required'),
|
|
19
|
+
repo_id: z.string().min(1, 'repo_id is required'),
|
|
20
|
+
max_depth: z.number().int().min(1).max(10).default(5),
|
|
21
|
+
});
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// Tool factory
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
export function createGraphTools(graphStore) {
|
|
26
|
+
return {
|
|
27
|
+
'get_impact_graph': {
|
|
28
|
+
schema: getImpactGraphSchema,
|
|
29
|
+
description: 'Get the impact graph (callers/dependents) for a code symbol. PREFER THIS over manual Grep for "who uses X" questions — it traverses the actual call/import graph with depth control, not just text matches. Requires FalkorDB graph store.',
|
|
30
|
+
handler: async (input) => {
|
|
31
|
+
if (!graphStore) {
|
|
32
|
+
return {
|
|
33
|
+
error: 'GRAPH_UNAVAILABLE',
|
|
34
|
+
message: 'FalkorDB graph store is not available. Impact graph requires a running FalkorDB instance.',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const healthy = await graphStore.isHealthy();
|
|
38
|
+
if (!healthy) {
|
|
39
|
+
return {
|
|
40
|
+
error: 'GRAPH_UNAVAILABLE',
|
|
41
|
+
message: 'FalkorDB is not healthy. Impact graph unavailable.',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const nodes = [];
|
|
46
|
+
const edges = [];
|
|
47
|
+
// Inbound: who calls/imports/uses this symbol?
|
|
48
|
+
if (input.direction === 'inbound' || input.direction === 'both') {
|
|
49
|
+
try {
|
|
50
|
+
const result = await graphStore.query(QUERY_INBOUND_IMPACT(input.symbol, input.repo_id, input.depth));
|
|
51
|
+
parseImpactResult(result, nodes, edges, 'inbound');
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
logger.warn('get_impact_graph: inbound query failed', { error: String(err) });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Outbound: what does this symbol depend on?
|
|
58
|
+
if (input.direction === 'outbound' || input.direction === 'both') {
|
|
59
|
+
try {
|
|
60
|
+
const result = await graphStore.query(QUERY_OUTBOUND_IMPACT(input.symbol, input.repo_id, input.depth));
|
|
61
|
+
parseImpactResult(result, nodes, edges, 'outbound');
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
logger.warn('get_impact_graph: outbound query failed', { error: String(err) });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Deduplicate nodes by name
|
|
68
|
+
const uniqueNodes = deduplicateNodes(nodes);
|
|
69
|
+
logger.debug('graph-tools.get_impact_graph: completed', {
|
|
70
|
+
symbol: input.symbol,
|
|
71
|
+
direction: input.direction,
|
|
72
|
+
nodes: uniqueNodes.length,
|
|
73
|
+
edges: edges.length,
|
|
74
|
+
});
|
|
75
|
+
return {
|
|
76
|
+
symbol: input.symbol,
|
|
77
|
+
direction: input.direction,
|
|
78
|
+
nodes: uniqueNodes,
|
|
79
|
+
edges,
|
|
80
|
+
total_nodes: uniqueNodes.length,
|
|
81
|
+
total_edges: edges.length,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
logger.error('graph-tools.get_impact_graph: error', { error: String(err) });
|
|
86
|
+
return {
|
|
87
|
+
error: 'GET_IMPACT_GRAPH_FAILED',
|
|
88
|
+
message: String(err),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
'search_logic_flow': {
|
|
94
|
+
schema: searchLogicFlowSchema,
|
|
95
|
+
description: 'Find the shortest path between two code symbols in the call/dependency graph. Use this to understand how data or control flows from A to B through the codebase — much faster than manually tracing imports. Requires FalkorDB graph store.',
|
|
96
|
+
handler: async (input) => {
|
|
97
|
+
if (!graphStore) {
|
|
98
|
+
return {
|
|
99
|
+
error: 'GRAPH_UNAVAILABLE',
|
|
100
|
+
message: 'FalkorDB graph store is not available. Logic flow search requires a running FalkorDB instance.',
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const healthy = await graphStore.isHealthy();
|
|
104
|
+
if (!healthy) {
|
|
105
|
+
return {
|
|
106
|
+
error: 'GRAPH_UNAVAILABLE',
|
|
107
|
+
message: 'FalkorDB is not healthy. Logic flow search unavailable.',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
const result = await graphStore.query(QUERY_SHORTEST_PATH(input.from_symbol, input.to_symbol, input.repo_id, input.max_depth));
|
|
112
|
+
const paths = parsePathResult(result);
|
|
113
|
+
logger.debug('graph-tools.search_logic_flow: completed', {
|
|
114
|
+
from: input.from_symbol,
|
|
115
|
+
to: input.to_symbol,
|
|
116
|
+
pathCount: paths.length,
|
|
117
|
+
});
|
|
118
|
+
return {
|
|
119
|
+
from_symbol: input.from_symbol,
|
|
120
|
+
to_symbol: input.to_symbol,
|
|
121
|
+
paths,
|
|
122
|
+
connected: paths.length > 0,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
logger.error('graph-tools.search_logic_flow: error', { error: String(err) });
|
|
127
|
+
return {
|
|
128
|
+
error: 'SEARCH_LOGIC_FLOW_FAILED',
|
|
129
|
+
message: String(err),
|
|
130
|
+
from_symbol: input.from_symbol,
|
|
131
|
+
to_symbol: input.to_symbol,
|
|
132
|
+
paths: [],
|
|
133
|
+
connected: false,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function parseImpactResult(result, nodes, edges, _direction) {
|
|
141
|
+
// Parse nodes from the result
|
|
142
|
+
for (const node of result.nodes ?? []) {
|
|
143
|
+
const name = String(node.properties?.['name'] ?? '');
|
|
144
|
+
const filePath = node.properties?.['file_path'];
|
|
145
|
+
if (name) {
|
|
146
|
+
nodes.push({ name, label: node.label, file_path: filePath });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// Parse edges from the result
|
|
150
|
+
for (const edge of result.edges ?? []) {
|
|
151
|
+
edges.push({
|
|
152
|
+
from: edge.from,
|
|
153
|
+
to: edge.to,
|
|
154
|
+
type: edge.type,
|
|
155
|
+
depth: 1,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
// Also try to parse from raw results (FalkorDB returns varying formats)
|
|
159
|
+
for (const row of result.raw ?? []) {
|
|
160
|
+
if (!row || !Array.isArray(row))
|
|
161
|
+
continue;
|
|
162
|
+
// Expected columns: [caller/dep, relationship_array, depth]
|
|
163
|
+
const entity = row[0];
|
|
164
|
+
const depth = typeof row[2] === 'number' ? row[2] : 1;
|
|
165
|
+
if (entity && typeof entity === 'object') {
|
|
166
|
+
const props = entity.properties;
|
|
167
|
+
if (props) {
|
|
168
|
+
const name = String(props['name'] ?? '');
|
|
169
|
+
const filePath = props['file_path'];
|
|
170
|
+
if (name) {
|
|
171
|
+
nodes.push({ name, label: 'unknown', file_path: filePath });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function parsePathResult(result) {
|
|
178
|
+
const paths = [];
|
|
179
|
+
// Try to parse from raw results
|
|
180
|
+
for (const row of result.raw ?? []) {
|
|
181
|
+
if (!row)
|
|
182
|
+
continue;
|
|
183
|
+
// The QUERY_SHORTEST_PATH returns path objects
|
|
184
|
+
// Different FalkorDB parsers represent these differently
|
|
185
|
+
if (Array.isArray(row)) {
|
|
186
|
+
const pathObj = row[0];
|
|
187
|
+
if (pathObj && typeof pathObj === 'object') {
|
|
188
|
+
const pathNodes = [];
|
|
189
|
+
const pathEdges = [];
|
|
190
|
+
// Extract from FalkorDB path representation
|
|
191
|
+
const pNodes = pathObj.nodes;
|
|
192
|
+
const pEdges = pathObj.edges;
|
|
193
|
+
if (pNodes) {
|
|
194
|
+
for (const n of pNodes) {
|
|
195
|
+
const props = n.properties;
|
|
196
|
+
pathNodes.push(String(props?.['name'] ?? 'unknown'));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (pEdges) {
|
|
200
|
+
for (const e of pEdges) {
|
|
201
|
+
pathEdges.push(String(e.type ?? e.relation ?? 'unknown'));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (pathNodes.length > 0) {
|
|
205
|
+
paths.push({
|
|
206
|
+
nodes: pathNodes,
|
|
207
|
+
edges: pathEdges,
|
|
208
|
+
length: pathNodes.length - 1,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
// Fallback: build from the standard node/edge arrays
|
|
215
|
+
if (paths.length === 0 && (result.nodes.length > 0 || result.edges.length > 0)) {
|
|
216
|
+
const nodeNames = result.nodes.map(n => String(n.properties?.['name'] ?? 'unknown'));
|
|
217
|
+
const edgeTypes = result.edges.map(e => e.type);
|
|
218
|
+
if (nodeNames.length > 0) {
|
|
219
|
+
paths.push({
|
|
220
|
+
nodes: nodeNames,
|
|
221
|
+
edges: edgeTypes,
|
|
222
|
+
length: Math.max(0, nodeNames.length - 1),
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return paths;
|
|
227
|
+
}
|
|
228
|
+
function deduplicateNodes(nodes) {
|
|
229
|
+
const seen = new Map();
|
|
230
|
+
for (const node of nodes) {
|
|
231
|
+
if (!seen.has(node.name)) {
|
|
232
|
+
seen.set(node.name, node);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return Array.from(seen.values());
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=graph-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-tools.js","sourceRoot":"","sources":["../../src/tools/graph-tools.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,mDAAmD;AACnD,6CAA6C;AAE7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,yBAAyB,CAAC;IACpD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,qBAAqB,CAAC;IACjD,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IAClE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;CACjD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,yBAAyB,CAAC;IACzD,SA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CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;QAC/E,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC;QACrF,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAEhD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,KAAK,CAAC,IAAI,CAAC;gBACT,KAAK,EAAE,SAAS;gBAChB,KAAK,EAAE,SAAS;gBAChB,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;aAC1C,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,gBAAgB,CACvB,KAAiE;IAEjE,MAAM,IAAI,GAAG,IAAI,GAAG,EAA+D,CAAC;IACpF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { GraphStore } from '../storage/interfaces.js';
|
|
3
|
+
export declare const submitLspEdgesSchema: z.ZodObject<{
|
|
4
|
+
repo_id: z.ZodString;
|
|
5
|
+
edges: z.ZodArray<z.ZodObject<{
|
|
6
|
+
from_file: z.ZodString;
|
|
7
|
+
from_symbol: z.ZodString;
|
|
8
|
+
to_file: z.ZodString;
|
|
9
|
+
to_symbol: z.ZodString;
|
|
10
|
+
edge_type: z.ZodString;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
from_file: string;
|
|
13
|
+
from_symbol: string;
|
|
14
|
+
to_file: string;
|
|
15
|
+
to_symbol: string;
|
|
16
|
+
edge_type: string;
|
|
17
|
+
}, {
|
|
18
|
+
from_file: string;
|
|
19
|
+
from_symbol: string;
|
|
20
|
+
to_file: string;
|
|
21
|
+
to_symbol: string;
|
|
22
|
+
edge_type: string;
|
|
23
|
+
}>, "many">;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
repo_id: string;
|
|
26
|
+
edges: {
|
|
27
|
+
from_file: string;
|
|
28
|
+
from_symbol: string;
|
|
29
|
+
to_file: string;
|
|
30
|
+
to_symbol: string;
|
|
31
|
+
edge_type: string;
|
|
32
|
+
}[];
|
|
33
|
+
}, {
|
|
34
|
+
repo_id: string;
|
|
35
|
+
edges: {
|
|
36
|
+
from_file: string;
|
|
37
|
+
from_symbol: string;
|
|
38
|
+
to_file: string;
|
|
39
|
+
to_symbol: string;
|
|
40
|
+
edge_type: string;
|
|
41
|
+
}[];
|
|
42
|
+
}>;
|
|
43
|
+
export declare function createIngestionTools(graphStore: GraphStore | null): {
|
|
44
|
+
submit_lsp_edges: {
|
|
45
|
+
schema: z.ZodObject<{
|
|
46
|
+
repo_id: z.ZodString;
|
|
47
|
+
edges: z.ZodArray<z.ZodObject<{
|
|
48
|
+
from_file: z.ZodString;
|
|
49
|
+
from_symbol: z.ZodString;
|
|
50
|
+
to_file: z.ZodString;
|
|
51
|
+
to_symbol: z.ZodString;
|
|
52
|
+
edge_type: z.ZodString;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
from_file: string;
|
|
55
|
+
from_symbol: string;
|
|
56
|
+
to_file: string;
|
|
57
|
+
to_symbol: string;
|
|
58
|
+
edge_type: string;
|
|
59
|
+
}, {
|
|
60
|
+
from_file: string;
|
|
61
|
+
from_symbol: string;
|
|
62
|
+
to_file: string;
|
|
63
|
+
to_symbol: string;
|
|
64
|
+
edge_type: string;
|
|
65
|
+
}>, "many">;
|
|
66
|
+
}, "strip", z.ZodTypeAny, {
|
|
67
|
+
repo_id: string;
|
|
68
|
+
edges: {
|
|
69
|
+
from_file: string;
|
|
70
|
+
from_symbol: string;
|
|
71
|
+
to_file: string;
|
|
72
|
+
to_symbol: string;
|
|
73
|
+
edge_type: string;
|
|
74
|
+
}[];
|
|
75
|
+
}, {
|
|
76
|
+
repo_id: string;
|
|
77
|
+
edges: {
|
|
78
|
+
from_file: string;
|
|
79
|
+
from_symbol: string;
|
|
80
|
+
to_file: string;
|
|
81
|
+
to_symbol: string;
|
|
82
|
+
edge_type: string;
|
|
83
|
+
}[];
|
|
84
|
+
}>;
|
|
85
|
+
description: string;
|
|
86
|
+
handler: (input: z.infer<typeof submitLspEdgesSchema>) => Promise<{
|
|
87
|
+
accepted: number;
|
|
88
|
+
failed: number;
|
|
89
|
+
errors?: string[];
|
|
90
|
+
} | {
|
|
91
|
+
error: string;
|
|
92
|
+
message: string;
|
|
93
|
+
}>;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=ingestion-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ingestion-tools.d.ts","sourceRoot":"","sources":["../../src/tools/ingestion-tools.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAe3D,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAG/B,CAAC;AAMH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAQrC,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC;sBAoE/B,MAAM;oBAAU,MAAM;qBAAW,MAAM,EAAE;;;;;;EAc1E"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// ingestion-tools.ts — Swarm Learning Phase 4
|
|
2
|
+
// MCP tool handlers for ingesting external data into the graph store.
|
|
3
|
+
// Tools: submit_lsp_edges
|
|
4
|
+
// Designed for VS Code extension and CI pipelines to push type-resolved
|
|
5
|
+
// call edges that supplement the static AST parsing.
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { logger } from '../util/logger.js';
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Input schemas
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
const lspEdgeSchema = z.object({
|
|
12
|
+
from_file: z.string().min(1),
|
|
13
|
+
from_symbol: z.string().min(1),
|
|
14
|
+
to_file: z.string().min(1),
|
|
15
|
+
to_symbol: z.string().min(1),
|
|
16
|
+
edge_type: z.string().min(1),
|
|
17
|
+
});
|
|
18
|
+
export const submitLspEdgesSchema = z.object({
|
|
19
|
+
repo_id: z.string().min(1, 'repo_id is required'),
|
|
20
|
+
edges: z.array(lspEdgeSchema).min(1, 'at least one edge is required'),
|
|
21
|
+
});
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// Tool factory
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
export function createIngestionTools(graphStore) {
|
|
26
|
+
return {
|
|
27
|
+
'submit_lsp_edges': {
|
|
28
|
+
schema: submitLspEdgesSchema,
|
|
29
|
+
description: 'Submit LSP-resolved call/reference edges to enrich the code graph. ' +
|
|
30
|
+
'Designed for the VS Code extension and CI pipelines. Each edge describes ' +
|
|
31
|
+
'a typed relationship between two symbols (e.g. calls, imports, implements).',
|
|
32
|
+
handler: async (input) => {
|
|
33
|
+
if (!graphStore) {
|
|
34
|
+
return {
|
|
35
|
+
error: 'GRAPH_UNAVAILABLE',
|
|
36
|
+
message: 'FalkorDB graph store is not available. LSP edges require a running FalkorDB instance.',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const healthy = await graphStore.isHealthy();
|
|
40
|
+
if (!healthy) {
|
|
41
|
+
return {
|
|
42
|
+
error: 'GRAPH_UNAVAILABLE',
|
|
43
|
+
message: 'FalkorDB is not healthy. Cannot ingest LSP edges.',
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
let accepted = 0;
|
|
47
|
+
let failed = 0;
|
|
48
|
+
const errors = [];
|
|
49
|
+
for (const edge of input.edges) {
|
|
50
|
+
try {
|
|
51
|
+
// Upsert the source node (Symbol)
|
|
52
|
+
await graphStore.upsertNode('Symbol', { name: edge.from_symbol, repo_id: input.repo_id }, { file_path: edge.from_file, source: 'lsp' });
|
|
53
|
+
// Upsert the target node (Symbol)
|
|
54
|
+
await graphStore.upsertNode('Symbol', { name: edge.to_symbol, repo_id: input.repo_id }, { file_path: edge.to_file, source: 'lsp' });
|
|
55
|
+
// Upsert the edge between the two symbols
|
|
56
|
+
await graphStore.upsertEdge('Symbol', { name: edge.from_symbol, repo_id: input.repo_id }, edge.edge_type, { source: 'lsp', repo_id: input.repo_id }, 'Symbol', { name: edge.to_symbol, repo_id: input.repo_id });
|
|
57
|
+
accepted++;
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
failed++;
|
|
61
|
+
const msg = `${edge.from_symbol} -[${edge.edge_type}]-> ${edge.to_symbol}: ${String(err)}`;
|
|
62
|
+
errors.push(msg);
|
|
63
|
+
logger.warn('ingestion-tools.submit_lsp_edges: edge failed', {
|
|
64
|
+
from: edge.from_symbol,
|
|
65
|
+
to: edge.to_symbol,
|
|
66
|
+
edgeType: edge.edge_type,
|
|
67
|
+
error: String(err),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
logger.debug('ingestion-tools.submit_lsp_edges: completed', {
|
|
72
|
+
repoId: input.repo_id,
|
|
73
|
+
total: input.edges.length,
|
|
74
|
+
accepted,
|
|
75
|
+
failed,
|
|
76
|
+
});
|
|
77
|
+
const result = {
|
|
78
|
+
accepted,
|
|
79
|
+
failed,
|
|
80
|
+
};
|
|
81
|
+
if (errors.length > 0) {
|
|
82
|
+
// Cap error messages to avoid oversized responses
|
|
83
|
+
result.errors = errors.slice(0, 20);
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=ingestion-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ingestion-tools.js","sourceRoot":"","sources":["../../src/tools/ingestion-tools.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,sEAAsE;AACtE,0BAA0B;AAC1B,wEAAwE;AACxE,qDAAqD;AAErD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC7B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,OAAO,E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CAAC;gBAEH,MAAM,MAAM,GAA4D;oBACtE,QAAQ;oBACR,MAAM;iBACP,CAAC;gBAEF,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACtB,kDAAkD;oBAClD,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACtC,CAAC;gBAED,OAAO,MAAM,CAAC;YAChB,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { KnowledgeSearch } from '../knowledge/search.js';
|
|
3
|
+
import type { ConfidenceManager } from '../learning/confidence.js';
|
|
4
|
+
import type { QdrantVectorStore } from '../storage/qdrant-store.js';
|
|
5
|
+
export declare const getPatternsSchema: z.ZodObject<{
|
|
6
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
7
|
+
min_confidence: z.ZodDefault<z.ZodNumber>;
|
|
8
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
limit: number;
|
|
11
|
+
min_confidence: number;
|
|
12
|
+
domain?: string | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
limit?: number | undefined;
|
|
15
|
+
min_confidence?: number | undefined;
|
|
16
|
+
domain?: string | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const getGotchasSchema: z.ZodObject<{
|
|
19
|
+
stack: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
20
|
+
min_confidence: z.ZodDefault<z.ZodNumber>;
|
|
21
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
limit: number;
|
|
24
|
+
min_confidence: number;
|
|
25
|
+
stack?: string[] | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
limit?: number | undefined;
|
|
28
|
+
stack?: string[] | undefined;
|
|
29
|
+
min_confidence?: number | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
export declare const boostKnowledgeSchema: z.ZodObject<{
|
|
32
|
+
knowledge_id: z.ZodString;
|
|
33
|
+
amount: z.ZodDefault<z.ZodNumber>;
|
|
34
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
knowledge_id: string;
|
|
37
|
+
amount: number;
|
|
38
|
+
reason?: string | undefined;
|
|
39
|
+
}, {
|
|
40
|
+
knowledge_id: string;
|
|
41
|
+
reason?: string | undefined;
|
|
42
|
+
amount?: number | undefined;
|
|
43
|
+
}>;
|
|
44
|
+
export declare const decayKnowledgeSchema: z.ZodObject<{
|
|
45
|
+
decay_rate: z.ZodDefault<z.ZodNumber>;
|
|
46
|
+
}, "strip", z.ZodTypeAny, {
|
|
47
|
+
decay_rate: number;
|
|
48
|
+
}, {
|
|
49
|
+
decay_rate?: number | undefined;
|
|
50
|
+
}>;
|
|
51
|
+
export declare function createLearningTools(knowledgeSearch: KnowledgeSearch, confidenceManager?: ConfidenceManager, vectorStore?: QdrantVectorStore | null): {
|
|
52
|
+
get_patterns: {
|
|
53
|
+
schema: z.ZodObject<{
|
|
54
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
55
|
+
min_confidence: z.ZodDefault<z.ZodNumber>;
|
|
56
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
limit: number;
|
|
59
|
+
min_confidence: number;
|
|
60
|
+
domain?: string | undefined;
|
|
61
|
+
}, {
|
|
62
|
+
limit?: number | undefined;
|
|
63
|
+
min_confidence?: number | undefined;
|
|
64
|
+
domain?: string | undefined;
|
|
65
|
+
}>;
|
|
66
|
+
description: string;
|
|
67
|
+
handler: (input: z.infer<typeof getPatternsSchema>) => Promise<{
|
|
68
|
+
patterns: {
|
|
69
|
+
title: string;
|
|
70
|
+
content: string;
|
|
71
|
+
confidence: number;
|
|
72
|
+
stack_tags: string[];
|
|
73
|
+
source_repo: string;
|
|
74
|
+
times_confirmed: number;
|
|
75
|
+
}[];
|
|
76
|
+
error?: undefined;
|
|
77
|
+
message?: undefined;
|
|
78
|
+
} | {
|
|
79
|
+
error: string;
|
|
80
|
+
message: string;
|
|
81
|
+
patterns: never[];
|
|
82
|
+
}>;
|
|
83
|
+
};
|
|
84
|
+
get_gotchas: {
|
|
85
|
+
schema: z.ZodObject<{
|
|
86
|
+
stack: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
87
|
+
min_confidence: z.ZodDefault<z.ZodNumber>;
|
|
88
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
89
|
+
}, "strip", z.ZodTypeAny, {
|
|
90
|
+
limit: number;
|
|
91
|
+
min_confidence: number;
|
|
92
|
+
stack?: string[] | undefined;
|
|
93
|
+
}, {
|
|
94
|
+
limit?: number | undefined;
|
|
95
|
+
stack?: string[] | undefined;
|
|
96
|
+
min_confidence?: number | undefined;
|
|
97
|
+
}>;
|
|
98
|
+
description: string;
|
|
99
|
+
handler: (input: z.infer<typeof getGotchasSchema>) => Promise<{
|
|
100
|
+
gotchas: {
|
|
101
|
+
title: string;
|
|
102
|
+
content: string;
|
|
103
|
+
confidence: number;
|
|
104
|
+
stack_tags: string[];
|
|
105
|
+
source_repo: string;
|
|
106
|
+
}[];
|
|
107
|
+
error?: undefined;
|
|
108
|
+
message?: undefined;
|
|
109
|
+
} | {
|
|
110
|
+
error: string;
|
|
111
|
+
message: string;
|
|
112
|
+
gotchas: never[];
|
|
113
|
+
}>;
|
|
114
|
+
};
|
|
115
|
+
boost_knowledge: {
|
|
116
|
+
schema: z.ZodObject<{
|
|
117
|
+
knowledge_id: z.ZodString;
|
|
118
|
+
amount: z.ZodDefault<z.ZodNumber>;
|
|
119
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
knowledge_id: string;
|
|
122
|
+
amount: number;
|
|
123
|
+
reason?: string | undefined;
|
|
124
|
+
}, {
|
|
125
|
+
knowledge_id: string;
|
|
126
|
+
reason?: string | undefined;
|
|
127
|
+
amount?: number | undefined;
|
|
128
|
+
}>;
|
|
129
|
+
description: string;
|
|
130
|
+
handler: (input: z.infer<typeof boostKnowledgeSchema>) => Promise<{
|
|
131
|
+
error: string;
|
|
132
|
+
message: string;
|
|
133
|
+
knowledge_id?: undefined;
|
|
134
|
+
boosted?: undefined;
|
|
135
|
+
amount?: undefined;
|
|
136
|
+
reason?: undefined;
|
|
137
|
+
} | {
|
|
138
|
+
knowledge_id: string;
|
|
139
|
+
boosted: boolean;
|
|
140
|
+
amount: number;
|
|
141
|
+
reason: string | undefined;
|
|
142
|
+
error?: undefined;
|
|
143
|
+
message?: undefined;
|
|
144
|
+
}>;
|
|
145
|
+
};
|
|
146
|
+
decay_knowledge: {
|
|
147
|
+
schema: z.ZodObject<{
|
|
148
|
+
decay_rate: z.ZodDefault<z.ZodNumber>;
|
|
149
|
+
}, "strip", z.ZodTypeAny, {
|
|
150
|
+
decay_rate: number;
|
|
151
|
+
}, {
|
|
152
|
+
decay_rate?: number | undefined;
|
|
153
|
+
}>;
|
|
154
|
+
description: string;
|
|
155
|
+
handler: (input: z.infer<typeof decayKnowledgeSchema>) => Promise<{
|
|
156
|
+
error: string;
|
|
157
|
+
message: string;
|
|
158
|
+
decayed_count?: undefined;
|
|
159
|
+
decay_rate?: undefined;
|
|
160
|
+
} | {
|
|
161
|
+
decayed_count: number;
|
|
162
|
+
decay_rate: number;
|
|
163
|
+
error?: undefined;
|
|
164
|
+
message?: undefined;
|
|
165
|
+
}>;
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=learning-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"learning-tools.d.ts","sourceRoot":"","sources":["../../src/tools/learning-tools.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAOpE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;EAI5B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;EAI3B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;EAI/B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;EAE/B,CAAC;AAMH,wBAAgB,mBAAmB,CACjC,eAAe,EAAE,eAAe,EAChC,iBAAiB,CAAC,EAAE,iBAAiB,EACrC,WAAW,CAAC,EAAE,iBAAiB,GAAG,IAAI;;;;;;;;;;;;;;;;yBAMX,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAiCjC,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAgChC,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;yBAoCpC,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC;;;;;;;;;;;;EA8BhE"}
|