@nervekit/tools 0.1.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/LICENSE +201 -0
- package/NOTICE +5 -0
- package/dist/catalog/core/filesystem.tools.d.ts +140 -0
- package/dist/catalog/core/filesystem.tools.d.ts.map +1 -0
- package/dist/catalog/core/filesystem.tools.js +221 -0
- package/dist/catalog/core/filesystem.tools.js.map +1 -0
- package/dist/catalog/core/interaction.tools.d.ts +37 -0
- package/dist/catalog/core/interaction.tools.d.ts.map +1 -0
- package/dist/catalog/core/interaction.tools.js +55 -0
- package/dist/catalog/core/interaction.tools.js.map +1 -0
- package/dist/catalog/core/python.tools.d.ts +17 -0
- package/dist/catalog/core/python.tools.d.ts.map +1 -0
- package/dist/catalog/core/python.tools.js +32 -0
- package/dist/catalog/core/python.tools.js.map +1 -0
- package/dist/catalog/core/shell.tools.d.ts +14 -0
- package/dist/catalog/core/shell.tools.d.ts.map +1 -0
- package/dist/catalog/core/shell.tools.js +22 -0
- package/dist/catalog/core/shell.tools.js.map +1 -0
- package/dist/catalog/core/web.tools.d.ts +23 -0
- package/dist/catalog/core/web.tools.d.ts.map +1 -0
- package/dist/catalog/core/web.tools.js +34 -0
- package/dist/catalog/core/web.tools.js.map +1 -0
- package/dist/catalog/descriptors.d.ts +4 -0
- package/dist/catalog/descriptors.d.ts.map +1 -0
- package/dist/catalog/descriptors.js +17 -0
- package/dist/catalog/descriptors.js.map +1 -0
- package/dist/catalog/index.d.ts +18 -0
- package/dist/catalog/index.d.ts.map +1 -0
- package/dist/catalog/index.js +44 -0
- package/dist/catalog/index.js.map +1 -0
- package/dist/catalog/orchestration/explore.tools.d.ts +20 -0
- package/dist/catalog/orchestration/explore.tools.d.ts.map +1 -0
- package/dist/catalog/orchestration/explore.tools.js +42 -0
- package/dist/catalog/orchestration/explore.tools.js.map +1 -0
- package/dist/catalog/orchestration/plan-mode.tools.d.ts +32 -0
- package/dist/catalog/orchestration/plan-mode.tools.d.ts.map +1 -0
- package/dist/catalog/orchestration/plan-mode.tools.js +43 -0
- package/dist/catalog/orchestration/plan-mode.tools.js.map +1 -0
- package/dist/catalog/orchestration/process.tools.d.ts +68 -0
- package/dist/catalog/orchestration/process.tools.d.ts.map +1 -0
- package/dist/catalog/orchestration/process.tools.js +96 -0
- package/dist/catalog/orchestration/process.tools.js.map +1 -0
- package/dist/catalog/orchestration/subagent.tools.d.ts +16 -0
- package/dist/catalog/orchestration/subagent.tools.d.ts.map +1 -0
- package/dist/catalog/orchestration/subagent.tools.js +25 -0
- package/dist/catalog/orchestration/subagent.tools.js.map +1 -0
- package/dist/catalog/orchestration/task.tools.d.ts +107 -0
- package/dist/catalog/orchestration/task.tools.d.ts.map +1 -0
- package/dist/catalog/orchestration/task.tools.js +170 -0
- package/dist/catalog/orchestration/task.tools.js.map +1 -0
- package/dist/catalog/risk.d.ts +3 -0
- package/dist/catalog/risk.d.ts.map +1 -0
- package/dist/catalog/risk.js +29 -0
- package/dist/catalog/risk.js.map +1 -0
- package/dist/catalog/types.d.ts +14 -0
- package/dist/catalog/types.d.ts.map +1 -0
- package/dist/catalog/types.js +2 -0
- package/dist/catalog/types.js.map +1 -0
- package/dist/definitions.d.ts +2 -0
- package/dist/definitions.d.ts.map +1 -0
- package/dist/definitions.js +2 -0
- package/dist/definitions.js.map +1 -0
- package/dist/execution/atomic-write.d.ts +2 -0
- package/dist/execution/atomic-write.d.ts.map +1 -0
- package/dist/execution/atomic-write.js +7 -0
- package/dist/execution/atomic-write.js.map +1 -0
- package/dist/execution/bash.d.ts +3 -0
- package/dist/execution/bash.d.ts.map +1 -0
- package/dist/execution/bash.js +133 -0
- package/dist/execution/bash.js.map +1 -0
- package/dist/execution/common/args.d.ts +2 -0
- package/dist/execution/common/args.d.ts.map +1 -0
- package/dist/execution/common/args.js +6 -0
- package/dist/execution/common/args.js.map +1 -0
- package/dist/execution/common/output-budget.d.ts +61 -0
- package/dist/execution/common/output-budget.d.ts.map +1 -0
- package/dist/execution/common/output-budget.js +140 -0
- package/dist/execution/common/output-budget.js.map +1 -0
- package/dist/execution/common/process-result.d.ts +44 -0
- package/dist/execution/common/process-result.d.ts.map +1 -0
- package/dist/execution/common/process-result.js +322 -0
- package/dist/execution/common/process-result.js.map +1 -0
- package/dist/execution/common/search-utils.d.ts +8 -0
- package/dist/execution/common/search-utils.d.ts.map +1 -0
- package/dist/execution/common/search-utils.js +110 -0
- package/dist/execution/common/search-utils.js.map +1 -0
- package/dist/execution/common/tool-error.d.ts +8 -0
- package/dist/execution/common/tool-error.d.ts.map +1 -0
- package/dist/execution/common/tool-error.js +14 -0
- package/dist/execution/common/tool-error.js.map +1 -0
- package/dist/execution/common/truncate.d.ts +27 -0
- package/dist/execution/common/truncate.d.ts.map +1 -0
- package/dist/execution/common/truncate.js +108 -0
- package/dist/execution/common/truncate.js.map +1 -0
- package/dist/execution/common.d.ts +2 -0
- package/dist/execution/common.d.ts.map +1 -0
- package/dist/execution/common.js +6 -0
- package/dist/execution/common.js.map +1 -0
- package/dist/execution/core-dispatch.d.ts +4 -0
- package/dist/execution/core-dispatch.d.ts.map +1 -0
- package/dist/execution/core-dispatch.js +58 -0
- package/dist/execution/core-dispatch.js.map +1 -0
- package/dist/execution/dispatch.d.ts +4 -0
- package/dist/execution/dispatch.d.ts.map +1 -0
- package/dist/execution/dispatch.js +54 -0
- package/dist/execution/dispatch.js.map +1 -0
- package/dist/execution/edit.d.ts +9 -0
- package/dist/execution/edit.d.ts.map +1 -0
- package/dist/execution/edit.js +175 -0
- package/dist/execution/edit.js.map +1 -0
- package/dist/execution/file-mutation-queue.d.ts +2 -0
- package/dist/execution/file-mutation-queue.d.ts.map +1 -0
- package/dist/execution/file-mutation-queue.js +19 -0
- package/dist/execution/file-mutation-queue.js.map +1 -0
- package/dist/execution/filesystem/atomic-write.d.ts +2 -0
- package/dist/execution/filesystem/atomic-write.d.ts.map +1 -0
- package/dist/execution/filesystem/atomic-write.js +7 -0
- package/dist/execution/filesystem/atomic-write.js.map +1 -0
- package/dist/execution/filesystem/edit-args.d.ts +46 -0
- package/dist/execution/filesystem/edit-args.d.ts.map +1 -0
- package/dist/execution/filesystem/edit-args.js +212 -0
- package/dist/execution/filesystem/edit-args.js.map +1 -0
- package/dist/execution/filesystem/edit-errors.d.ts +4 -0
- package/dist/execution/filesystem/edit-errors.d.ts.map +1 -0
- package/dist/execution/filesystem/edit-errors.js +8 -0
- package/dist/execution/filesystem/edit-errors.js.map +1 -0
- package/dist/execution/filesystem/edit.d.ts +4 -0
- package/dist/execution/filesystem/edit.d.ts.map +1 -0
- package/dist/execution/filesystem/edit.js +330 -0
- package/dist/execution/filesystem/edit.js.map +1 -0
- package/dist/execution/filesystem/file-mutation-queue.d.ts +2 -0
- package/dist/execution/filesystem/file-mutation-queue.d.ts.map +1 -0
- package/dist/execution/filesystem/file-mutation-queue.js +19 -0
- package/dist/execution/filesystem/file-mutation-queue.js.map +1 -0
- package/dist/execution/filesystem/find.d.ts +3 -0
- package/dist/execution/filesystem/find.d.ts.map +1 -0
- package/dist/execution/filesystem/find.js +93 -0
- package/dist/execution/filesystem/find.js.map +1 -0
- package/dist/execution/filesystem/legacy-edit.d.ts +9 -0
- package/dist/execution/filesystem/legacy-edit.d.ts.map +1 -0
- package/dist/execution/filesystem/legacy-edit.js +122 -0
- package/dist/execution/filesystem/legacy-edit.js.map +1 -0
- package/dist/execution/filesystem/list.d.ts +3 -0
- package/dist/execution/filesystem/list.d.ts.map +1 -0
- package/dist/execution/filesystem/list.js +49 -0
- package/dist/execution/filesystem/list.js.map +1 -0
- package/dist/execution/filesystem/path.d.ts +7 -0
- package/dist/execution/filesystem/path.d.ts.map +1 -0
- package/dist/execution/filesystem/path.js +69 -0
- package/dist/execution/filesystem/path.js.map +1 -0
- package/dist/execution/filesystem/read.d.ts +3 -0
- package/dist/execution/filesystem/read.d.ts.map +1 -0
- package/dist/execution/filesystem/read.js +225 -0
- package/dist/execution/filesystem/read.js.map +1 -0
- package/dist/execution/filesystem/search.d.ts +3 -0
- package/dist/execution/filesystem/search.d.ts.map +1 -0
- package/dist/execution/filesystem/search.js +149 -0
- package/dist/execution/filesystem/search.js.map +1 -0
- package/dist/execution/filesystem/smart-match.d.ts +31 -0
- package/dist/execution/filesystem/smart-match.d.ts.map +1 -0
- package/dist/execution/filesystem/smart-match.js +309 -0
- package/dist/execution/filesystem/smart-match.js.map +1 -0
- package/dist/execution/filesystem/text-editing.d.ts +9 -0
- package/dist/execution/filesystem/text-editing.d.ts.map +1 -0
- package/dist/execution/filesystem/text-editing.js +43 -0
- package/dist/execution/filesystem/text-editing.js.map +1 -0
- package/dist/execution/filesystem/write.d.ts +3 -0
- package/dist/execution/filesystem/write.d.ts.map +1 -0
- package/dist/execution/filesystem/write.js +21 -0
- package/dist/execution/filesystem/write.js.map +1 -0
- package/dist/execution/find.d.ts +3 -0
- package/dist/execution/find.d.ts.map +1 -0
- package/dist/execution/find.js +90 -0
- package/dist/execution/find.js.map +1 -0
- package/dist/execution/index.d.ts +18 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +17 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/list.d.ts +3 -0
- package/dist/execution/list.d.ts.map +1 -0
- package/dist/execution/list.js +46 -0
- package/dist/execution/list.js.map +1 -0
- package/dist/execution/path.d.ts +7 -0
- package/dist/execution/path.d.ts.map +1 -0
- package/dist/execution/path.js +69 -0
- package/dist/execution/path.js.map +1 -0
- package/dist/execution/python/python.d.ts +3 -0
- package/dist/execution/python/python.d.ts.map +1 -0
- package/dist/execution/python/python.js +566 -0
- package/dist/execution/python/python.js.map +1 -0
- package/dist/execution/python/runtime.d.ts +22 -0
- package/dist/execution/python/runtime.d.ts.map +1 -0
- package/dist/execution/python/runtime.js +178 -0
- package/dist/execution/python/runtime.js.map +1 -0
- package/dist/execution/read.d.ts +3 -0
- package/dist/execution/read.d.ts.map +1 -0
- package/dist/execution/read.js +97 -0
- package/dist/execution/read.js.map +1 -0
- package/dist/execution/search-utils.d.ts +8 -0
- package/dist/execution/search-utils.d.ts.map +1 -0
- package/dist/execution/search-utils.js +110 -0
- package/dist/execution/search-utils.js.map +1 -0
- package/dist/execution/search.d.ts +3 -0
- package/dist/execution/search.d.ts.map +1 -0
- package/dist/execution/search.js +131 -0
- package/dist/execution/search.js.map +1 -0
- package/dist/execution/shell/bash.d.ts +3 -0
- package/dist/execution/shell/bash.d.ts.map +1 -0
- package/dist/execution/shell/bash.js +134 -0
- package/dist/execution/shell/bash.js.map +1 -0
- package/dist/execution/truncate.d.ts +21 -0
- package/dist/execution/truncate.d.ts.map +1 -0
- package/dist/execution/truncate.js +94 -0
- package/dist/execution/truncate.js.map +1 -0
- package/dist/execution/web/web-fetch.d.ts +3 -0
- package/dist/execution/web/web-fetch.d.ts.map +1 -0
- package/dist/execution/web/web-fetch.js +132 -0
- package/dist/execution/web/web-fetch.js.map +1 -0
- package/dist/execution/web/web-search.d.ts +3 -0
- package/dist/execution/web/web-search.d.ts.map +1 -0
- package/dist/execution/web/web-search.js +59 -0
- package/dist/execution/web/web-search.js.map +1 -0
- package/dist/execution/web-fetch.d.ts +3 -0
- package/dist/execution/web-fetch.d.ts.map +1 -0
- package/dist/execution/web-fetch.js +132 -0
- package/dist/execution/web-fetch.js.map +1 -0
- package/dist/execution/web-search.d.ts +3 -0
- package/dist/execution/web-search.d.ts.map +1 -0
- package/dist/execution/web-search.js +59 -0
- package/dist/execution/web-search.js.map +1 -0
- package/dist/execution/write.d.ts +3 -0
- package/dist/execution/write.d.ts.map +1 -0
- package/dist/execution/write.js +21 -0
- package/dist/execution/write.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/safety/command-policy-git.d.ts +2 -0
- package/dist/safety/command-policy-git.d.ts.map +1 -0
- package/dist/safety/command-policy-git.js +88 -0
- package/dist/safety/command-policy-git.js.map +1 -0
- package/dist/safety/command-policy-options.d.ts +6 -0
- package/dist/safety/command-policy-options.d.ts.map +1 -0
- package/dist/safety/command-policy-options.js +112 -0
- package/dist/safety/command-policy-options.js.map +1 -0
- package/dist/safety/command-policy-packages.d.ts +4 -0
- package/dist/safety/command-policy-packages.d.ts.map +1 -0
- package/dist/safety/command-policy-packages.js +161 -0
- package/dist/safety/command-policy-packages.js.map +1 -0
- package/dist/safety/command-policy-parser.d.ts +11 -0
- package/dist/safety/command-policy-parser.d.ts.map +1 -0
- package/dist/safety/command-policy-parser.js +121 -0
- package/dist/safety/command-policy-parser.js.map +1 -0
- package/dist/safety/command-policy-wrappers.d.ts +6 -0
- package/dist/safety/command-policy-wrappers.d.ts.map +1 -0
- package/dist/safety/command-policy-wrappers.js +95 -0
- package/dist/safety/command-policy-wrappers.js.map +1 -0
- package/dist/safety/command-policy.d.ts +6 -0
- package/dist/safety/command-policy.d.ts.map +1 -0
- package/dist/safety/command-policy.js +118 -0
- package/dist/safety/command-policy.js.map +1 -0
- package/dist/types.d.ts +78 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { mkdir } from "node:fs/promises";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { writeTextFileAtomically } from "./atomic-write.js";
|
|
4
|
+
import { withFileMutationQueue } from "./file-mutation-queue.js";
|
|
5
|
+
import { resolveToolPath } from "./path.js";
|
|
6
|
+
export async function executeWrite(args, context) {
|
|
7
|
+
const path = resolveToolPath(context.cwd, args.path);
|
|
8
|
+
if (typeof args.content !== "string")
|
|
9
|
+
throw new Error("Tool argument 'content' must be a string.");
|
|
10
|
+
return withFileMutationQueue(path, async () => {
|
|
11
|
+
await mkdir(dirname(path), { recursive: true });
|
|
12
|
+
await writeTextFileAtomically(path, args.content);
|
|
13
|
+
const content = `Wrote ${Buffer.byteLength(args.content, "utf8")} bytes.`;
|
|
14
|
+
return {
|
|
15
|
+
path,
|
|
16
|
+
content,
|
|
17
|
+
contentBlocks: [{ type: "text", text: content }],
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=write.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/execution/filesystem/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAA6B,EAC7B,OAA6B;IAE7B,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACrD,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ;QAClC,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,OAAO,qBAAqB,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE;QAC5C,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAChD,MAAM,uBAAuB,CAAC,IAAI,EAAE,IAAI,CAAC,OAAiB,CAAC,CAAC;QAC5D,MAAM,OAAO,GAAG,SAAS,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,OAAiB,EAAE,MAAM,CAAC,SAAS,CAAC;QACpF,OAAO;YACL,IAAI;YACJ,OAAO;YACP,aAAa,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;SACjD,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../src/execution/find.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAY7E,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CA0B9B"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { stat } from "node:fs/promises";
|
|
3
|
+
import { relative } from "node:path";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
import { numberArg } from "./common.js";
|
|
6
|
+
import { isErrnoException, pathNotFoundMessage, resolveToolPath, } from "./path.js";
|
|
7
|
+
import { globToRegExp, walkFiles } from "./search-utils.js";
|
|
8
|
+
import { truncateHead } from "./truncate.js";
|
|
9
|
+
const execFileAsync = promisify(execFile);
|
|
10
|
+
export async function executeFind(args, context) {
|
|
11
|
+
if (typeof args.pattern !== "string" || args.pattern.length === 0) {
|
|
12
|
+
throw new Error("Tool argument 'pattern' must be a non-empty string.");
|
|
13
|
+
}
|
|
14
|
+
const input = args.path ?? ".";
|
|
15
|
+
const root = resolveToolPath(context.cwd, input);
|
|
16
|
+
await stat(root).catch((error) => {
|
|
17
|
+
if (isErrnoException(error) && error.code === "ENOENT") {
|
|
18
|
+
throw new Error(pathNotFoundMessage("find", input, root));
|
|
19
|
+
}
|
|
20
|
+
throw error;
|
|
21
|
+
});
|
|
22
|
+
const limit = Math.min(numberArg(args.limit, 1000), 5000);
|
|
23
|
+
const fd = await runFd(args.pattern, root, limit).catch(() => undefined);
|
|
24
|
+
const paths = fd ?? (await fallbackFind(root, args.pattern, limit));
|
|
25
|
+
const entries = paths
|
|
26
|
+
.slice(0, limit)
|
|
27
|
+
.map((path) => ({ path, kind: "file" }));
|
|
28
|
+
const formatted = formatFind(paths, limit);
|
|
29
|
+
return {
|
|
30
|
+
path: root,
|
|
31
|
+
entries,
|
|
32
|
+
content: formatted.content,
|
|
33
|
+
contentBlocks: [{ type: "text", text: formatted.content }],
|
|
34
|
+
details: formatted.details,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
async function runFd(pattern, root, limit) {
|
|
38
|
+
const fdArgs = [
|
|
39
|
+
"--hidden",
|
|
40
|
+
"--glob",
|
|
41
|
+
"--type",
|
|
42
|
+
"file",
|
|
43
|
+
"--color=never",
|
|
44
|
+
"--no-require-git",
|
|
45
|
+
"--max-results",
|
|
46
|
+
String(limit),
|
|
47
|
+
];
|
|
48
|
+
let effectivePattern = pattern;
|
|
49
|
+
if (pattern.includes("/")) {
|
|
50
|
+
fdArgs.push("--full-path");
|
|
51
|
+
if (!pattern.startsWith("/") && !pattern.startsWith("**/")) {
|
|
52
|
+
effectivePattern = `**/${pattern}`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
fdArgs.push("--", effectivePattern, root);
|
|
56
|
+
const { stdout } = await execFileAsync("fd", fdArgs, {
|
|
57
|
+
timeout: 30_000,
|
|
58
|
+
maxBuffer: 1024 * 1024,
|
|
59
|
+
});
|
|
60
|
+
return stdout
|
|
61
|
+
.split(/\r?\n/)
|
|
62
|
+
.map((line) => line.trim())
|
|
63
|
+
.filter(Boolean)
|
|
64
|
+
.map((path) => (relative(root, path) || path).replaceAll("\\", "/"));
|
|
65
|
+
}
|
|
66
|
+
async function fallbackFind(root, pattern, limit) {
|
|
67
|
+
const results = [];
|
|
68
|
+
const regex = globToRegExp(pattern);
|
|
69
|
+
await walkFiles(root, root, limit, async (_absolutePath, relativePath) => {
|
|
70
|
+
if (regex.test(relativePath))
|
|
71
|
+
results.push(relativePath.replaceAll("\\", "/"));
|
|
72
|
+
}, () => results.length >= limit);
|
|
73
|
+
return results;
|
|
74
|
+
}
|
|
75
|
+
function formatFind(paths, limit) {
|
|
76
|
+
const lines = paths.slice(0, limit);
|
|
77
|
+
if (lines.length === 0)
|
|
78
|
+
lines.push("No files found.");
|
|
79
|
+
if (paths.length >= limit) {
|
|
80
|
+
lines.push("", `[Result limit ${limit} reached. Increase limit or refine the pattern for more results.]`);
|
|
81
|
+
}
|
|
82
|
+
const truncated = truncateHead(lines.join("\n"), {
|
|
83
|
+
maxLines: Number.MAX_SAFE_INTEGER,
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
content: truncated.text,
|
|
87
|
+
details: truncated.truncated ? { truncation: truncated } : undefined,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=find.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../src/execution/find.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,GAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,IAA6B,EAC7B,OAA6B;IAE7B,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,KAA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, type BoundedTextResult, boundContentBlocks, boundLiveOutputChunk, boundText, FILE_OUTPUT_MAX_LINE_CHARS, LIVE_OUTPUT_MAX_BYTES, LIVE_OUTPUT_MAX_LINE_CHARS, LIVE_OUTPUT_MAX_LINES, MODEL_TEXT_MAX_BYTES, MODEL_TEXT_MAX_LINE_CHARS, MODEL_TEXT_MAX_LINES, PROCESS_INLINE_MAX_LINE_CHARS, type TextBoundaryDetails, type TextBudget, textBoundaryDetails, } from "./common/output-budget.js";
|
|
2
|
+
export { buildProcessResult, buildProcessTextResult, } from "./common/process-result.js";
|
|
3
|
+
export { ToolExecutionError } from "./common/tool-error.js";
|
|
4
|
+
export { executeTool } from "./core-dispatch.js";
|
|
5
|
+
export { executeEdit, normalizeEditArgs } from "./filesystem/edit.js";
|
|
6
|
+
export { executeFind } from "./filesystem/find.js";
|
|
7
|
+
export { executeLs } from "./filesystem/list.js";
|
|
8
|
+
export { resolveToolPath } from "./filesystem/path.js";
|
|
9
|
+
export { executeRead } from "./filesystem/read.js";
|
|
10
|
+
export { executeGrep } from "./filesystem/search.js";
|
|
11
|
+
export { executeWrite } from "./filesystem/write.js";
|
|
12
|
+
export { executePython } from "./python/python.js";
|
|
13
|
+
export type { PythonRuntime, PythonRuntimeStatus } from "./python/runtime.js";
|
|
14
|
+
export { resolvePythonRuntime } from "./python/runtime.js";
|
|
15
|
+
export { executeBash } from "./shell/bash.js";
|
|
16
|
+
export { executeWebFetch } from "./web/web-fetch.js";
|
|
17
|
+
export { executeWebSearch } from "./web/web-search.js";
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,KAAK,iBAAiB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACT,0BAA0B,EAC1B,qBAAqB,EACrB,0BAA0B,EAC1B,qBAAqB,E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MAX_LINE_CHARS, MODEL_TEXT_MAX_LINES, PROCESS_INLINE_MAX_LINE_CHARS, textBoundaryDetails, } from "./common/output-budget.js";
|
|
2
|
+
export { buildProcessResult, buildProcessTextResult, } from "./common/process-result.js";
|
|
3
|
+
export { ToolExecutionError } from "./common/tool-error.js";
|
|
4
|
+
export { executeTool } from "./core-dispatch.js";
|
|
5
|
+
export { executeEdit, normalizeEditArgs } from "./filesystem/edit.js";
|
|
6
|
+
export { executeFind } from "./filesystem/find.js";
|
|
7
|
+
export { executeLs } from "./filesystem/list.js";
|
|
8
|
+
export { resolveToolPath } from "./filesystem/path.js";
|
|
9
|
+
export { executeRead } from "./filesystem/read.js";
|
|
10
|
+
export { executeGrep } from "./filesystem/search.js";
|
|
11
|
+
export { executeWrite } from "./filesystem/write.js";
|
|
12
|
+
export { executePython } from "./python/python.js";
|
|
13
|
+
export { resolvePythonRuntime } from "./python/runtime.js";
|
|
14
|
+
export { executeBash } from "./shell/bash.js";
|
|
15
|
+
export { executeWebFetch } from "./web/web-fetch.js";
|
|
16
|
+
export { executeWebSearch } from "./web/web-search.js";
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAEvB,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACT,0BAA0B,EAC1B,qBAAqB,EACrB,0BAA0B,EAC1B,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EACzB,oBAAoB,EACpB,6BAA6B,EAG7B,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/execution/list.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAS7E,wBAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CA2C9B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { readdir, stat } from "node:fs/promises";
|
|
2
|
+
import { numberArg } from "./common.js";
|
|
3
|
+
import { isErrnoException, pathNotFoundMessage, resolveToolPath, } from "./path.js";
|
|
4
|
+
import { truncateHead } from "./truncate.js";
|
|
5
|
+
export async function executeLs(args, context) {
|
|
6
|
+
const input = args.path ?? ".";
|
|
7
|
+
const root = resolveToolPath(context.cwd, input);
|
|
8
|
+
const info = await stat(root).catch((error) => {
|
|
9
|
+
if (isErrnoException(error) && error.code === "ENOENT") {
|
|
10
|
+
throw new Error(pathNotFoundMessage("ls", input, root));
|
|
11
|
+
}
|
|
12
|
+
throw error;
|
|
13
|
+
});
|
|
14
|
+
if (!info.isDirectory())
|
|
15
|
+
throw new Error("ls path is not a directory.");
|
|
16
|
+
const limit = Math.min(numberArg(args.limit, 500), 5000);
|
|
17
|
+
const dirEntries = await readdir(root, { withFileTypes: true });
|
|
18
|
+
dirEntries.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()));
|
|
19
|
+
const entries = [];
|
|
20
|
+
for (const entry of dirEntries.slice(0, limit)) {
|
|
21
|
+
entries.push({
|
|
22
|
+
path: `${entry.name}${entry.isDirectory() ? "/" : ""}`,
|
|
23
|
+
kind: entry.isDirectory()
|
|
24
|
+
? "directory"
|
|
25
|
+
: entry.isFile()
|
|
26
|
+
? "file"
|
|
27
|
+
: "other",
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
let content = entries.map((entry) => entry.path).join("\n");
|
|
31
|
+
if (dirEntries.length > entries.length) {
|
|
32
|
+
content += `${content ? "\n\n" : ""}[...${dirEntries.length - entries.length} more entries. Increase limit to see more.]`;
|
|
33
|
+
}
|
|
34
|
+
const truncated = truncateHead(content, {
|
|
35
|
+
maxLines: Number.MAX_SAFE_INTEGER,
|
|
36
|
+
});
|
|
37
|
+
content = truncated.text;
|
|
38
|
+
return {
|
|
39
|
+
path: root,
|
|
40
|
+
entries,
|
|
41
|
+
content,
|
|
42
|
+
contentBlocks: [{ type: "text", text: content }],
|
|
43
|
+
details: truncated.truncated ? { truncation: truncated } : undefined,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/execution/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM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}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function expandToolPathInput(input: string): string;
|
|
2
|
+
export declare function resolveToCwd(cwd: string, input: string): string;
|
|
3
|
+
export declare function resolveToolPath(cwd: string, input: unknown): string;
|
|
4
|
+
export declare function isErrnoException(error: unknown): error is NodeJS.ErrnoException;
|
|
5
|
+
export declare function pathNotFoundMessage(toolName: string, input: unknown, resolvedPath: string): string;
|
|
6
|
+
export declare function resolveReadPath(cwd: string, input: unknown): Promise<string>;
|
|
7
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/execution/path.ts"],"names":[],"mappings":"AAMA,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQzD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAG/D;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAKnE;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,MAAM,CAAC,cAAc,CAEhC;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,EACd,YAAY,EAAE,MAAM,GACnB,MAAM,CAGR;AAED,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,MAAM,CAAC,CAOjB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { access } from "node:fs/promises";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { isAbsolute, resolve } from "node:path";
|
|
4
|
+
const UNICODE_SPACES = /[\u00a0\u2007\u202f]/g;
|
|
5
|
+
export function expandToolPathInput(input) {
|
|
6
|
+
let path = input.trim().replace(UNICODE_SPACES, " ").normalize("NFC");
|
|
7
|
+
if (path.startsWith("@"))
|
|
8
|
+
path = path.slice(1);
|
|
9
|
+
if (path === "~")
|
|
10
|
+
return homedir();
|
|
11
|
+
if (path.startsWith("~/") || path.startsWith("~\\")) {
|
|
12
|
+
return resolve(homedir(), path.slice(2));
|
|
13
|
+
}
|
|
14
|
+
return path;
|
|
15
|
+
}
|
|
16
|
+
export function resolveToCwd(cwd, input) {
|
|
17
|
+
const expanded = expandToolPathInput(input);
|
|
18
|
+
return isAbsolute(expanded) ? resolve(expanded) : resolve(cwd, expanded);
|
|
19
|
+
}
|
|
20
|
+
export function resolveToolPath(cwd, input) {
|
|
21
|
+
if (typeof input !== "string" || input.trim().length === 0) {
|
|
22
|
+
throw new Error("Tool argument 'path' must be a non-empty string.");
|
|
23
|
+
}
|
|
24
|
+
return resolveToCwd(cwd, input);
|
|
25
|
+
}
|
|
26
|
+
export function isErrnoException(error) {
|
|
27
|
+
return error instanceof Error && "code" in error;
|
|
28
|
+
}
|
|
29
|
+
export function pathNotFoundMessage(toolName, input, resolvedPath) {
|
|
30
|
+
const label = typeof input === "string" ? JSON.stringify(input) : "path";
|
|
31
|
+
return `${toolName} path not found: ${label} (resolved to ${resolvedPath}).`;
|
|
32
|
+
}
|
|
33
|
+
export async function resolveReadPath(cwd, input) {
|
|
34
|
+
const initial = resolveToolPath(cwd, input);
|
|
35
|
+
const candidates = readPathCandidates(initial);
|
|
36
|
+
for (const candidate of candidates) {
|
|
37
|
+
if (await exists(candidate))
|
|
38
|
+
return candidate;
|
|
39
|
+
}
|
|
40
|
+
return initial;
|
|
41
|
+
}
|
|
42
|
+
function readPathCandidates(path) {
|
|
43
|
+
const variants = new Set([
|
|
44
|
+
path,
|
|
45
|
+
path.normalize("NFC"),
|
|
46
|
+
path.normalize("NFD"),
|
|
47
|
+
]);
|
|
48
|
+
for (const value of [...variants]) {
|
|
49
|
+
variants.add(value.replace(UNICODE_SPACES, " "));
|
|
50
|
+
}
|
|
51
|
+
// macOS screenshots sometimes use narrow no-break spaces before AM/PM.
|
|
52
|
+
for (const value of [...variants]) {
|
|
53
|
+
variants.add(value.replace(/ ([AP]M)(\.[^./]+)?$/u, "\u202f$1$2"));
|
|
54
|
+
variants.add(value.replace(/\u202f([AP]M)(\.[^./]+)?$/u, " $1$2"));
|
|
55
|
+
variants.add(value.replace(/[’‘]/g, "'"));
|
|
56
|
+
variants.add(value.replace(/'/g, "’"));
|
|
57
|
+
}
|
|
58
|
+
return [...variants].filter((candidate) => candidate.length > 0);
|
|
59
|
+
}
|
|
60
|
+
async function exists(path) {
|
|
61
|
+
try {
|
|
62
|
+
await access(path);
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":["../../src/execution/path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEhD,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAE/C,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,IAAI,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACtE,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC/C,IAAI,IAAI,KAAK,GAAG;QAAE,OAAO,OAAO,EAAE,CAAC;IACnC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CA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