deepseek-coder-cli 1.0.10 → 1.0.12
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/dist/bin/lean.d.ts +9 -0
- package/dist/bin/lean.d.ts.map +1 -0
- package/dist/bin/lean.js +332 -0
- package/dist/bin/lean.js.map +1 -0
- package/dist/capabilities/index.d.ts +1 -0
- package/dist/capabilities/index.d.ts.map +1 -1
- package/dist/capabilities/index.js +3 -0
- package/dist/capabilities/index.js.map +1 -1
- package/dist/capabilities/unifiedCodingCapability.d.ts +42 -0
- package/dist/capabilities/unifiedCodingCapability.d.ts.map +1 -0
- package/dist/capabilities/unifiedCodingCapability.js +500 -0
- package/dist/capabilities/unifiedCodingCapability.js.map +1 -0
- package/dist/headless/interactiveShell.js +6 -4
- package/dist/headless/interactiveShell.js.map +1 -1
- package/dist/leanAgent.d.ts +73 -0
- package/dist/leanAgent.d.ts.map +1 -0
- package/dist/leanAgent.js +158 -0
- package/dist/leanAgent.js.map +1 -0
- package/package.json +8 -3
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UNIFIED CODING CAPABILITY
|
|
3
|
+
*
|
|
4
|
+
* A lean, consolidated capability module that provides all essential
|
|
5
|
+
* tools for an AI coding assistant in a single, coherent interface.
|
|
6
|
+
*
|
|
7
|
+
* Consolidates: Filesystem, Edit, Bash, Search, Git, Web
|
|
8
|
+
*/
|
|
9
|
+
import * as fs from 'fs';
|
|
10
|
+
import * as path from 'path';
|
|
11
|
+
import { execSync } from 'child_process';
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// SCHEMA HELPERS
|
|
14
|
+
// ============================================================================
|
|
15
|
+
function stringProp(description, enumValues) {
|
|
16
|
+
const prop = {
|
|
17
|
+
type: 'string',
|
|
18
|
+
description,
|
|
19
|
+
};
|
|
20
|
+
if (enumValues) {
|
|
21
|
+
return { ...prop, enum: enumValues };
|
|
22
|
+
}
|
|
23
|
+
return prop;
|
|
24
|
+
}
|
|
25
|
+
function objectSchema(properties, required) {
|
|
26
|
+
return {
|
|
27
|
+
type: 'object',
|
|
28
|
+
properties,
|
|
29
|
+
required,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// UNIFIED CODING CAPABILITY MODULE
|
|
34
|
+
// ============================================================================
|
|
35
|
+
export class UnifiedCodingCapabilityModule {
|
|
36
|
+
id = 'unified-coding';
|
|
37
|
+
options;
|
|
38
|
+
constructor(options = {}) {
|
|
39
|
+
this.options = {
|
|
40
|
+
workingDir: options.workingDir ?? process.cwd(),
|
|
41
|
+
enableGit: options.enableGit ?? true,
|
|
42
|
+
enableWeb: options.enableWeb ?? true,
|
|
43
|
+
enableBash: options.enableBash ?? true,
|
|
44
|
+
maxFileSize: options.maxFileSize ?? 10 * 1024 * 1024, // 10MB
|
|
45
|
+
timeout: options.timeout ?? 30000, // 30s
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
async create(_context) {
|
|
49
|
+
return {
|
|
50
|
+
id: this.id,
|
|
51
|
+
description: 'Unified coding assistant tools',
|
|
52
|
+
toolSuite: this.buildToolSuite(),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
buildToolSuite() {
|
|
56
|
+
const tools = [];
|
|
57
|
+
// === FILESYSTEM TOOLS ===
|
|
58
|
+
tools.push(this.createReadFileTool());
|
|
59
|
+
tools.push(this.createWriteFileTool());
|
|
60
|
+
tools.push(this.createListFilesTool());
|
|
61
|
+
tools.push(this.createFileExistsTool());
|
|
62
|
+
// === EDIT TOOLS ===
|
|
63
|
+
tools.push(this.createEditFileTool());
|
|
64
|
+
tools.push(this.createSearchReplaceTool());
|
|
65
|
+
// === SEARCH TOOLS ===
|
|
66
|
+
tools.push(this.createGrepTool());
|
|
67
|
+
tools.push(this.createGlobTool());
|
|
68
|
+
// === BASH TOOLS ===
|
|
69
|
+
if (this.options.enableBash) {
|
|
70
|
+
tools.push(this.createBashTool());
|
|
71
|
+
}
|
|
72
|
+
// === GIT TOOLS ===
|
|
73
|
+
if (this.options.enableGit) {
|
|
74
|
+
tools.push(this.createGitTool());
|
|
75
|
+
}
|
|
76
|
+
// === WEB TOOLS ===
|
|
77
|
+
if (this.options.enableWeb) {
|
|
78
|
+
tools.push(this.createWebFetchTool());
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
id: 'unified-coding-tools',
|
|
82
|
+
description: 'Unified coding assistant tools for file operations, editing, search, and execution',
|
|
83
|
+
tools,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// ============================================================================
|
|
87
|
+
// FILESYSTEM TOOLS
|
|
88
|
+
// ============================================================================
|
|
89
|
+
createReadFileTool() {
|
|
90
|
+
return {
|
|
91
|
+
name: 'read_file',
|
|
92
|
+
description: 'Read the contents of a file. Returns the file content as a string.',
|
|
93
|
+
parameters: objectSchema({
|
|
94
|
+
path: stringProp('Absolute or relative path to the file'),
|
|
95
|
+
encoding: stringProp('File encoding (default: utf-8)'),
|
|
96
|
+
}, ['path']),
|
|
97
|
+
handler: async (args) => {
|
|
98
|
+
try {
|
|
99
|
+
const filePath = this.resolvePath(args.path);
|
|
100
|
+
const stat = fs.statSync(filePath);
|
|
101
|
+
if (stat.size > this.options.maxFileSize) {
|
|
102
|
+
return `Error: File too large (${stat.size} bytes). Max: ${this.options.maxFileSize} bytes`;
|
|
103
|
+
}
|
|
104
|
+
const content = fs.readFileSync(filePath, { encoding: args.encoding ?? 'utf-8' });
|
|
105
|
+
return content;
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
return `Error reading file: ${error.message}`;
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
createWriteFileTool() {
|
|
114
|
+
return {
|
|
115
|
+
name: 'write_file',
|
|
116
|
+
description: 'Write content to a file. Creates the file if it does not exist.',
|
|
117
|
+
parameters: objectSchema({
|
|
118
|
+
path: stringProp('Absolute or relative path to the file'),
|
|
119
|
+
content: stringProp('Content to write to the file'),
|
|
120
|
+
createDirs: stringProp('Create parent directories if they do not exist (default: true)'),
|
|
121
|
+
}, ['path', 'content']),
|
|
122
|
+
handler: async (args) => {
|
|
123
|
+
try {
|
|
124
|
+
const filePath = this.resolvePath(args.path);
|
|
125
|
+
if (args.createDirs !== 'false') {
|
|
126
|
+
const dir = path.dirname(filePath);
|
|
127
|
+
if (!fs.existsSync(dir)) {
|
|
128
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
fs.writeFileSync(filePath, args.content, 'utf-8');
|
|
132
|
+
return `Successfully wrote ${args.content.length} characters to ${filePath}`;
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
return `Error writing file: ${error.message}`;
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
createListFilesTool() {
|
|
141
|
+
return {
|
|
142
|
+
name: 'list_files',
|
|
143
|
+
description: 'List files in a directory. Optionally filter by pattern and recurse into subdirectories.',
|
|
144
|
+
parameters: objectSchema({
|
|
145
|
+
path: stringProp('Directory path to list'),
|
|
146
|
+
recursive: stringProp('Recurse into subdirectories (default: false)'),
|
|
147
|
+
pattern: stringProp('Glob pattern to filter files (e.g., "*.ts")'),
|
|
148
|
+
}, ['path']),
|
|
149
|
+
handler: async (args) => {
|
|
150
|
+
try {
|
|
151
|
+
const dirPath = this.resolvePath(args.path);
|
|
152
|
+
const files = this.listDirectory(dirPath, args.recursive === 'true', args.pattern);
|
|
153
|
+
return files.join('\n');
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
return `Error listing files: ${error.message}`;
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
createFileExistsTool() {
|
|
162
|
+
return {
|
|
163
|
+
name: 'file_exists',
|
|
164
|
+
description: 'Check if a file or directory exists.',
|
|
165
|
+
parameters: objectSchema({
|
|
166
|
+
path: stringProp('Path to check'),
|
|
167
|
+
}, ['path']),
|
|
168
|
+
handler: async (args) => {
|
|
169
|
+
const filePath = this.resolvePath(args.path);
|
|
170
|
+
const exists = fs.existsSync(filePath);
|
|
171
|
+
if (exists) {
|
|
172
|
+
const stat = fs.statSync(filePath);
|
|
173
|
+
return `Exists: ${stat.isDirectory() ? 'directory' : 'file'}`;
|
|
174
|
+
}
|
|
175
|
+
return 'Does not exist';
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
// ============================================================================
|
|
180
|
+
// EDIT TOOLS
|
|
181
|
+
// ============================================================================
|
|
182
|
+
createEditFileTool() {
|
|
183
|
+
return {
|
|
184
|
+
name: 'edit_file',
|
|
185
|
+
description: 'Edit a file by replacing specific text. The oldText must match exactly.',
|
|
186
|
+
parameters: objectSchema({
|
|
187
|
+
path: stringProp('Path to the file to edit'),
|
|
188
|
+
oldText: stringProp('Exact text to find and replace'),
|
|
189
|
+
newText: stringProp('Text to replace with'),
|
|
190
|
+
}, ['path', 'oldText', 'newText']),
|
|
191
|
+
handler: async (args) => {
|
|
192
|
+
try {
|
|
193
|
+
const filePath = this.resolvePath(args.path);
|
|
194
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
195
|
+
if (!content.includes(args.oldText)) {
|
|
196
|
+
return `Error: Could not find the specified text in ${filePath}`;
|
|
197
|
+
}
|
|
198
|
+
const newContent = content.replace(args.oldText, args.newText);
|
|
199
|
+
fs.writeFileSync(filePath, newContent, 'utf-8');
|
|
200
|
+
return `Successfully edited ${filePath}`;
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
return `Error editing file: ${error.message}`;
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
createSearchReplaceTool() {
|
|
209
|
+
return {
|
|
210
|
+
name: 'search_replace',
|
|
211
|
+
description: 'Search and replace text in a file. Supports regex patterns.',
|
|
212
|
+
parameters: objectSchema({
|
|
213
|
+
path: stringProp('Path to the file'),
|
|
214
|
+
search: stringProp('Text or regex pattern to search for'),
|
|
215
|
+
replace: stringProp('Replacement text'),
|
|
216
|
+
regex: stringProp('Treat search as regex (default: false)'),
|
|
217
|
+
global: stringProp('Replace all occurrences (default: true)'),
|
|
218
|
+
}, ['path', 'search', 'replace']),
|
|
219
|
+
handler: async (args) => {
|
|
220
|
+
try {
|
|
221
|
+
const filePath = this.resolvePath(args.path);
|
|
222
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
223
|
+
let pattern;
|
|
224
|
+
if (args.regex === 'true') {
|
|
225
|
+
const flags = args.global !== 'false' ? 'g' : '';
|
|
226
|
+
pattern = new RegExp(args.search, flags);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
pattern = args.global !== 'false'
|
|
230
|
+
? new RegExp(this.escapeRegex(args.search), 'g')
|
|
231
|
+
: args.search;
|
|
232
|
+
}
|
|
233
|
+
const newContent = content.replace(pattern, args.replace);
|
|
234
|
+
const matchCount = (content.match(pattern instanceof RegExp ? pattern : new RegExp(this.escapeRegex(args.search), 'g')) || []).length;
|
|
235
|
+
fs.writeFileSync(filePath, newContent, 'utf-8');
|
|
236
|
+
return `Replaced ${matchCount} occurrence(s) in ${filePath}`;
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
return `Error in search/replace: ${error.message}`;
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
// ============================================================================
|
|
245
|
+
// SEARCH TOOLS
|
|
246
|
+
// ============================================================================
|
|
247
|
+
createGrepTool() {
|
|
248
|
+
return {
|
|
249
|
+
name: 'grep',
|
|
250
|
+
description: 'Search for a pattern in files. Returns matching lines with file names and line numbers.',
|
|
251
|
+
parameters: objectSchema({
|
|
252
|
+
pattern: stringProp('Regex pattern to search for'),
|
|
253
|
+
path: stringProp('Directory or file to search in (default: working directory)'),
|
|
254
|
+
filePattern: stringProp('Filter files by glob pattern (e.g., "*.ts")'),
|
|
255
|
+
contextLines: stringProp('Number of context lines around matches (default: 0)'),
|
|
256
|
+
}, ['pattern']),
|
|
257
|
+
handler: async (args) => {
|
|
258
|
+
try {
|
|
259
|
+
const searchPath = this.resolvePath(args.path ?? '.');
|
|
260
|
+
const results = [];
|
|
261
|
+
const files = fs.statSync(searchPath).isDirectory()
|
|
262
|
+
? this.listDirectory(searchPath, true, args.filePattern)
|
|
263
|
+
: [searchPath];
|
|
264
|
+
// Use regex without 'g' flag for test() to avoid lastIndex issues
|
|
265
|
+
const regex = new RegExp(args.pattern, 'i');
|
|
266
|
+
const contextLines = parseInt(args.contextLines ?? '0', 10) || 0;
|
|
267
|
+
const matchedLineSet = new Set(); // Prevent duplicate context lines
|
|
268
|
+
for (const file of files.slice(0, 100)) { // Limit to 100 files
|
|
269
|
+
try {
|
|
270
|
+
// Skip binary files by checking for null bytes
|
|
271
|
+
const buffer = fs.readFileSync(file);
|
|
272
|
+
if (buffer.includes(0))
|
|
273
|
+
continue; // Binary file
|
|
274
|
+
const content = buffer.toString('utf-8');
|
|
275
|
+
// Skip very large files
|
|
276
|
+
if (content.length > 1024 * 1024)
|
|
277
|
+
continue; // > 1MB
|
|
278
|
+
const lines = content.split('\n');
|
|
279
|
+
const fileMatches = [];
|
|
280
|
+
// First pass: find all matching line numbers
|
|
281
|
+
for (let i = 0; i < lines.length; i++) {
|
|
282
|
+
if (regex.test(lines[i])) {
|
|
283
|
+
fileMatches.push(i);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
// Second pass: output with context, avoiding duplicates
|
|
287
|
+
for (const matchIdx of fileMatches) {
|
|
288
|
+
const start = Math.max(0, matchIdx - contextLines);
|
|
289
|
+
const end = Math.min(lines.length - 1, matchIdx + contextLines);
|
|
290
|
+
for (let j = start; j <= end; j++) {
|
|
291
|
+
const lineKey = `${file}:${j}`;
|
|
292
|
+
if (!matchedLineSet.has(lineKey)) {
|
|
293
|
+
matchedLineSet.add(lineKey);
|
|
294
|
+
const prefix = j === matchIdx ? '>' : ' ';
|
|
295
|
+
results.push(`${file}:${j + 1}:${prefix} ${lines[j]}`);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (contextLines > 0 && matchIdx < fileMatches[fileMatches.length - 1]) {
|
|
299
|
+
results.push('--');
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
catch {
|
|
304
|
+
// Skip unreadable files
|
|
305
|
+
}
|
|
306
|
+
// Stop if we have enough results
|
|
307
|
+
if (results.length > 500)
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
return results.length > 0
|
|
311
|
+
? results.slice(0, 500).join('\n')
|
|
312
|
+
: 'No matches found';
|
|
313
|
+
}
|
|
314
|
+
catch (error) {
|
|
315
|
+
return `Error in grep: ${error.message}`;
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
createGlobTool() {
|
|
321
|
+
return {
|
|
322
|
+
name: 'glob',
|
|
323
|
+
description: 'Find files matching a glob pattern.',
|
|
324
|
+
parameters: objectSchema({
|
|
325
|
+
pattern: stringProp('Glob pattern (e.g., "**/*.ts", "src/**/*.js")'),
|
|
326
|
+
path: stringProp('Base directory (default: working directory)'),
|
|
327
|
+
}, ['pattern']),
|
|
328
|
+
handler: async (args) => {
|
|
329
|
+
try {
|
|
330
|
+
const basePath = this.resolvePath(args.path ?? '.');
|
|
331
|
+
const files = this.listDirectory(basePath, true, args.pattern);
|
|
332
|
+
return files.length > 0
|
|
333
|
+
? files.slice(0, 200).join('\n')
|
|
334
|
+
: 'No files found matching pattern';
|
|
335
|
+
}
|
|
336
|
+
catch (error) {
|
|
337
|
+
return `Error in glob: ${error.message}`;
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
// ============================================================================
|
|
343
|
+
// BASH TOOL
|
|
344
|
+
// ============================================================================
|
|
345
|
+
createBashTool() {
|
|
346
|
+
return {
|
|
347
|
+
name: 'bash',
|
|
348
|
+
description: 'Execute a bash command and return the output. Use for running builds, tests, git commands, etc.',
|
|
349
|
+
parameters: objectSchema({
|
|
350
|
+
command: stringProp('The command to execute'),
|
|
351
|
+
timeout: stringProp('Timeout in milliseconds (default: 30000)'),
|
|
352
|
+
cwd: stringProp('Working directory for the command'),
|
|
353
|
+
}, ['command']),
|
|
354
|
+
handler: async (args) => {
|
|
355
|
+
return new Promise((resolve) => {
|
|
356
|
+
try {
|
|
357
|
+
const timeout = parseInt(args.timeout ?? String(this.options.timeout), 10);
|
|
358
|
+
const cwd = args.cwd ? this.resolvePath(args.cwd) : this.options.workingDir;
|
|
359
|
+
const result = execSync(args.command, {
|
|
360
|
+
cwd,
|
|
361
|
+
timeout,
|
|
362
|
+
encoding: 'utf-8',
|
|
363
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
364
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
365
|
+
});
|
|
366
|
+
resolve(result.trim() || '(no output)');
|
|
367
|
+
}
|
|
368
|
+
catch (error) {
|
|
369
|
+
const execError = error;
|
|
370
|
+
const stdout = execError.stdout ?? '';
|
|
371
|
+
const stderr = execError.stderr ?? '';
|
|
372
|
+
resolve(`Error: ${execError.message}\nStdout: ${stdout}\nStderr: ${stderr}`);
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
},
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
// ============================================================================
|
|
379
|
+
// GIT TOOL
|
|
380
|
+
// ============================================================================
|
|
381
|
+
createGitTool() {
|
|
382
|
+
return {
|
|
383
|
+
name: 'git',
|
|
384
|
+
description: 'Execute git operations. Supports: status, diff, log, add, commit, push, pull, branch, checkout, merge, stash',
|
|
385
|
+
parameters: objectSchema({
|
|
386
|
+
operation: stringProp('Git operation', ['status', 'diff', 'log', 'add', 'commit', 'push', 'pull', 'branch', 'checkout', 'merge', 'stash', 'reset', 'fetch']),
|
|
387
|
+
args: stringProp('Additional arguments for the git command'),
|
|
388
|
+
}, ['operation']),
|
|
389
|
+
handler: async (args) => {
|
|
390
|
+
try {
|
|
391
|
+
const command = `git ${args.operation}${args.args ? ' ' + args.args : ''}`;
|
|
392
|
+
const result = execSync(command, {
|
|
393
|
+
cwd: this.options.workingDir,
|
|
394
|
+
encoding: 'utf-8',
|
|
395
|
+
timeout: this.options.timeout,
|
|
396
|
+
});
|
|
397
|
+
return result.trim() || '(no output)';
|
|
398
|
+
}
|
|
399
|
+
catch (error) {
|
|
400
|
+
const execError = error;
|
|
401
|
+
return `Git error: ${execError.stderr || execError.message}`;
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
// ============================================================================
|
|
407
|
+
// WEB TOOL
|
|
408
|
+
// ============================================================================
|
|
409
|
+
createWebFetchTool() {
|
|
410
|
+
return {
|
|
411
|
+
name: 'web_fetch',
|
|
412
|
+
description: 'Fetch content from a URL. Useful for downloading documentation or API responses.',
|
|
413
|
+
parameters: objectSchema({
|
|
414
|
+
url: stringProp('URL to fetch'),
|
|
415
|
+
method: stringProp('HTTP method (default: GET)'),
|
|
416
|
+
headers: stringProp('JSON string of headers'),
|
|
417
|
+
}, ['url']),
|
|
418
|
+
handler: async (args) => {
|
|
419
|
+
try {
|
|
420
|
+
const headers = args.headers ? JSON.parse(args.headers) : {};
|
|
421
|
+
const response = await fetch(args.url, {
|
|
422
|
+
method: args.method ?? 'GET',
|
|
423
|
+
headers,
|
|
424
|
+
});
|
|
425
|
+
if (!response.ok) {
|
|
426
|
+
return `HTTP ${response.status}: ${response.statusText}`;
|
|
427
|
+
}
|
|
428
|
+
const contentType = response.headers.get('content-type') ?? '';
|
|
429
|
+
if (contentType.includes('application/json')) {
|
|
430
|
+
const json = await response.json();
|
|
431
|
+
return JSON.stringify(json, null, 2);
|
|
432
|
+
}
|
|
433
|
+
const text = await response.text();
|
|
434
|
+
return text.slice(0, 50000); // Limit response size
|
|
435
|
+
}
|
|
436
|
+
catch (error) {
|
|
437
|
+
return `Fetch error: ${error.message}`;
|
|
438
|
+
}
|
|
439
|
+
},
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
// ============================================================================
|
|
443
|
+
// UTILITY METHODS
|
|
444
|
+
// ============================================================================
|
|
445
|
+
resolvePath(inputPath) {
|
|
446
|
+
if (path.isAbsolute(inputPath)) {
|
|
447
|
+
return inputPath;
|
|
448
|
+
}
|
|
449
|
+
return path.resolve(this.options.workingDir, inputPath);
|
|
450
|
+
}
|
|
451
|
+
listDirectory(dir, recursive, pattern) {
|
|
452
|
+
const results = [];
|
|
453
|
+
const regex = pattern ? this.globToRegex(pattern) : null;
|
|
454
|
+
const walk = (currentDir) => {
|
|
455
|
+
try {
|
|
456
|
+
const entries = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
457
|
+
for (const entry of entries) {
|
|
458
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
459
|
+
// Skip hidden files and common ignore patterns
|
|
460
|
+
if (entry.name.startsWith('.') || entry.name === 'node_modules') {
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
if (entry.isDirectory()) {
|
|
464
|
+
if (recursive) {
|
|
465
|
+
walk(fullPath);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
if (!regex || regex.test(entry.name) || regex.test(fullPath)) {
|
|
470
|
+
results.push(fullPath);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
catch {
|
|
476
|
+
// Skip unreadable directories
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
walk(dir);
|
|
480
|
+
return results;
|
|
481
|
+
}
|
|
482
|
+
globToRegex(pattern) {
|
|
483
|
+
const escaped = pattern
|
|
484
|
+
.replace(/[.+^${}()|[\]\\]/g, '\\$&')
|
|
485
|
+
.replace(/\*/g, '.*')
|
|
486
|
+
.replace(/\?/g, '.');
|
|
487
|
+
return new RegExp(escaped, 'i');
|
|
488
|
+
}
|
|
489
|
+
escapeRegex(str) {
|
|
490
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
// ============================================================================
|
|
494
|
+
// FACTORY & CONVENIENCE EXPORTS
|
|
495
|
+
// ============================================================================
|
|
496
|
+
export function createUnifiedCodingCapability(options) {
|
|
497
|
+
return new UnifiedCodingCapabilityModule(options);
|
|
498
|
+
}
|
|
499
|
+
export default UnifiedCodingCapabilityModule;
|
|
500
|
+
//# sourceMappingURL=unifiedCodingCapability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unifiedCodingCapability.js","sourceRoot":"","sources":["../../src/capabilities/unifiedCodingCapability.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAezC,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E,SAAS,UAAU,CAAC,WAAmB,EAAE,UAA8B;IACrE,MAAM,IAAI,GAAqB;QAC7B,IAAI,EAAE,QAAiB;QACvB,WAAW;KACZ,CAAC;IACF,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IACvC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,YAAY,CACnB,UAA4C,EAC5C,QAAkB;IAElB,OAAO;QACL,IAAI,EAAE,QAAiB;QACvB,UAAU;QACV,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,mCAAmC;AACnC,+EAA+E;AAE/E,MAAM,OAAO,6BAA6B;IAC/B,EAAE,GAAG,gBAAgB,CAAC;IAC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,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;4BAC7D,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;wBACzB,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,8BAA8B;YAChC,CAAC;QACH,CAAC,CAAC;QAEF,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,WAAW,CAAC,OAAe;QACjC,MAAM,OAAO,GAAG,OAAO;aACpB,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC;aACpC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC;aACpB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACvB,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;IAEO,WAAW,CAAC,GAAW;QAC7B,OAAO,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;CACF;AAED,+EAA+E;AAC/E,gCAAgC;AAChC,+EAA+E;AAE/E,MAAM,UAAU,6BAA6B,CAAC,OAA8B;IAC1E,OAAO,IAAI,6BAA6B,CAAC,OAAO,CAAC,CAAC;AACpD,CAAC;AAED,eAAe,6BAA6B,CAAC"}
|
|
@@ -2307,6 +2307,7 @@ Any text response is a failure. Only tool calls are accepted.`;
|
|
|
2307
2307
|
if (lower === '/key' || lower.startsWith('/key ')) {
|
|
2308
2308
|
const parts = trimmed.split(/\s+/);
|
|
2309
2309
|
const keyValue = parts[1];
|
|
2310
|
+
const renderer = this.promptController?.getRenderer();
|
|
2310
2311
|
if (keyValue) {
|
|
2311
2312
|
// Direct file write - most reliable method
|
|
2312
2313
|
try {
|
|
@@ -2323,16 +2324,17 @@ Any text response is a failure. Only tool calls are accepted.`;
|
|
|
2323
2324
|
writeFileSync(secretFile, JSON.stringify(existing, null, 2) + '\n');
|
|
2324
2325
|
// Also set in process.env for immediate use
|
|
2325
2326
|
process.env['DEEPSEEK_API_KEY'] = keyValue;
|
|
2326
|
-
|
|
2327
|
+
// Show confirmation via renderer
|
|
2328
|
+
renderer?.addEvent('response', chalk.green('✓ DEEPSEEK_API_KEY saved\n'));
|
|
2327
2329
|
}
|
|
2328
2330
|
catch (error) {
|
|
2329
2331
|
const msg = error instanceof Error ? error.message : String(error);
|
|
2330
|
-
|
|
2332
|
+
renderer?.addEvent('response', chalk.red(`✗ Failed: ${msg}\n`));
|
|
2331
2333
|
}
|
|
2332
2334
|
}
|
|
2333
2335
|
else {
|
|
2334
|
-
//
|
|
2335
|
-
|
|
2336
|
+
// Show usage hint
|
|
2337
|
+
renderer?.addEvent('response', chalk.yellow('Usage: /key YOUR_API_KEY\n'));
|
|
2336
2338
|
}
|
|
2337
2339
|
return true;
|
|
2338
2340
|
}
|