codehere 0.4.0 → 0.5.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/application/agents/execution-agent.js +2 -2
- package/dist/application/agents/execution-agent.js.map +1 -1
- package/dist/application/agents/planning-agent.d.ts.map +1 -1
- package/dist/application/agents/planning-agent.js +16 -8
- package/dist/application/agents/planning-agent.js.map +1 -1
- package/dist/application/agents/validation-agent.js +2 -2
- package/dist/application/agents/validation-agent.js.map +1 -1
- package/dist/application/services/dependency-container.d.ts +30 -6
- package/dist/application/services/dependency-container.d.ts.map +1 -1
- package/dist/application/services/dependency-container.js +75 -43
- package/dist/application/services/dependency-container.js.map +1 -1
- package/dist/application/services/intelligent-router.d.ts.map +1 -1
- package/dist/application/services/intelligent-router.js +6 -3
- package/dist/application/services/intelligent-router.js.map +1 -1
- package/dist/domain/entities/task.d.ts.map +1 -1
- package/dist/domain/entities/task.js +1 -1
- package/dist/domain/entities/task.js.map +1 -1
- package/dist/domain/errors/embeddings-not-found-error.d.ts +9 -0
- package/dist/domain/errors/embeddings-not-found-error.d.ts.map +1 -0
- package/dist/domain/errors/embeddings-not-found-error.js +13 -0
- package/dist/domain/errors/embeddings-not-found-error.js.map +1 -0
- package/dist/domain/interfaces/embedding-repository.interface.d.ts +5 -0
- package/dist/domain/interfaces/embedding-repository.interface.d.ts.map +1 -1
- package/dist/domain/services/environment-mode-manager.d.ts +4 -10
- package/dist/domain/services/environment-mode-manager.d.ts.map +1 -1
- package/dist/domain/services/environment-mode-manager.js +7 -22
- package/dist/domain/services/environment-mode-manager.js.map +1 -1
- package/dist/domain/services/risk-tier-detector.d.ts +8 -9
- package/dist/domain/services/risk-tier-detector.d.ts.map +1 -1
- package/dist/domain/services/risk-tier-detector.js +53 -40
- package/dist/domain/services/risk-tier-detector.js.map +1 -1
- package/dist/embed.d.ts.map +1 -1
- package/dist/embed.js +18 -8
- package/dist/embed.js.map +1 -1
- package/dist/index.js +308 -48
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/ai/cohere-ai-service.js +3 -3
- 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 +6 -6
- package/dist/infrastructure/ai/provider-ai-service.js.map +1 -1
- package/dist/infrastructure/cache/query-result-cache.d.ts +14 -55
- package/dist/infrastructure/cache/query-result-cache.d.ts.map +1 -1
- package/dist/infrastructure/cache/query-result-cache.js +40 -112
- package/dist/infrastructure/cache/query-result-cache.js.map +1 -1
- package/dist/infrastructure/cache/response-cache.d.ts +10 -78
- package/dist/infrastructure/cache/response-cache.d.ts.map +1 -1
- package/dist/infrastructure/cache/response-cache.js +22 -198
- package/dist/infrastructure/cache/response-cache.js.map +1 -1
- package/dist/infrastructure/cache/security-scan-cache.d.ts +8 -49
- package/dist/infrastructure/cache/security-scan-cache.d.ts.map +1 -1
- package/dist/infrastructure/cache/security-scan-cache.js +25 -102
- package/dist/infrastructure/cache/security-scan-cache.js.map +1 -1
- package/dist/infrastructure/completion/bash-completion.d.ts +2 -3
- package/dist/infrastructure/completion/bash-completion.d.ts.map +1 -1
- package/dist/infrastructure/completion/bash-completion.js +11 -87
- package/dist/infrastructure/completion/bash-completion.js.map +1 -1
- package/dist/infrastructure/completion/fish-completion.d.ts +2 -3
- package/dist/infrastructure/completion/fish-completion.d.ts.map +1 -1
- package/dist/infrastructure/completion/fish-completion.js +15 -58
- package/dist/infrastructure/completion/fish-completion.js.map +1 -1
- package/dist/infrastructure/completion/zsh-completion.d.ts +2 -3
- package/dist/infrastructure/completion/zsh-completion.d.ts.map +1 -1
- package/dist/infrastructure/completion/zsh-completion.js +18 -73
- package/dist/infrastructure/completion/zsh-completion.js.map +1 -1
- package/dist/infrastructure/config/config-manager.js +2 -2
- package/dist/infrastructure/config/config-manager.js.map +1 -1
- package/dist/infrastructure/context/conversation-context.d.ts +27 -31
- package/dist/infrastructure/context/conversation-context.d.ts.map +1 -1
- package/dist/infrastructure/context/conversation-context.js +94 -136
- package/dist/infrastructure/context/conversation-context.js.map +1 -1
- package/dist/infrastructure/context/session-manager.d.ts +27 -11
- package/dist/infrastructure/context/session-manager.d.ts.map +1 -1
- package/dist/infrastructure/context/session-manager.js +69 -73
- package/dist/infrastructure/context/session-manager.js.map +1 -1
- package/dist/infrastructure/providers/cohere-provider.d.ts.map +1 -1
- package/dist/infrastructure/providers/cohere-provider.js +102 -17
- package/dist/infrastructure/providers/cohere-provider.js.map +1 -1
- package/dist/infrastructure/providers/openrouter-provider.d.ts +42 -0
- package/dist/infrastructure/providers/openrouter-provider.d.ts.map +1 -0
- package/dist/infrastructure/providers/openrouter-provider.js +399 -0
- package/dist/infrastructure/providers/openrouter-provider.js.map +1 -0
- package/dist/infrastructure/serialization/toon-serializer.d.ts +45 -0
- package/dist/infrastructure/serialization/toon-serializer.d.ts.map +1 -0
- package/dist/infrastructure/serialization/toon-serializer.js +119 -0
- package/dist/infrastructure/serialization/toon-serializer.js.map +1 -0
- package/dist/infrastructure/storage/embeddings-path.d.ts +18 -0
- package/dist/infrastructure/storage/embeddings-path.d.ts.map +1 -0
- package/dist/infrastructure/storage/embeddings-path.js +37 -0
- package/dist/infrastructure/storage/embeddings-path.js.map +1 -0
- package/dist/infrastructure/storage/plan-repository.d.ts +2 -0
- package/dist/infrastructure/storage/plan-repository.d.ts.map +1 -1
- package/dist/infrastructure/storage/plan-repository.js +36 -73
- package/dist/infrastructure/storage/plan-repository.js.map +1 -1
- package/dist/infrastructure/storage/sqlite-embedding-repository.d.ts +10 -1
- package/dist/infrastructure/storage/sqlite-embedding-repository.d.ts.map +1 -1
- package/dist/infrastructure/storage/sqlite-embedding-repository.js +37 -3
- package/dist/infrastructure/storage/sqlite-embedding-repository.js.map +1 -1
- package/dist/infrastructure/storage/task-helpers.d.ts +11 -0
- package/dist/infrastructure/storage/task-helpers.d.ts.map +1 -1
- package/dist/infrastructure/storage/task-helpers.js +47 -7
- package/dist/infrastructure/storage/task-helpers.js.map +1 -1
- package/dist/infrastructure/storage/task-repository.d.ts.map +1 -1
- package/dist/infrastructure/storage/task-repository.js.map +1 -1
- package/dist/infrastructure/ux/capability-boundaries.d.ts +9 -37
- package/dist/infrastructure/ux/capability-boundaries.d.ts.map +1 -1
- package/dist/infrastructure/ux/capability-boundaries.js +23 -148
- package/dist/infrastructure/ux/capability-boundaries.js.map +1 -1
- package/dist/infrastructure/ux/comprehensive-formatter.d.ts +12 -54
- package/dist/infrastructure/ux/comprehensive-formatter.d.ts.map +1 -1
- package/dist/infrastructure/ux/comprehensive-formatter.js +87 -182
- package/dist/infrastructure/ux/comprehensive-formatter.js.map +1 -1
- package/dist/infrastructure/ux/contextual-feature-discovery.d.ts +5 -18
- package/dist/infrastructure/ux/contextual-feature-discovery.d.ts.map +1 -1
- package/dist/infrastructure/ux/contextual-feature-discovery.js +5 -139
- package/dist/infrastructure/ux/contextual-feature-discovery.js.map +1 -1
- package/dist/infrastructure/ux/feature-discovery.d.ts +3 -33
- package/dist/infrastructure/ux/feature-discovery.d.ts.map +1 -1
- package/dist/infrastructure/ux/feature-discovery.js +5 -181
- package/dist/infrastructure/ux/feature-discovery.js.map +1 -1
- package/dist/infrastructure/ux/feedback-prompt.d.ts +15 -31
- package/dist/infrastructure/ux/feedback-prompt.d.ts.map +1 -1
- package/dist/infrastructure/ux/feedback-prompt.js +30 -166
- package/dist/infrastructure/ux/feedback-prompt.js.map +1 -1
- package/dist/infrastructure/ux/progress-indicator.d.ts +3 -5
- package/dist/infrastructure/ux/progress-indicator.d.ts.map +1 -1
- package/dist/infrastructure/ux/progress-indicator.js +34 -49
- package/dist/infrastructure/ux/progress-indicator.js.map +1 -1
- package/dist/infrastructure/ux/review-checkpoint.d.ts +3 -1
- package/dist/infrastructure/ux/review-checkpoint.d.ts.map +1 -1
- package/dist/infrastructure/ux/review-checkpoint.js +33 -80
- package/dist/infrastructure/ux/review-checkpoint.js.map +1 -1
- package/dist/infrastructure/ux/staged-feature-intro.d.ts +14 -39
- package/dist/infrastructure/ux/staged-feature-intro.d.ts.map +1 -1
- package/dist/infrastructure/ux/staged-feature-intro.js +12 -132
- package/dist/infrastructure/ux/staged-feature-intro.js.map +1 -1
- package/dist/infrastructure/ux/syntax-highlighter.d.ts +1 -2
- package/dist/infrastructure/ux/syntax-highlighter.d.ts.map +1 -1
- package/dist/infrastructure/ux/syntax-highlighter.js +67 -148
- package/dist/infrastructure/ux/syntax-highlighter.js.map +1 -1
- package/dist/infrastructure/validation/agent-feedback.d.ts +25 -89
- package/dist/infrastructure/validation/agent-feedback.d.ts.map +1 -1
- package/dist/infrastructure/validation/agent-feedback.js +32 -204
- package/dist/infrastructure/validation/agent-feedback.js.map +1 -1
- package/dist/infrastructure/validation/agent-validation-helper.d.ts +53 -53
- package/dist/infrastructure/validation/agent-validation-helper.d.ts.map +1 -1
- package/dist/infrastructure/validation/agent-validation-helper.js +110 -61
- package/dist/infrastructure/validation/agent-validation-helper.js.map +1 -1
- package/dist/infrastructure/validation/review-handler.d.ts +13 -41
- package/dist/infrastructure/validation/review-handler.d.ts.map +1 -1
- package/dist/infrastructure/validation/review-handler.js +23 -189
- package/dist/infrastructure/validation/review-handler.js.map +1 -1
- package/dist/infrastructure/validation/summary-aggregator.d.ts +25 -22
- package/dist/infrastructure/validation/summary-aggregator.d.ts.map +1 -1
- package/dist/infrastructure/validation/summary-aggregator.js +47 -133
- package/dist/infrastructure/validation/summary-aggregator.js.map +1 -1
- package/dist/infrastructure/validation/summary-extractor.d.ts +13 -48
- package/dist/infrastructure/validation/summary-extractor.d.ts.map +1 -1
- package/dist/infrastructure/validation/summary-extractor.js +32 -89
- package/dist/infrastructure/validation/summary-extractor.js.map +1 -1
- package/dist/infrastructure/validation/trace-summary.d.ts +30 -57
- package/dist/infrastructure/validation/trace-summary.d.ts.map +1 -1
- package/dist/infrastructure/validation/trace-summary.js +37 -356
- package/dist/infrastructure/validation/trace-summary.js.map +1 -1
- package/dist/monitoring.d.ts +1 -1
- package/dist/monitoring.d.ts.map +1 -1
- package/dist/monitoring.js +12 -9
- package/dist/monitoring.js.map +1 -1
- package/dist/parallel-processor.d.ts.map +1 -1
- package/dist/parallel-processor.js +124 -45
- package/dist/parallel-processor.js.map +1 -1
- package/dist/presentation/cli/commands/ask-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/ask-command.js +185 -128
- package/dist/presentation/cli/commands/ask-command.js.map +1 -1
- package/dist/presentation/cli/commands/config-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/config-command.js +8 -6
- package/dist/presentation/cli/commands/config-command.js.map +1 -1
- package/dist/presentation/cli/commands/docs-command.d.ts +3 -1
- package/dist/presentation/cli/commands/docs-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/docs-command.js +13 -184
- package/dist/presentation/cli/commands/docs-command.js.map +1 -1
- package/dist/presentation/cli/commands/fix-command.d.ts +2 -0
- package/dist/presentation/cli/commands/fix-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/fix-command.js +25 -281
- package/dist/presentation/cli/commands/fix-command.js.map +1 -1
- package/dist/presentation/cli/commands/models-command.d.ts +13 -0
- package/dist/presentation/cli/commands/models-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/models-command.js +194 -0
- package/dist/presentation/cli/commands/models-command.js.map +1 -0
- package/dist/presentation/cli/commands/orchestrate-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/orchestrate-command.js +15 -7
- package/dist/presentation/cli/commands/orchestrate-command.js.map +1 -1
- package/dist/presentation/cli/commands/plan-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/plan-command.js +9 -6
- package/dist/presentation/cli/commands/plan-command.js.map +1 -1
- package/dist/presentation/cli/commands/product-command.d.ts +6 -4
- package/dist/presentation/cli/commands/product-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/product-command.js +12 -178
- package/dist/presentation/cli/commands/product-command.js.map +1 -1
- package/dist/presentation/cli/commands/review-command.d.ts +7 -7
- package/dist/presentation/cli/commands/review-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/review-command.js +148 -16
- package/dist/presentation/cli/commands/review-command.js.map +1 -1
- package/dist/presentation/cli/commands/run-command.d.ts +6 -8
- package/dist/presentation/cli/commands/run-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/run-command.js +182 -23
- package/dist/presentation/cli/commands/run-command.js.map +1 -1
- package/dist/presentation/cli/commands/setup-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/setup-command.js +15 -0
- package/dist/presentation/cli/commands/setup-command.js.map +1 -1
- package/dist/presentation/cli/commands/smart-command.js +1 -1
- package/dist/presentation/cli/commands/smart-command.js.map +1 -1
- package/dist/presentation/cli/commands/status-command.d.ts +3 -0
- package/dist/presentation/cli/commands/status-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/status-command.js +147 -156
- package/dist/presentation/cli/commands/status-command.js.map +1 -1
- package/dist/presentation/cli/commands/suggest-command.d.ts +3 -5
- package/dist/presentation/cli/commands/suggest-command.d.ts.map +1 -1
- package/dist/presentation/cli/commands/suggest-command.js +132 -19
- package/dist/presentation/cli/commands/suggest-command.js.map +1 -1
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +6 -1
- package/dist/search.js.map +1 -1
- package/dist/session.js +1 -1
- package/dist/session.js.map +1 -1
- package/dist/ui.d.ts +6 -0
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +35 -1
- package/dist/ui.js.map +1 -1
- package/package.json +8 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-context.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/context/conversation-context.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"conversation-context.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/context/conversation-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,Q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0
|
|
4
6
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
}
|
|
7
|
+
/**
|
|
8
|
+
* In-memory conversation context manager
|
|
9
|
+
* Stores conversation history per session for reference resolution
|
|
10
|
+
*/
|
|
11
|
+
class ConversationContextManager {
|
|
12
|
+
sessions = new Map();
|
|
13
|
+
maxHistoryPerSession = 50;
|
|
23
14
|
/**
|
|
24
|
-
*
|
|
25
|
-
* EDGE CASE: Handles very long histories, concurrent sessions, and memory limits
|
|
15
|
+
* Get conversation history for a session
|
|
26
16
|
*/
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
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);
|
|
17
|
+
getHistory(sessionId, limit = 10) {
|
|
18
|
+
const session = this.sessions.get(sessionId);
|
|
19
|
+
if (!session) {
|
|
20
|
+
return [];
|
|
34
21
|
}
|
|
35
|
-
//
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
: response
|
|
40
|
-
|
|
41
|
-
|
|
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);
|
|
22
|
+
// Return most recent turns, up to limit
|
|
23
|
+
const turns = session.turns.slice(-limit);
|
|
24
|
+
return turns.map(turn => ({
|
|
25
|
+
query: turn.query,
|
|
26
|
+
response: turn.response,
|
|
27
|
+
timestamp: turn.timestamp,
|
|
28
|
+
}));
|
|
68
29
|
}
|
|
69
30
|
/**
|
|
70
31
|
* Resolve references in query (e.g., "it", "that", "the previous")
|
|
71
32
|
*/
|
|
72
33
|
resolveReferences(sessionId, query) {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
}
|
|
34
|
+
const history = this.getHistory(sessionId, 3);
|
|
35
|
+
if (history.length === 0) {
|
|
36
|
+
return query;
|
|
94
37
|
}
|
|
95
|
-
//
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
38
|
+
// Simple reference resolution - replace common references
|
|
39
|
+
let resolved = query;
|
|
40
|
+
const lastTurn = history[history.length - 1];
|
|
41
|
+
// Replace "it" with last mentioned entity/context
|
|
42
|
+
if (/\bit\b/i.test(query) && lastTurn.response) {
|
|
43
|
+
// Extract key entities from last response (simple heuristic)
|
|
44
|
+
const lastResponse = lastTurn.response;
|
|
45
|
+
const words = lastResponse.split(/\s+/).filter(w => w.length > 3);
|
|
46
|
+
if (words.length > 0) {
|
|
47
|
+
// Try to replace "it" with last significant noun phrase
|
|
48
|
+
resolved = resolved.replace(/\bit\b/gi, words[words.length - 1]);
|
|
102
49
|
}
|
|
103
50
|
}
|
|
104
|
-
//
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
resolvedQuery = resolvedQuery.replace(/\b(previous|last)\s+(one|query|question|command)?\b/gi, lastTurn.query);
|
|
108
|
-
}
|
|
51
|
+
// Replace "that" with last query
|
|
52
|
+
if (/\bthat\b/i.test(query)) {
|
|
53
|
+
resolved = resolved.replace(/\bthat\b/gi, `"${lastTurn.query}"`);
|
|
109
54
|
}
|
|
110
|
-
//
|
|
111
|
-
if (
|
|
112
|
-
|
|
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
|
-
}
|
|
55
|
+
// Replace "the previous" with last query
|
|
56
|
+
if (/\bthe previous\b/i.test(query)) {
|
|
57
|
+
resolved = resolved.replace(/\bthe previous\b/gi, `"${lastTurn.query}"`);
|
|
119
58
|
}
|
|
120
|
-
return
|
|
59
|
+
return resolved;
|
|
121
60
|
}
|
|
122
61
|
/**
|
|
123
|
-
* Extract entities from
|
|
62
|
+
* Extract entities from text (simple heuristic-based extraction)
|
|
124
63
|
*/
|
|
125
|
-
extractEntities(
|
|
64
|
+
extractEntities(text, options) {
|
|
65
|
+
// Simple entity extraction - can be enhanced later
|
|
126
66
|
const entities = [];
|
|
127
67
|
// Extract file paths
|
|
128
|
-
const
|
|
129
|
-
const filePaths =
|
|
130
|
-
|
|
131
|
-
entities.push(
|
|
68
|
+
const filePathRegex = /[\w\/\-\.]+\.(ts|js|tsx|jsx|json|md|yaml|yml|txt|py|go|rs|java|cpp|h|hpp)/g;
|
|
69
|
+
const filePaths = text.match(filePathRegex) || [];
|
|
70
|
+
filePaths.forEach(path => {
|
|
71
|
+
entities.push({ type: 'file', value: path });
|
|
72
|
+
});
|
|
73
|
+
// Extract function/class names (simple heuristic)
|
|
74
|
+
const functionRegex = /(?:function|class|const|let|var)\s+([A-Z][a-zA-Z0-9_]+|[a-z][a-zA-Z0-9_]+)/g;
|
|
75
|
+
const matches = text.matchAll(functionRegex);
|
|
76
|
+
for (const match of matches) {
|
|
77
|
+
entities.push({ type: 'symbol', value: match[1] });
|
|
132
78
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
79
|
+
return entities;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Add a conversation turn
|
|
83
|
+
*/
|
|
84
|
+
addTurn(sessionId, query, response, entities = [], intent) {
|
|
85
|
+
let session = this.sessions.get(sessionId);
|
|
86
|
+
if (!session) {
|
|
87
|
+
session = {
|
|
88
|
+
sessionId,
|
|
89
|
+
turns: [],
|
|
90
|
+
createdAt: Date.now(),
|
|
91
|
+
lastUpdated: Date.now(),
|
|
92
|
+
};
|
|
93
|
+
this.sessions.set(sessionId, session);
|
|
138
94
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
entities
|
|
95
|
+
const turn = {
|
|
96
|
+
query,
|
|
97
|
+
response,
|
|
98
|
+
timestamp: new Date().toISOString(),
|
|
99
|
+
entities,
|
|
100
|
+
intent,
|
|
101
|
+
};
|
|
102
|
+
session.turns.push(turn);
|
|
103
|
+
session.lastUpdated = Date.now();
|
|
104
|
+
// Trim history if too long
|
|
105
|
+
if (session.turns.length > this.maxHistoryPerSession) {
|
|
106
|
+
session.turns = session.turns.slice(-this.maxHistoryPerSession);
|
|
144
107
|
}
|
|
145
|
-
return [...new Set(entities)]; // Remove duplicates
|
|
146
108
|
}
|
|
147
109
|
/**
|
|
148
|
-
* Get
|
|
110
|
+
* Get full context for a session
|
|
149
111
|
*/
|
|
150
|
-
|
|
151
|
-
|
|
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`;
|
|
112
|
+
getContext(sessionId) {
|
|
113
|
+
return this.sessions.get(sessionId) || null;
|
|
160
114
|
}
|
|
161
115
|
/**
|
|
162
|
-
* Clear conversation
|
|
116
|
+
* Clear conversation history for a session
|
|
163
117
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
118
|
+
clear(sessionId) {
|
|
119
|
+
if (sessionId) {
|
|
120
|
+
this.sessions.delete(sessionId);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
this.sessions.clear();
|
|
124
|
+
}
|
|
166
125
|
}
|
|
167
126
|
}
|
|
168
|
-
// Singleton instance
|
|
169
127
|
export const conversationContextManager = new ConversationContextManager();
|
|
170
128
|
//# sourceMappingURL=conversation-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-context.js","sourceRoot":"","sources":["../../../src/infrastructure/context/conversation-context.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"conversation-context.js","sourceRoot":"","sources":["../../../src/infrastructure/context/conversation-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiBH;;;GAGG;AACH,MAAM,0BAA0B;IACtB,QAAQ,GAAqC,IAAI,GAAG,EAAE,CAAC;IAC9C,oBAAoB,GAAG,EAAE,CAAC;IAE3C;;OAEG;IACH,UAAU,CAAC,SAAiB,EAAE,QAAgB,EAAE;QAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,wCAAwC;QACxC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;QAC1C,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACxB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC,CAAC,CAAC;IACN,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,SAAiB,EAAE,KAAa;QAChD,MAAM,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AAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,QAAQ;YACR,MAAM;SACP,CAAC;QAEF,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEjC,2BAA2B;QAC3B,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;YACrD,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,SAAiB;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAkB;QACtB,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACxB,CAAC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,0BAA0B,EAAE,CAAC"}
|
|
@@ -1,26 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Session Manager
|
|
3
|
-
* Manages
|
|
3
|
+
* Manages CLI sessions for context tracking
|
|
4
|
+
*
|
|
5
|
+
* Phase 1: v0.5.0-alpha.0
|
|
4
6
|
*/
|
|
5
|
-
|
|
7
|
+
interface Session {
|
|
8
|
+
sessionId: string;
|
|
9
|
+
cwd: string;
|
|
10
|
+
startedAt: number;
|
|
11
|
+
lastActivity: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Session manager for tracking CLI sessions
|
|
15
|
+
*/
|
|
16
|
+
declare class SessionManager {
|
|
6
17
|
private sessions;
|
|
7
|
-
|
|
18
|
+
private readonly sessionTimeout;
|
|
19
|
+
/**
|
|
20
|
+
* Get or create session ID for a working directory
|
|
21
|
+
*/
|
|
22
|
+
getSessionId(cwd: string): string;
|
|
8
23
|
/**
|
|
9
|
-
* Get
|
|
24
|
+
* Get current session for a working directory
|
|
10
25
|
*/
|
|
11
|
-
|
|
26
|
+
getCurrentSession(cwd: string): Session | null;
|
|
12
27
|
/**
|
|
13
|
-
*
|
|
28
|
+
* Create a new session explicitly
|
|
14
29
|
*/
|
|
15
|
-
|
|
30
|
+
createSession(cwd: string): Session;
|
|
16
31
|
/**
|
|
17
|
-
*
|
|
32
|
+
* End a session
|
|
18
33
|
*/
|
|
19
|
-
|
|
34
|
+
endSession(cwd: string): void;
|
|
20
35
|
/**
|
|
21
|
-
*
|
|
36
|
+
* Clean up expired sessions
|
|
22
37
|
*/
|
|
23
|
-
|
|
38
|
+
cleanup(): void;
|
|
24
39
|
}
|
|
25
40
|
export declare const sessionManager: SessionManager;
|
|
41
|
+
export {};
|
|
26
42
|
//# sourceMappingURL=session-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-manager.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/context/session-manager.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"session-manager.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/context/session-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,UAAU,OAAO;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,cAAM,cAAc;IAClB,OAAO,CAAC,QAAQ,CAAmC;IACnD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAuB;IAEtD;;OAEG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IA8BjC;;OAEG;IACH,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI;IAK9C;;OAEG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAenC;;OAEG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAK7B;;OAEG;IACH,OAAO,IAAI,IAAI;CAShB;AAED,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
|
|
@@ -1,98 +1,94 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Session Manager
|
|
3
|
-
* Manages
|
|
3
|
+
* Manages CLI sessions for context tracking
|
|
4
|
+
*
|
|
5
|
+
* Phase 1: v0.5.0-alpha.0
|
|
4
6
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const SESSION_FILE = path.join(SESSION_DIR, 'sessions.json');
|
|
10
|
-
export class SessionManager {
|
|
7
|
+
/**
|
|
8
|
+
* Session manager for tracking CLI sessions
|
|
9
|
+
*/
|
|
10
|
+
class SessionManager {
|
|
11
11
|
sessions = new Map();
|
|
12
|
-
|
|
13
|
-
this.loadSessions();
|
|
14
|
-
}
|
|
12
|
+
sessionTimeout = 24 * 60 * 60 * 1000; // 24 hours
|
|
15
13
|
/**
|
|
16
|
-
* Get or create session ID for a
|
|
14
|
+
* Get or create session ID for a working directory
|
|
17
15
|
*/
|
|
18
|
-
getSessionId(
|
|
19
|
-
// Normalize path
|
|
20
|
-
const
|
|
21
|
-
// Check if
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.
|
|
26
|
-
|
|
16
|
+
getSessionId(cwd) {
|
|
17
|
+
// Normalize cwd path
|
|
18
|
+
const normalizedCwd = cwd || process.cwd();
|
|
19
|
+
// Check if session exists and is still valid
|
|
20
|
+
const existingSession = this.sessions.get(normalizedCwd);
|
|
21
|
+
if (existingSession) {
|
|
22
|
+
const age = Date.now() - existingSession.lastActivity;
|
|
23
|
+
if (age < this.sessionTimeout) {
|
|
24
|
+
existingSession.lastActivity = Date.now();
|
|
25
|
+
return existingSession.sessionId;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
// Session expired, remove it
|
|
29
|
+
this.sessions.delete(normalizedCwd);
|
|
30
|
+
}
|
|
27
31
|
}
|
|
28
32
|
// Create new session
|
|
29
|
-
const sessionId = `session-${
|
|
33
|
+
const sessionId = `session-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
30
34
|
const session = {
|
|
31
35
|
sessionId,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
cwd: normalizedCwd,
|
|
37
|
+
startedAt: Date.now(),
|
|
38
|
+
lastActivity: Date.now(),
|
|
35
39
|
};
|
|
36
|
-
this.sessions.set(
|
|
37
|
-
this.saveSessions();
|
|
40
|
+
this.sessions.set(normalizedCwd, session);
|
|
38
41
|
return sessionId;
|
|
39
42
|
}
|
|
40
43
|
/**
|
|
41
|
-
*
|
|
44
|
+
* Get current session for a working directory
|
|
42
45
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const data = fs.readFileSync(SESSION_FILE, 'utf-8');
|
|
49
|
-
const sessions = JSON.parse(data);
|
|
50
|
-
// Clean up old sessions (older than 7 days)
|
|
51
|
-
const sevenDaysAgo = Date.now() - (7 * 24 * 60 * 60 * 1000);
|
|
52
|
-
for (const [key, session] of Object.entries(sessions)) {
|
|
53
|
-
if (session.lastUsed > sevenDaysAgo) {
|
|
54
|
-
this.sessions.set(key, session);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
// Save cleaned sessions
|
|
58
|
-
if (this.sessions.size !== Object.keys(sessions).length) {
|
|
59
|
-
this.saveSessions();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
63
|
-
// If file is corrupted or doesn't exist, start fresh
|
|
64
|
-
this.sessions.clear();
|
|
65
|
-
}
|
|
46
|
+
getCurrentSession(cwd) {
|
|
47
|
+
const normalizedCwd = cwd || process.cwd();
|
|
48
|
+
return this.sessions.get(normalizedCwd) || null;
|
|
66
49
|
}
|
|
67
50
|
/**
|
|
68
|
-
*
|
|
51
|
+
* Create a new session explicitly
|
|
69
52
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
// Fail silently - session persistence is not critical
|
|
84
|
-
console.warn('[SessionManager] Failed to save sessions:', error);
|
|
85
|
-
}
|
|
53
|
+
createSession(cwd) {
|
|
54
|
+
const normalizedCwd = cwd || process.cwd();
|
|
55
|
+
const sessionId = `session-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
56
|
+
const session = {
|
|
57
|
+
sessionId,
|
|
58
|
+
cwd: normalizedCwd,
|
|
59
|
+
startedAt: Date.now(),
|
|
60
|
+
lastActivity: Date.now(),
|
|
61
|
+
};
|
|
62
|
+
this.sessions.set(normalizedCwd, session);
|
|
63
|
+
return session;
|
|
86
64
|
}
|
|
87
65
|
/**
|
|
88
|
-
*
|
|
66
|
+
* End a session
|
|
89
67
|
*/
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
this.sessions.delete(
|
|
93
|
-
|
|
68
|
+
endSession(cwd) {
|
|
69
|
+
const normalizedCwd = cwd || process.cwd();
|
|
70
|
+
this.sessions.delete(normalizedCwd);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Clean up expired sessions
|
|
74
|
+
*/
|
|
75
|
+
cleanup() {
|
|
76
|
+
const now = Date.now();
|
|
77
|
+
for (const [cwd, session] of this.sessions.entries()) {
|
|
78
|
+
const age = now - session.lastActivity;
|
|
79
|
+
if (age >= this.sessionTimeout) {
|
|
80
|
+
this.sessions.delete(cwd);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
94
83
|
}
|
|
95
84
|
}
|
|
96
|
-
// Singleton instance
|
|
97
85
|
export const sessionManager = new SessionManager();
|
|
86
|
+
// Cleanup expired sessions periodically
|
|
87
|
+
// Use .unref() to allow process to exit even with timer active
|
|
88
|
+
if (typeof setInterval !== 'undefined') {
|
|
89
|
+
const cleanupInterval = setInterval(() => {
|
|
90
|
+
sessionManager.cleanup();
|
|
91
|
+
}, 60 * 60 * 1000); // Every hour
|
|
92
|
+
cleanupInterval.unref();
|
|
93
|
+
}
|
|
98
94
|
//# sourceMappingURL=session-manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-manager.js","sourceRoot":"","sources":["../../../src/infrastructure/context/session-manager.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"session-manager.js","sourceRoot":"","sources":["../../../src/infrastructure/context/session-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH;;GAEG;AACH,MAAM,cAAc;IACV,QAAQ,GAAyB,IAAI,GAAG,EAAE,CAAC;IAClC,cAAc,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,WAAW;IAElE;;OAEG;IACH,YAAY,CAAC,GAAW;QACtB,qBAAqB;QACrB,MAAM,aAAa,GAAG,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAE3C,6CAA6C;QAC7C,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACzD,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,eAAe,CAAC,YAAY,CAAC;YACtD,IAAI,GAAG,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;gBAC9B,eAAe,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;gBAC1C,OAAO,eA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