xibecode 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +434 -0
- package/dist/commands/chat.d.ts +8 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/chat.js +259 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/config.d.ts +10 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +196 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/run.d.ts +11 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +143 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/core/agent.d.ts +49 -0
- package/dist/core/agent.d.ts.map +1 -0
- package/dist/core/agent.js +392 -0
- package/dist/core/agent.js.map +1 -0
- package/dist/core/context.d.ts +82 -0
- package/dist/core/context.d.ts.map +1 -0
- package/dist/core/context.js +273 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/editor.d.ts +68 -0
- package/dist/core/editor.d.ts.map +1 -0
- package/dist/core/editor.js +271 -0
- package/dist/core/editor.js.map +1 -0
- package/dist/core/tools.d.ts +34 -0
- package/dist/core/tools.d.ts.map +1 -0
- package/dist/core/tools.js +675 -0
- package/dist/core/tools.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/dist/ui/enhanced-tui.d.ts +51 -0
- package/dist/ui/enhanced-tui.d.ts.map +1 -0
- package/dist/ui/enhanced-tui.js +438 -0
- package/dist/ui/enhanced-tui.js.map +1 -0
- package/dist/utils/config.d.ts +76 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +144 -0
- package/dist/utils/config.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import Anthropic from '@anthropic-ai/sdk';
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
export class LoopDetector {
|
|
4
|
+
history = [];
|
|
5
|
+
maxRepeats = 3;
|
|
6
|
+
timeWindow = 10000;
|
|
7
|
+
check(toolName, toolInput) {
|
|
8
|
+
const signature = JSON.stringify({ tool: toolName, input: toolInput });
|
|
9
|
+
const now = Date.now();
|
|
10
|
+
this.history.push({ tool: toolName, input: signature, timestamp: now });
|
|
11
|
+
this.history = this.history.filter(h => now - h.timestamp < this.timeWindow);
|
|
12
|
+
const recentDuplicates = this.history.filter(h => h.input === signature);
|
|
13
|
+
if (recentDuplicates.length >= this.maxRepeats) {
|
|
14
|
+
return {
|
|
15
|
+
allowed: false,
|
|
16
|
+
reason: `Loop detected: ${toolName} called ${this.maxRepeats}+ times with same parameters`,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const sameTool = this.history.filter(h => h.tool === toolName);
|
|
20
|
+
if (sameTool.length >= this.maxRepeats * 2) {
|
|
21
|
+
return {
|
|
22
|
+
allowed: true,
|
|
23
|
+
reason: `Warning: ${toolName} called ${sameTool.length} times recently`,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return { allowed: true };
|
|
27
|
+
}
|
|
28
|
+
reset() {
|
|
29
|
+
this.history = [];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// ─── Think-tag streaming filter ───────────────────────────────
|
|
33
|
+
class ThinkTagFilter {
|
|
34
|
+
insideThink = false;
|
|
35
|
+
buffer = '';
|
|
36
|
+
reset() {
|
|
37
|
+
this.insideThink = false;
|
|
38
|
+
this.buffer = '';
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Process a streaming text chunk. Returns the text that should be shown
|
|
42
|
+
* to the user (with <think>...</think> blocks removed in real-time).
|
|
43
|
+
*/
|
|
44
|
+
push(chunk) {
|
|
45
|
+
const combined = this.buffer + chunk;
|
|
46
|
+
this.buffer = '';
|
|
47
|
+
let output = '';
|
|
48
|
+
let i = 0;
|
|
49
|
+
while (i < combined.length) {
|
|
50
|
+
if (this.insideThink) {
|
|
51
|
+
const closeIdx = combined.indexOf('</think>', i);
|
|
52
|
+
if (closeIdx !== -1) {
|
|
53
|
+
this.insideThink = false;
|
|
54
|
+
i = closeIdx + 8;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
// Still inside think block, consume everything
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const openIdx = combined.indexOf('<think>', i);
|
|
63
|
+
if (openIdx !== -1) {
|
|
64
|
+
output += combined.substring(i, openIdx);
|
|
65
|
+
this.insideThink = true;
|
|
66
|
+
i = openIdx + 7;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// Check for partial '<think' or '</think' at the end
|
|
70
|
+
const remaining = combined.substring(i);
|
|
71
|
+
const partialTag = this.findPartialTag(remaining);
|
|
72
|
+
if (partialTag > 0) {
|
|
73
|
+
output += remaining.substring(0, remaining.length - partialTag);
|
|
74
|
+
this.buffer = remaining.substring(remaining.length - partialTag);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
output += remaining;
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return output;
|
|
84
|
+
}
|
|
85
|
+
/** Flush any remaining buffered text */
|
|
86
|
+
flush() {
|
|
87
|
+
const leftover = this.buffer;
|
|
88
|
+
this.buffer = '';
|
|
89
|
+
if (this.insideThink)
|
|
90
|
+
return '';
|
|
91
|
+
return leftover;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Strip all think tags from a complete string (non-streaming).
|
|
95
|
+
*/
|
|
96
|
+
static strip(text) {
|
|
97
|
+
return text.replace(/<think>[\s\S]*?<\/think>/g, '').trim();
|
|
98
|
+
}
|
|
99
|
+
findPartialTag(text) {
|
|
100
|
+
const tags = ['<think>', '</think>'];
|
|
101
|
+
for (const tag of tags) {
|
|
102
|
+
for (let len = tag.length - 1; len >= 1; len--) {
|
|
103
|
+
if (text.endsWith(tag.substring(0, len))) {
|
|
104
|
+
return len;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return 0;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// ─── Agent ────────────────────────────────────────────────────
|
|
112
|
+
export class EnhancedAgent extends EventEmitter {
|
|
113
|
+
client;
|
|
114
|
+
messages = [];
|
|
115
|
+
loopDetector = new LoopDetector();
|
|
116
|
+
thinkFilter = new ThinkTagFilter();
|
|
117
|
+
config;
|
|
118
|
+
iterationCount = 0;
|
|
119
|
+
toolCallCount = 0;
|
|
120
|
+
filesChanged = new Set();
|
|
121
|
+
constructor(config) {
|
|
122
|
+
super();
|
|
123
|
+
const clientConfig = { apiKey: config.apiKey };
|
|
124
|
+
if (config.baseUrl) {
|
|
125
|
+
clientConfig.baseURL = config.baseUrl;
|
|
126
|
+
}
|
|
127
|
+
this.client = new Anthropic(clientConfig);
|
|
128
|
+
this.config = {
|
|
129
|
+
...config,
|
|
130
|
+
maxIterations: config.maxIterations ?? 150,
|
|
131
|
+
verbose: config.verbose ?? false,
|
|
132
|
+
baseUrl: config.baseUrl ?? '',
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
emit(event, data) {
|
|
136
|
+
return super.emit('event', { type: event, data });
|
|
137
|
+
}
|
|
138
|
+
async run(initialPrompt, tools, toolExecutor) {
|
|
139
|
+
// Reset per-turn state (keeps conversation history in this.messages)
|
|
140
|
+
this.iterationCount = 0;
|
|
141
|
+
this.toolCallCount = 0;
|
|
142
|
+
this.loopDetector.reset();
|
|
143
|
+
this.messages.push({
|
|
144
|
+
role: 'user',
|
|
145
|
+
content: initialPrompt,
|
|
146
|
+
});
|
|
147
|
+
this.emit('thinking', { message: 'Starting agent...' });
|
|
148
|
+
while (this.iterationCount < this.config.maxIterations) {
|
|
149
|
+
this.iterationCount++;
|
|
150
|
+
this.emit('iteration', {
|
|
151
|
+
current: this.iterationCount,
|
|
152
|
+
total: this.config.maxIterations,
|
|
153
|
+
});
|
|
154
|
+
this.emit('thinking', { message: 'AI is thinking...' });
|
|
155
|
+
try {
|
|
156
|
+
const { message: response, streamed } = await this.callModel(tools);
|
|
157
|
+
// Add assistant response
|
|
158
|
+
this.messages.push({
|
|
159
|
+
role: 'assistant',
|
|
160
|
+
content: response.content,
|
|
161
|
+
});
|
|
162
|
+
// Process response
|
|
163
|
+
const content = response.content;
|
|
164
|
+
const textBlocks = content.filter((block) => block.type === 'text');
|
|
165
|
+
const toolUseBlocks = content.filter((block) => block.type === 'tool_use');
|
|
166
|
+
// Show text responses (only if not already streamed)
|
|
167
|
+
if (!streamed) {
|
|
168
|
+
for (const block of textBlocks) {
|
|
169
|
+
const cleanText = ThinkTagFilter.strip(block.text);
|
|
170
|
+
if (cleanText) {
|
|
171
|
+
this.emit('response', { text: cleanText });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// If no tools, we're done
|
|
176
|
+
if (toolUseBlocks.length === 0) {
|
|
177
|
+
this.emit('complete', {
|
|
178
|
+
iterations: this.iterationCount,
|
|
179
|
+
toolCalls: this.toolCallCount,
|
|
180
|
+
filesChanged: this.filesChanged.size,
|
|
181
|
+
});
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
// Execute tools
|
|
185
|
+
const toolResults = [];
|
|
186
|
+
for (let i = 0; i < toolUseBlocks.length; i++) {
|
|
187
|
+
const toolUse = toolUseBlocks[i];
|
|
188
|
+
this.toolCallCount++;
|
|
189
|
+
// Loop detection
|
|
190
|
+
const loopCheck = this.loopDetector.check(toolUse.name, toolUse.input);
|
|
191
|
+
if (!loopCheck.allowed) {
|
|
192
|
+
this.emit('warning', { message: loopCheck.reason });
|
|
193
|
+
toolResults.push({
|
|
194
|
+
type: 'tool_result',
|
|
195
|
+
tool_use_id: toolUse.id,
|
|
196
|
+
content: `Error: ${loopCheck.reason}. Try a different approach.`,
|
|
197
|
+
is_error: true,
|
|
198
|
+
});
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (loopCheck.reason) {
|
|
202
|
+
this.emit('warning', { message: loopCheck.reason });
|
|
203
|
+
}
|
|
204
|
+
// Emit tool call
|
|
205
|
+
this.emit('tool_call', {
|
|
206
|
+
name: toolUse.name,
|
|
207
|
+
input: toolUse.input,
|
|
208
|
+
index: i + 1,
|
|
209
|
+
});
|
|
210
|
+
// Execute
|
|
211
|
+
try {
|
|
212
|
+
const result = await toolExecutor.execute(toolUse.name, toolUse.input);
|
|
213
|
+
// Track file changes
|
|
214
|
+
if (['write_file', 'edit_file', 'edit_lines'].includes(toolUse.name)) {
|
|
215
|
+
const input = toolUse.input;
|
|
216
|
+
if (typeof input?.path === 'string')
|
|
217
|
+
this.filesChanged.add(input.path);
|
|
218
|
+
}
|
|
219
|
+
this.emit('tool_result', {
|
|
220
|
+
name: toolUse.name,
|
|
221
|
+
result,
|
|
222
|
+
success: !result.error && result.success !== false,
|
|
223
|
+
});
|
|
224
|
+
toolResults.push({
|
|
225
|
+
type: 'tool_result',
|
|
226
|
+
tool_use_id: toolUse.id,
|
|
227
|
+
content: typeof result === 'string' ? result : JSON.stringify(result, null, 2),
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
this.emit('error', {
|
|
232
|
+
tool: toolUse.name,
|
|
233
|
+
error: error.message,
|
|
234
|
+
});
|
|
235
|
+
toolResults.push({
|
|
236
|
+
type: 'tool_result',
|
|
237
|
+
tool_use_id: toolUse.id,
|
|
238
|
+
content: `Error: ${error.message}`,
|
|
239
|
+
is_error: true,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// Add results to conversation
|
|
244
|
+
this.messages.push({
|
|
245
|
+
role: 'user',
|
|
246
|
+
content: toolResults,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
catch (error) {
|
|
250
|
+
this.emit('error', {
|
|
251
|
+
message: 'API Error',
|
|
252
|
+
error: error.message,
|
|
253
|
+
});
|
|
254
|
+
throw error;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (this.iterationCount >= this.config.maxIterations) {
|
|
258
|
+
this.emit('warning', {
|
|
259
|
+
message: `Reached maximum iterations (${this.config.maxIterations})`,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Call the model with streaming (fallback to non-streaming).
|
|
265
|
+
*/
|
|
266
|
+
async callModel(tools) {
|
|
267
|
+
const params = {
|
|
268
|
+
model: this.config.model,
|
|
269
|
+
max_tokens: 8192,
|
|
270
|
+
messages: this.messages,
|
|
271
|
+
system: this.getSystemPrompt(),
|
|
272
|
+
};
|
|
273
|
+
if (tools.length > 0) {
|
|
274
|
+
params.tools = tools;
|
|
275
|
+
}
|
|
276
|
+
// ── Try streaming first ──
|
|
277
|
+
try {
|
|
278
|
+
if (typeof this.client.messages.stream !== 'function') {
|
|
279
|
+
throw new Error('Streaming not available');
|
|
280
|
+
}
|
|
281
|
+
this.thinkFilter.reset();
|
|
282
|
+
let hasEmittedStart = false;
|
|
283
|
+
const stream = this.client.messages.stream(params);
|
|
284
|
+
stream.on('text', (chunk) => {
|
|
285
|
+
const filtered = this.thinkFilter.push(chunk);
|
|
286
|
+
if (filtered) {
|
|
287
|
+
if (!hasEmittedStart) {
|
|
288
|
+
this.emit('stream_start', {});
|
|
289
|
+
hasEmittedStart = true;
|
|
290
|
+
}
|
|
291
|
+
this.emit('stream_text', { text: filtered });
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
const message = await stream.finalMessage();
|
|
295
|
+
// Flush remaining buffered text
|
|
296
|
+
const remaining = this.thinkFilter.flush();
|
|
297
|
+
if (remaining) {
|
|
298
|
+
if (!hasEmittedStart) {
|
|
299
|
+
this.emit('stream_start', {});
|
|
300
|
+
hasEmittedStart = true;
|
|
301
|
+
}
|
|
302
|
+
this.emit('stream_text', { text: remaining });
|
|
303
|
+
}
|
|
304
|
+
if (hasEmittedStart) {
|
|
305
|
+
this.emit('stream_end', {});
|
|
306
|
+
}
|
|
307
|
+
return { message, streamed: hasEmittedStart };
|
|
308
|
+
}
|
|
309
|
+
catch (_streamError) {
|
|
310
|
+
// ── Fallback to non-streaming ──
|
|
311
|
+
try {
|
|
312
|
+
const message = await this.client.messages.create(params);
|
|
313
|
+
return { message, streamed: false };
|
|
314
|
+
}
|
|
315
|
+
catch (error) {
|
|
316
|
+
throw error;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
getSystemPrompt() {
|
|
321
|
+
const platform = process.platform;
|
|
322
|
+
const platformNote = platform === 'win32'
|
|
323
|
+
? 'You are running on Windows. Use PowerShell commands and Windows path conventions.'
|
|
324
|
+
: platform === 'darwin'
|
|
325
|
+
? 'You are running on macOS. Use Unix/bash commands.'
|
|
326
|
+
: 'You are running on Linux. Use bash commands.';
|
|
327
|
+
return `You are XibeCode, an expert autonomous coding assistant with advanced capabilities.
|
|
328
|
+
|
|
329
|
+
${platformNote}
|
|
330
|
+
|
|
331
|
+
Working directory: ${process.cwd()}
|
|
332
|
+
|
|
333
|
+
## Core Principles
|
|
334
|
+
|
|
335
|
+
1. **Read Before Edit**: ALWAYS read files with read_file before modifying them
|
|
336
|
+
2. **Use Smart Editing**: Prefer edit_file (search/replace) over write_file for existing files
|
|
337
|
+
3. **Context Awareness**: Use get_context to understand project structure before making changes
|
|
338
|
+
4. **Incremental Changes**: Make small, tested changes rather than large rewrites
|
|
339
|
+
5. **Error Recovery**: If something fails, analyze the error and try a different approach
|
|
340
|
+
|
|
341
|
+
## Tool Usage
|
|
342
|
+
|
|
343
|
+
- **IMPORTANT**: Always provide all required parameters as documented
|
|
344
|
+
- For read_file: always include "path" as a string
|
|
345
|
+
- For read_multiple_files: always include "paths" as an array of strings
|
|
346
|
+
- For write_file: always include "path" and "content"
|
|
347
|
+
- For edit_file: always include "path", "search", and "replace"
|
|
348
|
+
- For run_command: always include "command" as a string
|
|
349
|
+
|
|
350
|
+
## File Editing Best Practices
|
|
351
|
+
|
|
352
|
+
- **For small edits**: Use edit_file with unique search strings
|
|
353
|
+
- **For large files**: Use edit_lines with specific line numbers
|
|
354
|
+
- **For new files**: Use write_file
|
|
355
|
+
- **Always verify**: Read the file after editing to confirm changes
|
|
356
|
+
|
|
357
|
+
## Running Commands
|
|
358
|
+
|
|
359
|
+
- Commands have a default timeout of 120 seconds.
|
|
360
|
+
- **CRITICAL**: ALWAYS use non-interactive flags to avoid prompts that hang:
|
|
361
|
+
- npm/npx: use --yes or -y (e.g. \`npx create-next-app@latest myapp --yes --typescript --tailwind --app --use-pnpm\`)
|
|
362
|
+
- pip: use --yes or -y
|
|
363
|
+
- apt: use -y
|
|
364
|
+
- General: look for --default, --non-interactive, --batch, --quiet flags
|
|
365
|
+
- If a command MUST be interactive, use the "input" parameter to pipe stdin answers.
|
|
366
|
+
Example: \`{"command": "npx some-cli", "input": "yes\\nmy-project\\n"}\`
|
|
367
|
+
Each \\n sends Enter. So "yes\\n\\n" sends "yes" + Enter + Enter.
|
|
368
|
+
- For long-running commands (installs, builds), increase timeout: \`{"command": "npm install", "timeout": 300}\`
|
|
369
|
+
- If a command times out, it was probably waiting for interactive input. Retry with --yes flags or input parameter.
|
|
370
|
+
|
|
371
|
+
## Error Handling
|
|
372
|
+
|
|
373
|
+
- If a tool fails, read the error carefully
|
|
374
|
+
- Don't repeat the exact same action - try alternatives
|
|
375
|
+
- Use revert_file if you need to undo changes
|
|
376
|
+
- Break down complex tasks into smaller steps
|
|
377
|
+
|
|
378
|
+
When you complete the task, provide a brief summary of what was accomplished.`;
|
|
379
|
+
}
|
|
380
|
+
getStats() {
|
|
381
|
+
return {
|
|
382
|
+
iterations: this.iterationCount,
|
|
383
|
+
toolCalls: this.toolCallCount,
|
|
384
|
+
filesChanged: this.filesChanged.size,
|
|
385
|
+
changedFiles: Array.from(this.filesChanged),
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
getMessages() {
|
|
389
|
+
return this.messages;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/core/agent.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAetC,MAAM,OAAO,YAAY;IACf,OAAO,GAA8D,EAAE,CAAC;IAC/D,UAAU,GAAG,CAAC,CAAC;IACf,UAAU,GAAG,KAAK,CAAC;IAEpC,KAAK,CAAC,QAAgB,EAAE,SAAc;QACpC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACvE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEvB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;QACxE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;QAE7E,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;QACzE,IAAI,gBAAgB,CAAC,MAAM,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAC/C,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,kBAAkB,QAAQ,WAAW,IAAI,CAAC,UAAU,8BAA8B;aAC3F,CAAC;QACJ,CAAC;QAED,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D;gBACrD,CAAC,CAAC,8CAA8C,CAAC;QAEnD,OAAO;;EAET,YAAY;;qBAEO,OAAO,CAAC,GAAG,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8EA+C4C,CAAC;IAC7E,CAAC;IAED,QAAQ;QACN,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,cAAc;YAC/B,SAAS,EAAE,IAAI,CAAC,aAAa;YAC7B,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI;YACpC,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;SAC5C,CAAC;IACJ,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export interface FileContext {
|
|
2
|
+
path: string;
|
|
3
|
+
content: string;
|
|
4
|
+
lines: number;
|
|
5
|
+
size: number;
|
|
6
|
+
language?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ContextWindow {
|
|
9
|
+
files: FileContext[];
|
|
10
|
+
totalTokens: number;
|
|
11
|
+
maxTokens: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class ContextManager {
|
|
14
|
+
private workingDir;
|
|
15
|
+
private maxContextTokens;
|
|
16
|
+
private loadedFiles;
|
|
17
|
+
private excludePatterns;
|
|
18
|
+
constructor(workingDir: string, maxTokens?: number);
|
|
19
|
+
/**
|
|
20
|
+
* Smart context builder - automatically includes relevant files
|
|
21
|
+
*/
|
|
22
|
+
buildContext(primaryFiles?: string[]): Promise<ContextWindow>;
|
|
23
|
+
/**
|
|
24
|
+
* Load a single file with metadata
|
|
25
|
+
*/
|
|
26
|
+
loadFile(filePath: string): Promise<FileContext | null>;
|
|
27
|
+
/**
|
|
28
|
+
* Find files related to the given files (imports, configs, tests)
|
|
29
|
+
*/
|
|
30
|
+
private findRelatedFiles;
|
|
31
|
+
/**
|
|
32
|
+
* Extract import statements from code
|
|
33
|
+
*/
|
|
34
|
+
private extractImports;
|
|
35
|
+
/**
|
|
36
|
+
* Resolve import path to actual file
|
|
37
|
+
*/
|
|
38
|
+
private resolveImport;
|
|
39
|
+
/**
|
|
40
|
+
* Find test file for a given source file
|
|
41
|
+
*/
|
|
42
|
+
private findTestFile;
|
|
43
|
+
/**
|
|
44
|
+
* Find config files in directory
|
|
45
|
+
*/
|
|
46
|
+
private findConfigFiles;
|
|
47
|
+
/**
|
|
48
|
+
* Search for files matching pattern
|
|
49
|
+
*/
|
|
50
|
+
searchFiles(pattern: string, options?: {
|
|
51
|
+
maxResults?: number;
|
|
52
|
+
}): Promise<string[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Get file chunk for large files (prevents token overflow)
|
|
55
|
+
*/
|
|
56
|
+
getFileChunk(filePath: string, startLine: number, endLine: number): Promise<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Detect programming language from file extension
|
|
59
|
+
*/
|
|
60
|
+
private detectLanguage;
|
|
61
|
+
/**
|
|
62
|
+
* Estimate token count (rough approximation: 1 token ≈ 4 chars)
|
|
63
|
+
*/
|
|
64
|
+
private estimateTokens;
|
|
65
|
+
/**
|
|
66
|
+
* Check if file exists
|
|
67
|
+
*/
|
|
68
|
+
private fileExists;
|
|
69
|
+
/**
|
|
70
|
+
* Clear loaded files cache
|
|
71
|
+
*/
|
|
72
|
+
clearCache(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Get loaded files summary
|
|
75
|
+
*/
|
|
76
|
+
getSummary(): {
|
|
77
|
+
fileCount: number;
|
|
78
|
+
totalSize: number;
|
|
79
|
+
files: string[];
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/core/context.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;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