minovative-mind-cli 2.5.1 → 2.6.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 +28 -25
- package/dist/commands/chat.js +1 -1
- package/dist/services/agent/inputHandler.d.ts +9 -0
- package/dist/services/agent/inputHandler.js +34 -0
- package/dist/services/agent/slashCommands.js +158 -37
- package/dist/services/agent/syntaxAgent.d.ts +40 -0
- package/dist/services/agent/syntaxAgent.js +237 -23
- package/dist/services/agent/toolLoop.js +10 -1
- package/dist/services/agent/types.d.ts +1 -0
- package/dist/services/agent-tools.d.ts +156 -1
- package/dist/services/agent-tools.js +259 -67
- package/dist/services/agent.d.ts +74 -0
- package/dist/services/agent.js +192 -30
- package/dist/services/ai.d.ts +5 -0
- package/dist/services/ai.js +80 -87
- package/dist/services/chatHistoryService.d.ts +11 -0
- package/dist/services/chatHistoryService.js +20 -1
- package/dist/services/contextAgent.d.ts +1 -1
- package/dist/services/contextAgent.js +9 -29
- package/dist/services/orchestration/investigationAgent.d.ts +2 -1
- package/dist/services/orchestration/investigationAgent.js +7 -2
- package/dist/services/orchestration/investigationOrchestrator.d.ts +1 -1
- package/dist/services/orchestration/investigationOrchestrator.js +13 -2
- package/dist/services/orchestration/orchestrator.js +21 -4
- package/dist/services/orchestration/subAgent.d.ts +2 -1
- package/dist/services/orchestration/subAgent.js +12 -6
- package/dist/services/workspaceRegistry.d.ts +7 -0
- package/dist/services/workspaceRegistry.js +22 -0
- package/dist/utils/analysisRunner.d.ts +27 -4
- package/dist/utils/analysisRunner.js +100 -20
- package/dist/utils/config.d.ts +2 -0
- package/dist/utils/config.js +2 -0
- package/dist/utils/fuzzyMatch.d.ts +32 -0
- package/dist/utils/fuzzyMatch.js +215 -27
- package/dist/utils/localSyntaxValidator.d.ts +2 -2
- package/dist/utils/localSyntaxValidator.js +280 -81
- package/dist/utils/performanceAuditor.d.ts +2 -7
- package/dist/utils/performanceAuditor.js +541 -89
- package/dist/utils/projectStorage.js +9 -0
- package/dist/utils/systemPrompts.d.ts +3 -2
- package/dist/utils/systemPrompts.js +29 -5
- package/oclif.manifest.json +2 -2
- package/package.json +1 -1
|
@@ -1,8 +1,67 @@
|
|
|
1
1
|
import { ProxyChatSession } from '../ai.js';
|
|
2
2
|
import { GEMINI_MODELS, MAX_OUTPUT_TOKENS } from '../../utils/config.js';
|
|
3
|
+
import { localValidate } from '../../utils/localSyntaxValidator.js';
|
|
4
|
+
/**
|
|
5
|
+
* Extracts a numeric character position from a syntax error message if present.
|
|
6
|
+
*/
|
|
7
|
+
function parseErrorPosition(errorMsg) {
|
|
8
|
+
if (!errorMsg)
|
|
9
|
+
return null;
|
|
10
|
+
const match = errorMsg.match(/position\s+(\d+)/i);
|
|
11
|
+
if (match && match[1]) {
|
|
12
|
+
const pos = parseInt(match[1], 10);
|
|
13
|
+
return isNaN(pos) ? null : pos;
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Extracts a surrounding line window around a given character position in file content.
|
|
19
|
+
*/
|
|
20
|
+
function getSnippetWindow(content, pos, contextLines = 40) {
|
|
21
|
+
if (pos < 0 || pos >= content.length)
|
|
22
|
+
return null;
|
|
23
|
+
const lines = content.split('\n');
|
|
24
|
+
let currentPos = 0;
|
|
25
|
+
let targetLine = 0;
|
|
26
|
+
for (let i = 0; i < lines.length; i++) {
|
|
27
|
+
const lineLen = lines[i].length + 1; // +1 for '\n'
|
|
28
|
+
if (currentPos + lineLen > pos) {
|
|
29
|
+
targetLine = i;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
currentPos += lineLen;
|
|
33
|
+
}
|
|
34
|
+
const startLine = Math.max(0, targetLine - contextLines);
|
|
35
|
+
const endLine = Math.min(lines.length - 1, targetLine + contextLines);
|
|
36
|
+
let startPos = 0;
|
|
37
|
+
for (let i = 0; i < startLine; i++) {
|
|
38
|
+
startPos += lines[i].length + 1;
|
|
39
|
+
}
|
|
40
|
+
const snippetLines = lines.slice(startLine, endLine + 1);
|
|
41
|
+
const snippet = snippetLines.join('\n');
|
|
42
|
+
const endPos = startPos + snippet.length;
|
|
43
|
+
return {
|
|
44
|
+
startPos,
|
|
45
|
+
endPos,
|
|
46
|
+
startLine: startLine + 1,
|
|
47
|
+
endLine: endLine + 1,
|
|
48
|
+
snippet,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Strips markdown code fences from AI model output.
|
|
53
|
+
*/
|
|
54
|
+
function cleanOutput(raw) {
|
|
55
|
+
let output = raw.trim();
|
|
56
|
+
if (output.startsWith('```')) {
|
|
57
|
+
output = output.replace(/^```[a-zA-Z]*\n?/, '').replace(/\n?```$/, '').trim();
|
|
58
|
+
}
|
|
59
|
+
return output;
|
|
60
|
+
}
|
|
3
61
|
/**
|
|
4
62
|
* Validates file content and attempts to fix syntax errors.
|
|
5
63
|
* Uses GEMINI_MODELS.FLASH to perform language-agnostic syntax repair.
|
|
64
|
+
* Utilizes local validation error context and windowed snippet repair for large files.
|
|
6
65
|
*
|
|
7
66
|
* @param content The file content to validate.
|
|
8
67
|
* @param filePath The path of the file being validated.
|
|
@@ -10,43 +69,198 @@ import { GEMINI_MODELS, MAX_OUTPUT_TOKENS } from '../../utils/config.js';
|
|
|
10
69
|
* @returns The fixed content, or undefined if it was completely valid or couldn't be fixed.
|
|
11
70
|
*/
|
|
12
71
|
export async function validateAndFixSyntax(content, filePath, error) {
|
|
13
|
-
|
|
14
|
-
const
|
|
72
|
+
// 1. First run fast local validation to check if content is already valid or gather error details
|
|
73
|
+
const localResult = localValidate(filePath, content);
|
|
74
|
+
if (localResult.isValid && !error) {
|
|
75
|
+
return undefined; // Content is already syntactically valid
|
|
76
|
+
}
|
|
77
|
+
const effectiveError = error || localResult.error || 'Syntax validation failed';
|
|
78
|
+
const model = GEMINI_MODELS.FLASH;
|
|
79
|
+
// 2. Determine error position for targeted window snippet repair on large files
|
|
80
|
+
const errorPos = parseErrorPosition(effectiveError) || parseErrorPosition(localResult.error);
|
|
81
|
+
const isLargeFile = content.length > 8000 || content.split('\n').length > 200;
|
|
82
|
+
if (isLargeFile && errorPos !== null) {
|
|
83
|
+
const win = getSnippetWindow(content, errorPos, 45);
|
|
84
|
+
if (win) {
|
|
85
|
+
const snippetSystemInstruction = `
|
|
86
|
+
<identity>
|
|
87
|
+
You are an expert software engineer and syntax repair agent.
|
|
88
|
+
Your job is to fix syntax errors in source code snippets extracted from large files.
|
|
89
|
+
</identity>
|
|
90
|
+
|
|
91
|
+
<rules>
|
|
92
|
+
1. Fix ONLY the syntax error described in the provided error context.
|
|
93
|
+
2. Return ONLY the fully corrected code snippet.
|
|
94
|
+
3. Do NOT include markdown code blocks (like \`\`\`typescript), explanations, or conversational text.
|
|
95
|
+
4. Keep all original formatting, variable names, logic, and comments intact outside the syntax fix.
|
|
96
|
+
</rules>
|
|
97
|
+
`;
|
|
98
|
+
const snippetChat = new ProxyChatSession(model, snippetSystemInstruction, [], {
|
|
99
|
+
maxOutputTokens: MAX_OUTPUT_TOKENS,
|
|
100
|
+
temperature: 0.1,
|
|
101
|
+
});
|
|
102
|
+
const snippetPrompt = `File Path: ${filePath}
|
|
103
|
+
Line Range: Lines ${win.startLine} to ${win.endLine} (Error near position ${errorPos})
|
|
104
|
+
Syntax Error Details: ${effectiveError}
|
|
105
|
+
|
|
106
|
+
Code Snippet to Repair:
|
|
107
|
+
${win.snippet}
|
|
108
|
+
|
|
109
|
+
Please fix the syntax error in the snippet above and return ONLY the raw repaired code snippet:`;
|
|
110
|
+
try {
|
|
111
|
+
const result = await snippetChat.sendMessage(snippetPrompt);
|
|
112
|
+
const repairedSnippet = cleanOutput(result.response.text());
|
|
113
|
+
if (repairedSnippet && repairedSnippet !== win.snippet) {
|
|
114
|
+
const candidateContent = content.slice(0, win.startPos) + repairedSnippet + content.slice(win.endPos);
|
|
115
|
+
const candidateCheck = localValidate(filePath, candidateContent);
|
|
116
|
+
if (candidateCheck.isValid) {
|
|
117
|
+
return candidateContent;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
// Snippet repair failed or encountered API error; continue to full file repair fallback
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// 3. Full file repair strategy (for smaller files or when snippet repair was insufficient)
|
|
127
|
+
const fullSystemInstruction = `
|
|
15
128
|
<identity>
|
|
16
129
|
You are an expert compiler and syntax validator.
|
|
17
|
-
Your sole job is to read source code and verify its syntax.
|
|
130
|
+
Your sole job is to read source code and verify or repair its syntax.
|
|
18
131
|
</identity>
|
|
19
132
|
|
|
20
133
|
<rules>
|
|
21
|
-
1. If the provided code has NO syntax errors (e.g., balanced braces, correct language keywords, complete statements),
|
|
22
|
-
2. If the code has syntax errors (e.g.,
|
|
23
|
-
3.
|
|
24
|
-
4.
|
|
134
|
+
1. If the provided code has NO syntax errors (e.g., balanced braces, correct language keywords, complete statements), respond exactly with: VALID
|
|
135
|
+
2. If the code has syntax errors (e.g., missing closing bracket, dangling parenthesis, unfinished string literal), fix the syntax.
|
|
136
|
+
3. Pay close attention to the provided Local Validator Error Context to locate and fix the specific issue.
|
|
137
|
+
4. Output ONLY the completely fixed file content. Do NOT include any explanations, markdown code blocks (like \`\`\`typescript), or conversational text.
|
|
138
|
+
5. Keep original formatting, comments, and logic intact. Only fix syntax defects.
|
|
25
139
|
</rules>
|
|
26
140
|
`;
|
|
27
|
-
const
|
|
28
|
-
{
|
|
141
|
+
const fullChat = new ProxyChatSession(model, fullSystemInstruction, [], {
|
|
29
142
|
maxOutputTokens: MAX_OUTPUT_TOKENS,
|
|
30
|
-
temperature: 0.1,
|
|
143
|
+
temperature: 0.1,
|
|
31
144
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
145
|
+
const fullPrompt = `File Path: ${filePath}
|
|
146
|
+
|
|
147
|
+
Local Validator Error Context:
|
|
148
|
+
${effectiveError}
|
|
149
|
+
|
|
150
|
+
Content:
|
|
151
|
+
${content}`;
|
|
36
152
|
try {
|
|
37
|
-
const result = await
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
output = output.replace(/^\`\`\`[a-zA-Z]*\n/, '').replace(/\n\`\`\`$/, '').trim();
|
|
153
|
+
const result = await fullChat.sendMessage(fullPrompt);
|
|
154
|
+
const output = cleanOutput(result.response.text());
|
|
155
|
+
if (output === 'VALID' || output === '' || output === content) {
|
|
156
|
+
return undefined;
|
|
42
157
|
}
|
|
43
|
-
|
|
44
|
-
|
|
158
|
+
// Verify the repaired full content is syntactically valid before returning
|
|
159
|
+
const postValidation = localValidate(filePath, output);
|
|
160
|
+
if (postValidation.isValid) {
|
|
161
|
+
return output;
|
|
45
162
|
}
|
|
46
|
-
return
|
|
163
|
+
return undefined;
|
|
47
164
|
}
|
|
48
165
|
catch (err) {
|
|
49
|
-
// If the AI fails (e.g., network error), we return undefined to fall back to the main agent loop
|
|
50
166
|
return undefined;
|
|
51
167
|
}
|
|
52
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Performs AI-assisted fuzzy search matching and edit application using Gemini Flash.
|
|
171
|
+
* Invoked when deterministic local fuzzy matchers fail to locate a search target block
|
|
172
|
+
* due to whitespace variations, formatting shifts, comment differences, or minor code drift.
|
|
173
|
+
*
|
|
174
|
+
* @param fileContent The current full file content.
|
|
175
|
+
* @param searchContent The search target block that local matchers failed to locate.
|
|
176
|
+
* @param replaceContent The replacement text block to insert in place of the target block.
|
|
177
|
+
* @param filePath The path of the file being edited (used for syntax and language context).
|
|
178
|
+
* @param options Optional configuration including custom model or syntax validation toggles.
|
|
179
|
+
* @returns A promise resolving to an AIFuzzyMatchResult.
|
|
180
|
+
*/
|
|
181
|
+
export async function aiFuzzyMatch(fileContent, searchContent, replaceContent, filePath, options = {}) {
|
|
182
|
+
if (!fileContent || !searchContent) {
|
|
183
|
+
return {
|
|
184
|
+
success: false,
|
|
185
|
+
error: 'File content and search content must not be empty.',
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
const model = options.model || GEMINI_MODELS.FLASH;
|
|
189
|
+
const shouldValidateSyntax = options.validateSyntax !== false;
|
|
190
|
+
const systemInstruction = `
|
|
191
|
+
<identity>
|
|
192
|
+
You are an expert software engineer and code editing agent.
|
|
193
|
+
Your primary job is to perform fuzzy search matching and replacement on source code when exact or deterministic matchers fail.
|
|
194
|
+
</identity>
|
|
195
|
+
|
|
196
|
+
<rules>
|
|
197
|
+
1. Analyze the provided File Content and locate the section that semantically and structurally matches the Search Target, even if there are variations in indentation, whitespace, line breaks, comments, or minor refactoring.
|
|
198
|
+
2. Replace that target section with the Replacement Content.
|
|
199
|
+
3. Preserve all surrounding code, formatting, comments, and imports exactly as they appear outside the target section.
|
|
200
|
+
4. Do NOT introduce any extra changes, refactoring, or formatting cleanups outside the specified edit location.
|
|
201
|
+
5. If the Search Target cannot be located anywhere in the File Content with reasonable confidence, respond with exactly: UNMATCHED
|
|
202
|
+
6. Output ONLY the updated full file content (or UNMATCHED). Do NOT wrap your output in markdown code blocks (like \`\`\`typescript), and do NOT include any explanations or conversational text.
|
|
203
|
+
</rules>
|
|
204
|
+
`;
|
|
205
|
+
const chat = new ProxyChatSession(model, systemInstruction, [], {
|
|
206
|
+
maxOutputTokens: MAX_OUTPUT_TOKENS,
|
|
207
|
+
temperature: 0.1,
|
|
208
|
+
});
|
|
209
|
+
const prompt = `File Path: ${filePath}
|
|
210
|
+
|
|
211
|
+
Search Target (Block to locate in file):
|
|
212
|
+
${searchContent}
|
|
213
|
+
|
|
214
|
+
Replacement Content (Block to insert in place of Search Target):
|
|
215
|
+
${replaceContent}
|
|
216
|
+
|
|
217
|
+
File Content:
|
|
218
|
+
${fileContent}`;
|
|
219
|
+
try {
|
|
220
|
+
const response = await chat.sendMessage(prompt);
|
|
221
|
+
const rawOutput = response.response.text();
|
|
222
|
+
const output = cleanOutput(rawOutput);
|
|
223
|
+
if (output === 'UNMATCHED' || !output || output === fileContent) {
|
|
224
|
+
return {
|
|
225
|
+
success: false,
|
|
226
|
+
error: `AI fuzzy search matcher could not locate search target block in ${filePath}.`,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
let finalContent = output;
|
|
230
|
+
if (shouldValidateSyntax) {
|
|
231
|
+
const valResult = localValidate(filePath, finalContent);
|
|
232
|
+
if (!valResult.isValid) {
|
|
233
|
+
// Attempt automatic syntax repair on AI output if local validation detected syntax error
|
|
234
|
+
const repaired = await validateAndFixSyntax(finalContent, filePath, valResult.error);
|
|
235
|
+
if (repaired) {
|
|
236
|
+
finalContent = repaired;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
success: true,
|
|
242
|
+
content: finalContent,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
catch (err) {
|
|
246
|
+
return {
|
|
247
|
+
success: false,
|
|
248
|
+
error: `AI fuzzy search error: ${err?.message || String(err)}`,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Convenience wrapper around aiFuzzyMatch that returns the updated file content string if successful,
|
|
254
|
+
* or undefined if fuzzy matching and replacement failed.
|
|
255
|
+
*
|
|
256
|
+
* @param fileContent The current full file content.
|
|
257
|
+
* @param searchContent The search target block that local matchers failed to locate.
|
|
258
|
+
* @param replaceContent The replacement text block to insert in place of the target block.
|
|
259
|
+
* @param filePath The path of the file being edited.
|
|
260
|
+
* @param options Optional configuration options.
|
|
261
|
+
* @returns The updated file content string if successful, or undefined if failed.
|
|
262
|
+
*/
|
|
263
|
+
export async function aiFuzzySearchAndReplace(fileContent, searchContent, replaceContent, filePath, options) {
|
|
264
|
+
const result = await aiFuzzyMatch(fileContent, searchContent, replaceContent, filePath, options);
|
|
265
|
+
return result.success ? result.content : undefined;
|
|
266
|
+
}
|
|
@@ -70,7 +70,16 @@ export function formatToolCall(name, args) {
|
|
|
70
70
|
write_file: () => `: ${formatPath(String(args.filePath))}`,
|
|
71
71
|
modify_file: () => `: ${formatPath(String(args.filePath))}`,
|
|
72
72
|
list_directory: () => `: ${formatPath(String(args.dirPath ?? '.'))}`,
|
|
73
|
-
run_command: () =>
|
|
73
|
+
run_command: () => {
|
|
74
|
+
const raw = String(args.command);
|
|
75
|
+
// Collapse to first line and truncate for readability
|
|
76
|
+
const firstLine = raw.split('\n')[0].trim();
|
|
77
|
+
const MAX_CMD_DISPLAY = 80;
|
|
78
|
+
const truncated = firstLine.length > MAX_CMD_DISPLAY
|
|
79
|
+
? firstLine.substring(0, MAX_CMD_DISPLAY) + '...'
|
|
80
|
+
: (raw.includes('\n') ? firstLine + '...' : firstLine);
|
|
81
|
+
return `: ${pc.yellow(truncated)}`;
|
|
82
|
+
},
|
|
74
83
|
grep_search: () => `: ${pc.magenta(String(args.pattern))}`,
|
|
75
84
|
delete_file: () => `: ${pc.red(String(args.filePath))}`,
|
|
76
85
|
rename_file: () => `: ${formatPath(String(args.sourcePath))} -> ${formatPath(String(args.targetPath))}`,
|
|
@@ -1,12 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file agent-tools.ts
|
|
3
|
+
* @description Implements tool declarations, approval state management, ignore rule parser,
|
|
4
|
+
* atomic file operations, search/grep engines, dependency tracer, scratchpad script runner,
|
|
5
|
+
* and central tool dispatcher used by the Minovative Mind AI agents.
|
|
6
|
+
*/
|
|
1
7
|
import { type FunctionDeclaration } from '@google/generative-ai';
|
|
8
|
+
/**
|
|
9
|
+
* Represents the structured result returned by any agent tool execution.
|
|
10
|
+
*/
|
|
2
11
|
export interface ToolResult {
|
|
12
|
+
/** Optional error message if the tool execution failed. */
|
|
3
13
|
error?: string;
|
|
14
|
+
/** Standard textual output or formatted content produced by the tool. */
|
|
4
15
|
output: string;
|
|
16
|
+
/** Optional binary or specialized inline data (such as PDFs) attached to the result. */
|
|
5
17
|
inlineData?: {
|
|
6
18
|
mimeType: string;
|
|
7
19
|
data: string;
|
|
8
20
|
};
|
|
9
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns the list of available function declarations for Gemini function calling.
|
|
24
|
+
*
|
|
25
|
+
* @param options - Configuration options such as `isExecutionAgent`.
|
|
26
|
+
* @returns An array of Google Generative AI `FunctionDeclaration` objects.
|
|
27
|
+
*/
|
|
10
28
|
export declare function getToolDeclarations(options?: {
|
|
11
29
|
isExecutionAgent?: boolean;
|
|
12
30
|
}): FunctionDeclaration[];
|
|
@@ -15,27 +33,164 @@ export declare function getToolDeclarations(options?: {
|
|
|
15
33
|
* every tool the agent can invoke. Passed to the model at init.
|
|
16
34
|
*/
|
|
17
35
|
export declare const toolDeclarations: FunctionDeclaration[];
|
|
36
|
+
/**
|
|
37
|
+
* Defines the command execution approval mode.
|
|
38
|
+
* - `ask`: Prompts the user before executing shell commands.
|
|
39
|
+
* - `skip-once`: Automatically approves the next shell command, then reverts to `ask`.
|
|
40
|
+
* - `skip-all`: Automatically approves all subsequent shell commands in the session.
|
|
41
|
+
*/
|
|
18
42
|
export type ApprovalMode = 'ask' | 'skip-once' | 'skip-all';
|
|
43
|
+
/**
|
|
44
|
+
* Retrieves the current command execution approval mode.
|
|
45
|
+
*
|
|
46
|
+
* @returns The active {@link ApprovalMode}.
|
|
47
|
+
*/
|
|
19
48
|
export declare function getApprovalMode(): ApprovalMode;
|
|
49
|
+
/**
|
|
50
|
+
* Sets the command execution approval mode.
|
|
51
|
+
*
|
|
52
|
+
* @param mode - The {@link ApprovalMode} to set.
|
|
53
|
+
*/
|
|
20
54
|
export declare function setApprovalMode(mode: ApprovalMode): void;
|
|
55
|
+
/**
|
|
56
|
+
* Checks whether sub-agents are currently enabled.
|
|
57
|
+
*
|
|
58
|
+
* @returns `true` if sub-agents are enabled, `false` otherwise.
|
|
59
|
+
*/
|
|
21
60
|
export declare function isSubAgentsEnabled(): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Enables or disables sub-agents.
|
|
63
|
+
*
|
|
64
|
+
* @param enabled - Boolean indicating whether sub-agents should be enabled.
|
|
65
|
+
*/
|
|
22
66
|
export declare function setSubAgentsEnabled(enabled: boolean): void;
|
|
23
67
|
/**
|
|
24
68
|
* If set to 'skip-once', reverts to 'ask' after a single command is run.
|
|
25
69
|
*/
|
|
26
70
|
export declare function consumeSkipOnce(): void;
|
|
71
|
+
/**
|
|
72
|
+
* Reads the contents of a file at the given relative or absolute path, supporting text files,
|
|
73
|
+
* native PDF parsing, SQLite database schema dumping, Jupyter Notebook (.ipynb) cell extraction,
|
|
74
|
+
* and CSV-to-Markdown table formatting.
|
|
75
|
+
*
|
|
76
|
+
* @param workspaceRoot - Absolute path to the workspace root directory.
|
|
77
|
+
* @param filePath - Relative path to the target file (or `@alias/` prefixed path).
|
|
78
|
+
* @param startLine - Optional 1-indexed starting line number.
|
|
79
|
+
* @param endLine - Optional 1-indexed ending line number.
|
|
80
|
+
* @param targetElements - Optional array of specific symbol or function names to extract.
|
|
81
|
+
* @returns A promise resolving to a {@link ToolResult} containing the file content or error details.
|
|
82
|
+
*/
|
|
27
83
|
export declare function readFile(workspaceRoot: string, filePath: string, startLine?: number, endLine?: number, targetElements?: string[]): Promise<ToolResult>;
|
|
84
|
+
/**
|
|
85
|
+
* Creates a new file or completely overwrites an existing file with the provided content,
|
|
86
|
+
* performing local syntax validation and iterative AI syntax auto-correction if validation fails.
|
|
87
|
+
*
|
|
88
|
+
* @param workspaceRoot - Absolute path to the workspace root directory.
|
|
89
|
+
* @param filePath - Relative path to the target file.
|
|
90
|
+
* @param content - The complete content to write.
|
|
91
|
+
* @returns A promise resolving to a {@link ToolResult} indicating success or failure.
|
|
92
|
+
*/
|
|
28
93
|
export declare function writeFile(workspaceRoot: string, filePath: string, content: string): Promise<ToolResult>;
|
|
94
|
+
/**
|
|
95
|
+
* Deletes a file from the filesystem and records the deletion in the change logger.
|
|
96
|
+
*
|
|
97
|
+
* @param workspaceRoot - Absolute path to the workspace root directory.
|
|
98
|
+
* @param filePath - Relative path to the file to delete.
|
|
99
|
+
* @returns A promise resolving to a {@link ToolResult} indicating success or failure.
|
|
100
|
+
*/
|
|
29
101
|
export declare function deleteFile(workspaceRoot: string, filePath: string): Promise<ToolResult>;
|
|
102
|
+
/**
|
|
103
|
+
* Moves or renames a file from `sourcePath` to `targetPath`.
|
|
104
|
+
*
|
|
105
|
+
* @param workspaceRoot - Absolute path to the workspace root directory.
|
|
106
|
+
* @param sourcePath - Original relative file path.
|
|
107
|
+
* @param targetPath - New destination relative file path.
|
|
108
|
+
* @returns A promise resolving to a {@link ToolResult} indicating success or failure.
|
|
109
|
+
*/
|
|
30
110
|
export declare function renameFile(workspaceRoot: string, sourcePath: string, targetPath: string): Promise<ToolResult>;
|
|
111
|
+
/**
|
|
112
|
+
* Performs one or multiple targeted search-and-replace edits on a file, utilizing deterministic fuzzy matching,
|
|
113
|
+
* fallback AI fuzzy matching, syntax validation, and atomic writes.
|
|
114
|
+
*
|
|
115
|
+
* @param workspaceRoot - Absolute path to the workspace root directory.
|
|
116
|
+
* @param filePath - Relative path to the target file.
|
|
117
|
+
* @param edits - An array of edit objects containing `searchContent` and `replaceContent`.
|
|
118
|
+
* @returns A promise resolving to a {@link ToolResult} indicating success or failure.
|
|
119
|
+
*/
|
|
31
120
|
export declare function modifyFile(workspaceRoot: string, filePath: string, edits: Array<{
|
|
32
121
|
searchContent: string;
|
|
33
122
|
replaceContent: string;
|
|
34
123
|
}>): Promise<ToolResult>;
|
|
124
|
+
/**
|
|
125
|
+
* Lists files and subdirectories within a directory, returning a recursive ASCII tree structure
|
|
126
|
+
* while respecting ignore rules and excluded extensions.
|
|
127
|
+
*
|
|
128
|
+
* @param workspaceRoot - Absolute path to the workspace root directory.
|
|
129
|
+
* @param dirPath - Relative path to the target directory.
|
|
130
|
+
* @param maxDepth - Maximum recursion depth (defaults to 3).
|
|
131
|
+
* @returns A promise resolving to a {@link ToolResult} containing the formatted tree output.
|
|
132
|
+
*/
|
|
35
133
|
export declare function listDirectory(workspaceRoot: string, dirPath: string, maxDepth?: number): Promise<ToolResult>;
|
|
134
|
+
/**
|
|
135
|
+
* Executes a shell command within the workspace root with a timeout and buffer limit.
|
|
136
|
+
*
|
|
137
|
+
* @param workspaceRoot - Absolute path to the workspace root directory.
|
|
138
|
+
* @param command - The shell command string to execute.
|
|
139
|
+
* @param abortSignal - Optional AbortSignal to cancel execution.
|
|
140
|
+
* @returns A promise resolving to a {@link ToolResult} containing stdout/stderr or an error.
|
|
141
|
+
*/
|
|
36
142
|
export declare function runCommand(workspaceRoot: string, command: string, abortSignal?: AbortSignal): Promise<ToolResult>;
|
|
37
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Performs a grep text or regular expression search across files in the workspace.
|
|
145
|
+
*
|
|
146
|
+
* @param workspaceRoot - Absolute path to the workspace root directory.
|
|
147
|
+
* @param pattern - The search text or regex pattern.
|
|
148
|
+
* @param fileGlob - Optional file glob to restrict matched files.
|
|
149
|
+
* @param fixedStrings - If true, treats the pattern as a literal fixed string.
|
|
150
|
+
* @param dirPath - Optional subdirectory path to restrict the search.
|
|
151
|
+
* @param abortSignal - Optional AbortSignal to cancel execution.
|
|
152
|
+
* @returns A promise resolving to a {@link ToolResult} containing matching lines and file paths.
|
|
153
|
+
*/
|
|
154
|
+
export declare function grepSearch(workspaceRoot: string, pattern: string, fileGlob?: string, fixedStrings?: boolean, dirPath?: string, abortSignal?: AbortSignal): Promise<ToolResult>;
|
|
155
|
+
/**
|
|
156
|
+
* Traces file dependencies (forward imports and reverse dependants) to determine the blast radius of changes.
|
|
157
|
+
*
|
|
158
|
+
* @param workspaceRoot - Absolute path to the workspace root directory.
|
|
159
|
+
* @param filePath - Relative path to the file to trace.
|
|
160
|
+
* @param direction - Trace direction (`'both'`, `'forward'`, or `'reverse'`).
|
|
161
|
+
* @param maxDepth - Maximum recursion depth (defaults to 3).
|
|
162
|
+
* @returns A promise resolving to a {@link ToolResult} containing formatted dependency results.
|
|
163
|
+
*/
|
|
38
164
|
export declare function traceDependencies(workspaceRoot: string, filePath: string, direction?: string, maxDepth?: number): Promise<ToolResult>;
|
|
165
|
+
/**
|
|
166
|
+
* Finds files modified within the workspace recently (within a specified time window).
|
|
167
|
+
*
|
|
168
|
+
* @param workspaceRoot - Absolute path to the workspace root directory.
|
|
169
|
+
* @param dirPath - Subdirectory path to search from (defaults to `'.'`).
|
|
170
|
+
* @param minutes - Time window in minutes (defaults to 60).
|
|
171
|
+
* @param maxDepth - Maximum directory traversal depth (defaults to 5).
|
|
172
|
+
* @returns A promise resolving to a {@link ToolResult} containing recently modified files.
|
|
173
|
+
*/
|
|
39
174
|
export declare function findRecentChanges(workspaceRoot: string, dirPath?: string, minutes?: number, maxDepth?: number): Promise<ToolResult>;
|
|
175
|
+
/**
|
|
176
|
+
* Writes a disposable scratchpad script to a temporary file, executes it using the specified runtime,
|
|
177
|
+
* and returns standard output and standard error.
|
|
178
|
+
*
|
|
179
|
+
* @param workspaceRoot - Absolute path to the workspace root directory.
|
|
180
|
+
* @param language - Runtime language (`'node'`, `'ts-node'`, `'python'`, `'bash'`, `'go'`, or `'rust'`).
|
|
181
|
+
* @param code - The exact script source code to execute.
|
|
182
|
+
* @param abortSignal - Optional AbortSignal to cancel execution.
|
|
183
|
+
* @returns A promise resolving to a {@link ToolResult} containing execution output.
|
|
184
|
+
*/
|
|
40
185
|
export declare function runDebugScript(workspaceRoot: string, language: string, code: string, abortSignal?: AbortSignal): Promise<ToolResult>;
|
|
186
|
+
/**
|
|
187
|
+
* Central tool dispatcher that resolves multi-workspace paths, executes the requested tool
|
|
188
|
+
* with the provided arguments, records metrics, and returns the standardized {@link ToolResult}.
|
|
189
|
+
*
|
|
190
|
+
* @param workspaceRoot - Absolute path to the primary workspace root directory.
|
|
191
|
+
* @param toolName - Name of the tool to invoke.
|
|
192
|
+
* @param args - Key-value map of tool arguments.
|
|
193
|
+
* @param abortSignal - Optional AbortSignal to cancel tool execution.
|
|
194
|
+
* @returns A promise resolving to a {@link ToolResult}.
|
|
195
|
+
*/
|
|
41
196
|
export declare function executeTool(workspaceRoot: string, toolName: string, args: Record<string, unknown>, abortSignal?: AbortSignal): Promise<ToolResult>;
|