codehere 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of codehere might be problematic. Click here for more details.
- package/README.md +223 -42
- package/dist/application/agents/documentation-agent.d.ts +24 -0
- package/dist/application/agents/documentation-agent.d.ts.map +1 -0
- package/dist/application/agents/documentation-agent.js +399 -0
- package/dist/application/agents/documentation-agent.js.map +1 -0
- package/dist/application/agents/execution-agent.d.ts +11 -0
- package/dist/application/agents/execution-agent.d.ts.map +1 -1
- package/dist/application/agents/execution-agent.js +289 -80
- package/dist/application/agents/execution-agent.js.map +1 -1
- package/dist/application/agents/multi-agent-orchestrator.d.ts +3 -0
- package/dist/application/agents/multi-agent-orchestrator.d.ts.map +1 -1
- package/dist/application/agents/multi-agent-orchestrator.js +86 -0
- package/dist/application/agents/multi-agent-orchestrator.js.map +1 -1
- package/dist/application/agents/planning-agent.d.ts +3 -0
- package/dist/application/agents/planning-agent.d.ts.map +1 -1
- package/dist/application/agents/planning-agent.js +132 -64
- package/dist/application/agents/planning-agent.js.map +1 -1
- package/dist/application/agents/product-requirements-agent.d.ts +21 -0
- package/dist/application/agents/product-requirements-agent.d.ts.map +1 -0
- package/dist/application/agents/product-requirements-agent.js +247 -0
- package/dist/application/agents/product-requirements-agent.js.map +1 -0
- package/dist/application/agents/validation-agent.d.ts +5 -1
- package/dist/application/agents/validation-agent.d.ts.map +1 -1
- package/dist/application/agents/validation-agent.js +156 -21
- package/dist/application/agents/validation-agent.js.map +1 -1
- package/dist/application/services/dependency-container.d.ts +22 -2
- package/dist/application/services/dependency-container.d.ts.map +1 -1
- package/dist/application/services/dependency-container.js +144 -6
- package/dist/application/services/dependency-container.js.map +1 -1
- package/dist/application/services/intelligent-router.d.ts +13 -0
- package/dist/application/services/intelligent-router.d.ts.map +1 -1
- package/dist/application/services/intelligent-router.js +300 -87
- package/dist/application/services/intelligent-router.js.map +1 -1
- package/dist/application/use-cases/ask-question-use-case.d.ts +19 -0
- package/dist/application/use-cases/ask-question-use-case.d.ts.map +1 -1
- package/dist/application/use-cases/ask-question-use-case.js +125 -46
- package/dist/application/use-cases/ask-question-use-case.js.map +1 -1
- package/dist/application/use-cases/edit-file-use-case.d.ts.map +1 -1
- package/dist/application/use-cases/edit-file-use-case.js +16 -1
- package/dist/application/use-cases/edit-file-use-case.js.map +1 -1
- package/dist/domain/entities/documentation.d.ts +35 -0
- package/dist/domain/entities/documentation.d.ts.map +1 -0
- package/dist/domain/entities/documentation.js +6 -0
- package/dist/domain/entities/documentation.js.map +1 -0
- package/dist/domain/entities/product-requirements.d.ts +50 -0
- package/dist/domain/entities/product-requirements.d.ts.map +1 -0
- package/dist/domain/entities/product-requirements.js +6 -0
- package/dist/domain/entities/product-requirements.js.map +1 -0
- package/dist/domain/entities/task.d.ts +152 -0
- package/dist/domain/entities/task.d.ts.map +1 -0
- package/dist/domain/entities/task.js +61 -0
- package/dist/domain/entities/task.js.map +1 -0
- package/dist/domain/interfaces/agent.interface.d.ts +15 -0
- package/dist/domain/interfaces/agent.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/agent.interface.js +6 -0
- package/dist/domain/interfaces/agent.interface.js.map +1 -0
- package/dist/domain/services/environment-mode-manager.d.ts +18 -0
- package/dist/domain/services/environment-mode-manager.d.ts.map +1 -0
- package/dist/domain/services/environment-mode-manager.js +37 -0
- package/dist/domain/services/environment-mode-manager.js.map +1 -0
- package/dist/domain/services/risk-tier-detector.d.ts +18 -0
- package/dist/domain/services/risk-tier-detector.d.ts.map +1 -0
- package/dist/domain/services/risk-tier-detector.js +65 -0
- package/dist/domain/services/risk-tier-detector.js.map +1 -0
- package/dist/formatter.d.ts.map +1 -1
- package/dist/formatter.js +10 -3
- package/dist/formatter.js.map +1 -1
- package/dist/index.js +103 -129
- 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 +15 -2
- package/dist/infrastructure/ai/cohere-ai-service.js.map +1 -1
- package/dist/infrastructure/ai/fake-ai-service.d.ts +22 -0
- package/dist/infrastructure/ai/fake-ai-service.d.ts.map +1 -0
- package/dist/infrastructure/ai/fake-ai-service.js +59 -0
- package/dist/infrastructure/ai/fake-ai-service.js.map +1 -0
- package/dist/infrastructure/ai/provider-ai-service.d.ts +59 -0
- package/dist/infrastructure/ai/provider-ai-service.d.ts.map +1 -0
- package/dist/infrastructure/ai/provider-ai-service.js +477 -0
- package/dist/infrastructure/ai/provider-ai-service.js.map +1 -0
- package/dist/infrastructure/cache/embedding-cache.d.ts +13 -1
- package/dist/infrastructure/cache/embedding-cache.d.ts.map +1 -1
- package/dist/infrastructure/cache/embedding-cache.js +80 -9
- package/dist/infrastructure/cache/embedding-cache.js.map +1 -1
- package/dist/infrastructure/cache/response-cache.d.ts +86 -0
- package/dist/infrastructure/cache/response-cache.d.ts.map +1 -0
- package/dist/infrastructure/cache/response-cache.js +224 -0
- package/dist/infrastructure/cache/response-cache.js.map +1 -0
- package/dist/infrastructure/context/conversation-context.d.ts +58 -0
- package/dist/infrastructure/context/conversation-context.d.ts.map +1 -0
- package/dist/infrastructure/context/conversation-context.js +170 -0
- package/dist/infrastructure/context/conversation-context.js.map +1 -0
- package/dist/infrastructure/context/session-manager.d.ts +26 -0
- package/dist/infrastructure/context/session-manager.d.ts.map +1 -0
- package/dist/infrastructure/context/session-manager.js +98 -0
- package/dist/infrastructure/context/session-manager.js.map +1 -0
- package/dist/infrastructure/cost/cost-tracker.d.ts +1 -0
- package/dist/infrastructure/cost/cost-tracker.d.ts.map +1 -1
- package/dist/infrastructure/cost/cost-tracker.js +12 -5
- package/dist/infrastructure/cost/cost-tracker.js.map +1 -1
- package/dist/infrastructure/governance/nist-ai-rmf.d.ts +6 -8
- package/dist/infrastructure/governance/nist-ai-rmf.d.ts.map +1 -1
- package/dist/infrastructure/governance/nist-ai-rmf.js +6 -8
- package/dist/infrastructure/governance/nist-ai-rmf.js.map +1 -1
- package/dist/infrastructure/governance/policy-as-code.d.ts +6 -8
- package/dist/infrastructure/governance/policy-as-code.d.ts.map +1 -1
- package/dist/infrastructure/governance/policy-as-code.js +6 -8
- package/dist/infrastructure/governance/policy-as-code.js.map +1 -1
- package/dist/infrastructure/governance/prompt-to-code-lineage.d.ts +7 -9
- package/dist/infrastructure/governance/prompt-to-code-lineage.d.ts.map +1 -1
- package/dist/infrastructure/governance/prompt-to-code-lineage.js +7 -9
- package/dist/infrastructure/governance/prompt-to-code-lineage.js.map +1 -1
- package/dist/infrastructure/providers/cohere-provider.d.ts +39 -0
- package/dist/infrastructure/providers/cohere-provider.d.ts.map +1 -0
- package/dist/infrastructure/providers/cohere-provider.js +359 -0
- package/dist/infrastructure/providers/cohere-provider.js.map +1 -0
- package/dist/infrastructure/providers/fake-provider.d.ts +43 -0
- package/dist/infrastructure/providers/fake-provider.d.ts.map +1 -0
- package/dist/infrastructure/providers/fake-provider.js +130 -0
- package/dist/infrastructure/providers/fake-provider.js.map +1 -0
- package/dist/infrastructure/providers/local-llm-provider.d.ts +49 -0
- package/dist/infrastructure/providers/local-llm-provider.d.ts.map +1 -0
- package/dist/infrastructure/providers/local-llm-provider.js +330 -0
- package/dist/infrastructure/providers/local-llm-provider.js.map +1 -0
- package/dist/infrastructure/providers/model-config.types.d.ts +70 -0
- package/dist/infrastructure/providers/model-config.types.d.ts.map +1 -0
- package/dist/infrastructure/providers/model-config.types.js +9 -0
- package/dist/infrastructure/providers/model-config.types.js.map +1 -0
- package/dist/infrastructure/providers/model-provider.interface.d.ts +113 -0
- package/dist/infrastructure/providers/model-provider.interface.d.ts.map +1 -0
- package/dist/infrastructure/providers/model-provider.interface.js +8 -0
- package/dist/infrastructure/providers/model-provider.interface.js.map +1 -0
- package/dist/infrastructure/providers/openai-provider.d.ts +38 -0
- package/dist/infrastructure/providers/openai-provider.d.ts.map +1 -0
- package/dist/infrastructure/providers/openai-provider.js +413 -0
- package/dist/infrastructure/providers/openai-provider.js.map +1 -0
- package/dist/infrastructure/providers/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/storage/task-helpers.d.ts +58 -0
- package/dist/infrastructure/storage/task-helpers.d.ts.map +1 -0
- package/dist/infrastructure/storage/task-helpers.js +157 -0
- package/dist/infrastructure/storage/task-helpers.js.map +1 -0
- package/dist/infrastructure/storage/task-repository.d.ts +67 -0
- package/dist/infrastructure/storage/task-repository.d.ts.map +1 -0
- package/dist/infrastructure/storage/task-repository.js +205 -0
- package/dist/infrastructure/storage/task-repository.js.map +1 -0
- package/dist/infrastructure/ux/bi-directional-learning.d.ts +22 -0
- package/dist/infrastructure/ux/bi-directional-learning.d.ts.map +1 -1
- package/dist/infrastructure/ux/bi-directional-learning.js +144 -7
- package/dist/infrastructure/ux/bi-directional-learning.js.map +1 -1
- package/dist/infrastructure/ux/capability-boundaries.d.ts +50 -0
- package/dist/infrastructure/ux/capability-boundaries.d.ts.map +1 -0
- package/dist/infrastructure/ux/capability-boundaries.js +167 -0
- package/dist/infrastructure/ux/capability-boundaries.js.map +1 -0
- package/dist/infrastructure/ux/comprehensive-formatter.d.ts +63 -0
- package/dist/infrastructure/ux/comprehensive-formatter.d.ts.map +1 -0
- package/dist/infrastructure/ux/comprehensive-formatter.js +212 -0
- package/dist/infrastructure/ux/comprehensive-formatter.js.map +1 -0
- package/dist/infrastructure/ux/feedback-prompt.d.ts +42 -0
- package/dist/infrastructure/ux/feedback-prompt.d.ts.map +1 -0
- package/dist/infrastructure/ux/feedback-prompt.js +181 -0
- package/dist/infrastructure/ux/feedback-prompt.js.map +1 -0
- package/dist/infrastructure/ux/hitl-review-portal.d.ts.map +1 -1
- package/dist/infrastructure/ux/hitl-review-portal.js +4 -1
- package/dist/infrastructure/ux/hitl-review-portal.js.map +1 -1
- package/dist/infrastructure/ux/hitl-validation.d.ts +35 -0
- package/dist/infrastructure/ux/hitl-validation.d.ts.map +1 -1
- package/dist/infrastructure/ux/hitl-validation.js +86 -0
- package/dist/infrastructure/ux/hitl-validation.js.map +1 -1
- package/dist/infrastructure/ux/progress-indicator.d.ts +2 -1
- package/dist/infrastructure/ux/progress-indicator.d.ts.map +1 -1
- package/dist/infrastructure/ux/progress-indicator.js +13 -3
- package/dist/infrastructure/ux/progress-indicator.js.map +1 -1
- package/dist/infrastructure/ux/proportional-friction.d.ts +73 -0
- package/dist/infrastructure/ux/proportional-friction.d.ts.map +1 -0
- package/dist/infrastructure/ux/proportional-friction.js +200 -0
- package/dist/infrastructure/ux/proportional-friction.js.map +1 -0
- package/dist/infrastructure/validation/agent-feedback.d.ts +115 -0
- package/dist/infrastructure/validation/agent-feedback.d.ts.map +1 -0
- package/dist/infrastructure/validation/agent-feedback.js +227 -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 +88 -0
- package/dist/infrastructure/validation/agent-validation-helper.js.map +1 -0
- package/dist/infrastructure/validation/feedback-stats.d.ts +99 -0
- package/dist/infrastructure/validation/feedback-stats.d.ts.map +1 -0
- package/dist/infrastructure/validation/feedback-stats.js +173 -0
- package/dist/infrastructure/validation/feedback-stats.js.map +1 -0
- package/dist/infrastructure/validation/review-handler.d.ts +54 -0
- package/dist/infrastructure/validation/review-handler.d.ts.map +1 -0
- package/dist/infrastructure/validation/review-handler.js +206 -0
- package/dist/infrastructure/validation/review-handler.js.map +1 -0
- package/dist/infrastructure/validation/summary-aggregator.d.ts +42 -0
- package/dist/infrastructure/validation/summary-aggregator.d.ts.map +1 -0
- package/dist/infrastructure/validation/summary-aggregator.js +156 -0
- package/dist/infrastructure/validation/summary-aggregator.js.map +1 -0
- package/dist/infrastructure/validation/summary-extractor.d.ts +59 -0
- package/dist/infrastructure/validation/summary-extractor.d.ts.map +1 -0
- package/dist/infrastructure/validation/summary-extractor.js +102 -0
- package/dist/infrastructure/validation/summary-extractor.js.map +1 -0
- package/dist/infrastructure/validation/trace-summary.d.ts +72 -0
- package/dist/infrastructure/validation/trace-summary.d.ts.map +1 -0
- package/dist/infrastructure/validation/trace-summary.js +371 -0
- package/dist/infrastructure/validation/trace-summary.js.map +1 -0
- package/dist/infrastructure/validation/trust-config.d.ts +27 -0
- package/dist/infrastructure/validation/trust-config.d.ts.map +1 -0
- package/dist/infrastructure/validation/trust-config.js +113 -0
- package/dist/infrastructure/validation/trust-config.js.map +1 -0
- package/dist/infrastructure/xai/attention-visualizer.d.ts +6 -8
- package/dist/infrastructure/xai/attention-visualizer.d.ts.map +1 -1
- package/dist/infrastructure/xai/attention-visualizer.js +6 -8
- package/dist/infrastructure/xai/attention-visualizer.js.map +1 -1
- package/dist/infrastructure/xai/cot-visualizer.d.ts +6 -9
- package/dist/infrastructure/xai/cot-visualizer.d.ts.map +1 -1
- package/dist/infrastructure/xai/cot-visualizer.js +6 -9
- package/dist/infrastructure/xai/cot-visualizer.js.map +1 -1
- package/dist/infrastructure/xai/decision-tree-log.d.ts +6 -10
- package/dist/infrastructure/xai/decision-tree-log.d.ts.map +1 -1
- package/dist/infrastructure/xai/decision-tree-log.js +6 -10
- package/dist/infrastructure/xai/decision-tree-log.js.map +1 -1
- package/dist/infrastructure/xai/interactive-xai.d.ts +6 -8
- package/dist/infrastructure/xai/interactive-xai.d.ts.map +1 -1
- package/dist/infrastructure/xai/interactive-xai.js +6 -8
- package/dist/infrastructure/xai/interactive-xai.js.map +1 -1
- package/dist/infrastructure/xai/uncertainty-quantifier.d.ts +6 -9
- package/dist/infrastructure/xai/uncertainty-quantifier.d.ts.map +1 -1
- package/dist/infrastructure/xai/uncertainty-quantifier.js +6 -9
- package/dist/infrastructure/xai/uncertainty-quantifier.js.map +1 -1
- package/dist/presentation/cli/commands/ask-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/ask-command.js +84 -2
- package/dist/presentation/cli/commands/ask-command.js.map +1 -1
- package/dist/presentation/cli/commands/docs-command.d.ts +12 -0
- package/dist/presentation/cli/commands/docs-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/docs-command.js +196 -0
- package/dist/presentation/cli/commands/docs-command.js.map +1 -0
- package/dist/presentation/cli/commands/fix-command.d.ts +8 -0
- package/dist/presentation/cli/commands/fix-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/fix-command.js +309 -0
- package/dist/presentation/cli/commands/fix-command.js.map +1 -0
- package/dist/presentation/cli/commands/help-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/help-command.js +2 -0
- package/dist/presentation/cli/commands/help-command.js.map +1 -1
- package/dist/presentation/cli/commands/orchestrate-command.d.ts +1 -0
- package/dist/presentation/cli/commands/orchestrate-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/orchestrate-command.js +53 -0
- package/dist/presentation/cli/commands/orchestrate-command.js.map +1 -1
- package/dist/presentation/cli/commands/plan-command.d.ts +1 -0
- package/dist/presentation/cli/commands/plan-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/plan-command.js +80 -3
- package/dist/presentation/cli/commands/plan-command.js.map +1 -1
- package/dist/presentation/cli/commands/product-command.d.ts +12 -0
- package/dist/presentation/cli/commands/product-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/product-command.js +188 -0
- package/dist/presentation/cli/commands/product-command.js.map +1 -0
- package/dist/presentation/cli/commands/react-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/react-command.js +3 -1
- package/dist/presentation/cli/commands/react-command.js.map +1 -1
- package/dist/presentation/cli/commands/review-command.d.ts +14 -0
- package/dist/presentation/cli/commands/review-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/review-command.js +22 -0
- package/dist/presentation/cli/commands/review-command.js.map +1 -0
- package/dist/presentation/cli/commands/run-command.d.ts +15 -0
- package/dist/presentation/cli/commands/run-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/run-command.js +29 -0
- package/dist/presentation/cli/commands/run-command.js.map +1 -0
- package/dist/presentation/cli/commands/smart-command.d.ts +3 -1
- package/dist/presentation/cli/commands/smart-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/smart-command.js +92 -6
- package/dist/presentation/cli/commands/smart-command.js.map +1 -1
- package/dist/presentation/cli/commands/status-command.d.ts +11 -0
- package/dist/presentation/cli/commands/status-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/status-command.js +176 -0
- package/dist/presentation/cli/commands/status-command.js.map +1 -0
- package/dist/presentation/cli/commands/suggest-command.d.ts +13 -0
- package/dist/presentation/cli/commands/suggest-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/suggest-command.js +25 -0
- package/dist/presentation/cli/commands/suggest-command.js.map +1 -0
- package/dist/presentation/cli/error-display.d.ts.map +1 -1
- package/dist/presentation/cli/error-display.js +43 -0
- package/dist/presentation/cli/error-display.js.map +1 -1
- package/dist/session.js +19 -2
- package/dist/session.js.map +1 -1
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +8 -5
- package/dist/ui.js.map +1 -1
- package/package.json +10 -2
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Infrastructure: Response Cache
|
|
3
|
+
* Caches AI chat responses to avoid redundant API calls for similar queries
|
|
4
|
+
*
|
|
5
|
+
* Performance optimization: Reduces AI Chat latency by ~90% for cached queries
|
|
6
|
+
* Uses fuzzy matching to cache similar queries (85%+ similarity)
|
|
7
|
+
*/
|
|
8
|
+
export declare class ResponseCache {
|
|
9
|
+
private cache;
|
|
10
|
+
private maxSize;
|
|
11
|
+
private ttl;
|
|
12
|
+
private accessOrder;
|
|
13
|
+
constructor(options?: {
|
|
14
|
+
maxSize?: number;
|
|
15
|
+
ttl?: number;
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* Generate cache key from query and context hash
|
|
19
|
+
*/
|
|
20
|
+
private getCacheKey;
|
|
21
|
+
/**
|
|
22
|
+
* Generate hash from context chunks (for cache key)
|
|
23
|
+
*/
|
|
24
|
+
generateContextHash(chunks: Array<{
|
|
25
|
+
filepath: string;
|
|
26
|
+
content: string;
|
|
27
|
+
}>): string;
|
|
28
|
+
/**
|
|
29
|
+
* Get cached response if available and not expired
|
|
30
|
+
* OPTIMIZATION: Also checks for similar queries with fuzzy matching
|
|
31
|
+
* Strategy: Try exact match first, then try without context hash (for same query, different context)
|
|
32
|
+
*/
|
|
33
|
+
get(query: string, contextHash?: string, enableFuzzyMatch?: boolean): string | null;
|
|
34
|
+
/**
|
|
35
|
+
* Find similar query using word overlap similarity
|
|
36
|
+
* Returns cached response if similarity >= threshold
|
|
37
|
+
*/
|
|
38
|
+
private findSimilarQuery;
|
|
39
|
+
/**
|
|
40
|
+
* Calculate string similarity using word overlap (Jaccard similarity)
|
|
41
|
+
* Returns value between 0.0 (no similarity) and 1.0 (identical)
|
|
42
|
+
*/
|
|
43
|
+
private calculateSimilarity;
|
|
44
|
+
/**
|
|
45
|
+
* Store response in cache
|
|
46
|
+
*/
|
|
47
|
+
set(query: string, answer: string, contextHash?: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Clear all cached responses
|
|
50
|
+
*/
|
|
51
|
+
clear(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Get cache statistics
|
|
54
|
+
*/
|
|
55
|
+
getStats(): {
|
|
56
|
+
size: number;
|
|
57
|
+
maxSize: number;
|
|
58
|
+
hitRate: number;
|
|
59
|
+
totalHits: number;
|
|
60
|
+
totalMisses: number;
|
|
61
|
+
};
|
|
62
|
+
private totalHits;
|
|
63
|
+
private totalMisses;
|
|
64
|
+
/**
|
|
65
|
+
* Record cache hit
|
|
66
|
+
*/
|
|
67
|
+
recordHit(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Record cache miss
|
|
70
|
+
*/
|
|
71
|
+
recordMiss(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Update access order for LRU eviction
|
|
74
|
+
*/
|
|
75
|
+
private updateAccessOrder;
|
|
76
|
+
/**
|
|
77
|
+
* Remove key from access order
|
|
78
|
+
*/
|
|
79
|
+
private removeFromAccessOrder;
|
|
80
|
+
/**
|
|
81
|
+
* Evict oldest entry (LRU)
|
|
82
|
+
*/
|
|
83
|
+
private evictOldest;
|
|
84
|
+
}
|
|
85
|
+
export declare function getResponseCache(): ResponseCache;
|
|
86
|
+
//# sourceMappingURL=response-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-cache.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/cache/response-cache.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH,qBAAa,aAAa;IACxB,OAAO,CAAC,KAAK,CAA0C;IACvD,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,GAAG,CAA0B;IACrC,OAAO,CAAC,WAAW,CAAgB;gBAEvB,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE;IAKxD;;OAEG;IACH,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACH,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,MAAM;IASjF;;;;OAIG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,gBAAgB,GAAE,OAAc,GAAG,MAAM,GAAG,IAAI;IAgDzF;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAgCxB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAsB3B;;OAEG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAkB9D;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,QAAQ,IAAI;QACV,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;KACrB;IAWD,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,WAAW,CAAa;IAEhC;;OAEG;IACH,SAAS,IAAI,IAAI;IAIjB;;OAEG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAQzB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAO7B;;OAEG;IACH,OAAO,CAAC,WAAW;CAOpB;AAKD,wBAAgB,gBAAgB,IAAI,aAAa,CAKhD"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Infrastructure: Response Cache
|
|
3
|
+
* Caches AI chat responses to avoid redundant API calls for similar queries
|
|
4
|
+
*
|
|
5
|
+
* Performance optimization: Reduces AI Chat latency by ~90% for cached queries
|
|
6
|
+
* Uses fuzzy matching to cache similar queries (85%+ similarity)
|
|
7
|
+
*/
|
|
8
|
+
import { createHash } from 'crypto';
|
|
9
|
+
export class ResponseCache {
|
|
10
|
+
cache = new Map();
|
|
11
|
+
maxSize = 200; // Max cached responses
|
|
12
|
+
ttl = 60 * 60 * 1000; // 1 hour TTL
|
|
13
|
+
accessOrder = []; // LRU tracking
|
|
14
|
+
constructor(options) {
|
|
15
|
+
this.maxSize = options?.maxSize || 200;
|
|
16
|
+
this.ttl = options?.ttl || 60 * 60 * 1000;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Generate cache key from query and context hash
|
|
20
|
+
*/
|
|
21
|
+
getCacheKey(query, contextHash) {
|
|
22
|
+
const normalized = query.trim().toLowerCase();
|
|
23
|
+
const key = contextHash ? `${normalized}:${contextHash}` : normalized;
|
|
24
|
+
return createHash('sha256').update(key).digest('hex');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Generate hash from context chunks (for cache key)
|
|
28
|
+
*/
|
|
29
|
+
generateContextHash(chunks) {
|
|
30
|
+
// Create hash from filepaths and content lengths (not full content for performance)
|
|
31
|
+
const contextKey = chunks
|
|
32
|
+
.map(c => `${c.filepath}:${c.content.length}`)
|
|
33
|
+
.sort()
|
|
34
|
+
.join('|');
|
|
35
|
+
return createHash('sha256').update(contextKey).digest('hex').substring(0, 16);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get cached response if available and not expired
|
|
39
|
+
* OPTIMIZATION: Also checks for similar queries with fuzzy matching
|
|
40
|
+
* Strategy: Try exact match first, then try without context hash (for same query, different context)
|
|
41
|
+
*/
|
|
42
|
+
get(query, contextHash, enableFuzzyMatch = true) {
|
|
43
|
+
// Try exact match with context hash first
|
|
44
|
+
const keyWithContext = this.getCacheKey(query, contextHash);
|
|
45
|
+
let cached = this.cache.get(keyWithContext);
|
|
46
|
+
if (cached) {
|
|
47
|
+
const now = Date.now();
|
|
48
|
+
if (now - cached.timestamp > this.ttl) {
|
|
49
|
+
this.cache.delete(keyWithContext);
|
|
50
|
+
this.removeFromAccessOrder(keyWithContext);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
this.updateAccessOrder(keyWithContext);
|
|
54
|
+
this.recordHit();
|
|
55
|
+
return cached.answer;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Try without context hash (same query, different context order is usually fine)
|
|
59
|
+
if (contextHash) {
|
|
60
|
+
const keyWithoutContext = this.getCacheKey(query);
|
|
61
|
+
cached = this.cache.get(keyWithoutContext);
|
|
62
|
+
if (cached) {
|
|
63
|
+
const now = Date.now();
|
|
64
|
+
if (now - cached.timestamp <= this.ttl) {
|
|
65
|
+
this.updateAccessOrder(keyWithoutContext);
|
|
66
|
+
this.recordHit();
|
|
67
|
+
return cached.answer;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Fuzzy matching for similar queries (85%+ similarity threshold)
|
|
72
|
+
if (enableFuzzyMatch && this.cache.size > 0) {
|
|
73
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
74
|
+
const bestMatch = this.findSimilarQuery(normalizedQuery, contextHash, 0.85);
|
|
75
|
+
if (bestMatch && bestMatch.response) {
|
|
76
|
+
// Found similar query - reuse its response
|
|
77
|
+
this.updateAccessOrder(bestMatch.key);
|
|
78
|
+
this.recordHit();
|
|
79
|
+
return bestMatch.response.answer;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
this.recordMiss();
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Find similar query using word overlap similarity
|
|
87
|
+
* Returns cached response if similarity >= threshold
|
|
88
|
+
*/
|
|
89
|
+
findSimilarQuery(query, contextHash, threshold = 0.85) {
|
|
90
|
+
let bestMatch = null;
|
|
91
|
+
const now = Date.now();
|
|
92
|
+
for (const [key, cached] of this.cache.entries()) {
|
|
93
|
+
// Skip expired entries
|
|
94
|
+
if (now - cached.timestamp > this.ttl) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
// If context hash provided, only match responses with same context
|
|
98
|
+
if (contextHash && cached.contextHash && cached.contextHash !== contextHash) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const normalizedCached = cached.query.trim().toLowerCase();
|
|
102
|
+
const similarity = this.calculateSimilarity(query, normalizedCached);
|
|
103
|
+
if (similarity >= threshold) {
|
|
104
|
+
if (!bestMatch || similarity > bestMatch.similarity) {
|
|
105
|
+
bestMatch = { key, response: cached, similarity };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return bestMatch;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Calculate string similarity using word overlap (Jaccard similarity)
|
|
113
|
+
* Returns value between 0.0 (no similarity) and 1.0 (identical)
|
|
114
|
+
*/
|
|
115
|
+
calculateSimilarity(str1, str2) {
|
|
116
|
+
if (str1 === str2)
|
|
117
|
+
return 1.0;
|
|
118
|
+
if (str1.length === 0 || str2.length === 0)
|
|
119
|
+
return 0.0;
|
|
120
|
+
// Use word overlap for performance (faster than full Levenshtein)
|
|
121
|
+
const words1 = new Set(str1.split(/\s+/).filter(w => w.length > 2)); // Ignore short words
|
|
122
|
+
const words2 = new Set(str2.split(/\s+/).filter(w => w.length > 2));
|
|
123
|
+
if (words1.size === 0 || words2.size === 0)
|
|
124
|
+
return 0.0;
|
|
125
|
+
// Calculate Jaccard similarity (word overlap)
|
|
126
|
+
let intersection = 0;
|
|
127
|
+
for (const word of words1) {
|
|
128
|
+
if (words2.has(word)) {
|
|
129
|
+
intersection++;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const union = words1.size + words2.size - intersection;
|
|
133
|
+
return union > 0 ? intersection / union : 0.0;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Store response in cache
|
|
137
|
+
*/
|
|
138
|
+
set(query, answer, contextHash) {
|
|
139
|
+
const key = this.getCacheKey(query, contextHash);
|
|
140
|
+
// Evict oldest if cache is full
|
|
141
|
+
if (this.cache.size >= this.maxSize && !this.cache.has(key)) {
|
|
142
|
+
this.evictOldest();
|
|
143
|
+
}
|
|
144
|
+
this.cache.set(key, {
|
|
145
|
+
answer,
|
|
146
|
+
timestamp: Date.now(),
|
|
147
|
+
query: query.trim(),
|
|
148
|
+
contextHash,
|
|
149
|
+
});
|
|
150
|
+
this.updateAccessOrder(key);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Clear all cached responses
|
|
154
|
+
*/
|
|
155
|
+
clear() {
|
|
156
|
+
this.cache.clear();
|
|
157
|
+
this.accessOrder = [];
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Get cache statistics
|
|
161
|
+
*/
|
|
162
|
+
getStats() {
|
|
163
|
+
const total = this.totalHits + this.totalMisses;
|
|
164
|
+
return {
|
|
165
|
+
size: this.cache.size,
|
|
166
|
+
maxSize: this.maxSize,
|
|
167
|
+
hitRate: total > 0 ? this.totalHits / total : 0,
|
|
168
|
+
totalHits: this.totalHits,
|
|
169
|
+
totalMisses: this.totalMisses,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
totalHits = 0;
|
|
173
|
+
totalMisses = 0;
|
|
174
|
+
/**
|
|
175
|
+
* Record cache hit
|
|
176
|
+
*/
|
|
177
|
+
recordHit() {
|
|
178
|
+
this.totalHits++;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Record cache miss
|
|
182
|
+
*/
|
|
183
|
+
recordMiss() {
|
|
184
|
+
this.totalMisses++;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Update access order for LRU eviction
|
|
188
|
+
*/
|
|
189
|
+
updateAccessOrder(key) {
|
|
190
|
+
const index = this.accessOrder.indexOf(key);
|
|
191
|
+
if (index > -1) {
|
|
192
|
+
this.accessOrder.splice(index, 1);
|
|
193
|
+
}
|
|
194
|
+
this.accessOrder.push(key);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Remove key from access order
|
|
198
|
+
*/
|
|
199
|
+
removeFromAccessOrder(key) {
|
|
200
|
+
const index = this.accessOrder.indexOf(key);
|
|
201
|
+
if (index > -1) {
|
|
202
|
+
this.accessOrder.splice(index, 1);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Evict oldest entry (LRU)
|
|
207
|
+
*/
|
|
208
|
+
evictOldest() {
|
|
209
|
+
if (this.accessOrder.length === 0)
|
|
210
|
+
return;
|
|
211
|
+
const oldestKey = this.accessOrder[0];
|
|
212
|
+
this.cache.delete(oldestKey);
|
|
213
|
+
this.accessOrder.shift();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// Singleton instance
|
|
217
|
+
let responseCacheInstance = null;
|
|
218
|
+
export function getResponseCache() {
|
|
219
|
+
if (!responseCacheInstance) {
|
|
220
|
+
responseCacheInstance = new ResponseCache();
|
|
221
|
+
}
|
|
222
|
+
return responseCacheInstance;
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=response-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-cache.js","sourceRoot":"","sources":["../../../src/infrastructure/cache/response-cache.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AASpC,MAAM,OAAO,aAAa;IAChB,KAAK,GAAgC,IAAI,GAAG,EAAE,CAAC;IAC/C,OAAO,GAAW,GAAG,CAAC,CAAC,uBAAuB;IAC9C,GAAG,GAAW,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;IAC3C,WAAW,GAAa,EAAE,CAAC,CAAC,eAAe;IAEnD,YAAY,OAA4C;QACtD,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,GAAG,CAAC;QACvC,IAAI,CAAC,GAAG,GAAG,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC5C,CAAC;IAED;;OAEG;IACK,WAAW,CAAC,KAAa,EAAE,WAAoB;QACrD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC9C,MAAM,GAAG,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,UAA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CAAC,CAAC,EAAE,CAAC;YACf,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAED;;OAEG;IACK,WAAW;QACjB,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAE1C,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QACtC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC7B,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACF;AAED,qBAAqB;AACrB,IAAI,qBAAqB,GAAyB,IAAI,CAAC;AAEvD,MAAM,UAAU,gBAAgB;IAC9B,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC3B,qBAAqB,GAAG,IAAI,aAAa,EAAE,CAAC;IAC9C,CAAC;IACD,OAAO,qBAAqB,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation Context Manager
|
|
3
|
+
* Maintains conversation history and enables reference resolution
|
|
4
|
+
*/
|
|
5
|
+
export interface ConversationTurn {
|
|
6
|
+
query: string;
|
|
7
|
+
response: string;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
entities?: string[];
|
|
10
|
+
intent?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ConversationContext {
|
|
13
|
+
sessionId: string;
|
|
14
|
+
turns: ConversationTurn[];
|
|
15
|
+
currentFocus?: {
|
|
16
|
+
entity?: string;
|
|
17
|
+
filepath?: string;
|
|
18
|
+
topic?: string;
|
|
19
|
+
};
|
|
20
|
+
createdAt: number;
|
|
21
|
+
lastUpdated: number;
|
|
22
|
+
}
|
|
23
|
+
export declare class ConversationContextManager {
|
|
24
|
+
private conversations;
|
|
25
|
+
private maxHistoryLength;
|
|
26
|
+
private maxTotalHistoryLength;
|
|
27
|
+
/**
|
|
28
|
+
* Get or create conversation context for a session
|
|
29
|
+
*/
|
|
30
|
+
getContext(sessionId: string): ConversationContext;
|
|
31
|
+
/**
|
|
32
|
+
* Add a turn to conversation history
|
|
33
|
+
* EDGE CASE: Handles very long histories, concurrent sessions, and memory limits
|
|
34
|
+
*/
|
|
35
|
+
addTurn(sessionId: string, query: string, response: string, entities?: string[], intent?: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Get conversation history for context
|
|
38
|
+
*/
|
|
39
|
+
getHistory(sessionId: string, maxTurns?: number): ConversationTurn[];
|
|
40
|
+
/**
|
|
41
|
+
* Resolve references in query (e.g., "it", "that", "the previous")
|
|
42
|
+
*/
|
|
43
|
+
resolveReferences(sessionId: string, query: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Extract entities from query (file names, functions, classes)
|
|
46
|
+
*/
|
|
47
|
+
extractEntities(query: string): string[];
|
|
48
|
+
/**
|
|
49
|
+
* Get conversation context summary for AI prompts
|
|
50
|
+
*/
|
|
51
|
+
getContextSummary(sessionId: string, maxTurns?: number): string;
|
|
52
|
+
/**
|
|
53
|
+
* Clear conversation context (for new session)
|
|
54
|
+
*/
|
|
55
|
+
clearContext(sessionId: string): void;
|
|
56
|
+
}
|
|
57
|
+
export declare const conversationContextManager: ConversationContextManager;
|
|
58
|
+
//# sourceMappingURL=conversation-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-context.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/context/conversation-context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,0BAA0B;IACrC,OAAO,CAAC,aAAa,CAA+C;IACpE,OAAO,CAAC,gBAAgB,CAAM;IAC9B,OAAO,CAAC,qBAAqB,CAAM;IAEnC;;OAEG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,mBAAmB;IAYlD;;;OAGG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IA2CvG;;OAEG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,gBAAgB,EAAE;IAKvE;;OAEG;IACH,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAyD3D;;OAEG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IA2BxC;;OAEG;IACH,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,MAAM;IAelE;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAGtC;AAGD,eAAO,MAAM,0BAA0B,4BAAmC,CAAC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation Context Manager
|
|
3
|
+
* Maintains conversation history and enables reference resolution
|
|
4
|
+
*/
|
|
5
|
+
export class ConversationContextManager {
|
|
6
|
+
conversations = new Map();
|
|
7
|
+
maxHistoryLength = 10; // Keep last 10 turns
|
|
8
|
+
maxTotalHistoryLength = 50; // Hard limit to prevent memory issues
|
|
9
|
+
/**
|
|
10
|
+
* Get or create conversation context for a session
|
|
11
|
+
*/
|
|
12
|
+
getContext(sessionId) {
|
|
13
|
+
if (!this.conversations.has(sessionId)) {
|
|
14
|
+
this.conversations.set(sessionId, {
|
|
15
|
+
sessionId,
|
|
16
|
+
turns: [],
|
|
17
|
+
createdAt: Date.now(),
|
|
18
|
+
lastUpdated: Date.now(),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return this.conversations.get(sessionId);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Add a turn to conversation history
|
|
25
|
+
* EDGE CASE: Handles very long histories, concurrent sessions, and memory limits
|
|
26
|
+
*/
|
|
27
|
+
addTurn(sessionId, query, response, entities, intent) {
|
|
28
|
+
const context = this.getContext(sessionId);
|
|
29
|
+
// EDGE CASE: Prevent memory issues with very long histories
|
|
30
|
+
if (context.turns.length >= this.maxTotalHistoryLength) {
|
|
31
|
+
// Keep only the most recent turns (remove oldest 25%)
|
|
32
|
+
const removeCount = Math.floor(this.maxTotalHistoryLength * 0.25);
|
|
33
|
+
context.turns = context.turns.slice(removeCount);
|
|
34
|
+
}
|
|
35
|
+
// EDGE CASE: Truncate very long responses to prevent memory bloat
|
|
36
|
+
const maxResponseLength = 5000; // 5KB per response
|
|
37
|
+
const truncatedResponse = response.length > maxResponseLength
|
|
38
|
+
? response.substring(0, maxResponseLength) + '... [truncated]'
|
|
39
|
+
: response;
|
|
40
|
+
const turn = {
|
|
41
|
+
query: query.substring(0, 500), // Limit query length too
|
|
42
|
+
response: truncatedResponse,
|
|
43
|
+
timestamp: Date.now(),
|
|
44
|
+
entities: entities?.slice(0, 10), // Limit entities to prevent bloat
|
|
45
|
+
intent,
|
|
46
|
+
};
|
|
47
|
+
context.turns.push(turn);
|
|
48
|
+
// Keep only last N turns for active context
|
|
49
|
+
if (context.turns.length > this.maxHistoryLength) {
|
|
50
|
+
context.turns.shift();
|
|
51
|
+
}
|
|
52
|
+
// Update current focus based on entities
|
|
53
|
+
if (entities && entities.length > 0) {
|
|
54
|
+
context.currentFocus = {
|
|
55
|
+
entity: entities[0],
|
|
56
|
+
filepath: entities.find(e => e.includes('/') || e.endsWith('.ts') || e.endsWith('.js')) || entities[0],
|
|
57
|
+
topic: query.split(' ').slice(0, 5).join(' '), // First 5 words as topic
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
context.lastUpdated = Date.now();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get conversation history for context
|
|
64
|
+
*/
|
|
65
|
+
getHistory(sessionId, maxTurns = 5) {
|
|
66
|
+
const context = this.getContext(sessionId);
|
|
67
|
+
return context.turns.slice(-maxTurns);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Resolve references in query (e.g., "it", "that", "the previous")
|
|
71
|
+
*/
|
|
72
|
+
resolveReferences(sessionId, query) {
|
|
73
|
+
const context = this.getContext(sessionId);
|
|
74
|
+
const lastTurn = context.turns[context.turns.length - 1];
|
|
75
|
+
if (!lastTurn) {
|
|
76
|
+
return query; // No history to reference
|
|
77
|
+
}
|
|
78
|
+
let resolvedQuery = query;
|
|
79
|
+
const queryLower = query.toLowerCase();
|
|
80
|
+
// Resolve "it" references
|
|
81
|
+
if (queryLower.includes(' it ') || queryLower.startsWith('it ') || queryLower.endsWith(' it')) {
|
|
82
|
+
if (context.currentFocus?.entity) {
|
|
83
|
+
resolvedQuery = resolvedQuery.replace(/\bit\b/gi, context.currentFocus.entity);
|
|
84
|
+
}
|
|
85
|
+
else if (lastTurn.entities && lastTurn.entities.length > 0) {
|
|
86
|
+
resolvedQuery = resolvedQuery.replace(/\bit\b/gi, lastTurn.entities[0]);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// Use last query's main subject
|
|
90
|
+
const lastQueryWords = lastTurn.query.split(' ');
|
|
91
|
+
const mainSubject = lastQueryWords.find(word => word.length > 3 && !['what', 'how', 'where', 'when', 'why', 'does', 'the', 'a', 'an'].includes(word.toLowerCase())) || lastQueryWords[lastQueryWords.length - 1];
|
|
92
|
+
resolvedQuery = resolvedQuery.replace(/\bit\b/gi, mainSubject);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Resolve "that" references
|
|
96
|
+
if (queryLower.includes(' that ') || queryLower.startsWith('that ') || queryLower.endsWith(' that')) {
|
|
97
|
+
if (context.currentFocus?.entity) {
|
|
98
|
+
resolvedQuery = resolvedQuery.replace(/\bthat\b/gi, context.currentFocus.entity);
|
|
99
|
+
}
|
|
100
|
+
else if (lastTurn.entities && lastTurn.entities.length > 0) {
|
|
101
|
+
resolvedQuery = resolvedQuery.replace(/\bthat\b/gi, lastTurn.entities[0]);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Resolve "the previous" references
|
|
105
|
+
if (queryLower.includes('previous') || queryLower.includes('last')) {
|
|
106
|
+
if (lastTurn.query) {
|
|
107
|
+
resolvedQuery = resolvedQuery.replace(/\b(previous|last)\s+(one|query|question|command)?\b/gi, lastTurn.query);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Resolve "too" / "also" - append to previous action
|
|
111
|
+
if (queryLower.includes(' too') || queryLower.includes(' also')) {
|
|
112
|
+
if (lastTurn.query) {
|
|
113
|
+
resolvedQuery = query.replace(/\s+(too|also)\b/i, '');
|
|
114
|
+
// If previous was an edit, append to same file
|
|
115
|
+
if (lastTurn.intent === 'edit' && context.currentFocus?.filepath) {
|
|
116
|
+
resolvedQuery = `Add to ${context.currentFocus.filepath}: ${resolvedQuery}`;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return resolvedQuery.trim();
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Extract entities from query (file names, functions, classes)
|
|
124
|
+
*/
|
|
125
|
+
extractEntities(query) {
|
|
126
|
+
const entities = [];
|
|
127
|
+
// Extract file paths
|
|
128
|
+
const filePathPattern = /[\w\-./]+\.(ts|js|tsx|jsx|py|java|go|rs|rb|php|cs)/g;
|
|
129
|
+
const filePaths = query.match(filePathPattern);
|
|
130
|
+
if (filePaths) {
|
|
131
|
+
entities.push(...filePaths);
|
|
132
|
+
}
|
|
133
|
+
// Extract function/class names (capitalized words or camelCase)
|
|
134
|
+
const identifierPattern = /[A-Z][a-zA-Z0-9]+/g;
|
|
135
|
+
const identifiers = query.match(identifierPattern);
|
|
136
|
+
if (identifiers) {
|
|
137
|
+
entities.push(...identifiers.filter(id => id.length > 2));
|
|
138
|
+
}
|
|
139
|
+
// Extract quoted strings (often entity names)
|
|
140
|
+
const quotedPattern = /"([^"]+)"/g;
|
|
141
|
+
const quoted = query.match(quotedPattern);
|
|
142
|
+
if (quoted) {
|
|
143
|
+
entities.push(...quoted.map(q => q.replace(/"/g, '')));
|
|
144
|
+
}
|
|
145
|
+
return [...new Set(entities)]; // Remove duplicates
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Get conversation context summary for AI prompts
|
|
149
|
+
*/
|
|
150
|
+
getContextSummary(sessionId, maxTurns = 3) {
|
|
151
|
+
const history = this.getHistory(sessionId, maxTurns);
|
|
152
|
+
if (history.length === 0) {
|
|
153
|
+
return '';
|
|
154
|
+
}
|
|
155
|
+
const summary = history.map((turn, idx) => {
|
|
156
|
+
const turnNum = history.length - maxTurns + idx + 1;
|
|
157
|
+
return `[Previous ${turnNum}]: User asked "${turn.query}". Response: ${turn.response.substring(0, 100)}...`;
|
|
158
|
+
}).join('\n');
|
|
159
|
+
return `\n\nCONVERSATION HISTORY:\n${summary}\n`;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Clear conversation context (for new session)
|
|
163
|
+
*/
|
|
164
|
+
clearContext(sessionId) {
|
|
165
|
+
this.conversations.delete(sessionId);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// Singleton instance
|
|
169
|
+
export const conversationContextManager = new ConversationContextManager();
|
|
170
|
+
//# sourceMappingURL=conversation-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-context.js","sourceRoot":"","sources":["../../../src/infrastructure/context/conversation-context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsBH,MAAM,OAAO,0BAA0B;IAC7B,aAAa,GAAqC,IAAI,GAAG,EAAE,CAAC;IAC5D,gBAAgB,GAAG,EAAE,CAAC,CAAC,qBAAqB;IAC5C,qBAAqB,GAAG,EAAE,CAAC,CAAC,sCAAsC;IAE1E;;OAEG;IACH,UAAU,CAAC,SAAiB;QAC1B,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACvC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,EAAE;gBAChC,SAAS;gBACT,KAAK,EAAE,EAAE;gBACT,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;gBACrB,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE;aACxB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,SAAiB,EAAE,KAAa,EAAE,QAAgB,EAAE,QAAmB,EAAE,MAAe;QAC9F,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAE3C,4DAA4D;QAC5D,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;YACvD,sDAAsD;YACtD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAAC;YAClE,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACnD,CAAC;QAED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ACF;AAED,qBAAqB;AACrB,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,0BAA0B,EAAE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Manager
|
|
3
|
+
* Manages persistent session IDs for conversation context across CLI commands
|
|
4
|
+
*/
|
|
5
|
+
export declare class SessionManager {
|
|
6
|
+
private sessions;
|
|
7
|
+
constructor();
|
|
8
|
+
/**
|
|
9
|
+
* Get or create session ID for a codebase directory
|
|
10
|
+
*/
|
|
11
|
+
getSessionId(codebasePath: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Load sessions from disk
|
|
14
|
+
*/
|
|
15
|
+
private loadSessions;
|
|
16
|
+
/**
|
|
17
|
+
* Save sessions to disk
|
|
18
|
+
*/
|
|
19
|
+
private saveSessions;
|
|
20
|
+
/**
|
|
21
|
+
* Clear session for a codebase
|
|
22
|
+
*/
|
|
23
|
+
clearSession(codebasePath: string): void;
|
|
24
|
+
}
|
|
25
|
+
export declare const sessionManager: SessionManager;
|
|
26
|
+
//# sourceMappingURL=session-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-manager.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/context/session-manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAuC;;IAMvD;;OAEG;IACH,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IA0B1C;;OAEG;IACH,OAAO,CAAC,YAAY;IA4BpB;;OAEG;IACH,OAAO,CAAC,YAAY;IAmBpB;;OAEG;IACH,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CAKzC;AAGD,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
|