@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
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+ import { t as assertPathAllowed } from "./pathValidation-Cgjh5WQO-DiCZTcq6.mjs";
3
+ import { existsSync, promises, statSync } from "fs";
4
+ import path from "path";
5
+ //#region ../../b4m-core/packages/services/dist/deleteFile-DKHfnyny.mjs
6
+ async function deleteFile(params, allowedDirectories) {
7
+ const { path: filePath, recursive = false } = params;
8
+ const resolvedPath = assertPathAllowed(filePath, allowedDirectories, "delete");
9
+ if (!existsSync(resolvedPath)) throw new Error(`File or directory not found: ${filePath}`);
10
+ const stats = statSync(resolvedPath);
11
+ const isDirectory = stats.isDirectory();
12
+ const size = stats.size;
13
+ if (isDirectory && !recursive) throw new Error(`Path is a directory: ${filePath}. Use recursive=true to delete directories and their contents.`);
14
+ if (isDirectory) {
15
+ await promises.rm(resolvedPath, {
16
+ recursive: true,
17
+ force: true
18
+ });
19
+ return `Directory deleted successfully: ${filePath}`;
20
+ } else {
21
+ await promises.unlink(resolvedPath);
22
+ return `File deleted successfully: ${filePath}\nSize: ${size} bytes`;
23
+ }
24
+ }
25
+ const deleteFileTool = {
26
+ name: "delete_file",
27
+ implementation: (context) => ({
28
+ toolFn: async (value) => {
29
+ const params = value;
30
+ const resolvedPath = path.resolve(process.cwd(), path.normalize(params.path));
31
+ const isDirectory = existsSync(resolvedPath) && statSync(resolvedPath).isDirectory();
32
+ context.logger.info(`🗑️ DeleteFile: Deleting ${isDirectory ? "directory" : "file"}`, {
33
+ path: params.path,
34
+ recursive: params.recursive
35
+ });
36
+ try {
37
+ const result = await deleteFile(params, context.allowedDirectories);
38
+ context.logger.info("✅ DeleteFile: Success", { path: params.path });
39
+ return result;
40
+ } catch (error) {
41
+ context.logger.error("❌ DeleteFile: Failed", error);
42
+ throw error;
43
+ }
44
+ },
45
+ toolSchema: {
46
+ name: "delete_file",
47
+ description: "Delete a file or directory. For directories, recursive option must be enabled. Restricted to current working directory for security. Always prompts user for confirmation before deletion.",
48
+ parameters: {
49
+ type: "object",
50
+ properties: {
51
+ path: {
52
+ type: "string",
53
+ description: "Path to the file or directory to delete (relative to current working directory)"
54
+ },
55
+ recursive: {
56
+ type: "boolean",
57
+ description: "Required to delete directories and their contents (default: false). Use with caution as this will delete all files and subdirectories."
58
+ }
59
+ },
60
+ required: ["path"]
61
+ }
62
+ }
63
+ })
64
+ };
65
+ //#endregion
66
+ export { deleteFileTool };
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+ import { n as isPathAllowed } from "./pathValidation-Cgjh5WQO-DiCZTcq6.mjs";
3
+ import path from "path";
4
+ import { stat } from "fs/promises";
5
+ import { glob } from "glob";
6
+ //#region ../../b4m-core/packages/services/dist/globFiles-D1en6joM.mjs
7
+ const DEFAULT_IGNORE_PATTERNS = [
8
+ "**/node_modules/**",
9
+ "**/.git/**",
10
+ "**/dist/**",
11
+ "**/build/**",
12
+ "**/.next/**",
13
+ "**/coverage/**",
14
+ "**/.turbo/**",
15
+ "**/.sst/**",
16
+ "**/*.min.js",
17
+ "**/*.min.css"
18
+ ];
19
+ async function findFiles(params, allowedDirectories) {
20
+ const { pattern, dir_path, case_sensitive = true, respect_git_ignore = true } = params;
21
+ const baseCwd = process.cwd();
22
+ const targetDir = dir_path ? path.resolve(baseCwd, path.normalize(dir_path)) : baseCwd;
23
+ if (!isPathAllowed(targetDir, allowedDirectories).allowed) {
24
+ const dirsMsg = allowedDirectories && allowedDirectories.length > 0 ? `Allowed directories: ${[baseCwd, ...allowedDirectories].join(", ")}` : `Working directory: ${baseCwd}`;
25
+ throw new Error(`Access denied: Cannot search outside allowed directories. ${dirsMsg}`);
26
+ }
27
+ const matches = await glob(pattern, {
28
+ cwd: targetDir,
29
+ dot: false,
30
+ ignore: respect_git_ignore ? DEFAULT_IGNORE_PATTERNS : [],
31
+ absolute: true,
32
+ nodir: true,
33
+ nocase: !case_sensitive,
34
+ maxDepth: 20
35
+ });
36
+ if (matches.length === 0) return `No files found matching pattern: ${pattern}${dir_path ? ` in ${dir_path}` : ""}`;
37
+ const filesWithStats = [];
38
+ for (const filePath of matches) try {
39
+ const stats = await stat(filePath);
40
+ filesWithStats.push({
41
+ path: filePath,
42
+ mtime: stats.mtimeMs
43
+ });
44
+ } catch {
45
+ continue;
46
+ }
47
+ filesWithStats.sort((a, b) => b.mtime - a.mtime);
48
+ const MAX_RESULTS = 500;
49
+ const truncated = filesWithStats.length > MAX_RESULTS;
50
+ const results = truncated ? filesWithStats.slice(0, MAX_RESULTS) : filesWithStats;
51
+ return `${`Found ${filesWithStats.length} file(s)${truncated ? ` (showing first ${MAX_RESULTS})` : ""} matching: ${pattern}`}${dir_path ? `\nDirectory: ${dir_path}` : ""}\n\n${results.map((file) => path.relative(baseCwd, file.path)).join("\n")}`;
52
+ }
53
+ const globFilesTool = {
54
+ name: "glob_files",
55
+ implementation: (context) => ({
56
+ toolFn: async (value) => {
57
+ const params = value;
58
+ context.logger.info("🔍 GlobFiles: Finding files", {
59
+ pattern: params.pattern,
60
+ dir_path: params.dir_path || "."
61
+ });
62
+ try {
63
+ const result = await findFiles(params, context.allowedDirectories);
64
+ context.logger.info("✅ GlobFiles: Success");
65
+ return result;
66
+ } catch (error) {
67
+ context.logger.error("❌ GlobFiles: Failed", error);
68
+ throw error;
69
+ }
70
+ },
71
+ toolSchema: {
72
+ name: "glob_files",
73
+ description: "Efficiently finds files matching specific glob patterns (e.g., `src/**/*.ts`, `**/*.md`), returning absolute paths sorted by modification time (newest first). Use this to locate files by name or extension when you need to discover or explore files in a project.",
74
+ parameters: {
75
+ type: "object",
76
+ properties: {
77
+ pattern: {
78
+ type: "string",
79
+ description: "The glob pattern to match against file paths. Supports wildcards (*, **), character ranges ([abc]), and brace expansion ({ts,tsx}). Examples: \"*.ts\" for TypeScript files in current dir, \"src/**/*.tsx\" for all TSX files in src tree, \"**/*.{js,ts}\" for all JS/TS files."
80
+ },
81
+ dir_path: {
82
+ type: "string",
83
+ description: "Optional: The absolute path to the directory to search in. If not specified, uses the current working directory. Must be within the current working directory."
84
+ },
85
+ case_sensitive: {
86
+ type: "boolean",
87
+ description: "Optional: Whether the pattern matching should be case-sensitive. Defaults to true. Set to false for case-insensitive matching on case-sensitive file systems."
88
+ },
89
+ respect_git_ignore: {
90
+ type: "boolean",
91
+ description: "Optional: Whether to respect common ignore patterns (node_modules, .git, dist, build, etc.). Defaults to true. Set to false to include all files."
92
+ }
93
+ },
94
+ required: ["pattern"]
95
+ }
96
+ }
97
+ })
98
+ };
99
+ //#endregion
100
+ export { globFilesTool };
@@ -0,0 +1,173 @@
1
+ #!/usr/bin/env node
2
+ import { n as isPathAllowed } from "./pathValidation-Cgjh5WQO-DiCZTcq6.mjs";
3
+ import { execFile, execFileSync } from "child_process";
4
+ import { existsSync } from "fs";
5
+ import path from "path";
6
+ import { stat } from "fs/promises";
7
+ import { promisify } from "util";
8
+ import { createRequire } from "module";
9
+ //#region ../../b4m-core/packages/services/dist/grepSearch-aMamoBn_.mjs
10
+ const execFileAsync = promisify(execFile);
11
+ const require = createRequire(import.meta.url);
12
+ /** Cached ripgrep binary path after first resolution */
13
+ let cachedRgPath = null;
14
+ /**
15
+ * Get ripgrep binary path
16
+ * This is an optional dependency (CLI-only), so we load it lazily.
17
+ * If the binary is missing (postinstall was skipped), auto-downloads it.
18
+ */
19
+ function getRipgrepPath() {
20
+ if (cachedRgPath) return cachedRgPath;
21
+ try {
22
+ const ripgrepPath = require.resolve("@vscode/ripgrep");
23
+ const ripgrepDir = path.dirname(ripgrepPath);
24
+ const rgBinary = path.join(ripgrepDir, "..", "bin", "rg" + (process.platform === "win32" ? ".exe" : ""));
25
+ if (!existsSync(rgBinary)) {
26
+ const postinstallScript = path.join(ripgrepDir, "..", "lib", "postinstall.js");
27
+ if (existsSync(postinstallScript)) execFileSync(process.execPath, [postinstallScript], {
28
+ cwd: path.join(ripgrepDir, ".."),
29
+ stdio: "pipe",
30
+ timeout: 3e4
31
+ });
32
+ if (!existsSync(rgBinary)) 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`);
33
+ }
34
+ cachedRgPath = rgBinary;
35
+ return rgBinary;
36
+ } catch (error) {
37
+ if (error instanceof Error && error.message.includes("ripgrep binary not found")) throw error;
38
+ throw new Error("ripgrep is not available. Please install @vscode/ripgrep: pnpm add @vscode/ripgrep --filter @bike4mind/services");
39
+ }
40
+ }
41
+ /**
42
+ * Converts a glob pattern to ripgrep glob patterns
43
+ * Handles common cases like *.ts, *.{ts,tsx}, src/**, etc.
44
+ */
45
+ function convertGlobToRipgrepGlobs(globPattern) {
46
+ if (!globPattern || globPattern === "**/*") return [];
47
+ const braceMatch = globPattern.match(/\*\.{([^}]+)}/);
48
+ if (braceMatch) return braceMatch[1].split(",").map((ext) => `*.${ext.trim()}`);
49
+ return [globPattern];
50
+ }
51
+ async function searchFiles(params, allowedDirectories) {
52
+ const { pattern, dir_path, include } = params;
53
+ const baseCwd = process.cwd();
54
+ const targetDir = dir_path ? path.resolve(baseCwd, dir_path) : baseCwd;
55
+ if (!isPathAllowed(targetDir, allowedDirectories).allowed) {
56
+ const dirsMsg = allowedDirectories && allowedDirectories.length > 0 ? `Allowed directories: ${[baseCwd, ...allowedDirectories].join(", ")}` : `Working directory: ${baseCwd}`;
57
+ throw new Error(`Path validation failed: "${dir_path}" resolves outside allowed directories. ${dirsMsg}`);
58
+ }
59
+ try {
60
+ if (!(await stat(targetDir)).isDirectory()) throw new Error(`Path is not a directory: ${dir_path}`);
61
+ } catch (error) {
62
+ if (error.code === "ENOENT") throw new Error(`Path does not exist: ${dir_path}`);
63
+ throw error;
64
+ }
65
+ const rgPath = getRipgrepPath();
66
+ const rgArgs = [
67
+ "--json",
68
+ "--max-count",
69
+ "500",
70
+ "--ignore-case",
71
+ "--max-filesize",
72
+ "10M"
73
+ ];
74
+ const globs = convertGlobToRipgrepGlobs(include || "");
75
+ if (globs.length > 0) globs.forEach((glob) => {
76
+ rgArgs.push("--glob", glob);
77
+ });
78
+ rgArgs.push(pattern, targetDir);
79
+ let stdout;
80
+ try {
81
+ stdout = (await execFileAsync(rgPath, rgArgs, { maxBuffer: 50 * 1024 * 1024 })).stdout;
82
+ } catch (error) {
83
+ const execError = error;
84
+ if (execError.code === 1 && execError.stdout) stdout = execError.stdout;
85
+ else if (execError.code === 2) {
86
+ const errorMsg = execError.stderr || "Unknown ripgrep error";
87
+ throw new Error(`Ripgrep error: ${errorMsg}`);
88
+ } else throw error;
89
+ }
90
+ const lines = stdout.split("\n").filter(Boolean);
91
+ const allMatches = [];
92
+ let filesSearched = 0;
93
+ for (const line of lines) try {
94
+ const item = JSON.parse(line);
95
+ if (item.type === "match") {
96
+ const match = item;
97
+ allMatches.push({
98
+ filePath: path.relative(targetDir, match.data.path.text) || path.basename(match.data.path.text),
99
+ lineNumber: match.data.line_number,
100
+ line: match.data.lines.text.trimEnd()
101
+ });
102
+ } else if (item.type === "summary") filesSearched = item.data.stats.searches || 0;
103
+ } catch {
104
+ continue;
105
+ }
106
+ const searchDirDisplay = dir_path || ".";
107
+ const filterInfo = include ? ` (filter: "${include}")` : "";
108
+ const maxMatches = 500;
109
+ if (allMatches.length === 0) return `No matches found for pattern "${pattern}" in "${searchDirDisplay}"${filterInfo}.\nSearched ${filesSearched} file(s).`;
110
+ const matchesByFile = allMatches.reduce((acc, match) => {
111
+ if (!acc[match.filePath]) acc[match.filePath] = [];
112
+ acc[match.filePath].push(match);
113
+ return acc;
114
+ }, {});
115
+ const matchCount = allMatches.length;
116
+ let result = `Found ${matchCount} ${matchCount === 1 ? "match" : "matches"}${matchCount >= maxMatches ? " (truncated)" : ""} for pattern "${pattern}" in "${searchDirDisplay}"${filterInfo}:\n`;
117
+ result += `Searched ${filesSearched} file(s)\n---\n`;
118
+ for (const filePath in matchesByFile) {
119
+ result += `File: ${filePath}\n`;
120
+ matchesByFile[filePath].forEach((match) => {
121
+ const trimmedLine = match.line.trim();
122
+ const displayLine = trimmedLine.length > 200 ? trimmedLine.slice(0, 200) + "..." : trimmedLine;
123
+ result += `L${match.lineNumber}: ${displayLine}\n`;
124
+ });
125
+ result += "---\n";
126
+ }
127
+ return result.trim();
128
+ }
129
+ const grepSearchTool = {
130
+ name: "grep_search",
131
+ implementation: (context) => ({
132
+ toolFn: async (value) => {
133
+ const params = value;
134
+ context.logger.info("🔍 GrepSearch: Searching files", {
135
+ pattern: params.pattern,
136
+ dir_path: params.dir_path || ".",
137
+ include: params.include || "**/*"
138
+ });
139
+ try {
140
+ const result = await searchFiles(params, context.allowedDirectories);
141
+ context.logger.info("✅ GrepSearch: Success");
142
+ return result;
143
+ } catch (error) {
144
+ context.logger.error("❌ GrepSearch: Failed", error);
145
+ throw error;
146
+ }
147
+ },
148
+ toolSchema: {
149
+ name: "grep_search",
150
+ 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.",
151
+ parameters: {
152
+ type: "object",
153
+ properties: {
154
+ pattern: {
155
+ type: "string",
156
+ description: "The regular expression (regex) pattern to search for within file contents (e.g., 'function\\s+myFunction', 'import\\s+\\{.*\\}\\s+from\\s+.*')."
157
+ },
158
+ dir_path: {
159
+ type: "string",
160
+ description: "Optional: The absolute path to the directory to search within. If omitted, searches the current working directory."
161
+ },
162
+ include: {
163
+ type: "string",
164
+ 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)."
165
+ }
166
+ },
167
+ required: ["pattern"]
168
+ }
169
+ }
170
+ })
171
+ };
172
+ //#endregion
173
+ export { grepSearchTool };