@bike4mind/cli 0.2.64-worktree-refactor-extract-search-query-builders.21815 → 0.2.64
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/bin/bike4mind-cli.mjs +6 -6
- package/dist/BubblewrapRuntime-BHbtqvLx.mjs +72 -0
- package/dist/ConfigStore-CllM6jOf.mjs +8614 -0
- package/dist/ImageStore-DaKT_Ew8.mjs +202 -0
- package/dist/ProxyManager-Dl2nFk-A.mjs +259 -0
- package/dist/ProxyManager-kiOD1X8-.mjs +3 -0
- package/dist/SandboxOrchestrator-BEW3rqYi.mjs +159 -0
- package/dist/SandboxOrchestrator-CHZgSR3P.mjs +3 -0
- package/dist/SandboxRuntimeAdapter-C1B4t20N.mjs +57 -0
- package/dist/SandboxRuntimeAdapter-D7UAG13n.mjs +3 -0
- package/dist/SeatbeltRuntime-D4m0VOcD.mjs +116 -0
- package/dist/StderrViolationParser-D0afQ3-1.mjs +70 -0
- package/dist/ViolationLogStore-CZl35HcA.mjs +96 -0
- package/dist/bashExecute-BTkdqlSs-5foM20Lb.mjs +466 -0
- package/dist/commands/doctorCommand.mjs +101 -0
- package/dist/commands/headlessCommand.mjs +319 -0
- package/dist/commands/mcpCommand.mjs +218 -0
- package/dist/commands/updateCommand.mjs +40 -0
- package/dist/createFile-yQfh8uvk-I-yM5DxC.mjs +63 -0
- package/dist/deleteFile-DKHfnyny-G3b1Kj2T.mjs +66 -0
- package/dist/globFiles-D1en6joM-8jekiXdX.mjs +100 -0
- package/dist/grepSearch-aMamoBn_-DCJcY8JS.mjs +173 -0
- package/dist/index.mjs +6722 -0
- package/dist/pathValidation-Cgjh5WQO-DiCZTcq6.mjs +63 -0
- package/dist/store-Dw1nZX2Y.mjs +128 -0
- package/dist/store-nZExNOWX.mjs +3 -0
- package/dist/terminalSetup-rmr1P8KF.mjs +254 -0
- package/dist/tools-C6M5aW8W.mjs +20907 -0
- package/dist/treeSitterEngine-DCSXcm_3.mjs +309 -0
- package/dist/types-DBEjF9YS.mjs +59 -0
- package/dist/types-DK3P88Px.mjs +3 -0
- package/dist/updateChecker-Cu9dkHxV.mjs +120 -0
- package/package.json +10 -10
- package/dist/BubblewrapRuntime-PMIOLWKR.js +0 -71
- package/dist/HydrationEngine-YL2HWJ3V.js +0 -9
- package/dist/ImageStore-MMUOUPI2.js +0 -224
- package/dist/ProxyManager-HEB4TLVX.js +0 -7
- package/dist/SandboxOrchestrator-UIJ5GYBB.js +0 -8
- package/dist/SandboxRuntimeAdapter-FQ56MAB2.js +0 -13
- package/dist/SeatbeltRuntime-EE3TTLEP.js +0 -98
- package/dist/StderrViolationParser-7OYPM2DJ.js +0 -59
- package/dist/ViolationLogStore-RIIUVURH.js +0 -104
- package/dist/artifactExtractor-R7DIP2XO.js +0 -180
- package/dist/bashExecute-GLGLD3JD.js +0 -379
- package/dist/chunk-4BIBE3J7.js +0 -48
- package/dist/chunk-5LZS5CVJ.js +0 -161
- package/dist/chunk-BDQBOLYG.js +0 -120
- package/dist/chunk-BPFEGDC7.js +0 -192
- package/dist/chunk-EPIYC3LA.js +0 -13770
- package/dist/chunk-G4ZGEQFT.js +0 -250
- package/dist/chunk-GQGOWACU.js +0 -770
- package/dist/chunk-J6ZBI6TI.js +0 -1079
- package/dist/chunk-JW3JRHH7.js +0 -12433
- package/dist/chunk-KQAMBXAW.js +0 -163
- package/dist/chunk-KUVV2NAB.js +0 -19125
- package/dist/chunk-LTLJRF6I.js +0 -44
- package/dist/chunk-PFBYGCOW.js +0 -449
- package/dist/chunk-QWB6ZYY4.js +0 -48
- package/dist/chunk-SGPRXN4C.js +0 -245
- package/dist/chunk-UZUHPHZC.js +0 -95
- package/dist/chunk-WBE7SQUB.js +0 -241
- package/dist/chunk-Y4WOJJM3.js +0 -147
- package/dist/commands/doctorCommand.js +0 -87
- package/dist/commands/headlessCommand.js +0 -380
- package/dist/commands/mcpCommand.js +0 -203
- package/dist/commands/updateCommand.js +0 -42
- package/dist/create-C4VEEEYR.js +0 -12
- package/dist/createFile-6PSPLW6R.js +0 -71
- package/dist/deleteFile-AUSRLWIK.js +0 -73
- package/dist/formatConverter-5QEJDW24.js +0 -7
- package/dist/globFiles-TSRN64N2.js +0 -120
- package/dist/grepSearch-634XWZOJ.js +0 -216
- package/dist/index.js +0 -6779
- package/dist/llmMarkdownGenerator-Z6NB26TT.js +0 -371
- package/dist/markdownGenerator-SK2ZQQL4.js +0 -269
- package/dist/mementoService-N4IM6QAC.js +0 -12
- package/dist/notificationDeduplicator-HUC53NEW.js +0 -9
- package/dist/src-F4KZCAA2.js +0 -319
- package/dist/src-ISX322I7.js +0 -1101
- package/dist/store-CAB6BV3P.js +0 -11
- package/dist/subtractCredits-D4KEM6VU.js +0 -12
- package/dist/terminalSetup-C5FHMLC3.js +0 -214
- package/dist/treeSitterEngine-4SGFQDY3.js +0 -330
- package/dist/types-KB5NP6T4.js +0 -7
- package/dist/utils-JCHWDM4Z.js +0 -31
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
isPathAllowed
|
|
4
|
-
} from "./chunk-LTLJRF6I.js";
|
|
5
|
-
|
|
6
|
-
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/grepSearch/index.js
|
|
7
|
-
import { stat } from "fs/promises";
|
|
8
|
-
import { existsSync } from "fs";
|
|
9
|
-
import path from "path";
|
|
10
|
-
import { execFile, execFileSync } from "child_process";
|
|
11
|
-
import { promisify } from "util";
|
|
12
|
-
import { createRequire } from "module";
|
|
13
|
-
var execFileAsync = promisify(execFile);
|
|
14
|
-
var require2 = createRequire(import.meta.url);
|
|
15
|
-
var cachedRgPath = null;
|
|
16
|
-
function getRipgrepPath() {
|
|
17
|
-
if (cachedRgPath)
|
|
18
|
-
return cachedRgPath;
|
|
19
|
-
try {
|
|
20
|
-
const ripgrepPath = require2.resolve("@vscode/ripgrep");
|
|
21
|
-
const ripgrepDir = path.dirname(ripgrepPath);
|
|
22
|
-
const rgBinary = path.join(ripgrepDir, "..", "bin", "rg" + (process.platform === "win32" ? ".exe" : ""));
|
|
23
|
-
if (!existsSync(rgBinary)) {
|
|
24
|
-
const postinstallScript = path.join(ripgrepDir, "..", "lib", "postinstall.js");
|
|
25
|
-
if (existsSync(postinstallScript)) {
|
|
26
|
-
execFileSync(process.execPath, [postinstallScript], {
|
|
27
|
-
cwd: path.join(ripgrepDir, ".."),
|
|
28
|
-
stdio: "pipe",
|
|
29
|
-
timeout: 3e4
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
if (!existsSync(rgBinary)) {
|
|
33
|
-
throw new Error(`ripgrep binary not found at ${rgBinary}. The postinstall download may have failed. Try running: cd ${path.join(ripgrepDir, "..")} && node lib/postinstall.js`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
cachedRgPath = rgBinary;
|
|
37
|
-
return rgBinary;
|
|
38
|
-
} catch (error) {
|
|
39
|
-
if (error instanceof Error && error.message.includes("ripgrep binary not found")) {
|
|
40
|
-
throw error;
|
|
41
|
-
}
|
|
42
|
-
throw new Error("ripgrep is not available. Please install @vscode/ripgrep: pnpm add @vscode/ripgrep --filter @bike4mind/services");
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function convertGlobToRipgrepGlobs(globPattern) {
|
|
46
|
-
if (!globPattern || globPattern === "**/*") {
|
|
47
|
-
return [];
|
|
48
|
-
}
|
|
49
|
-
const braceMatch = globPattern.match(/\*\.{([^}]+)}/);
|
|
50
|
-
if (braceMatch) {
|
|
51
|
-
const extensions = braceMatch[1].split(",");
|
|
52
|
-
return extensions.map((ext) => `*.${ext.trim()}`);
|
|
53
|
-
}
|
|
54
|
-
return [globPattern];
|
|
55
|
-
}
|
|
56
|
-
async function searchFiles(params, allowedDirectories) {
|
|
57
|
-
const { pattern, dir_path, include } = params;
|
|
58
|
-
const baseCwd = process.cwd();
|
|
59
|
-
const targetDir = dir_path ? path.resolve(baseCwd, dir_path) : baseCwd;
|
|
60
|
-
const validation = isPathAllowed(targetDir, allowedDirectories);
|
|
61
|
-
if (!validation.allowed) {
|
|
62
|
-
const dirsMsg = allowedDirectories && allowedDirectories.length > 0 ? `Allowed directories: ${[baseCwd, ...allowedDirectories].join(", ")}` : `Working directory: ${baseCwd}`;
|
|
63
|
-
throw new Error(`Path validation failed: "${dir_path}" resolves outside allowed directories. ${dirsMsg}`);
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
const stats = await stat(targetDir);
|
|
67
|
-
if (!stats.isDirectory()) {
|
|
68
|
-
throw new Error(`Path is not a directory: ${dir_path}`);
|
|
69
|
-
}
|
|
70
|
-
} catch (error) {
|
|
71
|
-
if (error.code === "ENOENT") {
|
|
72
|
-
throw new Error(`Path does not exist: ${dir_path}`);
|
|
73
|
-
}
|
|
74
|
-
throw error;
|
|
75
|
-
}
|
|
76
|
-
const rgPath = getRipgrepPath();
|
|
77
|
-
const rgArgs = [
|
|
78
|
-
"--json",
|
|
79
|
-
// Machine-readable output
|
|
80
|
-
"--max-count",
|
|
81
|
-
"500",
|
|
82
|
-
// Limit matches per file
|
|
83
|
-
"--ignore-case",
|
|
84
|
-
// Case-insensitive search
|
|
85
|
-
"--max-filesize",
|
|
86
|
-
"10M"
|
|
87
|
-
// Skip files larger than 10MB
|
|
88
|
-
];
|
|
89
|
-
const globs = convertGlobToRipgrepGlobs(include || "");
|
|
90
|
-
if (globs.length > 0) {
|
|
91
|
-
globs.forEach((glob) => {
|
|
92
|
-
rgArgs.push("--glob", glob);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
rgArgs.push(pattern, targetDir);
|
|
96
|
-
let stdout;
|
|
97
|
-
try {
|
|
98
|
-
const result2 = await execFileAsync(rgPath, rgArgs, {
|
|
99
|
-
maxBuffer: 50 * 1024 * 1024
|
|
100
|
-
// 50MB buffer for large results
|
|
101
|
-
});
|
|
102
|
-
stdout = result2.stdout;
|
|
103
|
-
} catch (error) {
|
|
104
|
-
const execError = error;
|
|
105
|
-
if (execError.code === 1 && execError.stdout) {
|
|
106
|
-
stdout = execError.stdout;
|
|
107
|
-
} else if (execError.code === 2) {
|
|
108
|
-
const errorMsg = execError.stderr || "Unknown ripgrep error";
|
|
109
|
-
throw new Error(`Ripgrep error: ${errorMsg}`);
|
|
110
|
-
} else {
|
|
111
|
-
throw error;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
const lines = stdout.split("\n").filter(Boolean);
|
|
115
|
-
const allMatches = [];
|
|
116
|
-
let filesSearched = 0;
|
|
117
|
-
for (const line of lines) {
|
|
118
|
-
try {
|
|
119
|
-
const item = JSON.parse(line);
|
|
120
|
-
if (item.type === "match") {
|
|
121
|
-
const match = item;
|
|
122
|
-
allMatches.push({
|
|
123
|
-
filePath: path.relative(targetDir, match.data.path.text) || path.basename(match.data.path.text),
|
|
124
|
-
lineNumber: match.data.line_number,
|
|
125
|
-
line: match.data.lines.text.trimEnd()
|
|
126
|
-
// Remove trailing newline
|
|
127
|
-
});
|
|
128
|
-
} else if (item.type === "summary") {
|
|
129
|
-
const stats = item;
|
|
130
|
-
filesSearched = stats.data.stats.searches || 0;
|
|
131
|
-
}
|
|
132
|
-
} catch {
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
const searchDirDisplay = dir_path || ".";
|
|
137
|
-
const filterInfo = include ? ` (filter: "${include}")` : "";
|
|
138
|
-
const maxMatches = 500;
|
|
139
|
-
if (allMatches.length === 0) {
|
|
140
|
-
return `No matches found for pattern "${pattern}" in "${searchDirDisplay}"${filterInfo}.
|
|
141
|
-
Searched ${filesSearched} file(s).`;
|
|
142
|
-
}
|
|
143
|
-
const matchesByFile = allMatches.reduce((acc, match) => {
|
|
144
|
-
if (!acc[match.filePath]) {
|
|
145
|
-
acc[match.filePath] = [];
|
|
146
|
-
}
|
|
147
|
-
acc[match.filePath].push(match);
|
|
148
|
-
return acc;
|
|
149
|
-
}, {});
|
|
150
|
-
const matchCount = allMatches.length;
|
|
151
|
-
const matchTerm = matchCount === 1 ? "match" : "matches";
|
|
152
|
-
const truncated = matchCount >= maxMatches;
|
|
153
|
-
let result = `Found ${matchCount} ${matchTerm}${truncated ? " (truncated)" : ""} for pattern "${pattern}" in "${searchDirDisplay}"${filterInfo}:
|
|
154
|
-
`;
|
|
155
|
-
result += `Searched ${filesSearched} file(s)
|
|
156
|
-
---
|
|
157
|
-
`;
|
|
158
|
-
for (const filePath in matchesByFile) {
|
|
159
|
-
result += `File: ${filePath}
|
|
160
|
-
`;
|
|
161
|
-
matchesByFile[filePath].forEach((match) => {
|
|
162
|
-
const trimmedLine = match.line.trim();
|
|
163
|
-
const displayLine = trimmedLine.length > 200 ? trimmedLine.slice(0, 200) + "..." : trimmedLine;
|
|
164
|
-
result += `L${match.lineNumber}: ${displayLine}
|
|
165
|
-
`;
|
|
166
|
-
});
|
|
167
|
-
result += "---\n";
|
|
168
|
-
}
|
|
169
|
-
return result.trim();
|
|
170
|
-
}
|
|
171
|
-
var grepSearchTool = {
|
|
172
|
-
name: "grep_search",
|
|
173
|
-
implementation: (context) => ({
|
|
174
|
-
toolFn: async (value) => {
|
|
175
|
-
const params = value;
|
|
176
|
-
context.logger.info("\u{1F50D} GrepSearch: Searching files", {
|
|
177
|
-
pattern: params.pattern,
|
|
178
|
-
dir_path: params.dir_path || ".",
|
|
179
|
-
include: params.include || "**/*"
|
|
180
|
-
});
|
|
181
|
-
try {
|
|
182
|
-
const result = await searchFiles(params, context.allowedDirectories);
|
|
183
|
-
context.logger.info("\u2705 GrepSearch: Success");
|
|
184
|
-
return result;
|
|
185
|
-
} catch (error) {
|
|
186
|
-
context.logger.error("\u274C GrepSearch: Failed", error);
|
|
187
|
-
throw error;
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
toolSchema: {
|
|
191
|
-
name: "grep_search",
|
|
192
|
-
description: "Searches for a regular expression pattern within the content of files in a specified directory (or current working directory). Can filter files by a glob pattern. Returns the lines containing matches, along with their file paths and line numbers.",
|
|
193
|
-
parameters: {
|
|
194
|
-
type: "object",
|
|
195
|
-
properties: {
|
|
196
|
-
pattern: {
|
|
197
|
-
type: "string",
|
|
198
|
-
description: "The regular expression (regex) pattern to search for within file contents (e.g., 'function\\s+myFunction', 'import\\s+\\{.*\\}\\s+from\\s+.*')."
|
|
199
|
-
},
|
|
200
|
-
dir_path: {
|
|
201
|
-
type: "string",
|
|
202
|
-
description: "Optional: The absolute path to the directory to search within. If omitted, searches the current working directory."
|
|
203
|
-
},
|
|
204
|
-
include: {
|
|
205
|
-
type: "string",
|
|
206
|
-
description: "Optional: A glob pattern to filter which files are searched (e.g., '*.js', '*.{ts,tsx}', 'src/**'). If omitted, searches all files (respecting potential global ignores)."
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
required: ["pattern"]
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
})
|
|
213
|
-
};
|
|
214
|
-
export {
|
|
215
|
-
grepSearchTool
|
|
216
|
-
};
|