wave-agent-sdk 0.0.7 → 0.0.10
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/agent.d.ts +105 -24
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +438 -53
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/managers/aiManager.d.ts +18 -7
- package/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +254 -142
- package/dist/managers/backgroundBashManager.d.ts.map +1 -1
- package/dist/managers/backgroundBashManager.js +11 -9
- package/dist/managers/hookManager.d.ts +6 -6
- package/dist/managers/hookManager.d.ts.map +1 -1
- package/dist/managers/hookManager.js +81 -39
- package/dist/managers/liveConfigManager.d.ts +95 -0
- package/dist/managers/liveConfigManager.d.ts.map +1 -0
- package/dist/managers/liveConfigManager.js +442 -0
- package/dist/managers/lspManager.d.ts +43 -0
- package/dist/managers/lspManager.d.ts.map +1 -0
- package/dist/managers/lspManager.js +326 -0
- package/dist/managers/messageManager.d.ts +41 -24
- package/dist/managers/messageManager.d.ts.map +1 -1
- package/dist/managers/messageManager.js +184 -73
- package/dist/managers/permissionManager.d.ts +66 -0
- package/dist/managers/permissionManager.d.ts.map +1 -0
- package/dist/managers/permissionManager.js +208 -0
- package/dist/managers/skillManager.d.ts +1 -0
- package/dist/managers/skillManager.d.ts.map +1 -1
- package/dist/managers/skillManager.js +2 -1
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +4 -2
- package/dist/managers/subagentManager.d.ts +42 -6
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +213 -62
- package/dist/managers/toolManager.d.ts +38 -1
- package/dist/managers/toolManager.d.ts.map +1 -1
- package/dist/managers/toolManager.js +66 -2
- package/dist/services/aiService.d.ts +15 -5
- package/dist/services/aiService.d.ts.map +1 -1
- package/dist/services/aiService.js +446 -77
- package/dist/services/configurationService.d.ts +116 -0
- package/dist/services/configurationService.d.ts.map +1 -0
- package/dist/services/configurationService.js +585 -0
- package/dist/services/fileWatcher.d.ts +69 -0
- package/dist/services/fileWatcher.d.ts.map +1 -0
- package/dist/services/fileWatcher.js +212 -0
- package/dist/services/hook.d.ts +5 -40
- package/dist/services/hook.d.ts.map +1 -1
- package/dist/services/hook.js +47 -109
- package/dist/services/jsonlHandler.d.ts +71 -0
- package/dist/services/jsonlHandler.d.ts.map +1 -0
- package/dist/services/jsonlHandler.js +236 -0
- package/dist/services/memory.d.ts.map +1 -1
- package/dist/services/memory.js +33 -11
- package/dist/services/session.d.ts +116 -52
- package/dist/services/session.d.ts.map +1 -1
- package/dist/services/session.js +415 -143
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +77 -17
- package/dist/tools/deleteFileTool.d.ts.map +1 -1
- package/dist/tools/deleteFileTool.js +27 -1
- package/dist/tools/editTool.d.ts.map +1 -1
- package/dist/tools/editTool.js +33 -8
- package/dist/tools/lspTool.d.ts +6 -0
- package/dist/tools/lspTool.d.ts.map +1 -0
- package/dist/tools/lspTool.js +589 -0
- package/dist/tools/multiEditTool.d.ts.map +1 -1
- package/dist/tools/multiEditTool.js +30 -10
- package/dist/tools/readTool.d.ts.map +1 -1
- package/dist/tools/readTool.js +113 -3
- package/dist/tools/skillTool.js +2 -2
- package/dist/tools/todoWriteTool.d.ts.map +1 -1
- package/dist/tools/todoWriteTool.js +23 -0
- package/dist/tools/types.d.ts +11 -8
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/writeTool.d.ts.map +1 -1
- package/dist/tools/writeTool.js +30 -15
- package/dist/types/commands.d.ts +4 -1
- package/dist/types/commands.d.ts.map +1 -1
- package/dist/types/config.d.ts +4 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/configuration.d.ts +69 -0
- package/dist/types/configuration.d.ts.map +1 -0
- package/dist/types/configuration.js +8 -0
- package/dist/types/core.d.ts +45 -0
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/environment.d.ts +83 -0
- package/dist/types/environment.d.ts.map +1 -0
- package/dist/types/environment.js +21 -0
- package/dist/types/fileSearch.d.ts +5 -0
- package/dist/types/fileSearch.d.ts.map +1 -0
- package/dist/types/fileSearch.js +1 -0
- package/dist/types/hooks.d.ts +18 -3
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/hooks.js +8 -8
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +7 -0
- package/dist/types/lsp.d.ts +90 -0
- package/dist/types/lsp.d.ts.map +1 -0
- package/dist/types/lsp.js +4 -0
- package/dist/types/messaging.d.ts +19 -12
- package/dist/types/messaging.d.ts.map +1 -1
- package/dist/types/permissions.d.ts +35 -0
- package/dist/types/permissions.d.ts.map +1 -0
- package/dist/types/permissions.js +12 -0
- package/dist/types/session.d.ts +15 -0
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/session.js +7 -0
- package/dist/types/skills.d.ts +1 -0
- package/dist/types/skills.d.ts.map +1 -1
- package/dist/types/tools.d.ts +35 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +4 -0
- package/dist/utils/abortUtils.d.ts +34 -0
- package/dist/utils/abortUtils.d.ts.map +1 -0
- package/dist/utils/abortUtils.js +92 -0
- package/dist/utils/bashHistory.d.ts +4 -0
- package/dist/utils/bashHistory.d.ts.map +1 -1
- package/dist/utils/bashHistory.js +48 -30
- package/dist/utils/builtinSubagents.d.ts +7 -0
- package/dist/utils/builtinSubagents.d.ts.map +1 -0
- package/dist/utils/builtinSubagents.js +65 -0
- package/dist/utils/cacheControlUtils.d.ts +96 -0
- package/dist/utils/cacheControlUtils.d.ts.map +1 -0
- package/dist/utils/cacheControlUtils.js +324 -0
- package/dist/utils/commandPathResolver.d.ts +52 -0
- package/dist/utils/commandPathResolver.d.ts.map +1 -0
- package/dist/utils/commandPathResolver.js +145 -0
- package/dist/utils/configPaths.d.ts +85 -0
- package/dist/utils/configPaths.d.ts.map +1 -0
- package/dist/utils/configPaths.js +121 -0
- package/dist/utils/constants.d.ts +1 -13
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +2 -14
- package/dist/utils/convertMessagesForAPI.d.ts +2 -1
- package/dist/utils/convertMessagesForAPI.d.ts.map +1 -1
- package/dist/utils/convertMessagesForAPI.js +39 -18
- package/dist/utils/customCommands.d.ts.map +1 -1
- package/dist/utils/customCommands.js +66 -21
- package/dist/utils/fileSearch.d.ts +14 -0
- package/dist/utils/fileSearch.d.ts.map +1 -0
- package/dist/utils/fileSearch.js +88 -0
- package/dist/utils/fileUtils.d.ts +27 -0
- package/dist/utils/fileUtils.d.ts.map +1 -0
- package/dist/utils/fileUtils.js +145 -0
- package/dist/utils/globalLogger.d.ts +88 -0
- package/dist/utils/globalLogger.d.ts.map +1 -0
- package/dist/utils/globalLogger.js +120 -0
- package/dist/utils/largeOutputHandler.d.ts +15 -0
- package/dist/utils/largeOutputHandler.d.ts.map +1 -0
- package/dist/utils/largeOutputHandler.js +40 -0
- package/dist/utils/markdownParser.d.ts.map +1 -1
- package/dist/utils/markdownParser.js +1 -17
- package/dist/utils/mcpUtils.d.ts.map +1 -1
- package/dist/utils/mcpUtils.js +25 -3
- package/dist/utils/messageOperations.d.ts +20 -18
- package/dist/utils/messageOperations.d.ts.map +1 -1
- package/dist/utils/messageOperations.js +30 -38
- package/dist/utils/pathEncoder.d.ts +108 -0
- package/dist/utils/pathEncoder.d.ts.map +1 -0
- package/dist/utils/pathEncoder.js +279 -0
- package/dist/utils/subagentParser.d.ts +2 -2
- package/dist/utils/subagentParser.d.ts.map +1 -1
- package/dist/utils/subagentParser.js +12 -8
- package/dist/utils/tokenCalculation.d.ts +26 -0
- package/dist/utils/tokenCalculation.d.ts.map +1 -0
- package/dist/utils/tokenCalculation.js +36 -0
- package/dist/utils/tokenEstimator.d.ts +39 -0
- package/dist/utils/tokenEstimator.d.ts.map +1 -0
- package/dist/utils/tokenEstimator.js +55 -0
- package/package.json +6 -6
- package/src/agent.ts +586 -78
- package/src/index.ts +4 -0
- package/src/managers/aiManager.ts +341 -192
- package/src/managers/backgroundBashManager.ts +11 -9
- package/src/managers/hookManager.ts +102 -54
- package/src/managers/liveConfigManager.ts +634 -0
- package/src/managers/lspManager.ts +434 -0
- package/src/managers/messageManager.ts +258 -121
- package/src/managers/permissionManager.ts +276 -0
- package/src/managers/skillManager.ts +3 -1
- package/src/managers/slashCommandManager.ts +5 -3
- package/src/managers/subagentManager.ts +295 -76
- package/src/managers/toolManager.ts +95 -3
- package/src/services/aiService.ts +656 -84
- package/src/services/configurationService.ts +762 -0
- package/src/services/fileWatcher.ts +300 -0
- package/src/services/hook.ts +54 -144
- package/src/services/jsonlHandler.ts +303 -0
- package/src/services/memory.ts +34 -11
- package/src/services/session.ts +522 -173
- package/src/tools/bashTool.ts +94 -20
- package/src/tools/deleteFileTool.ts +38 -1
- package/src/tools/editTool.ts +44 -9
- package/src/tools/lspTool.ts +760 -0
- package/src/tools/multiEditTool.ts +41 -11
- package/src/tools/readTool.ts +127 -3
- package/src/tools/skillTool.ts +2 -2
- package/src/tools/todoWriteTool.ts +33 -1
- package/src/tools/types.ts +15 -9
- package/src/tools/writeTool.ts +43 -16
- package/src/types/commands.ts +6 -1
- package/src/types/config.ts +5 -0
- package/src/types/configuration.ts +73 -0
- package/src/types/core.ts +55 -0
- package/src/types/environment.ts +104 -0
- package/src/types/fileSearch.ts +4 -0
- package/src/types/hooks.ts +32 -16
- package/src/types/index.ts +7 -0
- package/src/types/lsp.ts +96 -0
- package/src/types/messaging.ts +21 -14
- package/src/types/permissions.ts +48 -0
- package/src/types/session.ts +20 -0
- package/src/types/skills.ts +1 -0
- package/src/types/tools.ts +38 -0
- package/src/utils/abortUtils.ts +118 -0
- package/src/utils/bashHistory.ts +55 -31
- package/src/utils/builtinSubagents.ts +71 -0
- package/src/utils/cacheControlUtils.ts +475 -0
- package/src/utils/commandPathResolver.ts +189 -0
- package/src/utils/configPaths.ts +163 -0
- package/src/utils/constants.ts +2 -17
- package/src/utils/convertMessagesForAPI.ts +44 -18
- package/src/utils/customCommands.ts +90 -22
- package/src/utils/fileSearch.ts +107 -0
- package/src/utils/fileUtils.ts +160 -0
- package/src/utils/globalLogger.ts +128 -0
- package/src/utils/largeOutputHandler.ts +55 -0
- package/src/utils/markdownParser.ts +1 -19
- package/src/utils/mcpUtils.ts +34 -3
- package/src/utils/messageOperations.ts +47 -53
- package/src/utils/pathEncoder.ts +394 -0
- package/src/utils/subagentParser.ts +13 -9
- package/src/utils/tokenCalculation.ts +43 -0
- package/src/utils/tokenEstimator.ts +68 -0
- package/dist/utils/configResolver.d.ts +0 -38
- package/dist/utils/configResolver.d.ts.map +0 -1
- package/dist/utils/configResolver.js +0 -106
- package/src/utils/configResolver.ts +0 -142
package/src/utils/bashHistory.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import fs from "fs";
|
|
7
7
|
import { BASH_HISTORY_FILE, DATA_DIRECTORY } from "./constants.js";
|
|
8
|
+
import { logger } from "./globalLogger.js";
|
|
8
9
|
|
|
9
10
|
export interface BashHistoryEntry {
|
|
10
11
|
command: string;
|
|
@@ -28,8 +29,8 @@ const ensureDataDirectory = (): void => {
|
|
|
28
29
|
if (!fs.existsSync(DATA_DIRECTORY)) {
|
|
29
30
|
fs.mkdirSync(DATA_DIRECTORY, { recursive: true });
|
|
30
31
|
}
|
|
31
|
-
} catch {
|
|
32
|
-
|
|
32
|
+
} catch (error) {
|
|
33
|
+
logger.debug("Failed to create data directory:", error);
|
|
33
34
|
}
|
|
34
35
|
};
|
|
35
36
|
|
|
@@ -52,7 +53,7 @@ export const loadBashHistory = (): BashHistory => {
|
|
|
52
53
|
|
|
53
54
|
// Version compatibility check
|
|
54
55
|
if (history.version !== HISTORY_VERSION) {
|
|
55
|
-
|
|
56
|
+
logger.debug("Bash history version mismatch, resetting history");
|
|
56
57
|
return {
|
|
57
58
|
commands: [],
|
|
58
59
|
version: HISTORY_VERSION,
|
|
@@ -60,8 +61,8 @@ export const loadBashHistory = (): BashHistory => {
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
return history;
|
|
63
|
-
} catch {
|
|
64
|
-
|
|
64
|
+
} catch (error) {
|
|
65
|
+
logger.debug("Failed to load bash history:", error);
|
|
65
66
|
return {
|
|
66
67
|
commands: [],
|
|
67
68
|
version: HISTORY_VERSION,
|
|
@@ -76,7 +77,7 @@ export const saveBashHistory = (history: BashHistory): void => {
|
|
|
76
77
|
try {
|
|
77
78
|
// Skip saving to file when in test environment
|
|
78
79
|
if (process.env.NODE_ENV === "test") {
|
|
79
|
-
|
|
80
|
+
logger.debug("Skipping bash history save in test environment");
|
|
80
81
|
return;
|
|
81
82
|
}
|
|
82
83
|
|
|
@@ -89,8 +90,8 @@ export const saveBashHistory = (history: BashHistory): void => {
|
|
|
89
90
|
|
|
90
91
|
const data = JSON.stringify(history, null, 2);
|
|
91
92
|
fs.writeFileSync(BASH_HISTORY_FILE, data, "utf-8");
|
|
92
|
-
} catch {
|
|
93
|
-
|
|
93
|
+
} catch (error) {
|
|
94
|
+
logger.debug("Failed to save bash history:", error);
|
|
94
95
|
}
|
|
95
96
|
};
|
|
96
97
|
|
|
@@ -102,12 +103,6 @@ export const addBashCommandToHistory = (
|
|
|
102
103
|
workdir: string,
|
|
103
104
|
): void => {
|
|
104
105
|
try {
|
|
105
|
-
// Filter system-generated commands, do not add to history
|
|
106
|
-
if (command.startsWith("git add . && git commit -m")) {
|
|
107
|
-
// logger.debug("Skipping system-generated command:", { command, workdir });
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
106
|
const history = loadBashHistory();
|
|
112
107
|
const timestamp = Date.now();
|
|
113
108
|
|
|
@@ -130,9 +125,9 @@ export const addBashCommandToHistory = (
|
|
|
130
125
|
}
|
|
131
126
|
|
|
132
127
|
saveBashHistory(history);
|
|
133
|
-
|
|
134
|
-
} catch {
|
|
135
|
-
|
|
128
|
+
logger.debug("Added bash command to history:", { command, workdir });
|
|
129
|
+
} catch (error) {
|
|
130
|
+
logger.debug("Failed to add bash command to history:", error);
|
|
136
131
|
}
|
|
137
132
|
};
|
|
138
133
|
|
|
@@ -158,7 +153,7 @@ export const searchBashHistory = (
|
|
|
158
153
|
if (!normalizedQuery) {
|
|
159
154
|
// If no search query, return recent commands (deduplicated)
|
|
160
155
|
const deduped = deduplicateCommands(filteredCommands);
|
|
161
|
-
return deduped.slice(
|
|
156
|
+
return deduped.slice(0, limit); // Latest first
|
|
162
157
|
}
|
|
163
158
|
|
|
164
159
|
// Search by relevance
|
|
@@ -201,11 +196,16 @@ export const searchBashHistory = (
|
|
|
201
196
|
const dedupedMatches = deduplicateCommands(matches);
|
|
202
197
|
const result = dedupedMatches.slice(0, limit);
|
|
203
198
|
|
|
204
|
-
|
|
199
|
+
logger.debug("Bash history search results:", {
|
|
200
|
+
query,
|
|
201
|
+
workdir: process.cwd(),
|
|
202
|
+
originalCount: matches.length,
|
|
203
|
+
dedupedCount: result.length,
|
|
204
|
+
});
|
|
205
205
|
|
|
206
206
|
return result;
|
|
207
|
-
} catch {
|
|
208
|
-
|
|
207
|
+
} catch (error) {
|
|
208
|
+
logger.debug("Failed to search bash history:", error);
|
|
209
209
|
return [];
|
|
210
210
|
}
|
|
211
211
|
};
|
|
@@ -226,9 +226,9 @@ const deduplicateCommands = (
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
// Sort by timestamp and return
|
|
229
|
+
// Sort by timestamp and return (new to old)
|
|
230
230
|
return Array.from(commandMap.values()).sort(
|
|
231
|
-
(a, b) =>
|
|
231
|
+
(a, b) => b.timestamp - a.timestamp,
|
|
232
232
|
);
|
|
233
233
|
};
|
|
234
234
|
|
|
@@ -247,13 +247,37 @@ export const getRecentBashCommands = (
|
|
|
247
247
|
|
|
248
248
|
// Return recent commands after deduplication
|
|
249
249
|
const deduped = deduplicateCommands(filtered);
|
|
250
|
-
return deduped.slice(
|
|
251
|
-
} catch {
|
|
252
|
-
|
|
250
|
+
return deduped.slice(0, limit); // Latest first
|
|
251
|
+
} catch (error) {
|
|
252
|
+
logger.debug("Failed to get recent bash commands:", error);
|
|
253
253
|
return [];
|
|
254
254
|
}
|
|
255
255
|
};
|
|
256
256
|
|
|
257
|
+
/**
|
|
258
|
+
* Delete a specific command from bash history
|
|
259
|
+
*/
|
|
260
|
+
export const deleteBashCommandFromHistory = (
|
|
261
|
+
command: string,
|
|
262
|
+
workdir: string,
|
|
263
|
+
): void => {
|
|
264
|
+
try {
|
|
265
|
+
const history = loadBashHistory();
|
|
266
|
+
const initialLength = history.commands.length;
|
|
267
|
+
|
|
268
|
+
history.commands = history.commands.filter(
|
|
269
|
+
(entry) => !(entry.command === command && entry.workdir === workdir),
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
if (history.commands.length !== initialLength) {
|
|
273
|
+
saveBashHistory(history);
|
|
274
|
+
logger.debug("Deleted bash command from history:", { command, workdir });
|
|
275
|
+
}
|
|
276
|
+
} catch (error) {
|
|
277
|
+
logger.debug("Failed to delete bash command from history:", error);
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
|
|
257
281
|
/**
|
|
258
282
|
* Clear bash history
|
|
259
283
|
*/
|
|
@@ -264,9 +288,9 @@ export const clearBashHistory = (): void => {
|
|
|
264
288
|
version: HISTORY_VERSION,
|
|
265
289
|
};
|
|
266
290
|
saveBashHistory(history);
|
|
267
|
-
|
|
268
|
-
} catch {
|
|
269
|
-
|
|
291
|
+
logger.debug("Bash history cleared");
|
|
292
|
+
} catch (error) {
|
|
293
|
+
logger.debug("Failed to clear bash history:", error);
|
|
270
294
|
}
|
|
271
295
|
};
|
|
272
296
|
|
|
@@ -292,8 +316,8 @@ export const getBashCommandStats = (): {
|
|
|
292
316
|
uniqueCommands: uniqueCommands.size,
|
|
293
317
|
workdirs,
|
|
294
318
|
};
|
|
295
|
-
} catch {
|
|
296
|
-
|
|
319
|
+
} catch (error) {
|
|
320
|
+
logger.debug("Failed to get bash command stats:", error);
|
|
297
321
|
return {
|
|
298
322
|
totalCommands: 0,
|
|
299
323
|
uniqueCommands: 0,
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { SubagentConfiguration } from "./subagentParser.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get all built-in subagent configurations
|
|
5
|
+
* Built-in subagents have priority 3 (lowest) and can be overridden by user/project configs
|
|
6
|
+
*/
|
|
7
|
+
export function getBuiltinSubagents(): SubagentConfiguration[] {
|
|
8
|
+
return [
|
|
9
|
+
createExploreSubagent(),
|
|
10
|
+
// Add more built-in subagents here as needed
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Create the Explore built-in subagent configuration
|
|
16
|
+
* Specialized for codebase exploration and file search tasks
|
|
17
|
+
*/
|
|
18
|
+
function createExploreSubagent(): SubagentConfiguration {
|
|
19
|
+
const systemPrompt = `You are a file search specialist. You excel at thoroughly navigating and exploring codebases.
|
|
20
|
+
|
|
21
|
+
=== CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===
|
|
22
|
+
This is a READ-ONLY exploration task. You are STRICTLY PROHIBITED from:
|
|
23
|
+
- Creating new files (no Write, touch, or file creation of any kind)
|
|
24
|
+
- Modifying existing files (no Edit operations)
|
|
25
|
+
- Deleting files (no rm or deletion)
|
|
26
|
+
- Moving or copying files (no mv or cp)
|
|
27
|
+
- Creating temporary files anywhere, including /tmp
|
|
28
|
+
- Using redirect operators (>, >>, |) or heredocs to write to files
|
|
29
|
+
- Running ANY commands that change system state
|
|
30
|
+
|
|
31
|
+
Your role is EXCLUSIVELY to search and analyze existing code. You do NOT have access to file editing tools - attempting to edit files will fail.
|
|
32
|
+
|
|
33
|
+
Your strengths:
|
|
34
|
+
- Rapidly finding files using glob patterns
|
|
35
|
+
- Searching code and text with powerful regex patterns
|
|
36
|
+
- Reading and analyzing file contents
|
|
37
|
+
- Using Language Server Protocol (LSP) for deep code intelligence (definitions, references, etc.)
|
|
38
|
+
|
|
39
|
+
Guidelines:
|
|
40
|
+
- Use Glob for broad file pattern matching
|
|
41
|
+
- Use Grep for searching file contents with regex
|
|
42
|
+
- Use Read when you know the specific file path you need to read
|
|
43
|
+
- Use LSP for code intelligence features like finding definitions, references, implementations, and symbols. This is especially useful for understanding complex code relationships.
|
|
44
|
+
- Use Bash ONLY for read-only operations (ls, git status, git log, git diff, find, cat, head, tail)
|
|
45
|
+
- NEVER use Bash for: mkdir, touch, rm, cp, mv, git add, git commit, npm install, pip install, or any file creation/modification
|
|
46
|
+
- Adapt your search approach based on the thoroughness level specified by the caller
|
|
47
|
+
- Return file paths as absolute paths in your final response
|
|
48
|
+
- For clear communication, avoid using emojis
|
|
49
|
+
- Communicate your final report directly as a regular message - do NOT attempt to create files
|
|
50
|
+
|
|
51
|
+
NOTE: You are meant to be a fast agent that returns output as quickly as possible. In order to achieve this you must:
|
|
52
|
+
- Make efficient use of the tools that you have at your disposal: be smart about how you search for files and implementations
|
|
53
|
+
- Wherever possible you should try to spawn multiple parallel tool calls for grepping and reading files
|
|
54
|
+
|
|
55
|
+
Complete the user's search request efficiently and report your findings clearly.`;
|
|
56
|
+
|
|
57
|
+
// Define allowed tools for read-only operations
|
|
58
|
+
const allowedTools = ["Glob", "Grep", "Read", "Bash", "LS", "LSP"];
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
name: "Explore",
|
|
62
|
+
description:
|
|
63
|
+
'Fast agent specialized for exploring codebases. Use this when you need to quickly find files by patterns (eg. "src/components/**/*.tsx"), search code for keywords (eg. "API endpoints"), or answer questions about the codebase (eg. "how do API endpoints work?"). When calling this agent, specify the desired thoroughness level: "quick" for basic searches, "medium" for moderate exploration, or "very thorough" for comprehensive analysis across multiple locations and naming conventions.',
|
|
64
|
+
systemPrompt,
|
|
65
|
+
tools: allowedTools,
|
|
66
|
+
model: "fastModel", // Special value that will use parent's fastModel
|
|
67
|
+
filePath: "<builtin:Explore>",
|
|
68
|
+
scope: "builtin",
|
|
69
|
+
priority: 3, // Lowest priority - can be overridden by user configs
|
|
70
|
+
};
|
|
71
|
+
}
|