@bike4mind/cli 0.2.60 → 0.2.61-feat-pi-intelligence-visibility.21705

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 (28) hide show
  1. package/dist/{artifactExtractor-YB2LOUUT.js → artifactExtractor-UI7MK2WJ.js} +1 -1
  2. package/dist/bashExecute-GLGLD3JD.js +379 -0
  3. package/dist/{chunk-I6CFAOBC.js → chunk-43D4HP62.js} +2 -2
  4. package/dist/{chunk-3BBKI54Z.js → chunk-BHX4ZDRS.js} +7 -7
  5. package/dist/{chunk-R5RVIU2Q.js → chunk-FIQZKJJW.js} +2 -2
  6. package/dist/{chunk-3YQJY7XO.js → chunk-HD2W2IIP.js} +20 -0
  7. package/dist/{chunk-WGZBP2RV.js → chunk-HIL7VU5N.js} +3558 -4406
  8. package/dist/chunk-LTLJRF6I.js +44 -0
  9. package/dist/{chunk-VFTGF46N.js → chunk-MRD767FA.js} +83 -10
  10. package/dist/{chunk-DSUZXGAO.js → chunk-Q4X33IU7.js} +2 -2
  11. package/dist/{chunk-E2GWB6BT.js → chunk-SLQS2YOB.js} +1 -1
  12. package/dist/commands/doctorCommand.js +1 -1
  13. package/dist/commands/headlessCommand.js +12 -11
  14. package/dist/commands/mcpCommand.js +2 -2
  15. package/dist/commands/updateCommand.js +1 -1
  16. package/dist/{create-PLDWPQDE.js → create-HVZTJCDH.js} +3 -3
  17. package/dist/createFile-6PSPLW6R.js +71 -0
  18. package/dist/deleteFile-AUSRLWIK.js +73 -0
  19. package/dist/globFiles-TSRN64N2.js +120 -0
  20. package/dist/grepSearch-634XWZOJ.js +216 -0
  21. package/dist/index.js +10 -9
  22. package/dist/{llmMarkdownGenerator-GJET3GJG.js → llmMarkdownGenerator-QT4CMIAP.js} +1 -1
  23. package/dist/{markdownGenerator-6RRUHY4M.js → markdownGenerator-VCEAQJ4R.js} +1 -1
  24. package/dist/{mementoService-NG5TZ6MH.js → mementoService-X6KHF3A5.js} +3 -3
  25. package/dist/{src-KFBFVZ7M.js → src-4SIKEV27.js} +3 -1
  26. package/dist/{src-72EECVVN.js → src-7M7IDZPJ.js} +2 -2
  27. package/dist/{subtractCredits-TVFMVBNC.js → subtractCredits-2VCKP4HK.js} +3 -3
  28. package/package.json +7 -7
@@ -0,0 +1,216 @@
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
+ };
package/dist/index.js CHANGED
@@ -48,25 +48,26 @@ import {
48
48
  setWebSocketToolExecutor,
49
49
  substituteArguments,
50
50
  warmFileCache
51
- } from "./chunk-WGZBP2RV.js";
51
+ } from "./chunk-HIL7VU5N.js";
52
52
  import "./chunk-BDQBOLYG.js";
53
- import "./chunk-DSUZXGAO.js";
53
+ import "./chunk-Q4X33IU7.js";
54
54
  import "./chunk-GQGOWACU.js";
55
- import "./chunk-R5RVIU2Q.js";
56
- import "./chunk-I6CFAOBC.js";
55
+ import "./chunk-LTLJRF6I.js";
56
+ import "./chunk-FIQZKJJW.js";
57
+ import "./chunk-43D4HP62.js";
57
58
  import {
58
59
  OllamaBackend
59
- } from "./chunk-VFTGF46N.js";
60
+ } from "./chunk-MRD767FA.js";
60
61
  import "./chunk-PFBYGCOW.js";
61
62
  import "./chunk-BPFEGDC7.js";
62
63
  import {
63
64
  ConfigStore,
64
65
  logger
65
- } from "./chunk-E2GWB6BT.js";
66
+ } from "./chunk-SLQS2YOB.js";
66
67
  import {
67
68
  checkForUpdate,
68
69
  package_default
69
- } from "./chunk-3BBKI54Z.js";
70
+ } from "./chunk-BHX4ZDRS.js";
70
71
  import {
71
72
  selectActiveBackgroundAgents,
72
73
  useCliStore
@@ -76,7 +77,7 @@ import {
76
77
  ChatModels,
77
78
  validateJupyterKernelName,
78
79
  validateNotebookPath
79
- } from "./chunk-3YQJY7XO.js";
80
+ } from "./chunk-HD2W2IIP.js";
80
81
  import "./chunk-4BIBE3J7.js";
81
82
 
82
83
  // src/index.tsx
@@ -4445,7 +4446,7 @@ Pull a model: ollama pull qwen3.5`
4445
4446
  currentAgent: null,
4446
4447
  observationQueue: []
4447
4448
  };
4448
- const { tools: b4mTools } = generateCliTools(
4449
+ const { tools: b4mTools } = await generateCliTools(
4449
4450
  config.userId,
4450
4451
  llm,
4451
4452
  modelInfo.id,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CurationArtifactType
4
- } from "./chunk-3YQJY7XO.js";
4
+ } from "./chunk-HD2W2IIP.js";
5
5
 
6
6
  // ../../b4m-core/packages/services/dist/src/notebookCurationService/llmMarkdownGenerator.js
7
7
  var DEFAULT_OPTIONS = {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CurationArtifactType
4
- } from "./chunk-3YQJY7XO.js";
4
+ } from "./chunk-HD2W2IIP.js";
5
5
 
6
6
  // ../../b4m-core/packages/services/dist/src/notebookCurationService/markdownGenerator.js
7
7
  var DEFAULT_OPTIONS = {
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  findMostSimilarMemento,
4
4
  getRelevantMementos
5
- } from "./chunk-DSUZXGAO.js";
6
- import "./chunk-VFTGF46N.js";
5
+ } from "./chunk-Q4X33IU7.js";
6
+ import "./chunk-MRD767FA.js";
7
7
  import "./chunk-PFBYGCOW.js";
8
- import "./chunk-3YQJY7XO.js";
8
+ import "./chunk-HD2W2IIP.js";
9
9
  export {
10
10
  findMostSimilarMemento,
11
11
  getRelevantMementos
@@ -359,6 +359,7 @@ import {
359
359
  TaskScheduleHandler,
360
360
  TaskScheduleStatus,
361
361
  TavernHeartbeatLogAction,
362
+ TavernQuestUpdateAction,
362
363
  TavernSceneBroadcastAction,
363
364
  TavernSceneCommandRequestAction,
364
365
  TextGenerationUsageTransaction,
@@ -545,7 +546,7 @@ import {
545
546
  validateReactArtifactV2,
546
547
  validateSvgArtifactV2,
547
548
  wikiMarkupToAdf
548
- } from "./chunk-3YQJY7XO.js";
549
+ } from "./chunk-HD2W2IIP.js";
549
550
  export {
550
551
  ALERT_THRESHOLDS,
551
552
  ALLOWED_JUPYTER_KERNELS,
@@ -907,6 +908,7 @@ export {
907
908
  TaskScheduleHandler,
908
909
  TaskScheduleStatus,
909
910
  TavernHeartbeatLogAction,
911
+ TavernQuestUpdateAction,
910
912
  TavernSceneBroadcastAction,
911
913
  TavernSceneCommandRequestAction,
912
914
  TextGenerationUsageTransaction,
@@ -146,7 +146,7 @@ import {
146
146
  validateUrlForFetch,
147
147
  warmUpSettingsCache,
148
148
  withRetry
149
- } from "./chunk-VFTGF46N.js";
149
+ } from "./chunk-MRD767FA.js";
150
150
  import {
151
151
  Logger,
152
152
  NotificationDeduplicator,
@@ -159,7 +159,7 @@ import {
159
159
  buildRateLimitLogEntry,
160
160
  isNearLimit,
161
161
  parseRateLimitHeaders
162
- } from "./chunk-3YQJY7XO.js";
162
+ } from "./chunk-HD2W2IIP.js";
163
163
  export {
164
164
  AIVideoService,
165
165
  AWSBackend,
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  SubtractCreditsSchema,
4
4
  subtractCredits
5
- } from "./chunk-R5RVIU2Q.js";
6
- import "./chunk-VFTGF46N.js";
5
+ } from "./chunk-FIQZKJJW.js";
6
+ import "./chunk-MRD767FA.js";
7
7
  import "./chunk-PFBYGCOW.js";
8
- import "./chunk-3YQJY7XO.js";
8
+ import "./chunk-HD2W2IIP.js";
9
9
  export {
10
10
  SubtractCreditsSchema,
11
11
  subtractCredits
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bike4mind/cli",
3
- "version": "0.2.60",
3
+ "version": "0.2.61-feat-pi-intelligence-visibility.21705+4927fe8fb",
4
4
  "type": "module",
5
5
  "description": "Interactive CLI tool for Bike4Mind with ReAct agents",
6
6
  "license": "UNLICENSED",
@@ -115,11 +115,11 @@
115
115
  "zustand": "^4.5.4"
116
116
  },
117
117
  "devDependencies": {
118
- "@bike4mind/agents": "0.2.4",
119
- "@bike4mind/common": "2.73.0",
120
- "@bike4mind/mcp": "1.33.18",
121
- "@bike4mind/services": "2.68.0",
122
- "@bike4mind/utils": "2.15.12",
118
+ "@bike4mind/agents": "0.2.5-feat-pi-intelligence-visibility.21705+4927fe8fb",
119
+ "@bike4mind/common": "2.73.1-feat-pi-intelligence-visibility.21705+4927fe8fb",
120
+ "@bike4mind/mcp": "1.33.19-feat-pi-intelligence-visibility.21705+4927fe8fb",
121
+ "@bike4mind/services": "2.68.1-feat-pi-intelligence-visibility.21705+4927fe8fb",
122
+ "@bike4mind/utils": "2.15.13-feat-pi-intelligence-visibility.21705+4927fe8fb",
123
123
  "@types/better-sqlite3": "^7.6.13",
124
124
  "@types/jsonwebtoken": "^9.0.4",
125
125
  "@types/node": "^22.9.0",
@@ -136,5 +136,5 @@
136
136
  "optionalDependencies": {
137
137
  "@vscode/ripgrep": "^1.17.1"
138
138
  },
139
- "gitHead": "12403427aa932671a61ac8fd7fe50d2a50b9f4f7"
139
+ "gitHead": "4927fe8fbd64bba4678d9c9971fa3dd99ca98ab3"
140
140
  }