@bike4mind/cli 0.2.31-fix-lambda-unhandled-rejection.19490 → 0.2.31-fix-cli-ws-review-feedback.19589

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-UVOOKS6R.js";
4
+ } from "./chunk-PLA2VBQW.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
  }
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  BadRequestError,
4
4
  secureParameters
5
- } from "./chunk-3LGHTME3.js";
5
+ } from "./chunk-PV6PZFPC.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-UVOOKS6R.js";
15
+ } from "./chunk-PLA2VBQW.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-3LGHTME3.js";
9
+ } from "./chunk-PV6PZFPC.js";
10
10
  import {
11
11
  ApiKeyType,
12
12
  MementoTier,
13
13
  isSupportedEmbeddingModel
14
- } from "./chunk-UVOOKS6R.js";
14
+ } from "./chunk-PLA2VBQW.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()
@@ -5,6 +5,7 @@ var Logger = class _Logger {
5
5
  static globalInstance = new _Logger();
6
6
  metadata = {};
7
7
  logInJson;
8
+ prettyPrint;
8
9
  minLevel;
9
10
  // Log level hierarchy (higher number = more severe)
10
11
  static LOG_LEVELS = {
@@ -13,15 +14,112 @@ var Logger = class _Logger {
13
14
  warn: 2,
14
15
  error: 3
15
16
  };
17
+ // ANSI color codes for pretty printing
18
+ static COLORS = {
19
+ debug: "\x1B[36m",
20
+ // Cyan
21
+ info: "\x1B[32m",
22
+ // Green
23
+ warn: "\x1B[33m",
24
+ // Yellow
25
+ error: "\x1B[31m",
26
+ // Red
27
+ reset: "\x1B[0m",
28
+ dim: "\x1B[2m"
29
+ };
30
+ // Level labels for pretty printing (padded for alignment)
31
+ static LEVEL_LABELS = {
32
+ debug: "DEBUG",
33
+ info: " INFO",
34
+ warn: " WARN",
35
+ error: "ERROR"
36
+ };
37
+ // Indentation constants for pretty printing
38
+ static INDENT = " ";
39
+ static NESTED_INDENT = " ";
16
40
  constructor(options = {}) {
17
- const { metadata = {}, logInJson = process.env.LOG_JSON === "true" || !(process.env.IS_LOCAL === "true" || process.env.NODE_ENV === "development"), minLevel = process.env.LOG_LEVEL || "info" } = options;
41
+ const isLocalDev = process.env.IS_LOCAL === "true" || process.env.NODE_ENV === "development" || process.env.SST_LIVE === "true";
42
+ const { metadata = {}, logInJson = process.env.LOG_JSON === "true" || !isLocalDev, prettyPrint = isLocalDev && process.env.LOG_PRETTY !== "false", minLevel = process.env.LOG_LEVEL || "info" } = options;
18
43
  this.metadata = metadata;
19
44
  this.logInJson = logInJson;
45
+ this.prettyPrint = prettyPrint;
20
46
  this.minLevel = minLevel;
21
47
  }
22
48
  shouldLog(level) {
23
49
  return _Logger.LOG_LEVELS[level] >= _Logger.LOG_LEVELS[this.minLevel];
24
50
  }
51
+ /**
52
+ * Safely stringify a value, handling circular references
53
+ */
54
+ safeStringify(value, indent) {
55
+ try {
56
+ return JSON.stringify(value, null, indent);
57
+ } catch {
58
+ return "[Circular]";
59
+ }
60
+ }
61
+ /**
62
+ * Parse log arguments to extract message and optional metadata
63
+ */
64
+ parseArgs(args, errorAware = false) {
65
+ if (args.length === 0) {
66
+ return { message: "" };
67
+ }
68
+ const lastArg = args[args.length - 1];
69
+ const hasMetadata = args.length > 1 && typeof lastArg === "object" && lastArg !== null && !Array.isArray(lastArg) && !(lastArg instanceof Error);
70
+ const metadata = hasMetadata ? lastArg : void 0;
71
+ const messageArgs = hasMetadata ? args.slice(0, -1) : args;
72
+ const message = messageArgs.map((a) => {
73
+ if (errorAware && a instanceof Error) {
74
+ return a.stack || a.message;
75
+ }
76
+ return typeof a === "string" ? a : this.safeStringify(a);
77
+ }).join(" ");
78
+ return { message, metadata };
79
+ }
80
+ /**
81
+ * Output a log message using the appropriate format
82
+ */
83
+ output(level, consoleFn, message, metadata) {
84
+ const allMetadata = { ...this.metadata, ...metadata };
85
+ if (this.logInJson) {
86
+ consoleFn(this.safeStringify({ ...allMetadata, severity: level, message }));
87
+ } else if (this.prettyPrint) {
88
+ consoleFn(this.formatPretty(level, message, metadata));
89
+ } else {
90
+ const metadataKeys = Object.keys(allMetadata);
91
+ if (metadataKeys.length > 0) {
92
+ consoleFn(message, allMetadata);
93
+ } else {
94
+ consoleFn(message);
95
+ }
96
+ }
97
+ }
98
+ /**
99
+ * Format a log message with pino-pretty-like output for local development
100
+ */
101
+ formatPretty(level, message, metadata) {
102
+ const { reset, dim } = _Logger.COLORS;
103
+ const color = _Logger.COLORS[level];
104
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
105
+ const parts = [];
106
+ parts.push(`${dim}[${timestamp}]${reset} ${color}${_Logger.LEVEL_LABELS[level]}${reset} ${message}`);
107
+ const allMetadata = { ...this.metadata, ...metadata };
108
+ const metadataKeys = Object.keys(allMetadata);
109
+ if (metadataKeys.length > 0) {
110
+ for (const key of metadataKeys) {
111
+ const value = allMetadata[key];
112
+ if (typeof value === "object" && value !== null) {
113
+ const jsonStr = this.safeStringify(value, 2);
114
+ const indentedJson = jsonStr.split("\n").map((line, idx) => idx === 0 ? line : _Logger.NESTED_INDENT + line).join("\n");
115
+ parts.push(`${_Logger.INDENT}${dim}${key}:${reset} ${indentedJson}`);
116
+ } else {
117
+ parts.push(`${_Logger.INDENT}${dim}${key}:${reset} ${value}`);
118
+ }
119
+ }
120
+ }
121
+ return parts.join("\n");
122
+ }
25
123
  resetMetadata() {
26
124
  this.metadata = {};
27
125
  return this;
@@ -33,6 +131,7 @@ var Logger = class _Logger {
33
131
  ...metadata
34
132
  },
35
133
  logInJson: this.logInJson,
134
+ prettyPrint: this.prettyPrint,
36
135
  minLevel: this.minLevel
37
136
  });
38
137
  }
@@ -49,47 +148,26 @@ var Logger = class _Logger {
49
148
  debug(...args) {
50
149
  if (!this.shouldLog("debug"))
51
150
  return;
52
- const message = args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ");
53
- if (this.logInJson) {
54
- console.debug(JSON.stringify({ ...this.metadata, severity: "debug", message }));
55
- } else {
56
- console.debug(message);
57
- }
151
+ const { message, metadata } = this.parseArgs(args);
152
+ this.output("debug", console.debug, message, metadata);
58
153
  }
59
154
  info(...args) {
60
155
  if (!this.shouldLog("info"))
61
156
  return;
62
- const message = args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ");
63
- if (this.logInJson) {
64
- console.info(JSON.stringify({ ...this.metadata, severity: "info", message }));
65
- } else {
66
- console.info(message);
67
- }
157
+ const { message, metadata } = this.parseArgs(args);
158
+ this.output("info", console.info, message, metadata);
68
159
  }
69
160
  warn(...args) {
70
161
  if (!this.shouldLog("warn"))
71
162
  return;
72
- const message = args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ");
73
- if (this.logInJson) {
74
- console.warn(JSON.stringify({ ...this.metadata, severity: "warn", message }));
75
- } else {
76
- console.warn(message);
77
- }
163
+ const { message, metadata } = this.parseArgs(args);
164
+ this.output("warn", console.warn, message, metadata);
78
165
  }
79
166
  error(...args) {
80
167
  if (!this.shouldLog("error"))
81
168
  return;
82
- const message = args.map((a) => {
83
- if (a instanceof Error) {
84
- return a.stack || a.message;
85
- }
86
- return typeof a === "string" ? a : JSON.stringify(a);
87
- }).join(" ");
88
- if (this.logInJson) {
89
- console.error(JSON.stringify({ ...this.metadata, severity: "error", message }));
90
- } else {
91
- console.error(message);
92
- }
169
+ const { message, metadata } = this.parseArgs(args, true);
170
+ this.output("error", console.error, message, metadata);
93
171
  }
94
172
  /*
95
173
  * Global logger instance handling:
@@ -160,7 +238,7 @@ var notifyEventLogsToSlack = async ({ event, stage, slackUrl, throttlingSlackUrl
160
238
  if (!allowedStages.includes(stage))
161
239
  return;
162
240
  const logEvents = logData.logEvents;
163
- const { notificationDeduplicator: notificationDeduplicator2 } = await import("./notificationDeduplicator-UTHJHMSZ.js");
241
+ const { notificationDeduplicator: notificationDeduplicator2 } = await import("./notificationDeduplicator-HUC53NEW.js");
164
242
  for (const logEvent of logEvents) {
165
243
  try {
166
244
  let message;