@bike4mind/cli 0.2.31-b4m-cli-undo-command.19493 → 0.2.31-b4m-cli-undo-command.19535

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.
@@ -88,6 +88,8 @@ const argv = await yargs(hideBin(process.argv))
88
88
  })
89
89
  .demandCommand(1, 'You must provide a subcommand (list, add, remove, enable, disable)');
90
90
  })
91
+ .command('update', 'Check for and install CLI updates')
92
+ .command('doctor', 'Run diagnostic checks on CLI installation')
91
93
  .help()
92
94
  .alias('help', 'h')
93
95
  .version()
@@ -149,6 +151,52 @@ if (argv._[0] === 'mcp') {
149
151
  }
150
152
  }
151
153
 
154
+ // Handle update command (external command)
155
+ if (argv._[0] === 'update') {
156
+ try {
157
+ let handleUpdateCommand;
158
+
159
+ if (isDev) {
160
+ const { register } = require('tsx/esm/api');
161
+ register();
162
+ const module = await import('../src/commands/updateCommand.ts');
163
+ handleUpdateCommand = module.handleUpdateCommand;
164
+ } else {
165
+ const module = await import('../dist/commands/updateCommand.js');
166
+ handleUpdateCommand = module.handleUpdateCommand;
167
+ }
168
+
169
+ await handleUpdateCommand();
170
+ process.exit(0);
171
+ } catch (error) {
172
+ console.error('Error:', error.message);
173
+ process.exit(1);
174
+ }
175
+ }
176
+
177
+ // Handle doctor command (external command)
178
+ if (argv._[0] === 'doctor') {
179
+ try {
180
+ let handleDoctorCommand;
181
+
182
+ if (isDev) {
183
+ const { register } = require('tsx/esm/api');
184
+ register();
185
+ const module = await import('../src/commands/doctorCommand.ts');
186
+ handleDoctorCommand = module.handleDoctorCommand;
187
+ } else {
188
+ const module = await import('../dist/commands/doctorCommand.js');
189
+ handleDoctorCommand = module.handleDoctorCommand;
190
+ }
191
+
192
+ await handleDoctorCommand();
193
+ process.exit(0);
194
+ } catch (error) {
195
+ console.error('Error:', error.message);
196
+ process.exit(1);
197
+ }
198
+ }
199
+
152
200
  if (isDev) {
153
201
  // Show dev mode indicator for developers
154
202
  console.log('🔧 Running in development mode (using TypeScript source)\n');
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CurationArtifactType
4
- } from "./chunk-GE7Q64MS.js";
4
+ } from "./chunk-NI22LIK3.js";
5
5
 
6
6
  // ../../b4m-core/packages/services/dist/src/notebookCurationService/artifactExtractor.js
7
7
  var ARTIFACT_TAG_REGEX = /<artifact\s+(.*?)>([\s\S]*?)<\/artifact>/gi;
@@ -269,24 +269,25 @@ var AuthTokensSchema = z.object({
269
269
  userId: z.string()
270
270
  });
271
271
  var ApiConfigSchema = z.object({
272
- customUrl: z.string().url().optional()
272
+ customUrl: z.url().optional()
273
273
  });
274
274
  var McpServerSchema = z.object({
275
275
  name: z.string(),
276
276
  command: z.string().optional(),
277
277
  args: z.array(z.string()).optional(),
278
- env: z.record(z.string()).default({}),
279
- enabled: z.boolean().default(true)
278
+ env: z.record(z.string(), z.string()).prefault({}),
279
+ enabled: z.boolean().prefault(true)
280
280
  });
281
281
  var McpServersSchema = z.union([
282
282
  // Array format (B4M native)
283
283
  z.array(McpServerSchema),
284
284
  // Object format (portable - compatible with Claude Code)
285
285
  z.record(
286
+ z.string(),
286
287
  z.object({
287
288
  command: z.string().optional(),
288
289
  args: z.array(z.string()).optional(),
289
- env: z.record(z.string()).optional(),
290
+ env: z.record(z.string(), z.string()).optional(),
290
291
  enabled: z.boolean().optional()
291
292
  })
292
293
  )
@@ -325,24 +326,24 @@ var CliConfigSchema = z.object({
325
326
  maxTokens: z.number(),
326
327
  temperature: z.number(),
327
328
  autoSave: z.boolean(),
328
- autoCompact: z.boolean().optional().default(true),
329
+ autoCompact: z.boolean().optional().prefault(true),
329
330
  theme: z.enum(["light", "dark"]),
330
331
  exportFormat: z.enum(["markdown", "json"]),
331
- maxIterations: z.number().nullable().default(10),
332
- enableSkillTool: z.boolean().optional().default(true)
332
+ maxIterations: z.number().nullable().prefault(10),
333
+ enableSkillTool: z.boolean().optional().prefault(true)
333
334
  }),
334
335
  tools: z.object({
335
336
  enabled: z.array(z.string()),
336
337
  disabled: z.array(z.string()),
337
- config: z.record(z.any())
338
+ config: z.record(z.string(), z.any())
338
339
  }),
339
- trustedTools: z.array(z.string()).optional().default([])
340
+ trustedTools: z.array(z.string()).optional().prefault([])
340
341
  });
341
342
  var ProjectConfigSchema = z.object({
342
343
  tools: z.object({
343
344
  enabled: z.array(z.string()).optional(),
344
345
  denied: z.array(z.string()).optional(),
345
- config: z.record(z.any()).optional()
346
+ config: z.record(z.string(), z.any()).optional()
346
347
  }).optional(),
347
348
  defaultModel: z.string().optional(),
348
349
  mcpServers: McpServersSchema.optional(),
@@ -432,7 +433,7 @@ async function loadProjectConfig(projectDir) {
432
433
  return null;
433
434
  }
434
435
  if (error instanceof z.ZodError) {
435
- console.error("Project config validation error:", error.errors);
436
+ console.error("Project config validation error:", error.issues);
436
437
  return null;
437
438
  }
438
439
  console.error("Failed to load project config:", error);
@@ -455,7 +456,7 @@ async function loadProjectLocalConfig(projectDir) {
455
456
  return null;
456
457
  }
457
458
  if (error instanceof z.ZodError) {
458
- console.error("Project local config validation error:", error.errors);
459
+ console.error("Project local config validation error:", error.issues);
459
460
  return null;
460
461
  }
461
462
  console.error("Failed to load project local config:", error);
@@ -478,7 +479,7 @@ async function loadMcpJsonConfig(projectDir) {
478
479
  return null;
479
480
  }
480
481
  if (error instanceof z.ZodError) {
481
- console.error(".mcp.json validation error:", error.errors);
482
+ console.error(".mcp.json validation error:", error.issues);
482
483
  return null;
483
484
  }
484
485
  console.error("Failed to load .mcp.json:", error);
@@ -620,7 +621,7 @@ var ConfigStore = class {
620
621
  if (error.code === "ENOENT") {
621
622
  globalConfig = { ...DEFAULT_CONFIG };
622
623
  } else if (error instanceof z.ZodError) {
623
- console.error("Global config validation error:", error.errors);
624
+ console.error("Global config validation error:", error.issues);
624
625
  console.error("Using default configuration");
625
626
  globalConfig = { ...DEFAULT_CONFIG };
626
627
  } else {
@@ -657,7 +658,7 @@ var ConfigStore = class {
657
658
  return this.reset();
658
659
  }
659
660
  if (error instanceof z.ZodError) {
660
- console.error("Config validation error:", error.errors);
661
+ console.error("Config validation error:", error.issues);
661
662
  console.error("Resetting to default configuration");
662
663
  return this.reset();
663
664
  }
@@ -16,10 +16,10 @@ import {
16
16
  dayjsConfig_default,
17
17
  extractSnippetMeta,
18
18
  settingsMap
19
- } from "./chunk-GE7Q64MS.js";
19
+ } from "./chunk-NI22LIK3.js";
20
20
  import {
21
21
  Logger
22
- } from "./chunk-OCYRD7D6.js";
22
+ } from "./chunk-PFBYGCOW.js";
23
23
 
24
24
  // ../../b4m-core/packages/utils/dist/src/storage/S3Storage.js
25
25
  import { S3Client, PutObjectCommand, DeleteObjectCommand, GetObjectCommand, HeadObjectCommand } from "@aws-sdk/client-s3";
@@ -7791,7 +7791,7 @@ function secureParameters(params, schema) {
7791
7791
  return schema.parse(params);
7792
7792
  } catch (e) {
7793
7793
  if (isZodError(e)) {
7794
- throw new UnprocessableEntityError(e.errors.map((err) => `${err.path.join(".")}: ${err.message}`).join(", "));
7794
+ throw new UnprocessableEntityError(e.issues.map((err) => `${err.path.join(".")}: ${err.message}`).join(", "));
7795
7795
  }
7796
7796
  throw new InternalServerError();
7797
7797
  }
@@ -7,11 +7,11 @@ import {
7
7
  getSettingsMap,
8
8
  getSettingsValue,
9
9
  secureParameters
10
- } from "./chunk-RI45VJW3.js";
10
+ } from "./chunk-3SPW5FYJ.js";
11
11
  import {
12
12
  KnowledgeType,
13
13
  SupportedFabFileMimeTypes
14
- } from "./chunk-GE7Q64MS.js";
14
+ } from "./chunk-NI22LIK3.js";
15
15
 
16
16
  // ../../b4m-core/packages/services/dist/src/fabFileService/create.js
17
17
  import { z } from "zod";
@@ -20,7 +20,7 @@ var createFabFileSchema = z.object({
20
20
  fileName: z.string(),
21
21
  mimeType: z.string(),
22
22
  fileSize: z.number(),
23
- type: z.nativeEnum(KnowledgeType),
23
+ type: z.enum(KnowledgeType),
24
24
  content: z.union([z.string(), z.instanceof(Buffer)]).optional(),
25
25
  organizationId: z.string().optional(),
26
26
  /**
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  BadRequestError,
4
4
  secureParameters
5
- } from "./chunk-RI45VJW3.js";
5
+ } from "./chunk-3SPW5FYJ.js";
6
6
  import {
7
7
  CompletionApiUsageTransaction,
8
8
  GenericCreditDeductTransaction,
@@ -12,7 +12,7 @@ import {
12
12
  TextGenerationUsageTransaction,
13
13
  TransferCreditTransaction,
14
14
  VideoGenerationUsageTransaction
15
- } from "./chunk-GE7Q64MS.js";
15
+ } from "./chunk-NI22LIK3.js";
16
16
 
17
17
  // ../../b4m-core/packages/services/dist/src/creditService/subtractCredits.js
18
18
  import { z } from "zod";
@@ -6,17 +6,17 @@ import {
6
6
  getSettingsByNames,
7
7
  obfuscateApiKey,
8
8
  secureParameters
9
- } from "./chunk-RI45VJW3.js";
9
+ } from "./chunk-3SPW5FYJ.js";
10
10
  import {
11
11
  ApiKeyType,
12
12
  MementoTier,
13
13
  isSupportedEmbeddingModel
14
- } from "./chunk-GE7Q64MS.js";
14
+ } from "./chunk-NI22LIK3.js";
15
15
 
16
16
  // ../../b4m-core/packages/services/dist/src/apiKeyService/get.js
17
17
  import { z } from "zod";
18
18
  var getApiKeySchema = z.object({
19
- type: z.nativeEnum(ApiKeyType),
19
+ type: z.enum(ApiKeyType),
20
20
  nullIfMissing: z.boolean().optional(),
21
21
  obfuscate: z.boolean().optional(),
22
22
  demoKeyName: z.string().optional()
@@ -0,0 +1,244 @@
1
+ #!/usr/bin/env node
2
+
3
+ // package.json
4
+ var package_default = {
5
+ name: "@bike4mind/cli",
6
+ version: "0.2.31-b4m-cli-undo-command.19535+040263f1d",
7
+ type: "module",
8
+ description: "Interactive CLI tool for Bike4Mind with ReAct agents",
9
+ license: "UNLICENSED",
10
+ author: "Bike4Mind",
11
+ repository: {
12
+ type: "git",
13
+ url: "git+https://github.com/bike4mind/lumina5.git"
14
+ },
15
+ homepage: "https://github.com/bike4mind/lumina5#readme",
16
+ bugs: "https://github.com/bike4mind/lumina5/issues",
17
+ publishConfig: {
18
+ access: "public"
19
+ },
20
+ keywords: [
21
+ "cli",
22
+ "ai",
23
+ "bike4mind",
24
+ "agent",
25
+ "mcp",
26
+ "react-agent"
27
+ ],
28
+ bin: {
29
+ b4m: "./bin/bike4mind-cli.mjs",
30
+ bike4mind: "./bin/bike4mind-cli.mjs"
31
+ },
32
+ files: [
33
+ "dist",
34
+ "bin"
35
+ ],
36
+ scripts: {
37
+ dev: "tsx src/index.tsx",
38
+ build: "tsup",
39
+ typecheck: "tsc --noEmit",
40
+ test: "vitest run",
41
+ "test:watch": "vitest",
42
+ start: "node dist/index.js",
43
+ prepublishOnly: "pnpm build",
44
+ postinstall: `node -e "try { require('better-sqlite3') } catch(e) { if(e.message.includes('bindings')) { console.log('\\n\u26A0\uFE0F Rebuilding better-sqlite3 native bindings...'); require('child_process').execSync('pnpm rebuild better-sqlite3', {stdio:'inherit'}) } }"`
45
+ },
46
+ dependencies: {
47
+ "@anthropic-ai/sdk": "^0.71.2",
48
+ "@aws-sdk/client-apigatewaymanagementapi": "3.654.0",
49
+ "@aws-sdk/client-bedrock-runtime": "3.654.0",
50
+ "@aws-sdk/client-cloudwatch": "3.654.0",
51
+ "@aws-sdk/client-lambda": "3.654.0",
52
+ "@aws-sdk/client-s3": "3.654.0",
53
+ "@aws-sdk/client-sqs": "3.654.0",
54
+ "@aws-sdk/client-transcribe": "3.654.0",
55
+ "@aws-sdk/credential-provider-node": "3.654.0",
56
+ "@aws-sdk/node-http-handler": "^3.374.0",
57
+ "@aws-sdk/s3-request-presigner": "3.654.0",
58
+ "@casl/ability": "^6.5.0",
59
+ "@google/genai": "^1.27.0",
60
+ "@google/generative-ai": "^0.21.0",
61
+ "@joplin/turndown-plugin-gfm": "^1.0.62",
62
+ "@mendable/firecrawl-js": "^1.29.3",
63
+ "@modelcontextprotocol/sdk": "1.26.0",
64
+ "@octokit/rest": "^22.0.0",
65
+ "@opensearch-project/opensearch": "2.11.0",
66
+ "async-mutex": "^0.5.0",
67
+ axios: "^1.13.2",
68
+ bcryptjs: "^2.4.3",
69
+ "better-sqlite3": "^12.5.0",
70
+ cheerio: "1.0.0-rc.12",
71
+ "cli-highlight": "^2.1.11",
72
+ "csv-parse": "^5.5.6",
73
+ dayjs: "^1.11.13",
74
+ diff: "^8.0.2",
75
+ dotenv: "^16.3.1",
76
+ "eventsource-parser": "^3.0.6",
77
+ "file-type": "^18.7.0",
78
+ "fuse.js": "^7.1.0",
79
+ glob: "^13.0.0",
80
+ "gray-matter": "^4.0.3",
81
+ ink: "^6.5.1",
82
+ "ink-select-input": "^6.2.0",
83
+ "ink-spinner": "^5.0.0",
84
+ "ink-text-input": "^6.0.0",
85
+ jsonwebtoken: "^9.0.2",
86
+ lodash: "^4.17.21",
87
+ mammoth: "^1.11.0",
88
+ marked: "^15.0.11",
89
+ mathjs: "^14.2.0",
90
+ "mime-types": "^2.1.35",
91
+ mongoose: "^8.8.3",
92
+ ollama: "^0.5.12",
93
+ open: "^11.0.0",
94
+ openai: "^6.18.0",
95
+ "p-limit": "^6.2.0",
96
+ picomatch: "^4.0.3",
97
+ qrcode: "^1.5.4",
98
+ react: "^19.2.3",
99
+ sharp: "^0.34.5",
100
+ speakeasy: "^2.0.0",
101
+ tiktoken: "^1.0.16",
102
+ "tree-sitter-wasms": "^0.1.13",
103
+ turndown: "^7.2.0",
104
+ unpdf: "^0.10.0",
105
+ uuid: "^9.0.1",
106
+ voyageai: "^0.0.4",
107
+ "web-tree-sitter": "0.25.10",
108
+ xlsx: "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
109
+ yargs: "^17.7.2",
110
+ yauzl: "^3.1.3",
111
+ zod: "^4.3.6",
112
+ "zod-validation-error": "^5.0.0",
113
+ zustand: "^4.5.4"
114
+ },
115
+ devDependencies: {
116
+ "@bike4mind/agents": "0.1.0",
117
+ "@bike4mind/common": "2.52.1-b4m-cli-undo-command.19535+040263f1d",
118
+ "@bike4mind/mcp": "1.31.1-b4m-cli-undo-command.19535+040263f1d",
119
+ "@bike4mind/services": "2.50.1-b4m-cli-undo-command.19535+040263f1d",
120
+ "@bike4mind/utils": "2.7.1-b4m-cli-undo-command.19535+040263f1d",
121
+ "@types/better-sqlite3": "^7.6.13",
122
+ "@types/diff": "^5.0.9",
123
+ "@types/jsonwebtoken": "^9.0.4",
124
+ "@types/node": "^22.9.0",
125
+ "@types/picomatch": "^4.0.2",
126
+ "@types/react": "^19.2.7",
127
+ "@types/uuid": "^9.0.7",
128
+ "@types/yargs": "^17.0.32",
129
+ fdir: "^6.5.0",
130
+ fzf: "^0.5.2",
131
+ ignore: "^7.0.5",
132
+ "ink-testing-library": "^4.0.0",
133
+ tsup: "^8.5.1",
134
+ tsx: "^4.21.0",
135
+ typescript: "^5.9.3",
136
+ vitest: "^3.2.4"
137
+ },
138
+ optionalDependencies: {
139
+ "@vscode/ripgrep": "^1.17.0"
140
+ },
141
+ gitHead: "040263f1d1bb68be464392da9dc0129ea349940d"
142
+ };
143
+
144
+ // src/utils/updateChecker.ts
145
+ import { promises as fs } from "fs";
146
+ import path from "path";
147
+ import { homedir } from "os";
148
+ import axios from "axios";
149
+ var CACHE_FILE = path.join(homedir(), ".bike4mind", "update-check.json");
150
+ var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
151
+ var NPM_REGISTRY_URL = "https://registry.npmjs.org/@bike4mind/cli/latest";
152
+ var FETCH_TIMEOUT_MS = 5e3;
153
+ function compareSemver(a, b) {
154
+ const partsA = a.split(".").map(Number);
155
+ const partsB = b.split(".").map(Number);
156
+ for (let i = 0; i < 3; i++) {
157
+ const segA = partsA[i] ?? 0;
158
+ const segB = partsB[i] ?? 0;
159
+ if (segA < segB) return -1;
160
+ if (segA > segB) return 1;
161
+ }
162
+ return 0;
163
+ }
164
+ async function fetchLatestVersion() {
165
+ try {
166
+ const response = await axios.get(NPM_REGISTRY_URL, {
167
+ timeout: FETCH_TIMEOUT_MS,
168
+ headers: { Accept: "application/json" }
169
+ });
170
+ const version = response.data?.version;
171
+ return typeof version === "string" ? version : null;
172
+ } catch {
173
+ return null;
174
+ }
175
+ }
176
+ async function readCache() {
177
+ try {
178
+ const data = await fs.readFile(CACHE_FILE, "utf-8");
179
+ const parsed = JSON.parse(data);
180
+ if (parsed && typeof parsed.lastChecked === "string" && typeof parsed.latestVersion === "string") {
181
+ return parsed;
182
+ }
183
+ return null;
184
+ } catch {
185
+ return null;
186
+ }
187
+ }
188
+ async function writeCache(cache) {
189
+ try {
190
+ await fs.mkdir(path.dirname(CACHE_FILE), { recursive: true });
191
+ await fs.writeFile(CACHE_FILE, JSON.stringify(cache, null, 2), "utf-8");
192
+ } catch {
193
+ }
194
+ }
195
+ async function checkForUpdate(currentVersion) {
196
+ try {
197
+ const cache = await readCache();
198
+ if (cache && cache.currentVersion === currentVersion) {
199
+ const age = Date.now() - new Date(cache.lastChecked).getTime();
200
+ if (age < CACHE_TTL_MS) {
201
+ return {
202
+ currentVersion,
203
+ latestVersion: cache.latestVersion,
204
+ updateAvailable: compareSemver(cache.latestVersion, currentVersion) > 0
205
+ };
206
+ }
207
+ }
208
+ const latestVersion = await fetchLatestVersion();
209
+ if (!latestVersion) return null;
210
+ await writeCache({
211
+ lastChecked: (/* @__PURE__ */ new Date()).toISOString(),
212
+ latestVersion,
213
+ currentVersion
214
+ });
215
+ return {
216
+ currentVersion,
217
+ latestVersion,
218
+ updateAvailable: compareSemver(latestVersion, currentVersion) > 0
219
+ };
220
+ } catch {
221
+ return null;
222
+ }
223
+ }
224
+ async function forceCheckForUpdate(currentVersion) {
225
+ const latestVersion = await fetchLatestVersion();
226
+ if (!latestVersion) return null;
227
+ await writeCache({
228
+ lastChecked: (/* @__PURE__ */ new Date()).toISOString(),
229
+ latestVersion,
230
+ currentVersion
231
+ });
232
+ return {
233
+ currentVersion,
234
+ latestVersion,
235
+ updateAvailable: compareSemver(latestVersion, currentVersion) > 0
236
+ };
237
+ }
238
+
239
+ export {
240
+ package_default,
241
+ fetchLatestVersion,
242
+ checkForUpdate,
243
+ forceCheckForUpdate
244
+ };