llm-agent-cli 2.0.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/dist/agent.d.ts +112 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +730 -0
- package/dist/agent.js.map +1 -0
- package/dist/audit.d.ts +24 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +94 -0
- package/dist/audit.js.map +1 -0
- package/dist/auth.d.ts +36 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +236 -0
- package/dist/auth.js.map +1 -0
- package/dist/config.d.ts +35 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +92 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +48 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +94 -0
- package/dist/context.js.map +1 -0
- package/dist/diff.d.ts +27 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +174 -0
- package/dist/diff.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +905 -0
- package/dist/index.js.map +1 -0
- package/dist/input.d.ts +13 -0
- package/dist/input.d.ts.map +1 -0
- package/dist/input.js +88 -0
- package/dist/input.js.map +1 -0
- package/dist/memory.d.ts +32 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +103 -0
- package/dist/memory.js.map +1 -0
- package/dist/preprocessor.d.ts +12 -0
- package/dist/preprocessor.d.ts.map +1 -0
- package/dist/preprocessor.js +138 -0
- package/dist/preprocessor.js.map +1 -0
- package/dist/project.d.ts +10 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +145 -0
- package/dist/project.js.map +1 -0
- package/dist/renderer.d.ts +2 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/renderer.js +31 -0
- package/dist/renderer.js.map +1 -0
- package/dist/session.d.ts +36 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +78 -0
- package/dist/session.js.map +1 -0
- package/dist/tools/filesystem.d.ts +138 -0
- package/dist/tools/filesystem.d.ts.map +1 -0
- package/dist/tools/filesystem.js +539 -0
- package/dist/tools/filesystem.js.map +1 -0
- package/dist/tools/git.d.ts +60 -0
- package/dist/tools/git.d.ts.map +1 -0
- package/dist/tools/git.js +188 -0
- package/dist/tools/git.js.map +1 -0
- package/dist/tools/index.d.ts +386 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +142 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/linter.d.ts +44 -0
- package/dist/tools/linter.d.ts.map +1 -0
- package/dist/tools/linter.js +426 -0
- package/dist/tools/linter.js.map +1 -0
- package/dist/tools/network.d.ts +17 -0
- package/dist/tools/network.d.ts.map +1 -0
- package/dist/tools/network.js +121 -0
- package/dist/tools/network.js.map +1 -0
- package/dist/tools/search.d.ts +33 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +263 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/security.d.ts +18 -0
- package/dist/tools/security.d.ts.map +1 -0
- package/dist/tools/security.js +242 -0
- package/dist/tools/security.js.map +1 -0
- package/dist/tools/shell.d.ts +14 -0
- package/dist/tools/shell.d.ts.map +1 -0
- package/dist/tools/shell.js +68 -0
- package/dist/tools/shell.js.map +1 -0
- package/dist/tools/types.d.ts +5 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { exec } from "child_process";
|
|
2
|
+
import { promisify } from "util";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { resolveProtectedPath, getRuntimeConfig } from "./security.js";
|
|
5
|
+
const execAsync = promisify(exec);
|
|
6
|
+
const GIT_TIMEOUT_MS = 15_000;
|
|
7
|
+
const MAX_OUTPUT_CHARS = 50_000;
|
|
8
|
+
async function runGit(args, cwd) {
|
|
9
|
+
try {
|
|
10
|
+
const { stdout, stderr } = await execAsync(`git ${args.join(" ")}`, {
|
|
11
|
+
cwd,
|
|
12
|
+
timeout: GIT_TIMEOUT_MS,
|
|
13
|
+
maxBuffer: 1024 * 1024 * 4, // 4 MB
|
|
14
|
+
});
|
|
15
|
+
const out = (stdout + (stderr ? `\n[stderr]: ${stderr}` : "")).trim();
|
|
16
|
+
return out.length > MAX_OUTPUT_CHARS
|
|
17
|
+
? out.slice(0, MAX_OUTPUT_CHARS) + "\n[output truncated]"
|
|
18
|
+
: out;
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
22
|
+
return `git error: ${msg}`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function gitRoot() {
|
|
26
|
+
return getRuntimeConfig().workspaceRoot;
|
|
27
|
+
}
|
|
28
|
+
// ─── git_status ────────────────────────────────────────────────────────────
|
|
29
|
+
export const GitStatusSchema = z.object({
|
|
30
|
+
path: z
|
|
31
|
+
.string()
|
|
32
|
+
.optional()
|
|
33
|
+
.describe("Optional sub-path to limit status output to"),
|
|
34
|
+
});
|
|
35
|
+
export async function git_status(args) {
|
|
36
|
+
const parsed = GitStatusSchema.parse(args);
|
|
37
|
+
const cwd = gitRoot();
|
|
38
|
+
const pathArg = parsed.path ? [parsed.path] : [];
|
|
39
|
+
return runGit(["status", "--short", "--branch", ...pathArg], cwd);
|
|
40
|
+
}
|
|
41
|
+
// ─── git_diff ───────────────────────────────────────────────────────────────
|
|
42
|
+
export const GitDiffSchema = z.object({
|
|
43
|
+
path: z
|
|
44
|
+
.string()
|
|
45
|
+
.optional()
|
|
46
|
+
.describe("Optional file path to diff"),
|
|
47
|
+
staged: z
|
|
48
|
+
.boolean()
|
|
49
|
+
.default(false)
|
|
50
|
+
.describe("Show staged (index) diff instead of working-tree diff"),
|
|
51
|
+
base: z
|
|
52
|
+
.string()
|
|
53
|
+
.optional()
|
|
54
|
+
.describe("Base commit/branch to diff against (e.g. HEAD~1, main)"),
|
|
55
|
+
});
|
|
56
|
+
export async function git_diff(args) {
|
|
57
|
+
const parsed = GitDiffSchema.parse(args);
|
|
58
|
+
const cwd = gitRoot();
|
|
59
|
+
const extra = [];
|
|
60
|
+
if (parsed.staged)
|
|
61
|
+
extra.push("--staged");
|
|
62
|
+
if (parsed.base)
|
|
63
|
+
extra.push(parsed.base);
|
|
64
|
+
if (parsed.path) {
|
|
65
|
+
// Validate path is within workspace
|
|
66
|
+
try {
|
|
67
|
+
await resolveProtectedPath(parsed.path);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return `Error: path is outside workspace root`;
|
|
71
|
+
}
|
|
72
|
+
extra.push("--", parsed.path);
|
|
73
|
+
}
|
|
74
|
+
return runGit(["diff", "--stat", ...extra], cwd).then(async (stat) => {
|
|
75
|
+
const full = await runGit(["diff", ...extra], cwd);
|
|
76
|
+
if (!stat && !full)
|
|
77
|
+
return "(no changes)";
|
|
78
|
+
return stat ? `${stat}\n\n${full}` : full;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
// ─── git_log ────────────────────────────────────────────────────────────────
|
|
82
|
+
export const GitLogSchema = z.object({
|
|
83
|
+
path: z
|
|
84
|
+
.string()
|
|
85
|
+
.optional()
|
|
86
|
+
.describe("Optional file path to limit log to"),
|
|
87
|
+
n: z
|
|
88
|
+
.number()
|
|
89
|
+
.int()
|
|
90
|
+
.min(1)
|
|
91
|
+
.max(100)
|
|
92
|
+
.default(20)
|
|
93
|
+
.describe("Number of commits to show (default 20, max 100)"),
|
|
94
|
+
oneline: z
|
|
95
|
+
.boolean()
|
|
96
|
+
.default(true)
|
|
97
|
+
.describe("Show one line per commit (default true)"),
|
|
98
|
+
});
|
|
99
|
+
export async function git_log(args) {
|
|
100
|
+
const parsed = GitLogSchema.parse(args);
|
|
101
|
+
const cwd = gitRoot();
|
|
102
|
+
const fmt = parsed.oneline
|
|
103
|
+
? [`--pretty=format:'%h %ad %s (%an)'`, "--date=short"]
|
|
104
|
+
: ["--pretty=medium"];
|
|
105
|
+
const pathArg = parsed.path ? ["--", parsed.path] : [];
|
|
106
|
+
return runGit(["log", `-${parsed.n}`, ...fmt, ...pathArg], cwd);
|
|
107
|
+
}
|
|
108
|
+
// ─── git_blame ──────────────────────────────────────────────────────────────
|
|
109
|
+
export const GitBlameSchema = z.object({
|
|
110
|
+
absolute_path: z
|
|
111
|
+
.string()
|
|
112
|
+
.describe("Absolute path to the file to blame"),
|
|
113
|
+
start_line: z
|
|
114
|
+
.number()
|
|
115
|
+
.int()
|
|
116
|
+
.positive()
|
|
117
|
+
.optional()
|
|
118
|
+
.describe("Optional 1-based starting line"),
|
|
119
|
+
end_line: z
|
|
120
|
+
.number()
|
|
121
|
+
.int()
|
|
122
|
+
.positive()
|
|
123
|
+
.optional()
|
|
124
|
+
.describe("Optional 1-based ending line"),
|
|
125
|
+
});
|
|
126
|
+
export async function git_blame(args) {
|
|
127
|
+
const parsed = GitBlameSchema.parse(args);
|
|
128
|
+
const absPath = await resolveProtectedPath(parsed.absolute_path);
|
|
129
|
+
const cwd = gitRoot();
|
|
130
|
+
const lineArg = [];
|
|
131
|
+
if (parsed.start_line !== undefined && parsed.end_line !== undefined) {
|
|
132
|
+
lineArg.push(`-L${parsed.start_line},${parsed.end_line}`);
|
|
133
|
+
}
|
|
134
|
+
else if (parsed.start_line !== undefined) {
|
|
135
|
+
lineArg.push(`-L${parsed.start_line},${parsed.start_line + 49}`);
|
|
136
|
+
}
|
|
137
|
+
return runGit(["blame", "--date=short", "-p", ...lineArg, "--", absPath], cwd).then((raw) => {
|
|
138
|
+
// Convert porcelain blame to readable format
|
|
139
|
+
const lines = raw.split("\n");
|
|
140
|
+
const result = [];
|
|
141
|
+
let i = 0;
|
|
142
|
+
while (i < lines.length) {
|
|
143
|
+
const header = lines[i] ?? "";
|
|
144
|
+
if (/^[0-9a-f]{40}/.test(header)) {
|
|
145
|
+
const parts = header.split(" ");
|
|
146
|
+
const hash = (parts[0] ?? "").slice(0, 7);
|
|
147
|
+
const lineNo = parts[2] ?? "?";
|
|
148
|
+
// Scan forward for "summary" and "author"
|
|
149
|
+
let author = "";
|
|
150
|
+
let summary = "";
|
|
151
|
+
let content = "";
|
|
152
|
+
let j = i + 1;
|
|
153
|
+
while (j < lines.length && !/^[0-9a-f]{40}/.test(lines[j] ?? "")) {
|
|
154
|
+
const l = lines[j] ?? "";
|
|
155
|
+
if (l.startsWith("author "))
|
|
156
|
+
author = l.slice(7);
|
|
157
|
+
if (l.startsWith("summary "))
|
|
158
|
+
summary = l.slice(8);
|
|
159
|
+
if (l.startsWith("\t"))
|
|
160
|
+
content = l.slice(1);
|
|
161
|
+
j++;
|
|
162
|
+
}
|
|
163
|
+
result.push(`${lineNo.padStart(5)} ${hash} ${author.padEnd(20).slice(0, 20)} ${summary.slice(0, 50).padEnd(50)} | ${content}`);
|
|
164
|
+
i = j;
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
i++;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return result.length > 0 ? result.join("\n") : raw;
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
// ─── git_stash ──────────────────────────────────────────────────────────────
|
|
174
|
+
export const GitStashSchema = z.object({
|
|
175
|
+
action: z
|
|
176
|
+
.enum(["list", "show"])
|
|
177
|
+
.default("list")
|
|
178
|
+
.describe("'list' to show all stashes, 'show' to show top stash diff"),
|
|
179
|
+
});
|
|
180
|
+
export async function git_stash(args) {
|
|
181
|
+
const parsed = GitStashSchema.parse(args);
|
|
182
|
+
const cwd = gitRoot();
|
|
183
|
+
if (parsed.action === "list") {
|
|
184
|
+
return runGit(["stash", "list"], cwd);
|
|
185
|
+
}
|
|
186
|
+
return runGit(["stash", "show", "-p", "stash@{0}"], cwd);
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sour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AAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC;AAED,+EAA+E;AAE/E,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,MAAM,EAAE,CAAC;SACN,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;SACtB,OAAO,CAAC,MAAM,CAAC;SACf,QAAQ,CAAC,2DAA2D,CAAC;CACzE,CAAC,CAAC;AAEH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,IAAoC;IAEpC,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;IACtB,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,MAAM,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,EAAE,GAAG,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type PermissionMode, type ToolRuntimeConfig } from "./security.js";
|
|
3
|
+
import type { ToolExecutionContext, ToolHandler } from "./types.js";
|
|
4
|
+
declare const TOOL_REGISTRY: {
|
|
5
|
+
readonly read_file: {
|
|
6
|
+
readonly description: "Read a local file. Supports optional line-range reads via start_line/end_line.";
|
|
7
|
+
readonly schema: z.ZodEffects<z.ZodObject<{
|
|
8
|
+
absolute_path: z.ZodString;
|
|
9
|
+
start_line: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
end_line: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
absolute_path: string;
|
|
13
|
+
start_line?: number | undefined;
|
|
14
|
+
end_line?: number | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
absolute_path: string;
|
|
17
|
+
start_line?: number | undefined;
|
|
18
|
+
end_line?: number | undefined;
|
|
19
|
+
}>, {
|
|
20
|
+
absolute_path: string;
|
|
21
|
+
start_line?: number | undefined;
|
|
22
|
+
end_line?: number | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
absolute_path: string;
|
|
25
|
+
start_line?: number | undefined;
|
|
26
|
+
end_line?: number | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
29
|
+
};
|
|
30
|
+
readonly write_to_file: {
|
|
31
|
+
readonly description: "Write content to a local file. In standard mode this requires confirmation.";
|
|
32
|
+
readonly schema: z.ZodObject<{
|
|
33
|
+
absolute_path: z.ZodString;
|
|
34
|
+
content: z.ZodString;
|
|
35
|
+
overwrite: z.ZodDefault<z.ZodBoolean>;
|
|
36
|
+
}, "strip", z.ZodTypeAny, {
|
|
37
|
+
absolute_path: string;
|
|
38
|
+
content: string;
|
|
39
|
+
overwrite: boolean;
|
|
40
|
+
}, {
|
|
41
|
+
absolute_path: string;
|
|
42
|
+
content: string;
|
|
43
|
+
overwrite?: boolean | undefined;
|
|
44
|
+
}>;
|
|
45
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
46
|
+
};
|
|
47
|
+
readonly apply_diff: {
|
|
48
|
+
readonly description: "Safely replace one exact text block in an existing file. Fails if match count is not exactly one.";
|
|
49
|
+
readonly schema: z.ZodObject<{
|
|
50
|
+
absolute_path: z.ZodString;
|
|
51
|
+
search_string: z.ZodString;
|
|
52
|
+
replace_string: z.ZodString;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
absolute_path: string;
|
|
55
|
+
search_string: string;
|
|
56
|
+
replace_string: string;
|
|
57
|
+
}, {
|
|
58
|
+
absolute_path: string;
|
|
59
|
+
search_string: string;
|
|
60
|
+
replace_string: string;
|
|
61
|
+
}>;
|
|
62
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
63
|
+
};
|
|
64
|
+
readonly list_directory: {
|
|
65
|
+
readonly description: "List files and folders in a directory.";
|
|
66
|
+
readonly schema: z.ZodObject<{
|
|
67
|
+
path: z.ZodString;
|
|
68
|
+
}, "strip", z.ZodTypeAny, {
|
|
69
|
+
path: string;
|
|
70
|
+
}, {
|
|
71
|
+
path: string;
|
|
72
|
+
}>;
|
|
73
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
74
|
+
};
|
|
75
|
+
readonly create_directory: {
|
|
76
|
+
readonly description: "Create a directory (and optionally parent directories).";
|
|
77
|
+
readonly schema: z.ZodObject<{
|
|
78
|
+
path: z.ZodString;
|
|
79
|
+
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
path: string;
|
|
82
|
+
recursive: boolean;
|
|
83
|
+
}, {
|
|
84
|
+
path: string;
|
|
85
|
+
recursive?: boolean | undefined;
|
|
86
|
+
}>;
|
|
87
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
88
|
+
};
|
|
89
|
+
readonly delete_file: {
|
|
90
|
+
readonly description: "Delete a file (or directory with recursive=true). In standard mode this requires confirmation.";
|
|
91
|
+
readonly schema: z.ZodObject<{
|
|
92
|
+
path: z.ZodString;
|
|
93
|
+
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
94
|
+
}, "strip", z.ZodTypeAny, {
|
|
95
|
+
path: string;
|
|
96
|
+
recursive: boolean;
|
|
97
|
+
}, {
|
|
98
|
+
path: string;
|
|
99
|
+
recursive?: boolean | undefined;
|
|
100
|
+
}>;
|
|
101
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
102
|
+
};
|
|
103
|
+
readonly move_file: {
|
|
104
|
+
readonly description: "Move or rename a file/directory path. In standard mode this requires confirmation.";
|
|
105
|
+
readonly schema: z.ZodObject<{
|
|
106
|
+
source_path: z.ZodString;
|
|
107
|
+
destination_path: z.ZodString;
|
|
108
|
+
}, "strip", z.ZodTypeAny, {
|
|
109
|
+
source_path: string;
|
|
110
|
+
destination_path: string;
|
|
111
|
+
}, {
|
|
112
|
+
source_path: string;
|
|
113
|
+
destination_path: string;
|
|
114
|
+
}>;
|
|
115
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
116
|
+
};
|
|
117
|
+
readonly get_file_info: {
|
|
118
|
+
readonly description: "Get file metadata (type, size, timestamps, permissions) for a path.";
|
|
119
|
+
readonly schema: z.ZodObject<{
|
|
120
|
+
path: z.ZodString;
|
|
121
|
+
}, "strip", z.ZodTypeAny, {
|
|
122
|
+
path: string;
|
|
123
|
+
}, {
|
|
124
|
+
path: string;
|
|
125
|
+
}>;
|
|
126
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
127
|
+
};
|
|
128
|
+
readonly search_files: {
|
|
129
|
+
readonly description: "Search file contents using ripgrep (or fallback scan). Returns file:line:content matches.";
|
|
130
|
+
readonly schema: z.ZodObject<{
|
|
131
|
+
pattern: z.ZodString;
|
|
132
|
+
directory: z.ZodOptional<z.ZodString>;
|
|
133
|
+
case_sensitive: z.ZodDefault<z.ZodBoolean>;
|
|
134
|
+
max_results: z.ZodDefault<z.ZodNumber>;
|
|
135
|
+
}, "strip", z.ZodTypeAny, {
|
|
136
|
+
pattern: string;
|
|
137
|
+
case_sensitive: boolean;
|
|
138
|
+
max_results: number;
|
|
139
|
+
directory?: string | undefined;
|
|
140
|
+
}, {
|
|
141
|
+
pattern: string;
|
|
142
|
+
directory?: string | undefined;
|
|
143
|
+
case_sensitive?: boolean | undefined;
|
|
144
|
+
max_results?: number | undefined;
|
|
145
|
+
}>;
|
|
146
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
147
|
+
};
|
|
148
|
+
readonly find_files: {
|
|
149
|
+
readonly description: "Find files by glob pattern, for example **/*.ts. Returns absolute paths.";
|
|
150
|
+
readonly schema: z.ZodObject<{
|
|
151
|
+
glob_pattern: z.ZodString;
|
|
152
|
+
directory: z.ZodOptional<z.ZodString>;
|
|
153
|
+
max_results: z.ZodDefault<z.ZodNumber>;
|
|
154
|
+
}, "strip", z.ZodTypeAny, {
|
|
155
|
+
max_results: number;
|
|
156
|
+
glob_pattern: string;
|
|
157
|
+
directory?: string | undefined;
|
|
158
|
+
}, {
|
|
159
|
+
glob_pattern: string;
|
|
160
|
+
directory?: string | undefined;
|
|
161
|
+
max_results?: number | undefined;
|
|
162
|
+
}>;
|
|
163
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
164
|
+
};
|
|
165
|
+
readonly show_diff: {
|
|
166
|
+
readonly description: "Show a colored unified diff between a file on disk and proposed new content. Use before write_to_file to preview changes.";
|
|
167
|
+
readonly schema: z.ZodObject<{
|
|
168
|
+
absolute_path: z.ZodString;
|
|
169
|
+
new_content: z.ZodString;
|
|
170
|
+
context_lines: z.ZodDefault<z.ZodNumber>;
|
|
171
|
+
}, "strip", z.ZodTypeAny, {
|
|
172
|
+
absolute_path: string;
|
|
173
|
+
new_content: string;
|
|
174
|
+
context_lines: number;
|
|
175
|
+
}, {
|
|
176
|
+
absolute_path: string;
|
|
177
|
+
new_content: string;
|
|
178
|
+
context_lines?: number | undefined;
|
|
179
|
+
}>;
|
|
180
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
181
|
+
};
|
|
182
|
+
readonly search_and_replace_all: {
|
|
183
|
+
readonly description: "Search for a pattern across all files in a directory and replace it. Use dry_run=true (default) to preview before writing.";
|
|
184
|
+
readonly schema: z.ZodObject<{
|
|
185
|
+
directory: z.ZodString;
|
|
186
|
+
search_pattern: z.ZodString;
|
|
187
|
+
replace_string: z.ZodString;
|
|
188
|
+
glob: z.ZodOptional<z.ZodString>;
|
|
189
|
+
regex: z.ZodDefault<z.ZodBoolean>;
|
|
190
|
+
dry_run: z.ZodDefault<z.ZodBoolean>;
|
|
191
|
+
}, "strip", z.ZodTypeAny, {
|
|
192
|
+
replace_string: string;
|
|
193
|
+
directory: string;
|
|
194
|
+
search_pattern: string;
|
|
195
|
+
regex: boolean;
|
|
196
|
+
dry_run: boolean;
|
|
197
|
+
glob?: string | undefined;
|
|
198
|
+
}, {
|
|
199
|
+
replace_string: string;
|
|
200
|
+
directory: string;
|
|
201
|
+
search_pattern: string;
|
|
202
|
+
glob?: string | undefined;
|
|
203
|
+
regex?: boolean | undefined;
|
|
204
|
+
dry_run?: boolean | undefined;
|
|
205
|
+
}>;
|
|
206
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
207
|
+
};
|
|
208
|
+
readonly fetch_url: {
|
|
209
|
+
readonly description: "Fetch an HTTP/HTTPS URL and return the response text (with optional truncation).";
|
|
210
|
+
readonly schema: z.ZodObject<{
|
|
211
|
+
url: z.ZodString;
|
|
212
|
+
max_bytes: z.ZodDefault<z.ZodNumber>;
|
|
213
|
+
timeout_ms: z.ZodDefault<z.ZodNumber>;
|
|
214
|
+
}, "strip", z.ZodTypeAny, {
|
|
215
|
+
url: string;
|
|
216
|
+
max_bytes: number;
|
|
217
|
+
timeout_ms: number;
|
|
218
|
+
}, {
|
|
219
|
+
url: string;
|
|
220
|
+
max_bytes?: number | undefined;
|
|
221
|
+
timeout_ms?: number | undefined;
|
|
222
|
+
}>;
|
|
223
|
+
readonly handler: (args: Record<string, unknown>, context: ToolExecutionContext) => Promise<string>;
|
|
224
|
+
};
|
|
225
|
+
readonly run_bash_command: {
|
|
226
|
+
readonly description: "Run a shell command in the current working directory. Dangerous patterns are blocked.";
|
|
227
|
+
readonly schema: z.ZodObject<{
|
|
228
|
+
command: z.ZodString;
|
|
229
|
+
timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
230
|
+
}, "strip", z.ZodTypeAny, {
|
|
231
|
+
command: string;
|
|
232
|
+
timeout_ms?: number | undefined;
|
|
233
|
+
}, {
|
|
234
|
+
command: string;
|
|
235
|
+
timeout_ms?: number | undefined;
|
|
236
|
+
}>;
|
|
237
|
+
readonly handler: (args: Record<string, unknown>, context: ToolExecutionContext) => Promise<string>;
|
|
238
|
+
};
|
|
239
|
+
readonly git_status: {
|
|
240
|
+
readonly description: "Show git working tree status (short format with branch info).";
|
|
241
|
+
readonly schema: z.ZodObject<{
|
|
242
|
+
path: z.ZodOptional<z.ZodString>;
|
|
243
|
+
}, "strip", z.ZodTypeAny, {
|
|
244
|
+
path?: string | undefined;
|
|
245
|
+
}, {
|
|
246
|
+
path?: string | undefined;
|
|
247
|
+
}>;
|
|
248
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
249
|
+
};
|
|
250
|
+
readonly git_diff: {
|
|
251
|
+
readonly description: "Show git diff for the working tree, staged changes, or against a base commit/branch.";
|
|
252
|
+
readonly schema: z.ZodObject<{
|
|
253
|
+
path: z.ZodOptional<z.ZodString>;
|
|
254
|
+
staged: z.ZodDefault<z.ZodBoolean>;
|
|
255
|
+
base: z.ZodOptional<z.ZodString>;
|
|
256
|
+
}, "strip", z.ZodTypeAny, {
|
|
257
|
+
staged: boolean;
|
|
258
|
+
path?: string | undefined;
|
|
259
|
+
base?: string | undefined;
|
|
260
|
+
}, {
|
|
261
|
+
path?: string | undefined;
|
|
262
|
+
staged?: boolean | undefined;
|
|
263
|
+
base?: string | undefined;
|
|
264
|
+
}>;
|
|
265
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
266
|
+
};
|
|
267
|
+
readonly git_log: {
|
|
268
|
+
readonly description: "Show recent git commit history, optionally filtered to a file.";
|
|
269
|
+
readonly schema: z.ZodObject<{
|
|
270
|
+
path: z.ZodOptional<z.ZodString>;
|
|
271
|
+
n: z.ZodDefault<z.ZodNumber>;
|
|
272
|
+
oneline: z.ZodDefault<z.ZodBoolean>;
|
|
273
|
+
}, "strip", z.ZodTypeAny, {
|
|
274
|
+
n: number;
|
|
275
|
+
oneline: boolean;
|
|
276
|
+
path?: string | undefined;
|
|
277
|
+
}, {
|
|
278
|
+
path?: string | undefined;
|
|
279
|
+
n?: number | undefined;
|
|
280
|
+
oneline?: boolean | undefined;
|
|
281
|
+
}>;
|
|
282
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
283
|
+
};
|
|
284
|
+
readonly git_blame: {
|
|
285
|
+
readonly description: "Show who last modified each line of a file (git blame).";
|
|
286
|
+
readonly schema: z.ZodObject<{
|
|
287
|
+
absolute_path: z.ZodString;
|
|
288
|
+
start_line: z.ZodOptional<z.ZodNumber>;
|
|
289
|
+
end_line: z.ZodOptional<z.ZodNumber>;
|
|
290
|
+
}, "strip", z.ZodTypeAny, {
|
|
291
|
+
absolute_path: string;
|
|
292
|
+
start_line?: number | undefined;
|
|
293
|
+
end_line?: number | undefined;
|
|
294
|
+
}, {
|
|
295
|
+
absolute_path: string;
|
|
296
|
+
start_line?: number | undefined;
|
|
297
|
+
end_line?: number | undefined;
|
|
298
|
+
}>;
|
|
299
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
300
|
+
};
|
|
301
|
+
readonly git_stash: {
|
|
302
|
+
readonly description: "List all stashes or show the diff of the top stash.";
|
|
303
|
+
readonly schema: z.ZodObject<{
|
|
304
|
+
action: z.ZodDefault<z.ZodEnum<["list", "show"]>>;
|
|
305
|
+
}, "strip", z.ZodTypeAny, {
|
|
306
|
+
action: "list" | "show";
|
|
307
|
+
}, {
|
|
308
|
+
action?: "list" | "show" | undefined;
|
|
309
|
+
}>;
|
|
310
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
311
|
+
};
|
|
312
|
+
readonly run_linter: {
|
|
313
|
+
readonly description: "Run a linter (eslint, tsc, ruff, mypy, clippy, golangci-lint — auto-detected from project files).";
|
|
314
|
+
readonly schema: z.ZodObject<{
|
|
315
|
+
path: z.ZodOptional<z.ZodString>;
|
|
316
|
+
linter: z.ZodDefault<z.ZodEnum<["auto", "eslint", "tsc", "ruff", "mypy", "clippy", "golangci", "biome"]>>;
|
|
317
|
+
fix: z.ZodDefault<z.ZodBoolean>;
|
|
318
|
+
}, "strip", z.ZodTypeAny, {
|
|
319
|
+
linter: "eslint" | "tsc" | "ruff" | "mypy" | "clippy" | "golangci" | "biome" | "auto";
|
|
320
|
+
fix: boolean;
|
|
321
|
+
path?: string | undefined;
|
|
322
|
+
}, {
|
|
323
|
+
path?: string | undefined;
|
|
324
|
+
linter?: "eslint" | "tsc" | "ruff" | "mypy" | "clippy" | "golangci" | "biome" | "auto" | undefined;
|
|
325
|
+
fix?: boolean | undefined;
|
|
326
|
+
}>;
|
|
327
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
328
|
+
};
|
|
329
|
+
readonly run_tests: {
|
|
330
|
+
readonly description: "Run the project's test suite (vitest, jest, pytest, cargo test, go test — auto-detected).";
|
|
331
|
+
readonly schema: z.ZodObject<{
|
|
332
|
+
path: z.ZodOptional<z.ZodString>;
|
|
333
|
+
runner: z.ZodDefault<z.ZodEnum<["auto", "vitest", "jest", "npm_test", "pytest", "cargo_test", "go_test"]>>;
|
|
334
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
335
|
+
bail: z.ZodDefault<z.ZodBoolean>;
|
|
336
|
+
}, "strip", z.ZodTypeAny, {
|
|
337
|
+
runner: "npm_test" | "vitest" | "jest" | "pytest" | "cargo_test" | "go_test" | "auto";
|
|
338
|
+
bail: boolean;
|
|
339
|
+
path?: string | undefined;
|
|
340
|
+
pattern?: string | undefined;
|
|
341
|
+
}, {
|
|
342
|
+
path?: string | undefined;
|
|
343
|
+
pattern?: string | undefined;
|
|
344
|
+
runner?: "npm_test" | "vitest" | "jest" | "pytest" | "cargo_test" | "go_test" | "auto" | undefined;
|
|
345
|
+
bail?: boolean | undefined;
|
|
346
|
+
}>;
|
|
347
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
348
|
+
};
|
|
349
|
+
readonly security_scan: {
|
|
350
|
+
readonly description: "Scan source files for security issues: hardcoded secrets, XSS, SQL injection, eval usage, weak crypto, etc.";
|
|
351
|
+
readonly schema: z.ZodObject<{
|
|
352
|
+
path: z.ZodString;
|
|
353
|
+
include_low_severity: z.ZodDefault<z.ZodBoolean>;
|
|
354
|
+
}, "strip", z.ZodTypeAny, {
|
|
355
|
+
path: string;
|
|
356
|
+
include_low_severity: boolean;
|
|
357
|
+
}, {
|
|
358
|
+
path: string;
|
|
359
|
+
include_low_severity?: boolean | undefined;
|
|
360
|
+
}>;
|
|
361
|
+
readonly handler: (args: Record<string, unknown>) => Promise<string>;
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
export type ToolName = keyof typeof TOOL_REGISTRY;
|
|
365
|
+
export declare const TOOL_DEFINITIONS: {
|
|
366
|
+
type: "function";
|
|
367
|
+
function: {
|
|
368
|
+
name: string;
|
|
369
|
+
description: "Read a local file. Supports optional line-range reads via start_line/end_line." | "Write content to a local file. In standard mode this requires confirmation." | "Safely replace one exact text block in an existing file. Fails if match count is not exactly one." | "List files and folders in a directory." | "Create a directory (and optionally parent directories)." | "Delete a file (or directory with recursive=true). In standard mode this requires confirmation." | "Move or rename a file/directory path. In standard mode this requires confirmation." | "Get file metadata (type, size, timestamps, permissions) for a path." | "Search file contents using ripgrep (or fallback scan). Returns file:line:content matches." | "Find files by glob pattern, for example **/*.ts. Returns absolute paths." | "Show a colored unified diff between a file on disk and proposed new content. Use before write_to_file to preview changes." | "Search for a pattern across all files in a directory and replace it. Use dry_run=true (default) to preview before writing." | "Fetch an HTTP/HTTPS URL and return the response text (with optional truncation)." | "Run a shell command in the current working directory. Dangerous patterns are blocked." | "Show git working tree status (short format with branch info)." | "Show git diff for the working tree, staged changes, or against a base commit/branch." | "Show recent git commit history, optionally filtered to a file." | "Show who last modified each line of a file (git blame)." | "List all stashes or show the diff of the top stash." | "Run a linter (eslint, tsc, ruff, mypy, clippy, golangci-lint — auto-detected from project files)." | "Run the project's test suite (vitest, jest, pytest, cargo test, go test — auto-detected)." | "Scan source files for security issues: hardcoded secrets, XSS, SQL injection, eval usage, weak crypto, etc.";
|
|
370
|
+
parameters: object & {
|
|
371
|
+
$schema?: string | undefined;
|
|
372
|
+
definitions?: {
|
|
373
|
+
[key: string]: object;
|
|
374
|
+
} | undefined;
|
|
375
|
+
};
|
|
376
|
+
};
|
|
377
|
+
}[];
|
|
378
|
+
export declare const TOOL_MAP: Record<ToolName, ToolHandler>;
|
|
379
|
+
export declare function configureToolRuntime(config: Partial<ToolRuntimeConfig>): void;
|
|
380
|
+
export declare function listAvailableTools(): Array<{
|
|
381
|
+
name: ToolName;
|
|
382
|
+
description: string;
|
|
383
|
+
}>;
|
|
384
|
+
export declare function getToolRuntime(): ToolRuntimeConfig;
|
|
385
|
+
export type { ToolExecutionContext, ToolRuntimeConfig, PermissionMode };
|
|
386
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoDxB,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACvB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAQpE,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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