@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.
Files changed (85) hide show
  1. package/bin/bike4mind-cli.mjs +6 -6
  2. package/dist/BubblewrapRuntime-BHbtqvLx.mjs +72 -0
  3. package/dist/ConfigStore-CllM6jOf.mjs +8614 -0
  4. package/dist/ImageStore-DaKT_Ew8.mjs +202 -0
  5. package/dist/ProxyManager-Dl2nFk-A.mjs +259 -0
  6. package/dist/ProxyManager-kiOD1X8-.mjs +3 -0
  7. package/dist/SandboxOrchestrator-BEW3rqYi.mjs +159 -0
  8. package/dist/SandboxOrchestrator-CHZgSR3P.mjs +3 -0
  9. package/dist/SandboxRuntimeAdapter-C1B4t20N.mjs +57 -0
  10. package/dist/SandboxRuntimeAdapter-D7UAG13n.mjs +3 -0
  11. package/dist/SeatbeltRuntime-D4m0VOcD.mjs +116 -0
  12. package/dist/StderrViolationParser-D0afQ3-1.mjs +70 -0
  13. package/dist/ViolationLogStore-CZl35HcA.mjs +96 -0
  14. package/dist/bashExecute-BTkdqlSs-5foM20Lb.mjs +466 -0
  15. package/dist/commands/doctorCommand.mjs +101 -0
  16. package/dist/commands/headlessCommand.mjs +319 -0
  17. package/dist/commands/mcpCommand.mjs +218 -0
  18. package/dist/commands/updateCommand.mjs +40 -0
  19. package/dist/createFile-yQfh8uvk-I-yM5DxC.mjs +63 -0
  20. package/dist/deleteFile-DKHfnyny-G3b1Kj2T.mjs +66 -0
  21. package/dist/globFiles-D1en6joM-8jekiXdX.mjs +100 -0
  22. package/dist/grepSearch-aMamoBn_-DCJcY8JS.mjs +173 -0
  23. package/dist/index.mjs +6722 -0
  24. package/dist/pathValidation-Cgjh5WQO-DiCZTcq6.mjs +63 -0
  25. package/dist/store-Dw1nZX2Y.mjs +128 -0
  26. package/dist/store-nZExNOWX.mjs +3 -0
  27. package/dist/terminalSetup-rmr1P8KF.mjs +254 -0
  28. package/dist/tools-C6M5aW8W.mjs +20907 -0
  29. package/dist/treeSitterEngine-DCSXcm_3.mjs +309 -0
  30. package/dist/types-DBEjF9YS.mjs +59 -0
  31. package/dist/types-DK3P88Px.mjs +3 -0
  32. package/dist/updateChecker-Cu9dkHxV.mjs +120 -0
  33. package/package.json +10 -10
  34. package/dist/BubblewrapRuntime-PMIOLWKR.js +0 -71
  35. package/dist/HydrationEngine-YL2HWJ3V.js +0 -9
  36. package/dist/ImageStore-MMUOUPI2.js +0 -224
  37. package/dist/ProxyManager-HEB4TLVX.js +0 -7
  38. package/dist/SandboxOrchestrator-UIJ5GYBB.js +0 -8
  39. package/dist/SandboxRuntimeAdapter-FQ56MAB2.js +0 -13
  40. package/dist/SeatbeltRuntime-EE3TTLEP.js +0 -98
  41. package/dist/StderrViolationParser-7OYPM2DJ.js +0 -59
  42. package/dist/ViolationLogStore-RIIUVURH.js +0 -104
  43. package/dist/artifactExtractor-R7DIP2XO.js +0 -180
  44. package/dist/bashExecute-GLGLD3JD.js +0 -379
  45. package/dist/chunk-4BIBE3J7.js +0 -48
  46. package/dist/chunk-5LZS5CVJ.js +0 -161
  47. package/dist/chunk-BDQBOLYG.js +0 -120
  48. package/dist/chunk-BPFEGDC7.js +0 -192
  49. package/dist/chunk-EPIYC3LA.js +0 -13770
  50. package/dist/chunk-G4ZGEQFT.js +0 -250
  51. package/dist/chunk-GQGOWACU.js +0 -770
  52. package/dist/chunk-J6ZBI6TI.js +0 -1079
  53. package/dist/chunk-JW3JRHH7.js +0 -12433
  54. package/dist/chunk-KQAMBXAW.js +0 -163
  55. package/dist/chunk-KUVV2NAB.js +0 -19125
  56. package/dist/chunk-LTLJRF6I.js +0 -44
  57. package/dist/chunk-PFBYGCOW.js +0 -449
  58. package/dist/chunk-QWB6ZYY4.js +0 -48
  59. package/dist/chunk-SGPRXN4C.js +0 -245
  60. package/dist/chunk-UZUHPHZC.js +0 -95
  61. package/dist/chunk-WBE7SQUB.js +0 -241
  62. package/dist/chunk-Y4WOJJM3.js +0 -147
  63. package/dist/commands/doctorCommand.js +0 -87
  64. package/dist/commands/headlessCommand.js +0 -380
  65. package/dist/commands/mcpCommand.js +0 -203
  66. package/dist/commands/updateCommand.js +0 -42
  67. package/dist/create-C4VEEEYR.js +0 -12
  68. package/dist/createFile-6PSPLW6R.js +0 -71
  69. package/dist/deleteFile-AUSRLWIK.js +0 -73
  70. package/dist/formatConverter-5QEJDW24.js +0 -7
  71. package/dist/globFiles-TSRN64N2.js +0 -120
  72. package/dist/grepSearch-634XWZOJ.js +0 -216
  73. package/dist/index.js +0 -6779
  74. package/dist/llmMarkdownGenerator-Z6NB26TT.js +0 -371
  75. package/dist/markdownGenerator-SK2ZQQL4.js +0 -269
  76. package/dist/mementoService-N4IM6QAC.js +0 -12
  77. package/dist/notificationDeduplicator-HUC53NEW.js +0 -9
  78. package/dist/src-F4KZCAA2.js +0 -319
  79. package/dist/src-ISX322I7.js +0 -1101
  80. package/dist/store-CAB6BV3P.js +0 -11
  81. package/dist/subtractCredits-D4KEM6VU.js +0 -12
  82. package/dist/terminalSetup-C5FHMLC3.js +0 -214
  83. package/dist/treeSitterEngine-4SGFQDY3.js +0 -330
  84. package/dist/types-KB5NP6T4.js +0 -7
  85. 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
- };