codehere 0.3.0 → 0.5.0-alpha
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 +1 -1
- package/README.md +329 -65
- package/dist/application/agents/documentation-agent.d.ts +24 -0
- package/dist/application/agents/documentation-agent.d.ts.map +1 -0
- package/dist/application/agents/documentation-agent.js +399 -0
- package/dist/application/agents/documentation-agent.js.map +1 -0
- package/dist/application/agents/execution-agent.d.ts +11 -0
- package/dist/application/agents/execution-agent.d.ts.map +1 -1
- package/dist/application/agents/execution-agent.js +289 -80
- package/dist/application/agents/execution-agent.js.map +1 -1
- package/dist/application/agents/multi-agent-orchestrator.d.ts +4 -0
- package/dist/application/agents/multi-agent-orchestrator.d.ts.map +1 -1
- package/dist/application/agents/multi-agent-orchestrator.js +95 -2
- package/dist/application/agents/multi-agent-orchestrator.js.map +1 -1
- package/dist/application/agents/planning-agent.d.ts +3 -0
- package/dist/application/agents/planning-agent.d.ts.map +1 -1
- package/dist/application/agents/planning-agent.js +151 -71
- package/dist/application/agents/planning-agent.js.map +1 -1
- package/dist/application/agents/product-requirements-agent.d.ts +21 -0
- package/dist/application/agents/product-requirements-agent.d.ts.map +1 -0
- package/dist/application/agents/product-requirements-agent.js +247 -0
- package/dist/application/agents/product-requirements-agent.js.map +1 -0
- package/dist/application/agents/validation-agent.d.ts +5 -1
- package/dist/application/agents/validation-agent.d.ts.map +1 -1
- package/dist/application/agents/validation-agent.js +156 -21
- package/dist/application/agents/validation-agent.js.map +1 -1
- package/dist/application/reasoning/multi-model-planning-strategy.d.ts +21 -0
- package/dist/application/reasoning/multi-model-planning-strategy.d.ts.map +1 -0
- package/dist/application/reasoning/multi-model-planning-strategy.js +158 -0
- package/dist/application/reasoning/multi-model-planning-strategy.js.map +1 -0
- package/dist/application/reasoning/reasoning-config.d.ts +15 -0
- package/dist/application/reasoning/reasoning-config.d.ts.map +1 -0
- package/dist/application/reasoning/reasoning-config.js +50 -0
- package/dist/application/reasoning/reasoning-config.js.map +1 -0
- package/dist/application/reasoning/reasoning-orchestrator.d.ts +18 -0
- package/dist/application/reasoning/reasoning-orchestrator.d.ts.map +1 -0
- package/dist/application/reasoning/reasoning-orchestrator.js +170 -0
- package/dist/application/reasoning/reasoning-orchestrator.js.map +1 -0
- package/dist/application/reasoning/reasoning-strategy.interface.d.ts +24 -0
- package/dist/application/reasoning/reasoning-strategy.interface.d.ts.map +1 -0
- package/dist/application/reasoning/reasoning-strategy.interface.js +6 -0
- package/dist/application/reasoning/reasoning-strategy.interface.js.map +1 -0
- package/dist/application/reasoning/role-provider-resolver.d.ts +36 -0
- package/dist/application/reasoning/role-provider-resolver.d.ts.map +1 -0
- package/dist/application/reasoning/role-provider-resolver.js +74 -0
- package/dist/application/reasoning/role-provider-resolver.js.map +1 -0
- package/dist/application/reasoning/simple-planning-strategy.d.ts +22 -0
- package/dist/application/reasoning/simple-planning-strategy.d.ts.map +1 -0
- package/dist/application/reasoning/simple-planning-strategy.js +217 -0
- package/dist/application/reasoning/simple-planning-strategy.js.map +1 -0
- package/dist/application/reasoning/types.d.ts +65 -0
- package/dist/application/reasoning/types.d.ts.map +1 -0
- package/dist/application/reasoning/types.js +6 -0
- package/dist/application/reasoning/types.js.map +1 -0
- package/dist/application/reasoning/validator-strategy.d.ts +56 -0
- package/dist/application/reasoning/validator-strategy.d.ts.map +1 -0
- package/dist/application/reasoning/validator-strategy.js +103 -0
- package/dist/application/reasoning/validator-strategy.js.map +1 -0
- package/dist/application/services/dependency-container.d.ts +46 -2
- package/dist/application/services/dependency-container.d.ts.map +1 -1
- package/dist/application/services/dependency-container.js +198 -8
- package/dist/application/services/dependency-container.js.map +1 -1
- package/dist/application/services/intelligent-router.d.ts +19 -0
- package/dist/application/services/intelligent-router.d.ts.map +1 -1
- package/dist/application/services/intelligent-router.js +393 -91
- package/dist/application/services/intelligent-router.js.map +1 -1
- package/dist/application/use-cases/ask-question-use-case.d.ts +20 -0
- package/dist/application/use-cases/ask-question-use-case.d.ts.map +1 -1
- package/dist/application/use-cases/ask-question-use-case.js +129 -49
- package/dist/application/use-cases/ask-question-use-case.js.map +1 -1
- package/dist/application/use-cases/edit-file-use-case.d.ts.map +1 -1
- package/dist/application/use-cases/edit-file-use-case.js +16 -1
- package/dist/application/use-cases/edit-file-use-case.js.map +1 -1
- package/dist/application/use-cases/planning-use-case.d.ts +14 -1
- package/dist/application/use-cases/planning-use-case.d.ts.map +1 -1
- package/dist/application/use-cases/planning-use-case.js +109 -2
- package/dist/application/use-cases/planning-use-case.js.map +1 -1
- package/dist/domain/entities/documentation.d.ts +35 -0
- package/dist/domain/entities/documentation.d.ts.map +1 -0
- package/dist/domain/entities/documentation.js +6 -0
- package/dist/domain/entities/documentation.js.map +1 -0
- package/dist/domain/entities/memory.d.ts.map +1 -1
- package/dist/domain/entities/product-requirements.d.ts +50 -0
- package/dist/domain/entities/product-requirements.d.ts.map +1 -0
- package/dist/domain/entities/product-requirements.js +6 -0
- package/dist/domain/entities/product-requirements.js.map +1 -0
- package/dist/domain/entities/task.d.ts +152 -0
- package/dist/domain/entities/task.d.ts.map +1 -0
- package/dist/domain/entities/task.js +61 -0
- package/dist/domain/entities/task.js.map +1 -0
- package/dist/domain/errors/embeddings-not-found-error.d.ts +9 -0
- package/dist/domain/errors/embeddings-not-found-error.d.ts.map +1 -0
- package/dist/domain/errors/embeddings-not-found-error.js +13 -0
- package/dist/domain/errors/embeddings-not-found-error.js.map +1 -0
- package/dist/domain/interfaces/agent.interface.d.ts +15 -0
- package/dist/domain/interfaces/agent.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/agent.interface.js +6 -0
- package/dist/domain/interfaces/agent.interface.js.map +1 -0
- package/dist/domain/interfaces/embedding-repository.interface.d.ts +5 -0
- package/dist/domain/interfaces/embedding-repository.interface.d.ts.map +1 -1
- package/dist/domain/services/environment-mode-manager.d.ts +12 -0
- package/dist/domain/services/environment-mode-manager.d.ts.map +1 -0
- package/dist/domain/services/environment-mode-manager.js +22 -0
- package/dist/domain/services/environment-mode-manager.js.map +1 -0
- package/dist/domain/services/query-intent-classifier.d.ts.map +1 -1
- package/dist/domain/services/query-intent-classifier.js +20 -1
- package/dist/domain/services/query-intent-classifier.js.map +1 -1
- package/dist/domain/services/risk-tier-detector.d.ts +17 -0
- package/dist/domain/services/risk-tier-detector.d.ts.map +1 -0
- package/dist/domain/services/risk-tier-detector.js +78 -0
- package/dist/domain/services/risk-tier-detector.js.map +1 -0
- package/dist/embed.d.ts.map +1 -1
- package/dist/embed.js +18 -8
- package/dist/embed.js.map +1 -1
- package/dist/formatter.d.ts.map +1 -1
- package/dist/formatter.js +10 -3
- package/dist/formatter.js.map +1 -1
- package/dist/index.js +494 -167
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/ai/cohere-ai-service.d.ts.map +1 -1
- package/dist/infrastructure/ai/cohere-ai-service.js +19 -6
- package/dist/infrastructure/ai/cohere-ai-service.js.map +1 -1
- package/dist/infrastructure/ai/fake-ai-service.d.ts +22 -0
- package/dist/infrastructure/ai/fake-ai-service.d.ts.map +1 -0
- package/dist/infrastructure/ai/fake-ai-service.js +59 -0
- package/dist/infrastructure/ai/fake-ai-service.js.map +1 -0
- package/dist/infrastructure/ai/provider-ai-service.d.ts +59 -0
- package/dist/infrastructure/ai/provider-ai-service.d.ts.map +1 -0
- package/dist/infrastructure/ai/provider-ai-service.js +477 -0
- package/dist/infrastructure/ai/provider-ai-service.js.map +1 -0
- package/dist/infrastructure/cache/embedding-cache.d.ts +13 -1
- package/dist/infrastructure/cache/embedding-cache.d.ts.map +1 -1
- package/dist/infrastructure/cache/embedding-cache.js +80 -9
- package/dist/infrastructure/cache/embedding-cache.js.map +1 -1
- package/dist/infrastructure/cache/query-result-cache.d.ts +14 -55
- package/dist/infrastructure/cache/query-result-cache.d.ts.map +1 -1
- package/dist/infrastructure/cache/query-result-cache.js +40 -112
- package/dist/infrastructure/cache/query-result-cache.js.map +1 -1
- package/dist/infrastructure/cache/response-cache.d.ts +18 -0
- package/dist/infrastructure/cache/response-cache.d.ts.map +1 -0
- package/dist/infrastructure/cache/response-cache.js +48 -0
- package/dist/infrastructure/cache/response-cache.js.map +1 -0
- package/dist/infrastructure/cache/security-scan-cache.d.ts +8 -49
- package/dist/infrastructure/cache/security-scan-cache.d.ts.map +1 -1
- package/dist/infrastructure/cache/security-scan-cache.js +25 -102
- package/dist/infrastructure/cache/security-scan-cache.js.map +1 -1
- package/dist/infrastructure/completion/bash-completion.d.ts +2 -3
- package/dist/infrastructure/completion/bash-completion.d.ts.map +1 -1
- package/dist/infrastructure/completion/bash-completion.js +11 -87
- package/dist/infrastructure/completion/bash-completion.js.map +1 -1
- package/dist/infrastructure/completion/fish-completion.d.ts +2 -3
- package/dist/infrastructure/completion/fish-completion.d.ts.map +1 -1
- package/dist/infrastructure/completion/fish-completion.js +15 -58
- package/dist/infrastructure/completion/fish-completion.js.map +1 -1
- package/dist/infrastructure/completion/zsh-completion.d.ts +2 -3
- package/dist/infrastructure/completion/zsh-completion.d.ts.map +1 -1
- package/dist/infrastructure/completion/zsh-completion.js +18 -73
- package/dist/infrastructure/completion/zsh-completion.js.map +1 -1
- package/dist/infrastructure/config/config-manager.d.ts +10 -0
- package/dist/infrastructure/config/config-manager.d.ts.map +1 -1
- package/dist/infrastructure/config/config-manager.js +13 -2
- package/dist/infrastructure/config/config-manager.js.map +1 -1
- package/dist/infrastructure/context/conversation-context.d.ts +54 -0
- package/dist/infrastructure/context/conversation-context.d.ts.map +1 -0
- package/dist/infrastructure/context/conversation-context.js +129 -0
- package/dist/infrastructure/context/conversation-context.js.map +1 -0
- package/dist/infrastructure/context/session-manager.d.ts +42 -0
- package/dist/infrastructure/context/session-manager.d.ts.map +1 -0
- package/dist/infrastructure/context/session-manager.js +94 -0
- package/dist/infrastructure/context/session-manager.js.map +1 -0
- package/dist/infrastructure/cost/cost-tracker.d.ts +1 -0
- package/dist/infrastructure/cost/cost-tracker.d.ts.map +1 -1
- package/dist/infrastructure/cost/cost-tracker.js +12 -5
- package/dist/infrastructure/cost/cost-tracker.js.map +1 -1
- package/dist/infrastructure/governance/nist-ai-rmf.d.ts +6 -8
- package/dist/infrastructure/governance/nist-ai-rmf.d.ts.map +1 -1
- package/dist/infrastructure/governance/nist-ai-rmf.js +6 -8
- package/dist/infrastructure/governance/nist-ai-rmf.js.map +1 -1
- package/dist/infrastructure/governance/policy-as-code.d.ts +6 -8
- package/dist/infrastructure/governance/policy-as-code.d.ts.map +1 -1
- package/dist/infrastructure/governance/policy-as-code.js +6 -8
- package/dist/infrastructure/governance/policy-as-code.js.map +1 -1
- package/dist/infrastructure/governance/prompt-to-code-lineage.d.ts +7 -9
- package/dist/infrastructure/governance/prompt-to-code-lineage.d.ts.map +1 -1
- package/dist/infrastructure/governance/prompt-to-code-lineage.js +7 -9
- package/dist/infrastructure/governance/prompt-to-code-lineage.js.map +1 -1
- package/dist/infrastructure/protocols/a2a-metadata.js +1 -1
- package/dist/infrastructure/protocols/mcp-oauth.js +1 -1
- package/dist/infrastructure/providers/cohere-provider.d.ts +39 -0
- package/dist/infrastructure/providers/cohere-provider.d.ts.map +1 -0
- package/dist/infrastructure/providers/cohere-provider.js +444 -0
- package/dist/infrastructure/providers/cohere-provider.js.map +1 -0
- package/dist/infrastructure/providers/fake-provider.d.ts +43 -0
- package/dist/infrastructure/providers/fake-provider.d.ts.map +1 -0
- package/dist/infrastructure/providers/fake-provider.js +130 -0
- package/dist/infrastructure/providers/fake-provider.js.map +1 -0
- package/dist/infrastructure/providers/local-llm-provider.d.ts +49 -0
- package/dist/infrastructure/providers/local-llm-provider.d.ts.map +1 -0
- package/dist/infrastructure/providers/local-llm-provider.js +330 -0
- package/dist/infrastructure/providers/local-llm-provider.js.map +1 -0
- package/dist/infrastructure/providers/model-config.types.d.ts +70 -0
- package/dist/infrastructure/providers/model-config.types.d.ts.map +1 -0
- package/dist/infrastructure/providers/model-config.types.js +9 -0
- package/dist/infrastructure/providers/model-config.types.js.map +1 -0
- package/dist/infrastructure/providers/model-provider.interface.d.ts +113 -0
- package/dist/infrastructure/providers/model-provider.interface.d.ts.map +1 -0
- package/dist/infrastructure/providers/model-provider.interface.js +8 -0
- package/dist/infrastructure/providers/model-provider.interface.js.map +1 -0
- package/dist/infrastructure/providers/openai-provider.d.ts +38 -0
- package/dist/infrastructure/providers/openai-provider.d.ts.map +1 -0
- package/dist/infrastructure/providers/openai-provider.js +413 -0
- package/dist/infrastructure/providers/openai-provider.js.map +1 -0
- package/dist/infrastructure/providers/openrouter-provider.d.ts +42 -0
- package/dist/infrastructure/providers/openrouter-provider.d.ts.map +1 -0
- package/dist/infrastructure/providers/openrouter-provider.js +401 -0
- package/dist/infrastructure/providers/openrouter-provider.js.map +1 -0
- package/dist/infrastructure/providers/operation-provider-resolver.d.ts +48 -0
- package/dist/infrastructure/providers/operation-provider-resolver.d.ts.map +1 -0
- package/dist/infrastructure/providers/operation-provider-resolver.js +131 -0
- package/dist/infrastructure/providers/operation-provider-resolver.js.map +1 -0
- package/dist/infrastructure/providers/provider-config-loader.d.ts +37 -0
- package/dist/infrastructure/providers/provider-config-loader.d.ts.map +1 -0
- package/dist/infrastructure/providers/provider-config-loader.js +120 -0
- package/dist/infrastructure/providers/provider-config-loader.js.map +1 -0
- package/dist/infrastructure/providers/provider-registry.d.ts +53 -0
- package/dist/infrastructure/providers/provider-registry.d.ts.map +1 -0
- package/dist/infrastructure/providers/provider-registry.js +88 -0
- package/dist/infrastructure/providers/provider-registry.js.map +1 -0
- package/dist/infrastructure/security/input-validator.d.ts.map +1 -1
- package/dist/infrastructure/security/input-validator.js +19 -6
- package/dist/infrastructure/security/input-validator.js.map +1 -1
- package/dist/infrastructure/serialization/toon-serializer.d.ts +45 -0
- package/dist/infrastructure/serialization/toon-serializer.d.ts.map +1 -0
- package/dist/infrastructure/serialization/toon-serializer.js +119 -0
- package/dist/infrastructure/serialization/toon-serializer.js.map +1 -0
- package/dist/infrastructure/storage/embeddings-path.d.ts +18 -0
- package/dist/infrastructure/storage/embeddings-path.d.ts.map +1 -0
- package/dist/infrastructure/storage/embeddings-path.js +37 -0
- package/dist/infrastructure/storage/embeddings-path.js.map +1 -0
- package/dist/infrastructure/storage/plan-repository.d.ts +2 -0
- package/dist/infrastructure/storage/plan-repository.d.ts.map +1 -1
- package/dist/infrastructure/storage/plan-repository.js +36 -73
- package/dist/infrastructure/storage/plan-repository.js.map +1 -1
- package/dist/infrastructure/storage/sqlite-embedding-repository.d.ts +10 -1
- package/dist/infrastructure/storage/sqlite-embedding-repository.d.ts.map +1 -1
- package/dist/infrastructure/storage/sqlite-embedding-repository.js +37 -3
- package/dist/infrastructure/storage/sqlite-embedding-repository.js.map +1 -1
- package/dist/infrastructure/storage/task-helpers.d.ts +69 -0
- package/dist/infrastructure/storage/task-helpers.d.ts.map +1 -0
- package/dist/infrastructure/storage/task-helpers.js +197 -0
- package/dist/infrastructure/storage/task-helpers.js.map +1 -0
- package/dist/infrastructure/storage/task-repository.d.ts +68 -0
- package/dist/infrastructure/storage/task-repository.d.ts.map +1 -0
- package/dist/infrastructure/storage/task-repository.js +216 -0
- package/dist/infrastructure/storage/task-repository.js.map +1 -0
- package/dist/infrastructure/telemetry/telemetry-service.d.ts +74 -0
- package/dist/infrastructure/telemetry/telemetry-service.d.ts.map +1 -0
- package/dist/infrastructure/telemetry/telemetry-service.js +167 -0
- package/dist/infrastructure/telemetry/telemetry-service.js.map +1 -0
- package/dist/infrastructure/ux/bi-directional-learning.d.ts +22 -0
- package/dist/infrastructure/ux/bi-directional-learning.d.ts.map +1 -1
- package/dist/infrastructure/ux/bi-directional-learning.js +144 -7
- package/dist/infrastructure/ux/bi-directional-learning.js.map +1 -1
- package/dist/infrastructure/ux/capability-boundaries.d.ts +22 -0
- package/dist/infrastructure/ux/capability-boundaries.d.ts.map +1 -0
- package/dist/infrastructure/ux/capability-boundaries.js +42 -0
- package/dist/infrastructure/ux/capability-boundaries.js.map +1 -0
- package/dist/infrastructure/ux/comprehensive-formatter.d.ts +21 -0
- package/dist/infrastructure/ux/comprehensive-formatter.d.ts.map +1 -0
- package/dist/infrastructure/ux/comprehensive-formatter.js +117 -0
- package/dist/infrastructure/ux/comprehensive-formatter.js.map +1 -0
- package/dist/infrastructure/ux/contextual-feature-discovery.d.ts +5 -18
- package/dist/infrastructure/ux/contextual-feature-discovery.d.ts.map +1 -1
- package/dist/infrastructure/ux/contextual-feature-discovery.js +5 -139
- package/dist/infrastructure/ux/contextual-feature-discovery.js.map +1 -1
- package/dist/infrastructure/ux/feature-discovery.d.ts +3 -33
- package/dist/infrastructure/ux/feature-discovery.d.ts.map +1 -1
- package/dist/infrastructure/ux/feature-discovery.js +5 -181
- package/dist/infrastructure/ux/feature-discovery.js.map +1 -1
- package/dist/infrastructure/ux/feedback-prompt.d.ts +26 -0
- package/dist/infrastructure/ux/feedback-prompt.d.ts.map +1 -0
- package/dist/infrastructure/ux/feedback-prompt.js +45 -0
- package/dist/infrastructure/ux/feedback-prompt.js.map +1 -0
- package/dist/infrastructure/ux/hitl-review-portal.d.ts.map +1 -1
- package/dist/infrastructure/ux/hitl-review-portal.js +4 -1
- package/dist/infrastructure/ux/hitl-review-portal.js.map +1 -1
- package/dist/infrastructure/ux/hitl-validation.d.ts +35 -0
- package/dist/infrastructure/ux/hitl-validation.d.ts.map +1 -1
- package/dist/infrastructure/ux/hitl-validation.js +86 -0
- package/dist/infrastructure/ux/hitl-validation.js.map +1 -1
- package/dist/infrastructure/ux/progress-indicator.d.ts +5 -6
- package/dist/infrastructure/ux/progress-indicator.d.ts.map +1 -1
- package/dist/infrastructure/ux/progress-indicator.js +36 -41
- package/dist/infrastructure/ux/progress-indicator.js.map +1 -1
- package/dist/infrastructure/ux/proportional-friction.d.ts +73 -0
- package/dist/infrastructure/ux/proportional-friction.d.ts.map +1 -0
- package/dist/infrastructure/ux/proportional-friction.js +200 -0
- package/dist/infrastructure/ux/proportional-friction.js.map +1 -0
- package/dist/infrastructure/ux/review-checkpoint.d.ts +3 -1
- package/dist/infrastructure/ux/review-checkpoint.d.ts.map +1 -1
- package/dist/infrastructure/ux/review-checkpoint.js +33 -80
- package/dist/infrastructure/ux/review-checkpoint.js.map +1 -1
- package/dist/infrastructure/ux/staged-feature-intro.d.ts +14 -39
- package/dist/infrastructure/ux/staged-feature-intro.d.ts.map +1 -1
- package/dist/infrastructure/ux/staged-feature-intro.js +12 -132
- package/dist/infrastructure/ux/staged-feature-intro.js.map +1 -1
- package/dist/infrastructure/ux/syntax-highlighter.d.ts +1 -2
- package/dist/infrastructure/ux/syntax-highlighter.d.ts.map +1 -1
- package/dist/infrastructure/ux/syntax-highlighter.js +67 -148
- package/dist/infrastructure/ux/syntax-highlighter.js.map +1 -1
- package/dist/infrastructure/validation/agent-feedback.d.ts +51 -0
- package/dist/infrastructure/validation/agent-feedback.d.ts.map +1 -0
- package/dist/infrastructure/validation/agent-feedback.js +55 -0
- package/dist/infrastructure/validation/agent-feedback.js.map +1 -0
- package/dist/infrastructure/validation/agent-validation-helper.d.ts +75 -0
- package/dist/infrastructure/validation/agent-validation-helper.d.ts.map +1 -0
- package/dist/infrastructure/validation/agent-validation-helper.js +137 -0
- package/dist/infrastructure/validation/agent-validation-helper.js.map +1 -0
- package/dist/infrastructure/validation/feedback-stats.d.ts +99 -0
- package/dist/infrastructure/validation/feedback-stats.d.ts.map +1 -0
- package/dist/infrastructure/validation/feedback-stats.js +173 -0
- package/dist/infrastructure/validation/feedback-stats.js.map +1 -0
- package/dist/infrastructure/validation/review-handler.d.ts +26 -0
- package/dist/infrastructure/validation/review-handler.d.ts.map +1 -0
- package/dist/infrastructure/validation/review-handler.js +40 -0
- package/dist/infrastructure/validation/review-handler.js.map +1 -0
- package/dist/infrastructure/validation/summary-aggregator.d.ts +45 -0
- package/dist/infrastructure/validation/summary-aggregator.d.ts.map +1 -0
- package/dist/infrastructure/validation/summary-aggregator.js +70 -0
- package/dist/infrastructure/validation/summary-aggregator.js.map +1 -0
- package/dist/infrastructure/validation/summary-extractor.d.ts +24 -0
- package/dist/infrastructure/validation/summary-extractor.d.ts.map +1 -0
- package/dist/infrastructure/validation/summary-extractor.js +45 -0
- package/dist/infrastructure/validation/summary-extractor.js.map +1 -0
- package/dist/infrastructure/validation/trace-summary.d.ts +45 -0
- package/dist/infrastructure/validation/trace-summary.d.ts.map +1 -0
- package/dist/infrastructure/validation/trace-summary.js +52 -0
- package/dist/infrastructure/validation/trace-summary.js.map +1 -0
- package/dist/infrastructure/validation/trust-config.d.ts +27 -0
- package/dist/infrastructure/validation/trust-config.d.ts.map +1 -0
- package/dist/infrastructure/validation/trust-config.js +113 -0
- package/dist/infrastructure/validation/trust-config.js.map +1 -0
- package/dist/infrastructure/xai/attention-visualizer.d.ts +6 -8
- package/dist/infrastructure/xai/attention-visualizer.d.ts.map +1 -1
- package/dist/infrastructure/xai/attention-visualizer.js +6 -8
- package/dist/infrastructure/xai/attention-visualizer.js.map +1 -1
- package/dist/infrastructure/xai/cot-visualizer.d.ts +6 -9
- package/dist/infrastructure/xai/cot-visualizer.d.ts.map +1 -1
- package/dist/infrastructure/xai/cot-visualizer.js +6 -9
- package/dist/infrastructure/xai/cot-visualizer.js.map +1 -1
- package/dist/infrastructure/xai/decision-tree-log.d.ts +6 -10
- package/dist/infrastructure/xai/decision-tree-log.d.ts.map +1 -1
- package/dist/infrastructure/xai/decision-tree-log.js +6 -10
- package/dist/infrastructure/xai/decision-tree-log.js.map +1 -1
- package/dist/infrastructure/xai/interactive-xai.d.ts +6 -8
- package/dist/infrastructure/xai/interactive-xai.d.ts.map +1 -1
- package/dist/infrastructure/xai/interactive-xai.js +6 -8
- package/dist/infrastructure/xai/interactive-xai.js.map +1 -1
- package/dist/infrastructure/xai/uncertainty-quantifier.d.ts +6 -9
- package/dist/infrastructure/xai/uncertainty-quantifier.d.ts.map +1 -1
- package/dist/infrastructure/xai/uncertainty-quantifier.js +6 -9
- package/dist/infrastructure/xai/uncertainty-quantifier.js.map +1 -1
- package/dist/monitoring.d.ts +1 -1
- package/dist/monitoring.d.ts.map +1 -1
- package/dist/monitoring.js +12 -9
- package/dist/monitoring.js.map +1 -1
- package/dist/parallel-processor.d.ts.map +1 -1
- package/dist/parallel-processor.js +124 -45
- package/dist/parallel-processor.js.map +1 -1
- package/dist/presentation/cli/commands/ask-command.d.ts +2 -0
- package/dist/presentation/cli/commands/ask-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/ask-command.js +356 -87
- package/dist/presentation/cli/commands/ask-command.js.map +1 -1
- package/dist/presentation/cli/commands/config-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/config-command.js +22 -8
- package/dist/presentation/cli/commands/config-command.js.map +1 -1
- package/dist/presentation/cli/commands/decision-command.js +23 -6
- package/dist/presentation/cli/commands/decision-command.js.map +1 -1
- package/dist/presentation/cli/commands/docs-command.d.ts +14 -0
- package/dist/presentation/cli/commands/docs-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/docs-command.js +25 -0
- package/dist/presentation/cli/commands/docs-command.js.map +1 -0
- package/dist/presentation/cli/commands/fix-command.d.ts +10 -0
- package/dist/presentation/cli/commands/fix-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/fix-command.js +94 -0
- package/dist/presentation/cli/commands/fix-command.js.map +1 -0
- package/dist/presentation/cli/commands/help-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/help-command.js +23 -1
- package/dist/presentation/cli/commands/help-command.js.map +1 -1
- package/dist/presentation/cli/commands/memory-command.d.ts +17 -0
- package/dist/presentation/cli/commands/memory-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/memory-command.js +252 -0
- package/dist/presentation/cli/commands/memory-command.js.map +1 -0
- package/dist/presentation/cli/commands/models-command.d.ts +13 -0
- package/dist/presentation/cli/commands/models-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/models-command.js +194 -0
- package/dist/presentation/cli/commands/models-command.js.map +1 -0
- package/dist/presentation/cli/commands/orchestrate-command.d.ts +2 -0
- package/dist/presentation/cli/commands/orchestrate-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/orchestrate-command.js +182 -14
- package/dist/presentation/cli/commands/orchestrate-command.js.map +1 -1
- package/dist/presentation/cli/commands/plan-command.d.ts +2 -0
- package/dist/presentation/cli/commands/plan-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/plan-command.js +212 -26
- package/dist/presentation/cli/commands/plan-command.js.map +1 -1
- package/dist/presentation/cli/commands/product-command.d.ts +14 -0
- package/dist/presentation/cli/commands/product-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/product-command.js +22 -0
- package/dist/presentation/cli/commands/product-command.js.map +1 -0
- package/dist/presentation/cli/commands/react-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/react-command.js +8 -2
- package/dist/presentation/cli/commands/react-command.js.map +1 -1
- package/dist/presentation/cli/commands/review-command.d.ts +14 -0
- package/dist/presentation/cli/commands/review-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/review-command.js +173 -0
- package/dist/presentation/cli/commands/review-command.js.map +1 -0
- package/dist/presentation/cli/commands/run-command.d.ts +13 -0
- package/dist/presentation/cli/commands/run-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/run-command.js +188 -0
- package/dist/presentation/cli/commands/run-command.js.map +1 -0
- package/dist/presentation/cli/commands/setup-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/setup-command.js +15 -0
- package/dist/presentation/cli/commands/setup-command.js.map +1 -1
- package/dist/presentation/cli/commands/smart-command.d.ts +3 -1
- package/dist/presentation/cli/commands/smart-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/smart-command.js +165 -11
- package/dist/presentation/cli/commands/smart-command.js.map +1 -1
- package/dist/presentation/cli/commands/status-command.d.ts +14 -0
- package/dist/presentation/cli/commands/status-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/status-command.js +171 -0
- package/dist/presentation/cli/commands/status-command.js.map +1 -0
- package/dist/presentation/cli/commands/suggest-command.d.ts +11 -0
- package/dist/presentation/cli/commands/suggest-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/suggest-command.js +138 -0
- package/dist/presentation/cli/commands/suggest-command.js.map +1 -0
- package/dist/presentation/cli/error-display.d.ts.map +1 -1
- package/dist/presentation/cli/error-display.js +118 -17
- package/dist/presentation/cli/error-display.js.map +1 -1
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +6 -1
- package/dist/search.js.map +1 -1
- package/dist/session.d.ts +1 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +69 -4
- package/dist/session.js.map +1 -1
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +3 -0
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/git-tool.js +7 -7
- package/dist/tools/git-tool.js.map +1 -1
- package/dist/ui.d.ts +11 -0
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +62 -6
- package/dist/ui.js.map +1 -1
- package/package.json +22 -4
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { QueryIntentClassifier } from '../../domain/services/query-intent-classifier.js';
|
|
8
8
|
import { validateQuery } from '../../infrastructure/security/input-validator.js';
|
|
9
|
+
import { executionTracer } from '../../infrastructure/observability/execution-tracer.js';
|
|
10
|
+
import { agentFeedbackManager } from '../../infrastructure/validation/agent-feedback.js';
|
|
11
|
+
import { findCodebaseRoot } from '../../domain/services/codebase-detector.js';
|
|
9
12
|
export class IntelligentRouter {
|
|
10
13
|
intentClassifier;
|
|
11
14
|
aiService;
|
|
@@ -16,104 +19,351 @@ export class IntelligentRouter {
|
|
|
16
19
|
this.memoryStream = memoryStream;
|
|
17
20
|
}
|
|
18
21
|
async route(request) {
|
|
19
|
-
//
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
// Start routing trace
|
|
23
|
+
const codebaseInfo = findCodebaseRoot(process.cwd());
|
|
24
|
+
const routingRunId = executionTracer.startRun('intelligent-router', {
|
|
25
|
+
query: request.query,
|
|
26
|
+
codebaseId: codebaseInfo?.codebaseId || codebaseInfo?.rootPath,
|
|
27
|
+
});
|
|
28
|
+
// Track routing decision data
|
|
29
|
+
let routingDecision;
|
|
30
|
+
try {
|
|
31
|
+
// Validate input
|
|
32
|
+
const validation = validateQuery(request.query);
|
|
33
|
+
if (!validation.valid) {
|
|
34
|
+
executionTracer.endRun();
|
|
35
|
+
return {
|
|
36
|
+
intent: 'error',
|
|
37
|
+
action: 'general',
|
|
38
|
+
result: null,
|
|
39
|
+
success: false,
|
|
40
|
+
error: `Invalid query: ${validation.errors.join(', ')}`,
|
|
41
|
+
routingRunId,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
// Use sanitized query if validation found issues
|
|
45
|
+
let query = (validation.sanitized || request.query).trim();
|
|
46
|
+
// 2. Classify intent FIRST (needed for conversation tracking)
|
|
47
|
+
const classifiedIntent = this.intentClassifier.classify(query);
|
|
48
|
+
// Record intent classification
|
|
49
|
+
executionTracer.trace({
|
|
50
|
+
operationType: 'code_analysis',
|
|
51
|
+
operationName: 'intent_classification',
|
|
52
|
+
input: { query },
|
|
53
|
+
output: { intent: classifiedIntent },
|
|
54
|
+
metadata: {
|
|
55
|
+
classifier: 'QueryIntentClassifier',
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
// Resolve conversation references if we have history
|
|
59
|
+
let resolvedQuery = query;
|
|
60
|
+
let sessionId;
|
|
61
|
+
let lastIntent;
|
|
62
|
+
// PHASE 1 FIX: Get last intent from request context (passed from session)
|
|
63
|
+
// This is the most reliable source since it's the actual conversation history
|
|
64
|
+
if (request.context?.conversationHistory && request.context.conversationHistory.length > 0) {
|
|
65
|
+
const lastHistoryItem = request.context.conversationHistory[request.context.conversationHistory.length - 1];
|
|
66
|
+
lastIntent = lastHistoryItem.intent;
|
|
67
|
+
}
|
|
68
|
+
if (request.context?.conversationHistory && request.context.conversationHistory.length > 0) {
|
|
69
|
+
const { conversationContextManager } = await import('../../infrastructure/context/conversation-context.js');
|
|
70
|
+
sessionId = request.context.sessionId || 'default-session';
|
|
71
|
+
// Resolve references in query (e.g., "it", "that", "the previous")
|
|
72
|
+
resolvedQuery = conversationContextManager.resolveReferences(sessionId, query);
|
|
73
|
+
// Extract entities for context tracking
|
|
74
|
+
const entities = conversationContextManager.extractEntities(resolvedQuery);
|
|
75
|
+
// Store original query turn (will be updated with response after routing)
|
|
76
|
+
conversationContextManager.addTurn(sessionId, query, '', entities, classifiedIntent);
|
|
77
|
+
}
|
|
78
|
+
// Use resolved query for processing
|
|
79
|
+
query = resolvedQuery;
|
|
80
|
+
// 1. MEMORY-AWARE: Retrieve relevant memories to inform routing decision
|
|
81
|
+
let memories = [];
|
|
82
|
+
let memoryInformedIntent = null;
|
|
83
|
+
if (this.memoryStream) {
|
|
84
|
+
try {
|
|
85
|
+
// Retrieve memories relevant to this query
|
|
86
|
+
memories = await this.memoryStream.retrieve(query, 10);
|
|
87
|
+
// If we have memories, use them to inform intent classification
|
|
88
|
+
if (memories.length > 0 && this.aiService) {
|
|
89
|
+
memoryInformedIntent = await this.classifyIntentWithMemory(query, memories);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
// Fallback to basic classification if memory retrieval fails
|
|
94
|
+
console.warn('Memory retrieval failed, using basic classification:', error);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// CRITICAL: Compound instructions (numbered steps) MUST route to Planning Module
|
|
98
|
+
// Check this BEFORE memory-informed intent to prevent override
|
|
99
|
+
const isCompoundInstruction = query.includes('\n') && /\d+\.\s+[^\n]+\n\s*\d+\.\s+/.test(query);
|
|
100
|
+
// Use memory-informed intent ONLY if not a compound instruction
|
|
101
|
+
const intent = isCompoundInstruction && classifiedIntent === 'multi-file-modify'
|
|
102
|
+
? 'multi-file-modify' // Force compound instructions to Planning Module
|
|
103
|
+
: (memoryInformedIntent || classifiedIntent);
|
|
104
|
+
const symbols = this.intentClassifier.extractSymbols(query);
|
|
105
|
+
// Determine which action/agent will be selected based on intent
|
|
106
|
+
const actionMap = {
|
|
107
|
+
'explain': 'explain',
|
|
108
|
+
'multi-file-modify': 'orchestrate',
|
|
109
|
+
'modify': 'edit',
|
|
110
|
+
'debug': 'edit',
|
|
111
|
+
'implement': 'edit',
|
|
112
|
+
'index': 'index',
|
|
113
|
+
'plan': 'plan',
|
|
114
|
+
'find': 'ask',
|
|
115
|
+
'understand': 'ask',
|
|
116
|
+
'general': 'ask',
|
|
28
117
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
118
|
+
const selectedAction = actionMap[intent] || 'ask';
|
|
119
|
+
const selectedAgent = selectedAction === 'orchestrate' ? 'multi-agent-orchestrator' :
|
|
120
|
+
selectedAction === 'plan' ? 'planning-agent' :
|
|
121
|
+
selectedAction === 'react' ? 'react-orchestration' :
|
|
122
|
+
selectedAction === 'edit' ? 'edit-file-use-case' :
|
|
123
|
+
selectedAction === 'explain' ? 'explain-file-use-case' :
|
|
124
|
+
selectedAction === 'index' ? 'index-codebase-use-case' :
|
|
125
|
+
'ask-question-use-case';
|
|
126
|
+
// Calculate confidence score (heuristic)
|
|
127
|
+
let confidence = 0.8; // Default confidence
|
|
128
|
+
if (memoryInformedIntent && memoryInformedIntent === classifiedIntent) {
|
|
129
|
+
confidence = 0.95; // High confidence when memory and classifier agree
|
|
130
|
+
}
|
|
131
|
+
else if (memoryInformedIntent) {
|
|
132
|
+
confidence = 0.85; // Good confidence with memory override
|
|
133
|
+
}
|
|
134
|
+
else if (isCompoundInstruction) {
|
|
135
|
+
confidence = 0.9; // High confidence for compound instructions
|
|
136
|
+
}
|
|
137
|
+
// Build selection reason
|
|
138
|
+
const selectionReason = isCompoundInstruction
|
|
139
|
+
? 'Compound instruction detected - routing to orchestration'
|
|
140
|
+
: memoryInformedIntent && memoryInformedIntent !== classifiedIntent
|
|
141
|
+
? `Memory-informed routing: ${classifiedIntent} → ${memoryInformedIntent}`
|
|
142
|
+
: `Intent classification: ${intent}`;
|
|
143
|
+
// Track alternatives considered
|
|
144
|
+
const alternatives = Object.keys(actionMap)
|
|
145
|
+
.filter(k => actionMap[k] !== selectedAction)
|
|
146
|
+
.map(k => actionMap[k])
|
|
147
|
+
.filter((v, i, arr) => arr.indexOf(v) === i) // Deduplicate
|
|
148
|
+
.slice(0, 3); // Top 3 alternatives
|
|
149
|
+
// Record routing decision
|
|
150
|
+
routingDecision = {
|
|
151
|
+
confidence,
|
|
152
|
+
selectedAgent,
|
|
153
|
+
selectionReason,
|
|
154
|
+
alternatives,
|
|
155
|
+
};
|
|
156
|
+
// Trace routing decision
|
|
157
|
+
executionTracer.trace({
|
|
158
|
+
operationType: 'code_analysis',
|
|
159
|
+
operationName: 'routing_decision',
|
|
160
|
+
input: { query, intent, classifiedIntent, memoryInformedIntent },
|
|
161
|
+
output: { selectedAction, selectedAgent, confidence },
|
|
162
|
+
metadata: {
|
|
163
|
+
intent,
|
|
164
|
+
selectedAction,
|
|
165
|
+
selectedAgent,
|
|
166
|
+
confidence,
|
|
167
|
+
memoryInformed: !!memoryInformedIntent,
|
|
168
|
+
memoriesUsed: memories.length,
|
|
169
|
+
compoundInstruction: isCompoundInstruction,
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
// P0 FIX: Detect conversational follow-ups and skip index check
|
|
173
|
+
// Check if query is conversational (no code keywords, no file paths, questions/statements)
|
|
174
|
+
const hasCodeKeywords = /\b(src|lib|test|\.ts|\.js|\.py|\.java|file|function|class|import|export|require|module|package)\b/i.test(query);
|
|
175
|
+
const isFilePath = /^[A-Z][a-z]+\.(ts|js|py|java|go|rs|rb|php)$/.test(query) || /[\w\/\-\.]+\.(ts|js|tsx|jsx|json|md|yaml|yml|txt|py|go|rs|java|cpp|h|hpp)/.test(query);
|
|
176
|
+
const isQuestion = /^(what|how|where|when|why|can|could|should|would|do|does|is|are|will)\b/i.test(query.trim());
|
|
177
|
+
const isConversationalPhrase = /^(i want|i need|i should|i don't|i can't|let me|help me|what should|how should)\b/i.test(query.trim());
|
|
178
|
+
// P0 FIX: Detect conversational follow-ups - either from history OR from query pattern
|
|
179
|
+
// If query has conversational patterns and no code keywords, treat as conversational regardless of intent
|
|
180
|
+
const isConversationalFollowup = (
|
|
181
|
+
// Pattern-based detection (most reliable)
|
|
182
|
+
(isQuestion || isConversationalPhrase) &&
|
|
183
|
+
!hasCodeKeywords &&
|
|
184
|
+
!isFilePath) || (
|
|
185
|
+
// History-based detection
|
|
186
|
+
(lastIntent === 'plan' || intent === 'plan' || intent === 'general') &&
|
|
187
|
+
!hasCodeKeywords &&
|
|
188
|
+
!isFilePath &&
|
|
189
|
+
(isQuestion || isConversationalPhrase));
|
|
190
|
+
// Debug logging for compound instructions
|
|
191
|
+
if (isCompoundInstruction) {
|
|
192
|
+
console.log(`[IntelligentRouter] Compound instruction detected. Classified: ${classifiedIntent}, Memory: ${memoryInformedIntent}, Using: ${intent}`);
|
|
193
|
+
}
|
|
194
|
+
// 3. Check if indexing is needed
|
|
195
|
+
// CRITICAL: Only require index for code-specific queries (find, understand, explain)
|
|
196
|
+
// Planning, brainstorming, and product queries should work without index
|
|
197
|
+
const needsIndex = await this.checkIfIndexingNeeded(request.context);
|
|
198
|
+
const codeSpecificIntents = ['find', 'understand', 'explain', 'modify', 'debug', 'implement', 'multi-file-modify'];
|
|
199
|
+
// Skip index check for conversational follow-ups and non-code intents
|
|
200
|
+
const requiresIndex = !isConversationalFollowup && needsIndex && codeSpecificIntents.includes(intent);
|
|
201
|
+
// Handle indexing first if needed (only for code-specific queries)
|
|
202
|
+
if (requiresIndex) {
|
|
203
|
+
executionTracer.endRun();
|
|
204
|
+
// Record routing decision feedback
|
|
205
|
+
try {
|
|
206
|
+
agentFeedbackManager.recordFeedback({
|
|
207
|
+
runId: routingRunId,
|
|
208
|
+
agentName: 'intelligent-router',
|
|
209
|
+
operation: 'route',
|
|
210
|
+
query: request.query,
|
|
211
|
+
outcome: 'failure',
|
|
212
|
+
userAction: 'not_required', // Error case - no review flow
|
|
213
|
+
errors: ['Indexing required'],
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
// Non-blocking
|
|
218
|
+
}
|
|
219
|
+
return {
|
|
220
|
+
intent: 'index',
|
|
221
|
+
action: 'index',
|
|
222
|
+
result: { message: 'Indexing required. Please run: codehere index' },
|
|
223
|
+
success: false,
|
|
224
|
+
message: 'Codebase not indexed. Run "codehere index" first, then try again.',
|
|
225
|
+
memoriesUsed: memories.length,
|
|
226
|
+
routingDecision,
|
|
227
|
+
routingRunId,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
// Route based on intent (pass memories for context)
|
|
231
|
+
let routingResult;
|
|
36
232
|
try {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
233
|
+
switch (intent) {
|
|
234
|
+
case 'explain':
|
|
235
|
+
// Use deterministic workflow for faster performance (no ReAct overhead)
|
|
236
|
+
routingResult = await this.handleExplainWithWorkflow(query, symbols, memories);
|
|
237
|
+
break;
|
|
238
|
+
case 'multi-file-modify':
|
|
239
|
+
// Multi-file operations require planning AND execution
|
|
240
|
+
routingResult = await this.handleOrchestrate(query, memories);
|
|
241
|
+
break;
|
|
242
|
+
case 'modify':
|
|
243
|
+
case 'debug': // 'fix' maps to 'debug'
|
|
244
|
+
case 'implement':
|
|
245
|
+
routingResult = await this.handleEdit(query, symbols, memories);
|
|
246
|
+
break;
|
|
247
|
+
case 'index':
|
|
248
|
+
routingResult = await this.handleIndex(query);
|
|
249
|
+
break;
|
|
250
|
+
case 'plan':
|
|
251
|
+
// Complex goals need planning
|
|
252
|
+
routingResult = await this.handlePlan(query, memories);
|
|
253
|
+
// PHASE 1 FIX: Check conversation context - if last intent was non-code, skip code search
|
|
254
|
+
const nonCodeIntents = ['plan', 'general', 'product', 'business'];
|
|
255
|
+
const isFollowUpToNonCode = lastIntent && nonCodeIntents.includes(lastIntent);
|
|
256
|
+
// Also check if query is clearly conversational (not code-related) in empty directory
|
|
257
|
+
const isEmptyDirectory = await this.checkIfIndexingNeeded(request.context);
|
|
258
|
+
const isConversationalQuery = !query.toLowerCase().match(/\b(code|file|function|class|variable|import|export|module|package)\b/);
|
|
259
|
+
// If this is a follow-up to a non-code query OR a conversational query in empty directory, provide conversational response
|
|
260
|
+
if (isFollowUpToNonCode || (isEmptyDirectory && isConversationalQuery)) {
|
|
261
|
+
routingResult = await this.handleConversationalResponse(query, memories, lastIntent);
|
|
262
|
+
}
|
|
263
|
+
break;
|
|
264
|
+
case 'find':
|
|
265
|
+
case 'understand':
|
|
266
|
+
case 'general':
|
|
267
|
+
// CRITICAL FIX: Simple questions should NEVER use ReAct
|
|
268
|
+
// Only use ReAct for truly complex multi-step queries
|
|
269
|
+
// Simple questions (explain, find, understand) go directly to AskQuestionUseCase
|
|
270
|
+
if (this.isSimpleQuestion(query)) {
|
|
271
|
+
routingResult = await this.handleAsk(query, memories);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
// For complex queries, check if ReAct is appropriate
|
|
275
|
+
const shouldUseReAct = this.shouldUseReAct(query, memories);
|
|
276
|
+
if (shouldUseReAct) {
|
|
277
|
+
routingResult = await this.handleReAct(query, memories);
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
// Default to AskQuestion for understand/general queries
|
|
281
|
+
routingResult = await this.handleAsk(query, memories);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
break;
|
|
285
|
+
default:
|
|
286
|
+
// CRITICAL FIX: Default to AskQuestion, not ReAct
|
|
287
|
+
routingResult = await this.handleAsk(query, memories);
|
|
288
|
+
break;
|
|
42
289
|
}
|
|
290
|
+
// Attach routing decision to result
|
|
291
|
+
routingResult.routingDecision = routingDecision;
|
|
292
|
+
routingResult.routingRunId = routingRunId;
|
|
293
|
+
// End routing trace
|
|
294
|
+
executionTracer.endRun();
|
|
295
|
+
// Record routing feedback
|
|
296
|
+
try {
|
|
297
|
+
agentFeedbackManager.recordFeedback({
|
|
298
|
+
runId: routingRunId,
|
|
299
|
+
agentName: 'intelligent-router',
|
|
300
|
+
operation: 'route',
|
|
301
|
+
query: request.query,
|
|
302
|
+
outcome: routingResult.success ? 'success' : 'failure',
|
|
303
|
+
userAction: 'not_required', // Internal routing - no review flow
|
|
304
|
+
errors: routingResult.error ? [routingResult.error] : undefined,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
catch {
|
|
308
|
+
// Non-blocking
|
|
309
|
+
}
|
|
310
|
+
return routingResult;
|
|
43
311
|
}
|
|
44
312
|
catch (error) {
|
|
45
|
-
//
|
|
46
|
-
|
|
313
|
+
// End run on error
|
|
314
|
+
executionTracer.endRun();
|
|
315
|
+
// Record failure
|
|
316
|
+
try {
|
|
317
|
+
agentFeedbackManager.recordFeedback({
|
|
318
|
+
runId: routingRunId,
|
|
319
|
+
agentName: 'intelligent-router',
|
|
320
|
+
operation: 'route',
|
|
321
|
+
query: request.query,
|
|
322
|
+
outcome: 'failure',
|
|
323
|
+
userAction: 'not_required', // Error case - no review flow
|
|
324
|
+
errors: [error instanceof Error ? error.message : String(error)],
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
catch {
|
|
328
|
+
// Non-blocking
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
intent,
|
|
332
|
+
action: selectedAction === 'orchestrate' ? 'general' : selectedAction,
|
|
333
|
+
result: null,
|
|
334
|
+
success: false,
|
|
335
|
+
error: error instanceof Error ? error.message : String(error),
|
|
336
|
+
routingDecision,
|
|
337
|
+
routingRunId,
|
|
338
|
+
};
|
|
47
339
|
}
|
|
48
340
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (needsIndex && (intent === 'find' || intent === 'understand' || intent === 'explain')) {
|
|
341
|
+
catch (outerError) {
|
|
342
|
+
// Catch any errors from the outer try block (validation, classification, etc.)
|
|
343
|
+
executionTracer.endRun();
|
|
344
|
+
try {
|
|
345
|
+
agentFeedbackManager.recordFeedback({
|
|
346
|
+
runId: routingRunId,
|
|
347
|
+
agentName: 'intelligent-router',
|
|
348
|
+
operation: 'route',
|
|
349
|
+
query: request.query,
|
|
350
|
+
outcome: 'failure',
|
|
351
|
+
userAction: 'not_required', // Error case - no review flow
|
|
352
|
+
errors: [outerError instanceof Error ? outerError.message : String(outerError)],
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
catch {
|
|
356
|
+
// Non-blocking
|
|
357
|
+
}
|
|
67
358
|
return {
|
|
68
|
-
intent: '
|
|
69
|
-
action: '
|
|
70
|
-
result:
|
|
359
|
+
intent: 'error',
|
|
360
|
+
action: 'general',
|
|
361
|
+
result: null,
|
|
71
362
|
success: false,
|
|
72
|
-
|
|
73
|
-
|
|
363
|
+
error: outerError instanceof Error ? outerError.message : String(outerError),
|
|
364
|
+
routingRunId,
|
|
74
365
|
};
|
|
75
366
|
}
|
|
76
|
-
// Route based on intent (pass memories for context)
|
|
77
|
-
switch (intent) {
|
|
78
|
-
case 'explain':
|
|
79
|
-
// Use deterministic workflow for faster performance (no ReAct overhead)
|
|
80
|
-
return await this.handleExplainWithWorkflow(query, symbols, memories);
|
|
81
|
-
case 'multi-file-modify':
|
|
82
|
-
// Multi-file operations require planning AND execution
|
|
83
|
-
return await this.handleOrchestrate(query, memories);
|
|
84
|
-
case 'modify':
|
|
85
|
-
case 'debug': // 'fix' maps to 'debug'
|
|
86
|
-
case 'implement':
|
|
87
|
-
return await this.handleEdit(query, symbols, memories);
|
|
88
|
-
case 'index':
|
|
89
|
-
return await this.handleIndex(query);
|
|
90
|
-
case 'plan':
|
|
91
|
-
// Complex goals need planning
|
|
92
|
-
return await this.handlePlan(query, memories);
|
|
93
|
-
case 'find':
|
|
94
|
-
// For "find" queries, use AskQuestion to search the codebase
|
|
95
|
-
return await this.handleAsk(query, memories);
|
|
96
|
-
case 'understand':
|
|
97
|
-
case 'general':
|
|
98
|
-
// CRITICAL FIX: Simple questions should NEVER use ReAct
|
|
99
|
-
// Only use ReAct for truly complex multi-step queries
|
|
100
|
-
// Simple questions (explain, find, understand) go directly to AskQuestionUseCase
|
|
101
|
-
if (this.isSimpleQuestion(query)) {
|
|
102
|
-
return await this.handleAsk(query, memories);
|
|
103
|
-
}
|
|
104
|
-
// For complex queries, check if ReAct is appropriate
|
|
105
|
-
const shouldUseReAct = this.shouldUseReAct(query, memories);
|
|
106
|
-
if (shouldUseReAct) {
|
|
107
|
-
return await this.handleReAct(query, memories);
|
|
108
|
-
}
|
|
109
|
-
// Default to AskQuestion for understand/general queries
|
|
110
|
-
return await this.handleAsk(query, memories);
|
|
111
|
-
default:
|
|
112
|
-
// CRITICAL FIX: Default to AskQuestion, not ReAct
|
|
113
|
-
// ReAct should only be used when explicitly needed
|
|
114
|
-
// Most queries are simple and should use AskQuestionUseCase
|
|
115
|
-
return await this.handleAsk(query, memories);
|
|
116
|
-
}
|
|
117
367
|
}
|
|
118
368
|
/**
|
|
119
369
|
* Classify intent using AI and memory context
|
|
@@ -247,12 +497,63 @@ Respond with ONLY the intent word (e.g., "explain", "plan", "understand"):`;
|
|
|
247
497
|
// Requires multiple steps if 2+ indicators or very long query
|
|
248
498
|
return indicatorCount >= 2 || query.split(' ').length > 20;
|
|
249
499
|
}
|
|
500
|
+
/**
|
|
501
|
+
* Handle conversational response for follow-up queries after non-code intents
|
|
502
|
+
* Skips code search and provides contextual answer
|
|
503
|
+
*/
|
|
504
|
+
async handleConversationalResponse(query, memories, lastIntent) {
|
|
505
|
+
if (!this.aiService) {
|
|
506
|
+
return {
|
|
507
|
+
intent: 'general',
|
|
508
|
+
action: 'ask',
|
|
509
|
+
result: null,
|
|
510
|
+
success: false,
|
|
511
|
+
error: 'AI service not available',
|
|
512
|
+
memoriesUsed: memories?.length || 0,
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
try {
|
|
516
|
+
// Build conversational prompt without code context
|
|
517
|
+
const memoryContext = memories && memories.length > 0
|
|
518
|
+
? `\n\nRelevant context from previous interactions:\n${memories.slice(0, 3).map((m, i) => `${i + 1}. ${m.description}`).join('\n')}`
|
|
519
|
+
: '';
|
|
520
|
+
const conversationContext = lastIntent === 'plan'
|
|
521
|
+
? '\n\nNote: The user previously asked about planning or brainstorming. This is a follow-up question.'
|
|
522
|
+
: '';
|
|
523
|
+
const prompt = `You are a helpful AI assistant. The user is asking a follow-up question after a previous conversation about ${lastIntent || 'general topics'}.
|
|
524
|
+
|
|
525
|
+
User's question: "${query}"
|
|
526
|
+
${memoryContext}${conversationContext}
|
|
527
|
+
|
|
528
|
+
Provide a helpful, conversational response. Do NOT search for code unless the user explicitly asks about code or files.`;
|
|
529
|
+
const response = await this.aiService.chat(prompt, []);
|
|
530
|
+
return {
|
|
531
|
+
intent: 'general',
|
|
532
|
+
action: 'ask',
|
|
533
|
+
result: { answer: response, chunks: [] },
|
|
534
|
+
success: true,
|
|
535
|
+
message: response,
|
|
536
|
+
memoriesUsed: memories?.length || 0,
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
catch (error) {
|
|
540
|
+
return {
|
|
541
|
+
intent: 'general',
|
|
542
|
+
action: 'ask',
|
|
543
|
+
result: null,
|
|
544
|
+
success: false,
|
|
545
|
+
error: error instanceof Error ? error.message : String(error),
|
|
546
|
+
memoriesUsed: memories?.length || 0,
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
}
|
|
250
550
|
async checkIfIndexingNeeded(context) {
|
|
251
551
|
if (context?.hasIndex === false)
|
|
252
552
|
return true;
|
|
253
553
|
try {
|
|
254
554
|
const { container } = await import('./dependency-container.js');
|
|
255
|
-
|
|
555
|
+
// Use per-repo embedding repository for codebase isolation
|
|
556
|
+
const repo = container.getEmbeddingRepository(process.cwd());
|
|
256
557
|
// Check if any embeddings exist
|
|
257
558
|
const testSearch = await repo.searchWithEmbedding([0.1], 1);
|
|
258
559
|
return testSearch.length === 0;
|
|
@@ -264,7 +565,8 @@ Respond with ONLY the intent word (e.g., "explain", "plan", "understand"):`;
|
|
|
264
565
|
async handleAsk(query, memories) {
|
|
265
566
|
try {
|
|
266
567
|
const { container } = await import('./dependency-container.js');
|
|
267
|
-
|
|
568
|
+
// Use per-repo use case for codebase isolation
|
|
569
|
+
const useCase = container.getAskQuestionUseCase(process.cwd());
|
|
268
570
|
const result = await useCase.execute({ query, maxResults: 15 });
|
|
269
571
|
// Record successful routing in memory
|
|
270
572
|
if (this.memoryStream && memories && memories.length > 0) {
|
|
@@ -299,7 +601,8 @@ Respond with ONLY the intent word (e.g., "explain", "plan", "understand"):`;
|
|
|
299
601
|
try {
|
|
300
602
|
const { container } = await import('./dependency-container.js');
|
|
301
603
|
const { ExplainWorkflow } = await import('../workflows/deterministic-workflows.js');
|
|
302
|
-
|
|
604
|
+
// Use per-repo embedding repository for codebase isolation
|
|
605
|
+
const explainWorkflow = new ExplainWorkflow(container.getEmbeddingRepository(process.cwd()), container.aiService);
|
|
303
606
|
const workflowResult = await explainWorkflow.execute(query);
|
|
304
607
|
if (workflowResult.success) {
|
|
305
608
|
return {
|
|
@@ -641,7 +944,6 @@ Respond with ONLY the intent word (e.g., "explain", "plan", "understand"):`;
|
|
|
641
944
|
*/
|
|
642
945
|
fastSecurityCheck(query) {
|
|
643
946
|
// Fast pattern-based check for obvious security issues (synchronous, no API calls)
|
|
644
|
-
const lower = query.toLowerCase();
|
|
645
947
|
// Dangerous patterns that should be blocked immediately
|
|
646
948
|
const dangerousPatterns = [
|
|
647
949
|
{ pattern: /execute.*user.*input|eval.*user|exec.*user/i, reason: 'Security vulnerabilities detected: 1 critical, 0 high severity findings. Review and fix before applying.' },
|