grok-agent 0.5.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/CHANGELOG.md +113 -0
- package/LICENSE +190 -0
- package/README.md +449 -0
- package/bin/grok-cli.js +26 -0
- package/dist/agent.d.ts +4 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +898 -0
- package/dist/agent.js.map +1 -0
- package/dist/approvals.d.ts +4 -0
- package/dist/approvals.d.ts.map +1 -0
- package/dist/approvals.js +90 -0
- package/dist/approvals.js.map +1 -0
- package/dist/batch-api.d.ts +11 -0
- package/dist/batch-api.d.ts.map +1 -0
- package/dist/batch-api.js +101 -0
- package/dist/batch-api.js.map +1 -0
- package/dist/cli-errors.d.ts +6 -0
- package/dist/cli-errors.d.ts.map +1 -0
- package/dist/cli-errors.js +80 -0
- package/dist/cli-errors.js.map +1 -0
- package/dist/client.d.ts +6 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +41 -0
- package/dist/client.js.map +1 -0
- package/dist/collections-api.d.ts +11 -0
- package/dist/collections-api.d.ts.map +1 -0
- package/dist/collections-api.js +144 -0
- package/dist/collections-api.js.map +1 -0
- package/dist/compaction.d.ts +11 -0
- package/dist/compaction.d.ts.map +1 -0
- package/dist/compaction.js +94 -0
- package/dist/compaction.js.map +1 -0
- package/dist/config.d.ts +12 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +142 -0
- package/dist/config.js.map +1 -0
- package/dist/diff.d.ts +5 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +80 -0
- package/dist/diff.js.map +1 -0
- package/dist/hooks.d.ts +11 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +30 -0
- package/dist/hooks.js.map +1 -0
- package/dist/image.d.ts +8 -0
- package/dist/image.d.ts.map +1 -0
- package/dist/image.js +58 -0
- package/dist/image.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1264 -0
- package/dist/index.js.map +1 -0
- package/dist/json-output.d.ts +27 -0
- package/dist/json-output.d.ts.map +1 -0
- package/dist/json-output.js +62 -0
- package/dist/json-output.js.map +1 -0
- package/dist/notifications.d.ts +6 -0
- package/dist/notifications.d.ts.map +1 -0
- package/dist/notifications.js +25 -0
- package/dist/notifications.js.map +1 -0
- package/dist/project-context.d.ts +6 -0
- package/dist/project-context.d.ts.map +1 -0
- package/dist/project-context.js +34 -0
- package/dist/project-context.js.map +1 -0
- package/dist/response-utils.d.ts +10 -0
- package/dist/response-utils.d.ts.map +1 -0
- package/dist/response-utils.js +123 -0
- package/dist/response-utils.js.map +1 -0
- package/dist/server-tools.d.ts +7 -0
- package/dist/server-tools.d.ts.map +1 -0
- package/dist/server-tools.js +205 -0
- package/dist/server-tools.js.map +1 -0
- package/dist/session.d.ts +46 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +305 -0
- package/dist/session.js.map +1 -0
- package/dist/stream.d.ts +22 -0
- package/dist/stream.d.ts.map +1 -0
- package/dist/stream.js +102 -0
- package/dist/stream.js.map +1 -0
- package/dist/system-prompt.d.ts +3 -0
- package/dist/system-prompt.d.ts.map +1 -0
- package/dist/system-prompt.js +64 -0
- package/dist/system-prompt.js.map +1 -0
- package/dist/tools/bash.d.ts +8 -0
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +49 -0
- package/dist/tools/bash.js.map +1 -0
- package/dist/tools/definitions.d.ts +3 -0
- package/dist/tools/definitions.d.ts.map +1 -0
- package/dist/tools/definitions.js +190 -0
- package/dist/tools/definitions.js.map +1 -0
- package/dist/tools/edit-file.d.ts +10 -0
- package/dist/tools/edit-file.d.ts.map +1 -0
- package/dist/tools/edit-file.js +73 -0
- package/dist/tools/edit-file.js.map +1 -0
- package/dist/tools/glob.d.ts +7 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +44 -0
- package/dist/tools/glob.js.map +1 -0
- package/dist/tools/grep.d.ts +10 -0
- package/dist/tools/grep.d.ts.map +1 -0
- package/dist/tools/grep.js +102 -0
- package/dist/tools/grep.js.map +1 -0
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +41 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-dir.d.ts +7 -0
- package/dist/tools/list-dir.d.ts.map +1 -0
- package/dist/tools/list-dir.js +68 -0
- package/dist/tools/list-dir.js.map +1 -0
- package/dist/tools/policy.d.ts +4 -0
- package/dist/tools/policy.d.ts.map +1 -0
- package/dist/tools/policy.js +36 -0
- package/dist/tools/policy.js.map +1 -0
- package/dist/tools/read-file.d.ts +8 -0
- package/dist/tools/read-file.d.ts.map +1 -0
- package/dist/tools/read-file.js +45 -0
- package/dist/tools/read-file.js.map +1 -0
- package/dist/tools/write-file.d.ts +7 -0
- package/dist/tools/write-file.d.ts.map +1 -0
- package/dist/tools/write-file.js +35 -0
- package/dist/tools/write-file.js.map +1 -0
- package/dist/truncation.d.ts +13 -0
- package/dist/truncation.d.ts.map +1 -0
- package/dist/truncation.js +55 -0
- package/dist/truncation.js.map +1 -0
- package/dist/types.d.ts +159 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/usage.d.ts +17 -0
- package/dist/usage.d.ts.map +1 -0
- package/dist/usage.js +80 -0
- package/dist/usage.js.map +1 -0
- package/dist/voice-api.d.ts +16 -0
- package/dist/voice-api.d.ts.map +1 -0
- package/dist/voice-api.js +84 -0
- package/dist/voice-api.js.map +1 -0
- package/package.json +64 -0
package/dist/stream.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
export function createAccumulator() {
|
|
3
|
+
return {
|
|
4
|
+
content: "",
|
|
5
|
+
reasoningContent: "",
|
|
6
|
+
toolCalls: [],
|
|
7
|
+
finishReason: null,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export function processChunk(acc, chunk, options) {
|
|
11
|
+
const choice = chunk.choices?.[0];
|
|
12
|
+
if (!choice)
|
|
13
|
+
return;
|
|
14
|
+
const delta = choice.delta;
|
|
15
|
+
if (!delta)
|
|
16
|
+
return;
|
|
17
|
+
// Handle reasoning content (thinking tokens)
|
|
18
|
+
if (delta.reasoning_content) {
|
|
19
|
+
acc.reasoningContent += delta.reasoning_content;
|
|
20
|
+
if (options.showReasoning) {
|
|
21
|
+
process.stderr.write(chalk.dim(delta.reasoning_content));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// Handle regular content
|
|
25
|
+
if (delta.content) {
|
|
26
|
+
acc.content += delta.content;
|
|
27
|
+
if (options.showOutput) {
|
|
28
|
+
process.stdout.write(delta.content);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// Handle tool calls (accumulated across chunks)
|
|
32
|
+
if (delta.tool_calls) {
|
|
33
|
+
for (const tc of delta.tool_calls) {
|
|
34
|
+
const idx = tc.index;
|
|
35
|
+
if (!acc.toolCalls[idx]) {
|
|
36
|
+
acc.toolCalls[idx] = {
|
|
37
|
+
index: idx,
|
|
38
|
+
id: tc.id || "",
|
|
39
|
+
function: { name: "", arguments: "" },
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (tc.id)
|
|
43
|
+
acc.toolCalls[idx].id = tc.id;
|
|
44
|
+
if (tc.function?.name)
|
|
45
|
+
acc.toolCalls[idx].function.name += tc.function.name;
|
|
46
|
+
if (tc.function?.arguments)
|
|
47
|
+
acc.toolCalls[idx].function.arguments += tc.function.arguments;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Capture finish reason
|
|
51
|
+
if (choice.finish_reason) {
|
|
52
|
+
acc.finishReason = choice.finish_reason;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function formatToolCall(name, args, verbose) {
|
|
56
|
+
if (!verbose) {
|
|
57
|
+
return chalk.cyan(` ► ${name}`);
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const parsed = JSON.parse(args);
|
|
61
|
+
const summary = formatToolArgs(name, parsed);
|
|
62
|
+
return chalk.cyan(` ► ${name}`) + chalk.dim(` ${summary}`);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return chalk.cyan(` ► ${name}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function formatToolArgs(name, args) {
|
|
69
|
+
switch (name) {
|
|
70
|
+
case "bash":
|
|
71
|
+
return `$ ${truncate(args.command, 80)}`;
|
|
72
|
+
case "read_file":
|
|
73
|
+
return args.file_path;
|
|
74
|
+
case "write_file":
|
|
75
|
+
return args.file_path;
|
|
76
|
+
case "edit_file":
|
|
77
|
+
return args.file_path;
|
|
78
|
+
case "glob":
|
|
79
|
+
return args.pattern;
|
|
80
|
+
case "grep":
|
|
81
|
+
return `/${args.pattern}/ ${args.include || ""}`.trim();
|
|
82
|
+
case "list_directory":
|
|
83
|
+
return args.path || ".";
|
|
84
|
+
default:
|
|
85
|
+
return JSON.stringify(args).slice(0, 80);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function truncate(s, max) {
|
|
89
|
+
if (s.length <= max)
|
|
90
|
+
return s;
|
|
91
|
+
return s.slice(0, max - 3) + "...";
|
|
92
|
+
}
|
|
93
|
+
export function formatToolResult(output, isError) {
|
|
94
|
+
const lines = output.split("\n");
|
|
95
|
+
if (lines.length <= 5) {
|
|
96
|
+
const prefix = isError ? chalk.red(" ✗ ") : chalk.green(" ✓ ");
|
|
97
|
+
return prefix + chalk.dim(lines.join("\n "));
|
|
98
|
+
}
|
|
99
|
+
const prefix = isError ? chalk.red(" ✗ ") : chalk.green(" ✓ ");
|
|
100
|
+
return prefix + chalk.dim(`${lines[0]}\n ... (${lines.length} lines)`);
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.js","s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AAC,EAAE,CAAC;QACtB,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACrE,OAAO,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACpD,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACrE,OAAO,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,gBAAgB,KAAK,CAAC,MAAM,SAAS,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../src/system-prompt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAI7C,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,CAgE1E"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import { loadProjectContext } from "./project-context.js";
|
|
3
|
+
import { describeServerTools } from "./server-tools.js";
|
|
4
|
+
export function buildSystemPrompt(cwd, config) {
|
|
5
|
+
const platform = os.platform();
|
|
6
|
+
const shell = platform === "win32" ? "powershell" : (process.env.SHELL || "/bin/bash");
|
|
7
|
+
let prompt = `You are Grok CLI, an agentic coding assistant powered by xAI.
|
|
8
|
+
You help users with software engineering tasks: fixing bugs, adding features, refactoring, explaining code, running commands, and more.
|
|
9
|
+
|
|
10
|
+
# Environment
|
|
11
|
+
- Working directory: ${cwd}
|
|
12
|
+
- Platform: ${platform} (${os.arch()})
|
|
13
|
+
- Shell: ${shell}
|
|
14
|
+
- Node.js: ${process.version}
|
|
15
|
+
|
|
16
|
+
# Tools
|
|
17
|
+
You have local tools that execute on the user's machine:
|
|
18
|
+
- **bash**: Run shell commands. Use for git, npm, building, testing, etc.
|
|
19
|
+
- **read_file**: Read file contents with optional line range.
|
|
20
|
+
- **write_file**: Create or overwrite files.
|
|
21
|
+
- **edit_file**: Make targeted find-and-replace edits. Always read a file before editing.
|
|
22
|
+
- **glob**: Find files matching a glob pattern.
|
|
23
|
+
- **grep**: Search file contents with regex.
|
|
24
|
+
- **list_directory**: List files and directories.`;
|
|
25
|
+
if (config) {
|
|
26
|
+
const caps = [...describeServerTools(config.serverTools)];
|
|
27
|
+
if (config.mcpServers.length > 0) {
|
|
28
|
+
caps.push(`remote MCP tools (${config.mcpServers.map(s => s.label).join(", ")})`);
|
|
29
|
+
}
|
|
30
|
+
if (caps.length > 0) {
|
|
31
|
+
prompt += `\n\nServer-side tools (auto-executed by xAI): ${caps.join(", ")}`;
|
|
32
|
+
}
|
|
33
|
+
if (config.sandboxMode !== "danger-full-access") {
|
|
34
|
+
prompt += `\n\nLocal tool sandbox mode: ${config.sandboxMode}. Prefer structured file tools when shell access is restricted.`;
|
|
35
|
+
}
|
|
36
|
+
if (config.imageInputs.length > 0) {
|
|
37
|
+
prompt += `\n\nThe user has attached ${config.imageInputs.length} image(s) for analysis.`;
|
|
38
|
+
}
|
|
39
|
+
if (config.fileAttachments.length > 0) {
|
|
40
|
+
prompt += `\n\nThe user has attached ${config.fileAttachments.length} file(s) for reference.`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
prompt += `
|
|
44
|
+
|
|
45
|
+
# Guidelines
|
|
46
|
+
1. Read before edit. Understand existing code first.
|
|
47
|
+
2. Minimal changes. Don't refactor surrounding code.
|
|
48
|
+
3. Verify your work. Run tests/linters when available.
|
|
49
|
+
4. Be direct. Lead with actions, not preamble.
|
|
50
|
+
5. Safe by default. Don't run destructive commands without asking.
|
|
51
|
+
6. No hallucination. Use glob/list_directory to explore unknown projects.
|
|
52
|
+
7. Edit tool: exact string matching. Preserve indentation.
|
|
53
|
+
|
|
54
|
+
# Security
|
|
55
|
+
- Never commit or display secrets/API keys/passwords.
|
|
56
|
+
- Don't run destructive commands without explicit user approval.`;
|
|
57
|
+
// Load project context (GROK.md, .grokrc)
|
|
58
|
+
const projectCtx = loadProjectContext(cwd);
|
|
59
|
+
if (projectCtx) {
|
|
60
|
+
prompt += `\n\n${projectCtx}`;
|
|
61
|
+
}
|
|
62
|
+
return prompt;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=system-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../src/system-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,UAAU,iBAAiB,CAAC,GAAW,EAAE,MAAmB;IAChE,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,WAAW,CAAC,CAAC;IAEvF,IAAI,MAAM,GAAG;;;;uBAIQ,GAAG;cACZ,QAAQ,KAAK,EAAE,CAAC,IAAI,EAAE;WACzB,KAAK;aACH,OAAO,CAAC,OAAO;;;;;;;;;;kDAUsB,CAAC;IAEjD,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,IAAI,GAAa,CAAC,GAAG,mBAAmB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;QACpE,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,IAAI,CAAC,qBAAqB,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACpF,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,MAAM,IAAI,iDAAiD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/E,CAAC;QACD,IAAI,MAAM,CAAC,WAAW,KAAK,oBAAoB,EAAE,CAAC;YAChD,MAAM,IAAI,gCAAgC,MAAM,CAAC,WAAW,iEAAiE,CAAC;QAChI,CAAC;QACD,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,6BAA6B,MAAM,CAAC,WAAW,CAAC,MAAM,yBAAyB,CAAC;QAC5F,CAAC;QACD,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,6BAA6B,MAAM,CAAC,eAAe,CAAC,MAAM,yBAAyB,CAAC;QAChG,CAAC;IACH,CAAC;IAED,MAAM,IAAI;;;;;;;;;;;;;iEAaqD,CAAC;IAEhE,0CAA0C;IAC1C,MAAM,UAAU,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,IAAI,OAAO,UAAU,EAAE,CAAC;IAChC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ToolResult } from "../types.js";
|
|
2
|
+
import type { ToolExecutionOptions } from "./index.js";
|
|
3
|
+
export declare function executeBash(args: {
|
|
4
|
+
command: string;
|
|
5
|
+
timeout?: number;
|
|
6
|
+
cwd?: string;
|
|
7
|
+
}, projectCwd: string, options: ToolExecutionOptions): Promise<ToolResult>;
|
|
8
|
+
//# sourceMappingURL=bash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../src/tools/bash.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAOvD,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC,CA+CzE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
2
|
+
import { ensureCommandAllowed } from "./policy.js";
|
|
3
|
+
const MAX_TIMEOUT = 300_000; // 5 minutes
|
|
4
|
+
const DEFAULT_TIMEOUT = 30_000; // 30 seconds
|
|
5
|
+
const MAX_OUTPUT = 100_000; // 100KB output limit
|
|
6
|
+
export async function executeBash(args, projectCwd, options) {
|
|
7
|
+
const timeout = Math.min(args.timeout || DEFAULT_TIMEOUT, MAX_TIMEOUT);
|
|
8
|
+
const cwd = args.cwd || projectCwd;
|
|
9
|
+
const sandboxError = ensureCommandAllowed(options.sandboxMode || "danger-full-access");
|
|
10
|
+
if (sandboxError)
|
|
11
|
+
return sandboxError;
|
|
12
|
+
try {
|
|
13
|
+
const output = execSync(args.command, {
|
|
14
|
+
cwd,
|
|
15
|
+
timeout,
|
|
16
|
+
encoding: "utf-8",
|
|
17
|
+
maxBuffer: 10 * 1024 * 1024, // 10MB buffer
|
|
18
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
19
|
+
shell: process.platform === "win32" ? "cmd.exe" : "/bin/bash",
|
|
20
|
+
});
|
|
21
|
+
const trimmed = output.length > MAX_OUTPUT
|
|
22
|
+
? output.slice(0, MAX_OUTPUT) + `\n... (output truncated, ${output.length} bytes total)`
|
|
23
|
+
: output;
|
|
24
|
+
return { output: trimmed || "(no output)" };
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
const stderr = err.stderr?.toString() || "";
|
|
28
|
+
const stdout = err.stdout?.toString() || "";
|
|
29
|
+
const exitCode = err.status ?? "unknown";
|
|
30
|
+
// Some constrained environments report shell execution as EPERM even when
|
|
31
|
+
// the command itself succeeded and returned exit code 0.
|
|
32
|
+
if (exitCode === 0) {
|
|
33
|
+
const successOutput = [stdout, stderr].filter(Boolean).join("\n");
|
|
34
|
+
const trimmed = successOutput.length > MAX_OUTPUT
|
|
35
|
+
? successOutput.slice(0, MAX_OUTPUT) + `\n... (output truncated, ${successOutput.length} bytes total)`
|
|
36
|
+
: successOutput;
|
|
37
|
+
return { output: trimmed || "(no output)" };
|
|
38
|
+
}
|
|
39
|
+
const combined = [stdout, stderr].filter(Boolean).join("\n");
|
|
40
|
+
const msg = combined.length > MAX_OUTPUT
|
|
41
|
+
? combined.slice(0, MAX_OUTPUT) + `\n... (output truncated)`
|
|
42
|
+
: combined;
|
|
43
|
+
return {
|
|
44
|
+
output: `Command failed (exit code ${exitCode}):\n${msg || err.message}`,
|
|
45
|
+
error: true,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=bash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash.js","sourceRoot":"","sources":["../../src/tools/bash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,YAAY;AACzC,MAAM,eAAe,GAAG,MAAM,CAAC,CAA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Definitions = [
|
|
2
|
+
{
|
|
3
|
+
type: "function",
|
|
4
|
+
function: {
|
|
5
|
+
name: "bash",
|
|
6
|
+
description: "Execute a shell command and return its stdout/stderr. " +
|
|
7
|
+
"Use for running builds, tests, git commands, package managers, and system utilities. " +
|
|
8
|
+
"Commands run in the user's working directory. " +
|
|
9
|
+
"Avoid interactive commands (vim, less, etc). Prefer non-interactive flags.",
|
|
10
|
+
parameters: {
|
|
11
|
+
type: "object",
|
|
12
|
+
properties: {
|
|
13
|
+
command: {
|
|
14
|
+
type: "string",
|
|
15
|
+
description: "The shell command to execute",
|
|
16
|
+
},
|
|
17
|
+
timeout: {
|
|
18
|
+
type: "number",
|
|
19
|
+
description: "Timeout in milliseconds (default: 30000, max: 300000)",
|
|
20
|
+
},
|
|
21
|
+
cwd: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Working directory for the command. Defaults to the project root.",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
required: ["command"],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: "function",
|
|
32
|
+
function: {
|
|
33
|
+
name: "read_file",
|
|
34
|
+
description: "Read the contents of a file. Returns the file content with line numbers. " +
|
|
35
|
+
"Use offset and limit to read specific portions of large files.",
|
|
36
|
+
parameters: {
|
|
37
|
+
type: "object",
|
|
38
|
+
properties: {
|
|
39
|
+
file_path: {
|
|
40
|
+
type: "string",
|
|
41
|
+
description: "Absolute or relative path to the file",
|
|
42
|
+
},
|
|
43
|
+
offset: {
|
|
44
|
+
type: "number",
|
|
45
|
+
description: "Line number to start reading from (1-based). Default: 1",
|
|
46
|
+
},
|
|
47
|
+
limit: {
|
|
48
|
+
type: "number",
|
|
49
|
+
description: "Maximum number of lines to read. Default: 2000",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
required: ["file_path"],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: "function",
|
|
58
|
+
function: {
|
|
59
|
+
name: "write_file",
|
|
60
|
+
description: "Create or overwrite a file with the given content. " +
|
|
61
|
+
"Creates parent directories if they don't exist. " +
|
|
62
|
+
"Use edit_file for targeted modifications to existing files instead.",
|
|
63
|
+
parameters: {
|
|
64
|
+
type: "object",
|
|
65
|
+
properties: {
|
|
66
|
+
file_path: {
|
|
67
|
+
type: "string",
|
|
68
|
+
description: "Absolute or relative path for the file",
|
|
69
|
+
},
|
|
70
|
+
content: {
|
|
71
|
+
type: "string",
|
|
72
|
+
description: "The full content to write to the file",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
required: ["file_path", "content"],
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
type: "function",
|
|
81
|
+
function: {
|
|
82
|
+
name: "edit_file",
|
|
83
|
+
description: "Make a targeted edit to a file by replacing an exact string match. " +
|
|
84
|
+
"You MUST read the file first before editing. " +
|
|
85
|
+
"The old_string must match exactly (including indentation/whitespace). " +
|
|
86
|
+
"Provide enough surrounding context in old_string to ensure a unique match. " +
|
|
87
|
+
"If the match is not unique, the edit will fail.",
|
|
88
|
+
parameters: {
|
|
89
|
+
type: "object",
|
|
90
|
+
properties: {
|
|
91
|
+
file_path: {
|
|
92
|
+
type: "string",
|
|
93
|
+
description: "Path to the file to edit",
|
|
94
|
+
},
|
|
95
|
+
old_string: {
|
|
96
|
+
type: "string",
|
|
97
|
+
description: "The exact string to find and replace. Must be unique in the file.",
|
|
98
|
+
},
|
|
99
|
+
new_string: {
|
|
100
|
+
type: "string",
|
|
101
|
+
description: "The string to replace old_string with",
|
|
102
|
+
},
|
|
103
|
+
replace_all: {
|
|
104
|
+
type: "boolean",
|
|
105
|
+
description: "If true, replace all occurrences. Default: false (replace first match only)",
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
required: ["file_path", "old_string", "new_string"],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: "function",
|
|
114
|
+
function: {
|
|
115
|
+
name: "glob",
|
|
116
|
+
description: "Find files matching a glob pattern. Returns matching file paths. " +
|
|
117
|
+
'Supports patterns like "**/*.ts", "src/**/*.test.js", "*.json".',
|
|
118
|
+
parameters: {
|
|
119
|
+
type: "object",
|
|
120
|
+
properties: {
|
|
121
|
+
pattern: {
|
|
122
|
+
type: "string",
|
|
123
|
+
description: 'Glob pattern to match (e.g., "**/*.ts", "src/**/*.js")',
|
|
124
|
+
},
|
|
125
|
+
cwd: {
|
|
126
|
+
type: "string",
|
|
127
|
+
description: "Directory to search from. Defaults to project root.",
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
required: ["pattern"],
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
type: "function",
|
|
136
|
+
function: {
|
|
137
|
+
name: "grep",
|
|
138
|
+
description: "Search file contents using a regex pattern. Returns matching lines with file paths and line numbers. " +
|
|
139
|
+
"Use the include glob to filter which files to search.",
|
|
140
|
+
parameters: {
|
|
141
|
+
type: "object",
|
|
142
|
+
properties: {
|
|
143
|
+
pattern: {
|
|
144
|
+
type: "string",
|
|
145
|
+
description: "Regex pattern to search for",
|
|
146
|
+
},
|
|
147
|
+
path: {
|
|
148
|
+
type: "string",
|
|
149
|
+
description: "File or directory to search in. Defaults to project root.",
|
|
150
|
+
},
|
|
151
|
+
include: {
|
|
152
|
+
type: "string",
|
|
153
|
+
description: 'Glob pattern to filter files (e.g., "*.ts", "*.py")',
|
|
154
|
+
},
|
|
155
|
+
ignore_case: {
|
|
156
|
+
type: "boolean",
|
|
157
|
+
description: "Case insensitive search. Default: false",
|
|
158
|
+
},
|
|
159
|
+
max_results: {
|
|
160
|
+
type: "number",
|
|
161
|
+
description: "Maximum number of matching lines to return. Default: 100",
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
required: ["pattern"],
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
type: "function",
|
|
170
|
+
function: {
|
|
171
|
+
name: "list_directory",
|
|
172
|
+
description: "List files and directories at a given path. Returns names with type indicators (/ for directories). " +
|
|
173
|
+
"Use this to explore the project structure.",
|
|
174
|
+
parameters: {
|
|
175
|
+
type: "object",
|
|
176
|
+
properties: {
|
|
177
|
+
path: {
|
|
178
|
+
type: "string",
|
|
179
|
+
description: "Directory path to list. Defaults to project root.",
|
|
180
|
+
},
|
|
181
|
+
recursive: {
|
|
182
|
+
type: "boolean",
|
|
183
|
+
description: "If true, list recursively up to 3 levels deep. Default: false",
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
];
|
|
190
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/tools/definitions.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAc;IACxC;QACE,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE;YACR,IAAI,EAAE,MAAM;YACZ,WAAW,EACT,wDAAwD;gBACxD,uFAAuF;gBACvF,gDAAgD;gBAChD,4EAA4E;YAC9E,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,OAAO,EAAE;wBACP,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,8BAA8B;qBAC5C;oBACD,OAAO,EAAE;wBACP,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,uDAAuD;qBACrE;oBACD,GAAG,EAAE;wBACH,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,kEAAkE;qBAChF;iBACF;gBACD,QAAQ,EAAE,CAAC,SAAS,CAAC;aACtB;SACF;KACF;IACD;QACE,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE;YACR,IAAI,EAAE,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AQ,EAAE;YACR,IAAI,EAAE,gBAAgB;YACtB,WAAW,EACT,sGAAsG;gBACtG,4CAA4C;YAC9C,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,IAAI,EAAE;wBACJ,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,mDAAmD;qBACjE;oBACD,SAAS,EAAE;wBACT,IAAI,EAAE,SAAS;wBACf,WAAW,EAAE,+DAA+D;qBAC7E;iBACF;aACF;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ToolResult } from "../types.js";
|
|
2
|
+
import type { ToolExecutionOptions } from "./index.js";
|
|
3
|
+
export declare function setShowDiffs(enabled: boolean): void;
|
|
4
|
+
export declare function executeEditFile(args: {
|
|
5
|
+
file_path: string;
|
|
6
|
+
old_string: string;
|
|
7
|
+
new_string: string;
|
|
8
|
+
replace_all?: boolean;
|
|
9
|
+
}, projectCwd: string, options: ToolExecutionOptions): Promise<ToolResult>;
|
|
10
|
+
//# sourceMappingURL=edit-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-file.d.ts","sourceRoot":"","sources":["../../src/tools/edit-file.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAIvD,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAgC;AAEpF,wBAAsB,eAAe,CAAC,IAAI,EAAE;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC,CA0EzE"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { showDiff } from "../diff.js";
|
|
4
|
+
import { ensurePathAllowed } from "./policy.js";
|
|
5
|
+
let showDiffsEnabled = true;
|
|
6
|
+
export function setShowDiffs(enabled) { showDiffsEnabled = enabled; }
|
|
7
|
+
export async function executeEditFile(args, projectCwd, options) {
|
|
8
|
+
const filePath = path.resolve(projectCwd, args.file_path);
|
|
9
|
+
const sandboxError = ensurePathAllowed(filePath, projectCwd, options.sandboxMode || "danger-full-access", "write");
|
|
10
|
+
if (sandboxError)
|
|
11
|
+
return sandboxError;
|
|
12
|
+
try {
|
|
13
|
+
if (!fs.existsSync(filePath)) {
|
|
14
|
+
return { output: `File not found: ${filePath}`, error: true };
|
|
15
|
+
}
|
|
16
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
17
|
+
if (args.old_string === args.new_string) {
|
|
18
|
+
return { output: "old_string and new_string are identical, no changes made.", error: true };
|
|
19
|
+
}
|
|
20
|
+
if (!content.includes(args.old_string)) {
|
|
21
|
+
// Help debug: show similar lines
|
|
22
|
+
const searchLines = args.old_string.split("\n");
|
|
23
|
+
const firstLine = searchLines[0].trim();
|
|
24
|
+
const contentLines = content.split("\n");
|
|
25
|
+
const similar = contentLines
|
|
26
|
+
.map((line, i) => ({ line: line.trim(), num: i + 1 }))
|
|
27
|
+
.filter(({ line }) => line.includes(firstLine.slice(0, 30)))
|
|
28
|
+
.slice(0, 3);
|
|
29
|
+
let msg = `old_string not found in ${args.file_path}.`;
|
|
30
|
+
if (similar.length > 0) {
|
|
31
|
+
msg += "\n\nSimilar lines found:\n" +
|
|
32
|
+
similar.map(s => ` Line ${s.num}: ${s.line}`).join("\n");
|
|
33
|
+
msg += "\n\nCheck indentation and whitespace — they must match exactly.";
|
|
34
|
+
}
|
|
35
|
+
return { output: msg, error: true };
|
|
36
|
+
}
|
|
37
|
+
if (!args.replace_all) {
|
|
38
|
+
// Check uniqueness
|
|
39
|
+
const count = content.split(args.old_string).length - 1;
|
|
40
|
+
if (count > 1) {
|
|
41
|
+
return {
|
|
42
|
+
output: `old_string matches ${count} locations in ${args.file_path}. Provide more context to match uniquely, or set replace_all: true.`,
|
|
43
|
+
error: true,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
let updated;
|
|
48
|
+
if (args.replace_all) {
|
|
49
|
+
updated = content.split(args.old_string).join(args.new_string);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const idx = content.indexOf(args.old_string);
|
|
53
|
+
updated = content.slice(0, idx) + args.new_string + content.slice(idx + args.old_string.length);
|
|
54
|
+
}
|
|
55
|
+
fs.writeFileSync(filePath, updated, "utf-8");
|
|
56
|
+
// Show diff
|
|
57
|
+
if (showDiffsEnabled) {
|
|
58
|
+
showDiff(args.file_path, content, updated);
|
|
59
|
+
}
|
|
60
|
+
const oldLines = args.old_string.split("\n").length;
|
|
61
|
+
const newLines = args.new_string.split("\n").length;
|
|
62
|
+
const diffSummary = oldLines === newLines
|
|
63
|
+
? `${oldLines} line(s) modified`
|
|
64
|
+
: `${oldLines} line(s) → ${newLines} line(s)`;
|
|
65
|
+
return {
|
|
66
|
+
output: `Edited ${args.file_path}: ${diffSummary}${args.replace_all ? " (all occurrences)" : ""}`,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
return { output: `Error editing file: ${err.message}`, error: true };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=edit-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-file.js","sourceRoot":"","sources":["../../src/tools/edit-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,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AC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ToolResult } from "../types.js";
|
|
2
|
+
import type { ToolExecutionOptions } from "./index.js";
|
|
3
|
+
export declare function executeGlob(args: {
|
|
4
|
+
pattern: string;
|
|
5
|
+
cwd?: string;
|
|
6
|
+
}, projectCwd: string, options: ToolExecutionOptions): Promise<ToolResult>;
|
|
7
|
+
//# sourceMappingURL=glob.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../src/tools/glob.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAKvD,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC,CAyCzE"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import fg from "fast-glob";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { ensurePathAllowed } from "./policy.js";
|
|
4
|
+
const MAX_RESULTS = 500;
|
|
5
|
+
export async function executeGlob(args, projectCwd, options) {
|
|
6
|
+
const cwd = args.cwd ? path.resolve(projectCwd, args.cwd) : projectCwd;
|
|
7
|
+
const sandboxError = ensurePathAllowed(cwd, projectCwd, options.sandboxMode || "danger-full-access", "read");
|
|
8
|
+
if (sandboxError)
|
|
9
|
+
return sandboxError;
|
|
10
|
+
try {
|
|
11
|
+
const files = await fg(args.pattern, {
|
|
12
|
+
cwd,
|
|
13
|
+
dot: false,
|
|
14
|
+
ignore: [
|
|
15
|
+
"**/node_modules/**",
|
|
16
|
+
"**/.git/**",
|
|
17
|
+
"**/dist/**",
|
|
18
|
+
"**/build/**",
|
|
19
|
+
"**/.next/**",
|
|
20
|
+
"**/coverage/**",
|
|
21
|
+
"**/__pycache__/**",
|
|
22
|
+
"**/.venv/**",
|
|
23
|
+
"**/target/**",
|
|
24
|
+
],
|
|
25
|
+
onlyFiles: false,
|
|
26
|
+
markDirectories: true,
|
|
27
|
+
});
|
|
28
|
+
if (files.length === 0) {
|
|
29
|
+
return { output: `No files matching pattern: ${args.pattern}` };
|
|
30
|
+
}
|
|
31
|
+
const sorted = files.sort();
|
|
32
|
+
const limited = sorted.slice(0, MAX_RESULTS);
|
|
33
|
+
let output = limited.join("\n");
|
|
34
|
+
if (sorted.length > MAX_RESULTS) {
|
|
35
|
+
output += `\n... and ${sorted.length - MAX_RESULTS} more files`;
|
|
36
|
+
}
|
|
37
|
+
output = `Found ${sorted.length} match(es) for "${args.pattern}":\n${output}`;
|
|
38
|
+
return { output };
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
return { output: `Glob error: ${err.message}`, error: true };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=glob.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../../src/tools/glob.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3B,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAGjC,EAAE,UAAkB,EAAE,OAA6B;IAClD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IACvE,MAAM,YAAY,GAAG,iBAAiB,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,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ToolResult } from "../types.js";
|
|
2
|
+
import type { ToolExecutionOptions } from "./index.js";
|
|
3
|
+
export declare function executeGrep(args: {
|
|
4
|
+
pattern: string;
|
|
5
|
+
path?: string;
|
|
6
|
+
include?: string;
|
|
7
|
+
ignore_case?: boolean;
|
|
8
|
+
max_results?: number;
|
|
9
|
+
}, projectCwd: string, options: ToolExecutionOptions): Promise<ToolResult>;
|
|
10
|
+
//# sourceMappingURL=grep.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../src/tools/grep.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAMvD,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC,CA+EzE"}
|