@rigstate/cli 0.7.22 → 0.7.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -383,136 +383,6 @@ var init_suggest = __esm({
383
383
  }
384
384
  });
385
385
 
386
- // src/commands/hooks.ts
387
- var hooks_exports = {};
388
- __export(hooks_exports, {
389
- createHooksCommand: () => createHooksCommand
390
- });
391
- import { Command as Command4 } from "commander";
392
- import chalk5 from "chalk";
393
- import fs2 from "fs/promises";
394
- import path3 from "path";
395
- function createHooksCommand() {
396
- const hooks = new Command4("hooks").description("Manage git hooks for Guardian integration");
397
- hooks.command("install").description("Install pre-commit hook to run Guardian checks").option("--strict [level]", 'Strict level: "all" or "critical" (default)', "critical").action(async (options) => {
398
- try {
399
- const gitDir = path3.join(process.cwd(), ".git");
400
- try {
401
- await fs2.access(gitDir);
402
- } catch {
403
- console.log(chalk5.red("\u274C Not a git repository."));
404
- console.log(chalk5.dim(' Initialize with "git init" first.'));
405
- process.exit(1);
406
- }
407
- const hooksDir = path3.join(gitDir, "hooks");
408
- await fs2.mkdir(hooksDir, { recursive: true });
409
- const preCommitPath = path3.join(hooksDir, "pre-commit");
410
- let existingContent = "";
411
- try {
412
- existingContent = await fs2.readFile(preCommitPath, "utf-8");
413
- if (existingContent.includes("rigstate")) {
414
- console.log(chalk5.yellow("\u26A0 Rigstate pre-commit hook already installed."));
415
- console.log(chalk5.dim(' Use "rigstate hooks uninstall" to remove first.'));
416
- return;
417
- }
418
- } catch {
419
- }
420
- let script = PRE_COMMIT_SCRIPT;
421
- if (options.strict === "all") {
422
- script = script.replace("--strict=critical", "--strict");
423
- }
424
- if (existingContent && !existingContent.includes("rigstate")) {
425
- const combinedScript = existingContent + "\n\n" + script.replace("#!/bin/sh\n", "");
426
- await fs2.writeFile(preCommitPath, combinedScript, { mode: 493 });
427
- console.log(chalk5.green("\u2705 Rigstate hook appended to existing pre-commit."));
428
- } else {
429
- await fs2.writeFile(preCommitPath, script, { mode: 493 });
430
- console.log(chalk5.green("\u2705 Pre-commit hook installed!"));
431
- }
432
- console.log(chalk5.dim(` Path: ${preCommitPath}`));
433
- console.log(chalk5.dim(` Strict level: ${options.strict}`));
434
- console.log("");
435
- console.log(chalk5.cyan("Guardian will now check your code before each commit."));
436
- console.log(chalk5.dim('Use "rigstate hooks uninstall" to remove the hook.'));
437
- } catch (error) {
438
- console.error(chalk5.red("Failed to install hook:"), error.message);
439
- process.exit(1);
440
- }
441
- });
442
- hooks.command("uninstall").description("Remove Rigstate pre-commit hook").action(async () => {
443
- try {
444
- const preCommitPath = path3.join(process.cwd(), ".git", "hooks", "pre-commit");
445
- try {
446
- const content = await fs2.readFile(preCommitPath, "utf-8");
447
- if (!content.includes("rigstate")) {
448
- console.log(chalk5.yellow("\u26A0 No Rigstate hook found in pre-commit."));
449
- return;
450
- }
451
- if (content.includes("# Rigstate Guardian Pre-commit Hook") && content.trim().split("\n").filter((l) => l && !l.startsWith("#")).length <= 4) {
452
- await fs2.unlink(preCommitPath);
453
- console.log(chalk5.green("\u2705 Pre-commit hook removed."));
454
- } else {
455
- const lines = content.split("\n");
456
- const filteredLines = [];
457
- let inRigstateSection = false;
458
- for (const line of lines) {
459
- if (line.includes("Rigstate Guardian Pre-commit Hook")) {
460
- inRigstateSection = true;
461
- continue;
462
- }
463
- if (inRigstateSection && line.includes("exit $?")) {
464
- inRigstateSection = false;
465
- continue;
466
- }
467
- if (!inRigstateSection && !line.includes("rigstate check")) {
468
- filteredLines.push(line);
469
- }
470
- }
471
- await fs2.writeFile(preCommitPath, filteredLines.join("\n"), { mode: 493 });
472
- console.log(chalk5.green("\u2705 Rigstate section removed from pre-commit hook."));
473
- }
474
- } catch {
475
- console.log(chalk5.yellow("\u26A0 No pre-commit hook found."));
476
- }
477
- } catch (error) {
478
- console.error(chalk5.red("Failed to uninstall hook:"), error.message);
479
- process.exit(1);
480
- }
481
- });
482
- return hooks;
483
- }
484
- var PRE_COMMIT_SCRIPT;
485
- var init_hooks = __esm({
486
- "src/commands/hooks.ts"() {
487
- "use strict";
488
- init_esm_shims();
489
- PRE_COMMIT_SCRIPT = `#!/bin/sh
490
- # Rigstate Guardian Pre-commit Hook
491
- # Installed by: rigstate hooks install
492
-
493
- # 1. Silent Sentinel Check (Phase 5)
494
- if [ -f .rigstate/guardian.lock ]; then
495
- echo "\u{1F6D1} INTERVENTION ACTIVE: Commit blocked by Silent Sentinel."
496
- echo " A critical violation ('HARD_LOCK') was detected by the Guardian Daemon."
497
- echo " Please fix the violation to unlock the repo."
498
- echo ""
499
- if grep -q "HARD_LOCK_ACTIVE" .rigstate/guardian.lock; then
500
- cat .rigstate/guardian.lock
501
- fi
502
- exit 1
503
- fi
504
-
505
- echo "\u{1F6E1}\uFE0F Running Guardian checks..."
506
-
507
- # Run check with strict mode for critical violations
508
- rigstate check --staged --strict=critical
509
-
510
- # Exit with the same code as rigstate check
511
- exit $?
512
- `;
513
- }
514
- });
515
-
516
386
  // src/utils/skills-provisioner.ts
517
387
  var skills_provisioner_exports = {};
518
388
  __export(skills_provisioner_exports, {
@@ -521,9 +391,9 @@ __export(skills_provisioner_exports, {
521
391
  provisionSkills: () => provisionSkills
522
392
  });
523
393
  import axios6 from "axios";
524
- import fs7 from "fs/promises";
525
- import path8 from "path";
526
- import chalk9 from "chalk";
394
+ import fs6 from "fs/promises";
395
+ import path7 from "path";
396
+ import chalk8 from "chalk";
527
397
  async function provisionSkills(apiUrl, apiKey, projectId, rootDir) {
528
398
  const skills = [];
529
399
  try {
@@ -545,18 +415,18 @@ async function provisionSkills(apiUrl, apiKey, projectId, rootDir) {
545
415
  }
546
416
  } catch (e) {
547
417
  const msg = e.response?.data?.error || e.message;
548
- console.log(chalk9.dim(` (Skills API not available: ${msg}, using core library)`));
418
+ console.log(chalk8.dim(` (Skills API not available: ${msg}, using core library)`));
549
419
  }
550
420
  if (skills.length === 0) {
551
421
  const { getRigstateStandardSkills } = await import("@rigstate/rules-engine");
552
422
  const coreSkills = getRigstateStandardSkills();
553
423
  skills.push(...coreSkills);
554
424
  }
555
- const skillsDir = path8.join(rootDir, ".agent", "skills");
556
- await fs7.mkdir(skillsDir, { recursive: true });
425
+ const skillsDir = path7.join(rootDir, ".agent", "skills");
426
+ await fs6.mkdir(skillsDir, { recursive: true });
557
427
  for (const skill of skills) {
558
- const skillDir = path8.join(skillsDir, skill.name);
559
- await fs7.mkdir(skillDir, { recursive: true });
428
+ const skillDir = path7.join(skillsDir, skill.name);
429
+ await fs6.mkdir(skillDir, { recursive: true });
560
430
  const skillContent = `---
561
431
  name: ${skill.name}
562
432
  description: ${skill.description}
@@ -569,10 +439,10 @@ ${skill.content}
569
439
 
570
440
  ---
571
441
  *Provisioned by Rigstate CLI. Do not modify manually.*`;
572
- const skillPath = path8.join(skillDir, "SKILL.md");
573
- await fs7.writeFile(skillPath, skillContent, "utf-8");
442
+ const skillPath = path7.join(skillDir, "SKILL.md");
443
+ await fs6.writeFile(skillPath, skillContent, "utf-8");
574
444
  }
575
- console.log(chalk9.green(` \u2705 Provisioned ${skills.length} skill(s) to .agent/skills/`));
445
+ console.log(chalk8.green(` \u2705 Provisioned ${skills.length} skill(s) to .agent/skills/`));
576
446
  return skills;
577
447
  }
578
448
  function generateSkillsDiscoveryBlock(skills) {
@@ -587,16 +457,16 @@ ${skillBlocks}
587
457
  </available_skills>`;
588
458
  }
589
459
  async function jitProvisionSkill(skillId, apiUrl, apiKey, projectId, rootDir) {
590
- const rulesPath = path8.join(rootDir, ".cursorrules");
460
+ const rulesPath = path7.join(rootDir, ".cursorrules");
591
461
  let rulesContent = "";
592
462
  try {
593
- rulesContent = await fs7.readFile(rulesPath, "utf-8");
463
+ rulesContent = await fs6.readFile(rulesPath, "utf-8");
594
464
  } catch (e) {
595
465
  return false;
596
466
  }
597
467
  const isProvisioned = rulesContent.includes(`<name>${skillId}</name>`) || rulesContent.includes(`.agent/skills/${skillId}`);
598
468
  if (isProvisioned) return false;
599
- console.log(chalk9.yellow(` \u26A1 JIT PROVISIONING: Injecting ${skillId}...`));
469
+ console.log(chalk8.yellow(` \u26A1 JIT PROVISIONING: Injecting ${skillId}...`));
600
470
  try {
601
471
  const skills = await provisionSkills(apiUrl, apiKey, projectId, rootDir);
602
472
  const skillsBlock = generateSkillsDiscoveryBlock(skills);
@@ -611,10 +481,10 @@ async function jitProvisionSkill(skillId, apiUrl, apiKey, projectId, rootDir) {
611
481
  rulesContent = rulesContent.slice(0, insertPoint + 3) + "\n\n" + skillsBlock + "\n" + rulesContent.slice(insertPoint + 3);
612
482
  }
613
483
  }
614
- await fs7.writeFile(rulesPath, rulesContent, "utf-8");
484
+ await fs6.writeFile(rulesPath, rulesContent, "utf-8");
615
485
  return true;
616
486
  } catch (e) {
617
- console.log(chalk9.red(` Failed to provision skill: ${e.message}`));
487
+ console.log(chalk8.red(` Failed to provision skill: ${e.message}`));
618
488
  return false;
619
489
  }
620
490
  }
@@ -635,13 +505,13 @@ __export(governance_exports, {
635
505
  performOverride: () => performOverride,
636
506
  setSoftLock: () => setSoftLock
637
507
  });
638
- import fs8 from "fs/promises";
639
- import path9 from "path";
640
- import chalk10 from "chalk";
508
+ import fs7 from "fs/promises";
509
+ import path8 from "path";
510
+ import chalk9 from "chalk";
641
511
  async function getGovernanceConfig(rootDir = process.cwd()) {
642
512
  try {
643
- const configPath = path9.join(rootDir, "rigstate.config.json");
644
- const content = await fs8.readFile(configPath, "utf-8");
513
+ const configPath = path8.join(rootDir, "rigstate.config.json");
514
+ const content = await fs7.readFile(configPath, "utf-8");
645
515
  const userConfig = JSON.parse(content);
646
516
  return {
647
517
  governance: {
@@ -655,37 +525,37 @@ async function getGovernanceConfig(rootDir = process.cwd()) {
655
525
  }
656
526
  async function getSessionState(rootDir = process.cwd()) {
657
527
  try {
658
- const sessionPath = path9.join(rootDir, ".rigstate", "session.json");
659
- const content = await fs8.readFile(sessionPath, "utf-8");
528
+ const sessionPath = path8.join(rootDir, ".rigstate", "session.json");
529
+ const content = await fs7.readFile(sessionPath, "utf-8");
660
530
  return JSON.parse(content);
661
531
  } catch (e) {
662
532
  return DEFAULT_SESSION;
663
533
  }
664
534
  }
665
535
  async function setSoftLock(reason, violationId, rootDir = process.cwd()) {
666
- const sessionPath = path9.join(rootDir, ".rigstate", "session.json");
536
+ const sessionPath = path8.join(rootDir, ".rigstate", "session.json");
667
537
  const state = {
668
538
  status: "SOFT_LOCK",
669
539
  active_violation: violationId,
670
540
  lock_reason: reason,
671
541
  last_updated: (/* @__PURE__ */ new Date()).toISOString()
672
542
  };
673
- await fs8.mkdir(path9.dirname(sessionPath), { recursive: true });
674
- await fs8.writeFile(sessionPath, JSON.stringify(state, null, 2), "utf-8");
543
+ await fs7.mkdir(path8.dirname(sessionPath), { recursive: true });
544
+ await fs7.writeFile(sessionPath, JSON.stringify(state, null, 2), "utf-8");
675
545
  }
676
546
  async function clearSoftLock(rootDir = process.cwd()) {
677
- const sessionPath = path9.join(rootDir, ".rigstate", "session.json");
547
+ const sessionPath = path8.join(rootDir, ".rigstate", "session.json");
678
548
  const state = {
679
549
  ...DEFAULT_SESSION,
680
550
  last_updated: (/* @__PURE__ */ new Date()).toISOString()
681
551
  };
682
- await fs8.mkdir(path9.dirname(sessionPath), { recursive: true });
683
- await fs8.writeFile(sessionPath, JSON.stringify(state, null, 2), "utf-8");
552
+ await fs7.mkdir(path8.dirname(sessionPath), { recursive: true });
553
+ await fs7.writeFile(sessionPath, JSON.stringify(state, null, 2), "utf-8");
684
554
  }
685
555
  async function performOverride(violationId, reason, rootDir = process.cwd()) {
686
556
  const config2 = await getGovernanceConfig(rootDir);
687
557
  if (!config2.governance.allow_overrides) {
688
- console.log(chalk10.red("\u274C Overrides are disabled for this project."));
558
+ console.log(chalk9.red("\u274C Overrides are disabled for this project."));
689
559
  return false;
690
560
  }
691
561
  await clearSoftLock(rootDir);
@@ -722,22 +592,22 @@ var watchdog_exports = {};
722
592
  __export(watchdog_exports, {
723
593
  runGuardianWatchdog: () => runGuardianWatchdog
724
594
  });
725
- import fs9 from "fs/promises";
726
- import path10 from "path";
727
- import chalk11 from "chalk";
595
+ import fs8 from "fs/promises";
596
+ import path9 from "path";
597
+ import chalk10 from "chalk";
728
598
  import axios7 from "axios";
729
599
  async function countLines(filePath) {
730
600
  try {
731
- const content = await fs9.readFile(filePath, "utf-8");
601
+ const content = await fs8.readFile(filePath, "utf-8");
732
602
  return content.split("\n").length;
733
603
  } catch (e) {
734
604
  return 0;
735
605
  }
736
606
  }
737
607
  async function getFiles(dir, extension) {
738
- const entries = await fs9.readdir(dir, { withFileTypes: true });
608
+ const entries = await fs8.readdir(dir, { withFileTypes: true });
739
609
  const files = await Promise.all(entries.map(async (entry) => {
740
- const res = path10.resolve(dir, entry.name);
610
+ const res = path9.resolve(dir, entry.name);
741
611
  if (entry.isDirectory()) {
742
612
  if (entry.name === "node_modules" || entry.name === ".git" || entry.name === ".next" || entry.name === "dist") return [];
743
613
  return getFiles(res, extension);
@@ -765,8 +635,8 @@ async function fetchRulesFromApi(projectId) {
765
635
  }
766
636
  } catch (error) {
767
637
  try {
768
- const cachePath = path10.join(process.cwd(), CACHE_FILE);
769
- const content = await fs9.readFile(cachePath, "utf-8");
638
+ const cachePath = path9.join(process.cwd(), CACHE_FILE);
639
+ const content = await fs8.readFile(cachePath, "utf-8");
770
640
  const cached = JSON.parse(content);
771
641
  if (cached.settings) {
772
642
  return {
@@ -785,7 +655,7 @@ async function fetchRulesFromApi(projectId) {
785
655
  };
786
656
  }
787
657
  async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
788
- console.log(chalk11.bold("\n\u{1F6E1}\uFE0F Active Guardian Watchdog Initiated..."));
658
+ console.log(chalk10.bold("\n\u{1F6E1}\uFE0F Active Guardian Watchdog Initiated..."));
789
659
  let lmax = settings.lmax || DEFAULT_LMAX;
790
660
  let lmaxWarning = settings.lmax_warning || DEFAULT_LMAX_WARNING;
791
661
  let ruleSource = settings.lmax ? "Settings (Passed)" : "Default";
@@ -795,47 +665,47 @@ async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
795
665
  lmaxWarning = apiRules.lmaxWarning;
796
666
  ruleSource = apiRules.source;
797
667
  }
798
- console.log(chalk11.dim(`Governance Rules: L_max=${lmax}, L_max_warning=${lmaxWarning}, Source: ${ruleSource}`));
668
+ console.log(chalk10.dim(`Governance Rules: L_max=${lmax}, L_max_warning=${lmaxWarning}, Source: ${ruleSource}`));
799
669
  const targetExtensions = [".ts", ".tsx"];
800
670
  let scanTarget = rootPath;
801
- const webSrc = path10.join(rootPath, "apps", "web", "src");
671
+ const webSrc = path9.join(rootPath, "apps", "web", "src");
802
672
  try {
803
- await fs9.access(webSrc);
673
+ await fs8.access(webSrc);
804
674
  scanTarget = webSrc;
805
675
  } catch {
806
676
  }
807
- console.log(chalk11.dim(`Scanning target: ${path10.relative(process.cwd(), scanTarget)}`));
677
+ console.log(chalk10.dim(`Scanning target: ${path9.relative(process.cwd(), scanTarget)}`));
808
678
  const files = await getFiles(scanTarget, targetExtensions);
809
679
  let violations = 0;
810
680
  let warnings = 0;
811
681
  const results = [];
812
682
  for (const file of files) {
813
683
  const lines = await countLines(file);
814
- const relPath = path10.relative(rootPath, file);
684
+ const relPath = path9.relative(rootPath, file);
815
685
  if (lines > lmax) {
816
686
  results.push({ file: relPath, lines, status: "VIOLATION" });
817
687
  violations++;
818
- console.log(chalk11.red(`[VIOLATION] ${relPath}: ${lines} lines (Limit: ${lmax})`));
688
+ console.log(chalk10.red(`[VIOLATION] ${relPath}: ${lines} lines (Limit: ${lmax})`));
819
689
  } else if (lines > lmaxWarning) {
820
690
  results.push({ file: relPath, lines, status: "WARNING" });
821
691
  warnings++;
822
- console.log(chalk11.yellow(`[WARNING] ${relPath}: ${lines} lines (Threshold: ${lmaxWarning})`));
692
+ console.log(chalk10.yellow(`[WARNING] ${relPath}: ${lines} lines (Threshold: ${lmaxWarning})`));
823
693
  }
824
694
  }
825
695
  if (violations === 0 && warnings === 0) {
826
- console.log(chalk11.green(`\u2714 All ${files.length} files are within governance limits.`));
696
+ console.log(chalk10.green(`\u2714 All ${files.length} files are within governance limits.`));
827
697
  } else {
828
- console.log("\n" + chalk11.bold("Summary:"));
829
- console.log(chalk11.red(`Violations: ${violations}`));
830
- console.log(chalk11.yellow(`Warnings: ${warnings}`));
698
+ console.log("\n" + chalk10.bold("Summary:"));
699
+ console.log(chalk10.red(`Violations: ${violations}`));
700
+ console.log(chalk10.yellow(`Warnings: ${warnings}`));
831
701
  const { getGovernanceConfig: getGovernanceConfig2, setSoftLock: setSoftLock2, InterventionLevel: InterventionLevel2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
832
702
  const { governance } = await getGovernanceConfig2(rootPath);
833
- console.log(chalk11.dim(`Intervention Level: ${InterventionLevel2[governance.intervention_level] || "UNKNOWN"} (${governance.intervention_level})`));
703
+ console.log(chalk10.dim(`Intervention Level: ${InterventionLevel2[governance.intervention_level] || "UNKNOWN"} (${governance.intervention_level})`));
834
704
  if (violations > 0) {
835
- console.log(chalk11.red.bold("\nCRITICAL: Governance violations detected. Immediate refactoring required."));
705
+ console.log(chalk10.red.bold("\nCRITICAL: Governance violations detected. Immediate refactoring required."));
836
706
  if (governance.intervention_level >= InterventionLevel2.SENTINEL) {
837
- console.log(chalk11.red.bold("\u{1F6D1} SENTINEL MODE: Session SOFT_LOCKED until resolved."));
838
- console.log(chalk11.red(' Run "rigstate override <id> --reason \\"...\\"" if this is an emergency.'));
707
+ console.log(chalk10.red.bold("\u{1F6D1} SENTINEL MODE: Session SOFT_LOCKED until resolved."));
708
+ console.log(chalk10.red(' Run "rigstate override <id> --reason \\"...\\"" if this is an emergency.'));
839
709
  await setSoftLock2("Sentinel Mode: Governance Violations Detected", "ARC-VIOLATION", rootPath);
840
710
  }
841
711
  }
@@ -858,9 +728,9 @@ async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
858
728
  }, {
859
729
  headers: { Authorization: `Bearer ${apiKey}` }
860
730
  });
861
- console.log(chalk11.dim("\u2714 Violations synced to Rigstate Cloud."));
731
+ console.log(chalk10.dim("\u2714 Violations synced to Rigstate Cloud."));
862
732
  } catch (e) {
863
- console.log(chalk11.dim("\u26A0 Cloud sync skipped: " + (e.message || "Unknown")));
733
+ console.log(chalk10.dim("\u26A0 Cloud sync skipped: " + (e.message || "Unknown")));
864
734
  }
865
735
  }
866
736
  }
@@ -1757,7 +1627,7 @@ var require_package = __commonJS({
1757
1627
  "package.json"(exports, module) {
1758
1628
  module.exports = {
1759
1629
  name: "@rigstate/cli",
1760
- version: "0.7.22",
1630
+ version: "0.7.23",
1761
1631
  description: "Rigstate CLI - Code audit, sync and supervision tool",
1762
1632
  type: "module",
1763
1633
  main: "./dist/index.js",
@@ -1867,67 +1737,70 @@ Your API key has been securely stored. You can now use "rigstate scan" to audit
1867
1737
  // src/commands/link.ts
1868
1738
  init_esm_shims();
1869
1739
  init_config();
1870
- import { Command as Command5 } from "commander";
1871
- import fs3 from "fs/promises";
1872
- import path4 from "path";
1873
- import chalk6 from "chalk";
1740
+ import { Command as Command4 } from "commander";
1741
+ import fs2 from "fs/promises";
1742
+ import path3 from "path";
1743
+ import chalk5 from "chalk";
1874
1744
  import os from "os";
1875
1745
  function createLinkCommand() {
1876
- return new Command5("link").description("Link current directory to a Rigstate project").argument("<projectId>", "Project ID to link").action(async (projectId) => {
1746
+ return new Command4("link").description("Link current directory to a Rigstate project").argument("<projectId>", "Project ID to link").action(async (projectId) => {
1877
1747
  try {
1878
- const globalPath = path4.join(os.homedir(), ".rigstate", "config.json");
1879
- const globalData = await fs3.readFile(globalPath, "utf-8").catch(() => null);
1748
+ const globalPath = path3.join(os.homedir(), ".rigstate", "config.json");
1749
+ const globalData = await fs2.readFile(globalPath, "utf-8").catch(() => null);
1880
1750
  if (globalData) {
1881
1751
  const config2 = JSON.parse(globalData);
1882
1752
  const cwd = process.cwd();
1883
1753
  if (config2.overrides && config2.overrides[cwd]) {
1884
1754
  const overrideId = config2.overrides[cwd];
1885
1755
  if (overrideId !== projectId) {
1886
- console.warn(chalk6.yellow(`Global override detected. Enforcing project ID: ${overrideId}`));
1756
+ console.warn(chalk5.yellow(`Global override detected. Enforcing project ID: ${overrideId}`));
1887
1757
  projectId = overrideId;
1888
1758
  }
1889
1759
  }
1890
1760
  }
1891
1761
  } catch (e) {
1892
1762
  }
1893
- const manifestPath = path4.join(process.cwd(), ".rigstate");
1763
+ const manifestPath = path3.join(process.cwd(), ".rigstate");
1894
1764
  const content = {
1895
1765
  project_id: projectId,
1896
- api_url: getApiUrl(),
1897
1766
  linked_at: (/* @__PURE__ */ new Date()).toISOString()
1898
1767
  };
1768
+ const currentUrl = getApiUrl();
1769
+ if (currentUrl !== "https://app.rigstate.com") {
1770
+ content.api_url = currentUrl;
1771
+ }
1899
1772
  try {
1900
- await fs3.writeFile(manifestPath, JSON.stringify(content, null, 2), "utf-8");
1901
- console.log(chalk6.green(`\u2714 Linked to project ID: ${projectId}`));
1902
- console.log(chalk6.dim(`Created local context manifest at .rigstate`));
1773
+ await fs2.writeFile(manifestPath, JSON.stringify(content, null, 2), "utf-8");
1774
+ console.log(chalk5.green(`\u2714 Linked to project ID: ${projectId}`));
1775
+ console.log(chalk5.dim(`Created local context manifest at .rigstate`));
1903
1776
  console.log("");
1904
- console.log(chalk6.bold("\u{1F916} Rigstate Automation Detected"));
1777
+ console.log(chalk5.bold("\u{1F916} Rigstate Automation Detected"));
1905
1778
  console.log("");
1906
1779
  const { getApiKey: _getApiKey, getApiUrl: _getApiUrl } = await Promise.resolve().then(() => (init_config(), config_exports));
1907
1780
  const apiKey = getApiKey();
1908
1781
  const apiUrl = getApiUrl();
1909
1782
  if (apiKey) {
1910
- console.log(chalk6.blue("\u{1F510} Checking Vault for secrets..."));
1783
+ console.log(chalk5.blue("\u{1F510} Checking Vault for secrets..."));
1911
1784
  const { syncEnv: syncEnv2 } = await Promise.resolve().then(() => (init_env(), env_exports));
1912
1785
  await syncEnv2(projectId, apiKey, apiUrl, true);
1913
- console.log(chalk6.blue("\u{1F9E0} Syncing neural instructions..."));
1786
+ console.log(chalk5.blue("\u{1F9E0} Syncing neural instructions..."));
1914
1787
  const { syncProjectRules: syncProjectRules2 } = await Promise.resolve().then(() => (init_sync_rules(), sync_rules_exports));
1915
1788
  await syncProjectRules2(projectId, apiKey, apiUrl);
1916
- console.log(chalk6.blue("\u{1F6E1}\uFE0F Checking immunity system..."));
1789
+ console.log(chalk5.blue("\u{1F6E1}\uFE0F Checking immunity system..."));
1917
1790
  await installHooks(process.cwd());
1918
1791
  console.log("");
1919
- console.log(chalk6.bold.green("\u{1F680} Link Complete! Your environment is ready."));
1792
+ console.log(chalk5.bold.green("\u{1F680} Link Complete! Your environment is ready."));
1920
1793
  const { suggestNextMove: suggestNextMove2 } = await Promise.resolve().then(() => (init_suggest(), suggest_exports));
1921
1794
  await suggestNextMove2(projectId, apiKey, apiUrl);
1922
1795
  } else {
1923
1796
  console.log("");
1924
- console.log(chalk6.bold.green("\u{1F680} Link Complete!"));
1797
+ console.log(chalk5.bold.green("\u{1F680} Link Complete!"));
1925
1798
  }
1926
1799
  } catch (error) {
1927
1800
  if (error.message.includes("Not authenticated")) {
1928
- console.warn(chalk6.yellow('\u26A0\uFE0F Not authenticated. Run "rigstate login" to enable automation features.'));
1801
+ console.warn(chalk5.yellow('\u26A0\uFE0F Not authenticated. Run "rigstate login" to enable automation features.'));
1929
1802
  } else {
1930
- console.error(chalk6.red(`Failed to link project: ${error.message}`));
1803
+ console.error(chalk5.red(`Failed to link project: ${error.message}`));
1931
1804
  }
1932
1805
  }
1933
1806
  });
@@ -1938,18 +1811,17 @@ async function installHooks(cwd) {
1938
1811
  try {
1939
1812
  await fs23.access(path25.join(cwd, ".git"));
1940
1813
  } catch {
1941
- console.log(chalk6.dim(" (Not a git repository, skipping hooks)"));
1814
+ console.log(chalk5.dim(" (Not a git repository, skipping hooks)"));
1942
1815
  return;
1943
1816
  }
1944
1817
  const hooksDir = path25.join(cwd, ".husky");
1945
1818
  try {
1946
- const { installHooks: runInstall } = await Promise.resolve().then(() => (init_hooks(), hooks_exports));
1947
1819
  const preCommitPath = path25.join(cwd, ".git/hooks/pre-commit");
1948
1820
  try {
1949
1821
  await fs23.access(preCommitPath);
1950
- console.log(chalk6.green(" \u2714 Git hooks already active"));
1822
+ console.log(chalk5.green(" \u2714 Git hooks already active"));
1951
1823
  } catch {
1952
- console.log(chalk6.yellow(' \u26A0\uFE0F Git hooks missing. Run "rigstate hooks install" to secure repo.'));
1824
+ console.log(chalk5.yellow(' \u26A0\uFE0F Git hooks missing. Run "rigstate hooks install" to secure repo.'));
1953
1825
  }
1954
1826
  } catch (e) {
1955
1827
  }
@@ -1958,22 +1830,22 @@ async function installHooks(cwd) {
1958
1830
  // src/commands/scan.ts
1959
1831
  init_esm_shims();
1960
1832
  init_config();
1961
- import { Command as Command6 } from "commander";
1962
- import chalk7 from "chalk";
1833
+ import { Command as Command5 } from "commander";
1834
+ import chalk6 from "chalk";
1963
1835
  import ora3 from "ora";
1964
1836
  import axios4 from "axios";
1965
1837
  import { glob } from "glob";
1966
- import fs5 from "fs/promises";
1967
- import path6 from "path";
1838
+ import fs4 from "fs/promises";
1839
+ import path5 from "path";
1968
1840
 
1969
1841
  // src/utils/files.ts
1970
1842
  init_esm_shims();
1971
- import fs4 from "fs/promises";
1972
- import path5 from "path";
1843
+ import fs3 from "fs/promises";
1844
+ import path4 from "path";
1973
1845
  async function readGitignore(dir) {
1974
- const gitignorePath = path5.join(dir, ".gitignore");
1846
+ const gitignorePath = path4.join(dir, ".gitignore");
1975
1847
  try {
1976
- const content = await fs4.readFile(gitignorePath, "utf-8");
1848
+ const content = await fs3.readFile(gitignorePath, "utf-8");
1977
1849
  return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
1978
1850
  } catch (error) {
1979
1851
  return [];
@@ -2035,13 +1907,13 @@ function isCodeFile(filePath) {
2035
1907
  ".vue",
2036
1908
  ".svelte"
2037
1909
  ];
2038
- const ext = path5.extname(filePath).toLowerCase();
1910
+ const ext = path4.extname(filePath).toLowerCase();
2039
1911
  return codeExtensions.includes(ext);
2040
1912
  }
2041
1913
 
2042
1914
  // src/commands/scan.ts
2043
1915
  function createScanCommand() {
2044
- return new Command6("scan").description("Scan code files for security and quality issues").argument("[path]", "Directory or file to scan", ".").option("--json", "Output results as JSON").option("--project <id>", "Project ID to associate with this scan").action(async (targetPath, options) => {
1916
+ return new Command5("scan").description("Scan code files for security and quality issues").argument("[path]", "Directory or file to scan", ".").option("--json", "Output results as JSON").option("--project <id>", "Project ID to associate with this scan").action(async (targetPath, options) => {
2045
1917
  const spinner = ora3();
2046
1918
  try {
2047
1919
  const apiKey = getApiKey();
@@ -2049,26 +1921,26 @@ function createScanCommand() {
2049
1921
  const projectId = options.project || getProjectId();
2050
1922
  if (!projectId) {
2051
1923
  console.warn(
2052
- chalk7.yellow(
1924
+ chalk6.yellow(
2053
1925
  "\u26A0\uFE0F No project ID specified. Use --project <id> or set a default."
2054
1926
  )
2055
1927
  );
2056
1928
  }
2057
- const scanPath = path6.resolve(process.cwd(), targetPath);
2058
- spinner.start(`Scanning ${chalk7.cyan(scanPath)}...`);
1929
+ const scanPath = path5.resolve(process.cwd(), targetPath);
1930
+ spinner.start(`Scanning ${chalk6.cyan(scanPath)}...`);
2059
1931
  const gitignorePatterns = await readGitignore(scanPath);
2060
- const pattern = path6.join(scanPath, "**/*");
1932
+ const pattern = path5.join(scanPath, "**/*");
2061
1933
  const allFiles = await glob(pattern, {
2062
1934
  nodir: true,
2063
1935
  dot: false,
2064
1936
  ignore: ["**/node_modules/**", "**/.git/**", "**/dist/**", "**/build/**"]
2065
1937
  });
2066
1938
  const codeFiles = allFiles.filter((file) => {
2067
- const relativePath = path6.relative(scanPath, file);
1939
+ const relativePath = path5.relative(scanPath, file);
2068
1940
  return isCodeFile(file) && !shouldIgnore(relativePath, gitignorePatterns);
2069
1941
  });
2070
1942
  if (codeFiles.length === 0) {
2071
- spinner.warn(chalk7.yellow("No code files found to scan."));
1943
+ spinner.warn(chalk6.yellow("No code files found to scan."));
2072
1944
  return;
2073
1945
  }
2074
1946
  spinner.text = `Found ${codeFiles.length} files. Scanning...`;
@@ -2077,10 +1949,10 @@ function createScanCommand() {
2077
1949
  const severityCounts = {};
2078
1950
  for (let i = 0; i < codeFiles.length; i++) {
2079
1951
  const filePath = codeFiles[i];
2080
- const relativePath = path6.relative(scanPath, filePath);
1952
+ const relativePath = path5.relative(scanPath, filePath);
2081
1953
  spinner.text = `Scanning ${i + 1}/${codeFiles.length}: ${relativePath}`;
2082
1954
  try {
2083
- const content = await fs5.readFile(filePath, "utf-8");
1955
+ const content = await fs4.readFile(filePath, "utf-8");
2084
1956
  const response = await axios4.post(
2085
1957
  `${apiUrl}/api/v1/audit`,
2086
1958
  {
@@ -2116,15 +1988,15 @@ function createScanCommand() {
2116
1988
  }
2117
1989
  } catch (fileError) {
2118
1990
  if (axios4.isAxiosError(fileError)) {
2119
- console.warn(chalk7.yellow(`
1991
+ console.warn(chalk6.yellow(`
2120
1992
  \u26A0\uFE0F Skipping ${relativePath}: ${fileError.message}`));
2121
1993
  } else {
2122
- console.warn(chalk7.yellow(`
1994
+ console.warn(chalk6.yellow(`
2123
1995
  \u26A0\uFE0F Error reading ${relativePath}`));
2124
1996
  }
2125
1997
  }
2126
1998
  }
2127
- spinner.succeed(chalk7.green("\u2705 Scan completed!"));
1999
+ spinner.succeed(chalk6.green("\u2705 Scan completed!"));
2128
2000
  const aggregatedResponse = {
2129
2001
  results,
2130
2002
  summary: {
@@ -2139,21 +2011,21 @@ function createScanCommand() {
2139
2011
  printPrettyResults(aggregatedResponse);
2140
2012
  }
2141
2013
  } catch (error) {
2142
- spinner.fail(chalk7.red("\u274C Scan failed"));
2014
+ spinner.fail(chalk6.red("\u274C Scan failed"));
2143
2015
  if (axios4.isAxiosError(error)) {
2144
2016
  if (error.response) {
2145
- console.error(chalk7.red("API Error:"), error.response.data);
2017
+ console.error(chalk6.red("API Error:"), error.response.data);
2146
2018
  } else if (error.request) {
2147
2019
  console.error(
2148
- chalk7.red("Network Error:"),
2020
+ chalk6.red("Network Error:"),
2149
2021
  "Could not reach the API. Is the server running?"
2150
2022
  );
2151
2023
  } else {
2152
- console.error(chalk7.red("Error:"), error.message);
2024
+ console.error(chalk6.red("Error:"), error.message);
2153
2025
  }
2154
2026
  } else {
2155
2027
  console.error(
2156
- chalk7.red("Error:"),
2028
+ chalk6.red("Error:"),
2157
2029
  error instanceof Error ? error.message : "Unknown error"
2158
2030
  );
2159
2031
  }
@@ -2163,10 +2035,10 @@ function createScanCommand() {
2163
2035
  }
2164
2036
  function printPrettyResults(data) {
2165
2037
  const { results, summary } = data;
2166
- console.log("\n" + chalk7.bold("\u{1F4CA} Scan Summary"));
2167
- console.log(chalk7.dim("\u2500".repeat(60)));
2168
- console.log(`Total Files Scanned: ${chalk7.cyan(summary.total_files)}`);
2169
- console.log(`Total Issues Found: ${chalk7.yellow(summary.total_issues)}`);
2038
+ console.log("\n" + chalk6.bold("\u{1F4CA} Scan Summary"));
2039
+ console.log(chalk6.dim("\u2500".repeat(60)));
2040
+ console.log(`Total Files Scanned: ${chalk6.cyan(summary.total_files)}`);
2041
+ console.log(`Total Issues Found: ${chalk6.yellow(summary.total_issues)}`);
2170
2042
  if (summary.by_severity) {
2171
2043
  console.log("\nIssues by Severity:");
2172
2044
  Object.entries(summary.by_severity).forEach(([severity, count]) => {
@@ -2175,87 +2047,87 @@ function printPrettyResults(data) {
2175
2047
  });
2176
2048
  }
2177
2049
  if (results && results.length > 0) {
2178
- console.log("\n" + chalk7.bold("\u{1F50D} Detailed Results"));
2179
- console.log(chalk7.dim("\u2500".repeat(60)));
2050
+ console.log("\n" + chalk6.bold("\u{1F50D} Detailed Results"));
2051
+ console.log(chalk6.dim("\u2500".repeat(60)));
2180
2052
  results.forEach((result) => {
2181
2053
  if (result.issues && result.issues.length > 0) {
2182
2054
  console.log(`
2183
- ${chalk7.bold(result.file_path)}`);
2055
+ ${chalk6.bold(result.file_path)}`);
2184
2056
  result.issues.forEach((issue) => {
2185
2057
  const severityColor = getSeverityColor(issue.severity);
2186
- const lineInfo = issue.line ? chalk7.dim(`:${issue.line}`) : "";
2058
+ const lineInfo = issue.line ? chalk6.dim(`:${issue.line}`) : "";
2187
2059
  console.log(
2188
2060
  ` ${severityColor(`[${issue.severity.toUpperCase()}]`)} ${issue.type}${lineInfo}`
2189
2061
  );
2190
- console.log(` ${chalk7.dim(issue.message)}`);
2062
+ console.log(` ${chalk6.dim(issue.message)}`);
2191
2063
  });
2192
2064
  }
2193
2065
  });
2194
2066
  }
2195
- console.log("\n" + chalk7.dim("\u2500".repeat(60)));
2067
+ console.log("\n" + chalk6.dim("\u2500".repeat(60)));
2196
2068
  }
2197
2069
  function getSeverityColor(severity) {
2198
2070
  switch (severity.toLowerCase()) {
2199
2071
  case "critical":
2200
- return chalk7.red.bold;
2072
+ return chalk6.red.bold;
2201
2073
  case "high":
2202
- return chalk7.red;
2074
+ return chalk6.red;
2203
2075
  case "medium":
2204
- return chalk7.yellow;
2076
+ return chalk6.yellow;
2205
2077
  case "low":
2206
- return chalk7.blue;
2078
+ return chalk6.blue;
2207
2079
  case "info":
2208
- return chalk7.gray;
2080
+ return chalk6.gray;
2209
2081
  default:
2210
- return chalk7.white;
2082
+ return chalk6.white;
2211
2083
  }
2212
2084
  }
2213
2085
 
2214
2086
  // src/commands/fix.ts
2215
2087
  init_esm_shims();
2216
2088
  init_config();
2217
- import { Command as Command7 } from "commander";
2218
- import chalk8 from "chalk";
2089
+ import { Command as Command6 } from "commander";
2090
+ import chalk7 from "chalk";
2219
2091
  import ora4 from "ora";
2220
2092
  import axios5 from "axios";
2221
2093
  import { glob as glob2 } from "glob";
2222
- import fs6 from "fs/promises";
2223
- import path7 from "path";
2094
+ import fs5 from "fs/promises";
2095
+ import path6 from "path";
2224
2096
  import inquirer from "inquirer";
2225
2097
  import * as Diff from "diff";
2226
2098
  function createFixCommand() {
2227
- return new Command7("fix").description("Scan and interactively FIX detected issues using Rigstate AI").argument("[path]", "Directory or file to scan", ".").option("--project <id>", "Project ID to context-aware audit").action(async (targetPath, options) => {
2099
+ return new Command6("fix").description("Scan and interactively FIX detected issues using Rigstate AI").argument("[path]", "Directory or file to scan", ".").option("--project <id>", "Project ID to context-aware audit").action(async (targetPath, options) => {
2228
2100
  const spinner = ora4();
2229
2101
  try {
2230
2102
  const apiKey = getApiKey();
2231
2103
  const apiUrl = getApiUrl();
2232
2104
  const projectId = options.project || getProjectId();
2233
2105
  if (!projectId) {
2234
- console.log(chalk8.yellow("\u26A0\uFE0F Project ID is required for fixing. Using default or pass --project <id>"));
2106
+ console.log(chalk7.yellow("\u26A0\uFE0F Project ID is required for fixing. Using default or pass --project <id>"));
2235
2107
  }
2236
- const scanPath = path7.resolve(process.cwd(), targetPath);
2108
+ const scanPath = path6.resolve(process.cwd(), targetPath);
2237
2109
  const gitignorePatterns = await readGitignore(scanPath);
2238
- const pattern = path7.join(scanPath, "**/*");
2110
+ const pattern = path6.join(scanPath, "**/*");
2239
2111
  const allFiles = await glob2(pattern, { nodir: true, dot: false, ignore: ["**/node_modules/**", "**/.git/**"] });
2240
2112
  const codeFiles = allFiles.filter((file) => {
2241
- const relativePath = path7.relative(scanPath, file);
2113
+ const relativePath = path6.relative(scanPath, file);
2242
2114
  return isCodeFile(file) && !shouldIgnore(relativePath, gitignorePatterns);
2243
2115
  });
2244
2116
  if (codeFiles.length === 0) {
2245
- console.log(chalk8.yellow("No code files found."));
2117
+ console.log(chalk7.yellow("No code files found."));
2246
2118
  return;
2247
2119
  }
2248
- console.log(chalk8.bold(`
2120
+ console.log(chalk7.bold(`
2249
2121
  \u{1F9E0} Rigstate Fix Mode`));
2250
- console.log(chalk8.dim(`Scanning ${codeFiles.length} files with Project Context...
2122
+ console.log(chalk7.dim(`Scanning ${codeFiles.length} files with Project Context...
2251
2123
  `));
2252
2124
  let fixedCount = 0;
2253
2125
  for (let i = 0; i < codeFiles.length; i++) {
2254
2126
  const filePath = codeFiles[i];
2255
- const relativePath = path7.relative(scanPath, filePath);
2127
+ const relativePath = path6.relative(scanPath, filePath);
2256
2128
  spinner.start(`Analyzing ${relativePath}...`);
2257
2129
  try {
2258
- const content = await fs6.readFile(filePath, "utf-8");
2130
+ const content = await fs5.readFile(filePath, "utf-8");
2259
2131
  const response = await axios5.post(
2260
2132
  `${apiUrl}/api/v1/audit`,
2261
2133
  { content, file_path: relativePath, project_id: projectId },
@@ -2266,22 +2138,22 @@ function createFixCommand() {
2266
2138
  if (fixableIssues.length > 0) {
2267
2139
  spinner.stop();
2268
2140
  console.log(`
2269
- ${chalk8.bold(relativePath)}: Found ${fixableIssues.length} fixable issues.`);
2141
+ ${chalk7.bold(relativePath)}: Found ${fixableIssues.length} fixable issues.`);
2270
2142
  for (const issue of fixableIssues) {
2271
- console.log(chalk8.red(`
2143
+ console.log(chalk7.red(`
2272
2144
  [${issue.type}] ${issue.title}`));
2273
- console.log(chalk8.dim(issue.suggestion || issue.message));
2145
+ console.log(chalk7.dim(issue.suggestion || issue.message));
2274
2146
  const diff = Diff.createTwoFilesPatch(relativePath, relativePath, content, issue.fixed_content, "Current", "Fixed");
2275
2147
  console.log("\n" + diff.split("\n").slice(0, 15).join("\n") + (diff.split("\n").length > 15 ? "\n..." : ""));
2276
2148
  const { apply } = await inquirer.prompt([{
2277
2149
  type: "confirm",
2278
2150
  name: "apply",
2279
- message: `Apply this fix to ${chalk8.cyan(relativePath)}?`,
2151
+ message: `Apply this fix to ${chalk7.cyan(relativePath)}?`,
2280
2152
  default: true
2281
2153
  }]);
2282
2154
  if (apply) {
2283
- await fs6.writeFile(filePath, issue.fixed_content);
2284
- console.log(chalk8.green(`\u2705 Fixed applied!`));
2155
+ await fs5.writeFile(filePath, issue.fixed_content);
2156
+ console.log(chalk7.green(`\u2705 Fixed applied!`));
2285
2157
  fixedCount++;
2286
2158
  if (issue.related_step_id) {
2287
2159
  const { completeStep } = await inquirer.prompt([{
@@ -2297,15 +2169,15 @@ ${chalk8.bold(relativePath)}: Found ${fixableIssues.length} fixable issues.`);
2297
2169
  { step_id: issue.related_step_id, status: "COMPLETED", project_id: projectId },
2298
2170
  { headers: { "Authorization": `Bearer ${apiKey}` } }
2299
2171
  );
2300
- console.log(chalk8.green(`\u{1F680} Roadmap updated! Mission Control is in sync.`));
2172
+ console.log(chalk7.green(`\u{1F680} Roadmap updated! Mission Control is in sync.`));
2301
2173
  } catch (err) {
2302
- console.error(chalk8.yellow(`Failed to update roadmap: ${err.message}`));
2174
+ console.error(chalk7.yellow(`Failed to update roadmap: ${err.message}`));
2303
2175
  }
2304
2176
  }
2305
2177
  }
2306
2178
  break;
2307
2179
  } else {
2308
- console.log(chalk8.dim("Skipped."));
2180
+ console.log(chalk7.dim("Skipped."));
2309
2181
  }
2310
2182
  }
2311
2183
  } else {
@@ -2315,11 +2187,11 @@ ${chalk8.bold(relativePath)}: Found ${fixableIssues.length} fixable issues.`);
2315
2187
  }
2316
2188
  }
2317
2189
  spinner.stop();
2318
- console.log(chalk8.bold.green(`
2190
+ console.log(chalk7.bold.green(`
2319
2191
 
2320
2192
  \u{1F680} Fix session complete!`));
2321
2193
  console.log(`Frank fixed ${fixedCount} detected issues.`);
2322
- console.log(chalk8.dim(`Run 'rigstate scan' to verify remaining issues.`));
2194
+ console.log(chalk7.dim(`Run 'rigstate scan' to verify remaining issues.`));
2323
2195
  } catch (error) {
2324
2196
  spinner.fail("Fix session failed");
2325
2197
  console.error(error.message);
@@ -2330,14 +2202,14 @@ ${chalk8.bold(relativePath)}: Found ${fixableIssues.length} fixable issues.`);
2330
2202
  // src/commands/sync.ts
2331
2203
  init_esm_shims();
2332
2204
  init_config();
2333
- import { Command as Command8 } from "commander";
2334
- import chalk12 from "chalk";
2205
+ import { Command as Command7 } from "commander";
2206
+ import chalk11 from "chalk";
2335
2207
  import ora5 from "ora";
2336
2208
  import axios8 from "axios";
2337
- import fs10 from "fs/promises";
2338
- import path11 from "path";
2209
+ import fs9 from "fs/promises";
2210
+ import path10 from "path";
2339
2211
  function createSyncCommand() {
2340
- const sync = new Command8("sync");
2212
+ const sync = new Command7("sync");
2341
2213
  sync.description("Synchronize local state with Rigstate Cloud").option("-p, --project <id>", "Specify Project ID (saves to config automatically)").action(async (options) => {
2342
2214
  const spinner = ora5("Synchronizing project state...").start();
2343
2215
  try {
@@ -2351,8 +2223,8 @@ function createSyncCommand() {
2351
2223
  let projectId = options.project;
2352
2224
  if (!projectId) {
2353
2225
  try {
2354
- const manifestPath = path11.join(process.cwd(), ".rigstate");
2355
- const manifestContent = await fs10.readFile(manifestPath, "utf-8");
2226
+ const manifestPath = path10.join(process.cwd(), ".rigstate");
2227
+ const manifestContent = await fs9.readFile(manifestPath, "utf-8");
2356
2228
  const manifest = JSON.parse(manifestContent);
2357
2229
  if (manifest.project_id) projectId = manifest.project_id;
2358
2230
  } catch (e) {
@@ -2376,31 +2248,31 @@ function createSyncCommand() {
2376
2248
  }
2377
2249
  const { roadmap, project } = response.data.data;
2378
2250
  const timestamp = response.data.timestamp;
2379
- const targetPath = path11.join(process.cwd(), "roadmap.json");
2251
+ const targetPath = path10.join(process.cwd(), "roadmap.json");
2380
2252
  const fileContent = JSON.stringify({
2381
2253
  project,
2382
2254
  last_synced: timestamp,
2383
2255
  roadmap
2384
2256
  }, null, 2);
2385
- await fs10.writeFile(targetPath, fileContent, "utf-8");
2257
+ await fs9.writeFile(targetPath, fileContent, "utf-8");
2386
2258
  try {
2387
- const manifestPath = path11.join(process.cwd(), ".rigstate");
2259
+ const manifestPath = path10.join(process.cwd(), ".rigstate");
2388
2260
  const manifestContent = {
2389
2261
  project_id: projectId,
2390
2262
  project_name: project,
2391
2263
  last_synced: timestamp,
2392
2264
  api_url: apiUrl
2393
2265
  };
2394
- await fs10.writeFile(manifestPath, JSON.stringify(manifestContent, null, 2), "utf-8");
2266
+ await fs9.writeFile(manifestPath, JSON.stringify(manifestContent, null, 2), "utf-8");
2395
2267
  } catch (e) {
2396
2268
  }
2397
- console.log(chalk12.bold("\n\u{1F9E0} Agent Skills Provisioning..."));
2269
+ console.log(chalk11.bold("\n\u{1F9E0} Agent Skills Provisioning..."));
2398
2270
  try {
2399
2271
  const { provisionSkills: provisionSkills2, generateSkillsDiscoveryBlock: generateSkillsDiscoveryBlock2 } = await Promise.resolve().then(() => (init_skills_provisioner(), skills_provisioner_exports));
2400
2272
  const skills = await provisionSkills2(apiUrl, apiKey, projectId, process.cwd());
2401
- const cursorRulesPath = path11.join(process.cwd(), ".cursorrules");
2273
+ const cursorRulesPath = path10.join(process.cwd(), ".cursorrules");
2402
2274
  try {
2403
- let rulesContent = await fs10.readFile(cursorRulesPath, "utf-8");
2275
+ let rulesContent = await fs9.readFile(cursorRulesPath, "utf-8");
2404
2276
  const skillsBlock = generateSkillsDiscoveryBlock2(skills);
2405
2277
  if (rulesContent.includes("<available_skills>")) {
2406
2278
  rulesContent = rulesContent.replace(
@@ -2413,17 +2285,17 @@ function createSyncCommand() {
2413
2285
  rulesContent = rulesContent.slice(0, insertPoint + 3) + "\n\n" + skillsBlock + "\n" + rulesContent.slice(insertPoint + 3);
2414
2286
  }
2415
2287
  }
2416
- await fs10.writeFile(cursorRulesPath, rulesContent, "utf-8");
2417
- console.log(chalk12.dim(` Updated .cursorrules with skills discovery block`));
2288
+ await fs9.writeFile(cursorRulesPath, rulesContent, "utf-8");
2289
+ console.log(chalk11.dim(` Updated .cursorrules with skills discovery block`));
2418
2290
  } catch (e) {
2419
2291
  }
2420
2292
  } catch (e) {
2421
- console.log(chalk12.yellow(` \u26A0 Skills provisioning skipped: ${e.message}`));
2293
+ console.log(chalk11.yellow(` \u26A0 Skills provisioning skipped: ${e.message}`));
2422
2294
  }
2423
2295
  try {
2424
- const logPath = path11.join(process.cwd(), ".rigstate", "logs", "last_execution.json");
2296
+ const logPath = path10.join(process.cwd(), ".rigstate", "logs", "last_execution.json");
2425
2297
  try {
2426
- const logContent = await fs10.readFile(logPath, "utf-8");
2298
+ const logContent = await fs9.readFile(logPath, "utf-8");
2427
2299
  const logData = JSON.parse(logContent);
2428
2300
  if (logData.task_summary) {
2429
2301
  await axios8.post(`${apiUrl}/api/v1/execution-logs`, {
@@ -2433,8 +2305,8 @@ function createSyncCommand() {
2433
2305
  }, {
2434
2306
  headers: { Authorization: `Bearer ${apiKey}` }
2435
2307
  });
2436
- await fs10.unlink(logPath);
2437
- console.log(chalk12.dim(`\u2714 Mission Report uploaded.`));
2308
+ await fs9.unlink(logPath);
2309
+ console.log(chalk11.dim(`\u2714 Mission Report uploaded.`));
2438
2310
  }
2439
2311
  } catch (e) {
2440
2312
  if (e.code !== "ENOENT") {
@@ -2442,12 +2314,12 @@ function createSyncCommand() {
2442
2314
  }
2443
2315
  } catch (e) {
2444
2316
  }
2445
- spinner.succeed(chalk12.green(`Synced ${roadmap.length} roadmap steps for project "${project}"`));
2446
- console.log(chalk12.dim(`Local files updated: roadmap.json`));
2317
+ spinner.succeed(chalk11.green(`Synced ${roadmap.length} roadmap steps for project "${project}"`));
2318
+ console.log(chalk11.dim(`Local files updated: roadmap.json`));
2447
2319
  const { runGuardianWatchdog: runGuardianWatchdog2 } = await Promise.resolve().then(() => (init_watchdog(), watchdog_exports));
2448
2320
  const settings = response.data.data.settings || {};
2449
2321
  await runGuardianWatchdog2(process.cwd(), settings, projectId);
2450
- console.log(chalk12.bold("\n\u{1F4E1} Agent Bridge Heartbeat..."));
2322
+ console.log(chalk11.bold("\n\u{1F4E1} Agent Bridge Heartbeat..."));
2451
2323
  try {
2452
2324
  const bridgeResponse = await axios8.get(`${apiUrl}/api/v1/agent/bridge`, {
2453
2325
  params: { project_id: projectId },
@@ -2458,10 +2330,10 @@ function createSyncCommand() {
2458
2330
  const pending = tasks.filter((t) => t.status === "PENDING");
2459
2331
  const approved = tasks.filter((t) => t.status === "APPROVED");
2460
2332
  if (pending.length > 0 || approved.length > 0) {
2461
- console.log(chalk12.yellow(`\u26A0 Bridge Alert: ${pending.length} pending, ${approved.length} approved tasks found.`));
2462
- console.log(chalk12.dim('Run "rigstate fix" to process these tasks or ensure your IDE MCP server is active.'));
2333
+ console.log(chalk11.yellow(`\u26A0 Bridge Alert: ${pending.length} pending, ${approved.length} approved tasks found.`));
2334
+ console.log(chalk11.dim('Run "rigstate fix" to process these tasks or ensure your IDE MCP server is active.'));
2463
2335
  } else {
2464
- console.log(chalk12.green("\u2714 Heartbeat healthy. No pending bridge tasks."));
2336
+ console.log(chalk11.green("\u2714 Heartbeat healthy. No pending bridge tasks."));
2465
2337
  }
2466
2338
  const pings = pending.filter((t) => t.proposal?.startsWith("ping"));
2467
2339
  for (const ping of pings) {
@@ -2472,25 +2344,25 @@ function createSyncCommand() {
2472
2344
  }, {
2473
2345
  headers: { Authorization: `Bearer ${apiKey}` }
2474
2346
  });
2475
- console.log(chalk12.cyan(`\u{1F3D3} Pong! Acknowledged heartbeat signal [${ping.id}]`));
2347
+ console.log(chalk11.cyan(`\u{1F3D3} Pong! Acknowledged heartbeat signal [${ping.id}]`));
2476
2348
  }
2477
2349
  }
2478
2350
  } catch (e) {
2479
- console.log(chalk12.yellow(`\u26A0 Could not verify Bridge status: ${e.message}`));
2351
+ console.log(chalk11.yellow(`\u26A0 Could not verify Bridge status: ${e.message}`));
2480
2352
  }
2481
2353
  if (options.project) {
2482
- console.log(chalk12.blue(`Project context saved. Future commands will use this project.`));
2354
+ console.log(chalk11.blue(`Project context saved. Future commands will use this project.`));
2483
2355
  }
2484
2356
  try {
2485
- const migrationDir = path11.join(process.cwd(), "supabase", "migrations");
2486
- const files = await fs10.readdir(migrationDir);
2357
+ const migrationDir = path10.join(process.cwd(), "supabase", "migrations");
2358
+ const files = await fs9.readdir(migrationDir);
2487
2359
  const sqlFiles = files.filter((f) => f.endsWith(".sql")).sort();
2488
2360
  if (sqlFiles.length > 0) {
2489
2361
  const latestMigration = sqlFiles[sqlFiles.length - 1];
2490
- console.log(chalk12.dim(`
2362
+ console.log(chalk11.dim(`
2491
2363
  \u{1F6E1} Migration Guard:`));
2492
- console.log(chalk12.dim(` Latest Local: ${latestMigration}`));
2493
- console.log(chalk12.yellow(` \u26A0 Ensure DB schema matches this version. CLI cannot verify Remote RLS policies directly.`));
2364
+ console.log(chalk11.dim(` Latest Local: ${latestMigration}`));
2365
+ console.log(chalk11.yellow(` \u26A0 Ensure DB schema matches this version. CLI cannot verify Remote RLS policies directly.`));
2494
2366
  }
2495
2367
  } catch (e) {
2496
2368
  }
@@ -2502,15 +2374,15 @@ function createSyncCommand() {
2502
2374
  );
2503
2375
  if (vaultResponse.data.success) {
2504
2376
  const vaultContent = vaultResponse.data.data.content || "";
2505
- const localEnvPath = path11.join(process.cwd(), ".env.local");
2377
+ const localEnvPath = path10.join(process.cwd(), ".env.local");
2506
2378
  let localContent = "";
2507
2379
  try {
2508
- localContent = await fs10.readFile(localEnvPath, "utf-8");
2380
+ localContent = await fs9.readFile(localEnvPath, "utf-8");
2509
2381
  } catch (e) {
2510
2382
  }
2511
2383
  if (vaultContent.trim() !== localContent.trim()) {
2512
- console.log(chalk12.bold("\n\u{1F510} Sovereign Foundation (Vault):"));
2513
- console.log(chalk12.yellow(" Status: Drift Detected / Update Available"));
2384
+ console.log(chalk11.bold("\n\u{1F510} Sovereign Foundation (Vault):"));
2385
+ console.log(chalk11.yellow(" Status: Drift Detected / Update Available"));
2514
2386
  const { syncVault } = await import("inquirer").then((m) => m.default.prompt([{
2515
2387
  type: "confirm",
2516
2388
  name: "syncVault",
@@ -2518,25 +2390,25 @@ function createSyncCommand() {
2518
2390
  default: false
2519
2391
  }]));
2520
2392
  if (syncVault) {
2521
- await fs10.writeFile(localEnvPath, vaultContent, "utf-8");
2522
- console.log(chalk12.green(" \u2705 .env.local synchronized with Vault."));
2393
+ await fs9.writeFile(localEnvPath, vaultContent, "utf-8");
2394
+ console.log(chalk11.green(" \u2705 .env.local synchronized with Vault."));
2523
2395
  } else {
2524
- console.log(chalk12.dim(" Skipped vault sync."));
2396
+ console.log(chalk11.dim(" Skipped vault sync."));
2525
2397
  }
2526
2398
  } else {
2527
- console.log(chalk12.dim("\n\u{1F510} Sovereign Foundation: Synced."));
2399
+ console.log(chalk11.dim("\n\u{1F510} Sovereign Foundation: Synced."));
2528
2400
  }
2529
2401
  }
2530
2402
  } catch (e) {
2531
2403
  }
2532
- console.log(chalk12.dim("\n\u{1F6E1}\uFE0F System Integrity Check..."));
2404
+ console.log(chalk11.dim("\n\u{1F6E1}\uFE0F System Integrity Check..."));
2533
2405
  await checkSystemIntegrity(apiUrl, apiKey, projectId);
2534
2406
  } catch (error) {
2535
2407
  if (axios8.isAxiosError(error)) {
2536
2408
  const message = error.response?.data?.error || error.message;
2537
- spinner.fail(chalk12.red(`Sync failed: ${message}`));
2409
+ spinner.fail(chalk11.red(`Sync failed: ${message}`));
2538
2410
  } else {
2539
- spinner.fail(chalk12.red("Sync failed: " + (error.message || "Unknown error")));
2411
+ spinner.fail(chalk11.red("Sync failed: " + (error.message || "Unknown error")));
2540
2412
  }
2541
2413
  }
2542
2414
  });
@@ -2552,57 +2424,57 @@ async function checkSystemIntegrity(apiUrl, apiKey, projectId) {
2552
2424
  const { migrations, rls, guardian_violations } = response.data.data;
2553
2425
  if (migrations) {
2554
2426
  if (migrations.in_sync) {
2555
- console.log(chalk12.green(` \u2705 Migrations synced (${migrations.count} versions)`));
2427
+ console.log(chalk11.green(` \u2705 Migrations synced (${migrations.count} versions)`));
2556
2428
  } else {
2557
- console.log(chalk12.red(` \u{1F6D1} CRITICAL: DB Schema out of sync! ${migrations.missing?.length || 0} migrations not applied.`));
2429
+ console.log(chalk11.red(` \u{1F6D1} CRITICAL: DB Schema out of sync! ${migrations.missing?.length || 0} migrations not applied.`));
2558
2430
  if (migrations.missing?.length > 0) {
2559
- console.log(chalk12.dim(` Missing: ${migrations.missing.slice(0, 3).join(", ")}${migrations.missing.length > 3 ? "..." : ""}`));
2431
+ console.log(chalk11.dim(` Missing: ${migrations.missing.slice(0, 3).join(", ")}${migrations.missing.length > 3 ? "..." : ""}`));
2560
2432
  }
2561
- console.log(chalk12.yellow(` Run 'supabase db push' or apply migrations immediately.`));
2433
+ console.log(chalk11.yellow(` Run 'supabase db push' or apply migrations immediately.`));
2562
2434
  }
2563
2435
  }
2564
2436
  if (rls) {
2565
2437
  if (rls.all_secured) {
2566
- console.log(chalk12.green(` \u2705 RLS Audit Passed (${rls.table_count} tables secured)`));
2438
+ console.log(chalk11.green(` \u2705 RLS Audit Passed (${rls.table_count} tables secured)`));
2567
2439
  } else {
2568
- console.log(chalk12.red(` \u{1F6D1} CRITICAL: Security Vulnerability! ${rls.unsecured?.length || 0} tables have RLS disabled.`));
2440
+ console.log(chalk11.red(` \u{1F6D1} CRITICAL: Security Vulnerability! ${rls.unsecured?.length || 0} tables have RLS disabled.`));
2569
2441
  rls.unsecured?.forEach((table) => {
2570
- console.log(chalk12.red(` - ${table}`));
2442
+ console.log(chalk11.red(` - ${table}`));
2571
2443
  });
2572
- console.log(chalk12.yellow(' Enable RLS immediately: ALTER TABLE "table" ENABLE ROW LEVEL SECURITY;'));
2444
+ console.log(chalk11.yellow(' Enable RLS immediately: ALTER TABLE "table" ENABLE ROW LEVEL SECURITY;'));
2573
2445
  }
2574
2446
  }
2575
2447
  if (guardian_violations) {
2576
2448
  if (guardian_violations.count === 0) {
2577
- console.log(chalk12.green(" \u2705 Guardian: No active violations"));
2449
+ console.log(chalk11.green(" \u2705 Guardian: No active violations"));
2578
2450
  } else {
2579
- console.log(chalk12.yellow(` \u26A0\uFE0F Guardian: ${guardian_violations.count} active violations`));
2580
- console.log(chalk12.dim(' Run "rigstate check" for details.'));
2451
+ console.log(chalk11.yellow(` \u26A0\uFE0F Guardian: ${guardian_violations.count} active violations`));
2452
+ console.log(chalk11.dim(' Run "rigstate check" for details.'));
2581
2453
  }
2582
2454
  }
2583
2455
  }
2584
2456
  } catch (e) {
2585
- console.log(chalk12.dim(" (System integrity check skipped - API endpoint not available)"));
2457
+ console.log(chalk11.dim(" (System integrity check skipped - API endpoint not available)"));
2586
2458
  }
2587
2459
  }
2588
2460
 
2589
2461
  // src/commands/init.ts
2590
2462
  init_esm_shims();
2591
- import { Command as Command9 } from "commander";
2592
- import chalk13 from "chalk";
2593
- import fs12 from "fs/promises";
2594
- import path13 from "path";
2463
+ import { Command as Command8 } from "commander";
2464
+ import chalk12 from "chalk";
2465
+ import fs11 from "fs/promises";
2466
+ import path12 from "path";
2595
2467
  import ora6 from "ora";
2596
2468
  import { execSync } from "child_process";
2597
2469
 
2598
2470
  // src/utils/manifest.ts
2599
2471
  init_esm_shims();
2600
- import fs11 from "fs/promises";
2601
- import path12 from "path";
2472
+ import fs10 from "fs/promises";
2473
+ import path11 from "path";
2602
2474
  async function loadManifest() {
2603
2475
  try {
2604
- const manifestPath = path12.join(process.cwd(), ".rigstate");
2605
- const content = await fs11.readFile(manifestPath, "utf-8");
2476
+ const manifestPath = path11.join(process.cwd(), ".rigstate");
2477
+ const content = await fs10.readFile(manifestPath, "utf-8");
2606
2478
  return JSON.parse(content);
2607
2479
  } catch {
2608
2480
  return null;
@@ -2613,13 +2485,13 @@ async function loadManifest() {
2613
2485
  init_config();
2614
2486
  import axios9 from "axios";
2615
2487
  function createInitCommand() {
2616
- return new Command9("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) => {
2488
+ return new Command8("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) => {
2617
2489
  const spinner = ora6("Initializing Rigstate project...").start();
2618
2490
  let apiKey;
2619
2491
  try {
2620
2492
  apiKey = getApiKey();
2621
2493
  } catch (e) {
2622
- spinner.fail(chalk13.red('Not authenticated. Run "rigstate login" first.'));
2494
+ spinner.fail(chalk12.red('Not authenticated. Run "rigstate login" first.'));
2623
2495
  return;
2624
2496
  }
2625
2497
  const apiUrl = getApiUrl();
@@ -2716,7 +2588,7 @@ function createInitCommand() {
2716
2588
  selectedOrgId = orgId;
2717
2589
  }
2718
2590
  if (!selectedOrgId) {
2719
- console.log(chalk13.yellow("No organization available. Please create the project via the Rigstate dashboard."));
2591
+ console.log(chalk12.yellow("No organization available. Please create the project via the Rigstate dashboard."));
2720
2592
  return;
2721
2593
  }
2722
2594
  spinner.start("Creating new project...");
@@ -2728,13 +2600,13 @@ function createInitCommand() {
2728
2600
  headers: { Authorization: `Bearer ${apiKey}` }
2729
2601
  });
2730
2602
  if (!createResponse.data.success) {
2731
- spinner.fail(chalk13.red("Failed to create project: " + createResponse.data.error));
2603
+ spinner.fail(chalk12.red("Failed to create project: " + createResponse.data.error));
2732
2604
  return;
2733
2605
  }
2734
2606
  projectId = createResponse.data.data.project.id;
2735
- spinner.succeed(chalk13.green(`Created new project: ${newName}`));
2607
+ spinner.succeed(chalk12.green(`Created new project: ${newName}`));
2736
2608
  } catch (e) {
2737
- spinner.fail(chalk13.red("Project creation API not available. Please create via dashboard."));
2609
+ spinner.fail(chalk12.red("Project creation API not available. Please create via dashboard."));
2738
2610
  return;
2739
2611
  }
2740
2612
  } else {
@@ -2744,28 +2616,28 @@ function createInitCommand() {
2744
2616
  spinner.start(`Linking to project ID: ${projectId}...`);
2745
2617
  }
2746
2618
  setProjectId(projectId);
2747
- const manifestPath = path13.join(process.cwd(), ".rigstate");
2619
+ const manifestPath = path12.join(process.cwd(), ".rigstate");
2748
2620
  const manifestContent = {
2749
2621
  project_id: projectId,
2750
2622
  last_linked: (/* @__PURE__ */ new Date()).toISOString(),
2751
2623
  api_url: apiUrl
2752
2624
  };
2753
- await fs12.writeFile(manifestPath, JSON.stringify(manifestContent, null, 2), "utf-8");
2625
+ await fs11.writeFile(manifestPath, JSON.stringify(manifestContent, null, 2), "utf-8");
2754
2626
  try {
2755
- await fs12.access(".git");
2627
+ await fs11.access(".git");
2756
2628
  } catch {
2757
2629
  spinner.text = "Initializing git repository...";
2758
2630
  execSync("git init", { stdio: "ignore" });
2759
2631
  }
2760
- spinner.succeed(chalk13.green(`\u2705 Linked to project: ${projectId}`));
2632
+ spinner.succeed(chalk12.green(`\u2705 Linked to project: ${projectId}`));
2761
2633
  await generateRules(apiUrl, apiKey, projectId, options.force, spinner);
2762
2634
  console.log("");
2763
- console.log(chalk13.blue("Next steps:"));
2764
- console.log(chalk13.dim(" rigstate sync - Sync roadmap and context"));
2765
- console.log(chalk13.dim(" rigstate watch - Start development loop"));
2766
- console.log(chalk13.dim(" rigstate focus - Get current task"));
2635
+ console.log(chalk12.blue("Next steps:"));
2636
+ console.log(chalk12.dim(" rigstate sync - Sync roadmap and context"));
2637
+ console.log(chalk12.dim(" rigstate watch - Start development loop"));
2638
+ console.log(chalk12.dim(" rigstate focus - Get current task"));
2767
2639
  } catch (e) {
2768
- spinner.fail(chalk13.red("Initialization failed: " + e.message));
2640
+ spinner.fail(chalk12.red("Initialization failed: " + e.message));
2769
2641
  }
2770
2642
  });
2771
2643
  }
@@ -2780,67 +2652,67 @@ async function generateRules(apiUrl, apiKey, projectId, force, spinner) {
2780
2652
  if (response.data.success || response.data.files) {
2781
2653
  const files = response.data.files || [];
2782
2654
  if (files.length === 0 && response.data.rules) {
2783
- const rulesPath = path13.join(process.cwd(), ".cursorrules");
2784
- await fs12.writeFile(rulesPath, response.data.rules, "utf-8");
2785
- spinner.succeed(chalk13.green("\u2714 Generated .cursorrules (legacy mode)"));
2655
+ const rulesPath = path12.join(process.cwd(), ".cursorrules");
2656
+ await fs11.writeFile(rulesPath, response.data.rules, "utf-8");
2657
+ spinner.succeed(chalk12.green("\u2714 Generated .cursorrules (legacy mode)"));
2786
2658
  return;
2787
2659
  }
2788
2660
  for (const file of files) {
2789
- const targetPath = path13.join(process.cwd(), file.path);
2790
- const targetDir = path13.dirname(targetPath);
2791
- await fs12.mkdir(targetDir, { recursive: true });
2661
+ const targetPath = path12.join(process.cwd(), file.path);
2662
+ const targetDir = path12.dirname(targetPath);
2663
+ await fs11.mkdir(targetDir, { recursive: true });
2792
2664
  try {
2793
- await fs12.access(targetPath);
2665
+ await fs11.access(targetPath);
2794
2666
  if (!force && !file.path.startsWith(".cursor/rules/")) {
2795
- console.log(chalk13.dim(` ${file.path} already exists. Skipping.`));
2667
+ console.log(chalk12.dim(` ${file.path} already exists. Skipping.`));
2796
2668
  continue;
2797
2669
  }
2798
2670
  } catch {
2799
2671
  }
2800
- await fs12.writeFile(targetPath, file.content, "utf-8");
2672
+ await fs11.writeFile(targetPath, file.content, "utf-8");
2801
2673
  }
2802
2674
  if (files.length > 0) {
2803
- const legacyPath = path13.join(process.cwd(), ".cursorrules");
2675
+ const legacyPath = path12.join(process.cwd(), ".cursorrules");
2804
2676
  try {
2805
- const stats = await fs12.stat(legacyPath);
2677
+ const stats = await fs11.stat(legacyPath);
2806
2678
  if (stats.isFile()) {
2807
- await fs12.rename(legacyPath, `${legacyPath}.bak`);
2808
- console.log(chalk13.dim(" Moved legacy .cursorrules to .cursorrules.bak"));
2679
+ await fs11.rename(legacyPath, `${legacyPath}.bak`);
2680
+ console.log(chalk12.dim(" Moved legacy .cursorrules to .cursorrules.bak"));
2809
2681
  }
2810
2682
  } catch (e) {
2811
2683
  }
2812
2684
  }
2813
- spinner.succeed(chalk13.green(`\u2714 Generated ${files.length} rule files (v${response.data.version || "3.0"})`));
2685
+ spinner.succeed(chalk12.green(`\u2714 Generated ${files.length} rule files (v${response.data.version || "3.0"})`));
2814
2686
  } else {
2815
- spinner.info(chalk13.dim(" Rules generation skipped (API response invalid)"));
2687
+ spinner.info(chalk12.dim(" Rules generation skipped (API response invalid)"));
2816
2688
  }
2817
2689
  } catch (e) {
2818
- spinner.info(chalk13.dim(` Rules generation failed: ${e.message}`));
2690
+ spinner.info(chalk12.dim(` Rules generation failed: ${e.message}`));
2819
2691
  }
2820
2692
  }
2821
2693
 
2822
2694
  // src/commands/check.ts
2823
2695
  init_esm_shims();
2824
2696
  init_config();
2825
- import { Command as Command10 } from "commander";
2826
- import chalk15 from "chalk";
2697
+ import { Command as Command9 } from "commander";
2698
+ import chalk14 from "chalk";
2827
2699
  import ora7 from "ora";
2828
2700
  import axios10 from "axios";
2829
2701
  import { glob as glob3 } from "glob";
2830
- import fs14 from "fs/promises";
2831
- import path15 from "path";
2702
+ import fs13 from "fs/promises";
2703
+ import path14 from "path";
2832
2704
  import { execSync as execSync2 } from "child_process";
2833
2705
 
2834
2706
  // src/utils/rule-engine.ts
2835
2707
  init_esm_shims();
2836
- import fs13 from "fs/promises";
2837
- import path14 from "path";
2838
- import chalk14 from "chalk";
2708
+ import fs12 from "fs/promises";
2709
+ import path13 from "path";
2710
+ import chalk13 from "chalk";
2839
2711
  async function checkFile(filePath, rules, rootPath) {
2840
2712
  const violations = [];
2841
- const relativePath = path14.relative(rootPath, filePath);
2713
+ const relativePath = path13.relative(rootPath, filePath);
2842
2714
  try {
2843
- const content = await fs13.readFile(filePath, "utf-8");
2715
+ const content = await fs12.readFile(filePath, "utf-8");
2844
2716
  const lines = content.split("\n");
2845
2717
  for (const rule of rules) {
2846
2718
  const ruleViolations = await evaluateRule(rule, content, lines, relativePath);
@@ -2931,7 +2803,7 @@ async function evaluateRule(rule, content, lines, filePath) {
2931
2803
  case "NAMING_CONVENTION": {
2932
2804
  const value = rule.value;
2933
2805
  const pattern = new RegExp(value.pattern);
2934
- const fileName = path14.basename(filePath);
2806
+ const fileName = path13.basename(filePath);
2935
2807
  if (filePath.includes(value.context) && !pattern.test(fileName)) {
2936
2808
  violations.push({
2937
2809
  file: filePath,
@@ -2990,12 +2862,12 @@ function checkFunctionLines(content, lines, filePath, rule, limit) {
2990
2862
  }
2991
2863
  function formatViolations(violations) {
2992
2864
  for (const v of violations) {
2993
- const severityColor = v.severity === "critical" ? chalk14.red : v.severity === "warning" ? chalk14.yellow : chalk14.blue;
2994
- const lineInfo = v.line ? chalk14.dim(`:${v.line}`) : "";
2865
+ const severityColor = v.severity === "critical" ? chalk13.red : v.severity === "warning" ? chalk13.yellow : chalk13.blue;
2866
+ const lineInfo = v.line ? chalk13.dim(`:${v.line}`) : "";
2995
2867
  console.log(` ${severityColor(`[${v.severity.toUpperCase()}]`)} ${v.file}${lineInfo}`);
2996
2868
  console.log(` ${v.message}`);
2997
2869
  if (v.details) {
2998
- console.log(` ${chalk14.dim(v.details)}`);
2870
+ console.log(` ${chalk13.dim(v.details)}`);
2999
2871
  }
3000
2872
  }
3001
2873
  }
@@ -3024,7 +2896,7 @@ var CACHE_FILE2 = ".rigstate/rules-cache.json";
3024
2896
  var CACHE_TTL_MS = 5 * 60 * 1e3;
3025
2897
  var CACHE_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
3026
2898
  function createCheckCommand() {
3027
- return new Command10("check").description("Validate code against Guardian architectural rules").argument("[path]", "Directory or file to check", ".").option("--project <id>", "Project ID (or use .rigstate manifest)").option("--strict [level]", 'Exit 1 on violations. Level: "all" (default) or "critical"').option("--staged", "Only check git staged files (for pre-commit hooks)").option("--json", "Output results as JSON").option("--no-cache", "Skip rule cache and fetch fresh from API").action(async (targetPath, options) => {
2899
+ return new Command9("check").description("Validate code against Guardian architectural rules").argument("[path]", "Directory or file to check", ".").option("--project <id>", "Project ID (or use .rigstate manifest)").option("--strict [level]", 'Exit 1 on violations. Level: "all" (default) or "critical"').option("--staged", "Only check git staged files (for pre-commit hooks)").option("--json", "Output results as JSON").option("--no-cache", "Skip rule cache and fetch fresh from API").action(async (targetPath, options) => {
3028
2900
  const spinner = ora7();
3029
2901
  try {
3030
2902
  let projectId = options.project;
@@ -3040,15 +2912,15 @@ function createCheckCommand() {
3040
2912
  projectId = getProjectId();
3041
2913
  }
3042
2914
  if (!projectId) {
3043
- console.log(chalk15.red("\u274C No project context found."));
3044
- console.log(chalk15.dim(' Run "rigstate link" or pass --project <id>'));
2915
+ console.log(chalk14.red("\u274C No project context found."));
2916
+ console.log(chalk14.dim(' Run "rigstate link" or pass --project <id>'));
3045
2917
  process.exit(2);
3046
2918
  }
3047
2919
  let apiKey;
3048
2920
  try {
3049
2921
  apiKey = getApiKey();
3050
2922
  } catch {
3051
- console.log(chalk15.red('\u274C Not authenticated. Run "rigstate login" first.'));
2923
+ console.log(chalk14.red('\u274C Not authenticated. Run "rigstate login" first.'));
3052
2924
  process.exit(2);
3053
2925
  }
3054
2926
  spinner.start("Fetching Guardian rules...");
@@ -3076,17 +2948,17 @@ function createCheckCommand() {
3076
2948
  } catch (apiError) {
3077
2949
  const cached = await loadCachedRules(projectId);
3078
2950
  if (cached && !isStale(cached.timestamp, CACHE_MAX_AGE_MS)) {
3079
- spinner.warn(chalk15.yellow("Using cached rules (API unavailable)"));
2951
+ spinner.warn(chalk14.yellow("Using cached rules (API unavailable)"));
3080
2952
  rules = cached.rules;
3081
2953
  settings = cached.settings;
3082
2954
  } else {
3083
- spinner.fail(chalk15.red("Failed to fetch rules and no valid cache"));
3084
- console.log(chalk15.dim(` Error: ${apiError.message}`));
2955
+ spinner.fail(chalk14.red("Failed to fetch rules and no valid cache"));
2956
+ console.log(chalk14.dim(` Error: ${apiError.message}`));
3085
2957
  process.exit(2);
3086
2958
  }
3087
2959
  }
3088
2960
  spinner.succeed(`Loaded ${rules.length} Guardian rules`);
3089
- const scanPath = path15.resolve(process.cwd(), targetPath);
2961
+ const scanPath = path14.resolve(process.cwd(), targetPath);
3090
2962
  let filesToCheck;
3091
2963
  if (options.staged) {
3092
2964
  spinner.start("Getting staged files...");
@@ -3095,14 +2967,14 @@ function createCheckCommand() {
3095
2967
  encoding: "utf-8",
3096
2968
  cwd: process.cwd()
3097
2969
  });
3098
- filesToCheck = stagedOutput.split("\n").filter((f) => f.trim()).filter((f) => isCodeFile2(f)).map((f) => path15.resolve(process.cwd(), f));
2970
+ filesToCheck = stagedOutput.split("\n").filter((f) => f.trim()).filter((f) => isCodeFile2(f)).map((f) => path14.resolve(process.cwd(), f));
3099
2971
  } catch {
3100
2972
  spinner.fail("Not a git repository or no staged files");
3101
2973
  process.exit(2);
3102
2974
  }
3103
2975
  } else {
3104
- spinner.start(`Scanning ${chalk15.cyan(targetPath)}...`);
3105
- const pattern = path15.join(scanPath, "**/*");
2976
+ spinner.start(`Scanning ${chalk14.cyan(targetPath)}...`);
2977
+ const pattern = path14.join(scanPath, "**/*");
3106
2978
  const allFiles = await glob3(pattern, {
3107
2979
  nodir: true,
3108
2980
  dot: false,
@@ -3118,7 +2990,7 @@ function createCheckCommand() {
3118
2990
  filesToCheck = allFiles.filter((f) => isCodeFile2(f));
3119
2991
  }
3120
2992
  if (filesToCheck.length === 0) {
3121
- spinner.warn(chalk15.yellow("No code files found to check."));
2993
+ spinner.warn(chalk14.yellow("No code files found to check."));
3122
2994
  outputResults([], !!options.json);
3123
2995
  process.exit(0);
3124
2996
  }
@@ -3127,7 +2999,7 @@ function createCheckCommand() {
3127
2999
  const results = [];
3128
3000
  for (let i = 0; i < filesToCheck.length; i++) {
3129
3001
  const file = filesToCheck[i];
3130
- spinner.text = `Checking ${i + 1}/${filesToCheck.length}: ${path15.basename(file)}`;
3002
+ spinner.text = `Checking ${i + 1}/${filesToCheck.length}: ${path14.basename(file)}`;
3131
3003
  const result = await checkFile(file, rules, process.cwd());
3132
3004
  results.push(result);
3133
3005
  }
@@ -3137,47 +3009,47 @@ function createCheckCommand() {
3137
3009
  outputResults(results, true);
3138
3010
  } else {
3139
3011
  outputResults(results, false);
3140
- console.log("\n" + chalk15.bold("\u{1F4CA} Summary"));
3141
- console.log(chalk15.dim("\u2500".repeat(50)));
3142
- console.log(`Files checked: ${chalk15.cyan(summary.totalFiles)}`);
3143
- console.log(`Total violations: ${summary.totalViolations > 0 ? chalk15.red(summary.totalViolations) : chalk15.green(0)}`);
3012
+ console.log("\n" + chalk14.bold("\u{1F4CA} Summary"));
3013
+ console.log(chalk14.dim("\u2500".repeat(50)));
3014
+ console.log(`Files checked: ${chalk14.cyan(summary.totalFiles)}`);
3015
+ console.log(`Total violations: ${summary.totalViolations > 0 ? chalk14.red(summary.totalViolations) : chalk14.green(0)}`);
3144
3016
  if (summary.totalViolations > 0) {
3145
- console.log(` ${chalk15.red("Critical:")} ${summary.criticalCount}`);
3146
- console.log(` ${chalk15.yellow("Warning:")} ${summary.warningCount}`);
3147
- console.log(` ${chalk15.blue("Info:")} ${summary.infoCount}`);
3017
+ console.log(` ${chalk14.red("Critical:")} ${summary.criticalCount}`);
3018
+ console.log(` ${chalk14.yellow("Warning:")} ${summary.warningCount}`);
3019
+ console.log(` ${chalk14.blue("Info:")} ${summary.infoCount}`);
3148
3020
  }
3149
- console.log(chalk15.dim("\u2500".repeat(50)));
3021
+ console.log(chalk14.dim("\u2500".repeat(50)));
3150
3022
  }
3151
3023
  if (options.strict !== void 0) {
3152
3024
  const strictLevel = typeof options.strict === "string" ? options.strict : "all";
3153
3025
  if (strictLevel === "critical" && summary.criticalCount > 0) {
3154
- console.log(chalk15.red("\n\u274C Check failed: Critical violations found"));
3026
+ console.log(chalk14.red("\n\u274C Check failed: Critical violations found"));
3155
3027
  process.exit(1);
3156
3028
  } else if (strictLevel === "all" && summary.totalViolations > 0) {
3157
- console.log(chalk15.red("\n\u274C Check failed: Violations found"));
3029
+ console.log(chalk14.red("\n\u274C Check failed: Violations found"));
3158
3030
  process.exit(1);
3159
3031
  }
3160
3032
  }
3161
3033
  if (summary.totalViolations === 0) {
3162
- console.log(chalk15.green("\n\u2705 All checks passed!"));
3034
+ console.log(chalk14.green("\n\u2705 All checks passed!"));
3163
3035
  }
3164
3036
  process.exit(0);
3165
3037
  } catch (error) {
3166
- spinner.fail(chalk15.red("Check failed"));
3167
- console.error(chalk15.red("Error:"), error.message);
3038
+ spinner.fail(chalk14.red("Check failed"));
3039
+ console.error(chalk14.red("Error:"), error.message);
3168
3040
  process.exit(2);
3169
3041
  }
3170
3042
  });
3171
3043
  }
3172
3044
  function isCodeFile2(filePath) {
3173
3045
  const codeExtensions = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
3174
- const ext = path15.extname(filePath).toLowerCase();
3046
+ const ext = path14.extname(filePath).toLowerCase();
3175
3047
  return codeExtensions.includes(ext);
3176
3048
  }
3177
3049
  async function loadCachedRules(projectId) {
3178
3050
  try {
3179
- const cachePath = path15.join(process.cwd(), CACHE_FILE2);
3180
- const content = await fs14.readFile(cachePath, "utf-8");
3051
+ const cachePath = path14.join(process.cwd(), CACHE_FILE2);
3052
+ const content = await fs13.readFile(cachePath, "utf-8");
3181
3053
  const cached = JSON.parse(content);
3182
3054
  if (cached.projectId !== projectId) {
3183
3055
  return null;
@@ -3189,16 +3061,16 @@ async function loadCachedRules(projectId) {
3189
3061
  }
3190
3062
  async function saveCachedRules(projectId, rules, settings) {
3191
3063
  try {
3192
- const cacheDir = path15.join(process.cwd(), ".rigstate");
3193
- await fs14.mkdir(cacheDir, { recursive: true });
3064
+ const cacheDir = path14.join(process.cwd(), ".rigstate");
3065
+ await fs13.mkdir(cacheDir, { recursive: true });
3194
3066
  const cached = {
3195
3067
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
3196
3068
  projectId,
3197
3069
  rules,
3198
3070
  settings
3199
3071
  };
3200
- await fs14.writeFile(
3201
- path15.join(cacheDir, "rules-cache.json"),
3072
+ await fs13.writeFile(
3073
+ path14.join(cacheDir, "rules-cache.json"),
3202
3074
  JSON.stringify(cached, null, 2)
3203
3075
  );
3204
3076
  } catch {
@@ -3220,8 +3092,8 @@ function outputResults(results, json) {
3220
3092
  if (!hasViolations) {
3221
3093
  return;
3222
3094
  }
3223
- console.log("\n" + chalk15.bold("\u{1F50D} Violations Found"));
3224
- console.log(chalk15.dim("\u2500".repeat(50)));
3095
+ console.log("\n" + chalk14.bold("\u{1F50D} Violations Found"));
3096
+ console.log(chalk14.dim("\u2500".repeat(50)));
3225
3097
  for (const result of results) {
3226
3098
  if (result.violations.length > 0) {
3227
3099
  formatViolations(result.violations);
@@ -3229,8 +3101,125 @@ function outputResults(results, json) {
3229
3101
  }
3230
3102
  }
3231
3103
 
3232
- // src/index.ts
3233
- init_hooks();
3104
+ // src/commands/hooks.ts
3105
+ init_esm_shims();
3106
+ import { Command as Command10 } from "commander";
3107
+ import chalk15 from "chalk";
3108
+ import fs14 from "fs/promises";
3109
+ import path15 from "path";
3110
+ var PRE_COMMIT_SCRIPT = `#!/bin/sh
3111
+ # Rigstate Guardian Pre-commit Hook
3112
+ # Installed by: rigstate hooks install
3113
+
3114
+ # 1. Silent Sentinel Check (Phase 5)
3115
+ if [ -f .rigstate/guardian.lock ]; then
3116
+ echo "\u{1F6D1} INTERVENTION ACTIVE: Commit blocked by Silent Sentinel."
3117
+ echo " A critical violation ('HARD_LOCK') was detected by the Guardian Daemon."
3118
+ echo " Please fix the violation to unlock the repo."
3119
+ echo ""
3120
+ if grep -q "HARD_LOCK_ACTIVE" .rigstate/guardian.lock; then
3121
+ cat .rigstate/guardian.lock
3122
+ fi
3123
+ exit 1
3124
+ fi
3125
+
3126
+ echo "\u{1F6E1}\uFE0F Running Guardian checks..."
3127
+
3128
+ # Run check with strict mode for critical violations
3129
+ rigstate check --staged --strict=critical
3130
+
3131
+ # Exit with the same code as rigstate check
3132
+ exit $?
3133
+ `;
3134
+ function createHooksCommand() {
3135
+ const hooks = new Command10("hooks").description("Manage git hooks for Guardian integration");
3136
+ hooks.command("install").description("Install pre-commit hook to run Guardian checks").option("--strict [level]", 'Strict level: "all" or "critical" (default)', "critical").action(async (options) => {
3137
+ try {
3138
+ const gitDir = path15.join(process.cwd(), ".git");
3139
+ try {
3140
+ await fs14.access(gitDir);
3141
+ } catch {
3142
+ console.log(chalk15.red("\u274C Not a git repository."));
3143
+ console.log(chalk15.dim(' Initialize with "git init" first.'));
3144
+ process.exit(1);
3145
+ }
3146
+ const hooksDir = path15.join(gitDir, "hooks");
3147
+ await fs14.mkdir(hooksDir, { recursive: true });
3148
+ const preCommitPath = path15.join(hooksDir, "pre-commit");
3149
+ let existingContent = "";
3150
+ try {
3151
+ existingContent = await fs14.readFile(preCommitPath, "utf-8");
3152
+ if (existingContent.includes("rigstate")) {
3153
+ console.log(chalk15.yellow("\u26A0 Rigstate pre-commit hook already installed."));
3154
+ console.log(chalk15.dim(' Use "rigstate hooks uninstall" to remove first.'));
3155
+ return;
3156
+ }
3157
+ } catch {
3158
+ }
3159
+ let script = PRE_COMMIT_SCRIPT;
3160
+ if (options.strict === "all") {
3161
+ script = script.replace("--strict=critical", "--strict");
3162
+ }
3163
+ if (existingContent && !existingContent.includes("rigstate")) {
3164
+ const combinedScript = existingContent + "\n\n" + script.replace("#!/bin/sh\n", "");
3165
+ await fs14.writeFile(preCommitPath, combinedScript, { mode: 493 });
3166
+ console.log(chalk15.green("\u2705 Rigstate hook appended to existing pre-commit."));
3167
+ } else {
3168
+ await fs14.writeFile(preCommitPath, script, { mode: 493 });
3169
+ console.log(chalk15.green("\u2705 Pre-commit hook installed!"));
3170
+ }
3171
+ console.log(chalk15.dim(` Path: ${preCommitPath}`));
3172
+ console.log(chalk15.dim(` Strict level: ${options.strict}`));
3173
+ console.log("");
3174
+ console.log(chalk15.cyan("Guardian will now check your code before each commit."));
3175
+ console.log(chalk15.dim('Use "rigstate hooks uninstall" to remove the hook.'));
3176
+ } catch (error) {
3177
+ console.error(chalk15.red("Failed to install hook:"), error.message);
3178
+ process.exit(1);
3179
+ }
3180
+ });
3181
+ hooks.command("uninstall").description("Remove Rigstate pre-commit hook").action(async () => {
3182
+ try {
3183
+ const preCommitPath = path15.join(process.cwd(), ".git", "hooks", "pre-commit");
3184
+ try {
3185
+ const content = await fs14.readFile(preCommitPath, "utf-8");
3186
+ if (!content.includes("rigstate")) {
3187
+ console.log(chalk15.yellow("\u26A0 No Rigstate hook found in pre-commit."));
3188
+ return;
3189
+ }
3190
+ if (content.includes("# Rigstate Guardian Pre-commit Hook") && content.trim().split("\n").filter((l) => l && !l.startsWith("#")).length <= 4) {
3191
+ await fs14.unlink(preCommitPath);
3192
+ console.log(chalk15.green("\u2705 Pre-commit hook removed."));
3193
+ } else {
3194
+ const lines = content.split("\n");
3195
+ const filteredLines = [];
3196
+ let inRigstateSection = false;
3197
+ for (const line of lines) {
3198
+ if (line.includes("Rigstate Guardian Pre-commit Hook")) {
3199
+ inRigstateSection = true;
3200
+ continue;
3201
+ }
3202
+ if (inRigstateSection && line.includes("exit $?")) {
3203
+ inRigstateSection = false;
3204
+ continue;
3205
+ }
3206
+ if (!inRigstateSection && !line.includes("rigstate check")) {
3207
+ filteredLines.push(line);
3208
+ }
3209
+ }
3210
+ await fs14.writeFile(preCommitPath, filteredLines.join("\n"), { mode: 493 });
3211
+ console.log(chalk15.green("\u2705 Rigstate section removed from pre-commit hook."));
3212
+ }
3213
+ } catch {
3214
+ console.log(chalk15.yellow("\u26A0 No pre-commit hook found."));
3215
+ }
3216
+ } catch (error) {
3217
+ console.error(chalk15.red("Failed to uninstall hook:"), error.message);
3218
+ process.exit(1);
3219
+ }
3220
+ });
3221
+ return hooks;
3222
+ }
3234
3223
 
3235
3224
  // src/commands/daemon.ts
3236
3225
  init_esm_shims();
@@ -4796,6 +4785,7 @@ function createConfigCommand() {
4796
4785
 
4797
4786
  // src/commands/mcp.ts
4798
4787
  init_esm_shims();
4788
+ init_config();
4799
4789
  import { Command as Command16 } from "commander";
4800
4790
  import chalk25 from "chalk";
4801
4791
  import { spawn } from "child_process";
@@ -4832,11 +4822,21 @@ function createMcpCommand() {
4832
4822
  process.exit(1);
4833
4823
  }
4834
4824
  console.log(chalk25.dim(`Starting MCP server from: ${serverPath}`));
4835
- if (process.env.VIBE_API_KEY && !process.env.RIGSTATE_API_KEY) {
4836
- process.env.RIGSTATE_API_KEY = process.env.VIBE_API_KEY;
4825
+ const env = { ...process.env };
4826
+ try {
4827
+ const apiKey = getApiKey();
4828
+ if (apiKey) {
4829
+ env.RIGSTATE_API_KEY = apiKey;
4830
+ env.RIGSTATE_APP_URL = getApiUrl();
4831
+ env.RIGSTATE_API_URL = getApiUrl();
4832
+ }
4833
+ } catch (e) {
4834
+ }
4835
+ if (env.VIBE_API_KEY && !env.RIGSTATE_API_KEY) {
4836
+ env.RIGSTATE_API_KEY = env.VIBE_API_KEY;
4837
4837
  }
4838
4838
  const worker = spawn("node", [serverPath], {
4839
- env: process.env,
4839
+ env,
4840
4840
  stdio: ["inherit", "inherit", "inherit"]
4841
4841
  });
4842
4842
  worker.on("error", (err) => {