@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/.rigstate/daemon.state.json +3 -3
- package/.rigstate/rules-cache.json +1 -1
- package/dist/index.cjs +223 -212
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +223 -212
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/daemon/core.ts +64 -45
package/dist/index.cjs
CHANGED
|
@@ -1757,7 +1757,7 @@ var require_package = __commonJS({
|
|
|
1757
1757
|
"package.json"(exports2, module2) {
|
|
1758
1758
|
module2.exports = {
|
|
1759
1759
|
name: "@rigstate/cli",
|
|
1760
|
-
version: "0.7.
|
|
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_cjs_shims();
|
|
3237
3237
|
var import_commander11 = require("commander");
|
|
3238
|
-
var
|
|
3238
|
+
var import_chalk20 = __toESM(require("chalk"), 1);
|
|
3239
3239
|
var import_ora8 = __toESM(require("ora"), 1);
|
|
3240
3240
|
var import_promises17 = __toESM(require("fs/promises"), 1);
|
|
3241
3241
|
var import_path19 = __toESM(require("path"), 1);
|
|
@@ -3247,7 +3247,7 @@ init_cjs_shims();
|
|
|
3247
3247
|
|
|
3248
3248
|
// src/daemon/core.ts
|
|
3249
3249
|
init_cjs_shims();
|
|
3250
|
-
var
|
|
3250
|
+
var import_chalk19 = __toESM(require("chalk"), 1);
|
|
3251
3251
|
var fs17 = __toESM(require("fs/promises"), 1);
|
|
3252
3252
|
var import_events3 = require("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_cjs_shims();
|
|
3816
|
+
var import_chalk18 = __toESM(require("chalk"), 1);
|
|
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 = import_chalk18.default.blue(`[${"INFO" /* INFO */}]`);
|
|
3824
|
+
break;
|
|
3825
|
+
case "WARN" /* WARN */:
|
|
3826
|
+
prefix = import_chalk18.default.yellow(`[${"WARN" /* WARN */}]`);
|
|
3827
|
+
break;
|
|
3828
|
+
case "ERROR" /* ERROR */:
|
|
3829
|
+
prefix = import_chalk18.default.red(`[${"ERROR" /* ERROR */}]`);
|
|
3830
|
+
break;
|
|
3831
|
+
case "DEBUG" /* DEBUG */:
|
|
3832
|
+
prefix = import_chalk18.default.gray(`[${"DEBUG" /* DEBUG */}]`);
|
|
3833
|
+
break;
|
|
3834
|
+
}
|
|
3835
|
+
let output = `${import_chalk18.default.gray(timestamp)} ${prefix} ${message}`;
|
|
3836
|
+
if (context) {
|
|
3837
|
+
if (context instanceof Error) {
|
|
3838
|
+
output += `
|
|
3839
|
+
${import_chalk18.default.red(context.stack || context.message)}`;
|
|
3840
|
+
} else if (typeof context === "object") {
|
|
3841
|
+
try {
|
|
3842
|
+
output += `
|
|
3843
|
+
${import_chalk18.default.gray(JSON.stringify(context, null, 2))}`;
|
|
3844
|
+
} catch (e) {
|
|
3845
|
+
output += `
|
|
3846
|
+
${import_chalk18.default.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 import_events3.EventEmitter {
|
|
3814
3872
|
config;
|
|
3815
3873
|
state;
|
|
@@ -3832,7 +3890,7 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
3832
3890
|
}
|
|
3833
3891
|
async start() {
|
|
3834
3892
|
if (this.state.isRunning) {
|
|
3835
|
-
console.log(
|
|
3893
|
+
console.log(import_chalk19.default.yellow("Daemon is already running."));
|
|
3836
3894
|
return;
|
|
3837
3895
|
}
|
|
3838
3896
|
this.printWelcome();
|
|
@@ -3842,8 +3900,8 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
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
|
-
|
|
3846
|
-
|
|
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 import_events3.EventEmitter {
|
|
|
3853
3911
|
try {
|
|
3854
3912
|
await this.setupBridge();
|
|
3855
3913
|
} catch (e) {
|
|
3856
|
-
console.error(
|
|
3857
|
-
console.log(
|
|
3914
|
+
console.error(import_chalk19.default.yellow(` \u26A0\uFE0F Agent Bridge connection failed: ${e.message}`));
|
|
3915
|
+
console.log(import_chalk19.default.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(
|
|
3865
|
-
console.log(
|
|
3866
|
-
console.log(
|
|
3867
|
-
console.log(
|
|
3868
|
-
console.log(
|
|
3922
|
+
console.log(import_chalk19.default.bold.blue("\n\u{1F6E1}\uFE0F Guardian Daemon Starting..."));
|
|
3923
|
+
console.log(import_chalk19.default.dim(`Project: ${this.config.projectId}`));
|
|
3924
|
+
console.log(import_chalk19.default.dim(`API URL: ${this.config.apiUrl}`));
|
|
3925
|
+
console.log(import_chalk19.default.dim(`Watch Path: ${this.config.watchPath}`));
|
|
3926
|
+
console.log(import_chalk19.default.dim("\u2500".repeat(50)));
|
|
3869
3927
|
}
|
|
3870
3928
|
printActive() {
|
|
3871
|
-
console.log(
|
|
3872
|
-
console.log(
|
|
3873
|
-
console.log(
|
|
3929
|
+
console.log(import_chalk19.default.dim("\u2500".repeat(50)));
|
|
3930
|
+
console.log(import_chalk19.default.green.bold("\u2705 Guardian Daemon is now active"));
|
|
3931
|
+
console.log(import_chalk19.default.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)
|
|
3936
|
+
if (synced) Logger.info("Synced heuristic rules");
|
|
3879
3937
|
}
|
|
3880
3938
|
setupFileWatcher() {
|
|
3881
|
-
|
|
3939
|
+
Logger.info("Starting file watcher...");
|
|
3882
3940
|
this.fileWatcher = createFileWatcher(this.config.watchPath);
|
|
3883
3941
|
this.fileWatcher.on("change", (path24) => this.handleFileChange(path24));
|
|
3884
3942
|
this.fileWatcher.start();
|
|
3885
|
-
|
|
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)
|
|
3890
|
-
|
|
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
|
-
|
|
3955
|
+
return content.split("\n").length;
|
|
3894
3956
|
} catch (e) {
|
|
3957
|
+
return 0;
|
|
3895
3958
|
}
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
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
|
-
|
|
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" ? import_chalk18.default.red : v.severity === "warning" ? import_chalk18.default.yellow : import_chalk18.default.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(
|
|
3998
|
+
console.log(import_chalk19.default.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(
|
|
4003
|
+
console.log(import_chalk19.default.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(
|
|
4008
|
+
console.log(import_chalk19.default.green(" \u2713 Agent Bridge connected"));
|
|
3942
4009
|
}
|
|
3943
4010
|
async stop() {
|
|
3944
4011
|
if (!this.state.isRunning) return;
|
|
3945
|
-
console.log(
|
|
4012
|
+
console.log(import_chalk19.default.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(
|
|
4016
|
+
console.log(import_chalk19.default.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(
|
|
4013
|
-
console.log(
|
|
4079
|
+
console.log(import_chalk20.default.yellow("\u26A0 Another daemon instance is active (PID " + pid + ")."));
|
|
4080
|
+
console.log(import_chalk20.default.dim(` Run "rigstate daemon status" for details or Ctrl+C to stop.
|
|
4014
4081
|
`));
|
|
4015
4082
|
} catch {
|
|
4016
4083
|
await import_promises17.default.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(
|
|
4098
|
+
console.log(import_chalk20.default.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(
|
|
4052
|
-
console.error(
|
|
4118
|
+
spinner.fail(import_chalk20.default.red("Failed to start daemon"));
|
|
4119
|
+
console.error(import_chalk20.default.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(
|
|
4168
|
+
console.log(import_chalk20.default.bold("\n\u{1F6E1}\uFE0F Guardian Daemon Status\n"));
|
|
4102
4169
|
const running = await isRunning();
|
|
4103
4170
|
if (!running) {
|
|
4104
|
-
console.log(
|
|
4105
|
-
console.log(
|
|
4171
|
+
console.log(import_chalk20.default.yellow("Status: Not running"));
|
|
4172
|
+
console.log(import_chalk20.default.dim('Use "rigstate daemon" to start.\n'));
|
|
4106
4173
|
return;
|
|
4107
4174
|
}
|
|
4108
|
-
console.log(
|
|
4175
|
+
console.log(import_chalk20.default.green("Status: Running"));
|
|
4109
4176
|
try {
|
|
4110
4177
|
const statePath = import_path19.default.join(process.cwd(), STATE_FILE);
|
|
4111
4178
|
const content = await import_promises17.default.readFile(statePath, "utf-8");
|
|
4112
4179
|
const state = JSON.parse(content);
|
|
4113
|
-
console.log(
|
|
4180
|
+
console.log(import_chalk20.default.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(
|
|
4186
|
+
console.log(import_chalk20.default.dim("\u2500".repeat(40)));
|
|
4120
4187
|
} catch {
|
|
4121
|
-
console.log(
|
|
4188
|
+
console.log(import_chalk20.default.dim("(State file not found)"));
|
|
4122
4189
|
}
|
|
4123
4190
|
try {
|
|
4124
4191
|
const pidPath = import_path19.default.join(process.cwd(), PID_FILE);
|
|
4125
4192
|
const pid = await import_promises17.default.readFile(pidPath, "utf-8");
|
|
4126
|
-
console.log(
|
|
4193
|
+
console.log(import_chalk20.default.dim(`PID: ${pid.trim()}`));
|
|
4127
4194
|
} catch {
|
|
4128
4195
|
}
|
|
4129
4196
|
console.log("");
|
|
4130
4197
|
}
|
|
4131
4198
|
async function enableDaemon() {
|
|
4132
|
-
console.log(
|
|
4199
|
+
console.log(import_chalk20.default.bold("\n\u2699\uFE0F Enabling Rigstate Background Service (macOS)\n"));
|
|
4133
4200
|
if (process.platform !== "darwin") {
|
|
4134
|
-
console.error(
|
|
4135
|
-
console.error(
|
|
4201
|
+
console.error(import_chalk20.default.red("\u274C Currently only macOS is supported for auto-start."));
|
|
4202
|
+
console.error(import_chalk20.default.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(
|
|
4207
|
+
console.error(import_chalk20.default.red("\u274C Could not determine HOME directory."));
|
|
4141
4208
|
return;
|
|
4142
4209
|
}
|
|
4143
4210
|
const agentsDir = import_path19.default.join(homeDir, "Library/LaunchAgents");
|
|
@@ -4179,32 +4246,32 @@ async function enableDaemon() {
|
|
|
4179
4246
|
</plist>`;
|
|
4180
4247
|
try {
|
|
4181
4248
|
await import_promises17.default.writeFile(plistPath, plistContent);
|
|
4182
|
-
console.log(
|
|
4249
|
+
console.log(import_chalk20.default.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(
|
|
4189
|
-
console.log(
|
|
4190
|
-
console.log(
|
|
4255
|
+
console.log(import_chalk20.default.green("\u2705 Successfully enabled background daemon!"));
|
|
4256
|
+
console.log(import_chalk20.default.dim(`Logs: ${logDir}`));
|
|
4257
|
+
console.log(import_chalk20.default.dim("The daemon will now restart automatically if it crashes or on reboot."));
|
|
4191
4258
|
} catch (error) {
|
|
4192
|
-
console.error(
|
|
4259
|
+
console.error(import_chalk20.default.red("\u274C Failed to enable daemon:"), error.message);
|
|
4193
4260
|
}
|
|
4194
4261
|
}
|
|
4195
4262
|
async function disableDaemon() {
|
|
4196
|
-
console.log(
|
|
4263
|
+
console.log(import_chalk20.default.bold("\n\u2699\uFE0F Disabling Rigstate Background Service\n"));
|
|
4197
4264
|
const homeDir = process.env.HOME || "";
|
|
4198
4265
|
const plistPath = import_path19.default.join(homeDir, "Library/LaunchAgents/com.rigstate.daemon.plist");
|
|
4199
4266
|
try {
|
|
4200
4267
|
await execShellCommand(`launchctl unload ${plistPath}`);
|
|
4201
4268
|
await import_promises17.default.unlink(plistPath);
|
|
4202
|
-
console.log(
|
|
4269
|
+
console.log(import_chalk20.default.green("\u2705 Successfully disabled background daemon."));
|
|
4203
4270
|
} catch (error) {
|
|
4204
4271
|
if (error.code === "ENOENT") {
|
|
4205
|
-
console.log(
|
|
4272
|
+
console.log(import_chalk20.default.green("\u2705 Daemon was not enabled."));
|
|
4206
4273
|
} else {
|
|
4207
|
-
console.error(
|
|
4274
|
+
console.error(import_chalk20.default.red("\u274C Failed to disable daemon:"), error.message);
|
|
4208
4275
|
}
|
|
4209
4276
|
}
|
|
4210
4277
|
}
|
|
@@ -4220,7 +4287,7 @@ async function execShellCommand(cmd) {
|
|
|
4220
4287
|
// src/commands/work.ts
|
|
4221
4288
|
init_cjs_shims();
|
|
4222
4289
|
var import_commander12 = require("commander");
|
|
4223
|
-
var
|
|
4290
|
+
var import_chalk21 = __toESM(require("chalk"), 1);
|
|
4224
4291
|
var import_ora9 = __toESM(require("ora"), 1);
|
|
4225
4292
|
var import_axios15 = __toESM(require("axios"), 1);
|
|
4226
4293
|
var import_inquirer2 = __toESM(require("inquirer"), 1);
|
|
@@ -4257,7 +4324,7 @@ async function listInteractive() {
|
|
|
4257
4324
|
});
|
|
4258
4325
|
spinner.stop();
|
|
4259
4326
|
if (actionableTasks.length === 0) {
|
|
4260
|
-
console.log(
|
|
4327
|
+
console.log(import_chalk21.default.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} ${
|
|
4336
|
+
name: `${icon} ${import_chalk21.default.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(
|
|
4379
|
+
spinner.succeed(import_chalk21.default.green(`Task updated to ${status}.`));
|
|
4313
4380
|
if (status === "IN_PROGRESS") {
|
|
4314
|
-
console.log(
|
|
4381
|
+
console.log(import_chalk21.default.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(
|
|
4385
|
+
spinner.fail(import_chalk21.default.red(`Failed: ${e.message}`));
|
|
4319
4386
|
}
|
|
4320
4387
|
}
|
|
4321
4388
|
async function finishTask(taskId) {
|
|
4322
4389
|
console.log("");
|
|
4323
|
-
console.log(
|
|
4324
|
-
console.log(
|
|
4390
|
+
console.log(import_chalk21.default.bold.yellow("\u{1F6E1}\uFE0F FRANK'S QUALITY GATE"));
|
|
4391
|
+
console.log(import_chalk21.default.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 = (0, import_ora9.default)(" 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(
|
|
4397
|
+
console.log(import_chalk21.default.bold.green("\u{1F389} TASK COMPLETE! Momentum Preserved."));
|
|
4331
4398
|
const { projectId, apiKey, apiUrl } = getContext();
|
|
4332
4399
|
await suggestNextMove(projectId, apiKey, apiUrl);
|
|
4333
4400
|
}
|
|
@@ -4344,7 +4411,7 @@ function getContext() {
|
|
|
4344
4411
|
// src/commands/watch.ts
|
|
4345
4412
|
init_cjs_shims();
|
|
4346
4413
|
var import_commander13 = require("commander");
|
|
4347
|
-
var
|
|
4414
|
+
var import_chalk22 = __toESM(require("chalk"), 1);
|
|
4348
4415
|
var import_ora10 = __toESM(require("ora"), 1);
|
|
4349
4416
|
var import_chokidar = __toESM(require("chokidar"), 1);
|
|
4350
4417
|
var import_promises18 = __toESM(require("fs/promises"), 1);
|
|
@@ -4355,15 +4422,15 @@ var import_axios16 = __toESM(require("axios"), 1);
|
|
|
4355
4422
|
function createWatchCommand() {
|
|
4356
4423
|
const watch2 = new import_commander13.Command("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(
|
|
4359
|
-
console.log(
|
|
4425
|
+
console.log(import_chalk22.default.bold.blue("\u{1F52D} Rigstate Watch Mode"));
|
|
4426
|
+
console.log(import_chalk22.default.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(
|
|
4433
|
+
console.log(import_chalk22.default.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(
|
|
4447
|
+
console.log(import_chalk22.default.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(
|
|
4391
|
-
console.log(
|
|
4457
|
+
console.log(import_chalk22.default.dim(`Auto-commit: ${config2.autoCommit ? "ON" : "OFF"}`));
|
|
4458
|
+
console.log(import_chalk22.default.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(
|
|
4525
|
+
spinner.succeed(import_chalk22.default.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(
|
|
4547
|
+
console.log(import_chalk22.default.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(
|
|
4560
|
+
console.log(import_chalk22.default.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(
|
|
4503
|
-
console.log(
|
|
4569
|
+
console.log(import_chalk22.default.bold.yellow(`\u{1F4CC} Active Task #${task.step_number}: ${task.title}`));
|
|
4570
|
+
console.log(import_chalk22.default.dim(`Status: ${task.status}`));
|
|
4504
4571
|
if (task.verification_criteria) {
|
|
4505
|
-
console.log(
|
|
4572
|
+
console.log(import_chalk22.default.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(
|
|
4585
|
+
console.log(import_chalk22.default.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(
|
|
4610
|
+
console.log(import_chalk22.default.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(
|
|
4614
|
+
console.log(import_chalk22.default.dim("Watch mode stopped."));
|
|
4548
4615
|
watcher.close();
|
|
4549
4616
|
process.exit(0);
|
|
4550
4617
|
});
|
|
@@ -4555,7 +4622,7 @@ function createWatchCommand() {
|
|
|
4555
4622
|
// src/commands/focus.ts
|
|
4556
4623
|
init_cjs_shims();
|
|
4557
4624
|
var import_commander14 = require("commander");
|
|
4558
|
-
var
|
|
4625
|
+
var import_chalk23 = __toESM(require("chalk"), 1);
|
|
4559
4626
|
var import_ora11 = __toESM(require("ora"), 1);
|
|
4560
4627
|
init_config();
|
|
4561
4628
|
var import_axios17 = __toESM(require("axios"), 1);
|
|
@@ -4571,7 +4638,7 @@ function createFocusCommand() {
|
|
|
4571
4638
|
try {
|
|
4572
4639
|
apiKey = getApiKey();
|
|
4573
4640
|
} catch (e) {
|
|
4574
|
-
spinner.fail(
|
|
4641
|
+
spinner.fail(import_chalk23.default.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(
|
|
4655
|
+
spinner.fail(import_chalk23.default.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(
|
|
4620
|
-
const statusColor = nextTask.status === "IN_PROGRESS" ?
|
|
4621
|
-
console.log(
|
|
4622
|
-
console.log(
|
|
4686
|
+
console.log(import_chalk23.default.bold.blue(`\u{1F4CC} Task #${nextTask.step_number || "?"}: ${nextTask.title}`));
|
|
4687
|
+
const statusColor = nextTask.status === "IN_PROGRESS" ? import_chalk23.default.yellow : nextTask.status === "ACTIVE" ? import_chalk23.default.green : import_chalk23.default.dim;
|
|
4688
|
+
console.log(import_chalk23.default.dim("Status: ") + statusColor(nextTask.status));
|
|
4689
|
+
console.log(import_chalk23.default.dim("\u2500".repeat(60)));
|
|
4623
4690
|
if (nextTask.prompt_content) {
|
|
4624
|
-
console.log(
|
|
4625
|
-
console.log(
|
|
4691
|
+
console.log(import_chalk23.default.white(nextTask.prompt_content));
|
|
4692
|
+
console.log(import_chalk23.default.dim("\u2500".repeat(60)));
|
|
4626
4693
|
if (options.copy !== false) {
|
|
4627
4694
|
try {
|
|
4628
4695
|
if (process.platform === "darwin") {
|
|
4629
4696
|
(0, import_child_process5.execSync)("pbcopy", { input: nextTask.prompt_content });
|
|
4630
|
-
console.log(
|
|
4697
|
+
console.log(import_chalk23.default.green("\u2705 Prompt copied to clipboard! Ready to paste (Cmd+V)."));
|
|
4631
4698
|
} else if (process.platform === "linux") {
|
|
4632
4699
|
try {
|
|
4633
4700
|
(0, import_child_process5.execSync)("xclip -selection clipboard", { input: nextTask.prompt_content });
|
|
4634
|
-
console.log(
|
|
4701
|
+
console.log(import_chalk23.default.green("\u2705 Prompt copied to clipboard!"));
|
|
4635
4702
|
} catch (e) {
|
|
4636
|
-
console.log(
|
|
4703
|
+
console.log(import_chalk23.default.yellow("\u2139\uFE0F Copy prompt manually (xclip not available)"));
|
|
4637
4704
|
}
|
|
4638
4705
|
} else {
|
|
4639
|
-
console.log(
|
|
4706
|
+
console.log(import_chalk23.default.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(
|
|
4712
|
+
console.log(import_chalk23.default.yellow("No prompt instructions available."));
|
|
4646
4713
|
if (nextTask.architectural_brief) {
|
|
4647
|
-
console.log(
|
|
4714
|
+
console.log(import_chalk23.default.bold("Brief:"));
|
|
4648
4715
|
console.log(nextTask.architectural_brief);
|
|
4649
4716
|
}
|
|
4650
4717
|
}
|
|
4651
4718
|
console.log("");
|
|
4652
4719
|
} catch (e) {
|
|
4653
|
-
spinner.fail(
|
|
4720
|
+
spinner.fail(import_chalk23.default.red(`Failed to fetch task: ${e.message}`));
|
|
4654
4721
|
}
|
|
4655
4722
|
});
|
|
4656
4723
|
return focus;
|
|
@@ -4662,26 +4729,26 @@ init_env();
|
|
|
4662
4729
|
// src/commands/config.ts
|
|
4663
4730
|
init_cjs_shims();
|
|
4664
4731
|
var import_commander15 = require("commander");
|
|
4665
|
-
var
|
|
4732
|
+
var import_chalk24 = __toESM(require("chalk"), 1);
|
|
4666
4733
|
init_config();
|
|
4667
4734
|
function createConfigCommand() {
|
|
4668
4735
|
const config2 = new import_commander15.Command("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(
|
|
4672
|
-
console.log(
|
|
4738
|
+
console.log(import_chalk24.default.bold("Rigstate Configuration"));
|
|
4739
|
+
console.log(import_chalk24.default.dim("\u2500".repeat(40)));
|
|
4673
4740
|
try {
|
|
4674
4741
|
const apiKey = getApiKey();
|
|
4675
|
-
console.log(`${
|
|
4742
|
+
console.log(`${import_chalk24.default.cyan("api_key")}: ${apiKey.substring(0, 20)}...`);
|
|
4676
4743
|
} catch (e) {
|
|
4677
|
-
console.log(`${
|
|
4744
|
+
console.log(`${import_chalk24.default.cyan("api_key")}: ${import_chalk24.default.dim("(not set)")}`);
|
|
4678
4745
|
}
|
|
4679
4746
|
const projectId = getProjectId();
|
|
4680
|
-
console.log(`${
|
|
4747
|
+
console.log(`${import_chalk24.default.cyan("project_id")}: ${projectId || import_chalk24.default.dim("(not set)")}`);
|
|
4681
4748
|
const apiUrl = getApiUrl();
|
|
4682
|
-
console.log(`${
|
|
4749
|
+
console.log(`${import_chalk24.default.cyan("api_url")}: ${apiUrl}`);
|
|
4683
4750
|
console.log("");
|
|
4684
|
-
console.log(
|
|
4751
|
+
console.log(import_chalk24.default.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(
|
|
4761
|
+
console.log(import_chalk24.default.dim("(not set)"));
|
|
4695
4762
|
}
|
|
4696
4763
|
break;
|
|
4697
4764
|
case "project_id":
|
|
4698
|
-
console.log(getProjectId() ||
|
|
4765
|
+
console.log(getProjectId() || import_chalk24.default.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(
|
|
4705
|
-
console.log(
|
|
4771
|
+
console.log(import_chalk24.default.red(`Unknown config key: ${key}`));
|
|
4772
|
+
console.log(import_chalk24.default.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(
|
|
4779
|
+
console.log(import_chalk24.default.green(`\u2705 api_key updated`));
|
|
4713
4780
|
break;
|
|
4714
4781
|
case "project_id":
|
|
4715
4782
|
setProjectId(value);
|
|
4716
|
-
console.log(
|
|
4783
|
+
console.log(import_chalk24.default.green(`\u2705 project_id updated`));
|
|
4717
4784
|
break;
|
|
4718
4785
|
case "api_url":
|
|
4719
4786
|
setApiUrl(value);
|
|
4720
|
-
console.log(
|
|
4787
|
+
console.log(import_chalk24.default.green(`\u2705 api_url updated`));
|
|
4721
4788
|
break;
|
|
4722
4789
|
default:
|
|
4723
|
-
console.log(
|
|
4724
|
-
console.log(
|
|
4790
|
+
console.log(import_chalk24.default.red(`Unknown config key: ${key}`));
|
|
4791
|
+
console.log(import_chalk24.default.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_cjs_shims();
|
|
4732
4799
|
var import_commander16 = require("commander");
|
|
4733
|
-
var
|
|
4800
|
+
var import_chalk25 = __toESM(require("chalk"), 1);
|
|
4734
4801
|
var import_child_process6 = require("child_process");
|
|
4735
4802
|
var import_path22 = __toESM(require("path"), 1);
|
|
4736
4803
|
var import_fs = __toESM(require("fs"), 1);
|
|
@@ -4756,15 +4823,15 @@ function createMcpCommand() {
|
|
|
4756
4823
|
}
|
|
4757
4824
|
}
|
|
4758
4825
|
if (!serverPath) {
|
|
4759
|
-
console.error(
|
|
4760
|
-
console.error(
|
|
4761
|
-
console.error(
|
|
4826
|
+
console.error(import_chalk25.default.red("\u274C Error: Rigstate MCP Server binary not found."));
|
|
4827
|
+
console.error(import_chalk25.default.yellow("Please ensure that the mcp package is built:"));
|
|
4828
|
+
console.error(import_chalk25.default.white(" cd packages/mcp && npm run build"));
|
|
4762
4829
|
console.error("");
|
|
4763
|
-
console.error(
|
|
4764
|
-
console.error(
|
|
4830
|
+
console.error(import_chalk25.default.dim("Or run directly with:"));
|
|
4831
|
+
console.error(import_chalk25.default.white(" npx @rigstate/mcp"));
|
|
4765
4832
|
process.exit(1);
|
|
4766
4833
|
}
|
|
4767
|
-
console.log(
|
|
4834
|
+
console.log(import_chalk25.default.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(
|
|
4843
|
+
console.error(import_chalk25.default.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
|
-
var
|
|
4926
|
+
var import_chalk26 = __toESM(require("chalk"), 1);
|
|
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(
|
|
4936
|
+
console.log(import_chalk26.default.dim("\u26A0\uFE0F Hive Gateway disabled (No Token provided). Running in localized mode."));
|
|
4870
4937
|
}
|
|
4871
4938
|
this.client = import_axios18.default.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(
|
|
4956
|
+
console.warn(import_chalk26.default.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(
|
|
4961
|
+
console.error(import_chalk26.default.red(`\u{1F6D1} HIVE BLOCKED: Signal contains sensitive data (Risk: ${scrubResult.riskScore})`));
|
|
4895
4962
|
return false;
|
|
4896
4963
|
}
|
|
4897
4964
|
try {
|
|
4898
|
-
console.log(
|
|
4965
|
+
console.log(import_chalk26.default.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(
|
|
4969
|
+
console.log(import_chalk26.default.green("\u2705 Signal Received by Hive Core. Knowledge Shared."));
|
|
4903
4970
|
return true;
|
|
4904
4971
|
} catch (error) {
|
|
4905
|
-
console.error(
|
|
4972
|
+
console.error(import_chalk26.default.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_cjs_shims();
|
|
4913
|
-
var import_chalk26 = __toESM(require("chalk"), 1);
|
|
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 = import_chalk26.default.blue(`[${"INFO" /* INFO */}]`);
|
|
4921
|
-
break;
|
|
4922
|
-
case "WARN" /* WARN */:
|
|
4923
|
-
prefix = import_chalk26.default.yellow(`[${"WARN" /* WARN */}]`);
|
|
4924
|
-
break;
|
|
4925
|
-
case "ERROR" /* ERROR */:
|
|
4926
|
-
prefix = import_chalk26.default.red(`[${"ERROR" /* ERROR */}]`);
|
|
4927
|
-
break;
|
|
4928
|
-
case "DEBUG" /* DEBUG */:
|
|
4929
|
-
prefix = import_chalk26.default.gray(`[${"DEBUG" /* DEBUG */}]`);
|
|
4930
|
-
break;
|
|
4931
|
-
}
|
|
4932
|
-
let output = `${import_chalk26.default.gray(timestamp)} ${prefix} ${message}`;
|
|
4933
|
-
if (context) {
|
|
4934
|
-
if (context instanceof Error) {
|
|
4935
|
-
output += `
|
|
4936
|
-
${import_chalk26.default.red(context.stack || context.message)}`;
|
|
4937
|
-
} else if (typeof context === "object") {
|
|
4938
|
-
try {
|
|
4939
|
-
output += `
|
|
4940
|
-
${import_chalk26.default.gray(JSON.stringify(context, null, 2))}`;
|
|
4941
|
-
} catch (e) {
|
|
4942
|
-
output += `
|
|
4943
|
-
${import_chalk26.default.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 import_events4.default {
|
|
4969
4980
|
context;
|