deepseek-coder-agent-cli 1.0.58 → 1.0.65
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 +206 -30
- package/dist/capabilities/unifiedCodingCapability.d.ts +6 -0
- package/dist/capabilities/unifiedCodingCapability.d.ts.map +1 -1
- package/dist/capabilities/unifiedCodingCapability.js +96 -3
- package/dist/capabilities/unifiedCodingCapability.js.map +1 -1
- package/dist/core/initialExplorer.d.ts +53 -0
- package/dist/core/initialExplorer.d.ts.map +1 -0
- package/dist/core/initialExplorer.js +423 -0
- package/dist/core/initialExplorer.js.map +1 -0
- package/dist/headless/interactiveShell.d.ts.map +1 -1
- package/dist/headless/interactiveShell.js +50 -0
- package/dist/headless/interactiveShell.js.map +1 -1
- package/dist/leanAgent.d.ts.map +1 -1
- package/dist/leanAgent.js +18 -1
- package/dist/leanAgent.js.map +1 -1
- package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.d.ts +8 -1
- package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.d.ts.map +1 -1
- package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.js +90 -7
- package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initial Repository Explorer
|
|
3
|
+
*
|
|
4
|
+
* Runs a mandatory deep exploration of the repository at session start.
|
|
5
|
+
* Uses maximum parallelism within 128k context window constraints.
|
|
6
|
+
* Displays each file being processed in real-time to users.
|
|
7
|
+
*
|
|
8
|
+
* After initial exploration, follow-up prompts leverage cached context
|
|
9
|
+
* for dramatically faster and more accurate responses.
|
|
10
|
+
*/
|
|
11
|
+
export interface FileExplorationResult {
|
|
12
|
+
path: string;
|
|
13
|
+
relativePath: string;
|
|
14
|
+
content: string;
|
|
15
|
+
tokens: number;
|
|
16
|
+
truncated: boolean;
|
|
17
|
+
priority: number;
|
|
18
|
+
}
|
|
19
|
+
export interface ExplorationProgress {
|
|
20
|
+
phase: 'scanning' | 'reading' | 'analyzing' | 'complete';
|
|
21
|
+
totalFiles: number;
|
|
22
|
+
processedFiles: number;
|
|
23
|
+
currentFiles: string[];
|
|
24
|
+
tokensUsed: number;
|
|
25
|
+
tokenBudget: number;
|
|
26
|
+
}
|
|
27
|
+
export interface ExplorationResult {
|
|
28
|
+
files: FileExplorationResult[];
|
|
29
|
+
totalTokens: number;
|
|
30
|
+
skippedFiles: number;
|
|
31
|
+
duration: number;
|
|
32
|
+
contextSummary: string;
|
|
33
|
+
}
|
|
34
|
+
export type ProgressCallback = (progress: ExplorationProgress) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Run initial repository exploration
|
|
37
|
+
*
|
|
38
|
+
* This is called at session start to deeply understand the codebase.
|
|
39
|
+
* Uses maximum parallelism while staying within context budget.
|
|
40
|
+
*/
|
|
41
|
+
export declare function runInitialExploration(workingDir: string, onProgress?: ProgressCallback): Promise<ExplorationResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Format exploration results as context for the LLM
|
|
44
|
+
*/
|
|
45
|
+
export declare function formatExplorationContext(result: ExplorationResult): string;
|
|
46
|
+
/**
|
|
47
|
+
* Create a visual progress display for terminal output
|
|
48
|
+
*/
|
|
49
|
+
export declare function createProgressDisplay(): {
|
|
50
|
+
update: (progress: ExplorationProgress) => string;
|
|
51
|
+
complete: (result: ExplorationResult) => string;
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=initialExplorer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialExplorer.d.ts","sourceRoot":"","sources":["../../src/core/initialExplorer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAkEH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,qBAAqB,EAAE,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,mBAAmB,KAAK,IAAI,CAAC;AAmJvE;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,gBAAgB,GAC5B,OAAO,CAAC,iBAAiB,CAAC,CAgH5B;AAwDD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CA0C1E;AAMD;;GAEG;AACH,wBAAgB,qBAAqB,IAAI;IACvC,MAAM,EAAE,CAAC,QAAQ,EAAE,mBAAmB,KAAK,MAAM,CAAC;IAClD,QAAQ,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,MAAM,CAAC;CACjD,CAyDA"}
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initial Repository Explorer
|
|
3
|
+
*
|
|
4
|
+
* Runs a mandatory deep exploration of the repository at session start.
|
|
5
|
+
* Uses maximum parallelism within 128k context window constraints.
|
|
6
|
+
* Displays each file being processed in real-time to users.
|
|
7
|
+
*
|
|
8
|
+
* After initial exploration, follow-up prompts leverage cached context
|
|
9
|
+
* for dramatically faster and more accurate responses.
|
|
10
|
+
*/
|
|
11
|
+
import { resolve, relative, extname, basename, dirname } from 'node:path';
|
|
12
|
+
import { readFileSync, statSync, readdirSync } from 'node:fs';
|
|
13
|
+
import { createParallelExecutor } from './parallelExecutor.js';
|
|
14
|
+
import { theme } from '../ui/theme.js';
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Constants
|
|
17
|
+
// ============================================================================
|
|
18
|
+
/** Maximum context window size for DeepSeek */
|
|
19
|
+
const MAX_CONTEXT_TOKENS = 128000;
|
|
20
|
+
/** Estimated tokens per character (conservative) */
|
|
21
|
+
const TOKENS_PER_CHAR = 0.25;
|
|
22
|
+
/** Maximum tokens to use for exploration (leave room for conversation) */
|
|
23
|
+
const EXPLORATION_TOKEN_BUDGET = Math.floor(MAX_CONTEXT_TOKENS * 0.4); // 40% for exploration
|
|
24
|
+
/** Maximum chars to read per file */
|
|
25
|
+
const MAX_FILE_CHARS = 8000;
|
|
26
|
+
/** Maximum concurrent file reads */
|
|
27
|
+
const MAX_PARALLEL_READS = 12;
|
|
28
|
+
/** File extensions to explore */
|
|
29
|
+
const CODE_EXTENSIONS = new Set([
|
|
30
|
+
'.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs',
|
|
31
|
+
'.py', '.rs', '.go', '.java', '.kt', '.scala',
|
|
32
|
+
'.c', '.cpp', '.h', '.hpp', '.cs',
|
|
33
|
+
'.rb', '.php', '.swift', '.m', '.mm',
|
|
34
|
+
'.vue', '.svelte', '.astro',
|
|
35
|
+
'.json', '.yaml', '.yml', '.toml',
|
|
36
|
+
'.md', '.mdx', '.txt',
|
|
37
|
+
'.sql', '.graphql', '.prisma',
|
|
38
|
+
'.sh', '.bash', '.zsh',
|
|
39
|
+
'.css', '.scss', '.less', '.sass',
|
|
40
|
+
'.html', '.xml', '.svg',
|
|
41
|
+
]);
|
|
42
|
+
/** Directories to skip */
|
|
43
|
+
const SKIP_DIRS = new Set([
|
|
44
|
+
'node_modules', '.git', 'dist', 'build', 'out', 'target',
|
|
45
|
+
'.next', '.nuxt', '.cache', 'coverage', '.nyc_output',
|
|
46
|
+
'__pycache__', '.pytest_cache', 'venv', '.venv', 'env',
|
|
47
|
+
'vendor', 'Pods', '.gradle', '.idea', '.vscode',
|
|
48
|
+
'tmp', 'temp', 'logs', '.turbo', '.parcel-cache',
|
|
49
|
+
]);
|
|
50
|
+
/** Priority files to read first */
|
|
51
|
+
const PRIORITY_FILES = [
|
|
52
|
+
'package.json', 'Cargo.toml', 'go.mod', 'pyproject.toml',
|
|
53
|
+
'README.md', 'README', 'readme.md',
|
|
54
|
+
'tsconfig.json', '.eslintrc.js', '.eslintrc.json',
|
|
55
|
+
'src/index.ts', 'src/main.ts', 'src/app.ts',
|
|
56
|
+
'src/index.js', 'src/main.js', 'src/app.js',
|
|
57
|
+
'lib/index.ts', 'lib/main.ts',
|
|
58
|
+
'index.ts', 'main.ts', 'app.ts',
|
|
59
|
+
'index.js', 'main.js', 'app.js',
|
|
60
|
+
];
|
|
61
|
+
/**
|
|
62
|
+
* Recursively discover all code files in the repository
|
|
63
|
+
*/
|
|
64
|
+
function discoverFiles(rootDir, maxFiles = 500) {
|
|
65
|
+
const files = [];
|
|
66
|
+
function walk(dir, depth = 0) {
|
|
67
|
+
if (depth > 10 || files.length >= maxFiles)
|
|
68
|
+
return;
|
|
69
|
+
let entries;
|
|
70
|
+
try {
|
|
71
|
+
entries = readdirSync(dir);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
for (const entry of entries) {
|
|
77
|
+
if (files.length >= maxFiles)
|
|
78
|
+
break;
|
|
79
|
+
const fullPath = resolve(dir, entry);
|
|
80
|
+
const relativePath = relative(rootDir, fullPath);
|
|
81
|
+
// Skip hidden files (except specific config files)
|
|
82
|
+
if (entry.startsWith('.') && !entry.startsWith('.eslint') && !entry.startsWith('.prettier')) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
// Skip ignored directories
|
|
86
|
+
if (SKIP_DIRS.has(entry)) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
let stat;
|
|
90
|
+
try {
|
|
91
|
+
stat = statSync(fullPath);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (stat.isDirectory()) {
|
|
97
|
+
walk(fullPath, depth + 1);
|
|
98
|
+
}
|
|
99
|
+
else if (stat.isFile()) {
|
|
100
|
+
const ext = extname(entry).toLowerCase();
|
|
101
|
+
const name = basename(entry);
|
|
102
|
+
// Check if it's a code file
|
|
103
|
+
if (!CODE_EXTENSIONS.has(ext) && !PRIORITY_FILES.includes(name)) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
// Skip very large files
|
|
107
|
+
if (stat.size > 500000)
|
|
108
|
+
continue; // 500KB max
|
|
109
|
+
// Calculate priority
|
|
110
|
+
let priority = 50;
|
|
111
|
+
// Priority files get highest priority
|
|
112
|
+
const priorityIndex = PRIORITY_FILES.findIndex(p => relativePath === p || relativePath.endsWith('/' + p));
|
|
113
|
+
if (priorityIndex !== -1) {
|
|
114
|
+
priority = 100 - priorityIndex;
|
|
115
|
+
}
|
|
116
|
+
// Boost src/ files
|
|
117
|
+
if (relativePath.startsWith('src/'))
|
|
118
|
+
priority += 20;
|
|
119
|
+
if (relativePath.startsWith('lib/'))
|
|
120
|
+
priority += 15;
|
|
121
|
+
if (relativePath.startsWith('core/'))
|
|
122
|
+
priority += 15;
|
|
123
|
+
// Boost index/main files
|
|
124
|
+
if (name.match(/^(index|main|app)\.(ts|js|tsx|jsx)$/))
|
|
125
|
+
priority += 10;
|
|
126
|
+
// Boost type definition files
|
|
127
|
+
if (name.endsWith('.d.ts') || name === 'types.ts')
|
|
128
|
+
priority += 5;
|
|
129
|
+
// Boost test files slightly less
|
|
130
|
+
if (relativePath.includes('test') || relativePath.includes('spec'))
|
|
131
|
+
priority -= 10;
|
|
132
|
+
files.push({
|
|
133
|
+
path: fullPath,
|
|
134
|
+
relativePath,
|
|
135
|
+
size: stat.size,
|
|
136
|
+
priority,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
walk(rootDir);
|
|
142
|
+
// Sort by priority descending
|
|
143
|
+
files.sort((a, b) => b.priority - a.priority);
|
|
144
|
+
return files;
|
|
145
|
+
}
|
|
146
|
+
// ============================================================================
|
|
147
|
+
// File Reading
|
|
148
|
+
// ============================================================================
|
|
149
|
+
/**
|
|
150
|
+
* Read and process a single file
|
|
151
|
+
*/
|
|
152
|
+
function readFileForExploration(fileInfo) {
|
|
153
|
+
try {
|
|
154
|
+
let content = readFileSync(fileInfo.path, 'utf-8');
|
|
155
|
+
let truncated = false;
|
|
156
|
+
// Truncate if too large
|
|
157
|
+
if (content.length > MAX_FILE_CHARS) {
|
|
158
|
+
content = content.slice(0, MAX_FILE_CHARS) + '\n... [truncated]';
|
|
159
|
+
truncated = true;
|
|
160
|
+
}
|
|
161
|
+
// Estimate tokens
|
|
162
|
+
const tokens = Math.ceil(content.length * TOKENS_PER_CHAR);
|
|
163
|
+
return {
|
|
164
|
+
path: fileInfo.path,
|
|
165
|
+
relativePath: fileInfo.relativePath,
|
|
166
|
+
content,
|
|
167
|
+
tokens,
|
|
168
|
+
truncated,
|
|
169
|
+
priority: fileInfo.priority,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// ============================================================================
|
|
177
|
+
// Main Explorer
|
|
178
|
+
// ============================================================================
|
|
179
|
+
/**
|
|
180
|
+
* Run initial repository exploration
|
|
181
|
+
*
|
|
182
|
+
* This is called at session start to deeply understand the codebase.
|
|
183
|
+
* Uses maximum parallelism while staying within context budget.
|
|
184
|
+
*/
|
|
185
|
+
export async function runInitialExploration(workingDir, onProgress) {
|
|
186
|
+
const startTime = Date.now();
|
|
187
|
+
// Phase 1: Scan for files
|
|
188
|
+
onProgress?.({
|
|
189
|
+
phase: 'scanning',
|
|
190
|
+
totalFiles: 0,
|
|
191
|
+
processedFiles: 0,
|
|
192
|
+
currentFiles: [],
|
|
193
|
+
tokensUsed: 0,
|
|
194
|
+
tokenBudget: EXPLORATION_TOKEN_BUDGET,
|
|
195
|
+
});
|
|
196
|
+
const discoveredFiles = discoverFiles(workingDir);
|
|
197
|
+
if (discoveredFiles.length === 0) {
|
|
198
|
+
return {
|
|
199
|
+
files: [],
|
|
200
|
+
totalTokens: 0,
|
|
201
|
+
skippedFiles: 0,
|
|
202
|
+
duration: Date.now() - startTime,
|
|
203
|
+
contextSummary: 'No source files found in repository.',
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
// Phase 2: Read files in parallel with token budget management
|
|
207
|
+
const results = [];
|
|
208
|
+
let tokensUsed = 0;
|
|
209
|
+
let skippedFiles = 0;
|
|
210
|
+
const currentlyProcessing = new Set();
|
|
211
|
+
const executor = createParallelExecutor({
|
|
212
|
+
maxConcurrency: MAX_PARALLEL_READS,
|
|
213
|
+
onTaskEvent: (event) => {
|
|
214
|
+
if (event.type === 'task.start' && event.taskId) {
|
|
215
|
+
currentlyProcessing.add(event.taskId);
|
|
216
|
+
}
|
|
217
|
+
else if ((event.type === 'task.complete' || event.type === 'task.error') && event.taskId) {
|
|
218
|
+
currentlyProcessing.delete(event.taskId);
|
|
219
|
+
}
|
|
220
|
+
onProgress?.({
|
|
221
|
+
phase: 'reading',
|
|
222
|
+
totalFiles: discoveredFiles.length,
|
|
223
|
+
processedFiles: results.length + skippedFiles,
|
|
224
|
+
currentFiles: Array.from(currentlyProcessing),
|
|
225
|
+
tokensUsed,
|
|
226
|
+
tokenBudget: EXPLORATION_TOKEN_BUDGET,
|
|
227
|
+
});
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
// Create tasks for each file
|
|
231
|
+
const tasks = discoveredFiles.map((fileInfo) => ({
|
|
232
|
+
id: fileInfo.relativePath,
|
|
233
|
+
label: fileInfo.relativePath,
|
|
234
|
+
priority: fileInfo.priority,
|
|
235
|
+
execute: async () => {
|
|
236
|
+
// Check token budget before reading
|
|
237
|
+
if (tokensUsed >= EXPLORATION_TOKEN_BUDGET) {
|
|
238
|
+
skippedFiles++;
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
const result = readFileForExploration(fileInfo);
|
|
242
|
+
if (result) {
|
|
243
|
+
// Check if adding this file would exceed budget
|
|
244
|
+
if (tokensUsed + result.tokens > EXPLORATION_TOKEN_BUDGET) {
|
|
245
|
+
skippedFiles++;
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
tokensUsed += result.tokens;
|
|
249
|
+
results.push(result);
|
|
250
|
+
}
|
|
251
|
+
return result;
|
|
252
|
+
},
|
|
253
|
+
}));
|
|
254
|
+
// Execute all tasks in parallel
|
|
255
|
+
await executor.execute(tasks);
|
|
256
|
+
// Phase 3: Build context summary
|
|
257
|
+
onProgress?.({
|
|
258
|
+
phase: 'analyzing',
|
|
259
|
+
totalFiles: discoveredFiles.length,
|
|
260
|
+
processedFiles: results.length,
|
|
261
|
+
currentFiles: [],
|
|
262
|
+
tokensUsed,
|
|
263
|
+
tokenBudget: EXPLORATION_TOKEN_BUDGET,
|
|
264
|
+
});
|
|
265
|
+
const contextSummary = buildContextSummary(results, workingDir);
|
|
266
|
+
// Phase 4: Complete
|
|
267
|
+
onProgress?.({
|
|
268
|
+
phase: 'complete',
|
|
269
|
+
totalFiles: discoveredFiles.length,
|
|
270
|
+
processedFiles: results.length,
|
|
271
|
+
currentFiles: [],
|
|
272
|
+
tokensUsed,
|
|
273
|
+
tokenBudget: EXPLORATION_TOKEN_BUDGET,
|
|
274
|
+
});
|
|
275
|
+
return {
|
|
276
|
+
files: results,
|
|
277
|
+
totalTokens: tokensUsed,
|
|
278
|
+
skippedFiles,
|
|
279
|
+
duration: Date.now() - startTime,
|
|
280
|
+
contextSummary,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
// ============================================================================
|
|
284
|
+
// Context Building
|
|
285
|
+
// ============================================================================
|
|
286
|
+
/**
|
|
287
|
+
* Build a structured summary of the explored codebase
|
|
288
|
+
*/
|
|
289
|
+
function buildContextSummary(files, workingDir) {
|
|
290
|
+
const lines = [];
|
|
291
|
+
// Group files by directory
|
|
292
|
+
const byDir = new Map();
|
|
293
|
+
for (const file of files) {
|
|
294
|
+
const dir = dirname(file.relativePath) || '.';
|
|
295
|
+
if (!byDir.has(dir)) {
|
|
296
|
+
byDir.set(dir, []);
|
|
297
|
+
}
|
|
298
|
+
byDir.get(dir).push(file);
|
|
299
|
+
}
|
|
300
|
+
// Check for package.json
|
|
301
|
+
const packageJson = files.find(f => f.relativePath === 'package.json');
|
|
302
|
+
if (packageJson) {
|
|
303
|
+
try {
|
|
304
|
+
const pkg = JSON.parse(packageJson.content);
|
|
305
|
+
lines.push(`Project: ${pkg.name || 'unknown'} v${pkg.version || '0.0.0'}`);
|
|
306
|
+
if (pkg.description) {
|
|
307
|
+
lines.push(`Description: ${pkg.description}`);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
catch {
|
|
311
|
+
// Ignore parse errors
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
lines.push(`Files explored: ${files.length}`);
|
|
315
|
+
lines.push(`Directories: ${byDir.size}`);
|
|
316
|
+
// List main directories
|
|
317
|
+
const sortedDirs = Array.from(byDir.entries())
|
|
318
|
+
.sort((a, b) => b[1].length - a[1].length)
|
|
319
|
+
.slice(0, 10);
|
|
320
|
+
lines.push('\nKey directories:');
|
|
321
|
+
for (const [dir, dirFiles] of sortedDirs) {
|
|
322
|
+
lines.push(` ${dir}/ (${dirFiles.length} files)`);
|
|
323
|
+
}
|
|
324
|
+
return lines.join('\n');
|
|
325
|
+
}
|
|
326
|
+
// ============================================================================
|
|
327
|
+
// Formatted Context for LLM
|
|
328
|
+
// ============================================================================
|
|
329
|
+
/**
|
|
330
|
+
* Format exploration results as context for the LLM
|
|
331
|
+
*/
|
|
332
|
+
export function formatExplorationContext(result) {
|
|
333
|
+
const sections = [];
|
|
334
|
+
sections.push('=== REPOSITORY CONTEXT (AUTO-EXPLORED) ===');
|
|
335
|
+
sections.push(result.contextSummary);
|
|
336
|
+
sections.push('');
|
|
337
|
+
// Group files intelligently
|
|
338
|
+
const priorityFiles = result.files.filter(f => f.priority >= 80);
|
|
339
|
+
const srcFiles = result.files.filter(f => f.priority >= 50 && f.priority < 80);
|
|
340
|
+
const otherFiles = result.files.filter(f => f.priority < 50);
|
|
341
|
+
// Add priority files with full content
|
|
342
|
+
if (priorityFiles.length > 0) {
|
|
343
|
+
sections.push('=== KEY FILES ===');
|
|
344
|
+
for (const file of priorityFiles) {
|
|
345
|
+
sections.push(`\n--- ${file.relativePath} ---`);
|
|
346
|
+
sections.push(file.content);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
// Add source files with content
|
|
350
|
+
if (srcFiles.length > 0) {
|
|
351
|
+
sections.push('\n=== SOURCE FILES ===');
|
|
352
|
+
for (const file of srcFiles) {
|
|
353
|
+
sections.push(`\n--- ${file.relativePath} ---`);
|
|
354
|
+
sections.push(file.content);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
// Add other files with content
|
|
358
|
+
if (otherFiles.length > 0) {
|
|
359
|
+
sections.push('\n=== OTHER FILES ===');
|
|
360
|
+
for (const file of otherFiles) {
|
|
361
|
+
sections.push(`\n--- ${file.relativePath} ---`);
|
|
362
|
+
sections.push(file.content);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
sections.push('\n=== END REPOSITORY CONTEXT ===');
|
|
366
|
+
return sections.join('\n');
|
|
367
|
+
}
|
|
368
|
+
// ============================================================================
|
|
369
|
+
// Visual Progress Display
|
|
370
|
+
// ============================================================================
|
|
371
|
+
/**
|
|
372
|
+
* Create a visual progress display for terminal output
|
|
373
|
+
*/
|
|
374
|
+
export function createProgressDisplay() {
|
|
375
|
+
let lastPhase = '';
|
|
376
|
+
return {
|
|
377
|
+
update(progress) {
|
|
378
|
+
const lines = [];
|
|
379
|
+
// Phase header
|
|
380
|
+
if (progress.phase !== lastPhase) {
|
|
381
|
+
lastPhase = progress.phase;
|
|
382
|
+
switch (progress.phase) {
|
|
383
|
+
case 'scanning':
|
|
384
|
+
lines.push(theme.info('◈ Scanning repository...'));
|
|
385
|
+
break;
|
|
386
|
+
case 'reading':
|
|
387
|
+
lines.push(theme.info(`◈ Reading files (${progress.totalFiles} found)`));
|
|
388
|
+
break;
|
|
389
|
+
case 'analyzing':
|
|
390
|
+
lines.push(theme.info('◈ Building context...'));
|
|
391
|
+
break;
|
|
392
|
+
case 'complete':
|
|
393
|
+
lines.push(theme.success('◈ Exploration complete'));
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
// Show files being processed in parallel
|
|
398
|
+
if (progress.phase === 'reading' && progress.currentFiles.length > 0) {
|
|
399
|
+
const pct = Math.round((progress.processedFiles / progress.totalFiles) * 100);
|
|
400
|
+
const tokenPct = Math.round((progress.tokensUsed / progress.tokenBudget) * 100);
|
|
401
|
+
lines.push(theme.ui.muted(` Progress: ${progress.processedFiles}/${progress.totalFiles} files (${pct}%) | Context: ${tokenPct}%`));
|
|
402
|
+
// Show currently processing files (max 6 for readability)
|
|
403
|
+
const displayFiles = progress.currentFiles.slice(0, 6);
|
|
404
|
+
for (const file of displayFiles) {
|
|
405
|
+
lines.push(theme.info(` ├─ ${file}`));
|
|
406
|
+
}
|
|
407
|
+
if (progress.currentFiles.length > 6) {
|
|
408
|
+
lines.push(theme.ui.muted(` └─ +${progress.currentFiles.length - 6} more...`));
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return lines.join('\n');
|
|
412
|
+
},
|
|
413
|
+
complete(result) {
|
|
414
|
+
const durationSec = (result.duration / 1000).toFixed(1);
|
|
415
|
+
return [
|
|
416
|
+
theme.success(`✓ Repository explored: ${result.files.length} files in ${durationSec}s`),
|
|
417
|
+
theme.ui.muted(` Context: ~${Math.round(result.totalTokens / 1000)}k tokens | Skipped: ${result.skippedFiles} files`),
|
|
418
|
+
'',
|
|
419
|
+
].join('\n');
|
|
420
|
+
},
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
//# sourceMappingURL=initialExplorer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialExplorer.js","sourceRoot":"","sources":["../../src/core/initialExplorer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAc,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAqC,MAAM,uBAAuB,CAAC;AAClG,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,+CAA+C;AAC/C,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC,oDAAoD;AACpD,MAAM,eAAe,GAAG,IAAI,CAAC;AAE7B,0EAA0E;AAC1E,MAAM,wBAAwB,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,GAAG,GAAG,CAAC,CAAC,CAAC,sBAAsB;AAE7F,qCAAqC;AACrC,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B,oCAAoC;AACpC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,iCAAiC;AACjC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAC5C,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ;IAC7C,IAAI,EAAE,M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;gBACpF,CAAC;YACH,CAAC;YAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAED,QAAQ,CAAC,MAAyB;YAChC,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACxD,OAAO;gBACL,KAAK,CAAC,OAAO,CAAC,0BAA0B,MAAM,CAAC,KAAK,CAAC,MAAM,aAAa,WAAW,GAAG,CAAC;gBACvF,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,uBAAuB,MAAM,CAAC,YAAY,QAAQ,CAAC;gBACtH,EAAE;aACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactiveShell.d.ts","sourceRoot":"","sources":["../../src/headless/interactiveShell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"interactiveShell.d.ts","sourceRoot":"","sources":["../../src/headless/interactiveShell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAgLH,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAOD;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuDzF"}
|
|
@@ -49,6 +49,7 @@ import { formatUpdateNotification } from '../core/updateChecker.js';
|
|
|
49
49
|
import { getSelfUpgrade, SelfUpgrade, resumeAfterUpgrade } from '../core/selfUpgrade.js';
|
|
50
50
|
import { getHotReload } from '../core/hotReload.js';
|
|
51
51
|
import { theme } from '../ui/theme.js';
|
|
52
|
+
import { runInitialExploration, formatExplorationContext, createProgressDisplay, } from '../core/initialExplorer.js';
|
|
52
53
|
import { startNewRun } from '../tools/fileChangeTracker.js';
|
|
53
54
|
import { onSudoPasswordNeeded, offSudoPasswordNeeded, provideSudoPassword } from '../core/sudoPasswordManager.js';
|
|
54
55
|
import { reportStatus, setStatusSink } from '../utils/statusReporter.js';
|
|
@@ -203,6 +204,9 @@ class InteractiveShell {
|
|
|
203
204
|
selfUpgrade;
|
|
204
205
|
hotReload;
|
|
205
206
|
resumedFromUpgrade = false;
|
|
207
|
+
// Initial exploration state - runs on first prompt submission
|
|
208
|
+
explorationCompleted = false;
|
|
209
|
+
explorationContext = null;
|
|
206
210
|
constructor(controller, profile, profileConfig, workingDir) {
|
|
207
211
|
this.controller = controller;
|
|
208
212
|
this.profile = profile;
|
|
@@ -267,6 +271,44 @@ class InteractiveShell {
|
|
|
267
271
|
this.cachedProviders = [];
|
|
268
272
|
}
|
|
269
273
|
}
|
|
274
|
+
/**
|
|
275
|
+
* Run initial repository exploration on first prompt.
|
|
276
|
+
* Explores files in max parallel while showing visual progress.
|
|
277
|
+
* Context is cached for subsequent prompts.
|
|
278
|
+
*/
|
|
279
|
+
async runInitialExploration() {
|
|
280
|
+
if (this.explorationCompleted)
|
|
281
|
+
return;
|
|
282
|
+
const renderer = this.promptController?.getRenderer();
|
|
283
|
+
const progressDisplay = createProgressDisplay();
|
|
284
|
+
// Show exploration header
|
|
285
|
+
renderer?.addEvent('system', theme.info('\n◈ Deep repository exploration starting...'));
|
|
286
|
+
renderer?.addEvent('system', theme.ui.muted(' Processing files in parallel for maximum context understanding\n'));
|
|
287
|
+
try {
|
|
288
|
+
const result = await runInitialExploration(this.workingDir, (progress) => {
|
|
289
|
+
// Display visual progress showing each file being processed
|
|
290
|
+
const progressText = progressDisplay.update(progress);
|
|
291
|
+
if (progressText) {
|
|
292
|
+
// Clear previous progress lines and show new state
|
|
293
|
+
renderer?.addEvent('system', progressText);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
// Show completion summary
|
|
297
|
+
const completionText = progressDisplay.complete(result);
|
|
298
|
+
renderer?.addEvent('system', completionText);
|
|
299
|
+
// Store the formatted context for use in prompts
|
|
300
|
+
if (result.files.length > 0) {
|
|
301
|
+
this.explorationContext = formatExplorationContext(result);
|
|
302
|
+
}
|
|
303
|
+
this.explorationCompleted = true;
|
|
304
|
+
}
|
|
305
|
+
catch (error) {
|
|
306
|
+
// Log error but don't block - exploration is optional enhancement
|
|
307
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
308
|
+
renderer?.addEvent('system', theme.warning(` Exploration skipped: ${errorMsg}\n`));
|
|
309
|
+
this.explorationCompleted = true; // Don't retry on failure
|
|
310
|
+
}
|
|
311
|
+
}
|
|
270
312
|
async checkForUpdates() {
|
|
271
313
|
try {
|
|
272
314
|
// Use the new self-upgrade system for checking
|
|
@@ -3344,6 +3386,14 @@ Any text response is a failure. Only tool calls are accepted.`;
|
|
|
3344
3386
|
// Pin this prompt persistently at the top of the UI
|
|
3345
3387
|
this.savePinnedPrompt(prompt);
|
|
3346
3388
|
}
|
|
3389
|
+
// Run initial exploration on first prompt (not on continuations)
|
|
3390
|
+
if (!this.explorationCompleted && prompt !== 'continue') {
|
|
3391
|
+
await this.runInitialExploration();
|
|
3392
|
+
}
|
|
3393
|
+
// Prepend exploration context to prompt if available
|
|
3394
|
+
if (this.explorationContext) {
|
|
3395
|
+
sanitizedPrompt = `${this.explorationContext}\n\n---\n\nUser Request: ${sanitizedPrompt}`;
|
|
3396
|
+
}
|
|
3347
3397
|
// Enter critical section to prevent termination during AI processing
|
|
3348
3398
|
enterCriticalSection();
|
|
3349
3399
|
this.isProcessing = true;
|