@tachu/extensions 1.0.0-alpha.3 → 1.0.0-alpha.4
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 +47 -0
- package/README.md +21 -3
- package/README_ZH.md +20 -3
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +2 -1
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +2 -1
- package/dist/providers/openai.js.map +1 -1
- package/dist/tools/apply-patch/executor.d.ts.map +1 -1
- package/dist/tools/apply-patch/executor.js +47 -0
- package/dist/tools/apply-patch/executor.js.map +1 -1
- package/dist/tools/edit-file/executor.d.ts +32 -0
- package/dist/tools/edit-file/executor.d.ts.map +1 -0
- package/dist/tools/edit-file/executor.js +84 -0
- package/dist/tools/edit-file/executor.js.map +1 -0
- package/dist/tools/git-blame/executor.d.ts +24 -0
- package/dist/tools/git-blame/executor.d.ts.map +1 -0
- package/dist/tools/git-blame/executor.js +76 -0
- package/dist/tools/git-blame/executor.js.map +1 -0
- package/dist/tools/git-branch/executor.d.ts +22 -0
- package/dist/tools/git-branch/executor.d.ts.map +1 -0
- package/dist/tools/git-branch/executor.js +81 -0
- package/dist/tools/git-branch/executor.js.map +1 -0
- package/dist/tools/git-diff/executor.d.ts +37 -0
- package/dist/tools/git-diff/executor.d.ts.map +1 -0
- package/dist/tools/git-diff/executor.js +156 -0
- package/dist/tools/git-diff/executor.js.map +1 -0
- package/dist/tools/git-log/executor.d.ts +31 -0
- package/dist/tools/git-log/executor.d.ts.map +1 -0
- package/dist/tools/git-log/executor.js +65 -0
- package/dist/tools/git-log/executor.js.map +1 -0
- package/dist/tools/git-show/executor.d.ts +22 -0
- package/dist/tools/git-show/executor.d.ts.map +1 -0
- package/dist/tools/git-show/executor.js +74 -0
- package/dist/tools/git-show/executor.js.map +1 -0
- package/dist/tools/git-status/executor.d.ts +25 -0
- package/dist/tools/git-status/executor.d.ts.map +1 -0
- package/dist/tools/git-status/executor.js +120 -0
- package/dist/tools/git-status/executor.js.map +1 -0
- package/dist/tools/glob/executor.d.ts +18 -0
- package/dist/tools/glob/executor.d.ts.map +1 -0
- package/dist/tools/glob/executor.js +47 -0
- package/dist/tools/glob/executor.js.map +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +360 -3
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/multi-edit/executor.d.ts +29 -0
- package/dist/tools/multi-edit/executor.d.ts.map +1 -0
- package/dist/tools/multi-edit/executor.js +37 -0
- package/dist/tools/multi-edit/executor.js.map +1 -0
- package/dist/tools/read-file/executor.d.ts +5 -0
- package/dist/tools/read-file/executor.d.ts.map +1 -1
- package/dist/tools/read-file/executor.js +46 -2
- package/dist/tools/read-file/executor.js.map +1 -1
- package/dist/tools/run-shell/executor.d.ts +12 -1
- package/dist/tools/run-shell/executor.d.ts.map +1 -1
- package/dist/tools/run-shell/executor.js +89 -6
- package/dist/tools/run-shell/executor.js.map +1 -1
- package/dist/tools/run-tests/executor.d.ts +28 -0
- package/dist/tools/run-tests/executor.d.ts.map +1 -0
- package/dist/tools/run-tests/executor.js +161 -0
- package/dist/tools/run-tests/executor.js.map +1 -0
- package/dist/tools/run-typecheck/executor.d.ts +25 -0
- package/dist/tools/run-typecheck/executor.d.ts.map +1 -0
- package/dist/tools/run-typecheck/executor.js +83 -0
- package/dist/tools/run-typecheck/executor.js.map +1 -0
- package/dist/tools/todo-read/executor.d.ts +20 -0
- package/dist/tools/todo-read/executor.d.ts.map +1 -0
- package/dist/tools/todo-read/executor.js +26 -0
- package/dist/tools/todo-read/executor.js.map +1 -0
- package/dist/tools/todo-write/executor.d.ts +21 -0
- package/dist/tools/todo-write/executor.d.ts.map +1 -0
- package/dist/tools/todo-write/executor.js +38 -0
- package/dist/tools/todo-write/executor.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ToolExecutor } from "../shared";
|
|
2
|
+
interface GitStatusInput {
|
|
3
|
+
cwd?: string;
|
|
4
|
+
}
|
|
5
|
+
interface GitFileEntry {
|
|
6
|
+
path: string;
|
|
7
|
+
originalPath?: string;
|
|
8
|
+
status: string;
|
|
9
|
+
}
|
|
10
|
+
interface GitStatusOutput {
|
|
11
|
+
branch: string;
|
|
12
|
+
upstream?: string;
|
|
13
|
+
ahead: number;
|
|
14
|
+
behind: number;
|
|
15
|
+
staged: GitFileEntry[];
|
|
16
|
+
unstaged: GitFileEntry[];
|
|
17
|
+
untracked: string[];
|
|
18
|
+
isClean: boolean;
|
|
19
|
+
detachedHead: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare const gitStatusExecutor: ToolExecutor<GitStatusInput, GitStatusOutput | {
|
|
22
|
+
error: string;
|
|
23
|
+
}>;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/tools/git-status/executor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAI9C,UAAU,cAAc;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;CACvB;AA0FD,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,cAAc,EAAE,eAAe,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CA4B7F,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { assertNotAborted, resolveSandboxPolicy } from "../shared";
|
|
3
|
+
import { resolveAllowedPath } from "../../common/path";
|
|
4
|
+
const parsePortcelainV2 = (stdout) => {
|
|
5
|
+
const lines = stdout.split("\n");
|
|
6
|
+
let branch = "";
|
|
7
|
+
let upstream;
|
|
8
|
+
let ahead = 0;
|
|
9
|
+
let behind = 0;
|
|
10
|
+
let detachedHead = false;
|
|
11
|
+
const staged = [];
|
|
12
|
+
const unstaged = [];
|
|
13
|
+
const untracked = [];
|
|
14
|
+
for (const line of lines) {
|
|
15
|
+
if (line.startsWith("# branch.head ")) {
|
|
16
|
+
const head = line.slice("# branch.head ".length);
|
|
17
|
+
if (head === "(detached)") {
|
|
18
|
+
detachedHead = true;
|
|
19
|
+
branch = "HEAD";
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
branch = head;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else if (line.startsWith("# branch.upstream ")) {
|
|
26
|
+
upstream = line.slice("# branch.upstream ".length);
|
|
27
|
+
}
|
|
28
|
+
else if (line.startsWith("# branch.ab ")) {
|
|
29
|
+
const ab = line.slice("# branch.ab ".length);
|
|
30
|
+
const match = ab.match(/\+(\d+)\s+-(\d+)/);
|
|
31
|
+
if (match) {
|
|
32
|
+
ahead = parseInt(match[1], 10);
|
|
33
|
+
behind = parseInt(match[2], 10);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else if (line.startsWith("1 ")) {
|
|
37
|
+
// ordinary changed entries: "1 XY sub mH mI mW hH hI path"
|
|
38
|
+
const parts = line.split(" ");
|
|
39
|
+
const xy = parts[1];
|
|
40
|
+
const filePath = parts.slice(8).join(" ");
|
|
41
|
+
const stagedStatus = xy[0];
|
|
42
|
+
const unstagedStatus = xy[1];
|
|
43
|
+
if (stagedStatus !== "." && stagedStatus !== " ") {
|
|
44
|
+
staged.push({ path: filePath, status: stagedStatus });
|
|
45
|
+
}
|
|
46
|
+
if (unstagedStatus !== "." && unstagedStatus !== " ") {
|
|
47
|
+
unstaged.push({ path: filePath, status: unstagedStatus });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else if (line.startsWith("2 ")) {
|
|
51
|
+
// renamed/copied entries: "2 XY sub mH mI mW hH hI X score origPath\tpath"
|
|
52
|
+
const parts = line.split(" ");
|
|
53
|
+
const xy = parts[1];
|
|
54
|
+
const stagedStatus = xy[0];
|
|
55
|
+
const unstagedStatus = xy[1];
|
|
56
|
+
// paths are at the end after a tab
|
|
57
|
+
const pathPart = parts.slice(9).join(" ");
|
|
58
|
+
const tabIdx = pathPart.indexOf("\t");
|
|
59
|
+
let filePath;
|
|
60
|
+
let originalPath;
|
|
61
|
+
if (tabIdx >= 0) {
|
|
62
|
+
originalPath = pathPart.slice(0, tabIdx);
|
|
63
|
+
filePath = pathPart.slice(tabIdx + 1);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
filePath = pathPart;
|
|
67
|
+
}
|
|
68
|
+
if (stagedStatus !== "." && stagedStatus !== " ") {
|
|
69
|
+
const entry = { path: filePath, status: stagedStatus };
|
|
70
|
+
if (originalPath)
|
|
71
|
+
entry.originalPath = originalPath;
|
|
72
|
+
staged.push(entry);
|
|
73
|
+
}
|
|
74
|
+
if (unstagedStatus !== "." && unstagedStatus !== " ") {
|
|
75
|
+
unstaged.push({ path: filePath, status: unstagedStatus });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else if (line.startsWith("? ")) {
|
|
79
|
+
untracked.push(line.slice(2));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const isClean = staged.length === 0 && unstaged.length === 0 && untracked.length === 0;
|
|
83
|
+
const result = {
|
|
84
|
+
branch,
|
|
85
|
+
ahead,
|
|
86
|
+
behind,
|
|
87
|
+
staged,
|
|
88
|
+
unstaged,
|
|
89
|
+
untracked,
|
|
90
|
+
isClean,
|
|
91
|
+
detachedHead,
|
|
92
|
+
};
|
|
93
|
+
if (upstream !== undefined)
|
|
94
|
+
result.upstream = upstream;
|
|
95
|
+
return result;
|
|
96
|
+
};
|
|
97
|
+
export const gitStatusExecutor = async (input, context) => {
|
|
98
|
+
assertNotAborted(context.abortSignal);
|
|
99
|
+
const policy = resolveSandboxPolicy(context);
|
|
100
|
+
const cwd = input.cwd
|
|
101
|
+
? resolveAllowedPath(input.cwd, policy)
|
|
102
|
+
: resolve(context.workspaceRoot);
|
|
103
|
+
const proc = Bun.spawn({
|
|
104
|
+
cmd: ["git", "status", "--porcelain=v2", "--branch"],
|
|
105
|
+
cwd,
|
|
106
|
+
stdout: "pipe",
|
|
107
|
+
stderr: "pipe",
|
|
108
|
+
});
|
|
109
|
+
const [stdout, stderr, exitCode] = await Promise.all([
|
|
110
|
+
new Response(proc.stdout).text(),
|
|
111
|
+
new Response(proc.stderr).text(),
|
|
112
|
+
proc.exited,
|
|
113
|
+
]);
|
|
114
|
+
assertNotAborted(context.abortSignal);
|
|
115
|
+
if (exitCode !== 0) {
|
|
116
|
+
return { error: stderr || `git status exited with code ${exitCode}` };
|
|
117
|
+
}
|
|
118
|
+
return parsePortcelainV2(stdout);
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../src/tools/git-status/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAwBvD,MAAM,iBAAiB,GAAG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iB,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ToolExecutor } from "../shared";
|
|
2
|
+
interface GlobInput {
|
|
3
|
+
pattern: string;
|
|
4
|
+
cwd?: string;
|
|
5
|
+
ignore?: string[];
|
|
6
|
+
maxResults?: number;
|
|
7
|
+
}
|
|
8
|
+
interface GlobOutput {
|
|
9
|
+
files: string[];
|
|
10
|
+
truncated: boolean;
|
|
11
|
+
matchCount: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Glob 文件搜索 Tool 执行器。
|
|
15
|
+
*/
|
|
16
|
+
export declare const globExecutor: ToolExecutor<GlobInput, GlobOutput>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/tools/glob/executor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAM9C,UAAU,SAAS;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAWD;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,SAAS,EAAE,UAAU,CAuC5D,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { resolveAllowedPath, toWorkspaceRelativePath } from "../../common/path";
|
|
3
|
+
import { assertNotAborted, resolveSandboxPolicy } from "../shared";
|
|
4
|
+
const DEFAULT_IGNORE = ["**/node_modules/**", "**/.git/**"];
|
|
5
|
+
const DEFAULT_MAX_RESULTS = 1000;
|
|
6
|
+
const matchesIgnore = (relPath, ignorePatterns) => {
|
|
7
|
+
for (const pattern of ignorePatterns) {
|
|
8
|
+
if (new Bun.Glob(pattern).match(relPath)) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Glob 文件搜索 Tool 执行器。
|
|
16
|
+
*/
|
|
17
|
+
export const globExecutor = async (input, context) => {
|
|
18
|
+
assertNotAborted(context.abortSignal);
|
|
19
|
+
const policy = resolveSandboxPolicy(context);
|
|
20
|
+
const resolvedCwd = input.cwd !== undefined
|
|
21
|
+
? resolveAllowedPath(input.cwd, policy)
|
|
22
|
+
: context.workspaceRoot;
|
|
23
|
+
const ignore = input.ignore !== undefined ? input.ignore : DEFAULT_IGNORE;
|
|
24
|
+
const maxResults = input.maxResults !== undefined ? input.maxResults : DEFAULT_MAX_RESULTS;
|
|
25
|
+
const files = [];
|
|
26
|
+
let truncated = false;
|
|
27
|
+
for await (const relPath of new Bun.Glob(input.pattern).scan({ cwd: resolvedCwd, onlyFiles: true })) {
|
|
28
|
+
if (matchesIgnore(relPath, ignore)) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const absPath = resolve(resolvedCwd, relPath);
|
|
32
|
+
// Sandbox check: silently skip out-of-bounds paths
|
|
33
|
+
try {
|
|
34
|
+
resolveAllowedPath(absPath, policy);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (files.length >= maxResults) {
|
|
40
|
+
truncated = true;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
files.push(toWorkspaceRelativePath(context.workspaceRoot, absPath));
|
|
44
|
+
}
|
|
45
|
+
return { files, truncated, matchCount: files.length };
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingUR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AAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC;IAE3F,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,IAAI,KAAK,EAAE,MAAM,OAAO,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QACpG,IAAI,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC;YACnC,SAAS;QACX,CAAC;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAE9C,mDAAmD;QACnD,IAAI,CAAC;YACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;QAED,IAAI,KAAK,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;YAC/B,SAAS,GAAG,IAAI,CAAC;YACjB,MAAM;QACR,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;AACxD,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AA0B7C;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,cAAc,EA0kB3C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CA2BtD,CAAC;AAEF,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/tools/index.js
CHANGED
|
@@ -7,6 +7,21 @@ import { runShellExecutor } from "./run-shell/executor";
|
|
|
7
7
|
import { applyPatchExecutor } from "./apply-patch/executor";
|
|
8
8
|
import { executeWebFetch } from "./web-fetch";
|
|
9
9
|
import { executeWebSearch } from "./web-search";
|
|
10
|
+
// 新增工具 — S1 工具层核心
|
|
11
|
+
import { editFileExecutor } from "./edit-file/executor";
|
|
12
|
+
import { multiEditExecutor } from "./multi-edit/executor";
|
|
13
|
+
import { globExecutor } from "./glob/executor";
|
|
14
|
+
import { todoWriteExecutor } from "./todo-write/executor";
|
|
15
|
+
import { todoReadExecutor } from "./todo-read/executor";
|
|
16
|
+
// 新增工具 — S2 Git + 测试诊断
|
|
17
|
+
import { gitStatusExecutor } from "./git-status/executor";
|
|
18
|
+
import { gitDiffExecutor } from "./git-diff/executor";
|
|
19
|
+
import { gitLogExecutor } from "./git-log/executor";
|
|
20
|
+
import { gitBlameExecutor } from "./git-blame/executor";
|
|
21
|
+
import { gitShowExecutor } from "./git-show/executor";
|
|
22
|
+
import { gitBranchExecutor } from "./git-branch/executor";
|
|
23
|
+
import { runTypecheckExecutor } from "./run-typecheck/executor";
|
|
24
|
+
import { runTestsExecutor } from "./run-tests/executor";
|
|
10
25
|
/**
|
|
11
26
|
* 内置工具描述符列表。
|
|
12
27
|
*/
|
|
@@ -14,7 +29,7 @@ export const toolDescriptors = [
|
|
|
14
29
|
{
|
|
15
30
|
kind: "tool",
|
|
16
31
|
name: "read-file",
|
|
17
|
-
description: "
|
|
32
|
+
description: "读取工作区内的文件内容。支持 offset/limit 分段读取、withLineNumbers 行号注入(默认开启)。",
|
|
18
33
|
sideEffect: "readonly",
|
|
19
34
|
idempotent: true,
|
|
20
35
|
requiresApproval: false,
|
|
@@ -24,12 +39,20 @@ export const toolDescriptors = [
|
|
|
24
39
|
properties: {
|
|
25
40
|
path: { type: "string" },
|
|
26
41
|
encoding: { type: "string", enum: ["utf-8", "base64"] },
|
|
42
|
+
offset: { type: "number", description: "起始行(1-based),默认 1" },
|
|
43
|
+
limit: { type: "number", description: "最多读多少行,默认全文" },
|
|
44
|
+
withLineNumbers: { type: "boolean", description: "是否在每行前插入行号前缀(默认 true)" },
|
|
27
45
|
},
|
|
28
46
|
required: ["path"],
|
|
29
47
|
},
|
|
30
48
|
outputSchema: {
|
|
31
49
|
type: "object",
|
|
32
|
-
properties: {
|
|
50
|
+
properties: {
|
|
51
|
+
content: { type: "string" },
|
|
52
|
+
bytes: { type: "number" },
|
|
53
|
+
totalLines: { type: "number" },
|
|
54
|
+
hasMore: { type: "boolean" },
|
|
55
|
+
},
|
|
33
56
|
},
|
|
34
57
|
execute: "read-file",
|
|
35
58
|
},
|
|
@@ -246,7 +269,7 @@ export const toolDescriptors = [
|
|
|
246
269
|
{
|
|
247
270
|
kind: "tool",
|
|
248
271
|
name: "apply-patch",
|
|
249
|
-
description: "应用 unified diff
|
|
272
|
+
description: "应用 unified diff 补丁并支持失败回滚。支持上下文行宽容匹配(trim + ±3 行偏移)。",
|
|
250
273
|
sideEffect: "write",
|
|
251
274
|
idempotent: false,
|
|
252
275
|
requiresApproval: true,
|
|
@@ -268,11 +291,329 @@ export const toolDescriptors = [
|
|
|
268
291
|
},
|
|
269
292
|
execute: "apply-patch",
|
|
270
293
|
},
|
|
294
|
+
// ─── S1:编辑工具 ──────────────────────────────────────────────────────────
|
|
295
|
+
{
|
|
296
|
+
kind: "tool",
|
|
297
|
+
name: "edit-file",
|
|
298
|
+
description: "在文件中替换精确字符串片段。oldString 必须在文件中唯一(或配合 replaceAll)。改前会校验唯一性,失败时返回 matchCount 方便 LLM 调整上下文。fuzzy 默认 true,允许行首尾空白差异。",
|
|
299
|
+
sideEffect: "write",
|
|
300
|
+
idempotent: false,
|
|
301
|
+
requiresApproval: true,
|
|
302
|
+
timeout: 10000,
|
|
303
|
+
inputSchema: {
|
|
304
|
+
type: "object",
|
|
305
|
+
properties: {
|
|
306
|
+
path: { type: "string" },
|
|
307
|
+
oldString: { type: "string", description: "要被替换的精确原始内容(含缩进/换行)" },
|
|
308
|
+
newString: { type: "string", description: "替换后的新内容" },
|
|
309
|
+
replaceAll: { type: "boolean", description: "true 时替换所有匹配,不做唯一性校验" },
|
|
310
|
+
fuzzy: { type: "boolean", description: "允许 oldString 行首尾空白差异(默认 true)" },
|
|
311
|
+
},
|
|
312
|
+
required: ["path", "oldString", "newString"],
|
|
313
|
+
},
|
|
314
|
+
outputSchema: {
|
|
315
|
+
type: "object",
|
|
316
|
+
properties: {
|
|
317
|
+
replaced: { type: "number" },
|
|
318
|
+
matchCount: { type: "number" },
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
execute: "edit-file",
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
kind: "tool",
|
|
325
|
+
name: "multi-edit",
|
|
326
|
+
description: "在同一文件中原子地应用多处字符串替换。任一替换失败则全部回滚,不写磁盘。",
|
|
327
|
+
sideEffect: "write",
|
|
328
|
+
idempotent: false,
|
|
329
|
+
requiresApproval: true,
|
|
330
|
+
timeout: 15000,
|
|
331
|
+
inputSchema: {
|
|
332
|
+
type: "object",
|
|
333
|
+
properties: {
|
|
334
|
+
path: { type: "string" },
|
|
335
|
+
edits: {
|
|
336
|
+
type: "array",
|
|
337
|
+
items: {
|
|
338
|
+
type: "object",
|
|
339
|
+
properties: {
|
|
340
|
+
oldString: { type: "string" },
|
|
341
|
+
newString: { type: "string" },
|
|
342
|
+
replaceAll: { type: "boolean" },
|
|
343
|
+
},
|
|
344
|
+
required: ["oldString", "newString"],
|
|
345
|
+
},
|
|
346
|
+
},
|
|
347
|
+
fuzzy: { type: "boolean" },
|
|
348
|
+
},
|
|
349
|
+
required: ["path", "edits"],
|
|
350
|
+
},
|
|
351
|
+
outputSchema: {
|
|
352
|
+
type: "object",
|
|
353
|
+
properties: {
|
|
354
|
+
applied: { type: "number" },
|
|
355
|
+
total: { type: "number" },
|
|
356
|
+
results: { type: "array" },
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
execute: "multi-edit",
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
kind: "tool",
|
|
363
|
+
name: "glob",
|
|
364
|
+
description: "按 glob 模式查找工作区内的文件路径。只返回路径,不读文件内容。适合探索项目结构、定位特定类型文件。例:pattern=\"**/*.test.ts\"",
|
|
365
|
+
sideEffect: "readonly",
|
|
366
|
+
idempotent: true,
|
|
367
|
+
requiresApproval: false,
|
|
368
|
+
timeout: 15000,
|
|
369
|
+
inputSchema: {
|
|
370
|
+
type: "object",
|
|
371
|
+
properties: {
|
|
372
|
+
pattern: { type: "string", description: "glob 模式,如 **/*.ts" },
|
|
373
|
+
cwd: { type: "string", description: "搜索根(默认 workspaceRoot)" },
|
|
374
|
+
ignore: { type: "array", items: { type: "string" }, description: "排除 pattern(默认排除 node_modules/.git)" },
|
|
375
|
+
maxResults: { type: "number", description: "默认 1000" },
|
|
376
|
+
},
|
|
377
|
+
required: ["pattern"],
|
|
378
|
+
},
|
|
379
|
+
outputSchema: {
|
|
380
|
+
type: "object",
|
|
381
|
+
properties: {
|
|
382
|
+
files: { type: "array", items: { type: "string" } },
|
|
383
|
+
truncated: { type: "boolean" },
|
|
384
|
+
matchCount: { type: "number" },
|
|
385
|
+
},
|
|
386
|
+
},
|
|
387
|
+
execute: "glob",
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
kind: "tool",
|
|
391
|
+
name: "todo-write",
|
|
392
|
+
description: "创建或更新会话任务清单(持久化到磁盘)。merge=true 时按 id 合并,false 时全量覆盖。用于追踪复杂多步任务的进度。",
|
|
393
|
+
sideEffect: "write",
|
|
394
|
+
idempotent: false,
|
|
395
|
+
requiresApproval: false,
|
|
396
|
+
timeout: 5000,
|
|
397
|
+
inputSchema: {
|
|
398
|
+
type: "object",
|
|
399
|
+
properties: {
|
|
400
|
+
todos: {
|
|
401
|
+
type: "array",
|
|
402
|
+
items: {
|
|
403
|
+
type: "object",
|
|
404
|
+
properties: {
|
|
405
|
+
id: { type: "string" },
|
|
406
|
+
content: { type: "string" },
|
|
407
|
+
status: { type: "string", enum: ["pending", "in_progress", "completed", "cancelled"] },
|
|
408
|
+
},
|
|
409
|
+
required: ["id", "content", "status"],
|
|
410
|
+
},
|
|
411
|
+
},
|
|
412
|
+
merge: { type: "boolean", description: "默认 true;false 时全量覆盖" },
|
|
413
|
+
},
|
|
414
|
+
required: ["todos"],
|
|
415
|
+
},
|
|
416
|
+
outputSchema: {
|
|
417
|
+
type: "object",
|
|
418
|
+
properties: { total: { type: "number" }, written: { type: "number" } },
|
|
419
|
+
},
|
|
420
|
+
execute: "todo-write",
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
kind: "tool",
|
|
424
|
+
name: "todo-read",
|
|
425
|
+
description: "读取当前会话的任务清单。返回全部或按状态过滤的任务列表。",
|
|
426
|
+
sideEffect: "readonly",
|
|
427
|
+
idempotent: true,
|
|
428
|
+
requiresApproval: false,
|
|
429
|
+
timeout: 3000,
|
|
430
|
+
inputSchema: {
|
|
431
|
+
type: "object",
|
|
432
|
+
properties: {
|
|
433
|
+
status: {
|
|
434
|
+
type: "string",
|
|
435
|
+
enum: ["pending", "in_progress", "completed", "cancelled", "all"],
|
|
436
|
+
description: "过滤状态,默认 all",
|
|
437
|
+
},
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
outputSchema: {
|
|
441
|
+
type: "object",
|
|
442
|
+
properties: {
|
|
443
|
+
todos: { type: "array" },
|
|
444
|
+
total: { type: "number" },
|
|
445
|
+
},
|
|
446
|
+
},
|
|
447
|
+
execute: "todo-read",
|
|
448
|
+
},
|
|
449
|
+
// ─── S2:Git 工具组 ─────────────────────────────────────────────────────────
|
|
450
|
+
{
|
|
451
|
+
kind: "tool",
|
|
452
|
+
name: "git-status",
|
|
453
|
+
description: "获取 git 工作区状态:当前分支、ahead/behind、staged/unstaged/untracked 文件列表。",
|
|
454
|
+
sideEffect: "readonly",
|
|
455
|
+
idempotent: true,
|
|
456
|
+
requiresApproval: false,
|
|
457
|
+
timeout: 10000,
|
|
458
|
+
inputSchema: {
|
|
459
|
+
type: "object",
|
|
460
|
+
properties: { cwd: { type: "string" } },
|
|
461
|
+
},
|
|
462
|
+
outputSchema: { type: "object" },
|
|
463
|
+
execute: "git-status",
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
kind: "tool",
|
|
467
|
+
name: "git-diff",
|
|
468
|
+
description: "获取 git diff,支持 staged(暂存区)、ref 范围、指定文件。返回结构化 FileDiff 列表。",
|
|
469
|
+
sideEffect: "readonly",
|
|
470
|
+
idempotent: true,
|
|
471
|
+
requiresApproval: false,
|
|
472
|
+
timeout: 15000,
|
|
473
|
+
inputSchema: {
|
|
474
|
+
type: "object",
|
|
475
|
+
properties: {
|
|
476
|
+
cwd: { type: "string" },
|
|
477
|
+
path: { type: "string", description: "限定文件路径" },
|
|
478
|
+
staged: { type: "boolean", description: "true 时等价于 git diff --staged" },
|
|
479
|
+
ref: { type: "string", description: "如 HEAD~1, abc123..def456" },
|
|
480
|
+
context: { type: "number", description: "context lines,默认 3" },
|
|
481
|
+
maxBytes: { type: "number", description: "输出字节上限,默认 32768" },
|
|
482
|
+
},
|
|
483
|
+
},
|
|
484
|
+
outputSchema: { type: "object" },
|
|
485
|
+
execute: "git-diff",
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
kind: "tool",
|
|
489
|
+
name: "git-log",
|
|
490
|
+
description: "获取 git 提交历史。支持 limit/since/until/author/path 过滤,返回结构化 commit 列表。",
|
|
491
|
+
sideEffect: "readonly",
|
|
492
|
+
idempotent: true,
|
|
493
|
+
requiresApproval: false,
|
|
494
|
+
timeout: 10000,
|
|
495
|
+
inputSchema: {
|
|
496
|
+
type: "object",
|
|
497
|
+
properties: {
|
|
498
|
+
cwd: { type: "string" },
|
|
499
|
+
limit: { type: "number", description: "默认 20,上限 100" },
|
|
500
|
+
since: { type: "string", description: "如 '2 weeks ago', '2026-01-01'" },
|
|
501
|
+
until: { type: "string" },
|
|
502
|
+
author: { type: "string" },
|
|
503
|
+
path: { type: "string", description: "只看影响此路径的 commits" },
|
|
504
|
+
ref: { type: "string", description: "起点 ref,默认 HEAD" },
|
|
505
|
+
oneline: { type: "boolean", description: "只返回 hash + subject" },
|
|
506
|
+
},
|
|
507
|
+
},
|
|
508
|
+
outputSchema: { type: "object" },
|
|
509
|
+
execute: "git-log",
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
kind: "tool",
|
|
513
|
+
name: "git-blame",
|
|
514
|
+
description: "查看文件每行的最后修改者和 commit。支持行范围过滤。",
|
|
515
|
+
sideEffect: "readonly",
|
|
516
|
+
idempotent: true,
|
|
517
|
+
requiresApproval: false,
|
|
518
|
+
timeout: 15000,
|
|
519
|
+
inputSchema: {
|
|
520
|
+
type: "object",
|
|
521
|
+
properties: {
|
|
522
|
+
path: { type: "string" },
|
|
523
|
+
cwd: { type: "string" },
|
|
524
|
+
startLine: { type: "number", description: "1-based,默认 1" },
|
|
525
|
+
endLine: { type: "number", description: "1-based,默认文件尾" },
|
|
526
|
+
},
|
|
527
|
+
required: ["path"],
|
|
528
|
+
},
|
|
529
|
+
outputSchema: { type: "object" },
|
|
530
|
+
execute: "git-blame",
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
kind: "tool",
|
|
534
|
+
name: "git-show",
|
|
535
|
+
description: "查看单个 git commit 的元信息和 diff。",
|
|
536
|
+
sideEffect: "readonly",
|
|
537
|
+
idempotent: true,
|
|
538
|
+
requiresApproval: false,
|
|
539
|
+
timeout: 10000,
|
|
540
|
+
inputSchema: {
|
|
541
|
+
type: "object",
|
|
542
|
+
properties: {
|
|
543
|
+
ref: { type: "string", description: "commit hash, tag, HEAD~1 等" },
|
|
544
|
+
cwd: { type: "string" },
|
|
545
|
+
maxBytes: { type: "number", description: "diff 输出上限,默认 32768" },
|
|
546
|
+
},
|
|
547
|
+
required: ["ref"],
|
|
548
|
+
},
|
|
549
|
+
outputSchema: { type: "object" },
|
|
550
|
+
execute: "git-show",
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
kind: "tool",
|
|
554
|
+
name: "git-branch",
|
|
555
|
+
description: "列出本地(或含远端)分支,包含 current、upstream、ahead/behind 信息。",
|
|
556
|
+
sideEffect: "readonly",
|
|
557
|
+
idempotent: true,
|
|
558
|
+
requiresApproval: false,
|
|
559
|
+
timeout: 10000,
|
|
560
|
+
inputSchema: {
|
|
561
|
+
type: "object",
|
|
562
|
+
properties: {
|
|
563
|
+
cwd: { type: "string" },
|
|
564
|
+
all: { type: "boolean", description: "true 时含远端分支,默认 false" },
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
outputSchema: { type: "object" },
|
|
568
|
+
execute: "git-branch",
|
|
569
|
+
},
|
|
570
|
+
// ─── S2:测试诊断 ──────────────────────────────────────────────────────────
|
|
571
|
+
{
|
|
572
|
+
kind: "tool",
|
|
573
|
+
name: "run-typecheck",
|
|
574
|
+
description: "对工作区运行 TypeScript 类型检查(tsc --noEmit 或 package.json 的 typecheck script)。返回结构化错误列表,适合改完代码后验证是否引入类型错误。",
|
|
575
|
+
sideEffect: "readonly",
|
|
576
|
+
idempotent: true,
|
|
577
|
+
requiresApproval: false,
|
|
578
|
+
timeout: 120000,
|
|
579
|
+
inputSchema: {
|
|
580
|
+
type: "object",
|
|
581
|
+
properties: {
|
|
582
|
+
cwd: { type: "string" },
|
|
583
|
+
tsconfig: { type: "string", description: "tsconfig 路径,默认自动查找" },
|
|
584
|
+
maxErrors: { type: "number", description: "返回错误条数上限,默认 50" },
|
|
585
|
+
},
|
|
586
|
+
},
|
|
587
|
+
outputSchema: { type: "object" },
|
|
588
|
+
execute: "run-typecheck",
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
kind: "tool",
|
|
592
|
+
name: "run-tests",
|
|
593
|
+
description: "运行工作区的测试套件(bun test 或 package.json test script)。返回结构化通过/失败/跳过数和失败用例详情。",
|
|
594
|
+
sideEffect: "readonly",
|
|
595
|
+
idempotent: true,
|
|
596
|
+
requiresApproval: false,
|
|
597
|
+
timeout: 180000,
|
|
598
|
+
inputSchema: {
|
|
599
|
+
type: "object",
|
|
600
|
+
properties: {
|
|
601
|
+
cwd: { type: "string" },
|
|
602
|
+
filter: { type: "string", description: "测试名过滤" },
|
|
603
|
+
file: { type: "string", description: "只跑指定文件" },
|
|
604
|
+
maxFailures: { type: "number", description: "失败用例返回上限,默认 20" },
|
|
605
|
+
timeout: { type: "number", description: "进程超时 ms,默认 60000" },
|
|
606
|
+
},
|
|
607
|
+
},
|
|
608
|
+
outputSchema: { type: "object" },
|
|
609
|
+
execute: "run-tests",
|
|
610
|
+
},
|
|
271
611
|
];
|
|
272
612
|
/**
|
|
273
613
|
* 工具执行函数注册表。
|
|
274
614
|
*/
|
|
275
615
|
export const toolExecutors = {
|
|
616
|
+
// 原有工具
|
|
276
617
|
"read-file": readFileExecutor,
|
|
277
618
|
"write-file": writeFileExecutor,
|
|
278
619
|
"list-dir": listDirExecutor,
|
|
@@ -282,5 +623,21 @@ export const toolExecutors = {
|
|
|
282
623
|
"web-search": executeWebSearch,
|
|
283
624
|
"run-shell": runShellExecutor,
|
|
284
625
|
"apply-patch": applyPatchExecutor,
|
|
626
|
+
// S1:编辑工具
|
|
627
|
+
"edit-file": editFileExecutor,
|
|
628
|
+
"multi-edit": multiEditExecutor,
|
|
629
|
+
"glob": globExecutor,
|
|
630
|
+
"todo-write": todoWriteExecutor,
|
|
631
|
+
"todo-read": todoReadExecutor,
|
|
632
|
+
// S2:Git 工具组
|
|
633
|
+
"git-status": gitStatusExecutor,
|
|
634
|
+
"git-diff": gitDiffExecutor,
|
|
635
|
+
"git-log": gitLogExecutor,
|
|
636
|
+
"git-blame": gitBlameExecutor,
|
|
637
|
+
"git-show": gitShowExecutor,
|
|
638
|
+
"git-branch": gitBranchExecutor,
|
|
639
|
+
// S2:测试诊断
|
|
640
|
+
"run-typecheck": runTypecheckExecutor,
|
|
641
|
+
"run-tests": runTestsExecutor,
|
|
285
642
|
};
|
|
286
643
|
//# sourceMappingURL=index.js.map
|