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,37 @@
|
|
|
1
|
+
import type { KnowledgeYamlStore } from './store.js';
|
|
2
|
+
import type { QdrantVectorStore } from '../storage/qdrant-store.js';
|
|
3
|
+
import type { KnowledgeItem } from '../util/types.js';
|
|
4
|
+
import { embedText } from '../ingestion/embedder.js';
|
|
5
|
+
export declare class KnowledgeHydrator {
|
|
6
|
+
private readonly yamlStore;
|
|
7
|
+
private readonly vectorStore;
|
|
8
|
+
private readonly embedder;
|
|
9
|
+
constructor(yamlStore: KnowledgeYamlStore, vectorStore: QdrantVectorStore, embedder?: typeof embedText);
|
|
10
|
+
/**
|
|
11
|
+
* Hydrate the Qdrant knowledge collection from all YAML files for a given
|
|
12
|
+
* repo. Deletes any existing points for this repo first (handles removals),
|
|
13
|
+
* then upserts all current items.
|
|
14
|
+
*
|
|
15
|
+
* Returns the count of items successfully loaded.
|
|
16
|
+
* Returns 0 and logs a warning if Qdrant is unavailable.
|
|
17
|
+
*/
|
|
18
|
+
hydrate(repoId: string, sharing: string): Promise<number>;
|
|
19
|
+
/**
|
|
20
|
+
* Hydrate a single knowledge item into Qdrant.
|
|
21
|
+
* Used for incremental updates (e.g. after a single item is added via the
|
|
22
|
+
* knowledge-keeper agent) without re-hydrating the entire corpus.
|
|
23
|
+
*/
|
|
24
|
+
hydrateItem(item: KnowledgeItem, repoId: string, sharing: string): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Remove all knowledge items for a repo from Qdrant.
|
|
27
|
+
* Called by hydrate() before re-upserting, and by RepoRegistry.removeRepo().
|
|
28
|
+
* Silently succeeds if Qdrant is unavailable.
|
|
29
|
+
*/
|
|
30
|
+
removeRepo(repoId: string): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Derive category string from item id prefix.
|
|
33
|
+
* Mirrors the logic in KnowledgeYamlStore._categoryFromItem().
|
|
34
|
+
*/
|
|
35
|
+
private _categoryFromId;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=hydrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydrator.d.ts","sourceRoot":"","sources":["../../src/knowledge/hydrator.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAoB,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAc,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAEjE,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAG5B,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAJR,SAAS,EAAE,kBAAkB,EAC7B,WAAW,EAAE,iBAAiB,EAG9B,QAAQ,GAAE,OAAO,SAAqB;IAOzD;;;;;;;OAOG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAsF/D;;;;OAIG;IACG,WAAW,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkDtF;;;;OAIG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA2C/C;;;OAGG;IACH,OAAO,CAAC,eAAe;CAQxB"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// KnowledgeHydrator — syncs knowledge from YAML files into Qdrant's knowledge collection.
|
|
2
|
+
//
|
|
3
|
+
// The YAML files in .forge/knowledge/ are the source of truth. Qdrant is the
|
|
4
|
+
// search index. The hydrator reads all items from the YAML store, embeds them,
|
|
5
|
+
// and upserts into Qdrant. On re-hydration (after a manifest hash change) it
|
|
6
|
+
// first deletes all Qdrant points for the repo to handle removals cleanly.
|
|
7
|
+
//
|
|
8
|
+
// Design notes:
|
|
9
|
+
// - embedBatch() is used for bulk hydration instead of embedText() per item
|
|
10
|
+
// to amortise model inference overhead across all items.
|
|
11
|
+
// - If Qdrant is unavailable the method logs a warning and returns 0 — the
|
|
12
|
+
// caller (RepoRegistry) treats this as a non-fatal result and records the
|
|
13
|
+
// item count as 0 in the registration response.
|
|
14
|
+
// - The class accepts `embedder` as a constructor parameter (a reference to
|
|
15
|
+
// the embedBatch function) so tests can substitute a deterministic fake
|
|
16
|
+
// without dynamic import mocking.
|
|
17
|
+
import { logger } from '../util/logger.js';
|
|
18
|
+
import { embedBatch, embedText } from '../ingestion/embedder.js';
|
|
19
|
+
export class KnowledgeHydrator {
|
|
20
|
+
yamlStore;
|
|
21
|
+
vectorStore;
|
|
22
|
+
embedder;
|
|
23
|
+
constructor(yamlStore, vectorStore,
|
|
24
|
+
// Accept embedder as a parameter for testability. Defaults to the real embedBatch.
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
embedder = embedText) {
|
|
27
|
+
this.yamlStore = yamlStore;
|
|
28
|
+
this.vectorStore = vectorStore;
|
|
29
|
+
this.embedder = embedder;
|
|
30
|
+
}
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Public API
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
/**
|
|
35
|
+
* Hydrate the Qdrant knowledge collection from all YAML files for a given
|
|
36
|
+
* repo. Deletes any existing points for this repo first (handles removals),
|
|
37
|
+
* then upserts all current items.
|
|
38
|
+
*
|
|
39
|
+
* Returns the count of items successfully loaded.
|
|
40
|
+
* Returns 0 and logs a warning if Qdrant is unavailable.
|
|
41
|
+
*/
|
|
42
|
+
async hydrate(repoId, sharing) {
|
|
43
|
+
const items = this.yamlStore.readAll();
|
|
44
|
+
if (items.length === 0) {
|
|
45
|
+
logger.debug('KnowledgeHydrator: no items to hydrate', { repoId });
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
// Check Qdrant availability before attempting any operations.
|
|
49
|
+
const qdrantHealthy = await this.vectorStore.isHealthy();
|
|
50
|
+
if (!qdrantHealthy) {
|
|
51
|
+
logger.warn('KnowledgeHydrator: Qdrant unavailable, skipping hydration', { repoId });
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
// Remove all existing Qdrant points for this repo so that deletions
|
|
56
|
+
// in the YAML are reflected — a simple upsert-only approach would leave
|
|
57
|
+
// orphaned points for removed items.
|
|
58
|
+
await this.removeRepo(repoId);
|
|
59
|
+
// Embed all items in one batch call to amortise model init cost.
|
|
60
|
+
const texts = items.map((item) => `${item.title} ${item.content}`);
|
|
61
|
+
let vectors;
|
|
62
|
+
// embedBatch returns parallel arrays; embedText (the embedder param)
|
|
63
|
+
// is a single-text function. When the injected embedder is embedText
|
|
64
|
+
// we upgrade to batch mode internally. This gives tests a simple stub
|
|
65
|
+
// interface while production uses the efficient batch path.
|
|
66
|
+
if (this.embedder === embedText) {
|
|
67
|
+
vectors = await embedBatch(texts);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
// Fallback: call the injected embedder once per item. Used in tests.
|
|
71
|
+
vectors = await Promise.all(texts.map((t) => this.embedder(t)));
|
|
72
|
+
}
|
|
73
|
+
// Upsert each item with its vector and full KnowledgePayload.
|
|
74
|
+
const now = Date.now();
|
|
75
|
+
let loadedCount = 0;
|
|
76
|
+
for (let i = 0; i < items.length; i++) {
|
|
77
|
+
const item = items[i];
|
|
78
|
+
const vector = vectors[i];
|
|
79
|
+
const payload = {
|
|
80
|
+
id: item.id,
|
|
81
|
+
repo_id: repoId,
|
|
82
|
+
category: this._categoryFromId(item.id),
|
|
83
|
+
title: item.title,
|
|
84
|
+
content: item.content,
|
|
85
|
+
stack_tags: item.stack_tags,
|
|
86
|
+
confidence: item.confidence,
|
|
87
|
+
source: item.source,
|
|
88
|
+
source_phase: item.source_phase,
|
|
89
|
+
source_agent: item.source_agent,
|
|
90
|
+
sharing,
|
|
91
|
+
created_at: item.created_at,
|
|
92
|
+
updated_at: item.updated_at,
|
|
93
|
+
accessed_at: now,
|
|
94
|
+
access_count: 0,
|
|
95
|
+
};
|
|
96
|
+
await this.vectorStore.upsertKnowledge(item.id, vector, payload);
|
|
97
|
+
loadedCount++;
|
|
98
|
+
}
|
|
99
|
+
logger.info('KnowledgeHydrator: hydration complete', {
|
|
100
|
+
repoId,
|
|
101
|
+
itemCount: loadedCount,
|
|
102
|
+
sharing,
|
|
103
|
+
});
|
|
104
|
+
return loadedCount;
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
logger.warn('KnowledgeHydrator: hydration failed', {
|
|
108
|
+
repoId,
|
|
109
|
+
error: String(err),
|
|
110
|
+
});
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Hydrate a single knowledge item into Qdrant.
|
|
116
|
+
* Used for incremental updates (e.g. after a single item is added via the
|
|
117
|
+
* knowledge-keeper agent) without re-hydrating the entire corpus.
|
|
118
|
+
*/
|
|
119
|
+
async hydrateItem(item, repoId, sharing) {
|
|
120
|
+
const qdrantHealthy = await this.vectorStore.isHealthy();
|
|
121
|
+
if (!qdrantHealthy) {
|
|
122
|
+
logger.warn('KnowledgeHydrator.hydrateItem: Qdrant unavailable', { id: item.id, repoId });
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
const text = `${item.title} ${item.content}`;
|
|
127
|
+
const vector = await this.embedder(text);
|
|
128
|
+
const now = Date.now();
|
|
129
|
+
const payload = {
|
|
130
|
+
id: item.id,
|
|
131
|
+
repo_id: repoId,
|
|
132
|
+
category: this._categoryFromId(item.id),
|
|
133
|
+
title: item.title,
|
|
134
|
+
content: item.content,
|
|
135
|
+
stack_tags: item.stack_tags,
|
|
136
|
+
confidence: item.confidence,
|
|
137
|
+
source: item.source,
|
|
138
|
+
source_phase: item.source_phase,
|
|
139
|
+
source_agent: item.source_agent,
|
|
140
|
+
sharing,
|
|
141
|
+
created_at: item.created_at,
|
|
142
|
+
updated_at: item.updated_at,
|
|
143
|
+
accessed_at: now,
|
|
144
|
+
access_count: 0,
|
|
145
|
+
};
|
|
146
|
+
await this.vectorStore.upsertKnowledge(item.id, vector, payload);
|
|
147
|
+
logger.debug('KnowledgeHydrator.hydrateItem: item hydrated', {
|
|
148
|
+
id: item.id,
|
|
149
|
+
repoId,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
logger.warn('KnowledgeHydrator.hydrateItem: failed', {
|
|
154
|
+
id: item.id,
|
|
155
|
+
repoId,
|
|
156
|
+
error: String(err),
|
|
157
|
+
});
|
|
158
|
+
throw err;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Remove all knowledge items for a repo from Qdrant.
|
|
163
|
+
* Called by hydrate() before re-upserting, and by RepoRegistry.removeRepo().
|
|
164
|
+
* Silently succeeds if Qdrant is unavailable.
|
|
165
|
+
*/
|
|
166
|
+
async removeRepo(repoId) {
|
|
167
|
+
try {
|
|
168
|
+
// QdrantVectorStore.deleteKnowledge deletes by point ID.
|
|
169
|
+
// To delete ALL points for a repo we use the scroll+delete pattern via
|
|
170
|
+
// the Qdrant client's filter-based delete which the QdrantVectorStore
|
|
171
|
+
// exposes as deleteKnowledgeByRepo.
|
|
172
|
+
//
|
|
173
|
+
// The QdrantVectorStore may not have a deleteKnowledgeByRepo method yet.
|
|
174
|
+
// We call it if present; otherwise we fall through to the no-op with a
|
|
175
|
+
// log so the caller knows why old points were not removed.
|
|
176
|
+
const store = this.vectorStore;
|
|
177
|
+
if (typeof store.deleteKnowledgeByRepo === 'function') {
|
|
178
|
+
await store.deleteKnowledgeByRepo(repoId);
|
|
179
|
+
logger.debug('KnowledgeHydrator.removeRepo: deleted existing points', { repoId });
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
// Fallback: the store does not yet expose bulk-delete-by-repo for the
|
|
183
|
+
// knowledge collection. Log so the operator is aware that stale items
|
|
184
|
+
// may accumulate. This is non-fatal — upserts will overwrite matching
|
|
185
|
+
// IDs and only truly removed items will remain as orphans.
|
|
186
|
+
logger.debug('KnowledgeHydrator.removeRepo: deleteKnowledgeByRepo not available, ' +
|
|
187
|
+
'orphaned points may remain for removed items. Upserts will overwrite matching IDs.', { repoId });
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
catch (err) {
|
|
191
|
+
// Graceful degradation: if Qdrant is down or the delete fails, hydration
|
|
192
|
+
// should still proceed with upserts — better to have stale items than
|
|
193
|
+
// to completely block registration.
|
|
194
|
+
logger.warn('KnowledgeHydrator.removeRepo: delete failed (continuing)', {
|
|
195
|
+
repoId,
|
|
196
|
+
error: String(err),
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// ---------------------------------------------------------------------------
|
|
201
|
+
// Private helpers
|
|
202
|
+
// ---------------------------------------------------------------------------
|
|
203
|
+
/**
|
|
204
|
+
* Derive category string from item id prefix.
|
|
205
|
+
* Mirrors the logic in KnowledgeYamlStore._categoryFromItem().
|
|
206
|
+
*/
|
|
207
|
+
_categoryFromId(id) {
|
|
208
|
+
const lower = id.toLowerCase();
|
|
209
|
+
if (lower.startsWith('gotcha'))
|
|
210
|
+
return 'gotcha';
|
|
211
|
+
if (lower.startsWith('pattern'))
|
|
212
|
+
return 'pattern';
|
|
213
|
+
if (lower.startsWith('decision'))
|
|
214
|
+
return 'decision';
|
|
215
|
+
if (lower.startsWith('convention'))
|
|
216
|
+
return 'convention';
|
|
217
|
+
return 'pattern';
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=hydrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydrator.js","sourceRoot":"","sources":["../../src/knowledge/hydrator.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,6EAA6E;AAC7E,2EAA2E;AAC3E,EAAE;AACF,gBAAgB;AAChB,4EAA4E;AAC5E,2DAA2D;AAC3D,2EAA2E;AAC3E,4EAA4E;AAC5E,kDAAkD;AAClD,4EAA4E;AAC5E,0EAA0E;AAC1E,oCAAoC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,C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AC;YACpF,CAAC;iBAAM,CAAC;gBACN,sEAAsE;gBACtE,sEAAsE;gBACtE,sEAAsE;gBACtE,2DAA2D;gBAC3D,MAAM,CAAC,KAAK,CACV,qEAAqE;oBACrE,oFAAoF,EACpF,EAAE,MAAM,EAAE,CACX,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,yEAAyE;YACzE,sEAAsE;YACtE,oCAAoC;YACpC,MAAM,CAAC,IAAI,CAAC,0DAA0D,EAAE;gBACtE,MAAM;gBACN,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC;aACnB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,8EAA8E;IAC9E,kBAAkB;IAClB,8EAA8E;IAE9E;;;OAGG;IACK,eAAe,CAAC,EAAU;QAChC,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;QAC/B,IAAI,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,OAAO,QAAQ,CAAC;QAChD,IAAI,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;QAClD,IAAI,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC;YAAE,OAAO,UAAU,CAAC;QACpD,IAAI,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC;YAAE,OAAO,YAAY,CAAC;QACxD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { PipelineDB } from '../storage/sqlite.js';
|
|
2
|
+
import { KnowledgeHydrator } from './hydrator.js';
|
|
3
|
+
import type { Repo, ForgeManifest, SharingMode } from '../util/types.js';
|
|
4
|
+
export interface RegisterOptions {
|
|
5
|
+
auto?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Matches the spec B5 return shape (snake_case for MCP tool compat).
|
|
9
|
+
*/
|
|
10
|
+
export interface RegisterResult {
|
|
11
|
+
repo_id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
path: string;
|
|
14
|
+
remote?: string;
|
|
15
|
+
stack: string[];
|
|
16
|
+
sharing: string;
|
|
17
|
+
newly_registered: boolean;
|
|
18
|
+
knowledge_items_loaded: number;
|
|
19
|
+
}
|
|
20
|
+
export interface InitOptions {
|
|
21
|
+
name: string;
|
|
22
|
+
stack: string[];
|
|
23
|
+
sharing?: SharingMode;
|
|
24
|
+
org?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface RegisterResultCamel {
|
|
27
|
+
repoId: string;
|
|
28
|
+
name: string;
|
|
29
|
+
path: string;
|
|
30
|
+
remote?: string;
|
|
31
|
+
stack: string[];
|
|
32
|
+
sharing: SharingMode;
|
|
33
|
+
newlyRegistered: boolean;
|
|
34
|
+
knowledgeItemsLoaded: number;
|
|
35
|
+
}
|
|
36
|
+
export declare class RepoRegistry {
|
|
37
|
+
private readonly db;
|
|
38
|
+
private readonly hydrator?;
|
|
39
|
+
constructor(db: PipelineDB, hydrator?: KnowledgeHydrator | undefined);
|
|
40
|
+
/**
|
|
41
|
+
* Register (or update) a repo at `path`.
|
|
42
|
+
*
|
|
43
|
+
* Requires a .forge/manifest.yaml to exist at <path>/.forge/manifest.yaml.
|
|
44
|
+
* If the manifest is absent, throws an error describing the fix.
|
|
45
|
+
*
|
|
46
|
+
* Steps:
|
|
47
|
+
* 1. Read manifest from .forge/manifest.yaml
|
|
48
|
+
* 2. Resolve git origin URL
|
|
49
|
+
* 3. Generate repo_id from origin URL (or path hash if no remote)
|
|
50
|
+
* 4. Upsert into SQLite repos table
|
|
51
|
+
* 5. Compute knowledge content hash and compare with stored hash
|
|
52
|
+
* 6. If hash changed (or newly registered), hydrate Qdrant knowledge collection
|
|
53
|
+
* 7. Return RegisterResult
|
|
54
|
+
*/
|
|
55
|
+
register(path: string, options?: RegisterOptions): Promise<RegisterResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Initialize the .forge/ directory in a repo at `repoPath`.
|
|
58
|
+
* Creates:
|
|
59
|
+
* .forge/manifest.yaml — from provided manifest
|
|
60
|
+
* .forge/knowledge/gotchas.yaml
|
|
61
|
+
* .forge/knowledge/patterns.yaml
|
|
62
|
+
* .forge/knowledge/decisions.yaml
|
|
63
|
+
* .forge/knowledge/conventions.yaml
|
|
64
|
+
* .forge/.gitignore — excludes .forge.db
|
|
65
|
+
*
|
|
66
|
+
* All files are created only if they do not already exist.
|
|
67
|
+
* Returns { forgePath, filesCreated } listing the paths that were created.
|
|
68
|
+
*/
|
|
69
|
+
initForge(repoPath: string, manifest: ForgeManifest): {
|
|
70
|
+
forgePath: string;
|
|
71
|
+
filesCreated: string[];
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Read and parse .forge/manifest.yaml from `forgePath` (the .forge/ directory).
|
|
75
|
+
* Returns null if the file is absent or unparseable.
|
|
76
|
+
*
|
|
77
|
+
* NOTE: This method takes the .forge/ directory path, NOT the repo root.
|
|
78
|
+
* Callers that have the repo root should pass join(repoPath, '.forge').
|
|
79
|
+
*/
|
|
80
|
+
readManifest(forgePath: string): ForgeManifest | null;
|
|
81
|
+
/**
|
|
82
|
+
* Resolve the git remote origin URL for the repo at `repoPath`.
|
|
83
|
+
* Uses `git -C <repoPath> config --get remote.origin.url`.
|
|
84
|
+
* Returns null if the path is not a git repo or has no origin.
|
|
85
|
+
*/
|
|
86
|
+
resolveGitOrigin(repoPath: string): string | null;
|
|
87
|
+
/**
|
|
88
|
+
* Generate a stable repo ID from a remote URL or local path.
|
|
89
|
+
* Uses SHA-256, returns first 12 hex characters.
|
|
90
|
+
*
|
|
91
|
+
* For remote URLs: normalises to strip .git suffix and trailing slashes
|
|
92
|
+
* before hashing so that git@github.com:org/repo and
|
|
93
|
+
* https://github.com/org/repo.git produce the same ID.
|
|
94
|
+
*/
|
|
95
|
+
generateRepoId(remoteOrPath: string): string;
|
|
96
|
+
/**
|
|
97
|
+
* Get a registered repo by ID.
|
|
98
|
+
* Returns null if not found.
|
|
99
|
+
*/
|
|
100
|
+
getRepo(repoId: string): Repo | null;
|
|
101
|
+
/**
|
|
102
|
+
* List all registered repos sorted by last_seen_at descending.
|
|
103
|
+
* Returns repos augmented with knowledge_count (total items in Qdrant).
|
|
104
|
+
* knowledge_count is always 0 when Qdrant is not available — it is a
|
|
105
|
+
* best-effort annotation, not a blocking query.
|
|
106
|
+
*/
|
|
107
|
+
listRepos(): Array<Repo & {
|
|
108
|
+
knowledge_count: number;
|
|
109
|
+
}>;
|
|
110
|
+
/**
|
|
111
|
+
* Update the last_seen_at timestamp for a repo.
|
|
112
|
+
* Called on session-start to record that the repo is actively being used.
|
|
113
|
+
*/
|
|
114
|
+
touch(repoId: string): void;
|
|
115
|
+
/**
|
|
116
|
+
* Remove a repo from the registry.
|
|
117
|
+
* Does NOT remove Qdrant knowledge items — call hydrator.removeRepo() separately
|
|
118
|
+
* if you want to clean up vector data.
|
|
119
|
+
*/
|
|
120
|
+
removeRepo(repoId: string): void;
|
|
121
|
+
/** Whether a .forge/ directory exists in the given repo path. */
|
|
122
|
+
forgeDirectoryExists(repoPath?: string): boolean;
|
|
123
|
+
/** Find a registered repo by its filesystem path. */
|
|
124
|
+
findRepoByPath(repoPath: string): Repo | null;
|
|
125
|
+
private _parseManifestFile;
|
|
126
|
+
private _repoNameFromPath;
|
|
127
|
+
private _rowToRepo;
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/knowledge/registry.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAW,aAAa,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAoBlF,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,OAAO,CA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