iosm-cli 0.2.6 → 0.2.7
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 +26 -0
- package/README.md +7 -7
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +4 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-profiles.d.ts.map +1 -1
- package/dist/core/agent-profiles.js +3 -1
- package/dist/core/agent-profiles.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +14 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/sdk.d.ts +2 -2
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +3 -3
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/shadow-guard.js +1 -1
- package/dist/core/shadow-guard.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +17 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/fetch.d.ts +56 -0
- package/dist/core/tools/fetch.d.ts.map +1 -0
- package/dist/core/tools/fetch.js +272 -0
- package/dist/core/tools/fetch.js.map +1 -0
- package/dist/core/tools/fs-ops.d.ts +54 -0
- package/dist/core/tools/fs-ops.d.ts.map +1 -0
- package/dist/core/tools/fs-ops.js +206 -0
- package/dist/core/tools/fs-ops.js.map +1 -0
- package/dist/core/tools/git-read.d.ts +60 -0
- package/dist/core/tools/git-read.d.ts.map +1 -0
- package/dist/core/tools/git-read.js +267 -0
- package/dist/core/tools/git-read.js.map +1 -0
- package/dist/core/tools/index.d.ts +44 -0
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +22 -0
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/task.js +1 -1
- package/dist/core/tools/task.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +56 -22
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/docs/cli-reference.md +4 -1
- package/docs/configuration.md +2 -2
- package/docs/interactive-mode.md +2 -2
- package/docs/rpc-json-sdk.md +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
2
|
+
import { type Static } from "@sinclair/typebox";
|
|
3
|
+
import { type TruncationResult } from "./truncate.js";
|
|
4
|
+
declare const gitReadSchema: import("@sinclair/typebox").TObject<{
|
|
5
|
+
action: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"status">, import("@sinclair/typebox").TLiteral<"diff">, import("@sinclair/typebox").TLiteral<"log">, import("@sinclair/typebox").TLiteral<"blame">]>;
|
|
6
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
7
|
+
file: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
8
|
+
base: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
9
|
+
head: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
10
|
+
staged: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
11
|
+
context: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
12
|
+
porcelain: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
13
|
+
untracked: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
14
|
+
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
15
|
+
since: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
16
|
+
ref: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
17
|
+
line_start: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
18
|
+
line_end: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
19
|
+
timeout: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
20
|
+
}>;
|
|
21
|
+
export type GitReadToolInput = Static<typeof gitReadSchema>;
|
|
22
|
+
interface RunCommandResult {
|
|
23
|
+
stdout: string;
|
|
24
|
+
stderr: string;
|
|
25
|
+
exitCode: number;
|
|
26
|
+
captureTruncated: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface GitReadToolDetails {
|
|
29
|
+
action: "status" | "diff" | "log" | "blame";
|
|
30
|
+
command: string;
|
|
31
|
+
args: string[];
|
|
32
|
+
cwd: string;
|
|
33
|
+
exitCode: number;
|
|
34
|
+
captureTruncated?: boolean;
|
|
35
|
+
truncation?: TruncationResult;
|
|
36
|
+
}
|
|
37
|
+
export interface GitReadToolOptions {
|
|
38
|
+
commandExists?: (command: string) => boolean;
|
|
39
|
+
runCommand?: (args: string[], cwd: string, timeoutMs: number, signal?: AbortSignal) => Promise<RunCommandResult>;
|
|
40
|
+
}
|
|
41
|
+
export declare function createGitReadTool(cwd: string, options?: GitReadToolOptions): AgentTool<typeof gitReadSchema>;
|
|
42
|
+
export declare const gitReadTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
43
|
+
action: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"status">, import("@sinclair/typebox").TLiteral<"diff">, import("@sinclair/typebox").TLiteral<"log">, import("@sinclair/typebox").TLiteral<"blame">]>;
|
|
44
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
45
|
+
file: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
46
|
+
base: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
47
|
+
head: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
48
|
+
staged: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
49
|
+
context: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
50
|
+
porcelain: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
51
|
+
untracked: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
52
|
+
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
53
|
+
since: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
54
|
+
ref: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
55
|
+
line_start: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
56
|
+
line_end: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
57
|
+
timeout: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
58
|
+
}>, any>;
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=git-read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-read.d.ts","sourceRoot":"","sources":["../../../src/core/tools/git-read.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAIN,KAAK,gBAAgB,EAErB,MAAM,eAAe,CAAC;AAEvB,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;EAuBjB,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAO5D,UAAU,gBAAgB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAkB;IAClC,MAAM,EAAE,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IAClC,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;IAC7C,UAAU,CAAC,EAAE,CACZ,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,WAAW,KAChB,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC/B;AAiND,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC,OAAO,aAAa,CAAC,CAgE5G;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;QAAmC,CAAC"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
import { resolveToCwd } from "./path-utils.js";
|
|
4
|
+
import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead, } from "./truncate.js";
|
|
5
|
+
const gitReadSchema = Type.Object({
|
|
6
|
+
action: Type.Union([Type.Literal("status"), Type.Literal("diff"), Type.Literal("log"), Type.Literal("blame")], { description: "Git action: status | diff | log | blame." }),
|
|
7
|
+
path: Type.Optional(Type.String({ description: "Repository working directory (default: current directory)." })),
|
|
8
|
+
file: Type.Optional(Type.String({ description: "Optional file path for diff/log, required for blame." })),
|
|
9
|
+
base: Type.Optional(Type.String({ description: "Optional base ref/commit for diff." })),
|
|
10
|
+
head: Type.Optional(Type.String({ description: "Optional head ref/commit for diff (requires base)." })),
|
|
11
|
+
staged: Type.Optional(Type.Boolean({ description: "For diff action: compare staged changes." })),
|
|
12
|
+
context: Type.Optional(Type.Number({ description: "For diff action: unified context lines (default: 3)." })),
|
|
13
|
+
porcelain: Type.Optional(Type.Boolean({
|
|
14
|
+
description: "For status action: use short porcelain format with branch (default: true).",
|
|
15
|
+
})),
|
|
16
|
+
untracked: Type.Optional(Type.Boolean({ description: "For status action: include untracked files (default: true)." })),
|
|
17
|
+
limit: Type.Optional(Type.Number({ description: "For log action: max entries (default: 20, max: 200)." })),
|
|
18
|
+
since: Type.Optional(Type.String({ description: "For log action: git --since value (e.g. '2 weeks ago')." })),
|
|
19
|
+
ref: Type.Optional(Type.String({ description: "For blame action: optional ref/commit." })),
|
|
20
|
+
line_start: Type.Optional(Type.Number({ description: "For blame action: range start line (1-indexed)." })),
|
|
21
|
+
line_end: Type.Optional(Type.Number({ description: "For blame action: range end line (1-indexed)." })),
|
|
22
|
+
timeout: Type.Optional(Type.Number({ description: "Timeout in seconds (default: 30)." })),
|
|
23
|
+
});
|
|
24
|
+
const DEFAULT_TIMEOUT_SECONDS = 30;
|
|
25
|
+
const DEFAULT_LOG_LIMIT = 20;
|
|
26
|
+
const MAX_LOG_LIMIT = 200;
|
|
27
|
+
const MAX_CAPTURE_BYTES = 512 * 1024;
|
|
28
|
+
function commandExists(command) {
|
|
29
|
+
try {
|
|
30
|
+
const result = spawnSync(command, ["--version"], { stdio: "pipe" });
|
|
31
|
+
const err = result.error;
|
|
32
|
+
return !err || err.code !== "ENOENT";
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function normalizePositiveInt(raw, fallback, field) {
|
|
39
|
+
if (raw === undefined)
|
|
40
|
+
return fallback;
|
|
41
|
+
const value = Math.floor(raw);
|
|
42
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
43
|
+
throw new Error(`${field} must be a positive number.`);
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
function runGitCommand(args, cwd, timeoutMs, signal) {
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
if (signal?.aborted) {
|
|
50
|
+
reject(new Error("Operation aborted"));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const child = spawn("git", args, {
|
|
54
|
+
cwd,
|
|
55
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
56
|
+
});
|
|
57
|
+
let stdoutChunks = [];
|
|
58
|
+
let stderrChunks = [];
|
|
59
|
+
let stdoutBytes = 0;
|
|
60
|
+
let stderrBytes = 0;
|
|
61
|
+
let captureTruncated = false;
|
|
62
|
+
let timedOut = false;
|
|
63
|
+
let aborted = false;
|
|
64
|
+
let settled = false;
|
|
65
|
+
const settle = (fn) => {
|
|
66
|
+
if (!settled) {
|
|
67
|
+
settled = true;
|
|
68
|
+
fn();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const captureChunk = (chunk, chunks, currentBytes) => {
|
|
72
|
+
if (currentBytes >= MAX_CAPTURE_BYTES) {
|
|
73
|
+
return { nextBytes: currentBytes, truncated: true };
|
|
74
|
+
}
|
|
75
|
+
const remaining = MAX_CAPTURE_BYTES - currentBytes;
|
|
76
|
+
if (chunk.length <= remaining) {
|
|
77
|
+
chunks.push(chunk);
|
|
78
|
+
return { nextBytes: currentBytes + chunk.length, truncated: false };
|
|
79
|
+
}
|
|
80
|
+
chunks.push(chunk.subarray(0, remaining));
|
|
81
|
+
return { nextBytes: MAX_CAPTURE_BYTES, truncated: true };
|
|
82
|
+
};
|
|
83
|
+
const timeoutHandle = setTimeout(() => {
|
|
84
|
+
timedOut = true;
|
|
85
|
+
child.kill("SIGTERM");
|
|
86
|
+
}, Math.max(1000, timeoutMs));
|
|
87
|
+
const onAbort = () => {
|
|
88
|
+
aborted = true;
|
|
89
|
+
child.kill("SIGTERM");
|
|
90
|
+
};
|
|
91
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
92
|
+
const cleanup = () => {
|
|
93
|
+
clearTimeout(timeoutHandle);
|
|
94
|
+
signal?.removeEventListener("abort", onAbort);
|
|
95
|
+
};
|
|
96
|
+
child.stdout.on("data", (chunk) => {
|
|
97
|
+
const captured = captureChunk(chunk, stdoutChunks, stdoutBytes);
|
|
98
|
+
stdoutBytes = captured.nextBytes;
|
|
99
|
+
captureTruncated = captureTruncated || captured.truncated;
|
|
100
|
+
});
|
|
101
|
+
child.stderr.on("data", (chunk) => {
|
|
102
|
+
const captured = captureChunk(chunk, stderrChunks, stderrBytes);
|
|
103
|
+
stderrBytes = captured.nextBytes;
|
|
104
|
+
captureTruncated = captureTruncated || captured.truncated;
|
|
105
|
+
});
|
|
106
|
+
child.on("error", (error) => {
|
|
107
|
+
cleanup();
|
|
108
|
+
settle(() => reject(new Error(`Failed to run git: ${error.message}`)));
|
|
109
|
+
});
|
|
110
|
+
child.on("close", (code) => {
|
|
111
|
+
cleanup();
|
|
112
|
+
if (aborted) {
|
|
113
|
+
settle(() => reject(new Error("Operation aborted")));
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (timedOut) {
|
|
117
|
+
settle(() => reject(new Error(`Command timed out after ${Math.round(timeoutMs / 1000)}s`)));
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
settle(() => resolve({
|
|
121
|
+
stdout: Buffer.concat(stdoutChunks).toString("utf-8"),
|
|
122
|
+
stderr: Buffer.concat(stderrChunks).toString("utf-8"),
|
|
123
|
+
exitCode: code ?? -1,
|
|
124
|
+
captureTruncated,
|
|
125
|
+
}));
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function buildStatusArgs(input) {
|
|
130
|
+
const porcelain = input.porcelain ?? true;
|
|
131
|
+
const includeUntracked = input.untracked ?? true;
|
|
132
|
+
const args = ["status"];
|
|
133
|
+
if (porcelain) {
|
|
134
|
+
args.push("--short", "--branch");
|
|
135
|
+
}
|
|
136
|
+
if (!includeUntracked) {
|
|
137
|
+
args.push("--untracked-files=no");
|
|
138
|
+
}
|
|
139
|
+
return args;
|
|
140
|
+
}
|
|
141
|
+
function buildDiffArgs(input) {
|
|
142
|
+
if (input.head && !input.base) {
|
|
143
|
+
throw new Error("git_read diff requires base when head is provided.");
|
|
144
|
+
}
|
|
145
|
+
const context = normalizePositiveInt(input.context, 3, "context");
|
|
146
|
+
const args = ["diff", "--no-color", `--unified=${context}`];
|
|
147
|
+
if (input.staged) {
|
|
148
|
+
args.push("--staged");
|
|
149
|
+
}
|
|
150
|
+
if (input.base && input.head) {
|
|
151
|
+
args.push(`${input.base}..${input.head}`);
|
|
152
|
+
}
|
|
153
|
+
else if (input.base) {
|
|
154
|
+
args.push(input.base);
|
|
155
|
+
}
|
|
156
|
+
if (input.file) {
|
|
157
|
+
args.push("--", input.file);
|
|
158
|
+
}
|
|
159
|
+
return args;
|
|
160
|
+
}
|
|
161
|
+
function buildLogArgs(input) {
|
|
162
|
+
const limit = Math.min(MAX_LOG_LIMIT, normalizePositiveInt(input.limit, DEFAULT_LOG_LIMIT, "limit"));
|
|
163
|
+
const args = [
|
|
164
|
+
"log",
|
|
165
|
+
"--no-color",
|
|
166
|
+
`--max-count=${limit}`,
|
|
167
|
+
"--date=iso",
|
|
168
|
+
"--pretty=format:%H%x09%ad%x09%an%x09%s",
|
|
169
|
+
];
|
|
170
|
+
if (input.since) {
|
|
171
|
+
args.push(`--since=${input.since}`);
|
|
172
|
+
}
|
|
173
|
+
if (input.file) {
|
|
174
|
+
args.push("--", input.file);
|
|
175
|
+
}
|
|
176
|
+
return args;
|
|
177
|
+
}
|
|
178
|
+
function buildBlameArgs(input) {
|
|
179
|
+
if (!input.file) {
|
|
180
|
+
throw new Error("git_read blame requires file.");
|
|
181
|
+
}
|
|
182
|
+
const hasLineStart = input.line_start !== undefined;
|
|
183
|
+
const hasLineEnd = input.line_end !== undefined;
|
|
184
|
+
if (hasLineStart !== hasLineEnd) {
|
|
185
|
+
throw new Error("git_read blame requires both line_start and line_end when specifying a range.");
|
|
186
|
+
}
|
|
187
|
+
const args = ["blame", "--line-porcelain"];
|
|
188
|
+
if (input.ref) {
|
|
189
|
+
args.push(input.ref);
|
|
190
|
+
}
|
|
191
|
+
if (hasLineStart && hasLineEnd) {
|
|
192
|
+
const lineStart = normalizePositiveInt(input.line_start, 1, "line_start");
|
|
193
|
+
const lineEnd = normalizePositiveInt(input.line_end, 1, "line_end");
|
|
194
|
+
if (lineEnd < lineStart) {
|
|
195
|
+
throw new Error("line_end must be greater than or equal to line_start.");
|
|
196
|
+
}
|
|
197
|
+
args.push("-L", `${lineStart},${lineEnd}`);
|
|
198
|
+
}
|
|
199
|
+
args.push("--", input.file);
|
|
200
|
+
return args;
|
|
201
|
+
}
|
|
202
|
+
function buildGitArgs(input) {
|
|
203
|
+
if (input.action === "status")
|
|
204
|
+
return buildStatusArgs(input);
|
|
205
|
+
if (input.action === "diff")
|
|
206
|
+
return buildDiffArgs(input);
|
|
207
|
+
if (input.action === "log")
|
|
208
|
+
return buildLogArgs(input);
|
|
209
|
+
return buildBlameArgs(input);
|
|
210
|
+
}
|
|
211
|
+
export function createGitReadTool(cwd, options) {
|
|
212
|
+
const hasCommand = options?.commandExists ?? commandExists;
|
|
213
|
+
const runCommand = options?.runCommand ?? runGitCommand;
|
|
214
|
+
return {
|
|
215
|
+
name: "git_read",
|
|
216
|
+
label: "git_read",
|
|
217
|
+
description: "Structured read-only git introspection. Actions: status | diff | log | blame. Uses safe argv execution without shell interpolation.",
|
|
218
|
+
parameters: gitReadSchema,
|
|
219
|
+
execute: async (_toolCallId, input, signal) => {
|
|
220
|
+
if (!hasCommand("git")) {
|
|
221
|
+
throw new Error("git command is not available.");
|
|
222
|
+
}
|
|
223
|
+
const repoCwd = resolveToCwd(input.path || ".", cwd);
|
|
224
|
+
const args = buildGitArgs(input);
|
|
225
|
+
const timeoutSeconds = normalizePositiveInt(input.timeout, DEFAULT_TIMEOUT_SECONDS, "timeout");
|
|
226
|
+
const result = await runCommand(args, repoCwd, timeoutSeconds * 1000, signal);
|
|
227
|
+
if (result.exitCode !== 0) {
|
|
228
|
+
const errorText = result.stderr.trim() || result.stdout.trim() || `git_read ${input.action} failed with exit code ${result.exitCode}`;
|
|
229
|
+
throw new Error(errorText);
|
|
230
|
+
}
|
|
231
|
+
let output = result.stdout.trimEnd();
|
|
232
|
+
if (!output && result.stderr.trim().length > 0) {
|
|
233
|
+
output = result.stderr.trimEnd();
|
|
234
|
+
}
|
|
235
|
+
if (!output) {
|
|
236
|
+
output = "No output";
|
|
237
|
+
}
|
|
238
|
+
const truncation = truncateHead(output);
|
|
239
|
+
let finalOutput = truncation.content;
|
|
240
|
+
const notices = [];
|
|
241
|
+
if (truncation.truncated) {
|
|
242
|
+
notices.push(`${formatSize(DEFAULT_MAX_BYTES)} output limit reached`);
|
|
243
|
+
}
|
|
244
|
+
if (result.captureTruncated) {
|
|
245
|
+
notices.push(`capture limit reached (${formatSize(MAX_CAPTURE_BYTES)})`);
|
|
246
|
+
}
|
|
247
|
+
if (notices.length > 0) {
|
|
248
|
+
finalOutput += `\n\n[${notices.join(". ")} · showing up to ${DEFAULT_MAX_LINES} lines]`;
|
|
249
|
+
}
|
|
250
|
+
const details = {
|
|
251
|
+
action: input.action,
|
|
252
|
+
command: "git",
|
|
253
|
+
args,
|
|
254
|
+
cwd: repoCwd,
|
|
255
|
+
exitCode: result.exitCode,
|
|
256
|
+
captureTruncated: result.captureTruncated || undefined,
|
|
257
|
+
truncation: truncation.truncated ? truncation : undefined,
|
|
258
|
+
};
|
|
259
|
+
return {
|
|
260
|
+
content: [{ type: "text", text: finalOutput }],
|
|
261
|
+
details,
|
|
262
|
+
};
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
export const gitReadTool = createGitReadTool(process.cwd());
|
|
267
|
+
//# sourceMappingURL=git-read.js.map
|
|
@@ -0,0 +1 @@
|
|
|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AE,OAAO;gBACZ,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,IAAI,SAAS;gBACtD,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;aACzD,CAAC;YAEF,OAAO;gBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;gBAC9C,OAAO;aACP,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC","sourcesContent":["import { spawn, spawnSync } from \"node:child_process\";\nimport type { AgentTool } from \"@mariozechner/pi-agent-core\";\nimport { type Static, Type } from \"@sinclair/typebox\";\nimport { resolveToCwd } from \"./path-utils.js\";\nimport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationResult,\n\ttruncateHead,\n} from \"./truncate.js\";\n\nconst gitReadSchema = Type.Object({\n\taction: Type.Union(\n\t\t[Type.Literal(\"status\"), Type.Literal(\"diff\"), Type.Literal(\"log\"), Type.Literal(\"blame\")],\n\t\t{ description: \"Git action: status | diff | log | blame.\" },\n\t),\n\tpath: Type.Optional(Type.String({ description: \"Repository working directory (default: current directory).\" })),\n\tfile: Type.Optional(Type.String({ description: \"Optional file path for diff/log, required for blame.\" })),\n\tbase: Type.Optional(Type.String({ description: \"Optional base ref/commit for diff.\" })),\n\thead: Type.Optional(Type.String({ description: \"Optional head ref/commit for diff (requires base).\" })),\n\tstaged: Type.Optional(Type.Boolean({ description: \"For diff action: compare staged changes.\" })),\n\tcontext: Type.Optional(Type.Number({ description: \"For diff action: unified context lines (default: 3).\" })),\n\tporcelain: Type.Optional(\n\t\tType.Boolean({\n\t\t\tdescription: \"For status action: use short porcelain format with branch (default: true).\",\n\t\t}),\n\t),\n\tuntracked: Type.Optional(Type.Boolean({ description: \"For status action: include untracked files (default: true).\" })),\n\tlimit: Type.Optional(Type.Number({ description: \"For log action: max entries (default: 20, max: 200).\" })),\n\tsince: Type.Optional(Type.String({ description: \"For log action: git --since value (e.g. '2 weeks ago').\" })),\n\tref: Type.Optional(Type.String({ description: \"For blame action: optional ref/commit.\" })),\n\tline_start: Type.Optional(Type.Number({ description: \"For blame action: range start line (1-indexed).\" })),\n\tline_end: Type.Optional(Type.Number({ description: \"For blame action: range end line (1-indexed).\" })),\n\ttimeout: Type.Optional(Type.Number({ description: \"Timeout in seconds (default: 30).\" })),\n});\n\nexport type GitReadToolInput = Static<typeof gitReadSchema>;\n\nconst DEFAULT_TIMEOUT_SECONDS = 30;\nconst DEFAULT_LOG_LIMIT = 20;\nconst MAX_LOG_LIMIT = 200;\nconst MAX_CAPTURE_BYTES = 512 * 1024;\n\ninterface RunCommandResult {\n\tstdout: string;\n\tstderr: string;\n\texitCode: number;\n\tcaptureTruncated: boolean;\n}\n\nexport interface GitReadToolDetails {\n\taction: \"status\" | \"diff\" | \"log\" | \"blame\";\n\tcommand: string;\n\targs: string[];\n\tcwd: string;\n\texitCode: number;\n\tcaptureTruncated?: boolean;\n\ttruncation?: TruncationResult;\n}\n\nexport interface GitReadToolOptions {\n\tcommandExists?: (command: string) => boolean;\n\trunCommand?: (\n\t\targs: string[],\n\t\tcwd: string,\n\t\ttimeoutMs: number,\n\t\tsignal?: AbortSignal,\n\t) => Promise<RunCommandResult>;\n}\n\nfunction commandExists(command: string): boolean {\n\ttry {\n\t\tconst result = spawnSync(command, [\"--version\"], { stdio: \"pipe\" });\n\t\tconst err = result.error as NodeJS.ErrnoException | undefined;\n\t\treturn !err || err.code !== \"ENOENT\";\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction normalizePositiveInt(raw: number | undefined, fallback: number, field: string): number {\n\tif (raw === undefined) return fallback;\n\tconst value = Math.floor(raw);\n\tif (!Number.isFinite(value) || value <= 0) {\n\t\tthrow new Error(`${field} must be a positive number.`);\n\t}\n\treturn value;\n}\n\nfunction runGitCommand(\n\targs: string[],\n\tcwd: string,\n\ttimeoutMs: number,\n\tsignal?: AbortSignal,\n): Promise<RunCommandResult> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal?.aborted) {\n\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\treturn;\n\t\t}\n\n\t\tconst child = spawn(\"git\", args, {\n\t\t\tcwd,\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t});\n\n\t\tlet stdoutChunks: Buffer[] = [];\n\t\tlet stderrChunks: Buffer[] = [];\n\t\tlet stdoutBytes = 0;\n\t\tlet stderrBytes = 0;\n\t\tlet captureTruncated = false;\n\t\tlet timedOut = false;\n\t\tlet aborted = false;\n\t\tlet settled = false;\n\n\t\tconst settle = (fn: () => void) => {\n\t\t\tif (!settled) {\n\t\t\t\tsettled = true;\n\t\t\t\tfn();\n\t\t\t}\n\t\t};\n\n\t\tconst captureChunk = (\n\t\t\tchunk: Buffer,\n\t\t\tchunks: Buffer[],\n\t\t\tcurrentBytes: number,\n\t\t): { nextBytes: number; truncated: boolean } => {\n\t\t\tif (currentBytes >= MAX_CAPTURE_BYTES) {\n\t\t\t\treturn { nextBytes: currentBytes, truncated: true };\n\t\t\t}\n\t\t\tconst remaining = MAX_CAPTURE_BYTES - currentBytes;\n\t\t\tif (chunk.length <= remaining) {\n\t\t\t\tchunks.push(chunk);\n\t\t\t\treturn { nextBytes: currentBytes + chunk.length, truncated: false };\n\t\t\t}\n\t\t\tchunks.push(chunk.subarray(0, remaining));\n\t\t\treturn { nextBytes: MAX_CAPTURE_BYTES, truncated: true };\n\t\t};\n\n\t\tconst timeoutHandle = setTimeout(() => {\n\t\t\ttimedOut = true;\n\t\t\tchild.kill(\"SIGTERM\");\n\t\t}, Math.max(1000, timeoutMs));\n\n\t\tconst onAbort = () => {\n\t\t\taborted = true;\n\t\t\tchild.kill(\"SIGTERM\");\n\t\t};\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\n\t\tconst cleanup = () => {\n\t\t\tclearTimeout(timeoutHandle);\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t};\n\n\t\tchild.stdout.on(\"data\", (chunk: Buffer) => {\n\t\t\tconst captured = captureChunk(chunk, stdoutChunks, stdoutBytes);\n\t\t\tstdoutBytes = captured.nextBytes;\n\t\t\tcaptureTruncated = captureTruncated || captured.truncated;\n\t\t});\n\n\t\tchild.stderr.on(\"data\", (chunk: Buffer) => {\n\t\t\tconst captured = captureChunk(chunk, stderrChunks, stderrBytes);\n\t\t\tstderrBytes = captured.nextBytes;\n\t\t\tcaptureTruncated = captureTruncated || captured.truncated;\n\t\t});\n\n\t\tchild.on(\"error\", (error) => {\n\t\t\tcleanup();\n\t\t\tsettle(() => reject(new Error(`Failed to run git: ${error.message}`)));\n\t\t});\n\n\t\tchild.on(\"close\", (code) => {\n\t\t\tcleanup();\n\t\t\tif (aborted) {\n\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (timedOut) {\n\t\t\t\tsettle(() => reject(new Error(`Command timed out after ${Math.round(timeoutMs / 1000)}s`)));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsettle(() =>\n\t\t\t\tresolve({\n\t\t\t\t\tstdout: Buffer.concat(stdoutChunks).toString(\"utf-8\"),\n\t\t\t\t\tstderr: Buffer.concat(stderrChunks).toString(\"utf-8\"),\n\t\t\t\t\texitCode: code ?? -1,\n\t\t\t\t\tcaptureTruncated,\n\t\t\t\t}),\n\t\t\t);\n\t\t});\n\t});\n}\n\nfunction buildStatusArgs(input: GitReadToolInput): string[] {\n\tconst porcelain = input.porcelain ?? true;\n\tconst includeUntracked = input.untracked ?? true;\n\tconst args = [\"status\"];\n\tif (porcelain) {\n\t\targs.push(\"--short\", \"--branch\");\n\t}\n\tif (!includeUntracked) {\n\t\targs.push(\"--untracked-files=no\");\n\t}\n\treturn args;\n}\n\nfunction buildDiffArgs(input: GitReadToolInput): string[] {\n\tif (input.head && !input.base) {\n\t\tthrow new Error(\"git_read diff requires base when head is provided.\");\n\t}\n\tconst context = normalizePositiveInt(input.context, 3, \"context\");\n\tconst args = [\"diff\", \"--no-color\", `--unified=${context}`];\n\tif (input.staged) {\n\t\targs.push(\"--staged\");\n\t}\n\tif (input.base && input.head) {\n\t\targs.push(`${input.base}..${input.head}`);\n\t} else if (input.base) {\n\t\targs.push(input.base);\n\t}\n\tif (input.file) {\n\t\targs.push(\"--\", input.file);\n\t}\n\treturn args;\n}\n\nfunction buildLogArgs(input: GitReadToolInput): string[] {\n\tconst limit = Math.min(MAX_LOG_LIMIT, normalizePositiveInt(input.limit, DEFAULT_LOG_LIMIT, \"limit\"));\n\tconst args = [\n\t\t\"log\",\n\t\t\"--no-color\",\n\t\t`--max-count=${limit}`,\n\t\t\"--date=iso\",\n\t\t\"--pretty=format:%H%x09%ad%x09%an%x09%s\",\n\t];\n\tif (input.since) {\n\t\targs.push(`--since=${input.since}`);\n\t}\n\tif (input.file) {\n\t\targs.push(\"--\", input.file);\n\t}\n\treturn args;\n}\n\nfunction buildBlameArgs(input: GitReadToolInput): string[] {\n\tif (!input.file) {\n\t\tthrow new Error(\"git_read blame requires file.\");\n\t}\n\tconst hasLineStart = input.line_start !== undefined;\n\tconst hasLineEnd = input.line_end !== undefined;\n\tif (hasLineStart !== hasLineEnd) {\n\t\tthrow new Error(\"git_read blame requires both line_start and line_end when specifying a range.\");\n\t}\n\tconst args = [\"blame\", \"--line-porcelain\"];\n\tif (input.ref) {\n\t\targs.push(input.ref);\n\t}\n\tif (hasLineStart && hasLineEnd) {\n\t\tconst lineStart = normalizePositiveInt(input.line_start, 1, \"line_start\");\n\t\tconst lineEnd = normalizePositiveInt(input.line_end, 1, \"line_end\");\n\t\tif (lineEnd < lineStart) {\n\t\t\tthrow new Error(\"line_end must be greater than or equal to line_start.\");\n\t\t}\n\t\targs.push(\"-L\", `${lineStart},${lineEnd}`);\n\t}\n\targs.push(\"--\", input.file);\n\treturn args;\n}\n\nfunction buildGitArgs(input: GitReadToolInput): string[] {\n\tif (input.action === \"status\") return buildStatusArgs(input);\n\tif (input.action === \"diff\") return buildDiffArgs(input);\n\tif (input.action === \"log\") return buildLogArgs(input);\n\treturn buildBlameArgs(input);\n}\n\nexport function createGitReadTool(cwd: string, options?: GitReadToolOptions): AgentTool<typeof gitReadSchema> {\n\tconst hasCommand = options?.commandExists ?? commandExists;\n\tconst runCommand = options?.runCommand ?? runGitCommand;\n\n\treturn {\n\t\tname: \"git_read\",\n\t\tlabel: \"git_read\",\n\t\tdescription:\n\t\t\t\"Structured read-only git introspection. Actions: status | diff | log | blame. Uses safe argv execution without shell interpolation.\",\n\t\tparameters: gitReadSchema,\n\t\texecute: async (_toolCallId: string, input: GitReadToolInput, signal?: AbortSignal) => {\n\t\t\tif (!hasCommand(\"git\")) {\n\t\t\t\tthrow new Error(\"git command is not available.\");\n\t\t\t}\n\n\t\t\tconst repoCwd = resolveToCwd(input.path || \".\", cwd);\n\t\t\tconst args = buildGitArgs(input);\n\t\t\tconst timeoutSeconds = normalizePositiveInt(input.timeout, DEFAULT_TIMEOUT_SECONDS, \"timeout\");\n\t\t\tconst result = await runCommand(args, repoCwd, timeoutSeconds * 1000, signal);\n\n\t\t\tif (result.exitCode !== 0) {\n\t\t\t\tconst errorText =\n\t\t\t\t\tresult.stderr.trim() || result.stdout.trim() || `git_read ${input.action} failed with exit code ${result.exitCode}`;\n\t\t\t\tthrow new Error(errorText);\n\t\t\t}\n\n\t\t\tlet output = result.stdout.trimEnd();\n\t\t\tif (!output && result.stderr.trim().length > 0) {\n\t\t\t\toutput = result.stderr.trimEnd();\n\t\t\t}\n\t\t\tif (!output) {\n\t\t\t\toutput = \"No output\";\n\t\t\t}\n\n\t\t\tconst truncation = truncateHead(output);\n\t\t\tlet finalOutput = truncation.content;\n\t\t\tconst notices: string[] = [];\n\n\t\t\tif (truncation.truncated) {\n\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} output limit reached`);\n\t\t\t}\n\t\t\tif (result.captureTruncated) {\n\t\t\t\tnotices.push(`capture limit reached (${formatSize(MAX_CAPTURE_BYTES)})`);\n\t\t\t}\n\t\t\tif (notices.length > 0) {\n\t\t\t\tfinalOutput += `\\n\\n[${notices.join(\". \")} · showing up to ${DEFAULT_MAX_LINES} lines]`;\n\t\t\t}\n\n\t\t\tconst details: GitReadToolDetails = {\n\t\t\t\taction: input.action,\n\t\t\t\tcommand: \"git\",\n\t\t\t\targs,\n\t\t\t\tcwd: repoCwd,\n\t\t\t\texitCode: result.exitCode,\n\t\t\t\tcaptureTruncated: result.captureTruncated || undefined,\n\t\t\t\ttruncation: truncation.truncated ? truncation : undefined,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: finalOutput }],\n\t\t\t\tdetails,\n\t\t\t};\n\t\t},\n\t};\n}\n\nexport const gitReadTool = createGitReadTool(process.cwd());\n"]}
|
|
@@ -2,10 +2,13 @@ export { createAstGrepTool, type AstGrepToolInput, astGrepTool, } from "./ast-gr
|
|
|
2
2
|
export { type BashOperations, type BashSpawnContext, type BashSpawnHook, type BashToolDetails, type BashToolInput, type BashToolOptions, bashTool, createBashTool, } from "./bash.js";
|
|
3
3
|
export { type CombyToolInput, combyTool, createCombyTool, } from "./comby.js";
|
|
4
4
|
export { createEditTool, type EditOperations, type EditToolDetails, type EditToolInput, type EditToolOptions, editTool, } from "./edit.js";
|
|
5
|
+
export { createFetchTool, type FetchToolDetails, type FetchToolInput, type FetchToolOptions, type FetchMethod, type FetchResponseFormat, DEFAULT_FETCH_TIMEOUT_SECONDS, DEFAULT_FETCH_MAX_BYTES, DEFAULT_FETCH_MAX_REDIRECTS, getAllowedFetchMethodsForProfile, fetchTool, } from "./fetch.js";
|
|
5
6
|
export { type ExternalCliToolDetails, type ExternalCliToolInput, type ExternalCliToolOptions, createExternalCliTool, } from "./external-cli.js";
|
|
6
7
|
export { createFdTool, type FdToolInput, fdTool, } from "./fd.js";
|
|
7
8
|
export { createFindTool, type FindOperations, type FindToolDetails, type FindToolInput, type FindToolOptions, findTool, } from "./find.js";
|
|
9
|
+
export { createFsOpsTool, type FsOpsToolDetails, type FsOpsToolInput, type FsOpsToolOptions, fsOpsTool, } from "./fs-ops.js";
|
|
8
10
|
export { createGrepTool, type GrepOperations, type GrepToolDetails, type GrepToolInput, type GrepToolOptions, grepTool, } from "./grep.js";
|
|
11
|
+
export { createGitReadTool, type GitReadToolDetails, type GitReadToolInput, type GitReadToolOptions, gitReadTool, } from "./git-read.js";
|
|
9
12
|
export { createJqTool, type JqToolInput, jqTool, } from "./jq.js";
|
|
10
13
|
export { createLsTool, type LsOperations, type LsToolDetails, type LsToolInput, type LsToolOptions, lsTool, } from "./ls.js";
|
|
11
14
|
export { createReadTool, type ReadOperations, type ReadToolDetails, type ReadToolInput, type ReadToolOptions, readTool, } from "./read.js";
|
|
@@ -22,6 +25,8 @@ export { createTaskTool, type SubagentRunner, type TaskToolProgress, type TaskTo
|
|
|
22
25
|
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
23
26
|
import { type BashToolOptions } from "./bash.js";
|
|
24
27
|
import { type EditToolOptions } from "./edit.js";
|
|
28
|
+
import { type FetchToolOptions } from "./fetch.js";
|
|
29
|
+
import { type FsOpsToolOptions } from "./fs-ops.js";
|
|
25
30
|
import { type ReadToolOptions } from "./read.js";
|
|
26
31
|
import { type SemanticSearchToolOptions } from "./semantic-search.js";
|
|
27
32
|
import { type WriteToolOptions } from "./write.js";
|
|
@@ -121,6 +126,41 @@ export declare const allTools: {
|
|
|
121
126
|
query: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
122
127
|
top_k: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
123
128
|
}>, any>;
|
|
129
|
+
fetch: AgentTool<import("@sinclair/typebox").TObject<{
|
|
130
|
+
url: import("@sinclair/typebox").TString;
|
|
131
|
+
method: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"GET">, import("@sinclair/typebox").TLiteral<"POST">, import("@sinclair/typebox").TLiteral<"PUT">, import("@sinclair/typebox").TLiteral<"PATCH">, import("@sinclair/typebox").TLiteral<"DELETE">, import("@sinclair/typebox").TLiteral<"HEAD">, import("@sinclair/typebox").TLiteral<"OPTIONS">]>>;
|
|
132
|
+
headers: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>>;
|
|
133
|
+
body: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
134
|
+
timeout: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
135
|
+
max_bytes: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
136
|
+
response_format: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"auto">, import("@sinclair/typebox").TLiteral<"json">, import("@sinclair/typebox").TLiteral<"text">]>>;
|
|
137
|
+
max_redirects: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
138
|
+
}>, any>;
|
|
139
|
+
git_read: AgentTool<import("@sinclair/typebox").TObject<{
|
|
140
|
+
action: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"status">, import("@sinclair/typebox").TLiteral<"diff">, import("@sinclair/typebox").TLiteral<"log">, import("@sinclair/typebox").TLiteral<"blame">]>;
|
|
141
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
142
|
+
file: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
143
|
+
base: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
144
|
+
head: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
145
|
+
staged: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
146
|
+
context: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
147
|
+
porcelain: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
148
|
+
untracked: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
149
|
+
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
150
|
+
since: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
151
|
+
ref: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
152
|
+
line_start: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
153
|
+
line_end: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
154
|
+
timeout: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
155
|
+
}>, any>;
|
|
156
|
+
fs_ops: AgentTool<import("@sinclair/typebox").TObject<{
|
|
157
|
+
action: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"mkdir">, import("@sinclair/typebox").TLiteral<"move">, import("@sinclair/typebox").TLiteral<"copy">, import("@sinclair/typebox").TLiteral<"delete">]>;
|
|
158
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
159
|
+
from: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
160
|
+
to: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
161
|
+
recursive: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
162
|
+
force: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
163
|
+
}>, any>;
|
|
124
164
|
todo_write: AgentTool<import("@sinclair/typebox").TObject<{
|
|
125
165
|
tasks: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
126
166
|
id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
@@ -144,6 +184,10 @@ export interface ToolsOptions {
|
|
|
144
184
|
write?: WriteToolOptions;
|
|
145
185
|
/** Options for the semantic_search tool */
|
|
146
186
|
semantic?: SemanticSearchToolOptions;
|
|
187
|
+
/** Options for the fetch tool */
|
|
188
|
+
fetch?: FetchToolOptions;
|
|
189
|
+
/** Options for the fs_ops tool */
|
|
190
|
+
fsOps?: FsOpsToolOptions;
|
|
147
191
|
}
|
|
148
192
|
/**
|
|
149
193
|
* Create coding tools configured for a specific working directory.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,WAAW,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,QAAQ,EACR,cAAc,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,KAAK,cAAc,EACnB,SAAS,EACT,eAAe,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,QAAQ,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,YAAY,EACZ,KAAK,WAAW,EAChB,MAAM,GACN,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eA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AClB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,GAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,KAAK,WAAW,EAChB,MAAM,GACN,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,KAAK,eAAe,EAA4B,MAAM,WAAW,CAAC;AAE3E,OAAO,EAAkB,KAAK,eAAe,EAAY,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,WAAW,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,QAAQ,EACR,cAAc,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,KAAK,cAAc,EACnB,SAAS,EACT,eAAe,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,QAAQ,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,6BAA6B,EAC7B,uBAAuB,EACvB,2BAA2B,EAC3B,gCAAgC,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AC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAwB1F;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAKjG"}
|
package/dist/core/tools/index.js
CHANGED
|
@@ -2,10 +2,13 @@ export { createAstGrepTool, astGrepTool, } from "./ast-grep.js";
|
|
|
2
2
|
export { bashTool, createBashTool, } from "./bash.js";
|
|
3
3
|
export { combyTool, createCombyTool, } from "./comby.js";
|
|
4
4
|
export { createEditTool, editTool, } from "./edit.js";
|
|
5
|
+
export { createFetchTool, DEFAULT_FETCH_TIMEOUT_SECONDS, DEFAULT_FETCH_MAX_BYTES, DEFAULT_FETCH_MAX_REDIRECTS, getAllowedFetchMethodsForProfile, fetchTool, } from "./fetch.js";
|
|
5
6
|
export { createExternalCliTool, } from "./external-cli.js";
|
|
6
7
|
export { createFdTool, fdTool, } from "./fd.js";
|
|
7
8
|
export { createFindTool, findTool, } from "./find.js";
|
|
9
|
+
export { createFsOpsTool, fsOpsTool, } from "./fs-ops.js";
|
|
8
10
|
export { createGrepTool, grepTool, } from "./grep.js";
|
|
11
|
+
export { createGitReadTool, gitReadTool, } from "./git-read.js";
|
|
9
12
|
export { createJqTool, jqTool, } from "./jq.js";
|
|
10
13
|
export { createLsTool, lsTool, } from "./ls.js";
|
|
11
14
|
export { createReadTool, readTool, } from "./read.js";
|
|
@@ -22,9 +25,12 @@ import { astGrepTool, createAstGrepTool } from "./ast-grep.js";
|
|
|
22
25
|
import { bashTool, createBashTool } from "./bash.js";
|
|
23
26
|
import { combyTool, createCombyTool } from "./comby.js";
|
|
24
27
|
import { createEditTool, editTool } from "./edit.js";
|
|
28
|
+
import { createFetchTool, fetchTool, getAllowedFetchMethodsForProfile, } from "./fetch.js";
|
|
25
29
|
import { createFdTool, fdTool } from "./fd.js";
|
|
26
30
|
import { createFindTool, findTool } from "./find.js";
|
|
31
|
+
import { createFsOpsTool, fsOpsTool } from "./fs-ops.js";
|
|
27
32
|
import { createGrepTool, grepTool } from "./grep.js";
|
|
33
|
+
import { createGitReadTool, gitReadTool } from "./git-read.js";
|
|
28
34
|
import { createJqTool, jqTool } from "./jq.js";
|
|
29
35
|
import { createLsTool, lsTool } from "./ls.js";
|
|
30
36
|
import { createReadTool, readTool } from "./read.js";
|
|
@@ -52,6 +58,10 @@ export const readOnlyTools = [
|
|
|
52
58
|
semgrepTool,
|
|
53
59
|
sedTool,
|
|
54
60
|
semanticSearchTool,
|
|
61
|
+
createFetchTool(process.cwd(), {
|
|
62
|
+
resolveAllowedMethods: () => getAllowedFetchMethodsForProfile("plan"),
|
|
63
|
+
}),
|
|
64
|
+
gitReadTool,
|
|
55
65
|
];
|
|
56
66
|
// All available tools (using process.cwd())
|
|
57
67
|
export const allTools = {
|
|
@@ -71,6 +81,9 @@ export const allTools = {
|
|
|
71
81
|
semgrep: semgrepTool,
|
|
72
82
|
sed: sedTool,
|
|
73
83
|
semantic_search: semanticSearchTool,
|
|
84
|
+
fetch: fetchTool,
|
|
85
|
+
git_read: gitReadTool,
|
|
86
|
+
fs_ops: fsOpsTool,
|
|
74
87
|
todo_write: todoWriteTool,
|
|
75
88
|
todo_read: todoReadTool,
|
|
76
89
|
};
|
|
@@ -89,6 +102,10 @@ export function createCodingTools(cwd, options) {
|
|
|
89
102
|
* Create read-only tools configured for a specific working directory.
|
|
90
103
|
*/
|
|
91
104
|
export function createReadOnlyTools(cwd, options) {
|
|
105
|
+
const fetchOptions = {
|
|
106
|
+
...(options?.fetch ?? {}),
|
|
107
|
+
resolveAllowedMethods: options?.fetch?.resolveAllowedMethods ?? (() => getAllowedFetchMethodsForProfile("plan")),
|
|
108
|
+
};
|
|
92
109
|
return [
|
|
93
110
|
createReadTool(cwd, options?.read),
|
|
94
111
|
createGrepTool(cwd),
|
|
@@ -103,6 +120,8 @@ export function createReadOnlyTools(cwd, options) {
|
|
|
103
120
|
createSemgrepTool(cwd),
|
|
104
121
|
createSedTool(cwd),
|
|
105
122
|
createSemanticSearchTool(cwd, options?.semantic),
|
|
123
|
+
createFetchTool(cwd, fetchOptions),
|
|
124
|
+
createGitReadTool(cwd),
|
|
106
125
|
];
|
|
107
126
|
}
|
|
108
127
|
/**
|
|
@@ -126,6 +145,9 @@ export function createAllTools(cwd, options) {
|
|
|
126
145
|
semgrep: createSemgrepTool(cwd),
|
|
127
146
|
sed: createSedTool(cwd),
|
|
128
147
|
semantic_search: createSemanticSearchTool(cwd, options?.semantic),
|
|
148
|
+
fetch: createFetchTool(cwd, options?.fetch),
|
|
149
|
+
git_read: createGitReadTool(cwd),
|
|
150
|
+
fs_ops: createFsOpsTool(cwd, options?.fsOps),
|
|
129
151
|
todo_write: todoWriteTool,
|
|
130
152
|
todo_read: todoReadTool,
|
|
131
153
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EAEjB,WAAW,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAON,QAAQ,EACR,cAAc,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EAEN,SAAS,EACT,eAAe,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,cAAc,EAKd,QAAQ,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,EAIN,qBAAqB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,YAAY,EAEZ,MAAM,GACN,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,cAAc,EAKd,QAAQ,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EAKd,QAAQ,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EAEZ,MAAM,GACN,MAAM,SAAS,CAAC;AACjB,OAAO,EAC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,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,KAAK,EAAE,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC;QAC3C,IAAI,EAAE,cAAc,CAAC,GAAG,CAAC;QACzB,IAAI,EAAE,cAAc,CAAC,GAAG,CAAC;QACzB,EAAE,EAAE,YAAY,CAAC,GAAG,CAAC;QACrB,EAAE,EAAE,YAAY,CAAC,GAAG,CAAC;QACrB,EAAE,EAAE,YAAY,CAAC,GAAG,CAAC;QACrB,QAAQ,EAAE,iBAAiB,CAAC,GAAG,CAAC;QAChC,KAAK,EAAE,eAAe,CAAC,GAAG,CAAC;QAC3B,EAAE,EAAE,YAAY,CAAC,GAAG,CAAC;QACrB,EAAE,EAAE,YAAY,CAAC,GAAG,CAAC;QACrB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC;QAC/B,GAAG,EAAE,aAAa,CAAC,GAAG,CAAC;QACvB,eAAe,EAAE,wBAAwB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC;QACjE,UAAU,EAAE,aAAa;QACzB,SAAS,EAAE,YAAY;KACvB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW,EAAE,KAAe,EAAE,OAAsB;IACxF,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACzC,OAAO,KAAK;SACV,MAAM,CAAC,CAAC,CAAC,EAAiB,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC;SACtC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACtB,CAAC","sourcesContent":["export {\n\tcreateAstGrepTool,\n\ttype AstGrepToolInput,\n\tastGrepTool,\n} from \"./ast-grep.js\";\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tbashTool,\n\tcreateBashTool,\n} from \"./bash.js\";\nexport {\n\ttype CombyToolInput,\n\tcombyTool,\n\tcreateCombyTool,\n} from \"./comby.js\";\nexport {\n\tcreateEditTool,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n\teditTool,\n} from \"./edit.js\";\nexport {\n\ttype ExternalCliToolDetails,\n\ttype ExternalCliToolInput,\n\ttype ExternalCliToolOptions,\n\tcreateExternalCliTool,\n} from \"./external-cli.js\";\nexport {\n\tcreateFdTool,\n\ttype FdToolInput,\n\tfdTool,\n} from \"./fd.js\";\nexport {\n\tcreateFindTool,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n\tfindTool,\n} from \"./find.js\";\nexport {\n\tcreateGrepTool,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n\tgrepTool,\n} from \"./grep.js\";\nexport {\n\tcreateJqTool,\n\ttype JqToolInput,\n\tjqTool,\n} from \"./jq.js\";\nexport {\n\tcreateLsTool,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n\tlsTool,\n} from \"./ls.js\";\nexport {\n\tcreateReadTool,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n\treadTool,\n} from \"./read.js\";\nexport {\n\tcreateRgTool,\n\ttype RgToolInput,\n\trgTool,\n} from \"./rg.js\";\nexport {\n\tcreateSedTool,\n\ttype SedToolInput,\n\tsedTool,\n} from \"./sed.js\";\nexport {\n\tcreateSemgrepTool,\n\ttype SemgrepToolInput,\n\tsemgrepTool,\n} from \"./semgrep.js\";\nexport {\n\tcreateSemanticSearchTool,\n\ttype SemanticSearchToolInput,\n\ttype SemanticSearchToolOptions,\n\tsemanticSearchTool,\n} from \"./semantic-search.js\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.js\";\nexport {\n\tcreateWriteTool,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n\twriteTool,\n} from \"./write.js\";\nexport { type ToolPermissionGuard, type ToolPermissionRequest } from \"./permissions.js\";\nexport {\n\tcreateTodoWriteTool,\n\tcreateTodoReadTool,\n\ttodoWriteTool,\n\ttodoReadTool,\n\tgetTaskFilePath,\n\ttype TodoTask,\n\ttype TodoTaskStatus,\n\ttype TodoWriteInput,\n\ttype TodoReadInput,\n} from \"./todo.js\";\nexport {\n\tcreateYqTool,\n\ttype YqToolInput,\n\tyqTool,\n} from \"./yq.js\";\nexport {\n\tcreateTaskTool,\n\ttype SubagentRunner,\n\ttype TaskToolProgress,\n\ttype TaskToolProgressPhase,\n\ttype TaskToolInput,\n\ttype TaskToolDetails,\n} from \"./task.js\";\n\nimport type { AgentTool } from \"@mariozechner/pi-agent-core\";\nimport { astGrepTool, createAstGrepTool } from \"./ast-grep.js\";\nimport { type BashToolOptions, bashTool, createBashTool } from \"./bash.js\";\nimport { combyTool, createCombyTool } from \"./comby.js\";\nimport { createEditTool, type EditToolOptions, editTool } from \"./edit.js\";\nimport { createFdTool, fdTool } from \"./fd.js\";\nimport { createFindTool, findTool } from \"./find.js\";\nimport { createGrepTool, grepTool } from \"./grep.js\";\nimport { createJqTool, jqTool } from \"./jq.js\";\nimport { createLsTool, lsTool } from \"./ls.js\";\nimport { createReadTool, type ReadToolOptions, readTool } from \"./read.js\";\nimport { createRgTool, rgTool } from \"./rg.js\";\nimport { createSedTool, sedTool } from \"./sed.js\";\nimport { createSemgrepTool, semgrepTool } from \"./semgrep.js\";\nimport {\n\tcreateSemanticSearchTool,\n\ttype SemanticSearchToolOptions,\n\tsemanticSearchTool,\n} from \"./semantic-search.js\";\nimport { createWriteTool, type WriteToolOptions, writeTool } from \"./write.js\";\nimport { createYqTool, yqTool } from \"./yq.js\";\nimport { todoWriteTool, todoReadTool } from \"./todo.js\";\n\n/** Tool type (AgentTool from pi-ai) */\nexport type Tool = AgentTool<any>;\n\n// Default tools for full access mode (using process.cwd())\nexport const codingTools: Tool[] = [readTool, bashTool, editTool, writeTool];\n\n// Read-only tools for exploration without modification (using process.cwd())\nexport const readOnlyTools: Tool[] = [\n\treadTool,\n\tgrepTool,\n\tfindTool,\n\tlsTool,\n\trgTool,\n\tfdTool,\n\tastGrepTool,\n\tcombyTool,\n\tjqTool,\n\tyqTool,\n\tsemgrepTool,\n\tsedTool,\n\tsemanticSearchTool,\n];\n\n// All available tools (using process.cwd())\nexport const allTools = {\n\tread: readTool,\n\tbash: bashTool,\n\tedit: editTool,\n\twrite: writeTool,\n\tgrep: grepTool,\n\tfind: findTool,\n\tls: lsTool,\n\trg: rgTool,\n\tfd: fdTool,\n\tast_grep: astGrepTool,\n\tcomby: combyTool,\n\tjq: jqTool,\n\tyq: yqTool,\n\tsemgrep: semgrepTool,\n\tsed: sedTool,\n\tsemantic_search: semanticSearchTool,\n\ttodo_write: todoWriteTool,\n\ttodo_read: todoReadTool,\n};\n\nexport type ToolName = keyof typeof allTools;\n\nexport interface ToolsOptions {\n\t/** Options for the read tool */\n\tread?: ReadToolOptions;\n\t/** Options for the bash tool */\n\tbash?: BashToolOptions;\n\t/** Options for the edit tool */\n\tedit?: EditToolOptions;\n\t/** Options for the write tool */\n\twrite?: WriteToolOptions;\n\t/** Options for the semantic_search tool */\n\tsemantic?: SemanticSearchToolOptions;\n}\n\n/**\n * Create coding tools configured for a specific working directory.\n */\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\n/**\n * Create read-only tools configured for a specific working directory.\n */\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd),\n\t\tcreateFindTool(cwd),\n\t\tcreateLsTool(cwd),\n\t\tcreateRgTool(cwd),\n\t\tcreateFdTool(cwd),\n\t\tcreateAstGrepTool(cwd),\n\t\tcreateCombyTool(cwd),\n\t\tcreateJqTool(cwd),\n\t\tcreateYqTool(cwd),\n\t\tcreateSemgrepTool(cwd),\n\t\tcreateSedTool(cwd),\n\t\tcreateSemanticSearchTool(cwd, options?.semantic),\n\t];\n}\n\n/**\n * Create all tools configured for a specific working directory.\n */\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd),\n\t\tfind: createFindTool(cwd),\n\t\tls: createLsTool(cwd),\n\t\trg: createRgTool(cwd),\n\t\tfd: createFdTool(cwd),\n\t\tast_grep: createAstGrepTool(cwd),\n\t\tcomby: createCombyTool(cwd),\n\t\tjq: createJqTool(cwd),\n\t\tyq: createYqTool(cwd),\n\t\tsemgrep: createSemgrepTool(cwd),\n\t\tsed: createSedTool(cwd),\n\t\tsemantic_search: createSemanticSearchTool(cwd, options?.semantic),\n\t\ttodo_write: todoWriteTool,\n\t\ttodo_read: todoReadTool,\n\t};\n}\n\n/**\n * Create a filtered set of tools from a list of tool names.\n * Used by agent profiles and the Task tool to configure subagent capabilities.\n */\nexport function createToolsFromNames(cwd: string, names: string[], options?: ToolsOptions): Tool[] {\n\tconst all = createAllTools(cwd, options);\n\treturn names\n\t\t.filter((n): n is ToolName => n in all)\n\t\t.map((n) => all[n]);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools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sB;IACxF,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACzC,OAAO,KAAK;SACV,MAAM,CAAC,CAAC,CAAC,EAAiB,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC;SACtC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACtB,CAAC","sourcesContent":["export {\n\tcreateAstGrepTool,\n\ttype AstGrepToolInput,\n\tastGrepTool,\n} from \"./ast-grep.js\";\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tbashTool,\n\tcreateBashTool,\n} from \"./bash.js\";\nexport {\n\ttype CombyToolInput,\n\tcombyTool,\n\tcreateCombyTool,\n} from \"./comby.js\";\nexport {\n\tcreateEditTool,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n\teditTool,\n} from \"./edit.js\";\nexport {\n\tcreateFetchTool,\n\ttype FetchToolDetails,\n\ttype FetchToolInput,\n\ttype FetchToolOptions,\n\ttype FetchMethod,\n\ttype FetchResponseFormat,\n\tDEFAULT_FETCH_TIMEOUT_SECONDS,\n\tDEFAULT_FETCH_MAX_BYTES,\n\tDEFAULT_FETCH_MAX_REDIRECTS,\n\tgetAllowedFetchMethodsForProfile,\n\tfetchTool,\n} from \"./fetch.js\";\nexport {\n\ttype ExternalCliToolDetails,\n\ttype ExternalCliToolInput,\n\ttype ExternalCliToolOptions,\n\tcreateExternalCliTool,\n} from \"./external-cli.js\";\nexport {\n\tcreateFdTool,\n\ttype FdToolInput,\n\tfdTool,\n} from \"./fd.js\";\nexport {\n\tcreateFindTool,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n\tfindTool,\n} from \"./find.js\";\nexport {\n\tcreateFsOpsTool,\n\ttype FsOpsToolDetails,\n\ttype FsOpsToolInput,\n\ttype FsOpsToolOptions,\n\tfsOpsTool,\n} from \"./fs-ops.js\";\nexport {\n\tcreateGrepTool,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n\tgrepTool,\n} from \"./grep.js\";\nexport {\n\tcreateGitReadTool,\n\ttype GitReadToolDetails,\n\ttype GitReadToolInput,\n\ttype GitReadToolOptions,\n\tgitReadTool,\n} from \"./git-read.js\";\nexport {\n\tcreateJqTool,\n\ttype JqToolInput,\n\tjqTool,\n} from \"./jq.js\";\nexport {\n\tcreateLsTool,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n\tlsTool,\n} from \"./ls.js\";\nexport {\n\tcreateReadTool,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n\treadTool,\n} from \"./read.js\";\nexport {\n\tcreateRgTool,\n\ttype RgToolInput,\n\trgTool,\n} from \"./rg.js\";\nexport {\n\tcreateSedTool,\n\ttype SedToolInput,\n\tsedTool,\n} from \"./sed.js\";\nexport {\n\tcreateSemgrepTool,\n\ttype SemgrepToolInput,\n\tsemgrepTool,\n} from \"./semgrep.js\";\nexport {\n\tcreateSemanticSearchTool,\n\ttype SemanticSearchToolInput,\n\ttype SemanticSearchToolOptions,\n\tsemanticSearchTool,\n} from \"./semantic-search.js\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.js\";\nexport {\n\tcreateWriteTool,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n\twriteTool,\n} from \"./write.js\";\nexport { type ToolPermissionGuard, type ToolPermissionRequest } from \"./permissions.js\";\nexport {\n\tcreateTodoWriteTool,\n\tcreateTodoReadTool,\n\ttodoWriteTool,\n\ttodoReadTool,\n\tgetTaskFilePath,\n\ttype TodoTask,\n\ttype TodoTaskStatus,\n\ttype TodoWriteInput,\n\ttype TodoReadInput,\n} from \"./todo.js\";\nexport {\n\tcreateYqTool,\n\ttype YqToolInput,\n\tyqTool,\n} from \"./yq.js\";\nexport {\n\tcreateTaskTool,\n\ttype SubagentRunner,\n\ttype TaskToolProgress,\n\ttype TaskToolProgressPhase,\n\ttype TaskToolInput,\n\ttype TaskToolDetails,\n} from \"./task.js\";\n\nimport type { AgentTool } from \"@mariozechner/pi-agent-core\";\nimport { astGrepTool, createAstGrepTool } from \"./ast-grep.js\";\nimport { type BashToolOptions, bashTool, createBashTool } from \"./bash.js\";\nimport { combyTool, createCombyTool } from \"./comby.js\";\nimport { createEditTool, type EditToolOptions, editTool } from \"./edit.js\";\nimport {\n\tcreateFetchTool,\n\ttype FetchToolOptions,\n\tfetchTool,\n\tgetAllowedFetchMethodsForProfile,\n} from \"./fetch.js\";\nimport { createFdTool, fdTool } from \"./fd.js\";\nimport { createFindTool, findTool } from \"./find.js\";\nimport { createFsOpsTool, type FsOpsToolOptions, fsOpsTool } from \"./fs-ops.js\";\nimport { createGrepTool, grepTool } from \"./grep.js\";\nimport { createGitReadTool, gitReadTool } from \"./git-read.js\";\nimport { createJqTool, jqTool } from \"./jq.js\";\nimport { createLsTool, lsTool } from \"./ls.js\";\nimport { createReadTool, type ReadToolOptions, readTool } from \"./read.js\";\nimport { createRgTool, rgTool } from \"./rg.js\";\nimport { createSedTool, sedTool } from \"./sed.js\";\nimport { createSemgrepTool, semgrepTool } from \"./semgrep.js\";\nimport {\n\tcreateSemanticSearchTool,\n\ttype SemanticSearchToolOptions,\n\tsemanticSearchTool,\n} from \"./semantic-search.js\";\nimport { createWriteTool, type WriteToolOptions, writeTool } from \"./write.js\";\nimport { createYqTool, yqTool } from \"./yq.js\";\nimport { todoWriteTool, todoReadTool } from \"./todo.js\";\n\n/** Tool type (AgentTool from pi-ai) */\nexport type Tool = AgentTool<any>;\n\n// Default tools for full access mode (using process.cwd())\nexport const codingTools: Tool[] = [readTool, bashTool, editTool, writeTool];\n\n// Read-only tools for exploration without modification (using process.cwd())\nexport const readOnlyTools: Tool[] = [\n\treadTool,\n\tgrepTool,\n\tfindTool,\n\tlsTool,\n\trgTool,\n\tfdTool,\n\tastGrepTool,\n\tcombyTool,\n\tjqTool,\n\tyqTool,\n\tsemgrepTool,\n\tsedTool,\n\tsemanticSearchTool,\n\tcreateFetchTool(process.cwd(), {\n\t\tresolveAllowedMethods: () => getAllowedFetchMethodsForProfile(\"plan\"),\n\t}),\n\tgitReadTool,\n];\n\n// All available tools (using process.cwd())\nexport const allTools = {\n\tread: readTool,\n\tbash: bashTool,\n\tedit: editTool,\n\twrite: writeTool,\n\tgrep: grepTool,\n\tfind: findTool,\n\tls: lsTool,\n\trg: rgTool,\n\tfd: fdTool,\n\tast_grep: astGrepTool,\n\tcomby: combyTool,\n\tjq: jqTool,\n\tyq: yqTool,\n\tsemgrep: semgrepTool,\n\tsed: sedTool,\n\tsemantic_search: semanticSearchTool,\n\tfetch: fetchTool,\n\tgit_read: gitReadTool,\n\tfs_ops: fsOpsTool,\n\ttodo_write: todoWriteTool,\n\ttodo_read: todoReadTool,\n};\n\nexport type ToolName = keyof typeof allTools;\n\nexport interface ToolsOptions {\n\t/** Options for the read tool */\n\tread?: ReadToolOptions;\n\t/** Options for the bash tool */\n\tbash?: BashToolOptions;\n\t/** Options for the edit tool */\n\tedit?: EditToolOptions;\n\t/** Options for the write tool */\n\twrite?: WriteToolOptions;\n\t/** Options for the semantic_search tool */\n\tsemantic?: SemanticSearchToolOptions;\n\t/** Options for the fetch tool */\n\tfetch?: FetchToolOptions;\n\t/** Options for the fs_ops tool */\n\tfsOps?: FsOpsToolOptions;\n}\n\n/**\n * Create coding tools configured for a specific working directory.\n */\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\n/**\n * Create read-only tools configured for a specific working directory.\n */\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\tconst fetchOptions: FetchToolOptions = {\n\t\t...(options?.fetch ?? {}),\n\t\tresolveAllowedMethods:\n\t\t\toptions?.fetch?.resolveAllowedMethods ?? (() => getAllowedFetchMethodsForProfile(\"plan\")),\n\t};\n\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd),\n\t\tcreateFindTool(cwd),\n\t\tcreateLsTool(cwd),\n\t\tcreateRgTool(cwd),\n\t\tcreateFdTool(cwd),\n\t\tcreateAstGrepTool(cwd),\n\t\tcreateCombyTool(cwd),\n\t\tcreateJqTool(cwd),\n\t\tcreateYqTool(cwd),\n\t\tcreateSemgrepTool(cwd),\n\t\tcreateSedTool(cwd),\n\t\tcreateSemanticSearchTool(cwd, options?.semantic),\n\t\tcreateFetchTool(cwd, fetchOptions),\n\t\tcreateGitReadTool(cwd),\n\t];\n}\n\n/**\n * Create all tools configured for a specific working directory.\n */\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd),\n\t\tfind: createFindTool(cwd),\n\t\tls: createLsTool(cwd),\n\t\trg: createRgTool(cwd),\n\t\tfd: createFdTool(cwd),\n\t\tast_grep: createAstGrepTool(cwd),\n\t\tcomby: createCombyTool(cwd),\n\t\tjq: createJqTool(cwd),\n\t\tyq: createYqTool(cwd),\n\t\tsemgrep: createSemgrepTool(cwd),\n\t\tsed: createSedTool(cwd),\n\t\tsemantic_search: createSemanticSearchTool(cwd, options?.semantic),\n\t\tfetch: createFetchTool(cwd, options?.fetch),\n\t\tgit_read: createGitReadTool(cwd),\n\t\tfs_ops: createFsOpsTool(cwd, options?.fsOps),\n\t\ttodo_write: todoWriteTool,\n\t\ttodo_read: todoReadTool,\n\t};\n}\n\n/**\n * Create a filtered set of tools from a list of tool names.\n * Used by agent profiles and the Task tool to configure subagent capabilities.\n */\nexport function createToolsFromNames(cwd: string, names: string[], options?: ToolsOptions): Tool[] {\n\tconst all = createAllTools(cwd, options);\n\treturn names\n\t\t.filter((n): n is ToolName => n in all)\n\t\t.map((n) => all[n]);\n}\n"]}
|