wave-agent-sdk 0.4.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.ts +42 -11
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +114 -115
- package/dist/constants/prompts.d.ts +18 -14
- package/dist/constants/prompts.d.ts.map +1 -1
- package/dist/constants/prompts.js +130 -54
- package/dist/constants/tools.d.ts +6 -3
- package/dist/constants/tools.d.ts.map +1 -1
- package/dist/constants/tools.js +6 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/managers/MemoryRuleManager.js +1 -1
- package/dist/managers/aiManager.d.ts +5 -3
- package/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +57 -20
- package/dist/managers/backgroundBashManager.d.ts.map +1 -1
- package/dist/managers/backgroundBashManager.js +1 -0
- package/dist/managers/backgroundTaskManager.d.ts +35 -0
- package/dist/managers/backgroundTaskManager.d.ts.map +1 -0
- package/dist/managers/backgroundTaskManager.js +255 -0
- package/dist/managers/foregroundTaskManager.d.ts +9 -0
- package/dist/managers/foregroundTaskManager.d.ts.map +1 -0
- package/dist/managers/foregroundTaskManager.js +21 -0
- package/dist/managers/liveConfigManager.d.ts +1 -1
- package/dist/managers/lspManager.d.ts.map +1 -1
- package/dist/managers/lspManager.js +3 -1
- package/dist/managers/mcpManager.d.ts.map +1 -1
- package/dist/managers/messageManager.d.ts +26 -12
- package/dist/managers/messageManager.d.ts.map +1 -1
- package/dist/managers/messageManager.js +138 -64
- package/dist/managers/permissionManager.d.ts.map +1 -1
- package/dist/managers/permissionManager.js +26 -22
- package/dist/managers/planManager.d.ts +1 -1
- package/dist/managers/planManager.d.ts.map +1 -1
- package/dist/managers/planManager.js +2 -2
- package/dist/managers/pluginManager.d.ts.map +1 -1
- package/dist/managers/pluginManager.js +3 -2
- package/dist/managers/slashCommandManager.d.ts +6 -0
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +8 -2
- package/dist/managers/subagentManager.d.ts +15 -2
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +153 -39
- package/dist/managers/toolManager.d.ts +18 -1
- package/dist/managers/toolManager.d.ts.map +1 -1
- package/dist/managers/toolManager.js +29 -5
- package/dist/services/GitService.d.ts.map +1 -1
- package/dist/services/GitService.js +6 -2
- package/dist/services/MarketplaceService.d.ts +2 -2
- package/dist/services/MarketplaceService.d.ts.map +1 -1
- package/dist/services/MarketplaceService.js +18 -11
- package/dist/services/MemoryRuleService.d.ts +1 -1
- package/dist/services/MemoryRuleService.d.ts.map +1 -1
- package/dist/services/MemoryRuleService.js +13 -2
- package/dist/services/aiService.d.ts +0 -1
- package/dist/services/aiService.d.ts.map +1 -1
- package/dist/services/aiService.js +4 -140
- package/dist/services/memory.d.ts +0 -3
- package/dist/services/memory.d.ts.map +1 -1
- package/dist/services/memory.js +1 -60
- package/dist/services/session.d.ts +15 -1
- package/dist/services/session.d.ts.map +1 -1
- package/dist/services/session.js +57 -1
- package/dist/services/taskManager.d.ts +21 -0
- package/dist/services/taskManager.d.ts.map +1 -0
- package/dist/services/taskManager.js +158 -0
- package/dist/tools/askUserQuestion.d.ts.map +1 -1
- package/dist/tools/askUserQuestion.js +39 -25
- package/dist/tools/bashTool.d.ts +0 -8
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +48 -172
- package/dist/tools/editTool.d.ts.map +1 -1
- package/dist/tools/editTool.js +8 -6
- package/dist/tools/exitPlanMode.d.ts.map +1 -1
- package/dist/tools/exitPlanMode.js +25 -1
- package/dist/tools/globTool.d.ts.map +1 -1
- package/dist/tools/globTool.js +8 -2
- package/dist/tools/grepTool.d.ts.map +1 -1
- package/dist/tools/grepTool.js +17 -6
- package/dist/tools/lsTool.d.ts.map +1 -1
- package/dist/tools/lsTool.js +3 -1
- package/dist/tools/multiEditTool.d.ts.map +1 -1
- package/dist/tools/multiEditTool.js +7 -6
- package/dist/tools/readTool.d.ts.map +1 -1
- package/dist/tools/readTool.js +16 -1
- package/dist/tools/taskManagementTools.d.ts +6 -0
- package/dist/tools/taskManagementTools.d.ts.map +1 -0
- package/dist/tools/taskManagementTools.js +453 -0
- package/dist/tools/taskOutputTool.d.ts +3 -0
- package/dist/tools/taskOutputTool.d.ts.map +1 -0
- package/dist/tools/taskOutputTool.js +173 -0
- package/dist/tools/taskStopTool.d.ts +3 -0
- package/dist/tools/taskStopTool.d.ts.map +1 -0
- package/dist/tools/taskStopTool.js +71 -0
- package/dist/tools/taskTool.d.ts.map +1 -1
- package/dist/tools/taskTool.js +110 -63
- package/dist/tools/types.d.ts +12 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/writeTool.d.ts.map +1 -1
- package/dist/tools/writeTool.js +9 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/marketplace.d.ts +1 -0
- package/dist/types/marketplace.d.ts.map +1 -1
- package/dist/types/messaging.d.ts +3 -8
- package/dist/types/messaging.d.ts.map +1 -1
- package/dist/types/processes.d.ts +29 -4
- package/dist/types/processes.d.ts.map +1 -1
- package/dist/types/tasks.d.ts +13 -0
- package/dist/types/tasks.d.ts.map +1 -0
- package/dist/types/tasks.js +1 -0
- package/dist/types/tools.d.ts +4 -1
- package/dist/types/tools.d.ts.map +1 -1
- package/dist/utils/builtinSubagents.d.ts.map +1 -1
- package/dist/utils/builtinSubagents.js +38 -1
- package/dist/utils/cacheControlUtils.d.ts.map +1 -1
- package/dist/utils/cacheControlUtils.js +18 -12
- package/dist/utils/constants.d.ts +0 -4
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +0 -4
- package/dist/utils/convertMessagesForAPI.js +2 -2
- package/dist/utils/editUtils.d.ts +2 -11
- package/dist/utils/editUtils.d.ts.map +1 -1
- package/dist/utils/editUtils.js +52 -79
- package/dist/utils/messageOperations.d.ts +5 -36
- package/dist/utils/messageOperations.d.ts.map +1 -1
- package/dist/utils/messageOperations.js +9 -98
- package/dist/utils/nameGenerator.d.ts +1 -1
- package/dist/utils/nameGenerator.d.ts.map +1 -1
- package/dist/utils/nameGenerator.js +19 -3
- package/package.json +5 -5
- package/src/agent.ts +157 -134
- package/src/constants/prompts.ts +156 -65
- package/src/constants/tools.ts +6 -3
- package/src/index.ts +1 -0
- package/src/managers/MemoryRuleManager.ts +1 -1
- package/src/managers/aiManager.ts +77 -35
- package/src/managers/backgroundBashManager.ts +1 -0
- package/src/managers/backgroundTaskManager.ts +305 -0
- package/src/managers/foregroundTaskManager.ts +27 -0
- package/src/managers/lspManager.ts +3 -1
- package/src/managers/mcpManager.ts +6 -3
- package/src/managers/messageManager.ts +185 -75
- package/src/managers/permissionManager.ts +33 -28
- package/src/managers/planManager.ts +2 -2
- package/src/managers/pluginManager.ts +4 -3
- package/src/managers/slashCommandManager.ts +15 -2
- package/src/managers/subagentManager.ts +194 -35
- package/src/managers/toolManager.ts +48 -6
- package/src/services/GitService.ts +6 -2
- package/src/services/MarketplaceService.ts +30 -12
- package/src/services/MemoryRuleService.ts +18 -6
- package/src/services/aiService.ts +3 -145
- package/src/services/memory.ts +1 -73
- package/src/services/session.ts +73 -0
- package/src/services/taskManager.ts +188 -0
- package/src/tools/askUserQuestion.ts +51 -29
- package/src/tools/bashTool.ts +63 -196
- package/src/tools/editTool.ts +9 -18
- package/src/tools/exitPlanMode.ts +26 -2
- package/src/tools/globTool.ts +10 -2
- package/src/tools/grepTool.ts +17 -6
- package/src/tools/lsTool.ts +3 -1
- package/src/tools/multiEditTool.ts +7 -18
- package/src/tools/readTool.ts +17 -1
- package/src/tools/taskManagementTools.ts +498 -0
- package/src/tools/taskOutputTool.ts +196 -0
- package/src/tools/taskStopTool.ts +78 -0
- package/src/tools/taskTool.ts +136 -74
- package/src/tools/types.ts +13 -0
- package/src/tools/writeTool.ts +9 -2
- package/src/types/index.ts +1 -0
- package/src/types/marketplace.ts +1 -0
- package/src/types/messaging.ts +2 -9
- package/src/types/processes.ts +39 -4
- package/src/types/tasks.ts +13 -0
- package/src/types/tools.ts +4 -1
- package/src/utils/builtinSubagents.ts +47 -1
- package/src/utils/cacheControlUtils.ts +26 -18
- package/src/utils/constants.ts +0 -5
- package/src/utils/convertMessagesForAPI.ts +2 -2
- package/src/utils/editUtils.ts +65 -103
- package/src/utils/messageOperations.ts +12 -136
- package/src/utils/nameGenerator.ts +20 -3
- package/dist/tools/todoWriteTool.d.ts +0 -6
- package/dist/tools/todoWriteTool.d.ts.map +0 -1
- package/dist/tools/todoWriteTool.js +0 -220
- package/src/tools/todoWriteTool.ts +0 -257
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
import { ASK_USER_QUESTION_TOOL_NAME
|
|
1
|
+
import { ASK_USER_QUESTION_TOOL_NAME } from "../constants/tools.js";
|
|
2
2
|
export const askUserQuestionTool = {
|
|
3
3
|
name: ASK_USER_QUESTION_TOOL_NAME,
|
|
4
4
|
config: {
|
|
5
5
|
type: "function",
|
|
6
6
|
function: {
|
|
7
7
|
name: ASK_USER_QUESTION_TOOL_NAME,
|
|
8
|
-
description:
|
|
9
|
-
Use this tool when you need to ask the user questions during execution. This allows you to:
|
|
10
|
-
1. Gather user preferences or requirements
|
|
11
|
-
2. Clarify ambiguous instructions
|
|
12
|
-
3. Get decisions on implementation choices as you work
|
|
13
|
-
4. Offer choices to the user about what direction to take.
|
|
14
|
-
|
|
15
|
-
Usage notes:
|
|
16
|
-
- Users will always be able to select "Other" to provide custom text input
|
|
17
|
-
- Use multiSelect: true to allow multiple answers to be selected for a question
|
|
18
|
-
- If you recommend a specific option, make that the first option in the list and add "(Recommended)" at the end of the label
|
|
19
|
-
|
|
20
|
-
Plan mode note: In plan mode, use this tool to clarify requirements or choose between approaches BEFORE finalizing your plan. Do NOT use this tool to ask "Is my plan ready?" or "Should I proceed?" - use ${EXIT_PLAN_MODE_TOOL_NAME} for plan approval.`,
|
|
8
|
+
description: "Asks the user multiple choice questions to gather information, clarify ambiguity, understand preferences, make decisions or offer them choices.",
|
|
21
9
|
parameters: {
|
|
22
10
|
type: "object",
|
|
23
11
|
properties: {
|
|
@@ -25,36 +13,34 @@ Plan mode note: In plan mode, use this tool to clarify requirements or choose be
|
|
|
25
13
|
type: "array",
|
|
26
14
|
minItems: 1,
|
|
27
15
|
maxItems: 4,
|
|
16
|
+
description: "Questions to ask the user (1-4 questions)",
|
|
28
17
|
items: {
|
|
29
18
|
type: "object",
|
|
30
19
|
properties: {
|
|
31
20
|
question: {
|
|
32
21
|
type: "string",
|
|
33
|
-
description:
|
|
22
|
+
description: 'The complete question to ask the user. Should be clear, specific, and end with a question mark. Example: "Which library should we use for date formatting?" If multiSelect is true, phrase it accordingly, e.g. "Which features do you want to enable?"',
|
|
34
23
|
},
|
|
35
24
|
header: {
|
|
36
25
|
type: "string",
|
|
37
26
|
maxLength: 12,
|
|
38
|
-
description:
|
|
27
|
+
description: `Very short label displayed as a chip/tag (max 12 chars). Examples: "Auth method", "Library", "Approach".`,
|
|
39
28
|
},
|
|
40
29
|
options: {
|
|
41
30
|
type: "array",
|
|
42
31
|
minItems: 2,
|
|
43
32
|
maxItems: 4,
|
|
33
|
+
description: "The available choices for this question. Must have 2-4 options. Each option should be a distinct, mutually exclusive choice (unless multiSelect is enabled). There should be no 'Other' option, that will be provided automatically.",
|
|
44
34
|
items: {
|
|
45
35
|
type: "object",
|
|
46
36
|
properties: {
|
|
47
37
|
label: {
|
|
48
38
|
type: "string",
|
|
49
|
-
description: "The display text for this option.",
|
|
39
|
+
description: "The display text for this option that the user will see and select. Should be concise (1-5 words) and clearly describe the choice.",
|
|
50
40
|
},
|
|
51
41
|
description: {
|
|
52
42
|
type: "string",
|
|
53
|
-
description: "Explanation of what this option means.",
|
|
54
|
-
},
|
|
55
|
-
isRecommended: {
|
|
56
|
-
type: "boolean",
|
|
57
|
-
description: "Whether this option is recommended.",
|
|
43
|
+
description: "Explanation of what this option means or what will happen if chosen. Useful for providing context about trade-offs or implications.",
|
|
58
44
|
},
|
|
59
45
|
},
|
|
60
46
|
required: ["label"],
|
|
@@ -63,23 +49,51 @@ Plan mode note: In plan mode, use this tool to clarify requirements or choose be
|
|
|
63
49
|
multiSelect: {
|
|
64
50
|
type: "boolean",
|
|
65
51
|
default: false,
|
|
66
|
-
description: "
|
|
52
|
+
description: "Set to true to allow the user to select multiple options instead of just one. Use when choices are not mutually exclusive.",
|
|
67
53
|
},
|
|
68
54
|
},
|
|
69
55
|
required: ["question", "header", "options"],
|
|
70
56
|
},
|
|
71
57
|
},
|
|
58
|
+
answers: {
|
|
59
|
+
type: "object",
|
|
60
|
+
additionalProperties: { type: "string" },
|
|
61
|
+
description: "User answers collected by the permission component",
|
|
62
|
+
},
|
|
63
|
+
metadata: {
|
|
64
|
+
type: "object",
|
|
65
|
+
properties: {
|
|
66
|
+
source: {
|
|
67
|
+
type: "string",
|
|
68
|
+
description: 'Optional identifier for the source of this question (e.g., "remember" for /remember command). Used for analytics tracking.',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
description: "Optional metadata for the question",
|
|
72
|
+
},
|
|
72
73
|
},
|
|
73
74
|
required: ["questions"],
|
|
74
75
|
},
|
|
75
76
|
},
|
|
76
77
|
},
|
|
78
|
+
prompt: () => `Use this tool when you need to ask the user questions during execution. This allows you to:
|
|
79
|
+
1. Gather user preferences or requirements
|
|
80
|
+
2. Clarify ambiguous instructions
|
|
81
|
+
3. Get decisions on implementation choices as you work
|
|
82
|
+
4. Offer choices to the user about what direction to take.
|
|
83
|
+
|
|
84
|
+
Usage notes:
|
|
85
|
+
- Users will always be able to select "Other" to provide custom text input
|
|
86
|
+
- Use multiSelect: true to allow multiple answers to be selected for a question
|
|
87
|
+
- If you recommend a specific option, make that the first option in the list and add "(Recommended)" at the end of the label
|
|
88
|
+
|
|
89
|
+
Plan mode note: In plan mode, use this tool to clarify requirements or choose between approaches BEFORE finalizing your plan. Do NOT use this tool to ask "Is my plan ready?" or "Should I proceed?" - use ExitPlanMode for plan approval.
|
|
90
|
+
`,
|
|
77
91
|
execute: async (args, context) => {
|
|
78
|
-
const { questions } = args;
|
|
92
|
+
const { questions, answers: existingAnswers, metadata, } = args;
|
|
79
93
|
if (!context.permissionManager) {
|
|
80
94
|
throw new Error(`Permission manager is required for ${ASK_USER_QUESTION_TOOL_NAME} tool`);
|
|
81
95
|
}
|
|
82
|
-
const permissionContext = context.permissionManager.createContext(ASK_USER_QUESTION_TOOL_NAME, context.permissionMode || "default", context.canUseToolCallback, { questions });
|
|
96
|
+
const permissionContext = context.permissionManager.createContext(ASK_USER_QUESTION_TOOL_NAME, context.permissionMode || "default", context.canUseToolCallback, { questions, answers: existingAnswers, metadata });
|
|
83
97
|
permissionContext.hidePersistentOption = true; // Always hide persistent option for questions
|
|
84
98
|
const decision = await context.permissionManager.checkPermission(permissionContext);
|
|
85
99
|
if (decision.behavior === "deny") {
|
package/dist/tools/bashTool.d.ts
CHANGED
|
@@ -3,12 +3,4 @@ import type { ToolPlugin } from "./types.js";
|
|
|
3
3
|
* Bash command execution tool - supports both foreground and background execution
|
|
4
4
|
*/
|
|
5
5
|
export declare const bashTool: ToolPlugin;
|
|
6
|
-
/**
|
|
7
|
-
* BashOutput tool - retrieves output from background bash shells
|
|
8
|
-
*/
|
|
9
|
-
export declare const bashOutputTool: ToolPlugin;
|
|
10
|
-
/**
|
|
11
|
-
* KillBash tool - kills a running background bash shell
|
|
12
|
-
*/
|
|
13
|
-
export declare const killBashTool: ToolPlugin;
|
|
14
6
|
//# sourceMappingURL=bashTool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bashTool.d.ts","sourceRoot":"","sources":["../../src/tools/bashTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"bashTool.d.ts","sourceRoot":"","sources":["../../src/tools/bashTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AActE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,UA6WtB,CAAC"}
|
package/dist/tools/bashTool.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawn } from "child_process";
|
|
2
2
|
import { logger } from "../utils/globalLogger.js";
|
|
3
3
|
import { stripAnsiColors } from "../utils/stringUtils.js";
|
|
4
|
-
import { BASH_TOOL_NAME,
|
|
4
|
+
import { BASH_TOOL_NAME, TASK_OUTPUT_TOOL_NAME, GLOB_TOOL_NAME, GREP_TOOL_NAME, READ_TOOL_NAME, EDIT_TOOL_NAME, WRITE_TOOL_NAME, } from "../constants/tools.js";
|
|
5
5
|
const MAX_OUTPUT_LENGTH = 30000;
|
|
6
6
|
const BASH_DEFAULT_TIMEOUT_MS = 120000;
|
|
7
7
|
/**
|
|
@@ -76,13 +76,16 @@ Usage notes:
|
|
|
76
76
|
},
|
|
77
77
|
run_in_background: {
|
|
78
78
|
type: "boolean",
|
|
79
|
-
description: `Set to true to run this command in the background. Use ${
|
|
79
|
+
description: `Set to true to run this command in the background. Use ${TASK_OUTPUT_TOOL_NAME} to read the output later.`,
|
|
80
80
|
},
|
|
81
81
|
},
|
|
82
82
|
required: ["command"],
|
|
83
83
|
},
|
|
84
84
|
},
|
|
85
85
|
},
|
|
86
|
+
prompt: () => `
|
|
87
|
+
- Reserve bash tools exclusively for actual system commands and terminal operations that require shell execution. NEVER use bash echo or other command-line tools to communicate thoughts, explanations, or instructions to the user. Output all communication directly in your response text instead.
|
|
88
|
+
- When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run "git status" and "git diff", send a single message with two tool calls in parallel.`,
|
|
86
89
|
execute: async (args, context) => {
|
|
87
90
|
const command = args.command;
|
|
88
91
|
const runInBackground = args.run_in_background;
|
|
@@ -135,19 +138,19 @@ Usage notes:
|
|
|
135
138
|
}
|
|
136
139
|
if (runInBackground) {
|
|
137
140
|
// Background execution
|
|
138
|
-
const
|
|
139
|
-
if (!
|
|
141
|
+
const backgroundTaskManager = context?.backgroundTaskManager;
|
|
142
|
+
if (!backgroundTaskManager) {
|
|
140
143
|
return {
|
|
141
144
|
success: false,
|
|
142
145
|
content: "",
|
|
143
|
-
error: "Background
|
|
146
|
+
error: "Background task manager not available",
|
|
144
147
|
};
|
|
145
148
|
}
|
|
146
|
-
const
|
|
149
|
+
const { id: taskId } = backgroundTaskManager.startShell(command, timeout);
|
|
147
150
|
return {
|
|
148
151
|
success: true,
|
|
149
|
-
content: `Command started in background with ID: ${
|
|
150
|
-
shortResult: `Background process ${
|
|
152
|
+
content: `Command started in background with ID: ${taskId}. Use TaskOutput tool with task_id="${taskId}" to monitor output.`,
|
|
153
|
+
shortResult: `Background process ${taskId} started`,
|
|
151
154
|
};
|
|
152
155
|
}
|
|
153
156
|
// Foreground execution (original behavior)
|
|
@@ -163,6 +166,33 @@ Usage notes:
|
|
|
163
166
|
let outputBuffer = "";
|
|
164
167
|
let errorBuffer = "";
|
|
165
168
|
let isAborted = false;
|
|
169
|
+
let isBackgrounded = false;
|
|
170
|
+
const foregroundTaskId = `bash_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
171
|
+
// Register as foreground task
|
|
172
|
+
if (context.foregroundTaskManager && command) {
|
|
173
|
+
context.foregroundTaskManager.registerForegroundTask({
|
|
174
|
+
id: foregroundTaskId,
|
|
175
|
+
backgroundHandler: async () => {
|
|
176
|
+
isBackgrounded = true;
|
|
177
|
+
if (timeoutHandle) {
|
|
178
|
+
clearTimeout(timeoutHandle);
|
|
179
|
+
}
|
|
180
|
+
const backgroundTaskManager = context.backgroundTaskManager;
|
|
181
|
+
if (backgroundTaskManager) {
|
|
182
|
+
const taskId = backgroundTaskManager.adoptProcess(child, command, outputBuffer, errorBuffer);
|
|
183
|
+
resolve({
|
|
184
|
+
success: true,
|
|
185
|
+
content: `Command moved to background with ID: ${taskId}.`,
|
|
186
|
+
shortResult: `Process ${taskId} backgrounded`,
|
|
187
|
+
isManuallyBackgrounded: true,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
handleAbort("Failed to background: Background task manager not available");
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
}
|
|
166
196
|
// Set up timeout
|
|
167
197
|
let timeoutHandle;
|
|
168
198
|
if (timeout && timeout > 0) {
|
|
@@ -230,17 +260,20 @@ Usage notes:
|
|
|
230
260
|
});
|
|
231
261
|
}
|
|
232
262
|
child.stdout?.on("data", (data) => {
|
|
233
|
-
if (!isAborted) {
|
|
263
|
+
if (!isAborted && !isBackgrounded) {
|
|
234
264
|
outputBuffer += stripAnsiColors(data.toString());
|
|
235
265
|
}
|
|
236
266
|
});
|
|
237
267
|
child.stderr?.on("data", (data) => {
|
|
238
|
-
if (!isAborted) {
|
|
268
|
+
if (!isAborted && !isBackgrounded) {
|
|
239
269
|
errorBuffer += stripAnsiColors(data.toString());
|
|
240
270
|
}
|
|
241
271
|
});
|
|
242
272
|
child.on("exit", (code) => {
|
|
243
|
-
if (
|
|
273
|
+
if (context.foregroundTaskManager) {
|
|
274
|
+
context.foregroundTaskManager.unregisterForegroundTask(foregroundTaskId);
|
|
275
|
+
}
|
|
276
|
+
if (!isAborted && !isBackgrounded) {
|
|
244
277
|
if (timeoutHandle) {
|
|
245
278
|
clearTimeout(timeoutHandle);
|
|
246
279
|
}
|
|
@@ -262,7 +295,10 @@ Usage notes:
|
|
|
262
295
|
}
|
|
263
296
|
});
|
|
264
297
|
child.on("error", (error) => {
|
|
265
|
-
if (
|
|
298
|
+
if (context.foregroundTaskManager) {
|
|
299
|
+
context.foregroundTaskManager.unregisterForegroundTask(foregroundTaskId);
|
|
300
|
+
}
|
|
301
|
+
if (!isAborted && !isBackgrounded) {
|
|
266
302
|
if (timeoutHandle) {
|
|
267
303
|
clearTimeout(timeoutHandle);
|
|
268
304
|
}
|
|
@@ -285,163 +321,3 @@ Usage notes:
|
|
|
285
321
|
return `${command}${runInBackground ? " (background)" : ""}`;
|
|
286
322
|
},
|
|
287
323
|
};
|
|
288
|
-
/**
|
|
289
|
-
* BashOutput tool - retrieves output from background bash shells
|
|
290
|
-
*/
|
|
291
|
-
export const bashOutputTool = {
|
|
292
|
-
name: BASH_OUTPUT_TOOL_NAME,
|
|
293
|
-
config: {
|
|
294
|
-
type: "function",
|
|
295
|
-
function: {
|
|
296
|
-
name: BASH_OUTPUT_TOOL_NAME,
|
|
297
|
-
description: "Retrieves output from a running or completed background bash shell",
|
|
298
|
-
parameters: {
|
|
299
|
-
type: "object",
|
|
300
|
-
properties: {
|
|
301
|
-
bash_id: {
|
|
302
|
-
type: "string",
|
|
303
|
-
description: "The ID of the background shell to retrieve output from",
|
|
304
|
-
},
|
|
305
|
-
filter: {
|
|
306
|
-
type: "string",
|
|
307
|
-
description: "Optional regular expression to filter the output lines. Only lines matching this regex will be included in the result. Any lines that do not match will no longer be available to read.",
|
|
308
|
-
},
|
|
309
|
-
},
|
|
310
|
-
required: ["bash_id"],
|
|
311
|
-
},
|
|
312
|
-
},
|
|
313
|
-
},
|
|
314
|
-
execute: async (args, context) => {
|
|
315
|
-
const bashId = args.bash_id;
|
|
316
|
-
const filter = args.filter;
|
|
317
|
-
if (!bashId || typeof bashId !== "string") {
|
|
318
|
-
return {
|
|
319
|
-
success: false,
|
|
320
|
-
content: "",
|
|
321
|
-
error: "bash_id parameter is required and must be a string",
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
const backgroundBashManager = context?.backgroundBashManager;
|
|
325
|
-
if (!backgroundBashManager) {
|
|
326
|
-
return {
|
|
327
|
-
success: false,
|
|
328
|
-
content: "",
|
|
329
|
-
error: "Background bash manager not available",
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
const output = backgroundBashManager.getOutput(bashId, filter);
|
|
333
|
-
if (!output) {
|
|
334
|
-
return {
|
|
335
|
-
success: false,
|
|
336
|
-
content: "",
|
|
337
|
-
error: `Background shell with ID ${bashId} not found`,
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
const shell = backgroundBashManager.getShell(bashId);
|
|
341
|
-
if (!shell) {
|
|
342
|
-
return {
|
|
343
|
-
success: false,
|
|
344
|
-
content: "",
|
|
345
|
-
error: `Background shell with ID ${bashId} not found`,
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
let content = "";
|
|
349
|
-
if (output.stdout) {
|
|
350
|
-
content += stripAnsiColors(output.stdout);
|
|
351
|
-
}
|
|
352
|
-
if (output.stderr) {
|
|
353
|
-
content += (content ? "\n" : "") + stripAnsiColors(output.stderr);
|
|
354
|
-
}
|
|
355
|
-
const finalContent = content || "No output available";
|
|
356
|
-
const processedContent = finalContent.length > MAX_OUTPUT_LENGTH
|
|
357
|
-
? finalContent.substring(0, MAX_OUTPUT_LENGTH) +
|
|
358
|
-
"\n\n... (output truncated)"
|
|
359
|
-
: finalContent;
|
|
360
|
-
return {
|
|
361
|
-
success: true,
|
|
362
|
-
content: processedContent,
|
|
363
|
-
shortResult: `${bashId}: ${output.status}${shell.exitCode !== undefined ? ` (${shell.exitCode})` : ""}`,
|
|
364
|
-
error: undefined,
|
|
365
|
-
};
|
|
366
|
-
},
|
|
367
|
-
formatCompactParams: (params) => {
|
|
368
|
-
const bashId = params.bash_id;
|
|
369
|
-
const filter = params.filter;
|
|
370
|
-
return filter ? `${bashId} filtered: ${filter}` : bashId;
|
|
371
|
-
},
|
|
372
|
-
};
|
|
373
|
-
/**
|
|
374
|
-
* KillBash tool - kills a running background bash shell
|
|
375
|
-
*/
|
|
376
|
-
export const killBashTool = {
|
|
377
|
-
name: KILL_BASH_TOOL_NAME,
|
|
378
|
-
config: {
|
|
379
|
-
type: "function",
|
|
380
|
-
function: {
|
|
381
|
-
name: KILL_BASH_TOOL_NAME,
|
|
382
|
-
description: "Kills a running background bash shell by its ID",
|
|
383
|
-
parameters: {
|
|
384
|
-
type: "object",
|
|
385
|
-
properties: {
|
|
386
|
-
shell_id: {
|
|
387
|
-
type: "string",
|
|
388
|
-
description: "The ID of the background shell to kill",
|
|
389
|
-
},
|
|
390
|
-
},
|
|
391
|
-
required: ["shell_id"],
|
|
392
|
-
},
|
|
393
|
-
},
|
|
394
|
-
},
|
|
395
|
-
execute: async (args, context) => {
|
|
396
|
-
const shellId = args.shell_id;
|
|
397
|
-
if (!shellId || typeof shellId !== "string") {
|
|
398
|
-
return {
|
|
399
|
-
success: false,
|
|
400
|
-
content: "",
|
|
401
|
-
error: "shell_id parameter is required and must be a string",
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
const backgroundBashManager = context?.backgroundBashManager;
|
|
405
|
-
if (!backgroundBashManager) {
|
|
406
|
-
return {
|
|
407
|
-
success: false,
|
|
408
|
-
content: "",
|
|
409
|
-
error: "Background bash manager not available",
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
const shell = backgroundBashManager.getShell(shellId);
|
|
413
|
-
if (!shell) {
|
|
414
|
-
return {
|
|
415
|
-
success: false,
|
|
416
|
-
content: "",
|
|
417
|
-
error: `Background shell with ID ${shellId} not found`,
|
|
418
|
-
};
|
|
419
|
-
}
|
|
420
|
-
if (shell.status !== "running") {
|
|
421
|
-
return {
|
|
422
|
-
success: false,
|
|
423
|
-
content: "",
|
|
424
|
-
error: `Background shell ${shellId} is not running (status: ${shell.status})`,
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
const killed = backgroundBashManager.killShell(shellId);
|
|
428
|
-
if (killed) {
|
|
429
|
-
return {
|
|
430
|
-
success: true,
|
|
431
|
-
content: `Background shell ${shellId} has been killed`,
|
|
432
|
-
shortResult: `Killed ${shellId}`,
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
|
-
else {
|
|
436
|
-
return {
|
|
437
|
-
success: false,
|
|
438
|
-
content: "",
|
|
439
|
-
error: `Failed to kill background shell ${shellId}`,
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
},
|
|
443
|
-
formatCompactParams: (params) => {
|
|
444
|
-
const shellId = params.shell_id;
|
|
445
|
-
return shellId;
|
|
446
|
-
},
|
|
447
|
-
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editTool.d.ts","sourceRoot":"","sources":["../../src/tools/editTool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"editTool.d.ts","sourceRoot":"","sources":["../../src/tools/editTool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAgBtE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,UAmNtB,CAAC"}
|
package/dist/tools/editTool.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFile, writeFile } from "fs/promises";
|
|
2
2
|
import { logger } from "../utils/globalLogger.js";
|
|
3
3
|
import { resolvePath, getDisplayPath } from "../utils/path.js";
|
|
4
|
-
import {
|
|
4
|
+
import { escapeRegExp, analyzeEditMismatch } from "../utils/editUtils.js";
|
|
5
5
|
import { EDIT_TOOL_NAME, READ_TOOL_NAME } from "../constants/tools.js";
|
|
6
6
|
/**
|
|
7
7
|
* Format compact parameter display
|
|
@@ -16,11 +16,12 @@ function formatCompactParams(args, context) {
|
|
|
16
16
|
export const editTool = {
|
|
17
17
|
name: EDIT_TOOL_NAME,
|
|
18
18
|
formatCompactParams,
|
|
19
|
+
prompt: () => `Performs exact string replacements in files. \n\nUsage:\n- You must use your \`${READ_TOOL_NAME}\` tool at least once in the conversation before editing. This tool will error if you attempt an edit without reading the file. \n- When editing text from read_file tool output, ensure you preserve the exact indentation (tabs/spaces) as it appears AFTER the line number prefix. The line number prefix format is: spaces + line number + tab. Everything after that tab is the actual file content to match. Never include any part of the line number prefix in the old_string or new_string.\n- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.\n- Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked.\n- The edit will FAIL if \`old_string\` is not unique in the file. Either provide a larger string with more surrounding context to make it unique or use \`replace_all\` to change every instance of \`old_string\`. \n- Use \`replace_all\` for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable for instance.`,
|
|
19
20
|
config: {
|
|
20
21
|
type: "function",
|
|
21
22
|
function: {
|
|
22
23
|
name: EDIT_TOOL_NAME,
|
|
23
|
-
description:
|
|
24
|
+
description: "A tool for editing files",
|
|
24
25
|
parameters: {
|
|
25
26
|
type: "object",
|
|
26
27
|
properties: {
|
|
@@ -95,14 +96,15 @@ export const editTool = {
|
|
|
95
96
|
error: `Failed to read file: ${readError instanceof Error ? readError.message : String(readError)}`,
|
|
96
97
|
};
|
|
97
98
|
}
|
|
98
|
-
// Check if old_string exists
|
|
99
|
-
const matchedOldString =
|
|
99
|
+
// Check if old_string exists
|
|
100
|
+
const matchedOldString = originalContent.includes(oldString)
|
|
101
|
+
? oldString
|
|
102
|
+
: null;
|
|
100
103
|
if (!matchedOldString) {
|
|
101
|
-
await saveEditErrorSnapshot(resolvedPath, oldString, originalContent, EDIT_TOOL_NAME);
|
|
102
104
|
return {
|
|
103
105
|
success: false,
|
|
104
106
|
content: "",
|
|
105
|
-
error:
|
|
107
|
+
error: analyzeEditMismatch(originalContent, oldString),
|
|
106
108
|
};
|
|
107
109
|
}
|
|
108
110
|
let newContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exitPlanMode.d.ts","sourceRoot":"","sources":["../../src/tools/exitPlanMode.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAGtE;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"exitPlanMode.d.ts","sourceRoot":"","sources":["../../src/tools/exitPlanMode.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAGtE;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,UA4G9B,CAAC"}
|
|
@@ -10,7 +10,7 @@ export const exitPlanModeTool = {
|
|
|
10
10
|
type: "function",
|
|
11
11
|
function: {
|
|
12
12
|
name: EXIT_PLAN_MODE_TOOL_NAME,
|
|
13
|
-
description: "
|
|
13
|
+
description: "Prompts the user to exit plan mode and start coding",
|
|
14
14
|
parameters: {
|
|
15
15
|
type: "object",
|
|
16
16
|
properties: {},
|
|
@@ -19,6 +19,30 @@ export const exitPlanModeTool = {
|
|
|
19
19
|
},
|
|
20
20
|
},
|
|
21
21
|
},
|
|
22
|
+
prompt: () => `Use this tool when you are in plan mode and have finished writing your plan to the plan file and are ready for user approval.
|
|
23
|
+
|
|
24
|
+
## How This Tool Works
|
|
25
|
+
- You should have already written your plan to the plan file specified in the plan mode system message
|
|
26
|
+
- This tool does NOT take the plan content as a parameter - it will read the plan from the file you wrote
|
|
27
|
+
- This tool simply signals that you're done planning and ready for the user to review and approve
|
|
28
|
+
- The user will see the contents of your plan file when they review it
|
|
29
|
+
|
|
30
|
+
## When to Use This Tool
|
|
31
|
+
IMPORTANT: Only use this tool when the task requires planning the implementation steps of a task that requires writing code. For research tasks where you're gathering information, searching files, reading files or in general trying to understand the codebase - do NOT use this tool.
|
|
32
|
+
|
|
33
|
+
## Before Using This Tool
|
|
34
|
+
Ensure your plan is complete and unambiguous:
|
|
35
|
+
- If you have unresolved questions about requirements or approach, use AskUserQuestion first (in earlier phases)
|
|
36
|
+
- Once your plan is finalized, use THIS tool to request approval
|
|
37
|
+
|
|
38
|
+
**Important:** Do NOT use AskUserQuestion to ask "Is this plan okay?" or "Should I proceed?" - that's exactly what THIS tool does. ExitPlanMode inherently requests user approval of your plan.
|
|
39
|
+
|
|
40
|
+
## Examples
|
|
41
|
+
|
|
42
|
+
1. Initial task: "Search for and understand the implementation of vim mode in the codebase" - Do not use the exit plan mode tool because you are not planning the implementation steps of a task.
|
|
43
|
+
2. Initial task: "Help me implement yank mode for vim" - Use the exit plan mode tool after you have finished planning the implementation steps of the task.
|
|
44
|
+
3. Initial task: "Add a new feature to handle user authentication" - If unsure about auth method (OAuth, JWT, etc.), use AskUserQuestion first, then use exit plan mode tool after clarifying the approach.
|
|
45
|
+
`,
|
|
22
46
|
execute: async (_args, context) => {
|
|
23
47
|
try {
|
|
24
48
|
if (!context.permissionManager) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globTool.d.ts","sourceRoot":"","sources":["../../src/tools/globTool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAKtE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"globTool.d.ts","sourceRoot":"","sources":["../../src/tools/globTool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAKtE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,UAoItB,CAAC"}
|
package/dist/tools/globTool.js
CHANGED
|
@@ -2,7 +2,7 @@ import { glob } from "glob";
|
|
|
2
2
|
import { stat } from "fs/promises";
|
|
3
3
|
import { resolvePath, getDisplayPath } from "../utils/path.js";
|
|
4
4
|
import { getGlobIgnorePatterns } from "../utils/fileFilter.js";
|
|
5
|
-
import { GLOB_TOOL_NAME
|
|
5
|
+
import { GLOB_TOOL_NAME } from "../constants/tools.js";
|
|
6
6
|
/**
|
|
7
7
|
* Glob Tool Plugin - Fast file pattern matching
|
|
8
8
|
*/
|
|
@@ -12,7 +12,7 @@ export const globTool = {
|
|
|
12
12
|
type: "function",
|
|
13
13
|
function: {
|
|
14
14
|
name: GLOB_TOOL_NAME,
|
|
15
|
-
description:
|
|
15
|
+
description: "Fast file pattern matching tool that works with any codebase size",
|
|
16
16
|
parameters: {
|
|
17
17
|
type: "object",
|
|
18
18
|
properties: {
|
|
@@ -29,6 +29,12 @@ export const globTool = {
|
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
|
+
prompt: () => `- Fast file pattern matching tool that works with any codebase size
|
|
33
|
+
- Supports glob patterns like "**/*.js" or "src/**/*.ts"
|
|
34
|
+
- Returns matching file paths sorted by modification time
|
|
35
|
+
- Use this tool when you need to find files by name patterns
|
|
36
|
+
- When you are doing an open ended search that may require multiple rounds of globbing and grepping, use the Agent tool instead
|
|
37
|
+
- You can call multiple tools in a single response. It is always better to speculatively perform multiple searches in parallel if they are potentially useful.`,
|
|
32
38
|
execute: async (args, context) => {
|
|
33
39
|
const pattern = args.pattern;
|
|
34
40
|
const searchPath = args.path;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grepTool.d.ts","sourceRoot":"","sources":["../../src/tools/grepTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAWtE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"grepTool.d.ts","sourceRoot":"","sources":["../../src/tools/grepTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAWtE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,UAuRtB,CAAC"}
|
package/dist/tools/grepTool.js
CHANGED
|
@@ -12,7 +12,7 @@ export const grepTool = {
|
|
|
12
12
|
type: "function",
|
|
13
13
|
function: {
|
|
14
14
|
name: GREP_TOOL_NAME,
|
|
15
|
-
description:
|
|
15
|
+
description: "A powerful search tool built on ripgrep",
|
|
16
16
|
parameters: {
|
|
17
17
|
type: "object",
|
|
18
18
|
properties: {
|
|
@@ -47,7 +47,7 @@ export const grepTool = {
|
|
|
47
47
|
},
|
|
48
48
|
"-n": {
|
|
49
49
|
type: "boolean",
|
|
50
|
-
description: 'Show line numbers in output (rg -n). Requires output_mode: "content", ignored otherwise.',
|
|
50
|
+
description: 'Show line numbers in output (rg -n). Requires output_mode: "content", ignored otherwise. Defaults to true.',
|
|
51
51
|
},
|
|
52
52
|
"-i": {
|
|
53
53
|
type: "boolean",
|
|
@@ -59,7 +59,7 @@ export const grepTool = {
|
|
|
59
59
|
},
|
|
60
60
|
head_limit: {
|
|
61
61
|
type: "number",
|
|
62
|
-
description: 'Limit output to first N lines/entries, equivalent to "| head -N". Works across all output modes: content (limits output lines), files_with_matches (limits file paths), count (limits count entries). Defaults to
|
|
62
|
+
description: 'Limit output to first N lines/entries, equivalent to "| head -N". Works across all output modes: content (limits output lines), files_with_matches (limits file paths), count (limits count entries). Defaults to 0 (unlimited).',
|
|
63
63
|
},
|
|
64
64
|
multiline: {
|
|
65
65
|
type: "boolean",
|
|
@@ -70,6 +70,17 @@ export const grepTool = {
|
|
|
70
70
|
},
|
|
71
71
|
},
|
|
72
72
|
},
|
|
73
|
+
prompt: () => `A powerful search tool built on ripgrep
|
|
74
|
+
|
|
75
|
+
Usage:
|
|
76
|
+
- ALWAYS use ${GREP_TOOL_NAME} for search tasks. NEVER invoke \`grep\` or \`rg\` as a ${BASH_TOOL_NAME} command. The ${GREP_TOOL_NAME} tool has been optimized for correct permissions and access.
|
|
77
|
+
- Supports full regex syntax (e.g., "log.*Error", "function\\s+\\w+")
|
|
78
|
+
- Filter files with glob parameter (e.g., "*.js", "**/*.tsx") or type parameter (e.g., "js", "py", "rust")
|
|
79
|
+
- Output modes: "content" shows matching lines, "files_with_matches" shows only file paths (default), "count" shows match counts
|
|
80
|
+
- Use ${TASK_TOOL_NAME} tool for open-ended searches requiring multiple rounds
|
|
81
|
+
- Pattern syntax: Uses ripgrep (not grep) - literal braces need escaping (use \`interface\\{\\}\` to find \`interface{}\` in Go code)
|
|
82
|
+
- Multiline matching: By default patterns match within single lines only. For cross-line patterns like \`struct \\{[\\s\\S]*?field\`, use \`multiline: true\`
|
|
83
|
+
`,
|
|
73
84
|
execute: async (args, context) => {
|
|
74
85
|
const pattern = args.pattern;
|
|
75
86
|
const searchPath = args.path;
|
|
@@ -78,7 +89,7 @@ export const grepTool = {
|
|
|
78
89
|
const contextBefore = args["-B"];
|
|
79
90
|
const contextAfter = args["-A"];
|
|
80
91
|
const contextAround = args["-C"];
|
|
81
|
-
const showLineNumbers = args["-n"];
|
|
92
|
+
const showLineNumbers = args["-n"] !== false;
|
|
82
93
|
const caseInsensitive = args["-i"];
|
|
83
94
|
const fileType = args.type;
|
|
84
95
|
const headLimit = args.head_limit;
|
|
@@ -181,8 +192,8 @@ export const grepTool = {
|
|
|
181
192
|
let finalOutput = output;
|
|
182
193
|
let lines = output.split("\n");
|
|
183
194
|
// Set default head_limit if not specified to prevent excessive token usage
|
|
184
|
-
const effectiveHeadLimit = headLimit ||
|
|
185
|
-
if (lines.length > effectiveHeadLimit) {
|
|
195
|
+
const effectiveHeadLimit = headLimit || 0;
|
|
196
|
+
if (effectiveHeadLimit > 0 && lines.length > effectiveHeadLimit) {
|
|
186
197
|
lines = lines.slice(0, effectiveHeadLimit);
|
|
187
198
|
finalOutput = lines.join("\n");
|
|
188
199
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lsTool.d.ts","sourceRoot":"","sources":["../../src/tools/lsTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAQtE;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"lsTool.d.ts","sourceRoot":"","sources":["../../src/tools/lsTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAQtE;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,UAqMpB,CAAC"}
|