@skroyc/librarian 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -16
- package/dist/agents/context-schema.d.ts +1 -1
- package/dist/agents/context-schema.d.ts.map +1 -1
- package/dist/agents/context-schema.js +5 -2
- package/dist/agents/context-schema.js.map +1 -1
- package/dist/agents/react-agent.d.ts.map +1 -1
- package/dist/agents/react-agent.js +36 -27
- package/dist/agents/react-agent.js.map +1 -1
- package/dist/agents/tool-runtime.d.ts.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +53 -49
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +115 -69
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +246 -150
- package/dist/index.js.map +1 -1
- package/dist/tools/file-finding.tool.d.ts +1 -1
- package/dist/tools/file-finding.tool.d.ts.map +1 -1
- package/dist/tools/file-finding.tool.js +70 -130
- package/dist/tools/file-finding.tool.js.map +1 -1
- package/dist/tools/file-listing.tool.d.ts +7 -1
- package/dist/tools/file-listing.tool.d.ts.map +1 -1
- package/dist/tools/file-listing.tool.js +96 -80
- package/dist/tools/file-listing.tool.js.map +1 -1
- package/dist/tools/file-reading.tool.d.ts +4 -1
- package/dist/tools/file-reading.tool.d.ts.map +1 -1
- package/dist/tools/file-reading.tool.js +107 -45
- package/dist/tools/file-reading.tool.js.map +1 -1
- package/dist/tools/grep-content.tool.d.ts +13 -1
- package/dist/tools/grep-content.tool.d.ts.map +1 -1
- package/dist/tools/grep-content.tool.js +186 -144
- package/dist/tools/grep-content.tool.js.map +1 -1
- package/dist/utils/error-utils.d.ts +9 -0
- package/dist/utils/error-utils.d.ts.map +1 -0
- package/dist/utils/error-utils.js +61 -0
- package/dist/utils/error-utils.js.map +1 -0
- package/dist/utils/file-utils.d.ts +1 -0
- package/dist/utils/file-utils.d.ts.map +1 -1
- package/dist/utils/file-utils.js +81 -9
- package/dist/utils/file-utils.js.map +1 -1
- package/dist/utils/format-utils.d.ts +25 -0
- package/dist/utils/format-utils.d.ts.map +1 -0
- package/dist/utils/format-utils.js +111 -0
- package/dist/utils/format-utils.js.map +1 -0
- package/dist/utils/gitignore-service.d.ts +10 -0
- package/dist/utils/gitignore-service.d.ts.map +1 -0
- package/dist/utils/gitignore-service.js +91 -0
- package/dist/utils/gitignore-service.js.map +1 -0
- package/dist/utils/logger.d.ts +2 -2
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +35 -34
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/path-utils.js +3 -3
- package/dist/utils/path-utils.js.map +1 -1
- package/package.json +1 -1
- package/src/agents/context-schema.ts +5 -2
- package/src/agents/react-agent.ts +667 -641
- package/src/agents/tool-runtime.ts +4 -4
- package/src/cli.ts +95 -57
- package/src/config.ts +192 -90
- package/src/index.ts +402 -180
- package/src/tools/file-finding.tool.ts +198 -310
- package/src/tools/file-listing.tool.ts +245 -202
- package/src/tools/file-reading.tool.ts +225 -138
- package/src/tools/grep-content.tool.ts +387 -307
- package/src/utils/error-utils.ts +95 -0
- package/src/utils/file-utils.ts +104 -19
- package/src/utils/format-utils.ts +190 -0
- package/src/utils/gitignore-service.ts +123 -0
- package/src/utils/logger.ts +112 -77
- package/src/utils/path-utils.ts +3 -3
|
@@ -1,198 +1,220 @@
|
|
|
1
|
+
import { stat } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { Glob } from "bun";
|
|
1
4
|
import { tool } from "langchain";
|
|
2
5
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { logger } from "../utils/logger.js";
|
|
6
|
+
import { formatToolError, getToolSuggestion } from "../utils/error-utils.js";
|
|
6
7
|
import { isTextFile } from "../utils/file-utils.js";
|
|
7
|
-
|
|
8
|
+
import { formatSearchResults, } from "../utils/format-utils.js";
|
|
9
|
+
import { GitIgnoreService } from "../utils/gitignore-service.js";
|
|
10
|
+
import { logger } from "../utils/logger.js";
|
|
11
|
+
async function searchFileWithContext(filePath, regex, contextBefore = 0, contextAfter = 0) {
|
|
12
|
+
const file = Bun.file(filePath);
|
|
13
|
+
const stream = file.stream();
|
|
14
|
+
const reader = stream.getReader();
|
|
15
|
+
const decoder = new TextDecoder();
|
|
16
|
+
const matches = [];
|
|
17
|
+
const beforeBuffer = [];
|
|
18
|
+
let currentLineNum = 1;
|
|
19
|
+
let partialLine = "";
|
|
20
|
+
const pendingMatches = [];
|
|
8
21
|
try {
|
|
9
|
-
|
|
22
|
+
while (true) {
|
|
23
|
+
const { done, value } = await reader.read();
|
|
24
|
+
if (done) {
|
|
25
|
+
if (partialLine) {
|
|
26
|
+
processLine(partialLine);
|
|
27
|
+
}
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
const chunk = decoder.decode(value, { stream: true });
|
|
31
|
+
const lines = (partialLine + chunk).split("\n");
|
|
32
|
+
partialLine = lines.pop() || "";
|
|
33
|
+
for (const line of lines) {
|
|
34
|
+
processLine(line);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
10
37
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
throw new Error(`Failed to read file: ${errorMessage}`);
|
|
38
|
+
finally {
|
|
39
|
+
reader.releaseLock();
|
|
14
40
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
41
|
+
function processLine(line) {
|
|
42
|
+
for (const pending of pendingMatches) {
|
|
43
|
+
if (pending.linesRemaining > 0) {
|
|
44
|
+
pending.match.context?.after.push(line);
|
|
45
|
+
pending.linesRemaining--;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
for (let i = pendingMatches.length - 1; i >= 0; i--) {
|
|
49
|
+
const pending = pendingMatches[i];
|
|
50
|
+
if (pending && pending.linesRemaining === 0) {
|
|
51
|
+
pendingMatches.splice(i, 1);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
regex.lastIndex = 0;
|
|
55
|
+
const matchExec = regex.exec(line);
|
|
56
|
+
if (matchExec !== null) {
|
|
57
|
+
const searchMatch = {
|
|
58
|
+
line: currentLineNum,
|
|
59
|
+
column: matchExec.index + 1,
|
|
29
60
|
text: line,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
61
|
+
};
|
|
62
|
+
if (contextBefore > 0 || contextAfter > 0) {
|
|
63
|
+
const context = {
|
|
64
|
+
before: contextBefore > 0 ? [...beforeBuffer] : [],
|
|
65
|
+
after: [],
|
|
66
|
+
};
|
|
67
|
+
searchMatch.context = context;
|
|
68
|
+
if (contextAfter > 0) {
|
|
69
|
+
pendingMatches.push({
|
|
70
|
+
match: searchMatch,
|
|
71
|
+
linesRemaining: contextAfter,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
matches.push(searchMatch);
|
|
33
76
|
}
|
|
77
|
+
if (contextBefore > 0) {
|
|
78
|
+
beforeBuffer.push(line);
|
|
79
|
+
if (beforeBuffer.length > contextBefore) {
|
|
80
|
+
beforeBuffer.shift();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
currentLineNum++;
|
|
34
84
|
}
|
|
35
85
|
return matches;
|
|
36
86
|
}
|
|
37
|
-
async function
|
|
87
|
+
async function findFilesToSearch(dirPath, patterns, recursive, includeHidden) {
|
|
38
88
|
const foundFiles = [];
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
89
|
+
for (const pattern of patterns) {
|
|
90
|
+
const effectivePattern = recursive && !pattern.includes("/") && !pattern.includes("**")
|
|
91
|
+
? `**/${pattern}`
|
|
92
|
+
: pattern;
|
|
93
|
+
const glob = new Glob(effectivePattern);
|
|
94
|
+
for await (const file of glob.scan({
|
|
95
|
+
cwd: dirPath,
|
|
96
|
+
onlyFiles: true,
|
|
97
|
+
dot: includeHidden,
|
|
98
|
+
})) {
|
|
99
|
+
const fullPath = path.resolve(dirPath, file);
|
|
100
|
+
if (!foundFiles.includes(fullPath)) {
|
|
101
|
+
foundFiles.push(fullPath);
|
|
46
102
|
}
|
|
47
103
|
}
|
|
48
|
-
else if (entry.isFile() && (pattern === "*" || entry.name.includes(pattern.replace(/\*/g, "")))) {
|
|
49
|
-
foundFiles.push(fullPath);
|
|
50
|
-
}
|
|
51
104
|
}
|
|
52
105
|
return foundFiles;
|
|
53
106
|
}
|
|
54
|
-
async function validateAndResolvePath(workingDir, searchPath) {
|
|
55
|
-
const resolvedPath = path.resolve(workingDir, searchPath);
|
|
56
|
-
const resolvedWorkingDir = path.resolve(workingDir);
|
|
57
|
-
const relativePath = path.relative(resolvedWorkingDir, resolvedPath);
|
|
58
|
-
logger.debug("TOOL", "Path validation", {
|
|
59
|
-
resolvedPath: resolvedPath.replace(Bun.env.HOME || "", "~"),
|
|
60
|
-
resolvedWorkingDir: resolvedWorkingDir.replace(Bun.env.HOME || "", "~"),
|
|
61
|
-
relativePath,
|
|
62
|
-
validated: !relativePath.startsWith(".."),
|
|
63
|
-
});
|
|
64
|
-
if (relativePath.startsWith("..")) {
|
|
65
|
-
logger.error("PATH", "Search path escapes working directory sandbox", undefined, { searchPath, relativePath });
|
|
66
|
-
throw new Error(`Search path "${searchPath}" attempts to escape the working directory sandbox`);
|
|
67
|
-
}
|
|
68
|
-
const stats = await stat(resolvedPath);
|
|
69
|
-
if (!stats.isDirectory()) {
|
|
70
|
-
logger.error("TOOL", "Search path is not a directory", undefined, {
|
|
71
|
-
searchPath,
|
|
72
|
-
});
|
|
73
|
-
throw new Error(`Search path "${searchPath}" is not a directory`);
|
|
74
|
-
}
|
|
75
|
-
return resolvedPath;
|
|
76
|
-
}
|
|
77
|
-
async function findFilesToSearch(resolvedPath, patterns, recursive) {
|
|
78
|
-
let filesToSearch = [];
|
|
79
|
-
for (const pattern of patterns) {
|
|
80
|
-
const foundFiles = await findFiles(resolvedPath, pattern, recursive);
|
|
81
|
-
filesToSearch = [...filesToSearch, ...foundFiles];
|
|
82
|
-
}
|
|
83
|
-
logger.debug("TOOL", "Files to search", {
|
|
84
|
-
count: filesToSearch.length,
|
|
85
|
-
patterns,
|
|
86
|
-
});
|
|
87
|
-
return filesToSearch;
|
|
88
|
-
}
|
|
89
107
|
function compileSearchRegex(query, regex, caseSensitive) {
|
|
90
108
|
const flags = caseSensitive ? "gm" : "gim";
|
|
91
109
|
if (regex) {
|
|
92
110
|
try {
|
|
93
|
-
|
|
94
|
-
logger.debug("TOOL", "Regex pattern compiled", { query, flags });
|
|
95
|
-
return searchRegex;
|
|
111
|
+
return new RegExp(query, flags);
|
|
96
112
|
}
|
|
97
113
|
catch (e) {
|
|
98
|
-
logger.error("TOOL", "Invalid regex pattern", e instanceof Error ? e : new Error(String(e)), { query });
|
|
99
114
|
throw new Error(`Invalid regex pattern: ${e.message}`);
|
|
100
115
|
}
|
|
101
116
|
}
|
|
102
117
|
const escapedQuery = query.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
103
|
-
|
|
104
|
-
logger.debug("TOOL", "Escaped query compiled to regex", {
|
|
105
|
-
originalQuery: query,
|
|
106
|
-
flags,
|
|
107
|
-
});
|
|
108
|
-
return searchRegex;
|
|
118
|
+
return new RegExp(escapedQuery, flags);
|
|
109
119
|
}
|
|
110
|
-
async
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
for (const file of filesToSearch) {
|
|
114
|
-
if (totalMatches >= maxResults) {
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
if (await isTextFile(file)) {
|
|
118
|
-
try {
|
|
119
|
-
const content = await readFileContent(file);
|
|
120
|
-
const fileMatches = searchFileContent(content, searchRegex);
|
|
121
|
-
if (fileMatches.length > 0) {
|
|
122
|
-
const limitedMatches = fileMatches.slice(0, maxResults - totalMatches);
|
|
123
|
-
results.push({ path: file, matches: limitedMatches });
|
|
124
|
-
totalMatches += limitedMatches.length;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
catch {
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return results;
|
|
132
|
-
}
|
|
133
|
-
function formatGrepResults(results, query) {
|
|
134
|
-
if (results.length === 0) {
|
|
135
|
-
return `No matches found for query "${query}" in the searched files`;
|
|
136
|
-
}
|
|
137
|
-
const totalMatches = results.reduce((sum, r) => sum + r.matches.length, 0);
|
|
138
|
-
let output = `Found ${totalMatches} matches for query "${query}" in ${results.length} files:\n\n`;
|
|
139
|
-
for (const result of results) {
|
|
140
|
-
output += `File: ${result.path}\n`;
|
|
141
|
-
for (const match of result.matches) {
|
|
142
|
-
output += ` Line ${match.line}, Col ${match.column}: ${match.text}\n`;
|
|
143
|
-
}
|
|
144
|
-
output += "\n";
|
|
145
|
-
}
|
|
146
|
-
return output;
|
|
147
|
-
}
|
|
148
|
-
export const grepContentTool = tool(async ({ searchPath = ".", query, patterns = ["*"], caseSensitive = false, regex = false, recursive = true, maxResults = 100, }, config) => {
|
|
149
|
-
const timingId = logger.timingStart("grepContent");
|
|
150
|
-
logger.info("TOOL", "grep_content called", {
|
|
120
|
+
export const grepTool = tool(async ({ searchPath = ".", query, patterns = ["*"], caseSensitive = false, regex = false, recursive = true, maxResults = 100, contextBefore = 0, contextAfter = 0, exclude = [], includeHidden = false, }, config) => {
|
|
121
|
+
const timingId = logger.timingStart("grep");
|
|
122
|
+
logger.info("TOOL", "grep called", {
|
|
151
123
|
searchPath,
|
|
152
|
-
|
|
124
|
+
query,
|
|
153
125
|
patterns,
|
|
154
126
|
caseSensitive,
|
|
155
127
|
regex,
|
|
156
128
|
recursive,
|
|
157
129
|
maxResults,
|
|
130
|
+
contextBefore,
|
|
131
|
+
contextAfter,
|
|
132
|
+
exclude,
|
|
133
|
+
includeHidden,
|
|
158
134
|
});
|
|
159
135
|
try {
|
|
160
136
|
const workingDir = config?.context?.workingDir;
|
|
161
137
|
if (!workingDir) {
|
|
162
138
|
throw new Error("Context with workingDir is required for file operations");
|
|
163
139
|
}
|
|
164
|
-
logger.debug("TOOL", "Working directory", {
|
|
165
|
-
workingDir: workingDir.replace(Bun.env.HOME || "", "~"),
|
|
166
|
-
});
|
|
167
140
|
if (!query) {
|
|
168
|
-
logger.error("TOOL", "Query parameter missing", undefined, {});
|
|
169
141
|
throw new Error('The "query" parameter is required');
|
|
170
142
|
}
|
|
171
|
-
const resolvedPath =
|
|
172
|
-
const
|
|
143
|
+
const resolvedPath = path.resolve(workingDir, searchPath);
|
|
144
|
+
const resolvedWorkingDir = path.resolve(workingDir);
|
|
145
|
+
const relativePath = path.relative(resolvedWorkingDir, resolvedPath);
|
|
146
|
+
if (relativePath.startsWith("..")) {
|
|
147
|
+
throw new Error(`Search path "${searchPath}" attempts to escape the working directory sandbox`);
|
|
148
|
+
}
|
|
149
|
+
let stats;
|
|
150
|
+
try {
|
|
151
|
+
stats = await stat(resolvedPath);
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
if (error.code === "ENOENT") {
|
|
155
|
+
throw new Error(`Search path "${searchPath}" does not exist`);
|
|
156
|
+
}
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
if (!stats.isDirectory()) {
|
|
160
|
+
throw new Error(`Search path "${searchPath}" is not a directory`);
|
|
161
|
+
}
|
|
162
|
+
const gitignore = new GitIgnoreService(workingDir);
|
|
163
|
+
await gitignore.initialize();
|
|
164
|
+
const filesToSearch = await findFilesToSearch(resolvedPath, patterns, recursive, includeHidden);
|
|
173
165
|
const searchRegex = compileSearchRegex(query, regex, caseSensitive);
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
166
|
+
const excludeGlobs = exclude.map((pattern) => new Glob(pattern));
|
|
167
|
+
const results = [];
|
|
168
|
+
let totalMatches = 0;
|
|
169
|
+
for (const file of filesToSearch) {
|
|
170
|
+
if (totalMatches >= maxResults) {
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
const relativeFileToWorkingDir = path.relative(workingDir, file);
|
|
174
|
+
if (gitignore.shouldIgnore(file, false)) {
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const isExcluded = excludeGlobs.some((eg) => eg.match(relativeFileToWorkingDir));
|
|
178
|
+
if (isExcluded) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (await isTextFile(file)) {
|
|
182
|
+
const fileMatches = await searchFileWithContext(file, searchRegex, contextBefore, contextAfter);
|
|
183
|
+
if (fileMatches.length > 0) {
|
|
184
|
+
const remainingSlot = maxResults - totalMatches;
|
|
185
|
+
const limitedMatches = fileMatches.slice(0, remainingSlot);
|
|
186
|
+
results.push({
|
|
187
|
+
path: path.relative(workingDir, file),
|
|
188
|
+
matches: limitedMatches,
|
|
189
|
+
});
|
|
190
|
+
totalMatches += limitedMatches.length;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
logger.timingEnd(timingId, "TOOL", "grep completed");
|
|
195
|
+
if (results.length === 0) {
|
|
196
|
+
return `No matches found for query "${query}" in the searched files`;
|
|
197
|
+
}
|
|
198
|
+
return formatSearchResults(results);
|
|
182
199
|
}
|
|
183
200
|
catch (error) {
|
|
184
|
-
logger.error("TOOL", "
|
|
185
|
-
return
|
|
201
|
+
logger.error("TOOL", "grep failed", error instanceof Error ? error : new Error(String(error)), { searchPath, query });
|
|
202
|
+
return formatToolError({
|
|
203
|
+
operation: "grep",
|
|
204
|
+
path: searchPath,
|
|
205
|
+
cause: error,
|
|
206
|
+
suggestion: getToolSuggestion("grep", searchPath),
|
|
207
|
+
});
|
|
186
208
|
}
|
|
187
209
|
}, {
|
|
188
|
-
name: "
|
|
189
|
-
description: `A powerful search tool
|
|
210
|
+
name: "grep",
|
|
211
|
+
description: `A powerful search tool for finding text patterns in files.
|
|
190
212
|
|
|
191
213
|
Usage:
|
|
192
|
-
- ALWAYS use
|
|
214
|
+
- ALWAYS use grep for search tasks.
|
|
193
215
|
- Supports full regex syntax (e.g., "log.*Error", "function\\s+\\w+")
|
|
194
|
-
- Filter files with glob parameter (e.g., "*.js", "**/*.tsx")
|
|
195
|
-
- Pattern syntax: Uses
|
|
216
|
+
- Filter files with glob parameter (e.g., "*.js", "**/*.tsx")
|
|
217
|
+
- Pattern syntax: Uses JavaScript regex - literal braces need escaping (use \`interface{}\` to find \`interface{}\` in Go code)
|
|
196
218
|
`,
|
|
197
219
|
schema: z.object({
|
|
198
220
|
searchPath: z.string().describe("The directory path to search in"),
|
|
@@ -224,6 +246,26 @@ Usage:
|
|
|
224
246
|
.optional()
|
|
225
247
|
.default(100)
|
|
226
248
|
.describe("Maximum number of matches to return. Defaults to 100"),
|
|
249
|
+
contextBefore: z
|
|
250
|
+
.number()
|
|
251
|
+
.optional()
|
|
252
|
+
.default(0)
|
|
253
|
+
.describe("Number of lines of context to show before each match. Defaults to 0"),
|
|
254
|
+
contextAfter: z
|
|
255
|
+
.number()
|
|
256
|
+
.optional()
|
|
257
|
+
.default(0)
|
|
258
|
+
.describe("Number of lines of context to show after each match. Defaults to 0"),
|
|
259
|
+
exclude: z
|
|
260
|
+
.array(z.string())
|
|
261
|
+
.optional()
|
|
262
|
+
.default([])
|
|
263
|
+
.describe("Array of glob patterns to exclude from results (e.g., ['dist/**', 'node_modules/**'])"),
|
|
264
|
+
includeHidden: z
|
|
265
|
+
.boolean()
|
|
266
|
+
.optional()
|
|
267
|
+
.default(false)
|
|
268
|
+
.describe("Whether to include hidden files and directories in the search. Defaults to `false`"),
|
|
227
269
|
}),
|
|
228
270
|
});
|
|
229
271
|
//# sourceMappingURL=grep-content.tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grep-content.tool.js","sourceRoot":"","sources":["../../src/tools/grep-content.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"grep-content.tool.js","sourceRoot":"","sources":["../../src/tools/grep-content.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EACL,mBAAmB,GAEpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAQ5C,KAAK,UAAU,qBAAqB,CAClC,QAAgB,EAChB,KAAa,EACb,aAAa,GAAG,CAAC,EACjB,YAAY,GAAG,CAAC;IAEhB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;IAClC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAElC,MAAM,OAAO,GAAkB,EAAE,CAAC;IAClC,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,WAAW,GAAG,EAAE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,CAAC,CAAC,CAAC;aACV,QAAQ,CACP,qEAAqE,CACtE;QACH,YAAY,EAAE,CAAC;aACZ,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,OAAO,CAAC,CAAC,CAAC;aACV,QAAQ,CACP,oEAAoE,CACrE;QACH,OAAO,EAAE,CAAC;aACP,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;aACjB,QAAQ,EAAE;aACV,OAAO,CAAC,EAAE,CAAC;aACX,QAAQ,CACP,uFAAuF,CACxF;QACH,aAAa,EAAE,CAAC;aACb,OAAO,EAAE;aACT,QAAQ,EAAE;aACV,OAAO,CAAC,KAAK,CAAC;aACd,QAAQ,CACP,oFAAoF,CACrF;KACJ,CAAC;CACH,CACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ToolErrorOptions {
|
|
2
|
+
operation: string;
|
|
3
|
+
path?: string;
|
|
4
|
+
suggestion?: string | undefined;
|
|
5
|
+
cause?: unknown;
|
|
6
|
+
}
|
|
7
|
+
export declare function formatToolError(options: ToolErrorOptions): string;
|
|
8
|
+
export declare function getToolSuggestion(operation: string, targetPath?: string): string | undefined;
|
|
9
|
+
//# sourceMappingURL=error-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-utils.d.ts","sourceRoot":"","sources":["../../src/utils/error-utils.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAKD,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAuCjE;AAKD,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,GAAG,SAAS,CA8BpB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
export function formatToolError(options) {
|
|
3
|
+
const { operation, path: targetPath, suggestion, cause } = options;
|
|
4
|
+
let message = `${operation} failed`;
|
|
5
|
+
if (targetPath) {
|
|
6
|
+
message += `: ${targetPath}`;
|
|
7
|
+
}
|
|
8
|
+
if (cause && typeof cause === "object" && "code" in cause) {
|
|
9
|
+
const code = cause.code;
|
|
10
|
+
switch (code) {
|
|
11
|
+
case "ENOENT":
|
|
12
|
+
message = `Path not found: ${targetPath || "unknown"}`;
|
|
13
|
+
break;
|
|
14
|
+
case "EACCES":
|
|
15
|
+
case "EPERM":
|
|
16
|
+
message = `Permission denied: ${targetPath || "unknown"}`;
|
|
17
|
+
break;
|
|
18
|
+
case "ENOTDIR":
|
|
19
|
+
message = `Path is not a directory: ${targetPath || "unknown"}`;
|
|
20
|
+
break;
|
|
21
|
+
case "EISDIR":
|
|
22
|
+
message = `Path is a directory, not a file: ${targetPath || "unknown"}`;
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
if ("message" in cause) {
|
|
26
|
+
message += `. ${cause.message}`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else if (cause instanceof Error) {
|
|
31
|
+
message += `. ${cause.message}`;
|
|
32
|
+
}
|
|
33
|
+
if (suggestion) {
|
|
34
|
+
message += `\n\nSuggestion: ${suggestion}`;
|
|
35
|
+
}
|
|
36
|
+
return message;
|
|
37
|
+
}
|
|
38
|
+
export function getToolSuggestion(operation, targetPath) {
|
|
39
|
+
if (operation === "view" && targetPath) {
|
|
40
|
+
const ext = path.extname(targetPath).toLowerCase();
|
|
41
|
+
if ([".png", ".jpg", ".pdf"].includes(ext)) {
|
|
42
|
+
return "This file appears to be a binary or media file. Only text files can be read.";
|
|
43
|
+
}
|
|
44
|
+
return "Ensure the file path is correct and the file is a text file.";
|
|
45
|
+
}
|
|
46
|
+
if (operation === "list") {
|
|
47
|
+
return "Check if the directory exists and you have permissions to read it.";
|
|
48
|
+
}
|
|
49
|
+
if (operation === "grep") {
|
|
50
|
+
return "Try a simpler search pattern or verify the search path.";
|
|
51
|
+
}
|
|
52
|
+
if (operation === "find") {
|
|
53
|
+
return "Check if the search path exists and the patterns are valid glob patterns.";
|
|
54
|
+
}
|
|
55
|
+
if (targetPath &&
|
|
56
|
+
(operation === "view" || operation === "list" || operation === "find")) {
|
|
57
|
+
return "Check file permissions and ensure you have read access to the path.";
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=error-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-utils.js","sourceRoot":"","sources":["../../src/utils/error-utils.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAiB7B,MAAM,UAAU,eAAe,CAAC,OAAyB;IACvD,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAEnE,IAAI,OAAO,GAAG,GAAG,SAAS,SAAS,CAAC;IACpC,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;IAC/B,CAAC;IAED,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;QAC1D,MAAM,IAAI,GAAI,KAA0B,CAAC,IAAI,CAAC;QAE9C,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,QAAQ;gBACX,OAAO,GAAG,mBAAmB,UAAU,IAAI,SAAS,EAAE,CAAC;gBACvD,MAAM;YACR,KAAK,QAAQ,CAAC;YACd,KAAK,OAAO;gBACV,OAAO,GAAG,sBAAsB,UAAU,IAAI,SAAS,EAAE,CAAC;gBAC1D,MAAM;YACR,KAAK,SAAS;gBACZ,OAAO,GAAG,4BAA4B,UAAU,IAAI,SAAS,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AAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-utils.d.ts","sourceRoot":"","sources":["../../src/utils/file-utils.ts"],"names":[],"mappings":"AAWA,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"file-utils.d.ts","sourceRoot":"","sources":["../../src/utils/file-utils.ts"],"names":[],"mappings":"AAWA,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAsEnE;AAMD,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAoCxE"}
|