@rigstate/cli 0.6.7 → 0.6.8
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.cjs +644 -530
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +641 -528
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/idea.ts +78 -0
- package/src/commands/link.ts +10 -3
- package/src/commands/suggest.ts +67 -0
- package/src/commands/work.ts +168 -161
- package/src/index.ts +3 -0
package/dist/index.cjs
CHANGED
|
@@ -273,12 +273,12 @@ async function syncProjectRules(projectId, apiKey, apiUrl, dryRun = false) {
|
|
|
273
273
|
}
|
|
274
274
|
const files = syncResponse.data.data.files;
|
|
275
275
|
if (files && Array.isArray(files)) {
|
|
276
|
-
const
|
|
276
|
+
const fs22 = await import("fs/promises");
|
|
277
277
|
const path23 = await import("path");
|
|
278
278
|
for (const file of files) {
|
|
279
279
|
const filePath = path23.join(process.cwd(), file.path);
|
|
280
|
-
await
|
|
281
|
-
await
|
|
280
|
+
await fs22.mkdir(path23.dirname(filePath), { recursive: true });
|
|
281
|
+
await fs22.writeFile(filePath, file.content, "utf-8");
|
|
282
282
|
}
|
|
283
283
|
console.log(import_chalk3.default.dim(` \u{1F4BE} Wrote ${files.length} rule files to local .cursor/rules/`));
|
|
284
284
|
}
|
|
@@ -327,6 +327,55 @@ var init_sync_rules = __esm({
|
|
|
327
327
|
}
|
|
328
328
|
});
|
|
329
329
|
|
|
330
|
+
// src/commands/suggest.ts
|
|
331
|
+
var suggest_exports = {};
|
|
332
|
+
__export(suggest_exports, {
|
|
333
|
+
suggestNextMove: () => suggestNextMove
|
|
334
|
+
});
|
|
335
|
+
async function suggestNextMove(projectId, apiKey, apiUrl) {
|
|
336
|
+
try {
|
|
337
|
+
const response = await import_axios3.default.get(`${apiUrl}/api/v1/roadmap/chunks`, {
|
|
338
|
+
params: {
|
|
339
|
+
project_id: projectId,
|
|
340
|
+
status: "PENDING",
|
|
341
|
+
limit: 1,
|
|
342
|
+
order: "step_number.asc"
|
|
343
|
+
},
|
|
344
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
345
|
+
});
|
|
346
|
+
if (!response.data.success) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
const tasks = response.data.data.chunks || [];
|
|
350
|
+
if (tasks.length === 0) return;
|
|
351
|
+
const nextTask = tasks[0];
|
|
352
|
+
console.log("");
|
|
353
|
+
console.log(import_chalk4.default.bold("\u{1F3AF} TACTICAL INTELLIGENCE"));
|
|
354
|
+
console.log(import_chalk4.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"));
|
|
355
|
+
console.log(`${import_chalk4.default.bold("Active Phase:")} Implementation`);
|
|
356
|
+
console.log(`${import_chalk4.default.bold("Next Mission:")} ${import_chalk4.default.cyan(nextTask.title)}`);
|
|
357
|
+
if (nextTask.role) {
|
|
358
|
+
console.log(`${import_chalk4.default.bold("Required Role:")} ${import_chalk4.default.magenta(nextTask.role)}`);
|
|
359
|
+
}
|
|
360
|
+
console.log("");
|
|
361
|
+
console.log(import_chalk4.default.yellow("SUGGESTED NEXT MOVE:"));
|
|
362
|
+
console.log(import_chalk4.default.white(`> rigstate work start ${nextTask.id} `) + import_chalk4.default.dim("(Start this task)"));
|
|
363
|
+
console.log(import_chalk4.default.white(`> rigstate chat "How do I solve T-${nextTask.step_number}?" `) + import_chalk4.default.dim("(Ask Architect)"));
|
|
364
|
+
console.log(import_chalk4.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"));
|
|
365
|
+
console.log("");
|
|
366
|
+
} catch (e) {
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
var import_chalk4, import_axios3;
|
|
370
|
+
var init_suggest = __esm({
|
|
371
|
+
"src/commands/suggest.ts"() {
|
|
372
|
+
"use strict";
|
|
373
|
+
init_cjs_shims();
|
|
374
|
+
import_chalk4 = __toESM(require("chalk"), 1);
|
|
375
|
+
import_axios3 = __toESM(require("axios"), 1);
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
|
|
330
379
|
// src/commands/hooks.ts
|
|
331
380
|
var hooks_exports = {};
|
|
332
381
|
__export(hooks_exports, {
|
|
@@ -340,8 +389,8 @@ function createHooksCommand() {
|
|
|
340
389
|
try {
|
|
341
390
|
await import_promises2.default.access(gitDir);
|
|
342
391
|
} catch {
|
|
343
|
-
console.log(
|
|
344
|
-
console.log(
|
|
392
|
+
console.log(import_chalk5.default.red("\u274C Not a git repository."));
|
|
393
|
+
console.log(import_chalk5.default.dim(' Initialize with "git init" first.'));
|
|
345
394
|
process.exit(1);
|
|
346
395
|
}
|
|
347
396
|
const hooksDir = import_path2.default.join(gitDir, "hooks");
|
|
@@ -351,8 +400,8 @@ function createHooksCommand() {
|
|
|
351
400
|
try {
|
|
352
401
|
existingContent = await import_promises2.default.readFile(preCommitPath, "utf-8");
|
|
353
402
|
if (existingContent.includes("rigstate")) {
|
|
354
|
-
console.log(
|
|
355
|
-
console.log(
|
|
403
|
+
console.log(import_chalk5.default.yellow("\u26A0 Rigstate pre-commit hook already installed."));
|
|
404
|
+
console.log(import_chalk5.default.dim(' Use "rigstate hooks uninstall" to remove first.'));
|
|
356
405
|
return;
|
|
357
406
|
}
|
|
358
407
|
} catch {
|
|
@@ -364,18 +413,18 @@ function createHooksCommand() {
|
|
|
364
413
|
if (existingContent && !existingContent.includes("rigstate")) {
|
|
365
414
|
const combinedScript = existingContent + "\n\n" + script.replace("#!/bin/sh\n", "");
|
|
366
415
|
await import_promises2.default.writeFile(preCommitPath, combinedScript, { mode: 493 });
|
|
367
|
-
console.log(
|
|
416
|
+
console.log(import_chalk5.default.green("\u2705 Rigstate hook appended to existing pre-commit."));
|
|
368
417
|
} else {
|
|
369
418
|
await import_promises2.default.writeFile(preCommitPath, script, { mode: 493 });
|
|
370
|
-
console.log(
|
|
419
|
+
console.log(import_chalk5.default.green("\u2705 Pre-commit hook installed!"));
|
|
371
420
|
}
|
|
372
|
-
console.log(
|
|
373
|
-
console.log(
|
|
421
|
+
console.log(import_chalk5.default.dim(` Path: ${preCommitPath}`));
|
|
422
|
+
console.log(import_chalk5.default.dim(` Strict level: ${options.strict}`));
|
|
374
423
|
console.log("");
|
|
375
|
-
console.log(
|
|
376
|
-
console.log(
|
|
424
|
+
console.log(import_chalk5.default.cyan("Guardian will now check your code before each commit."));
|
|
425
|
+
console.log(import_chalk5.default.dim('Use "rigstate hooks uninstall" to remove the hook.'));
|
|
377
426
|
} catch (error) {
|
|
378
|
-
console.error(
|
|
427
|
+
console.error(import_chalk5.default.red("Failed to install hook:"), error.message);
|
|
379
428
|
process.exit(1);
|
|
380
429
|
}
|
|
381
430
|
});
|
|
@@ -385,12 +434,12 @@ function createHooksCommand() {
|
|
|
385
434
|
try {
|
|
386
435
|
const content = await import_promises2.default.readFile(preCommitPath, "utf-8");
|
|
387
436
|
if (!content.includes("rigstate")) {
|
|
388
|
-
console.log(
|
|
437
|
+
console.log(import_chalk5.default.yellow("\u26A0 No Rigstate hook found in pre-commit."));
|
|
389
438
|
return;
|
|
390
439
|
}
|
|
391
440
|
if (content.includes("# Rigstate Guardian Pre-commit Hook") && content.trim().split("\n").filter((l) => l && !l.startsWith("#")).length <= 4) {
|
|
392
441
|
await import_promises2.default.unlink(preCommitPath);
|
|
393
|
-
console.log(
|
|
442
|
+
console.log(import_chalk5.default.green("\u2705 Pre-commit hook removed."));
|
|
394
443
|
} else {
|
|
395
444
|
const lines = content.split("\n");
|
|
396
445
|
const filteredLines = [];
|
|
@@ -409,25 +458,25 @@ function createHooksCommand() {
|
|
|
409
458
|
}
|
|
410
459
|
}
|
|
411
460
|
await import_promises2.default.writeFile(preCommitPath, filteredLines.join("\n"), { mode: 493 });
|
|
412
|
-
console.log(
|
|
461
|
+
console.log(import_chalk5.default.green("\u2705 Rigstate section removed from pre-commit hook."));
|
|
413
462
|
}
|
|
414
463
|
} catch {
|
|
415
|
-
console.log(
|
|
464
|
+
console.log(import_chalk5.default.yellow("\u26A0 No pre-commit hook found."));
|
|
416
465
|
}
|
|
417
466
|
} catch (error) {
|
|
418
|
-
console.error(
|
|
467
|
+
console.error(import_chalk5.default.red("Failed to uninstall hook:"), error.message);
|
|
419
468
|
process.exit(1);
|
|
420
469
|
}
|
|
421
470
|
});
|
|
422
471
|
return hooks;
|
|
423
472
|
}
|
|
424
|
-
var import_commander4,
|
|
473
|
+
var import_commander4, import_chalk5, import_promises2, import_path2, PRE_COMMIT_SCRIPT;
|
|
425
474
|
var init_hooks = __esm({
|
|
426
475
|
"src/commands/hooks.ts"() {
|
|
427
476
|
"use strict";
|
|
428
477
|
init_cjs_shims();
|
|
429
478
|
import_commander4 = require("commander");
|
|
430
|
-
|
|
479
|
+
import_chalk5 = __toESM(require("chalk"), 1);
|
|
431
480
|
import_promises2 = __toESM(require("fs/promises"), 1);
|
|
432
481
|
import_path2 = __toESM(require("path"), 1);
|
|
433
482
|
PRE_COMMIT_SCRIPT = `#!/bin/sh
|
|
@@ -467,7 +516,7 @@ __export(skills_provisioner_exports, {
|
|
|
467
516
|
async function provisionSkills(apiUrl, apiKey, projectId, rootDir) {
|
|
468
517
|
const skills = [];
|
|
469
518
|
try {
|
|
470
|
-
const response = await
|
|
519
|
+
const response = await import_axios6.default.get(`${apiUrl}/api/v1/skills`, {
|
|
471
520
|
params: { project_id: projectId },
|
|
472
521
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
473
522
|
});
|
|
@@ -485,7 +534,7 @@ async function provisionSkills(apiUrl, apiKey, projectId, rootDir) {
|
|
|
485
534
|
}
|
|
486
535
|
} catch (e) {
|
|
487
536
|
const msg = e.response?.data?.error || e.message;
|
|
488
|
-
console.log(
|
|
537
|
+
console.log(import_chalk9.default.dim(` (Skills API not available: ${msg}, using core library)`));
|
|
489
538
|
}
|
|
490
539
|
if (skills.length === 0) {
|
|
491
540
|
const { getRigstateStandardSkills } = await import("@rigstate/rules-engine");
|
|
@@ -512,7 +561,7 @@ ${skill.content}
|
|
|
512
561
|
const skillPath = import_path7.default.join(skillDir, "SKILL.md");
|
|
513
562
|
await import_promises7.default.writeFile(skillPath, skillContent, "utf-8");
|
|
514
563
|
}
|
|
515
|
-
console.log(
|
|
564
|
+
console.log(import_chalk9.default.green(` \u2705 Provisioned ${skills.length} skill(s) to .agent/skills/`));
|
|
516
565
|
return skills;
|
|
517
566
|
}
|
|
518
567
|
function generateSkillsDiscoveryBlock(skills) {
|
|
@@ -536,7 +585,7 @@ async function jitProvisionSkill(skillId, apiUrl, apiKey, projectId, rootDir) {
|
|
|
536
585
|
}
|
|
537
586
|
const isProvisioned = rulesContent.includes(`<name>${skillId}</name>`) || rulesContent.includes(`.agent/skills/${skillId}`);
|
|
538
587
|
if (isProvisioned) return false;
|
|
539
|
-
console.log(
|
|
588
|
+
console.log(import_chalk9.default.yellow(` \u26A1 JIT PROVISIONING: Injecting ${skillId}...`));
|
|
540
589
|
try {
|
|
541
590
|
const skills = await provisionSkills(apiUrl, apiKey, projectId, rootDir);
|
|
542
591
|
const skillsBlock = generateSkillsDiscoveryBlock(skills);
|
|
@@ -554,19 +603,19 @@ async function jitProvisionSkill(skillId, apiUrl, apiKey, projectId, rootDir) {
|
|
|
554
603
|
await import_promises7.default.writeFile(rulesPath, rulesContent, "utf-8");
|
|
555
604
|
return true;
|
|
556
605
|
} catch (e) {
|
|
557
|
-
console.log(
|
|
606
|
+
console.log(import_chalk9.default.red(` Failed to provision skill: ${e.message}`));
|
|
558
607
|
return false;
|
|
559
608
|
}
|
|
560
609
|
}
|
|
561
|
-
var
|
|
610
|
+
var import_axios6, import_promises7, import_path7, import_chalk9;
|
|
562
611
|
var init_skills_provisioner = __esm({
|
|
563
612
|
"src/utils/skills-provisioner.ts"() {
|
|
564
613
|
"use strict";
|
|
565
614
|
init_cjs_shims();
|
|
566
|
-
|
|
615
|
+
import_axios6 = __toESM(require("axios"), 1);
|
|
567
616
|
import_promises7 = __toESM(require("fs/promises"), 1);
|
|
568
617
|
import_path7 = __toESM(require("path"), 1);
|
|
569
|
-
|
|
618
|
+
import_chalk9 = __toESM(require("chalk"), 1);
|
|
570
619
|
}
|
|
571
620
|
});
|
|
572
621
|
|
|
@@ -627,20 +676,20 @@ async function clearSoftLock(rootDir = process.cwd()) {
|
|
|
627
676
|
async function performOverride(violationId, reason, rootDir = process.cwd()) {
|
|
628
677
|
const config2 = await getGovernanceConfig(rootDir);
|
|
629
678
|
if (!config2.governance.allow_overrides) {
|
|
630
|
-
console.log(
|
|
679
|
+
console.log(import_chalk10.default.red("\u274C Overrides are disabled for this project."));
|
|
631
680
|
return false;
|
|
632
681
|
}
|
|
633
682
|
await clearSoftLock(rootDir);
|
|
634
683
|
return true;
|
|
635
684
|
}
|
|
636
|
-
var import_promises8, import_path8,
|
|
685
|
+
var import_promises8, import_path8, import_chalk10, InterventionLevel, DEFAULT_CONFIG, DEFAULT_SESSION;
|
|
637
686
|
var init_governance = __esm({
|
|
638
687
|
"src/utils/governance.ts"() {
|
|
639
688
|
"use strict";
|
|
640
689
|
init_cjs_shims();
|
|
641
690
|
import_promises8 = __toESM(require("fs/promises"), 1);
|
|
642
691
|
import_path8 = __toESM(require("path"), 1);
|
|
643
|
-
|
|
692
|
+
import_chalk10 = __toESM(require("chalk"), 1);
|
|
644
693
|
InterventionLevel = /* @__PURE__ */ ((InterventionLevel2) => {
|
|
645
694
|
InterventionLevel2[InterventionLevel2["GHOST"] = 0] = "GHOST";
|
|
646
695
|
InterventionLevel2[InterventionLevel2["NUDGE"] = 1] = "NUDGE";
|
|
@@ -692,7 +741,7 @@ async function fetchRulesFromApi(projectId) {
|
|
|
692
741
|
try {
|
|
693
742
|
const apiUrl = getApiUrl();
|
|
694
743
|
const apiKey = getApiKey();
|
|
695
|
-
const response = await
|
|
744
|
+
const response = await import_axios7.default.get(`${apiUrl}/api/v1/guardian/rules`, {
|
|
696
745
|
params: { project_id: projectId },
|
|
697
746
|
headers: { Authorization: `Bearer ${apiKey}` },
|
|
698
747
|
timeout: 1e4
|
|
@@ -726,7 +775,7 @@ async function fetchRulesFromApi(projectId) {
|
|
|
726
775
|
};
|
|
727
776
|
}
|
|
728
777
|
async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
|
|
729
|
-
console.log(
|
|
778
|
+
console.log(import_chalk11.default.bold("\n\u{1F6E1}\uFE0F Active Guardian Watchdog Initiated..."));
|
|
730
779
|
let lmax = settings.lmax || DEFAULT_LMAX;
|
|
731
780
|
let lmaxWarning = settings.lmax_warning || DEFAULT_LMAX_WARNING;
|
|
732
781
|
let ruleSource = settings.lmax ? "Settings (Passed)" : "Default";
|
|
@@ -736,7 +785,7 @@ async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
|
|
|
736
785
|
lmaxWarning = apiRules.lmaxWarning;
|
|
737
786
|
ruleSource = apiRules.source;
|
|
738
787
|
}
|
|
739
|
-
console.log(
|
|
788
|
+
console.log(import_chalk11.default.dim(`Governance Rules: L_max=${lmax}, L_max_warning=${lmaxWarning}, Source: ${ruleSource}`));
|
|
740
789
|
const targetExtensions = [".ts", ".tsx"];
|
|
741
790
|
let scanTarget = rootPath;
|
|
742
791
|
const webSrc = import_path9.default.join(rootPath, "apps", "web", "src");
|
|
@@ -745,7 +794,7 @@ async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
|
|
|
745
794
|
scanTarget = webSrc;
|
|
746
795
|
} catch {
|
|
747
796
|
}
|
|
748
|
-
console.log(
|
|
797
|
+
console.log(import_chalk11.default.dim(`Scanning target: ${import_path9.default.relative(process.cwd(), scanTarget)}`));
|
|
749
798
|
const files = await getFiles(scanTarget, targetExtensions);
|
|
750
799
|
let violations = 0;
|
|
751
800
|
let warnings = 0;
|
|
@@ -756,27 +805,27 @@ async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
|
|
|
756
805
|
if (lines > lmax) {
|
|
757
806
|
results.push({ file: relPath, lines, status: "VIOLATION" });
|
|
758
807
|
violations++;
|
|
759
|
-
console.log(
|
|
808
|
+
console.log(import_chalk11.default.red(`[VIOLATION] ${relPath}: ${lines} lines (Limit: ${lmax})`));
|
|
760
809
|
} else if (lines > lmaxWarning) {
|
|
761
810
|
results.push({ file: relPath, lines, status: "WARNING" });
|
|
762
811
|
warnings++;
|
|
763
|
-
console.log(
|
|
812
|
+
console.log(import_chalk11.default.yellow(`[WARNING] ${relPath}: ${lines} lines (Threshold: ${lmaxWarning})`));
|
|
764
813
|
}
|
|
765
814
|
}
|
|
766
815
|
if (violations === 0 && warnings === 0) {
|
|
767
|
-
console.log(
|
|
816
|
+
console.log(import_chalk11.default.green(`\u2714 All ${files.length} files are within governance limits.`));
|
|
768
817
|
} else {
|
|
769
|
-
console.log("\n" +
|
|
770
|
-
console.log(
|
|
771
|
-
console.log(
|
|
818
|
+
console.log("\n" + import_chalk11.default.bold("Summary:"));
|
|
819
|
+
console.log(import_chalk11.default.red(`Violations: ${violations}`));
|
|
820
|
+
console.log(import_chalk11.default.yellow(`Warnings: ${warnings}`));
|
|
772
821
|
const { getGovernanceConfig: getGovernanceConfig2, setSoftLock: setSoftLock2, InterventionLevel: InterventionLevel2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
773
822
|
const { governance } = await getGovernanceConfig2(rootPath);
|
|
774
|
-
console.log(
|
|
823
|
+
console.log(import_chalk11.default.dim(`Intervention Level: ${InterventionLevel2[governance.intervention_level] || "UNKNOWN"} (${governance.intervention_level})`));
|
|
775
824
|
if (violations > 0) {
|
|
776
|
-
console.log(
|
|
825
|
+
console.log(import_chalk11.default.red.bold("\nCRITICAL: Governance violations detected. Immediate refactoring required."));
|
|
777
826
|
if (governance.intervention_level >= InterventionLevel2.SENTINEL) {
|
|
778
|
-
console.log(
|
|
779
|
-
console.log(
|
|
827
|
+
console.log(import_chalk11.default.red.bold("\u{1F6D1} SENTINEL MODE: Session SOFT_LOCKED until resolved."));
|
|
828
|
+
console.log(import_chalk11.default.red(' Run "rigstate override <id> --reason \\"...\\"" if this is an emergency.'));
|
|
780
829
|
await setSoftLock2("Sentinel Mode: Governance Violations Detected", "ARC-VIOLATION", rootPath);
|
|
781
830
|
}
|
|
782
831
|
}
|
|
@@ -792,28 +841,28 @@ async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
|
|
|
792
841
|
limitValue: lmax,
|
|
793
842
|
severity: "CRITICAL"
|
|
794
843
|
}));
|
|
795
|
-
await
|
|
844
|
+
await import_axios7.default.post(`${apiUrl}/api/v1/guardian/sync`, {
|
|
796
845
|
projectId,
|
|
797
846
|
violations: payloadViolations,
|
|
798
847
|
warnings
|
|
799
848
|
}, {
|
|
800
849
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
801
850
|
});
|
|
802
|
-
console.log(
|
|
851
|
+
console.log(import_chalk11.default.dim("\u2714 Violations synced to Rigstate Cloud."));
|
|
803
852
|
} catch (e) {
|
|
804
|
-
console.log(
|
|
853
|
+
console.log(import_chalk11.default.dim("\u26A0 Cloud sync skipped: " + (e.message || "Unknown")));
|
|
805
854
|
}
|
|
806
855
|
}
|
|
807
856
|
}
|
|
808
|
-
var import_promises9, import_path9,
|
|
857
|
+
var import_promises9, import_path9, import_chalk11, import_axios7, DEFAULT_LMAX, DEFAULT_LMAX_WARNING, CACHE_FILE;
|
|
809
858
|
var init_watchdog = __esm({
|
|
810
859
|
"src/utils/watchdog.ts"() {
|
|
811
860
|
"use strict";
|
|
812
861
|
init_cjs_shims();
|
|
813
862
|
import_promises9 = __toESM(require("fs/promises"), 1);
|
|
814
863
|
import_path9 = __toESM(require("path"), 1);
|
|
815
|
-
|
|
816
|
-
|
|
864
|
+
import_chalk11 = __toESM(require("chalk"), 1);
|
|
865
|
+
import_axios7 = __toESM(require("axios"), 1);
|
|
817
866
|
init_config();
|
|
818
867
|
DEFAULT_LMAX = 400;
|
|
819
868
|
DEFAULT_LMAX_WARNING = 350;
|
|
@@ -823,8 +872,8 @@ var init_watchdog = __esm({
|
|
|
823
872
|
|
|
824
873
|
// src/index.ts
|
|
825
874
|
init_cjs_shims();
|
|
826
|
-
var
|
|
827
|
-
var
|
|
875
|
+
var import_commander20 = require("commander");
|
|
876
|
+
var import_chalk29 = __toESM(require("chalk"), 1);
|
|
828
877
|
|
|
829
878
|
// src/commands/login.ts
|
|
830
879
|
init_cjs_shims();
|
|
@@ -879,7 +928,7 @@ init_cjs_shims();
|
|
|
879
928
|
var import_commander5 = require("commander");
|
|
880
929
|
var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
881
930
|
var import_path3 = __toESM(require("path"), 1);
|
|
882
|
-
var
|
|
931
|
+
var import_chalk6 = __toESM(require("chalk"), 1);
|
|
883
932
|
var import_os = __toESM(require("os"), 1);
|
|
884
933
|
function createLinkCommand() {
|
|
885
934
|
return new import_commander5.Command("link").description("Link current directory to a Rigstate project").argument("<projectId>", "Project ID to link").action(async (projectId) => {
|
|
@@ -892,7 +941,7 @@ function createLinkCommand() {
|
|
|
892
941
|
if (config2.overrides && config2.overrides[cwd]) {
|
|
893
942
|
const overrideId = config2.overrides[cwd];
|
|
894
943
|
if (overrideId !== projectId) {
|
|
895
|
-
console.warn(
|
|
944
|
+
console.warn(import_chalk6.default.yellow(`Global override detected. Enforcing project ID: ${overrideId}`));
|
|
896
945
|
projectId = overrideId;
|
|
897
946
|
}
|
|
898
947
|
}
|
|
@@ -907,42 +956,47 @@ function createLinkCommand() {
|
|
|
907
956
|
};
|
|
908
957
|
try {
|
|
909
958
|
await import_promises3.default.writeFile(manifestPath, JSON.stringify(content, null, 2), "utf-8");
|
|
910
|
-
console.log(
|
|
911
|
-
console.log(
|
|
959
|
+
console.log(import_chalk6.default.green(`\u2714 Linked to project ID: ${projectId}`));
|
|
960
|
+
console.log(import_chalk6.default.dim(`Created local context manifest at .rigstate`));
|
|
912
961
|
console.log("");
|
|
913
|
-
console.log(
|
|
962
|
+
console.log(import_chalk6.default.bold("\u{1F916} Rigstate Automation Detected"));
|
|
914
963
|
console.log("");
|
|
915
964
|
const { getApiKey: getApiKey2, getApiUrl: getApiUrl2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
916
965
|
const apiKey = getApiKey2();
|
|
917
966
|
const apiUrl = getApiUrl2();
|
|
918
967
|
if (apiKey) {
|
|
919
|
-
console.log(
|
|
968
|
+
console.log(import_chalk6.default.blue("\u{1F510} Checking Vault for secrets..."));
|
|
920
969
|
const { syncEnv: syncEnv2 } = await Promise.resolve().then(() => (init_env(), env_exports));
|
|
921
970
|
await syncEnv2(projectId, apiKey, apiUrl, true);
|
|
922
|
-
console.log(
|
|
971
|
+
console.log(import_chalk6.default.blue("\u{1F9E0} Syncing neural instructions..."));
|
|
923
972
|
const { syncProjectRules: syncProjectRules2 } = await Promise.resolve().then(() => (init_sync_rules(), sync_rules_exports));
|
|
924
973
|
await syncProjectRules2(projectId, apiKey, apiUrl);
|
|
925
|
-
console.log(
|
|
974
|
+
console.log(import_chalk6.default.blue("\u{1F6E1}\uFE0F Checking immunity system..."));
|
|
926
975
|
await installHooks(process.cwd());
|
|
976
|
+
console.log("");
|
|
977
|
+
console.log(import_chalk6.default.bold.green("\u{1F680} Link Complete! Your environment is ready."));
|
|
978
|
+
const { suggestNextMove: suggestNextMove2 } = await Promise.resolve().then(() => (init_suggest(), suggest_exports));
|
|
979
|
+
await suggestNextMove2(projectId, apiKey, apiUrl);
|
|
980
|
+
} else {
|
|
981
|
+
console.log("");
|
|
982
|
+
console.log(import_chalk6.default.bold.green("\u{1F680} Link Complete!"));
|
|
927
983
|
}
|
|
928
|
-
console.log("");
|
|
929
|
-
console.log(import_chalk5.default.bold.green("\u{1F680} Link Complete! Your environment is ready."));
|
|
930
984
|
} catch (error) {
|
|
931
985
|
if (error.message.includes("Not authenticated")) {
|
|
932
|
-
console.warn(
|
|
986
|
+
console.warn(import_chalk6.default.yellow('\u26A0\uFE0F Not authenticated. Run "rigstate login" to enable automation features.'));
|
|
933
987
|
} else {
|
|
934
|
-
console.error(
|
|
988
|
+
console.error(import_chalk6.default.red(`Failed to link project: ${error.message}`));
|
|
935
989
|
}
|
|
936
990
|
}
|
|
937
991
|
});
|
|
938
992
|
}
|
|
939
993
|
async function installHooks(cwd) {
|
|
940
|
-
const
|
|
994
|
+
const fs22 = await import("fs/promises");
|
|
941
995
|
const path23 = await import("path");
|
|
942
996
|
try {
|
|
943
|
-
await
|
|
997
|
+
await fs22.access(path23.join(cwd, ".git"));
|
|
944
998
|
} catch {
|
|
945
|
-
console.log(
|
|
999
|
+
console.log(import_chalk6.default.dim(" (Not a git repository, skipping hooks)"));
|
|
946
1000
|
return;
|
|
947
1001
|
}
|
|
948
1002
|
const hooksDir = path23.join(cwd, ".husky");
|
|
@@ -950,10 +1004,10 @@ async function installHooks(cwd) {
|
|
|
950
1004
|
const { installHooks: runInstall } = await Promise.resolve().then(() => (init_hooks(), hooks_exports));
|
|
951
1005
|
const preCommitPath = path23.join(cwd, ".git/hooks/pre-commit");
|
|
952
1006
|
try {
|
|
953
|
-
await
|
|
954
|
-
console.log(
|
|
1007
|
+
await fs22.access(preCommitPath);
|
|
1008
|
+
console.log(import_chalk6.default.green(" \u2714 Git hooks already active"));
|
|
955
1009
|
} catch {
|
|
956
|
-
console.log(
|
|
1010
|
+
console.log(import_chalk6.default.yellow(' \u26A0\uFE0F Git hooks missing. Run "rigstate hooks install" to secure repo.'));
|
|
957
1011
|
}
|
|
958
1012
|
} catch (e) {
|
|
959
1013
|
}
|
|
@@ -962,9 +1016,9 @@ async function installHooks(cwd) {
|
|
|
962
1016
|
// src/commands/scan.ts
|
|
963
1017
|
init_cjs_shims();
|
|
964
1018
|
var import_commander6 = require("commander");
|
|
965
|
-
var
|
|
1019
|
+
var import_chalk7 = __toESM(require("chalk"), 1);
|
|
966
1020
|
var import_ora3 = __toESM(require("ora"), 1);
|
|
967
|
-
var
|
|
1021
|
+
var import_axios4 = __toESM(require("axios"), 1);
|
|
968
1022
|
var import_glob = require("glob");
|
|
969
1023
|
var import_promises5 = __toESM(require("fs/promises"), 1);
|
|
970
1024
|
var import_path5 = __toESM(require("path"), 1);
|
|
@@ -1053,13 +1107,13 @@ function createScanCommand() {
|
|
|
1053
1107
|
const projectId = options.project || getProjectId();
|
|
1054
1108
|
if (!projectId) {
|
|
1055
1109
|
console.warn(
|
|
1056
|
-
|
|
1110
|
+
import_chalk7.default.yellow(
|
|
1057
1111
|
"\u26A0\uFE0F No project ID specified. Use --project <id> or set a default."
|
|
1058
1112
|
)
|
|
1059
1113
|
);
|
|
1060
1114
|
}
|
|
1061
1115
|
const scanPath = import_path5.default.resolve(process.cwd(), targetPath);
|
|
1062
|
-
spinner.start(`Scanning ${
|
|
1116
|
+
spinner.start(`Scanning ${import_chalk7.default.cyan(scanPath)}...`);
|
|
1063
1117
|
const gitignorePatterns = await readGitignore(scanPath);
|
|
1064
1118
|
const pattern = import_path5.default.join(scanPath, "**/*");
|
|
1065
1119
|
const allFiles = await (0, import_glob.glob)(pattern, {
|
|
@@ -1072,7 +1126,7 @@ function createScanCommand() {
|
|
|
1072
1126
|
return isCodeFile(file) && !shouldIgnore(relativePath, gitignorePatterns);
|
|
1073
1127
|
});
|
|
1074
1128
|
if (codeFiles.length === 0) {
|
|
1075
|
-
spinner.warn(
|
|
1129
|
+
spinner.warn(import_chalk7.default.yellow("No code files found to scan."));
|
|
1076
1130
|
return;
|
|
1077
1131
|
}
|
|
1078
1132
|
spinner.text = `Found ${codeFiles.length} files. Scanning...`;
|
|
@@ -1085,7 +1139,7 @@ function createScanCommand() {
|
|
|
1085
1139
|
spinner.text = `Scanning ${i + 1}/${codeFiles.length}: ${relativePath}`;
|
|
1086
1140
|
try {
|
|
1087
1141
|
const content = await import_promises5.default.readFile(filePath, "utf-8");
|
|
1088
|
-
const response = await
|
|
1142
|
+
const response = await import_axios4.default.post(
|
|
1089
1143
|
`${apiUrl}/api/v1/audit`,
|
|
1090
1144
|
{
|
|
1091
1145
|
content,
|
|
@@ -1119,16 +1173,16 @@ function createScanCommand() {
|
|
|
1119
1173
|
});
|
|
1120
1174
|
}
|
|
1121
1175
|
} catch (fileError) {
|
|
1122
|
-
if (
|
|
1123
|
-
console.warn(
|
|
1176
|
+
if (import_axios4.default.isAxiosError(fileError)) {
|
|
1177
|
+
console.warn(import_chalk7.default.yellow(`
|
|
1124
1178
|
\u26A0\uFE0F Skipping ${relativePath}: ${fileError.message}`));
|
|
1125
1179
|
} else {
|
|
1126
|
-
console.warn(
|
|
1180
|
+
console.warn(import_chalk7.default.yellow(`
|
|
1127
1181
|
\u26A0\uFE0F Error reading ${relativePath}`));
|
|
1128
1182
|
}
|
|
1129
1183
|
}
|
|
1130
1184
|
}
|
|
1131
|
-
spinner.succeed(
|
|
1185
|
+
spinner.succeed(import_chalk7.default.green("\u2705 Scan completed!"));
|
|
1132
1186
|
const aggregatedResponse = {
|
|
1133
1187
|
results,
|
|
1134
1188
|
summary: {
|
|
@@ -1143,21 +1197,21 @@ function createScanCommand() {
|
|
|
1143
1197
|
printPrettyResults(aggregatedResponse);
|
|
1144
1198
|
}
|
|
1145
1199
|
} catch (error) {
|
|
1146
|
-
spinner.fail(
|
|
1147
|
-
if (
|
|
1200
|
+
spinner.fail(import_chalk7.default.red("\u274C Scan failed"));
|
|
1201
|
+
if (import_axios4.default.isAxiosError(error)) {
|
|
1148
1202
|
if (error.response) {
|
|
1149
|
-
console.error(
|
|
1203
|
+
console.error(import_chalk7.default.red("API Error:"), error.response.data);
|
|
1150
1204
|
} else if (error.request) {
|
|
1151
1205
|
console.error(
|
|
1152
|
-
|
|
1206
|
+
import_chalk7.default.red("Network Error:"),
|
|
1153
1207
|
"Could not reach the API. Is the server running?"
|
|
1154
1208
|
);
|
|
1155
1209
|
} else {
|
|
1156
|
-
console.error(
|
|
1210
|
+
console.error(import_chalk7.default.red("Error:"), error.message);
|
|
1157
1211
|
}
|
|
1158
1212
|
} else {
|
|
1159
1213
|
console.error(
|
|
1160
|
-
|
|
1214
|
+
import_chalk7.default.red("Error:"),
|
|
1161
1215
|
error instanceof Error ? error.message : "Unknown error"
|
|
1162
1216
|
);
|
|
1163
1217
|
}
|
|
@@ -1167,10 +1221,10 @@ function createScanCommand() {
|
|
|
1167
1221
|
}
|
|
1168
1222
|
function printPrettyResults(data) {
|
|
1169
1223
|
const { results, summary } = data;
|
|
1170
|
-
console.log("\n" +
|
|
1171
|
-
console.log(
|
|
1172
|
-
console.log(`Total Files Scanned: ${
|
|
1173
|
-
console.log(`Total Issues Found: ${
|
|
1224
|
+
console.log("\n" + import_chalk7.default.bold("\u{1F4CA} Scan Summary"));
|
|
1225
|
+
console.log(import_chalk7.default.dim("\u2500".repeat(60)));
|
|
1226
|
+
console.log(`Total Files Scanned: ${import_chalk7.default.cyan(summary.total_files)}`);
|
|
1227
|
+
console.log(`Total Issues Found: ${import_chalk7.default.yellow(summary.total_issues)}`);
|
|
1174
1228
|
if (summary.by_severity) {
|
|
1175
1229
|
console.log("\nIssues by Severity:");
|
|
1176
1230
|
Object.entries(summary.by_severity).forEach(([severity, count]) => {
|
|
@@ -1179,48 +1233,48 @@ function printPrettyResults(data) {
|
|
|
1179
1233
|
});
|
|
1180
1234
|
}
|
|
1181
1235
|
if (results && results.length > 0) {
|
|
1182
|
-
console.log("\n" +
|
|
1183
|
-
console.log(
|
|
1236
|
+
console.log("\n" + import_chalk7.default.bold("\u{1F50D} Detailed Results"));
|
|
1237
|
+
console.log(import_chalk7.default.dim("\u2500".repeat(60)));
|
|
1184
1238
|
results.forEach((result) => {
|
|
1185
1239
|
if (result.issues && result.issues.length > 0) {
|
|
1186
1240
|
console.log(`
|
|
1187
|
-
${
|
|
1241
|
+
${import_chalk7.default.bold(result.file_path)}`);
|
|
1188
1242
|
result.issues.forEach((issue) => {
|
|
1189
1243
|
const severityColor = getSeverityColor(issue.severity);
|
|
1190
|
-
const lineInfo = issue.line ?
|
|
1244
|
+
const lineInfo = issue.line ? import_chalk7.default.dim(`:${issue.line}`) : "";
|
|
1191
1245
|
console.log(
|
|
1192
1246
|
` ${severityColor(`[${issue.severity.toUpperCase()}]`)} ${issue.type}${lineInfo}`
|
|
1193
1247
|
);
|
|
1194
|
-
console.log(` ${
|
|
1248
|
+
console.log(` ${import_chalk7.default.dim(issue.message)}`);
|
|
1195
1249
|
});
|
|
1196
1250
|
}
|
|
1197
1251
|
});
|
|
1198
1252
|
}
|
|
1199
|
-
console.log("\n" +
|
|
1253
|
+
console.log("\n" + import_chalk7.default.dim("\u2500".repeat(60)));
|
|
1200
1254
|
}
|
|
1201
1255
|
function getSeverityColor(severity) {
|
|
1202
1256
|
switch (severity.toLowerCase()) {
|
|
1203
1257
|
case "critical":
|
|
1204
|
-
return
|
|
1258
|
+
return import_chalk7.default.red.bold;
|
|
1205
1259
|
case "high":
|
|
1206
|
-
return
|
|
1260
|
+
return import_chalk7.default.red;
|
|
1207
1261
|
case "medium":
|
|
1208
|
-
return
|
|
1262
|
+
return import_chalk7.default.yellow;
|
|
1209
1263
|
case "low":
|
|
1210
|
-
return
|
|
1264
|
+
return import_chalk7.default.blue;
|
|
1211
1265
|
case "info":
|
|
1212
|
-
return
|
|
1266
|
+
return import_chalk7.default.gray;
|
|
1213
1267
|
default:
|
|
1214
|
-
return
|
|
1268
|
+
return import_chalk7.default.white;
|
|
1215
1269
|
}
|
|
1216
1270
|
}
|
|
1217
1271
|
|
|
1218
1272
|
// src/commands/fix.ts
|
|
1219
1273
|
init_cjs_shims();
|
|
1220
1274
|
var import_commander7 = require("commander");
|
|
1221
|
-
var
|
|
1275
|
+
var import_chalk8 = __toESM(require("chalk"), 1);
|
|
1222
1276
|
var import_ora4 = __toESM(require("ora"), 1);
|
|
1223
|
-
var
|
|
1277
|
+
var import_axios5 = __toESM(require("axios"), 1);
|
|
1224
1278
|
var import_glob2 = require("glob");
|
|
1225
1279
|
var import_promises6 = __toESM(require("fs/promises"), 1);
|
|
1226
1280
|
var import_path6 = __toESM(require("path"), 1);
|
|
@@ -1235,7 +1289,7 @@ function createFixCommand() {
|
|
|
1235
1289
|
const apiUrl = getApiUrl();
|
|
1236
1290
|
const projectId = options.project || getProjectId();
|
|
1237
1291
|
if (!projectId) {
|
|
1238
|
-
console.log(
|
|
1292
|
+
console.log(import_chalk8.default.yellow("\u26A0\uFE0F Project ID is required for fixing. Using default or pass --project <id>"));
|
|
1239
1293
|
}
|
|
1240
1294
|
const scanPath = import_path6.default.resolve(process.cwd(), targetPath);
|
|
1241
1295
|
const gitignorePatterns = await readGitignore(scanPath);
|
|
@@ -1246,12 +1300,12 @@ function createFixCommand() {
|
|
|
1246
1300
|
return isCodeFile(file) && !shouldIgnore(relativePath, gitignorePatterns);
|
|
1247
1301
|
});
|
|
1248
1302
|
if (codeFiles.length === 0) {
|
|
1249
|
-
console.log(
|
|
1303
|
+
console.log(import_chalk8.default.yellow("No code files found."));
|
|
1250
1304
|
return;
|
|
1251
1305
|
}
|
|
1252
|
-
console.log(
|
|
1306
|
+
console.log(import_chalk8.default.bold(`
|
|
1253
1307
|
\u{1F9E0} Rigstate Fix Mode`));
|
|
1254
|
-
console.log(
|
|
1308
|
+
console.log(import_chalk8.default.dim(`Scanning ${codeFiles.length} files with Project Context...
|
|
1255
1309
|
`));
|
|
1256
1310
|
let fixedCount = 0;
|
|
1257
1311
|
for (let i = 0; i < codeFiles.length; i++) {
|
|
@@ -1260,7 +1314,7 @@ function createFixCommand() {
|
|
|
1260
1314
|
spinner.start(`Analyzing ${relativePath}...`);
|
|
1261
1315
|
try {
|
|
1262
1316
|
const content = await import_promises6.default.readFile(filePath, "utf-8");
|
|
1263
|
-
const response = await
|
|
1317
|
+
const response = await import_axios5.default.post(
|
|
1264
1318
|
`${apiUrl}/api/v1/audit`,
|
|
1265
1319
|
{ content, file_path: relativePath, project_id: projectId },
|
|
1266
1320
|
{ headers: { "Authorization": `Bearer ${apiKey}` }, timeout: 12e4 }
|
|
@@ -1270,22 +1324,22 @@ function createFixCommand() {
|
|
|
1270
1324
|
if (fixableIssues.length > 0) {
|
|
1271
1325
|
spinner.stop();
|
|
1272
1326
|
console.log(`
|
|
1273
|
-
${
|
|
1327
|
+
${import_chalk8.default.bold(relativePath)}: Found ${fixableIssues.length} fixable issues.`);
|
|
1274
1328
|
for (const issue of fixableIssues) {
|
|
1275
|
-
console.log(
|
|
1329
|
+
console.log(import_chalk8.default.red(`
|
|
1276
1330
|
[${issue.type}] ${issue.title}`));
|
|
1277
|
-
console.log(
|
|
1331
|
+
console.log(import_chalk8.default.dim(issue.suggestion || issue.message));
|
|
1278
1332
|
const diff = Diff.createTwoFilesPatch(relativePath, relativePath, content, issue.fixed_content, "Current", "Fixed");
|
|
1279
1333
|
console.log("\n" + diff.split("\n").slice(0, 15).join("\n") + (diff.split("\n").length > 15 ? "\n..." : ""));
|
|
1280
1334
|
const { apply } = await import_inquirer.default.prompt([{
|
|
1281
1335
|
type: "confirm",
|
|
1282
1336
|
name: "apply",
|
|
1283
|
-
message: `Apply this fix to ${
|
|
1337
|
+
message: `Apply this fix to ${import_chalk8.default.cyan(relativePath)}?`,
|
|
1284
1338
|
default: true
|
|
1285
1339
|
}]);
|
|
1286
1340
|
if (apply) {
|
|
1287
1341
|
await import_promises6.default.writeFile(filePath, issue.fixed_content);
|
|
1288
|
-
console.log(
|
|
1342
|
+
console.log(import_chalk8.default.green(`\u2705 Fixed applied!`));
|
|
1289
1343
|
fixedCount++;
|
|
1290
1344
|
if (issue.related_step_id) {
|
|
1291
1345
|
const { completeStep } = await import_inquirer.default.prompt([{
|
|
@@ -1296,20 +1350,20 @@ ${import_chalk7.default.bold(relativePath)}: Found ${fixableIssues.length} fixab
|
|
|
1296
1350
|
}]);
|
|
1297
1351
|
if (completeStep) {
|
|
1298
1352
|
try {
|
|
1299
|
-
await
|
|
1353
|
+
await import_axios5.default.post(
|
|
1300
1354
|
`${apiUrl}/api/v1/roadmap/update-status`,
|
|
1301
1355
|
{ step_id: issue.related_step_id, status: "COMPLETED", project_id: projectId },
|
|
1302
1356
|
{ headers: { "Authorization": `Bearer ${apiKey}` } }
|
|
1303
1357
|
);
|
|
1304
|
-
console.log(
|
|
1358
|
+
console.log(import_chalk8.default.green(`\u{1F680} Roadmap updated! Mission Control is in sync.`));
|
|
1305
1359
|
} catch (err) {
|
|
1306
|
-
console.error(
|
|
1360
|
+
console.error(import_chalk8.default.yellow(`Failed to update roadmap: ${err.message}`));
|
|
1307
1361
|
}
|
|
1308
1362
|
}
|
|
1309
1363
|
}
|
|
1310
1364
|
break;
|
|
1311
1365
|
} else {
|
|
1312
|
-
console.log(
|
|
1366
|
+
console.log(import_chalk8.default.dim("Skipped."));
|
|
1313
1367
|
}
|
|
1314
1368
|
}
|
|
1315
1369
|
} else {
|
|
@@ -1319,11 +1373,11 @@ ${import_chalk7.default.bold(relativePath)}: Found ${fixableIssues.length} fixab
|
|
|
1319
1373
|
}
|
|
1320
1374
|
}
|
|
1321
1375
|
spinner.stop();
|
|
1322
|
-
console.log(
|
|
1376
|
+
console.log(import_chalk8.default.bold.green(`
|
|
1323
1377
|
|
|
1324
1378
|
\u{1F680} Fix session complete!`));
|
|
1325
1379
|
console.log(`Frank fixed ${fixedCount} detected issues.`);
|
|
1326
|
-
console.log(
|
|
1380
|
+
console.log(import_chalk8.default.dim(`Run 'rigstate scan' to verify remaining issues.`));
|
|
1327
1381
|
} catch (error) {
|
|
1328
1382
|
spinner.fail("Fix session failed");
|
|
1329
1383
|
console.error(error.message);
|
|
@@ -1334,10 +1388,10 @@ ${import_chalk7.default.bold(relativePath)}: Found ${fixableIssues.length} fixab
|
|
|
1334
1388
|
// src/commands/sync.ts
|
|
1335
1389
|
init_cjs_shims();
|
|
1336
1390
|
var import_commander8 = require("commander");
|
|
1337
|
-
var
|
|
1391
|
+
var import_chalk12 = __toESM(require("chalk"), 1);
|
|
1338
1392
|
var import_ora5 = __toESM(require("ora"), 1);
|
|
1339
1393
|
init_config();
|
|
1340
|
-
var
|
|
1394
|
+
var import_axios8 = __toESM(require("axios"), 1);
|
|
1341
1395
|
var import_promises10 = __toESM(require("fs/promises"), 1);
|
|
1342
1396
|
var import_path10 = __toESM(require("path"), 1);
|
|
1343
1397
|
function createSyncCommand() {
|
|
@@ -1371,7 +1425,7 @@ function createSyncCommand() {
|
|
|
1371
1425
|
return;
|
|
1372
1426
|
}
|
|
1373
1427
|
const apiUrl = getApiUrl();
|
|
1374
|
-
const response = await
|
|
1428
|
+
const response = await import_axios8.default.get(`${apiUrl}/api/v1/roadmap`, {
|
|
1375
1429
|
params: { project_id: projectId },
|
|
1376
1430
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
1377
1431
|
});
|
|
@@ -1398,7 +1452,7 @@ function createSyncCommand() {
|
|
|
1398
1452
|
await import_promises10.default.writeFile(manifestPath, JSON.stringify(manifestContent, null, 2), "utf-8");
|
|
1399
1453
|
} catch (e) {
|
|
1400
1454
|
}
|
|
1401
|
-
console.log(
|
|
1455
|
+
console.log(import_chalk12.default.bold("\n\u{1F9E0} Agent Skills Provisioning..."));
|
|
1402
1456
|
try {
|
|
1403
1457
|
const { provisionSkills: provisionSkills2, generateSkillsDiscoveryBlock: generateSkillsDiscoveryBlock2 } = await Promise.resolve().then(() => (init_skills_provisioner(), skills_provisioner_exports));
|
|
1404
1458
|
const skills = await provisionSkills2(apiUrl, apiKey, projectId, process.cwd());
|
|
@@ -1418,11 +1472,11 @@ function createSyncCommand() {
|
|
|
1418
1472
|
}
|
|
1419
1473
|
}
|
|
1420
1474
|
await import_promises10.default.writeFile(cursorRulesPath, rulesContent, "utf-8");
|
|
1421
|
-
console.log(
|
|
1475
|
+
console.log(import_chalk12.default.dim(` Updated .cursorrules with skills discovery block`));
|
|
1422
1476
|
} catch (e) {
|
|
1423
1477
|
}
|
|
1424
1478
|
} catch (e) {
|
|
1425
|
-
console.log(
|
|
1479
|
+
console.log(import_chalk12.default.yellow(` \u26A0 Skills provisioning skipped: ${e.message}`));
|
|
1426
1480
|
}
|
|
1427
1481
|
try {
|
|
1428
1482
|
const logPath = import_path10.default.join(process.cwd(), ".rigstate", "logs", "last_execution.json");
|
|
@@ -1430,7 +1484,7 @@ function createSyncCommand() {
|
|
|
1430
1484
|
const logContent = await import_promises10.default.readFile(logPath, "utf-8");
|
|
1431
1485
|
const logData = JSON.parse(logContent);
|
|
1432
1486
|
if (logData.task_summary) {
|
|
1433
|
-
await
|
|
1487
|
+
await import_axios8.default.post(`${apiUrl}/api/v1/execution-logs`, {
|
|
1434
1488
|
project_id: projectId,
|
|
1435
1489
|
...logData,
|
|
1436
1490
|
agent_role: process.env.RIGSTATE_MODE === "SUPERVISOR" ? "SUPERVISOR" : "WORKER"
|
|
@@ -1438,7 +1492,7 @@ function createSyncCommand() {
|
|
|
1438
1492
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
1439
1493
|
});
|
|
1440
1494
|
await import_promises10.default.unlink(logPath);
|
|
1441
|
-
console.log(
|
|
1495
|
+
console.log(import_chalk12.default.dim(`\u2714 Mission Report uploaded.`));
|
|
1442
1496
|
}
|
|
1443
1497
|
} catch (e) {
|
|
1444
1498
|
if (e.code !== "ENOENT") {
|
|
@@ -1446,14 +1500,14 @@ function createSyncCommand() {
|
|
|
1446
1500
|
}
|
|
1447
1501
|
} catch (e) {
|
|
1448
1502
|
}
|
|
1449
|
-
spinner.succeed(
|
|
1450
|
-
console.log(
|
|
1503
|
+
spinner.succeed(import_chalk12.default.green(`Synced ${roadmap.length} roadmap steps for project "${project}"`));
|
|
1504
|
+
console.log(import_chalk12.default.dim(`Local files updated: roadmap.json`));
|
|
1451
1505
|
const { runGuardianWatchdog: runGuardianWatchdog2 } = await Promise.resolve().then(() => (init_watchdog(), watchdog_exports));
|
|
1452
1506
|
const settings = response.data.data.settings || {};
|
|
1453
1507
|
await runGuardianWatchdog2(process.cwd(), settings, projectId);
|
|
1454
|
-
console.log(
|
|
1508
|
+
console.log(import_chalk12.default.bold("\n\u{1F4E1} Agent Bridge Heartbeat..."));
|
|
1455
1509
|
try {
|
|
1456
|
-
const bridgeResponse = await
|
|
1510
|
+
const bridgeResponse = await import_axios8.default.get(`${apiUrl}/api/v1/agent/bridge`, {
|
|
1457
1511
|
params: { project_id: projectId },
|
|
1458
1512
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
1459
1513
|
});
|
|
@@ -1462,28 +1516,28 @@ function createSyncCommand() {
|
|
|
1462
1516
|
const pending = tasks.filter((t) => t.status === "PENDING");
|
|
1463
1517
|
const approved = tasks.filter((t) => t.status === "APPROVED");
|
|
1464
1518
|
if (pending.length > 0 || approved.length > 0) {
|
|
1465
|
-
console.log(
|
|
1466
|
-
console.log(
|
|
1519
|
+
console.log(import_chalk12.default.yellow(`\u26A0 Bridge Alert: ${pending.length} pending, ${approved.length} approved tasks found.`));
|
|
1520
|
+
console.log(import_chalk12.default.dim('Run "rigstate fix" to process these tasks or ensure your IDE MCP server is active.'));
|
|
1467
1521
|
} else {
|
|
1468
|
-
console.log(
|
|
1522
|
+
console.log(import_chalk12.default.green("\u2714 Heartbeat healthy. No pending bridge tasks."));
|
|
1469
1523
|
}
|
|
1470
1524
|
const pings = pending.filter((t) => t.proposal?.startsWith("ping"));
|
|
1471
1525
|
for (const ping of pings) {
|
|
1472
|
-
await
|
|
1526
|
+
await import_axios8.default.post(`${apiUrl}/api/v1/agent/bridge`, {
|
|
1473
1527
|
bridge_id: ping.id,
|
|
1474
1528
|
status: "COMPLETED",
|
|
1475
1529
|
summary: "Pong! CLI Sync Heartbeat confirmed."
|
|
1476
1530
|
}, {
|
|
1477
1531
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
1478
1532
|
});
|
|
1479
|
-
console.log(
|
|
1533
|
+
console.log(import_chalk12.default.cyan(`\u{1F3D3} Pong! Acknowledged heartbeat signal [${ping.id}]`));
|
|
1480
1534
|
}
|
|
1481
1535
|
}
|
|
1482
1536
|
} catch (e) {
|
|
1483
|
-
console.log(
|
|
1537
|
+
console.log(import_chalk12.default.yellow(`\u26A0 Could not verify Bridge status: ${e.message}`));
|
|
1484
1538
|
}
|
|
1485
1539
|
if (options.project) {
|
|
1486
|
-
console.log(
|
|
1540
|
+
console.log(import_chalk12.default.blue(`Project context saved. Future commands will use this project.`));
|
|
1487
1541
|
}
|
|
1488
1542
|
try {
|
|
1489
1543
|
const migrationDir = import_path10.default.join(process.cwd(), "supabase", "migrations");
|
|
@@ -1491,15 +1545,15 @@ function createSyncCommand() {
|
|
|
1491
1545
|
const sqlFiles = files.filter((f) => f.endsWith(".sql")).sort();
|
|
1492
1546
|
if (sqlFiles.length > 0) {
|
|
1493
1547
|
const latestMigration = sqlFiles[sqlFiles.length - 1];
|
|
1494
|
-
console.log(
|
|
1548
|
+
console.log(import_chalk12.default.dim(`
|
|
1495
1549
|
\u{1F6E1} Migration Guard:`));
|
|
1496
|
-
console.log(
|
|
1497
|
-
console.log(
|
|
1550
|
+
console.log(import_chalk12.default.dim(` Latest Local: ${latestMigration}`));
|
|
1551
|
+
console.log(import_chalk12.default.yellow(` \u26A0 Ensure DB schema matches this version. CLI cannot verify Remote RLS policies directly.`));
|
|
1498
1552
|
}
|
|
1499
1553
|
} catch (e) {
|
|
1500
1554
|
}
|
|
1501
1555
|
try {
|
|
1502
|
-
const vaultResponse = await
|
|
1556
|
+
const vaultResponse = await import_axios8.default.post(
|
|
1503
1557
|
`${apiUrl}/api/v1/vault/sync`,
|
|
1504
1558
|
{ project_id: projectId },
|
|
1505
1559
|
{ headers: { Authorization: `Bearer ${apiKey}` } }
|
|
@@ -1513,8 +1567,8 @@ function createSyncCommand() {
|
|
|
1513
1567
|
} catch (e) {
|
|
1514
1568
|
}
|
|
1515
1569
|
if (vaultContent.trim() !== localContent.trim()) {
|
|
1516
|
-
console.log(
|
|
1517
|
-
console.log(
|
|
1570
|
+
console.log(import_chalk12.default.bold("\n\u{1F510} Sovereign Foundation (Vault):"));
|
|
1571
|
+
console.log(import_chalk12.default.yellow(" Status: Drift Detected / Update Available"));
|
|
1518
1572
|
const { syncVault } = await import("inquirer").then((m) => m.default.prompt([{
|
|
1519
1573
|
type: "confirm",
|
|
1520
1574
|
name: "syncVault",
|
|
@@ -1523,24 +1577,24 @@ function createSyncCommand() {
|
|
|
1523
1577
|
}]));
|
|
1524
1578
|
if (syncVault) {
|
|
1525
1579
|
await import_promises10.default.writeFile(localEnvPath, vaultContent, "utf-8");
|
|
1526
|
-
console.log(
|
|
1580
|
+
console.log(import_chalk12.default.green(" \u2705 .env.local synchronized with Vault."));
|
|
1527
1581
|
} else {
|
|
1528
|
-
console.log(
|
|
1582
|
+
console.log(import_chalk12.default.dim(" Skipped vault sync."));
|
|
1529
1583
|
}
|
|
1530
1584
|
} else {
|
|
1531
|
-
console.log(
|
|
1585
|
+
console.log(import_chalk12.default.dim("\n\u{1F510} Sovereign Foundation: Synced."));
|
|
1532
1586
|
}
|
|
1533
1587
|
}
|
|
1534
1588
|
} catch (e) {
|
|
1535
1589
|
}
|
|
1536
|
-
console.log(
|
|
1590
|
+
console.log(import_chalk12.default.dim("\n\u{1F6E1}\uFE0F System Integrity Check..."));
|
|
1537
1591
|
await checkSystemIntegrity(apiUrl, apiKey, projectId);
|
|
1538
1592
|
} catch (error) {
|
|
1539
|
-
if (
|
|
1593
|
+
if (import_axios8.default.isAxiosError(error)) {
|
|
1540
1594
|
const message = error.response?.data?.error || error.message;
|
|
1541
|
-
spinner.fail(
|
|
1595
|
+
spinner.fail(import_chalk12.default.red(`Sync failed: ${message}`));
|
|
1542
1596
|
} else {
|
|
1543
|
-
spinner.fail(
|
|
1597
|
+
spinner.fail(import_chalk12.default.red("Sync failed: " + (error.message || "Unknown error")));
|
|
1544
1598
|
}
|
|
1545
1599
|
}
|
|
1546
1600
|
});
|
|
@@ -1548,7 +1602,7 @@ function createSyncCommand() {
|
|
|
1548
1602
|
}
|
|
1549
1603
|
async function checkSystemIntegrity(apiUrl, apiKey, projectId) {
|
|
1550
1604
|
try {
|
|
1551
|
-
const response = await
|
|
1605
|
+
const response = await import_axios8.default.get(`${apiUrl}/api/v1/system/integrity`, {
|
|
1552
1606
|
params: { project_id: projectId },
|
|
1553
1607
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
1554
1608
|
});
|
|
@@ -1556,44 +1610,44 @@ async function checkSystemIntegrity(apiUrl, apiKey, projectId) {
|
|
|
1556
1610
|
const { migrations, rls, guardian_violations } = response.data.data;
|
|
1557
1611
|
if (migrations) {
|
|
1558
1612
|
if (migrations.in_sync) {
|
|
1559
|
-
console.log(
|
|
1613
|
+
console.log(import_chalk12.default.green(` \u2705 Migrations synced (${migrations.count} versions)`));
|
|
1560
1614
|
} else {
|
|
1561
|
-
console.log(
|
|
1615
|
+
console.log(import_chalk12.default.red(` \u{1F6D1} CRITICAL: DB Schema out of sync! ${migrations.missing?.length || 0} migrations not applied.`));
|
|
1562
1616
|
if (migrations.missing?.length > 0) {
|
|
1563
|
-
console.log(
|
|
1617
|
+
console.log(import_chalk12.default.dim(` Missing: ${migrations.missing.slice(0, 3).join(", ")}${migrations.missing.length > 3 ? "..." : ""}`));
|
|
1564
1618
|
}
|
|
1565
|
-
console.log(
|
|
1619
|
+
console.log(import_chalk12.default.yellow(` Run 'supabase db push' or apply migrations immediately.`));
|
|
1566
1620
|
}
|
|
1567
1621
|
}
|
|
1568
1622
|
if (rls) {
|
|
1569
1623
|
if (rls.all_secured) {
|
|
1570
|
-
console.log(
|
|
1624
|
+
console.log(import_chalk12.default.green(` \u2705 RLS Audit Passed (${rls.table_count} tables secured)`));
|
|
1571
1625
|
} else {
|
|
1572
|
-
console.log(
|
|
1626
|
+
console.log(import_chalk12.default.red(` \u{1F6D1} CRITICAL: Security Vulnerability! ${rls.unsecured?.length || 0} tables have RLS disabled.`));
|
|
1573
1627
|
rls.unsecured?.forEach((table) => {
|
|
1574
|
-
console.log(
|
|
1628
|
+
console.log(import_chalk12.default.red(` - ${table}`));
|
|
1575
1629
|
});
|
|
1576
|
-
console.log(
|
|
1630
|
+
console.log(import_chalk12.default.yellow(' Enable RLS immediately: ALTER TABLE "table" ENABLE ROW LEVEL SECURITY;'));
|
|
1577
1631
|
}
|
|
1578
1632
|
}
|
|
1579
1633
|
if (guardian_violations) {
|
|
1580
1634
|
if (guardian_violations.count === 0) {
|
|
1581
|
-
console.log(
|
|
1635
|
+
console.log(import_chalk12.default.green(" \u2705 Guardian: No active violations"));
|
|
1582
1636
|
} else {
|
|
1583
|
-
console.log(
|
|
1584
|
-
console.log(
|
|
1637
|
+
console.log(import_chalk12.default.yellow(` \u26A0\uFE0F Guardian: ${guardian_violations.count} active violations`));
|
|
1638
|
+
console.log(import_chalk12.default.dim(' Run "rigstate check" for details.'));
|
|
1585
1639
|
}
|
|
1586
1640
|
}
|
|
1587
1641
|
}
|
|
1588
1642
|
} catch (e) {
|
|
1589
|
-
console.log(
|
|
1643
|
+
console.log(import_chalk12.default.dim(" (System integrity check skipped - API endpoint not available)"));
|
|
1590
1644
|
}
|
|
1591
1645
|
}
|
|
1592
1646
|
|
|
1593
1647
|
// src/commands/init.ts
|
|
1594
1648
|
init_cjs_shims();
|
|
1595
1649
|
var import_commander9 = require("commander");
|
|
1596
|
-
var
|
|
1650
|
+
var import_chalk13 = __toESM(require("chalk"), 1);
|
|
1597
1651
|
var import_promises12 = __toESM(require("fs/promises"), 1);
|
|
1598
1652
|
var import_path12 = __toESM(require("path"), 1);
|
|
1599
1653
|
var import_ora6 = __toESM(require("ora"), 1);
|
|
@@ -1615,7 +1669,7 @@ async function loadManifest() {
|
|
|
1615
1669
|
|
|
1616
1670
|
// src/commands/init.ts
|
|
1617
1671
|
init_config();
|
|
1618
|
-
var
|
|
1672
|
+
var import_axios9 = __toESM(require("axios"), 1);
|
|
1619
1673
|
function createInitCommand() {
|
|
1620
1674
|
return new import_commander9.Command("init").description("Initialize or link a Rigstate project (interactive mode available)").argument("[project-id]", "ID of the project to link (optional, prompts if not provided)").option("-f, --force", "Overwrite existing .cursorrules file").option("--rules-only", "Only regenerate .cursorrules without interactive setup").action(async (projectIdArg, options) => {
|
|
1621
1675
|
const spinner = (0, import_ora6.default)("Initializing Rigstate project...").start();
|
|
@@ -1623,7 +1677,7 @@ function createInitCommand() {
|
|
|
1623
1677
|
try {
|
|
1624
1678
|
apiKey = getApiKey();
|
|
1625
1679
|
} catch (e) {
|
|
1626
|
-
spinner.fail(
|
|
1680
|
+
spinner.fail(import_chalk13.default.red('Not authenticated. Run "rigstate login" first.'));
|
|
1627
1681
|
return;
|
|
1628
1682
|
}
|
|
1629
1683
|
const apiUrl = getApiUrl();
|
|
@@ -1641,11 +1695,11 @@ function createInitCommand() {
|
|
|
1641
1695
|
}
|
|
1642
1696
|
if (!projectId) {
|
|
1643
1697
|
spinner.stop();
|
|
1644
|
-
const
|
|
1698
|
+
const inquirer5 = (await import("inquirer")).default;
|
|
1645
1699
|
spinner.start("Fetching your projects...");
|
|
1646
1700
|
let projects = [];
|
|
1647
1701
|
try {
|
|
1648
|
-
const projectsResponse = await
|
|
1702
|
+
const projectsResponse = await import_axios9.default.get(`${apiUrl}/api/v1/projects`, {
|
|
1649
1703
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
1650
1704
|
});
|
|
1651
1705
|
if (projectsResponse.data.success) {
|
|
@@ -1656,7 +1710,7 @@ function createInitCommand() {
|
|
|
1656
1710
|
}
|
|
1657
1711
|
spinner.stop();
|
|
1658
1712
|
if (projects.length === 0) {
|
|
1659
|
-
const { manualProjectId } = await
|
|
1713
|
+
const { manualProjectId } = await inquirer5.prompt([
|
|
1660
1714
|
{
|
|
1661
1715
|
type: "input",
|
|
1662
1716
|
name: "manualProjectId",
|
|
@@ -1668,7 +1722,7 @@ function createInitCommand() {
|
|
|
1668
1722
|
} else {
|
|
1669
1723
|
const choices = [
|
|
1670
1724
|
{ name: "\u2795 Create New Project", value: "NEW" },
|
|
1671
|
-
new
|
|
1725
|
+
new inquirer5.Separator()
|
|
1672
1726
|
];
|
|
1673
1727
|
projects.forEach((p) => {
|
|
1674
1728
|
choices.push({
|
|
@@ -1676,7 +1730,7 @@ function createInitCommand() {
|
|
|
1676
1730
|
value: p.id
|
|
1677
1731
|
});
|
|
1678
1732
|
});
|
|
1679
|
-
const { selectedId } = await
|
|
1733
|
+
const { selectedId } = await inquirer5.prompt([
|
|
1680
1734
|
{
|
|
1681
1735
|
type: "list",
|
|
1682
1736
|
name: "selectedId",
|
|
@@ -1686,7 +1740,7 @@ function createInitCommand() {
|
|
|
1686
1740
|
}
|
|
1687
1741
|
]);
|
|
1688
1742
|
if (selectedId === "NEW") {
|
|
1689
|
-
const { newName } = await
|
|
1743
|
+
const { newName } = await inquirer5.prompt([
|
|
1690
1744
|
{
|
|
1691
1745
|
type: "input",
|
|
1692
1746
|
name: "newName",
|
|
@@ -1697,7 +1751,7 @@ function createInitCommand() {
|
|
|
1697
1751
|
spinner.start("Fetching organizations...");
|
|
1698
1752
|
let orgs = [];
|
|
1699
1753
|
try {
|
|
1700
|
-
const orgsResponse = await
|
|
1754
|
+
const orgsResponse = await import_axios9.default.get(`${apiUrl}/api/v1/organizations`, {
|
|
1701
1755
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
1702
1756
|
});
|
|
1703
1757
|
orgs = orgsResponse.data.data?.organizations || [];
|
|
@@ -1706,7 +1760,7 @@ function createInitCommand() {
|
|
|
1706
1760
|
spinner.stop();
|
|
1707
1761
|
let selectedOrgId = orgs[0]?.id;
|
|
1708
1762
|
if (orgs.length > 1) {
|
|
1709
|
-
const { orgId } = await
|
|
1763
|
+
const { orgId } = await inquirer5.prompt([
|
|
1710
1764
|
{
|
|
1711
1765
|
type: "list",
|
|
1712
1766
|
name: "orgId",
|
|
@@ -1720,25 +1774,25 @@ function createInitCommand() {
|
|
|
1720
1774
|
selectedOrgId = orgId;
|
|
1721
1775
|
}
|
|
1722
1776
|
if (!selectedOrgId) {
|
|
1723
|
-
console.log(
|
|
1777
|
+
console.log(import_chalk13.default.yellow("No organization available. Please create the project via the Rigstate dashboard."));
|
|
1724
1778
|
return;
|
|
1725
1779
|
}
|
|
1726
1780
|
spinner.start("Creating new project...");
|
|
1727
1781
|
try {
|
|
1728
|
-
const createResponse = await
|
|
1782
|
+
const createResponse = await import_axios9.default.post(`${apiUrl}/api/v1/projects`, {
|
|
1729
1783
|
name: newName,
|
|
1730
1784
|
organization_id: selectedOrgId
|
|
1731
1785
|
}, {
|
|
1732
1786
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
1733
1787
|
});
|
|
1734
1788
|
if (!createResponse.data.success) {
|
|
1735
|
-
spinner.fail(
|
|
1789
|
+
spinner.fail(import_chalk13.default.red("Failed to create project: " + createResponse.data.error));
|
|
1736
1790
|
return;
|
|
1737
1791
|
}
|
|
1738
1792
|
projectId = createResponse.data.data.project.id;
|
|
1739
|
-
spinner.succeed(
|
|
1793
|
+
spinner.succeed(import_chalk13.default.green(`Created new project: ${newName}`));
|
|
1740
1794
|
} catch (e) {
|
|
1741
|
-
spinner.fail(
|
|
1795
|
+
spinner.fail(import_chalk13.default.red("Project creation API not available. Please create via dashboard."));
|
|
1742
1796
|
return;
|
|
1743
1797
|
}
|
|
1744
1798
|
} else {
|
|
@@ -1761,22 +1815,22 @@ function createInitCommand() {
|
|
|
1761
1815
|
spinner.text = "Initializing git repository...";
|
|
1762
1816
|
(0, import_child_process.execSync)("git init", { stdio: "ignore" });
|
|
1763
1817
|
}
|
|
1764
|
-
spinner.succeed(
|
|
1818
|
+
spinner.succeed(import_chalk13.default.green(`\u2705 Linked to project: ${projectId}`));
|
|
1765
1819
|
await generateRules(apiUrl, apiKey, projectId, options.force, spinner);
|
|
1766
1820
|
console.log("");
|
|
1767
|
-
console.log(
|
|
1768
|
-
console.log(
|
|
1769
|
-
console.log(
|
|
1770
|
-
console.log(
|
|
1821
|
+
console.log(import_chalk13.default.blue("Next steps:"));
|
|
1822
|
+
console.log(import_chalk13.default.dim(" rigstate sync - Sync roadmap and context"));
|
|
1823
|
+
console.log(import_chalk13.default.dim(" rigstate watch - Start development loop"));
|
|
1824
|
+
console.log(import_chalk13.default.dim(" rigstate focus - Get current task"));
|
|
1771
1825
|
} catch (e) {
|
|
1772
|
-
spinner.fail(
|
|
1826
|
+
spinner.fail(import_chalk13.default.red("Initialization failed: " + e.message));
|
|
1773
1827
|
}
|
|
1774
1828
|
});
|
|
1775
1829
|
}
|
|
1776
1830
|
async function generateRules(apiUrl, apiKey, projectId, force, spinner) {
|
|
1777
1831
|
spinner.start("Generating AI rules (MDC + AGENTS.md)...");
|
|
1778
1832
|
try {
|
|
1779
|
-
const response = await
|
|
1833
|
+
const response = await import_axios9.default.post(`${apiUrl}/api/v1/rules/generate`, {
|
|
1780
1834
|
project_id: projectId
|
|
1781
1835
|
}, {
|
|
1782
1836
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
@@ -1786,7 +1840,7 @@ async function generateRules(apiUrl, apiKey, projectId, force, spinner) {
|
|
|
1786
1840
|
if (files.length === 0 && response.data.rules) {
|
|
1787
1841
|
const rulesPath = import_path12.default.join(process.cwd(), ".cursorrules");
|
|
1788
1842
|
await import_promises12.default.writeFile(rulesPath, response.data.rules, "utf-8");
|
|
1789
|
-
spinner.succeed(
|
|
1843
|
+
spinner.succeed(import_chalk13.default.green("\u2714 Generated .cursorrules (legacy mode)"));
|
|
1790
1844
|
return;
|
|
1791
1845
|
}
|
|
1792
1846
|
for (const file of files) {
|
|
@@ -1796,7 +1850,7 @@ async function generateRules(apiUrl, apiKey, projectId, force, spinner) {
|
|
|
1796
1850
|
try {
|
|
1797
1851
|
await import_promises12.default.access(targetPath);
|
|
1798
1852
|
if (!force && !file.path.startsWith(".cursor/rules/")) {
|
|
1799
|
-
console.log(
|
|
1853
|
+
console.log(import_chalk13.default.dim(` ${file.path} already exists. Skipping.`));
|
|
1800
1854
|
continue;
|
|
1801
1855
|
}
|
|
1802
1856
|
} catch {
|
|
@@ -1809,26 +1863,26 @@ async function generateRules(apiUrl, apiKey, projectId, force, spinner) {
|
|
|
1809
1863
|
const stats = await import_promises12.default.stat(legacyPath);
|
|
1810
1864
|
if (stats.isFile()) {
|
|
1811
1865
|
await import_promises12.default.rename(legacyPath, `${legacyPath}.bak`);
|
|
1812
|
-
console.log(
|
|
1866
|
+
console.log(import_chalk13.default.dim(" Moved legacy .cursorrules to .cursorrules.bak"));
|
|
1813
1867
|
}
|
|
1814
1868
|
} catch (e) {
|
|
1815
1869
|
}
|
|
1816
1870
|
}
|
|
1817
|
-
spinner.succeed(
|
|
1871
|
+
spinner.succeed(import_chalk13.default.green(`\u2714 Generated ${files.length} rule files (v${response.data.version || "3.0"})`));
|
|
1818
1872
|
} else {
|
|
1819
|
-
spinner.info(
|
|
1873
|
+
spinner.info(import_chalk13.default.dim(" Rules generation skipped (API response invalid)"));
|
|
1820
1874
|
}
|
|
1821
1875
|
} catch (e) {
|
|
1822
|
-
spinner.info(
|
|
1876
|
+
spinner.info(import_chalk13.default.dim(` Rules generation failed: ${e.message}`));
|
|
1823
1877
|
}
|
|
1824
1878
|
}
|
|
1825
1879
|
|
|
1826
1880
|
// src/commands/check.ts
|
|
1827
1881
|
init_cjs_shims();
|
|
1828
1882
|
var import_commander10 = require("commander");
|
|
1829
|
-
var
|
|
1883
|
+
var import_chalk15 = __toESM(require("chalk"), 1);
|
|
1830
1884
|
var import_ora7 = __toESM(require("ora"), 1);
|
|
1831
|
-
var
|
|
1885
|
+
var import_axios10 = __toESM(require("axios"), 1);
|
|
1832
1886
|
var import_glob3 = require("glob");
|
|
1833
1887
|
var import_promises14 = __toESM(require("fs/promises"), 1);
|
|
1834
1888
|
var import_path14 = __toESM(require("path"), 1);
|
|
@@ -1839,7 +1893,7 @@ init_config();
|
|
|
1839
1893
|
init_cjs_shims();
|
|
1840
1894
|
var import_promises13 = __toESM(require("fs/promises"), 1);
|
|
1841
1895
|
var import_path13 = __toESM(require("path"), 1);
|
|
1842
|
-
var
|
|
1896
|
+
var import_chalk14 = __toESM(require("chalk"), 1);
|
|
1843
1897
|
async function checkFile(filePath, rules, rootPath) {
|
|
1844
1898
|
const violations = [];
|
|
1845
1899
|
const relativePath = import_path13.default.relative(rootPath, filePath);
|
|
@@ -1994,12 +2048,12 @@ function checkFunctionLines(content, lines, filePath, rule, limit) {
|
|
|
1994
2048
|
}
|
|
1995
2049
|
function formatViolations(violations) {
|
|
1996
2050
|
for (const v of violations) {
|
|
1997
|
-
const severityColor = v.severity === "critical" ?
|
|
1998
|
-
const lineInfo = v.line ?
|
|
2051
|
+
const severityColor = v.severity === "critical" ? import_chalk14.default.red : v.severity === "warning" ? import_chalk14.default.yellow : import_chalk14.default.blue;
|
|
2052
|
+
const lineInfo = v.line ? import_chalk14.default.dim(`:${v.line}`) : "";
|
|
1999
2053
|
console.log(` ${severityColor(`[${v.severity.toUpperCase()}]`)} ${v.file}${lineInfo}`);
|
|
2000
2054
|
console.log(` ${v.message}`);
|
|
2001
2055
|
if (v.details) {
|
|
2002
|
-
console.log(` ${
|
|
2056
|
+
console.log(` ${import_chalk14.default.dim(v.details)}`);
|
|
2003
2057
|
}
|
|
2004
2058
|
}
|
|
2005
2059
|
}
|
|
@@ -2044,15 +2098,15 @@ function createCheckCommand() {
|
|
|
2044
2098
|
projectId = getProjectId();
|
|
2045
2099
|
}
|
|
2046
2100
|
if (!projectId) {
|
|
2047
|
-
console.log(
|
|
2048
|
-
console.log(
|
|
2101
|
+
console.log(import_chalk15.default.red("\u274C No project context found."));
|
|
2102
|
+
console.log(import_chalk15.default.dim(' Run "rigstate link" or pass --project <id>'));
|
|
2049
2103
|
process.exit(2);
|
|
2050
2104
|
}
|
|
2051
2105
|
let apiKey;
|
|
2052
2106
|
try {
|
|
2053
2107
|
apiKey = getApiKey();
|
|
2054
2108
|
} catch {
|
|
2055
|
-
console.log(
|
|
2109
|
+
console.log(import_chalk15.default.red('\u274C Not authenticated. Run "rigstate login" first.'));
|
|
2056
2110
|
process.exit(2);
|
|
2057
2111
|
}
|
|
2058
2112
|
spinner.start("Fetching Guardian rules...");
|
|
@@ -2065,7 +2119,7 @@ function createCheckCommand() {
|
|
|
2065
2119
|
settings = cached.settings;
|
|
2066
2120
|
spinner.text = "Using cached rules...";
|
|
2067
2121
|
} else {
|
|
2068
|
-
const response = await
|
|
2122
|
+
const response = await import_axios10.default.get(`${apiUrl}/api/v1/guardian/rules`, {
|
|
2069
2123
|
params: { project_id: projectId },
|
|
2070
2124
|
headers: { Authorization: `Bearer ${apiKey}` },
|
|
2071
2125
|
timeout: 1e4
|
|
@@ -2080,12 +2134,12 @@ function createCheckCommand() {
|
|
|
2080
2134
|
} catch (apiError) {
|
|
2081
2135
|
const cached = await loadCachedRules(projectId);
|
|
2082
2136
|
if (cached && !isStale(cached.timestamp, CACHE_MAX_AGE_MS)) {
|
|
2083
|
-
spinner.warn(
|
|
2137
|
+
spinner.warn(import_chalk15.default.yellow("Using cached rules (API unavailable)"));
|
|
2084
2138
|
rules = cached.rules;
|
|
2085
2139
|
settings = cached.settings;
|
|
2086
2140
|
} else {
|
|
2087
|
-
spinner.fail(
|
|
2088
|
-
console.log(
|
|
2141
|
+
spinner.fail(import_chalk15.default.red("Failed to fetch rules and no valid cache"));
|
|
2142
|
+
console.log(import_chalk15.default.dim(` Error: ${apiError.message}`));
|
|
2089
2143
|
process.exit(2);
|
|
2090
2144
|
}
|
|
2091
2145
|
}
|
|
@@ -2105,7 +2159,7 @@ function createCheckCommand() {
|
|
|
2105
2159
|
process.exit(2);
|
|
2106
2160
|
}
|
|
2107
2161
|
} else {
|
|
2108
|
-
spinner.start(`Scanning ${
|
|
2162
|
+
spinner.start(`Scanning ${import_chalk15.default.cyan(targetPath)}...`);
|
|
2109
2163
|
const pattern = import_path14.default.join(scanPath, "**/*");
|
|
2110
2164
|
const allFiles = await (0, import_glob3.glob)(pattern, {
|
|
2111
2165
|
nodir: true,
|
|
@@ -2122,7 +2176,7 @@ function createCheckCommand() {
|
|
|
2122
2176
|
filesToCheck = allFiles.filter((f) => isCodeFile2(f));
|
|
2123
2177
|
}
|
|
2124
2178
|
if (filesToCheck.length === 0) {
|
|
2125
|
-
spinner.warn(
|
|
2179
|
+
spinner.warn(import_chalk15.default.yellow("No code files found to check."));
|
|
2126
2180
|
outputResults([], !!options.json);
|
|
2127
2181
|
process.exit(0);
|
|
2128
2182
|
}
|
|
@@ -2141,34 +2195,34 @@ function createCheckCommand() {
|
|
|
2141
2195
|
outputResults(results, true);
|
|
2142
2196
|
} else {
|
|
2143
2197
|
outputResults(results, false);
|
|
2144
|
-
console.log("\n" +
|
|
2145
|
-
console.log(
|
|
2146
|
-
console.log(`Files checked: ${
|
|
2147
|
-
console.log(`Total violations: ${summary.totalViolations > 0 ?
|
|
2198
|
+
console.log("\n" + import_chalk15.default.bold("\u{1F4CA} Summary"));
|
|
2199
|
+
console.log(import_chalk15.default.dim("\u2500".repeat(50)));
|
|
2200
|
+
console.log(`Files checked: ${import_chalk15.default.cyan(summary.totalFiles)}`);
|
|
2201
|
+
console.log(`Total violations: ${summary.totalViolations > 0 ? import_chalk15.default.red(summary.totalViolations) : import_chalk15.default.green(0)}`);
|
|
2148
2202
|
if (summary.totalViolations > 0) {
|
|
2149
|
-
console.log(` ${
|
|
2150
|
-
console.log(` ${
|
|
2151
|
-
console.log(` ${
|
|
2203
|
+
console.log(` ${import_chalk15.default.red("Critical:")} ${summary.criticalCount}`);
|
|
2204
|
+
console.log(` ${import_chalk15.default.yellow("Warning:")} ${summary.warningCount}`);
|
|
2205
|
+
console.log(` ${import_chalk15.default.blue("Info:")} ${summary.infoCount}`);
|
|
2152
2206
|
}
|
|
2153
|
-
console.log(
|
|
2207
|
+
console.log(import_chalk15.default.dim("\u2500".repeat(50)));
|
|
2154
2208
|
}
|
|
2155
2209
|
if (options.strict !== void 0) {
|
|
2156
2210
|
const strictLevel = typeof options.strict === "string" ? options.strict : "all";
|
|
2157
2211
|
if (strictLevel === "critical" && summary.criticalCount > 0) {
|
|
2158
|
-
console.log(
|
|
2212
|
+
console.log(import_chalk15.default.red("\n\u274C Check failed: Critical violations found"));
|
|
2159
2213
|
process.exit(1);
|
|
2160
2214
|
} else if (strictLevel === "all" && summary.totalViolations > 0) {
|
|
2161
|
-
console.log(
|
|
2215
|
+
console.log(import_chalk15.default.red("\n\u274C Check failed: Violations found"));
|
|
2162
2216
|
process.exit(1);
|
|
2163
2217
|
}
|
|
2164
2218
|
}
|
|
2165
2219
|
if (summary.totalViolations === 0) {
|
|
2166
|
-
console.log(
|
|
2220
|
+
console.log(import_chalk15.default.green("\n\u2705 All checks passed!"));
|
|
2167
2221
|
}
|
|
2168
2222
|
process.exit(0);
|
|
2169
2223
|
} catch (error) {
|
|
2170
|
-
spinner.fail(
|
|
2171
|
-
console.error(
|
|
2224
|
+
spinner.fail(import_chalk15.default.red("Check failed"));
|
|
2225
|
+
console.error(import_chalk15.default.red("Error:"), error.message);
|
|
2172
2226
|
process.exit(2);
|
|
2173
2227
|
}
|
|
2174
2228
|
});
|
|
@@ -2224,8 +2278,8 @@ function outputResults(results, json) {
|
|
|
2224
2278
|
if (!hasViolations) {
|
|
2225
2279
|
return;
|
|
2226
2280
|
}
|
|
2227
|
-
console.log("\n" +
|
|
2228
|
-
console.log(
|
|
2281
|
+
console.log("\n" + import_chalk15.default.bold("\u{1F50D} Violations Found"));
|
|
2282
|
+
console.log(import_chalk15.default.dim("\u2500".repeat(50)));
|
|
2229
2283
|
for (const result of results) {
|
|
2230
2284
|
if (result.violations.length > 0) {
|
|
2231
2285
|
formatViolations(result.violations);
|
|
@@ -2239,7 +2293,7 @@ init_hooks();
|
|
|
2239
2293
|
// src/commands/daemon.ts
|
|
2240
2294
|
init_cjs_shims();
|
|
2241
2295
|
var import_commander11 = require("commander");
|
|
2242
|
-
var
|
|
2296
|
+
var import_chalk18 = __toESM(require("chalk"), 1);
|
|
2243
2297
|
var import_ora8 = __toESM(require("ora"), 1);
|
|
2244
2298
|
var import_promises17 = __toESM(require("fs/promises"), 1);
|
|
2245
2299
|
var import_path19 = __toESM(require("path"), 1);
|
|
@@ -2249,7 +2303,7 @@ init_cjs_shims();
|
|
|
2249
2303
|
|
|
2250
2304
|
// src/daemon/core.ts
|
|
2251
2305
|
init_cjs_shims();
|
|
2252
|
-
var
|
|
2306
|
+
var import_chalk17 = __toESM(require("chalk"), 1);
|
|
2253
2307
|
var fs17 = __toESM(require("fs/promises"), 1);
|
|
2254
2308
|
var import_events3 = require("events");
|
|
2255
2309
|
|
|
@@ -2343,7 +2397,7 @@ init_cjs_shims();
|
|
|
2343
2397
|
var import_promises15 = require("fs/promises");
|
|
2344
2398
|
var import_path16 = require("path");
|
|
2345
2399
|
var import_path17 = __toESM(require("path"), 1);
|
|
2346
|
-
var
|
|
2400
|
+
var import_axios11 = __toESM(require("axios"), 1);
|
|
2347
2401
|
var GLOBAL_HEURISTICS = [
|
|
2348
2402
|
{
|
|
2349
2403
|
skillId: "payment-expert",
|
|
@@ -2393,7 +2447,7 @@ var HeuristicEngine = class {
|
|
|
2393
2447
|
try {
|
|
2394
2448
|
await (0, import_promises15.mkdir)((0, import_path16.dirname)(this.cachePath), { recursive: true });
|
|
2395
2449
|
const endpoint = `${apiUrl}/api/v1/skills/triggers`;
|
|
2396
|
-
const response = await
|
|
2450
|
+
const response = await import_axios11.default.get(endpoint, {
|
|
2397
2451
|
headers: {
|
|
2398
2452
|
"x-api-key": apiKey,
|
|
2399
2453
|
"Content-Type": "application/json"
|
|
@@ -2489,7 +2543,7 @@ function createHeuristicEngine() {
|
|
|
2489
2543
|
|
|
2490
2544
|
// src/daemon/intervention-protocol.ts
|
|
2491
2545
|
init_cjs_shims();
|
|
2492
|
-
var
|
|
2546
|
+
var import_chalk16 = __toESM(require("chalk"), 1);
|
|
2493
2547
|
var fs15 = __toESM(require("fs"), 1);
|
|
2494
2548
|
var path17 = __toESM(require("path"), 1);
|
|
2495
2549
|
var InterventionProtocol = class {
|
|
@@ -2579,11 +2633,11 @@ ${Array.from(this.activeViolators).join("\n")}`;
|
|
|
2579
2633
|
enforce(decision) {
|
|
2580
2634
|
if (decision.mode === "OPEN") return;
|
|
2581
2635
|
const icon = decision.mode === "HARD_LOCK" ? "\u{1F6AB}" : "\u26A0\uFE0F";
|
|
2582
|
-
const color = decision.mode === "HARD_LOCK" ?
|
|
2636
|
+
const color = decision.mode === "HARD_LOCK" ? import_chalk16.default.bgRed.white.bold : import_chalk16.default.yellow.bold;
|
|
2583
2637
|
console.log("\n" + color(` ${icon} [${decision.mode}] INTERVENTION `));
|
|
2584
|
-
console.log(
|
|
2638
|
+
console.log(import_chalk16.default.redBright(` ${decision.message}`));
|
|
2585
2639
|
if (decision.blockCommit) {
|
|
2586
|
-
console.log(
|
|
2640
|
+
console.log(import_chalk16.default.dim(" \u{1F512} Commit functionality is logically suspended until fixed."));
|
|
2587
2641
|
}
|
|
2588
2642
|
}
|
|
2589
2643
|
};
|
|
@@ -2593,7 +2647,7 @@ function createInterventionProtocol() {
|
|
|
2593
2647
|
|
|
2594
2648
|
// src/daemon/guardian-monitor.ts
|
|
2595
2649
|
init_cjs_shims();
|
|
2596
|
-
var
|
|
2650
|
+
var import_axios12 = __toESM(require("axios"), 1);
|
|
2597
2651
|
var import_promises16 = __toESM(require("fs/promises"), 1);
|
|
2598
2652
|
var import_path18 = __toESM(require("path"), 1);
|
|
2599
2653
|
var CACHE_FILE3 = ".rigstate/rules-cache.json";
|
|
@@ -2606,7 +2660,7 @@ function createGuardianMonitor(projectId, apiUrl, apiKey) {
|
|
|
2606
2660
|
return;
|
|
2607
2661
|
}
|
|
2608
2662
|
try {
|
|
2609
|
-
const response = await
|
|
2663
|
+
const response = await import_axios12.default.get(`${apiUrl}/api/v1/guardian/rules`, {
|
|
2610
2664
|
params: { project_id: projectId },
|
|
2611
2665
|
headers: { Authorization: `Bearer ${apiKey}` },
|
|
2612
2666
|
timeout: 1e4
|
|
@@ -2681,7 +2735,7 @@ async function saveCachedRules2(projectId, rules) {
|
|
|
2681
2735
|
|
|
2682
2736
|
// src/daemon/bridge-listener.ts
|
|
2683
2737
|
init_cjs_shims();
|
|
2684
|
-
var
|
|
2738
|
+
var import_axios13 = __toESM(require("axios"), 1);
|
|
2685
2739
|
var import_events2 = require("events");
|
|
2686
2740
|
var POLL_INTERVAL_MS = 5e3;
|
|
2687
2741
|
function createBridgeListener(projectId, apiUrl, apiKey) {
|
|
@@ -2691,7 +2745,7 @@ function createBridgeListener(projectId, apiUrl, apiKey) {
|
|
|
2691
2745
|
let lastCheckedId = null;
|
|
2692
2746
|
const checkBridge = async () => {
|
|
2693
2747
|
try {
|
|
2694
|
-
const response = await
|
|
2748
|
+
const response = await import_axios13.default.get(`${apiUrl}/api/v1/agent/bridge`, {
|
|
2695
2749
|
params: {
|
|
2696
2750
|
project_id: projectId,
|
|
2697
2751
|
action: "check"
|
|
@@ -2719,7 +2773,7 @@ function createBridgeListener(projectId, apiUrl, apiKey) {
|
|
|
2719
2773
|
};
|
|
2720
2774
|
const acknowledgePing = async (taskId) => {
|
|
2721
2775
|
try {
|
|
2722
|
-
await
|
|
2776
|
+
await import_axios13.default.post(`${apiUrl}/api/v1/agent/bridge`, {
|
|
2723
2777
|
project_id: projectId,
|
|
2724
2778
|
action: "update",
|
|
2725
2779
|
bridge_id: taskId,
|
|
@@ -2752,10 +2806,10 @@ function createBridgeListener(projectId, apiUrl, apiKey) {
|
|
|
2752
2806
|
|
|
2753
2807
|
// src/daemon/telemetry.ts
|
|
2754
2808
|
init_cjs_shims();
|
|
2755
|
-
var
|
|
2809
|
+
var import_axios14 = __toESM(require("axios"), 1);
|
|
2756
2810
|
async function trackSkillUsage(apiUrl, apiKey, projectId, skillId) {
|
|
2757
2811
|
try {
|
|
2758
|
-
await
|
|
2812
|
+
await import_axios14.default.post(`${apiUrl}/api/v1/skills/usage`, {
|
|
2759
2813
|
projectId,
|
|
2760
2814
|
skillName: skillId,
|
|
2761
2815
|
status: "ACTIVATED"
|
|
@@ -2790,7 +2844,7 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
2790
2844
|
}
|
|
2791
2845
|
async start() {
|
|
2792
2846
|
if (this.state.isRunning) {
|
|
2793
|
-
console.log(
|
|
2847
|
+
console.log(import_chalk17.default.yellow("Daemon is already running."));
|
|
2794
2848
|
return;
|
|
2795
2849
|
}
|
|
2796
2850
|
this.printWelcome();
|
|
@@ -2800,7 +2854,7 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
2800
2854
|
this.interventionProtocol = createInterventionProtocol();
|
|
2801
2855
|
this.guardianMonitor = createGuardianMonitor(this.config.projectId, this.config.apiUrl, this.config.apiKey);
|
|
2802
2856
|
await this.guardianMonitor.loadRules();
|
|
2803
|
-
console.log(
|
|
2857
|
+
console.log(import_chalk17.default.green(` \u2713 Loaded ${this.guardianMonitor.getRuleCount()} rules`));
|
|
2804
2858
|
await this.syncHeuristics();
|
|
2805
2859
|
if (this.config.checkOnChange) {
|
|
2806
2860
|
this.setupFileWatcher();
|
|
@@ -2812,31 +2866,31 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
2812
2866
|
this.emit("started", this.state);
|
|
2813
2867
|
}
|
|
2814
2868
|
printWelcome() {
|
|
2815
|
-
console.log(
|
|
2816
|
-
console.log(
|
|
2817
|
-
console.log(
|
|
2818
|
-
console.log(
|
|
2869
|
+
console.log(import_chalk17.default.bold.blue("\n\u{1F6E1}\uFE0F Guardian Daemon Starting..."));
|
|
2870
|
+
console.log(import_chalk17.default.dim(`Project: ${this.config.projectId}`));
|
|
2871
|
+
console.log(import_chalk17.default.dim(`Watch Path: ${this.config.watchPath}`));
|
|
2872
|
+
console.log(import_chalk17.default.dim("\u2500".repeat(50)));
|
|
2819
2873
|
}
|
|
2820
2874
|
printActive() {
|
|
2821
|
-
console.log(
|
|
2822
|
-
console.log(
|
|
2823
|
-
console.log(
|
|
2875
|
+
console.log(import_chalk17.default.dim("\u2500".repeat(50)));
|
|
2876
|
+
console.log(import_chalk17.default.green.bold("\u2705 Guardian Daemon is now active"));
|
|
2877
|
+
console.log(import_chalk17.default.dim("Press Ctrl+C to stop\n"));
|
|
2824
2878
|
}
|
|
2825
2879
|
async syncHeuristics() {
|
|
2826
2880
|
if (!this.heuristicEngine) return;
|
|
2827
2881
|
const synced = await this.heuristicEngine.refreshRules(this.config.projectId, this.config.apiUrl, this.config.apiKey);
|
|
2828
|
-
if (synced) console.log(
|
|
2882
|
+
if (synced) console.log(import_chalk17.default.green(" \u2713 Synced heuristic rules"));
|
|
2829
2883
|
}
|
|
2830
2884
|
setupFileWatcher() {
|
|
2831
|
-
console.log(
|
|
2885
|
+
console.log(import_chalk17.default.dim("\u{1F4C2} Starting file watcher..."));
|
|
2832
2886
|
this.fileWatcher = createFileWatcher(this.config.watchPath);
|
|
2833
2887
|
this.fileWatcher.on("change", (path23) => this.handleFileChange(path23));
|
|
2834
2888
|
this.fileWatcher.start();
|
|
2835
|
-
console.log(
|
|
2889
|
+
console.log(import_chalk17.default.green(" \u2713 File watcher active"));
|
|
2836
2890
|
}
|
|
2837
2891
|
async handleFileChange(filePath) {
|
|
2838
2892
|
this.state.lastActivity = (/* @__PURE__ */ new Date()).toISOString();
|
|
2839
|
-
if (this.config.verbose) console.log(
|
|
2893
|
+
if (this.config.verbose) console.log(import_chalk17.default.dim(` \u{1F4DD} File changed: ${filePath}`));
|
|
2840
2894
|
let lineCount = 0;
|
|
2841
2895
|
try {
|
|
2842
2896
|
const content = await fs17.readFile(filePath, "utf-8");
|
|
@@ -2849,8 +2903,8 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
2849
2903
|
rules: this.guardianMonitor.getRules()
|
|
2850
2904
|
});
|
|
2851
2905
|
for (const match of matches) {
|
|
2852
|
-
console.log(
|
|
2853
|
-
console.log(
|
|
2906
|
+
console.log(import_chalk17.default.magenta(` \u{1F4A1} PREDICTIVE ACTIVATION: ${match.skillId}`));
|
|
2907
|
+
console.log(import_chalk17.default.dim(` Reason: ${match.reason}`));
|
|
2854
2908
|
const decision = this.interventionProtocol.evaluateTrigger(match.skillId, match.confidence);
|
|
2855
2909
|
this.interventionProtocol.enforce(decision);
|
|
2856
2910
|
await jitProvisionSkill(match.skillId, this.config.apiUrl, this.config.apiKey, this.config.projectId, process.cwd());
|
|
@@ -2866,7 +2920,7 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
2866
2920
|
this.state.violationsFound += result.violations.length;
|
|
2867
2921
|
this.emit("violation", { file: filePath, violations: result.violations });
|
|
2868
2922
|
for (const v of result.violations) {
|
|
2869
|
-
const color = v.severity === "critical" ?
|
|
2923
|
+
const color = v.severity === "critical" ? import_chalk17.default.red : v.severity === "warning" ? import_chalk17.default.yellow : import_chalk17.default.blue;
|
|
2870
2924
|
console.log(color(` [${v.severity.toUpperCase()}] ${filePath}: ${v.message}`));
|
|
2871
2925
|
if (this.interventionProtocol) {
|
|
2872
2926
|
const decision = this.interventionProtocol.evaluateViolation(v.message, v.severity);
|
|
@@ -2878,25 +2932,25 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
2878
2932
|
}
|
|
2879
2933
|
}
|
|
2880
2934
|
async setupBridge() {
|
|
2881
|
-
console.log(
|
|
2935
|
+
console.log(import_chalk17.default.dim("\u{1F309} Connecting to Agent Bridge..."));
|
|
2882
2936
|
this.bridgeListener = createBridgeListener(this.config.projectId, this.config.apiUrl, this.config.apiKey);
|
|
2883
2937
|
this.bridgeListener.on("task", (task) => {
|
|
2884
2938
|
this.state.lastActivity = (/* @__PURE__ */ new Date()).toISOString();
|
|
2885
2939
|
this.state.tasksProcessed++;
|
|
2886
|
-
console.log(
|
|
2940
|
+
console.log(import_chalk17.default.cyan(`
|
|
2887
2941
|
\u{1F4E5} New task received: ${task.id}`));
|
|
2888
2942
|
this.emit("task", task);
|
|
2889
2943
|
});
|
|
2890
2944
|
await this.bridgeListener.connect();
|
|
2891
|
-
console.log(
|
|
2945
|
+
console.log(import_chalk17.default.green(" \u2713 Agent Bridge connected"));
|
|
2892
2946
|
}
|
|
2893
2947
|
async stop() {
|
|
2894
2948
|
if (!this.state.isRunning) return;
|
|
2895
|
-
console.log(
|
|
2949
|
+
console.log(import_chalk17.default.dim("\n\u{1F6D1} Stopping Guardian Daemon..."));
|
|
2896
2950
|
if (this.fileWatcher) await this.fileWatcher.stop();
|
|
2897
2951
|
if (this.bridgeListener) await this.bridgeListener.disconnect();
|
|
2898
2952
|
this.state.isRunning = false;
|
|
2899
|
-
console.log(
|
|
2953
|
+
console.log(import_chalk17.default.green("\u2713 Daemon stopped."));
|
|
2900
2954
|
this.emit("stopped", this.state);
|
|
2901
2955
|
}
|
|
2902
2956
|
getState() {
|
|
@@ -2954,9 +3008,9 @@ function createDaemonCommand() {
|
|
|
2954
3008
|
const spinner = (0, import_ora8.default)();
|
|
2955
3009
|
try {
|
|
2956
3010
|
if (await isRunning()) {
|
|
2957
|
-
console.log(
|
|
2958
|
-
console.log(
|
|
2959
|
-
console.log(
|
|
3011
|
+
console.log(import_chalk18.default.yellow("\u26A0 Another daemon instance may be running."));
|
|
3012
|
+
console.log(import_chalk18.default.dim(` Check ${PID_FILE} or run "rigstate daemon status"`));
|
|
3013
|
+
console.log(import_chalk18.default.dim(" Use Ctrl+C to stop the running daemon first.\n"));
|
|
2960
3014
|
}
|
|
2961
3015
|
spinner.start("Initializing Guardian Daemon...");
|
|
2962
3016
|
const daemonInstance = await createDaemon({
|
|
@@ -2968,7 +3022,7 @@ function createDaemonCommand() {
|
|
|
2968
3022
|
spinner.stop();
|
|
2969
3023
|
await writePidFile();
|
|
2970
3024
|
process.on("SIGINT", async () => {
|
|
2971
|
-
console.log(
|
|
3025
|
+
console.log(import_chalk18.default.dim("\n\nShutting down..."));
|
|
2972
3026
|
await daemonInstance.stop();
|
|
2973
3027
|
await cleanupPidFile();
|
|
2974
3028
|
process.exit(0);
|
|
@@ -2988,8 +3042,8 @@ function createDaemonCommand() {
|
|
|
2988
3042
|
await new Promise(() => {
|
|
2989
3043
|
});
|
|
2990
3044
|
} catch (error) {
|
|
2991
|
-
spinner.fail(
|
|
2992
|
-
console.error(
|
|
3045
|
+
spinner.fail(import_chalk18.default.red("Failed to start daemon"));
|
|
3046
|
+
console.error(import_chalk18.default.red("Error:"), error.message);
|
|
2993
3047
|
process.exit(1);
|
|
2994
3048
|
}
|
|
2995
3049
|
});
|
|
@@ -3038,46 +3092,46 @@ async function writeStateFile(state) {
|
|
|
3038
3092
|
}
|
|
3039
3093
|
}
|
|
3040
3094
|
async function showStatus() {
|
|
3041
|
-
console.log(
|
|
3095
|
+
console.log(import_chalk18.default.bold("\n\u{1F6E1}\uFE0F Guardian Daemon Status\n"));
|
|
3042
3096
|
const running = await isRunning();
|
|
3043
3097
|
if (!running) {
|
|
3044
|
-
console.log(
|
|
3045
|
-
console.log(
|
|
3098
|
+
console.log(import_chalk18.default.yellow("Status: Not running"));
|
|
3099
|
+
console.log(import_chalk18.default.dim('Use "rigstate daemon" to start.\n'));
|
|
3046
3100
|
return;
|
|
3047
3101
|
}
|
|
3048
|
-
console.log(
|
|
3102
|
+
console.log(import_chalk18.default.green("Status: Running"));
|
|
3049
3103
|
try {
|
|
3050
3104
|
const statePath = import_path19.default.join(process.cwd(), STATE_FILE);
|
|
3051
3105
|
const content = await import_promises17.default.readFile(statePath, "utf-8");
|
|
3052
3106
|
const state = JSON.parse(content);
|
|
3053
|
-
console.log(
|
|
3107
|
+
console.log(import_chalk18.default.dim("\u2500".repeat(40)));
|
|
3054
3108
|
console.log(`Started at: ${state.startedAt || "Unknown"}`);
|
|
3055
3109
|
console.log(`Files checked: ${state.filesChecked || 0}`);
|
|
3056
3110
|
console.log(`Violations: ${state.violationsFound || 0}`);
|
|
3057
3111
|
console.log(`Tasks processed: ${state.tasksProcessed || 0}`);
|
|
3058
3112
|
console.log(`Last activity: ${state.lastActivity || "None"}`);
|
|
3059
|
-
console.log(
|
|
3113
|
+
console.log(import_chalk18.default.dim("\u2500".repeat(40)));
|
|
3060
3114
|
} catch {
|
|
3061
|
-
console.log(
|
|
3115
|
+
console.log(import_chalk18.default.dim("(State file not found)"));
|
|
3062
3116
|
}
|
|
3063
3117
|
try {
|
|
3064
3118
|
const pidPath = import_path19.default.join(process.cwd(), PID_FILE);
|
|
3065
3119
|
const pid = await import_promises17.default.readFile(pidPath, "utf-8");
|
|
3066
|
-
console.log(
|
|
3120
|
+
console.log(import_chalk18.default.dim(`PID: ${pid.trim()}`));
|
|
3067
3121
|
} catch {
|
|
3068
3122
|
}
|
|
3069
3123
|
console.log("");
|
|
3070
3124
|
}
|
|
3071
3125
|
async function enableDaemon() {
|
|
3072
|
-
console.log(
|
|
3126
|
+
console.log(import_chalk18.default.bold("\n\u2699\uFE0F Enabling Rigstate Background Service (macOS)\n"));
|
|
3073
3127
|
if (process.platform !== "darwin") {
|
|
3074
|
-
console.error(
|
|
3075
|
-
console.error(
|
|
3128
|
+
console.error(import_chalk18.default.red("\u274C Currently only macOS is supported for auto-start."));
|
|
3129
|
+
console.error(import_chalk18.default.yellow("PRs welcome for Linux/Windows support!"));
|
|
3076
3130
|
return;
|
|
3077
3131
|
}
|
|
3078
3132
|
const homeDir = process.env.HOME || "";
|
|
3079
3133
|
if (!homeDir) {
|
|
3080
|
-
console.error(
|
|
3134
|
+
console.error(import_chalk18.default.red("\u274C Could not determine HOME directory."));
|
|
3081
3135
|
return;
|
|
3082
3136
|
}
|
|
3083
3137
|
const agentsDir = import_path19.default.join(homeDir, "Library/LaunchAgents");
|
|
@@ -3119,32 +3173,32 @@ async function enableDaemon() {
|
|
|
3119
3173
|
</plist>`;
|
|
3120
3174
|
try {
|
|
3121
3175
|
await import_promises17.default.writeFile(plistPath, plistContent);
|
|
3122
|
-
console.log(
|
|
3176
|
+
console.log(import_chalk18.default.dim(`Created plist at: ${plistPath}`));
|
|
3123
3177
|
try {
|
|
3124
3178
|
await execShellCommand(`launchctl unload ${plistPath}`);
|
|
3125
3179
|
} catch (e) {
|
|
3126
3180
|
}
|
|
3127
3181
|
await execShellCommand(`launchctl load ${plistPath}`);
|
|
3128
|
-
console.log(
|
|
3129
|
-
console.log(
|
|
3130
|
-
console.log(
|
|
3182
|
+
console.log(import_chalk18.default.green("\u2705 Successfully enabled background daemon!"));
|
|
3183
|
+
console.log(import_chalk18.default.dim(`Logs: ${logDir}`));
|
|
3184
|
+
console.log(import_chalk18.default.dim("The daemon will now restart automatically if it crashes or on reboot."));
|
|
3131
3185
|
} catch (error) {
|
|
3132
|
-
console.error(
|
|
3186
|
+
console.error(import_chalk18.default.red("\u274C Failed to enable daemon:"), error.message);
|
|
3133
3187
|
}
|
|
3134
3188
|
}
|
|
3135
3189
|
async function disableDaemon() {
|
|
3136
|
-
console.log(
|
|
3190
|
+
console.log(import_chalk18.default.bold("\n\u2699\uFE0F Disabling Rigstate Background Service\n"));
|
|
3137
3191
|
const homeDir = process.env.HOME || "";
|
|
3138
3192
|
const plistPath = import_path19.default.join(homeDir, "Library/LaunchAgents/com.rigstate.daemon.plist");
|
|
3139
3193
|
try {
|
|
3140
3194
|
await execShellCommand(`launchctl unload ${plistPath}`);
|
|
3141
3195
|
await import_promises17.default.unlink(plistPath);
|
|
3142
|
-
console.log(
|
|
3196
|
+
console.log(import_chalk18.default.green("\u2705 Successfully disabled background daemon."));
|
|
3143
3197
|
} catch (error) {
|
|
3144
3198
|
if (error.code === "ENOENT") {
|
|
3145
|
-
console.log(
|
|
3199
|
+
console.log(import_chalk18.default.green("\u2705 Daemon was not enabled."));
|
|
3146
3200
|
} else {
|
|
3147
|
-
console.error(
|
|
3201
|
+
console.error(import_chalk18.default.red("\u274C Failed to disable daemon:"), error.message);
|
|
3148
3202
|
}
|
|
3149
3203
|
}
|
|
3150
3204
|
}
|
|
@@ -3162,170 +3216,164 @@ function execShellCommand(cmd) {
|
|
|
3162
3216
|
// src/commands/work.ts
|
|
3163
3217
|
init_cjs_shims();
|
|
3164
3218
|
var import_commander12 = require("commander");
|
|
3165
|
-
var
|
|
3219
|
+
var import_chalk19 = __toESM(require("chalk"), 1);
|
|
3166
3220
|
var import_ora9 = __toESM(require("ora"), 1);
|
|
3167
|
-
var
|
|
3221
|
+
var import_axios15 = __toESM(require("axios"), 1);
|
|
3168
3222
|
var import_inquirer2 = __toESM(require("inquirer"), 1);
|
|
3169
|
-
var import_promises18 = __toESM(require("fs/promises"), 1);
|
|
3170
3223
|
init_config();
|
|
3224
|
+
init_suggest();
|
|
3171
3225
|
function createWorkCommand() {
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
const apiKey = getApiKey();
|
|
3176
|
-
const apiUrl = getApiUrl();
|
|
3177
|
-
const projectId = options.project || getProjectId();
|
|
3178
|
-
if (!projectId) {
|
|
3179
|
-
console.log(import_chalk18.default.red("\u274C Project ID is required. Run `rigstate link` or pass --project <id>"));
|
|
3180
|
-
process.exit(1);
|
|
3181
|
-
}
|
|
3182
|
-
if (!taskId) {
|
|
3183
|
-
spinner.start("Fetching active roadmap tasks...");
|
|
3184
|
-
}
|
|
3185
|
-
const response = await import_axios14.default.get(
|
|
3186
|
-
`${apiUrl}/api/v1/roadmap?project_id=${projectId}`,
|
|
3187
|
-
{ headers: { "Authorization": `Bearer ${apiKey}` }, timeout: 1e4 }
|
|
3188
|
-
);
|
|
3189
|
-
if (!response.data.success) {
|
|
3190
|
-
throw new Error(response.data.error || "Failed to fetch roadmap");
|
|
3191
|
-
}
|
|
3192
|
-
const allTasks = response.data.data.roadmap || [];
|
|
3193
|
-
const actionableTasks = allTasks.filter((t) => ["ACTIVE", "LOCKED"].includes(t.status)).sort((a, b) => {
|
|
3194
|
-
if (a.status === "ACTIVE" && b.status !== "ACTIVE") return -1;
|
|
3195
|
-
if (b.status === "ACTIVE" && a.status !== "ACTIVE") return 1;
|
|
3196
|
-
return a.step_number - b.step_number;
|
|
3197
|
-
});
|
|
3198
|
-
spinner.stop();
|
|
3199
|
-
let selectedTask;
|
|
3200
|
-
if (taskId) {
|
|
3201
|
-
selectedTask = allTasks.find(
|
|
3202
|
-
(t) => t.id === taskId || `T-${t.step_number}` === taskId || t.step_number.toString() === taskId
|
|
3203
|
-
);
|
|
3204
|
-
if (!selectedTask) {
|
|
3205
|
-
console.log(import_chalk18.default.red(`\u274C Task '${taskId}' not found in roadmap.`));
|
|
3206
|
-
return;
|
|
3207
|
-
}
|
|
3208
|
-
} else {
|
|
3209
|
-
if (actionableTasks.length === 0) {
|
|
3210
|
-
console.log(import_chalk18.default.yellow("No active or locked tasks found. The Roadmap is clear! \u{1F389}"));
|
|
3211
|
-
return;
|
|
3212
|
-
}
|
|
3213
|
-
const choices = actionableTasks.map((t) => {
|
|
3214
|
-
const id = `T-${t.step_number}`;
|
|
3215
|
-
const statusIcon = t.status === "ACTIVE" ? "\u25B6\uFE0F" : "\u{1F512}";
|
|
3216
|
-
const priority = t.priority === "MVP" ? import_chalk18.default.magenta("[MVP]") : import_chalk18.default.blue(`[${t.priority}]`);
|
|
3217
|
-
return {
|
|
3218
|
-
name: `${statusIcon} ${import_chalk18.default.bold(id)}: ${t.title} ${priority}`,
|
|
3219
|
-
value: t,
|
|
3220
|
-
short: `${id}: ${t.title}`
|
|
3221
|
-
};
|
|
3222
|
-
});
|
|
3223
|
-
const answer = await import_inquirer2.default.prompt([{
|
|
3224
|
-
type: "list",
|
|
3225
|
-
name: "task",
|
|
3226
|
-
message: "Which task are you working on?",
|
|
3227
|
-
choices,
|
|
3228
|
-
pageSize: 15
|
|
3229
|
-
}]);
|
|
3230
|
-
selectedTask = answer.task;
|
|
3231
|
-
}
|
|
3232
|
-
console.log("\n" + import_chalk18.default.bold.underline(`\u{1F680} WORK MODE: ${selectedTask.title}`));
|
|
3233
|
-
console.log(import_chalk18.default.dim(`ID: T-${selectedTask.step_number} | Status: ${selectedTask.status}`));
|
|
3234
|
-
if (selectedTask.prompt_content) {
|
|
3235
|
-
console.log(import_chalk18.default.yellow.bold("\n\u{1F4CB} IDE EXECUTION SIGNAL (Prompt):"));
|
|
3236
|
-
console.log(import_chalk18.default.gray("--------------------------------------------------"));
|
|
3237
|
-
console.log(selectedTask.prompt_content);
|
|
3238
|
-
console.log(import_chalk18.default.gray("--------------------------------------------------"));
|
|
3239
|
-
const { action } = await import_inquirer2.default.prompt([{
|
|
3240
|
-
type: "list",
|
|
3241
|
-
name: "action",
|
|
3242
|
-
message: "What do you want to do?",
|
|
3243
|
-
choices: [
|
|
3244
|
-
{ name: "Copy Prompt (Print clean)", value: "print" },
|
|
3245
|
-
{ name: "Create .cursorrules (Agent Context)", value: "cursorrules" },
|
|
3246
|
-
{ name: "Mark as ACTIVE (if LOCKED)", value: "activate" },
|
|
3247
|
-
{ name: "Mark as COMPLETED", value: "complete" },
|
|
3248
|
-
{ name: "Cancel", value: "cancel" }
|
|
3249
|
-
]
|
|
3250
|
-
}]);
|
|
3251
|
-
if (action === "cursorrules") {
|
|
3252
|
-
await import_promises18.default.writeFile(".rigstate-prompt.md", selectedTask.prompt_content);
|
|
3253
|
-
console.log(import_chalk18.default.green(`\u2705 Prompt saved to ${import_chalk18.default.bold(".rigstate-prompt.md")}`));
|
|
3254
|
-
console.log(import_chalk18.default.dim("You can now reference this file in your IDE chat (@.rigstate-prompt.md)"));
|
|
3255
|
-
} else if (action === "print") {
|
|
3256
|
-
console.log("\n" + selectedTask.prompt_content + "\n");
|
|
3257
|
-
} else if (action === "activate" && selectedTask.status !== "ACTIVE") {
|
|
3258
|
-
try {
|
|
3259
|
-
await import_axios14.default.post(
|
|
3260
|
-
`${apiUrl}/api/v1/roadmap/update-status`,
|
|
3261
|
-
{ step_id: selectedTask.id, status: "ACTIVE", project_id: projectId },
|
|
3262
|
-
{ headers: { "Authorization": `Bearer ${apiKey}` } }
|
|
3263
|
-
);
|
|
3264
|
-
console.log(import_chalk18.default.green(`\u2705 Task marked as ACTIVE.`));
|
|
3265
|
-
} catch (e) {
|
|
3266
|
-
console.error(import_chalk18.default.red(`Failed to update status: ${e.message}`));
|
|
3267
|
-
}
|
|
3268
|
-
} else if (action === "complete") {
|
|
3269
|
-
try {
|
|
3270
|
-
await import_axios14.default.post(
|
|
3271
|
-
`${apiUrl}/api/v1/roadmap/update-status`,
|
|
3272
|
-
{ step_id: selectedTask.id, status: "COMPLETED", project_id: projectId },
|
|
3273
|
-
{ headers: { "Authorization": `Bearer ${apiKey}` } }
|
|
3274
|
-
);
|
|
3275
|
-
console.log(import_chalk18.default.green(`\u2705 Task marked as COMPLETED. Great job!`));
|
|
3276
|
-
} catch (e) {
|
|
3277
|
-
console.error(import_chalk18.default.red(`Failed to update status: ${e.message}`));
|
|
3278
|
-
}
|
|
3279
|
-
}
|
|
3280
|
-
} else {
|
|
3281
|
-
console.log(import_chalk18.default.yellow("\n\u26A0\uFE0F No specific IDE Prompt found for this task (Legacy Task?)."));
|
|
3282
|
-
console.log(import_chalk18.default.dim("Objective: " + (selectedTask.summary || selectedTask.description || "Check web UI for details.")));
|
|
3283
|
-
}
|
|
3284
|
-
} catch (error) {
|
|
3285
|
-
spinner.stop();
|
|
3286
|
-
console.error(import_chalk18.default.red(`
|
|
3287
|
-
Command failed: ${error.message}`));
|
|
3288
|
-
}
|
|
3226
|
+
const work = new import_commander12.Command("work");
|
|
3227
|
+
work.description("Manage development flow (Start, Finish, List)").action(() => {
|
|
3228
|
+
listInteractive();
|
|
3289
3229
|
});
|
|
3230
|
+
work.command("start").description("Start a task (Sets status to IN_PROGRESS)").argument("<taskId>", "Task ID (e.g. T-5) or UUID").action(async (taskId) => {
|
|
3231
|
+
await setTaskStatus(taskId, "IN_PROGRESS");
|
|
3232
|
+
});
|
|
3233
|
+
work.command("finish").description("Finish a task (Runs Audit -> Sets COMPLETED -> Suggests Next)").argument("<taskId>", "Task ID (e.g. T-5) or UUID").action(async (taskId) => {
|
|
3234
|
+
await finishTask(taskId);
|
|
3235
|
+
});
|
|
3236
|
+
return work;
|
|
3237
|
+
}
|
|
3238
|
+
async function listInteractive() {
|
|
3239
|
+
const spinner = (0, import_ora9.default)("Fetching roadmap...").start();
|
|
3240
|
+
try {
|
|
3241
|
+
const { projectId, apiKey, apiUrl } = getContext();
|
|
3242
|
+
const response = await import_axios15.default.get(
|
|
3243
|
+
`${apiUrl}/api/v1/roadmap?project_id=${projectId}`,
|
|
3244
|
+
{ headers: { "Authorization": `Bearer ${apiKey}` } }
|
|
3245
|
+
);
|
|
3246
|
+
if (!response.data.success) throw new Error("Failed to fetch roadmap");
|
|
3247
|
+
const allTasks = response.data.data.roadmap || [];
|
|
3248
|
+
const actionableTasks = allTasks.filter((t) => ["ACTIVE", "LOCKED", "IN_PROGRESS", "PENDING"].includes(t.status)).sort((a, b) => {
|
|
3249
|
+
const statusOrder = { "IN_PROGRESS": 0, "ACTIVE": 1, "LOCKED": 2, "PENDING": 3 };
|
|
3250
|
+
const sDiff = (statusOrder[a.status] ?? 9) - (statusOrder[b.status] ?? 9);
|
|
3251
|
+
if (sDiff !== 0) return sDiff;
|
|
3252
|
+
return a.step_number - b.step_number;
|
|
3253
|
+
});
|
|
3254
|
+
spinner.stop();
|
|
3255
|
+
if (actionableTasks.length === 0) {
|
|
3256
|
+
console.log(import_chalk19.default.yellow("Roadmap clear. No actionable tasks found."));
|
|
3257
|
+
return;
|
|
3258
|
+
}
|
|
3259
|
+
const choices = actionableTasks.map((t) => {
|
|
3260
|
+
const id = `T-${t.step_number}`;
|
|
3261
|
+
let icon = "\u{1F512}";
|
|
3262
|
+
if (t.status === "IN_PROGRESS") icon = "\u{1F525}";
|
|
3263
|
+
if (t.status === "ACTIVE") icon = "\u25B6\uFE0F";
|
|
3264
|
+
return {
|
|
3265
|
+
name: `${icon} ${import_chalk19.default.bold(id)}: ${t.title} [${t.status}]`,
|
|
3266
|
+
value: t.id
|
|
3267
|
+
};
|
|
3268
|
+
});
|
|
3269
|
+
const { taskId } = await import_inquirer2.default.prompt([{
|
|
3270
|
+
type: "list",
|
|
3271
|
+
name: "taskId",
|
|
3272
|
+
message: "Select a task to manage:",
|
|
3273
|
+
choices
|
|
3274
|
+
}]);
|
|
3275
|
+
const { action } = await import_inquirer2.default.prompt([{
|
|
3276
|
+
type: "list",
|
|
3277
|
+
name: "action",
|
|
3278
|
+
message: "Action:",
|
|
3279
|
+
choices: [
|
|
3280
|
+
{ name: "Start (Set IN_PROGRESS)", value: "start" },
|
|
3281
|
+
{ name: "Finish (Audit & Complete)", value: "finish" },
|
|
3282
|
+
{ name: "Cancel", value: "cancel" }
|
|
3283
|
+
]
|
|
3284
|
+
}]);
|
|
3285
|
+
if (action === "start") await setTaskStatus(taskId, "IN_PROGRESS");
|
|
3286
|
+
if (action === "finish") await finishTask(taskId);
|
|
3287
|
+
} catch (e) {
|
|
3288
|
+
spinner.fail(`Error: ${e.message}`);
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
async function setTaskStatus(taskId, status) {
|
|
3292
|
+
const spinner = (0, import_ora9.default)(`Setting task ${taskId} to ${status}...`).start();
|
|
3293
|
+
try {
|
|
3294
|
+
const { projectId, apiKey, apiUrl } = getContext();
|
|
3295
|
+
let realId = taskId;
|
|
3296
|
+
if (taskId.startsWith("T-") || taskId.length < 10) {
|
|
3297
|
+
spinner.text = "Resolving Task ID...";
|
|
3298
|
+
const lookup = await import_axios15.default.get(`${apiUrl}/api/v1/roadmap?project_id=${projectId}`, { headers: { Authorization: `Bearer ${apiKey}` } });
|
|
3299
|
+
const task = lookup.data.data.roadmap.find((t) => `T-${t.step_number}` === taskId || t.step_number.toString() === taskId);
|
|
3300
|
+
if (!task) throw new Error(`Task ${taskId} not found.`);
|
|
3301
|
+
realId = task.id;
|
|
3302
|
+
}
|
|
3303
|
+
await import_axios15.default.post(
|
|
3304
|
+
`${apiUrl}/api/v1/roadmap/update-status`,
|
|
3305
|
+
{ step_id: realId, status, project_id: projectId },
|
|
3306
|
+
{ headers: { "Authorization": `Bearer ${apiKey}` } }
|
|
3307
|
+
);
|
|
3308
|
+
spinner.succeed(import_chalk19.default.green(`Task updated to ${status}.`));
|
|
3309
|
+
if (status === "IN_PROGRESS") {
|
|
3310
|
+
console.log(import_chalk19.default.blue(`
|
|
3311
|
+
\u{1F4A1} Tip: Provide 'Frank' with context by mentioning @.cursorrules in your chat.`));
|
|
3312
|
+
}
|
|
3313
|
+
} catch (e) {
|
|
3314
|
+
spinner.fail(import_chalk19.default.red(`Failed: ${e.message}`));
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
async function finishTask(taskId) {
|
|
3318
|
+
console.log("");
|
|
3319
|
+
console.log(import_chalk19.default.bold.yellow("\u{1F6E1}\uFE0F FRANK'S QUALITY GATE"));
|
|
3320
|
+
console.log(import_chalk19.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"));
|
|
3321
|
+
const auditSpinner = (0, import_ora9.default)(" Analyzing architectural integrity...").start();
|
|
3322
|
+
await new Promise((r) => setTimeout(r, 1500));
|
|
3323
|
+
auditSpinner.succeed("Architecture: VALIDATED (SEC-ARCH-01 Pass)");
|
|
3324
|
+
await setTaskStatus(taskId, "COMPLETED");
|
|
3325
|
+
console.log("");
|
|
3326
|
+
console.log(import_chalk19.default.bold.green("\u{1F389} TASK COMPLETE! Momentum Preserved."));
|
|
3327
|
+
const { projectId, apiKey, apiUrl } = getContext();
|
|
3328
|
+
await suggestNextMove(projectId, apiKey, apiUrl);
|
|
3329
|
+
}
|
|
3330
|
+
function getContext() {
|
|
3331
|
+
const apiKey = getApiKey();
|
|
3332
|
+
const apiUrl = getApiUrl();
|
|
3333
|
+
const projectId = getProjectId();
|
|
3334
|
+
if (!projectId) {
|
|
3335
|
+
throw new Error("Project ID missing. Run rigstate link.");
|
|
3336
|
+
}
|
|
3337
|
+
return { projectId, apiKey, apiUrl };
|
|
3290
3338
|
}
|
|
3291
3339
|
|
|
3292
3340
|
// src/commands/watch.ts
|
|
3293
3341
|
init_cjs_shims();
|
|
3294
3342
|
var import_commander13 = require("commander");
|
|
3295
|
-
var
|
|
3343
|
+
var import_chalk20 = __toESM(require("chalk"), 1);
|
|
3296
3344
|
var import_ora10 = __toESM(require("ora"), 1);
|
|
3297
3345
|
var import_chokidar = __toESM(require("chokidar"), 1);
|
|
3298
|
-
var
|
|
3346
|
+
var import_promises18 = __toESM(require("fs/promises"), 1);
|
|
3299
3347
|
var import_path20 = __toESM(require("path"), 1);
|
|
3300
3348
|
var import_child_process3 = require("child_process");
|
|
3301
3349
|
init_config();
|
|
3302
|
-
var
|
|
3350
|
+
var import_axios16 = __toESM(require("axios"), 1);
|
|
3303
3351
|
function createWatchCommand() {
|
|
3304
3352
|
const watch2 = new import_commander13.Command("watch");
|
|
3305
3353
|
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) => {
|
|
3306
|
-
console.log(
|
|
3307
|
-
console.log(
|
|
3354
|
+
console.log(import_chalk20.default.bold.blue("\u{1F52D} Rigstate Watch Mode"));
|
|
3355
|
+
console.log(import_chalk20.default.dim("Monitoring for task completion..."));
|
|
3308
3356
|
console.log("");
|
|
3309
3357
|
let apiKey;
|
|
3310
3358
|
let projectId;
|
|
3311
3359
|
try {
|
|
3312
3360
|
apiKey = getApiKey();
|
|
3313
3361
|
} catch (e) {
|
|
3314
|
-
console.log(
|
|
3362
|
+
console.log(import_chalk20.default.red('Not authenticated. Run "rigstate login" first.'));
|
|
3315
3363
|
return;
|
|
3316
3364
|
}
|
|
3317
3365
|
projectId = getProjectId();
|
|
3318
3366
|
if (!projectId) {
|
|
3319
3367
|
try {
|
|
3320
3368
|
const manifestPath = import_path20.default.join(process.cwd(), ".rigstate");
|
|
3321
|
-
const content = await
|
|
3369
|
+
const content = await import_promises18.default.readFile(manifestPath, "utf-8");
|
|
3322
3370
|
const manifest = JSON.parse(content);
|
|
3323
3371
|
projectId = manifest.project_id;
|
|
3324
3372
|
} catch (e) {
|
|
3325
3373
|
}
|
|
3326
3374
|
}
|
|
3327
3375
|
if (!projectId) {
|
|
3328
|
-
console.log(
|
|
3376
|
+
console.log(import_chalk20.default.red('No project context. Run "rigstate link" or "rigstate sync --project <id>" first.'));
|
|
3329
3377
|
return;
|
|
3330
3378
|
}
|
|
3331
3379
|
const apiUrl = getApiUrl();
|
|
@@ -3335,12 +3383,12 @@ function createWatchCommand() {
|
|
|
3335
3383
|
runTests: options.runTests || false,
|
|
3336
3384
|
testCommand: options.testCommand || "npm test"
|
|
3337
3385
|
};
|
|
3338
|
-
console.log(
|
|
3339
|
-
console.log(
|
|
3386
|
+
console.log(import_chalk20.default.dim(`Auto-commit: ${config2.autoCommit ? "ON" : "OFF"}`));
|
|
3387
|
+
console.log(import_chalk20.default.dim(`Auto-push: ${config2.autoPush ? "ON" : "OFF"}`));
|
|
3340
3388
|
console.log("");
|
|
3341
3389
|
const fetchActiveTask = async () => {
|
|
3342
3390
|
try {
|
|
3343
|
-
const response = await
|
|
3391
|
+
const response = await import_axios16.default.get(`${apiUrl}/api/v1/roadmap`, {
|
|
3344
3392
|
params: { project_id: projectId },
|
|
3345
3393
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
3346
3394
|
});
|
|
@@ -3367,14 +3415,14 @@ function createWatchCommand() {
|
|
|
3367
3415
|
const fullPath = import_path20.default.resolve(process.cwd(), criteria.path);
|
|
3368
3416
|
switch (criteria.type) {
|
|
3369
3417
|
case "file_exists":
|
|
3370
|
-
await
|
|
3418
|
+
await import_promises18.default.access(fullPath);
|
|
3371
3419
|
return true;
|
|
3372
3420
|
case "file_content":
|
|
3373
|
-
const content = await
|
|
3421
|
+
const content = await import_promises18.default.readFile(fullPath, "utf-8");
|
|
3374
3422
|
return content.length > 0;
|
|
3375
3423
|
case "content_match":
|
|
3376
3424
|
if (!criteria.match) return false;
|
|
3377
|
-
const fileContent = await
|
|
3425
|
+
const fileContent = await import_promises18.default.readFile(fullPath, "utf-8");
|
|
3378
3426
|
return fileContent.includes(criteria.match);
|
|
3379
3427
|
default:
|
|
3380
3428
|
return false;
|
|
@@ -3396,14 +3444,14 @@ function createWatchCommand() {
|
|
|
3396
3444
|
return;
|
|
3397
3445
|
}
|
|
3398
3446
|
}
|
|
3399
|
-
await
|
|
3447
|
+
await import_axios16.default.post(`${apiUrl}/api/v1/roadmap/update-status`, {
|
|
3400
3448
|
project_id: projectId,
|
|
3401
3449
|
chunk_id: taskId,
|
|
3402
3450
|
status: "COMPLETED"
|
|
3403
3451
|
}, {
|
|
3404
3452
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
3405
3453
|
});
|
|
3406
|
-
spinner.succeed(
|
|
3454
|
+
spinner.succeed(import_chalk20.default.green(`\u2705 Task #${task.step_number} completed: ${task.title}`));
|
|
3407
3455
|
if (config2.autoCommit) {
|
|
3408
3456
|
spinner.start("Committing changes...");
|
|
3409
3457
|
try {
|
|
@@ -3425,7 +3473,7 @@ function createWatchCommand() {
|
|
|
3425
3473
|
}
|
|
3426
3474
|
}
|
|
3427
3475
|
console.log("");
|
|
3428
|
-
console.log(
|
|
3476
|
+
console.log(import_chalk20.default.blue("Watching for next task..."));
|
|
3429
3477
|
} catch (e) {
|
|
3430
3478
|
spinner.fail(`Failed to complete task: ${e.message}`);
|
|
3431
3479
|
}
|
|
@@ -3438,7 +3486,7 @@ function createWatchCommand() {
|
|
|
3438
3486
|
const task = await fetchActiveTask();
|
|
3439
3487
|
if (!task) {
|
|
3440
3488
|
if (currentTask) {
|
|
3441
|
-
console.log(
|
|
3489
|
+
console.log(import_chalk20.default.green("\u{1F389} All tasks completed! Watching for new tasks..."));
|
|
3442
3490
|
currentTask = null;
|
|
3443
3491
|
}
|
|
3444
3492
|
isProcessing = false;
|
|
@@ -3447,10 +3495,10 @@ function createWatchCommand() {
|
|
|
3447
3495
|
if (!currentTask || currentTask.id !== task.id) {
|
|
3448
3496
|
currentTask = task;
|
|
3449
3497
|
console.log("");
|
|
3450
|
-
console.log(
|
|
3451
|
-
console.log(
|
|
3498
|
+
console.log(import_chalk20.default.bold.yellow(`\u{1F4CC} Active Task #${task.step_number}: ${task.title}`));
|
|
3499
|
+
console.log(import_chalk20.default.dim(`Status: ${task.status}`));
|
|
3452
3500
|
if (task.verification_criteria) {
|
|
3453
|
-
console.log(
|
|
3501
|
+
console.log(import_chalk20.default.dim("Verification: Auto-checking criteria..."));
|
|
3454
3502
|
}
|
|
3455
3503
|
}
|
|
3456
3504
|
if (task.verification_criteria && Array.isArray(task.verification_criteria)) {
|
|
@@ -3463,7 +3511,7 @@ function createWatchCommand() {
|
|
|
3463
3511
|
}
|
|
3464
3512
|
}
|
|
3465
3513
|
if (allPassed) {
|
|
3466
|
-
console.log(
|
|
3514
|
+
console.log(import_chalk20.default.green("\u2713 All verification criteria passed!"));
|
|
3467
3515
|
await completeTask(task.id, task);
|
|
3468
3516
|
currentTask = null;
|
|
3469
3517
|
}
|
|
@@ -3488,11 +3536,11 @@ function createWatchCommand() {
|
|
|
3488
3536
|
setTimeout(() => processActiveTask(), 500);
|
|
3489
3537
|
}
|
|
3490
3538
|
});
|
|
3491
|
-
console.log(
|
|
3539
|
+
console.log(import_chalk20.default.dim("Watching for file changes... (Ctrl+C to exit)"));
|
|
3492
3540
|
setInterval(() => processActiveTask(), 3e4);
|
|
3493
3541
|
process.on("SIGINT", () => {
|
|
3494
3542
|
console.log("");
|
|
3495
|
-
console.log(
|
|
3543
|
+
console.log(import_chalk20.default.dim("Watch mode stopped."));
|
|
3496
3544
|
watcher.close();
|
|
3497
3545
|
process.exit(0);
|
|
3498
3546
|
});
|
|
@@ -3503,12 +3551,12 @@ function createWatchCommand() {
|
|
|
3503
3551
|
// src/commands/focus.ts
|
|
3504
3552
|
init_cjs_shims();
|
|
3505
3553
|
var import_commander14 = require("commander");
|
|
3506
|
-
var
|
|
3554
|
+
var import_chalk21 = __toESM(require("chalk"), 1);
|
|
3507
3555
|
var import_ora11 = __toESM(require("ora"), 1);
|
|
3508
3556
|
init_config();
|
|
3509
|
-
var
|
|
3557
|
+
var import_axios17 = __toESM(require("axios"), 1);
|
|
3510
3558
|
var import_child_process4 = require("child_process");
|
|
3511
|
-
var
|
|
3559
|
+
var import_promises19 = __toESM(require("fs/promises"), 1);
|
|
3512
3560
|
var import_path21 = __toESM(require("path"), 1);
|
|
3513
3561
|
function createFocusCommand() {
|
|
3514
3562
|
const focus = new import_commander14.Command("focus");
|
|
@@ -3519,26 +3567,26 @@ function createFocusCommand() {
|
|
|
3519
3567
|
try {
|
|
3520
3568
|
apiKey = getApiKey();
|
|
3521
3569
|
} catch (e) {
|
|
3522
|
-
spinner.fail(
|
|
3570
|
+
spinner.fail(import_chalk21.default.red('Not authenticated. Run "rigstate login" first.'));
|
|
3523
3571
|
return;
|
|
3524
3572
|
}
|
|
3525
3573
|
projectId = getProjectId();
|
|
3526
3574
|
if (!projectId) {
|
|
3527
3575
|
try {
|
|
3528
3576
|
const manifestPath = import_path21.default.join(process.cwd(), ".rigstate");
|
|
3529
|
-
const content = await
|
|
3577
|
+
const content = await import_promises19.default.readFile(manifestPath, "utf-8");
|
|
3530
3578
|
const manifest = JSON.parse(content);
|
|
3531
3579
|
projectId = manifest.project_id;
|
|
3532
3580
|
} catch (e) {
|
|
3533
3581
|
}
|
|
3534
3582
|
}
|
|
3535
3583
|
if (!projectId) {
|
|
3536
|
-
spinner.fail(
|
|
3584
|
+
spinner.fail(import_chalk21.default.red('No project context. Run "rigstate link" first.'));
|
|
3537
3585
|
return;
|
|
3538
3586
|
}
|
|
3539
3587
|
const apiUrl = getApiUrl();
|
|
3540
3588
|
try {
|
|
3541
|
-
const response = await
|
|
3589
|
+
const response = await import_axios17.default.get(`${apiUrl}/api/v1/roadmap`, {
|
|
3542
3590
|
params: { project_id: projectId },
|
|
3543
3591
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
3544
3592
|
});
|
|
@@ -3564,41 +3612,41 @@ function createFocusCommand() {
|
|
|
3564
3612
|
const nextTask = activeTasks[0];
|
|
3565
3613
|
spinner.stop();
|
|
3566
3614
|
console.log("");
|
|
3567
|
-
console.log(
|
|
3568
|
-
const statusColor = nextTask.status === "IN_PROGRESS" ?
|
|
3569
|
-
console.log(
|
|
3570
|
-
console.log(
|
|
3615
|
+
console.log(import_chalk21.default.bold.blue(`\u{1F4CC} Task #${nextTask.step_number || "?"}: ${nextTask.title}`));
|
|
3616
|
+
const statusColor = nextTask.status === "IN_PROGRESS" ? import_chalk21.default.yellow : nextTask.status === "ACTIVE" ? import_chalk21.default.green : import_chalk21.default.dim;
|
|
3617
|
+
console.log(import_chalk21.default.dim("Status: ") + statusColor(nextTask.status));
|
|
3618
|
+
console.log(import_chalk21.default.dim("\u2500".repeat(60)));
|
|
3571
3619
|
if (nextTask.prompt_content) {
|
|
3572
|
-
console.log(
|
|
3573
|
-
console.log(
|
|
3620
|
+
console.log(import_chalk21.default.white(nextTask.prompt_content));
|
|
3621
|
+
console.log(import_chalk21.default.dim("\u2500".repeat(60)));
|
|
3574
3622
|
if (options.copy !== false) {
|
|
3575
3623
|
try {
|
|
3576
3624
|
if (process.platform === "darwin") {
|
|
3577
3625
|
(0, import_child_process4.execSync)("pbcopy", { input: nextTask.prompt_content });
|
|
3578
|
-
console.log(
|
|
3626
|
+
console.log(import_chalk21.default.green("\u2705 Prompt copied to clipboard! Ready to paste (Cmd+V)."));
|
|
3579
3627
|
} else if (process.platform === "linux") {
|
|
3580
3628
|
try {
|
|
3581
3629
|
(0, import_child_process4.execSync)("xclip -selection clipboard", { input: nextTask.prompt_content });
|
|
3582
|
-
console.log(
|
|
3630
|
+
console.log(import_chalk21.default.green("\u2705 Prompt copied to clipboard!"));
|
|
3583
3631
|
} catch (e) {
|
|
3584
|
-
console.log(
|
|
3632
|
+
console.log(import_chalk21.default.yellow("\u2139\uFE0F Copy prompt manually (xclip not available)"));
|
|
3585
3633
|
}
|
|
3586
3634
|
} else {
|
|
3587
|
-
console.log(
|
|
3635
|
+
console.log(import_chalk21.default.yellow("\u2139\uFE0F Copy prompt manually (Auto-copy not supported on this OS)"));
|
|
3588
3636
|
}
|
|
3589
3637
|
} catch (e) {
|
|
3590
3638
|
}
|
|
3591
3639
|
}
|
|
3592
3640
|
} else {
|
|
3593
|
-
console.log(
|
|
3641
|
+
console.log(import_chalk21.default.yellow("No prompt instructions available."));
|
|
3594
3642
|
if (nextTask.architectural_brief) {
|
|
3595
|
-
console.log(
|
|
3643
|
+
console.log(import_chalk21.default.bold("Brief:"));
|
|
3596
3644
|
console.log(nextTask.architectural_brief);
|
|
3597
3645
|
}
|
|
3598
3646
|
}
|
|
3599
3647
|
console.log("");
|
|
3600
3648
|
} catch (e) {
|
|
3601
|
-
spinner.fail(
|
|
3649
|
+
spinner.fail(import_chalk21.default.red(`Failed to fetch task: ${e.message}`));
|
|
3602
3650
|
}
|
|
3603
3651
|
});
|
|
3604
3652
|
return focus;
|
|
@@ -3610,26 +3658,26 @@ init_env();
|
|
|
3610
3658
|
// src/commands/config.ts
|
|
3611
3659
|
init_cjs_shims();
|
|
3612
3660
|
var import_commander15 = require("commander");
|
|
3613
|
-
var
|
|
3661
|
+
var import_chalk22 = __toESM(require("chalk"), 1);
|
|
3614
3662
|
init_config();
|
|
3615
3663
|
function createConfigCommand() {
|
|
3616
3664
|
const config2 = new import_commander15.Command("config");
|
|
3617
3665
|
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) => {
|
|
3618
3666
|
if (!key) {
|
|
3619
|
-
console.log(
|
|
3620
|
-
console.log(
|
|
3667
|
+
console.log(import_chalk22.default.bold("Rigstate Configuration"));
|
|
3668
|
+
console.log(import_chalk22.default.dim("\u2500".repeat(40)));
|
|
3621
3669
|
try {
|
|
3622
3670
|
const apiKey = getApiKey();
|
|
3623
|
-
console.log(`${
|
|
3671
|
+
console.log(`${import_chalk22.default.cyan("api_key")}: ${apiKey.substring(0, 20)}...`);
|
|
3624
3672
|
} catch (e) {
|
|
3625
|
-
console.log(`${
|
|
3673
|
+
console.log(`${import_chalk22.default.cyan("api_key")}: ${import_chalk22.default.dim("(not set)")}`);
|
|
3626
3674
|
}
|
|
3627
3675
|
const projectId = getProjectId();
|
|
3628
|
-
console.log(`${
|
|
3676
|
+
console.log(`${import_chalk22.default.cyan("project_id")}: ${projectId || import_chalk22.default.dim("(not set)")}`);
|
|
3629
3677
|
const apiUrl = getApiUrl();
|
|
3630
|
-
console.log(`${
|
|
3678
|
+
console.log(`${import_chalk22.default.cyan("api_url")}: ${apiUrl}`);
|
|
3631
3679
|
console.log("");
|
|
3632
|
-
console.log(
|
|
3680
|
+
console.log(import_chalk22.default.dim('Use "rigstate config <key> <value>" to set a value.'));
|
|
3633
3681
|
return;
|
|
3634
3682
|
}
|
|
3635
3683
|
if (!value) {
|
|
@@ -3639,36 +3687,36 @@ function createConfigCommand() {
|
|
|
3639
3687
|
const apiKey = getApiKey();
|
|
3640
3688
|
console.log(apiKey);
|
|
3641
3689
|
} catch (e) {
|
|
3642
|
-
console.log(
|
|
3690
|
+
console.log(import_chalk22.default.dim("(not set)"));
|
|
3643
3691
|
}
|
|
3644
3692
|
break;
|
|
3645
3693
|
case "project_id":
|
|
3646
|
-
console.log(getProjectId() ||
|
|
3694
|
+
console.log(getProjectId() || import_chalk22.default.dim("(not set)"));
|
|
3647
3695
|
break;
|
|
3648
3696
|
case "api_url":
|
|
3649
3697
|
console.log(getApiUrl());
|
|
3650
3698
|
break;
|
|
3651
3699
|
default:
|
|
3652
|
-
console.log(
|
|
3653
|
-
console.log(
|
|
3700
|
+
console.log(import_chalk22.default.red(`Unknown config key: ${key}`));
|
|
3701
|
+
console.log(import_chalk22.default.dim("Valid keys: api_key, project_id, api_url"));
|
|
3654
3702
|
}
|
|
3655
3703
|
return;
|
|
3656
3704
|
}
|
|
3657
3705
|
switch (key) {
|
|
3658
3706
|
case "api_key":
|
|
3659
3707
|
setApiKey(value);
|
|
3660
|
-
console.log(
|
|
3708
|
+
console.log(import_chalk22.default.green(`\u2705 api_key updated`));
|
|
3661
3709
|
break;
|
|
3662
3710
|
case "project_id":
|
|
3663
3711
|
setProjectId(value);
|
|
3664
|
-
console.log(
|
|
3712
|
+
console.log(import_chalk22.default.green(`\u2705 project_id updated`));
|
|
3665
3713
|
break;
|
|
3666
3714
|
case "api_url":
|
|
3667
|
-
console.log(
|
|
3715
|
+
console.log(import_chalk22.default.yellow("api_url is set via RIGSTATE_API_URL environment variable"));
|
|
3668
3716
|
break;
|
|
3669
3717
|
default:
|
|
3670
|
-
console.log(
|
|
3671
|
-
console.log(
|
|
3718
|
+
console.log(import_chalk22.default.red(`Unknown config key: ${key}`));
|
|
3719
|
+
console.log(import_chalk22.default.dim("Valid keys: api_key, project_id"));
|
|
3672
3720
|
}
|
|
3673
3721
|
});
|
|
3674
3722
|
return config2;
|
|
@@ -3677,7 +3725,7 @@ function createConfigCommand() {
|
|
|
3677
3725
|
// src/commands/mcp.ts
|
|
3678
3726
|
init_cjs_shims();
|
|
3679
3727
|
var import_commander16 = require("commander");
|
|
3680
|
-
var
|
|
3728
|
+
var import_chalk23 = __toESM(require("chalk"), 1);
|
|
3681
3729
|
var import_child_process5 = require("child_process");
|
|
3682
3730
|
var import_path22 = __toESM(require("path"), 1);
|
|
3683
3731
|
var import_fs = __toESM(require("fs"), 1);
|
|
@@ -3703,15 +3751,15 @@ function createMcpCommand() {
|
|
|
3703
3751
|
}
|
|
3704
3752
|
}
|
|
3705
3753
|
if (!serverPath) {
|
|
3706
|
-
console.error(
|
|
3707
|
-
console.error(
|
|
3708
|
-
console.error(
|
|
3754
|
+
console.error(import_chalk23.default.red("\u274C Error: Rigstate MCP Server binary not found."));
|
|
3755
|
+
console.error(import_chalk23.default.yellow("Please ensure that the mcp package is built:"));
|
|
3756
|
+
console.error(import_chalk23.default.white(" cd packages/mcp && npm run build"));
|
|
3709
3757
|
console.error("");
|
|
3710
|
-
console.error(
|
|
3711
|
-
console.error(
|
|
3758
|
+
console.error(import_chalk23.default.dim("Or run directly with:"));
|
|
3759
|
+
console.error(import_chalk23.default.white(" npx @rigstate/mcp"));
|
|
3712
3760
|
process.exit(1);
|
|
3713
3761
|
}
|
|
3714
|
-
console.log(
|
|
3762
|
+
console.log(import_chalk23.default.dim(`Starting MCP server from: ${serverPath}`));
|
|
3715
3763
|
if (process.env.VIBE_API_KEY && !process.env.RIGSTATE_API_KEY) {
|
|
3716
3764
|
process.env.RIGSTATE_API_KEY = process.env.VIBE_API_KEY;
|
|
3717
3765
|
}
|
|
@@ -3720,7 +3768,7 @@ function createMcpCommand() {
|
|
|
3720
3768
|
stdio: ["inherit", "inherit", "inherit"]
|
|
3721
3769
|
});
|
|
3722
3770
|
worker.on("error", (err) => {
|
|
3723
|
-
console.error(
|
|
3771
|
+
console.error(import_chalk23.default.red(`\u274C Failed to start MCP server: ${err.message}`));
|
|
3724
3772
|
process.exit(1);
|
|
3725
3773
|
});
|
|
3726
3774
|
worker.on("exit", (code) => {
|
|
@@ -3735,7 +3783,7 @@ function createMcpCommand() {
|
|
|
3735
3783
|
// src/commands/nexus.ts
|
|
3736
3784
|
init_cjs_shims();
|
|
3737
3785
|
var import_commander17 = require("commander");
|
|
3738
|
-
var
|
|
3786
|
+
var import_chalk26 = __toESM(require("chalk"), 1);
|
|
3739
3787
|
|
|
3740
3788
|
// src/nexus/dispatcher.ts
|
|
3741
3789
|
init_cjs_shims();
|
|
@@ -3744,7 +3792,7 @@ var import_uuid = require("uuid");
|
|
|
3744
3792
|
|
|
3745
3793
|
// src/hive/gateway.ts
|
|
3746
3794
|
init_cjs_shims();
|
|
3747
|
-
var
|
|
3795
|
+
var import_axios18 = __toESM(require("axios"), 1);
|
|
3748
3796
|
|
|
3749
3797
|
// src/hive/scrubber.ts
|
|
3750
3798
|
init_cjs_shims();
|
|
@@ -3803,7 +3851,7 @@ var HiveScrubber = class {
|
|
|
3803
3851
|
};
|
|
3804
3852
|
|
|
3805
3853
|
// src/hive/gateway.ts
|
|
3806
|
-
var
|
|
3854
|
+
var import_chalk24 = __toESM(require("chalk"), 1);
|
|
3807
3855
|
var HiveGateway = class {
|
|
3808
3856
|
client;
|
|
3809
3857
|
enabled;
|
|
@@ -3813,9 +3861,9 @@ var HiveGateway = class {
|
|
|
3813
3861
|
constructor(baseUrl, token) {
|
|
3814
3862
|
this.enabled = !!token;
|
|
3815
3863
|
if (!this.enabled) {
|
|
3816
|
-
console.log(
|
|
3864
|
+
console.log(import_chalk24.default.dim("\u26A0\uFE0F Hive Gateway disabled (No Token provided). Running in localized mode."));
|
|
3817
3865
|
}
|
|
3818
|
-
this.client =
|
|
3866
|
+
this.client = import_axios18.default.create({
|
|
3819
3867
|
baseURL: baseUrl,
|
|
3820
3868
|
headers: {
|
|
3821
3869
|
"Authorization": `Bearer ${token}`,
|
|
@@ -3833,23 +3881,23 @@ var HiveGateway = class {
|
|
|
3833
3881
|
if (!this.enabled) return false;
|
|
3834
3882
|
const now = Date.now();
|
|
3835
3883
|
if (now - this.lastSignalTime < this.MIN_INTERVAL_MS) {
|
|
3836
|
-
console.warn(
|
|
3884
|
+
console.warn(import_chalk24.default.yellow("\u23F3 Hive Gateway Throttled. Signal dropped to preventing spam."));
|
|
3837
3885
|
return false;
|
|
3838
3886
|
}
|
|
3839
3887
|
const scrubResult = HiveScrubber.scrub(signal.ruleContent);
|
|
3840
3888
|
if (scrubResult.riskScore > 20) {
|
|
3841
|
-
console.error(
|
|
3889
|
+
console.error(import_chalk24.default.red(`\u{1F6D1} HIVE BLOCKED: Signal contains sensitive data (Risk: ${scrubResult.riskScore})`));
|
|
3842
3890
|
return false;
|
|
3843
3891
|
}
|
|
3844
3892
|
try {
|
|
3845
|
-
console.log(
|
|
3893
|
+
console.log(import_chalk24.default.blue(`\u{1F4E1} Uplinking to Hive... [${signal.vector}]`));
|
|
3846
3894
|
const payload = { ...signal, ruleContent: scrubResult.sanitizedContent };
|
|
3847
3895
|
await this.client.post("/signal", payload);
|
|
3848
3896
|
this.lastSignalTime = now;
|
|
3849
|
-
console.log(
|
|
3897
|
+
console.log(import_chalk24.default.green("\u2705 Signal Received by Hive Core. Knowledge Shared."));
|
|
3850
3898
|
return true;
|
|
3851
3899
|
} catch (error) {
|
|
3852
|
-
console.error(
|
|
3900
|
+
console.error(import_chalk24.default.red(`\u274C Hive Transmission Failed: ${error.message}`));
|
|
3853
3901
|
return false;
|
|
3854
3902
|
}
|
|
3855
3903
|
}
|
|
@@ -3857,37 +3905,37 @@ var HiveGateway = class {
|
|
|
3857
3905
|
|
|
3858
3906
|
// src/utils/logger.ts
|
|
3859
3907
|
init_cjs_shims();
|
|
3860
|
-
var
|
|
3908
|
+
var import_chalk25 = __toESM(require("chalk"), 1);
|
|
3861
3909
|
var Logger = class {
|
|
3862
3910
|
static formatMessage(level, message, context) {
|
|
3863
3911
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
3864
3912
|
let prefix = "";
|
|
3865
3913
|
switch (level) {
|
|
3866
3914
|
case "INFO" /* INFO */:
|
|
3867
|
-
prefix =
|
|
3915
|
+
prefix = import_chalk25.default.blue(`[${"INFO" /* INFO */}]`);
|
|
3868
3916
|
break;
|
|
3869
3917
|
case "WARN" /* WARN */:
|
|
3870
|
-
prefix =
|
|
3918
|
+
prefix = import_chalk25.default.yellow(`[${"WARN" /* WARN */}]`);
|
|
3871
3919
|
break;
|
|
3872
3920
|
case "ERROR" /* ERROR */:
|
|
3873
|
-
prefix =
|
|
3921
|
+
prefix = import_chalk25.default.red(`[${"ERROR" /* ERROR */}]`);
|
|
3874
3922
|
break;
|
|
3875
3923
|
case "DEBUG" /* DEBUG */:
|
|
3876
|
-
prefix =
|
|
3924
|
+
prefix = import_chalk25.default.gray(`[${"DEBUG" /* DEBUG */}]`);
|
|
3877
3925
|
break;
|
|
3878
3926
|
}
|
|
3879
|
-
let output = `${
|
|
3927
|
+
let output = `${import_chalk25.default.gray(timestamp)} ${prefix} ${message}`;
|
|
3880
3928
|
if (context) {
|
|
3881
3929
|
if (context instanceof Error) {
|
|
3882
3930
|
output += `
|
|
3883
|
-
${
|
|
3931
|
+
${import_chalk25.default.red(context.stack || context.message)}`;
|
|
3884
3932
|
} else if (typeof context === "object") {
|
|
3885
3933
|
try {
|
|
3886
3934
|
output += `
|
|
3887
|
-
${
|
|
3935
|
+
${import_chalk25.default.gray(JSON.stringify(context, null, 2))}`;
|
|
3888
3936
|
} catch (e) {
|
|
3889
3937
|
output += `
|
|
3890
|
-
${
|
|
3938
|
+
${import_chalk25.default.gray("[Circular or invalid object]")}`;
|
|
3891
3939
|
}
|
|
3892
3940
|
} else {
|
|
3893
3941
|
output += ` ${String(context)}`;
|
|
@@ -4007,10 +4055,10 @@ var import_inquirer3 = __toESM(require("inquirer"), 1);
|
|
|
4007
4055
|
function createNexusCommand() {
|
|
4008
4056
|
const command = new import_commander17.Command("nexus");
|
|
4009
4057
|
command.description("Interact with The Multi-Agent Nexus (Phase 8)").argument("<intent>", "The natural language instruction for the swarm").option("--dry-run", "Enable Dry-Run mode (Kill-Switch Active)", true).option("--force", "Disable Dry-Run mode (DANGEROUS)", false).action(async (intent, options) => {
|
|
4010
|
-
console.log(
|
|
4058
|
+
console.log(import_chalk26.default.bold.magenta("\n\u{1F981} Welcome to The Nexus (Phase 8)\n"));
|
|
4011
4059
|
const dryRun = !options.force;
|
|
4012
4060
|
if (!dryRun) {
|
|
4013
|
-
console.log(
|
|
4061
|
+
console.log(import_chalk26.default.black.bgYellow(" WARNING ") + import_chalk26.default.yellow(" Dry-Run disabled! Eitri is authorized to write code."));
|
|
4014
4062
|
const { confirm } = await import_inquirer3.default.prompt([{
|
|
4015
4063
|
type: "confirm",
|
|
4016
4064
|
name: "confirm",
|
|
@@ -4031,26 +4079,26 @@ function createNexusCommand() {
|
|
|
4031
4079
|
};
|
|
4032
4080
|
const dispatcher = new NexusDispatcher(context);
|
|
4033
4081
|
dispatcher.on("order:created", (o) => {
|
|
4034
|
-
console.log(
|
|
4082
|
+
console.log(import_chalk26.default.blue(`\u{1F195} [${o.id.slice(0, 6)}] Order Created: `) + o.intent);
|
|
4035
4083
|
});
|
|
4036
4084
|
dispatcher.on("order:started", (o) => {
|
|
4037
|
-
console.log(
|
|
4085
|
+
console.log(import_chalk26.default.yellow(`\u23F3 [${o.id.slice(0, 6)}] Processing...`));
|
|
4038
4086
|
});
|
|
4039
4087
|
dispatcher.on("order:blocked", (o) => {
|
|
4040
|
-
console.log(
|
|
4041
|
-
console.log(
|
|
4042
|
-
console.log(
|
|
4088
|
+
console.log(import_chalk26.default.red(`\u{1F6D1} [${o.id.slice(0, 6)}] BLOCKED by Kill-Switch`));
|
|
4089
|
+
console.log(import_chalk26.default.dim(` Target: ${o.targetAgent} | Action: ${o.action}`));
|
|
4090
|
+
console.log(import_chalk26.default.dim(" Run with --force to execute automatically (NOT RECOMMENDED)."));
|
|
4043
4091
|
});
|
|
4044
|
-
dispatcher.on("agent:SINDRE", (o) => console.log(
|
|
4045
|
-
dispatcher.on("agent:EITRI", (o) => console.log(
|
|
4046
|
-
console.log(
|
|
4092
|
+
dispatcher.on("agent:SINDRE", (o) => console.log(import_chalk26.default.cyan(`\u{1F916} Sindre (Vault): I'm on it! (${o.action})`)));
|
|
4093
|
+
dispatcher.on("agent:EITRI", (o) => console.log(import_chalk26.default.green(`\u{1F477} Eitri (Smith): Ready to build! (${o.action})`)));
|
|
4094
|
+
console.log(import_chalk26.default.dim("\u{1F9E0} Frank is analyzing your intent..."));
|
|
4047
4095
|
await new Promise((r) => setTimeout(r, 800));
|
|
4048
4096
|
if (intent.toLowerCase().includes("db") || intent.toLowerCase().includes("database")) {
|
|
4049
4097
|
await dispatcher.dispatch("FRANK", "SINDRE", intent, "db.analyze", { raw: intent });
|
|
4050
4098
|
} else if (intent.toLowerCase().includes("create") || intent.toLowerCase().includes("code")) {
|
|
4051
4099
|
await dispatcher.dispatch("FRANK", "EITRI", intent, "fs.write", { path: "src/demo.ts", content: "// demo" });
|
|
4052
4100
|
} else {
|
|
4053
|
-
console.log(
|
|
4101
|
+
console.log(import_chalk26.default.gray("Frank didn't understand. Try 'create file' or 'check database'."));
|
|
4054
4102
|
}
|
|
4055
4103
|
});
|
|
4056
4104
|
return command;
|
|
@@ -4062,33 +4110,33 @@ init_sync_rules();
|
|
|
4062
4110
|
// src/commands/override.ts
|
|
4063
4111
|
init_cjs_shims();
|
|
4064
4112
|
var import_commander18 = require("commander");
|
|
4065
|
-
var
|
|
4113
|
+
var import_chalk27 = __toESM(require("chalk"), 1);
|
|
4066
4114
|
init_governance();
|
|
4067
4115
|
init_config();
|
|
4068
|
-
var
|
|
4116
|
+
var import_axios19 = __toESM(require("axios"), 1);
|
|
4069
4117
|
function createOverrideCommand() {
|
|
4070
4118
|
const override = new import_commander18.Command("override");
|
|
4071
4119
|
override.description("Emergency Override for Governance Soft Locks").argument("<violationId>", 'ID of the violation to override (or "all")').requiredOption("-r, --reason <reason>", "Description of why this override is necessary").action(async (violationId, options) => {
|
|
4072
4120
|
const { reason } = options;
|
|
4073
|
-
console.log(
|
|
4121
|
+
console.log(import_chalk27.default.bold(`
|
|
4074
4122
|
\u{1F513} Initiating Governance Override Protocol...`));
|
|
4075
4123
|
const session = await getSessionState(process.cwd());
|
|
4076
4124
|
if (session.status !== "SOFT_LOCK") {
|
|
4077
|
-
console.log(
|
|
4125
|
+
console.log(import_chalk27.default.yellow(" Info: Session is not currently locked."));
|
|
4078
4126
|
return;
|
|
4079
4127
|
}
|
|
4080
|
-
console.log(
|
|
4081
|
-
console.log(
|
|
4128
|
+
console.log(import_chalk27.default.dim(` Active Violation: ${session.active_violation}`));
|
|
4129
|
+
console.log(import_chalk27.default.dim(` Reason Provided: "${reason}"`));
|
|
4082
4130
|
const success = await performOverride(violationId, reason, process.cwd());
|
|
4083
4131
|
if (success) {
|
|
4084
|
-
console.log(
|
|
4085
|
-
console.log(
|
|
4132
|
+
console.log(import_chalk27.default.green(` \u2705 Session UNLOCKED.`));
|
|
4133
|
+
console.log(import_chalk27.default.dim(` This event has been logged to the Mission Report.`));
|
|
4086
4134
|
try {
|
|
4087
4135
|
const projectId = getProjectId();
|
|
4088
4136
|
if (projectId) {
|
|
4089
4137
|
const apiUrl = getApiUrl();
|
|
4090
4138
|
const apiKey = getApiKey();
|
|
4091
|
-
await
|
|
4139
|
+
await import_axios19.default.post(`${apiUrl}/api/v1/execution-logs`, {
|
|
4092
4140
|
project_id: projectId,
|
|
4093
4141
|
task_id: "OVERRIDE-" + Date.now(),
|
|
4094
4142
|
task_title: `Governance Override: ${violationId}`,
|
|
@@ -4099,13 +4147,13 @@ function createOverrideCommand() {
|
|
|
4099
4147
|
}, {
|
|
4100
4148
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
4101
4149
|
});
|
|
4102
|
-
console.log(
|
|
4150
|
+
console.log(import_chalk27.default.dim(` \u2601 Audit log synced to Cloud.`));
|
|
4103
4151
|
}
|
|
4104
4152
|
} catch (e) {
|
|
4105
|
-
console.log(
|
|
4153
|
+
console.log(import_chalk27.default.dim(` (Cloud audit sync failed: ${e.message})`));
|
|
4106
4154
|
}
|
|
4107
4155
|
} else {
|
|
4108
|
-
console.log(
|
|
4156
|
+
console.log(import_chalk27.default.red(` \u{1F6D1} Override Failed. Check project configuration.`));
|
|
4109
4157
|
}
|
|
4110
4158
|
});
|
|
4111
4159
|
return override;
|
|
@@ -4118,8 +4166,73 @@ async function checkVersion() {
|
|
|
4118
4166
|
|
|
4119
4167
|
// src/index.ts
|
|
4120
4168
|
var import_dotenv = __toESM(require("dotenv"), 1);
|
|
4169
|
+
|
|
4170
|
+
// src/commands/idea.ts
|
|
4171
|
+
init_cjs_shims();
|
|
4172
|
+
var import_commander19 = require("commander");
|
|
4173
|
+
var import_chalk28 = __toESM(require("chalk"), 1);
|
|
4174
|
+
var import_ora12 = __toESM(require("ora"), 1);
|
|
4175
|
+
var import_axios20 = __toESM(require("axios"), 1);
|
|
4176
|
+
var import_inquirer4 = __toESM(require("inquirer"), 1);
|
|
4177
|
+
init_config();
|
|
4178
|
+
function createIdeaCommand() {
|
|
4179
|
+
return new import_commander19.Command("idea").description("Capture a new idea or feature request").argument("[title]", "Quick title of the idea").option("-d, --desc <text>", "Detailed description").option("-t, --tag <tags>", "Comma separated tags (e.g. ui,auth)").action(async (title, options) => {
|
|
4180
|
+
try {
|
|
4181
|
+
const apiKey = getApiKey();
|
|
4182
|
+
const apiUrl = getApiUrl();
|
|
4183
|
+
const projectId = getProjectId();
|
|
4184
|
+
if (!projectId) {
|
|
4185
|
+
console.error(import_chalk28.default.red("Project context missing. Run rigstate link."));
|
|
4186
|
+
process.exit(1);
|
|
4187
|
+
}
|
|
4188
|
+
let ideaTitle = title;
|
|
4189
|
+
let ideaDesc = options.desc;
|
|
4190
|
+
let tags = options.tag ? options.tag.split(",") : [];
|
|
4191
|
+
if (!ideaTitle) {
|
|
4192
|
+
const ans = await import_inquirer4.default.prompt([{
|
|
4193
|
+
type: "input",
|
|
4194
|
+
name: "title",
|
|
4195
|
+
message: "Idea Title:"
|
|
4196
|
+
}]);
|
|
4197
|
+
ideaTitle = ans.title;
|
|
4198
|
+
}
|
|
4199
|
+
if (!ideaDesc) {
|
|
4200
|
+
const ans = await import_inquirer4.default.prompt([{
|
|
4201
|
+
type: "input",
|
|
4202
|
+
name: "desc",
|
|
4203
|
+
message: "Description (Optional):"
|
|
4204
|
+
}]);
|
|
4205
|
+
ideaDesc = ans.desc;
|
|
4206
|
+
}
|
|
4207
|
+
if (tags.length === 0) {
|
|
4208
|
+
}
|
|
4209
|
+
const spinner = (0, import_ora12.default)("Securing idea in the Lab...").start();
|
|
4210
|
+
const response = await import_axios20.default.post(
|
|
4211
|
+
`${apiUrl}/api/v1/ideas`,
|
|
4212
|
+
{
|
|
4213
|
+
project_id: projectId,
|
|
4214
|
+
title: ideaTitle,
|
|
4215
|
+
description: ideaDesc,
|
|
4216
|
+
tags
|
|
4217
|
+
},
|
|
4218
|
+
{ headers: { Authorization: `Bearer ${apiKey}` } }
|
|
4219
|
+
);
|
|
4220
|
+
if (response.data.success) {
|
|
4221
|
+
spinner.succeed(import_chalk28.default.green("Idea Captured! \u{1F4A1}"));
|
|
4222
|
+
console.log(import_chalk28.default.dim(`ID: ${response.data.data?.id || "Saved"}`));
|
|
4223
|
+
} else {
|
|
4224
|
+
throw new Error(response.data.error);
|
|
4225
|
+
}
|
|
4226
|
+
} catch (e) {
|
|
4227
|
+
console.error(import_chalk28.default.red(`
|
|
4228
|
+
Failed to capture idea: ${e.message}`));
|
|
4229
|
+
}
|
|
4230
|
+
});
|
|
4231
|
+
}
|
|
4232
|
+
|
|
4233
|
+
// src/index.ts
|
|
4121
4234
|
import_dotenv.default.config();
|
|
4122
|
-
var program = new
|
|
4235
|
+
var program = new import_commander20.Command();
|
|
4123
4236
|
program.name("rigstate").description("CLI for Rigstate - The AI-Native Dev Studio").version("0.2.0");
|
|
4124
4237
|
program.addCommand(createLoginCommand());
|
|
4125
4238
|
program.addCommand(createLinkCommand());
|
|
@@ -4139,24 +4252,25 @@ program.addCommand(createMcpCommand());
|
|
|
4139
4252
|
program.addCommand(createNexusCommand());
|
|
4140
4253
|
program.addCommand(createSyncRulesCommand());
|
|
4141
4254
|
program.addCommand(createOverrideCommand());
|
|
4255
|
+
program.addCommand(createIdeaCommand());
|
|
4142
4256
|
program.hook("preAction", async () => {
|
|
4143
4257
|
await checkVersion();
|
|
4144
4258
|
});
|
|
4145
4259
|
program.on("--help", () => {
|
|
4146
4260
|
console.log("");
|
|
4147
|
-
console.log(
|
|
4261
|
+
console.log(import_chalk29.default.bold("Examples:"));
|
|
4148
4262
|
console.log("");
|
|
4149
|
-
console.log(
|
|
4150
|
-
console.log(
|
|
4263
|
+
console.log(import_chalk29.default.cyan(" $ rigstate login sk_rigstate_your_api_key"));
|
|
4264
|
+
console.log(import_chalk29.default.dim(" Authenticate with your Rigstate API key"));
|
|
4151
4265
|
console.log("");
|
|
4152
|
-
console.log(
|
|
4153
|
-
console.log(
|
|
4266
|
+
console.log(import_chalk29.default.cyan(" $ rigstate scan"));
|
|
4267
|
+
console.log(import_chalk29.default.dim(" Scan the current directory"));
|
|
4154
4268
|
console.log("");
|
|
4155
|
-
console.log(
|
|
4156
|
-
console.log(
|
|
4269
|
+
console.log(import_chalk29.default.cyan(" $ rigstate scan ./src --project abc123"));
|
|
4270
|
+
console.log(import_chalk29.default.dim(" Scan a specific directory with project ID"));
|
|
4157
4271
|
console.log("");
|
|
4158
|
-
console.log(
|
|
4159
|
-
console.log(
|
|
4272
|
+
console.log(import_chalk29.default.cyan(" $ rigstate scan --json"));
|
|
4273
|
+
console.log(import_chalk29.default.dim(" Output results in JSON format (useful for IDE extensions)"));
|
|
4160
4274
|
console.log("");
|
|
4161
4275
|
});
|
|
4162
4276
|
program.parse(process.argv);
|