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