codehere 0.1.1
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 +22 -0
- package/README.md +378 -0
- package/dist/agents/base.d.ts +107 -0
- package/dist/agents/base.d.ts.map +1 -0
- package/dist/agents/base.js +101 -0
- package/dist/agents/base.js.map +1 -0
- package/dist/agents/orchestrator-model-driven.d.ts +41 -0
- package/dist/agents/orchestrator-model-driven.d.ts.map +1 -0
- package/dist/agents/orchestrator-model-driven.js +141 -0
- package/dist/agents/orchestrator-model-driven.js.map +1 -0
- package/dist/agents/react-orchestrator-agent.d.ts +15 -0
- package/dist/agents/react-orchestrator-agent.d.ts.map +1 -0
- package/dist/agents/react-orchestrator-agent.js +54 -0
- package/dist/agents/react-orchestrator-agent.js.map +1 -0
- package/dist/application/agents/execution-agent.d.ts +79 -0
- package/dist/application/agents/execution-agent.d.ts.map +1 -0
- package/dist/application/agents/execution-agent.js +534 -0
- package/dist/application/agents/execution-agent.js.map +1 -0
- package/dist/application/agents/multi-agent-orchestrator.d.ts +69 -0
- package/dist/application/agents/multi-agent-orchestrator.d.ts.map +1 -0
- package/dist/application/agents/multi-agent-orchestrator.js +296 -0
- package/dist/application/agents/multi-agent-orchestrator.js.map +1 -0
- package/dist/application/agents/planning-agent.d.ts +65 -0
- package/dist/application/agents/planning-agent.d.ts.map +1 -0
- package/dist/application/agents/planning-agent.js +553 -0
- package/dist/application/agents/planning-agent.js.map +1 -0
- package/dist/application/agents/validation-agent.d.ts +68 -0
- package/dist/application/agents/validation-agent.d.ts.map +1 -0
- package/dist/application/agents/validation-agent.js +317 -0
- package/dist/application/agents/validation-agent.js.map +1 -0
- package/dist/application/architectures/plan-and-act.d.ts +94 -0
- package/dist/application/architectures/plan-and-act.d.ts.map +1 -0
- package/dist/application/architectures/plan-and-act.js +242 -0
- package/dist/application/architectures/plan-and-act.js.map +1 -0
- package/dist/application/index.d.ts +12 -0
- package/dist/application/index.d.ts.map +1 -0
- package/dist/application/index.js +12 -0
- package/dist/application/index.js.map +1 -0
- package/dist/application/services/agent-factory.d.ts +9 -0
- package/dist/application/services/agent-factory.d.ts.map +1 -0
- package/dist/application/services/agent-factory.js +28 -0
- package/dist/application/services/agent-factory.js.map +1 -0
- package/dist/application/services/context-importer.d.ts +71 -0
- package/dist/application/services/context-importer.d.ts.map +1 -0
- package/dist/application/services/context-importer.js +436 -0
- package/dist/application/services/context-importer.js.map +1 -0
- package/dist/application/services/context-manager.d.ts +132 -0
- package/dist/application/services/context-manager.d.ts.map +1 -0
- package/dist/application/services/context-manager.js +369 -0
- package/dist/application/services/context-manager.js.map +1 -0
- package/dist/application/services/dependency-container.d.ts +187 -0
- package/dist/application/services/dependency-container.d.ts.map +1 -0
- package/dist/application/services/dependency-container.js +607 -0
- package/dist/application/services/dependency-container.js.map +1 -0
- package/dist/application/services/git-context-service.d.ts +30 -0
- package/dist/application/services/git-context-service.d.ts.map +1 -0
- package/dist/application/services/git-context-service.js +83 -0
- package/dist/application/services/git-context-service.js.map +1 -0
- package/dist/application/services/intelligent-router.d.ts +90 -0
- package/dist/application/services/intelligent-router.d.ts.map +1 -0
- package/dist/application/services/intelligent-router.js +942 -0
- package/dist/application/services/intelligent-router.js.map +1 -0
- package/dist/application/services/token-counting-service.d.ts +87 -0
- package/dist/application/services/token-counting-service.d.ts.map +1 -0
- package/dist/application/services/token-counting-service.js +196 -0
- package/dist/application/services/token-counting-service.js.map +1 -0
- package/dist/application/services/tool-executor-service.d.ts +14 -0
- package/dist/application/services/tool-executor-service.d.ts.map +1 -0
- package/dist/application/services/tool-executor-service.js +94 -0
- package/dist/application/services/tool-executor-service.js.map +1 -0
- package/dist/application/use-cases/ask-question-use-case.d.ts +67 -0
- package/dist/application/use-cases/ask-question-use-case.d.ts.map +1 -0
- package/dist/application/use-cases/ask-question-use-case.js +437 -0
- package/dist/application/use-cases/ask-question-use-case.js.map +1 -0
- package/dist/application/use-cases/edit-file-use-case.d.ts +92 -0
- package/dist/application/use-cases/edit-file-use-case.d.ts.map +1 -0
- package/dist/application/use-cases/edit-file-use-case.js +819 -0
- package/dist/application/use-cases/edit-file-use-case.js.map +1 -0
- package/dist/application/use-cases/explain-file-use-case.d.ts +21 -0
- package/dist/application/use-cases/explain-file-use-case.d.ts.map +1 -0
- package/dist/application/use-cases/explain-file-use-case.js +50 -0
- package/dist/application/use-cases/explain-file-use-case.js.map +1 -0
- package/dist/application/use-cases/index-codebase-use-case.d.ts +46 -0
- package/dist/application/use-cases/index-codebase-use-case.d.ts.map +1 -0
- package/dist/application/use-cases/index-codebase-use-case.js +113 -0
- package/dist/application/use-cases/index-codebase-use-case.js.map +1 -0
- package/dist/application/use-cases/planning-use-case.d.ts +46 -0
- package/dist/application/use-cases/planning-use-case.d.ts.map +1 -0
- package/dist/application/use-cases/planning-use-case.js +276 -0
- package/dist/application/use-cases/planning-use-case.js.map +1 -0
- package/dist/application/use-cases/react-orchestration-use-case.d.ts +51 -0
- package/dist/application/use-cases/react-orchestration-use-case.d.ts.map +1 -0
- package/dist/application/use-cases/react-orchestration-use-case.js +362 -0
- package/dist/application/use-cases/react-orchestration-use-case.js.map +1 -0
- package/dist/application/use-cases/reflexion-use-case.d.ts +24 -0
- package/dist/application/use-cases/reflexion-use-case.d.ts.map +1 -0
- package/dist/application/use-cases/reflexion-use-case.js +30 -0
- package/dist/application/use-cases/reflexion-use-case.js.map +1 -0
- package/dist/application/workflows/deterministic-workflows.d.ts +61 -0
- package/dist/application/workflows/deterministic-workflows.d.ts.map +1 -0
- package/dist/application/workflows/deterministic-workflows.js +189 -0
- package/dist/application/workflows/deterministic-workflows.js.map +1 -0
- package/dist/ast-parser.d 2.ts +55 -0
- package/dist/ast-parser.d.ts +55 -0
- package/dist/ast-parser.d.ts.map +1 -0
- package/dist/ast-parser.js +331 -0
- package/dist/ast-parser.js.map +1 -0
- package/dist/cache.d.ts +45 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +180 -0
- package/dist/cache.js.map +1 -0
- package/dist/chat.d.ts +4 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/chat.js +175 -0
- package/dist/chat.js.map +1 -0
- package/dist/code-analysis 2.js +327 -0
- package/dist/code-analysis.d.ts +50 -0
- package/dist/code-analysis.d.ts.map +1 -0
- package/dist/code-analysis.js +327 -0
- package/dist/code-analysis.js.map +1 -0
- package/dist/context.d.ts +44 -0
- package/dist/context.d.ts 2.map +1 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +187 -0
- package/dist/context.js.map +1 -0
- package/dist/docs.d.ts +21 -0
- package/dist/docs.d.ts.map +1 -0
- package/dist/docs.js +146 -0
- package/dist/docs.js.map +1 -0
- package/dist/domain/entities/code-chunk.d.ts +26 -0
- package/dist/domain/entities/code-chunk.d.ts.map +1 -0
- package/dist/domain/entities/code-chunk.js +6 -0
- package/dist/domain/entities/code-chunk.js.map +1 -0
- package/dist/domain/entities/conversation-context.d.ts +245 -0
- package/dist/domain/entities/conversation-context.d.ts.map +1 -0
- package/dist/domain/entities/conversation-context.js +50 -0
- package/dist/domain/entities/conversation-context.js.map +1 -0
- package/dist/domain/entities/decision.d.ts +37 -0
- package/dist/domain/entities/decision.d.ts.map +1 -0
- package/dist/domain/entities/decision.js +9 -0
- package/dist/domain/entities/decision.js.map +1 -0
- package/dist/domain/entities/edit.d.ts +35 -0
- package/dist/domain/entities/edit.d.ts.map +1 -0
- package/dist/domain/entities/edit.js +6 -0
- package/dist/domain/entities/edit.js.map +1 -0
- package/dist/domain/entities/knowledge-node.d.ts +83 -0
- package/dist/domain/entities/knowledge-node.d.ts.map +1 -0
- package/dist/domain/entities/knowledge-node.js +9 -0
- package/dist/domain/entities/knowledge-node.js.map +1 -0
- package/dist/domain/entities/knowledge-preservation.d.ts +42 -0
- package/dist/domain/entities/knowledge-preservation.d.ts.map +1 -0
- package/dist/domain/entities/knowledge-preservation.js +10 -0
- package/dist/domain/entities/knowledge-preservation.js.map +1 -0
- package/dist/domain/entities/memory.d.ts +36 -0
- package/dist/domain/entities/memory.d.ts.map +1 -0
- package/dist/domain/entities/memory.js +6 -0
- package/dist/domain/entities/memory.js.map +1 -0
- package/dist/domain/entities/pattern.d.ts +49 -0
- package/dist/domain/entities/pattern.d.ts.map +1 -0
- package/dist/domain/entities/pattern.js +7 -0
- package/dist/domain/entities/pattern.js.map +1 -0
- package/dist/domain/entities/plan.d.ts +42 -0
- package/dist/domain/entities/plan.d.ts.map +1 -0
- package/dist/domain/entities/plan.js +6 -0
- package/dist/domain/entities/plan.js.map +1 -0
- package/dist/domain/entities/query.d.ts +17 -0
- package/dist/domain/entities/query.d.ts.map +1 -0
- package/dist/domain/entities/query.js +6 -0
- package/dist/domain/entities/query.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/index.d.ts +16 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +19 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/interfaces/ai-service.interface.d.ts +72 -0
- package/dist/domain/interfaces/ai-service.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/ai-service.interface.js +6 -0
- package/dist/domain/interfaces/ai-service.interface.js.map +1 -0
- package/dist/domain/interfaces/code-analyzer.interface.d.ts +38 -0
- package/dist/domain/interfaces/code-analyzer.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/code-analyzer.interface.js +6 -0
- package/dist/domain/interfaces/code-analyzer.interface.js.map +1 -0
- package/dist/domain/interfaces/context-repository.interface.d.ts +71 -0
- package/dist/domain/interfaces/context-repository.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/context-repository.interface.js +10 -0
- package/dist/domain/interfaces/context-repository.interface.js.map +1 -0
- package/dist/domain/interfaces/decision-repository.interface.d.ts +51 -0
- package/dist/domain/interfaces/decision-repository.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/decision-repository.interface.js +9 -0
- package/dist/domain/interfaces/decision-repository.interface.js.map +1 -0
- package/dist/domain/interfaces/embedding-repository.interface.d.ts +33 -0
- package/dist/domain/interfaces/embedding-repository.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/embedding-repository.interface.js +6 -0
- package/dist/domain/interfaces/embedding-repository.interface.js.map +1 -0
- package/dist/domain/interfaces/knowledge-graph-repository.interface.d.ts +91 -0
- package/dist/domain/interfaces/knowledge-graph-repository.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/knowledge-graph-repository.interface.js +9 -0
- package/dist/domain/interfaces/knowledge-graph-repository.interface.js.map +1 -0
- package/dist/domain/interfaces/knowledge-preservation-repository.interface.d.ts +50 -0
- package/dist/domain/interfaces/knowledge-preservation-repository.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/knowledge-preservation-repository.interface.js +8 -0
- package/dist/domain/interfaces/knowledge-preservation-repository.interface.js.map +1 -0
- package/dist/domain/interfaces/memory-repository.interface.d.ts +49 -0
- package/dist/domain/interfaces/memory-repository.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/memory-repository.interface.js +6 -0
- package/dist/domain/interfaces/memory-repository.interface.js.map +1 -0
- package/dist/domain/interfaces/pattern-repository.interface.d.ts +48 -0
- package/dist/domain/interfaces/pattern-repository.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/pattern-repository.interface.js +6 -0
- package/dist/domain/interfaces/pattern-repository.interface.js.map +1 -0
- package/dist/domain/interfaces/verification-service.interface.d.ts +20 -0
- package/dist/domain/interfaces/verification-service.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/verification-service.interface.js +6 -0
- package/dist/domain/interfaces/verification-service.interface.js.map +1 -0
- package/dist/domain/services/codebase-detector.d.ts +18 -0
- package/dist/domain/services/codebase-detector.d.ts.map +1 -0
- package/dist/domain/services/codebase-detector.js +91 -0
- package/dist/domain/services/codebase-detector.js.map +1 -0
- package/dist/domain/services/cross-team-pattern-sharing.d.ts +65 -0
- package/dist/domain/services/cross-team-pattern-sharing.d.ts.map +1 -0
- package/dist/domain/services/cross-team-pattern-sharing.js +125 -0
- package/dist/domain/services/cross-team-pattern-sharing.js.map +1 -0
- package/dist/domain/services/decision-recorder.d.ts +76 -0
- package/dist/domain/services/decision-recorder.d.ts.map +1 -0
- package/dist/domain/services/decision-recorder.js +223 -0
- package/dist/domain/services/decision-recorder.js.map +1 -0
- package/dist/domain/services/decision-retriever.d.ts +75 -0
- package/dist/domain/services/decision-retriever.d.ts.map +1 -0
- package/dist/domain/services/decision-retriever.js +133 -0
- package/dist/domain/services/decision-retriever.js.map +1 -0
- 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/graded-memory-activation.d.ts +37 -0
- package/dist/domain/services/graded-memory-activation.d.ts.map +1 -0
- package/dist/domain/services/graded-memory-activation.js +69 -0
- package/dist/domain/services/graded-memory-activation.js.map +1 -0
- package/dist/domain/services/knowledge-access.d.ts +63 -0
- package/dist/domain/services/knowledge-access.d.ts.map +1 -0
- package/dist/domain/services/knowledge-access.js +132 -0
- package/dist/domain/services/knowledge-access.js.map +1 -0
- package/dist/domain/services/knowledge-extractor.d.ts +54 -0
- package/dist/domain/services/knowledge-extractor.d.ts.map +1 -0
- package/dist/domain/services/knowledge-extractor.js +247 -0
- package/dist/domain/services/knowledge-extractor.js.map +1 -0
- package/dist/domain/services/knowledge-graph-builder.d.ts +70 -0
- package/dist/domain/services/knowledge-graph-builder.d.ts.map +1 -0
- package/dist/domain/services/knowledge-graph-builder.js +268 -0
- package/dist/domain/services/knowledge-graph-builder.js.map +1 -0
- package/dist/domain/services/knowledge-graph-query.d.ts +69 -0
- package/dist/domain/services/knowledge-graph-query.d.ts.map +1 -0
- package/dist/domain/services/knowledge-graph-query.js +187 -0
- package/dist/domain/services/knowledge-graph-query.js.map +1 -0
- package/dist/domain/services/memory-retriever.d.ts +30 -0
- package/dist/domain/services/memory-retriever.d.ts.map +1 -0
- package/dist/domain/services/memory-retriever.js +82 -0
- package/dist/domain/services/memory-retriever.js.map +1 -0
- package/dist/domain/services/memory-synthesizer.d.ts +57 -0
- package/dist/domain/services/memory-synthesizer.d.ts.map +1 -0
- package/dist/domain/services/memory-synthesizer.js +91 -0
- package/dist/domain/services/memory-synthesizer.js.map +1 -0
- package/dist/domain/services/pattern-extractor.d.ts +108 -0
- package/dist/domain/services/pattern-extractor.d.ts.map +1 -0
- package/dist/domain/services/pattern-extractor.js +442 -0
- package/dist/domain/services/pattern-extractor.js.map +1 -0
- package/dist/domain/services/query-intent-classifier.d.ts +16 -0
- package/dist/domain/services/query-intent-classifier.d.ts.map +1 -0
- package/dist/domain/services/query-intent-classifier.js +173 -0
- package/dist/domain/services/query-intent-classifier.js.map +1 -0
- package/dist/domain/services/react-loop.d.ts +52 -0
- package/dist/domain/services/react-loop.d.ts.map +1 -0
- package/dist/domain/services/react-loop.js +186 -0
- package/dist/domain/services/react-loop.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/edit.d.ts +26 -0
- package/dist/edit.d.ts 2.map +1 -0
- package/dist/edit.d.ts.map +1 -0
- package/dist/edit.js +319 -0
- package/dist/edit.js.map +1 -0
- package/dist/embed.d 2.ts +14 -0
- package/dist/embed.d.ts +14 -0
- package/dist/embed.d.ts.map +1 -0
- package/dist/embed.js +472 -0
- package/dist/embed.js.map +1 -0
- package/dist/error-handler.d 2.ts +77 -0
- package/dist/error-handler.d.ts +77 -0
- package/dist/error-handler.d.ts.map +1 -0
- package/dist/error-handler.js +256 -0
- package/dist/error-handler.js.map +1 -0
- package/dist/formatter 2.js +168 -0
- package/dist/formatter.d.ts +25 -0
- package/dist/formatter.d.ts 2.map +1 -0
- package/dist/formatter.d.ts.map +1 -0
- package/dist/formatter.js +168 -0
- package/dist/formatter.js.map +1 -0
- package/dist/git 2.js +198 -0
- package/dist/git.d 2.ts +55 -0
- package/dist/git.d.ts +55 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +198 -0
- package/dist/git.js.map +1 -0
- package/dist/index 2.d.ts +16 -0
- package/dist/index 2.d.ts.map +1 -0
- package/dist/index 2.js +429 -0
- package/dist/index 2.js.map +1 -0
- package/dist/index-backup-before-lazy-loading.d.ts +3 -0
- package/dist/index-backup-before-lazy-loading.d.ts.map +1 -0
- package/dist/index-backup-before-lazy-loading.js +1551 -0
- package/dist/index-backup-before-lazy-loading.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts 2.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +489 -0
- package/dist/index.js 2.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/ai/cohere-ai-service.d.ts +71 -0
- package/dist/infrastructure/ai/cohere-ai-service.d.ts.map +1 -0
- package/dist/infrastructure/ai/cohere-ai-service.js +676 -0
- package/dist/infrastructure/ai/cohere-ai-service.js.map +1 -0
- package/dist/infrastructure/ai/command-r-evaluation.d.ts +42 -0
- package/dist/infrastructure/ai/command-r-evaluation.d.ts.map +1 -0
- package/dist/infrastructure/ai/command-r-evaluation.js +206 -0
- package/dist/infrastructure/ai/command-r-evaluation.js.map +1 -0
- package/dist/infrastructure/ai/model-config.d.ts +47 -0
- package/dist/infrastructure/ai/model-config.d.ts.map +1 -0
- package/dist/infrastructure/ai/model-config.js +84 -0
- package/dist/infrastructure/ai/model-config.js.map +1 -0
- package/dist/infrastructure/ai/provider-ai-service.d.ts +67 -0
- package/dist/infrastructure/ai/provider-ai-service.d.ts.map +1 -0
- package/dist/infrastructure/ai/provider-ai-service.js +580 -0
- package/dist/infrastructure/ai/provider-ai-service.js.map +1 -0
- package/dist/infrastructure/cache/embedding-cache.d.ts +58 -0
- package/dist/infrastructure/cache/embedding-cache.d.ts.map +1 -0
- package/dist/infrastructure/cache/embedding-cache.js +175 -0
- package/dist/infrastructure/cache/embedding-cache.js.map +1 -0
- package/dist/infrastructure/cache/query-result-cache.d.ts +27 -0
- package/dist/infrastructure/cache/query-result-cache.d.ts.map +1 -0
- package/dist/infrastructure/cache/query-result-cache.js +66 -0
- package/dist/infrastructure/cache/query-result-cache.js.map +1 -0
- 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 +16 -0
- package/dist/infrastructure/cache/security-scan-cache.d.ts.map +1 -0
- package/dist/infrastructure/cache/security-scan-cache.js +47 -0
- package/dist/infrastructure/cache/security-scan-cache.js.map +1 -0
- package/dist/infrastructure/chunking/ast-code-chunker.d.ts +12 -0
- package/dist/infrastructure/chunking/ast-code-chunker.d.ts.map +1 -0
- package/dist/infrastructure/chunking/ast-code-chunker.js +19 -0
- package/dist/infrastructure/chunking/ast-code-chunker.js.map +1 -0
- package/dist/infrastructure/chunking/code-aware-chunker.d.ts +63 -0
- package/dist/infrastructure/chunking/code-aware-chunker.d.ts.map +1 -0
- package/dist/infrastructure/chunking/code-aware-chunker.js +397 -0
- package/dist/infrastructure/chunking/code-aware-chunker.js.map +1 -0
- package/dist/infrastructure/completion/bash-completion.d.ts +7 -0
- package/dist/infrastructure/completion/bash-completion.d.ts.map +1 -0
- package/dist/infrastructure/completion/bash-completion.js +25 -0
- package/dist/infrastructure/completion/bash-completion.js.map +1 -0
- package/dist/infrastructure/completion/fish-completion.d.ts +7 -0
- package/dist/infrastructure/completion/fish-completion.d.ts.map +1 -0
- package/dist/infrastructure/completion/fish-completion.js +22 -0
- package/dist/infrastructure/completion/fish-completion.js.map +1 -0
- package/dist/infrastructure/completion/zsh-completion.d.ts +7 -0
- package/dist/infrastructure/completion/zsh-completion.d.ts.map +1 -0
- package/dist/infrastructure/completion/zsh-completion.js +30 -0
- package/dist/infrastructure/completion/zsh-completion.js.map +1 -0
- package/dist/infrastructure/config/config-manager.d.ts +158 -0
- package/dist/infrastructure/config/config-manager.d.ts.map +1 -0
- package/dist/infrastructure/config/config-manager.js +294 -0
- package/dist/infrastructure/config/config-manager.js.map +1 -0
- package/dist/infrastructure/context/context-compressor.d.ts +94 -0
- package/dist/infrastructure/context/context-compressor.d.ts.map +1 -0
- package/dist/infrastructure/context/context-compressor.js +329 -0
- package/dist/infrastructure/context/context-compressor.js.map +1 -0
- package/dist/infrastructure/context/conversation-context.d.ts +82 -0
- package/dist/infrastructure/context/conversation-context.d.ts.map +1 -0
- package/dist/infrastructure/context/conversation-context.js +213 -0
- package/dist/infrastructure/context/conversation-context.js.map +1 -0
- package/dist/infrastructure/context/direct-context-provider.d.ts +18 -0
- package/dist/infrastructure/context/direct-context-provider.d.ts.map +1 -0
- package/dist/infrastructure/context/direct-context-provider.js +222 -0
- package/dist/infrastructure/context/direct-context-provider.js.map +1 -0
- package/dist/infrastructure/context/git-context-provider.d.ts +30 -0
- package/dist/infrastructure/context/git-context-provider.d.ts.map +1 -0
- package/dist/infrastructure/context/git-context-provider.js +140 -0
- package/dist/infrastructure/context/git-context-provider.js.map +1 -0
- package/dist/infrastructure/context/project-context-loader.d.ts +35 -0
- package/dist/infrastructure/context/project-context-loader.d.ts.map +1 -0
- package/dist/infrastructure/context/project-context-loader.js +184 -0
- package/dist/infrastructure/context/project-context-loader.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 +91 -0
- package/dist/infrastructure/cost/cost-tracker.d.ts.map +1 -0
- package/dist/infrastructure/cost/cost-tracker.js +361 -0
- package/dist/infrastructure/cost/cost-tracker.js.map +1 -0
- package/dist/infrastructure/cost/session-token-tracker.d.ts +68 -0
- package/dist/infrastructure/cost/session-token-tracker.d.ts.map +1 -0
- package/dist/infrastructure/cost/session-token-tracker.js +178 -0
- package/dist/infrastructure/cost/session-token-tracker.js.map +1 -0
- package/dist/infrastructure/cost-calculator.d.ts +34 -0
- package/dist/infrastructure/cost-calculator.d.ts.map +1 -0
- package/dist/infrastructure/cost-calculator.js +145 -0
- package/dist/infrastructure/cost-calculator.js.map +1 -0
- package/dist/infrastructure/cost-estimator.d.ts +48 -0
- package/dist/infrastructure/cost-estimator.d.ts.map +1 -0
- package/dist/infrastructure/cost-estimator.js +201 -0
- package/dist/infrastructure/cost-estimator.js.map +1 -0
- package/dist/infrastructure/file-scanner/file-scanner.d.ts +31 -0
- package/dist/infrastructure/file-scanner/file-scanner.d.ts.map +1 -0
- package/dist/infrastructure/file-scanner/file-scanner.js +106 -0
- package/dist/infrastructure/file-scanner/file-scanner.js.map +1 -0
- package/dist/infrastructure/governance/nist-ai-rmf.d.ts +105 -0
- package/dist/infrastructure/governance/nist-ai-rmf.d.ts.map +1 -0
- package/dist/infrastructure/governance/nist-ai-rmf.js +292 -0
- package/dist/infrastructure/governance/nist-ai-rmf.js.map +1 -0
- package/dist/infrastructure/governance/policy-as-code.d.ts +88 -0
- package/dist/infrastructure/governance/policy-as-code.d.ts.map +1 -0
- package/dist/infrastructure/governance/policy-as-code.js +257 -0
- package/dist/infrastructure/governance/policy-as-code.js.map +1 -0
- package/dist/infrastructure/governance/prompt-to-code-lineage.d.ts +136 -0
- package/dist/infrastructure/governance/prompt-to-code-lineage.d.ts.map +1 -0
- package/dist/infrastructure/governance/prompt-to-code-lineage.js +239 -0
- package/dist/infrastructure/governance/prompt-to-code-lineage.js.map +1 -0
- package/dist/infrastructure/index.d.ts +7 -0
- package/dist/infrastructure/index.d.ts.map +1 -0
- package/dist/infrastructure/index.js +7 -0
- package/dist/infrastructure/index.js.map +1 -0
- package/dist/infrastructure/observability/execution-tracer.d.ts +130 -0
- package/dist/infrastructure/observability/execution-tracer.d.ts.map +1 -0
- package/dist/infrastructure/observability/execution-tracer.js +400 -0
- package/dist/infrastructure/observability/execution-tracer.js.map +1 -0
- package/dist/infrastructure/observability/prompt-versioner.d.ts +67 -0
- package/dist/infrastructure/observability/prompt-versioner.d.ts.map +1 -0
- package/dist/infrastructure/observability/prompt-versioner.js +145 -0
- package/dist/infrastructure/observability/prompt-versioner.js.map +1 -0
- package/dist/infrastructure/protocols/a2a-metadata.d.ts +278 -0
- package/dist/infrastructure/protocols/a2a-metadata.d.ts.map +1 -0
- package/dist/infrastructure/protocols/a2a-metadata.js +137 -0
- package/dist/infrastructure/protocols/a2a-metadata.js.map +1 -0
- package/dist/infrastructure/protocols/a2a-protocol.d.ts +132 -0
- package/dist/infrastructure/protocols/a2a-protocol.d.ts.map +1 -0
- package/dist/infrastructure/protocols/a2a-protocol.js +314 -0
- package/dist/infrastructure/protocols/a2a-protocol.js.map +1 -0
- package/dist/infrastructure/protocols/mcp-oauth.d.ts +91 -0
- package/dist/infrastructure/protocols/mcp-oauth.d.ts.map +1 -0
- package/dist/infrastructure/protocols/mcp-oauth.js +184 -0
- package/dist/infrastructure/protocols/mcp-oauth.js.map +1 -0
- package/dist/infrastructure/protocols/mcp-server.d.ts +126 -0
- package/dist/infrastructure/protocols/mcp-server.d.ts.map +1 -0
- package/dist/infrastructure/protocols/mcp-server.js +333 -0
- package/dist/infrastructure/protocols/mcp-server.js.map +1 -0
- package/dist/infrastructure/protocols/streaming-handler.d.ts +57 -0
- package/dist/infrastructure/protocols/streaming-handler.d.ts.map +1 -0
- package/dist/infrastructure/protocols/streaming-handler.js +103 -0
- package/dist/infrastructure/protocols/streaming-handler.js.map +1 -0
- 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 +470 -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 +138 -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 +336 -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 +445 -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 +407 -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/security/ai-sast-scanner.d.ts +59 -0
- package/dist/infrastructure/security/ai-sast-scanner.d.ts.map +1 -0
- package/dist/infrastructure/security/ai-sast-scanner.js +241 -0
- package/dist/infrastructure/security/ai-sast-scanner.js.map +1 -0
- package/dist/infrastructure/security/docker-sandbox.d.ts +57 -0
- package/dist/infrastructure/security/docker-sandbox.d.ts.map +1 -0
- package/dist/infrastructure/security/docker-sandbox.js +178 -0
- package/dist/infrastructure/security/docker-sandbox.js.map +1 -0
- package/dist/infrastructure/security/enhanced-security-gate.d.ts +66 -0
- package/dist/infrastructure/security/enhanced-security-gate.d.ts.map +1 -0
- package/dist/infrastructure/security/enhanced-security-gate.js +210 -0
- package/dist/infrastructure/security/enhanced-security-gate.js.map +1 -0
- package/dist/infrastructure/security/input-validator.d.ts +46 -0
- package/dist/infrastructure/security/input-validator.d.ts.map +1 -0
- package/dist/infrastructure/security/input-validator.js +269 -0
- package/dist/infrastructure/security/input-validator.js.map +1 -0
- package/dist/infrastructure/security/license-scanner.d.ts +55 -0
- package/dist/infrastructure/security/license-scanner.d.ts.map +1 -0
- package/dist/infrastructure/security/license-scanner.js +167 -0
- package/dist/infrastructure/security/license-scanner.js.map +1 -0
- package/dist/infrastructure/security/provider-bias-detector.d.ts +53 -0
- package/dist/infrastructure/security/provider-bias-detector.d.ts.map +1 -0
- package/dist/infrastructure/security/provider-bias-detector.js +164 -0
- package/dist/infrastructure/security/provider-bias-detector.js.map +1 -0
- package/dist/infrastructure/security/sandbox-executor.d.ts +34 -0
- package/dist/infrastructure/security/sandbox-executor.d.ts.map +1 -0
- package/dist/infrastructure/security/sandbox-executor.js +64 -0
- package/dist/infrastructure/security/sandbox-executor.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 +47 -0
- package/dist/infrastructure/storage/embeddings-path.js.map +1 -0
- package/dist/infrastructure/storage/memory-stream-service.d.ts +47 -0
- package/dist/infrastructure/storage/memory-stream-service.d.ts.map +1 -0
- package/dist/infrastructure/storage/memory-stream-service.js +204 -0
- package/dist/infrastructure/storage/memory-stream-service.js.map +1 -0
- package/dist/infrastructure/storage/plan-repository.d.ts +40 -0
- package/dist/infrastructure/storage/plan-repository.d.ts.map +1 -0
- package/dist/infrastructure/storage/plan-repository.js +95 -0
- package/dist/infrastructure/storage/plan-repository.js.map +1 -0
- package/dist/infrastructure/storage/sqlite-context-repository.d.ts +95 -0
- package/dist/infrastructure/storage/sqlite-context-repository.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite-context-repository.js +467 -0
- package/dist/infrastructure/storage/sqlite-context-repository.js.map +1 -0
- package/dist/infrastructure/storage/sqlite-decision-repository.d.ts +29 -0
- package/dist/infrastructure/storage/sqlite-decision-repository.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite-decision-repository.js +228 -0
- package/dist/infrastructure/storage/sqlite-decision-repository.js.map +1 -0
- package/dist/infrastructure/storage/sqlite-embedding-repository.d.ts +47 -0
- package/dist/infrastructure/storage/sqlite-embedding-repository.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite-embedding-repository.js +323 -0
- package/dist/infrastructure/storage/sqlite-embedding-repository.js.map +1 -0
- package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.d.ts +41 -0
- package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.js +413 -0
- package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.js.map +1 -0
- package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.d.ts +29 -0
- package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.js +226 -0
- package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.js.map +1 -0
- package/dist/infrastructure/storage/sqlite-memory-repository.d.ts +40 -0
- package/dist/infrastructure/storage/sqlite-memory-repository.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite-memory-repository.js +225 -0
- package/dist/infrastructure/storage/sqlite-memory-repository.js.map +1 -0
- package/dist/infrastructure/storage/sqlite-pattern-repository.d.ts +25 -0
- package/dist/infrastructure/storage/sqlite-pattern-repository.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite-pattern-repository.js +245 -0
- package/dist/infrastructure/storage/sqlite-pattern-repository.js.map +1 -0
- 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/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/appropriate-friction.d.ts +77 -0
- package/dist/infrastructure/ux/appropriate-friction.d.ts.map +1 -0
- package/dist/infrastructure/ux/appropriate-friction.js +213 -0
- package/dist/infrastructure/ux/appropriate-friction.js.map +1 -0
- package/dist/infrastructure/ux/bi-directional-learning.d.ts +131 -0
- package/dist/infrastructure/ux/bi-directional-learning.d.ts.map +1 -0
- package/dist/infrastructure/ux/bi-directional-learning.js +337 -0
- package/dist/infrastructure/ux/bi-directional-learning.js.map +1 -0
- 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/cli-style-guide.d.ts +105 -0
- package/dist/infrastructure/ux/cli-style-guide.d.ts.map +1 -0
- package/dist/infrastructure/ux/cli-style-guide.js +220 -0
- package/dist/infrastructure/ux/cli-style-guide.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 +11 -0
- package/dist/infrastructure/ux/contextual-feature-discovery.d.ts.map +1 -0
- package/dist/infrastructure/ux/contextual-feature-discovery.js +10 -0
- package/dist/infrastructure/ux/contextual-feature-discovery.js.map +1 -0
- package/dist/infrastructure/ux/expectation-management.d.ts +98 -0
- package/dist/infrastructure/ux/expectation-management.d.ts.map +1 -0
- package/dist/infrastructure/ux/expectation-management.js +327 -0
- package/dist/infrastructure/ux/expectation-management.js.map +1 -0
- package/dist/infrastructure/ux/feature-discovery.d.ts +17 -0
- package/dist/infrastructure/ux/feature-discovery.d.ts.map +1 -0
- package/dist/infrastructure/ux/feature-discovery.js +14 -0
- package/dist/infrastructure/ux/feature-discovery.js.map +1 -0
- 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-validation.d.ts +139 -0
- package/dist/infrastructure/ux/hitl-validation.d.ts.map +1 -0
- package/dist/infrastructure/ux/hitl-validation.js +297 -0
- package/dist/infrastructure/ux/hitl-validation.js.map +1 -0
- package/dist/infrastructure/ux/progress-indicator.d.ts +53 -0
- package/dist/infrastructure/ux/progress-indicator.d.ts.map +1 -0
- package/dist/infrastructure/ux/progress-indicator.js +116 -0
- package/dist/infrastructure/ux/progress-indicator.js.map +1 -0
- package/dist/infrastructure/ux/progressive-disclosure.d.ts +84 -0
- package/dist/infrastructure/ux/progressive-disclosure.d.ts.map +1 -0
- package/dist/infrastructure/ux/progressive-disclosure.js +236 -0
- package/dist/infrastructure/ux/progressive-disclosure.js.map +1 -0
- package/dist/infrastructure/ux/review-checkpoint.d.ts +37 -0
- package/dist/infrastructure/ux/review-checkpoint.d.ts.map +1 -0
- package/dist/infrastructure/ux/review-checkpoint.js +72 -0
- package/dist/infrastructure/ux/review-checkpoint.js.map +1 -0
- package/dist/infrastructure/ux/staged-feature-intro.d.ts +22 -0
- package/dist/infrastructure/ux/staged-feature-intro.d.ts.map +1 -0
- package/dist/infrastructure/ux/staged-feature-intro.js +24 -0
- package/dist/infrastructure/ux/staged-feature-intro.js.map +1 -0
- package/dist/infrastructure/ux/syntax-highlighter.d.ts +20 -0
- package/dist/infrastructure/ux/syntax-highlighter.d.ts.map +1 -0
- package/dist/infrastructure/ux/syntax-highlighter.js +91 -0
- package/dist/infrastructure/ux/syntax-highlighter.js.map +1 -0
- package/dist/infrastructure/ux/team-standards.d.ts +94 -0
- package/dist/infrastructure/ux/team-standards.d.ts.map +1 -0
- package/dist/infrastructure/ux/team-standards.js +196 -0
- package/dist/infrastructure/ux/team-standards.js.map +1 -0
- package/dist/infrastructure/validation/agent-feedback.d.ts +57 -0
- package/dist/infrastructure/validation/agent-feedback.d.ts.map +1 -0
- package/dist/infrastructure/validation/agent-feedback.js +100 -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/hallucination-detector.d.ts +121 -0
- package/dist/infrastructure/validation/hallucination-detector.d.ts.map +1 -0
- package/dist/infrastructure/validation/hallucination-detector.js +388 -0
- package/dist/infrastructure/validation/hallucination-detector.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/verification/verification-service.d.ts +12 -0
- package/dist/infrastructure/verification/verification-service.d.ts.map +1 -0
- package/dist/infrastructure/verification/verification-service.js +47 -0
- package/dist/infrastructure/verification/verification-service.js.map +1 -0
- package/dist/infrastructure/xai/attention-visualizer.d.ts +71 -0
- package/dist/infrastructure/xai/attention-visualizer.d.ts.map +1 -0
- package/dist/infrastructure/xai/attention-visualizer.js +172 -0
- package/dist/infrastructure/xai/attention-visualizer.js.map +1 -0
- package/dist/infrastructure/xai/cot-visualizer.d.ts +103 -0
- package/dist/infrastructure/xai/cot-visualizer.d.ts.map +1 -0
- package/dist/infrastructure/xai/cot-visualizer.js +283 -0
- package/dist/infrastructure/xai/cot-visualizer.js.map +1 -0
- package/dist/infrastructure/xai/decision-tree-log.d.ts +100 -0
- package/dist/infrastructure/xai/decision-tree-log.d.ts.map +1 -0
- package/dist/infrastructure/xai/decision-tree-log.js +212 -0
- package/dist/infrastructure/xai/decision-tree-log.js.map +1 -0
- package/dist/infrastructure/xai/interactive-xai.d.ts +104 -0
- package/dist/infrastructure/xai/interactive-xai.d.ts.map +1 -0
- package/dist/infrastructure/xai/interactive-xai.js +260 -0
- package/dist/infrastructure/xai/interactive-xai.js.map +1 -0
- package/dist/infrastructure/xai/uncertainty-quantifier.d.ts +77 -0
- package/dist/infrastructure/xai/uncertainty-quantifier.d.ts.map +1 -0
- package/dist/infrastructure/xai/uncertainty-quantifier.js +198 -0
- package/dist/infrastructure/xai/uncertainty-quantifier.js.map +1 -0
- package/dist/intelligent-retrieval 2.js +272 -0
- package/dist/intelligent-retrieval.d.ts +41 -0
- package/dist/intelligent-retrieval.d.ts 2.map +1 -0
- package/dist/intelligent-retrieval.d.ts.map +1 -0
- package/dist/intelligent-retrieval.js +272 -0
- package/dist/intelligent-retrieval.js.map +1 -0
- package/dist/intent/classifier.d.ts +6 -0
- package/dist/intent/classifier.d.ts.map +1 -0
- package/dist/intent/classifier.js +2 -0
- package/dist/intent/classifier.js.map +1 -0
- package/dist/intent/context.d.ts +4 -0
- package/dist/intent/context.d.ts.map +1 -0
- package/dist/intent/context.js +2 -0
- package/dist/intent/context.js.map +1 -0
- package/dist/iterative-refinement.d.ts +31 -0
- package/dist/iterative-refinement.d.ts.map +1 -0
- package/dist/iterative-refinement.js +189 -0
- package/dist/iterative-refinement.js.map +1 -0
- package/dist/learning.d.ts +69 -0
- package/dist/learning.d.ts.map +1 -0
- package/dist/learning.js +232 -0
- package/dist/learning.js.map +1 -0
- package/dist/log.d.ts +4 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +31 -0
- package/dist/log.js 2.map +1 -0
- package/dist/log.js.map +1 -0
- package/dist/migrate.d.ts +33 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +133 -0
- package/dist/migrate.js 2.map +1 -0
- package/dist/migrate.js.map +1 -0
- package/dist/monitoring.d.ts +75 -0
- package/dist/monitoring.d.ts.map +1 -0
- package/dist/monitoring.js +250 -0
- package/dist/monitoring.js.map +1 -0
- package/dist/parallel-processor.d 2.ts +44 -0
- package/dist/parallel-processor.d.ts +44 -0
- package/dist/parallel-processor.d.ts.map +1 -0
- package/dist/parallel-processor.js +606 -0
- package/dist/parallel-processor.js.map +1 -0
- package/dist/planner.d.ts +47 -0
- package/dist/planner.d.ts.map +1 -0
- package/dist/planner.js +198 -0
- package/dist/planner.js.map +1 -0
- package/dist/policy.d 2.ts +3 -0
- package/dist/policy.d.ts +3 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +26 -0
- package/dist/policy.js.map +1 -0
- package/dist/presentation/cli/commands/ask-command.d.ts +9 -0
- package/dist/presentation/cli/commands/ask-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/ask-command.js +355 -0
- package/dist/presentation/cli/commands/ask-command.js.map +1 -0
- package/dist/presentation/cli/commands/audit-command.d.ts +13 -0
- package/dist/presentation/cli/commands/audit-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/audit-command.js +96 -0
- package/dist/presentation/cli/commands/audit-command.js.map +1 -0
- package/dist/presentation/cli/commands/config-command.d.ts +9 -0
- package/dist/presentation/cli/commands/config-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/config-command.js +125 -0
- package/dist/presentation/cli/commands/config-command.js.map +1 -0
- package/dist/presentation/cli/commands/context-command.d.ts +32 -0
- package/dist/presentation/cli/commands/context-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/context-command.js +295 -0
- package/dist/presentation/cli/commands/context-command.js.map +1 -0
- package/dist/presentation/cli/commands/context-helper.d.ts +16 -0
- package/dist/presentation/cli/commands/context-helper.d.ts.map +1 -0
- package/dist/presentation/cli/commands/context-helper.js +88 -0
- package/dist/presentation/cli/commands/context-helper.js.map +1 -0
- package/dist/presentation/cli/commands/cost-command.d.ts +8 -0
- package/dist/presentation/cli/commands/cost-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/cost-command.js +191 -0
- package/dist/presentation/cli/commands/cost-command.js.map +1 -0
- package/dist/presentation/cli/commands/decision-command.d.ts +12 -0
- package/dist/presentation/cli/commands/decision-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/decision-command.js +207 -0
- package/dist/presentation/cli/commands/decision-command.js.map +1 -0
- 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 +15 -0
- package/dist/presentation/cli/commands/fix-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/fix-command.js +93 -0
- package/dist/presentation/cli/commands/fix-command.js.map +1 -0
- package/dist/presentation/cli/commands/help-command.d.ts +9 -0
- package/dist/presentation/cli/commands/help-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/help-command.js +283 -0
- package/dist/presentation/cli/commands/help-command.js.map +1 -0
- package/dist/presentation/cli/commands/knowledge-command.d.ts +13 -0
- package/dist/presentation/cli/commands/knowledge-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/knowledge-command.js +129 -0
- package/dist/presentation/cli/commands/knowledge-command.js.map +1 -0
- package/dist/presentation/cli/commands/learning-dashboard-command.d.ts +8 -0
- package/dist/presentation/cli/commands/learning-dashboard-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/learning-dashboard-command.js +183 -0
- package/dist/presentation/cli/commands/learning-dashboard-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 +10 -0
- package/dist/presentation/cli/commands/orchestrate-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/orchestrate-command.js +249 -0
- package/dist/presentation/cli/commands/orchestrate-command.js.map +1 -0
- package/dist/presentation/cli/commands/plan-command.d.ts +9 -0
- package/dist/presentation/cli/commands/plan-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/plan-command.js +246 -0
- package/dist/presentation/cli/commands/plan-command.js.map +1 -0
- 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 +8 -0
- package/dist/presentation/cli/commands/react-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/react-command.js +181 -0
- package/dist/presentation/cli/commands/react-command.js.map +1 -0
- 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 +10 -0
- package/dist/presentation/cli/commands/setup-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/setup-command.js +301 -0
- package/dist/presentation/cli/commands/setup-command.js.map +1 -0
- package/dist/presentation/cli/commands/smart-command.d.ts +11 -0
- package/dist/presentation/cli/commands/smart-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/smart-command.js +517 -0
- package/dist/presentation/cli/commands/smart-command.js.map +1 -0
- 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/commands/trace-command.d.ts +8 -0
- package/dist/presentation/cli/commands/trace-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/trace-command.js +129 -0
- package/dist/presentation/cli/commands/trace-command.js.map +1 -0
- package/dist/presentation/cli/commands/trust-command.d.ts +28 -0
- package/dist/presentation/cli/commands/trust-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/trust-command.js +301 -0
- package/dist/presentation/cli/commands/trust-command.js.map +1 -0
- package/dist/presentation/cli/commands/undo-command.d.ts +8 -0
- package/dist/presentation/cli/commands/undo-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/undo-command.js +150 -0
- package/dist/presentation/cli/commands/undo-command.js.map +1 -0
- package/dist/presentation/cli/error-display.d.ts +25 -0
- package/dist/presentation/cli/error-display.d.ts.map +1 -0
- package/dist/presentation/cli/error-display.js +340 -0
- package/dist/presentation/cli/error-display.js.map +1 -0
- package/dist/query-optimizer.d.ts +32 -0
- package/dist/query-optimizer.d.ts.map +1 -0
- package/dist/query-optimizer.js +205 -0
- package/dist/query-optimizer.js.map +1 -0
- package/dist/refactor.d.ts +27 -0
- package/dist/refactor.d.ts.map +1 -0
- package/dist/refactor.js +116 -0
- package/dist/refactor.js.map +1 -0
- package/dist/review 2.js +206 -0
- package/dist/review.d.ts +31 -0
- package/dist/review.d.ts.map +1 -0
- package/dist/review.js +206 -0
- package/dist/review.js.map +1 -0
- package/dist/search.d.ts +19 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +193 -0
- package/dist/search.js 2.map +1 -0
- package/dist/search.js.map +1 -0
- package/dist/session 2.js +593 -0
- package/dist/session.d.ts +17 -0
- package/dist/session.d.ts 2.map +1 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +593 -0
- package/dist/session.js.map +1 -0
- package/dist/task-verification 2.js +336 -0
- package/dist/task-verification.d.ts +39 -0
- package/dist/task-verification.d.ts 2.map +1 -0
- package/dist/task-verification.d.ts.map +1 -0
- package/dist/task-verification.js +336 -0
- package/dist/task-verification.js.map +1 -0
- package/dist/test-minimal.d.ts +2 -0
- package/dist/test-minimal.d.ts.map +1 -0
- package/dist/test-minimal.js +2 -0
- package/dist/test-minimal.js.map +1 -0
- package/dist/testgen.d.ts +24 -0
- package/dist/testgen.d.ts.map +1 -0
- package/dist/testgen.js +166 -0
- package/dist/testgen.js 2.map +1 -0
- package/dist/testgen.js.map +1 -0
- package/dist/token-optimizer.d 2.ts +20 -0
- package/dist/token-optimizer.d.ts +20 -0
- package/dist/token-optimizer.d.ts.map +1 -0
- package/dist/token-optimizer.js +282 -0
- package/dist/token-optimizer.js.map +1 -0
- package/dist/tools/bash.d.ts +53 -0
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +213 -0
- package/dist/tools/bash.js.map +1 -0
- package/dist/tools/edit.d.ts +48 -0
- package/dist/tools/edit.d.ts.map +1 -0
- package/dist/tools/edit.js +235 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/executor.d.ts +29 -0
- package/dist/tools/executor.d.ts.map +1 -0
- package/dist/tools/executor.js +153 -0
- package/dist/tools/executor.js.map +1 -0
- package/dist/tools/git-tool.d.ts +87 -0
- package/dist/tools/git-tool.d.ts.map +1 -0
- package/dist/tools/git-tool.js +292 -0
- package/dist/tools/git-tool.js.map +1 -0
- package/dist/tools/parser.d.ts +33 -0
- package/dist/tools/parser.d.ts.map +1 -0
- package/dist/tools/parser.js +158 -0
- package/dist/tools/parser.js.map +1 -0
- package/dist/tools/registry.d.ts +74 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +302 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/search.d.ts +41 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +100 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/types.d.ts +36 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/ui.d.ts +60 -0
- package/dist/ui.d.ts 2.map +1 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +334 -0
- package/dist/ui.js.map +1 -0
- package/dist/utils/check-api-status.d.ts +12 -0
- package/dist/utils/check-api-status.d.ts.map +1 -0
- package/dist/utils/check-api-status.js +82 -0
- package/dist/utils/check-api-status.js.map +1 -0
- package/dist/utils/debug.d.ts +7 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/debug.js +24 -0
- package/dist/utils/debug.js.map +1 -0
- package/dist/utils/diff-parser.d.ts +22 -0
- package/dist/utils/diff-parser.d.ts.map +1 -0
- package/dist/utils/diff-parser.js +192 -0
- package/dist/utils/diff-parser.js.map +1 -0
- package/dist/utils/provider-check.d.ts +21 -0
- package/dist/utils/provider-check.d.ts.map +1 -0
- package/dist/utils/provider-check.js +124 -0
- package/dist/utils/provider-check.js.map +1 -0
- package/dist/utils/version.d.ts +21 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +52 -0
- package/dist/utils/version.js.map +1 -0
- package/dist/verification/backup.d.ts +30 -0
- package/dist/verification/backup.d.ts.map +1 -0
- package/dist/verification/backup.js +259 -0
- package/dist/verification/backup.js.map +1 -0
- package/dist/verification/compiler.d.ts +20 -0
- package/dist/verification/compiler.d.ts.map +1 -0
- package/dist/verification/compiler.js +263 -0
- package/dist/verification/compiler.js.map +1 -0
- package/dist/verification/index.d.ts +59 -0
- package/dist/verification/index.d.ts.map +1 -0
- package/dist/verification/index.js +273 -0
- package/dist/verification/index.js.map +1 -0
- package/dist/verification/test-runner.d.ts +27 -0
- package/dist/verification/test-runner.d.ts.map +1 -0
- package/dist/verification/test-runner.js +379 -0
- package/dist/verification/test-runner.js.map +1 -0
- package/dist/verify_db.d.ts +2 -0
- package/dist/verify_db.d.ts.map +1 -0
- package/dist/verify_db.js +52 -0
- package/dist/verify_db.js 2.map +1 -0
- package/dist/verify_db.js.map +1 -0
- package/package.json +125 -0
|
@@ -0,0 +1,676 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Infrastructure: CohereAIService
|
|
3
|
+
* Implements IAIService using Cohere API
|
|
4
|
+
*
|
|
5
|
+
* @deprecated This class is deprecated and should not be used in new code.
|
|
6
|
+
* Use CohereProvider from infrastructure/providers/cohere-provider.ts instead.
|
|
7
|
+
* This class is maintained only as an emergency fallback in dependency-container.ts
|
|
8
|
+
* and requires COHERE_API_KEY environment variable to function.
|
|
9
|
+
*
|
|
10
|
+
* Migration path: Use ProviderRegistry to get providers and ProviderAIService for AI operations.
|
|
11
|
+
*/
|
|
12
|
+
import { CohereClient } from 'cohere-ai';
|
|
13
|
+
import { config } from 'dotenv';
|
|
14
|
+
import { join, dirname } from 'path';
|
|
15
|
+
import { fileURLToPath } from 'url';
|
|
16
|
+
import { encoding_for_model } from 'tiktoken';
|
|
17
|
+
import { retryWithBackoff, cohereCircuitBreaker } from '../../error-handler.js';
|
|
18
|
+
import { executionTracer } from '../observability/execution-tracer.js';
|
|
19
|
+
import { promptVersioner } from '../observability/prompt-versioner.js';
|
|
20
|
+
import { getModelConfigManager } from './model-config.js';
|
|
21
|
+
import { getConfigManager } from '../config/config-manager.js';
|
|
22
|
+
// Initialize tiktoken encoder for accurate token counting
|
|
23
|
+
// Using cl100k_base which is compatible with most models
|
|
24
|
+
let tokenEncoder = null;
|
|
25
|
+
function getTokenEncoder() {
|
|
26
|
+
if (!tokenEncoder) {
|
|
27
|
+
try {
|
|
28
|
+
// Use default model from config for token encoding (tiktoken is OpenAI-specific)
|
|
29
|
+
const config = getConfigManager();
|
|
30
|
+
const defaultModel = config.getModel('default') || config.getPreference('defaultModel');
|
|
31
|
+
// tiktoken uses OpenAI models - use GPT model if available, else default to gpt-3.5-turbo
|
|
32
|
+
const tiktokenModel = (defaultModel && defaultModel.includes('gpt')) ? defaultModel : 'gpt-3.5-turbo';
|
|
33
|
+
tokenEncoder = encoding_for_model(tiktokenModel);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// Fallback if model not found
|
|
37
|
+
tokenEncoder = encoding_for_model('gpt-3.5-turbo');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return tokenEncoder;
|
|
41
|
+
}
|
|
42
|
+
function countTokens(text) {
|
|
43
|
+
try {
|
|
44
|
+
const encoder = getTokenEncoder();
|
|
45
|
+
return encoder.encode(text).length;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
// Fallback: Use character-based estimate only if tiktoken completely fails
|
|
49
|
+
// This should rarely happen, but provides a safety net
|
|
50
|
+
console.warn('Warning: tiktoken failed, using character-based estimate (less accurate)');
|
|
51
|
+
return Math.ceil(text.length / 4);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Load .env
|
|
55
|
+
try {
|
|
56
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
57
|
+
const __dirname = dirname(__filename);
|
|
58
|
+
const agentDir = join(__dirname, '../../..');
|
|
59
|
+
config({ path: join(agentDir, '.env') });
|
|
60
|
+
}
|
|
61
|
+
catch { }
|
|
62
|
+
config();
|
|
63
|
+
export class CohereAIService {
|
|
64
|
+
client;
|
|
65
|
+
_contextCompressor;
|
|
66
|
+
constructor(contextCompressor) {
|
|
67
|
+
console.warn('[DEPRECATED] CohereAIService is deprecated. Use CohereProvider from infrastructure/providers/cohere-provider.ts instead.');
|
|
68
|
+
this._contextCompressor = contextCompressor;
|
|
69
|
+
const apiKey = process.env.COHERE_API_KEY;
|
|
70
|
+
if (!apiKey) {
|
|
71
|
+
throw new Error('COHERE_API_KEY not found in environment');
|
|
72
|
+
}
|
|
73
|
+
this.client = new CohereClient({ token: apiKey });
|
|
74
|
+
}
|
|
75
|
+
async chat(query, context, memories) {
|
|
76
|
+
// Context Compression: Compress if context is too large (P0 - prevents cost escalation)
|
|
77
|
+
let finalContext = context;
|
|
78
|
+
let finalMemories = memories;
|
|
79
|
+
let compressionMetrics;
|
|
80
|
+
// Lazy getter for context compressor to avoid circular dependency
|
|
81
|
+
const contextCompressor = this._contextCompressor || this.contextCompressor;
|
|
82
|
+
if (contextCompressor) {
|
|
83
|
+
// Estimate tokens (rough: 1 token ≈ 4 chars)
|
|
84
|
+
const estimatedTokens = context.reduce((sum, chunk) => sum + Math.ceil(chunk.content.length / 4), 0);
|
|
85
|
+
// OPTIMIZATION: Lower compression threshold to trigger earlier (3000 vs 8000)
|
|
86
|
+
// This reduces AI Chat latency by compressing context more aggressively
|
|
87
|
+
// Further reduced from 4000 to 3000 for even more aggressive compression
|
|
88
|
+
const maxTokens = 3000; // Reduced from 8000 to trigger compression earlier
|
|
89
|
+
if (estimatedTokens > maxTokens) {
|
|
90
|
+
const strategy = {
|
|
91
|
+
maxTokens,
|
|
92
|
+
preserveCode: true, // Keep code, compress comments/context
|
|
93
|
+
preserveErrors: true,
|
|
94
|
+
compressMemories: true,
|
|
95
|
+
compressObservations: false, // Not applicable here
|
|
96
|
+
};
|
|
97
|
+
const compressed = await contextCompressor.compressWithSummarization(context, query, strategy);
|
|
98
|
+
finalContext = compressed.chunks;
|
|
99
|
+
compressionMetrics = {
|
|
100
|
+
originalTokens: compressed.originalTokenCount,
|
|
101
|
+
compressedTokens: compressed.compressedTokenCount,
|
|
102
|
+
reductionPercent: compressed.reductionPercent,
|
|
103
|
+
};
|
|
104
|
+
// Compress memories if enabled
|
|
105
|
+
if (strategy.compressMemories && memories && memories.length > 10) {
|
|
106
|
+
finalMemories = await contextCompressor.compressMemories(memories, query, 10);
|
|
107
|
+
}
|
|
108
|
+
// Log compression metrics
|
|
109
|
+
const runId = executionTracer.getCurrentRunId();
|
|
110
|
+
if (runId) {
|
|
111
|
+
executionTracer.trace({
|
|
112
|
+
operationType: 'context_compression',
|
|
113
|
+
operationName: 'compress_context',
|
|
114
|
+
input: { contextCount: context.length, estimatedTokens },
|
|
115
|
+
output: {
|
|
116
|
+
compressedCount: finalContext.length,
|
|
117
|
+
...compressionMetrics
|
|
118
|
+
},
|
|
119
|
+
metadata: { strategy: 'llm_summarization' },
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Use TOON serialization if enabled, otherwise use traditional format
|
|
125
|
+
const { serializeCodeChunks } = await import('../serialization/toon-serializer.js');
|
|
126
|
+
const contextText = await serializeCodeChunks(finalContext);
|
|
127
|
+
const memoryText = finalMemories && finalMemories.length > 0
|
|
128
|
+
? `\n\nPREVIOUS EXPERIENCES:\n${finalMemories.map(m => `- ${m.description}`).join('\n')}`
|
|
129
|
+
: '';
|
|
130
|
+
// Get conversation history if available in context
|
|
131
|
+
let conversationHistoryText = '';
|
|
132
|
+
if (context.length > 0 && context[0].conversationHistory) {
|
|
133
|
+
const history = context[0].conversationHistory;
|
|
134
|
+
if (history && history.length > 0) {
|
|
135
|
+
const recentHistory = history.slice(-3); // Last 3 turns
|
|
136
|
+
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`;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const prompt = `You are a strict coding assistant for enterprise environments.
|
|
140
|
+
Use ONLY the provided code context.
|
|
141
|
+
${conversationHistoryText ? 'Consider the conversation history when answering the current query, especially if the user uses references like "it", "that", or "the previous".' : ''}
|
|
142
|
+
|
|
143
|
+
CONTEXT:
|
|
144
|
+
${contextText}${memoryText}${conversationHistoryText}
|
|
145
|
+
|
|
146
|
+
USER QUERY:
|
|
147
|
+
${query}`;
|
|
148
|
+
// Determine model based on context size and use case
|
|
149
|
+
// For now, use default. Command A evaluation will determine if we should migrate.
|
|
150
|
+
const model = this.selectModel(context.length, memories?.length || 0, 'chat');
|
|
151
|
+
// Get temperature from config
|
|
152
|
+
const config = getConfigManager();
|
|
153
|
+
const chatTemperature = config.getTemperature('chat') || 0.7;
|
|
154
|
+
// Register prompt version for reproducibility
|
|
155
|
+
const promptVersionId = promptVersioner.registerVersion(prompt, {
|
|
156
|
+
model: model || 'default',
|
|
157
|
+
temperature: chatTemperature,
|
|
158
|
+
operation: 'chat',
|
|
159
|
+
});
|
|
160
|
+
// Link to current run if available
|
|
161
|
+
const runId = executionTracer.getCurrentRunId();
|
|
162
|
+
if (runId) {
|
|
163
|
+
promptVersioner.linkRunToVersion(prompt, runId);
|
|
164
|
+
}
|
|
165
|
+
const startTime = Date.now();
|
|
166
|
+
return await retryWithBackoff(async () => {
|
|
167
|
+
return await cohereCircuitBreaker.execute(async () => {
|
|
168
|
+
// Trace LLM call
|
|
169
|
+
const traceId = executionTracer.trace({
|
|
170
|
+
operationType: 'llm_call',
|
|
171
|
+
operationName: 'chat',
|
|
172
|
+
input: { query, contextCount: context.length, memoryCount: memories?.length || 0 },
|
|
173
|
+
metadata: {
|
|
174
|
+
model: model || 'default',
|
|
175
|
+
temperature: chatTemperature,
|
|
176
|
+
promptVersionId,
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
try {
|
|
180
|
+
const response = await this.client.chat({
|
|
181
|
+
message: prompt,
|
|
182
|
+
...(model ? { model } : {}), // Only add model if specified
|
|
183
|
+
temperature: chatTemperature, // Balanced for general chat/explanation
|
|
184
|
+
});
|
|
185
|
+
const result = response.text || 'No response generated';
|
|
186
|
+
const duration = Date.now() - startTime;
|
|
187
|
+
// Count tokens for trace metadata
|
|
188
|
+
const inputTokens = countTokens(prompt);
|
|
189
|
+
const outputTokens = countTokens(result);
|
|
190
|
+
// Update trace with output
|
|
191
|
+
executionTracer.trace({
|
|
192
|
+
operationType: 'llm_call',
|
|
193
|
+
operationName: 'chat',
|
|
194
|
+
output: { responseLength: result.length, inputTokens, outputTokens },
|
|
195
|
+
duration,
|
|
196
|
+
metadata: {
|
|
197
|
+
model: model || 'default',
|
|
198
|
+
temperature: 0.7,
|
|
199
|
+
promptVersionId,
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
// Trace error
|
|
206
|
+
executionTracer.trace({
|
|
207
|
+
operationType: 'llm_call',
|
|
208
|
+
operationName: 'chat',
|
|
209
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
210
|
+
duration: Date.now() - startTime,
|
|
211
|
+
metadata: {
|
|
212
|
+
model: model || 'default',
|
|
213
|
+
temperature: 0.7,
|
|
214
|
+
promptVersionId,
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
throw error;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}, {
|
|
221
|
+
maxRetries: 5,
|
|
222
|
+
baseDelay: 2000,
|
|
223
|
+
maxDelay: 60000,
|
|
224
|
+
operationName: 'chat',
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Generate chat response with streaming support
|
|
229
|
+
* Real-time feedback for better UX (target: < 200ms latency)
|
|
230
|
+
*
|
|
231
|
+
* NOTE: Cohere SDK streaming implementation - using async iteration pattern
|
|
232
|
+
* Falls back to regular chat if streaming is not available
|
|
233
|
+
*/
|
|
234
|
+
async chatStream(query, context, memories, streamHandler) {
|
|
235
|
+
const contextText = context
|
|
236
|
+
.map((chunk, idx) => `[Chunk ${idx + 1} from ${chunk.filepath}]\n${chunk.content}`)
|
|
237
|
+
.join('\n\n---\n\n');
|
|
238
|
+
const memoryText = memories && memories.length > 0
|
|
239
|
+
? `\n\nPREVIOUS EXPERIENCES:\n${memories.map(m => `- ${m.description}`).join('\n')}`
|
|
240
|
+
: '';
|
|
241
|
+
const prompt = `You are a strict coding assistant for enterprise environments.
|
|
242
|
+
Use ONLY the provided code context.
|
|
243
|
+
|
|
244
|
+
CONTEXT:
|
|
245
|
+
${contextText}${memoryText}
|
|
246
|
+
|
|
247
|
+
USER QUERY:
|
|
248
|
+
${query}`;
|
|
249
|
+
const model = this.selectModel(context.length, memories?.length || 0, 'chat');
|
|
250
|
+
// Register prompt version
|
|
251
|
+
const promptVersionId = promptVersioner.registerVersion(prompt, {
|
|
252
|
+
model: model || 'default',
|
|
253
|
+
temperature: 0.7,
|
|
254
|
+
operation: 'chat-stream',
|
|
255
|
+
});
|
|
256
|
+
const runId = executionTracer.getCurrentRunId();
|
|
257
|
+
if (runId) {
|
|
258
|
+
promptVersioner.linkRunToVersion(prompt, runId);
|
|
259
|
+
}
|
|
260
|
+
const startTime = Date.now();
|
|
261
|
+
let fullText = '';
|
|
262
|
+
try {
|
|
263
|
+
// Trace streaming start
|
|
264
|
+
executionTracer.trace({
|
|
265
|
+
operationType: 'llm_call',
|
|
266
|
+
operationName: 'chat-stream',
|
|
267
|
+
input: { query, contextCount: context.length, memoryCount: memories?.length || 0 },
|
|
268
|
+
metadata: {
|
|
269
|
+
model: model || 'default',
|
|
270
|
+
temperature: 0.7,
|
|
271
|
+
promptVersionId,
|
|
272
|
+
streaming: true,
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
// Check if Cohere SDK supports streaming
|
|
276
|
+
// Cohere SDK v7+ should support streaming via chatStream method or stream option
|
|
277
|
+
// Fallback: Use regular chat if streaming not available
|
|
278
|
+
if (typeof this.client.chatStream === 'function') {
|
|
279
|
+
// Use Cohere's native streaming
|
|
280
|
+
const stream = await this.client.chatStream({
|
|
281
|
+
message: prompt,
|
|
282
|
+
...(model ? { model } : {}),
|
|
283
|
+
temperature: 0.7,
|
|
284
|
+
});
|
|
285
|
+
// Process stream events (Cohere SDK typically uses async iterator)
|
|
286
|
+
for await (const event of stream) {
|
|
287
|
+
if (event.eventType === 'text-generation' || event.type === 'text') {
|
|
288
|
+
const token = event.text || event.delta || '';
|
|
289
|
+
if (token) {
|
|
290
|
+
fullText += token;
|
|
291
|
+
if (streamHandler.onToken) {
|
|
292
|
+
streamHandler.onToken(token);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
// Fallback: Use regular chat and simulate streaming
|
|
300
|
+
// Split response into chunks for better UX
|
|
301
|
+
const response = await this.client.chat({
|
|
302
|
+
message: prompt,
|
|
303
|
+
...(model ? { model } : {}),
|
|
304
|
+
temperature: 0.7,
|
|
305
|
+
});
|
|
306
|
+
fullText = response.text || '';
|
|
307
|
+
// Simulate streaming by sending chunks
|
|
308
|
+
// Target: < 200ms latency (send chunks every 50-100ms)
|
|
309
|
+
const chunkSize = 10; // Characters per chunk
|
|
310
|
+
for (let i = 0; i < fullText.length; i += chunkSize) {
|
|
311
|
+
const chunk = fullText.substring(i, i + chunkSize);
|
|
312
|
+
if (streamHandler.onToken) {
|
|
313
|
+
streamHandler.onToken(chunk);
|
|
314
|
+
}
|
|
315
|
+
// Small delay to simulate streaming (only if text is long enough)
|
|
316
|
+
if (fullText.length > chunkSize * 2) {
|
|
317
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
const duration = Date.now() - startTime;
|
|
322
|
+
// Count tokens for trace metadata
|
|
323
|
+
const inputTokens = countTokens(prompt);
|
|
324
|
+
const outputTokens = countTokens(fullText);
|
|
325
|
+
// Update trace
|
|
326
|
+
executionTracer.trace({
|
|
327
|
+
operationType: 'llm_call',
|
|
328
|
+
operationName: 'chat-stream',
|
|
329
|
+
output: { responseLength: fullText.length, inputTokens, outputTokens },
|
|
330
|
+
duration,
|
|
331
|
+
metadata: {
|
|
332
|
+
model: model || 'default',
|
|
333
|
+
temperature: 0.7,
|
|
334
|
+
promptVersionId,
|
|
335
|
+
streaming: true,
|
|
336
|
+
},
|
|
337
|
+
});
|
|
338
|
+
// Call completion handler
|
|
339
|
+
if (streamHandler.onComplete) {
|
|
340
|
+
streamHandler.onComplete(fullText);
|
|
341
|
+
}
|
|
342
|
+
return fullText;
|
|
343
|
+
}
|
|
344
|
+
catch (error) {
|
|
345
|
+
const duration = Date.now() - startTime;
|
|
346
|
+
// Trace error
|
|
347
|
+
executionTracer.trace({
|
|
348
|
+
operationType: 'llm_call',
|
|
349
|
+
operationName: 'chat-stream',
|
|
350
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
351
|
+
duration,
|
|
352
|
+
metadata: {
|
|
353
|
+
model: model || 'default',
|
|
354
|
+
temperature: 0.7,
|
|
355
|
+
promptVersionId,
|
|
356
|
+
streaming: true,
|
|
357
|
+
},
|
|
358
|
+
});
|
|
359
|
+
// Call error handler
|
|
360
|
+
if (streamHandler.onError) {
|
|
361
|
+
streamHandler.onError(error instanceof Error ? error : new Error(String(error)));
|
|
362
|
+
}
|
|
363
|
+
throw error;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Select appropriate model based on context size and use case
|
|
368
|
+
* Returns model name if we should use a specific model, undefined for default
|
|
369
|
+
* Uses model configuration from Command A evaluation results
|
|
370
|
+
*/
|
|
371
|
+
selectModel(contextChunks, memoryCount, useCase = 'default') {
|
|
372
|
+
const modelConfig = getModelConfigManager();
|
|
373
|
+
// Check if Command models are available from evaluation
|
|
374
|
+
if (modelConfig.isCommandModelAvailable()) {
|
|
375
|
+
const preferredModel = modelConfig.getPreferredModel(useCase);
|
|
376
|
+
if (preferredModel) {
|
|
377
|
+
return preferredModel;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
// Use default model for now (will be updated after Command A evaluation)
|
|
381
|
+
// Large context or many memories → might need Command A (after evaluation)
|
|
382
|
+
if (contextChunks > 20 || memoryCount > 10) {
|
|
383
|
+
// After evaluation, this will return the preferred Command model
|
|
384
|
+
return undefined; // Use default for now
|
|
385
|
+
}
|
|
386
|
+
return undefined; // Use default
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Embed text as documents (for code chunks, memory storage)
|
|
390
|
+
* Uses 'search_document' input type for optimal document embedding
|
|
391
|
+
*/
|
|
392
|
+
async embed(text) {
|
|
393
|
+
const texts = Array.isArray(text) ? text : [text];
|
|
394
|
+
return await retryWithBackoff(async () => {
|
|
395
|
+
return await cohereCircuitBreaker.execute(async () => {
|
|
396
|
+
const response = await this.client.embed({
|
|
397
|
+
texts,
|
|
398
|
+
model: 'embed-english-v3.0',
|
|
399
|
+
inputType: 'search_document', // For code chunks/documents
|
|
400
|
+
});
|
|
401
|
+
const embeddings = response.embeddings;
|
|
402
|
+
if (texts.length === 1) {
|
|
403
|
+
return embeddings[0];
|
|
404
|
+
}
|
|
405
|
+
return embeddings;
|
|
406
|
+
});
|
|
407
|
+
}, {
|
|
408
|
+
maxRetries: 5,
|
|
409
|
+
baseDelay: 2000,
|
|
410
|
+
maxDelay: 60000,
|
|
411
|
+
operationName: 'embed',
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Embed text as a search query (for user queries)
|
|
416
|
+
* Uses 'search_query' input type for optimal query-document matching
|
|
417
|
+
* This is critical for better search quality!
|
|
418
|
+
*/
|
|
419
|
+
async embedQuery(query) {
|
|
420
|
+
return await retryWithBackoff(async () => {
|
|
421
|
+
return await cohereCircuitBreaker.execute(async () => {
|
|
422
|
+
const response = await this.client.embed({
|
|
423
|
+
texts: [query],
|
|
424
|
+
model: 'embed-english-v3.0',
|
|
425
|
+
inputType: 'search_query', // For user queries - better matching!
|
|
426
|
+
});
|
|
427
|
+
const embeddings = response.embeddings;
|
|
428
|
+
// Handle both array and object response types
|
|
429
|
+
if (Array.isArray(embeddings)) {
|
|
430
|
+
if (embeddings.length === 0) {
|
|
431
|
+
throw new Error('No embedding returned for query');
|
|
432
|
+
}
|
|
433
|
+
return embeddings[0] || [];
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
// Handle EmbedByTypeResponseEmbeddings type
|
|
437
|
+
const embeddingsArray = embeddings.float || [];
|
|
438
|
+
if (embeddingsArray.length === 0) {
|
|
439
|
+
throw new Error('No embedding returned for query');
|
|
440
|
+
}
|
|
441
|
+
return embeddingsArray[0] || [];
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
}, {
|
|
445
|
+
maxRetries: 5,
|
|
446
|
+
baseDelay: 2000,
|
|
447
|
+
maxDelay: 60000,
|
|
448
|
+
operationName: 'embedQuery',
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
async generateEdit(fileContent, instruction, filepath, requestExplanation) {
|
|
452
|
+
// For simplicity and reliability, always request the complete modified file
|
|
453
|
+
// This avoids diff parsing issues and is more reliable
|
|
454
|
+
let prompt;
|
|
455
|
+
if (requestExplanation) {
|
|
456
|
+
// Learning mode: request both code and explanation
|
|
457
|
+
prompt = `You are a code editor and teacher. Your task is to modify the code AND explain what you changed and why.
|
|
458
|
+
|
|
459
|
+
CRITICAL RULES:
|
|
460
|
+
1. First, provide the COMPLETE modified file content
|
|
461
|
+
2. Then add a line with exactly: ---EXPLANATION---
|
|
462
|
+
3. After that separator, provide a clear explanation of what changed and why
|
|
463
|
+
4. If renaming a function/class/variable, you MUST update ALL references
|
|
464
|
+
5. Maintain exact indentation and formatting from the original
|
|
465
|
+
6. Only modify what's necessary for the instruction
|
|
466
|
+
|
|
467
|
+
FILE: ${filepath}
|
|
468
|
+
|
|
469
|
+
CURRENT CODE:
|
|
470
|
+
\`\`\`
|
|
471
|
+
${fileContent}
|
|
472
|
+
\`\`\`
|
|
473
|
+
|
|
474
|
+
INSTRUCTION: ${instruction}
|
|
475
|
+
|
|
476
|
+
Return format:
|
|
477
|
+
1. Complete modified file content (entire file, not a diff)
|
|
478
|
+
2. A line with: ---EXPLANATION---
|
|
479
|
+
3. Your explanation of the changes`;
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
// Standard mode: just code
|
|
483
|
+
prompt = `You are a code editor. Return the COMPLETE modified file content.
|
|
484
|
+
|
|
485
|
+
CRITICAL RULES:
|
|
486
|
+
1. Return ONLY the complete modified file content - no explanations, no markdown, no code blocks
|
|
487
|
+
2. If renaming a function/class/variable, you MUST update ALL references
|
|
488
|
+
3. Maintain exact indentation and formatting from the original
|
|
489
|
+
4. Only modify what's necessary for the instruction
|
|
490
|
+
5. Return the ENTIRE file, not just the changes
|
|
491
|
+
|
|
492
|
+
FILE: ${filepath}
|
|
493
|
+
|
|
494
|
+
CURRENT CODE:
|
|
495
|
+
\`\`\`
|
|
496
|
+
${fileContent}
|
|
497
|
+
\`\`\`
|
|
498
|
+
|
|
499
|
+
INSTRUCTION: ${instruction}
|
|
500
|
+
|
|
501
|
+
Return the COMPLETE modified file content (entire file, not a diff):`;
|
|
502
|
+
}
|
|
503
|
+
return await retryWithBackoff(async () => {
|
|
504
|
+
return await cohereCircuitBreaker.execute(async () => {
|
|
505
|
+
const response = await this.client.chat({
|
|
506
|
+
message: prompt,
|
|
507
|
+
temperature: 0.3, // Lower for deterministic code generation and editing
|
|
508
|
+
});
|
|
509
|
+
const responseText = response.text || '';
|
|
510
|
+
// Parse response to extract code and explanation if requested
|
|
511
|
+
let text = responseText;
|
|
512
|
+
let explanation;
|
|
513
|
+
if (requestExplanation) {
|
|
514
|
+
const separatorIndex = responseText.indexOf('---EXPLANATION---');
|
|
515
|
+
if (separatorIndex !== -1) {
|
|
516
|
+
text = responseText.substring(0, separatorIndex).trim();
|
|
517
|
+
explanation = responseText.substring(separatorIndex + '---EXPLANATION---'.length).trim();
|
|
518
|
+
}
|
|
519
|
+
else {
|
|
520
|
+
// Fallback: if separator not found, treat entire response as code
|
|
521
|
+
text = responseText;
|
|
522
|
+
explanation = 'Explanation not provided in expected format.';
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
// Extract usage data if available from Cohere API
|
|
526
|
+
const usage = response.meta?.tokens ? {
|
|
527
|
+
inputTokens: response.meta.tokens.inputTokens || 0,
|
|
528
|
+
outputTokens: response.meta.tokens.outputTokens || 0,
|
|
529
|
+
} : undefined;
|
|
530
|
+
// Cohere SDK doesn't expose model in response, use configured model
|
|
531
|
+
const model = 'command-r';
|
|
532
|
+
return { text, explanation, usage, model };
|
|
533
|
+
});
|
|
534
|
+
}, {
|
|
535
|
+
maxRetries: 3,
|
|
536
|
+
baseDelay: 2000,
|
|
537
|
+
maxDelay: 30000,
|
|
538
|
+
operationName: 'generateEdit',
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
async generateFileContent(filepath, instruction, requirements = []) {
|
|
542
|
+
const requirementsText = requirements.length > 0
|
|
543
|
+
? `\n\nREQUIREMENTS:\n${requirements.map((r, i) => `${i + 1}. ${r}`).join('\n')}`
|
|
544
|
+
: '';
|
|
545
|
+
// Detect file type from extension
|
|
546
|
+
const ext = filepath.split('.').pop()?.toLowerCase() || '';
|
|
547
|
+
const languageMap = {
|
|
548
|
+
'ts': 'TypeScript',
|
|
549
|
+
'js': 'JavaScript',
|
|
550
|
+
'tsx': 'TypeScript React',
|
|
551
|
+
'jsx': 'JavaScript React',
|
|
552
|
+
'py': 'Python',
|
|
553
|
+
'java': 'Java',
|
|
554
|
+
'go': 'Go',
|
|
555
|
+
'rs': 'Rust',
|
|
556
|
+
'rb': 'Ruby',
|
|
557
|
+
'php': 'PHP',
|
|
558
|
+
'vue': 'Vue',
|
|
559
|
+
'svelte': 'Svelte',
|
|
560
|
+
'html': 'HTML',
|
|
561
|
+
'css': 'CSS',
|
|
562
|
+
'json': 'JSON',
|
|
563
|
+
'yaml': 'YAML',
|
|
564
|
+
'yml': 'YAML',
|
|
565
|
+
'md': 'Markdown',
|
|
566
|
+
'sh': 'Bash',
|
|
567
|
+
'bash': 'Bash',
|
|
568
|
+
};
|
|
569
|
+
const language = languageMap[ext] || 'code';
|
|
570
|
+
const prompt = `You are a code generator. Create a NEW ${language} file from scratch.
|
|
571
|
+
|
|
572
|
+
CRITICAL RULES:
|
|
573
|
+
1. Return ONLY the complete file content - no explanations, no markdown, no code blocks
|
|
574
|
+
2. Follow ${language} best practices and conventions
|
|
575
|
+
3. Include proper imports, exports, and structure
|
|
576
|
+
4. Add appropriate comments for clarity
|
|
577
|
+
5. Ensure the code is production-ready and well-structured
|
|
578
|
+
|
|
579
|
+
FILE PATH: ${filepath}
|
|
580
|
+
FILE TYPE: ${language}${requirementsText}
|
|
581
|
+
|
|
582
|
+
INSTRUCTION: ${instruction}
|
|
583
|
+
|
|
584
|
+
Return the COMPLETE file content (entire file, ready to save):`;
|
|
585
|
+
return await retryWithBackoff(async () => {
|
|
586
|
+
return await cohereCircuitBreaker.execute(async () => {
|
|
587
|
+
const response = await this.client.chat({
|
|
588
|
+
message: prompt,
|
|
589
|
+
temperature: 0.35, // Slightly higher for new file generation (allows some creativity while staying deterministic)
|
|
590
|
+
});
|
|
591
|
+
let content = response.text || '';
|
|
592
|
+
// Clean up common markdown formatting
|
|
593
|
+
// Remove code blocks if present
|
|
594
|
+
content = content.replace(/^```[\w]*\n?/gm, '');
|
|
595
|
+
content = content.replace(/^```$/gm, '');
|
|
596
|
+
content = content.trim();
|
|
597
|
+
return content;
|
|
598
|
+
});
|
|
599
|
+
}, {
|
|
600
|
+
maxRetries: 3,
|
|
601
|
+
baseDelay: 2000,
|
|
602
|
+
maxDelay: 30000,
|
|
603
|
+
operationName: 'generateFileContent',
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
async generateReflection(trajectory, reward, errors) {
|
|
607
|
+
const prompt = `You are a self-reflection model. Analyze the following failed trajectory:
|
|
608
|
+
|
|
609
|
+
Trajectory:
|
|
610
|
+
${JSON.stringify(trajectory, null, 2)}
|
|
611
|
+
|
|
612
|
+
Reward: ${reward}
|
|
613
|
+
Errors: ${errors.join('; ')}
|
|
614
|
+
|
|
615
|
+
Generate a reflective text that:
|
|
616
|
+
1. Identifies the root cause of failure
|
|
617
|
+
2. Explains what went wrong
|
|
618
|
+
3. Suggests specific improvements for the next attempt
|
|
619
|
+
4. Extracts lessons learned
|
|
620
|
+
|
|
621
|
+
Reflection:`;
|
|
622
|
+
return await retryWithBackoff(async () => {
|
|
623
|
+
return await cohereCircuitBreaker.execute(async () => {
|
|
624
|
+
const response = await this.client.chat({
|
|
625
|
+
message: prompt,
|
|
626
|
+
temperature: 0.5, // Balanced for reflection (analytical but open to insights)
|
|
627
|
+
});
|
|
628
|
+
const result = response.text || '';
|
|
629
|
+
return result;
|
|
630
|
+
});
|
|
631
|
+
}, {
|
|
632
|
+
maxRetries: 3,
|
|
633
|
+
baseDelay: 2000,
|
|
634
|
+
maxDelay: 30000,
|
|
635
|
+
operationName: 'generateReflection',
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Rerank search results using Cohere Rerank API
|
|
640
|
+
* Implements two-stage retrieval: initial recall → rerank precision
|
|
641
|
+
*
|
|
642
|
+
* Strategy:
|
|
643
|
+
* 1. Initial retrieval (vector search) finds candidate documents
|
|
644
|
+
* 2. Rerank API scores and reorders for precision
|
|
645
|
+
* 3. Returns top N most relevant results
|
|
646
|
+
*/
|
|
647
|
+
async rerank(query, documents, topN = 10) {
|
|
648
|
+
if (documents.length === 0) {
|
|
649
|
+
return [];
|
|
650
|
+
}
|
|
651
|
+
// Cohere Rerank API has limits, so we cap at 100 documents
|
|
652
|
+
const documentsToRerank = documents.slice(0, 100);
|
|
653
|
+
const topNAdjusted = Math.min(topN, documentsToRerank.length);
|
|
654
|
+
return await retryWithBackoff(async () => {
|
|
655
|
+
return await cohereCircuitBreaker.execute(async () => {
|
|
656
|
+
const response = await this.client.rerank({
|
|
657
|
+
model: 'rerank-english-v3.0', // Use latest English rerank model
|
|
658
|
+
query,
|
|
659
|
+
documents: documentsToRerank,
|
|
660
|
+
topN: topNAdjusted,
|
|
661
|
+
});
|
|
662
|
+
// Map Cohere rerank results to our format
|
|
663
|
+
return (response.results || []).map((result) => ({
|
|
664
|
+
index: result.index,
|
|
665
|
+
relevanceScore: result.relevanceScore || 0,
|
|
666
|
+
}));
|
|
667
|
+
});
|
|
668
|
+
}, {
|
|
669
|
+
maxRetries: 3,
|
|
670
|
+
baseDelay: 2000,
|
|
671
|
+
maxDelay: 30000,
|
|
672
|
+
operationName: 'rerank',
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
//# sourceMappingURL=cohere-ai-service.js.map
|