@cloudbase/agent-tools 0.0.2
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 +416 -0
- package/dist/agent_tool.d.ts +7 -0
- package/dist/agent_tool.d.ts.map +1 -0
- package/dist/agent_tool.js +16 -0
- package/dist/agent_tool.js.map +1 -0
- package/dist/bash/bash-tool.d.ts +61 -0
- package/dist/bash/bash-tool.d.ts.map +1 -0
- package/dist/bash/bash-tool.js +191 -0
- package/dist/bash/bash-tool.js.map +1 -0
- package/dist/bash/index.d.ts +7 -0
- package/dist/bash/index.d.ts.map +1 -0
- package/dist/bash/index.js +17 -0
- package/dist/bash/index.js.map +1 -0
- package/dist/bash/operator/base-operator.d.ts +44 -0
- package/dist/bash/operator/base-operator.d.ts.map +1 -0
- package/dist/bash/operator/base-operator.js +14 -0
- package/dist/bash/operator/base-operator.js.map +1 -0
- package/dist/bash/operator/local-operator.d.ts +15 -0
- package/dist/bash/operator/local-operator.d.ts.map +1 -0
- package/dist/bash/operator/local-operator.js +145 -0
- package/dist/bash/operator/local-operator.js.map +1 -0
- package/dist/bash/operator/sandbox-operator.d.ts +22 -0
- package/dist/bash/operator/sandbox-operator.d.ts.map +1 -0
- package/dist/bash/operator/sandbox-operator.js +112 -0
- package/dist/bash/operator/sandbox-operator.js.map +1 -0
- package/dist/bash/utils.d.ts +106 -0
- package/dist/bash/utils.d.ts.map +1 -0
- package/dist/bash/utils.js +197 -0
- package/dist/bash/utils.js.map +1 -0
- package/dist/browser/browser-instance-manager.d.ts +79 -0
- package/dist/browser/browser-instance-manager.d.ts.map +1 -0
- package/dist/browser/browser-instance-manager.js +242 -0
- package/dist/browser/browser-instance-manager.js.map +1 -0
- package/dist/browser/browser-tool-executor.d.ts +57 -0
- package/dist/browser/browser-tool-executor.d.ts.map +1 -0
- package/dist/browser/browser-tool-executor.js +205 -0
- package/dist/browser/browser-tool-executor.js.map +1 -0
- package/dist/browser/browser_client_unified.d.ts +52 -0
- package/dist/browser/browser_client_unified.d.ts.map +1 -0
- package/dist/browser/browser_client_unified.js +381 -0
- package/dist/browser/browser_client_unified.js.map +1 -0
- package/dist/browser/browser_tool_unified.d.ts +93 -0
- package/dist/browser/browser_tool_unified.d.ts.map +1 -0
- package/dist/browser/browser_tool_unified.js +181 -0
- package/dist/browser/browser_tool_unified.js.map +1 -0
- package/dist/browser/index.d.ts +7 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +19 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/sandbox-connector.d.ts +93 -0
- package/dist/browser/sandbox-connector.d.ts.map +1 -0
- package/dist/browser/sandbox-connector.js +272 -0
- package/dist/browser/sandbox-connector.js.map +1 -0
- package/dist/browser/types.d.ts +53 -0
- package/dist/browser/types.d.ts.map +1 -0
- package/dist/browser/types.js +3 -0
- package/dist/browser/types.js.map +1 -0
- package/dist/code_executers/base_code_executor.d.ts +17 -0
- package/dist/code_executers/base_code_executor.d.ts.map +1 -0
- package/dist/code_executers/base_code_executor.js +20 -0
- package/dist/code_executers/base_code_executor.js.map +1 -0
- package/dist/code_executers/built_in_code_executor.d.ts +25 -0
- package/dist/code_executers/built_in_code_executor.d.ts.map +1 -0
- package/dist/code_executers/built_in_code_executor.js +106 -0
- package/dist/code_executers/built_in_code_executor.js.map +1 -0
- package/dist/code_executers/unsafe_local_code_executor.d.ts +118 -0
- package/dist/code_executers/unsafe_local_code_executor.d.ts.map +1 -0
- package/dist/code_executers/unsafe_local_code_executor.js +605 -0
- package/dist/code_executers/unsafe_local_code_executor.js.map +1 -0
- package/dist/fs/edit-tool.d.ts +26 -0
- package/dist/fs/edit-tool.d.ts.map +1 -0
- package/dist/fs/edit-tool.js +202 -0
- package/dist/fs/edit-tool.js.map +1 -0
- package/dist/fs/glob-tool.d.ts +31 -0
- package/dist/fs/glob-tool.d.ts.map +1 -0
- package/dist/fs/glob-tool.js +287 -0
- package/dist/fs/glob-tool.js.map +1 -0
- package/dist/fs/grep-tool.d.ts +32 -0
- package/dist/fs/grep-tool.d.ts.map +1 -0
- package/dist/fs/grep-tool.js +353 -0
- package/dist/fs/grep-tool.js.map +1 -0
- package/dist/fs/index.d.ts +11 -0
- package/dist/fs/index.d.ts.map +1 -0
- package/dist/fs/index.js +38 -0
- package/dist/fs/index.js.map +1 -0
- package/dist/fs/ls-tool.d.ts +26 -0
- package/dist/fs/ls-tool.d.ts.map +1 -0
- package/dist/fs/ls-tool.js +235 -0
- package/dist/fs/ls-tool.js.map +1 -0
- package/dist/fs/multiedit-tool.d.ts +34 -0
- package/dist/fs/multiedit-tool.d.ts.map +1 -0
- package/dist/fs/multiedit-tool.js +158 -0
- package/dist/fs/multiedit-tool.js.map +1 -0
- package/dist/fs/operator/base-operator.d.ts +28 -0
- package/dist/fs/operator/base-operator.d.ts.map +1 -0
- package/dist/fs/operator/base-operator.js +21 -0
- package/dist/fs/operator/base-operator.js.map +1 -0
- package/dist/fs/operator/in-memory-operator.d.ts +39 -0
- package/dist/fs/operator/in-memory-operator.d.ts.map +1 -0
- package/dist/fs/operator/in-memory-operator.js +115 -0
- package/dist/fs/operator/in-memory-operator.js.map +1 -0
- package/dist/fs/operator/index.d.ts +6 -0
- package/dist/fs/operator/index.d.ts.map +1 -0
- package/dist/fs/operator/index.js +28 -0
- package/dist/fs/operator/index.js.map +1 -0
- package/dist/fs/operator/local-operator.d.ts +25 -0
- package/dist/fs/operator/local-operator.d.ts.map +1 -0
- package/dist/fs/operator/local-operator.js +62 -0
- package/dist/fs/operator/local-operator.js.map +1 -0
- package/dist/fs/operator/sanbox-operator.d.ts +31 -0
- package/dist/fs/operator/sanbox-operator.d.ts.map +1 -0
- package/dist/fs/operator/sanbox-operator.js +172 -0
- package/dist/fs/operator/sanbox-operator.js.map +1 -0
- package/dist/fs/operator/transaction/index.d.ts +6 -0
- package/dist/fs/operator/transaction/index.d.ts.map +1 -0
- package/dist/fs/operator/transaction/index.js +28 -0
- package/dist/fs/operator/transaction/index.js.map +1 -0
- package/dist/fs/operator/transaction/snapshot-strategies.d.ts +54 -0
- package/dist/fs/operator/transaction/snapshot-strategies.d.ts.map +1 -0
- package/dist/fs/operator/transaction/snapshot-strategies.js +278 -0
- package/dist/fs/operator/transaction/snapshot-strategies.js.map +1 -0
- package/dist/fs/operator/transaction/transaction-operator.d.ts +53 -0
- package/dist/fs/operator/transaction/transaction-operator.d.ts.map +1 -0
- package/dist/fs/operator/transaction/transaction-operator.js +195 -0
- package/dist/fs/operator/transaction/transaction-operator.js.map +1 -0
- package/dist/fs/operator/transaction/transaction-utils.d.ts +80 -0
- package/dist/fs/operator/transaction/transaction-utils.d.ts.map +1 -0
- package/dist/fs/operator/transaction/transaction-utils.js +156 -0
- package/dist/fs/operator/transaction/transaction-utils.js.map +1 -0
- package/dist/fs/read-tool.d.ts +32 -0
- package/dist/fs/read-tool.d.ts.map +1 -0
- package/dist/fs/read-tool.js +271 -0
- package/dist/fs/read-tool.js.map +1 -0
- package/dist/fs/str-replace-editor.d.ts +23 -0
- package/dist/fs/str-replace-editor.d.ts.map +1 -0
- package/dist/fs/str-replace-editor.js +74 -0
- package/dist/fs/str-replace-editor.js.map +1 -0
- package/dist/fs/toolkit.d.ts +61 -0
- package/dist/fs/toolkit.d.ts.map +1 -0
- package/dist/fs/toolkit.js +113 -0
- package/dist/fs/toolkit.js.map +1 -0
- package/dist/fs/utils.d.ts +32 -0
- package/dist/fs/utils.d.ts.map +1 -0
- package/dist/fs/utils.js +133 -0
- package/dist/fs/utils.js.map +1 -0
- package/dist/fs/write-tool.d.ts +26 -0
- package/dist/fs/write-tool.d.ts.map +1 -0
- package/dist/fs/write-tool.js +110 -0
- package/dist/fs/write-tool.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/agkit-mcp-server.d.ts +291 -0
- package/dist/mcp/agkit-mcp-server.d.ts.map +1 -0
- package/dist/mcp/agkit-mcp-server.js +821 -0
- package/dist/mcp/agkit-mcp-server.js.map +1 -0
- package/dist/mcp/client-tool.d.ts +65 -0
- package/dist/mcp/client-tool.d.ts.map +1 -0
- package/dist/mcp/client-tool.js +220 -0
- package/dist/mcp/client-tool.js.map +1 -0
- package/dist/mcp/index.d.ts +14 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +26 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/mcp-client-manager.d.ts +153 -0
- package/dist/mcp/mcp-client-manager.d.ts.map +1 -0
- package/dist/mcp/mcp-client-manager.js +606 -0
- package/dist/mcp/mcp-client-manager.js.map +1 -0
- package/dist/mcp/mcp-toolkit.d.ts +112 -0
- package/dist/mcp/mcp-toolkit.d.ts.map +1 -0
- package/dist/mcp/mcp-toolkit.js +188 -0
- package/dist/mcp/mcp-toolkit.js.map +1 -0
- package/dist/mcp/types.d.ts +157 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +34 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/mcp/utils.d.ts +17 -0
- package/dist/mcp/utils.d.ts.map +1 -0
- package/dist/mcp/utils.js +48 -0
- package/dist/mcp/utils.js.map +1 -0
- package/dist/types/index.d.ts +31 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/zod.d.ts +18 -0
- package/dist/types/zod.d.ts.map +1 -0
- package/dist/types/zod.js +3 -0
- package/dist/types/zod.js.map +1 -0
- package/dist/utils.d.ts +141 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +379 -0
- package/dist/utils.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createGrepTool = createGrepTool;
|
|
37
|
+
const v4_1 = require("zod/v4");
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const utils_1 = require("./utils");
|
|
40
|
+
const utils_2 = require("../utils");
|
|
41
|
+
const grepParametersSchema = v4_1.z.object({
|
|
42
|
+
pattern: v4_1.z
|
|
43
|
+
.string()
|
|
44
|
+
.describe('Regular expression pattern to search for (e.g., "function\\s+\\w+", "import.*from")'),
|
|
45
|
+
path: v4_1.z
|
|
46
|
+
.string()
|
|
47
|
+
.optional()
|
|
48
|
+
.describe("Directory to search in (relative to workspace root, or absolute path within workspace). Defaults to workspace root."),
|
|
49
|
+
include: v4_1.z
|
|
50
|
+
.string()
|
|
51
|
+
.optional()
|
|
52
|
+
.describe('File pattern to include (e.g., "*.js", "*.{ts,tsx}", "src/**/*.ts")'),
|
|
53
|
+
case_sensitive: v4_1.z
|
|
54
|
+
.boolean()
|
|
55
|
+
.optional()
|
|
56
|
+
.describe("Whether the search should be case-sensitive (default: false)"),
|
|
57
|
+
max_files: v4_1.z
|
|
58
|
+
.number()
|
|
59
|
+
.min(1)
|
|
60
|
+
.optional()
|
|
61
|
+
.describe("Maximum number of files to search (default: 1000)"),
|
|
62
|
+
max_matches: v4_1.z
|
|
63
|
+
.number()
|
|
64
|
+
.min(1)
|
|
65
|
+
.optional()
|
|
66
|
+
.describe("Maximum number of matches to return (default: 100)"),
|
|
67
|
+
});
|
|
68
|
+
// Path validation is now handled by validateWorkspacePath in tool-utils
|
|
69
|
+
/**
|
|
70
|
+
* Check if a file path matches the include pattern
|
|
71
|
+
*/
|
|
72
|
+
function matchesIncludePattern(filePath, includePattern) {
|
|
73
|
+
if (!includePattern) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
// Convert glob pattern to regex (simplified)
|
|
77
|
+
const regexPattern = includePattern
|
|
78
|
+
.replace(/[.+^${}()|[\]\\]/g, "\\$&") // Escape special regex chars
|
|
79
|
+
.replace(/\*\*/g, "###DOUBLESTAR###") // Temporarily replace **
|
|
80
|
+
.replace(/\*/g, "[^/]*") // * becomes [^/]* (no directory separators)
|
|
81
|
+
.replace(/###DOUBLESTAR###/g, ".*") // ** becomes .* (any characters)
|
|
82
|
+
.replace(/\?/g, "[^/]"); // ? becomes [^/] (single char, no dir sep)
|
|
83
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
84
|
+
return regex.test(filePath);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Check if a file should be skipped based on common patterns
|
|
88
|
+
*/
|
|
89
|
+
function shouldSkipFile(filePath) {
|
|
90
|
+
const skipPatterns = [
|
|
91
|
+
/node_modules/,
|
|
92
|
+
/\.git/,
|
|
93
|
+
/\.vscode/,
|
|
94
|
+
/dist/,
|
|
95
|
+
/build/,
|
|
96
|
+
/coverage/,
|
|
97
|
+
/\.nyc_output/,
|
|
98
|
+
/\.next/,
|
|
99
|
+
/\.cache/,
|
|
100
|
+
/\.DS_Store/,
|
|
101
|
+
/Thumbs\.db/,
|
|
102
|
+
/\.log$/,
|
|
103
|
+
/\.tmp$/,
|
|
104
|
+
/\.temp$/,
|
|
105
|
+
];
|
|
106
|
+
return skipPatterns.some((pattern) => pattern.test(filePath));
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Simple check if file is likely a text file
|
|
110
|
+
*/
|
|
111
|
+
function isTextFile(filePath) {
|
|
112
|
+
const textExtensions = [
|
|
113
|
+
".js",
|
|
114
|
+
".ts",
|
|
115
|
+
".jsx",
|
|
116
|
+
".tsx",
|
|
117
|
+
".json",
|
|
118
|
+
".html",
|
|
119
|
+
".htm",
|
|
120
|
+
".css",
|
|
121
|
+
".scss",
|
|
122
|
+
".sass",
|
|
123
|
+
".py",
|
|
124
|
+
".java",
|
|
125
|
+
".cpp",
|
|
126
|
+
".c",
|
|
127
|
+
".h",
|
|
128
|
+
".hpp",
|
|
129
|
+
".cs",
|
|
130
|
+
".php",
|
|
131
|
+
".rb",
|
|
132
|
+
".go",
|
|
133
|
+
".rs",
|
|
134
|
+
".swift",
|
|
135
|
+
".kt",
|
|
136
|
+
".scala",
|
|
137
|
+
".clj",
|
|
138
|
+
".hs",
|
|
139
|
+
".elm",
|
|
140
|
+
".ml",
|
|
141
|
+
".f",
|
|
142
|
+
".txt",
|
|
143
|
+
".md",
|
|
144
|
+
".rst",
|
|
145
|
+
".asciidoc",
|
|
146
|
+
".xml",
|
|
147
|
+
".yaml",
|
|
148
|
+
".yml",
|
|
149
|
+
".toml",
|
|
150
|
+
".ini",
|
|
151
|
+
".cfg",
|
|
152
|
+
".conf",
|
|
153
|
+
".properties",
|
|
154
|
+
".env",
|
|
155
|
+
".gitignore",
|
|
156
|
+
".gitattributes",
|
|
157
|
+
".dockerfile",
|
|
158
|
+
".makefile",
|
|
159
|
+
".sh",
|
|
160
|
+
".bat",
|
|
161
|
+
".ps1",
|
|
162
|
+
".sql",
|
|
163
|
+
".graphql",
|
|
164
|
+
".vue",
|
|
165
|
+
".svelte",
|
|
166
|
+
".astro",
|
|
167
|
+
".prisma",
|
|
168
|
+
".proto",
|
|
169
|
+
];
|
|
170
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
171
|
+
return textExtensions.includes(ext) || !ext; // Include extensionless files
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Recursively find files to search
|
|
175
|
+
*/
|
|
176
|
+
async function findFilesToSearch(context, dirPath, includePattern, maxFiles = 1000) {
|
|
177
|
+
const files = [];
|
|
178
|
+
const scanDirectory = async (currentPath) => {
|
|
179
|
+
if (files.length >= maxFiles) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
const entries = (await context.fsOperator.readdir(currentPath, {
|
|
184
|
+
withFileTypes: true,
|
|
185
|
+
}));
|
|
186
|
+
for (const entry of entries) {
|
|
187
|
+
if (files.length >= maxFiles) {
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
const fullPath = path.join(currentPath, entry.name.toString());
|
|
191
|
+
const relativePath = path.relative(dirPath, fullPath);
|
|
192
|
+
// Skip common directories and files
|
|
193
|
+
if (shouldSkipFile(relativePath)) {
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
if (entry.isDirectory()) {
|
|
197
|
+
await scanDirectory(fullPath);
|
|
198
|
+
}
|
|
199
|
+
else if (entry.isFile()) {
|
|
200
|
+
// Check if file matches include pattern
|
|
201
|
+
if (matchesIncludePattern(relativePath, includePattern)) {
|
|
202
|
+
// Only include text files (basic check)
|
|
203
|
+
if (isTextFile(fullPath)) {
|
|
204
|
+
files.push(fullPath);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
// Ignore permission errors and continue
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
await scanDirectory(dirPath);
|
|
215
|
+
return files;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Search for pattern in a single file
|
|
219
|
+
*/
|
|
220
|
+
async function searchInFile(context, filePath, regex, maxMatches) {
|
|
221
|
+
const matches = [];
|
|
222
|
+
try {
|
|
223
|
+
const content = (await context.fsOperator.readFile(filePath, "utf8")).toString();
|
|
224
|
+
const lines = content.split(/\r?\n/);
|
|
225
|
+
for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
|
|
226
|
+
if (matches.length >= maxMatches) {
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
const line = lines[lineIndex];
|
|
230
|
+
let match;
|
|
231
|
+
regex.lastIndex = 0; // Reset regex state
|
|
232
|
+
while ((match = regex.exec(line)) !== null) {
|
|
233
|
+
matches.push({
|
|
234
|
+
filePath,
|
|
235
|
+
lineNumber: lineIndex + 1,
|
|
236
|
+
line: line,
|
|
237
|
+
matchStart: match.index,
|
|
238
|
+
matchEnd: match.index + match[0].length,
|
|
239
|
+
});
|
|
240
|
+
if (matches.length >= maxMatches) {
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
// Prevent infinite loop on zero-length matches
|
|
244
|
+
if (match.index === regex.lastIndex) {
|
|
245
|
+
regex.lastIndex++;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
// Ignore files that can't be read (binary files, permission issues, etc.)
|
|
252
|
+
}
|
|
253
|
+
return matches;
|
|
254
|
+
}
|
|
255
|
+
function createGrepTool(context) {
|
|
256
|
+
return (0, utils_2.tool)(async (params) => {
|
|
257
|
+
try {
|
|
258
|
+
const { pattern, path: searchPath = ".", include, case_sensitive = false, max_files = 1000, max_matches = 100, } = params;
|
|
259
|
+
// Pattern validation (test if it's a valid regex)
|
|
260
|
+
try {
|
|
261
|
+
new RegExp(pattern);
|
|
262
|
+
}
|
|
263
|
+
catch (error) {
|
|
264
|
+
return (0, utils_2.handleToolError)(`Invalid regular expression pattern: ${error instanceof Error ? error.message : String(error)}`, "Pattern validation", "validation");
|
|
265
|
+
}
|
|
266
|
+
// Validate workspace path (handles both absolute and relative paths)
|
|
267
|
+
const pathError = (0, utils_1.validateWorkspacePath)(searchPath, context);
|
|
268
|
+
if (pathError) {
|
|
269
|
+
return pathError;
|
|
270
|
+
}
|
|
271
|
+
// Resolve search directory
|
|
272
|
+
const absolutePath = (0, utils_1.resolveWorkspacePath)(searchPath, context);
|
|
273
|
+
// Check if path exists and is a directory
|
|
274
|
+
const dirError = await (0, utils_1.validateDirectoryExists)(context, absolutePath, searchPath);
|
|
275
|
+
if (dirError) {
|
|
276
|
+
return dirError;
|
|
277
|
+
}
|
|
278
|
+
// Create regex pattern
|
|
279
|
+
const regexFlags = case_sensitive ? "g" : "gi";
|
|
280
|
+
const regex = new RegExp(pattern, regexFlags);
|
|
281
|
+
// Find files to search
|
|
282
|
+
const filesToSearch = await findFilesToSearch(context, absolutePath, include, max_files);
|
|
283
|
+
if (filesToSearch.length === 0) {
|
|
284
|
+
const message = `No files found to search in ${searchPath}${include ? ` matching ${include}` : ""}`;
|
|
285
|
+
return (0, utils_1.createSuccessResponse)({
|
|
286
|
+
pattern,
|
|
287
|
+
search_path: searchPath,
|
|
288
|
+
include_pattern: include,
|
|
289
|
+
files_searched: 0,
|
|
290
|
+
matches: [],
|
|
291
|
+
total_matches: 0,
|
|
292
|
+
message,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
// Search in files
|
|
296
|
+
const allMatches = [];
|
|
297
|
+
let filesSearched = 0;
|
|
298
|
+
let filesWithMatches = 0;
|
|
299
|
+
for (const file of filesToSearch) {
|
|
300
|
+
if (allMatches.length >= max_matches) {
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
const fileMatches = await searchInFile(context, file, regex, max_matches - allMatches.length);
|
|
304
|
+
if (fileMatches.length > 0) {
|
|
305
|
+
// Convert absolute paths to relative paths for output
|
|
306
|
+
const relativePath = path.relative(absolutePath, file);
|
|
307
|
+
fileMatches.forEach((match) => {
|
|
308
|
+
match.filePath = relativePath;
|
|
309
|
+
});
|
|
310
|
+
allMatches.push(...fileMatches);
|
|
311
|
+
filesWithMatches++;
|
|
312
|
+
}
|
|
313
|
+
filesSearched++;
|
|
314
|
+
}
|
|
315
|
+
// Format results
|
|
316
|
+
let summary = `Found ${allMatches.length} match(es) for "${pattern}" in ${filesWithMatches} file(s)`;
|
|
317
|
+
if (filesSearched < filesToSearch.length) {
|
|
318
|
+
summary += ` (searched ${filesSearched}/${filesToSearch.length} files)`;
|
|
319
|
+
}
|
|
320
|
+
// Group matches by file for better readability
|
|
321
|
+
const matchesByFile = {};
|
|
322
|
+
allMatches.forEach((match) => {
|
|
323
|
+
if (!matchesByFile[match.filePath]) {
|
|
324
|
+
matchesByFile[match.filePath] = [];
|
|
325
|
+
}
|
|
326
|
+
matchesByFile[match.filePath].push(match);
|
|
327
|
+
});
|
|
328
|
+
return (0, utils_1.createSuccessResponse)({
|
|
329
|
+
pattern,
|
|
330
|
+
search_path: searchPath,
|
|
331
|
+
include_pattern: include,
|
|
332
|
+
files_searched: filesSearched,
|
|
333
|
+
files_with_matches: filesWithMatches,
|
|
334
|
+
matches: allMatches,
|
|
335
|
+
matches_by_file: matchesByFile,
|
|
336
|
+
total_matches: allMatches.length,
|
|
337
|
+
summary,
|
|
338
|
+
truncated: allMatches.length >= max_matches,
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
catch (error) {
|
|
342
|
+
return (0, utils_2.handleToolError)(error, "Grep tool execution", "execution");
|
|
343
|
+
}
|
|
344
|
+
}, {
|
|
345
|
+
name: "Grep",
|
|
346
|
+
description: '\n- Fast content search tool that works with any codebase size\n- Searches file contents using regular expressions\n- Supports full regex syntax (eg. "log.*Error", "function\\s+\\w+", etc.)\n- Filter files by pattern with the include parameter (eg. "*.js", "*.{ts,tsx}")\n- Returns file paths with at least one match sorted by modification time\n- Use this tool when you need to find files containing specific patterns\n',
|
|
347
|
+
schema: grepParametersSchema,
|
|
348
|
+
getDisplay: ({ name, input }) => {
|
|
349
|
+
return `Using ${name} for tool call: ${input.pattern || ""}`;
|
|
350
|
+
},
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
//# sourceMappingURL=grep-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grep-tool.js","sourceRoot":"","sources":["../../src/fs/grep-tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsSA,wCA8IC;AApbD,+BAA2B;AAC3B,2CAA6B;AAC7B,mCAMiB;AACjB,oCAAiD;AAMjD,MAAM,oBAAoB,GAAG,MAAC,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,MAAC;SACP,MAAM,EAAE;SACR,QAAQ,CACP,qFAAqF,CACtF;IACH,IAAI,EAAE,MAAC;SACJ,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,qHAAqH,CACtH;IACH,OAAO,EAAE,MAAC;SACP,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,qEAAqE,CACtE;IACH,cAAc,EAAE,MAAC;SACd,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,QAAQ,CAAC,8DAA8D,CAAC;IAC3E,SAAS,EAAE,MAAC;SACT,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,EAAE;SACV,QAAQ,CAA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write-tool";
|
|
3
|
+
export { createEditTool } from "./edit-tool";
|
|
4
|
+
export { createGlobTool } from "./glob-tool";
|
|
5
|
+
export { createGrepTool } from "./grep-tool";
|
|
6
|
+
export { createLsTool } from "./ls-tool";
|
|
7
|
+
export { createStrReplaceEditorTool } from "./str-replace-editor";
|
|
8
|
+
export { FilesystemToolkit, type FilesystemToolkitConfig, type FilesystemToolkitOptions, } from "./toolkit";
|
|
9
|
+
export * from "./utils";
|
|
10
|
+
export * from "./operator";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fs/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAGlE,OAAO,EACL,iBAAiB,EACjB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,GAC9B,MAAM,WAAW,CAAC;AAEnB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
|
package/dist/fs/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.FilesystemToolkit = exports.createStrReplaceEditorTool = exports.createLsTool = exports.createGrepTool = exports.createGlobTool = exports.createEditTool = exports.createWriteTool = exports.createReadTool = void 0;
|
|
18
|
+
// File system tools export
|
|
19
|
+
var read_tool_1 = require("./read-tool");
|
|
20
|
+
Object.defineProperty(exports, "createReadTool", { enumerable: true, get: function () { return read_tool_1.createReadTool; } });
|
|
21
|
+
var write_tool_1 = require("./write-tool");
|
|
22
|
+
Object.defineProperty(exports, "createWriteTool", { enumerable: true, get: function () { return write_tool_1.createWriteTool; } });
|
|
23
|
+
var edit_tool_1 = require("./edit-tool");
|
|
24
|
+
Object.defineProperty(exports, "createEditTool", { enumerable: true, get: function () { return edit_tool_1.createEditTool; } });
|
|
25
|
+
var glob_tool_1 = require("./glob-tool");
|
|
26
|
+
Object.defineProperty(exports, "createGlobTool", { enumerable: true, get: function () { return glob_tool_1.createGlobTool; } });
|
|
27
|
+
var grep_tool_1 = require("./grep-tool");
|
|
28
|
+
Object.defineProperty(exports, "createGrepTool", { enumerable: true, get: function () { return grep_tool_1.createGrepTool; } });
|
|
29
|
+
var ls_tool_1 = require("./ls-tool");
|
|
30
|
+
Object.defineProperty(exports, "createLsTool", { enumerable: true, get: function () { return ls_tool_1.createLsTool; } });
|
|
31
|
+
var str_replace_editor_1 = require("./str-replace-editor");
|
|
32
|
+
Object.defineProperty(exports, "createStrReplaceEditorTool", { enumerable: true, get: function () { return str_replace_editor_1.createStrReplaceEditorTool; } });
|
|
33
|
+
// Filesystem toolkit exports
|
|
34
|
+
var toolkit_1 = require("./toolkit");
|
|
35
|
+
Object.defineProperty(exports, "FilesystemToolkit", { enumerable: true, get: function () { return toolkit_1.FilesystemToolkit; } });
|
|
36
|
+
__exportStar(require("./utils"), exports);
|
|
37
|
+
__exportStar(require("./operator"), exports);
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2BAA2B;AAC3B,yCAA6C;AAApC,2GAAA,cAAc,OAAA;AACvB,2CAA+C;AAAtC,6GAAA,eAAe,OAAA;AACxB,yCAA6C;AAApC,2GAAA,cAAc,OAAA;AACvB,yCAA6C;AAApC,2GAAA,cAAc,OAAA;AACvB,yCAA6C;AAApC,2GAAA,cAAc,OAAA;AACvB,qCAAyC;AAAhC,uGAAA,YAAY,OAAA;AACrB,2DAAkE;AAAzD,gIAAA,0BAA0B,OAAA;AAEnC,6BAA6B;AAC7B,qCAImB;AAHjB,4GAAA,iBAAiB,OAAA;AAKnB,0CAAwB;AACxB,6CAA2B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
import { ExecutionContext } from "./utils";
|
|
3
|
+
interface FileEntry {
|
|
4
|
+
name: string;
|
|
5
|
+
isDirectory: boolean;
|
|
6
|
+
size: number;
|
|
7
|
+
modifiedTime: Date;
|
|
8
|
+
extension?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function createLsTool(context: ExecutionContext): import("../utils").DynamicTool<z.ZodObject<{
|
|
11
|
+
path: z.ZodOptional<z.ZodString>;
|
|
12
|
+
ignore: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
13
|
+
}, z.core.$strip>, Record<string, unknown>, {
|
|
14
|
+
path: string;
|
|
15
|
+
absolute_path: string;
|
|
16
|
+
entries: FileEntry[];
|
|
17
|
+
total_count: number;
|
|
18
|
+
hidden_count?: number;
|
|
19
|
+
ignored_count?: number;
|
|
20
|
+
directories?: number;
|
|
21
|
+
files?: number;
|
|
22
|
+
summary?: string;
|
|
23
|
+
detailed_listing?: string;
|
|
24
|
+
}>;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=ls-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ls-tool.d.ts","sourceRoot":"","sources":["../../src/fs/ls-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAG3B,OAAO,EACL,gBAAgB,EAKjB,MAAM,SAAS,CAAC;AAwBjB,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAqED,wBAAgB,YAAY,CAAC,OAAO,EAAE,gBAAgB;;;;UAMxC,MAAM;mBACG,MAAM;aACZ,SAAS,EAAE;iBACP,MAAM;mBACJ,MAAM;oBACL,MAAM;kBACR,MAAM;YACZ,MAAM;cACJ,MAAM;uBACG,MAAM;GAqJhC"}
|