codehere 0.3.0 → 0.5.0-alpha.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/README.md +230 -42
- 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 +3 -0
- package/dist/application/agents/multi-agent-orchestrator.d.ts.map +1 -1
- package/dist/application/agents/multi-agent-orchestrator.js +86 -0
- 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 +146 -70
- 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/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 +177 -7
- package/dist/application/services/dependency-container.js.map +1 -1
- package/dist/application/services/intelligent-router.d.ts +13 -0
- package/dist/application/services/intelligent-router.d.ts.map +1 -1
- package/dist/application/services/intelligent-router.js +306 -90
- package/dist/application/services/intelligent-router.js.map +1 -1
- package/dist/application/use-cases/ask-question-use-case.d.ts +19 -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 +125 -46
- 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/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/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/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 +398 -164
- 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 +18 -5
- 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.js +2 -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 +128 -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/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 +399 -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 +105 -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/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 +67 -0
- package/dist/infrastructure/storage/task-repository.d.ts.map +1 -0
- package/dist/infrastructure/storage/task-repository.js +205 -0
- package/dist/infrastructure/storage/task-repository.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 +4 -5
- package/dist/infrastructure/ux/progress-indicator.d.ts.map +1 -1
- package/dist/infrastructure/ux/progress-indicator.js +35 -40
- 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.map +1 -1
- package/dist/presentation/cli/commands/ask-command.js +225 -86
- 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 +8 -6
- package/dist/presentation/cli/commands/config-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 +53 -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 +2 -0
- package/dist/presentation/cli/commands/help-command.js.map +1 -1
- 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 +1 -0
- package/dist/presentation/cli/commands/orchestrate-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/orchestrate-command.js +68 -7
- package/dist/presentation/cli/commands/orchestrate-command.js.map +1 -1
- package/dist/presentation/cli/commands/plan-command.d.ts +1 -0
- package/dist/presentation/cli/commands/plan-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/plan-command.js +88 -8
- 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 +3 -1
- 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 +154 -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 +92 -6
- 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 +167 -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 +43 -0
- 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.js +19 -2
- package/dist/session.js.map +1 -1
- package/dist/ui.d.ts +6 -0
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +43 -6
- package/dist/ui.js.map +1 -1
- package/package.json +16 -3
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Infrastructure: ProviderAIService
|
|
3
|
+
* Adapter from IModelProvider → IAIService
|
|
4
|
+
*
|
|
5
|
+
* Phase 4B: Provider Adapter Implementation
|
|
6
|
+
* Bridges provider layer into existing IAIService abstraction
|
|
7
|
+
*
|
|
8
|
+
* This adapter:
|
|
9
|
+
* - Implements IAIService interface
|
|
10
|
+
* - Uses IModelProvider internally for actual AI operations
|
|
11
|
+
* - Preserves all existing behavior (context compression, tracing, prompt building)
|
|
12
|
+
* - Maintains backward compatibility with existing code
|
|
13
|
+
*/
|
|
14
|
+
import { executionTracer } from '../observability/execution-tracer.js';
|
|
15
|
+
import { promptVersioner } from '../observability/prompt-versioner.js';
|
|
16
|
+
import { getModelConfigManager } from './model-config.js';
|
|
17
|
+
import { OperationProviderResolver } from '../providers/operation-provider-resolver.js';
|
|
18
|
+
import { ProviderRegistry } from '../providers/provider-registry.js';
|
|
19
|
+
import { encoding_for_model } from 'tiktoken';
|
|
20
|
+
import { serializeCodeChunks } from '../serialization/toon-serializer.js';
|
|
21
|
+
// Token counting helper (same as CohereAIService for consistency)
|
|
22
|
+
let tokenEncoder = null;
|
|
23
|
+
function getTokenEncoder() {
|
|
24
|
+
if (!tokenEncoder) {
|
|
25
|
+
try {
|
|
26
|
+
tokenEncoder = encoding_for_model('gpt-3.5-turbo');
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
tokenEncoder = encoding_for_model('gpt-4');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return tokenEncoder;
|
|
33
|
+
}
|
|
34
|
+
function countTokens(text) {
|
|
35
|
+
try {
|
|
36
|
+
const encoder = getTokenEncoder();
|
|
37
|
+
return encoder.encode(text).length;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
console.warn('Warning: tiktoken failed, using character-based estimate (less accurate)');
|
|
41
|
+
return Math.ceil(text.length / 4);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* ProviderAIService
|
|
46
|
+
* Adapter that implements IAIService using IModelProvider(s)
|
|
47
|
+
*
|
|
48
|
+
* Phase 4F: Supports per-operation provider selection
|
|
49
|
+
* Phase 4G: Supports user-facing config files
|
|
50
|
+
*/
|
|
51
|
+
export class ProviderAIService {
|
|
52
|
+
_contextCompressor;
|
|
53
|
+
provider; // Default provider (backward compatibility)
|
|
54
|
+
providerResolver = null;
|
|
55
|
+
constructor(provider, contextCompressor, operationConfig, configDefaultProvider) {
|
|
56
|
+
this.provider = provider; // Keep for backward compatibility
|
|
57
|
+
this._contextCompressor = contextCompressor;
|
|
58
|
+
// Phase 4F/4G: Initialize operation provider resolver if operation config is provided
|
|
59
|
+
if (operationConfig !== undefined || configDefaultProvider !== undefined) {
|
|
60
|
+
const registry = ProviderRegistry.getInstance();
|
|
61
|
+
this.providerResolver = new OperationProviderResolver(registry, operationConfig || null, configDefaultProvider || null);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get provider for a specific operation
|
|
66
|
+
* Phase 4F: Operation-aware provider resolution
|
|
67
|
+
*/
|
|
68
|
+
getProviderForOperation(operation) {
|
|
69
|
+
// If resolver is configured, use it
|
|
70
|
+
if (this.providerResolver) {
|
|
71
|
+
return this.providerResolver.resolveProvider(operation);
|
|
72
|
+
}
|
|
73
|
+
// Otherwise, use default provider (backward compatible)
|
|
74
|
+
return this.provider;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Build prompt from query, context, and memories
|
|
78
|
+
* Reuses logic from CohereAIService to preserve behavior
|
|
79
|
+
*/
|
|
80
|
+
async buildPrompt(query, context, memories) {
|
|
81
|
+
// Use TOON serialization if enabled, otherwise use traditional format
|
|
82
|
+
const contextText = await serializeCodeChunks(context);
|
|
83
|
+
const memoryText = memories && memories.length > 0
|
|
84
|
+
? `\n\nPREVIOUS EXPERIENCES:\n${memories.map(m => `- ${m.description}`).join('\n')}`
|
|
85
|
+
: '';
|
|
86
|
+
// Get conversation history if available in context
|
|
87
|
+
let conversationHistoryText = '';
|
|
88
|
+
if (context.length > 0 && context[0].conversationHistory) {
|
|
89
|
+
const history = context[0].conversationHistory;
|
|
90
|
+
if (history && history.length > 0) {
|
|
91
|
+
const recentHistory = history.slice(-3);
|
|
92
|
+
conversationHistoryText = `\n\nCONVERSATION HISTORY:\n${recentHistory.map((turn, idx) => `[Previous ${idx + 1}]: User asked "${turn.query}". Response: ${turn.response.substring(0, 150)}...`).join('\n')}\n`;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return `You are a strict coding assistant for enterprise environments.
|
|
96
|
+
Use ONLY the provided code context.
|
|
97
|
+
${conversationHistoryText ? 'Consider the conversation history when answering the current query, especially if the user uses references like "it", "that", or "the previous".' : ''}
|
|
98
|
+
|
|
99
|
+
CONTEXT:
|
|
100
|
+
${contextText}${memoryText}${conversationHistoryText}
|
|
101
|
+
|
|
102
|
+
USER QUERY:
|
|
103
|
+
${query}`;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Select model based on context size and use case
|
|
107
|
+
* Preserves existing model selection logic
|
|
108
|
+
*/
|
|
109
|
+
selectModel(contextChunks, memoryCount, useCase = 'default') {
|
|
110
|
+
const modelConfig = getModelConfigManager();
|
|
111
|
+
if (modelConfig.isCommandModelAvailable()) {
|
|
112
|
+
const preferredModel = modelConfig.getPreferredModel(useCase);
|
|
113
|
+
if (preferredModel) {
|
|
114
|
+
return preferredModel;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Use default model for now
|
|
118
|
+
if (contextChunks > 20 || memoryCount > 10) {
|
|
119
|
+
return undefined; // Use default
|
|
120
|
+
}
|
|
121
|
+
return undefined; // Use default
|
|
122
|
+
}
|
|
123
|
+
async chat(query, context, memories) {
|
|
124
|
+
// Context Compression: Compress if context is too large (preserves CohereAIService behavior)
|
|
125
|
+
let finalContext = context;
|
|
126
|
+
let finalMemories = memories;
|
|
127
|
+
let compressionMetrics;
|
|
128
|
+
const contextCompressor = this._contextCompressor || this.contextCompressor;
|
|
129
|
+
if (contextCompressor) {
|
|
130
|
+
const estimatedTokens = context.reduce((sum, chunk) => sum + Math.ceil(chunk.content.length / 4), 0);
|
|
131
|
+
const maxTokens = 3000; // Same threshold as CohereAIService
|
|
132
|
+
if (estimatedTokens > maxTokens) {
|
|
133
|
+
const strategy = {
|
|
134
|
+
maxTokens,
|
|
135
|
+
preserveCode: true,
|
|
136
|
+
preserveErrors: true,
|
|
137
|
+
compressMemories: true,
|
|
138
|
+
compressObservations: false,
|
|
139
|
+
};
|
|
140
|
+
const compressed = await contextCompressor.compressWithSummarization(context, query, strategy);
|
|
141
|
+
finalContext = compressed.chunks;
|
|
142
|
+
compressionMetrics = {
|
|
143
|
+
originalTokens: compressed.originalTokenCount,
|
|
144
|
+
compressedTokens: compressed.compressedTokenCount,
|
|
145
|
+
reductionPercent: compressed.reductionPercent,
|
|
146
|
+
};
|
|
147
|
+
if (strategy.compressMemories && memories && memories.length > 10) {
|
|
148
|
+
finalMemories = await contextCompressor.compressMemories(memories, query, 10);
|
|
149
|
+
}
|
|
150
|
+
const runId = executionTracer.getCurrentRunId();
|
|
151
|
+
if (runId) {
|
|
152
|
+
executionTracer.trace({
|
|
153
|
+
operationType: 'context_compression',
|
|
154
|
+
operationName: 'compress_context',
|
|
155
|
+
input: { contextCount: context.length, estimatedTokens },
|
|
156
|
+
output: {
|
|
157
|
+
compressedCount: finalContext.length,
|
|
158
|
+
...compressionMetrics
|
|
159
|
+
},
|
|
160
|
+
metadata: { strategy: 'llm_summarization' },
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const prompt = await this.buildPrompt(query, finalContext, finalMemories);
|
|
166
|
+
const model = this.selectModel(finalContext.length, finalMemories?.length || 0, 'chat');
|
|
167
|
+
// Register prompt version for reproducibility
|
|
168
|
+
const promptVersionId = promptVersioner.registerVersion(prompt, {
|
|
169
|
+
model: model || 'default',
|
|
170
|
+
temperature: 0.7,
|
|
171
|
+
operation: 'chat',
|
|
172
|
+
});
|
|
173
|
+
const runId = executionTracer.getCurrentRunId();
|
|
174
|
+
if (runId) {
|
|
175
|
+
promptVersioner.linkRunToVersion(prompt, runId);
|
|
176
|
+
}
|
|
177
|
+
const startTime = Date.now();
|
|
178
|
+
// Phase 4F: Use operation-aware provider resolution
|
|
179
|
+
const operationProvider = this.getProviderForOperation('chat');
|
|
180
|
+
// Trace LLM call
|
|
181
|
+
const traceId = executionTracer.trace({
|
|
182
|
+
operationType: 'llm_call',
|
|
183
|
+
operationName: 'chat',
|
|
184
|
+
input: { query, contextCount: context.length, memoryCount: memories?.length || 0 },
|
|
185
|
+
metadata: {
|
|
186
|
+
model: model || 'default',
|
|
187
|
+
temperature: 0.7,
|
|
188
|
+
promptVersionId,
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
try {
|
|
192
|
+
const response = await operationProvider.chat(prompt, {
|
|
193
|
+
model,
|
|
194
|
+
temperature: 0.7,
|
|
195
|
+
});
|
|
196
|
+
const result = response.text || 'No response generated';
|
|
197
|
+
const duration = Date.now() - startTime;
|
|
198
|
+
// Phase 4F: Use operation-aware provider for token counting
|
|
199
|
+
const inputTokens = response.usage?.inputTokens || await operationProvider.countTokens(prompt, model);
|
|
200
|
+
const outputTokens = response.usage?.outputTokens || await operationProvider.countTokens(result, model);
|
|
201
|
+
executionTracer.trace({
|
|
202
|
+
operationType: 'llm_call',
|
|
203
|
+
operationName: 'chat',
|
|
204
|
+
output: { responseLength: result.length, inputTokens, outputTokens },
|
|
205
|
+
duration,
|
|
206
|
+
metadata: {
|
|
207
|
+
model: model || 'default',
|
|
208
|
+
temperature: 0.7,
|
|
209
|
+
promptVersionId,
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
executionTracer.trace({
|
|
216
|
+
operationType: 'llm_call',
|
|
217
|
+
operationName: 'chat',
|
|
218
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
219
|
+
duration: Date.now() - startTime,
|
|
220
|
+
metadata: {
|
|
221
|
+
model: model || 'default',
|
|
222
|
+
temperature: 0.7,
|
|
223
|
+
promptVersionId,
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
throw error;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
async chatStream(query, context, memories, streamHandler) {
|
|
230
|
+
const prompt = await this.buildPrompt(query, context, memories);
|
|
231
|
+
const model = this.selectModel(context.length, memories?.length || 0, 'chat');
|
|
232
|
+
const promptVersionId = promptVersioner.registerVersion(prompt, {
|
|
233
|
+
model: model || 'default',
|
|
234
|
+
temperature: 0.7,
|
|
235
|
+
operation: 'chat-stream',
|
|
236
|
+
});
|
|
237
|
+
const runId = executionTracer.getCurrentRunId();
|
|
238
|
+
if (runId) {
|
|
239
|
+
promptVersioner.linkRunToVersion(prompt, runId);
|
|
240
|
+
}
|
|
241
|
+
const startTime = Date.now();
|
|
242
|
+
let fullText = '';
|
|
243
|
+
try {
|
|
244
|
+
executionTracer.trace({
|
|
245
|
+
operationType: 'llm_call',
|
|
246
|
+
operationName: 'chat-stream',
|
|
247
|
+
input: { query, contextCount: context.length, memoryCount: memories?.length || 0 },
|
|
248
|
+
metadata: {
|
|
249
|
+
model: model || 'default',
|
|
250
|
+
temperature: 0.7,
|
|
251
|
+
promptVersionId,
|
|
252
|
+
streaming: true,
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
// Phase 4F: Use operation-aware provider resolution
|
|
256
|
+
const operationProvider = this.getProviderForOperation('chat');
|
|
257
|
+
if (operationProvider.chatStream) {
|
|
258
|
+
// Use provider's streaming if available
|
|
259
|
+
const response = await operationProvider.chatStream(prompt, {
|
|
260
|
+
model,
|
|
261
|
+
temperature: 0.7,
|
|
262
|
+
}, (event) => {
|
|
263
|
+
if (event.type === 'delta' && event.text) {
|
|
264
|
+
fullText += event.text;
|
|
265
|
+
if (streamHandler.onToken) {
|
|
266
|
+
streamHandler.onToken(event.text);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
else if (event.type === 'complete' && event.text) {
|
|
270
|
+
fullText = event.text;
|
|
271
|
+
}
|
|
272
|
+
else if (event.type === 'error' && event.error) {
|
|
273
|
+
if (streamHandler.onError) {
|
|
274
|
+
streamHandler.onError(event.error);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
fullText = response.text || fullText;
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
// Fallback: Use regular chat and simulate streaming
|
|
282
|
+
const response = await operationProvider.chat(prompt, {
|
|
283
|
+
model,
|
|
284
|
+
temperature: 0.7,
|
|
285
|
+
});
|
|
286
|
+
fullText = response.text || '';
|
|
287
|
+
// Simulate streaming by sending chunks
|
|
288
|
+
const chunkSize = 10;
|
|
289
|
+
for (let i = 0; i < fullText.length; i += chunkSize) {
|
|
290
|
+
const chunk = fullText.substring(i, i + chunkSize);
|
|
291
|
+
if (streamHandler.onToken) {
|
|
292
|
+
streamHandler.onToken(chunk);
|
|
293
|
+
}
|
|
294
|
+
if (fullText.length > chunkSize * 2) {
|
|
295
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
const duration = Date.now() - startTime;
|
|
300
|
+
const inputTokens = await operationProvider.countTokens(prompt, model);
|
|
301
|
+
const outputTokens = await operationProvider.countTokens(fullText, model);
|
|
302
|
+
executionTracer.trace({
|
|
303
|
+
operationType: 'llm_call',
|
|
304
|
+
operationName: 'chat-stream',
|
|
305
|
+
output: { responseLength: fullText.length, inputTokens, outputTokens },
|
|
306
|
+
duration,
|
|
307
|
+
metadata: {
|
|
308
|
+
model: model || 'default',
|
|
309
|
+
temperature: 0.7,
|
|
310
|
+
promptVersionId,
|
|
311
|
+
streaming: true,
|
|
312
|
+
},
|
|
313
|
+
});
|
|
314
|
+
if (streamHandler.onComplete) {
|
|
315
|
+
streamHandler.onComplete(fullText);
|
|
316
|
+
}
|
|
317
|
+
return fullText;
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
const duration = Date.now() - startTime;
|
|
321
|
+
executionTracer.trace({
|
|
322
|
+
operationType: 'llm_call',
|
|
323
|
+
operationName: 'chat-stream',
|
|
324
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
325
|
+
duration,
|
|
326
|
+
metadata: {
|
|
327
|
+
model: model || 'default',
|
|
328
|
+
temperature: 0.7,
|
|
329
|
+
promptVersionId,
|
|
330
|
+
streaming: true,
|
|
331
|
+
},
|
|
332
|
+
});
|
|
333
|
+
if (streamHandler.onError) {
|
|
334
|
+
streamHandler.onError(error instanceof Error ? error : new Error(String(error)));
|
|
335
|
+
}
|
|
336
|
+
throw error;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
async embed(text) {
|
|
340
|
+
// Phase 4F: Use operation-aware provider resolution
|
|
341
|
+
const operationProvider = this.getProviderForOperation('embedding');
|
|
342
|
+
return await operationProvider.embed(text);
|
|
343
|
+
}
|
|
344
|
+
async embedQuery(query) {
|
|
345
|
+
// Phase 4F: Use operation-aware provider resolution
|
|
346
|
+
const operationProvider = this.getProviderForOperation('embedding');
|
|
347
|
+
if (operationProvider.embedQuery) {
|
|
348
|
+
return await operationProvider.embedQuery(query);
|
|
349
|
+
}
|
|
350
|
+
// Fallback: Use regular embed if embedQuery not available
|
|
351
|
+
const result = await operationProvider.embed(query);
|
|
352
|
+
return Array.isArray(result[0]) ? result[0] : result;
|
|
353
|
+
}
|
|
354
|
+
async generateEdit(fileContent, instruction, filepath) {
|
|
355
|
+
const prompt = `You are a code editor. Return the COMPLETE modified file content.
|
|
356
|
+
|
|
357
|
+
CRITICAL RULES:
|
|
358
|
+
1. Return ONLY the complete modified file content - no explanations, no markdown, no code blocks
|
|
359
|
+
2. If renaming a function/class/variable, you MUST update ALL references
|
|
360
|
+
3. Maintain exact indentation and formatting from the original
|
|
361
|
+
4. Only modify what's necessary for the instruction
|
|
362
|
+
5. Return the ENTIRE file, not just the changes
|
|
363
|
+
|
|
364
|
+
FILE: ${filepath}
|
|
365
|
+
|
|
366
|
+
CURRENT CODE:
|
|
367
|
+
\`\`\`
|
|
368
|
+
${fileContent}
|
|
369
|
+
\`\`\`
|
|
370
|
+
|
|
371
|
+
INSTRUCTION: ${instruction}
|
|
372
|
+
|
|
373
|
+
Return the COMPLETE modified file content (entire file, not a diff):`;
|
|
374
|
+
// Phase 4F: Use operation-aware provider resolution (chat operation)
|
|
375
|
+
const operationProvider = this.getProviderForOperation('chat');
|
|
376
|
+
const response = await operationProvider.chat(prompt, {
|
|
377
|
+
temperature: 0.3, // Lower for deterministic code generation
|
|
378
|
+
});
|
|
379
|
+
return response.text || '';
|
|
380
|
+
}
|
|
381
|
+
async generateFileContent(filepath, instruction, requirements = []) {
|
|
382
|
+
const requirementsText = requirements.length > 0
|
|
383
|
+
? `\n\nREQUIREMENTS:\n${requirements.map((r, i) => `${i + 1}. ${r}`).join('\n')}`
|
|
384
|
+
: '';
|
|
385
|
+
const ext = filepath.split('.').pop()?.toLowerCase() || '';
|
|
386
|
+
const languageMap = {
|
|
387
|
+
'ts': 'TypeScript',
|
|
388
|
+
'js': 'JavaScript',
|
|
389
|
+
'tsx': 'TypeScript React',
|
|
390
|
+
'jsx': 'JavaScript React',
|
|
391
|
+
'py': 'Python',
|
|
392
|
+
'java': 'Java',
|
|
393
|
+
'go': 'Go',
|
|
394
|
+
'rs': 'Rust',
|
|
395
|
+
'rb': 'Ruby',
|
|
396
|
+
'php': 'PHP',
|
|
397
|
+
'vue': 'Vue',
|
|
398
|
+
'svelte': 'Svelte',
|
|
399
|
+
'html': 'HTML',
|
|
400
|
+
'css': 'CSS',
|
|
401
|
+
'json': 'JSON',
|
|
402
|
+
'yaml': 'YAML',
|
|
403
|
+
'yml': 'YAML',
|
|
404
|
+
'md': 'Markdown',
|
|
405
|
+
'sh': 'Bash',
|
|
406
|
+
'bash': 'Bash',
|
|
407
|
+
};
|
|
408
|
+
const language = languageMap[ext] || 'code';
|
|
409
|
+
const prompt = `You are a code generator. Create a NEW ${language} file from scratch.
|
|
410
|
+
|
|
411
|
+
CRITICAL RULES:
|
|
412
|
+
1. Return ONLY the complete file content - no explanations, no markdown, no code blocks
|
|
413
|
+
2. Follow ${language} best practices and conventions
|
|
414
|
+
3. Include proper imports, exports, and structure
|
|
415
|
+
4. Add appropriate comments for clarity
|
|
416
|
+
5. Ensure the code is production-ready and well-structured
|
|
417
|
+
|
|
418
|
+
FILE PATH: ${filepath}
|
|
419
|
+
FILE TYPE: ${language}${requirementsText}
|
|
420
|
+
|
|
421
|
+
INSTRUCTION: ${instruction}
|
|
422
|
+
|
|
423
|
+
Return the COMPLETE file content (entire file, ready to save):`;
|
|
424
|
+
// Phase 4F: Use operation-aware provider resolution (chat operation)
|
|
425
|
+
const operationProvider = this.getProviderForOperation('chat');
|
|
426
|
+
const response = await operationProvider.chat(prompt, {
|
|
427
|
+
temperature: 0.35,
|
|
428
|
+
});
|
|
429
|
+
let content = response.text || '';
|
|
430
|
+
// Clean up common markdown formatting
|
|
431
|
+
content = content.replace(/^```[\w]*\n?/gm, '');
|
|
432
|
+
content = content.replace(/^```$/gm, '');
|
|
433
|
+
content = content.trim();
|
|
434
|
+
return content;
|
|
435
|
+
}
|
|
436
|
+
async generateReflection(trajectory, reward, errors) {
|
|
437
|
+
const prompt = `You are a self-reflection model. Analyze the following failed trajectory:
|
|
438
|
+
|
|
439
|
+
Trajectory:
|
|
440
|
+
${JSON.stringify(trajectory, null, 2)}
|
|
441
|
+
|
|
442
|
+
Reward: ${reward}
|
|
443
|
+
Errors: ${errors.join('; ')}
|
|
444
|
+
|
|
445
|
+
Generate a reflective text that:
|
|
446
|
+
1. Identifies the root cause of failure
|
|
447
|
+
2. Explains what went wrong
|
|
448
|
+
3. Suggests specific improvements for the next attempt
|
|
449
|
+
4. Extracts lessons learned
|
|
450
|
+
|
|
451
|
+
Reflection:`;
|
|
452
|
+
// Phase 4F: Use operation-aware provider resolution (chat operation)
|
|
453
|
+
const operationProvider = this.getProviderForOperation('chat');
|
|
454
|
+
const response = await operationProvider.chat(prompt, {
|
|
455
|
+
temperature: 0.5,
|
|
456
|
+
});
|
|
457
|
+
return response.text || '';
|
|
458
|
+
}
|
|
459
|
+
async rerank(query, documents, topN = 10) {
|
|
460
|
+
if (documents.length === 0) {
|
|
461
|
+
return [];
|
|
462
|
+
}
|
|
463
|
+
// Phase 4F: Use operation-aware provider resolution
|
|
464
|
+
const operationProvider = this.getProviderForOperation('rerank');
|
|
465
|
+
if (!operationProvider.capabilities.rerank || !operationProvider.rerank) {
|
|
466
|
+
// Fallback: Return original order if rerank not supported
|
|
467
|
+
return documents.slice(0, topN).map((_, i) => ({ index: i, relevanceScore: 1.0 }));
|
|
468
|
+
}
|
|
469
|
+
const topNAdjusted = Math.min(topN, documents.length);
|
|
470
|
+
const response = await operationProvider.rerank(query, documents, { topN: topNAdjusted });
|
|
471
|
+
return response.results.map(result => ({
|
|
472
|
+
index: result.index,
|
|
473
|
+
relevanceScore: result.relevanceScore,
|
|
474
|
+
}));
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
//# sourceMappingURL=provider-ai-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-ai-service.js","sourceRoot":"","sources":["../../../src/infrastructure/ai/provider-ai-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAsB,MAAM,6CAA6C,CAAC;AAC5G,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAE1E,kEAAkE;AAClE,IAAI,YAAY,GAAiD,IAAI,CAAC;AACtE,SAAS,eAAe;IACtB,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,IAAI,CAAC;YACH,YAAY,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC;QACrD,CAAC;QAAC,MAAM,CAAC;YACP,YAAY,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;QAClC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CA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CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QACrF,CAAC;QAED,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QACtD,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;QAE1F,OAAO,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACrC,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,cAAc,EAAE,MAAM,CAAC,cAAc;SACtC,CAAC,CAAC,CAAC;IACN,CAAC;CACF"}
|
|
@@ -15,8 +15,20 @@ export declare class EmbeddingCache {
|
|
|
15
15
|
private getCacheKey;
|
|
16
16
|
/**
|
|
17
17
|
* Get cached embedding if available and not expired
|
|
18
|
+
* OPTIMIZATION: Also checks for similar queries with fuzzy matching
|
|
18
19
|
*/
|
|
19
|
-
get(query: string): number[] | null;
|
|
20
|
+
get(query: string, enableFuzzyMatch?: boolean): number[] | null;
|
|
21
|
+
/**
|
|
22
|
+
* Find similar query using Levenshtein distance
|
|
23
|
+
* Returns cached embedding if similarity >= threshold
|
|
24
|
+
*/
|
|
25
|
+
private findSimilarQuery;
|
|
26
|
+
/**
|
|
27
|
+
* Calculate string similarity using word overlap with stop word filtering
|
|
28
|
+
* Returns value between 0.0 (no similarity) and 1.0 (identical)
|
|
29
|
+
* OPTIMIZATION: Filters common stop words to focus on meaningful content
|
|
30
|
+
*/
|
|
31
|
+
private calculateSimilarity;
|
|
20
32
|
/**
|
|
21
33
|
* Store embedding in cache
|
|
22
34
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding-cache.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/cache/embedding-cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAA2C;IACxD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,GAAG,CAAS;gBAER,OAAO,GAAE,MAAa,EAAE,GAAG,GAAE,MAAgB;IAKzD;;OAEG;IACH,OAAO,CAAC,WAAW;IAMnB
|
|
1
|
+
{"version":3,"file":"embedding-cache.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/cache/embedding-cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAA2C;IACxD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,GAAG,CAAS;gBAER,OAAO,GAAE,MAAa,EAAE,GAAG,GAAE,MAAgB;IAKzD;;OAEG;IACH,OAAO,CAAC,WAAW;IAMnB;;;OAGG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,gBAAgB,GAAE,OAAc,GAAG,MAAM,EAAE,GAAG,IAAI;IAkCrE;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAuBxB;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IA+B3B;;OAEG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI;IAe7C;;OAEG;IACH,OAAO,CAAC,WAAW;IAYnB;;OAEG;IACH,YAAY,IAAI,IAAI;IASpB;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,QAAQ,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;CAMhE;AAKD,wBAAgB,iBAAiB,IAAI,cAAc,CAKlD"}
|
|
@@ -23,20 +23,91 @@ export class EmbeddingCache {
|
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Get cached embedding if available and not expired
|
|
26
|
+
* OPTIMIZATION: Also checks for similar queries with fuzzy matching
|
|
26
27
|
*/
|
|
27
|
-
get(query) {
|
|
28
|
+
get(query, enableFuzzyMatch = true) {
|
|
28
29
|
const key = this.getCacheKey(query);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
let cached = this.cache.get(key);
|
|
31
|
+
// Direct cache hit
|
|
32
|
+
if (cached) {
|
|
33
|
+
const now = Date.now();
|
|
34
|
+
if (now - cached.timestamp > this.ttl) {
|
|
35
|
+
this.cache.delete(key);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return cached.embedding;
|
|
39
|
+
}
|
|
32
40
|
}
|
|
33
|
-
//
|
|
41
|
+
// Fuzzy matching for similar queries
|
|
42
|
+
// OPTIMIZATION: Use lower threshold (80%) for more aggressive caching
|
|
43
|
+
// This helps with query variations like "what is main" vs "what is the main function"
|
|
44
|
+
if (enableFuzzyMatch && this.cache.size > 0) {
|
|
45
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
46
|
+
// Try with standard threshold first (85%), then lower threshold (80%) for more aggressive matching
|
|
47
|
+
let bestMatch = this.findSimilarQuery(normalizedQuery, 0.85);
|
|
48
|
+
if (!bestMatch) {
|
|
49
|
+
bestMatch = this.findSimilarQuery(normalizedQuery, 0.80);
|
|
50
|
+
}
|
|
51
|
+
if (bestMatch && bestMatch.embedding) {
|
|
52
|
+
// Found similar query - reuse its embedding
|
|
53
|
+
return bestMatch.embedding;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Find similar query using Levenshtein distance
|
|
60
|
+
* Returns cached embedding if similarity >= threshold
|
|
61
|
+
*/
|
|
62
|
+
findSimilarQuery(query, threshold = 0.85) {
|
|
63
|
+
let bestMatch = null;
|
|
34
64
|
const now = Date.now();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
65
|
+
for (const [key, cached] of this.cache.entries()) {
|
|
66
|
+
// Skip expired entries
|
|
67
|
+
if (now - cached.timestamp > this.ttl) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const normalizedCached = cached.query.trim().toLowerCase();
|
|
71
|
+
const similarity = this.calculateSimilarity(query, normalizedCached);
|
|
72
|
+
if (similarity >= threshold) {
|
|
73
|
+
if (!bestMatch || similarity > bestMatch.similarity) {
|
|
74
|
+
bestMatch = { cached, similarity };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return bestMatch ? bestMatch.cached : null;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Calculate string similarity using word overlap with stop word filtering
|
|
82
|
+
* Returns value between 0.0 (no similarity) and 1.0 (identical)
|
|
83
|
+
* OPTIMIZATION: Filters common stop words to focus on meaningful content
|
|
84
|
+
*/
|
|
85
|
+
calculateSimilarity(str1, str2) {
|
|
86
|
+
if (str1 === str2)
|
|
87
|
+
return 1.0;
|
|
88
|
+
if (str1.length === 0 || str2.length === 0)
|
|
89
|
+
return 0.0;
|
|
90
|
+
// Common stop words to ignore for better matching
|
|
91
|
+
const stopWords = new Set(['the', 'a', 'an', 'is', 'are', 'was', 'were', 'be', 'been', 'being', 'have', 'has', 'had', 'do', 'does', 'did', 'will', 'would', 'should', 'could', 'may', 'might', 'must', 'can', 'this', 'that', 'these', 'those', 'what', 'which', 'who', 'where', 'when', 'why', 'how', 'to', 'of', 'in', 'on', 'at', 'by', 'for', 'with', 'from', 'as', 'about', 'into', 'through', 'during', 'including', 'against', 'among', 'throughout', 'despite', 'towards', 'upon', 'concerning', 'to', 'of', 'in', 'on', 'at', 'by', 'for', 'with', 'from']);
|
|
92
|
+
// Filter out stop words and short words for better matching
|
|
93
|
+
const filterWords = (text) => {
|
|
94
|
+
return text.split(/\s+/)
|
|
95
|
+
.filter(w => w.length > 2 && !stopWords.has(w.toLowerCase()))
|
|
96
|
+
.map(w => w.toLowerCase().replace(/[^\w]/g, '')); // Normalize
|
|
97
|
+
};
|
|
98
|
+
const words1 = new Set(filterWords(str1));
|
|
99
|
+
const words2 = new Set(filterWords(str2));
|
|
100
|
+
if (words1.size === 0 || words2.size === 0)
|
|
101
|
+
return 0.0;
|
|
102
|
+
// Calculate Jaccard similarity (word overlap)
|
|
103
|
+
let intersection = 0;
|
|
104
|
+
for (const word of words1) {
|
|
105
|
+
if (words2.has(word)) {
|
|
106
|
+
intersection++;
|
|
107
|
+
}
|
|
38
108
|
}
|
|
39
|
-
|
|
109
|
+
const union = words1.size + words2.size - intersection;
|
|
110
|
+
return union > 0 ? intersection / union : 0.0;
|
|
40
111
|
}
|
|
41
112
|
/**
|
|
42
113
|
* Store embedding in cache
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding-cache.js","sourceRoot":"","sources":["../../../src/infrastructure/cache/embedding-cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAQpC,MAAM,OAAO,cAAc;IACjB,KAAK,GAAiC,IAAI,GAAG,EAAE,CAAC;IAChD,OAAO,CAAS;IAChB,GAAG,CAAS,CAAC,+BAA+B;IAEpD,YAAY,UAAkB,IAAI,EAAE,MAAc,OAAO;QACvD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;OAEG;IACK,WAAW,CAAC,KAAa;QAC/B,0DAA0D;QAC1D,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC9C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/D,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"embedding-cache.js","sourceRoot":"","sources":["../../../src/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