@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/.rigstate/daemon.pid +1 -1
- package/.rigstate/daemon.state.json +4 -4
- package/.rigstate/rules-cache.json +1 -1
- package/dist/index.cjs +225 -211
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +225 -211
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/daemon/core.ts +69 -44
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
|
|
|
@@ -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_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
|
|
3812
3871
|
var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
3813
3872
|
config;
|
|
3814
3873
|
state;
|
|
@@ -3831,7 +3890,7 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
3831
3890
|
}
|
|
3832
3891
|
async start() {
|
|
3833
3892
|
if (this.state.isRunning) {
|
|
3834
|
-
console.log(
|
|
3893
|
+
console.log(import_chalk19.default.yellow("Daemon is already running."));
|
|
3835
3894
|
return;
|
|
3836
3895
|
}
|
|
3837
3896
|
this.printWelcome();
|
|
@@ -3841,7 +3900,9 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
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
|
-
|
|
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 import_events3.EventEmitter {
|
|
|
3850
3911
|
try {
|
|
3851
3912
|
await this.setupBridge();
|
|
3852
3913
|
} catch (e) {
|
|
3853
|
-
console.error(
|
|
3854
|
-
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)"));
|
|
3855
3916
|
}
|
|
3856
3917
|
}
|
|
3857
3918
|
this.printActive();
|
|
3858
3919
|
this.emit("started", this.state);
|
|
3859
3920
|
}
|
|
3860
3921
|
printWelcome() {
|
|
3861
|
-
console.log(
|
|
3862
|
-
console.log(
|
|
3863
|
-
console.log(
|
|
3864
|
-
console.log(
|
|
3865
|
-
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)));
|
|
3866
3927
|
}
|
|
3867
3928
|
printActive() {
|
|
3868
|
-
console.log(
|
|
3869
|
-
console.log(
|
|
3870
|
-
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"));
|
|
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)
|
|
3936
|
+
if (synced) Logger.info("Synced heuristic rules");
|
|
3876
3937
|
}
|
|
3877
3938
|
setupFileWatcher() {
|
|
3878
|
-
|
|
3939
|
+
Logger.info("Starting file watcher...");
|
|
3879
3940
|
this.fileWatcher = createFileWatcher(this.config.watchPath);
|
|
3880
3941
|
this.fileWatcher.on("change", (path24) => this.handleFileChange(path24));
|
|
3881
3942
|
this.fileWatcher.start();
|
|
3882
|
-
|
|
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)
|
|
3887
|
-
|
|
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
|
-
|
|
3955
|
+
return content.split("\n").length;
|
|
3891
3956
|
} catch (e) {
|
|
3957
|
+
return 0;
|
|
3892
3958
|
}
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
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
|
-
|
|
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" ? import_chalk18.default.red : v.severity === "warning" ? import_chalk18.default.yellow : import_chalk18.default.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(
|
|
3998
|
+
console.log(import_chalk19.default.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(
|
|
4003
|
+
console.log(import_chalk19.default.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(
|
|
4008
|
+
console.log(import_chalk19.default.green(" \u2713 Agent Bridge connected"));
|
|
3939
4009
|
}
|
|
3940
4010
|
async stop() {
|
|
3941
4011
|
if (!this.state.isRunning) return;
|
|
3942
|
-
console.log(
|
|
4012
|
+
console.log(import_chalk19.default.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(
|
|
4016
|
+
console.log(import_chalk19.default.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(
|
|
4010
|
-
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.
|
|
4011
4081
|
`));
|
|
4012
4082
|
} catch {
|
|
4013
4083
|
await import_promises17.default.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(
|
|
4098
|
+
console.log(import_chalk20.default.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(
|
|
4049
|
-
console.error(
|
|
4118
|
+
spinner.fail(import_chalk20.default.red("Failed to start daemon"));
|
|
4119
|
+
console.error(import_chalk20.default.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(
|
|
4168
|
+
console.log(import_chalk20.default.bold("\n\u{1F6E1}\uFE0F Guardian Daemon Status\n"));
|
|
4099
4169
|
const running = await isRunning();
|
|
4100
4170
|
if (!running) {
|
|
4101
|
-
console.log(
|
|
4102
|
-
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'));
|
|
4103
4173
|
return;
|
|
4104
4174
|
}
|
|
4105
|
-
console.log(
|
|
4175
|
+
console.log(import_chalk20.default.green("Status: Running"));
|
|
4106
4176
|
try {
|
|
4107
4177
|
const statePath = import_path19.default.join(process.cwd(), STATE_FILE);
|
|
4108
4178
|
const content = await import_promises17.default.readFile(statePath, "utf-8");
|
|
4109
4179
|
const state = JSON.parse(content);
|
|
4110
|
-
console.log(
|
|
4180
|
+
console.log(import_chalk20.default.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(
|
|
4186
|
+
console.log(import_chalk20.default.dim("\u2500".repeat(40)));
|
|
4117
4187
|
} catch {
|
|
4118
|
-
console.log(
|
|
4188
|
+
console.log(import_chalk20.default.dim("(State file not found)"));
|
|
4119
4189
|
}
|
|
4120
4190
|
try {
|
|
4121
4191
|
const pidPath = import_path19.default.join(process.cwd(), PID_FILE);
|
|
4122
4192
|
const pid = await import_promises17.default.readFile(pidPath, "utf-8");
|
|
4123
|
-
console.log(
|
|
4193
|
+
console.log(import_chalk20.default.dim(`PID: ${pid.trim()}`));
|
|
4124
4194
|
} catch {
|
|
4125
4195
|
}
|
|
4126
4196
|
console.log("");
|
|
4127
4197
|
}
|
|
4128
4198
|
async function enableDaemon() {
|
|
4129
|
-
console.log(
|
|
4199
|
+
console.log(import_chalk20.default.bold("\n\u2699\uFE0F Enabling Rigstate Background Service (macOS)\n"));
|
|
4130
4200
|
if (process.platform !== "darwin") {
|
|
4131
|
-
console.error(
|
|
4132
|
-
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!"));
|
|
4133
4203
|
return;
|
|
4134
4204
|
}
|
|
4135
4205
|
const homeDir = process.env.HOME || "";
|
|
4136
4206
|
if (!homeDir) {
|
|
4137
|
-
console.error(
|
|
4207
|
+
console.error(import_chalk20.default.red("\u274C Could not determine HOME directory."));
|
|
4138
4208
|
return;
|
|
4139
4209
|
}
|
|
4140
4210
|
const agentsDir = import_path19.default.join(homeDir, "Library/LaunchAgents");
|
|
@@ -4176,32 +4246,32 @@ async function enableDaemon() {
|
|
|
4176
4246
|
</plist>`;
|
|
4177
4247
|
try {
|
|
4178
4248
|
await import_promises17.default.writeFile(plistPath, plistContent);
|
|
4179
|
-
console.log(
|
|
4249
|
+
console.log(import_chalk20.default.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(
|
|
4186
|
-
console.log(
|
|
4187
|
-
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."));
|
|
4188
4258
|
} catch (error) {
|
|
4189
|
-
console.error(
|
|
4259
|
+
console.error(import_chalk20.default.red("\u274C Failed to enable daemon:"), error.message);
|
|
4190
4260
|
}
|
|
4191
4261
|
}
|
|
4192
4262
|
async function disableDaemon() {
|
|
4193
|
-
console.log(
|
|
4263
|
+
console.log(import_chalk20.default.bold("\n\u2699\uFE0F Disabling Rigstate Background Service\n"));
|
|
4194
4264
|
const homeDir = process.env.HOME || "";
|
|
4195
4265
|
const plistPath = import_path19.default.join(homeDir, "Library/LaunchAgents/com.rigstate.daemon.plist");
|
|
4196
4266
|
try {
|
|
4197
4267
|
await execShellCommand(`launchctl unload ${plistPath}`);
|
|
4198
4268
|
await import_promises17.default.unlink(plistPath);
|
|
4199
|
-
console.log(
|
|
4269
|
+
console.log(import_chalk20.default.green("\u2705 Successfully disabled background daemon."));
|
|
4200
4270
|
} catch (error) {
|
|
4201
4271
|
if (error.code === "ENOENT") {
|
|
4202
|
-
console.log(
|
|
4272
|
+
console.log(import_chalk20.default.green("\u2705 Daemon was not enabled."));
|
|
4203
4273
|
} else {
|
|
4204
|
-
console.error(
|
|
4274
|
+
console.error(import_chalk20.default.red("\u274C Failed to disable daemon:"), error.message);
|
|
4205
4275
|
}
|
|
4206
4276
|
}
|
|
4207
4277
|
}
|
|
@@ -4217,7 +4287,7 @@ async function execShellCommand(cmd) {
|
|
|
4217
4287
|
// src/commands/work.ts
|
|
4218
4288
|
init_cjs_shims();
|
|
4219
4289
|
var import_commander12 = require("commander");
|
|
4220
|
-
var
|
|
4290
|
+
var import_chalk21 = __toESM(require("chalk"), 1);
|
|
4221
4291
|
var import_ora9 = __toESM(require("ora"), 1);
|
|
4222
4292
|
var import_axios15 = __toESM(require("axios"), 1);
|
|
4223
4293
|
var import_inquirer2 = __toESM(require("inquirer"), 1);
|
|
@@ -4254,7 +4324,7 @@ async function listInteractive() {
|
|
|
4254
4324
|
});
|
|
4255
4325
|
spinner.stop();
|
|
4256
4326
|
if (actionableTasks.length === 0) {
|
|
4257
|
-
console.log(
|
|
4327
|
+
console.log(import_chalk21.default.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} ${
|
|
4336
|
+
name: `${icon} ${import_chalk21.default.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(
|
|
4379
|
+
spinner.succeed(import_chalk21.default.green(`Task updated to ${status}.`));
|
|
4310
4380
|
if (status === "IN_PROGRESS") {
|
|
4311
|
-
console.log(
|
|
4381
|
+
console.log(import_chalk21.default.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(
|
|
4385
|
+
spinner.fail(import_chalk21.default.red(`Failed: ${e.message}`));
|
|
4316
4386
|
}
|
|
4317
4387
|
}
|
|
4318
4388
|
async function finishTask(taskId) {
|
|
4319
4389
|
console.log("");
|
|
4320
|
-
console.log(
|
|
4321
|
-
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"));
|
|
4322
4392
|
const auditSpinner = (0, import_ora9.default)(" 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(
|
|
4397
|
+
console.log(import_chalk21.default.bold.green("\u{1F389} TASK COMPLETE! Momentum Preserved."));
|
|
4328
4398
|
const { projectId, apiKey, apiUrl } = getContext();
|
|
4329
4399
|
await suggestNextMove(projectId, apiKey, apiUrl);
|
|
4330
4400
|
}
|
|
@@ -4341,7 +4411,7 @@ function getContext() {
|
|
|
4341
4411
|
// src/commands/watch.ts
|
|
4342
4412
|
init_cjs_shims();
|
|
4343
4413
|
var import_commander13 = require("commander");
|
|
4344
|
-
var
|
|
4414
|
+
var import_chalk22 = __toESM(require("chalk"), 1);
|
|
4345
4415
|
var import_ora10 = __toESM(require("ora"), 1);
|
|
4346
4416
|
var import_chokidar = __toESM(require("chokidar"), 1);
|
|
4347
4417
|
var import_promises18 = __toESM(require("fs/promises"), 1);
|
|
@@ -4352,15 +4422,15 @@ var import_axios16 = __toESM(require("axios"), 1);
|
|
|
4352
4422
|
function createWatchCommand() {
|
|
4353
4423
|
const watch2 = new import_commander13.Command("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(
|
|
4356
|
-
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..."));
|
|
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(
|
|
4433
|
+
console.log(import_chalk22.default.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(
|
|
4447
|
+
console.log(import_chalk22.default.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(
|
|
4388
|
-
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"}`));
|
|
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(
|
|
4525
|
+
spinner.succeed(import_chalk22.default.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(
|
|
4547
|
+
console.log(import_chalk22.default.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(
|
|
4560
|
+
console.log(import_chalk22.default.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(
|
|
4500
|
-
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}`));
|
|
4501
4571
|
if (task.verification_criteria) {
|
|
4502
|
-
console.log(
|
|
4572
|
+
console.log(import_chalk22.default.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(
|
|
4585
|
+
console.log(import_chalk22.default.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(
|
|
4610
|
+
console.log(import_chalk22.default.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(
|
|
4614
|
+
console.log(import_chalk22.default.dim("Watch mode stopped."));
|
|
4545
4615
|
watcher.close();
|
|
4546
4616
|
process.exit(0);
|
|
4547
4617
|
});
|
|
@@ -4552,7 +4622,7 @@ function createWatchCommand() {
|
|
|
4552
4622
|
// src/commands/focus.ts
|
|
4553
4623
|
init_cjs_shims();
|
|
4554
4624
|
var import_commander14 = require("commander");
|
|
4555
|
-
var
|
|
4625
|
+
var import_chalk23 = __toESM(require("chalk"), 1);
|
|
4556
4626
|
var import_ora11 = __toESM(require("ora"), 1);
|
|
4557
4627
|
init_config();
|
|
4558
4628
|
var import_axios17 = __toESM(require("axios"), 1);
|
|
@@ -4568,7 +4638,7 @@ function createFocusCommand() {
|
|
|
4568
4638
|
try {
|
|
4569
4639
|
apiKey = getApiKey();
|
|
4570
4640
|
} catch (e) {
|
|
4571
|
-
spinner.fail(
|
|
4641
|
+
spinner.fail(import_chalk23.default.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(
|
|
4655
|
+
spinner.fail(import_chalk23.default.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(
|
|
4617
|
-
const statusColor = nextTask.status === "IN_PROGRESS" ?
|
|
4618
|
-
console.log(
|
|
4619
|
-
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)));
|
|
4620
4690
|
if (nextTask.prompt_content) {
|
|
4621
|
-
console.log(
|
|
4622
|
-
console.log(
|
|
4691
|
+
console.log(import_chalk23.default.white(nextTask.prompt_content));
|
|
4692
|
+
console.log(import_chalk23.default.dim("\u2500".repeat(60)));
|
|
4623
4693
|
if (options.copy !== false) {
|
|
4624
4694
|
try {
|
|
4625
4695
|
if (process.platform === "darwin") {
|
|
4626
4696
|
(0, import_child_process5.execSync)("pbcopy", { input: nextTask.prompt_content });
|
|
4627
|
-
console.log(
|
|
4697
|
+
console.log(import_chalk23.default.green("\u2705 Prompt copied to clipboard! Ready to paste (Cmd+V)."));
|
|
4628
4698
|
} else if (process.platform === "linux") {
|
|
4629
4699
|
try {
|
|
4630
4700
|
(0, import_child_process5.execSync)("xclip -selection clipboard", { input: nextTask.prompt_content });
|
|
4631
|
-
console.log(
|
|
4701
|
+
console.log(import_chalk23.default.green("\u2705 Prompt copied to clipboard!"));
|
|
4632
4702
|
} catch (e) {
|
|
4633
|
-
console.log(
|
|
4703
|
+
console.log(import_chalk23.default.yellow("\u2139\uFE0F Copy prompt manually (xclip not available)"));
|
|
4634
4704
|
}
|
|
4635
4705
|
} else {
|
|
4636
|
-
console.log(
|
|
4706
|
+
console.log(import_chalk23.default.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(
|
|
4712
|
+
console.log(import_chalk23.default.yellow("No prompt instructions available."));
|
|
4643
4713
|
if (nextTask.architectural_brief) {
|
|
4644
|
-
console.log(
|
|
4714
|
+
console.log(import_chalk23.default.bold("Brief:"));
|
|
4645
4715
|
console.log(nextTask.architectural_brief);
|
|
4646
4716
|
}
|
|
4647
4717
|
}
|
|
4648
4718
|
console.log("");
|
|
4649
4719
|
} catch (e) {
|
|
4650
|
-
spinner.fail(
|
|
4720
|
+
spinner.fail(import_chalk23.default.red(`Failed to fetch task: ${e.message}`));
|
|
4651
4721
|
}
|
|
4652
4722
|
});
|
|
4653
4723
|
return focus;
|
|
@@ -4659,26 +4729,26 @@ init_env();
|
|
|
4659
4729
|
// src/commands/config.ts
|
|
4660
4730
|
init_cjs_shims();
|
|
4661
4731
|
var import_commander15 = require("commander");
|
|
4662
|
-
var
|
|
4732
|
+
var import_chalk24 = __toESM(require("chalk"), 1);
|
|
4663
4733
|
init_config();
|
|
4664
4734
|
function createConfigCommand() {
|
|
4665
4735
|
const config2 = new import_commander15.Command("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(
|
|
4669
|
-
console.log(
|
|
4738
|
+
console.log(import_chalk24.default.bold("Rigstate Configuration"));
|
|
4739
|
+
console.log(import_chalk24.default.dim("\u2500".repeat(40)));
|
|
4670
4740
|
try {
|
|
4671
4741
|
const apiKey = getApiKey();
|
|
4672
|
-
console.log(`${
|
|
4742
|
+
console.log(`${import_chalk24.default.cyan("api_key")}: ${apiKey.substring(0, 20)}...`);
|
|
4673
4743
|
} catch (e) {
|
|
4674
|
-
console.log(`${
|
|
4744
|
+
console.log(`${import_chalk24.default.cyan("api_key")}: ${import_chalk24.default.dim("(not set)")}`);
|
|
4675
4745
|
}
|
|
4676
4746
|
const projectId = getProjectId();
|
|
4677
|
-
console.log(`${
|
|
4747
|
+
console.log(`${import_chalk24.default.cyan("project_id")}: ${projectId || import_chalk24.default.dim("(not set)")}`);
|
|
4678
4748
|
const apiUrl = getApiUrl();
|
|
4679
|
-
console.log(`${
|
|
4749
|
+
console.log(`${import_chalk24.default.cyan("api_url")}: ${apiUrl}`);
|
|
4680
4750
|
console.log("");
|
|
4681
|
-
console.log(
|
|
4751
|
+
console.log(import_chalk24.default.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(
|
|
4761
|
+
console.log(import_chalk24.default.dim("(not set)"));
|
|
4692
4762
|
}
|
|
4693
4763
|
break;
|
|
4694
4764
|
case "project_id":
|
|
4695
|
-
console.log(getProjectId() ||
|
|
4765
|
+
console.log(getProjectId() || import_chalk24.default.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(
|
|
4702
|
-
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"));
|
|
4703
4773
|
}
|
|
4704
4774
|
return;
|
|
4705
4775
|
}
|
|
4706
4776
|
switch (key) {
|
|
4707
4777
|
case "api_key":
|
|
4708
4778
|
setApiKey(value);
|
|
4709
|
-
console.log(
|
|
4779
|
+
console.log(import_chalk24.default.green(`\u2705 api_key updated`));
|
|
4710
4780
|
break;
|
|
4711
4781
|
case "project_id":
|
|
4712
4782
|
setProjectId(value);
|
|
4713
|
-
console.log(
|
|
4783
|
+
console.log(import_chalk24.default.green(`\u2705 project_id updated`));
|
|
4714
4784
|
break;
|
|
4715
4785
|
case "api_url":
|
|
4716
4786
|
setApiUrl(value);
|
|
4717
|
-
console.log(
|
|
4787
|
+
console.log(import_chalk24.default.green(`\u2705 api_url updated`));
|
|
4718
4788
|
break;
|
|
4719
4789
|
default:
|
|
4720
|
-
console.log(
|
|
4721
|
-
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"));
|
|
4722
4792
|
}
|
|
4723
4793
|
});
|
|
4724
4794
|
return config2;
|
|
@@ -4727,7 +4797,7 @@ function createConfigCommand() {
|
|
|
4727
4797
|
// src/commands/mcp.ts
|
|
4728
4798
|
init_cjs_shims();
|
|
4729
4799
|
var import_commander16 = require("commander");
|
|
4730
|
-
var
|
|
4800
|
+
var import_chalk25 = __toESM(require("chalk"), 1);
|
|
4731
4801
|
var import_child_process6 = require("child_process");
|
|
4732
4802
|
var import_path22 = __toESM(require("path"), 1);
|
|
4733
4803
|
var import_fs = __toESM(require("fs"), 1);
|
|
@@ -4753,15 +4823,15 @@ function createMcpCommand() {
|
|
|
4753
4823
|
}
|
|
4754
4824
|
}
|
|
4755
4825
|
if (!serverPath) {
|
|
4756
|
-
console.error(
|
|
4757
|
-
console.error(
|
|
4758
|
-
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"));
|
|
4759
4829
|
console.error("");
|
|
4760
|
-
console.error(
|
|
4761
|
-
console.error(
|
|
4830
|
+
console.error(import_chalk25.default.dim("Or run directly with:"));
|
|
4831
|
+
console.error(import_chalk25.default.white(" npx @rigstate/mcp"));
|
|
4762
4832
|
process.exit(1);
|
|
4763
4833
|
}
|
|
4764
|
-
console.log(
|
|
4834
|
+
console.log(import_chalk25.default.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(
|
|
4843
|
+
console.error(import_chalk25.default.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
|
-
var
|
|
4926
|
+
var import_chalk26 = __toESM(require("chalk"), 1);
|
|
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(
|
|
4936
|
+
console.log(import_chalk26.default.dim("\u26A0\uFE0F Hive Gateway disabled (No Token provided). Running in localized mode."));
|
|
4867
4937
|
}
|
|
4868
4938
|
this.client = import_axios18.default.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(
|
|
4956
|
+
console.warn(import_chalk26.default.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(
|
|
4961
|
+
console.error(import_chalk26.default.red(`\u{1F6D1} HIVE BLOCKED: Signal contains sensitive data (Risk: ${scrubResult.riskScore})`));
|
|
4892
4962
|
return false;
|
|
4893
4963
|
}
|
|
4894
4964
|
try {
|
|
4895
|
-
console.log(
|
|
4965
|
+
console.log(import_chalk26.default.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(
|
|
4969
|
+
console.log(import_chalk26.default.green("\u2705 Signal Received by Hive Core. Knowledge Shared."));
|
|
4900
4970
|
return true;
|
|
4901
4971
|
} catch (error) {
|
|
4902
|
-
console.error(
|
|
4972
|
+
console.error(import_chalk26.default.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_cjs_shims();
|
|
4910
|
-
var import_chalk26 = __toESM(require("chalk"), 1);
|
|
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 = import_chalk26.default.blue(`[${"INFO" /* INFO */}]`);
|
|
4918
|
-
break;
|
|
4919
|
-
case "WARN" /* WARN */:
|
|
4920
|
-
prefix = import_chalk26.default.yellow(`[${"WARN" /* WARN */}]`);
|
|
4921
|
-
break;
|
|
4922
|
-
case "ERROR" /* ERROR */:
|
|
4923
|
-
prefix = import_chalk26.default.red(`[${"ERROR" /* ERROR */}]`);
|
|
4924
|
-
break;
|
|
4925
|
-
case "DEBUG" /* DEBUG */:
|
|
4926
|
-
prefix = import_chalk26.default.gray(`[${"DEBUG" /* DEBUG */}]`);
|
|
4927
|
-
break;
|
|
4928
|
-
}
|
|
4929
|
-
let output = `${import_chalk26.default.gray(timestamp)} ${prefix} ${message}`;
|
|
4930
|
-
if (context) {
|
|
4931
|
-
if (context instanceof Error) {
|
|
4932
|
-
output += `
|
|
4933
|
-
${import_chalk26.default.red(context.stack || context.message)}`;
|
|
4934
|
-
} else if (typeof context === "object") {
|
|
4935
|
-
try {
|
|
4936
|
-
output += `
|
|
4937
|
-
${import_chalk26.default.gray(JSON.stringify(context, null, 2))}`;
|
|
4938
|
-
} catch (e) {
|
|
4939
|
-
output += `
|
|
4940
|
-
${import_chalk26.default.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 import_events4.default {
|
|
4966
4980
|
context;
|