@rigstate/cli 0.7.24 → 0.7.26

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
@@ -286,12 +286,12 @@ async function syncProjectRules(projectId, apiKey, apiUrl, dryRun = false) {
286
286
  }
287
287
  const files = syncResponse.data.data.files;
288
288
  if (files && Array.isArray(files)) {
289
- const fs23 = await import("fs/promises");
290
- const path26 = await import("path");
289
+ const fs24 = await import("fs/promises");
290
+ const path27 = await import("path");
291
291
  for (const file of files) {
292
- const filePath = path26.join(process.cwd(), file.path);
293
- await fs23.mkdir(path26.dirname(filePath), { recursive: true });
294
- await fs23.writeFile(filePath, file.content, "utf-8");
292
+ const filePath = path27.join(process.cwd(), file.path);
293
+ await fs24.mkdir(path27.dirname(filePath), { recursive: true });
294
+ await fs24.writeFile(filePath, file.content, "utf-8");
295
295
  }
296
296
  console.log(chalk3.dim(` \u{1F4BE} Wrote ${files.length} rule files to local .cursor/rules/`));
297
297
  }
@@ -335,12 +335,142 @@ var init_sync_rules = __esm({
335
335
  }
336
336
  });
337
337
 
338
+ // src/commands/hooks.ts
339
+ var hooks_exports = {};
340
+ __export(hooks_exports, {
341
+ createHooksCommand: () => createHooksCommand
342
+ });
343
+ import { Command as Command4 } from "commander";
344
+ import chalk4 from "chalk";
345
+ import fs2 from "fs/promises";
346
+ import path3 from "path";
347
+ function createHooksCommand() {
348
+ const hooks = new Command4("hooks").description("Manage git hooks for Guardian integration");
349
+ 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) => {
350
+ try {
351
+ const gitDir = path3.join(process.cwd(), ".git");
352
+ try {
353
+ await fs2.access(gitDir);
354
+ } catch {
355
+ console.log(chalk4.red("\u274C Not a git repository."));
356
+ console.log(chalk4.dim(' Initialize with "git init" first.'));
357
+ process.exit(1);
358
+ }
359
+ const hooksDir = path3.join(gitDir, "hooks");
360
+ await fs2.mkdir(hooksDir, { recursive: true });
361
+ const preCommitPath = path3.join(hooksDir, "pre-commit");
362
+ let existingContent = "";
363
+ try {
364
+ existingContent = await fs2.readFile(preCommitPath, "utf-8");
365
+ if (existingContent.includes("rigstate")) {
366
+ console.log(chalk4.yellow("\u26A0 Rigstate pre-commit hook already installed."));
367
+ console.log(chalk4.dim(' Use "rigstate hooks uninstall" to remove first.'));
368
+ return;
369
+ }
370
+ } catch {
371
+ }
372
+ let script = PRE_COMMIT_SCRIPT;
373
+ if (options.strict === "all") {
374
+ script = script.replace("--strict=critical", "--strict");
375
+ }
376
+ if (existingContent && !existingContent.includes("rigstate")) {
377
+ const combinedScript = existingContent + "\n\n" + script.replace("#!/bin/sh\n", "");
378
+ await fs2.writeFile(preCommitPath, combinedScript, { mode: 493 });
379
+ console.log(chalk4.green("\u2705 Rigstate hook appended to existing pre-commit."));
380
+ } else {
381
+ await fs2.writeFile(preCommitPath, script, { mode: 493 });
382
+ console.log(chalk4.green("\u2705 Pre-commit hook installed!"));
383
+ }
384
+ console.log(chalk4.dim(` Path: ${preCommitPath}`));
385
+ console.log(chalk4.dim(` Strict level: ${options.strict}`));
386
+ console.log("");
387
+ console.log(chalk4.cyan("Guardian will now check your code before each commit."));
388
+ console.log(chalk4.dim('Use "rigstate hooks uninstall" to remove the hook.'));
389
+ } catch (error) {
390
+ console.error(chalk4.red("Failed to install hook:"), error.message);
391
+ process.exit(1);
392
+ }
393
+ });
394
+ hooks.command("uninstall").description("Remove Rigstate pre-commit hook").action(async () => {
395
+ try {
396
+ const preCommitPath = path3.join(process.cwd(), ".git", "hooks", "pre-commit");
397
+ try {
398
+ const content = await fs2.readFile(preCommitPath, "utf-8");
399
+ if (!content.includes("rigstate")) {
400
+ console.log(chalk4.yellow("\u26A0 No Rigstate hook found in pre-commit."));
401
+ return;
402
+ }
403
+ if (content.includes("# Rigstate Guardian Pre-commit Hook") && content.trim().split("\n").filter((l) => l && !l.startsWith("#")).length <= 4) {
404
+ await fs2.unlink(preCommitPath);
405
+ console.log(chalk4.green("\u2705 Pre-commit hook removed."));
406
+ } else {
407
+ const lines = content.split("\n");
408
+ const filteredLines = [];
409
+ let inRigstateSection = false;
410
+ for (const line of lines) {
411
+ if (line.includes("Rigstate Guardian Pre-commit Hook")) {
412
+ inRigstateSection = true;
413
+ continue;
414
+ }
415
+ if (inRigstateSection && line.includes("exit $?")) {
416
+ inRigstateSection = false;
417
+ continue;
418
+ }
419
+ if (!inRigstateSection && !line.includes("rigstate check")) {
420
+ filteredLines.push(line);
421
+ }
422
+ }
423
+ await fs2.writeFile(preCommitPath, filteredLines.join("\n"), { mode: 493 });
424
+ console.log(chalk4.green("\u2705 Rigstate section removed from pre-commit hook."));
425
+ }
426
+ } catch {
427
+ console.log(chalk4.yellow("\u26A0 No pre-commit hook found."));
428
+ }
429
+ } catch (error) {
430
+ console.error(chalk4.red("Failed to uninstall hook:"), error.message);
431
+ process.exit(1);
432
+ }
433
+ });
434
+ return hooks;
435
+ }
436
+ var PRE_COMMIT_SCRIPT;
437
+ var init_hooks = __esm({
438
+ "src/commands/hooks.ts"() {
439
+ "use strict";
440
+ init_esm_shims();
441
+ PRE_COMMIT_SCRIPT = `#!/bin/sh
442
+ # Rigstate Guardian Pre-commit Hook
443
+ # Installed by: rigstate hooks install
444
+
445
+ # 1. Silent Sentinel Check (Phase 5)
446
+ if [ -f .rigstate/guardian.lock ]; then
447
+ echo "\u{1F6D1} INTERVENTION ACTIVE: Commit blocked by Silent Sentinel."
448
+ echo " A critical violation ('HARD_LOCK') was detected by the Guardian Daemon."
449
+ echo " Please fix the violation to unlock the repo."
450
+ echo ""
451
+ if grep -q "HARD_LOCK_ACTIVE" .rigstate/guardian.lock; then
452
+ cat .rigstate/guardian.lock
453
+ fi
454
+ exit 1
455
+ fi
456
+
457
+ echo "\u{1F6E1}\uFE0F Running Guardian checks..."
458
+
459
+ # Run check with strict mode for critical violations
460
+ rigstate check --staged --strict=critical
461
+
462
+ # Exit with the same code as rigstate check
463
+ exit $?
464
+ `;
465
+ }
466
+ });
467
+
338
468
  // src/commands/suggest.ts
339
469
  var suggest_exports = {};
340
470
  __export(suggest_exports, {
341
471
  suggestNextMove: () => suggestNextMove
342
472
  });
343
- import chalk4 from "chalk";
473
+ import chalk5 from "chalk";
344
474
  import axios3 from "axios";
345
475
  async function suggestNextMove(projectId, apiKey, apiUrl) {
346
476
  try {
@@ -360,18 +490,18 @@ async function suggestNextMove(projectId, apiKey, apiUrl) {
360
490
  if (tasks.length === 0) return;
361
491
  const nextTask = tasks[0];
362
492
  console.log("");
363
- console.log(chalk4.bold("\u{1F3AF} TACTICAL INTELLIGENCE"));
364
- console.log(chalk4.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(`${chalk4.bold("Active Phase:")} Implementation`);
366
- console.log(`${chalk4.bold("Next Mission:")} ${chalk4.cyan(nextTask.title)}`);
493
+ console.log(chalk5.bold("\u{1F3AF} TACTICAL INTELLIGENCE"));
494
+ console.log(chalk5.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"));
495
+ console.log(`${chalk5.bold("Active Phase:")} Implementation`);
496
+ console.log(`${chalk5.bold("Next Mission:")} ${chalk5.cyan(nextTask.title)}`);
367
497
  if (nextTask.role) {
368
- console.log(`${chalk4.bold("Required Role:")} ${chalk4.magenta(nextTask.role)}`);
498
+ console.log(`${chalk5.bold("Required Role:")} ${chalk5.magenta(nextTask.role)}`);
369
499
  }
370
500
  console.log("");
371
- console.log(chalk4.yellow("SUGGESTED NEXT MOVE:"));
372
- console.log(chalk4.white(`> rigstate work start ${nextTask.id} `) + chalk4.dim("(Start this task)"));
373
- console.log(chalk4.white(`> rigstate chat "How do I solve T-${nextTask.step_number}?" `) + chalk4.dim("(Ask Architect)"));
374
- console.log(chalk4.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"));
501
+ console.log(chalk5.yellow("SUGGESTED NEXT MOVE:"));
502
+ console.log(chalk5.white(`> rigstate work start ${nextTask.id} `) + chalk5.dim("(Start this task)"));
503
+ console.log(chalk5.white(`> rigstate chat "How do I solve T-${nextTask.step_number}?" `) + chalk5.dim("(Ask Architect)"));
504
+ console.log(chalk5.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"));
375
505
  console.log("");
376
506
  } catch (e) {
377
507
  }
@@ -391,9 +521,9 @@ __export(skills_provisioner_exports, {
391
521
  provisionSkills: () => provisionSkills
392
522
  });
393
523
  import axios6 from "axios";
394
- import fs6 from "fs/promises";
395
- import path7 from "path";
396
- import chalk8 from "chalk";
524
+ import fs7 from "fs/promises";
525
+ import path8 from "path";
526
+ import chalk9 from "chalk";
397
527
  async function provisionSkills(apiUrl, apiKey, projectId, rootDir) {
398
528
  const skills = [];
399
529
  try {
@@ -415,18 +545,18 @@ async function provisionSkills(apiUrl, apiKey, projectId, rootDir) {
415
545
  }
416
546
  } catch (e) {
417
547
  const msg = e.response?.data?.error || e.message;
418
- console.log(chalk8.dim(` (Skills API not available: ${msg}, using core library)`));
548
+ console.log(chalk9.dim(` (Skills API not available: ${msg}, using core library)`));
419
549
  }
420
550
  if (skills.length === 0) {
421
551
  const { getRigstateStandardSkills } = await import("@rigstate/rules-engine");
422
552
  const coreSkills = getRigstateStandardSkills();
423
553
  skills.push(...coreSkills);
424
554
  }
425
- const skillsDir = path7.join(rootDir, ".agent", "skills");
426
- await fs6.mkdir(skillsDir, { recursive: true });
555
+ const skillsDir = path8.join(rootDir, ".agent", "skills");
556
+ await fs7.mkdir(skillsDir, { recursive: true });
427
557
  for (const skill of skills) {
428
- const skillDir = path7.join(skillsDir, skill.name);
429
- await fs6.mkdir(skillDir, { recursive: true });
558
+ const skillDir = path8.join(skillsDir, skill.name);
559
+ await fs7.mkdir(skillDir, { recursive: true });
430
560
  const skillContent = `---
431
561
  name: ${skill.name}
432
562
  description: ${skill.description}
@@ -439,10 +569,10 @@ ${skill.content}
439
569
 
440
570
  ---
441
571
  *Provisioned by Rigstate CLI. Do not modify manually.*`;
442
- const skillPath = path7.join(skillDir, "SKILL.md");
443
- await fs6.writeFile(skillPath, skillContent, "utf-8");
572
+ const skillPath = path8.join(skillDir, "SKILL.md");
573
+ await fs7.writeFile(skillPath, skillContent, "utf-8");
444
574
  }
445
- console.log(chalk8.green(` \u2705 Provisioned ${skills.length} skill(s) to .agent/skills/`));
575
+ console.log(chalk9.green(` \u2705 Provisioned ${skills.length} skill(s) to .agent/skills/`));
446
576
  return skills;
447
577
  }
448
578
  function generateSkillsDiscoveryBlock(skills) {
@@ -457,16 +587,16 @@ ${skillBlocks}
457
587
  </available_skills>`;
458
588
  }
459
589
  async function jitProvisionSkill(skillId, apiUrl, apiKey, projectId, rootDir) {
460
- const rulesPath = path7.join(rootDir, ".cursorrules");
590
+ const rulesPath = path8.join(rootDir, ".cursorrules");
461
591
  let rulesContent = "";
462
592
  try {
463
- rulesContent = await fs6.readFile(rulesPath, "utf-8");
593
+ rulesContent = await fs7.readFile(rulesPath, "utf-8");
464
594
  } catch (e) {
465
595
  return false;
466
596
  }
467
597
  const isProvisioned = rulesContent.includes(`<name>${skillId}</name>`) || rulesContent.includes(`.agent/skills/${skillId}`);
468
598
  if (isProvisioned) return false;
469
- console.log(chalk8.yellow(` \u26A1 JIT PROVISIONING: Injecting ${skillId}...`));
599
+ console.log(chalk9.yellow(` \u26A1 JIT PROVISIONING: Injecting ${skillId}...`));
470
600
  try {
471
601
  const skills = await provisionSkills(apiUrl, apiKey, projectId, rootDir);
472
602
  const skillsBlock = generateSkillsDiscoveryBlock(skills);
@@ -481,10 +611,10 @@ async function jitProvisionSkill(skillId, apiUrl, apiKey, projectId, rootDir) {
481
611
  rulesContent = rulesContent.slice(0, insertPoint + 3) + "\n\n" + skillsBlock + "\n" + rulesContent.slice(insertPoint + 3);
482
612
  }
483
613
  }
484
- await fs6.writeFile(rulesPath, rulesContent, "utf-8");
614
+ await fs7.writeFile(rulesPath, rulesContent, "utf-8");
485
615
  return true;
486
616
  } catch (e) {
487
- console.log(chalk8.red(` Failed to provision skill: ${e.message}`));
617
+ console.log(chalk9.red(` Failed to provision skill: ${e.message}`));
488
618
  return false;
489
619
  }
490
620
  }
@@ -505,13 +635,13 @@ __export(governance_exports, {
505
635
  performOverride: () => performOverride,
506
636
  setSoftLock: () => setSoftLock
507
637
  });
508
- import fs7 from "fs/promises";
509
- import path8 from "path";
510
- import chalk9 from "chalk";
638
+ import fs8 from "fs/promises";
639
+ import path9 from "path";
640
+ import chalk10 from "chalk";
511
641
  async function getGovernanceConfig(rootDir = process.cwd()) {
512
642
  try {
513
- const configPath = path8.join(rootDir, "rigstate.config.json");
514
- const content = await fs7.readFile(configPath, "utf-8");
643
+ const configPath = path9.join(rootDir, "rigstate.config.json");
644
+ const content = await fs8.readFile(configPath, "utf-8");
515
645
  const userConfig = JSON.parse(content);
516
646
  return {
517
647
  governance: {
@@ -525,37 +655,37 @@ async function getGovernanceConfig(rootDir = process.cwd()) {
525
655
  }
526
656
  async function getSessionState(rootDir = process.cwd()) {
527
657
  try {
528
- const sessionPath = path8.join(rootDir, ".rigstate", "session.json");
529
- const content = await fs7.readFile(sessionPath, "utf-8");
658
+ const sessionPath = path9.join(rootDir, ".rigstate", "session.json");
659
+ const content = await fs8.readFile(sessionPath, "utf-8");
530
660
  return JSON.parse(content);
531
661
  } catch (e) {
532
662
  return DEFAULT_SESSION;
533
663
  }
534
664
  }
535
665
  async function setSoftLock(reason, violationId, rootDir = process.cwd()) {
536
- const sessionPath = path8.join(rootDir, ".rigstate", "session.json");
666
+ const sessionPath = path9.join(rootDir, ".rigstate", "session.json");
537
667
  const state = {
538
668
  status: "SOFT_LOCK",
539
669
  active_violation: violationId,
540
670
  lock_reason: reason,
541
671
  last_updated: (/* @__PURE__ */ new Date()).toISOString()
542
672
  };
543
- await fs7.mkdir(path8.dirname(sessionPath), { recursive: true });
544
- await fs7.writeFile(sessionPath, JSON.stringify(state, null, 2), "utf-8");
673
+ await fs8.mkdir(path9.dirname(sessionPath), { recursive: true });
674
+ await fs8.writeFile(sessionPath, JSON.stringify(state, null, 2), "utf-8");
545
675
  }
546
676
  async function clearSoftLock(rootDir = process.cwd()) {
547
- const sessionPath = path8.join(rootDir, ".rigstate", "session.json");
677
+ const sessionPath = path9.join(rootDir, ".rigstate", "session.json");
548
678
  const state = {
549
679
  ...DEFAULT_SESSION,
550
680
  last_updated: (/* @__PURE__ */ new Date()).toISOString()
551
681
  };
552
- await fs7.mkdir(path8.dirname(sessionPath), { recursive: true });
553
- await fs7.writeFile(sessionPath, JSON.stringify(state, null, 2), "utf-8");
682
+ await fs8.mkdir(path9.dirname(sessionPath), { recursive: true });
683
+ await fs8.writeFile(sessionPath, JSON.stringify(state, null, 2), "utf-8");
554
684
  }
555
685
  async function performOverride(violationId, reason, rootDir = process.cwd()) {
556
686
  const config2 = await getGovernanceConfig(rootDir);
557
687
  if (!config2.governance.allow_overrides) {
558
- console.log(chalk9.red("\u274C Overrides are disabled for this project."));
688
+ console.log(chalk10.red("\u274C Overrides are disabled for this project."));
559
689
  return false;
560
690
  }
561
691
  await clearSoftLock(rootDir);
@@ -592,22 +722,22 @@ var watchdog_exports = {};
592
722
  __export(watchdog_exports, {
593
723
  runGuardianWatchdog: () => runGuardianWatchdog
594
724
  });
595
- import fs8 from "fs/promises";
596
- import path9 from "path";
597
- import chalk10 from "chalk";
725
+ import fs9 from "fs/promises";
726
+ import path10 from "path";
727
+ import chalk11 from "chalk";
598
728
  import axios7 from "axios";
599
729
  async function countLines(filePath) {
600
730
  try {
601
- const content = await fs8.readFile(filePath, "utf-8");
731
+ const content = await fs9.readFile(filePath, "utf-8");
602
732
  return content.split("\n").length;
603
733
  } catch (e) {
604
734
  return 0;
605
735
  }
606
736
  }
607
737
  async function getFiles(dir, extension) {
608
- const entries = await fs8.readdir(dir, { withFileTypes: true });
738
+ const entries = await fs9.readdir(dir, { withFileTypes: true });
609
739
  const files = await Promise.all(entries.map(async (entry) => {
610
- const res = path9.resolve(dir, entry.name);
740
+ const res = path10.resolve(dir, entry.name);
611
741
  if (entry.isDirectory()) {
612
742
  if (entry.name === "node_modules" || entry.name === ".git" || entry.name === ".next" || entry.name === "dist") return [];
613
743
  return getFiles(res, extension);
@@ -635,8 +765,8 @@ async function fetchRulesFromApi(projectId) {
635
765
  }
636
766
  } catch (error) {
637
767
  try {
638
- const cachePath = path9.join(process.cwd(), CACHE_FILE);
639
- const content = await fs8.readFile(cachePath, "utf-8");
768
+ const cachePath = path10.join(process.cwd(), CACHE_FILE);
769
+ const content = await fs9.readFile(cachePath, "utf-8");
640
770
  const cached = JSON.parse(content);
641
771
  if (cached.settings) {
642
772
  return {
@@ -655,7 +785,7 @@ async function fetchRulesFromApi(projectId) {
655
785
  };
656
786
  }
657
787
  async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
658
- console.log(chalk10.bold("\n\u{1F6E1}\uFE0F Active Guardian Watchdog Initiated..."));
788
+ console.log(chalk11.bold("\n\u{1F6E1}\uFE0F Active Guardian Watchdog Initiated..."));
659
789
  let lmax = settings.lmax || DEFAULT_LMAX;
660
790
  let lmaxWarning = settings.lmax_warning || DEFAULT_LMAX_WARNING;
661
791
  let ruleSource = settings.lmax ? "Settings (Passed)" : "Default";
@@ -665,47 +795,47 @@ async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
665
795
  lmaxWarning = apiRules.lmaxWarning;
666
796
  ruleSource = apiRules.source;
667
797
  }
668
- console.log(chalk10.dim(`Governance Rules: L_max=${lmax}, L_max_warning=${lmaxWarning}, Source: ${ruleSource}`));
798
+ console.log(chalk11.dim(`Governance Rules: L_max=${lmax}, L_max_warning=${lmaxWarning}, Source: ${ruleSource}`));
669
799
  const targetExtensions = [".ts", ".tsx"];
670
800
  let scanTarget = rootPath;
671
- const webSrc = path9.join(rootPath, "apps", "web", "src");
801
+ const webSrc = path10.join(rootPath, "apps", "web", "src");
672
802
  try {
673
- await fs8.access(webSrc);
803
+ await fs9.access(webSrc);
674
804
  scanTarget = webSrc;
675
805
  } catch {
676
806
  }
677
- console.log(chalk10.dim(`Scanning target: ${path9.relative(process.cwd(), scanTarget)}`));
807
+ console.log(chalk11.dim(`Scanning target: ${path10.relative(process.cwd(), scanTarget)}`));
678
808
  const files = await getFiles(scanTarget, targetExtensions);
679
809
  let violations = 0;
680
810
  let warnings = 0;
681
811
  const results = [];
682
812
  for (const file of files) {
683
813
  const lines = await countLines(file);
684
- const relPath = path9.relative(rootPath, file);
814
+ const relPath = path10.relative(rootPath, file);
685
815
  if (lines > lmax) {
686
816
  results.push({ file: relPath, lines, status: "VIOLATION" });
687
817
  violations++;
688
- console.log(chalk10.red(`[VIOLATION] ${relPath}: ${lines} lines (Limit: ${lmax})`));
818
+ console.log(chalk11.red(`[VIOLATION] ${relPath}: ${lines} lines (Limit: ${lmax})`));
689
819
  } else if (lines > lmaxWarning) {
690
820
  results.push({ file: relPath, lines, status: "WARNING" });
691
821
  warnings++;
692
- console.log(chalk10.yellow(`[WARNING] ${relPath}: ${lines} lines (Threshold: ${lmaxWarning})`));
822
+ console.log(chalk11.yellow(`[WARNING] ${relPath}: ${lines} lines (Threshold: ${lmaxWarning})`));
693
823
  }
694
824
  }
695
825
  if (violations === 0 && warnings === 0) {
696
- console.log(chalk10.green(`\u2714 All ${files.length} files are within governance limits.`));
826
+ console.log(chalk11.green(`\u2714 All ${files.length} files are within governance limits.`));
697
827
  } else {
698
- console.log("\n" + chalk10.bold("Summary:"));
699
- console.log(chalk10.red(`Violations: ${violations}`));
700
- console.log(chalk10.yellow(`Warnings: ${warnings}`));
828
+ console.log("\n" + chalk11.bold("Summary:"));
829
+ console.log(chalk11.red(`Violations: ${violations}`));
830
+ console.log(chalk11.yellow(`Warnings: ${warnings}`));
701
831
  const { getGovernanceConfig: getGovernanceConfig2, setSoftLock: setSoftLock2, InterventionLevel: InterventionLevel2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
702
832
  const { governance } = await getGovernanceConfig2(rootPath);
703
- console.log(chalk10.dim(`Intervention Level: ${InterventionLevel2[governance.intervention_level] || "UNKNOWN"} (${governance.intervention_level})`));
833
+ console.log(chalk11.dim(`Intervention Level: ${InterventionLevel2[governance.intervention_level] || "UNKNOWN"} (${governance.intervention_level})`));
704
834
  if (violations > 0) {
705
- console.log(chalk10.red.bold("\nCRITICAL: Governance violations detected. Immediate refactoring required."));
835
+ console.log(chalk11.red.bold("\nCRITICAL: Governance violations detected. Immediate refactoring required."));
706
836
  if (governance.intervention_level >= InterventionLevel2.SENTINEL) {
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.'));
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.'));
709
839
  await setSoftLock2("Sentinel Mode: Governance Violations Detected", "ARC-VIOLATION", rootPath);
710
840
  }
711
841
  }
@@ -728,9 +858,9 @@ async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
728
858
  }, {
729
859
  headers: { Authorization: `Bearer ${apiKey}` }
730
860
  });
731
- console.log(chalk10.dim("\u2714 Violations synced to Rigstate Cloud."));
861
+ console.log(chalk11.dim("\u2714 Violations synced to Rigstate Cloud."));
732
862
  } catch (e) {
733
- console.log(chalk10.dim("\u26A0 Cloud sync skipped: " + (e.message || "Unknown")));
863
+ console.log(chalk11.dim("\u26A0 Cloud sync skipped: " + (e.message || "Unknown")));
734
864
  }
735
865
  }
736
866
  }
@@ -1533,10 +1663,10 @@ var require_src2 = __commonJS({
1533
1663
  var fs_1 = __require("fs");
1534
1664
  var debug_1 = __importDefault(require_src());
1535
1665
  var log = debug_1.default("@kwsites/file-exists");
1536
- function check(path26, isFile, isDirectory) {
1537
- log(`checking %s`, path26);
1666
+ function check(path27, isFile, isDirectory) {
1667
+ log(`checking %s`, path27);
1538
1668
  try {
1539
- const stat = fs_1.statSync(path26);
1669
+ const stat = fs_1.statSync(path27);
1540
1670
  if (stat.isFile() && isFile) {
1541
1671
  log(`[OK] path represents a file`);
1542
1672
  return true;
@@ -1556,8 +1686,8 @@ var require_src2 = __commonJS({
1556
1686
  throw e;
1557
1687
  }
1558
1688
  }
1559
- function exists2(path26, type = exports.READABLE) {
1560
- return check(path26, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
1689
+ function exists2(path27, type = exports.READABLE) {
1690
+ return check(path27, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
1561
1691
  }
1562
1692
  exports.exists = exists2;
1563
1693
  exports.FILE = 1;
@@ -1627,7 +1757,7 @@ var require_package = __commonJS({
1627
1757
  "package.json"(exports, module) {
1628
1758
  module.exports = {
1629
1759
  name: "@rigstate/cli",
1630
- version: "0.7.24",
1760
+ version: "0.7.26",
1631
1761
  description: "Rigstate CLI - Code audit, sync and supervision tool",
1632
1762
  type: "module",
1633
1763
  main: "./dist/index.js",
@@ -1684,7 +1814,7 @@ var require_package = __commonJS({
1684
1814
  // src/index.ts
1685
1815
  init_esm_shims();
1686
1816
  import { Command as Command23 } from "commander";
1687
- import chalk33 from "chalk";
1817
+ import chalk34 from "chalk";
1688
1818
 
1689
1819
  // src/commands/login.ts
1690
1820
  init_esm_shims();
@@ -1737,30 +1867,30 @@ Your API key has been securely stored. You can now use "rigstate scan" to audit
1737
1867
  // src/commands/link.ts
1738
1868
  init_esm_shims();
1739
1869
  init_config();
1740
- import { Command as Command4 } from "commander";
1741
- import fs2 from "fs/promises";
1742
- import path3 from "path";
1743
- import chalk5 from "chalk";
1870
+ import { Command as Command5 } from "commander";
1871
+ import fs3 from "fs/promises";
1872
+ import path4 from "path";
1873
+ import chalk6 from "chalk";
1744
1874
  import os from "os";
1745
1875
  function createLinkCommand() {
1746
- return new Command4("link").description("Link current directory to a Rigstate project").argument("<projectId>", "Project ID to link").action(async (projectId) => {
1876
+ return new Command5("link").description("Link current directory to a Rigstate project").argument("<projectId>", "Project ID to link").action(async (projectId) => {
1747
1877
  try {
1748
- const globalPath = path3.join(os.homedir(), ".rigstate", "config.json");
1749
- const globalData = await fs2.readFile(globalPath, "utf-8").catch(() => null);
1878
+ const globalPath = path4.join(os.homedir(), ".rigstate", "config.json");
1879
+ const globalData = await fs3.readFile(globalPath, "utf-8").catch(() => null);
1750
1880
  if (globalData) {
1751
1881
  const config2 = JSON.parse(globalData);
1752
1882
  const cwd = process.cwd();
1753
1883
  if (config2.overrides && config2.overrides[cwd]) {
1754
1884
  const overrideId = config2.overrides[cwd];
1755
1885
  if (overrideId !== projectId) {
1756
- console.warn(chalk5.yellow(`Global override detected. Enforcing project ID: ${overrideId}`));
1886
+ console.warn(chalk6.yellow(`Global override detected. Enforcing project ID: ${overrideId}`));
1757
1887
  projectId = overrideId;
1758
1888
  }
1759
1889
  }
1760
1890
  }
1761
1891
  } catch (e) {
1762
1892
  }
1763
- const manifestPath = path3.join(process.cwd(), ".rigstate");
1893
+ const manifestPath = path4.join(process.cwd(), ".rigstate");
1764
1894
  const content = {
1765
1895
  project_id: projectId,
1766
1896
  linked_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -1770,82 +1900,123 @@ function createLinkCommand() {
1770
1900
  content.api_url = currentUrl;
1771
1901
  }
1772
1902
  try {
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
+ await fs3.writeFile(manifestPath, JSON.stringify(content, null, 2), "utf-8");
1904
+ console.log(chalk6.green(`\u2714 Linked to project ID: ${projectId}`));
1905
+ console.log(chalk6.dim(`Created local context manifest at .rigstate`));
1776
1906
  console.log("");
1777
- console.log(chalk5.bold("\u{1F916} Rigstate Automation Detected"));
1907
+ console.log(chalk6.bold("\u{1F916} Rigstate Automation Detected"));
1778
1908
  console.log("");
1779
1909
  const { getApiKey: _getApiKey, getApiUrl: _getApiUrl } = await Promise.resolve().then(() => (init_config(), config_exports));
1780
1910
  const apiKey = getApiKey();
1781
1911
  const apiUrl = getApiUrl();
1782
1912
  if (apiKey) {
1783
- console.log(chalk5.blue("\u{1F510} Checking Vault for secrets..."));
1913
+ console.log(chalk6.blue("\u{1F510} Checking Vault for secrets..."));
1784
1914
  const { syncEnv: syncEnv2 } = await Promise.resolve().then(() => (init_env(), env_exports));
1785
1915
  await syncEnv2(projectId, apiKey, apiUrl, true);
1786
- console.log(chalk5.blue("\u{1F9E0} Syncing neural instructions..."));
1916
+ console.log(chalk6.blue("\u{1F9E0} Syncing neural instructions..."));
1787
1917
  const { syncProjectRules: syncProjectRules2 } = await Promise.resolve().then(() => (init_sync_rules(), sync_rules_exports));
1788
1918
  await syncProjectRules2(projectId, apiKey, apiUrl);
1789
- console.log(chalk5.blue("\u{1F6E1}\uFE0F Checking immunity system..."));
1919
+ console.log(chalk6.blue("\u{1F6E1}\uFE0F Injecting Guardian hooks..."));
1920
+ const { createHooksCommand: createHooksCommand2 } = await Promise.resolve().then(() => (init_hooks(), hooks_exports));
1790
1921
  await installHooks(process.cwd());
1791
1922
  console.log("");
1792
- console.log(chalk5.bold.green("\u{1F680} Link Complete! Your environment is ready."));
1923
+ console.log(chalk6.bold.green("\u{1F680} Link Complete! Your environment is ready."));
1793
1924
  const { suggestNextMove: suggestNextMove2 } = await Promise.resolve().then(() => (init_suggest(), suggest_exports));
1794
1925
  await suggestNextMove2(projectId, apiKey, apiUrl);
1795
1926
  } else {
1796
1927
  console.log("");
1797
- console.log(chalk5.bold.green("\u{1F680} Link Complete!"));
1928
+ console.log(chalk6.bold.green("\u{1F680} Link Complete!"));
1798
1929
  }
1799
1930
  } catch (error) {
1800
1931
  if (error.message.includes("Not authenticated")) {
1801
- console.warn(chalk5.yellow('\u26A0\uFE0F Not authenticated. Run "rigstate login" to enable automation features.'));
1932
+ console.warn(chalk6.yellow('\u26A0\uFE0F Not authenticated. Run "rigstate login" to enable automation features.'));
1802
1933
  } else {
1803
- console.error(chalk5.red(`Failed to link project: ${error.message}`));
1934
+ console.error(chalk6.red(`Failed to link project: ${error.message}`));
1804
1935
  }
1805
1936
  }
1806
1937
  });
1807
1938
  }
1808
1939
  async function installHooks(cwd) {
1809
- const fs23 = await import("fs/promises");
1810
- const path26 = await import("path");
1940
+ const fs24 = await import("fs/promises");
1941
+ const path27 = await import("path");
1811
1942
  try {
1812
- await fs23.access(path26.join(cwd, ".git"));
1943
+ await fs24.access(path27.join(cwd, ".git"));
1813
1944
  } catch {
1814
- console.log(chalk5.dim(" (Not a git repository, skipping hooks)"));
1945
+ console.log(chalk6.dim(" (Not a git repository, skipping hooks)"));
1815
1946
  return;
1816
1947
  }
1817
- const hooksDir = path26.join(cwd, ".husky");
1948
+ const hooksDir = path27.join(cwd, ".husky");
1818
1949
  try {
1819
- const preCommitPath = path26.join(cwd, ".git/hooks/pre-commit");
1950
+ const preCommitPath = path27.join(cwd, ".git/hooks/pre-commit");
1951
+ let shouldInstall = false;
1820
1952
  try {
1821
- await fs23.access(preCommitPath);
1822
- console.log(chalk5.green(" \u2714 Git hooks already active"));
1953
+ await fs24.access(preCommitPath);
1954
+ const content = await fs24.readFile(preCommitPath, "utf-8");
1955
+ if (content.includes("rigstate")) {
1956
+ console.log(chalk6.green(" \u2714 Git hooks already active"));
1957
+ } else {
1958
+ shouldInstall = true;
1959
+ }
1823
1960
  } catch {
1824
- console.log(chalk5.yellow(' \u26A0\uFE0F Git hooks missing. Run "rigstate hooks install" to secure repo.'));
1961
+ shouldInstall = true;
1962
+ }
1963
+ if (shouldInstall) {
1964
+ const PRE_COMMIT_SCRIPT2 = `#!/bin/sh
1965
+ # Rigstate Guardian Pre-commit Hook
1966
+ # Installed by: rigstate link (v0.7.25)
1967
+
1968
+ # 1. Silent Sentinel Check
1969
+ if [ -f .rigstate/guardian.lock ]; then
1970
+ echo "\u{1F6D1} INTERVENTION ACTIVE: Commit blocked by Silent Sentinel."
1971
+ exit 1
1972
+ fi
1973
+
1974
+ echo "\u{1F6E1}\uFE0F Running Guardian checks..."
1975
+ rigstate check --staged --strict=critical
1976
+ exit $?
1977
+ `;
1978
+ await fs24.mkdir(path27.dirname(preCommitPath), { recursive: true });
1979
+ if (await fileExists(preCommitPath)) {
1980
+ const existing = await fs24.readFile(preCommitPath, "utf-8");
1981
+ await fs24.writeFile(preCommitPath, existing + "\n\n" + PRE_COMMIT_SCRIPT2.replace("#!/bin/sh\n", ""), { mode: 493 });
1982
+ } else {
1983
+ await fs24.writeFile(preCommitPath, PRE_COMMIT_SCRIPT2, { mode: 493 });
1984
+ }
1985
+ console.log(chalk6.green(" \u2714 Applied Guardian protection (git-hooks)"));
1825
1986
  }
1826
1987
  } catch (e) {
1988
+ console.log(chalk6.dim(" (Skipped hooks: " + e.message + ")"));
1989
+ }
1990
+ }
1991
+ async function fileExists(path27) {
1992
+ const fs24 = await import("fs/promises");
1993
+ try {
1994
+ await fs24.access(path27);
1995
+ return true;
1996
+ } catch {
1997
+ return false;
1827
1998
  }
1828
1999
  }
1829
2000
 
1830
2001
  // src/commands/scan.ts
1831
2002
  init_esm_shims();
1832
2003
  init_config();
1833
- import { Command as Command5 } from "commander";
1834
- import chalk6 from "chalk";
2004
+ import { Command as Command6 } from "commander";
2005
+ import chalk7 from "chalk";
1835
2006
  import ora3 from "ora";
1836
2007
  import axios4 from "axios";
1837
2008
  import { glob } from "glob";
1838
- import fs4 from "fs/promises";
1839
- import path5 from "path";
2009
+ import fs5 from "fs/promises";
2010
+ import path6 from "path";
1840
2011
 
1841
2012
  // src/utils/files.ts
1842
2013
  init_esm_shims();
1843
- import fs3 from "fs/promises";
1844
- import path4 from "path";
2014
+ import fs4 from "fs/promises";
2015
+ import path5 from "path";
1845
2016
  async function readGitignore(dir) {
1846
- const gitignorePath = path4.join(dir, ".gitignore");
2017
+ const gitignorePath = path5.join(dir, ".gitignore");
1847
2018
  try {
1848
- const content = await fs3.readFile(gitignorePath, "utf-8");
2019
+ const content = await fs4.readFile(gitignorePath, "utf-8");
1849
2020
  return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
1850
2021
  } catch (error) {
1851
2022
  return [];
@@ -1907,13 +2078,13 @@ function isCodeFile(filePath) {
1907
2078
  ".vue",
1908
2079
  ".svelte"
1909
2080
  ];
1910
- const ext = path4.extname(filePath).toLowerCase();
2081
+ const ext = path5.extname(filePath).toLowerCase();
1911
2082
  return codeExtensions.includes(ext);
1912
2083
  }
1913
2084
 
1914
2085
  // src/commands/scan.ts
1915
2086
  function createScanCommand() {
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) => {
2087
+ 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) => {
1917
2088
  const spinner = ora3();
1918
2089
  try {
1919
2090
  const apiKey = getApiKey();
@@ -1921,26 +2092,26 @@ function createScanCommand() {
1921
2092
  const projectId = options.project || getProjectId();
1922
2093
  if (!projectId) {
1923
2094
  console.warn(
1924
- chalk6.yellow(
2095
+ chalk7.yellow(
1925
2096
  "\u26A0\uFE0F No project ID specified. Use --project <id> or set a default."
1926
2097
  )
1927
2098
  );
1928
2099
  }
1929
- const scanPath = path5.resolve(process.cwd(), targetPath);
1930
- spinner.start(`Scanning ${chalk6.cyan(scanPath)}...`);
2100
+ const scanPath = path6.resolve(process.cwd(), targetPath);
2101
+ spinner.start(`Scanning ${chalk7.cyan(scanPath)}...`);
1931
2102
  const gitignorePatterns = await readGitignore(scanPath);
1932
- const pattern = path5.join(scanPath, "**/*");
2103
+ const pattern = path6.join(scanPath, "**/*");
1933
2104
  const allFiles = await glob(pattern, {
1934
2105
  nodir: true,
1935
2106
  dot: false,
1936
2107
  ignore: ["**/node_modules/**", "**/.git/**", "**/dist/**", "**/build/**"]
1937
2108
  });
1938
2109
  const codeFiles = allFiles.filter((file) => {
1939
- const relativePath = path5.relative(scanPath, file);
2110
+ const relativePath = path6.relative(scanPath, file);
1940
2111
  return isCodeFile(file) && !shouldIgnore(relativePath, gitignorePatterns);
1941
2112
  });
1942
2113
  if (codeFiles.length === 0) {
1943
- spinner.warn(chalk6.yellow("No code files found to scan."));
2114
+ spinner.warn(chalk7.yellow("No code files found to scan."));
1944
2115
  return;
1945
2116
  }
1946
2117
  spinner.text = `Found ${codeFiles.length} files. Scanning...`;
@@ -1949,10 +2120,10 @@ function createScanCommand() {
1949
2120
  const severityCounts = {};
1950
2121
  for (let i = 0; i < codeFiles.length; i++) {
1951
2122
  const filePath = codeFiles[i];
1952
- const relativePath = path5.relative(scanPath, filePath);
2123
+ const relativePath = path6.relative(scanPath, filePath);
1953
2124
  spinner.text = `Scanning ${i + 1}/${codeFiles.length}: ${relativePath}`;
1954
2125
  try {
1955
- const content = await fs4.readFile(filePath, "utf-8");
2126
+ const content = await fs5.readFile(filePath, "utf-8");
1956
2127
  const response = await axios4.post(
1957
2128
  `${apiUrl}/api/v1/audit`,
1958
2129
  {
@@ -1988,15 +2159,15 @@ function createScanCommand() {
1988
2159
  }
1989
2160
  } catch (fileError) {
1990
2161
  if (axios4.isAxiosError(fileError)) {
1991
- console.warn(chalk6.yellow(`
2162
+ console.warn(chalk7.yellow(`
1992
2163
  \u26A0\uFE0F Skipping ${relativePath}: ${fileError.message}`));
1993
2164
  } else {
1994
- console.warn(chalk6.yellow(`
2165
+ console.warn(chalk7.yellow(`
1995
2166
  \u26A0\uFE0F Error reading ${relativePath}`));
1996
2167
  }
1997
2168
  }
1998
2169
  }
1999
- spinner.succeed(chalk6.green("\u2705 Scan completed!"));
2170
+ spinner.succeed(chalk7.green("\u2705 Scan completed!"));
2000
2171
  const aggregatedResponse = {
2001
2172
  results,
2002
2173
  summary: {
@@ -2011,21 +2182,21 @@ function createScanCommand() {
2011
2182
  printPrettyResults(aggregatedResponse);
2012
2183
  }
2013
2184
  } catch (error) {
2014
- spinner.fail(chalk6.red("\u274C Scan failed"));
2185
+ spinner.fail(chalk7.red("\u274C Scan failed"));
2015
2186
  if (axios4.isAxiosError(error)) {
2016
2187
  if (error.response) {
2017
- console.error(chalk6.red("API Error:"), error.response.data);
2188
+ console.error(chalk7.red("API Error:"), error.response.data);
2018
2189
  } else if (error.request) {
2019
2190
  console.error(
2020
- chalk6.red("Network Error:"),
2191
+ chalk7.red("Network Error:"),
2021
2192
  "Could not reach the API. Is the server running?"
2022
2193
  );
2023
2194
  } else {
2024
- console.error(chalk6.red("Error:"), error.message);
2195
+ console.error(chalk7.red("Error:"), error.message);
2025
2196
  }
2026
2197
  } else {
2027
2198
  console.error(
2028
- chalk6.red("Error:"),
2199
+ chalk7.red("Error:"),
2029
2200
  error instanceof Error ? error.message : "Unknown error"
2030
2201
  );
2031
2202
  }
@@ -2035,10 +2206,10 @@ function createScanCommand() {
2035
2206
  }
2036
2207
  function printPrettyResults(data) {
2037
2208
  const { results, summary } = data;
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)}`);
2209
+ console.log("\n" + chalk7.bold("\u{1F4CA} Scan Summary"));
2210
+ console.log(chalk7.dim("\u2500".repeat(60)));
2211
+ console.log(`Total Files Scanned: ${chalk7.cyan(summary.total_files)}`);
2212
+ console.log(`Total Issues Found: ${chalk7.yellow(summary.total_issues)}`);
2042
2213
  if (summary.by_severity) {
2043
2214
  console.log("\nIssues by Severity:");
2044
2215
  Object.entries(summary.by_severity).forEach(([severity, count]) => {
@@ -2047,87 +2218,87 @@ function printPrettyResults(data) {
2047
2218
  });
2048
2219
  }
2049
2220
  if (results && results.length > 0) {
2050
- console.log("\n" + chalk6.bold("\u{1F50D} Detailed Results"));
2051
- console.log(chalk6.dim("\u2500".repeat(60)));
2221
+ console.log("\n" + chalk7.bold("\u{1F50D} Detailed Results"));
2222
+ console.log(chalk7.dim("\u2500".repeat(60)));
2052
2223
  results.forEach((result) => {
2053
2224
  if (result.issues && result.issues.length > 0) {
2054
2225
  console.log(`
2055
- ${chalk6.bold(result.file_path)}`);
2226
+ ${chalk7.bold(result.file_path)}`);
2056
2227
  result.issues.forEach((issue) => {
2057
2228
  const severityColor = getSeverityColor(issue.severity);
2058
- const lineInfo = issue.line ? chalk6.dim(`:${issue.line}`) : "";
2229
+ const lineInfo = issue.line ? chalk7.dim(`:${issue.line}`) : "";
2059
2230
  console.log(
2060
2231
  ` ${severityColor(`[${issue.severity.toUpperCase()}]`)} ${issue.type}${lineInfo}`
2061
2232
  );
2062
- console.log(` ${chalk6.dim(issue.message)}`);
2233
+ console.log(` ${chalk7.dim(issue.message)}`);
2063
2234
  });
2064
2235
  }
2065
2236
  });
2066
2237
  }
2067
- console.log("\n" + chalk6.dim("\u2500".repeat(60)));
2238
+ console.log("\n" + chalk7.dim("\u2500".repeat(60)));
2068
2239
  }
2069
2240
  function getSeverityColor(severity) {
2070
2241
  switch (severity.toLowerCase()) {
2071
2242
  case "critical":
2072
- return chalk6.red.bold;
2243
+ return chalk7.red.bold;
2073
2244
  case "high":
2074
- return chalk6.red;
2245
+ return chalk7.red;
2075
2246
  case "medium":
2076
- return chalk6.yellow;
2247
+ return chalk7.yellow;
2077
2248
  case "low":
2078
- return chalk6.blue;
2249
+ return chalk7.blue;
2079
2250
  case "info":
2080
- return chalk6.gray;
2251
+ return chalk7.gray;
2081
2252
  default:
2082
- return chalk6.white;
2253
+ return chalk7.white;
2083
2254
  }
2084
2255
  }
2085
2256
 
2086
2257
  // src/commands/fix.ts
2087
2258
  init_esm_shims();
2088
2259
  init_config();
2089
- import { Command as Command6 } from "commander";
2090
- import chalk7 from "chalk";
2260
+ import { Command as Command7 } from "commander";
2261
+ import chalk8 from "chalk";
2091
2262
  import ora4 from "ora";
2092
2263
  import axios5 from "axios";
2093
2264
  import { glob as glob2 } from "glob";
2094
- import fs5 from "fs/promises";
2095
- import path6 from "path";
2265
+ import fs6 from "fs/promises";
2266
+ import path7 from "path";
2096
2267
  import inquirer from "inquirer";
2097
2268
  import * as Diff from "diff";
2098
2269
  function createFixCommand() {
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) => {
2270
+ 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) => {
2100
2271
  const spinner = ora4();
2101
2272
  try {
2102
2273
  const apiKey = getApiKey();
2103
2274
  const apiUrl = getApiUrl();
2104
2275
  const projectId = options.project || getProjectId();
2105
2276
  if (!projectId) {
2106
- console.log(chalk7.yellow("\u26A0\uFE0F Project ID is required for fixing. Using default or pass --project <id>"));
2277
+ console.log(chalk8.yellow("\u26A0\uFE0F Project ID is required for fixing. Using default or pass --project <id>"));
2107
2278
  }
2108
- const scanPath = path6.resolve(process.cwd(), targetPath);
2279
+ const scanPath = path7.resolve(process.cwd(), targetPath);
2109
2280
  const gitignorePatterns = await readGitignore(scanPath);
2110
- const pattern = path6.join(scanPath, "**/*");
2281
+ const pattern = path7.join(scanPath, "**/*");
2111
2282
  const allFiles = await glob2(pattern, { nodir: true, dot: false, ignore: ["**/node_modules/**", "**/.git/**"] });
2112
2283
  const codeFiles = allFiles.filter((file) => {
2113
- const relativePath = path6.relative(scanPath, file);
2284
+ const relativePath = path7.relative(scanPath, file);
2114
2285
  return isCodeFile(file) && !shouldIgnore(relativePath, gitignorePatterns);
2115
2286
  });
2116
2287
  if (codeFiles.length === 0) {
2117
- console.log(chalk7.yellow("No code files found."));
2288
+ console.log(chalk8.yellow("No code files found."));
2118
2289
  return;
2119
2290
  }
2120
- console.log(chalk7.bold(`
2291
+ console.log(chalk8.bold(`
2121
2292
  \u{1F9E0} Rigstate Fix Mode`));
2122
- console.log(chalk7.dim(`Scanning ${codeFiles.length} files with Project Context...
2293
+ console.log(chalk8.dim(`Scanning ${codeFiles.length} files with Project Context...
2123
2294
  `));
2124
2295
  let fixedCount = 0;
2125
2296
  for (let i = 0; i < codeFiles.length; i++) {
2126
2297
  const filePath = codeFiles[i];
2127
- const relativePath = path6.relative(scanPath, filePath);
2298
+ const relativePath = path7.relative(scanPath, filePath);
2128
2299
  spinner.start(`Analyzing ${relativePath}...`);
2129
2300
  try {
2130
- const content = await fs5.readFile(filePath, "utf-8");
2301
+ const content = await fs6.readFile(filePath, "utf-8");
2131
2302
  const response = await axios5.post(
2132
2303
  `${apiUrl}/api/v1/audit`,
2133
2304
  { content, file_path: relativePath, project_id: projectId },
@@ -2138,22 +2309,22 @@ function createFixCommand() {
2138
2309
  if (fixableIssues.length > 0) {
2139
2310
  spinner.stop();
2140
2311
  console.log(`
2141
- ${chalk7.bold(relativePath)}: Found ${fixableIssues.length} fixable issues.`);
2312
+ ${chalk8.bold(relativePath)}: Found ${fixableIssues.length} fixable issues.`);
2142
2313
  for (const issue of fixableIssues) {
2143
- console.log(chalk7.red(`
2314
+ console.log(chalk8.red(`
2144
2315
  [${issue.type}] ${issue.title}`));
2145
- console.log(chalk7.dim(issue.suggestion || issue.message));
2316
+ console.log(chalk8.dim(issue.suggestion || issue.message));
2146
2317
  const diff = Diff.createTwoFilesPatch(relativePath, relativePath, content, issue.fixed_content, "Current", "Fixed");
2147
2318
  console.log("\n" + diff.split("\n").slice(0, 15).join("\n") + (diff.split("\n").length > 15 ? "\n..." : ""));
2148
2319
  const { apply } = await inquirer.prompt([{
2149
2320
  type: "confirm",
2150
2321
  name: "apply",
2151
- message: `Apply this fix to ${chalk7.cyan(relativePath)}?`,
2322
+ message: `Apply this fix to ${chalk8.cyan(relativePath)}?`,
2152
2323
  default: true
2153
2324
  }]);
2154
2325
  if (apply) {
2155
- await fs5.writeFile(filePath, issue.fixed_content);
2156
- console.log(chalk7.green(`\u2705 Fixed applied!`));
2326
+ await fs6.writeFile(filePath, issue.fixed_content);
2327
+ console.log(chalk8.green(`\u2705 Fixed applied!`));
2157
2328
  fixedCount++;
2158
2329
  if (issue.related_step_id) {
2159
2330
  const { completeStep } = await inquirer.prompt([{
@@ -2169,15 +2340,15 @@ ${chalk7.bold(relativePath)}: Found ${fixableIssues.length} fixable issues.`);
2169
2340
  { step_id: issue.related_step_id, status: "COMPLETED", project_id: projectId },
2170
2341
  { headers: { "Authorization": `Bearer ${apiKey}` } }
2171
2342
  );
2172
- console.log(chalk7.green(`\u{1F680} Roadmap updated! Mission Control is in sync.`));
2343
+ console.log(chalk8.green(`\u{1F680} Roadmap updated! Mission Control is in sync.`));
2173
2344
  } catch (err) {
2174
- console.error(chalk7.yellow(`Failed to update roadmap: ${err.message}`));
2345
+ console.error(chalk8.yellow(`Failed to update roadmap: ${err.message}`));
2175
2346
  }
2176
2347
  }
2177
2348
  }
2178
2349
  break;
2179
2350
  } else {
2180
- console.log(chalk7.dim("Skipped."));
2351
+ console.log(chalk8.dim("Skipped."));
2181
2352
  }
2182
2353
  }
2183
2354
  } else {
@@ -2187,11 +2358,11 @@ ${chalk7.bold(relativePath)}: Found ${fixableIssues.length} fixable issues.`);
2187
2358
  }
2188
2359
  }
2189
2360
  spinner.stop();
2190
- console.log(chalk7.bold.green(`
2361
+ console.log(chalk8.bold.green(`
2191
2362
 
2192
2363
  \u{1F680} Fix session complete!`));
2193
2364
  console.log(`Frank fixed ${fixedCount} detected issues.`);
2194
- console.log(chalk7.dim(`Run 'rigstate scan' to verify remaining issues.`));
2365
+ console.log(chalk8.dim(`Run 'rigstate scan' to verify remaining issues.`));
2195
2366
  } catch (error) {
2196
2367
  spinner.fail("Fix session failed");
2197
2368
  console.error(error.message);
@@ -2202,14 +2373,14 @@ ${chalk7.bold(relativePath)}: Found ${fixableIssues.length} fixable issues.`);
2202
2373
  // src/commands/sync.ts
2203
2374
  init_esm_shims();
2204
2375
  init_config();
2205
- import { Command as Command7 } from "commander";
2206
- import chalk11 from "chalk";
2376
+ import { Command as Command8 } from "commander";
2377
+ import chalk12 from "chalk";
2207
2378
  import ora5 from "ora";
2208
2379
  import axios8 from "axios";
2209
- import fs9 from "fs/promises";
2210
- import path10 from "path";
2380
+ import fs10 from "fs/promises";
2381
+ import path11 from "path";
2211
2382
  function createSyncCommand() {
2212
- const sync = new Command7("sync");
2383
+ const sync = new Command8("sync");
2213
2384
  sync.description("Synchronize local state with Rigstate Cloud").option("-p, --project <id>", "Specify Project ID (saves to config automatically)").action(async (options) => {
2214
2385
  const spinner = ora5("Synchronizing project state...").start();
2215
2386
  try {
@@ -2223,8 +2394,8 @@ function createSyncCommand() {
2223
2394
  let projectId = options.project;
2224
2395
  if (!projectId) {
2225
2396
  try {
2226
- const manifestPath = path10.join(process.cwd(), ".rigstate");
2227
- const manifestContent = await fs9.readFile(manifestPath, "utf-8");
2397
+ const manifestPath = path11.join(process.cwd(), ".rigstate");
2398
+ const manifestContent = await fs10.readFile(manifestPath, "utf-8");
2228
2399
  const manifest = JSON.parse(manifestContent);
2229
2400
  if (manifest.project_id) projectId = manifest.project_id;
2230
2401
  } catch (e) {
@@ -2248,31 +2419,31 @@ function createSyncCommand() {
2248
2419
  }
2249
2420
  const { roadmap, project } = response.data.data;
2250
2421
  const timestamp = response.data.timestamp;
2251
- const targetPath = path10.join(process.cwd(), "roadmap.json");
2422
+ const targetPath = path11.join(process.cwd(), "roadmap.json");
2252
2423
  const fileContent = JSON.stringify({
2253
2424
  project,
2254
2425
  last_synced: timestamp,
2255
2426
  roadmap
2256
2427
  }, null, 2);
2257
- await fs9.writeFile(targetPath, fileContent, "utf-8");
2428
+ await fs10.writeFile(targetPath, fileContent, "utf-8");
2258
2429
  try {
2259
- const manifestPath = path10.join(process.cwd(), ".rigstate");
2430
+ const manifestPath = path11.join(process.cwd(), ".rigstate");
2260
2431
  const manifestContent = {
2261
2432
  project_id: projectId,
2262
2433
  project_name: project,
2263
2434
  last_synced: timestamp,
2264
2435
  api_url: apiUrl
2265
2436
  };
2266
- await fs9.writeFile(manifestPath, JSON.stringify(manifestContent, null, 2), "utf-8");
2437
+ await fs10.writeFile(manifestPath, JSON.stringify(manifestContent, null, 2), "utf-8");
2267
2438
  } catch (e) {
2268
2439
  }
2269
- console.log(chalk11.bold("\n\u{1F9E0} Agent Skills Provisioning..."));
2440
+ console.log(chalk12.bold("\n\u{1F9E0} Agent Skills Provisioning..."));
2270
2441
  try {
2271
2442
  const { provisionSkills: provisionSkills2, generateSkillsDiscoveryBlock: generateSkillsDiscoveryBlock2 } = await Promise.resolve().then(() => (init_skills_provisioner(), skills_provisioner_exports));
2272
2443
  const skills = await provisionSkills2(apiUrl, apiKey, projectId, process.cwd());
2273
- const cursorRulesPath = path10.join(process.cwd(), ".cursorrules");
2444
+ const cursorRulesPath = path11.join(process.cwd(), ".cursorrules");
2274
2445
  try {
2275
- let rulesContent = await fs9.readFile(cursorRulesPath, "utf-8");
2446
+ let rulesContent = await fs10.readFile(cursorRulesPath, "utf-8");
2276
2447
  const skillsBlock = generateSkillsDiscoveryBlock2(skills);
2277
2448
  if (rulesContent.includes("<available_skills>")) {
2278
2449
  rulesContent = rulesContent.replace(
@@ -2285,17 +2456,17 @@ function createSyncCommand() {
2285
2456
  rulesContent = rulesContent.slice(0, insertPoint + 3) + "\n\n" + skillsBlock + "\n" + rulesContent.slice(insertPoint + 3);
2286
2457
  }
2287
2458
  }
2288
- await fs9.writeFile(cursorRulesPath, rulesContent, "utf-8");
2289
- console.log(chalk11.dim(` Updated .cursorrules with skills discovery block`));
2459
+ await fs10.writeFile(cursorRulesPath, rulesContent, "utf-8");
2460
+ console.log(chalk12.dim(` Updated .cursorrules with skills discovery block`));
2290
2461
  } catch (e) {
2291
2462
  }
2292
2463
  } catch (e) {
2293
- console.log(chalk11.yellow(` \u26A0 Skills provisioning skipped: ${e.message}`));
2464
+ console.log(chalk12.yellow(` \u26A0 Skills provisioning skipped: ${e.message}`));
2294
2465
  }
2295
2466
  try {
2296
- const logPath = path10.join(process.cwd(), ".rigstate", "logs", "last_execution.json");
2467
+ const logPath = path11.join(process.cwd(), ".rigstate", "logs", "last_execution.json");
2297
2468
  try {
2298
- const logContent = await fs9.readFile(logPath, "utf-8");
2469
+ const logContent = await fs10.readFile(logPath, "utf-8");
2299
2470
  const logData = JSON.parse(logContent);
2300
2471
  if (logData.task_summary) {
2301
2472
  await axios8.post(`${apiUrl}/api/v1/execution-logs`, {
@@ -2305,8 +2476,8 @@ function createSyncCommand() {
2305
2476
  }, {
2306
2477
  headers: { Authorization: `Bearer ${apiKey}` }
2307
2478
  });
2308
- await fs9.unlink(logPath);
2309
- console.log(chalk11.dim(`\u2714 Mission Report uploaded.`));
2479
+ await fs10.unlink(logPath);
2480
+ console.log(chalk12.dim(`\u2714 Mission Report uploaded.`));
2310
2481
  }
2311
2482
  } catch (e) {
2312
2483
  if (e.code !== "ENOENT") {
@@ -2314,12 +2485,12 @@ function createSyncCommand() {
2314
2485
  }
2315
2486
  } catch (e) {
2316
2487
  }
2317
- spinner.succeed(chalk11.green(`Synced ${roadmap.length} roadmap steps for project "${project}"`));
2318
- console.log(chalk11.dim(`Local files updated: roadmap.json`));
2488
+ spinner.succeed(chalk12.green(`Synced ${roadmap.length} roadmap steps for project "${project}"`));
2489
+ console.log(chalk12.dim(`Local files updated: roadmap.json`));
2319
2490
  const { runGuardianWatchdog: runGuardianWatchdog2 } = await Promise.resolve().then(() => (init_watchdog(), watchdog_exports));
2320
2491
  const settings = response.data.data.settings || {};
2321
2492
  await runGuardianWatchdog2(process.cwd(), settings, projectId);
2322
- console.log(chalk11.bold("\n\u{1F4E1} Agent Bridge Heartbeat..."));
2493
+ console.log(chalk12.bold("\n\u{1F4E1} Agent Bridge Heartbeat..."));
2323
2494
  try {
2324
2495
  const bridgeResponse = await axios8.get(`${apiUrl}/api/v1/agent/bridge`, {
2325
2496
  params: { project_id: projectId },
@@ -2330,10 +2501,10 @@ function createSyncCommand() {
2330
2501
  const pending = tasks.filter((t) => t.status === "PENDING");
2331
2502
  const approved = tasks.filter((t) => t.status === "APPROVED");
2332
2503
  if (pending.length > 0 || approved.length > 0) {
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.'));
2504
+ console.log(chalk12.yellow(`\u26A0 Bridge Alert: ${pending.length} pending, ${approved.length} approved tasks found.`));
2505
+ console.log(chalk12.dim('Run "rigstate fix" to process these tasks or ensure your IDE MCP server is active.'));
2335
2506
  } else {
2336
- console.log(chalk11.green("\u2714 Heartbeat healthy. No pending bridge tasks."));
2507
+ console.log(chalk12.green("\u2714 Heartbeat healthy. No pending bridge tasks."));
2337
2508
  }
2338
2509
  const pings = pending.filter((t) => t.proposal?.startsWith("ping"));
2339
2510
  for (const ping of pings) {
@@ -2344,25 +2515,25 @@ function createSyncCommand() {
2344
2515
  }, {
2345
2516
  headers: { Authorization: `Bearer ${apiKey}` }
2346
2517
  });
2347
- console.log(chalk11.cyan(`\u{1F3D3} Pong! Acknowledged heartbeat signal [${ping.id}]`));
2518
+ console.log(chalk12.cyan(`\u{1F3D3} Pong! Acknowledged heartbeat signal [${ping.id}]`));
2348
2519
  }
2349
2520
  }
2350
2521
  } catch (e) {
2351
- console.log(chalk11.yellow(`\u26A0 Could not verify Bridge status: ${e.message}`));
2522
+ console.log(chalk12.yellow(`\u26A0 Could not verify Bridge status: ${e.message}`));
2352
2523
  }
2353
2524
  if (options.project) {
2354
- console.log(chalk11.blue(`Project context saved. Future commands will use this project.`));
2525
+ console.log(chalk12.blue(`Project context saved. Future commands will use this project.`));
2355
2526
  }
2356
2527
  try {
2357
- const migrationDir = path10.join(process.cwd(), "supabase", "migrations");
2358
- const files = await fs9.readdir(migrationDir);
2528
+ const migrationDir = path11.join(process.cwd(), "supabase", "migrations");
2529
+ const files = await fs10.readdir(migrationDir);
2359
2530
  const sqlFiles = files.filter((f) => f.endsWith(".sql")).sort();
2360
2531
  if (sqlFiles.length > 0) {
2361
2532
  const latestMigration = sqlFiles[sqlFiles.length - 1];
2362
- console.log(chalk11.dim(`
2533
+ console.log(chalk12.dim(`
2363
2534
  \u{1F6E1} Migration Guard:`));
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.`));
2535
+ console.log(chalk12.dim(` Latest Local: ${latestMigration}`));
2536
+ console.log(chalk12.yellow(` \u26A0 Ensure DB schema matches this version. CLI cannot verify Remote RLS policies directly.`));
2366
2537
  }
2367
2538
  } catch (e) {
2368
2539
  }
@@ -2374,15 +2545,15 @@ function createSyncCommand() {
2374
2545
  );
2375
2546
  if (vaultResponse.data.success) {
2376
2547
  const vaultContent = vaultResponse.data.data.content || "";
2377
- const localEnvPath = path10.join(process.cwd(), ".env.local");
2548
+ const localEnvPath = path11.join(process.cwd(), ".env.local");
2378
2549
  let localContent = "";
2379
2550
  try {
2380
- localContent = await fs9.readFile(localEnvPath, "utf-8");
2551
+ localContent = await fs10.readFile(localEnvPath, "utf-8");
2381
2552
  } catch (e) {
2382
2553
  }
2383
2554
  if (vaultContent.trim() !== localContent.trim()) {
2384
- console.log(chalk11.bold("\n\u{1F510} Sovereign Foundation (Vault):"));
2385
- console.log(chalk11.yellow(" Status: Drift Detected / Update Available"));
2555
+ console.log(chalk12.bold("\n\u{1F510} Sovereign Foundation (Vault):"));
2556
+ console.log(chalk12.yellow(" Status: Drift Detected / Update Available"));
2386
2557
  const { syncVault } = await import("inquirer").then((m) => m.default.prompt([{
2387
2558
  type: "confirm",
2388
2559
  name: "syncVault",
@@ -2390,25 +2561,25 @@ function createSyncCommand() {
2390
2561
  default: false
2391
2562
  }]));
2392
2563
  if (syncVault) {
2393
- await fs9.writeFile(localEnvPath, vaultContent, "utf-8");
2394
- console.log(chalk11.green(" \u2705 .env.local synchronized with Vault."));
2564
+ await fs10.writeFile(localEnvPath, vaultContent, "utf-8");
2565
+ console.log(chalk12.green(" \u2705 .env.local synchronized with Vault."));
2395
2566
  } else {
2396
- console.log(chalk11.dim(" Skipped vault sync."));
2567
+ console.log(chalk12.dim(" Skipped vault sync."));
2397
2568
  }
2398
2569
  } else {
2399
- console.log(chalk11.dim("\n\u{1F510} Sovereign Foundation: Synced."));
2570
+ console.log(chalk12.dim("\n\u{1F510} Sovereign Foundation: Synced."));
2400
2571
  }
2401
2572
  }
2402
2573
  } catch (e) {
2403
2574
  }
2404
- console.log(chalk11.dim("\n\u{1F6E1}\uFE0F System Integrity Check..."));
2575
+ console.log(chalk12.dim("\n\u{1F6E1}\uFE0F System Integrity Check..."));
2405
2576
  await checkSystemIntegrity(apiUrl, apiKey, projectId);
2406
2577
  } catch (error) {
2407
2578
  if (axios8.isAxiosError(error)) {
2408
2579
  const message = error.response?.data?.error || error.message;
2409
- spinner.fail(chalk11.red(`Sync failed: ${message}`));
2580
+ spinner.fail(chalk12.red(`Sync failed: ${message}`));
2410
2581
  } else {
2411
- spinner.fail(chalk11.red("Sync failed: " + (error.message || "Unknown error")));
2582
+ spinner.fail(chalk12.red("Sync failed: " + (error.message || "Unknown error")));
2412
2583
  }
2413
2584
  }
2414
2585
  });
@@ -2424,57 +2595,57 @@ async function checkSystemIntegrity(apiUrl, apiKey, projectId) {
2424
2595
  const { migrations, rls, guardian_violations } = response.data.data;
2425
2596
  if (migrations) {
2426
2597
  if (migrations.in_sync) {
2427
- console.log(chalk11.green(` \u2705 Migrations synced (${migrations.count} versions)`));
2598
+ console.log(chalk12.green(` \u2705 Migrations synced (${migrations.count} versions)`));
2428
2599
  } else {
2429
- console.log(chalk11.red(` \u{1F6D1} CRITICAL: DB Schema out of sync! ${migrations.missing?.length || 0} migrations not applied.`));
2600
+ console.log(chalk12.red(` \u{1F6D1} CRITICAL: DB Schema out of sync! ${migrations.missing?.length || 0} migrations not applied.`));
2430
2601
  if (migrations.missing?.length > 0) {
2431
- console.log(chalk11.dim(` Missing: ${migrations.missing.slice(0, 3).join(", ")}${migrations.missing.length > 3 ? "..." : ""}`));
2602
+ console.log(chalk12.dim(` Missing: ${migrations.missing.slice(0, 3).join(", ")}${migrations.missing.length > 3 ? "..." : ""}`));
2432
2603
  }
2433
- console.log(chalk11.yellow(` Run 'supabase db push' or apply migrations immediately.`));
2604
+ console.log(chalk12.yellow(` Run 'supabase db push' or apply migrations immediately.`));
2434
2605
  }
2435
2606
  }
2436
2607
  if (rls) {
2437
2608
  if (rls.all_secured) {
2438
- console.log(chalk11.green(` \u2705 RLS Audit Passed (${rls.table_count} tables secured)`));
2609
+ console.log(chalk12.green(` \u2705 RLS Audit Passed (${rls.table_count} tables secured)`));
2439
2610
  } else {
2440
- console.log(chalk11.red(` \u{1F6D1} CRITICAL: Security Vulnerability! ${rls.unsecured?.length || 0} tables have RLS disabled.`));
2611
+ console.log(chalk12.red(` \u{1F6D1} CRITICAL: Security Vulnerability! ${rls.unsecured?.length || 0} tables have RLS disabled.`));
2441
2612
  rls.unsecured?.forEach((table) => {
2442
- console.log(chalk11.red(` - ${table}`));
2613
+ console.log(chalk12.red(` - ${table}`));
2443
2614
  });
2444
- console.log(chalk11.yellow(' Enable RLS immediately: ALTER TABLE "table" ENABLE ROW LEVEL SECURITY;'));
2615
+ console.log(chalk12.yellow(' Enable RLS immediately: ALTER TABLE "table" ENABLE ROW LEVEL SECURITY;'));
2445
2616
  }
2446
2617
  }
2447
2618
  if (guardian_violations) {
2448
2619
  if (guardian_violations.count === 0) {
2449
- console.log(chalk11.green(" \u2705 Guardian: No active violations"));
2620
+ console.log(chalk12.green(" \u2705 Guardian: No active violations"));
2450
2621
  } else {
2451
- console.log(chalk11.yellow(` \u26A0\uFE0F Guardian: ${guardian_violations.count} active violations`));
2452
- console.log(chalk11.dim(' Run "rigstate check" for details.'));
2622
+ console.log(chalk12.yellow(` \u26A0\uFE0F Guardian: ${guardian_violations.count} active violations`));
2623
+ console.log(chalk12.dim(' Run "rigstate check" for details.'));
2453
2624
  }
2454
2625
  }
2455
2626
  }
2456
2627
  } catch (e) {
2457
- console.log(chalk11.dim(" (System integrity check skipped - API endpoint not available)"));
2628
+ console.log(chalk12.dim(" (System integrity check skipped - API endpoint not available)"));
2458
2629
  }
2459
2630
  }
2460
2631
 
2461
2632
  // src/commands/init.ts
2462
2633
  init_esm_shims();
2463
- import { Command as Command8 } from "commander";
2464
- import chalk12 from "chalk";
2465
- import fs11 from "fs/promises";
2466
- import path12 from "path";
2634
+ import { Command as Command9 } from "commander";
2635
+ import chalk13 from "chalk";
2636
+ import fs12 from "fs/promises";
2637
+ import path13 from "path";
2467
2638
  import ora6 from "ora";
2468
2639
  import { execSync } from "child_process";
2469
2640
 
2470
2641
  // src/utils/manifest.ts
2471
2642
  init_esm_shims();
2472
- import fs10 from "fs/promises";
2473
- import path11 from "path";
2643
+ import fs11 from "fs/promises";
2644
+ import path12 from "path";
2474
2645
  async function loadManifest() {
2475
2646
  try {
2476
- const manifestPath = path11.join(process.cwd(), ".rigstate");
2477
- const content = await fs10.readFile(manifestPath, "utf-8");
2647
+ const manifestPath = path12.join(process.cwd(), ".rigstate");
2648
+ const content = await fs11.readFile(manifestPath, "utf-8");
2478
2649
  return JSON.parse(content);
2479
2650
  } catch {
2480
2651
  return null;
@@ -2485,13 +2656,13 @@ async function loadManifest() {
2485
2656
  init_config();
2486
2657
  import axios9 from "axios";
2487
2658
  function createInitCommand() {
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) => {
2659
+ 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) => {
2489
2660
  const spinner = ora6("Initializing Rigstate project...").start();
2490
2661
  let apiKey;
2491
2662
  try {
2492
2663
  apiKey = getApiKey();
2493
2664
  } catch (e) {
2494
- spinner.fail(chalk12.red('Not authenticated. Run "rigstate login" first.'));
2665
+ spinner.fail(chalk13.red('Not authenticated. Run "rigstate login" first.'));
2495
2666
  return;
2496
2667
  }
2497
2668
  const apiUrl = getApiUrl();
@@ -2588,7 +2759,7 @@ function createInitCommand() {
2588
2759
  selectedOrgId = orgId;
2589
2760
  }
2590
2761
  if (!selectedOrgId) {
2591
- console.log(chalk12.yellow("No organization available. Please create the project via the Rigstate dashboard."));
2762
+ console.log(chalk13.yellow("No organization available. Please create the project via the Rigstate dashboard."));
2592
2763
  return;
2593
2764
  }
2594
2765
  spinner.start("Creating new project...");
@@ -2600,13 +2771,13 @@ function createInitCommand() {
2600
2771
  headers: { Authorization: `Bearer ${apiKey}` }
2601
2772
  });
2602
2773
  if (!createResponse.data.success) {
2603
- spinner.fail(chalk12.red("Failed to create project: " + createResponse.data.error));
2774
+ spinner.fail(chalk13.red("Failed to create project: " + createResponse.data.error));
2604
2775
  return;
2605
2776
  }
2606
2777
  projectId = createResponse.data.data.project.id;
2607
- spinner.succeed(chalk12.green(`Created new project: ${newName}`));
2778
+ spinner.succeed(chalk13.green(`Created new project: ${newName}`));
2608
2779
  } catch (e) {
2609
- spinner.fail(chalk12.red("Project creation API not available. Please create via dashboard."));
2780
+ spinner.fail(chalk13.red("Project creation API not available. Please create via dashboard."));
2610
2781
  return;
2611
2782
  }
2612
2783
  } else {
@@ -2616,28 +2787,28 @@ function createInitCommand() {
2616
2787
  spinner.start(`Linking to project ID: ${projectId}...`);
2617
2788
  }
2618
2789
  setProjectId(projectId);
2619
- const manifestPath = path12.join(process.cwd(), ".rigstate");
2790
+ const manifestPath = path13.join(process.cwd(), ".rigstate");
2620
2791
  const manifestContent = {
2621
2792
  project_id: projectId,
2622
2793
  last_linked: (/* @__PURE__ */ new Date()).toISOString(),
2623
2794
  api_url: apiUrl
2624
2795
  };
2625
- await fs11.writeFile(manifestPath, JSON.stringify(manifestContent, null, 2), "utf-8");
2796
+ await fs12.writeFile(manifestPath, JSON.stringify(manifestContent, null, 2), "utf-8");
2626
2797
  try {
2627
- await fs11.access(".git");
2798
+ await fs12.access(".git");
2628
2799
  } catch {
2629
2800
  spinner.text = "Initializing git repository...";
2630
2801
  execSync("git init", { stdio: "ignore" });
2631
2802
  }
2632
- spinner.succeed(chalk12.green(`\u2705 Linked to project: ${projectId}`));
2803
+ spinner.succeed(chalk13.green(`\u2705 Linked to project: ${projectId}`));
2633
2804
  await generateRules(apiUrl, apiKey, projectId, options.force, spinner);
2634
2805
  console.log("");
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"));
2806
+ console.log(chalk13.blue("Next steps:"));
2807
+ console.log(chalk13.dim(" rigstate sync - Sync roadmap and context"));
2808
+ console.log(chalk13.dim(" rigstate watch - Start development loop"));
2809
+ console.log(chalk13.dim(" rigstate focus - Get current task"));
2639
2810
  } catch (e) {
2640
- spinner.fail(chalk12.red("Initialization failed: " + e.message));
2811
+ spinner.fail(chalk13.red("Initialization failed: " + e.message));
2641
2812
  }
2642
2813
  });
2643
2814
  }
@@ -2652,67 +2823,67 @@ async function generateRules(apiUrl, apiKey, projectId, force, spinner) {
2652
2823
  if (response.data.success || response.data.files) {
2653
2824
  const files = response.data.files || [];
2654
2825
  if (files.length === 0 && response.data.rules) {
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)"));
2826
+ const rulesPath = path13.join(process.cwd(), ".cursorrules");
2827
+ await fs12.writeFile(rulesPath, response.data.rules, "utf-8");
2828
+ spinner.succeed(chalk13.green("\u2714 Generated .cursorrules (legacy mode)"));
2658
2829
  return;
2659
2830
  }
2660
2831
  for (const file of files) {
2661
- const targetPath = path12.join(process.cwd(), file.path);
2662
- const targetDir = path12.dirname(targetPath);
2663
- await fs11.mkdir(targetDir, { recursive: true });
2832
+ const targetPath = path13.join(process.cwd(), file.path);
2833
+ const targetDir = path13.dirname(targetPath);
2834
+ await fs12.mkdir(targetDir, { recursive: true });
2664
2835
  try {
2665
- await fs11.access(targetPath);
2836
+ await fs12.access(targetPath);
2666
2837
  if (!force && !file.path.startsWith(".cursor/rules/")) {
2667
- console.log(chalk12.dim(` ${file.path} already exists. Skipping.`));
2838
+ console.log(chalk13.dim(` ${file.path} already exists. Skipping.`));
2668
2839
  continue;
2669
2840
  }
2670
2841
  } catch {
2671
2842
  }
2672
- await fs11.writeFile(targetPath, file.content, "utf-8");
2843
+ await fs12.writeFile(targetPath, file.content, "utf-8");
2673
2844
  }
2674
2845
  if (files.length > 0) {
2675
- const legacyPath = path12.join(process.cwd(), ".cursorrules");
2846
+ const legacyPath = path13.join(process.cwd(), ".cursorrules");
2676
2847
  try {
2677
- const stats = await fs11.stat(legacyPath);
2848
+ const stats = await fs12.stat(legacyPath);
2678
2849
  if (stats.isFile()) {
2679
- await fs11.rename(legacyPath, `${legacyPath}.bak`);
2680
- console.log(chalk12.dim(" Moved legacy .cursorrules to .cursorrules.bak"));
2850
+ await fs12.rename(legacyPath, `${legacyPath}.bak`);
2851
+ console.log(chalk13.dim(" Moved legacy .cursorrules to .cursorrules.bak"));
2681
2852
  }
2682
2853
  } catch (e) {
2683
2854
  }
2684
2855
  }
2685
- spinner.succeed(chalk12.green(`\u2714 Generated ${files.length} rule files (v${response.data.version || "3.0"})`));
2856
+ spinner.succeed(chalk13.green(`\u2714 Generated ${files.length} rule files (v${response.data.version || "3.0"})`));
2686
2857
  } else {
2687
- spinner.info(chalk12.dim(" Rules generation skipped (API response invalid)"));
2858
+ spinner.info(chalk13.dim(" Rules generation skipped (API response invalid)"));
2688
2859
  }
2689
2860
  } catch (e) {
2690
- spinner.info(chalk12.dim(` Rules generation failed: ${e.message}`));
2861
+ spinner.info(chalk13.dim(` Rules generation failed: ${e.message}`));
2691
2862
  }
2692
2863
  }
2693
2864
 
2694
2865
  // src/commands/check.ts
2695
2866
  init_esm_shims();
2696
2867
  init_config();
2697
- import { Command as Command9 } from "commander";
2698
- import chalk14 from "chalk";
2868
+ import { Command as Command10 } from "commander";
2869
+ import chalk15 from "chalk";
2699
2870
  import ora7 from "ora";
2700
2871
  import axios10 from "axios";
2701
2872
  import { glob as glob3 } from "glob";
2702
- import fs13 from "fs/promises";
2703
- import path14 from "path";
2873
+ import fs14 from "fs/promises";
2874
+ import path15 from "path";
2704
2875
  import { execSync as execSync2 } from "child_process";
2705
2876
 
2706
2877
  // src/utils/rule-engine.ts
2707
2878
  init_esm_shims();
2708
- import fs12 from "fs/promises";
2709
- import path13 from "path";
2710
- import chalk13 from "chalk";
2879
+ import fs13 from "fs/promises";
2880
+ import path14 from "path";
2881
+ import chalk14 from "chalk";
2711
2882
  async function checkFile(filePath, rules, rootPath) {
2712
2883
  const violations = [];
2713
- const relativePath = path13.relative(rootPath, filePath);
2884
+ const relativePath = path14.relative(rootPath, filePath);
2714
2885
  try {
2715
- const content = await fs12.readFile(filePath, "utf-8");
2886
+ const content = await fs13.readFile(filePath, "utf-8");
2716
2887
  const lines = content.split("\n");
2717
2888
  for (const rule of rules) {
2718
2889
  const ruleViolations = await evaluateRule(rule, content, lines, relativePath);
@@ -2803,7 +2974,7 @@ async function evaluateRule(rule, content, lines, filePath) {
2803
2974
  case "NAMING_CONVENTION": {
2804
2975
  const value = rule.value;
2805
2976
  const pattern = new RegExp(value.pattern);
2806
- const fileName = path13.basename(filePath);
2977
+ const fileName = path14.basename(filePath);
2807
2978
  if (filePath.includes(value.context) && !pattern.test(fileName)) {
2808
2979
  violations.push({
2809
2980
  file: filePath,
@@ -2862,12 +3033,12 @@ function checkFunctionLines(content, lines, filePath, rule, limit) {
2862
3033
  }
2863
3034
  function formatViolations(violations) {
2864
3035
  for (const v of violations) {
2865
- const severityColor = v.severity === "critical" ? chalk13.red : v.severity === "warning" ? chalk13.yellow : chalk13.blue;
2866
- const lineInfo = v.line ? chalk13.dim(`:${v.line}`) : "";
3036
+ const severityColor = v.severity === "critical" ? chalk14.red : v.severity === "warning" ? chalk14.yellow : chalk14.blue;
3037
+ const lineInfo = v.line ? chalk14.dim(`:${v.line}`) : "";
2867
3038
  console.log(` ${severityColor(`[${v.severity.toUpperCase()}]`)} ${v.file}${lineInfo}`);
2868
3039
  console.log(` ${v.message}`);
2869
3040
  if (v.details) {
2870
- console.log(` ${chalk13.dim(v.details)}`);
3041
+ console.log(` ${chalk14.dim(v.details)}`);
2871
3042
  }
2872
3043
  }
2873
3044
  }
@@ -2896,7 +3067,7 @@ var CACHE_FILE2 = ".rigstate/rules-cache.json";
2896
3067
  var CACHE_TTL_MS = 5 * 60 * 1e3;
2897
3068
  var CACHE_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
2898
3069
  function createCheckCommand() {
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) => {
3070
+ 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) => {
2900
3071
  const spinner = ora7();
2901
3072
  try {
2902
3073
  let projectId = options.project;
@@ -2912,15 +3083,15 @@ function createCheckCommand() {
2912
3083
  projectId = getProjectId();
2913
3084
  }
2914
3085
  if (!projectId) {
2915
- console.log(chalk14.red("\u274C No project context found."));
2916
- console.log(chalk14.dim(' Run "rigstate link" or pass --project <id>'));
3086
+ console.log(chalk15.red("\u274C No project context found."));
3087
+ console.log(chalk15.dim(' Run "rigstate link" or pass --project <id>'));
2917
3088
  process.exit(2);
2918
3089
  }
2919
3090
  let apiKey;
2920
3091
  try {
2921
3092
  apiKey = getApiKey();
2922
3093
  } catch {
2923
- console.log(chalk14.red('\u274C Not authenticated. Run "rigstate login" first.'));
3094
+ console.log(chalk15.red('\u274C Not authenticated. Run "rigstate login" first.'));
2924
3095
  process.exit(2);
2925
3096
  }
2926
3097
  spinner.start("Fetching Guardian rules...");
@@ -2948,17 +3119,17 @@ function createCheckCommand() {
2948
3119
  } catch (apiError) {
2949
3120
  const cached = await loadCachedRules(projectId);
2950
3121
  if (cached && !isStale(cached.timestamp, CACHE_MAX_AGE_MS)) {
2951
- spinner.warn(chalk14.yellow("Using cached rules (API unavailable)"));
3122
+ spinner.warn(chalk15.yellow("Using cached rules (API unavailable)"));
2952
3123
  rules = cached.rules;
2953
3124
  settings = cached.settings;
2954
3125
  } else {
2955
- spinner.fail(chalk14.red("Failed to fetch rules and no valid cache"));
2956
- console.log(chalk14.dim(` Error: ${apiError.message}`));
3126
+ spinner.fail(chalk15.red("Failed to fetch rules and no valid cache"));
3127
+ console.log(chalk15.dim(` Error: ${apiError.message}`));
2957
3128
  process.exit(2);
2958
3129
  }
2959
3130
  }
2960
3131
  spinner.succeed(`Loaded ${rules.length} Guardian rules`);
2961
- const scanPath = path14.resolve(process.cwd(), targetPath);
3132
+ const scanPath = path15.resolve(process.cwd(), targetPath);
2962
3133
  let filesToCheck;
2963
3134
  if (options.staged) {
2964
3135
  spinner.start("Getting staged files...");
@@ -2967,14 +3138,14 @@ function createCheckCommand() {
2967
3138
  encoding: "utf-8",
2968
3139
  cwd: process.cwd()
2969
3140
  });
2970
- filesToCheck = stagedOutput.split("\n").filter((f) => f.trim()).filter((f) => isCodeFile2(f)).map((f) => path14.resolve(process.cwd(), f));
3141
+ filesToCheck = stagedOutput.split("\n").filter((f) => f.trim()).filter((f) => isCodeFile2(f)).map((f) => path15.resolve(process.cwd(), f));
2971
3142
  } catch {
2972
3143
  spinner.fail("Not a git repository or no staged files");
2973
3144
  process.exit(2);
2974
3145
  }
2975
3146
  } else {
2976
- spinner.start(`Scanning ${chalk14.cyan(targetPath)}...`);
2977
- const pattern = path14.join(scanPath, "**/*");
3147
+ spinner.start(`Scanning ${chalk15.cyan(targetPath)}...`);
3148
+ const pattern = path15.join(scanPath, "**/*");
2978
3149
  const allFiles = await glob3(pattern, {
2979
3150
  nodir: true,
2980
3151
  dot: false,
@@ -2990,7 +3161,7 @@ function createCheckCommand() {
2990
3161
  filesToCheck = allFiles.filter((f) => isCodeFile2(f));
2991
3162
  }
2992
3163
  if (filesToCheck.length === 0) {
2993
- spinner.warn(chalk14.yellow("No code files found to check."));
3164
+ spinner.warn(chalk15.yellow("No code files found to check."));
2994
3165
  outputResults([], !!options.json);
2995
3166
  process.exit(0);
2996
3167
  }
@@ -2999,7 +3170,7 @@ function createCheckCommand() {
2999
3170
  const results = [];
3000
3171
  for (let i = 0; i < filesToCheck.length; i++) {
3001
3172
  const file = filesToCheck[i];
3002
- spinner.text = `Checking ${i + 1}/${filesToCheck.length}: ${path14.basename(file)}`;
3173
+ spinner.text = `Checking ${i + 1}/${filesToCheck.length}: ${path15.basename(file)}`;
3003
3174
  const result = await checkFile(file, rules, process.cwd());
3004
3175
  results.push(result);
3005
3176
  }
@@ -3009,47 +3180,47 @@ function createCheckCommand() {
3009
3180
  outputResults(results, true);
3010
3181
  } else {
3011
3182
  outputResults(results, false);
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)}`);
3183
+ console.log("\n" + chalk15.bold("\u{1F4CA} Summary"));
3184
+ console.log(chalk15.dim("\u2500".repeat(50)));
3185
+ console.log(`Files checked: ${chalk15.cyan(summary.totalFiles)}`);
3186
+ console.log(`Total violations: ${summary.totalViolations > 0 ? chalk15.red(summary.totalViolations) : chalk15.green(0)}`);
3016
3187
  if (summary.totalViolations > 0) {
3017
- console.log(` ${chalk14.red("Critical:")} ${summary.criticalCount}`);
3018
- console.log(` ${chalk14.yellow("Warning:")} ${summary.warningCount}`);
3019
- console.log(` ${chalk14.blue("Info:")} ${summary.infoCount}`);
3188
+ console.log(` ${chalk15.red("Critical:")} ${summary.criticalCount}`);
3189
+ console.log(` ${chalk15.yellow("Warning:")} ${summary.warningCount}`);
3190
+ console.log(` ${chalk15.blue("Info:")} ${summary.infoCount}`);
3020
3191
  }
3021
- console.log(chalk14.dim("\u2500".repeat(50)));
3192
+ console.log(chalk15.dim("\u2500".repeat(50)));
3022
3193
  }
3023
3194
  if (options.strict !== void 0) {
3024
3195
  const strictLevel = typeof options.strict === "string" ? options.strict : "all";
3025
3196
  if (strictLevel === "critical" && summary.criticalCount > 0) {
3026
- console.log(chalk14.red("\n\u274C Check failed: Critical violations found"));
3197
+ console.log(chalk15.red("\n\u274C Check failed: Critical violations found"));
3027
3198
  process.exit(1);
3028
3199
  } else if (strictLevel === "all" && summary.totalViolations > 0) {
3029
- console.log(chalk14.red("\n\u274C Check failed: Violations found"));
3200
+ console.log(chalk15.red("\n\u274C Check failed: Violations found"));
3030
3201
  process.exit(1);
3031
3202
  }
3032
3203
  }
3033
3204
  if (summary.totalViolations === 0) {
3034
- console.log(chalk14.green("\n\u2705 All checks passed!"));
3205
+ console.log(chalk15.green("\n\u2705 All checks passed!"));
3035
3206
  }
3036
3207
  process.exit(0);
3037
3208
  } catch (error) {
3038
- spinner.fail(chalk14.red("Check failed"));
3039
- console.error(chalk14.red("Error:"), error.message);
3209
+ spinner.fail(chalk15.red("Check failed"));
3210
+ console.error(chalk15.red("Error:"), error.message);
3040
3211
  process.exit(2);
3041
3212
  }
3042
3213
  });
3043
3214
  }
3044
3215
  function isCodeFile2(filePath) {
3045
3216
  const codeExtensions = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
3046
- const ext = path14.extname(filePath).toLowerCase();
3217
+ const ext = path15.extname(filePath).toLowerCase();
3047
3218
  return codeExtensions.includes(ext);
3048
3219
  }
3049
3220
  async function loadCachedRules(projectId) {
3050
3221
  try {
3051
- const cachePath = path14.join(process.cwd(), CACHE_FILE2);
3052
- const content = await fs13.readFile(cachePath, "utf-8");
3222
+ const cachePath = path15.join(process.cwd(), CACHE_FILE2);
3223
+ const content = await fs14.readFile(cachePath, "utf-8");
3053
3224
  const cached = JSON.parse(content);
3054
3225
  if (cached.projectId !== projectId) {
3055
3226
  return null;
@@ -3061,16 +3232,16 @@ async function loadCachedRules(projectId) {
3061
3232
  }
3062
3233
  async function saveCachedRules(projectId, rules, settings) {
3063
3234
  try {
3064
- const cacheDir = path14.join(process.cwd(), ".rigstate");
3065
- await fs13.mkdir(cacheDir, { recursive: true });
3235
+ const cacheDir = path15.join(process.cwd(), ".rigstate");
3236
+ await fs14.mkdir(cacheDir, { recursive: true });
3066
3237
  const cached = {
3067
3238
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
3068
3239
  projectId,
3069
3240
  rules,
3070
3241
  settings
3071
3242
  };
3072
- await fs13.writeFile(
3073
- path14.join(cacheDir, "rules-cache.json"),
3243
+ await fs14.writeFile(
3244
+ path15.join(cacheDir, "rules-cache.json"),
3074
3245
  JSON.stringify(cached, null, 2)
3075
3246
  );
3076
3247
  } catch {
@@ -3081,155 +3252,36 @@ function isStale(timestamp, maxAge) {
3081
3252
  return age > maxAge;
3082
3253
  }
3083
3254
  function outputResults(results, json) {
3084
- if (json) {
3085
- console.log(JSON.stringify({
3086
- results,
3087
- summary: summarizeResults(results)
3088
- }, null, 2));
3089
- return;
3090
- }
3091
- const hasViolations = results.some((r) => r.violations.length > 0);
3092
- if (!hasViolations) {
3093
- return;
3094
- }
3095
- console.log("\n" + chalk14.bold("\u{1F50D} Violations Found"));
3096
- console.log(chalk14.dim("\u2500".repeat(50)));
3097
- for (const result of results) {
3098
- if (result.violations.length > 0) {
3099
- formatViolations(result.violations);
3100
- }
3101
- }
3102
- }
3103
-
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);
3255
+ if (json) {
3256
+ console.log(JSON.stringify({
3257
+ results,
3258
+ summary: summarizeResults(results)
3259
+ }, null, 2));
3260
+ return;
3261
+ }
3262
+ const hasViolations = results.some((r) => r.violations.length > 0);
3263
+ if (!hasViolations) {
3264
+ return;
3265
+ }
3266
+ console.log("\n" + chalk15.bold("\u{1F50D} Violations Found"));
3267
+ console.log(chalk15.dim("\u2500".repeat(50)));
3268
+ for (const result of results) {
3269
+ if (result.violations.length > 0) {
3270
+ formatViolations(result.violations);
3219
3271
  }
3220
- });
3221
- return hooks;
3272
+ }
3222
3273
  }
3223
3274
 
3275
+ // src/index.ts
3276
+ init_hooks();
3277
+
3224
3278
  // src/commands/daemon.ts
3225
3279
  init_esm_shims();
3226
3280
  import { Command as Command11 } from "commander";
3227
- import chalk20 from "chalk";
3281
+ import chalk21 from "chalk";
3228
3282
  import ora8 from "ora";
3229
- import fs18 from "fs/promises";
3230
- import path21 from "path";
3231
- import { execSync as execSync3 } from "child_process";
3232
- import { fileURLToPath as fileURLToPath2 } from "url";
3283
+ import fs19 from "fs/promises";
3284
+ import path22 from "path";
3233
3285
 
3234
3286
  // src/daemon/factory.ts
3235
3287
  init_esm_shims();
@@ -3929,7 +3981,7 @@ var GuardianDaemon = class extends EventEmitter3 {
3929
3981
  setupFileWatcher() {
3930
3982
  Logger.info("Starting file watcher...");
3931
3983
  this.fileWatcher = createFileWatcher(this.config.watchPath);
3932
- this.fileWatcher.on("change", (path26) => this.handleFileChange(path26));
3984
+ this.fileWatcher.on("change", (path27) => this.handleFileChange(path27));
3933
3985
  this.fileWatcher.start();
3934
3986
  Logger.info("File watcher active");
3935
3987
  }
@@ -3963,6 +4015,7 @@ var GuardianDaemon = class extends EventEmitter3 {
3963
4015
  this.emit("skill:suggestion", match);
3964
4016
  }
3965
4017
  }
4018
+ violationsMap = /* @__PURE__ */ new Map();
3966
4019
  async runIntegrityCheck(filePath) {
3967
4020
  if (!this.guardianMonitor) return;
3968
4021
  if (this.interventionProtocol) this.interventionProtocol.clear(filePath);
@@ -3971,24 +4024,37 @@ var GuardianDaemon = class extends EventEmitter3 {
3971
4024
  if (result.violations.length > 0) {
3972
4025
  this.handleViolations(filePath, result.violations);
3973
4026
  } else {
3974
- await this.updateViolationReport([]);
4027
+ if (this.violationsMap.has(filePath)) {
4028
+ this.violationsMap.delete(filePath);
4029
+ this.updateViolationReport();
4030
+ }
3975
4031
  }
3976
4032
  }
3977
4033
  async updateViolationReport(violations) {
3978
4034
  const reportPath = path20.join(process.cwd(), ".rigstate", "ACTIVE_VIOLATIONS.md");
3979
- let content = `# \u{1F6E1}\uFE0F Guardian Status: ${violations.length > 0 ? "\u26A0\uFE0F ATTENTION" : "\u2705 PASS"}
4035
+ const allViolations = Array.from(this.violationsMap.entries());
4036
+ const totalCount = allViolations.reduce((acc, [, v]) => acc + v.length, 0);
4037
+ let content = `# \u{1F6E1}\uFE0F Guardian Status: ${totalCount > 0 ? "\u26A0\uFE0F ATTENTION" : "\u2705 PASS"}
3980
4038
 
3981
4039
  `;
3982
4040
  content += `*Last check: ${(/* @__PURE__ */ new Date()).toLocaleString()}*
4041
+ `;
4042
+ content += `*Files with issues: ${allViolations.length}*
3983
4043
 
3984
4044
  `;
3985
- if (violations.length === 0) {
4045
+ if (totalCount === 0) {
3986
4046
  content += "All systems within architectural limits. Frank is satisfied. \u{1F92B}\n";
3987
4047
  } else {
3988
4048
  content += "### \u{1F6A8} Active Violations\n\n";
3989
- for (const v of violations) {
3990
- content += `- **[${v.severity.toUpperCase()}]**: ${v.message}
4049
+ for (const [file, fileViolations] of allViolations) {
4050
+ const relPath = path20.relative(process.cwd(), file);
4051
+ content += `#### \u{1F4C4} ${relPath}
4052
+ `;
4053
+ for (const v of fileViolations) {
4054
+ content += `- **[${v.severity.toUpperCase()}]**: ${v.message}
3991
4055
  `;
4056
+ }
4057
+ content += "\n";
3992
4058
  }
3993
4059
  content += "\n---\n*Rigstate Daemon is watching. Fix violations to clear this report.*";
3994
4060
  }
@@ -4000,7 +4066,8 @@ var GuardianDaemon = class extends EventEmitter3 {
4000
4066
  handleViolations(filePath, violations) {
4001
4067
  this.state.violationsFound += violations.length;
4002
4068
  this.emit("violation", { file: filePath, violations });
4003
- this.updateViolationReport(violations);
4069
+ this.violationsMap.set(filePath, violations);
4070
+ this.updateViolationReport();
4004
4071
  for (const v of violations) {
4005
4072
  const level = v.severity === "critical" ? "error" : v.severity === "warning" ? "warn" : "info";
4006
4073
  Logger[level](`[${v.severity.toUpperCase()}] ${filePath}: ${v.message}`);
@@ -4067,6 +4134,102 @@ async function createDaemon(options) {
4067
4134
  return new GuardianDaemon(config2);
4068
4135
  }
4069
4136
 
4137
+ // src/utils/service-manager.ts
4138
+ init_esm_shims();
4139
+ import chalk20 from "chalk";
4140
+ import fs18 from "fs/promises";
4141
+ import path21 from "path";
4142
+ import { execSync as execSync3 } from "child_process";
4143
+ import { fileURLToPath as fileURLToPath2 } from "url";
4144
+ async function execShellCommand(cmd) {
4145
+ try {
4146
+ const output = execSync3(cmd, { stdio: "pipe" }).toString();
4147
+ return output;
4148
+ } catch (error) {
4149
+ return error.stderr?.toString() || error.stdout?.toString() || error.message;
4150
+ }
4151
+ }
4152
+ async function enableDaemon() {
4153
+ console.log(chalk20.bold("\n\u2699\uFE0F Enabling Rigstate Background Service (macOS)\n"));
4154
+ if (process.platform !== "darwin") {
4155
+ console.error(chalk20.red("\u274C Currently only macOS is supported for auto-start."));
4156
+ console.error(chalk20.yellow("PRs welcome for Linux/Windows support!"));
4157
+ return;
4158
+ }
4159
+ const homeDir = process.env.HOME || "";
4160
+ if (!homeDir) {
4161
+ console.error(chalk20.red("\u274C Could not determine HOME directory."));
4162
+ return;
4163
+ }
4164
+ const agentsDir = path21.join(homeDir, "Library/LaunchAgents");
4165
+ const logDir = path21.join(homeDir, ".rigstate/logs");
4166
+ const plistPath = path21.join(agentsDir, "com.rigstate.daemon.plist");
4167
+ await fs18.mkdir(agentsDir, { recursive: true });
4168
+ await fs18.mkdir(logDir, { recursive: true });
4169
+ const scriptPath = fileURLToPath2(import.meta.url);
4170
+ const nodePath = process.execPath;
4171
+ const plistContent = `<?xml version="1.0" encoding="UTF-8"?>
4172
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
4173
+ <plist version="1.0">
4174
+ <dict>
4175
+ <key>Label</key>
4176
+ <string>com.rigstate.daemon</string>
4177
+ <key>ProgramArguments</key>
4178
+ <array>
4179
+ <string>${nodePath}</string>
4180
+ <string>${scriptPath}</string>
4181
+ <string>daemon</string>
4182
+ <string>--no-bridge</string>
4183
+ </array>
4184
+ <key>WorkingDirectory</key>
4185
+ <string>${process.cwd()}</string>
4186
+ <key>StandardOutPath</key>
4187
+ <string>${path21.join(logDir, "daemon.out.log")}</string>
4188
+ <key>StandardErrorPath</key>
4189
+ <string>${path21.join(logDir, "daemon.err.log")}</string>
4190
+ <key>RunAtLoad</key>
4191
+ <true/>
4192
+ <key>KeepAlive</key>
4193
+ <true/>
4194
+ <key>EnvironmentVariables</key>
4195
+ <dict>
4196
+ <key>PATH</key>
4197
+ <string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:${process.env.PATH}</string>
4198
+ </dict>
4199
+ </dict>
4200
+ </plist>`;
4201
+ try {
4202
+ await fs18.writeFile(plistPath, plistContent);
4203
+ console.log(chalk20.dim(`Created plist at: ${plistPath}`));
4204
+ try {
4205
+ await execShellCommand(`launchctl unload ${plistPath}`);
4206
+ } catch (e) {
4207
+ }
4208
+ await execShellCommand(`launchctl load ${plistPath}`);
4209
+ console.log(chalk20.green("\u2705 Successfully enabled background daemon!"));
4210
+ console.log(chalk20.dim(`Logs: ${logDir}`));
4211
+ console.log(chalk20.dim("The daemon will now restart automatically if it crashes or on reboot."));
4212
+ } catch (error) {
4213
+ console.error(chalk20.red("\u274C Failed to enable daemon:"), error.message);
4214
+ }
4215
+ }
4216
+ async function disableDaemon() {
4217
+ console.log(chalk20.bold("\n\u2699\uFE0F Disabling Rigstate Background Service\n"));
4218
+ const homeDir = process.env.HOME || "";
4219
+ const plistPath = path21.join(homeDir, "Library/LaunchAgents/com.rigstate.daemon.plist");
4220
+ try {
4221
+ await execShellCommand(`launchctl unload ${plistPath}`);
4222
+ await fs18.unlink(plistPath);
4223
+ console.log(chalk20.green("\u2705 Successfully disabled background daemon."));
4224
+ } catch (error) {
4225
+ if (error.code === "ENOENT") {
4226
+ console.log(chalk20.green("\u2705 Daemon was not enabled."));
4227
+ } else {
4228
+ console.error(chalk20.red("\u274C Failed to disable daemon:"), error.message);
4229
+ }
4230
+ }
4231
+ }
4232
+
4070
4233
  // src/commands/daemon.ts
4071
4234
  var PID_FILE = ".rigstate/daemon.pid";
4072
4235
  var STATE_FILE = ".rigstate/daemon.state.json";
@@ -4087,17 +4250,17 @@ function createDaemonCommand() {
4087
4250
  }
4088
4251
  const spinner = ora8();
4089
4252
  try {
4090
- const pidPath = path21.join(process.cwd(), PID_FILE);
4253
+ const pidPath = path22.join(process.cwd(), PID_FILE);
4091
4254
  try {
4092
- const content = await fs18.readFile(pidPath, "utf-8");
4255
+ const content = await fs19.readFile(pidPath, "utf-8");
4093
4256
  const pid = parseInt(content.trim(), 10);
4094
4257
  try {
4095
4258
  process.kill(pid, 0);
4096
- console.log(chalk20.yellow("\u26A0 Another daemon instance is active (PID " + pid + ")."));
4097
- console.log(chalk20.dim(` Run "rigstate daemon status" for details or Ctrl+C to stop.
4259
+ console.log(chalk21.yellow("\u26A0 Another daemon instance is active (PID " + pid + ")."));
4260
+ console.log(chalk21.dim(` Run "rigstate daemon status" for details or Ctrl+C to stop.
4098
4261
  `));
4099
4262
  } catch {
4100
- await fs18.unlink(pidPath).catch(() => {
4263
+ await fs19.unlink(pidPath).catch(() => {
4101
4264
  });
4102
4265
  }
4103
4266
  } catch {
@@ -4112,7 +4275,7 @@ function createDaemonCommand() {
4112
4275
  spinner.stop();
4113
4276
  await writePidFile();
4114
4277
  process.on("SIGINT", async () => {
4115
- console.log(chalk20.dim("\n\nShutting down..."));
4278
+ console.log(chalk21.dim("\n\nShutting down..."));
4116
4279
  await daemonInstance.stop();
4117
4280
  await cleanupPidFile();
4118
4281
  process.exit(0);
@@ -4132,8 +4295,8 @@ function createDaemonCommand() {
4132
4295
  await new Promise(() => {
4133
4296
  });
4134
4297
  } catch (error) {
4135
- spinner.fail(chalk20.red("Failed to start daemon"));
4136
- console.error(chalk20.red("Error:"), error.message);
4298
+ spinner.fail(chalk21.red("Failed to start daemon"));
4299
+ console.error(chalk21.red("Error:"), error.message);
4137
4300
  process.exit(1);
4138
4301
  }
4139
4302
  });
@@ -4141,14 +4304,14 @@ function createDaemonCommand() {
4141
4304
  }
4142
4305
  async function isRunning() {
4143
4306
  try {
4144
- const pidPath = path21.join(process.cwd(), PID_FILE);
4145
- const content = await fs18.readFile(pidPath, "utf-8");
4307
+ const pidPath = path22.join(process.cwd(), PID_FILE);
4308
+ const content = await fs19.readFile(pidPath, "utf-8");
4146
4309
  const pid = parseInt(content.trim(), 10);
4147
4310
  try {
4148
4311
  process.kill(pid, 0);
4149
4312
  return true;
4150
4313
  } catch {
4151
- await fs18.unlink(pidPath);
4314
+ await fs19.unlink(pidPath);
4152
4315
  return false;
4153
4316
  }
4154
4317
  } catch {
@@ -4157,156 +4320,68 @@ async function isRunning() {
4157
4320
  }
4158
4321
  async function writePidFile() {
4159
4322
  try {
4160
- const dir = path21.join(process.cwd(), ".rigstate");
4161
- await fs18.mkdir(dir, { recursive: true });
4162
- await fs18.writeFile(path21.join(dir, "daemon.pid"), process.pid.toString());
4323
+ const dir = path22.join(process.cwd(), ".rigstate");
4324
+ await fs19.mkdir(dir, { recursive: true });
4325
+ await fs19.writeFile(path22.join(dir, "daemon.pid"), process.pid.toString());
4163
4326
  } catch {
4164
4327
  }
4165
4328
  }
4166
4329
  async function cleanupPidFile() {
4167
4330
  try {
4168
- await fs18.unlink(path21.join(process.cwd(), PID_FILE));
4169
- await fs18.unlink(path21.join(process.cwd(), STATE_FILE));
4331
+ await fs19.unlink(path22.join(process.cwd(), PID_FILE));
4332
+ await fs19.unlink(path22.join(process.cwd(), STATE_FILE));
4170
4333
  } catch {
4171
4334
  }
4172
4335
  }
4173
4336
  async function writeStateFile(state) {
4174
4337
  try {
4175
- const dir = path21.join(process.cwd(), ".rigstate");
4176
- await fs18.mkdir(dir, { recursive: true });
4177
- await fs18.writeFile(
4178
- path21.join(dir, "daemon.state.json"),
4338
+ const dir = path22.join(process.cwd(), ".rigstate");
4339
+ await fs19.mkdir(dir, { recursive: true });
4340
+ await fs19.writeFile(
4341
+ path22.join(dir, "daemon.state.json"),
4179
4342
  JSON.stringify(state, null, 2)
4180
4343
  );
4181
4344
  } catch {
4182
4345
  }
4183
4346
  }
4184
4347
  async function showStatus() {
4185
- console.log(chalk20.bold("\n\u{1F6E1}\uFE0F Guardian Daemon Status\n"));
4348
+ console.log(chalk21.bold("\n\u{1F6E1}\uFE0F Guardian Daemon Status\n"));
4186
4349
  const running = await isRunning();
4187
4350
  if (!running) {
4188
- console.log(chalk20.yellow("Status: Not running"));
4189
- console.log(chalk20.dim('Use "rigstate daemon" to start.\n'));
4351
+ console.log(chalk21.yellow("Status: Not running"));
4352
+ console.log(chalk21.dim('Use "rigstate daemon" to start.\n'));
4190
4353
  return;
4191
4354
  }
4192
- console.log(chalk20.green("Status: Running"));
4355
+ console.log(chalk21.green("Status: Running"));
4193
4356
  try {
4194
- const statePath = path21.join(process.cwd(), STATE_FILE);
4195
- const content = await fs18.readFile(statePath, "utf-8");
4357
+ const statePath = path22.join(process.cwd(), STATE_FILE);
4358
+ const content = await fs19.readFile(statePath, "utf-8");
4196
4359
  const state = JSON.parse(content);
4197
- console.log(chalk20.dim("\u2500".repeat(40)));
4360
+ console.log(chalk21.dim("\u2500".repeat(40)));
4198
4361
  console.log(`Started at: ${state.startedAt || "Unknown"}`);
4199
4362
  console.log(`Files checked: ${state.filesChecked || 0}`);
4200
4363
  console.log(`Violations: ${state.violationsFound || 0}`);
4201
4364
  console.log(`Tasks processed: ${state.tasksProcessed || 0}`);
4202
4365
  console.log(`Last activity: ${state.lastActivity || "None"}`);
4203
- console.log(chalk20.dim("\u2500".repeat(40)));
4366
+ console.log(chalk21.dim("\u2500".repeat(40)));
4204
4367
  } catch {
4205
- console.log(chalk20.dim("(State file not found)"));
4368
+ console.log(chalk21.dim("(State file not found)"));
4206
4369
  }
4207
4370
  try {
4208
- const pidPath = path21.join(process.cwd(), PID_FILE);
4209
- const pid = await fs18.readFile(pidPath, "utf-8");
4210
- console.log(chalk20.dim(`PID: ${pid.trim()}`));
4371
+ const pidPath = path22.join(process.cwd(), PID_FILE);
4372
+ const pid = await fs19.readFile(pidPath, "utf-8");
4373
+ console.log(chalk21.dim(`PID: ${pid.trim()}`));
4211
4374
  } catch {
4212
4375
  }
4213
4376
  console.log("");
4214
4377
  }
4215
- async function enableDaemon() {
4216
- console.log(chalk20.bold("\n\u2699\uFE0F Enabling Rigstate Background Service (macOS)\n"));
4217
- if (process.platform !== "darwin") {
4218
- console.error(chalk20.red("\u274C Currently only macOS is supported for auto-start."));
4219
- console.error(chalk20.yellow("PRs welcome for Linux/Windows support!"));
4220
- return;
4221
- }
4222
- const homeDir = process.env.HOME || "";
4223
- if (!homeDir) {
4224
- console.error(chalk20.red("\u274C Could not determine HOME directory."));
4225
- return;
4226
- }
4227
- const agentsDir = path21.join(homeDir, "Library/LaunchAgents");
4228
- const logDir = path21.join(homeDir, ".rigstate/logs");
4229
- const plistPath = path21.join(agentsDir, "com.rigstate.daemon.plist");
4230
- await fs18.mkdir(agentsDir, { recursive: true });
4231
- await fs18.mkdir(logDir, { recursive: true });
4232
- const scriptPath = fileURLToPath2(import.meta.url);
4233
- const nodePath = process.execPath;
4234
- const plistContent = `<?xml version="1.0" encoding="UTF-8"?>
4235
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
4236
- <plist version="1.0">
4237
- <dict>
4238
- <key>Label</key>
4239
- <string>com.rigstate.daemon</string>
4240
- <key>ProgramArguments</key>
4241
- <array>
4242
- <string>${nodePath}</string>
4243
- <string>${scriptPath}</string>
4244
- <string>daemon</string>
4245
- <string>--no-bridge</string>
4246
- </array>
4247
- <key>WorkingDirectory</key>
4248
- <string>${process.cwd()}</string>
4249
- <key>StandardOutPath</key>
4250
- <string>${path21.join(logDir, "daemon.out.log")}</string>
4251
- <key>StandardErrorPath</key>
4252
- <string>${path21.join(logDir, "daemon.err.log")}</string>
4253
- <key>RunAtLoad</key>
4254
- <true/>
4255
- <key>KeepAlive</key>
4256
- <true/>
4257
- <key>EnvironmentVariables</key>
4258
- <dict>
4259
- <key>PATH</key>
4260
- <string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:${process.env.PATH}</string>
4261
- </dict>
4262
- </dict>
4263
- </plist>`;
4264
- try {
4265
- await fs18.writeFile(plistPath, plistContent);
4266
- console.log(chalk20.dim(`Created plist at: ${plistPath}`));
4267
- try {
4268
- await execShellCommand(`launchctl unload ${plistPath}`);
4269
- } catch (e) {
4270
- }
4271
- await execShellCommand(`launchctl load ${plistPath}`);
4272
- console.log(chalk20.green("\u2705 Successfully enabled background daemon!"));
4273
- console.log(chalk20.dim(`Logs: ${logDir}`));
4274
- console.log(chalk20.dim("The daemon will now restart automatically if it crashes or on reboot."));
4275
- } catch (error) {
4276
- console.error(chalk20.red("\u274C Failed to enable daemon:"), error.message);
4277
- }
4278
- }
4279
- async function disableDaemon() {
4280
- console.log(chalk20.bold("\n\u2699\uFE0F Disabling Rigstate Background Service\n"));
4281
- const homeDir = process.env.HOME || "";
4282
- const plistPath = path21.join(homeDir, "Library/LaunchAgents/com.rigstate.daemon.plist");
4283
- try {
4284
- await execShellCommand(`launchctl unload ${plistPath}`);
4285
- await fs18.unlink(plistPath);
4286
- console.log(chalk20.green("\u2705 Successfully disabled background daemon."));
4287
- } catch (error) {
4288
- if (error.code === "ENOENT") {
4289
- console.log(chalk20.green("\u2705 Daemon was not enabled."));
4290
- } else {
4291
- console.error(chalk20.red("\u274C Failed to disable daemon:"), error.message);
4292
- }
4293
- }
4294
- }
4295
- async function execShellCommand(cmd) {
4296
- try {
4297
- const output = execSync3(cmd, { stdio: "pipe" }).toString();
4298
- return output;
4299
- } catch (error) {
4300
- return error.stderr?.toString() || error.stdout?.toString() || error.message;
4301
- }
4302
- }
4303
4378
 
4304
4379
  // src/commands/work.ts
4305
4380
  init_esm_shims();
4306
4381
  init_config();
4307
4382
  init_suggest();
4308
4383
  import { Command as Command12 } from "commander";
4309
- import chalk21 from "chalk";
4384
+ import chalk22 from "chalk";
4310
4385
  import ora9 from "ora";
4311
4386
  import axios15 from "axios";
4312
4387
  import inquirer2 from "inquirer";
@@ -4341,7 +4416,7 @@ async function listInteractive() {
4341
4416
  });
4342
4417
  spinner.stop();
4343
4418
  if (actionableTasks.length === 0) {
4344
- console.log(chalk21.yellow("Roadmap clear. No actionable tasks found."));
4419
+ console.log(chalk22.yellow("Roadmap clear. No actionable tasks found."));
4345
4420
  return;
4346
4421
  }
4347
4422
  const choices = actionableTasks.map((t) => {
@@ -4350,7 +4425,7 @@ async function listInteractive() {
4350
4425
  if (t.status === "IN_PROGRESS") icon = "\u{1F525}";
4351
4426
  if (t.status === "ACTIVE") icon = "\u25B6\uFE0F";
4352
4427
  return {
4353
- name: `${icon} ${chalk21.bold(id)}: ${t.title} [${t.status}]`,
4428
+ name: `${icon} ${chalk22.bold(id)}: ${t.title} [${t.status}]`,
4354
4429
  value: t.id
4355
4430
  };
4356
4431
  });
@@ -4393,25 +4468,25 @@ async function setTaskStatus(taskId, status) {
4393
4468
  { step_id: realId, status, project_id: projectId },
4394
4469
  { headers: { "Authorization": `Bearer ${apiKey}` } }
4395
4470
  );
4396
- spinner.succeed(chalk21.green(`Task updated to ${status}.`));
4471
+ spinner.succeed(chalk22.green(`Task updated to ${status}.`));
4397
4472
  if (status === "IN_PROGRESS") {
4398
- console.log(chalk21.blue(`
4473
+ console.log(chalk22.blue(`
4399
4474
  \u{1F4A1} Tip: Provide 'Frank' with context by mentioning @.cursorrules in your chat.`));
4400
4475
  }
4401
4476
  } catch (e) {
4402
- spinner.fail(chalk21.red(`Failed: ${e.message}`));
4477
+ spinner.fail(chalk22.red(`Failed: ${e.message}`));
4403
4478
  }
4404
4479
  }
4405
4480
  async function finishTask(taskId) {
4406
4481
  console.log("");
4407
- console.log(chalk21.bold.yellow("\u{1F6E1}\uFE0F FRANK'S QUALITY GATE"));
4408
- console.log(chalk21.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
4482
+ console.log(chalk22.bold.yellow("\u{1F6E1}\uFE0F FRANK'S QUALITY GATE"));
4483
+ console.log(chalk22.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"));
4409
4484
  const auditSpinner = ora9(" Analyzing architectural integrity...").start();
4410
4485
  await new Promise((r) => setTimeout(r, 1500));
4411
4486
  auditSpinner.succeed("Architecture: VALIDATED (SEC-ARCH-01 Pass)");
4412
4487
  await setTaskStatus(taskId, "COMPLETED");
4413
4488
  console.log("");
4414
- console.log(chalk21.bold.green("\u{1F389} TASK COMPLETE! Momentum Preserved."));
4489
+ console.log(chalk22.bold.green("\u{1F389} TASK COMPLETE! Momentum Preserved."));
4415
4490
  const { projectId, apiKey, apiUrl } = getContext();
4416
4491
  await suggestNextMove(projectId, apiKey, apiUrl);
4417
4492
  }
@@ -4429,39 +4504,39 @@ function getContext() {
4429
4504
  init_esm_shims();
4430
4505
  init_config();
4431
4506
  import { Command as Command13 } from "commander";
4432
- import chalk22 from "chalk";
4507
+ import chalk23 from "chalk";
4433
4508
  import ora10 from "ora";
4434
4509
  import chokidar2 from "chokidar";
4435
- import fs19 from "fs/promises";
4436
- import path22 from "path";
4510
+ import fs20 from "fs/promises";
4511
+ import path23 from "path";
4437
4512
  import { execSync as execSync4 } from "child_process";
4438
4513
  import axios16 from "axios";
4439
4514
  function createWatchCommand() {
4440
4515
  const watch2 = new Command13("watch");
4441
4516
  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) => {
4442
- console.log(chalk22.bold.blue("\u{1F52D} Rigstate Watch Mode"));
4443
- console.log(chalk22.dim("Monitoring for task completion..."));
4517
+ console.log(chalk23.bold.blue("\u{1F52D} Rigstate Watch Mode"));
4518
+ console.log(chalk23.dim("Monitoring for task completion..."));
4444
4519
  console.log("");
4445
4520
  let apiKey;
4446
4521
  let projectId;
4447
4522
  try {
4448
4523
  apiKey = getApiKey();
4449
4524
  } catch (e) {
4450
- console.log(chalk22.red('Not authenticated. Run "rigstate login" first.'));
4525
+ console.log(chalk23.red('Not authenticated. Run "rigstate login" first.'));
4451
4526
  return;
4452
4527
  }
4453
4528
  projectId = getProjectId();
4454
4529
  if (!projectId) {
4455
4530
  try {
4456
- const manifestPath = path22.join(process.cwd(), ".rigstate");
4457
- const content = await fs19.readFile(manifestPath, "utf-8");
4531
+ const manifestPath = path23.join(process.cwd(), ".rigstate");
4532
+ const content = await fs20.readFile(manifestPath, "utf-8");
4458
4533
  const manifest = JSON.parse(content);
4459
4534
  projectId = manifest.project_id;
4460
4535
  } catch (e) {
4461
4536
  }
4462
4537
  }
4463
4538
  if (!projectId) {
4464
- console.log(chalk22.red('No project context. Run "rigstate link" or "rigstate sync --project <id>" first.'));
4539
+ console.log(chalk23.red('No project context. Run "rigstate link" or "rigstate sync --project <id>" first.'));
4465
4540
  return;
4466
4541
  }
4467
4542
  const apiUrl = getApiUrl();
@@ -4471,8 +4546,8 @@ function createWatchCommand() {
4471
4546
  runTests: options.runTests || false,
4472
4547
  testCommand: options.testCommand || "npm test"
4473
4548
  };
4474
- console.log(chalk22.dim(`Auto-commit: ${config2.autoCommit ? "ON" : "OFF"}`));
4475
- console.log(chalk22.dim(`Auto-push: ${config2.autoPush ? "ON" : "OFF"}`));
4549
+ console.log(chalk23.dim(`Auto-commit: ${config2.autoCommit ? "ON" : "OFF"}`));
4550
+ console.log(chalk23.dim(`Auto-push: ${config2.autoPush ? "ON" : "OFF"}`));
4476
4551
  console.log("");
4477
4552
  const fetchActiveTask = async () => {
4478
4553
  try {
@@ -4500,17 +4575,17 @@ function createWatchCommand() {
4500
4575
  };
4501
4576
  const checkCriteria = async (criteria) => {
4502
4577
  try {
4503
- const fullPath = path22.resolve(process.cwd(), criteria.path);
4578
+ const fullPath = path23.resolve(process.cwd(), criteria.path);
4504
4579
  switch (criteria.type) {
4505
4580
  case "file_exists":
4506
- await fs19.access(fullPath);
4581
+ await fs20.access(fullPath);
4507
4582
  return true;
4508
4583
  case "file_content":
4509
- const content = await fs19.readFile(fullPath, "utf-8");
4584
+ const content = await fs20.readFile(fullPath, "utf-8");
4510
4585
  return content.length > 0;
4511
4586
  case "content_match":
4512
4587
  if (!criteria.match) return false;
4513
- const fileContent = await fs19.readFile(fullPath, "utf-8");
4588
+ const fileContent = await fs20.readFile(fullPath, "utf-8");
4514
4589
  return fileContent.includes(criteria.match);
4515
4590
  default:
4516
4591
  return false;
@@ -4539,7 +4614,7 @@ function createWatchCommand() {
4539
4614
  }, {
4540
4615
  headers: { Authorization: `Bearer ${apiKey}` }
4541
4616
  });
4542
- spinner.succeed(chalk22.green(`\u2705 Task #${task.step_number} completed: ${task.title}`));
4617
+ spinner.succeed(chalk23.green(`\u2705 Task #${task.step_number} completed: ${task.title}`));
4543
4618
  if (config2.autoCommit) {
4544
4619
  spinner.start("Committing changes...");
4545
4620
  try {
@@ -4561,7 +4636,7 @@ function createWatchCommand() {
4561
4636
  }
4562
4637
  }
4563
4638
  console.log("");
4564
- console.log(chalk22.blue("Watching for next task..."));
4639
+ console.log(chalk23.blue("Watching for next task..."));
4565
4640
  } catch (e) {
4566
4641
  spinner.fail(`Failed to complete task: ${e.message}`);
4567
4642
  }
@@ -4574,7 +4649,7 @@ function createWatchCommand() {
4574
4649
  const task = await fetchActiveTask();
4575
4650
  if (!task) {
4576
4651
  if (currentTask) {
4577
- console.log(chalk22.green("\u{1F389} All tasks completed! Watching for new tasks..."));
4652
+ console.log(chalk23.green("\u{1F389} All tasks completed! Watching for new tasks..."));
4578
4653
  currentTask = null;
4579
4654
  }
4580
4655
  isProcessing = false;
@@ -4583,10 +4658,10 @@ function createWatchCommand() {
4583
4658
  if (!currentTask || currentTask.id !== task.id) {
4584
4659
  currentTask = task;
4585
4660
  console.log("");
4586
- console.log(chalk22.bold.yellow(`\u{1F4CC} Active Task #${task.step_number}: ${task.title}`));
4587
- console.log(chalk22.dim(`Status: ${task.status}`));
4661
+ console.log(chalk23.bold.yellow(`\u{1F4CC} Active Task #${task.step_number}: ${task.title}`));
4662
+ console.log(chalk23.dim(`Status: ${task.status}`));
4588
4663
  if (task.verification_criteria) {
4589
- console.log(chalk22.dim("Verification: Auto-checking criteria..."));
4664
+ console.log(chalk23.dim("Verification: Auto-checking criteria..."));
4590
4665
  }
4591
4666
  }
4592
4667
  if (task.verification_criteria && Array.isArray(task.verification_criteria)) {
@@ -4599,7 +4674,7 @@ function createWatchCommand() {
4599
4674
  }
4600
4675
  }
4601
4676
  if (allPassed) {
4602
- console.log(chalk22.green("\u2713 All verification criteria passed!"));
4677
+ console.log(chalk23.green("\u2713 All verification criteria passed!"));
4603
4678
  await completeTask(task.id, task);
4604
4679
  currentTask = null;
4605
4680
  }
@@ -4624,11 +4699,11 @@ function createWatchCommand() {
4624
4699
  setTimeout(() => processActiveTask(), 500);
4625
4700
  }
4626
4701
  });
4627
- console.log(chalk22.dim("Watching for file changes... (Ctrl+C to exit)"));
4702
+ console.log(chalk23.dim("Watching for file changes... (Ctrl+C to exit)"));
4628
4703
  setInterval(() => processActiveTask(), 3e4);
4629
4704
  process.on("SIGINT", () => {
4630
4705
  console.log("");
4631
- console.log(chalk22.dim("Watch mode stopped."));
4706
+ console.log(chalk23.dim("Watch mode stopped."));
4632
4707
  watcher.close();
4633
4708
  process.exit(0);
4634
4709
  });
@@ -4640,12 +4715,12 @@ function createWatchCommand() {
4640
4715
  init_esm_shims();
4641
4716
  init_config();
4642
4717
  import { Command as Command14 } from "commander";
4643
- import chalk23 from "chalk";
4718
+ import chalk24 from "chalk";
4644
4719
  import ora11 from "ora";
4645
4720
  import axios17 from "axios";
4646
4721
  import { execSync as execSync5 } from "child_process";
4647
- import fs20 from "fs/promises";
4648
- import path23 from "path";
4722
+ import fs21 from "fs/promises";
4723
+ import path24 from "path";
4649
4724
  function createFocusCommand() {
4650
4725
  const focus = new Command14("focus");
4651
4726
  focus.alias("task").description("Get the next active roadmap task and copy its prompt to clipboard").option("--no-copy", "Do not copy to clipboard").action(async (options) => {
@@ -4655,21 +4730,21 @@ function createFocusCommand() {
4655
4730
  try {
4656
4731
  apiKey = getApiKey();
4657
4732
  } catch (e) {
4658
- spinner.fail(chalk23.red('Not authenticated. Run "rigstate login" first.'));
4733
+ spinner.fail(chalk24.red('Not authenticated. Run "rigstate login" first.'));
4659
4734
  return;
4660
4735
  }
4661
4736
  projectId = getProjectId();
4662
4737
  if (!projectId) {
4663
4738
  try {
4664
- const manifestPath = path23.join(process.cwd(), ".rigstate");
4665
- const content = await fs20.readFile(manifestPath, "utf-8");
4739
+ const manifestPath = path24.join(process.cwd(), ".rigstate");
4740
+ const content = await fs21.readFile(manifestPath, "utf-8");
4666
4741
  const manifest = JSON.parse(content);
4667
4742
  projectId = manifest.project_id;
4668
4743
  } catch (e) {
4669
4744
  }
4670
4745
  }
4671
4746
  if (!projectId) {
4672
- spinner.fail(chalk23.red('No project context. Run "rigstate link" first.'));
4747
+ spinner.fail(chalk24.red('No project context. Run "rigstate link" first.'));
4673
4748
  return;
4674
4749
  }
4675
4750
  const apiUrl = getApiUrl();
@@ -4700,41 +4775,41 @@ function createFocusCommand() {
4700
4775
  const nextTask = activeTasks[0];
4701
4776
  spinner.stop();
4702
4777
  console.log("");
4703
- console.log(chalk23.bold.blue(`\u{1F4CC} Task #${nextTask.step_number || "?"}: ${nextTask.title}`));
4704
- const statusColor = nextTask.status === "IN_PROGRESS" ? chalk23.yellow : nextTask.status === "ACTIVE" ? chalk23.green : chalk23.dim;
4705
- console.log(chalk23.dim("Status: ") + statusColor(nextTask.status));
4706
- console.log(chalk23.dim("\u2500".repeat(60)));
4778
+ console.log(chalk24.bold.blue(`\u{1F4CC} Task #${nextTask.step_number || "?"}: ${nextTask.title}`));
4779
+ const statusColor = nextTask.status === "IN_PROGRESS" ? chalk24.yellow : nextTask.status === "ACTIVE" ? chalk24.green : chalk24.dim;
4780
+ console.log(chalk24.dim("Status: ") + statusColor(nextTask.status));
4781
+ console.log(chalk24.dim("\u2500".repeat(60)));
4707
4782
  if (nextTask.prompt_content) {
4708
- console.log(chalk23.white(nextTask.prompt_content));
4709
- console.log(chalk23.dim("\u2500".repeat(60)));
4783
+ console.log(chalk24.white(nextTask.prompt_content));
4784
+ console.log(chalk24.dim("\u2500".repeat(60)));
4710
4785
  if (options.copy !== false) {
4711
4786
  try {
4712
4787
  if (process.platform === "darwin") {
4713
4788
  execSync5("pbcopy", { input: nextTask.prompt_content });
4714
- console.log(chalk23.green("\u2705 Prompt copied to clipboard! Ready to paste (Cmd+V)."));
4789
+ console.log(chalk24.green("\u2705 Prompt copied to clipboard! Ready to paste (Cmd+V)."));
4715
4790
  } else if (process.platform === "linux") {
4716
4791
  try {
4717
4792
  execSync5("xclip -selection clipboard", { input: nextTask.prompt_content });
4718
- console.log(chalk23.green("\u2705 Prompt copied to clipboard!"));
4793
+ console.log(chalk24.green("\u2705 Prompt copied to clipboard!"));
4719
4794
  } catch (e) {
4720
- console.log(chalk23.yellow("\u2139\uFE0F Copy prompt manually (xclip not available)"));
4795
+ console.log(chalk24.yellow("\u2139\uFE0F Copy prompt manually (xclip not available)"));
4721
4796
  }
4722
4797
  } else {
4723
- console.log(chalk23.yellow("\u2139\uFE0F Copy prompt manually (Auto-copy not supported on this OS)"));
4798
+ console.log(chalk24.yellow("\u2139\uFE0F Copy prompt manually (Auto-copy not supported on this OS)"));
4724
4799
  }
4725
4800
  } catch (e) {
4726
4801
  }
4727
4802
  }
4728
4803
  } else {
4729
- console.log(chalk23.yellow("No prompt instructions available."));
4804
+ console.log(chalk24.yellow("No prompt instructions available."));
4730
4805
  if (nextTask.architectural_brief) {
4731
- console.log(chalk23.bold("Brief:"));
4806
+ console.log(chalk24.bold("Brief:"));
4732
4807
  console.log(nextTask.architectural_brief);
4733
4808
  }
4734
4809
  }
4735
4810
  console.log("");
4736
4811
  } catch (e) {
4737
- spinner.fail(chalk23.red(`Failed to fetch task: ${e.message}`));
4812
+ spinner.fail(chalk24.red(`Failed to fetch task: ${e.message}`));
4738
4813
  }
4739
4814
  });
4740
4815
  return focus;
@@ -4747,25 +4822,25 @@ init_env();
4747
4822
  init_esm_shims();
4748
4823
  init_config();
4749
4824
  import { Command as Command15 } from "commander";
4750
- import chalk24 from "chalk";
4825
+ import chalk25 from "chalk";
4751
4826
  function createConfigCommand() {
4752
4827
  const config2 = new Command15("config");
4753
4828
  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) => {
4754
4829
  if (!key) {
4755
- console.log(chalk24.bold("Rigstate Configuration"));
4756
- console.log(chalk24.dim("\u2500".repeat(40)));
4830
+ console.log(chalk25.bold("Rigstate Configuration"));
4831
+ console.log(chalk25.dim("\u2500".repeat(40)));
4757
4832
  try {
4758
4833
  const apiKey = getApiKey();
4759
- console.log(`${chalk24.cyan("api_key")}: ${apiKey.substring(0, 20)}...`);
4834
+ console.log(`${chalk25.cyan("api_key")}: ${apiKey.substring(0, 20)}...`);
4760
4835
  } catch (e) {
4761
- console.log(`${chalk24.cyan("api_key")}: ${chalk24.dim("(not set)")}`);
4836
+ console.log(`${chalk25.cyan("api_key")}: ${chalk25.dim("(not set)")}`);
4762
4837
  }
4763
4838
  const projectId = getProjectId();
4764
- console.log(`${chalk24.cyan("project_id")}: ${projectId || chalk24.dim("(not set)")}`);
4839
+ console.log(`${chalk25.cyan("project_id")}: ${projectId || chalk25.dim("(not set)")}`);
4765
4840
  const apiUrl = getApiUrl();
4766
- console.log(`${chalk24.cyan("api_url")}: ${apiUrl}`);
4841
+ console.log(`${chalk25.cyan("api_url")}: ${apiUrl}`);
4767
4842
  console.log("");
4768
- console.log(chalk24.dim('Use "rigstate config <key> <value>" to set a value.'));
4843
+ console.log(chalk25.dim('Use "rigstate config <key> <value>" to set a value.'));
4769
4844
  return;
4770
4845
  }
4771
4846
  if (!value) {
@@ -4775,37 +4850,37 @@ function createConfigCommand() {
4775
4850
  const apiKey = getApiKey();
4776
4851
  console.log(apiKey);
4777
4852
  } catch (e) {
4778
- console.log(chalk24.dim("(not set)"));
4853
+ console.log(chalk25.dim("(not set)"));
4779
4854
  }
4780
4855
  break;
4781
4856
  case "project_id":
4782
- console.log(getProjectId() || chalk24.dim("(not set)"));
4857
+ console.log(getProjectId() || chalk25.dim("(not set)"));
4783
4858
  break;
4784
4859
  case "api_url":
4785
4860
  console.log(getApiUrl());
4786
4861
  break;
4787
4862
  default:
4788
- console.log(chalk24.red(`Unknown config key: ${key}`));
4789
- console.log(chalk24.dim("Valid keys: api_key, project_id, api_url"));
4863
+ console.log(chalk25.red(`Unknown config key: ${key}`));
4864
+ console.log(chalk25.dim("Valid keys: api_key, project_id, api_url"));
4790
4865
  }
4791
4866
  return;
4792
4867
  }
4793
4868
  switch (key) {
4794
4869
  case "api_key":
4795
4870
  setApiKey(value);
4796
- console.log(chalk24.green(`\u2705 api_key updated`));
4871
+ console.log(chalk25.green(`\u2705 api_key updated`));
4797
4872
  break;
4798
4873
  case "project_id":
4799
4874
  setProjectId(value);
4800
- console.log(chalk24.green(`\u2705 project_id updated`));
4875
+ console.log(chalk25.green(`\u2705 project_id updated`));
4801
4876
  break;
4802
4877
  case "api_url":
4803
4878
  setApiUrl(value);
4804
- console.log(chalk24.green(`\u2705 api_url updated`));
4879
+ console.log(chalk25.green(`\u2705 api_url updated`));
4805
4880
  break;
4806
4881
  default:
4807
- console.log(chalk24.red(`Unknown config key: ${key}`));
4808
- console.log(chalk24.dim("Valid keys: api_key, project_id, api_url"));
4882
+ console.log(chalk25.red(`Unknown config key: ${key}`));
4883
+ console.log(chalk25.dim("Valid keys: api_key, project_id, api_url"));
4809
4884
  }
4810
4885
  });
4811
4886
  return config2;
@@ -4815,41 +4890,41 @@ function createConfigCommand() {
4815
4890
  init_esm_shims();
4816
4891
  init_config();
4817
4892
  import { Command as Command16 } from "commander";
4818
- import chalk25 from "chalk";
4893
+ import chalk26 from "chalk";
4819
4894
  import { spawn } from "child_process";
4820
- import path24 from "path";
4821
- import fs21 from "fs";
4895
+ import path25 from "path";
4896
+ import fs22 from "fs";
4822
4897
  import { fileURLToPath as fileURLToPath3 } from "url";
4823
4898
  var __filename2 = fileURLToPath3(import.meta.url);
4824
- var __dirname2 = path24.dirname(__filename2);
4899
+ var __dirname2 = path25.dirname(__filename2);
4825
4900
  function createMcpCommand() {
4826
4901
  const mcp = new Command16("mcp");
4827
4902
  mcp.description("Run the Rigstate MCP server for AI editors").action(async () => {
4828
4903
  const possiblePaths = [
4829
4904
  // From packages/cli -> packages/mcp (sibling package)
4830
- path24.resolve(__dirname2, "../../mcp/dist/index.js"),
4905
+ path25.resolve(__dirname2, "../../mcp/dist/index.js"),
4831
4906
  // If installed globally or via npm
4832
- path24.resolve(__dirname2, "../../../mcp/dist/index.js"),
4907
+ path25.resolve(__dirname2, "../../../mcp/dist/index.js"),
4833
4908
  // Development path from packages/cli/dist
4834
- path24.resolve(__dirname2, "../../../packages/mcp/dist/index.js")
4909
+ path25.resolve(__dirname2, "../../../packages/mcp/dist/index.js")
4835
4910
  ];
4836
4911
  let serverPath = "";
4837
4912
  for (const p of possiblePaths) {
4838
- if (fs21.existsSync(p)) {
4913
+ if (fs22.existsSync(p)) {
4839
4914
  serverPath = p;
4840
4915
  break;
4841
4916
  }
4842
4917
  }
4843
4918
  if (!serverPath) {
4844
- console.error(chalk25.red("\u274C Error: Rigstate MCP Server binary not found."));
4845
- console.error(chalk25.yellow("Please ensure that the mcp package is built:"));
4846
- console.error(chalk25.white(" cd packages/mcp && npm run build"));
4919
+ console.error(chalk26.red("\u274C Error: Rigstate MCP Server binary not found."));
4920
+ console.error(chalk26.yellow("Please ensure that the mcp package is built:"));
4921
+ console.error(chalk26.white(" cd packages/mcp && npm run build"));
4847
4922
  console.error("");
4848
- console.error(chalk25.dim("Or run directly with:"));
4849
- console.error(chalk25.white(" npx @rigstate/mcp"));
4923
+ console.error(chalk26.dim("Or run directly with:"));
4924
+ console.error(chalk26.white(" npx @rigstate/mcp"));
4850
4925
  process.exit(1);
4851
4926
  }
4852
- console.log(chalk25.dim(`Starting MCP server from: ${serverPath}`));
4927
+ console.log(chalk26.dim(`Starting MCP server from: ${serverPath}`));
4853
4928
  const env = { ...process.env };
4854
4929
  try {
4855
4930
  const apiKey = getApiKey();
@@ -4868,7 +4943,7 @@ function createMcpCommand() {
4868
4943
  stdio: ["inherit", "inherit", "inherit"]
4869
4944
  });
4870
4945
  worker.on("error", (err) => {
4871
- console.error(chalk25.red(`\u274C Failed to start MCP server: ${err.message}`));
4946
+ console.error(chalk26.red(`\u274C Failed to start MCP server: ${err.message}`));
4872
4947
  process.exit(1);
4873
4948
  });
4874
4949
  worker.on("exit", (code) => {
@@ -4883,7 +4958,7 @@ function createMcpCommand() {
4883
4958
  // src/commands/nexus.ts
4884
4959
  init_esm_shims();
4885
4960
  import { Command as Command17 } from "commander";
4886
- import chalk27 from "chalk";
4961
+ import chalk28 from "chalk";
4887
4962
 
4888
4963
  // src/nexus/dispatcher.ts
4889
4964
  init_esm_shims();
@@ -4951,7 +5026,7 @@ var HiveScrubber = class {
4951
5026
  };
4952
5027
 
4953
5028
  // src/hive/gateway.ts
4954
- import chalk26 from "chalk";
5029
+ import chalk27 from "chalk";
4955
5030
  var HiveGateway = class {
4956
5031
  client;
4957
5032
  enabled;
@@ -4961,7 +5036,7 @@ var HiveGateway = class {
4961
5036
  constructor(baseUrl, token) {
4962
5037
  this.enabled = !!token;
4963
5038
  if (!this.enabled) {
4964
- console.log(chalk26.dim("\u26A0\uFE0F Hive Gateway disabled (No Token provided). Running in localized mode."));
5039
+ console.log(chalk27.dim("\u26A0\uFE0F Hive Gateway disabled (No Token provided). Running in localized mode."));
4965
5040
  }
4966
5041
  this.client = axios18.create({
4967
5042
  baseURL: baseUrl,
@@ -4981,23 +5056,23 @@ var HiveGateway = class {
4981
5056
  if (!this.enabled) return false;
4982
5057
  const now = Date.now();
4983
5058
  if (now - this.lastSignalTime < this.MIN_INTERVAL_MS) {
4984
- console.warn(chalk26.yellow("\u23F3 Hive Gateway Throttled. Signal dropped to preventing spam."));
5059
+ console.warn(chalk27.yellow("\u23F3 Hive Gateway Throttled. Signal dropped to preventing spam."));
4985
5060
  return false;
4986
5061
  }
4987
5062
  const scrubResult = HiveScrubber.scrub(signal.ruleContent);
4988
5063
  if (scrubResult.riskScore > 20) {
4989
- console.error(chalk26.red(`\u{1F6D1} HIVE BLOCKED: Signal contains sensitive data (Risk: ${scrubResult.riskScore})`));
5064
+ console.error(chalk27.red(`\u{1F6D1} HIVE BLOCKED: Signal contains sensitive data (Risk: ${scrubResult.riskScore})`));
4990
5065
  return false;
4991
5066
  }
4992
5067
  try {
4993
- console.log(chalk26.blue(`\u{1F4E1} Uplinking to Hive... [${signal.vector}]`));
5068
+ console.log(chalk27.blue(`\u{1F4E1} Uplinking to Hive... [${signal.vector}]`));
4994
5069
  const payload = { ...signal, ruleContent: scrubResult.sanitizedContent };
4995
5070
  await this.client.post("/signal", payload);
4996
5071
  this.lastSignalTime = now;
4997
- console.log(chalk26.green("\u2705 Signal Received by Hive Core. Knowledge Shared."));
5072
+ console.log(chalk27.green("\u2705 Signal Received by Hive Core. Knowledge Shared."));
4998
5073
  return true;
4999
5074
  } catch (error) {
5000
- console.error(chalk26.red(`\u274C Hive Transmission Failed: ${error.message}`));
5075
+ console.error(chalk27.red(`\u274C Hive Transmission Failed: ${error.message}`));
5001
5076
  return false;
5002
5077
  }
5003
5078
  }
@@ -5099,10 +5174,10 @@ import inquirer3 from "inquirer";
5099
5174
  function createNexusCommand() {
5100
5175
  const command = new Command17("nexus");
5101
5176
  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) => {
5102
- console.log(chalk27.bold.magenta("\n\u{1F981} Welcome to The Nexus (Phase 8)\n"));
5177
+ console.log(chalk28.bold.magenta("\n\u{1F981} Welcome to The Nexus (Phase 8)\n"));
5103
5178
  const dryRun = !options.force;
5104
5179
  if (!dryRun) {
5105
- console.log(chalk27.black.bgYellow(" WARNING ") + chalk27.yellow(" Dry-Run disabled! Eitri is authorized to write code."));
5180
+ console.log(chalk28.black.bgYellow(" WARNING ") + chalk28.yellow(" Dry-Run disabled! Eitri is authorized to write code."));
5106
5181
  const { confirm } = await inquirer3.prompt([{
5107
5182
  type: "confirm",
5108
5183
  name: "confirm",
@@ -5123,26 +5198,26 @@ function createNexusCommand() {
5123
5198
  };
5124
5199
  const dispatcher = new NexusDispatcher(context);
5125
5200
  dispatcher.on("order:created", (o) => {
5126
- console.log(chalk27.blue(`\u{1F195} [${o.id.slice(0, 6)}] Order Created: `) + o.intent);
5201
+ console.log(chalk28.blue(`\u{1F195} [${o.id.slice(0, 6)}] Order Created: `) + o.intent);
5127
5202
  });
5128
5203
  dispatcher.on("order:started", (o) => {
5129
- console.log(chalk27.yellow(`\u23F3 [${o.id.slice(0, 6)}] Processing...`));
5204
+ console.log(chalk28.yellow(`\u23F3 [${o.id.slice(0, 6)}] Processing...`));
5130
5205
  });
5131
5206
  dispatcher.on("order:blocked", (o) => {
5132
- console.log(chalk27.red(`\u{1F6D1} [${o.id.slice(0, 6)}] BLOCKED by Kill-Switch`));
5133
- console.log(chalk27.dim(` Target: ${o.targetAgent} | Action: ${o.action}`));
5134
- console.log(chalk27.dim(" Run with --force to execute automatically (NOT RECOMMENDED)."));
5207
+ console.log(chalk28.red(`\u{1F6D1} [${o.id.slice(0, 6)}] BLOCKED by Kill-Switch`));
5208
+ console.log(chalk28.dim(` Target: ${o.targetAgent} | Action: ${o.action}`));
5209
+ console.log(chalk28.dim(" Run with --force to execute automatically (NOT RECOMMENDED)."));
5135
5210
  });
5136
- dispatcher.on("agent:SINDRE", (o) => console.log(chalk27.cyan(`\u{1F916} Sindre (Vault): I'm on it! (${o.action})`)));
5137
- dispatcher.on("agent:EITRI", (o) => console.log(chalk27.green(`\u{1F477} Eitri (Smith): Ready to build! (${o.action})`)));
5138
- console.log(chalk27.dim("\u{1F9E0} Frank is analyzing your intent..."));
5211
+ dispatcher.on("agent:SINDRE", (o) => console.log(chalk28.cyan(`\u{1F916} Sindre (Vault): I'm on it! (${o.action})`)));
5212
+ dispatcher.on("agent:EITRI", (o) => console.log(chalk28.green(`\u{1F477} Eitri (Smith): Ready to build! (${o.action})`)));
5213
+ console.log(chalk28.dim("\u{1F9E0} Frank is analyzing your intent..."));
5139
5214
  await new Promise((r) => setTimeout(r, 800));
5140
5215
  if (intent.toLowerCase().includes("db") || intent.toLowerCase().includes("database")) {
5141
5216
  await dispatcher.dispatch("FRANK", "SINDRE", intent, "db.analyze", { raw: intent });
5142
5217
  } else if (intent.toLowerCase().includes("create") || intent.toLowerCase().includes("code")) {
5143
5218
  await dispatcher.dispatch("FRANK", "EITRI", intent, "fs.write", { path: "src/demo.ts", content: "// demo" });
5144
5219
  } else {
5145
- console.log(chalk27.gray("Frank didn't understand. Try 'create file' or 'check database'."));
5220
+ console.log(chalk28.gray("Frank didn't understand. Try 'create file' or 'check database'."));
5146
5221
  }
5147
5222
  });
5148
5223
  return command;
@@ -5156,25 +5231,25 @@ init_esm_shims();
5156
5231
  init_governance();
5157
5232
  init_config();
5158
5233
  import { Command as Command18 } from "commander";
5159
- import chalk28 from "chalk";
5234
+ import chalk29 from "chalk";
5160
5235
  import axios19 from "axios";
5161
5236
  function createOverrideCommand() {
5162
5237
  const override = new Command18("override");
5163
5238
  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) => {
5164
5239
  const { reason } = options;
5165
- console.log(chalk28.bold(`
5240
+ console.log(chalk29.bold(`
5166
5241
  \u{1F513} Initiating Governance Override Protocol...`));
5167
5242
  const session = await getSessionState(process.cwd());
5168
5243
  if (session.status !== "SOFT_LOCK") {
5169
- console.log(chalk28.yellow(" Info: Session is not currently locked."));
5244
+ console.log(chalk29.yellow(" Info: Session is not currently locked."));
5170
5245
  return;
5171
5246
  }
5172
- console.log(chalk28.dim(` Active Violation: ${session.active_violation}`));
5173
- console.log(chalk28.dim(` Reason Provided: "${reason}"`));
5247
+ console.log(chalk29.dim(` Active Violation: ${session.active_violation}`));
5248
+ console.log(chalk29.dim(` Reason Provided: "${reason}"`));
5174
5249
  const success = await performOverride(violationId, reason, process.cwd());
5175
5250
  if (success) {
5176
- console.log(chalk28.green(` \u2705 Session UNLOCKED.`));
5177
- console.log(chalk28.dim(` This event has been logged to the Mission Report.`));
5251
+ console.log(chalk29.green(` \u2705 Session UNLOCKED.`));
5252
+ console.log(chalk29.dim(` This event has been logged to the Mission Report.`));
5178
5253
  try {
5179
5254
  const projectId = getProjectId();
5180
5255
  if (projectId) {
@@ -5191,13 +5266,13 @@ function createOverrideCommand() {
5191
5266
  }, {
5192
5267
  headers: { Authorization: `Bearer ${apiKey}` }
5193
5268
  });
5194
- console.log(chalk28.dim(` \u2601 Audit log synced to Cloud.`));
5269
+ console.log(chalk29.dim(` \u2601 Audit log synced to Cloud.`));
5195
5270
  }
5196
5271
  } catch (e) {
5197
- console.log(chalk28.dim(` (Cloud audit sync failed: ${e.message})`));
5272
+ console.log(chalk29.dim(` (Cloud audit sync failed: ${e.message})`));
5198
5273
  }
5199
5274
  } else {
5200
- console.log(chalk28.red(` \u{1F6D1} Override Failed. Check project configuration.`));
5275
+ console.log(chalk29.red(` \u{1F6D1} Override Failed. Check project configuration.`));
5201
5276
  }
5202
5277
  });
5203
5278
  return override;
@@ -5207,7 +5282,7 @@ function createOverrideCommand() {
5207
5282
  init_esm_shims();
5208
5283
  init_config();
5209
5284
  import { Command as Command19 } from "commander";
5210
- import chalk29 from "chalk";
5285
+ import chalk30 from "chalk";
5211
5286
  import ora12 from "ora";
5212
5287
  import axios20 from "axios";
5213
5288
  import inquirer4 from "inquirer";
@@ -5218,7 +5293,7 @@ function createIdeaCommand() {
5218
5293
  const apiUrl = getApiUrl();
5219
5294
  const projectId = getProjectId();
5220
5295
  if (!projectId) {
5221
- console.error(chalk29.red("Project context missing. Run rigstate link."));
5296
+ console.error(chalk30.red("Project context missing. Run rigstate link."));
5222
5297
  process.exit(1);
5223
5298
  }
5224
5299
  let ideaTitle = title;
@@ -5254,14 +5329,14 @@ function createIdeaCommand() {
5254
5329
  { headers: { Authorization: `Bearer ${apiKey}` } }
5255
5330
  );
5256
5331
  if (response.data.success) {
5257
- spinner.succeed(chalk29.green("Idea Captured! \u{1F4A1}"));
5258
- console.log(chalk29.dim(`ID: ${response.data.data?.id || "Saved"}`));
5332
+ spinner.succeed(chalk30.green("Idea Captured! \u{1F4A1}"));
5333
+ console.log(chalk30.dim(`ID: ${response.data.data?.id || "Saved"}`));
5259
5334
  } else {
5260
5335
  throw new Error(response.data.error);
5261
5336
  }
5262
5337
  } catch (e) {
5263
5338
  const errorDetail = e.response?.data?.error || e.message;
5264
- console.error(chalk29.red(`
5339
+ console.error(chalk30.red(`
5265
5340
  Failed to capture idea: ${errorDetail}`));
5266
5341
  }
5267
5342
  });
@@ -5271,11 +5346,11 @@ Failed to capture idea: ${errorDetail}`));
5271
5346
  init_esm_shims();
5272
5347
  init_config();
5273
5348
  import { Command as Command20 } from "commander";
5274
- import chalk30 from "chalk";
5349
+ import chalk31 from "chalk";
5275
5350
  import ora13 from "ora";
5276
5351
  import inquirer5 from "inquirer";
5277
- import fs22 from "fs/promises";
5278
- import path25 from "path";
5352
+ import fs23 from "fs/promises";
5353
+ import path26 from "path";
5279
5354
 
5280
5355
  // ../../node_modules/simple-git/dist/esm/index.js
5281
5356
  init_esm_shims();
@@ -5315,8 +5390,8 @@ function pathspec(...paths) {
5315
5390
  cache.set(key, paths);
5316
5391
  return key;
5317
5392
  }
5318
- function isPathSpec(path26) {
5319
- return path26 instanceof String && cache.has(path26);
5393
+ function isPathSpec(path27) {
5394
+ return path27 instanceof String && cache.has(path27);
5320
5395
  }
5321
5396
  function toPaths(pathSpec) {
5322
5397
  return cache.get(pathSpec) || [];
@@ -5405,8 +5480,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
5405
5480
  function forEachLineWithContent(input, callback) {
5406
5481
  return toLinesWithContent(input, true).map((line) => callback(line));
5407
5482
  }
5408
- function folderExists(path26) {
5409
- return (0, import_file_exists.exists)(path26, import_file_exists.FOLDER);
5483
+ function folderExists(path27) {
5484
+ return (0, import_file_exists.exists)(path27, import_file_exists.FOLDER);
5410
5485
  }
5411
5486
  function append(target, item) {
5412
5487
  if (Array.isArray(target)) {
@@ -5810,8 +5885,8 @@ function checkIsRepoRootTask() {
5810
5885
  commands,
5811
5886
  format: "utf-8",
5812
5887
  onError,
5813
- parser(path26) {
5814
- return /^\.(git)?$/.test(path26.trim());
5888
+ parser(path27) {
5889
+ return /^\.(git)?$/.test(path27.trim());
5815
5890
  }
5816
5891
  };
5817
5892
  }
@@ -6245,11 +6320,11 @@ function parseGrep(grep) {
6245
6320
  const paths = /* @__PURE__ */ new Set();
6246
6321
  const results = {};
6247
6322
  forEachLineWithContent(grep, (input) => {
6248
- const [path26, line, preview] = input.split(NULL);
6249
- paths.add(path26);
6250
- (results[path26] = results[path26] || []).push({
6323
+ const [path27, line, preview] = input.split(NULL);
6324
+ paths.add(path27);
6325
+ (results[path27] = results[path27] || []).push({
6251
6326
  line: asNumber(line),
6252
- path: path26,
6327
+ path: path27,
6253
6328
  preview
6254
6329
  });
6255
6330
  });
@@ -7014,14 +7089,14 @@ var init_hash_object = __esm2({
7014
7089
  init_task();
7015
7090
  }
7016
7091
  });
7017
- function parseInit(bare, path26, text) {
7092
+ function parseInit(bare, path27, text) {
7018
7093
  const response = String(text).trim();
7019
7094
  let result;
7020
7095
  if (result = initResponseRegex.exec(response)) {
7021
- return new InitSummary(bare, path26, false, result[1]);
7096
+ return new InitSummary(bare, path27, false, result[1]);
7022
7097
  }
7023
7098
  if (result = reInitResponseRegex.exec(response)) {
7024
- return new InitSummary(bare, path26, true, result[1]);
7099
+ return new InitSummary(bare, path27, true, result[1]);
7025
7100
  }
7026
7101
  let gitDir = "";
7027
7102
  const tokens = response.split(" ");
@@ -7032,7 +7107,7 @@ function parseInit(bare, path26, text) {
7032
7107
  break;
7033
7108
  }
7034
7109
  }
7035
- return new InitSummary(bare, path26, /^re/i.test(response), gitDir);
7110
+ return new InitSummary(bare, path27, /^re/i.test(response), gitDir);
7036
7111
  }
7037
7112
  var InitSummary;
7038
7113
  var initResponseRegex;
@@ -7041,9 +7116,9 @@ var init_InitSummary = __esm2({
7041
7116
  "src/lib/responses/InitSummary.ts"() {
7042
7117
  "use strict";
7043
7118
  InitSummary = class {
7044
- constructor(bare, path26, existing, gitDir) {
7119
+ constructor(bare, path27, existing, gitDir) {
7045
7120
  this.bare = bare;
7046
- this.path = path26;
7121
+ this.path = path27;
7047
7122
  this.existing = existing;
7048
7123
  this.gitDir = gitDir;
7049
7124
  }
@@ -7055,7 +7130,7 @@ var init_InitSummary = __esm2({
7055
7130
  function hasBareCommand(command) {
7056
7131
  return command.includes(bareCommand);
7057
7132
  }
7058
- function initTask(bare = false, path26, customArgs) {
7133
+ function initTask(bare = false, path27, customArgs) {
7059
7134
  const commands = ["init", ...customArgs];
7060
7135
  if (bare && !hasBareCommand(commands)) {
7061
7136
  commands.splice(1, 0, bareCommand);
@@ -7064,7 +7139,7 @@ function initTask(bare = false, path26, customArgs) {
7064
7139
  commands,
7065
7140
  format: "utf-8",
7066
7141
  parser(text) {
7067
- return parseInit(commands.includes("--bare"), path26, text);
7142
+ return parseInit(commands.includes("--bare"), path27, text);
7068
7143
  }
7069
7144
  };
7070
7145
  }
@@ -7880,12 +7955,12 @@ var init_FileStatusSummary = __esm2({
7880
7955
  "use strict";
7881
7956
  fromPathRegex = /^(.+)\0(.+)$/;
7882
7957
  FileStatusSummary = class {
7883
- constructor(path26, index, working_dir) {
7884
- this.path = path26;
7958
+ constructor(path27, index, working_dir) {
7959
+ this.path = path27;
7885
7960
  this.index = index;
7886
7961
  this.working_dir = working_dir;
7887
7962
  if (index === "R" || working_dir === "R") {
7888
- const detail = fromPathRegex.exec(path26) || [null, path26, path26];
7963
+ const detail = fromPathRegex.exec(path27) || [null, path27, path27];
7889
7964
  this.from = detail[2] || "";
7890
7965
  this.path = detail[1] || "";
7891
7966
  }
@@ -7916,14 +7991,14 @@ function splitLine(result, lineStr) {
7916
7991
  default:
7917
7992
  return;
7918
7993
  }
7919
- function data(index, workingDir, path26) {
7994
+ function data(index, workingDir, path27) {
7920
7995
  const raw = `${index}${workingDir}`;
7921
7996
  const handler = parsers6.get(raw);
7922
7997
  if (handler) {
7923
- handler(result, path26);
7998
+ handler(result, path27);
7924
7999
  }
7925
8000
  if (raw !== "##" && raw !== "!!") {
7926
- result.files.push(new FileStatusSummary(path26, index, workingDir));
8001
+ result.files.push(new FileStatusSummary(path27, index, workingDir));
7927
8002
  }
7928
8003
  }
7929
8004
  }
@@ -8236,9 +8311,9 @@ var init_simple_git_api = __esm2({
8236
8311
  next
8237
8312
  );
8238
8313
  }
8239
- hashObject(path26, write) {
8314
+ hashObject(path27, write) {
8240
8315
  return this._runTask(
8241
- hashObjectTask(path26, write === true),
8316
+ hashObjectTask(path27, write === true),
8242
8317
  trailingFunctionArgument(arguments)
8243
8318
  );
8244
8319
  }
@@ -8591,8 +8666,8 @@ var init_branch = __esm2({
8591
8666
  }
8592
8667
  });
8593
8668
  function toPath(input) {
8594
- const path26 = input.trim().replace(/^["']|["']$/g, "");
8595
- return path26 && normalize(path26);
8669
+ const path27 = input.trim().replace(/^["']|["']$/g, "");
8670
+ return path27 && normalize(path27);
8596
8671
  }
8597
8672
  var parseCheckIgnore;
8598
8673
  var init_CheckIgnore = __esm2({
@@ -8906,8 +8981,8 @@ __export2(sub_module_exports, {
8906
8981
  subModuleTask: () => subModuleTask,
8907
8982
  updateSubModuleTask: () => updateSubModuleTask
8908
8983
  });
8909
- function addSubModuleTask(repo, path26) {
8910
- return subModuleTask(["add", repo, path26]);
8984
+ function addSubModuleTask(repo, path27) {
8985
+ return subModuleTask(["add", repo, path27]);
8911
8986
  }
8912
8987
  function initSubModuleTask(customArgs) {
8913
8988
  return subModuleTask(["init", ...customArgs]);
@@ -9237,8 +9312,8 @@ var require_git = __commonJS2({
9237
9312
  }
9238
9313
  return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
9239
9314
  };
9240
- Git2.prototype.submoduleAdd = function(repo, path26, then) {
9241
- return this._runTask(addSubModuleTask2(repo, path26), trailingFunctionArgument2(arguments));
9315
+ Git2.prototype.submoduleAdd = function(repo, path27, then) {
9316
+ return this._runTask(addSubModuleTask2(repo, path27), trailingFunctionArgument2(arguments));
9242
9317
  };
9243
9318
  Git2.prototype.submoduleUpdate = function(args, then) {
9244
9319
  return this._runTask(
@@ -9838,8 +9913,8 @@ function createReleaseCommand() {
9838
9913
  return;
9839
9914
  }
9840
9915
  spinner.text = "Scanning completed tasks...";
9841
- const pkgPath = path25.resolve(process.cwd(), "package.json");
9842
- const pkgContent = await fs22.readFile(pkgPath, "utf-8");
9916
+ const pkgPath = path26.resolve(process.cwd(), "package.json");
9917
+ const pkgContent = await fs23.readFile(pkgPath, "utf-8");
9843
9918
  const pkg2 = JSON.parse(pkgContent);
9844
9919
  const currentVersion = pkg2.version;
9845
9920
  const [major, minor, patch] = currentVersion.split(".").map(Number);
@@ -9847,7 +9922,7 @@ function createReleaseCommand() {
9847
9922
  if (type === "major") newVersion = `${major + 1}.0.0`;
9848
9923
  if (type === "minor") newVersion = `${major}.${minor + 1}.0`;
9849
9924
  if (type === "patch") newVersion = `${major}.${minor}.${patch + 1}`;
9850
- spinner.succeed(`Bumping ${pkg2.name} from ${chalk30.dim(currentVersion)} to ${chalk30.green(newVersion)}`);
9925
+ spinner.succeed(`Bumping ${pkg2.name} from ${chalk31.dim(currentVersion)} to ${chalk31.green(newVersion)}`);
9851
9926
  const { confirm } = await inquirer5.prompt([{
9852
9927
  type: "confirm",
9853
9928
  name: "confirm",
@@ -9859,17 +9934,17 @@ function createReleaseCommand() {
9859
9934
  return;
9860
9935
  }
9861
9936
  pkg2.version = newVersion;
9862
- await fs22.writeFile(pkgPath, JSON.stringify(pkg2, null, 4));
9863
- const changelogPath = path25.resolve(process.cwd(), "CHANGELOG.md");
9937
+ await fs23.writeFile(pkgPath, JSON.stringify(pkg2, null, 4));
9938
+ const changelogPath = path26.resolve(process.cwd(), "CHANGELOG.md");
9864
9939
  const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
9865
9940
  const entry = `
9866
9941
  ## [${newVersion}] - ${date}
9867
9942
  - Automated release via Rigstate.
9868
9943
  `;
9869
9944
  try {
9870
- await fs22.appendFile(changelogPath, entry);
9945
+ await fs23.appendFile(changelogPath, entry);
9871
9946
  } catch {
9872
- await fs22.writeFile(changelogPath, "# Changelog\n" + entry);
9947
+ await fs23.writeFile(changelogPath, "# Changelog\n" + entry);
9873
9948
  }
9874
9949
  spinner.start("Tagging and pushing...");
9875
9950
  await git.add(["package.json", "CHANGELOG.md"]);
@@ -9877,7 +9952,7 @@ function createReleaseCommand() {
9877
9952
  await git.addTag(`v${newVersion}`);
9878
9953
  await git.push();
9879
9954
  await git.pushTags();
9880
- spinner.succeed(chalk30.bold.green(`\u{1F680} Release v${newVersion} shipped!`));
9955
+ spinner.succeed(chalk31.bold.green(`\u{1F680} Release v${newVersion} shipped!`));
9881
9956
  } catch (e) {
9882
9957
  spinner.fail(e.message);
9883
9958
  }
@@ -9895,7 +9970,7 @@ function getContext2() {
9895
9970
  init_esm_shims();
9896
9971
  init_config();
9897
9972
  import { Command as Command21 } from "commander";
9898
- import chalk31 from "chalk";
9973
+ import chalk32 from "chalk";
9899
9974
  import ora14 from "ora";
9900
9975
  import axios21 from "axios";
9901
9976
  function createRoadmapCommand() {
@@ -9906,7 +9981,7 @@ function createRoadmapCommand() {
9906
9981
  const apiUrl = getApiUrl();
9907
9982
  const projectId = getProjectId();
9908
9983
  if (!projectId) {
9909
- spinner.fail(chalk31.red('Project context missing. Run "rigstate link".'));
9984
+ spinner.fail(chalk32.red('Project context missing. Run "rigstate link".'));
9910
9985
  return;
9911
9986
  }
9912
9987
  const response = await axios21.get(
@@ -9919,11 +9994,11 @@ function createRoadmapCommand() {
9919
9994
  const tasks = response.data.data.roadmap || [];
9920
9995
  spinner.stop();
9921
9996
  if (tasks.length === 0) {
9922
- console.log(chalk31.yellow("\nRoadmap is empty. Use the web UI to define your journey."));
9997
+ console.log(chalk32.yellow("\nRoadmap is empty. Use the web UI to define your journey."));
9923
9998
  return;
9924
9999
  }
9925
- console.log("\n" + chalk31.bold.underline("\u{1F6F0}\uFE0F TACTICAL OVERVIEW: PROJECT ROADMAP"));
9926
- console.log(chalk31.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\u2500\u2500\u2500\u2500\u2500\u2500"));
10000
+ console.log("\n" + chalk32.bold.underline("\u{1F6F0}\uFE0F TACTICAL OVERVIEW: PROJECT ROADMAP"));
10001
+ console.log(chalk32.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\u2500\u2500\u2500\u2500\u2500\u2500"));
9927
10002
  const columns = {
9928
10003
  "IN_PROGRESS": [],
9929
10004
  "ACTIVE": [],
@@ -9935,14 +10010,14 @@ function createRoadmapCommand() {
9935
10010
  columns[t.status].push(t);
9936
10011
  }
9937
10012
  });
9938
- displayColumn("\u{1F525} IN PROGRESS", columns.IN_PROGRESS, chalk31.yellow);
9939
- displayColumn("\u25B6\uFE0F ACTIVE / NEXT", columns.ACTIVE, chalk31.green);
9940
- displayColumn("\u{1F512} LOCKED", columns.LOCKED, chalk31.blue);
9941
- displayColumn("\u23F3 PENDING", columns.PENDING, chalk31.gray);
9942
- console.log(chalk31.dim("\n\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\u2500\u2500\u2500\u2500\u2500\u2500"));
9943
- console.log(chalk31.dim(`Total: ${tasks.length} tasks | Run "rigstate work" to start coding.`));
10013
+ displayColumn("\u{1F525} IN PROGRESS", columns.IN_PROGRESS, chalk32.yellow);
10014
+ displayColumn("\u25B6\uFE0F ACTIVE / NEXT", columns.ACTIVE, chalk32.green);
10015
+ displayColumn("\u{1F512} LOCKED", columns.LOCKED, chalk32.blue);
10016
+ displayColumn("\u23F3 PENDING", columns.PENDING, chalk32.gray);
10017
+ console.log(chalk32.dim("\n\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\u2500\u2500\u2500\u2500\u2500\u2500"));
10018
+ console.log(chalk32.dim(`Total: ${tasks.length} tasks | Run "rigstate work" to start coding.`));
9944
10019
  } catch (e) {
9945
- spinner.fail(chalk31.red(`
10020
+ spinner.fail(chalk32.red(`
9946
10021
  Failed to fetch roadmap: ${e.message}`));
9947
10022
  }
9948
10023
  });
@@ -9953,8 +10028,8 @@ function displayColumn(title, items, color) {
9953
10028
  ${color.bold(title)}`);
9954
10029
  items.sort((a, b) => a.step_number - b.step_number).forEach((item) => {
9955
10030
  const id = `T-${item.step_number}`.padEnd(8);
9956
- const priority = item.priority === "MVP" ? chalk31.magenta(" [MVP]") : "";
9957
- console.log(` ${color("\u2022")} ${chalk31.bold(id)} ${item.title}${priority}`);
10031
+ const priority = item.priority === "MVP" ? chalk32.magenta(" [MVP]") : "";
10032
+ console.log(` ${color("\u2022")} ${chalk32.bold(id)} ${item.title}${priority}`);
9958
10033
  });
9959
10034
  }
9960
10035
 
@@ -9962,7 +10037,7 @@ ${color.bold(title)}`);
9962
10037
  init_esm_shims();
9963
10038
  init_config();
9964
10039
  import { Command as Command22 } from "commander";
9965
- import chalk32 from "chalk";
10040
+ import chalk33 from "chalk";
9966
10041
  import ora15 from "ora";
9967
10042
  import inquirer6 from "inquirer";
9968
10043
  function createCouncilCommand() {
@@ -9973,7 +10048,7 @@ function createCouncilCommand() {
9973
10048
  const apiUrl = getApiUrl();
9974
10049
  const projectId = getProjectId();
9975
10050
  if (!projectId) {
9976
- console.error(chalk32.red('Project context missing. Run "rigstate link".'));
10051
+ console.error(chalk33.red('Project context missing. Run "rigstate link".'));
9977
10052
  return;
9978
10053
  }
9979
10054
  let sessionTopic = topic;
@@ -9985,25 +10060,25 @@ function createCouncilCommand() {
9985
10060
  }]);
9986
10061
  sessionTopic = ans.topic;
9987
10062
  }
9988
- console.log(chalk32.bold.magenta("\n\u2696\uFE0F CONVENING THE COUNCIL OF SOVEREIGNTY\n"));
9989
- console.log(chalk32.dim(`Topic: ${sessionTopic}`));
9990
- console.log(chalk32.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\u2500\u2500\u2500\u2500\u2500\u2500"));
9991
- console.log(chalk32.yellow("\n\u{1F9E0} Frank (Architect): Analyzing alignment with Project DNA..."));
10063
+ console.log(chalk33.bold.magenta("\n\u2696\uFE0F CONVENING THE COUNCIL OF SOVEREIGNTY\n"));
10064
+ console.log(chalk33.dim(`Topic: ${sessionTopic}`));
10065
+ console.log(chalk33.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\u2500\u2500\u2500\u2500\u2500\u2500"));
10066
+ console.log(chalk33.yellow("\n\u{1F9E0} Frank (Architect): Analyzing alignment with Project DNA..."));
9992
10067
  await sleep(1500);
9993
- console.log(chalk32.gray(' "This decision affects our backend scalability. I recommend caution."'));
9994
- console.log(chalk32.blue("\n\u{1F6E1}\uFE0F Sigrid (Curator): Checking historical precedents..."));
10068
+ console.log(chalk33.gray(' "This decision affects our backend scalability. I recommend caution."'));
10069
+ console.log(chalk33.blue("\n\u{1F6E1}\uFE0F Sigrid (Curator): Checking historical precedents..."));
9995
10070
  await sleep(1500);
9996
- console.log(chalk32.gray(` "Similar patterns in other projects led to technical debt. Let's review RLS."`));
9997
- console.log(chalk32.green("\n\u{1F4D0} Einar (Analyst): Scanning dependency impact..."));
10071
+ console.log(chalk33.gray(` "Similar patterns in other projects led to technical debt. Let's review RLS."`));
10072
+ console.log(chalk33.green("\n\u{1F4D0} Einar (Analyst): Scanning dependency impact..."));
9998
10073
  await sleep(1500);
9999
- console.log(chalk32.gray(' "Implementation will require updating 3 core services."'));
10000
- console.log(chalk32.bold.white("\n\u{1F4CB} [FINAL DECISION RECORD]"));
10001
- console.log(chalk32.white(" Status: Approved with conditions"));
10002
- console.log(chalk32.white(" Rationale: Value outweighs migration cost. Ensure SEC-SQL-01 compliance."));
10003
- console.log(chalk32.dim("\n\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\u2500\u2500\u2500\u2500\u2500\u2500"));
10004
- console.log(chalk32.green("\u2705 Decision saved to Project Brain (ADR-102)"));
10074
+ console.log(chalk33.gray(' "Implementation will require updating 3 core services."'));
10075
+ console.log(chalk33.bold.white("\n\u{1F4CB} [FINAL DECISION RECORD]"));
10076
+ console.log(chalk33.white(" Status: Approved with conditions"));
10077
+ console.log(chalk33.white(" Rationale: Value outweighs migration cost. Ensure SEC-SQL-01 compliance."));
10078
+ console.log(chalk33.dim("\n\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\u2500\u2500\u2500\u2500\u2500\u2500"));
10079
+ console.log(chalk33.green("\u2705 Decision saved to Project Brain (ADR-102)"));
10005
10080
  } catch (e) {
10006
- console.error(chalk32.red(`
10081
+ console.error(chalk33.red(`
10007
10082
  Council session aborted: ${e.message}`));
10008
10083
  }
10009
10084
  });
@@ -10050,19 +10125,19 @@ program.hook("preAction", async () => {
10050
10125
  });
10051
10126
  program.on("--help", () => {
10052
10127
  console.log("");
10053
- console.log(chalk33.bold("Examples:"));
10128
+ console.log(chalk34.bold("Examples:"));
10054
10129
  console.log("");
10055
- console.log(chalk33.cyan(" $ rigstate login sk_rigstate_your_api_key"));
10056
- console.log(chalk33.dim(" Authenticate with your Rigstate API key"));
10130
+ console.log(chalk34.cyan(" $ rigstate login sk_rigstate_your_api_key"));
10131
+ console.log(chalk34.dim(" Authenticate with your Rigstate API key"));
10057
10132
  console.log("");
10058
- console.log(chalk33.cyan(" $ rigstate scan"));
10059
- console.log(chalk33.dim(" Scan the current directory"));
10133
+ console.log(chalk34.cyan(" $ rigstate scan"));
10134
+ console.log(chalk34.dim(" Scan the current directory"));
10060
10135
  console.log("");
10061
- console.log(chalk33.cyan(" $ rigstate scan ./src --project abc123"));
10062
- console.log(chalk33.dim(" Scan a specific directory with project ID"));
10136
+ console.log(chalk34.cyan(" $ rigstate scan ./src --project abc123"));
10137
+ console.log(chalk34.dim(" Scan a specific directory with project ID"));
10063
10138
  console.log("");
10064
- console.log(chalk33.cyan(" $ rigstate scan --json"));
10065
- console.log(chalk33.dim(" Output results in JSON format (useful for IDE extensions)"));
10139
+ console.log(chalk34.cyan(" $ rigstate scan --json"));
10140
+ console.log(chalk34.dim(" Output results in JSON format (useful for IDE extensions)"));
10066
10141
  console.log("");
10067
10142
  });
10068
10143
  program.parse(process.argv);