codehere 0.5.1-alpha → 0.5.3-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +126 -102
- package/dist/application/agents/execution-agent.js +2 -2
- package/dist/application/agents/multi-agent-orchestrator.d.ts +0 -1
- package/dist/application/agents/multi-agent-orchestrator.d.ts.map +1 -1
- package/dist/application/agents/multi-agent-orchestrator.js +2 -9
- package/dist/application/agents/multi-agent-orchestrator.js.map +1 -1
- package/dist/application/agents/planning-agent.d.ts.map +1 -1
- package/dist/application/agents/planning-agent.js +11 -15
- package/dist/application/agents/planning-agent.js.map +1 -1
- 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.map +1 -1
- package/dist/application/services/dependency-container.js +7 -5
- package/dist/application/services/dependency-container.js.map +1 -1
- package/dist/application/services/intelligent-router.d.ts +8 -5
- package/dist/application/services/intelligent-router.d.ts.map +1 -1
- package/dist/application/services/intelligent-router.js +78 -82
- package/dist/application/services/intelligent-router.js.map +1 -1
- 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/use-cases/ask-question-use-case.d.ts.map +1 -1
- package/dist/application/use-cases/ask-question-use-case.js +109 -21
- 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 +19 -0
- package/dist/application/use-cases/edit-file-use-case.js.map +1 -1
- package/dist/application/use-cases/planning-use-case.d.ts +1 -14
- package/dist/application/use-cases/planning-use-case.d.ts.map +1 -1
- package/dist/application/use-cases/planning-use-case.js +2 -109
- package/dist/application/use-cases/planning-use-case.js.map +1 -1
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +6 -17
- package/dist/chat.js.map +1 -1
- 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/memory.d.ts.map +1 -1
- 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/services/query-intent-classifier.d.ts.map +1 -1
- package/dist/domain/services/query-intent-classifier.js +37 -23
- package/dist/domain/services/query-intent-classifier.js.map +1 -1
- package/dist/embed.d.ts.map +1 -1
- package/dist/embed.js +8 -3
- package/dist/embed.js.map +1 -1
- package/dist/index.js +267 -143
- 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 +14 -5
- package/dist/infrastructure/ai/cohere-ai-service.js.map +1 -1
- package/dist/infrastructure/ai/provider-ai-service.d.ts.map +1 -1
- package/dist/infrastructure/ai/provider-ai-service.js +64 -14
- package/dist/infrastructure/ai/provider-ai-service.js.map +1 -1
- package/dist/infrastructure/config/config-manager.d.ts +78 -9
- package/dist/infrastructure/config/config-manager.d.ts.map +1 -1
- package/dist/infrastructure/config/config-manager.js +127 -9
- package/dist/infrastructure/config/config-manager.js.map +1 -1
- package/dist/infrastructure/context/conversation-context.d.ts +39 -12
- package/dist/infrastructure/context/conversation-context.d.ts.map +1 -1
- package/dist/infrastructure/context/conversation-context.js +91 -4
- package/dist/infrastructure/context/conversation-context.js.map +1 -1
- 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/cost/cost-tracker.d.ts.map +1 -1
- package/dist/infrastructure/cost/cost-tracker.js +3 -2
- package/dist/infrastructure/cost/cost-tracker.js.map +1 -1
- 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/index.d.ts +1 -0
- package/dist/infrastructure/index.d.ts.map +1 -1
- package/dist/infrastructure/index.js +1 -2
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/infrastructure/observability/execution-tracer.d.ts +21 -0
- package/dist/infrastructure/observability/execution-tracer.d.ts.map +1 -1
- package/dist/infrastructure/observability/execution-tracer.js +157 -4
- package/dist/infrastructure/observability/execution-tracer.js.map +1 -1
- package/dist/infrastructure/protocols/a2a-metadata.js +1 -1
- package/dist/infrastructure/protocols/mcp-oauth.js +1 -1
- package/dist/infrastructure/providers/cohere-provider.d.ts +1 -2
- package/dist/infrastructure/providers/cohere-provider.d.ts.map +1 -1
- package/dist/infrastructure/providers/cohere-provider.js +44 -42
- package/dist/infrastructure/providers/cohere-provider.js.map +1 -1
- package/dist/infrastructure/providers/fake-provider.d.ts.map +1 -1
- package/dist/infrastructure/providers/fake-provider.js +8 -0
- package/dist/infrastructure/providers/fake-provider.js.map +1 -1
- package/dist/infrastructure/providers/local-llm-provider.d.ts.map +1 -1
- package/dist/infrastructure/providers/local-llm-provider.js +8 -2
- package/dist/infrastructure/providers/local-llm-provider.js.map +1 -1
- package/dist/infrastructure/providers/openai-provider.d.ts.map +1 -1
- package/dist/infrastructure/providers/openai-provider.js +40 -7
- package/dist/infrastructure/providers/openai-provider.js.map +1 -1
- package/dist/infrastructure/providers/openrouter-provider.d.ts.map +1 -1
- package/dist/infrastructure/providers/openrouter-provider.js +13 -7
- package/dist/infrastructure/providers/openrouter-provider.js.map +1 -1
- package/dist/infrastructure/security/enhanced-security-gate.d.ts +13 -0
- package/dist/infrastructure/security/enhanced-security-gate.d.ts.map +1 -1
- package/dist/infrastructure/security/enhanced-security-gate.js +56 -1
- package/dist/infrastructure/security/enhanced-security-gate.js.map +1 -1
- package/dist/infrastructure/security/input-validator.d.ts +17 -0
- package/dist/infrastructure/security/input-validator.d.ts.map +1 -1
- package/dist/infrastructure/security/input-validator.js +140 -25
- package/dist/infrastructure/security/input-validator.js.map +1 -1
- package/dist/infrastructure/storage/embeddings-path.d.ts.map +1 -1
- package/dist/infrastructure/storage/embeddings-path.js +14 -4
- package/dist/infrastructure/storage/embeddings-path.js.map +1 -1
- package/dist/infrastructure/storage/memory-stream-service.d.ts.map +1 -1
- package/dist/infrastructure/storage/memory-stream-service.js +58 -88
- package/dist/infrastructure/storage/memory-stream-service.js.map +1 -1
- package/dist/infrastructure/storage/plan-repository.d.ts.map +1 -1
- package/dist/infrastructure/storage/plan-repository.js +4 -5
- package/dist/infrastructure/storage/plan-repository.js.map +1 -1
- 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.map +1 -1
- package/dist/infrastructure/storage/sqlite-decision-repository.js +4 -8
- package/dist/infrastructure/storage/sqlite-decision-repository.js.map +1 -1
- package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.d.ts.map +1 -1
- package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.js +4 -8
- package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.js.map +1 -1
- package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.d.ts.map +1 -1
- package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.js +4 -8
- package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.js.map +1 -1
- package/dist/infrastructure/storage/sqlite-memory-repository.d.ts.map +1 -1
- package/dist/infrastructure/storage/sqlite-memory-repository.js +4 -8
- package/dist/infrastructure/storage/sqlite-memory-repository.js.map +1 -1
- package/dist/infrastructure/storage/sqlite-pattern-repository.d.ts.map +1 -1
- package/dist/infrastructure/storage/sqlite-pattern-repository.js +4 -8
- package/dist/infrastructure/storage/sqlite-pattern-repository.js.map +1 -1
- package/dist/infrastructure/storage/task-repository.d.ts +0 -1
- package/dist/infrastructure/storage/task-repository.d.ts.map +1 -1
- package/dist/infrastructure/storage/task-repository.js +2 -13
- package/dist/infrastructure/storage/task-repository.js.map +1 -1
- 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/progress-indicator.d.ts +49 -10
- package/dist/infrastructure/ux/progress-indicator.d.ts.map +1 -1
- package/dist/infrastructure/ux/progress-indicator.js +112 -9
- package/dist/infrastructure/ux/progress-indicator.js.map +1 -1
- package/dist/infrastructure/validation/agent-feedback.d.ts +14 -1
- package/dist/infrastructure/validation/agent-feedback.d.ts.map +1 -1
- package/dist/infrastructure/validation/agent-feedback.js +57 -3
- package/dist/infrastructure/validation/agent-feedback.js.map +1 -1
- package/dist/parallel-processor.d.ts.map +1 -1
- package/dist/parallel-processor.js +39 -11
- package/dist/parallel-processor.js.map +1 -1
- package/dist/presentation/cli/commands/ask-command.d.ts +1 -2
- package/dist/presentation/cli/commands/ask-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/ask-command.js +66 -150
- package/dist/presentation/cli/commands/ask-command.js.map +1 -1
- 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.map +1 -1
- package/dist/presentation/cli/commands/config-command.js +2 -14
- package/dist/presentation/cli/commands/config-command.js.map +1 -1
- 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/decision-command.js +6 -23
- package/dist/presentation/cli/commands/decision-command.js.map +1 -1
- package/dist/presentation/cli/commands/fix-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/fix-command.js +19 -23
- package/dist/presentation/cli/commands/fix-command.js.map +1 -1
- package/dist/presentation/cli/commands/help-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/help-command.js +1 -21
- package/dist/presentation/cli/commands/help-command.js.map +1 -1
- package/dist/presentation/cli/commands/orchestrate-command.d.ts +0 -1
- package/dist/presentation/cli/commands/orchestrate-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/orchestrate-command.js +19 -126
- package/dist/presentation/cli/commands/orchestrate-command.js.map +1 -1
- package/dist/presentation/cli/commands/plan-command.d.ts +0 -1
- package/dist/presentation/cli/commands/plan-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/plan-command.js +42 -132
- package/dist/presentation/cli/commands/plan-command.js.map +1 -1
- package/dist/presentation/cli/commands/react-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/react-command.js +1 -5
- package/dist/presentation/cli/commands/react-command.js.map +1 -1
- package/dist/presentation/cli/commands/review-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/review-command.js +2 -21
- package/dist/presentation/cli/commands/review-command.js.map +1 -1
- package/dist/presentation/cli/commands/smart-command.d.ts +3 -0
- package/dist/presentation/cli/commands/smart-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/smart-command.js +127 -93
- package/dist/presentation/cli/commands/smart-command.js.map +1 -1
- package/dist/presentation/cli/commands/status-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/status-command.js +1 -5
- package/dist/presentation/cli/commands/status-command.js.map +1 -1
- 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/error-display.d.ts.map +1 -1
- package/dist/presentation/cli/error-display.js +17 -75
- package/dist/presentation/cli/error-display.js.map +1 -1
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +5 -18
- package/dist/search.js.map +1 -1
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +221 -57
- package/dist/session.js.map +1 -1
- package/dist/token-optimizer.d.ts.map +1 -1
- package/dist/token-optimizer.js +6 -1
- package/dist/token-optimizer.js.map +1 -1
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +0 -3
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/git-tool.js +7 -7
- package/dist/tools/git-tool.js.map +1 -1
- package/dist/ui.d.ts +0 -5
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +0 -19
- package/dist/ui.js.map +1 -1
- 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/package.json +16 -13
- package/dist/application/agents/documentation-agent.d.ts +0 -24
- package/dist/application/agents/documentation-agent.d.ts.map +0 -1
- package/dist/application/agents/documentation-agent.js +0 -399
- package/dist/application/agents/documentation-agent.js.map +0 -1
- package/dist/application/agents/product-requirements-agent.d.ts +0 -21
- package/dist/application/agents/product-requirements-agent.d.ts.map +0 -1
- package/dist/application/agents/product-requirements-agent.js +0 -247
- package/dist/application/agents/product-requirements-agent.js.map +0 -1
- package/dist/application/reasoning/multi-model-planning-strategy.d.ts +0 -21
- package/dist/application/reasoning/multi-model-planning-strategy.d.ts.map +0 -1
- package/dist/application/reasoning/multi-model-planning-strategy.js +0 -158
- package/dist/application/reasoning/multi-model-planning-strategy.js.map +0 -1
- package/dist/application/reasoning/reasoning-config.d.ts +0 -15
- package/dist/application/reasoning/reasoning-config.d.ts.map +0 -1
- package/dist/application/reasoning/reasoning-config.js +0 -50
- package/dist/application/reasoning/reasoning-config.js.map +0 -1
- package/dist/application/reasoning/reasoning-orchestrator.d.ts +0 -18
- package/dist/application/reasoning/reasoning-orchestrator.d.ts.map +0 -1
- package/dist/application/reasoning/reasoning-orchestrator.js +0 -170
- package/dist/application/reasoning/reasoning-orchestrator.js.map +0 -1
- package/dist/application/reasoning/reasoning-strategy.interface.d.ts +0 -24
- package/dist/application/reasoning/reasoning-strategy.interface.d.ts.map +0 -1
- package/dist/application/reasoning/reasoning-strategy.interface.js +0 -6
- package/dist/application/reasoning/reasoning-strategy.interface.js.map +0 -1
- package/dist/application/reasoning/role-provider-resolver.d.ts +0 -36
- package/dist/application/reasoning/role-provider-resolver.d.ts.map +0 -1
- package/dist/application/reasoning/role-provider-resolver.js +0 -74
- package/dist/application/reasoning/role-provider-resolver.js.map +0 -1
- package/dist/application/reasoning/simple-planning-strategy.d.ts +0 -22
- package/dist/application/reasoning/simple-planning-strategy.d.ts.map +0 -1
- package/dist/application/reasoning/simple-planning-strategy.js +0 -217
- package/dist/application/reasoning/simple-planning-strategy.js.map +0 -1
- package/dist/application/reasoning/types.d.ts +0 -65
- package/dist/application/reasoning/types.d.ts.map +0 -1
- package/dist/application/reasoning/types.js +0 -6
- package/dist/application/reasoning/types.js.map +0 -1
- package/dist/application/reasoning/validator-strategy.d.ts +0 -56
- package/dist/application/reasoning/validator-strategy.d.ts.map +0 -1
- package/dist/application/reasoning/validator-strategy.js +0 -103
- package/dist/application/reasoning/validator-strategy.js.map +0 -1
- package/dist/domain/entities/documentation.d.ts +0 -35
- package/dist/domain/entities/documentation.d.ts.map +0 -1
- package/dist/domain/entities/documentation.js +0 -6
- package/dist/domain/entities/documentation.js.map +0 -1
- package/dist/domain/entities/product-requirements.d.ts +0 -50
- package/dist/domain/entities/product-requirements.d.ts.map +0 -1
- package/dist/domain/entities/product-requirements.js +0 -6
- package/dist/domain/entities/product-requirements.js.map +0 -1
- package/dist/domain/interfaces/agent.interface.d.ts +0 -15
- package/dist/domain/interfaces/agent.interface.d.ts.map +0 -1
- package/dist/domain/interfaces/agent.interface.js +0 -6
- package/dist/domain/interfaces/agent.interface.js.map +0 -1
- package/dist/infrastructure/ai/fake-ai-service.d.ts +0 -22
- package/dist/infrastructure/ai/fake-ai-service.d.ts.map +0 -1
- package/dist/infrastructure/ai/fake-ai-service.js +0 -59
- package/dist/infrastructure/ai/fake-ai-service.js.map +0 -1
- package/dist/infrastructure/completion/completion-generator.d.ts +0 -42
- package/dist/infrastructure/completion/completion-generator.d.ts.map +0 -1
- package/dist/infrastructure/completion/completion-generator.js +0 -184
- package/dist/infrastructure/completion/completion-generator.js.map +0 -1
- package/dist/infrastructure/security/network-guard.d.ts +0 -8
- package/dist/infrastructure/security/network-guard.d.ts.map +0 -1
- package/dist/infrastructure/security/network-guard.js +0 -70
- package/dist/infrastructure/security/network-guard.js.map +0 -1
- package/dist/infrastructure/security/offline.d.ts +0 -16
- package/dist/infrastructure/security/offline.d.ts.map +0 -1
- package/dist/infrastructure/security/offline.js +0 -24
- package/dist/infrastructure/security/offline.js.map +0 -1
- package/dist/infrastructure/storage/sqljs-init.d.ts +0 -8
- package/dist/infrastructure/storage/sqljs-init.d.ts.map +0 -1
- package/dist/infrastructure/storage/sqljs-init.js +0 -23
- package/dist/infrastructure/storage/sqljs-init.js.map +0 -1
- package/dist/infrastructure/ux/hitl-review-portal.d.ts +0 -47
- package/dist/infrastructure/ux/hitl-review-portal.d.ts.map +0 -1
- package/dist/infrastructure/ux/hitl-review-portal.js +0 -228
- package/dist/infrastructure/ux/hitl-review-portal.js.map +0 -1
- package/dist/infrastructure/ux/meta-query.d.ts +0 -9
- package/dist/infrastructure/ux/meta-query.d.ts.map +0 -1
- package/dist/infrastructure/ux/meta-query.js +0 -63
- package/dist/infrastructure/ux/meta-query.js.map +0 -1
- package/dist/infrastructure/ux/proportional-friction.d.ts +0 -73
- package/dist/infrastructure/ux/proportional-friction.d.ts.map +0 -1
- package/dist/infrastructure/ux/proportional-friction.js +0 -200
- package/dist/infrastructure/ux/proportional-friction.js.map +0 -1
- package/dist/infrastructure/ux/repo-fingerprint.d.ts +0 -10
- package/dist/infrastructure/ux/repo-fingerprint.d.ts.map +0 -1
- package/dist/infrastructure/ux/repo-fingerprint.js +0 -55
- package/dist/infrastructure/ux/repo-fingerprint.js.map +0 -1
- package/dist/infrastructure/validation/feedback-stats.d.ts +0 -99
- package/dist/infrastructure/validation/feedback-stats.d.ts.map +0 -1
- package/dist/infrastructure/validation/feedback-stats.js +0 -173
- package/dist/infrastructure/validation/feedback-stats.js.map +0 -1
- package/dist/infrastructure/validation/trust-config.d.ts +0 -27
- package/dist/infrastructure/validation/trust-config.d.ts.map +0 -1
- package/dist/infrastructure/validation/trust-config.js +0 -113
- package/dist/infrastructure/validation/trust-config.js.map +0 -1
- package/dist/presentation/cli/commands/memory-command.d.ts +0 -17
- package/dist/presentation/cli/commands/memory-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/memory-command.js +0 -252
- package/dist/presentation/cli/commands/memory-command.js.map +0 -1
- package/dist/presentation/cli/keyboard-shortcuts.d.ts +0 -27
- package/dist/presentation/cli/keyboard-shortcuts.d.ts.map +0 -1
- package/dist/presentation/cli/keyboard-shortcuts.js +0 -77
- package/dist/presentation/cli/keyboard-shortcuts.js.map +0 -1
- package/dist/test_cohere.d.ts +0 -2
- package/dist/test_cohere.d.ts.map +0 -1
- package/dist/test_cohere.js +0 -68
- package/dist/test_cohere.js.map +0 -1
- package/dist/test_env.d.ts +0 -2
- package/dist/test_env.d.ts.map +0 -1
- package/dist/test_env.js +0 -24
- package/dist/test_env.js.map +0 -1
- package/dist/test_retrieval.d.ts +0 -2
- package/dist/test_retrieval.d.ts.map +0 -1
- package/dist/test_retrieval.js +0 -84
- package/dist/test_retrieval.js.map +0 -1
- package/dist/tools/bash.d 2.ts +0 -53
- package/dist/tools/bash.js 2.map +0 -1
- package/dist/tools/edit 2.js +0 -235
- package/dist/tools/edit.d.ts 2.map +0 -1
- package/dist/utils/logger.d.ts +0 -34
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -56
- package/dist/utils/logger.js.map +0 -1
package/dist/chat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAoB/C,wBAAsB,eAAe,CACnC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,YAAY,EAAE,GACtB,OAAO,CAAC,MAAM,CAAC,CA4DjB;AAED,wBAAsB,YAAY,CAChC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CAsEjB"}
|
package/dist/chat.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { config } from 'dotenv';
|
|
2
2
|
import { join, dirname } from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
|
+
import { CohereClient } from 'cohere-ai';
|
|
4
5
|
import { retryWithBackoff, cohereCircuitBreaker, handleError } from './error-handler.js';
|
|
5
6
|
import { optimizeContext } from './token-optimizer.js';
|
|
6
7
|
import { optimizeQuery } from './query-optimizer.js';
|
|
@@ -15,21 +16,9 @@ catch {
|
|
|
15
16
|
// Fallback
|
|
16
17
|
}
|
|
17
18
|
config(); // Also try current directory
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (!cohere) {
|
|
22
|
-
if (process.env.CODEHERE_FAKE_AI === '1') {
|
|
23
|
-
throw new Error('CohereClient should not be used when CODEHERE_FAKE_AI=1');
|
|
24
|
-
}
|
|
25
|
-
// Dynamic import to prevent loading cohere-ai at module load time
|
|
26
|
-
const { CohereClient: CohereClientClass } = await import('cohere-ai');
|
|
27
|
-
cohere = new CohereClientClass({
|
|
28
|
-
token: process.env.COHERE_API_KEY || '',
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
return cohere;
|
|
32
|
-
}
|
|
19
|
+
const cohere = new CohereClient({
|
|
20
|
+
token: process.env.COHERE_API_KEY || '',
|
|
21
|
+
});
|
|
33
22
|
export async function chatWithContext(query, context) {
|
|
34
23
|
// Optimize query to understand intent and select strategy
|
|
35
24
|
const { optimizedQuery, strategy } = optimizeQuery(query);
|
|
@@ -52,7 +41,7 @@ USER QUERY:
|
|
|
52
41
|
${optimizedQuery}`;
|
|
53
42
|
return await retryWithBackoff(async () => {
|
|
54
43
|
return await cohereCircuitBreaker.execute(async () => {
|
|
55
|
-
const response = await
|
|
44
|
+
const response = await cohere.chat({
|
|
56
45
|
message: prompt,
|
|
57
46
|
});
|
|
58
47
|
return response.text || 'No response generated';
|
|
@@ -104,7 +93,7 @@ Instruction: ${instruction}
|
|
|
104
93
|
Return the unified diff patch:`;
|
|
105
94
|
return await retryWithBackoff(async () => {
|
|
106
95
|
return await cohereCircuitBreaker.execute(async () => {
|
|
107
|
-
const response = await
|
|
96
|
+
const response = await cohere.chat({
|
|
108
97
|
message: prompt,
|
|
109
98
|
});
|
|
110
99
|
let diffText = response.text || '';
|
package/dist/chat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,WAAW,EAAa,MAAM,oBAAoB,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,iCAAiC;AACjC,IAAI,CAAC;IACH,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC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E;YACjB,SAAS,EAAE,cAAc;YACzB,QAAQ;YACR,QAAQ,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE;SAC1D,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain Entity: Conversation Context
|
|
3
|
+
*
|
|
4
|
+
* Represents a complete conversation session with auto-compaction support
|
|
5
|
+
* for context continuity across AI tools and providers.
|
|
6
|
+
*
|
|
7
|
+
* Design Goals:
|
|
8
|
+
* - Support cross-tool import (Claude Code, OpenCode, Cursor)
|
|
9
|
+
* - Auto-compact at 90% token limit to prevent context loss
|
|
10
|
+
* - Preserve key information through summarization
|
|
11
|
+
* - Enable seamless provider switching
|
|
12
|
+
*
|
|
13
|
+
* @since v0.5.0 (Context Continuity Feature)
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Conversation message role types
|
|
17
|
+
*/
|
|
18
|
+
export type MessageRole = 'user' | 'assistant' | 'system';
|
|
19
|
+
/**
|
|
20
|
+
* Source format for imported contexts
|
|
21
|
+
*/
|
|
22
|
+
export type SourceFormat = 'claude-code' | 'cursor' | 'codehere' | 'opencode';
|
|
23
|
+
/**
|
|
24
|
+
* Compaction trigger reasons
|
|
25
|
+
*/
|
|
26
|
+
export type CompactionTrigger = '90%_limit' | 'manual' | 'import';
|
|
27
|
+
/**
|
|
28
|
+
* Individual message in a conversation
|
|
29
|
+
*/
|
|
30
|
+
export interface ConversationMessage {
|
|
31
|
+
/**
|
|
32
|
+
* Message role (user, assistant, system)
|
|
33
|
+
*/
|
|
34
|
+
role: MessageRole;
|
|
35
|
+
/**
|
|
36
|
+
* Message content
|
|
37
|
+
*/
|
|
38
|
+
content: string;
|
|
39
|
+
/**
|
|
40
|
+
* Message timestamp
|
|
41
|
+
*/
|
|
42
|
+
timestamp: Date;
|
|
43
|
+
/**
|
|
44
|
+
* Token count for this message
|
|
45
|
+
*/
|
|
46
|
+
tokenCount: number;
|
|
47
|
+
/**
|
|
48
|
+
* Optional metadata
|
|
49
|
+
*/
|
|
50
|
+
metadata?: MessageMetadata;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Metadata attached to a message
|
|
54
|
+
*/
|
|
55
|
+
export interface MessageMetadata {
|
|
56
|
+
/**
|
|
57
|
+
* Files referenced in this message
|
|
58
|
+
*/
|
|
59
|
+
files?: string[];
|
|
60
|
+
/**
|
|
61
|
+
* Command that triggered this message
|
|
62
|
+
*/
|
|
63
|
+
command?: string;
|
|
64
|
+
/**
|
|
65
|
+
* AI provider used for this message
|
|
66
|
+
*/
|
|
67
|
+
provider?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Model used for this message
|
|
70
|
+
*/
|
|
71
|
+
model?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Cost of this message (if available)
|
|
74
|
+
*/
|
|
75
|
+
cost?: number;
|
|
76
|
+
/**
|
|
77
|
+
* Source of this message (for imports)
|
|
78
|
+
*/
|
|
79
|
+
source?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Original ID from imported source
|
|
82
|
+
*/
|
|
83
|
+
originalId?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Raw import flag
|
|
86
|
+
*/
|
|
87
|
+
raw?: boolean;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Summary created during context compaction
|
|
91
|
+
*/
|
|
92
|
+
export interface CompactedSummary {
|
|
93
|
+
/**
|
|
94
|
+
* Number of messages before compaction
|
|
95
|
+
*/
|
|
96
|
+
originalMessageCount: number;
|
|
97
|
+
/**
|
|
98
|
+
* Number of messages after compaction
|
|
99
|
+
*/
|
|
100
|
+
compactedMessageCount: number;
|
|
101
|
+
/**
|
|
102
|
+
* Summary text
|
|
103
|
+
*/
|
|
104
|
+
summaryText: string;
|
|
105
|
+
/**
|
|
106
|
+
* When this summary was created
|
|
107
|
+
*/
|
|
108
|
+
compactedAt: Date;
|
|
109
|
+
/**
|
|
110
|
+
* Key points preserved from compacted messages
|
|
111
|
+
*/
|
|
112
|
+
preservedKeyPoints: string[];
|
|
113
|
+
/**
|
|
114
|
+
* Number of tokens saved by compaction
|
|
115
|
+
*/
|
|
116
|
+
tokensSaved: number;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Record of a compaction event
|
|
120
|
+
*/
|
|
121
|
+
export interface CompactionEvent {
|
|
122
|
+
/**
|
|
123
|
+
* When compaction occurred
|
|
124
|
+
*/
|
|
125
|
+
timestamp: Date;
|
|
126
|
+
/**
|
|
127
|
+
* Why compaction was triggered
|
|
128
|
+
*/
|
|
129
|
+
triggerReason: CompactionTrigger;
|
|
130
|
+
/**
|
|
131
|
+
* Message count before compaction
|
|
132
|
+
*/
|
|
133
|
+
messagesBefore: number;
|
|
134
|
+
/**
|
|
135
|
+
* Message count after compaction
|
|
136
|
+
*/
|
|
137
|
+
messagesAfter: number;
|
|
138
|
+
/**
|
|
139
|
+
* Token count before compaction
|
|
140
|
+
*/
|
|
141
|
+
tokensBefore: number;
|
|
142
|
+
/**
|
|
143
|
+
* Token count after compaction
|
|
144
|
+
*/
|
|
145
|
+
tokensAfter: number;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Project metadata
|
|
149
|
+
*/
|
|
150
|
+
export interface ProjectMetadata {
|
|
151
|
+
/**
|
|
152
|
+
* Absolute path to project root
|
|
153
|
+
*/
|
|
154
|
+
path: string;
|
|
155
|
+
/**
|
|
156
|
+
* Project name
|
|
157
|
+
*/
|
|
158
|
+
name: string;
|
|
159
|
+
/**
|
|
160
|
+
* Detected programming languages
|
|
161
|
+
*/
|
|
162
|
+
languages: string[];
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Complete conversation context
|
|
166
|
+
*
|
|
167
|
+
* Represents a full conversation session with all metadata needed
|
|
168
|
+
* for context continuity, auto-compaction, and cross-tool import/export.
|
|
169
|
+
*/
|
|
170
|
+
export interface ConversationContext {
|
|
171
|
+
/**
|
|
172
|
+
* Unique session identifier
|
|
173
|
+
*/
|
|
174
|
+
sessionId: string;
|
|
175
|
+
/**
|
|
176
|
+
* When this session was created
|
|
177
|
+
*/
|
|
178
|
+
createdAt: Date;
|
|
179
|
+
/**
|
|
180
|
+
* Last update timestamp
|
|
181
|
+
*/
|
|
182
|
+
lastUpdatedAt: Date;
|
|
183
|
+
/**
|
|
184
|
+
* All messages in this conversation
|
|
185
|
+
* After compaction, includes summary message + recent messages
|
|
186
|
+
*/
|
|
187
|
+
messages: ConversationMessage[];
|
|
188
|
+
/**
|
|
189
|
+
* Total token count (sum of all message tokens)
|
|
190
|
+
*/
|
|
191
|
+
totalTokenCount: number;
|
|
192
|
+
/**
|
|
193
|
+
* Maximum token limit for this model
|
|
194
|
+
* Used to determine when auto-compact triggers (90% threshold)
|
|
195
|
+
*/
|
|
196
|
+
maxTokenLimit: number;
|
|
197
|
+
/**
|
|
198
|
+
* Summary created during last compaction (if any)
|
|
199
|
+
*/
|
|
200
|
+
summary?: CompactedSummary;
|
|
201
|
+
/**
|
|
202
|
+
* History of all compaction events
|
|
203
|
+
*/
|
|
204
|
+
compactionHistory: CompactionEvent[];
|
|
205
|
+
/**
|
|
206
|
+
* AI model being used (e.g., "claude-3-5-sonnet", "gpt-4o")
|
|
207
|
+
*/
|
|
208
|
+
model: string;
|
|
209
|
+
/**
|
|
210
|
+
* AI provider being used (e.g., "anthropic", "openai", "cohere")
|
|
211
|
+
*/
|
|
212
|
+
provider: string;
|
|
213
|
+
/**
|
|
214
|
+
* Project metadata
|
|
215
|
+
*/
|
|
216
|
+
project: ProjectMetadata;
|
|
217
|
+
/**
|
|
218
|
+
* Source format if imported from another tool
|
|
219
|
+
*/
|
|
220
|
+
sourceFormat?: SourceFormat;
|
|
221
|
+
/**
|
|
222
|
+
* When this context was exported (for export tracking)
|
|
223
|
+
*/
|
|
224
|
+
exportedAt?: Date;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Factory function to create a new ConversationContext
|
|
228
|
+
*/
|
|
229
|
+
export declare function createConversationContext(params: {
|
|
230
|
+
sessionId: string;
|
|
231
|
+
model: string;
|
|
232
|
+
provider: string;
|
|
233
|
+
maxTokenLimit: number;
|
|
234
|
+
project: ProjectMetadata;
|
|
235
|
+
sourceFormat?: SourceFormat;
|
|
236
|
+
}): ConversationContext;
|
|
237
|
+
/**
|
|
238
|
+
* Type guard to check if a context needs compaction
|
|
239
|
+
*/
|
|
240
|
+
export declare function needsCompaction(context: ConversationContext, threshold?: number): boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Calculate total token count from messages
|
|
243
|
+
*/
|
|
244
|
+
export declare function calculateTotalTokens(messages: ConversationMessage[]): number;
|
|
245
|
+
//# sourceMappingURL=conversation-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-context.d.ts","sourceRoot":"","sources":["../../../src/domain/entities/conversation-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAElB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,EAAE,IAAI,CAAC;IAEhB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,KAAK,CAAC,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E,MAAM,CAAC;IAElB;;OAEG;IACH,SAAS,EAAE,IAAI,CAAC;IAEhB;;OAEG;IACH,aAAa,EAAE,IAAI,CAAC;IAEpB;;;OAGG;IACH,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAEhC;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAE3B;;OAEG;IACH,iBAAiB,EAAE,eAAe,EAAE,CAAC;IAErC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,EAAE,eAAe,CAAC;IAEzB;;OAEG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B;;OAEG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,eAAe,CAAC;IACzB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,GAAG,mBAAmB,CAgBtB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,mBAAmB,EAC5B,SAAS,GAAE,MAAa,GACvB,OAAO,CAOT;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAE5E"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain Entity: Conversation Context
|
|
3
|
+
*
|
|
4
|
+
* Represents a complete conversation session with auto-compaction support
|
|
5
|
+
* for context continuity across AI tools and providers.
|
|
6
|
+
*
|
|
7
|
+
* Design Goals:
|
|
8
|
+
* - Support cross-tool import (Claude Code, OpenCode, Cursor)
|
|
9
|
+
* - Auto-compact at 90% token limit to prevent context loss
|
|
10
|
+
* - Preserve key information through summarization
|
|
11
|
+
* - Enable seamless provider switching
|
|
12
|
+
*
|
|
13
|
+
* @since v0.5.0 (Context Continuity Feature)
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Factory function to create a new ConversationContext
|
|
17
|
+
*/
|
|
18
|
+
export function createConversationContext(params) {
|
|
19
|
+
const now = new Date();
|
|
20
|
+
return {
|
|
21
|
+
sessionId: params.sessionId,
|
|
22
|
+
createdAt: now,
|
|
23
|
+
lastUpdatedAt: now,
|
|
24
|
+
messages: [],
|
|
25
|
+
totalTokenCount: 0,
|
|
26
|
+
maxTokenLimit: params.maxTokenLimit,
|
|
27
|
+
compactionHistory: [],
|
|
28
|
+
model: params.model,
|
|
29
|
+
provider: params.provider,
|
|
30
|
+
project: params.project,
|
|
31
|
+
sourceFormat: params.sourceFormat,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Type guard to check if a context needs compaction
|
|
36
|
+
*/
|
|
37
|
+
export function needsCompaction(context, threshold = 0.90) {
|
|
38
|
+
if (context.maxTokenLimit === 0) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
const usage = context.totalTokenCount / context.maxTokenLimit;
|
|
42
|
+
return usage >= threshold;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Calculate total token count from messages
|
|
46
|
+
*/
|
|
47
|
+
export function calculateTotalTokens(messages) {
|
|
48
|
+
return messages.reduce((sum, msg) => sum + msg.tokenCount, 0);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=conversation-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-context.js","sourceRoot":"","sources":["../../../src/domain/entities/conversation-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAiQH;;GAE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U,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,IAAI,CAAC;IACnB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repository Interface: Context Repository
|
|
3
|
+
*
|
|
4
|
+
* Defines persistence operations for conversation contexts
|
|
5
|
+
* Following repository pattern for clean architecture
|
|
6
|
+
*
|
|
7
|
+
* @since v0.5.0 (Context Continuity Feature)
|
|
8
|
+
*/
|
|
9
|
+
import type { ConversationContext, ConversationMessage } from '../entities/conversation-context.js';
|
|
10
|
+
/**
|
|
11
|
+
* Repository interface for conversation context persistence
|
|
12
|
+
*/
|
|
13
|
+
export interface IContextRepository {
|
|
14
|
+
/**
|
|
15
|
+
* Store a complete conversation context
|
|
16
|
+
* @param context - The context to store
|
|
17
|
+
*/
|
|
18
|
+
store(context: ConversationContext): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieve a conversation context by session ID
|
|
21
|
+
* @param sessionId - Session identifier
|
|
22
|
+
* @returns Context if found, null otherwise
|
|
23
|
+
*/
|
|
24
|
+
findById(sessionId: string): Promise<ConversationContext | null>;
|
|
25
|
+
/**
|
|
26
|
+
* Retrieve the most recent conversation context
|
|
27
|
+
* @returns Most recent context if any exists, null otherwise
|
|
28
|
+
*/
|
|
29
|
+
findLatest(): Promise<ConversationContext | null>;
|
|
30
|
+
/**
|
|
31
|
+
* List all conversation contexts, ordered by last updated
|
|
32
|
+
* @param limit - Maximum number of contexts to return
|
|
33
|
+
* @returns Array of contexts
|
|
34
|
+
*/
|
|
35
|
+
findAll(limit?: number): Promise<ConversationContext[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Add a message to an existing context
|
|
38
|
+
* @param sessionId - Session identifier
|
|
39
|
+
* @param message - Message to add
|
|
40
|
+
*/
|
|
41
|
+
addMessage(sessionId: string, message: ConversationMessage): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Update an existing conversation context
|
|
44
|
+
* @param context - Updated context
|
|
45
|
+
*/
|
|
46
|
+
update(context: ConversationContext): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Delete a conversation context
|
|
49
|
+
* @param sessionId - Session identifier
|
|
50
|
+
*/
|
|
51
|
+
delete(sessionId: string): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Get contexts by source format (for import tracking)
|
|
54
|
+
* @param sourceFormat - Source format to filter by
|
|
55
|
+
* @returns Array of contexts from that source
|
|
56
|
+
*/
|
|
57
|
+
findBySource(sourceFormat: string): Promise<ConversationContext[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Get session statistics
|
|
60
|
+
* @param sessionId - Session identifier
|
|
61
|
+
* @returns Stats object with message count, token count, etc.
|
|
62
|
+
*/
|
|
63
|
+
getStats(sessionId: string): Promise<{
|
|
64
|
+
messageCount: number;
|
|
65
|
+
totalTokens: number;
|
|
66
|
+
compactionCount: number;
|
|
67
|
+
tokensSaved: number;
|
|
68
|
+
age: number;
|
|
69
|
+
} | null>;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=context-repository.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-repository.interface.d.ts","sourceRoot":"","sources":["../../../src/domain/interfaces/context-repository.interface.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAEpG;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,KAAK,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnD;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IAEjE;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IAElD;;;;OAIG;IACH,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAExD;;;;OAIG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3E;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD;;;OAGG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzC;;;;OAIG;IACH,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAEnE;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QACnC,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;QACpB,GAAG,EAAE,MAAM,CAAC;KACb,GAAG,IAAI,CAAC,CAAC;CACX"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repository Interface: Context Repository
|
|
3
|
+
*
|
|
4
|
+
* Defines persistence operations for conversation contexts
|
|
5
|
+
* Following repository pattern for clean architecture
|
|
6
|
+
*
|
|
7
|
+
* @since v0.5.0 (Context Continuity Feature)
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=context-repository.interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-repository.interface.js","sourceRoot":"","sources":["../../../src/domain/interfaces/context-repository.interface.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-intent-classifier.d.ts","sourceRoot":"","sources":["../../../src/domain/services/query-intent-classifier.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAS,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE/D,qBAAa,qBAAqB;IAChC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW;
|
|
1
|
+
{"version":3,"file":"query-intent-classifier.d.ts","sourceRoot":"","sources":["../../../src/domain/services/query-intent-classifier.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAS,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE/D,qBAAa,qBAAqB;IAChC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW;IA0JpC;;OAEG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CA0BxC"}
|
|
@@ -60,6 +60,30 @@ export class QueryIntentClassifier {
|
|
|
60
60
|
return 'multi-file-modify';
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
// EARLY CHECK: Open questions about codebase state (before action intents!)
|
|
64
|
+
// Must come BEFORE modify/debug/implement to catch "what changed?" correctly
|
|
65
|
+
const openQuestionPatterns = [
|
|
66
|
+
/^what\s+(changed|is\s+new|happened|did\s+i|files?\s+changed)/i, // "what changed"
|
|
67
|
+
/what\s+has\s+(changed|happened|been\s+modified)/i, // "what has changed"
|
|
68
|
+
/what\s+are\s+the\s+(recent|latest|new)\s+(changes|updates|modifications)/i,
|
|
69
|
+
/what\s+are\s+the\s+(main|key|important|recent)/i,
|
|
70
|
+
/how\s+does\s+the\s+(project|codebase|system|app)/i,
|
|
71
|
+
/how\s+does\s+(it|this)\s+work/i,
|
|
72
|
+
/tell\s+me\s+about/i,
|
|
73
|
+
/overview\s+of/i,
|
|
74
|
+
/summary\s+of/i,
|
|
75
|
+
/what\s+is\s+this\s+(project|codebase|app|repo)/i,
|
|
76
|
+
/^what\s+is\s+\w+\??$/i, // "What is X?" without file context
|
|
77
|
+
/what\s+is\s+this\??$/i, // "What is this?"
|
|
78
|
+
/show\s+me\s+(recent|latest|new)\s+(changes|updates)/i,
|
|
79
|
+
/what\s+did\s+(i|we)\s+(change|modify|update)/i,
|
|
80
|
+
/recently\s+(changed|modified|updated)/i,
|
|
81
|
+
];
|
|
82
|
+
for (const pattern of openQuestionPatterns) {
|
|
83
|
+
if (pattern.test(query)) {
|
|
84
|
+
return 'understand'; // Route to ask handler for semantic search
|
|
85
|
+
}
|
|
86
|
+
}
|
|
63
87
|
// Refactor intent (single-file)
|
|
64
88
|
if (lowerQuery.includes('refactor') || lowerQuery.includes('rename') ||
|
|
65
89
|
lowerQuery.includes('extract') || lowerQuery.includes('move') ||
|
|
@@ -72,26 +96,7 @@ export class QueryIntentClassifier {
|
|
|
72
96
|
lowerQuery.includes('problem') || lowerQuery.includes('wrong')) {
|
|
73
97
|
return 'debug';
|
|
74
98
|
}
|
|
75
|
-
//
|
|
76
|
-
// These are high-level planning queries, not code implementation
|
|
77
|
-
const planPatterns = [
|
|
78
|
-
/brainstorm/i,
|
|
79
|
-
/plan.*(product|business|saas|startup|app|feature|architecture|system)/i,
|
|
80
|
-
/(product|business|saas|startup|app|feature|architecture|system).*plan/i,
|
|
81
|
-
/build.*(micro.*saas|saas|product|business|startup|app)/i,
|
|
82
|
-
/(micro.*saas|saas|product|business|startup|app).*build/i,
|
|
83
|
-
/earn.*(month|monthly|\$|usd)/i,
|
|
84
|
-
/(month|monthly|\$|usd).*earn/i,
|
|
85
|
-
/ideat/i, // "ideate" or "ideation"
|
|
86
|
-
/let.*brainstorm/i,
|
|
87
|
-
/want.*build/i,
|
|
88
|
-
];
|
|
89
|
-
for (const pattern of planPatterns) {
|
|
90
|
-
if (pattern.test(query)) {
|
|
91
|
-
return 'plan';
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
// Implement intent (code implementation - only if not a planning query)
|
|
99
|
+
// Implement intent
|
|
95
100
|
if (lowerQuery.includes('implement') || lowerQuery.includes('create') ||
|
|
96
101
|
lowerQuery.includes('add') || lowerQuery.includes('write') ||
|
|
97
102
|
lowerQuery.includes('build')) {
|
|
@@ -107,12 +112,21 @@ export class QueryIntentClassifier {
|
|
|
107
112
|
lowerQuery.includes('update') || lowerQuery.includes('edit')) {
|
|
108
113
|
return 'modify';
|
|
109
114
|
}
|
|
110
|
-
// Explain intent
|
|
111
|
-
if
|
|
115
|
+
// Explain intent - requires file/function context
|
|
116
|
+
// Only match if query mentions a specific file, function, or code element
|
|
117
|
+
const hasFileContext = /\.(ts|js|tsx|jsx|py|go|java|rs|cpp|c|h|json|yaml|yml|md)\b/i.test(query) ||
|
|
118
|
+
/function|class|interface|type|const|method|component/i.test(lowerQuery) ||
|
|
119
|
+
/src\/|lib\/|app\/|components\/|utils\/|services\//i.test(query);
|
|
120
|
+
if (hasFileContext && (lowerQuery.includes('how') || lowerQuery.includes('what') ||
|
|
112
121
|
lowerQuery.includes('explain') || lowerQuery.includes('understand') ||
|
|
113
|
-
lowerQuery.includes('does') || lowerQuery.includes('work')) {
|
|
122
|
+
lowerQuery.includes('does') || lowerQuery.includes('work'))) {
|
|
114
123
|
return 'explain';
|
|
115
124
|
}
|
|
125
|
+
// General understanding questions without file context → ask handler
|
|
126
|
+
if (lowerQuery.includes('how') || lowerQuery.includes('what') ||
|
|
127
|
+
lowerQuery.includes('explain') || lowerQuery.includes('understand')) {
|
|
128
|
+
return 'understand';
|
|
129
|
+
}
|
|
116
130
|
// Review intent
|
|
117
131
|
if (lowerQuery.includes('review') || lowerQuery.includes('check') ||
|
|
118
132
|
lowerQuery.includes('analyze') || lowerQuery.includes('audit')) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-intent-classifier.js","sourceRoot":"","sources":["../../../src/domain/services/query-intent-classifier.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,OAAO,qBAAqB;IAChC;;OAEG;IACH,QAAQ,CAAC,KAAa;QACpB,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QAEvC,qEAAqE;QACrE,6DAA6D;QAC7D,MAAM,iBAAiB,GAAG;YACxB,4EAA4E;YAC5E,oCAAoC,EAAE,gDAAgD;YACtF,8CAA8C,EAAE,+BAA+B;YAC/E,+CAA+C,EAAE,iDAAiD;YAClG,oDAAoD;YACpD,wCAAwC,EAAE,6BAA6B;YACvE,qCAAqC,EAAE,0BAA0B;YACjE,0BAA0B;YAC1B,oEAAoE;YACpE,0DAA0D;YAC1D,oFAAoF;YACpF,qBAAqB;YACrB,0DAA0D;YAC1D,yCAAyC;YACzC,wBAAwB;YACxB,iDAAiD;YACjD,+CAA+C;YAC/C,2CAA2C;YAC3C,yDAAyD;YACzD,wDAAwD;YACxD,qGAAqG;YACrG,gDAAgD;YAChD,oFAAoF;YACpF,iFAAiF;YACjF,qBAAqB;YACrB,0FAA0F;YAC1F,qHAA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F"}
|
package/dist/embed.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../src/embed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../src/embed.ts"],"names":[],"mappings":"AA2MA,wBAAsB,eAAe,CAAC,QAAQ,GAAE,MAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2JrF;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,QAAQ,CAAC,EAAE,MAAM,EACjB,OAAO,GAAE;IACP,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACpB,GACL,OAAO,CAAC;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAkJD"}
|
package/dist/embed.js
CHANGED
|
@@ -41,9 +41,14 @@ function getLegacyDbPath() {
|
|
|
41
41
|
// Legacy DB_PATH - only used by deprecated indexRepository() function
|
|
42
42
|
// Active CLI uses indexRepositoryParallel() with per-repo paths
|
|
43
43
|
const DB_PATH = getLegacyDbPath();
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
44
|
+
// Token encoder and chunking - use config
|
|
45
|
+
import { getConfigManager } from './infrastructure/config/config-manager.js';
|
|
46
|
+
const embedConfig = getConfigManager();
|
|
47
|
+
const defaultModel = embedConfig.getModel('default') || embedConfig.getPreference('defaultModel') || 'command-r-08-2024';
|
|
48
|
+
const tiktokenModel = defaultModel.includes('gpt') ? defaultModel : 'gpt-3.5-turbo';
|
|
49
|
+
const enc = encoding_for_model(tiktokenModel);
|
|
50
|
+
const CHUNK_SIZE = embedConfig.getChunking('chunkSize') || 300; // target tokens per chunk
|
|
51
|
+
const OVERLAP = embedConfig.getChunking('overlap') || 50; // overlap tokens between chunks
|
|
47
52
|
function shouldIgnorePath(filepath) {
|
|
48
53
|
const ignorePatterns = [
|
|
49
54
|
'node_modules',
|