indusagi 0.12.6 → 0.12.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/dist/agent/index.d.ts +1 -0
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +2 -0
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/tools/bash.d.ts +45 -0
- package/dist/agent/tools/bash.d.ts.map +1 -0
- package/dist/agent/tools/bash.js +227 -0
- package/dist/agent/tools/bash.js.map +1 -0
- package/dist/agent/tools/edit-diff.d.ts +63 -0
- package/dist/agent/tools/edit-diff.d.ts.map +1 -0
- package/dist/agent/tools/edit-diff.js +241 -0
- package/dist/agent/tools/edit-diff.js.map +1 -0
- package/dist/agent/tools/edit.d.ts +37 -0
- package/dist/agent/tools/edit.d.ts.map +1 -0
- package/dist/agent/tools/edit.js +146 -0
- package/dist/agent/tools/edit.js.map +1 -0
- package/dist/agent/tools/find.d.ts +24 -0
- package/dist/agent/tools/find.d.ts.map +1 -0
- package/dist/agent/tools/find.js +132 -0
- package/dist/agent/tools/find.js.map +1 -0
- package/dist/agent/tools/grep.d.ts +43 -0
- package/dist/agent/tools/grep.d.ts.map +1 -0
- package/dist/agent/tools/grep.js +178 -0
- package/dist/agent/tools/grep.js.map +1 -0
- package/dist/agent/tools/index.d.ts +158 -0
- package/dist/agent/tools/index.d.ts.map +1 -0
- package/dist/agent/tools/index.js +128 -0
- package/dist/agent/tools/index.js.map +1 -0
- package/dist/agent/tools/ls.d.ts +38 -0
- package/dist/agent/tools/ls.d.ts.map +1 -0
- package/dist/agent/tools/ls.js +118 -0
- package/dist/agent/tools/ls.js.map +1 -0
- package/dist/agent/tools/path-utils.d.ts +8 -0
- package/dist/agent/tools/path-utils.d.ts.map +1 -0
- package/dist/agent/tools/path-utils.js +53 -0
- package/dist/agent/tools/path-utils.js.map +1 -0
- package/dist/agent/tools/read.d.ts +37 -0
- package/dist/agent/tools/read.d.ts.map +1 -0
- package/dist/agent/tools/read.js +168 -0
- package/dist/agent/tools/read.js.map +1 -0
- package/dist/agent/tools/task.d.ts +26 -0
- package/dist/agent/tools/task.d.ts.map +1 -0
- package/dist/agent/tools/task.js +30 -0
- package/dist/agent/tools/task.js.map +1 -0
- package/dist/agent/tools/todo-store.d.ts +20 -0
- package/dist/agent/tools/todo-store.d.ts.map +1 -0
- package/dist/agent/tools/todo-store.js +24 -0
- package/dist/agent/tools/todo-store.js.map +1 -0
- package/dist/agent/tools/todo.d.ts +26 -0
- package/dist/agent/tools/todo.d.ts.map +1 -0
- package/dist/agent/tools/todo.js +52 -0
- package/dist/agent/tools/todo.js.map +1 -0
- package/dist/agent/tools/truncate.d.ts +70 -0
- package/dist/agent/tools/truncate.d.ts.map +1 -0
- package/dist/agent/tools/truncate.js +205 -0
- package/dist/agent/tools/truncate.js.map +1 -0
- package/dist/agent/tools/utils/hook-runner.d.ts +9 -0
- package/dist/agent/tools/utils/hook-runner.d.ts.map +1 -0
- package/dist/agent/tools/utils/hook-runner.js +14 -0
- package/dist/agent/tools/utils/hook-runner.js.map +1 -0
- package/dist/agent/tools/utils/image-resize.d.ts +32 -0
- package/dist/agent/tools/utils/image-resize.d.ts.map +1 -0
- package/dist/agent/tools/utils/image-resize.js +42 -0
- package/dist/agent/tools/utils/image-resize.js.map +1 -0
- package/dist/agent/tools/utils/mime.d.ts +10 -0
- package/dist/agent/tools/utils/mime.d.ts.map +1 -0
- package/dist/agent/tools/utils/mime.js +48 -0
- package/dist/agent/tools/utils/mime.js.map +1 -0
- package/dist/agent/tools/utils/shell.d.ts +30 -0
- package/dist/agent/tools/utils/shell.d.ts.map +1 -0
- package/dist/agent/tools/utils/shell.js +137 -0
- package/dist/agent/tools/utils/shell.js.map +1 -0
- package/dist/agent/tools/webfetch.d.ts +34 -0
- package/dist/agent/tools/webfetch.d.ts.map +1 -0
- package/dist/agent/tools/webfetch.js +244 -0
- package/dist/agent/tools/webfetch.js.map +1 -0
- package/dist/agent/tools/websearch.d.ts +29 -0
- package/dist/agent/tools/websearch.d.ts.map +1 -0
- package/dist/agent/tools/websearch.js +69 -0
- package/dist/agent/tools/websearch.js.map +1 -0
- package/dist/agent/tools/write.d.ts +27 -0
- package/dist/agent/tools/write.d.ts.map +1 -0
- package/dist/agent/tools/write.js +78 -0
- package/dist/agent/tools/write.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AgentTool } from "../types.js";
|
|
2
|
+
declare const editSchema: import("@sinclair/typebox").TObject<{
|
|
3
|
+
path: import("@sinclair/typebox").TString;
|
|
4
|
+
oldText: import("@sinclair/typebox").TString;
|
|
5
|
+
newText: import("@sinclair/typebox").TString;
|
|
6
|
+
}>;
|
|
7
|
+
export interface EditToolDetails {
|
|
8
|
+
/** Unified diff of changes made */
|
|
9
|
+
diff: string;
|
|
10
|
+
/** Line number of first change in the new file (for editor navigation) */
|
|
11
|
+
firstChangedLine?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Pluggable operations for the edit tool.
|
|
15
|
+
* Override these to delegate file editing to remote systems (e.g., SSH).
|
|
16
|
+
*/
|
|
17
|
+
export interface EditOperations {
|
|
18
|
+
/** Read file contents as a Buffer */
|
|
19
|
+
readFile: (absolutePath: string) => Promise<Buffer>;
|
|
20
|
+
/** Write content to a file */
|
|
21
|
+
writeFile: (absolutePath: string, content: string) => Promise<void>;
|
|
22
|
+
/** Check if file is readable and writable (throw if not) */
|
|
23
|
+
access: (absolutePath: string) => Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export interface EditToolOptions {
|
|
26
|
+
/** Custom operations for file editing. Default: local filesystem */
|
|
27
|
+
operations?: EditOperations;
|
|
28
|
+
}
|
|
29
|
+
export declare function createEditTool(cwd: string, options?: EditToolOptions): AgentTool<typeof editSchema>;
|
|
30
|
+
/** Default edit tool using process.cwd() - for backwards compatibility */
|
|
31
|
+
export declare const editTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
32
|
+
path: import("@sinclair/typebox").TString;
|
|
33
|
+
oldText: import("@sinclair/typebox").TString;
|
|
34
|
+
newText: import("@sinclair/typebox").TString;
|
|
35
|
+
}>, any>;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=edit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/edit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAe7C,QAAA,MAAM,UAAU;;;;EAId,CAAC;AAEH,MAAM,WAAW,eAAe;IAC/B,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,qCAAqC;IACrC,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACpD,8BAA8B;IAC9B,SAAS,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,4DAA4D;IAC5D,MAAM,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AAQD,MAAM,WAAW,eAAe;IAC/B,oEAAoE;IACpE,UAAU,CAAC,EAAE,cAAc,CAAC;CAC5B;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAyKnG;AAED,0EAA0E;AAC1E,eAAO,MAAM,QAAQ;;;;QAAgC,CAAC"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { constants } from "fs";
|
|
3
|
+
import { access as fsAccess, readFile as fsReadFile, writeFile as fsWriteFile } from "fs/promises";
|
|
4
|
+
import { detectLineEnding, fuzzyFindText, generateDiffString, normalizeForFuzzyMatch, normalizeToLF, restoreLineEndings, stripBom, } from "./edit-diff.js";
|
|
5
|
+
import { resolveToCwd } from "./path-utils.js";
|
|
6
|
+
const editSchema = Type.Object({
|
|
7
|
+
path: Type.String({ description: "Path to file to edit (relative or absolute)" }),
|
|
8
|
+
oldText: Type.String({ description: "Exact text to find and replace (must match exactly)" }),
|
|
9
|
+
newText: Type.String({ description: "New text to replace the old text with" }),
|
|
10
|
+
});
|
|
11
|
+
const defaultEditOperations = {
|
|
12
|
+
readFile: (path) => fsReadFile(path),
|
|
13
|
+
writeFile: (path, content) => fsWriteFile(path, content, "utf-8"),
|
|
14
|
+
access: (path) => fsAccess(path, constants.R_OK | constants.W_OK),
|
|
15
|
+
};
|
|
16
|
+
export function createEditTool(cwd, options) {
|
|
17
|
+
const ops = options?.operations ?? defaultEditOperations;
|
|
18
|
+
return {
|
|
19
|
+
name: "edit",
|
|
20
|
+
label: "edit",
|
|
21
|
+
description: "Edit a file by replacing exact text. The oldText must match exactly (including whitespace). Use this for precise, surgical edits.",
|
|
22
|
+
parameters: editSchema,
|
|
23
|
+
execute: async (_toolCallId, { path, oldText, newText }, signal) => {
|
|
24
|
+
const absolutePath = resolveToCwd(path, cwd);
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
// Check if already aborted
|
|
27
|
+
if (signal?.aborted) {
|
|
28
|
+
reject(new Error("Operation aborted"));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
let aborted = false;
|
|
32
|
+
// Set up abort handler
|
|
33
|
+
const onAbort = () => {
|
|
34
|
+
aborted = true;
|
|
35
|
+
reject(new Error("Operation aborted"));
|
|
36
|
+
};
|
|
37
|
+
if (signal) {
|
|
38
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
39
|
+
}
|
|
40
|
+
// Perform the edit operation
|
|
41
|
+
(async () => {
|
|
42
|
+
try {
|
|
43
|
+
// Check if file exists
|
|
44
|
+
try {
|
|
45
|
+
await ops.access(absolutePath);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
if (signal) {
|
|
49
|
+
signal.removeEventListener("abort", onAbort);
|
|
50
|
+
}
|
|
51
|
+
reject(new Error(`File not found: ${path}`));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
// Check if aborted before reading
|
|
55
|
+
if (aborted) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
// Read the file
|
|
59
|
+
const buffer = await ops.readFile(absolutePath);
|
|
60
|
+
const rawContent = buffer.toString("utf-8");
|
|
61
|
+
// Check if aborted after reading
|
|
62
|
+
if (aborted) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
// Strip BOM before matching (LLM won't include invisible BOM in oldText)
|
|
66
|
+
const { bom, text: content } = stripBom(rawContent);
|
|
67
|
+
const originalEnding = detectLineEnding(content);
|
|
68
|
+
const normalizedContent = normalizeToLF(content);
|
|
69
|
+
const normalizedOldText = normalizeToLF(oldText);
|
|
70
|
+
const normalizedNewText = normalizeToLF(newText);
|
|
71
|
+
// Find old text using fuzzy matching (tries exact match first, then fuzzy)
|
|
72
|
+
const matchResult = fuzzyFindText(normalizedContent, normalizedOldText);
|
|
73
|
+
if (!matchResult.found) {
|
|
74
|
+
if (signal) {
|
|
75
|
+
signal.removeEventListener("abort", onAbort);
|
|
76
|
+
}
|
|
77
|
+
reject(new Error(`Could not find the exact text in ${path}. The old text must match exactly including all whitespace and newlines.`));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// Count occurrences using fuzzy-normalized content for consistency
|
|
81
|
+
const fuzzyContent = normalizeForFuzzyMatch(normalizedContent);
|
|
82
|
+
const fuzzyOldText = normalizeForFuzzyMatch(normalizedOldText);
|
|
83
|
+
const occurrences = fuzzyContent.split(fuzzyOldText).length - 1;
|
|
84
|
+
if (occurrences > 1) {
|
|
85
|
+
if (signal) {
|
|
86
|
+
signal.removeEventListener("abort", onAbort);
|
|
87
|
+
}
|
|
88
|
+
reject(new Error(`Found ${occurrences} occurrences of the text in ${path}. The text must be unique. Please provide more context to make it unique.`));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
// Check if aborted before writing
|
|
92
|
+
if (aborted) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
// Perform replacement using the matched text position
|
|
96
|
+
// When fuzzy matching was used, contentForReplacement is the normalized version
|
|
97
|
+
const baseContent = matchResult.contentForReplacement;
|
|
98
|
+
const newContent = baseContent.substring(0, matchResult.index) +
|
|
99
|
+
normalizedNewText +
|
|
100
|
+
baseContent.substring(matchResult.index + matchResult.matchLength);
|
|
101
|
+
// Verify that replacement actually changed something
|
|
102
|
+
if (baseContent === newContent) {
|
|
103
|
+
if (signal) {
|
|
104
|
+
signal.removeEventListener("abort", onAbort);
|
|
105
|
+
}
|
|
106
|
+
reject(new Error(`No changes made to ${path}. The replacement produced identical content. This might indicate an issue with special characters or the text not existing as expected.`));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const finalContent = bom + restoreLineEndings(newContent, originalEnding);
|
|
110
|
+
await ops.writeFile(absolutePath, finalContent);
|
|
111
|
+
// Check if aborted after writing
|
|
112
|
+
if (aborted) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
// Clean up abort handler
|
|
116
|
+
if (signal) {
|
|
117
|
+
signal.removeEventListener("abort", onAbort);
|
|
118
|
+
}
|
|
119
|
+
const diffResult = generateDiffString(baseContent, newContent);
|
|
120
|
+
resolve({
|
|
121
|
+
content: [
|
|
122
|
+
{
|
|
123
|
+
type: "text",
|
|
124
|
+
text: `Successfully replaced text in ${path}.`,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
details: { diff: diffResult.diff, firstChangedLine: diffResult.firstChangedLine },
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
// Clean up abort handler
|
|
132
|
+
if (signal) {
|
|
133
|
+
signal.removeEventListener("abort", onAbort);
|
|
134
|
+
}
|
|
135
|
+
if (!aborted) {
|
|
136
|
+
reject(error);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
})();
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/** Default edit tool using process.cwd() - for backwards compatibility */
|
|
145
|
+
export const editTool = createEditTool(process.cwd());
|
|
146
|
+
//# sourceMappingURL=edit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/agent/tools/edit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,QAAQ,IAAI,UAAU,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EACN,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,kBAAkB,EAClB,QAAQ,GACR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,6CAA6C,EAAE,CAAC;IACjF,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,qDAAqD,EAAE,CAAC;IAC5F,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC;CAC9E,CAAC,CAAC;AAsBH,MAAM,qBAAqB,GAAmB;IAC7C,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,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MAAM,YAAY,GAAG,GAAG,GAAG,kBAAkB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;wBAC1E,MAAM,GAAG,CAAC,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;wBAEhD,iCAAiC;wBACjC,IAAI,OAAO,EAAE,CAAC;4BACb,OAAO;wBACR,CAAC;wBAED,yBAAyB;wBACzB,IAAI,MAAM,EAAE,CAAC;4BACZ,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;wBAC9C,CAAC;wBAED,MAAM,UAAU,GAAG,kBAAkB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;wBAC/D,OAAO,CAAC;4BACP,OAAO,EAAE;gCACR;oCACC,IAAI,EAAE,MAAM;oCACZ,IAAI,EAAE,iCAAiC,IAAI,GAAG;iCAC9C;6BACD;4BACD,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,EAAE;yBACjF,CAAC,CAAC;oBACJ,CAAC;oBAAC,OAAO,KAAU,EAAE,CAAC;wBACrB,yBAAyB;wBACzB,IAAI,MAAM,EAAE,CAAC;4BACZ,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;wBAC9C,CAAC;wBAED,IAAI,CAAC,OAAO,EAAE,CAAC;4BACd,MAAM,CAAC,KAAK,CAAC,CAAC;wBACf,CAAC;oBACF,CAAC;gBACF,CAAC,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC;AAED,0EAA0E;AAC1E,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AgentTool } from "../types.js";
|
|
2
|
+
import { type TruncationResult } from "./truncate.js";
|
|
3
|
+
declare const findSchema: import("@sinclair/typebox").TObject<{
|
|
4
|
+
pattern: import("@sinclair/typebox").TString;
|
|
5
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
6
|
+
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
7
|
+
}>;
|
|
8
|
+
export interface FindToolDetails {
|
|
9
|
+
truncation?: TruncationResult;
|
|
10
|
+
resultLimitReached?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface FindToolOptions {
|
|
13
|
+
/** Custom operations for find. Default: local filesystem */
|
|
14
|
+
operations?: any;
|
|
15
|
+
}
|
|
16
|
+
export declare function createFindTool(cwd: string, options?: FindToolOptions): AgentTool<typeof findSchema>;
|
|
17
|
+
/** Default find tool using process.cwd() - for backwards compatibility */
|
|
18
|
+
export declare const findTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
19
|
+
pattern: import("@sinclair/typebox").TString;
|
|
20
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
21
|
+
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
22
|
+
}>, any>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=find.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAK7C,OAAO,EAAiC,KAAK,gBAAgB,EAAgB,MAAM,eAAe,CAAC;AAEnG,QAAA,MAAM,UAAU;;;;EAMd,CAAC;AAIH,MAAM,WAAW,eAAe;IAC/B,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAkDD,MAAM,WAAW,eAAe;IAC/B,4DAA4D;IAC5D,UAAU,CAAC,EAAE,GAAG,CAAC;CACjB;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAsFnG;AAED,0EAA0E;AAC1E,eAAO,MAAM,QAAQ;;;;QAAgC,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { resolveToCwd } from "./path-utils.js";
|
|
5
|
+
import { DEFAULT_MAX_BYTES, formatSize, truncateHead } from "./truncate.js";
|
|
6
|
+
const findSchema = Type.Object({
|
|
7
|
+
pattern: Type.String({
|
|
8
|
+
description: "Glob pattern to match files, e.g. '*.ts', '**/*.json', or 'src/**/*.spec.ts'",
|
|
9
|
+
}),
|
|
10
|
+
path: Type.Optional(Type.String({ description: "Directory to search in (default: current directory)" })),
|
|
11
|
+
limit: Type.Optional(Type.Number({ description: "Maximum number of results (default: 1000)" })),
|
|
12
|
+
});
|
|
13
|
+
const DEFAULT_LIMIT = 1000;
|
|
14
|
+
/**
|
|
15
|
+
* Simple glob matching function
|
|
16
|
+
*/
|
|
17
|
+
function globMatch(pattern, str) {
|
|
18
|
+
const regexPattern = pattern
|
|
19
|
+
.replace(/\*/g, ".*")
|
|
20
|
+
.replace(/\?/g, ".")
|
|
21
|
+
.replace(/\./g, "\\.");
|
|
22
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
23
|
+
return regex.test(str);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Find files matching a glob pattern
|
|
27
|
+
*/
|
|
28
|
+
async function findFiles(dir, pattern, limit) {
|
|
29
|
+
const fs = require("fs");
|
|
30
|
+
const results = [];
|
|
31
|
+
async function search(currentDir, depth) {
|
|
32
|
+
if (results.length >= limit || depth > 20)
|
|
33
|
+
return;
|
|
34
|
+
try {
|
|
35
|
+
const entries = fs.readdirSync(currentDir);
|
|
36
|
+
for (const entry of entries) {
|
|
37
|
+
if (results.length >= limit)
|
|
38
|
+
break;
|
|
39
|
+
const fullPath = path.join(currentDir, entry);
|
|
40
|
+
const stat = fs.statSync(fullPath);
|
|
41
|
+
if (stat.isDirectory()) {
|
|
42
|
+
// Skip hidden directories and common exclusions
|
|
43
|
+
if (!entry.startsWith(".") && entry !== "node_modules" && entry !== ".git") {
|
|
44
|
+
await search(fullPath, depth + 1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else if (globMatch(pattern, entry)) {
|
|
48
|
+
results.push(fullPath);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// Skip inaccessible directories
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
await search(dir, 0);
|
|
57
|
+
return results;
|
|
58
|
+
}
|
|
59
|
+
export function createFindTool(cwd, options) {
|
|
60
|
+
return {
|
|
61
|
+
name: "find",
|
|
62
|
+
label: "find",
|
|
63
|
+
description: `Search for files by glob pattern. Returns matching file paths relative to the search directory. Output is truncated to ${DEFAULT_LIMIT} results or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first).`,
|
|
64
|
+
parameters: findSchema,
|
|
65
|
+
execute: async (_toolCallId, { pattern, path: searchDir, limit }, signal) => {
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
if (signal?.aborted) {
|
|
68
|
+
reject(new Error("Operation aborted"));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const onAbort = () => reject(new Error("Operation aborted"));
|
|
72
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
73
|
+
(async () => {
|
|
74
|
+
try {
|
|
75
|
+
const searchPath = resolveToCwd(searchDir || ".", cwd);
|
|
76
|
+
const effectiveLimit = limit ?? DEFAULT_LIMIT;
|
|
77
|
+
// Check if path exists
|
|
78
|
+
if (!existsSync(searchPath)) {
|
|
79
|
+
reject(new Error(`Path not found: ${searchPath}`));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// Find files matching pattern
|
|
83
|
+
const results = await findFiles(searchPath, pattern, effectiveLimit);
|
|
84
|
+
signal?.removeEventListener("abort", onAbort);
|
|
85
|
+
if (results.length === 0) {
|
|
86
|
+
resolve({
|
|
87
|
+
content: [{ type: "text", text: "No files found matching pattern" }],
|
|
88
|
+
details: undefined,
|
|
89
|
+
});
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// Relativize paths
|
|
93
|
+
const relativized = results.map((p) => {
|
|
94
|
+
if (p.startsWith(searchPath)) {
|
|
95
|
+
return p.slice(searchPath.length + 1);
|
|
96
|
+
}
|
|
97
|
+
return path.relative(searchPath, p);
|
|
98
|
+
});
|
|
99
|
+
const resultLimitReached = relativized.length >= effectiveLimit;
|
|
100
|
+
const rawOutput = relativized.join("\n");
|
|
101
|
+
const truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });
|
|
102
|
+
let resultOutput = truncation.content;
|
|
103
|
+
const details = {};
|
|
104
|
+
const notices = [];
|
|
105
|
+
if (resultLimitReached) {
|
|
106
|
+
notices.push(`${effectiveLimit} results limit reached`);
|
|
107
|
+
details.resultLimitReached = effectiveLimit;
|
|
108
|
+
}
|
|
109
|
+
if (truncation.truncated) {
|
|
110
|
+
notices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);
|
|
111
|
+
details.truncation = truncation;
|
|
112
|
+
}
|
|
113
|
+
if (notices.length > 0) {
|
|
114
|
+
resultOutput += `\n\n[${notices.join(". ")}]`;
|
|
115
|
+
}
|
|
116
|
+
resolve({
|
|
117
|
+
content: [{ type: "text", text: resultOutput }],
|
|
118
|
+
details: Object.keys(details).length > 0 ? details : undefined,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
signal?.removeEventListener("abort", onAbort);
|
|
123
|
+
reject(e);
|
|
124
|
+
}
|
|
125
|
+
})();
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/** Default find tool using process.cwd() - for backwards compatibility */
|
|
131
|
+
export const findTool = createFindTool(process.cwd());
|
|
132
|
+
//# sourceMappingURL=find.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../../src/agent/tools/find.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAyB,YAAY,EAAE,MAAM,eAAe,CAAC;AAEnG,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC;QACpB,WAAW,EAAE,8EAA8E;KAC3F,CAAC;IACF,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,qDAAqD,EAAE,CAAC,CAAC;IACxG,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC,CAAC;CAC/F,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,IAAI,CAAC;AAO3B;;GAEG;AACH,SAAS,SAAS,CAAC,OAAe,EAAE,GAAW;IAC9C,MAAM,YAAY,GAAG,OAAO;SAC1B,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC;SACpB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACxB,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,YAAY,GAAG,CAAC,CAAC;IAC9C,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC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AAU,GAAG,UAAU,CAAC;wBACjC,CAAC;wBAED,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;4BACxB,YAAY,IAAI,QAAQ,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;wBAC/C,CAAC;wBAED,OAAO,CAAC;4BACP,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;4BAC/C,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;yBAC9D,CAAC,CAAC;oBACJ,CAAC;oBAAC,OAAO,CAAM,EAAE,CAAC;wBACjB,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;wBAC9C,MAAM,CAAC,CAAC,CAAC,CAAC;oBACX,CAAC;gBACF,CAAC,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC;AAED,0EAA0E;AAC1E,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AgentTool } from "../types.js";
|
|
2
|
+
import { type TruncationResult } from "./truncate.js";
|
|
3
|
+
declare const grepSchema: import("@sinclair/typebox").TObject<{
|
|
4
|
+
pattern: import("@sinclair/typebox").TString;
|
|
5
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
6
|
+
ignoreCase: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
7
|
+
literal: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
8
|
+
context: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
9
|
+
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
10
|
+
}>;
|
|
11
|
+
export interface GrepToolDetails {
|
|
12
|
+
truncation?: TruncationResult;
|
|
13
|
+
matchLimitReached?: number;
|
|
14
|
+
linesTruncated?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Pluggable operations for the grep tool.
|
|
18
|
+
* Override these to delegate search to remote systems (e.g., SSH).
|
|
19
|
+
*/
|
|
20
|
+
export interface GrepOperations {
|
|
21
|
+
/** Check if path is a directory. Throws if path doesn't exist. */
|
|
22
|
+
isDirectory: (absolutePath: string) => Promise<boolean> | boolean;
|
|
23
|
+
/** Read file contents for context lines */
|
|
24
|
+
readFile: (absolutePath: string) => Promise<string> | string;
|
|
25
|
+
/** List files in a directory */
|
|
26
|
+
readdir: (absolutePath: string) => Promise<string[]> | string[];
|
|
27
|
+
}
|
|
28
|
+
export interface GrepToolOptions {
|
|
29
|
+
/** Custom operations for grep. Default: local filesystem */
|
|
30
|
+
operations?: GrepOperations;
|
|
31
|
+
}
|
|
32
|
+
export declare function createGrepTool(cwd: string, options?: GrepToolOptions): AgentTool<typeof grepSchema>;
|
|
33
|
+
/** Default grep tool using process.cwd() - for backwards compatibility */
|
|
34
|
+
export declare const grepTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
35
|
+
pattern: import("@sinclair/typebox").TString;
|
|
36
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
37
|
+
ignoreCase: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
38
|
+
literal: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
39
|
+
context: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
40
|
+
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
41
|
+
}>, any>;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=grep.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/grep.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAK7C,OAAO,EAIN,KAAK,gBAAgB,EAGrB,MAAM,eAAe,CAAC;AAEvB,QAAA,MAAM,UAAU;;;;;;;EAWd,CAAC;AAIH,MAAM,WAAW,eAAe;IAC/B,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,kEAAkE;IAClE,WAAW,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAClE,2CAA2C;IAC3C,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAC7D,gCAAgC;IAChC,OAAO,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC;CAChE;AAWD,MAAM,WAAW,eAAe;IAC/B,4DAA4D;IAC5D,UAAU,CAAC,EAAE,cAAc,CAAC;CAC5B;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CA8LnG;AAED,0EAA0E;AAC1E,eAAO,MAAM,QAAQ;;;;;;;QAAgC,CAAC"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { readFileSync, statSync } from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { resolveToCwd } from "./path-utils.js";
|
|
5
|
+
import { DEFAULT_MAX_BYTES, formatSize, GREP_MAX_LINE_LENGTH, truncateHead, truncateLine, } from "./truncate.js";
|
|
6
|
+
const grepSchema = Type.Object({
|
|
7
|
+
pattern: Type.String({ description: "Search pattern (regex or literal string)" }),
|
|
8
|
+
path: Type.Optional(Type.String({ description: "Directory or file to search (default: current directory)" })),
|
|
9
|
+
ignoreCase: Type.Optional(Type.Boolean({ description: "Case-insensitive search (default: false)" })),
|
|
10
|
+
literal: Type.Optional(Type.Boolean({ description: "Treat pattern as literal string instead of regex (default: false)" })),
|
|
11
|
+
context: Type.Optional(Type.Number({ description: "Number of lines to show before and after each match (default: 0)" })),
|
|
12
|
+
limit: Type.Optional(Type.Number({ description: "Maximum number of matches to return (default: 100)" })),
|
|
13
|
+
});
|
|
14
|
+
const DEFAULT_LIMIT = 100;
|
|
15
|
+
const defaultGrepOperations = {
|
|
16
|
+
isDirectory: (p) => statSync(p).isDirectory(),
|
|
17
|
+
readFile: (p) => readFileSync(p, "utf-8"),
|
|
18
|
+
readdir: (p) => {
|
|
19
|
+
const fs = require("fs");
|
|
20
|
+
return fs.readdirSync(p);
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
export function createGrepTool(cwd, options) {
|
|
24
|
+
const customOps = options?.operations;
|
|
25
|
+
return {
|
|
26
|
+
name: "grep",
|
|
27
|
+
label: "grep",
|
|
28
|
+
description: `Search file contents for a pattern. Returns matching lines with file paths and line numbers. Output is truncated to ${DEFAULT_LIMIT} matches or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Long lines are truncated to ${GREP_MAX_LINE_LENGTH} chars.`,
|
|
29
|
+
parameters: grepSchema,
|
|
30
|
+
execute: async (_toolCallId, { pattern, path: searchDir, ignoreCase, literal, context, limit, }, signal) => {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
if (signal?.aborted) {
|
|
33
|
+
reject(new Error("Operation aborted"));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const onAbort = () => reject(new Error("Operation aborted"));
|
|
37
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
38
|
+
(async () => {
|
|
39
|
+
try {
|
|
40
|
+
const searchPath = resolveToCwd(searchDir || ".", cwd);
|
|
41
|
+
const ops = customOps ?? defaultGrepOperations;
|
|
42
|
+
const effectiveLimit = limit ?? DEFAULT_LIMIT;
|
|
43
|
+
const contextValue = context && context > 0 ? context : 0;
|
|
44
|
+
// Check if path exists and get files to search
|
|
45
|
+
const filesToSearch = [];
|
|
46
|
+
const isDir = await ops.isDirectory(searchPath);
|
|
47
|
+
if (isDir) {
|
|
48
|
+
// Recursively find all files
|
|
49
|
+
const entries = await ops.readdir(searchPath);
|
|
50
|
+
for (const entry of entries) {
|
|
51
|
+
const fullPath = path.join(searchPath, entry);
|
|
52
|
+
try {
|
|
53
|
+
if ((await ops.isDirectory(fullPath)) && !entry.startsWith(".")) {
|
|
54
|
+
// Recursively search subdirectory
|
|
55
|
+
const subEntries = await ops.readdir(fullPath);
|
|
56
|
+
for (const subEntry of subEntries) {
|
|
57
|
+
filesToSearch.push(path.join(fullPath, subEntry));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else if (!await ops.isDirectory(fullPath)) {
|
|
61
|
+
filesToSearch.push(fullPath);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// Skip inaccessible files
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
filesToSearch.push(searchPath);
|
|
71
|
+
}
|
|
72
|
+
if (filesToSearch.length === 0) {
|
|
73
|
+
signal?.removeEventListener("abort", onAbort);
|
|
74
|
+
resolve({ content: [{ type: "text", text: "No files to search" }], details: undefined });
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
// Build regex from pattern
|
|
78
|
+
let regex;
|
|
79
|
+
try {
|
|
80
|
+
if (literal) {
|
|
81
|
+
regex = new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), ignoreCase ? "gi" : "g");
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
regex = new RegExp(pattern, ignoreCase ? "gi" : "g");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
signal?.removeEventListener("abort", onAbort);
|
|
89
|
+
reject(new Error(`Invalid regex pattern: ${e.message}`));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// Search files
|
|
93
|
+
const matches = [];
|
|
94
|
+
let linesTruncated = false;
|
|
95
|
+
for (const filePath of filesToSearch) {
|
|
96
|
+
if (matches.length >= effectiveLimit)
|
|
97
|
+
break;
|
|
98
|
+
try {
|
|
99
|
+
const content = await ops.readFile(filePath);
|
|
100
|
+
const lines = content.split("\n");
|
|
101
|
+
for (let i = 0; i < lines.length; i++) {
|
|
102
|
+
if (matches.length >= effectiveLimit)
|
|
103
|
+
break;
|
|
104
|
+
const line = lines[i];
|
|
105
|
+
if (regex.test(line)) {
|
|
106
|
+
// Get relative path
|
|
107
|
+
const relativePath = path.relative(searchPath, filePath);
|
|
108
|
+
// Truncate long lines
|
|
109
|
+
const { text: truncatedText, wasTruncated } = truncateLine(line, GREP_MAX_LINE_LENGTH);
|
|
110
|
+
if (wasTruncated)
|
|
111
|
+
linesTruncated = true;
|
|
112
|
+
// Add context lines
|
|
113
|
+
const output = [];
|
|
114
|
+
const start = Math.max(0, i - contextValue);
|
|
115
|
+
const end = Math.min(lines.length - 1, i + contextValue);
|
|
116
|
+
for (let j = start; j <= end; j++) {
|
|
117
|
+
const isMatch = j === i;
|
|
118
|
+
const prefix = isMatch ? ":" : "-";
|
|
119
|
+
const contextLine = lines[j];
|
|
120
|
+
const { text: ctxText } = truncateLine(contextLine, GREP_MAX_LINE_LENGTH);
|
|
121
|
+
output.push(`${relativePath}${prefix}${j + 1} ${ctxText}`);
|
|
122
|
+
}
|
|
123
|
+
matches.push({ file: relativePath, line: i + 1, text: output.join("\n") });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
// Skip files we can't read
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
signal?.removeEventListener("abort", onAbort);
|
|
132
|
+
if (matches.length === 0) {
|
|
133
|
+
resolve({ content: [{ type: "text", text: "No matches found" }], details: undefined });
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
// Format output
|
|
137
|
+
const outputLines = [];
|
|
138
|
+
for (const match of matches) {
|
|
139
|
+
outputLines.push(match.text);
|
|
140
|
+
}
|
|
141
|
+
// Apply truncation
|
|
142
|
+
const rawOutput = outputLines.join("\n");
|
|
143
|
+
const truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });
|
|
144
|
+
let output = truncation.content;
|
|
145
|
+
const details = {};
|
|
146
|
+
const notices = [];
|
|
147
|
+
if (matches.length >= effectiveLimit) {
|
|
148
|
+
notices.push(`${effectiveLimit} matches limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern`);
|
|
149
|
+
details.matchLimitReached = effectiveLimit;
|
|
150
|
+
}
|
|
151
|
+
if (truncation.truncated) {
|
|
152
|
+
notices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);
|
|
153
|
+
details.truncation = truncation;
|
|
154
|
+
}
|
|
155
|
+
if (linesTruncated) {
|
|
156
|
+
notices.push(`Some lines truncated to ${GREP_MAX_LINE_LENGTH} chars. Use read tool to see full lines`);
|
|
157
|
+
details.linesTruncated = true;
|
|
158
|
+
}
|
|
159
|
+
if (notices.length > 0) {
|
|
160
|
+
output += `\n\n[${notices.join(". ")}]`;
|
|
161
|
+
}
|
|
162
|
+
resolve({
|
|
163
|
+
content: [{ type: "text", text: output }],
|
|
164
|
+
details: Object.keys(details).length > 0 ? details : undefined,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
signal?.removeEventListener("abort", onAbort);
|
|
169
|
+
reject(e);
|
|
170
|
+
}
|
|
171
|
+
})();
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/** Default grep tool using process.cwd() - for backwards compatibility */
|
|
177
|
+
export const grepTool = createGrepTool(process.cwd());
|
|
178
|
+
//# sourceMappingURL=grep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grep.js","sourceRoot":"","sources":["../../../src/agent/tools/grep.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC5C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EACN,iBAAiB,EACjB,UAAU,EACV,oBAAoB,EAEpB,YAAY,EACZ,YAAY,GACZ,MAAM,eAAe,CAAC;AAEvB,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;IACjF,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,0DAA0D,EAAE,CAAC,CAAC;IAC7G,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC,CAAC;IACpG,OAAO,EAAE,IAAI,CAAC,QAAQ,CACrB,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,mEAAmE,EAAE,CAAC,CAClG;IACD,OAAO,EAAE,IAAI,CAAC,QAAQ,CACrB,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,kEAAkE,EAAE,CAAC,CAChG;IACD,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,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