@rigstate/cli 0.7.20 → 0.7.22

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.
package/dist/index.js CHANGED
@@ -1757,7 +1757,7 @@ var require_package = __commonJS({
1757
1757
  "package.json"(exports, module) {
1758
1758
  module.exports = {
1759
1759
  name: "@rigstate/cli",
1760
- version: "0.7.20",
1760
+ version: "0.7.22",
1761
1761
  description: "Rigstate CLI - Code audit, sync and supervision tool",
1762
1762
  type: "module",
1763
1763
  main: "./dist/index.js",
@@ -3235,7 +3235,7 @@ init_hooks();
3235
3235
  // src/commands/daemon.ts
3236
3236
  init_esm_shims();
3237
3237
  import { Command as Command11 } from "commander";
3238
- import chalk19 from "chalk";
3238
+ import chalk20 from "chalk";
3239
3239
  import ora8 from "ora";
3240
3240
  import fs18 from "fs/promises";
3241
3241
  import path20 from "path";
@@ -3247,7 +3247,7 @@ init_esm_shims();
3247
3247
 
3248
3248
  // src/daemon/core.ts
3249
3249
  init_esm_shims();
3250
- import chalk18 from "chalk";
3250
+ import chalk19 from "chalk";
3251
3251
  import * as fs17 from "fs/promises";
3252
3252
  import { EventEmitter as EventEmitter3 } from "events";
3253
3253
 
@@ -3809,6 +3809,65 @@ async function trackSkillUsage(apiUrl, apiKey, projectId, skillId) {
3809
3809
 
3810
3810
  // src/daemon/core.ts
3811
3811
  init_skills_provisioner();
3812
+ init_sync_rules();
3813
+
3814
+ // src/utils/logger.ts
3815
+ init_esm_shims();
3816
+ import chalk18 from "chalk";
3817
+ var Logger = class {
3818
+ static formatMessage(level, message, context) {
3819
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
3820
+ let prefix = "";
3821
+ switch (level) {
3822
+ case "INFO" /* INFO */:
3823
+ prefix = chalk18.blue(`[${"INFO" /* INFO */}]`);
3824
+ break;
3825
+ case "WARN" /* WARN */:
3826
+ prefix = chalk18.yellow(`[${"WARN" /* WARN */}]`);
3827
+ break;
3828
+ case "ERROR" /* ERROR */:
3829
+ prefix = chalk18.red(`[${"ERROR" /* ERROR */}]`);
3830
+ break;
3831
+ case "DEBUG" /* DEBUG */:
3832
+ prefix = chalk18.gray(`[${"DEBUG" /* DEBUG */}]`);
3833
+ break;
3834
+ }
3835
+ let output = `${chalk18.gray(timestamp)} ${prefix} ${message}`;
3836
+ if (context) {
3837
+ if (context instanceof Error) {
3838
+ output += `
3839
+ ${chalk18.red(context.stack || context.message)}`;
3840
+ } else if (typeof context === "object") {
3841
+ try {
3842
+ output += `
3843
+ ${chalk18.gray(JSON.stringify(context, null, 2))}`;
3844
+ } catch (e) {
3845
+ output += `
3846
+ ${chalk18.gray("[Circular or invalid object]")}`;
3847
+ }
3848
+ } else {
3849
+ output += ` ${String(context)}`;
3850
+ }
3851
+ }
3852
+ return output;
3853
+ }
3854
+ static info(message, context) {
3855
+ console.log(this.formatMessage("INFO" /* INFO */, message, context));
3856
+ }
3857
+ static warn(message, context) {
3858
+ console.warn(this.formatMessage("WARN" /* WARN */, message, context));
3859
+ }
3860
+ static error(message, error) {
3861
+ console.error(this.formatMessage("ERROR" /* ERROR */, message, error));
3862
+ }
3863
+ static debug(message, context) {
3864
+ if (process.env.DEBUG || process.env.RIGSTATE_DEBUG) {
3865
+ console.debug(this.formatMessage("DEBUG" /* DEBUG */, message, context));
3866
+ }
3867
+ }
3868
+ };
3869
+
3870
+ // src/daemon/core.ts
3812
3871
  var GuardianDaemon = class extends EventEmitter3 {
3813
3872
  config;
3814
3873
  state;
@@ -3831,7 +3890,7 @@ var GuardianDaemon = class extends EventEmitter3 {
3831
3890
  }
3832
3891
  async start() {
3833
3892
  if (this.state.isRunning) {
3834
- console.log(chalk18.yellow("Daemon is already running."));
3893
+ console.log(chalk19.yellow("Daemon is already running."));
3835
3894
  return;
3836
3895
  }
3837
3896
  this.printWelcome();
@@ -3841,7 +3900,9 @@ var GuardianDaemon = class extends EventEmitter3 {
3841
3900
  this.interventionProtocol = createInterventionProtocol();
3842
3901
  this.guardianMonitor = createGuardianMonitor(this.config.projectId, this.config.apiUrl, this.config.apiKey);
3843
3902
  await this.guardianMonitor.loadRules();
3844
- console.log(chalk18.green(` \u2713 Loaded ${this.guardianMonitor.getRuleCount()} rules`));
3903
+ Logger.info(`Loaded ${this.guardianMonitor.getRuleCount()} rules`);
3904
+ Logger.info("Syncing Brain to IDE (.cursor/rules)...");
3905
+ await syncProjectRules(this.config.projectId, this.config.apiKey, this.config.apiUrl);
3845
3906
  await this.syncHeuristics();
3846
3907
  if (this.config.checkOnChange) {
3847
3908
  this.setupFileWatcher();
@@ -3850,100 +3911,109 @@ var GuardianDaemon = class extends EventEmitter3 {
3850
3911
  try {
3851
3912
  await this.setupBridge();
3852
3913
  } catch (e) {
3853
- console.error(chalk18.yellow(` \u26A0\uFE0F Agent Bridge connection failed: ${e.message}`));
3854
- console.log(chalk18.dim(" (Daemon will continue with local monitoring only)"));
3914
+ console.error(chalk19.yellow(` \u26A0\uFE0F Agent Bridge connection failed: ${e.message}`));
3915
+ console.log(chalk19.dim(" (Daemon will continue with local monitoring only)"));
3855
3916
  }
3856
3917
  }
3857
3918
  this.printActive();
3858
3919
  this.emit("started", this.state);
3859
3920
  }
3860
3921
  printWelcome() {
3861
- console.log(chalk18.bold.blue("\n\u{1F6E1}\uFE0F Guardian Daemon Starting..."));
3862
- console.log(chalk18.dim(`Project: ${this.config.projectId}`));
3863
- console.log(chalk18.dim(`API URL: ${this.config.apiUrl}`));
3864
- console.log(chalk18.dim(`Watch Path: ${this.config.watchPath}`));
3865
- console.log(chalk18.dim("\u2500".repeat(50)));
3922
+ console.log(chalk19.bold.blue("\n\u{1F6E1}\uFE0F Guardian Daemon Starting..."));
3923
+ console.log(chalk19.dim(`Project: ${this.config.projectId}`));
3924
+ console.log(chalk19.dim(`API URL: ${this.config.apiUrl}`));
3925
+ console.log(chalk19.dim(`Watch Path: ${this.config.watchPath}`));
3926
+ console.log(chalk19.dim("\u2500".repeat(50)));
3866
3927
  }
3867
3928
  printActive() {
3868
- console.log(chalk18.dim("\u2500".repeat(50)));
3869
- console.log(chalk18.green.bold("\u2705 Guardian Daemon is now active"));
3870
- console.log(chalk18.dim("Press Ctrl+C to stop\n"));
3929
+ console.log(chalk19.dim("\u2500".repeat(50)));
3930
+ console.log(chalk19.green.bold("\u2705 Guardian Daemon is now active"));
3931
+ console.log(chalk19.dim("Press Ctrl+C to stop\n"));
3871
3932
  }
3872
3933
  async syncHeuristics() {
3873
3934
  if (!this.heuristicEngine) return;
3874
3935
  const synced = await this.heuristicEngine.refreshRules(this.config.projectId, this.config.apiUrl, this.config.apiKey);
3875
- if (synced) console.log(chalk18.green(" \u2713 Synced heuristic rules"));
3936
+ if (synced) Logger.info("Synced heuristic rules");
3876
3937
  }
3877
3938
  setupFileWatcher() {
3878
- console.log(chalk18.dim("\u{1F4C2} Starting file watcher..."));
3939
+ Logger.info("Starting file watcher...");
3879
3940
  this.fileWatcher = createFileWatcher(this.config.watchPath);
3880
3941
  this.fileWatcher.on("change", (path25) => this.handleFileChange(path25));
3881
3942
  this.fileWatcher.start();
3882
- console.log(chalk18.green(" \u2713 File watcher active"));
3943
+ Logger.info("File watcher active");
3883
3944
  }
3884
3945
  async handleFileChange(filePath) {
3885
3946
  this.state.lastActivity = (/* @__PURE__ */ new Date()).toISOString();
3886
- if (this.config.verbose) console.log(chalk18.dim(` \u{1F4DD} File changed: ${filePath}`));
3887
- let lineCount = 0;
3947
+ if (this.config.verbose) Logger.debug(`File changed: ${filePath}`);
3948
+ const lineCount = await this.getLineCount(filePath);
3949
+ await this.runPredictiveAnalysis(filePath, lineCount);
3950
+ await this.runIntegrityCheck(filePath);
3951
+ }
3952
+ async getLineCount(filePath) {
3888
3953
  try {
3889
3954
  const content = await fs17.readFile(filePath, "utf-8");
3890
- lineCount = content.split("\n").length;
3955
+ return content.split("\n").length;
3891
3956
  } catch (e) {
3957
+ return 0;
3892
3958
  }
3893
- if (this.heuristicEngine && this.interventionProtocol && this.guardianMonitor) {
3894
- const matches = await this.heuristicEngine.analyzeFile(filePath, {
3895
- lineCount,
3896
- rules: this.guardianMonitor.getRules()
3897
- });
3898
- for (const match of matches) {
3899
- console.log(chalk18.magenta(` \u{1F4A1} PREDICTIVE ACTIVATION: ${match.skillId}`));
3900
- console.log(chalk18.dim(` Reason: ${match.reason}`));
3901
- const decision = this.interventionProtocol.evaluateTrigger(match.skillId, match.confidence);
3959
+ }
3960
+ async runPredictiveAnalysis(filePath, lineCount) {
3961
+ if (!this.heuristicEngine || !this.interventionProtocol || !this.guardianMonitor) return;
3962
+ const matches = await this.heuristicEngine.analyzeFile(filePath, {
3963
+ lineCount,
3964
+ rules: this.guardianMonitor.getRules()
3965
+ });
3966
+ for (const match of matches) {
3967
+ Logger.info(`PREDICTIVE ACTIVATION: ${match.skillId} (${match.reason})`);
3968
+ const decision = this.interventionProtocol.evaluateTrigger(match.skillId, match.confidence);
3969
+ this.interventionProtocol.enforce(decision);
3970
+ await jitProvisionSkill(match.skillId, this.config.apiUrl, this.config.apiKey, this.config.projectId, process.cwd());
3971
+ await trackSkillUsage(this.config.apiUrl, this.config.apiKey, this.config.projectId, match.skillId);
3972
+ this.emit("skill:suggestion", match);
3973
+ }
3974
+ }
3975
+ async runIntegrityCheck(filePath) {
3976
+ if (!this.guardianMonitor) return;
3977
+ if (this.interventionProtocol) this.interventionProtocol.clear(filePath);
3978
+ const result = await this.guardianMonitor.checkFile(filePath);
3979
+ this.state.filesChecked++;
3980
+ if (result.violations.length > 0) {
3981
+ this.handleViolations(filePath, result.violations);
3982
+ }
3983
+ }
3984
+ handleViolations(filePath, violations) {
3985
+ this.state.violationsFound += violations.length;
3986
+ this.emit("violation", { file: filePath, violations });
3987
+ for (const v of violations) {
3988
+ const level = v.severity === "critical" ? "error" : v.severity === "warning" ? "warn" : "info";
3989
+ Logger[level](`[${v.severity.toUpperCase()}] ${filePath}: ${v.message}`);
3990
+ if (this.interventionProtocol) {
3991
+ const decision = this.interventionProtocol.evaluateViolation(v.message, v.severity);
3902
3992
  this.interventionProtocol.enforce(decision);
3903
- await jitProvisionSkill(match.skillId, this.config.apiUrl, this.config.apiKey, this.config.projectId, process.cwd());
3904
- await trackSkillUsage(this.config.apiUrl, this.config.apiKey, this.config.projectId, match.skillId);
3905
- this.emit("skill:suggestion", match);
3906
- }
3907
- }
3908
- if (this.guardianMonitor) {
3909
- if (this.interventionProtocol) this.interventionProtocol.clear(filePath);
3910
- const result = await this.guardianMonitor.checkFile(filePath);
3911
- this.state.filesChecked++;
3912
- if (result.violations.length > 0) {
3913
- this.state.violationsFound += result.violations.length;
3914
- this.emit("violation", { file: filePath, violations: result.violations });
3915
- for (const v of result.violations) {
3916
- const color = v.severity === "critical" ? chalk18.red : v.severity === "warning" ? chalk18.yellow : chalk18.blue;
3917
- console.log(color(` [${v.severity.toUpperCase()}] ${filePath}: ${v.message}`));
3918
- if (this.interventionProtocol) {
3919
- const decision = this.interventionProtocol.evaluateViolation(v.message, v.severity);
3920
- this.interventionProtocol.enforce(decision);
3921
- this.interventionProtocol.registerViolation(filePath, decision);
3922
- }
3923
- }
3993
+ this.interventionProtocol.registerViolation(filePath, decision);
3924
3994
  }
3925
3995
  }
3926
3996
  }
3927
3997
  async setupBridge() {
3928
- console.log(chalk18.dim("\u{1F309} Connecting to Agent Bridge..."));
3998
+ console.log(chalk19.dim("\u{1F309} Connecting to Agent Bridge..."));
3929
3999
  this.bridgeListener = createBridgeListener(this.config.projectId, this.config.apiUrl, this.config.apiKey);
3930
4000
  this.bridgeListener.on("task", (task) => {
3931
4001
  this.state.lastActivity = (/* @__PURE__ */ new Date()).toISOString();
3932
4002
  this.state.tasksProcessed++;
3933
- console.log(chalk18.cyan(`
4003
+ console.log(chalk19.cyan(`
3934
4004
  \u{1F4E5} New task received: ${task.id}`));
3935
4005
  this.emit("task", task);
3936
4006
  });
3937
4007
  await this.bridgeListener.connect();
3938
- console.log(chalk18.green(" \u2713 Agent Bridge connected"));
4008
+ console.log(chalk19.green(" \u2713 Agent Bridge connected"));
3939
4009
  }
3940
4010
  async stop() {
3941
4011
  if (!this.state.isRunning) return;
3942
- console.log(chalk18.dim("\n\u{1F6D1} Stopping Guardian Daemon..."));
4012
+ console.log(chalk19.dim("\n\u{1F6D1} Stopping Guardian Daemon..."));
3943
4013
  if (this.fileWatcher) await this.fileWatcher.stop();
3944
4014
  if (this.bridgeListener) await this.bridgeListener.disconnect();
3945
4015
  this.state.isRunning = false;
3946
- console.log(chalk18.green("\u2713 Daemon stopped."));
4016
+ console.log(chalk19.green("\u2713 Daemon stopped."));
3947
4017
  this.emit("stopped", this.state);
3948
4018
  }
3949
4019
  getState() {
@@ -4006,8 +4076,8 @@ function createDaemonCommand() {
4006
4076
  const pid = parseInt(content.trim(), 10);
4007
4077
  try {
4008
4078
  process.kill(pid, 0);
4009
- console.log(chalk19.yellow("\u26A0 Another daemon instance is active (PID " + pid + ")."));
4010
- console.log(chalk19.dim(` Run "rigstate daemon status" for details or Ctrl+C to stop.
4079
+ console.log(chalk20.yellow("\u26A0 Another daemon instance is active (PID " + pid + ")."));
4080
+ console.log(chalk20.dim(` Run "rigstate daemon status" for details or Ctrl+C to stop.
4011
4081
  `));
4012
4082
  } catch {
4013
4083
  await fs18.unlink(pidPath).catch(() => {
@@ -4025,7 +4095,7 @@ function createDaemonCommand() {
4025
4095
  spinner.stop();
4026
4096
  await writePidFile();
4027
4097
  process.on("SIGINT", async () => {
4028
- console.log(chalk19.dim("\n\nShutting down..."));
4098
+ console.log(chalk20.dim("\n\nShutting down..."));
4029
4099
  await daemonInstance.stop();
4030
4100
  await cleanupPidFile();
4031
4101
  process.exit(0);
@@ -4045,8 +4115,8 @@ function createDaemonCommand() {
4045
4115
  await new Promise(() => {
4046
4116
  });
4047
4117
  } catch (error) {
4048
- spinner.fail(chalk19.red("Failed to start daemon"));
4049
- console.error(chalk19.red("Error:"), error.message);
4118
+ spinner.fail(chalk20.red("Failed to start daemon"));
4119
+ console.error(chalk20.red("Error:"), error.message);
4050
4120
  process.exit(1);
4051
4121
  }
4052
4122
  });
@@ -4095,46 +4165,46 @@ async function writeStateFile(state) {
4095
4165
  }
4096
4166
  }
4097
4167
  async function showStatus() {
4098
- console.log(chalk19.bold("\n\u{1F6E1}\uFE0F Guardian Daemon Status\n"));
4168
+ console.log(chalk20.bold("\n\u{1F6E1}\uFE0F Guardian Daemon Status\n"));
4099
4169
  const running = await isRunning();
4100
4170
  if (!running) {
4101
- console.log(chalk19.yellow("Status: Not running"));
4102
- console.log(chalk19.dim('Use "rigstate daemon" to start.\n'));
4171
+ console.log(chalk20.yellow("Status: Not running"));
4172
+ console.log(chalk20.dim('Use "rigstate daemon" to start.\n'));
4103
4173
  return;
4104
4174
  }
4105
- console.log(chalk19.green("Status: Running"));
4175
+ console.log(chalk20.green("Status: Running"));
4106
4176
  try {
4107
4177
  const statePath = path20.join(process.cwd(), STATE_FILE);
4108
4178
  const content = await fs18.readFile(statePath, "utf-8");
4109
4179
  const state = JSON.parse(content);
4110
- console.log(chalk19.dim("\u2500".repeat(40)));
4180
+ console.log(chalk20.dim("\u2500".repeat(40)));
4111
4181
  console.log(`Started at: ${state.startedAt || "Unknown"}`);
4112
4182
  console.log(`Files checked: ${state.filesChecked || 0}`);
4113
4183
  console.log(`Violations: ${state.violationsFound || 0}`);
4114
4184
  console.log(`Tasks processed: ${state.tasksProcessed || 0}`);
4115
4185
  console.log(`Last activity: ${state.lastActivity || "None"}`);
4116
- console.log(chalk19.dim("\u2500".repeat(40)));
4186
+ console.log(chalk20.dim("\u2500".repeat(40)));
4117
4187
  } catch {
4118
- console.log(chalk19.dim("(State file not found)"));
4188
+ console.log(chalk20.dim("(State file not found)"));
4119
4189
  }
4120
4190
  try {
4121
4191
  const pidPath = path20.join(process.cwd(), PID_FILE);
4122
4192
  const pid = await fs18.readFile(pidPath, "utf-8");
4123
- console.log(chalk19.dim(`PID: ${pid.trim()}`));
4193
+ console.log(chalk20.dim(`PID: ${pid.trim()}`));
4124
4194
  } catch {
4125
4195
  }
4126
4196
  console.log("");
4127
4197
  }
4128
4198
  async function enableDaemon() {
4129
- console.log(chalk19.bold("\n\u2699\uFE0F Enabling Rigstate Background Service (macOS)\n"));
4199
+ console.log(chalk20.bold("\n\u2699\uFE0F Enabling Rigstate Background Service (macOS)\n"));
4130
4200
  if (process.platform !== "darwin") {
4131
- console.error(chalk19.red("\u274C Currently only macOS is supported for auto-start."));
4132
- console.error(chalk19.yellow("PRs welcome for Linux/Windows support!"));
4201
+ console.error(chalk20.red("\u274C Currently only macOS is supported for auto-start."));
4202
+ console.error(chalk20.yellow("PRs welcome for Linux/Windows support!"));
4133
4203
  return;
4134
4204
  }
4135
4205
  const homeDir = process.env.HOME || "";
4136
4206
  if (!homeDir) {
4137
- console.error(chalk19.red("\u274C Could not determine HOME directory."));
4207
+ console.error(chalk20.red("\u274C Could not determine HOME directory."));
4138
4208
  return;
4139
4209
  }
4140
4210
  const agentsDir = path20.join(homeDir, "Library/LaunchAgents");
@@ -4176,32 +4246,32 @@ async function enableDaemon() {
4176
4246
  </plist>`;
4177
4247
  try {
4178
4248
  await fs18.writeFile(plistPath, plistContent);
4179
- console.log(chalk19.dim(`Created plist at: ${plistPath}`));
4249
+ console.log(chalk20.dim(`Created plist at: ${plistPath}`));
4180
4250
  try {
4181
4251
  await execShellCommand(`launchctl unload ${plistPath}`);
4182
4252
  } catch (e) {
4183
4253
  }
4184
4254
  await execShellCommand(`launchctl load ${plistPath}`);
4185
- console.log(chalk19.green("\u2705 Successfully enabled background daemon!"));
4186
- console.log(chalk19.dim(`Logs: ${logDir}`));
4187
- console.log(chalk19.dim("The daemon will now restart automatically if it crashes or on reboot."));
4255
+ console.log(chalk20.green("\u2705 Successfully enabled background daemon!"));
4256
+ console.log(chalk20.dim(`Logs: ${logDir}`));
4257
+ console.log(chalk20.dim("The daemon will now restart automatically if it crashes or on reboot."));
4188
4258
  } catch (error) {
4189
- console.error(chalk19.red("\u274C Failed to enable daemon:"), error.message);
4259
+ console.error(chalk20.red("\u274C Failed to enable daemon:"), error.message);
4190
4260
  }
4191
4261
  }
4192
4262
  async function disableDaemon() {
4193
- console.log(chalk19.bold("\n\u2699\uFE0F Disabling Rigstate Background Service\n"));
4263
+ console.log(chalk20.bold("\n\u2699\uFE0F Disabling Rigstate Background Service\n"));
4194
4264
  const homeDir = process.env.HOME || "";
4195
4265
  const plistPath = path20.join(homeDir, "Library/LaunchAgents/com.rigstate.daemon.plist");
4196
4266
  try {
4197
4267
  await execShellCommand(`launchctl unload ${plistPath}`);
4198
4268
  await fs18.unlink(plistPath);
4199
- console.log(chalk19.green("\u2705 Successfully disabled background daemon."));
4269
+ console.log(chalk20.green("\u2705 Successfully disabled background daemon."));
4200
4270
  } catch (error) {
4201
4271
  if (error.code === "ENOENT") {
4202
- console.log(chalk19.green("\u2705 Daemon was not enabled."));
4272
+ console.log(chalk20.green("\u2705 Daemon was not enabled."));
4203
4273
  } else {
4204
- console.error(chalk19.red("\u274C Failed to disable daemon:"), error.message);
4274
+ console.error(chalk20.red("\u274C Failed to disable daemon:"), error.message);
4205
4275
  }
4206
4276
  }
4207
4277
  }
@@ -4219,7 +4289,7 @@ init_esm_shims();
4219
4289
  init_config();
4220
4290
  init_suggest();
4221
4291
  import { Command as Command12 } from "commander";
4222
- import chalk20 from "chalk";
4292
+ import chalk21 from "chalk";
4223
4293
  import ora9 from "ora";
4224
4294
  import axios15 from "axios";
4225
4295
  import inquirer2 from "inquirer";
@@ -4254,7 +4324,7 @@ async function listInteractive() {
4254
4324
  });
4255
4325
  spinner.stop();
4256
4326
  if (actionableTasks.length === 0) {
4257
- console.log(chalk20.yellow("Roadmap clear. No actionable tasks found."));
4327
+ console.log(chalk21.yellow("Roadmap clear. No actionable tasks found."));
4258
4328
  return;
4259
4329
  }
4260
4330
  const choices = actionableTasks.map((t) => {
@@ -4263,7 +4333,7 @@ async function listInteractive() {
4263
4333
  if (t.status === "IN_PROGRESS") icon = "\u{1F525}";
4264
4334
  if (t.status === "ACTIVE") icon = "\u25B6\uFE0F";
4265
4335
  return {
4266
- name: `${icon} ${chalk20.bold(id)}: ${t.title} [${t.status}]`,
4336
+ name: `${icon} ${chalk21.bold(id)}: ${t.title} [${t.status}]`,
4267
4337
  value: t.id
4268
4338
  };
4269
4339
  });
@@ -4306,25 +4376,25 @@ async function setTaskStatus(taskId, status) {
4306
4376
  { step_id: realId, status, project_id: projectId },
4307
4377
  { headers: { "Authorization": `Bearer ${apiKey}` } }
4308
4378
  );
4309
- spinner.succeed(chalk20.green(`Task updated to ${status}.`));
4379
+ spinner.succeed(chalk21.green(`Task updated to ${status}.`));
4310
4380
  if (status === "IN_PROGRESS") {
4311
- console.log(chalk20.blue(`
4381
+ console.log(chalk21.blue(`
4312
4382
  \u{1F4A1} Tip: Provide 'Frank' with context by mentioning @.cursorrules in your chat.`));
4313
4383
  }
4314
4384
  } catch (e) {
4315
- spinner.fail(chalk20.red(`Failed: ${e.message}`));
4385
+ spinner.fail(chalk21.red(`Failed: ${e.message}`));
4316
4386
  }
4317
4387
  }
4318
4388
  async function finishTask(taskId) {
4319
4389
  console.log("");
4320
- console.log(chalk20.bold.yellow("\u{1F6E1}\uFE0F FRANK'S QUALITY GATE"));
4321
- console.log(chalk20.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
4390
+ console.log(chalk21.bold.yellow("\u{1F6E1}\uFE0F FRANK'S QUALITY GATE"));
4391
+ console.log(chalk21.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
4322
4392
  const auditSpinner = ora9(" Analyzing architectural integrity...").start();
4323
4393
  await new Promise((r) => setTimeout(r, 1500));
4324
4394
  auditSpinner.succeed("Architecture: VALIDATED (SEC-ARCH-01 Pass)");
4325
4395
  await setTaskStatus(taskId, "COMPLETED");
4326
4396
  console.log("");
4327
- console.log(chalk20.bold.green("\u{1F389} TASK COMPLETE! Momentum Preserved."));
4397
+ console.log(chalk21.bold.green("\u{1F389} TASK COMPLETE! Momentum Preserved."));
4328
4398
  const { projectId, apiKey, apiUrl } = getContext();
4329
4399
  await suggestNextMove(projectId, apiKey, apiUrl);
4330
4400
  }
@@ -4342,7 +4412,7 @@ function getContext() {
4342
4412
  init_esm_shims();
4343
4413
  init_config();
4344
4414
  import { Command as Command13 } from "commander";
4345
- import chalk21 from "chalk";
4415
+ import chalk22 from "chalk";
4346
4416
  import ora10 from "ora";
4347
4417
  import chokidar2 from "chokidar";
4348
4418
  import fs19 from "fs/promises";
@@ -4352,15 +4422,15 @@ import axios16 from "axios";
4352
4422
  function createWatchCommand() {
4353
4423
  const watch2 = new Command13("watch");
4354
4424
  watch2.description("Watch for changes and auto-verify roadmap tasks").option("--no-auto-commit", "Disable auto-commit on verification").option("--no-auto-push", "Disable auto-push after commit").option("--run-tests", "Run tests before committing").option("--test-command <cmd>", "Custom test command (default: npm test)").action(async (options) => {
4355
- console.log(chalk21.bold.blue("\u{1F52D} Rigstate Watch Mode"));
4356
- console.log(chalk21.dim("Monitoring for task completion..."));
4425
+ console.log(chalk22.bold.blue("\u{1F52D} Rigstate Watch Mode"));
4426
+ console.log(chalk22.dim("Monitoring for task completion..."));
4357
4427
  console.log("");
4358
4428
  let apiKey;
4359
4429
  let projectId;
4360
4430
  try {
4361
4431
  apiKey = getApiKey();
4362
4432
  } catch (e) {
4363
- console.log(chalk21.red('Not authenticated. Run "rigstate login" first.'));
4433
+ console.log(chalk22.red('Not authenticated. Run "rigstate login" first.'));
4364
4434
  return;
4365
4435
  }
4366
4436
  projectId = getProjectId();
@@ -4374,7 +4444,7 @@ function createWatchCommand() {
4374
4444
  }
4375
4445
  }
4376
4446
  if (!projectId) {
4377
- console.log(chalk21.red('No project context. Run "rigstate link" or "rigstate sync --project <id>" first.'));
4447
+ console.log(chalk22.red('No project context. Run "rigstate link" or "rigstate sync --project <id>" first.'));
4378
4448
  return;
4379
4449
  }
4380
4450
  const apiUrl = getApiUrl();
@@ -4384,8 +4454,8 @@ function createWatchCommand() {
4384
4454
  runTests: options.runTests || false,
4385
4455
  testCommand: options.testCommand || "npm test"
4386
4456
  };
4387
- console.log(chalk21.dim(`Auto-commit: ${config2.autoCommit ? "ON" : "OFF"}`));
4388
- console.log(chalk21.dim(`Auto-push: ${config2.autoPush ? "ON" : "OFF"}`));
4457
+ console.log(chalk22.dim(`Auto-commit: ${config2.autoCommit ? "ON" : "OFF"}`));
4458
+ console.log(chalk22.dim(`Auto-push: ${config2.autoPush ? "ON" : "OFF"}`));
4389
4459
  console.log("");
4390
4460
  const fetchActiveTask = async () => {
4391
4461
  try {
@@ -4452,7 +4522,7 @@ function createWatchCommand() {
4452
4522
  }, {
4453
4523
  headers: { Authorization: `Bearer ${apiKey}` }
4454
4524
  });
4455
- spinner.succeed(chalk21.green(`\u2705 Task #${task.step_number} completed: ${task.title}`));
4525
+ spinner.succeed(chalk22.green(`\u2705 Task #${task.step_number} completed: ${task.title}`));
4456
4526
  if (config2.autoCommit) {
4457
4527
  spinner.start("Committing changes...");
4458
4528
  try {
@@ -4474,7 +4544,7 @@ function createWatchCommand() {
4474
4544
  }
4475
4545
  }
4476
4546
  console.log("");
4477
- console.log(chalk21.blue("Watching for next task..."));
4547
+ console.log(chalk22.blue("Watching for next task..."));
4478
4548
  } catch (e) {
4479
4549
  spinner.fail(`Failed to complete task: ${e.message}`);
4480
4550
  }
@@ -4487,7 +4557,7 @@ function createWatchCommand() {
4487
4557
  const task = await fetchActiveTask();
4488
4558
  if (!task) {
4489
4559
  if (currentTask) {
4490
- console.log(chalk21.green("\u{1F389} All tasks completed! Watching for new tasks..."));
4560
+ console.log(chalk22.green("\u{1F389} All tasks completed! Watching for new tasks..."));
4491
4561
  currentTask = null;
4492
4562
  }
4493
4563
  isProcessing = false;
@@ -4496,10 +4566,10 @@ function createWatchCommand() {
4496
4566
  if (!currentTask || currentTask.id !== task.id) {
4497
4567
  currentTask = task;
4498
4568
  console.log("");
4499
- console.log(chalk21.bold.yellow(`\u{1F4CC} Active Task #${task.step_number}: ${task.title}`));
4500
- console.log(chalk21.dim(`Status: ${task.status}`));
4569
+ console.log(chalk22.bold.yellow(`\u{1F4CC} Active Task #${task.step_number}: ${task.title}`));
4570
+ console.log(chalk22.dim(`Status: ${task.status}`));
4501
4571
  if (task.verification_criteria) {
4502
- console.log(chalk21.dim("Verification: Auto-checking criteria..."));
4572
+ console.log(chalk22.dim("Verification: Auto-checking criteria..."));
4503
4573
  }
4504
4574
  }
4505
4575
  if (task.verification_criteria && Array.isArray(task.verification_criteria)) {
@@ -4512,7 +4582,7 @@ function createWatchCommand() {
4512
4582
  }
4513
4583
  }
4514
4584
  if (allPassed) {
4515
- console.log(chalk21.green("\u2713 All verification criteria passed!"));
4585
+ console.log(chalk22.green("\u2713 All verification criteria passed!"));
4516
4586
  await completeTask(task.id, task);
4517
4587
  currentTask = null;
4518
4588
  }
@@ -4537,11 +4607,11 @@ function createWatchCommand() {
4537
4607
  setTimeout(() => processActiveTask(), 500);
4538
4608
  }
4539
4609
  });
4540
- console.log(chalk21.dim("Watching for file changes... (Ctrl+C to exit)"));
4610
+ console.log(chalk22.dim("Watching for file changes... (Ctrl+C to exit)"));
4541
4611
  setInterval(() => processActiveTask(), 3e4);
4542
4612
  process.on("SIGINT", () => {
4543
4613
  console.log("");
4544
- console.log(chalk21.dim("Watch mode stopped."));
4614
+ console.log(chalk22.dim("Watch mode stopped."));
4545
4615
  watcher.close();
4546
4616
  process.exit(0);
4547
4617
  });
@@ -4553,7 +4623,7 @@ function createWatchCommand() {
4553
4623
  init_esm_shims();
4554
4624
  init_config();
4555
4625
  import { Command as Command14 } from "commander";
4556
- import chalk22 from "chalk";
4626
+ import chalk23 from "chalk";
4557
4627
  import ora11 from "ora";
4558
4628
  import axios17 from "axios";
4559
4629
  import { execSync as execSync5 } from "child_process";
@@ -4568,7 +4638,7 @@ function createFocusCommand() {
4568
4638
  try {
4569
4639
  apiKey = getApiKey();
4570
4640
  } catch (e) {
4571
- spinner.fail(chalk22.red('Not authenticated. Run "rigstate login" first.'));
4641
+ spinner.fail(chalk23.red('Not authenticated. Run "rigstate login" first.'));
4572
4642
  return;
4573
4643
  }
4574
4644
  projectId = getProjectId();
@@ -4582,7 +4652,7 @@ function createFocusCommand() {
4582
4652
  }
4583
4653
  }
4584
4654
  if (!projectId) {
4585
- spinner.fail(chalk22.red('No project context. Run "rigstate link" first.'));
4655
+ spinner.fail(chalk23.red('No project context. Run "rigstate link" first.'));
4586
4656
  return;
4587
4657
  }
4588
4658
  const apiUrl = getApiUrl();
@@ -4613,41 +4683,41 @@ function createFocusCommand() {
4613
4683
  const nextTask = activeTasks[0];
4614
4684
  spinner.stop();
4615
4685
  console.log("");
4616
- console.log(chalk22.bold.blue(`\u{1F4CC} Task #${nextTask.step_number || "?"}: ${nextTask.title}`));
4617
- const statusColor = nextTask.status === "IN_PROGRESS" ? chalk22.yellow : nextTask.status === "ACTIVE" ? chalk22.green : chalk22.dim;
4618
- console.log(chalk22.dim("Status: ") + statusColor(nextTask.status));
4619
- console.log(chalk22.dim("\u2500".repeat(60)));
4686
+ console.log(chalk23.bold.blue(`\u{1F4CC} Task #${nextTask.step_number || "?"}: ${nextTask.title}`));
4687
+ const statusColor = nextTask.status === "IN_PROGRESS" ? chalk23.yellow : nextTask.status === "ACTIVE" ? chalk23.green : chalk23.dim;
4688
+ console.log(chalk23.dim("Status: ") + statusColor(nextTask.status));
4689
+ console.log(chalk23.dim("\u2500".repeat(60)));
4620
4690
  if (nextTask.prompt_content) {
4621
- console.log(chalk22.white(nextTask.prompt_content));
4622
- console.log(chalk22.dim("\u2500".repeat(60)));
4691
+ console.log(chalk23.white(nextTask.prompt_content));
4692
+ console.log(chalk23.dim("\u2500".repeat(60)));
4623
4693
  if (options.copy !== false) {
4624
4694
  try {
4625
4695
  if (process.platform === "darwin") {
4626
4696
  execSync5("pbcopy", { input: nextTask.prompt_content });
4627
- console.log(chalk22.green("\u2705 Prompt copied to clipboard! Ready to paste (Cmd+V)."));
4697
+ console.log(chalk23.green("\u2705 Prompt copied to clipboard! Ready to paste (Cmd+V)."));
4628
4698
  } else if (process.platform === "linux") {
4629
4699
  try {
4630
4700
  execSync5("xclip -selection clipboard", { input: nextTask.prompt_content });
4631
- console.log(chalk22.green("\u2705 Prompt copied to clipboard!"));
4701
+ console.log(chalk23.green("\u2705 Prompt copied to clipboard!"));
4632
4702
  } catch (e) {
4633
- console.log(chalk22.yellow("\u2139\uFE0F Copy prompt manually (xclip not available)"));
4703
+ console.log(chalk23.yellow("\u2139\uFE0F Copy prompt manually (xclip not available)"));
4634
4704
  }
4635
4705
  } else {
4636
- console.log(chalk22.yellow("\u2139\uFE0F Copy prompt manually (Auto-copy not supported on this OS)"));
4706
+ console.log(chalk23.yellow("\u2139\uFE0F Copy prompt manually (Auto-copy not supported on this OS)"));
4637
4707
  }
4638
4708
  } catch (e) {
4639
4709
  }
4640
4710
  }
4641
4711
  } else {
4642
- console.log(chalk22.yellow("No prompt instructions available."));
4712
+ console.log(chalk23.yellow("No prompt instructions available."));
4643
4713
  if (nextTask.architectural_brief) {
4644
- console.log(chalk22.bold("Brief:"));
4714
+ console.log(chalk23.bold("Brief:"));
4645
4715
  console.log(nextTask.architectural_brief);
4646
4716
  }
4647
4717
  }
4648
4718
  console.log("");
4649
4719
  } catch (e) {
4650
- spinner.fail(chalk22.red(`Failed to fetch task: ${e.message}`));
4720
+ spinner.fail(chalk23.red(`Failed to fetch task: ${e.message}`));
4651
4721
  }
4652
4722
  });
4653
4723
  return focus;
@@ -4660,25 +4730,25 @@ init_env();
4660
4730
  init_esm_shims();
4661
4731
  init_config();
4662
4732
  import { Command as Command15 } from "commander";
4663
- import chalk23 from "chalk";
4733
+ import chalk24 from "chalk";
4664
4734
  function createConfigCommand() {
4665
4735
  const config2 = new Command15("config");
4666
4736
  config2.description("View or modify Rigstate configuration").argument("[key]", "Configuration key to view/set (api_key, project_id, api_url)").argument("[value]", "Value to set").action(async (key, value) => {
4667
4737
  if (!key) {
4668
- console.log(chalk23.bold("Rigstate Configuration"));
4669
- console.log(chalk23.dim("\u2500".repeat(40)));
4738
+ console.log(chalk24.bold("Rigstate Configuration"));
4739
+ console.log(chalk24.dim("\u2500".repeat(40)));
4670
4740
  try {
4671
4741
  const apiKey = getApiKey();
4672
- console.log(`${chalk23.cyan("api_key")}: ${apiKey.substring(0, 20)}...`);
4742
+ console.log(`${chalk24.cyan("api_key")}: ${apiKey.substring(0, 20)}...`);
4673
4743
  } catch (e) {
4674
- console.log(`${chalk23.cyan("api_key")}: ${chalk23.dim("(not set)")}`);
4744
+ console.log(`${chalk24.cyan("api_key")}: ${chalk24.dim("(not set)")}`);
4675
4745
  }
4676
4746
  const projectId = getProjectId();
4677
- console.log(`${chalk23.cyan("project_id")}: ${projectId || chalk23.dim("(not set)")}`);
4747
+ console.log(`${chalk24.cyan("project_id")}: ${projectId || chalk24.dim("(not set)")}`);
4678
4748
  const apiUrl = getApiUrl();
4679
- console.log(`${chalk23.cyan("api_url")}: ${apiUrl}`);
4749
+ console.log(`${chalk24.cyan("api_url")}: ${apiUrl}`);
4680
4750
  console.log("");
4681
- console.log(chalk23.dim('Use "rigstate config <key> <value>" to set a value.'));
4751
+ console.log(chalk24.dim('Use "rigstate config <key> <value>" to set a value.'));
4682
4752
  return;
4683
4753
  }
4684
4754
  if (!value) {
@@ -4688,37 +4758,37 @@ function createConfigCommand() {
4688
4758
  const apiKey = getApiKey();
4689
4759
  console.log(apiKey);
4690
4760
  } catch (e) {
4691
- console.log(chalk23.dim("(not set)"));
4761
+ console.log(chalk24.dim("(not set)"));
4692
4762
  }
4693
4763
  break;
4694
4764
  case "project_id":
4695
- console.log(getProjectId() || chalk23.dim("(not set)"));
4765
+ console.log(getProjectId() || chalk24.dim("(not set)"));
4696
4766
  break;
4697
4767
  case "api_url":
4698
4768
  console.log(getApiUrl());
4699
4769
  break;
4700
4770
  default:
4701
- console.log(chalk23.red(`Unknown config key: ${key}`));
4702
- console.log(chalk23.dim("Valid keys: api_key, project_id, api_url"));
4771
+ console.log(chalk24.red(`Unknown config key: ${key}`));
4772
+ console.log(chalk24.dim("Valid keys: api_key, project_id, api_url"));
4703
4773
  }
4704
4774
  return;
4705
4775
  }
4706
4776
  switch (key) {
4707
4777
  case "api_key":
4708
4778
  setApiKey(value);
4709
- console.log(chalk23.green(`\u2705 api_key updated`));
4779
+ console.log(chalk24.green(`\u2705 api_key updated`));
4710
4780
  break;
4711
4781
  case "project_id":
4712
4782
  setProjectId(value);
4713
- console.log(chalk23.green(`\u2705 project_id updated`));
4783
+ console.log(chalk24.green(`\u2705 project_id updated`));
4714
4784
  break;
4715
4785
  case "api_url":
4716
4786
  setApiUrl(value);
4717
- console.log(chalk23.green(`\u2705 api_url updated`));
4787
+ console.log(chalk24.green(`\u2705 api_url updated`));
4718
4788
  break;
4719
4789
  default:
4720
- console.log(chalk23.red(`Unknown config key: ${key}`));
4721
- console.log(chalk23.dim("Valid keys: api_key, project_id, api_url"));
4790
+ console.log(chalk24.red(`Unknown config key: ${key}`));
4791
+ console.log(chalk24.dim("Valid keys: api_key, project_id, api_url"));
4722
4792
  }
4723
4793
  });
4724
4794
  return config2;
@@ -4727,7 +4797,7 @@ function createConfigCommand() {
4727
4797
  // src/commands/mcp.ts
4728
4798
  init_esm_shims();
4729
4799
  import { Command as Command16 } from "commander";
4730
- import chalk24 from "chalk";
4800
+ import chalk25 from "chalk";
4731
4801
  import { spawn } from "child_process";
4732
4802
  import path23 from "path";
4733
4803
  import fs21 from "fs";
@@ -4753,15 +4823,15 @@ function createMcpCommand() {
4753
4823
  }
4754
4824
  }
4755
4825
  if (!serverPath) {
4756
- console.error(chalk24.red("\u274C Error: Rigstate MCP Server binary not found."));
4757
- console.error(chalk24.yellow("Please ensure that the mcp package is built:"));
4758
- console.error(chalk24.white(" cd packages/mcp && npm run build"));
4826
+ console.error(chalk25.red("\u274C Error: Rigstate MCP Server binary not found."));
4827
+ console.error(chalk25.yellow("Please ensure that the mcp package is built:"));
4828
+ console.error(chalk25.white(" cd packages/mcp && npm run build"));
4759
4829
  console.error("");
4760
- console.error(chalk24.dim("Or run directly with:"));
4761
- console.error(chalk24.white(" npx @rigstate/mcp"));
4830
+ console.error(chalk25.dim("Or run directly with:"));
4831
+ console.error(chalk25.white(" npx @rigstate/mcp"));
4762
4832
  process.exit(1);
4763
4833
  }
4764
- console.log(chalk24.dim(`Starting MCP server from: ${serverPath}`));
4834
+ console.log(chalk25.dim(`Starting MCP server from: ${serverPath}`));
4765
4835
  if (process.env.VIBE_API_KEY && !process.env.RIGSTATE_API_KEY) {
4766
4836
  process.env.RIGSTATE_API_KEY = process.env.VIBE_API_KEY;
4767
4837
  }
@@ -4770,7 +4840,7 @@ function createMcpCommand() {
4770
4840
  stdio: ["inherit", "inherit", "inherit"]
4771
4841
  });
4772
4842
  worker.on("error", (err) => {
4773
- console.error(chalk24.red(`\u274C Failed to start MCP server: ${err.message}`));
4843
+ console.error(chalk25.red(`\u274C Failed to start MCP server: ${err.message}`));
4774
4844
  process.exit(1);
4775
4845
  });
4776
4846
  worker.on("exit", (code) => {
@@ -4853,7 +4923,7 @@ var HiveScrubber = class {
4853
4923
  };
4854
4924
 
4855
4925
  // src/hive/gateway.ts
4856
- import chalk25 from "chalk";
4926
+ import chalk26 from "chalk";
4857
4927
  var HiveGateway = class {
4858
4928
  client;
4859
4929
  enabled;
@@ -4863,7 +4933,7 @@ var HiveGateway = class {
4863
4933
  constructor(baseUrl, token) {
4864
4934
  this.enabled = !!token;
4865
4935
  if (!this.enabled) {
4866
- console.log(chalk25.dim("\u26A0\uFE0F Hive Gateway disabled (No Token provided). Running in localized mode."));
4936
+ console.log(chalk26.dim("\u26A0\uFE0F Hive Gateway disabled (No Token provided). Running in localized mode."));
4867
4937
  }
4868
4938
  this.client = axios18.create({
4869
4939
  baseURL: baseUrl,
@@ -4883,84 +4953,28 @@ var HiveGateway = class {
4883
4953
  if (!this.enabled) return false;
4884
4954
  const now = Date.now();
4885
4955
  if (now - this.lastSignalTime < this.MIN_INTERVAL_MS) {
4886
- console.warn(chalk25.yellow("\u23F3 Hive Gateway Throttled. Signal dropped to preventing spam."));
4956
+ console.warn(chalk26.yellow("\u23F3 Hive Gateway Throttled. Signal dropped to preventing spam."));
4887
4957
  return false;
4888
4958
  }
4889
4959
  const scrubResult = HiveScrubber.scrub(signal.ruleContent);
4890
4960
  if (scrubResult.riskScore > 20) {
4891
- console.error(chalk25.red(`\u{1F6D1} HIVE BLOCKED: Signal contains sensitive data (Risk: ${scrubResult.riskScore})`));
4961
+ console.error(chalk26.red(`\u{1F6D1} HIVE BLOCKED: Signal contains sensitive data (Risk: ${scrubResult.riskScore})`));
4892
4962
  return false;
4893
4963
  }
4894
4964
  try {
4895
- console.log(chalk25.blue(`\u{1F4E1} Uplinking to Hive... [${signal.vector}]`));
4965
+ console.log(chalk26.blue(`\u{1F4E1} Uplinking to Hive... [${signal.vector}]`));
4896
4966
  const payload = { ...signal, ruleContent: scrubResult.sanitizedContent };
4897
4967
  await this.client.post("/signal", payload);
4898
4968
  this.lastSignalTime = now;
4899
- console.log(chalk25.green("\u2705 Signal Received by Hive Core. Knowledge Shared."));
4969
+ console.log(chalk26.green("\u2705 Signal Received by Hive Core. Knowledge Shared."));
4900
4970
  return true;
4901
4971
  } catch (error) {
4902
- console.error(chalk25.red(`\u274C Hive Transmission Failed: ${error.message}`));
4972
+ console.error(chalk26.red(`\u274C Hive Transmission Failed: ${error.message}`));
4903
4973
  return false;
4904
4974
  }
4905
4975
  }
4906
4976
  };
4907
4977
 
4908
- // src/utils/logger.ts
4909
- init_esm_shims();
4910
- import chalk26 from "chalk";
4911
- var Logger = class {
4912
- static formatMessage(level, message, context) {
4913
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
4914
- let prefix = "";
4915
- switch (level) {
4916
- case "INFO" /* INFO */:
4917
- prefix = chalk26.blue(`[${"INFO" /* INFO */}]`);
4918
- break;
4919
- case "WARN" /* WARN */:
4920
- prefix = chalk26.yellow(`[${"WARN" /* WARN */}]`);
4921
- break;
4922
- case "ERROR" /* ERROR */:
4923
- prefix = chalk26.red(`[${"ERROR" /* ERROR */}]`);
4924
- break;
4925
- case "DEBUG" /* DEBUG */:
4926
- prefix = chalk26.gray(`[${"DEBUG" /* DEBUG */}]`);
4927
- break;
4928
- }
4929
- let output = `${chalk26.gray(timestamp)} ${prefix} ${message}`;
4930
- if (context) {
4931
- if (context instanceof Error) {
4932
- output += `
4933
- ${chalk26.red(context.stack || context.message)}`;
4934
- } else if (typeof context === "object") {
4935
- try {
4936
- output += `
4937
- ${chalk26.gray(JSON.stringify(context, null, 2))}`;
4938
- } catch (e) {
4939
- output += `
4940
- ${chalk26.gray("[Circular or invalid object]")}`;
4941
- }
4942
- } else {
4943
- output += ` ${String(context)}`;
4944
- }
4945
- }
4946
- return output;
4947
- }
4948
- static info(message, context) {
4949
- console.log(this.formatMessage("INFO" /* INFO */, message, context));
4950
- }
4951
- static warn(message, context) {
4952
- console.warn(this.formatMessage("WARN" /* WARN */, message, context));
4953
- }
4954
- static error(message, error) {
4955
- console.error(this.formatMessage("ERROR" /* ERROR */, message, error));
4956
- }
4957
- static debug(message, context) {
4958
- if (process.env.DEBUG || process.env.RIGSTATE_DEBUG) {
4959
- console.debug(this.formatMessage("DEBUG" /* DEBUG */, message, context));
4960
- }
4961
- }
4962
- };
4963
-
4964
4978
  // src/nexus/dispatcher.ts
4965
4979
  var NexusDispatcher = class extends EventEmitter4 {
4966
4980
  context;