@rigstate/cli 0.7.26 → 0.7.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -279,12 +279,12 @@ async function syncProjectRules(projectId, apiKey, apiUrl, dryRun = false) {
279
279
  }
280
280
  const files = syncResponse.data.data.files;
281
281
  if (files && Array.isArray(files)) {
282
- const fs24 = await import("fs/promises");
283
- const path26 = await import("path");
282
+ const fs25 = await import("fs/promises");
283
+ const path27 = await import("path");
284
284
  for (const file of files) {
285
- const filePath = path26.join(process.cwd(), file.path);
286
- await fs24.mkdir(path26.dirname(filePath), { recursive: true });
287
- await fs24.writeFile(filePath, file.content, "utf-8");
285
+ const filePath = path27.join(process.cwd(), file.path);
286
+ await fs25.mkdir(path27.dirname(filePath), { recursive: true });
287
+ await fs25.writeFile(filePath, file.content, "utf-8");
288
288
  }
289
289
  console.log(import_chalk3.default.dim(` \u{1F4BE} Wrote ${files.length} rule files to local .cursor/rules/`));
290
290
  }
@@ -333,136 +333,6 @@ var init_sync_rules = __esm({
333
333
  }
334
334
  });
335
335
 
336
- // src/commands/hooks.ts
337
- var hooks_exports = {};
338
- __export(hooks_exports, {
339
- createHooksCommand: () => createHooksCommand
340
- });
341
- function createHooksCommand() {
342
- const hooks = new import_commander4.Command("hooks").description("Manage git hooks for Guardian integration");
343
- 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) => {
344
- try {
345
- const gitDir = import_path2.default.join(process.cwd(), ".git");
346
- try {
347
- await import_promises2.default.access(gitDir);
348
- } catch {
349
- console.log(import_chalk4.default.red("\u274C Not a git repository."));
350
- console.log(import_chalk4.default.dim(' Initialize with "git init" first.'));
351
- process.exit(1);
352
- }
353
- const hooksDir = import_path2.default.join(gitDir, "hooks");
354
- await import_promises2.default.mkdir(hooksDir, { recursive: true });
355
- const preCommitPath = import_path2.default.join(hooksDir, "pre-commit");
356
- let existingContent = "";
357
- try {
358
- existingContent = await import_promises2.default.readFile(preCommitPath, "utf-8");
359
- if (existingContent.includes("rigstate")) {
360
- console.log(import_chalk4.default.yellow("\u26A0 Rigstate pre-commit hook already installed."));
361
- console.log(import_chalk4.default.dim(' Use "rigstate hooks uninstall" to remove first.'));
362
- return;
363
- }
364
- } catch {
365
- }
366
- let script = PRE_COMMIT_SCRIPT;
367
- if (options.strict === "all") {
368
- script = script.replace("--strict=critical", "--strict");
369
- }
370
- if (existingContent && !existingContent.includes("rigstate")) {
371
- const combinedScript = existingContent + "\n\n" + script.replace("#!/bin/sh\n", "");
372
- await import_promises2.default.writeFile(preCommitPath, combinedScript, { mode: 493 });
373
- console.log(import_chalk4.default.green("\u2705 Rigstate hook appended to existing pre-commit."));
374
- } else {
375
- await import_promises2.default.writeFile(preCommitPath, script, { mode: 493 });
376
- console.log(import_chalk4.default.green("\u2705 Pre-commit hook installed!"));
377
- }
378
- console.log(import_chalk4.default.dim(` Path: ${preCommitPath}`));
379
- console.log(import_chalk4.default.dim(` Strict level: ${options.strict}`));
380
- console.log("");
381
- console.log(import_chalk4.default.cyan("Guardian will now check your code before each commit."));
382
- console.log(import_chalk4.default.dim('Use "rigstate hooks uninstall" to remove the hook.'));
383
- } catch (error) {
384
- console.error(import_chalk4.default.red("Failed to install hook:"), error.message);
385
- process.exit(1);
386
- }
387
- });
388
- hooks.command("uninstall").description("Remove Rigstate pre-commit hook").action(async () => {
389
- try {
390
- const preCommitPath = import_path2.default.join(process.cwd(), ".git", "hooks", "pre-commit");
391
- try {
392
- const content = await import_promises2.default.readFile(preCommitPath, "utf-8");
393
- if (!content.includes("rigstate")) {
394
- console.log(import_chalk4.default.yellow("\u26A0 No Rigstate hook found in pre-commit."));
395
- return;
396
- }
397
- if (content.includes("# Rigstate Guardian Pre-commit Hook") && content.trim().split("\n").filter((l) => l && !l.startsWith("#")).length <= 4) {
398
- await import_promises2.default.unlink(preCommitPath);
399
- console.log(import_chalk4.default.green("\u2705 Pre-commit hook removed."));
400
- } else {
401
- const lines = content.split("\n");
402
- const filteredLines = [];
403
- let inRigstateSection = false;
404
- for (const line of lines) {
405
- if (line.includes("Rigstate Guardian Pre-commit Hook")) {
406
- inRigstateSection = true;
407
- continue;
408
- }
409
- if (inRigstateSection && line.includes("exit $?")) {
410
- inRigstateSection = false;
411
- continue;
412
- }
413
- if (!inRigstateSection && !line.includes("rigstate check")) {
414
- filteredLines.push(line);
415
- }
416
- }
417
- await import_promises2.default.writeFile(preCommitPath, filteredLines.join("\n"), { mode: 493 });
418
- console.log(import_chalk4.default.green("\u2705 Rigstate section removed from pre-commit hook."));
419
- }
420
- } catch {
421
- console.log(import_chalk4.default.yellow("\u26A0 No pre-commit hook found."));
422
- }
423
- } catch (error) {
424
- console.error(import_chalk4.default.red("Failed to uninstall hook:"), error.message);
425
- process.exit(1);
426
- }
427
- });
428
- return hooks;
429
- }
430
- var import_commander4, import_chalk4, import_promises2, import_path2, PRE_COMMIT_SCRIPT;
431
- var init_hooks = __esm({
432
- "src/commands/hooks.ts"() {
433
- "use strict";
434
- init_cjs_shims();
435
- import_commander4 = require("commander");
436
- import_chalk4 = __toESM(require("chalk"), 1);
437
- import_promises2 = __toESM(require("fs/promises"), 1);
438
- import_path2 = __toESM(require("path"), 1);
439
- PRE_COMMIT_SCRIPT = `#!/bin/sh
440
- # Rigstate Guardian Pre-commit Hook
441
- # Installed by: rigstate hooks install
442
-
443
- # 1. Silent Sentinel Check (Phase 5)
444
- if [ -f .rigstate/guardian.lock ]; then
445
- echo "\u{1F6D1} INTERVENTION ACTIVE: Commit blocked by Silent Sentinel."
446
- echo " A critical violation ('HARD_LOCK') was detected by the Guardian Daemon."
447
- echo " Please fix the violation to unlock the repo."
448
- echo ""
449
- if grep -q "HARD_LOCK_ACTIVE" .rigstate/guardian.lock; then
450
- cat .rigstate/guardian.lock
451
- fi
452
- exit 1
453
- fi
454
-
455
- echo "\u{1F6E1}\uFE0F Running Guardian checks..."
456
-
457
- # Run check with strict mode for critical violations
458
- rigstate check --staged --strict=critical
459
-
460
- # Exit with the same code as rigstate check
461
- exit $?
462
- `;
463
- }
464
- });
465
-
466
336
  // src/commands/suggest.ts
467
337
  var suggest_exports = {};
468
338
  __export(suggest_exports, {
@@ -486,28 +356,28 @@ async function suggestNextMove(projectId, apiKey, apiUrl) {
486
356
  if (tasks.length === 0) return;
487
357
  const nextTask = tasks[0];
488
358
  console.log("");
489
- console.log(import_chalk5.default.bold("\u{1F3AF} TACTICAL INTELLIGENCE"));
490
- console.log(import_chalk5.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
491
- console.log(`${import_chalk5.default.bold("Active Phase:")} Implementation`);
492
- console.log(`${import_chalk5.default.bold("Next Mission:")} ${import_chalk5.default.cyan(nextTask.title)}`);
359
+ console.log(import_chalk4.default.bold("\u{1F3AF} TACTICAL INTELLIGENCE"));
360
+ console.log(import_chalk4.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
361
+ console.log(`${import_chalk4.default.bold("Active Phase:")} Implementation`);
362
+ console.log(`${import_chalk4.default.bold("Next Mission:")} ${import_chalk4.default.cyan(nextTask.title)}`);
493
363
  if (nextTask.role) {
494
- console.log(`${import_chalk5.default.bold("Required Role:")} ${import_chalk5.default.magenta(nextTask.role)}`);
364
+ console.log(`${import_chalk4.default.bold("Required Role:")} ${import_chalk4.default.magenta(nextTask.role)}`);
495
365
  }
496
366
  console.log("");
497
- console.log(import_chalk5.default.yellow("SUGGESTED NEXT MOVE:"));
498
- console.log(import_chalk5.default.white(`> rigstate work start ${nextTask.id} `) + import_chalk5.default.dim("(Start this task)"));
499
- console.log(import_chalk5.default.white(`> rigstate chat "How do I solve T-${nextTask.step_number}?" `) + import_chalk5.default.dim("(Ask Architect)"));
500
- console.log(import_chalk5.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
367
+ console.log(import_chalk4.default.yellow("SUGGESTED NEXT MOVE:"));
368
+ console.log(import_chalk4.default.white(`> rigstate work start ${nextTask.id} `) + import_chalk4.default.dim("(Start this task)"));
369
+ console.log(import_chalk4.default.white(`> rigstate chat "How do I solve T-${nextTask.step_number}?" `) + import_chalk4.default.dim("(Ask Architect)"));
370
+ console.log(import_chalk4.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
501
371
  console.log("");
502
372
  } catch (e) {
503
373
  }
504
374
  }
505
- var import_chalk5, import_axios3;
375
+ var import_chalk4, import_axios3;
506
376
  var init_suggest = __esm({
507
377
  "src/commands/suggest.ts"() {
508
378
  "use strict";
509
379
  init_cjs_shims();
510
- import_chalk5 = __toESM(require("chalk"), 1);
380
+ import_chalk4 = __toESM(require("chalk"), 1);
511
381
  import_axios3 = __toESM(require("axios"), 1);
512
382
  }
513
383
  });
@@ -540,18 +410,18 @@ async function provisionSkills(apiUrl, apiKey, projectId, rootDir) {
540
410
  }
541
411
  } catch (e) {
542
412
  const msg = e.response?.data?.error || e.message;
543
- console.log(import_chalk9.default.dim(` (Skills API not available: ${msg}, using core library)`));
413
+ console.log(import_chalk8.default.dim(` (Skills API not available: ${msg}, using core library)`));
544
414
  }
545
415
  if (skills.length === 0) {
546
416
  const { getRigstateStandardSkills } = await import("@rigstate/rules-engine");
547
417
  const coreSkills = getRigstateStandardSkills();
548
418
  skills.push(...coreSkills);
549
419
  }
550
- const skillsDir = import_path7.default.join(rootDir, ".agent", "skills");
551
- await import_promises7.default.mkdir(skillsDir, { recursive: true });
420
+ const skillsDir = import_path6.default.join(rootDir, ".agent", "skills");
421
+ await import_promises6.default.mkdir(skillsDir, { recursive: true });
552
422
  for (const skill of skills) {
553
- const skillDir = import_path7.default.join(skillsDir, skill.name);
554
- await import_promises7.default.mkdir(skillDir, { recursive: true });
423
+ const skillDir = import_path6.default.join(skillsDir, skill.name);
424
+ await import_promises6.default.mkdir(skillDir, { recursive: true });
555
425
  const skillContent = `---
556
426
  name: ${skill.name}
557
427
  description: ${skill.description}
@@ -564,10 +434,10 @@ ${skill.content}
564
434
 
565
435
  ---
566
436
  *Provisioned by Rigstate CLI. Do not modify manually.*`;
567
- const skillPath = import_path7.default.join(skillDir, "SKILL.md");
568
- await import_promises7.default.writeFile(skillPath, skillContent, "utf-8");
437
+ const skillPath = import_path6.default.join(skillDir, "SKILL.md");
438
+ await import_promises6.default.writeFile(skillPath, skillContent, "utf-8");
569
439
  }
570
- console.log(import_chalk9.default.green(` \u2705 Provisioned ${skills.length} skill(s) to .agent/skills/`));
440
+ console.log(import_chalk8.default.green(` \u2705 Provisioned ${skills.length} skill(s) to .agent/skills/`));
571
441
  return skills;
572
442
  }
573
443
  function generateSkillsDiscoveryBlock(skills) {
@@ -582,16 +452,16 @@ ${skillBlocks}
582
452
  </available_skills>`;
583
453
  }
584
454
  async function jitProvisionSkill(skillId, apiUrl, apiKey, projectId, rootDir) {
585
- const rulesPath = import_path7.default.join(rootDir, ".cursorrules");
455
+ const rulesPath = import_path6.default.join(rootDir, ".cursorrules");
586
456
  let rulesContent = "";
587
457
  try {
588
- rulesContent = await import_promises7.default.readFile(rulesPath, "utf-8");
458
+ rulesContent = await import_promises6.default.readFile(rulesPath, "utf-8");
589
459
  } catch (e) {
590
460
  return false;
591
461
  }
592
462
  const isProvisioned = rulesContent.includes(`<name>${skillId}</name>`) || rulesContent.includes(`.agent/skills/${skillId}`);
593
463
  if (isProvisioned) return false;
594
- console.log(import_chalk9.default.yellow(` \u26A1 JIT PROVISIONING: Injecting ${skillId}...`));
464
+ console.log(import_chalk8.default.yellow(` \u26A1 JIT PROVISIONING: Injecting ${skillId}...`));
595
465
  try {
596
466
  const skills = await provisionSkills(apiUrl, apiKey, projectId, rootDir);
597
467
  const skillsBlock = generateSkillsDiscoveryBlock(skills);
@@ -606,22 +476,22 @@ async function jitProvisionSkill(skillId, apiUrl, apiKey, projectId, rootDir) {
606
476
  rulesContent = rulesContent.slice(0, insertPoint + 3) + "\n\n" + skillsBlock + "\n" + rulesContent.slice(insertPoint + 3);
607
477
  }
608
478
  }
609
- await import_promises7.default.writeFile(rulesPath, rulesContent, "utf-8");
479
+ await import_promises6.default.writeFile(rulesPath, rulesContent, "utf-8");
610
480
  return true;
611
481
  } catch (e) {
612
- console.log(import_chalk9.default.red(` Failed to provision skill: ${e.message}`));
482
+ console.log(import_chalk8.default.red(` Failed to provision skill: ${e.message}`));
613
483
  return false;
614
484
  }
615
485
  }
616
- var import_axios6, import_promises7, import_path7, import_chalk9;
486
+ var import_axios6, import_promises6, import_path6, import_chalk8;
617
487
  var init_skills_provisioner = __esm({
618
488
  "src/utils/skills-provisioner.ts"() {
619
489
  "use strict";
620
490
  init_cjs_shims();
621
491
  import_axios6 = __toESM(require("axios"), 1);
622
- import_promises7 = __toESM(require("fs/promises"), 1);
623
- import_path7 = __toESM(require("path"), 1);
624
- import_chalk9 = __toESM(require("chalk"), 1);
492
+ import_promises6 = __toESM(require("fs/promises"), 1);
493
+ import_path6 = __toESM(require("path"), 1);
494
+ import_chalk8 = __toESM(require("chalk"), 1);
625
495
  }
626
496
  });
627
497
 
@@ -637,8 +507,8 @@ __export(governance_exports, {
637
507
  });
638
508
  async function getGovernanceConfig(rootDir = process.cwd()) {
639
509
  try {
640
- const configPath = import_path8.default.join(rootDir, "rigstate.config.json");
641
- const content = await import_promises8.default.readFile(configPath, "utf-8");
510
+ const configPath = import_path7.default.join(rootDir, "rigstate.config.json");
511
+ const content = await import_promises7.default.readFile(configPath, "utf-8");
642
512
  const userConfig = JSON.parse(content);
643
513
  return {
644
514
  governance: {
@@ -652,50 +522,50 @@ async function getGovernanceConfig(rootDir = process.cwd()) {
652
522
  }
653
523
  async function getSessionState(rootDir = process.cwd()) {
654
524
  try {
655
- const sessionPath = import_path8.default.join(rootDir, ".rigstate", "session.json");
656
- const content = await import_promises8.default.readFile(sessionPath, "utf-8");
525
+ const sessionPath = import_path7.default.join(rootDir, ".rigstate", "session.json");
526
+ const content = await import_promises7.default.readFile(sessionPath, "utf-8");
657
527
  return JSON.parse(content);
658
528
  } catch (e) {
659
529
  return DEFAULT_SESSION;
660
530
  }
661
531
  }
662
532
  async function setSoftLock(reason, violationId, rootDir = process.cwd()) {
663
- const sessionPath = import_path8.default.join(rootDir, ".rigstate", "session.json");
533
+ const sessionPath = import_path7.default.join(rootDir, ".rigstate", "session.json");
664
534
  const state = {
665
535
  status: "SOFT_LOCK",
666
536
  active_violation: violationId,
667
537
  lock_reason: reason,
668
538
  last_updated: (/* @__PURE__ */ new Date()).toISOString()
669
539
  };
670
- await import_promises8.default.mkdir(import_path8.default.dirname(sessionPath), { recursive: true });
671
- await import_promises8.default.writeFile(sessionPath, JSON.stringify(state, null, 2), "utf-8");
540
+ await import_promises7.default.mkdir(import_path7.default.dirname(sessionPath), { recursive: true });
541
+ await import_promises7.default.writeFile(sessionPath, JSON.stringify(state, null, 2), "utf-8");
672
542
  }
673
543
  async function clearSoftLock(rootDir = process.cwd()) {
674
- const sessionPath = import_path8.default.join(rootDir, ".rigstate", "session.json");
544
+ const sessionPath = import_path7.default.join(rootDir, ".rigstate", "session.json");
675
545
  const state = {
676
546
  ...DEFAULT_SESSION,
677
547
  last_updated: (/* @__PURE__ */ new Date()).toISOString()
678
548
  };
679
- await import_promises8.default.mkdir(import_path8.default.dirname(sessionPath), { recursive: true });
680
- await import_promises8.default.writeFile(sessionPath, JSON.stringify(state, null, 2), "utf-8");
549
+ await import_promises7.default.mkdir(import_path7.default.dirname(sessionPath), { recursive: true });
550
+ await import_promises7.default.writeFile(sessionPath, JSON.stringify(state, null, 2), "utf-8");
681
551
  }
682
552
  async function performOverride(violationId, reason, rootDir = process.cwd()) {
683
553
  const config2 = await getGovernanceConfig(rootDir);
684
554
  if (!config2.governance.allow_overrides) {
685
- console.log(import_chalk10.default.red("\u274C Overrides are disabled for this project."));
555
+ console.log(import_chalk9.default.red("\u274C Overrides are disabled for this project."));
686
556
  return false;
687
557
  }
688
558
  await clearSoftLock(rootDir);
689
559
  return true;
690
560
  }
691
- var import_promises8, import_path8, import_chalk10, InterventionLevel, DEFAULT_CONFIG, DEFAULT_SESSION;
561
+ var import_promises7, import_path7, import_chalk9, InterventionLevel, DEFAULT_CONFIG, DEFAULT_SESSION;
692
562
  var init_governance = __esm({
693
563
  "src/utils/governance.ts"() {
694
564
  "use strict";
695
565
  init_cjs_shims();
696
- import_promises8 = __toESM(require("fs/promises"), 1);
697
- import_path8 = __toESM(require("path"), 1);
698
- import_chalk10 = __toESM(require("chalk"), 1);
566
+ import_promises7 = __toESM(require("fs/promises"), 1);
567
+ import_path7 = __toESM(require("path"), 1);
568
+ import_chalk9 = __toESM(require("chalk"), 1);
699
569
  InterventionLevel = /* @__PURE__ */ ((InterventionLevel2) => {
700
570
  InterventionLevel2[InterventionLevel2["GHOST"] = 0] = "GHOST";
701
571
  InterventionLevel2[InterventionLevel2["NUDGE"] = 1] = "NUDGE";
@@ -724,16 +594,16 @@ __export(watchdog_exports, {
724
594
  });
725
595
  async function countLines(filePath) {
726
596
  try {
727
- const content = await import_promises9.default.readFile(filePath, "utf-8");
597
+ const content = await import_promises8.default.readFile(filePath, "utf-8");
728
598
  return content.split("\n").length;
729
599
  } catch (e) {
730
600
  return 0;
731
601
  }
732
602
  }
733
603
  async function getFiles(dir, extension) {
734
- const entries = await import_promises9.default.readdir(dir, { withFileTypes: true });
604
+ const entries = await import_promises8.default.readdir(dir, { withFileTypes: true });
735
605
  const files = await Promise.all(entries.map(async (entry) => {
736
- const res = import_path9.default.resolve(dir, entry.name);
606
+ const res = import_path8.default.resolve(dir, entry.name);
737
607
  if (entry.isDirectory()) {
738
608
  if (entry.name === "node_modules" || entry.name === ".git" || entry.name === ".next" || entry.name === "dist") return [];
739
609
  return getFiles(res, extension);
@@ -761,8 +631,8 @@ async function fetchRulesFromApi(projectId) {
761
631
  }
762
632
  } catch (error) {
763
633
  try {
764
- const cachePath = import_path9.default.join(process.cwd(), CACHE_FILE);
765
- const content = await import_promises9.default.readFile(cachePath, "utf-8");
634
+ const cachePath = import_path8.default.join(process.cwd(), CACHE_FILE);
635
+ const content = await import_promises8.default.readFile(cachePath, "utf-8");
766
636
  const cached = JSON.parse(content);
767
637
  if (cached.settings) {
768
638
  return {
@@ -781,7 +651,7 @@ async function fetchRulesFromApi(projectId) {
781
651
  };
782
652
  }
783
653
  async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
784
- console.log(import_chalk11.default.bold("\n\u{1F6E1}\uFE0F Active Guardian Watchdog Initiated..."));
654
+ console.log(import_chalk10.default.bold("\n\u{1F6E1}\uFE0F Active Guardian Watchdog Initiated..."));
785
655
  let lmax = settings.lmax || DEFAULT_LMAX;
786
656
  let lmaxWarning = settings.lmax_warning || DEFAULT_LMAX_WARNING;
787
657
  let ruleSource = settings.lmax ? "Settings (Passed)" : "Default";
@@ -791,47 +661,47 @@ async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
791
661
  lmaxWarning = apiRules.lmaxWarning;
792
662
  ruleSource = apiRules.source;
793
663
  }
794
- console.log(import_chalk11.default.dim(`Governance Rules: L_max=${lmax}, L_max_warning=${lmaxWarning}, Source: ${ruleSource}`));
664
+ console.log(import_chalk10.default.dim(`Governance Rules: L_max=${lmax}, L_max_warning=${lmaxWarning}, Source: ${ruleSource}`));
795
665
  const targetExtensions = [".ts", ".tsx"];
796
666
  let scanTarget = rootPath;
797
- const webSrc = import_path9.default.join(rootPath, "apps", "web", "src");
667
+ const webSrc = import_path8.default.join(rootPath, "apps", "web", "src");
798
668
  try {
799
- await import_promises9.default.access(webSrc);
669
+ await import_promises8.default.access(webSrc);
800
670
  scanTarget = webSrc;
801
671
  } catch {
802
672
  }
803
- console.log(import_chalk11.default.dim(`Scanning target: ${import_path9.default.relative(process.cwd(), scanTarget)}`));
673
+ console.log(import_chalk10.default.dim(`Scanning target: ${import_path8.default.relative(process.cwd(), scanTarget)}`));
804
674
  const files = await getFiles(scanTarget, targetExtensions);
805
675
  let violations = 0;
806
676
  let warnings = 0;
807
677
  const results = [];
808
678
  for (const file of files) {
809
679
  const lines = await countLines(file);
810
- const relPath = import_path9.default.relative(rootPath, file);
680
+ const relPath = import_path8.default.relative(rootPath, file);
811
681
  if (lines > lmax) {
812
682
  results.push({ file: relPath, lines, status: "VIOLATION" });
813
683
  violations++;
814
- console.log(import_chalk11.default.red(`[VIOLATION] ${relPath}: ${lines} lines (Limit: ${lmax})`));
684
+ console.log(import_chalk10.default.red(`[VIOLATION] ${relPath}: ${lines} lines (Limit: ${lmax})`));
815
685
  } else if (lines > lmaxWarning) {
816
686
  results.push({ file: relPath, lines, status: "WARNING" });
817
687
  warnings++;
818
- console.log(import_chalk11.default.yellow(`[WARNING] ${relPath}: ${lines} lines (Threshold: ${lmaxWarning})`));
688
+ console.log(import_chalk10.default.yellow(`[WARNING] ${relPath}: ${lines} lines (Threshold: ${lmaxWarning})`));
819
689
  }
820
690
  }
821
691
  if (violations === 0 && warnings === 0) {
822
- console.log(import_chalk11.default.green(`\u2714 All ${files.length} files are within governance limits.`));
692
+ console.log(import_chalk10.default.green(`\u2714 All ${files.length} files are within governance limits.`));
823
693
  } else {
824
- console.log("\n" + import_chalk11.default.bold("Summary:"));
825
- console.log(import_chalk11.default.red(`Violations: ${violations}`));
826
- console.log(import_chalk11.default.yellow(`Warnings: ${warnings}`));
694
+ console.log("\n" + import_chalk10.default.bold("Summary:"));
695
+ console.log(import_chalk10.default.red(`Violations: ${violations}`));
696
+ console.log(import_chalk10.default.yellow(`Warnings: ${warnings}`));
827
697
  const { getGovernanceConfig: getGovernanceConfig2, setSoftLock: setSoftLock2, InterventionLevel: InterventionLevel2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
828
698
  const { governance } = await getGovernanceConfig2(rootPath);
829
- console.log(import_chalk11.default.dim(`Intervention Level: ${InterventionLevel2[governance.intervention_level] || "UNKNOWN"} (${governance.intervention_level})`));
699
+ console.log(import_chalk10.default.dim(`Intervention Level: ${InterventionLevel2[governance.intervention_level] || "UNKNOWN"} (${governance.intervention_level})`));
830
700
  if (violations > 0) {
831
- console.log(import_chalk11.default.red.bold("\nCRITICAL: Governance violations detected. Immediate refactoring required."));
701
+ console.log(import_chalk10.default.red.bold("\nCRITICAL: Governance violations detected. Immediate refactoring required."));
832
702
  if (governance.intervention_level >= InterventionLevel2.SENTINEL) {
833
- console.log(import_chalk11.default.red.bold("\u{1F6D1} SENTINEL MODE: Session SOFT_LOCKED until resolved."));
834
- console.log(import_chalk11.default.red(' Run "rigstate override <id> --reason \\"...\\"" if this is an emergency.'));
703
+ console.log(import_chalk10.default.red.bold("\u{1F6D1} SENTINEL MODE: Session SOFT_LOCKED until resolved."));
704
+ console.log(import_chalk10.default.red(' Run "rigstate override <id> --reason \\"...\\"" if this is an emergency.'));
835
705
  await setSoftLock2("Sentinel Mode: Governance Violations Detected", "ARC-VIOLATION", rootPath);
836
706
  }
837
707
  }
@@ -854,20 +724,20 @@ async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
854
724
  }, {
855
725
  headers: { Authorization: `Bearer ${apiKey}` }
856
726
  });
857
- console.log(import_chalk11.default.dim("\u2714 Violations synced to Rigstate Cloud."));
727
+ console.log(import_chalk10.default.dim("\u2714 Violations synced to Rigstate Cloud."));
858
728
  } catch (e) {
859
- console.log(import_chalk11.default.dim("\u26A0 Cloud sync skipped: " + (e.message || "Unknown")));
729
+ console.log(import_chalk10.default.dim("\u26A0 Cloud sync skipped: " + (e.message || "Unknown")));
860
730
  }
861
731
  }
862
732
  }
863
- var import_promises9, import_path9, import_chalk11, import_axios7, DEFAULT_LMAX, DEFAULT_LMAX_WARNING, CACHE_FILE;
733
+ var import_promises8, import_path8, import_chalk10, import_axios7, DEFAULT_LMAX, DEFAULT_LMAX_WARNING, CACHE_FILE;
864
734
  var init_watchdog = __esm({
865
735
  "src/utils/watchdog.ts"() {
866
736
  "use strict";
867
737
  init_cjs_shims();
868
- import_promises9 = __toESM(require("fs/promises"), 1);
869
- import_path9 = __toESM(require("path"), 1);
870
- import_chalk11 = __toESM(require("chalk"), 1);
738
+ import_promises8 = __toESM(require("fs/promises"), 1);
739
+ import_path8 = __toESM(require("path"), 1);
740
+ import_chalk10 = __toESM(require("chalk"), 1);
871
741
  import_axios7 = __toESM(require("axios"), 1);
872
742
  init_config();
873
743
  DEFAULT_LMAX = 400;
@@ -1663,10 +1533,10 @@ var require_src2 = __commonJS({
1663
1533
  var fs_1 = require("fs");
1664
1534
  var debug_1 = __importDefault(require_src());
1665
1535
  var log = debug_1.default("@kwsites/file-exists");
1666
- function check(path26, isFile, isDirectory) {
1667
- log(`checking %s`, path26);
1536
+ function check(path27, isFile, isDirectory) {
1537
+ log(`checking %s`, path27);
1668
1538
  try {
1669
- const stat = fs_1.statSync(path26);
1539
+ const stat = fs_1.statSync(path27);
1670
1540
  if (stat.isFile() && isFile) {
1671
1541
  log(`[OK] path represents a file`);
1672
1542
  return true;
@@ -1686,8 +1556,8 @@ var require_src2 = __commonJS({
1686
1556
  throw e;
1687
1557
  }
1688
1558
  }
1689
- function exists2(path26, type = exports2.READABLE) {
1690
- return check(path26, (type & exports2.FILE) > 0, (type & exports2.FOLDER) > 0);
1559
+ function exists2(path27, type = exports2.READABLE) {
1560
+ return check(path27, (type & exports2.FILE) > 0, (type & exports2.FOLDER) > 0);
1691
1561
  }
1692
1562
  exports2.exists = exists2;
1693
1563
  exports2.FILE = 1;
@@ -1757,7 +1627,7 @@ var require_package = __commonJS({
1757
1627
  "package.json"(exports2, module2) {
1758
1628
  module2.exports = {
1759
1629
  name: "@rigstate/cli",
1760
- version: "0.7.26",
1630
+ version: "0.7.30",
1761
1631
  description: "Rigstate CLI - Code audit, sync and supervision tool",
1762
1632
  type: "module",
1763
1633
  main: "./dist/index.js",
@@ -1813,8 +1683,8 @@ var require_package = __commonJS({
1813
1683
 
1814
1684
  // src/index.ts
1815
1685
  init_cjs_shims();
1816
- var import_commander23 = require("commander");
1817
- var import_chalk34 = __toESM(require("chalk"), 1);
1686
+ var import_commander24 = require("commander");
1687
+ var import_chalk35 = __toESM(require("chalk"), 1);
1818
1688
 
1819
1689
  // src/commands/login.ts
1820
1690
  init_cjs_shims();
@@ -1866,31 +1736,69 @@ Your API key has been securely stored. You can now use "rigstate scan" to audit
1866
1736
 
1867
1737
  // src/commands/link.ts
1868
1738
  init_cjs_shims();
1869
- var import_commander5 = require("commander");
1870
- var import_promises3 = __toESM(require("fs/promises"), 1);
1871
- var import_path3 = __toESM(require("path"), 1);
1872
- var import_chalk6 = __toESM(require("chalk"), 1);
1739
+ var import_commander4 = require("commander");
1740
+ var import_promises2 = __toESM(require("fs/promises"), 1);
1741
+ var import_path2 = __toESM(require("path"), 1);
1742
+ var import_chalk5 = __toESM(require("chalk"), 1);
1873
1743
  var import_os = __toESM(require("os"), 1);
1874
1744
  init_config();
1875
1745
  function createLinkCommand() {
1876
- return new import_commander5.Command("link").description("Link current directory to a Rigstate project").argument("<projectId>", "Project ID to link").action(async (projectId) => {
1746
+ return new import_commander4.Command("link").description("Link current directory to a Rigstate project").argument("[projectId]", "Project ID to link").action(async (projectId) => {
1877
1747
  try {
1878
- const globalPath = import_path3.default.join(import_os.default.homedir(), ".rigstate", "config.json");
1879
- const globalData = await import_promises3.default.readFile(globalPath, "utf-8").catch(() => null);
1748
+ const globalPath = import_path2.default.join(import_os.default.homedir(), ".rigstate", "config.json");
1749
+ const globalData = await import_promises2.default.readFile(globalPath, "utf-8").catch(() => null);
1880
1750
  if (globalData) {
1881
1751
  const config2 = JSON.parse(globalData);
1882
1752
  const cwd = process.cwd();
1883
1753
  if (config2.overrides && config2.overrides[cwd]) {
1884
1754
  const overrideId = config2.overrides[cwd];
1885
- if (overrideId !== projectId) {
1886
- console.warn(import_chalk6.default.yellow(`Global override detected. Enforcing project ID: ${overrideId}`));
1755
+ console.warn(import_chalk5.default.yellow(`Global override detected. Enforcing project ID: ${overrideId}`));
1756
+ if (!projectId) projectId = overrideId;
1757
+ else if (projectId !== overrideId) {
1758
+ console.warn(import_chalk5.default.red(`Ignoring provided ID ${projectId}. Using override.`));
1887
1759
  projectId = overrideId;
1888
1760
  }
1889
1761
  }
1890
1762
  }
1891
1763
  } catch (e) {
1892
1764
  }
1893
- const manifestPath = import_path3.default.join(process.cwd(), ".rigstate");
1765
+ if (!projectId) {
1766
+ try {
1767
+ const inquirer8 = (await import("inquirer")).default;
1768
+ const { getApiKey: _getApiKey, getApiUrl: _getApiUrl } = await Promise.resolve().then(() => (init_config(), config_exports));
1769
+ const apiKey = getApiKey();
1770
+ const apiUrl = getApiUrl();
1771
+ if (!apiKey) {
1772
+ console.error(import_chalk5.default.red('Not authenticated. Please run "rigstate login" or provide a Project ID.'));
1773
+ process.exit(1);
1774
+ }
1775
+ console.log(import_chalk5.default.dim("Fetching your projects..."));
1776
+ const axios23 = (await import("axios")).default;
1777
+ const response = await axios23.get(`${apiUrl}/api/v1/projects`, {
1778
+ headers: { Authorization: `Bearer ${apiKey}` }
1779
+ });
1780
+ if (!response.data.success || !response.data.data.projects?.length) {
1781
+ console.error(import_chalk5.default.yellow("No projects found. Create one at https://app.rigstate.com"));
1782
+ process.exit(1);
1783
+ }
1784
+ const choices = response.data.data.projects.map((p) => ({
1785
+ name: `${p.name} (${p.id})`,
1786
+ value: p.id
1787
+ }));
1788
+ const answer = await inquirer8.prompt([{
1789
+ type: "list",
1790
+ name: "id",
1791
+ message: "Select project to link:",
1792
+ choices
1793
+ }]);
1794
+ projectId = answer.id;
1795
+ } catch (e) {
1796
+ console.error(import_chalk5.default.red(`Failed to fetch projects: ${e.message}`));
1797
+ console.error("Please provide project ID manually: rigstate link <id>");
1798
+ process.exit(1);
1799
+ }
1800
+ }
1801
+ const manifestPath = import_path2.default.join(process.cwd(), ".rigstate");
1894
1802
  const content = {
1895
1803
  project_id: projectId,
1896
1804
  linked_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -1900,60 +1808,96 @@ function createLinkCommand() {
1900
1808
  content.api_url = currentUrl;
1901
1809
  }
1902
1810
  try {
1903
- await import_promises3.default.writeFile(manifestPath, JSON.stringify(content, null, 2), "utf-8");
1904
- console.log(import_chalk6.default.green(`\u2714 Linked to project ID: ${projectId}`));
1905
- console.log(import_chalk6.default.dim(`Created local context manifest at .rigstate`));
1811
+ await import_promises2.default.mkdir(import_path2.default.dirname(manifestPath), { recursive: true });
1812
+ await import_promises2.default.writeFile(manifestPath, JSON.stringify(content, null, 2), "utf-8");
1813
+ console.log(import_chalk5.default.green(`\u2714 Linked to project ID: ${projectId}`));
1814
+ console.log(import_chalk5.default.dim(`Created local context manifest at .rigstate`));
1906
1815
  console.log("");
1907
- console.log(import_chalk6.default.bold("\u{1F916} Rigstate Automation Detected"));
1816
+ console.log(import_chalk5.default.bold("\u{1F916} Rigstate Automation Detected"));
1908
1817
  console.log("");
1909
1818
  const { getApiKey: _getApiKey, getApiUrl: _getApiUrl } = await Promise.resolve().then(() => (init_config(), config_exports));
1910
1819
  const apiKey = getApiKey();
1911
1820
  const apiUrl = getApiUrl();
1912
1821
  if (apiKey) {
1913
- console.log(import_chalk6.default.blue("\u{1F510} Checking Vault for secrets..."));
1822
+ console.log(import_chalk5.default.blue("\u{1F510} Checking Vault for secrets..."));
1914
1823
  const { syncEnv: syncEnv2 } = await Promise.resolve().then(() => (init_env(), env_exports));
1915
1824
  await syncEnv2(projectId, apiKey, apiUrl, true);
1916
- console.log(import_chalk6.default.blue("\u{1F9E0} Syncing neural instructions..."));
1825
+ console.log(import_chalk5.default.blue("\u{1F9E0} Syncing neural instructions..."));
1917
1826
  const { syncProjectRules: syncProjectRules2 } = await Promise.resolve().then(() => (init_sync_rules(), sync_rules_exports));
1918
1827
  await syncProjectRules2(projectId, apiKey, apiUrl);
1919
- console.log(import_chalk6.default.blue("\u{1F6E1}\uFE0F Injecting Guardian hooks..."));
1920
- const { createHooksCommand: createHooksCommand2 } = await Promise.resolve().then(() => (init_hooks(), hooks_exports));
1828
+ console.log(import_chalk5.default.blue("\u{1F6E1}\uFE0F Injecting Guardian hooks & Safety nets..."));
1921
1829
  await installHooks(process.cwd());
1830
+ await hardenGitIgnore(process.cwd());
1922
1831
  console.log("");
1923
- console.log(import_chalk6.default.bold.green("\u{1F680} Link Complete! Your environment is ready."));
1832
+ console.log(import_chalk5.default.bold.green("\u{1F680} Link Complete! Your environment is ready."));
1924
1833
  const { suggestNextMove: suggestNextMove2 } = await Promise.resolve().then(() => (init_suggest(), suggest_exports));
1925
1834
  await suggestNextMove2(projectId, apiKey, apiUrl);
1926
1835
  } else {
1927
1836
  console.log("");
1928
- console.log(import_chalk6.default.bold.green("\u{1F680} Link Complete!"));
1837
+ console.log(import_chalk5.default.bold.green("\u{1F680} Link Complete!"));
1929
1838
  }
1930
1839
  } catch (error) {
1931
- if (error.message.includes("Not authenticated")) {
1932
- console.warn(import_chalk6.default.yellow('\u26A0\uFE0F Not authenticated. Run "rigstate login" to enable automation features.'));
1840
+ if (error.message?.includes("Not authenticated")) {
1841
+ console.warn(import_chalk5.default.yellow('\u26A0\uFE0F Not authenticated. Run "rigstate login" to enable automation features.'));
1933
1842
  } else {
1934
- console.error(import_chalk6.default.red(`Failed to link project: ${error.message}`));
1843
+ console.error(import_chalk5.default.red(`Failed to link project: ${error.message}`));
1935
1844
  }
1936
1845
  }
1937
1846
  });
1938
1847
  }
1848
+ async function hardenGitIgnore(cwd) {
1849
+ const fs25 = await import("fs/promises");
1850
+ const path27 = await import("path");
1851
+ const ignorePath = path27.join(cwd, ".gitignore");
1852
+ const REQUIRED_IGNORES = [
1853
+ "# Rigstate - Runtime Artifacts (Do not commit)",
1854
+ ".rigstate/ACTIVE_VIOLATIONS.md",
1855
+ ".rigstate/CURRENT_CONTEXT.md",
1856
+ ".rigstate/daemon.pid",
1857
+ ".rigstate/daemon.state.json",
1858
+ ".rigstate/*.log",
1859
+ ".rigstate/*.bak",
1860
+ "# Keep identity tracked",
1861
+ "!.rigstate/identity.json"
1862
+ ];
1863
+ try {
1864
+ let content = "";
1865
+ try {
1866
+ content = await fs25.readFile(ignorePath, "utf-8");
1867
+ } catch {
1868
+ content = "";
1869
+ }
1870
+ const missing = REQUIRED_IGNORES.filter((line) => !content.includes(line) && !line.startsWith("#"));
1871
+ if (missing.length > 0) {
1872
+ console.log(import_chalk5.default.dim(" Configuring .gitignore for Rigstate safety..."));
1873
+ const toAppend = "\n\n" + REQUIRED_IGNORES.join("\n") + "\n";
1874
+ await fs25.writeFile(ignorePath, content + toAppend, "utf-8");
1875
+ console.log(import_chalk5.default.green(" \u2714 .gitignore updated (Artifacts protected)"));
1876
+ } else {
1877
+ console.log(import_chalk5.default.green(" \u2714 .gitignore already hardened"));
1878
+ }
1879
+ } catch (e) {
1880
+ console.warn(import_chalk5.default.yellow(` Could not update .gitignore: ${e.message}`));
1881
+ }
1882
+ }
1939
1883
  async function installHooks(cwd) {
1940
- const fs24 = await import("fs/promises");
1941
- const path26 = await import("path");
1884
+ const fs25 = await import("fs/promises");
1885
+ const path27 = await import("path");
1942
1886
  try {
1943
- await fs24.access(path26.join(cwd, ".git"));
1887
+ await fs25.access(path27.join(cwd, ".git"));
1944
1888
  } catch {
1945
- console.log(import_chalk6.default.dim(" (Not a git repository, skipping hooks)"));
1889
+ console.log(import_chalk5.default.dim(" (Not a git repository, skipping hooks)"));
1946
1890
  return;
1947
1891
  }
1948
- const hooksDir = path26.join(cwd, ".husky");
1892
+ const hooksDir = path27.join(cwd, ".husky");
1949
1893
  try {
1950
- const preCommitPath = path26.join(cwd, ".git/hooks/pre-commit");
1894
+ const preCommitPath = path27.join(cwd, ".git/hooks/pre-commit");
1951
1895
  let shouldInstall = false;
1952
1896
  try {
1953
- await fs24.access(preCommitPath);
1954
- const content = await fs24.readFile(preCommitPath, "utf-8");
1897
+ await fs25.access(preCommitPath);
1898
+ const content = await fs25.readFile(preCommitPath, "utf-8");
1955
1899
  if (content.includes("rigstate")) {
1956
- console.log(import_chalk6.default.green(" \u2714 Git hooks already active"));
1900
+ console.log(import_chalk5.default.green(" \u2714 Git hooks already active"));
1957
1901
  } else {
1958
1902
  shouldInstall = true;
1959
1903
  }
@@ -1975,23 +1919,23 @@ echo "\u{1F6E1}\uFE0F Running Guardian checks..."
1975
1919
  rigstate check --staged --strict=critical
1976
1920
  exit $?
1977
1921
  `;
1978
- await fs24.mkdir(path26.dirname(preCommitPath), { recursive: true });
1922
+ await fs25.mkdir(path27.dirname(preCommitPath), { recursive: true });
1979
1923
  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 });
1924
+ const existing = await fs25.readFile(preCommitPath, "utf-8");
1925
+ await fs25.writeFile(preCommitPath, existing + "\n\n" + PRE_COMMIT_SCRIPT2.replace("#!/bin/sh\n", ""), { mode: 493 });
1982
1926
  } else {
1983
- await fs24.writeFile(preCommitPath, PRE_COMMIT_SCRIPT2, { mode: 493 });
1927
+ await fs25.writeFile(preCommitPath, PRE_COMMIT_SCRIPT2, { mode: 493 });
1984
1928
  }
1985
- console.log(import_chalk6.default.green(" \u2714 Applied Guardian protection (git-hooks)"));
1929
+ console.log(import_chalk5.default.green(" \u2714 Applied Guardian protection (git-hooks)"));
1986
1930
  }
1987
1931
  } catch (e) {
1988
- console.log(import_chalk6.default.dim(" (Skipped hooks: " + e.message + ")"));
1932
+ console.log(import_chalk5.default.dim(" (Skipped hooks: " + e.message + ")"));
1989
1933
  }
1990
1934
  }
1991
- async function fileExists(path26) {
1992
- const fs24 = await import("fs/promises");
1935
+ async function fileExists(path27) {
1936
+ const fs25 = await import("fs/promises");
1993
1937
  try {
1994
- await fs24.access(path26);
1938
+ await fs25.access(path27);
1995
1939
  return true;
1996
1940
  } catch {
1997
1941
  return false;
@@ -2000,23 +1944,23 @@ async function fileExists(path26) {
2000
1944
 
2001
1945
  // src/commands/scan.ts
2002
1946
  init_cjs_shims();
2003
- var import_commander6 = require("commander");
2004
- var import_chalk7 = __toESM(require("chalk"), 1);
1947
+ var import_commander5 = require("commander");
1948
+ var import_chalk6 = __toESM(require("chalk"), 1);
2005
1949
  var import_ora3 = __toESM(require("ora"), 1);
2006
1950
  var import_axios4 = __toESM(require("axios"), 1);
2007
1951
  var import_glob = require("glob");
2008
- var import_promises5 = __toESM(require("fs/promises"), 1);
2009
- var import_path5 = __toESM(require("path"), 1);
1952
+ var import_promises4 = __toESM(require("fs/promises"), 1);
1953
+ var import_path4 = __toESM(require("path"), 1);
2010
1954
  init_config();
2011
1955
 
2012
1956
  // src/utils/files.ts
2013
1957
  init_cjs_shims();
2014
- var import_promises4 = __toESM(require("fs/promises"), 1);
2015
- var import_path4 = __toESM(require("path"), 1);
1958
+ var import_promises3 = __toESM(require("fs/promises"), 1);
1959
+ var import_path3 = __toESM(require("path"), 1);
2016
1960
  async function readGitignore(dir) {
2017
- const gitignorePath = import_path4.default.join(dir, ".gitignore");
1961
+ const gitignorePath = import_path3.default.join(dir, ".gitignore");
2018
1962
  try {
2019
- const content = await import_promises4.default.readFile(gitignorePath, "utf-8");
1963
+ const content = await import_promises3.default.readFile(gitignorePath, "utf-8");
2020
1964
  return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
2021
1965
  } catch (error) {
2022
1966
  return [];
@@ -2078,13 +2022,13 @@ function isCodeFile(filePath) {
2078
2022
  ".vue",
2079
2023
  ".svelte"
2080
2024
  ];
2081
- const ext = import_path4.default.extname(filePath).toLowerCase();
2025
+ const ext = import_path3.default.extname(filePath).toLowerCase();
2082
2026
  return codeExtensions.includes(ext);
2083
2027
  }
2084
2028
 
2085
2029
  // src/commands/scan.ts
2086
2030
  function createScanCommand() {
2087
- return new import_commander6.Command("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) => {
2031
+ return new import_commander5.Command("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) => {
2088
2032
  const spinner = (0, import_ora3.default)();
2089
2033
  try {
2090
2034
  const apiKey = getApiKey();
@@ -2092,26 +2036,26 @@ function createScanCommand() {
2092
2036
  const projectId = options.project || getProjectId();
2093
2037
  if (!projectId) {
2094
2038
  console.warn(
2095
- import_chalk7.default.yellow(
2039
+ import_chalk6.default.yellow(
2096
2040
  "\u26A0\uFE0F No project ID specified. Use --project <id> or set a default."
2097
2041
  )
2098
2042
  );
2099
2043
  }
2100
- const scanPath = import_path5.default.resolve(process.cwd(), targetPath);
2101
- spinner.start(`Scanning ${import_chalk7.default.cyan(scanPath)}...`);
2044
+ const scanPath = import_path4.default.resolve(process.cwd(), targetPath);
2045
+ spinner.start(`Scanning ${import_chalk6.default.cyan(scanPath)}...`);
2102
2046
  const gitignorePatterns = await readGitignore(scanPath);
2103
- const pattern = import_path5.default.join(scanPath, "**/*");
2047
+ const pattern = import_path4.default.join(scanPath, "**/*");
2104
2048
  const allFiles = await (0, import_glob.glob)(pattern, {
2105
2049
  nodir: true,
2106
2050
  dot: false,
2107
2051
  ignore: ["**/node_modules/**", "**/.git/**", "**/dist/**", "**/build/**"]
2108
2052
  });
2109
2053
  const codeFiles = allFiles.filter((file) => {
2110
- const relativePath = import_path5.default.relative(scanPath, file);
2054
+ const relativePath = import_path4.default.relative(scanPath, file);
2111
2055
  return isCodeFile(file) && !shouldIgnore(relativePath, gitignorePatterns);
2112
2056
  });
2113
2057
  if (codeFiles.length === 0) {
2114
- spinner.warn(import_chalk7.default.yellow("No code files found to scan."));
2058
+ spinner.warn(import_chalk6.default.yellow("No code files found to scan."));
2115
2059
  return;
2116
2060
  }
2117
2061
  spinner.text = `Found ${codeFiles.length} files. Scanning...`;
@@ -2120,10 +2064,10 @@ function createScanCommand() {
2120
2064
  const severityCounts = {};
2121
2065
  for (let i = 0; i < codeFiles.length; i++) {
2122
2066
  const filePath = codeFiles[i];
2123
- const relativePath = import_path5.default.relative(scanPath, filePath);
2067
+ const relativePath = import_path4.default.relative(scanPath, filePath);
2124
2068
  spinner.text = `Scanning ${i + 1}/${codeFiles.length}: ${relativePath}`;
2125
2069
  try {
2126
- const content = await import_promises5.default.readFile(filePath, "utf-8");
2070
+ const content = await import_promises4.default.readFile(filePath, "utf-8");
2127
2071
  const response = await import_axios4.default.post(
2128
2072
  `${apiUrl}/api/v1/audit`,
2129
2073
  {
@@ -2159,15 +2103,15 @@ function createScanCommand() {
2159
2103
  }
2160
2104
  } catch (fileError) {
2161
2105
  if (import_axios4.default.isAxiosError(fileError)) {
2162
- console.warn(import_chalk7.default.yellow(`
2106
+ console.warn(import_chalk6.default.yellow(`
2163
2107
  \u26A0\uFE0F Skipping ${relativePath}: ${fileError.message}`));
2164
2108
  } else {
2165
- console.warn(import_chalk7.default.yellow(`
2109
+ console.warn(import_chalk6.default.yellow(`
2166
2110
  \u26A0\uFE0F Error reading ${relativePath}`));
2167
2111
  }
2168
2112
  }
2169
2113
  }
2170
- spinner.succeed(import_chalk7.default.green("\u2705 Scan completed!"));
2114
+ spinner.succeed(import_chalk6.default.green("\u2705 Scan completed!"));
2171
2115
  const aggregatedResponse = {
2172
2116
  results,
2173
2117
  summary: {
@@ -2182,21 +2126,21 @@ function createScanCommand() {
2182
2126
  printPrettyResults(aggregatedResponse);
2183
2127
  }
2184
2128
  } catch (error) {
2185
- spinner.fail(import_chalk7.default.red("\u274C Scan failed"));
2129
+ spinner.fail(import_chalk6.default.red("\u274C Scan failed"));
2186
2130
  if (import_axios4.default.isAxiosError(error)) {
2187
2131
  if (error.response) {
2188
- console.error(import_chalk7.default.red("API Error:"), error.response.data);
2132
+ console.error(import_chalk6.default.red("API Error:"), error.response.data);
2189
2133
  } else if (error.request) {
2190
2134
  console.error(
2191
- import_chalk7.default.red("Network Error:"),
2135
+ import_chalk6.default.red("Network Error:"),
2192
2136
  "Could not reach the API. Is the server running?"
2193
2137
  );
2194
2138
  } else {
2195
- console.error(import_chalk7.default.red("Error:"), error.message);
2139
+ console.error(import_chalk6.default.red("Error:"), error.message);
2196
2140
  }
2197
2141
  } else {
2198
2142
  console.error(
2199
- import_chalk7.default.red("Error:"),
2143
+ import_chalk6.default.red("Error:"),
2200
2144
  error instanceof Error ? error.message : "Unknown error"
2201
2145
  );
2202
2146
  }
@@ -2206,10 +2150,10 @@ function createScanCommand() {
2206
2150
  }
2207
2151
  function printPrettyResults(data) {
2208
2152
  const { results, summary } = data;
2209
- console.log("\n" + import_chalk7.default.bold("\u{1F4CA} Scan Summary"));
2210
- console.log(import_chalk7.default.dim("\u2500".repeat(60)));
2211
- console.log(`Total Files Scanned: ${import_chalk7.default.cyan(summary.total_files)}`);
2212
- console.log(`Total Issues Found: ${import_chalk7.default.yellow(summary.total_issues)}`);
2153
+ console.log("\n" + import_chalk6.default.bold("\u{1F4CA} Scan Summary"));
2154
+ console.log(import_chalk6.default.dim("\u2500".repeat(60)));
2155
+ console.log(`Total Files Scanned: ${import_chalk6.default.cyan(summary.total_files)}`);
2156
+ console.log(`Total Issues Found: ${import_chalk6.default.yellow(summary.total_issues)}`);
2213
2157
  if (summary.by_severity) {
2214
2158
  console.log("\nIssues by Severity:");
2215
2159
  Object.entries(summary.by_severity).forEach(([severity, count]) => {
@@ -2218,87 +2162,87 @@ function printPrettyResults(data) {
2218
2162
  });
2219
2163
  }
2220
2164
  if (results && results.length > 0) {
2221
- console.log("\n" + import_chalk7.default.bold("\u{1F50D} Detailed Results"));
2222
- console.log(import_chalk7.default.dim("\u2500".repeat(60)));
2165
+ console.log("\n" + import_chalk6.default.bold("\u{1F50D} Detailed Results"));
2166
+ console.log(import_chalk6.default.dim("\u2500".repeat(60)));
2223
2167
  results.forEach((result) => {
2224
2168
  if (result.issues && result.issues.length > 0) {
2225
2169
  console.log(`
2226
- ${import_chalk7.default.bold(result.file_path)}`);
2170
+ ${import_chalk6.default.bold(result.file_path)}`);
2227
2171
  result.issues.forEach((issue) => {
2228
2172
  const severityColor = getSeverityColor(issue.severity);
2229
- const lineInfo = issue.line ? import_chalk7.default.dim(`:${issue.line}`) : "";
2173
+ const lineInfo = issue.line ? import_chalk6.default.dim(`:${issue.line}`) : "";
2230
2174
  console.log(
2231
2175
  ` ${severityColor(`[${issue.severity.toUpperCase()}]`)} ${issue.type}${lineInfo}`
2232
2176
  );
2233
- console.log(` ${import_chalk7.default.dim(issue.message)}`);
2177
+ console.log(` ${import_chalk6.default.dim(issue.message)}`);
2234
2178
  });
2235
2179
  }
2236
2180
  });
2237
2181
  }
2238
- console.log("\n" + import_chalk7.default.dim("\u2500".repeat(60)));
2182
+ console.log("\n" + import_chalk6.default.dim("\u2500".repeat(60)));
2239
2183
  }
2240
2184
  function getSeverityColor(severity) {
2241
2185
  switch (severity.toLowerCase()) {
2242
2186
  case "critical":
2243
- return import_chalk7.default.red.bold;
2187
+ return import_chalk6.default.red.bold;
2244
2188
  case "high":
2245
- return import_chalk7.default.red;
2189
+ return import_chalk6.default.red;
2246
2190
  case "medium":
2247
- return import_chalk7.default.yellow;
2191
+ return import_chalk6.default.yellow;
2248
2192
  case "low":
2249
- return import_chalk7.default.blue;
2193
+ return import_chalk6.default.blue;
2250
2194
  case "info":
2251
- return import_chalk7.default.gray;
2195
+ return import_chalk6.default.gray;
2252
2196
  default:
2253
- return import_chalk7.default.white;
2197
+ return import_chalk6.default.white;
2254
2198
  }
2255
2199
  }
2256
2200
 
2257
2201
  // src/commands/fix.ts
2258
2202
  init_cjs_shims();
2259
- var import_commander7 = require("commander");
2260
- var import_chalk8 = __toESM(require("chalk"), 1);
2203
+ var import_commander6 = require("commander");
2204
+ var import_chalk7 = __toESM(require("chalk"), 1);
2261
2205
  var import_ora4 = __toESM(require("ora"), 1);
2262
2206
  var import_axios5 = __toESM(require("axios"), 1);
2263
2207
  var import_glob2 = require("glob");
2264
- var import_promises6 = __toESM(require("fs/promises"), 1);
2265
- var import_path6 = __toESM(require("path"), 1);
2208
+ var import_promises5 = __toESM(require("fs/promises"), 1);
2209
+ var import_path5 = __toESM(require("path"), 1);
2266
2210
  var import_inquirer = __toESM(require("inquirer"), 1);
2267
2211
  var Diff = __toESM(require("diff"), 1);
2268
2212
  init_config();
2269
2213
  function createFixCommand() {
2270
- return new import_commander7.Command("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) => {
2214
+ return new import_commander6.Command("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) => {
2271
2215
  const spinner = (0, import_ora4.default)();
2272
2216
  try {
2273
2217
  const apiKey = getApiKey();
2274
2218
  const apiUrl = getApiUrl();
2275
2219
  const projectId = options.project || getProjectId();
2276
2220
  if (!projectId) {
2277
- console.log(import_chalk8.default.yellow("\u26A0\uFE0F Project ID is required for fixing. Using default or pass --project <id>"));
2221
+ console.log(import_chalk7.default.yellow("\u26A0\uFE0F Project ID is required for fixing. Using default or pass --project <id>"));
2278
2222
  }
2279
- const scanPath = import_path6.default.resolve(process.cwd(), targetPath);
2223
+ const scanPath = import_path5.default.resolve(process.cwd(), targetPath);
2280
2224
  const gitignorePatterns = await readGitignore(scanPath);
2281
- const pattern = import_path6.default.join(scanPath, "**/*");
2225
+ const pattern = import_path5.default.join(scanPath, "**/*");
2282
2226
  const allFiles = await (0, import_glob2.glob)(pattern, { nodir: true, dot: false, ignore: ["**/node_modules/**", "**/.git/**"] });
2283
2227
  const codeFiles = allFiles.filter((file) => {
2284
- const relativePath = import_path6.default.relative(scanPath, file);
2228
+ const relativePath = import_path5.default.relative(scanPath, file);
2285
2229
  return isCodeFile(file) && !shouldIgnore(relativePath, gitignorePatterns);
2286
2230
  });
2287
2231
  if (codeFiles.length === 0) {
2288
- console.log(import_chalk8.default.yellow("No code files found."));
2232
+ console.log(import_chalk7.default.yellow("No code files found."));
2289
2233
  return;
2290
2234
  }
2291
- console.log(import_chalk8.default.bold(`
2235
+ console.log(import_chalk7.default.bold(`
2292
2236
  \u{1F9E0} Rigstate Fix Mode`));
2293
- console.log(import_chalk8.default.dim(`Scanning ${codeFiles.length} files with Project Context...
2237
+ console.log(import_chalk7.default.dim(`Scanning ${codeFiles.length} files with Project Context...
2294
2238
  `));
2295
2239
  let fixedCount = 0;
2296
2240
  for (let i = 0; i < codeFiles.length; i++) {
2297
2241
  const filePath = codeFiles[i];
2298
- const relativePath = import_path6.default.relative(scanPath, filePath);
2242
+ const relativePath = import_path5.default.relative(scanPath, filePath);
2299
2243
  spinner.start(`Analyzing ${relativePath}...`);
2300
2244
  try {
2301
- const content = await import_promises6.default.readFile(filePath, "utf-8");
2245
+ const content = await import_promises5.default.readFile(filePath, "utf-8");
2302
2246
  const response = await import_axios5.default.post(
2303
2247
  `${apiUrl}/api/v1/audit`,
2304
2248
  { content, file_path: relativePath, project_id: projectId },
@@ -2309,22 +2253,22 @@ function createFixCommand() {
2309
2253
  if (fixableIssues.length > 0) {
2310
2254
  spinner.stop();
2311
2255
  console.log(`
2312
- ${import_chalk8.default.bold(relativePath)}: Found ${fixableIssues.length} fixable issues.`);
2256
+ ${import_chalk7.default.bold(relativePath)}: Found ${fixableIssues.length} fixable issues.`);
2313
2257
  for (const issue of fixableIssues) {
2314
- console.log(import_chalk8.default.red(`
2258
+ console.log(import_chalk7.default.red(`
2315
2259
  [${issue.type}] ${issue.title}`));
2316
- console.log(import_chalk8.default.dim(issue.suggestion || issue.message));
2260
+ console.log(import_chalk7.default.dim(issue.suggestion || issue.message));
2317
2261
  const diff = Diff.createTwoFilesPatch(relativePath, relativePath, content, issue.fixed_content, "Current", "Fixed");
2318
2262
  console.log("\n" + diff.split("\n").slice(0, 15).join("\n") + (diff.split("\n").length > 15 ? "\n..." : ""));
2319
2263
  const { apply } = await import_inquirer.default.prompt([{
2320
2264
  type: "confirm",
2321
2265
  name: "apply",
2322
- message: `Apply this fix to ${import_chalk8.default.cyan(relativePath)}?`,
2266
+ message: `Apply this fix to ${import_chalk7.default.cyan(relativePath)}?`,
2323
2267
  default: true
2324
2268
  }]);
2325
2269
  if (apply) {
2326
- await import_promises6.default.writeFile(filePath, issue.fixed_content);
2327
- console.log(import_chalk8.default.green(`\u2705 Fixed applied!`));
2270
+ await import_promises5.default.writeFile(filePath, issue.fixed_content);
2271
+ console.log(import_chalk7.default.green(`\u2705 Fixed applied!`));
2328
2272
  fixedCount++;
2329
2273
  if (issue.related_step_id) {
2330
2274
  const { completeStep } = await import_inquirer.default.prompt([{
@@ -2340,15 +2284,15 @@ ${import_chalk8.default.bold(relativePath)}: Found ${fixableIssues.length} fixab
2340
2284
  { step_id: issue.related_step_id, status: "COMPLETED", project_id: projectId },
2341
2285
  { headers: { "Authorization": `Bearer ${apiKey}` } }
2342
2286
  );
2343
- console.log(import_chalk8.default.green(`\u{1F680} Roadmap updated! Mission Control is in sync.`));
2287
+ console.log(import_chalk7.default.green(`\u{1F680} Roadmap updated! Mission Control is in sync.`));
2344
2288
  } catch (err) {
2345
- console.error(import_chalk8.default.yellow(`Failed to update roadmap: ${err.message}`));
2289
+ console.error(import_chalk7.default.yellow(`Failed to update roadmap: ${err.message}`));
2346
2290
  }
2347
2291
  }
2348
2292
  }
2349
2293
  break;
2350
2294
  } else {
2351
- console.log(import_chalk8.default.dim("Skipped."));
2295
+ console.log(import_chalk7.default.dim("Skipped."));
2352
2296
  }
2353
2297
  }
2354
2298
  } else {
@@ -2358,11 +2302,11 @@ ${import_chalk8.default.bold(relativePath)}: Found ${fixableIssues.length} fixab
2358
2302
  }
2359
2303
  }
2360
2304
  spinner.stop();
2361
- console.log(import_chalk8.default.bold.green(`
2305
+ console.log(import_chalk7.default.bold.green(`
2362
2306
 
2363
2307
  \u{1F680} Fix session complete!`));
2364
2308
  console.log(`Frank fixed ${fixedCount} detected issues.`);
2365
- console.log(import_chalk8.default.dim(`Run 'rigstate scan' to verify remaining issues.`));
2309
+ console.log(import_chalk7.default.dim(`Run 'rigstate scan' to verify remaining issues.`));
2366
2310
  } catch (error) {
2367
2311
  spinner.fail("Fix session failed");
2368
2312
  console.error(error.message);
@@ -2372,15 +2316,15 @@ ${import_chalk8.default.bold(relativePath)}: Found ${fixableIssues.length} fixab
2372
2316
 
2373
2317
  // src/commands/sync.ts
2374
2318
  init_cjs_shims();
2375
- var import_commander8 = require("commander");
2376
- var import_chalk12 = __toESM(require("chalk"), 1);
2319
+ var import_commander7 = require("commander");
2320
+ var import_chalk11 = __toESM(require("chalk"), 1);
2377
2321
  var import_ora5 = __toESM(require("ora"), 1);
2378
2322
  init_config();
2379
2323
  var import_axios8 = __toESM(require("axios"), 1);
2380
- var import_promises10 = __toESM(require("fs/promises"), 1);
2381
- var import_path10 = __toESM(require("path"), 1);
2324
+ var import_promises9 = __toESM(require("fs/promises"), 1);
2325
+ var import_path9 = __toESM(require("path"), 1);
2382
2326
  function createSyncCommand() {
2383
- const sync = new import_commander8.Command("sync");
2327
+ const sync = new import_commander7.Command("sync");
2384
2328
  sync.description("Synchronize local state with Rigstate Cloud").option("-p, --project <id>", "Specify Project ID (saves to config automatically)").action(async (options) => {
2385
2329
  const spinner = (0, import_ora5.default)("Synchronizing project state...").start();
2386
2330
  try {
@@ -2394,8 +2338,8 @@ function createSyncCommand() {
2394
2338
  let projectId = options.project;
2395
2339
  if (!projectId) {
2396
2340
  try {
2397
- const manifestPath = import_path10.default.join(process.cwd(), ".rigstate");
2398
- const manifestContent = await import_promises10.default.readFile(manifestPath, "utf-8");
2341
+ const manifestPath = import_path9.default.join(process.cwd(), ".rigstate");
2342
+ const manifestContent = await import_promises9.default.readFile(manifestPath, "utf-8");
2399
2343
  const manifest = JSON.parse(manifestContent);
2400
2344
  if (manifest.project_id) projectId = manifest.project_id;
2401
2345
  } catch (e) {
@@ -2419,31 +2363,31 @@ function createSyncCommand() {
2419
2363
  }
2420
2364
  const { roadmap, project } = response.data.data;
2421
2365
  const timestamp = response.data.timestamp;
2422
- const targetPath = import_path10.default.join(process.cwd(), "roadmap.json");
2366
+ const targetPath = import_path9.default.join(process.cwd(), "roadmap.json");
2423
2367
  const fileContent = JSON.stringify({
2424
2368
  project,
2425
2369
  last_synced: timestamp,
2426
2370
  roadmap
2427
2371
  }, null, 2);
2428
- await import_promises10.default.writeFile(targetPath, fileContent, "utf-8");
2372
+ await import_promises9.default.writeFile(targetPath, fileContent, "utf-8");
2429
2373
  try {
2430
- const manifestPath = import_path10.default.join(process.cwd(), ".rigstate");
2374
+ const manifestPath = import_path9.default.join(process.cwd(), ".rigstate");
2431
2375
  const manifestContent = {
2432
2376
  project_id: projectId,
2433
2377
  project_name: project,
2434
2378
  last_synced: timestamp,
2435
2379
  api_url: apiUrl
2436
2380
  };
2437
- await import_promises10.default.writeFile(manifestPath, JSON.stringify(manifestContent, null, 2), "utf-8");
2381
+ await import_promises9.default.writeFile(manifestPath, JSON.stringify(manifestContent, null, 2), "utf-8");
2438
2382
  } catch (e) {
2439
2383
  }
2440
- console.log(import_chalk12.default.bold("\n\u{1F9E0} Agent Skills Provisioning..."));
2384
+ console.log(import_chalk11.default.bold("\n\u{1F9E0} Agent Skills Provisioning..."));
2441
2385
  try {
2442
2386
  const { provisionSkills: provisionSkills2, generateSkillsDiscoveryBlock: generateSkillsDiscoveryBlock2 } = await Promise.resolve().then(() => (init_skills_provisioner(), skills_provisioner_exports));
2443
2387
  const skills = await provisionSkills2(apiUrl, apiKey, projectId, process.cwd());
2444
- const cursorRulesPath = import_path10.default.join(process.cwd(), ".cursorrules");
2388
+ const cursorRulesPath = import_path9.default.join(process.cwd(), ".cursorrules");
2445
2389
  try {
2446
- let rulesContent = await import_promises10.default.readFile(cursorRulesPath, "utf-8");
2390
+ let rulesContent = await import_promises9.default.readFile(cursorRulesPath, "utf-8");
2447
2391
  const skillsBlock = generateSkillsDiscoveryBlock2(skills);
2448
2392
  if (rulesContent.includes("<available_skills>")) {
2449
2393
  rulesContent = rulesContent.replace(
@@ -2456,17 +2400,17 @@ function createSyncCommand() {
2456
2400
  rulesContent = rulesContent.slice(0, insertPoint + 3) + "\n\n" + skillsBlock + "\n" + rulesContent.slice(insertPoint + 3);
2457
2401
  }
2458
2402
  }
2459
- await import_promises10.default.writeFile(cursorRulesPath, rulesContent, "utf-8");
2460
- console.log(import_chalk12.default.dim(` Updated .cursorrules with skills discovery block`));
2403
+ await import_promises9.default.writeFile(cursorRulesPath, rulesContent, "utf-8");
2404
+ console.log(import_chalk11.default.dim(` Updated .cursorrules with skills discovery block`));
2461
2405
  } catch (e) {
2462
2406
  }
2463
2407
  } catch (e) {
2464
- console.log(import_chalk12.default.yellow(` \u26A0 Skills provisioning skipped: ${e.message}`));
2408
+ console.log(import_chalk11.default.yellow(` \u26A0 Skills provisioning skipped: ${e.message}`));
2465
2409
  }
2466
2410
  try {
2467
- const logPath = import_path10.default.join(process.cwd(), ".rigstate", "logs", "last_execution.json");
2411
+ const logPath = import_path9.default.join(process.cwd(), ".rigstate", "logs", "last_execution.json");
2468
2412
  try {
2469
- const logContent = await import_promises10.default.readFile(logPath, "utf-8");
2413
+ const logContent = await import_promises9.default.readFile(logPath, "utf-8");
2470
2414
  const logData = JSON.parse(logContent);
2471
2415
  if (logData.task_summary) {
2472
2416
  await import_axios8.default.post(`${apiUrl}/api/v1/execution-logs`, {
@@ -2476,8 +2420,8 @@ function createSyncCommand() {
2476
2420
  }, {
2477
2421
  headers: { Authorization: `Bearer ${apiKey}` }
2478
2422
  });
2479
- await import_promises10.default.unlink(logPath);
2480
- console.log(import_chalk12.default.dim(`\u2714 Mission Report uploaded.`));
2423
+ await import_promises9.default.unlink(logPath);
2424
+ console.log(import_chalk11.default.dim(`\u2714 Mission Report uploaded.`));
2481
2425
  }
2482
2426
  } catch (e) {
2483
2427
  if (e.code !== "ENOENT") {
@@ -2485,12 +2429,12 @@ function createSyncCommand() {
2485
2429
  }
2486
2430
  } catch (e) {
2487
2431
  }
2488
- spinner.succeed(import_chalk12.default.green(`Synced ${roadmap.length} roadmap steps for project "${project}"`));
2489
- console.log(import_chalk12.default.dim(`Local files updated: roadmap.json`));
2432
+ spinner.succeed(import_chalk11.default.green(`Synced ${roadmap.length} roadmap steps for project "${project}"`));
2433
+ console.log(import_chalk11.default.dim(`Local files updated: roadmap.json`));
2490
2434
  const { runGuardianWatchdog: runGuardianWatchdog2 } = await Promise.resolve().then(() => (init_watchdog(), watchdog_exports));
2491
2435
  const settings = response.data.data.settings || {};
2492
2436
  await runGuardianWatchdog2(process.cwd(), settings, projectId);
2493
- console.log(import_chalk12.default.bold("\n\u{1F4E1} Agent Bridge Heartbeat..."));
2437
+ console.log(import_chalk11.default.bold("\n\u{1F4E1} Agent Bridge Heartbeat..."));
2494
2438
  try {
2495
2439
  const bridgeResponse = await import_axios8.default.get(`${apiUrl}/api/v1/agent/bridge`, {
2496
2440
  params: { project_id: projectId },
@@ -2501,10 +2445,10 @@ function createSyncCommand() {
2501
2445
  const pending = tasks.filter((t) => t.status === "PENDING");
2502
2446
  const approved = tasks.filter((t) => t.status === "APPROVED");
2503
2447
  if (pending.length > 0 || approved.length > 0) {
2504
- console.log(import_chalk12.default.yellow(`\u26A0 Bridge Alert: ${pending.length} pending, ${approved.length} approved tasks found.`));
2505
- console.log(import_chalk12.default.dim('Run "rigstate fix" to process these tasks or ensure your IDE MCP server is active.'));
2448
+ console.log(import_chalk11.default.yellow(`\u26A0 Bridge Alert: ${pending.length} pending, ${approved.length} approved tasks found.`));
2449
+ console.log(import_chalk11.default.dim('Run "rigstate fix" to process these tasks or ensure your IDE MCP server is active.'));
2506
2450
  } else {
2507
- console.log(import_chalk12.default.green("\u2714 Heartbeat healthy. No pending bridge tasks."));
2451
+ console.log(import_chalk11.default.green("\u2714 Heartbeat healthy. No pending bridge tasks."));
2508
2452
  }
2509
2453
  const pings = pending.filter((t) => t.proposal?.startsWith("ping"));
2510
2454
  for (const ping of pings) {
@@ -2515,25 +2459,25 @@ function createSyncCommand() {
2515
2459
  }, {
2516
2460
  headers: { Authorization: `Bearer ${apiKey}` }
2517
2461
  });
2518
- console.log(import_chalk12.default.cyan(`\u{1F3D3} Pong! Acknowledged heartbeat signal [${ping.id}]`));
2462
+ console.log(import_chalk11.default.cyan(`\u{1F3D3} Pong! Acknowledged heartbeat signal [${ping.id}]`));
2519
2463
  }
2520
2464
  }
2521
2465
  } catch (e) {
2522
- console.log(import_chalk12.default.yellow(`\u26A0 Could not verify Bridge status: ${e.message}`));
2466
+ console.log(import_chalk11.default.yellow(`\u26A0 Could not verify Bridge status: ${e.message}`));
2523
2467
  }
2524
2468
  if (options.project) {
2525
- console.log(import_chalk12.default.blue(`Project context saved. Future commands will use this project.`));
2469
+ console.log(import_chalk11.default.blue(`Project context saved. Future commands will use this project.`));
2526
2470
  }
2527
2471
  try {
2528
- const migrationDir = import_path10.default.join(process.cwd(), "supabase", "migrations");
2529
- const files = await import_promises10.default.readdir(migrationDir);
2472
+ const migrationDir = import_path9.default.join(process.cwd(), "supabase", "migrations");
2473
+ const files = await import_promises9.default.readdir(migrationDir);
2530
2474
  const sqlFiles = files.filter((f) => f.endsWith(".sql")).sort();
2531
2475
  if (sqlFiles.length > 0) {
2532
2476
  const latestMigration = sqlFiles[sqlFiles.length - 1];
2533
- console.log(import_chalk12.default.dim(`
2477
+ console.log(import_chalk11.default.dim(`
2534
2478
  \u{1F6E1} Migration Guard:`));
2535
- console.log(import_chalk12.default.dim(` Latest Local: ${latestMigration}`));
2536
- console.log(import_chalk12.default.yellow(` \u26A0 Ensure DB schema matches this version. CLI cannot verify Remote RLS policies directly.`));
2479
+ console.log(import_chalk11.default.dim(` Latest Local: ${latestMigration}`));
2480
+ console.log(import_chalk11.default.yellow(` \u26A0 Ensure DB schema matches this version. CLI cannot verify Remote RLS policies directly.`));
2537
2481
  }
2538
2482
  } catch (e) {
2539
2483
  }
@@ -2545,15 +2489,15 @@ function createSyncCommand() {
2545
2489
  );
2546
2490
  if (vaultResponse.data.success) {
2547
2491
  const vaultContent = vaultResponse.data.data.content || "";
2548
- const localEnvPath = import_path10.default.join(process.cwd(), ".env.local");
2492
+ const localEnvPath = import_path9.default.join(process.cwd(), ".env.local");
2549
2493
  let localContent = "";
2550
2494
  try {
2551
- localContent = await import_promises10.default.readFile(localEnvPath, "utf-8");
2495
+ localContent = await import_promises9.default.readFile(localEnvPath, "utf-8");
2552
2496
  } catch (e) {
2553
2497
  }
2554
2498
  if (vaultContent.trim() !== localContent.trim()) {
2555
- console.log(import_chalk12.default.bold("\n\u{1F510} Sovereign Foundation (Vault):"));
2556
- console.log(import_chalk12.default.yellow(" Status: Drift Detected / Update Available"));
2499
+ console.log(import_chalk11.default.bold("\n\u{1F510} Sovereign Foundation (Vault):"));
2500
+ console.log(import_chalk11.default.yellow(" Status: Drift Detected / Update Available"));
2557
2501
  const { syncVault } = await import("inquirer").then((m) => m.default.prompt([{
2558
2502
  type: "confirm",
2559
2503
  name: "syncVault",
@@ -2561,25 +2505,25 @@ function createSyncCommand() {
2561
2505
  default: false
2562
2506
  }]));
2563
2507
  if (syncVault) {
2564
- await import_promises10.default.writeFile(localEnvPath, vaultContent, "utf-8");
2565
- console.log(import_chalk12.default.green(" \u2705 .env.local synchronized with Vault."));
2508
+ await import_promises9.default.writeFile(localEnvPath, vaultContent, "utf-8");
2509
+ console.log(import_chalk11.default.green(" \u2705 .env.local synchronized with Vault."));
2566
2510
  } else {
2567
- console.log(import_chalk12.default.dim(" Skipped vault sync."));
2511
+ console.log(import_chalk11.default.dim(" Skipped vault sync."));
2568
2512
  }
2569
2513
  } else {
2570
- console.log(import_chalk12.default.dim("\n\u{1F510} Sovereign Foundation: Synced."));
2514
+ console.log(import_chalk11.default.dim("\n\u{1F510} Sovereign Foundation: Synced."));
2571
2515
  }
2572
2516
  }
2573
2517
  } catch (e) {
2574
2518
  }
2575
- console.log(import_chalk12.default.dim("\n\u{1F6E1}\uFE0F System Integrity Check..."));
2519
+ console.log(import_chalk11.default.dim("\n\u{1F6E1}\uFE0F System Integrity Check..."));
2576
2520
  await checkSystemIntegrity(apiUrl, apiKey, projectId);
2577
2521
  } catch (error) {
2578
2522
  if (import_axios8.default.isAxiosError(error)) {
2579
2523
  const message = error.response?.data?.error || error.message;
2580
- spinner.fail(import_chalk12.default.red(`Sync failed: ${message}`));
2524
+ spinner.fail(import_chalk11.default.red(`Sync failed: ${message}`));
2581
2525
  } else {
2582
- spinner.fail(import_chalk12.default.red("Sync failed: " + (error.message || "Unknown error")));
2526
+ spinner.fail(import_chalk11.default.red("Sync failed: " + (error.message || "Unknown error")));
2583
2527
  }
2584
2528
  }
2585
2529
  });
@@ -2595,57 +2539,57 @@ async function checkSystemIntegrity(apiUrl, apiKey, projectId) {
2595
2539
  const { migrations, rls, guardian_violations } = response.data.data;
2596
2540
  if (migrations) {
2597
2541
  if (migrations.in_sync) {
2598
- console.log(import_chalk12.default.green(` \u2705 Migrations synced (${migrations.count} versions)`));
2542
+ console.log(import_chalk11.default.green(` \u2705 Migrations synced (${migrations.count} versions)`));
2599
2543
  } else {
2600
- console.log(import_chalk12.default.red(` \u{1F6D1} CRITICAL: DB Schema out of sync! ${migrations.missing?.length || 0} migrations not applied.`));
2544
+ console.log(import_chalk11.default.red(` \u{1F6D1} CRITICAL: DB Schema out of sync! ${migrations.missing?.length || 0} migrations not applied.`));
2601
2545
  if (migrations.missing?.length > 0) {
2602
- console.log(import_chalk12.default.dim(` Missing: ${migrations.missing.slice(0, 3).join(", ")}${migrations.missing.length > 3 ? "..." : ""}`));
2546
+ console.log(import_chalk11.default.dim(` Missing: ${migrations.missing.slice(0, 3).join(", ")}${migrations.missing.length > 3 ? "..." : ""}`));
2603
2547
  }
2604
- console.log(import_chalk12.default.yellow(` Run 'supabase db push' or apply migrations immediately.`));
2548
+ console.log(import_chalk11.default.yellow(` Run 'supabase db push' or apply migrations immediately.`));
2605
2549
  }
2606
2550
  }
2607
2551
  if (rls) {
2608
2552
  if (rls.all_secured) {
2609
- console.log(import_chalk12.default.green(` \u2705 RLS Audit Passed (${rls.table_count} tables secured)`));
2553
+ console.log(import_chalk11.default.green(` \u2705 RLS Audit Passed (${rls.table_count} tables secured)`));
2610
2554
  } else {
2611
- console.log(import_chalk12.default.red(` \u{1F6D1} CRITICAL: Security Vulnerability! ${rls.unsecured?.length || 0} tables have RLS disabled.`));
2555
+ console.log(import_chalk11.default.red(` \u{1F6D1} CRITICAL: Security Vulnerability! ${rls.unsecured?.length || 0} tables have RLS disabled.`));
2612
2556
  rls.unsecured?.forEach((table) => {
2613
- console.log(import_chalk12.default.red(` - ${table}`));
2557
+ console.log(import_chalk11.default.red(` - ${table}`));
2614
2558
  });
2615
- console.log(import_chalk12.default.yellow(' Enable RLS immediately: ALTER TABLE "table" ENABLE ROW LEVEL SECURITY;'));
2559
+ console.log(import_chalk11.default.yellow(' Enable RLS immediately: ALTER TABLE "table" ENABLE ROW LEVEL SECURITY;'));
2616
2560
  }
2617
2561
  }
2618
2562
  if (guardian_violations) {
2619
2563
  if (guardian_violations.count === 0) {
2620
- console.log(import_chalk12.default.green(" \u2705 Guardian: No active violations"));
2564
+ console.log(import_chalk11.default.green(" \u2705 Guardian: No active violations"));
2621
2565
  } else {
2622
- console.log(import_chalk12.default.yellow(` \u26A0\uFE0F Guardian: ${guardian_violations.count} active violations`));
2623
- console.log(import_chalk12.default.dim(' Run "rigstate check" for details.'));
2566
+ console.log(import_chalk11.default.yellow(` \u26A0\uFE0F Guardian: ${guardian_violations.count} active violations`));
2567
+ console.log(import_chalk11.default.dim(' Run "rigstate check" for details.'));
2624
2568
  }
2625
2569
  }
2626
2570
  }
2627
2571
  } catch (e) {
2628
- console.log(import_chalk12.default.dim(" (System integrity check skipped - API endpoint not available)"));
2572
+ console.log(import_chalk11.default.dim(" (System integrity check skipped - API endpoint not available)"));
2629
2573
  }
2630
2574
  }
2631
2575
 
2632
2576
  // src/commands/init.ts
2633
2577
  init_cjs_shims();
2634
- var import_commander9 = require("commander");
2635
- var import_chalk13 = __toESM(require("chalk"), 1);
2636
- var import_promises12 = __toESM(require("fs/promises"), 1);
2637
- var import_path12 = __toESM(require("path"), 1);
2578
+ var import_commander8 = require("commander");
2579
+ var import_chalk12 = __toESM(require("chalk"), 1);
2580
+ var import_promises11 = __toESM(require("fs/promises"), 1);
2581
+ var import_path11 = __toESM(require("path"), 1);
2638
2582
  var import_ora6 = __toESM(require("ora"), 1);
2639
2583
  var import_child_process = require("child_process");
2640
2584
 
2641
2585
  // src/utils/manifest.ts
2642
2586
  init_cjs_shims();
2643
- var import_promises11 = __toESM(require("fs/promises"), 1);
2644
- var import_path11 = __toESM(require("path"), 1);
2587
+ var import_promises10 = __toESM(require("fs/promises"), 1);
2588
+ var import_path10 = __toESM(require("path"), 1);
2645
2589
  async function loadManifest() {
2646
2590
  try {
2647
- const manifestPath = import_path11.default.join(process.cwd(), ".rigstate");
2648
- const content = await import_promises11.default.readFile(manifestPath, "utf-8");
2591
+ const manifestPath = import_path10.default.join(process.cwd(), ".rigstate");
2592
+ const content = await import_promises10.default.readFile(manifestPath, "utf-8");
2649
2593
  return JSON.parse(content);
2650
2594
  } catch {
2651
2595
  return null;
@@ -2656,13 +2600,13 @@ async function loadManifest() {
2656
2600
  init_config();
2657
2601
  var import_axios9 = __toESM(require("axios"), 1);
2658
2602
  function createInitCommand() {
2659
- return new import_commander9.Command("init").description("Initialize or link a Rigstate project (interactive mode available)").argument("[project-id]", "ID of the project to link (optional, prompts if not provided)").option("-f, --force", "Overwrite existing .cursorrules file").option("--rules-only", "Only regenerate .cursorrules without interactive setup").action(async (projectIdArg, options) => {
2603
+ return new import_commander8.Command("init").description("Initialize or link a Rigstate project (interactive mode available)").argument("[project-id]", "ID of the project to link (optional, prompts if not provided)").option("-f, --force", "Overwrite existing .cursorrules file").option("--rules-only", "Only regenerate .cursorrules without interactive setup").action(async (projectIdArg, options) => {
2660
2604
  const spinner = (0, import_ora6.default)("Initializing Rigstate project...").start();
2661
2605
  let apiKey;
2662
2606
  try {
2663
2607
  apiKey = getApiKey();
2664
2608
  } catch (e) {
2665
- spinner.fail(import_chalk13.default.red('Not authenticated. Run "rigstate login" first.'));
2609
+ spinner.fail(import_chalk12.default.red('Not authenticated. Run "rigstate login" first.'));
2666
2610
  return;
2667
2611
  }
2668
2612
  const apiUrl = getApiUrl();
@@ -2680,7 +2624,7 @@ function createInitCommand() {
2680
2624
  }
2681
2625
  if (!projectId) {
2682
2626
  spinner.stop();
2683
- const inquirer7 = (await import("inquirer")).default;
2627
+ const inquirer8 = (await import("inquirer")).default;
2684
2628
  spinner.start("Fetching your projects...");
2685
2629
  let projects = [];
2686
2630
  try {
@@ -2695,7 +2639,7 @@ function createInitCommand() {
2695
2639
  }
2696
2640
  spinner.stop();
2697
2641
  if (projects.length === 0) {
2698
- const { manualProjectId } = await inquirer7.prompt([
2642
+ const { manualProjectId } = await inquirer8.prompt([
2699
2643
  {
2700
2644
  type: "input",
2701
2645
  name: "manualProjectId",
@@ -2707,7 +2651,7 @@ function createInitCommand() {
2707
2651
  } else {
2708
2652
  const choices = [
2709
2653
  { name: "\u2795 Create New Project", value: "NEW" },
2710
- new inquirer7.Separator()
2654
+ new inquirer8.Separator()
2711
2655
  ];
2712
2656
  projects.forEach((p) => {
2713
2657
  choices.push({
@@ -2715,7 +2659,7 @@ function createInitCommand() {
2715
2659
  value: p.id
2716
2660
  });
2717
2661
  });
2718
- const { selectedId } = await inquirer7.prompt([
2662
+ const { selectedId } = await inquirer8.prompt([
2719
2663
  {
2720
2664
  type: "list",
2721
2665
  name: "selectedId",
@@ -2725,7 +2669,7 @@ function createInitCommand() {
2725
2669
  }
2726
2670
  ]);
2727
2671
  if (selectedId === "NEW") {
2728
- const { newName } = await inquirer7.prompt([
2672
+ const { newName } = await inquirer8.prompt([
2729
2673
  {
2730
2674
  type: "input",
2731
2675
  name: "newName",
@@ -2745,7 +2689,7 @@ function createInitCommand() {
2745
2689
  spinner.stop();
2746
2690
  let selectedOrgId = orgs[0]?.id;
2747
2691
  if (orgs.length > 1) {
2748
- const { orgId } = await inquirer7.prompt([
2692
+ const { orgId } = await inquirer8.prompt([
2749
2693
  {
2750
2694
  type: "list",
2751
2695
  name: "orgId",
@@ -2759,7 +2703,7 @@ function createInitCommand() {
2759
2703
  selectedOrgId = orgId;
2760
2704
  }
2761
2705
  if (!selectedOrgId) {
2762
- console.log(import_chalk13.default.yellow("No organization available. Please create the project via the Rigstate dashboard."));
2706
+ console.log(import_chalk12.default.yellow("No organization available. Please create the project via the Rigstate dashboard."));
2763
2707
  return;
2764
2708
  }
2765
2709
  spinner.start("Creating new project...");
@@ -2771,13 +2715,13 @@ function createInitCommand() {
2771
2715
  headers: { Authorization: `Bearer ${apiKey}` }
2772
2716
  });
2773
2717
  if (!createResponse.data.success) {
2774
- spinner.fail(import_chalk13.default.red("Failed to create project: " + createResponse.data.error));
2718
+ spinner.fail(import_chalk12.default.red("Failed to create project: " + createResponse.data.error));
2775
2719
  return;
2776
2720
  }
2777
2721
  projectId = createResponse.data.data.project.id;
2778
- spinner.succeed(import_chalk13.default.green(`Created new project: ${newName}`));
2722
+ spinner.succeed(import_chalk12.default.green(`Created new project: ${newName}`));
2779
2723
  } catch (e) {
2780
- spinner.fail(import_chalk13.default.red("Project creation API not available. Please create via dashboard."));
2724
+ spinner.fail(import_chalk12.default.red("Project creation API not available. Please create via dashboard."));
2781
2725
  return;
2782
2726
  }
2783
2727
  } else {
@@ -2787,28 +2731,28 @@ function createInitCommand() {
2787
2731
  spinner.start(`Linking to project ID: ${projectId}...`);
2788
2732
  }
2789
2733
  setProjectId(projectId);
2790
- const manifestPath = import_path12.default.join(process.cwd(), ".rigstate");
2734
+ const manifestPath = import_path11.default.join(process.cwd(), ".rigstate");
2791
2735
  const manifestContent = {
2792
2736
  project_id: projectId,
2793
2737
  last_linked: (/* @__PURE__ */ new Date()).toISOString(),
2794
2738
  api_url: apiUrl
2795
2739
  };
2796
- await import_promises12.default.writeFile(manifestPath, JSON.stringify(manifestContent, null, 2), "utf-8");
2740
+ await import_promises11.default.writeFile(manifestPath, JSON.stringify(manifestContent, null, 2), "utf-8");
2797
2741
  try {
2798
- await import_promises12.default.access(".git");
2742
+ await import_promises11.default.access(".git");
2799
2743
  } catch {
2800
2744
  spinner.text = "Initializing git repository...";
2801
2745
  (0, import_child_process.execSync)("git init", { stdio: "ignore" });
2802
2746
  }
2803
- spinner.succeed(import_chalk13.default.green(`\u2705 Linked to project: ${projectId}`));
2747
+ spinner.succeed(import_chalk12.default.green(`\u2705 Linked to project: ${projectId}`));
2804
2748
  await generateRules(apiUrl, apiKey, projectId, options.force, spinner);
2805
2749
  console.log("");
2806
- console.log(import_chalk13.default.blue("Next steps:"));
2807
- console.log(import_chalk13.default.dim(" rigstate sync - Sync roadmap and context"));
2808
- console.log(import_chalk13.default.dim(" rigstate watch - Start development loop"));
2809
- console.log(import_chalk13.default.dim(" rigstate focus - Get current task"));
2750
+ console.log(import_chalk12.default.blue("Next steps:"));
2751
+ console.log(import_chalk12.default.dim(" rigstate sync - Sync roadmap and context"));
2752
+ console.log(import_chalk12.default.dim(" rigstate watch - Start development loop"));
2753
+ console.log(import_chalk12.default.dim(" rigstate focus - Get current task"));
2810
2754
  } catch (e) {
2811
- spinner.fail(import_chalk13.default.red("Initialization failed: " + e.message));
2755
+ spinner.fail(import_chalk12.default.red("Initialization failed: " + e.message));
2812
2756
  }
2813
2757
  });
2814
2758
  }
@@ -2823,67 +2767,67 @@ async function generateRules(apiUrl, apiKey, projectId, force, spinner) {
2823
2767
  if (response.data.success || response.data.files) {
2824
2768
  const files = response.data.files || [];
2825
2769
  if (files.length === 0 && response.data.rules) {
2826
- const rulesPath = import_path12.default.join(process.cwd(), ".cursorrules");
2827
- await import_promises12.default.writeFile(rulesPath, response.data.rules, "utf-8");
2828
- spinner.succeed(import_chalk13.default.green("\u2714 Generated .cursorrules (legacy mode)"));
2770
+ const rulesPath = import_path11.default.join(process.cwd(), ".cursorrules");
2771
+ await import_promises11.default.writeFile(rulesPath, response.data.rules, "utf-8");
2772
+ spinner.succeed(import_chalk12.default.green("\u2714 Generated .cursorrules (legacy mode)"));
2829
2773
  return;
2830
2774
  }
2831
2775
  for (const file of files) {
2832
- const targetPath = import_path12.default.join(process.cwd(), file.path);
2833
- const targetDir = import_path12.default.dirname(targetPath);
2834
- await import_promises12.default.mkdir(targetDir, { recursive: true });
2776
+ const targetPath = import_path11.default.join(process.cwd(), file.path);
2777
+ const targetDir = import_path11.default.dirname(targetPath);
2778
+ await import_promises11.default.mkdir(targetDir, { recursive: true });
2835
2779
  try {
2836
- await import_promises12.default.access(targetPath);
2780
+ await import_promises11.default.access(targetPath);
2837
2781
  if (!force && !file.path.startsWith(".cursor/rules/")) {
2838
- console.log(import_chalk13.default.dim(` ${file.path} already exists. Skipping.`));
2782
+ console.log(import_chalk12.default.dim(` ${file.path} already exists. Skipping.`));
2839
2783
  continue;
2840
2784
  }
2841
2785
  } catch {
2842
2786
  }
2843
- await import_promises12.default.writeFile(targetPath, file.content, "utf-8");
2787
+ await import_promises11.default.writeFile(targetPath, file.content, "utf-8");
2844
2788
  }
2845
2789
  if (files.length > 0) {
2846
- const legacyPath = import_path12.default.join(process.cwd(), ".cursorrules");
2790
+ const legacyPath = import_path11.default.join(process.cwd(), ".cursorrules");
2847
2791
  try {
2848
- const stats = await import_promises12.default.stat(legacyPath);
2792
+ const stats = await import_promises11.default.stat(legacyPath);
2849
2793
  if (stats.isFile()) {
2850
- await import_promises12.default.rename(legacyPath, `${legacyPath}.bak`);
2851
- console.log(import_chalk13.default.dim(" Moved legacy .cursorrules to .cursorrules.bak"));
2794
+ await import_promises11.default.rename(legacyPath, `${legacyPath}.bak`);
2795
+ console.log(import_chalk12.default.dim(" Moved legacy .cursorrules to .cursorrules.bak"));
2852
2796
  }
2853
2797
  } catch (e) {
2854
2798
  }
2855
2799
  }
2856
- spinner.succeed(import_chalk13.default.green(`\u2714 Generated ${files.length} rule files (v${response.data.version || "3.0"})`));
2800
+ spinner.succeed(import_chalk12.default.green(`\u2714 Generated ${files.length} rule files (v${response.data.version || "3.0"})`));
2857
2801
  } else {
2858
- spinner.info(import_chalk13.default.dim(" Rules generation skipped (API response invalid)"));
2802
+ spinner.info(import_chalk12.default.dim(" Rules generation skipped (API response invalid)"));
2859
2803
  }
2860
2804
  } catch (e) {
2861
- spinner.info(import_chalk13.default.dim(` Rules generation failed: ${e.message}`));
2805
+ spinner.info(import_chalk12.default.dim(` Rules generation failed: ${e.message}`));
2862
2806
  }
2863
2807
  }
2864
2808
 
2865
2809
  // src/commands/check.ts
2866
2810
  init_cjs_shims();
2867
- var import_commander10 = require("commander");
2868
- var import_chalk15 = __toESM(require("chalk"), 1);
2811
+ var import_commander9 = require("commander");
2812
+ var import_chalk14 = __toESM(require("chalk"), 1);
2869
2813
  var import_ora7 = __toESM(require("ora"), 1);
2870
2814
  var import_axios10 = __toESM(require("axios"), 1);
2871
2815
  var import_glob3 = require("glob");
2872
- var import_promises14 = __toESM(require("fs/promises"), 1);
2873
- var import_path14 = __toESM(require("path"), 1);
2816
+ var import_promises13 = __toESM(require("fs/promises"), 1);
2817
+ var import_path13 = __toESM(require("path"), 1);
2874
2818
  var import_child_process2 = require("child_process");
2875
2819
  init_config();
2876
2820
 
2877
2821
  // src/utils/rule-engine.ts
2878
2822
  init_cjs_shims();
2879
- var import_promises13 = __toESM(require("fs/promises"), 1);
2880
- var import_path13 = __toESM(require("path"), 1);
2881
- var import_chalk14 = __toESM(require("chalk"), 1);
2823
+ var import_promises12 = __toESM(require("fs/promises"), 1);
2824
+ var import_path12 = __toESM(require("path"), 1);
2825
+ var import_chalk13 = __toESM(require("chalk"), 1);
2882
2826
  async function checkFile(filePath, rules, rootPath) {
2883
2827
  const violations = [];
2884
- const relativePath = import_path13.default.relative(rootPath, filePath);
2828
+ const relativePath = import_path12.default.relative(rootPath, filePath);
2885
2829
  try {
2886
- const content = await import_promises13.default.readFile(filePath, "utf-8");
2830
+ const content = await import_promises12.default.readFile(filePath, "utf-8");
2887
2831
  const lines = content.split("\n");
2888
2832
  for (const rule of rules) {
2889
2833
  const ruleViolations = await evaluateRule(rule, content, lines, relativePath);
@@ -2974,7 +2918,7 @@ async function evaluateRule(rule, content, lines, filePath) {
2974
2918
  case "NAMING_CONVENTION": {
2975
2919
  const value = rule.value;
2976
2920
  const pattern = new RegExp(value.pattern);
2977
- const fileName = import_path13.default.basename(filePath);
2921
+ const fileName = import_path12.default.basename(filePath);
2978
2922
  if (filePath.includes(value.context) && !pattern.test(fileName)) {
2979
2923
  violations.push({
2980
2924
  file: filePath,
@@ -3033,12 +2977,12 @@ function checkFunctionLines(content, lines, filePath, rule, limit) {
3033
2977
  }
3034
2978
  function formatViolations(violations) {
3035
2979
  for (const v of violations) {
3036
- const severityColor = v.severity === "critical" ? import_chalk14.default.red : v.severity === "warning" ? import_chalk14.default.yellow : import_chalk14.default.blue;
3037
- const lineInfo = v.line ? import_chalk14.default.dim(`:${v.line}`) : "";
2980
+ const severityColor = v.severity === "critical" ? import_chalk13.default.red : v.severity === "warning" ? import_chalk13.default.yellow : import_chalk13.default.blue;
2981
+ const lineInfo = v.line ? import_chalk13.default.dim(`:${v.line}`) : "";
3038
2982
  console.log(` ${severityColor(`[${v.severity.toUpperCase()}]`)} ${v.file}${lineInfo}`);
3039
2983
  console.log(` ${v.message}`);
3040
2984
  if (v.details) {
3041
- console.log(` ${import_chalk14.default.dim(v.details)}`);
2985
+ console.log(` ${import_chalk13.default.dim(v.details)}`);
3042
2986
  }
3043
2987
  }
3044
2988
  }
@@ -3067,7 +3011,7 @@ var CACHE_FILE2 = ".rigstate/rules-cache.json";
3067
3011
  var CACHE_TTL_MS = 5 * 60 * 1e3;
3068
3012
  var CACHE_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
3069
3013
  function createCheckCommand() {
3070
- return new import_commander10.Command("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) => {
3014
+ return new import_commander9.Command("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) => {
3071
3015
  const spinner = (0, import_ora7.default)();
3072
3016
  try {
3073
3017
  let projectId = options.project;
@@ -3083,15 +3027,15 @@ function createCheckCommand() {
3083
3027
  projectId = getProjectId();
3084
3028
  }
3085
3029
  if (!projectId) {
3086
- console.log(import_chalk15.default.red("\u274C No project context found."));
3087
- console.log(import_chalk15.default.dim(' Run "rigstate link" or pass --project <id>'));
3030
+ console.log(import_chalk14.default.red("\u274C No project context found."));
3031
+ console.log(import_chalk14.default.dim(' Run "rigstate link" or pass --project <id>'));
3088
3032
  process.exit(2);
3089
3033
  }
3090
3034
  let apiKey;
3091
3035
  try {
3092
3036
  apiKey = getApiKey();
3093
3037
  } catch {
3094
- console.log(import_chalk15.default.red('\u274C Not authenticated. Run "rigstate login" first.'));
3038
+ console.log(import_chalk14.default.red('\u274C Not authenticated. Run "rigstate login" first.'));
3095
3039
  process.exit(2);
3096
3040
  }
3097
3041
  spinner.start("Fetching Guardian rules...");
@@ -3119,17 +3063,17 @@ function createCheckCommand() {
3119
3063
  } catch (apiError) {
3120
3064
  const cached = await loadCachedRules(projectId);
3121
3065
  if (cached && !isStale(cached.timestamp, CACHE_MAX_AGE_MS)) {
3122
- spinner.warn(import_chalk15.default.yellow("Using cached rules (API unavailable)"));
3066
+ spinner.warn(import_chalk14.default.yellow("Using cached rules (API unavailable)"));
3123
3067
  rules = cached.rules;
3124
3068
  settings = cached.settings;
3125
3069
  } else {
3126
- spinner.fail(import_chalk15.default.red("Failed to fetch rules and no valid cache"));
3127
- console.log(import_chalk15.default.dim(` Error: ${apiError.message}`));
3070
+ spinner.fail(import_chalk14.default.red("Failed to fetch rules and no valid cache"));
3071
+ console.log(import_chalk14.default.dim(` Error: ${apiError.message}`));
3128
3072
  process.exit(2);
3129
3073
  }
3130
3074
  }
3131
3075
  spinner.succeed(`Loaded ${rules.length} Guardian rules`);
3132
- const scanPath = import_path14.default.resolve(process.cwd(), targetPath);
3076
+ const scanPath = import_path13.default.resolve(process.cwd(), targetPath);
3133
3077
  let filesToCheck;
3134
3078
  if (options.staged) {
3135
3079
  spinner.start("Getting staged files...");
@@ -3138,14 +3082,14 @@ function createCheckCommand() {
3138
3082
  encoding: "utf-8",
3139
3083
  cwd: process.cwd()
3140
3084
  });
3141
- filesToCheck = stagedOutput.split("\n").filter((f) => f.trim()).filter((f) => isCodeFile2(f)).map((f) => import_path14.default.resolve(process.cwd(), f));
3085
+ filesToCheck = stagedOutput.split("\n").filter((f) => f.trim()).filter((f) => isCodeFile2(f)).map((f) => import_path13.default.resolve(process.cwd(), f));
3142
3086
  } catch {
3143
3087
  spinner.fail("Not a git repository or no staged files");
3144
3088
  process.exit(2);
3145
3089
  }
3146
3090
  } else {
3147
- spinner.start(`Scanning ${import_chalk15.default.cyan(targetPath)}...`);
3148
- const pattern = import_path14.default.join(scanPath, "**/*");
3091
+ spinner.start(`Scanning ${import_chalk14.default.cyan(targetPath)}...`);
3092
+ const pattern = import_path13.default.join(scanPath, "**/*");
3149
3093
  const allFiles = await (0, import_glob3.glob)(pattern, {
3150
3094
  nodir: true,
3151
3095
  dot: false,
@@ -3161,7 +3105,7 @@ function createCheckCommand() {
3161
3105
  filesToCheck = allFiles.filter((f) => isCodeFile2(f));
3162
3106
  }
3163
3107
  if (filesToCheck.length === 0) {
3164
- spinner.warn(import_chalk15.default.yellow("No code files found to check."));
3108
+ spinner.warn(import_chalk14.default.yellow("No code files found to check."));
3165
3109
  outputResults([], !!options.json);
3166
3110
  process.exit(0);
3167
3111
  }
@@ -3170,7 +3114,7 @@ function createCheckCommand() {
3170
3114
  const results = [];
3171
3115
  for (let i = 0; i < filesToCheck.length; i++) {
3172
3116
  const file = filesToCheck[i];
3173
- spinner.text = `Checking ${i + 1}/${filesToCheck.length}: ${import_path14.default.basename(file)}`;
3117
+ spinner.text = `Checking ${i + 1}/${filesToCheck.length}: ${import_path13.default.basename(file)}`;
3174
3118
  const result = await checkFile(file, rules, process.cwd());
3175
3119
  results.push(result);
3176
3120
  }
@@ -3180,47 +3124,47 @@ function createCheckCommand() {
3180
3124
  outputResults(results, true);
3181
3125
  } else {
3182
3126
  outputResults(results, false);
3183
- console.log("\n" + import_chalk15.default.bold("\u{1F4CA} Summary"));
3184
- console.log(import_chalk15.default.dim("\u2500".repeat(50)));
3185
- console.log(`Files checked: ${import_chalk15.default.cyan(summary.totalFiles)}`);
3186
- console.log(`Total violations: ${summary.totalViolations > 0 ? import_chalk15.default.red(summary.totalViolations) : import_chalk15.default.green(0)}`);
3127
+ console.log("\n" + import_chalk14.default.bold("\u{1F4CA} Summary"));
3128
+ console.log(import_chalk14.default.dim("\u2500".repeat(50)));
3129
+ console.log(`Files checked: ${import_chalk14.default.cyan(summary.totalFiles)}`);
3130
+ console.log(`Total violations: ${summary.totalViolations > 0 ? import_chalk14.default.red(summary.totalViolations) : import_chalk14.default.green(0)}`);
3187
3131
  if (summary.totalViolations > 0) {
3188
- console.log(` ${import_chalk15.default.red("Critical:")} ${summary.criticalCount}`);
3189
- console.log(` ${import_chalk15.default.yellow("Warning:")} ${summary.warningCount}`);
3190
- console.log(` ${import_chalk15.default.blue("Info:")} ${summary.infoCount}`);
3132
+ console.log(` ${import_chalk14.default.red("Critical:")} ${summary.criticalCount}`);
3133
+ console.log(` ${import_chalk14.default.yellow("Warning:")} ${summary.warningCount}`);
3134
+ console.log(` ${import_chalk14.default.blue("Info:")} ${summary.infoCount}`);
3191
3135
  }
3192
- console.log(import_chalk15.default.dim("\u2500".repeat(50)));
3136
+ console.log(import_chalk14.default.dim("\u2500".repeat(50)));
3193
3137
  }
3194
3138
  if (options.strict !== void 0) {
3195
3139
  const strictLevel = typeof options.strict === "string" ? options.strict : "all";
3196
3140
  if (strictLevel === "critical" && summary.criticalCount > 0) {
3197
- console.log(import_chalk15.default.red("\n\u274C Check failed: Critical violations found"));
3141
+ console.log(import_chalk14.default.red("\n\u274C Check failed: Critical violations found"));
3198
3142
  process.exit(1);
3199
3143
  } else if (strictLevel === "all" && summary.totalViolations > 0) {
3200
- console.log(import_chalk15.default.red("\n\u274C Check failed: Violations found"));
3144
+ console.log(import_chalk14.default.red("\n\u274C Check failed: Violations found"));
3201
3145
  process.exit(1);
3202
3146
  }
3203
3147
  }
3204
3148
  if (summary.totalViolations === 0) {
3205
- console.log(import_chalk15.default.green("\n\u2705 All checks passed!"));
3149
+ console.log(import_chalk14.default.green("\n\u2705 All checks passed!"));
3206
3150
  }
3207
3151
  process.exit(0);
3208
3152
  } catch (error) {
3209
- spinner.fail(import_chalk15.default.red("Check failed"));
3210
- console.error(import_chalk15.default.red("Error:"), error.message);
3153
+ spinner.fail(import_chalk14.default.red("Check failed"));
3154
+ console.error(import_chalk14.default.red("Error:"), error.message);
3211
3155
  process.exit(2);
3212
3156
  }
3213
3157
  });
3214
3158
  }
3215
3159
  function isCodeFile2(filePath) {
3216
3160
  const codeExtensions = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
3217
- const ext = import_path14.default.extname(filePath).toLowerCase();
3161
+ const ext = import_path13.default.extname(filePath).toLowerCase();
3218
3162
  return codeExtensions.includes(ext);
3219
3163
  }
3220
3164
  async function loadCachedRules(projectId) {
3221
3165
  try {
3222
- const cachePath = import_path14.default.join(process.cwd(), CACHE_FILE2);
3223
- const content = await import_promises14.default.readFile(cachePath, "utf-8");
3166
+ const cachePath = import_path13.default.join(process.cwd(), CACHE_FILE2);
3167
+ const content = await import_promises13.default.readFile(cachePath, "utf-8");
3224
3168
  const cached = JSON.parse(content);
3225
3169
  if (cached.projectId !== projectId) {
3226
3170
  return null;
@@ -3232,16 +3176,16 @@ async function loadCachedRules(projectId) {
3232
3176
  }
3233
3177
  async function saveCachedRules(projectId, rules, settings) {
3234
3178
  try {
3235
- const cacheDir = import_path14.default.join(process.cwd(), ".rigstate");
3236
- await import_promises14.default.mkdir(cacheDir, { recursive: true });
3179
+ const cacheDir = import_path13.default.join(process.cwd(), ".rigstate");
3180
+ await import_promises13.default.mkdir(cacheDir, { recursive: true });
3237
3181
  const cached = {
3238
3182
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
3239
3183
  projectId,
3240
3184
  rules,
3241
3185
  settings
3242
3186
  };
3243
- await import_promises14.default.writeFile(
3244
- import_path14.default.join(cacheDir, "rules-cache.json"),
3187
+ await import_promises13.default.writeFile(
3188
+ import_path13.default.join(cacheDir, "rules-cache.json"),
3245
3189
  JSON.stringify(cached, null, 2)
3246
3190
  );
3247
3191
  } catch {
@@ -3263,8 +3207,8 @@ function outputResults(results, json) {
3263
3207
  if (!hasViolations) {
3264
3208
  return;
3265
3209
  }
3266
- console.log("\n" + import_chalk15.default.bold("\u{1F50D} Violations Found"));
3267
- console.log(import_chalk15.default.dim("\u2500".repeat(50)));
3210
+ console.log("\n" + import_chalk14.default.bold("\u{1F50D} Violations Found"));
3211
+ console.log(import_chalk14.default.dim("\u2500".repeat(50)));
3268
3212
  for (const result of results) {
3269
3213
  if (result.violations.length > 0) {
3270
3214
  formatViolations(result.violations);
@@ -3272,8 +3216,125 @@ function outputResults(results, json) {
3272
3216
  }
3273
3217
  }
3274
3218
 
3275
- // src/index.ts
3276
- init_hooks();
3219
+ // src/commands/hooks.ts
3220
+ init_cjs_shims();
3221
+ var import_commander10 = require("commander");
3222
+ var import_chalk15 = __toESM(require("chalk"), 1);
3223
+ var import_promises14 = __toESM(require("fs/promises"), 1);
3224
+ var import_path14 = __toESM(require("path"), 1);
3225
+ var PRE_COMMIT_SCRIPT = `#!/bin/sh
3226
+ # Rigstate Guardian Pre-commit Hook
3227
+ # Installed by: rigstate hooks install
3228
+
3229
+ # 1. Silent Sentinel Check (Phase 5)
3230
+ if [ -f .rigstate/guardian.lock ]; then
3231
+ echo "\u{1F6D1} INTERVENTION ACTIVE: Commit blocked by Silent Sentinel."
3232
+ echo " A critical violation ('HARD_LOCK') was detected by the Guardian Daemon."
3233
+ echo " Please fix the violation to unlock the repo."
3234
+ echo ""
3235
+ if grep -q "HARD_LOCK_ACTIVE" .rigstate/guardian.lock; then
3236
+ cat .rigstate/guardian.lock
3237
+ fi
3238
+ exit 1
3239
+ fi
3240
+
3241
+ echo "\u{1F6E1}\uFE0F Running Guardian checks..."
3242
+
3243
+ # Run check with strict mode for critical violations
3244
+ rigstate check --staged --strict=critical
3245
+
3246
+ # Exit with the same code as rigstate check
3247
+ exit $?
3248
+ `;
3249
+ function createHooksCommand() {
3250
+ const hooks = new import_commander10.Command("hooks").description("Manage git hooks for Guardian integration");
3251
+ 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) => {
3252
+ try {
3253
+ const gitDir = import_path14.default.join(process.cwd(), ".git");
3254
+ try {
3255
+ await import_promises14.default.access(gitDir);
3256
+ } catch {
3257
+ console.log(import_chalk15.default.red("\u274C Not a git repository."));
3258
+ console.log(import_chalk15.default.dim(' Initialize with "git init" first.'));
3259
+ process.exit(1);
3260
+ }
3261
+ const hooksDir = import_path14.default.join(gitDir, "hooks");
3262
+ await import_promises14.default.mkdir(hooksDir, { recursive: true });
3263
+ const preCommitPath = import_path14.default.join(hooksDir, "pre-commit");
3264
+ let existingContent = "";
3265
+ try {
3266
+ existingContent = await import_promises14.default.readFile(preCommitPath, "utf-8");
3267
+ if (existingContent.includes("rigstate")) {
3268
+ console.log(import_chalk15.default.yellow("\u26A0 Rigstate pre-commit hook already installed."));
3269
+ console.log(import_chalk15.default.dim(' Use "rigstate hooks uninstall" to remove first.'));
3270
+ return;
3271
+ }
3272
+ } catch {
3273
+ }
3274
+ let script = PRE_COMMIT_SCRIPT;
3275
+ if (options.strict === "all") {
3276
+ script = script.replace("--strict=critical", "--strict");
3277
+ }
3278
+ if (existingContent && !existingContent.includes("rigstate")) {
3279
+ const combinedScript = existingContent + "\n\n" + script.replace("#!/bin/sh\n", "");
3280
+ await import_promises14.default.writeFile(preCommitPath, combinedScript, { mode: 493 });
3281
+ console.log(import_chalk15.default.green("\u2705 Rigstate hook appended to existing pre-commit."));
3282
+ } else {
3283
+ await import_promises14.default.writeFile(preCommitPath, script, { mode: 493 });
3284
+ console.log(import_chalk15.default.green("\u2705 Pre-commit hook installed!"));
3285
+ }
3286
+ console.log(import_chalk15.default.dim(` Path: ${preCommitPath}`));
3287
+ console.log(import_chalk15.default.dim(` Strict level: ${options.strict}`));
3288
+ console.log("");
3289
+ console.log(import_chalk15.default.cyan("Guardian will now check your code before each commit."));
3290
+ console.log(import_chalk15.default.dim('Use "rigstate hooks uninstall" to remove the hook.'));
3291
+ } catch (error) {
3292
+ console.error(import_chalk15.default.red("Failed to install hook:"), error.message);
3293
+ process.exit(1);
3294
+ }
3295
+ });
3296
+ hooks.command("uninstall").description("Remove Rigstate pre-commit hook").action(async () => {
3297
+ try {
3298
+ const preCommitPath = import_path14.default.join(process.cwd(), ".git", "hooks", "pre-commit");
3299
+ try {
3300
+ const content = await import_promises14.default.readFile(preCommitPath, "utf-8");
3301
+ if (!content.includes("rigstate")) {
3302
+ console.log(import_chalk15.default.yellow("\u26A0 No Rigstate hook found in pre-commit."));
3303
+ return;
3304
+ }
3305
+ if (content.includes("# Rigstate Guardian Pre-commit Hook") && content.trim().split("\n").filter((l) => l && !l.startsWith("#")).length <= 4) {
3306
+ await import_promises14.default.unlink(preCommitPath);
3307
+ console.log(import_chalk15.default.green("\u2705 Pre-commit hook removed."));
3308
+ } else {
3309
+ const lines = content.split("\n");
3310
+ const filteredLines = [];
3311
+ let inRigstateSection = false;
3312
+ for (const line of lines) {
3313
+ if (line.includes("Rigstate Guardian Pre-commit Hook")) {
3314
+ inRigstateSection = true;
3315
+ continue;
3316
+ }
3317
+ if (inRigstateSection && line.includes("exit $?")) {
3318
+ inRigstateSection = false;
3319
+ continue;
3320
+ }
3321
+ if (!inRigstateSection && !line.includes("rigstate check")) {
3322
+ filteredLines.push(line);
3323
+ }
3324
+ }
3325
+ await import_promises14.default.writeFile(preCommitPath, filteredLines.join("\n"), { mode: 493 });
3326
+ console.log(import_chalk15.default.green("\u2705 Rigstate section removed from pre-commit hook."));
3327
+ }
3328
+ } catch {
3329
+ console.log(import_chalk15.default.yellow("\u26A0 No pre-commit hook found."));
3330
+ }
3331
+ } catch (error) {
3332
+ console.error(import_chalk15.default.red("Failed to uninstall hook:"), error.message);
3333
+ process.exit(1);
3334
+ }
3335
+ });
3336
+ return hooks;
3337
+ }
3277
3338
 
3278
3339
  // src/commands/daemon.ts
3279
3340
  init_cjs_shims();
@@ -3981,7 +4042,7 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
3981
4042
  setupFileWatcher() {
3982
4043
  Logger.info("Starting file watcher...");
3983
4044
  this.fileWatcher = createFileWatcher(this.config.watchPath);
3984
- this.fileWatcher.on("change", (path26) => this.handleFileChange(path26));
4045
+ this.fileWatcher.on("change", (path27) => this.handleFileChange(path27));
3985
4046
  this.fileWatcher.start();
3986
4047
  Logger.info("File watcher active");
3987
4048
  }
@@ -4378,15 +4439,149 @@ async function showStatus() {
4378
4439
 
4379
4440
  // src/commands/work.ts
4380
4441
  init_cjs_shims();
4442
+ var import_commander13 = require("commander");
4443
+ var import_chalk23 = __toESM(require("chalk"), 1);
4444
+ var import_ora10 = __toESM(require("ora"), 1);
4445
+ var import_axios16 = __toESM(require("axios"), 1);
4446
+ var import_inquirer3 = __toESM(require("inquirer"), 1);
4447
+ init_config();
4448
+ init_suggest();
4449
+
4450
+ // src/commands/plan.ts
4451
+ init_cjs_shims();
4381
4452
  var import_commander12 = require("commander");
4382
4453
  var import_chalk22 = __toESM(require("chalk"), 1);
4383
4454
  var import_ora9 = __toESM(require("ora"), 1);
4384
4455
  var import_axios15 = __toESM(require("axios"), 1);
4456
+ var import_promises19 = __toESM(require("fs/promises"), 1);
4457
+ var import_path22 = __toESM(require("path"), 1);
4385
4458
  var import_inquirer2 = __toESM(require("inquirer"), 1);
4386
4459
  init_config();
4387
- init_suggest();
4460
+ function createPlanCommand() {
4461
+ const plan = new import_commander12.Command("plan");
4462
+ plan.description("Generate an implementation plan for a roadmap task").argument("[taskId]", "Task ID (e.g. T-10) or UUID").action(async (taskId) => {
4463
+ await executePlan(taskId);
4464
+ });
4465
+ return plan;
4466
+ }
4467
+ async function executePlan(taskId) {
4468
+ const spinner = (0, import_ora9.default)("Initializing Planning Mode...").start();
4469
+ try {
4470
+ const { projectId, apiKey, apiUrl } = getContext();
4471
+ let realId = taskId;
4472
+ let taskTitle = "";
4473
+ let taskDescription = "";
4474
+ if (!taskId) {
4475
+ spinner.text = "Fetching actionable tasks...";
4476
+ const response = await import_axios15.default.get(
4477
+ `${apiUrl}/api/v1/roadmap?project_id=${projectId}`,
4478
+ { headers: { "Authorization": `Bearer ${apiKey}` } }
4479
+ );
4480
+ if (!response.data.success) throw new Error("Failed to fetch roadmap");
4481
+ const tasks = response.data.data.roadmap || [];
4482
+ const choices = tasks.filter((t) => ["ACTIVE", "IN_PROGRESS", "PENDING"].includes(t.status)).map((t) => ({
4483
+ name: `T-${t.step_number}: ${t.title}`,
4484
+ value: t
4485
+ }));
4486
+ if (choices.length === 0) {
4487
+ spinner.fail("No actionable tasks found in roadmap.");
4488
+ return;
4489
+ }
4490
+ spinner.stop();
4491
+ const answer = await import_inquirer2.default.prompt([{
4492
+ type: "list",
4493
+ name: "task",
4494
+ message: "Select a task to plan:",
4495
+ choices
4496
+ }]);
4497
+ realId = answer.task.id;
4498
+ taskTitle = answer.task.title;
4499
+ taskDescription = answer.task.description;
4500
+ taskId = `T-${answer.task.step_number}`;
4501
+ } else {
4502
+ spinner.text = `Fetching details for ${taskId}...`;
4503
+ const response = await import_axios15.default.get(
4504
+ `${apiUrl}/api/v1/roadmap?project_id=${projectId}`,
4505
+ { headers: { "Authorization": `Bearer ${apiKey}` } }
4506
+ );
4507
+ const task = response.data.data.roadmap.find(
4508
+ (t) => t.id === taskId || `T-${t.step_number}` === taskId || t.step_number.toString() === taskId
4509
+ );
4510
+ if (!task) throw new Error(`Task ${taskId} not found.`);
4511
+ realId = task.id;
4512
+ taskTitle = task.title;
4513
+ taskDescription = task.description;
4514
+ }
4515
+ spinner.start("Generating Context for Frank...");
4516
+ const contextPath = import_path22.default.join(process.cwd(), ".rigstate", "CURRENT_CONTEXT.md");
4517
+ const contextContent = `
4518
+ # \u{1F3AF} Active Mission: ${taskTitle}
4519
+ **ID:** ${taskId}
4520
+
4521
+ ## \u{1F4DD} Description
4522
+ ${taskDescription}
4523
+
4524
+ ## \u{1F6E1}\uFE0F Architectural Constraints
4525
+ - Follow strictly the rules in .cursor/rules/
4526
+ - Ensure zero violations in ACTIVE_VIOLATIONS.md
4527
+ - Update IMPLEMENTATION_PLAN.md before writing code.
4528
+
4529
+ *Generated by Rigstate CLI at ${(/* @__PURE__ */ new Date()).toLocaleString()}*
4530
+ `;
4531
+ await import_promises19.default.mkdir(import_path22.default.dirname(contextPath), { recursive: true });
4532
+ await import_promises19.default.writeFile(contextPath, contextContent.trim());
4533
+ const planPath = import_path22.default.join(process.cwd(), "IMPLEMENTATION_PLAN.md");
4534
+ const planExists = await import_promises19.default.stat(planPath).then(() => true).catch(() => false);
4535
+ if (!planExists) {
4536
+ const planTemplate = `
4537
+ # \u{1F4CB} Implementation Plan: ${taskTitle}
4538
+
4539
+ ## 1. \u{1F50D} Analysis
4540
+ - [ ] Understand the requirements in .rigstate/CURRENT_CONTEXT.md
4541
+ - [ ] Check for existing architectural patterns
4542
+
4543
+ ## 2. \u{1F3D7}\uFE0F Proposed Changes
4544
+ [Frank: List the files you intend to modify and the nature of the changes]
4545
+
4546
+ ## 3. \u2705 Verification
4547
+ - [ ] Run tests
4548
+ - [ ] Verification Step 1...
4549
+
4550
+ ## 4. \u{1F680} Execution
4551
+ [Frank: Log your progress here]
4552
+ `;
4553
+ await import_promises19.default.writeFile(planPath, planTemplate.trim());
4554
+ spinner.succeed(import_chalk22.default.green("Created new IMPLEMENTATION_PLAN.md"));
4555
+ } else {
4556
+ spinner.info(import_chalk22.default.yellow("IMPLEMENTATION_PLAN.md already exists. Preserving it."));
4557
+ }
4558
+ console.log("");
4559
+ console.log(import_chalk22.default.bold.blue("\u{1F680} Planning Mode Activated"));
4560
+ console.log(import_chalk22.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
4561
+ console.log(`1. Context loaded into: ${import_chalk22.default.bold(".rigstate/CURRENT_CONTEXT.md")}`);
4562
+ console.log(`2. Plan template ready: ${import_chalk22.default.bold("IMPLEMENTATION_PLAN.md")}`);
4563
+ console.log("");
4564
+ console.log(import_chalk22.default.yellow("\u{1F449} NEXT STEP:"));
4565
+ console.log(` Open ${import_chalk22.default.bold("IMPLEMENTATION_PLAN.md")} in your IDE.`);
4566
+ console.log(` Tell Frank: ${import_chalk22.default.italic('"Read the context and draft the plan."')}`);
4567
+ console.log("");
4568
+ } catch (e) {
4569
+ spinner.fail(import_chalk22.default.red(`Planning failed: ${e.message}`));
4570
+ }
4571
+ }
4572
+ function getContext() {
4573
+ const apiKey = getApiKey();
4574
+ const apiUrl = getApiUrl();
4575
+ const projectId = getProjectId();
4576
+ if (!projectId) {
4577
+ throw new Error("Project ID missing. Run rigstate link.");
4578
+ }
4579
+ return { projectId, apiKey, apiUrl };
4580
+ }
4581
+
4582
+ // src/commands/work.ts
4388
4583
  function createWorkCommand() {
4389
- const work = new import_commander12.Command("work");
4584
+ const work = new import_commander13.Command("work");
4390
4585
  work.description("Manage development flow (Start, Finish, List)").action(() => {
4391
4586
  listInteractive();
4392
4587
  });
@@ -4399,10 +4594,10 @@ function createWorkCommand() {
4399
4594
  return work;
4400
4595
  }
4401
4596
  async function listInteractive() {
4402
- const spinner = (0, import_ora9.default)("Fetching roadmap...").start();
4597
+ const spinner = (0, import_ora10.default)("Fetching roadmap...").start();
4403
4598
  try {
4404
- const { projectId, apiKey, apiUrl } = getContext();
4405
- const response = await import_axios15.default.get(
4599
+ const { projectId, apiKey, apiUrl } = getContext2();
4600
+ const response = await import_axios16.default.get(
4406
4601
  `${apiUrl}/api/v1/roadmap?project_id=${projectId}`,
4407
4602
  { headers: { "Authorization": `Bearer ${apiKey}` } }
4408
4603
  );
@@ -4416,7 +4611,7 @@ async function listInteractive() {
4416
4611
  });
4417
4612
  spinner.stop();
4418
4613
  if (actionableTasks.length === 0) {
4419
- console.log(import_chalk22.default.yellow("Roadmap clear. No actionable tasks found."));
4614
+ console.log(import_chalk23.default.yellow("Roadmap clear. No actionable tasks found."));
4420
4615
  return;
4421
4616
  }
4422
4617
  const choices = actionableTasks.map((t) => {
@@ -4425,26 +4620,30 @@ async function listInteractive() {
4425
4620
  if (t.status === "IN_PROGRESS") icon = "\u{1F525}";
4426
4621
  if (t.status === "ACTIVE") icon = "\u25B6\uFE0F";
4427
4622
  return {
4428
- name: `${icon} ${import_chalk22.default.bold(id)}: ${t.title} [${t.status}]`,
4623
+ name: `${icon} ${import_chalk23.default.bold(id)}: ${t.title} [${t.status}]`,
4429
4624
  value: t.id
4430
4625
  };
4431
4626
  });
4432
- const { taskId } = await import_inquirer2.default.prompt([{
4627
+ const { taskId } = await import_inquirer3.default.prompt([{
4433
4628
  type: "list",
4434
4629
  name: "taskId",
4435
4630
  message: "Select a task to manage:",
4436
4631
  choices
4437
4632
  }]);
4438
- const { action } = await import_inquirer2.default.prompt([{
4633
+ const { action } = await import_inquirer3.default.prompt([{
4439
4634
  type: "list",
4440
4635
  name: "action",
4441
4636
  message: "Action:",
4442
4637
  choices: [
4638
+ { name: "Plan (Draft Blueprint - RECOMMENDED)", value: "plan" },
4443
4639
  { name: "Start (Set IN_PROGRESS)", value: "start" },
4444
4640
  { name: "Finish (Audit & Complete)", value: "finish" },
4445
4641
  { name: "Cancel", value: "cancel" }
4446
4642
  ]
4447
4643
  }]);
4644
+ if (action === "plan") {
4645
+ await executePlan(taskId);
4646
+ }
4448
4647
  if (action === "start") await setTaskStatus(taskId, "IN_PROGRESS");
4449
4648
  if (action === "finish") await finishTask(taskId);
4450
4649
  } catch (e) {
@@ -4452,45 +4651,45 @@ async function listInteractive() {
4452
4651
  }
4453
4652
  }
4454
4653
  async function setTaskStatus(taskId, status) {
4455
- const spinner = (0, import_ora9.default)(`Setting task ${taskId} to ${status}...`).start();
4654
+ const spinner = (0, import_ora10.default)(`Setting task ${taskId} to ${status}...`).start();
4456
4655
  try {
4457
- const { projectId, apiKey, apiUrl } = getContext();
4656
+ const { projectId, apiKey, apiUrl } = getContext2();
4458
4657
  let realId = taskId;
4459
4658
  if (taskId.startsWith("T-") || taskId.length < 10) {
4460
4659
  spinner.text = "Resolving Task ID...";
4461
- const lookup = await import_axios15.default.get(`${apiUrl}/api/v1/roadmap?project_id=${projectId}`, { headers: { Authorization: `Bearer ${apiKey}` } });
4660
+ const lookup = await import_axios16.default.get(`${apiUrl}/api/v1/roadmap?project_id=${projectId}`, { headers: { Authorization: `Bearer ${apiKey}` } });
4462
4661
  const task = lookup.data.data.roadmap.find((t) => `T-${t.step_number}` === taskId || t.step_number.toString() === taskId);
4463
4662
  if (!task) throw new Error(`Task ${taskId} not found.`);
4464
4663
  realId = task.id;
4465
4664
  }
4466
- await import_axios15.default.post(
4665
+ await import_axios16.default.post(
4467
4666
  `${apiUrl}/api/v1/roadmap/update-status`,
4468
4667
  { step_id: realId, status, project_id: projectId },
4469
4668
  { headers: { "Authorization": `Bearer ${apiKey}` } }
4470
4669
  );
4471
- spinner.succeed(import_chalk22.default.green(`Task updated to ${status}.`));
4670
+ spinner.succeed(import_chalk23.default.green(`Task updated to ${status}.`));
4472
4671
  if (status === "IN_PROGRESS") {
4473
- console.log(import_chalk22.default.blue(`
4672
+ console.log(import_chalk23.default.blue(`
4474
4673
  \u{1F4A1} Tip: Provide 'Frank' with context by mentioning @.cursorrules in your chat.`));
4475
4674
  }
4476
4675
  } catch (e) {
4477
- spinner.fail(import_chalk22.default.red(`Failed: ${e.message}`));
4676
+ spinner.fail(import_chalk23.default.red(`Failed: ${e.message}`));
4478
4677
  }
4479
4678
  }
4480
4679
  async function finishTask(taskId) {
4481
4680
  console.log("");
4482
- console.log(import_chalk22.default.bold.yellow("\u{1F6E1}\uFE0F FRANK'S QUALITY GATE"));
4483
- console.log(import_chalk22.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
4484
- const auditSpinner = (0, import_ora9.default)(" Analyzing architectural integrity...").start();
4681
+ console.log(import_chalk23.default.bold.yellow("\u{1F6E1}\uFE0F FRANK'S QUALITY GATE"));
4682
+ console.log(import_chalk23.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
4683
+ const auditSpinner = (0, import_ora10.default)(" Analyzing architectural integrity...").start();
4485
4684
  await new Promise((r) => setTimeout(r, 1500));
4486
4685
  auditSpinner.succeed("Architecture: VALIDATED (SEC-ARCH-01 Pass)");
4487
4686
  await setTaskStatus(taskId, "COMPLETED");
4488
4687
  console.log("");
4489
- console.log(import_chalk22.default.bold.green("\u{1F389} TASK COMPLETE! Momentum Preserved."));
4490
- const { projectId, apiKey, apiUrl } = getContext();
4688
+ console.log(import_chalk23.default.bold.green("\u{1F389} TASK COMPLETE! Momentum Preserved."));
4689
+ const { projectId, apiKey, apiUrl } = getContext2();
4491
4690
  await suggestNextMove(projectId, apiKey, apiUrl);
4492
4691
  }
4493
- function getContext() {
4692
+ function getContext2() {
4494
4693
  const apiKey = getApiKey();
4495
4694
  const apiUrl = getApiUrl();
4496
4695
  const projectId = getProjectId();
@@ -4502,41 +4701,41 @@ function getContext() {
4502
4701
 
4503
4702
  // src/commands/watch.ts
4504
4703
  init_cjs_shims();
4505
- var import_commander13 = require("commander");
4506
- var import_chalk23 = __toESM(require("chalk"), 1);
4507
- var import_ora10 = __toESM(require("ora"), 1);
4704
+ var import_commander14 = require("commander");
4705
+ var import_chalk24 = __toESM(require("chalk"), 1);
4706
+ var import_ora11 = __toESM(require("ora"), 1);
4508
4707
  var import_chokidar = __toESM(require("chokidar"), 1);
4509
- var import_promises19 = __toESM(require("fs/promises"), 1);
4510
- var import_path22 = __toESM(require("path"), 1);
4708
+ var import_promises20 = __toESM(require("fs/promises"), 1);
4709
+ var import_path23 = __toESM(require("path"), 1);
4511
4710
  var import_child_process4 = require("child_process");
4512
4711
  init_config();
4513
- var import_axios16 = __toESM(require("axios"), 1);
4712
+ var import_axios17 = __toESM(require("axios"), 1);
4514
4713
  function createWatchCommand() {
4515
- const watch2 = new import_commander13.Command("watch");
4714
+ const watch2 = new import_commander14.Command("watch");
4516
4715
  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) => {
4517
- console.log(import_chalk23.default.bold.blue("\u{1F52D} Rigstate Watch Mode"));
4518
- console.log(import_chalk23.default.dim("Monitoring for task completion..."));
4716
+ console.log(import_chalk24.default.bold.blue("\u{1F52D} Rigstate Watch Mode"));
4717
+ console.log(import_chalk24.default.dim("Monitoring for task completion..."));
4519
4718
  console.log("");
4520
4719
  let apiKey;
4521
4720
  let projectId;
4522
4721
  try {
4523
4722
  apiKey = getApiKey();
4524
4723
  } catch (e) {
4525
- console.log(import_chalk23.default.red('Not authenticated. Run "rigstate login" first.'));
4724
+ console.log(import_chalk24.default.red('Not authenticated. Run "rigstate login" first.'));
4526
4725
  return;
4527
4726
  }
4528
4727
  projectId = getProjectId();
4529
4728
  if (!projectId) {
4530
4729
  try {
4531
- const manifestPath = import_path22.default.join(process.cwd(), ".rigstate");
4532
- const content = await import_promises19.default.readFile(manifestPath, "utf-8");
4730
+ const manifestPath = import_path23.default.join(process.cwd(), ".rigstate");
4731
+ const content = await import_promises20.default.readFile(manifestPath, "utf-8");
4533
4732
  const manifest = JSON.parse(content);
4534
4733
  projectId = manifest.project_id;
4535
4734
  } catch (e) {
4536
4735
  }
4537
4736
  }
4538
4737
  if (!projectId) {
4539
- console.log(import_chalk23.default.red('No project context. Run "rigstate link" or "rigstate sync --project <id>" first.'));
4738
+ console.log(import_chalk24.default.red('No project context. Run "rigstate link" or "rigstate sync --project <id>" first.'));
4540
4739
  return;
4541
4740
  }
4542
4741
  const apiUrl = getApiUrl();
@@ -4546,12 +4745,12 @@ function createWatchCommand() {
4546
4745
  runTests: options.runTests || false,
4547
4746
  testCommand: options.testCommand || "npm test"
4548
4747
  };
4549
- console.log(import_chalk23.default.dim(`Auto-commit: ${config2.autoCommit ? "ON" : "OFF"}`));
4550
- console.log(import_chalk23.default.dim(`Auto-push: ${config2.autoPush ? "ON" : "OFF"}`));
4748
+ console.log(import_chalk24.default.dim(`Auto-commit: ${config2.autoCommit ? "ON" : "OFF"}`));
4749
+ console.log(import_chalk24.default.dim(`Auto-push: ${config2.autoPush ? "ON" : "OFF"}`));
4551
4750
  console.log("");
4552
4751
  const fetchActiveTask = async () => {
4553
4752
  try {
4554
- const response = await import_axios16.default.get(`${apiUrl}/api/v1/roadmap`, {
4753
+ const response = await import_axios17.default.get(`${apiUrl}/api/v1/roadmap`, {
4555
4754
  params: { project_id: projectId },
4556
4755
  headers: { Authorization: `Bearer ${apiKey}` }
4557
4756
  });
@@ -4575,17 +4774,17 @@ function createWatchCommand() {
4575
4774
  };
4576
4775
  const checkCriteria = async (criteria) => {
4577
4776
  try {
4578
- const fullPath = import_path22.default.resolve(process.cwd(), criteria.path);
4777
+ const fullPath = import_path23.default.resolve(process.cwd(), criteria.path);
4579
4778
  switch (criteria.type) {
4580
4779
  case "file_exists":
4581
- await import_promises19.default.access(fullPath);
4780
+ await import_promises20.default.access(fullPath);
4582
4781
  return true;
4583
4782
  case "file_content":
4584
- const content = await import_promises19.default.readFile(fullPath, "utf-8");
4783
+ const content = await import_promises20.default.readFile(fullPath, "utf-8");
4585
4784
  return content.length > 0;
4586
4785
  case "content_match":
4587
4786
  if (!criteria.match) return false;
4588
- const fileContent = await import_promises19.default.readFile(fullPath, "utf-8");
4787
+ const fileContent = await import_promises20.default.readFile(fullPath, "utf-8");
4589
4788
  return fileContent.includes(criteria.match);
4590
4789
  default:
4591
4790
  return false;
@@ -4595,7 +4794,7 @@ function createWatchCommand() {
4595
4794
  }
4596
4795
  };
4597
4796
  const completeTask = async (taskId, task) => {
4598
- const spinner = (0, import_ora10.default)("Completing task...").start();
4797
+ const spinner = (0, import_ora11.default)("Completing task...").start();
4599
4798
  try {
4600
4799
  if (config2.runTests) {
4601
4800
  spinner.text = "Running tests...";
@@ -4607,14 +4806,14 @@ function createWatchCommand() {
4607
4806
  return;
4608
4807
  }
4609
4808
  }
4610
- await import_axios16.default.post(`${apiUrl}/api/v1/roadmap/update-status`, {
4809
+ await import_axios17.default.post(`${apiUrl}/api/v1/roadmap/update-status`, {
4611
4810
  project_id: projectId,
4612
4811
  chunk_id: taskId,
4613
4812
  status: "COMPLETED"
4614
4813
  }, {
4615
4814
  headers: { Authorization: `Bearer ${apiKey}` }
4616
4815
  });
4617
- spinner.succeed(import_chalk23.default.green(`\u2705 Task #${task.step_number} completed: ${task.title}`));
4816
+ spinner.succeed(import_chalk24.default.green(`\u2705 Task #${task.step_number} completed: ${task.title}`));
4618
4817
  if (config2.autoCommit) {
4619
4818
  spinner.start("Committing changes...");
4620
4819
  try {
@@ -4636,7 +4835,7 @@ function createWatchCommand() {
4636
4835
  }
4637
4836
  }
4638
4837
  console.log("");
4639
- console.log(import_chalk23.default.blue("Watching for next task..."));
4838
+ console.log(import_chalk24.default.blue("Watching for next task..."));
4640
4839
  } catch (e) {
4641
4840
  spinner.fail(`Failed to complete task: ${e.message}`);
4642
4841
  }
@@ -4649,7 +4848,7 @@ function createWatchCommand() {
4649
4848
  const task = await fetchActiveTask();
4650
4849
  if (!task) {
4651
4850
  if (currentTask) {
4652
- console.log(import_chalk23.default.green("\u{1F389} All tasks completed! Watching for new tasks..."));
4851
+ console.log(import_chalk24.default.green("\u{1F389} All tasks completed! Watching for new tasks..."));
4653
4852
  currentTask = null;
4654
4853
  }
4655
4854
  isProcessing = false;
@@ -4658,10 +4857,10 @@ function createWatchCommand() {
4658
4857
  if (!currentTask || currentTask.id !== task.id) {
4659
4858
  currentTask = task;
4660
4859
  console.log("");
4661
- console.log(import_chalk23.default.bold.yellow(`\u{1F4CC} Active Task #${task.step_number}: ${task.title}`));
4662
- console.log(import_chalk23.default.dim(`Status: ${task.status}`));
4860
+ console.log(import_chalk24.default.bold.yellow(`\u{1F4CC} Active Task #${task.step_number}: ${task.title}`));
4861
+ console.log(import_chalk24.default.dim(`Status: ${task.status}`));
4663
4862
  if (task.verification_criteria) {
4664
- console.log(import_chalk23.default.dim("Verification: Auto-checking criteria..."));
4863
+ console.log(import_chalk24.default.dim("Verification: Auto-checking criteria..."));
4665
4864
  }
4666
4865
  }
4667
4866
  if (task.verification_criteria && Array.isArray(task.verification_criteria)) {
@@ -4674,7 +4873,7 @@ function createWatchCommand() {
4674
4873
  }
4675
4874
  }
4676
4875
  if (allPassed) {
4677
- console.log(import_chalk23.default.green("\u2713 All verification criteria passed!"));
4876
+ console.log(import_chalk24.default.green("\u2713 All verification criteria passed!"));
4678
4877
  await completeTask(task.id, task);
4679
4878
  currentTask = null;
4680
4879
  }
@@ -4699,11 +4898,11 @@ function createWatchCommand() {
4699
4898
  setTimeout(() => processActiveTask(), 500);
4700
4899
  }
4701
4900
  });
4702
- console.log(import_chalk23.default.dim("Watching for file changes... (Ctrl+C to exit)"));
4901
+ console.log(import_chalk24.default.dim("Watching for file changes... (Ctrl+C to exit)"));
4703
4902
  setInterval(() => processActiveTask(), 3e4);
4704
4903
  process.on("SIGINT", () => {
4705
4904
  console.log("");
4706
- console.log(import_chalk23.default.dim("Watch mode stopped."));
4905
+ console.log(import_chalk24.default.dim("Watch mode stopped."));
4707
4906
  watcher.close();
4708
4907
  process.exit(0);
4709
4908
  });
@@ -4713,43 +4912,43 @@ function createWatchCommand() {
4713
4912
 
4714
4913
  // src/commands/focus.ts
4715
4914
  init_cjs_shims();
4716
- var import_commander14 = require("commander");
4717
- var import_chalk24 = __toESM(require("chalk"), 1);
4718
- var import_ora11 = __toESM(require("ora"), 1);
4915
+ var import_commander15 = require("commander");
4916
+ var import_chalk25 = __toESM(require("chalk"), 1);
4917
+ var import_ora12 = __toESM(require("ora"), 1);
4719
4918
  init_config();
4720
- var import_axios17 = __toESM(require("axios"), 1);
4919
+ var import_axios18 = __toESM(require("axios"), 1);
4721
4920
  var import_child_process5 = require("child_process");
4722
- var import_promises20 = __toESM(require("fs/promises"), 1);
4723
- var import_path23 = __toESM(require("path"), 1);
4921
+ var import_promises21 = __toESM(require("fs/promises"), 1);
4922
+ var import_path24 = __toESM(require("path"), 1);
4724
4923
  function createFocusCommand() {
4725
- const focus = new import_commander14.Command("focus");
4924
+ const focus = new import_commander15.Command("focus");
4726
4925
  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) => {
4727
- const spinner = (0, import_ora11.default)("Fetching next objective...").start();
4926
+ const spinner = (0, import_ora12.default)("Fetching next objective...").start();
4728
4927
  let apiKey;
4729
4928
  let projectId;
4730
4929
  try {
4731
4930
  apiKey = getApiKey();
4732
4931
  } catch (e) {
4733
- spinner.fail(import_chalk24.default.red('Not authenticated. Run "rigstate login" first.'));
4932
+ spinner.fail(import_chalk25.default.red('Not authenticated. Run "rigstate login" first.'));
4734
4933
  return;
4735
4934
  }
4736
4935
  projectId = getProjectId();
4737
4936
  if (!projectId) {
4738
4937
  try {
4739
- const manifestPath = import_path23.default.join(process.cwd(), ".rigstate");
4740
- const content = await import_promises20.default.readFile(manifestPath, "utf-8");
4938
+ const manifestPath = import_path24.default.join(process.cwd(), ".rigstate");
4939
+ const content = await import_promises21.default.readFile(manifestPath, "utf-8");
4741
4940
  const manifest = JSON.parse(content);
4742
4941
  projectId = manifest.project_id;
4743
4942
  } catch (e) {
4744
4943
  }
4745
4944
  }
4746
4945
  if (!projectId) {
4747
- spinner.fail(import_chalk24.default.red('No project context. Run "rigstate link" first.'));
4946
+ spinner.fail(import_chalk25.default.red('No project context. Run "rigstate link" first.'));
4748
4947
  return;
4749
4948
  }
4750
4949
  const apiUrl = getApiUrl();
4751
4950
  try {
4752
- const response = await import_axios17.default.get(`${apiUrl}/api/v1/roadmap`, {
4951
+ const response = await import_axios18.default.get(`${apiUrl}/api/v1/roadmap`, {
4753
4952
  params: { project_id: projectId },
4754
4953
  headers: { Authorization: `Bearer ${apiKey}` }
4755
4954
  });
@@ -4775,41 +4974,41 @@ function createFocusCommand() {
4775
4974
  const nextTask = activeTasks[0];
4776
4975
  spinner.stop();
4777
4976
  console.log("");
4778
- console.log(import_chalk24.default.bold.blue(`\u{1F4CC} Task #${nextTask.step_number || "?"}: ${nextTask.title}`));
4779
- const statusColor = nextTask.status === "IN_PROGRESS" ? import_chalk24.default.yellow : nextTask.status === "ACTIVE" ? import_chalk24.default.green : import_chalk24.default.dim;
4780
- console.log(import_chalk24.default.dim("Status: ") + statusColor(nextTask.status));
4781
- console.log(import_chalk24.default.dim("\u2500".repeat(60)));
4977
+ console.log(import_chalk25.default.bold.blue(`\u{1F4CC} Task #${nextTask.step_number || "?"}: ${nextTask.title}`));
4978
+ const statusColor = nextTask.status === "IN_PROGRESS" ? import_chalk25.default.yellow : nextTask.status === "ACTIVE" ? import_chalk25.default.green : import_chalk25.default.dim;
4979
+ console.log(import_chalk25.default.dim("Status: ") + statusColor(nextTask.status));
4980
+ console.log(import_chalk25.default.dim("\u2500".repeat(60)));
4782
4981
  if (nextTask.prompt_content) {
4783
- console.log(import_chalk24.default.white(nextTask.prompt_content));
4784
- console.log(import_chalk24.default.dim("\u2500".repeat(60)));
4982
+ console.log(import_chalk25.default.white(nextTask.prompt_content));
4983
+ console.log(import_chalk25.default.dim("\u2500".repeat(60)));
4785
4984
  if (options.copy !== false) {
4786
4985
  try {
4787
4986
  if (process.platform === "darwin") {
4788
4987
  (0, import_child_process5.execSync)("pbcopy", { input: nextTask.prompt_content });
4789
- console.log(import_chalk24.default.green("\u2705 Prompt copied to clipboard! Ready to paste (Cmd+V)."));
4988
+ console.log(import_chalk25.default.green("\u2705 Prompt copied to clipboard! Ready to paste (Cmd+V)."));
4790
4989
  } else if (process.platform === "linux") {
4791
4990
  try {
4792
4991
  (0, import_child_process5.execSync)("xclip -selection clipboard", { input: nextTask.prompt_content });
4793
- console.log(import_chalk24.default.green("\u2705 Prompt copied to clipboard!"));
4992
+ console.log(import_chalk25.default.green("\u2705 Prompt copied to clipboard!"));
4794
4993
  } catch (e) {
4795
- console.log(import_chalk24.default.yellow("\u2139\uFE0F Copy prompt manually (xclip not available)"));
4994
+ console.log(import_chalk25.default.yellow("\u2139\uFE0F Copy prompt manually (xclip not available)"));
4796
4995
  }
4797
4996
  } else {
4798
- console.log(import_chalk24.default.yellow("\u2139\uFE0F Copy prompt manually (Auto-copy not supported on this OS)"));
4997
+ console.log(import_chalk25.default.yellow("\u2139\uFE0F Copy prompt manually (Auto-copy not supported on this OS)"));
4799
4998
  }
4800
4999
  } catch (e) {
4801
5000
  }
4802
5001
  }
4803
5002
  } else {
4804
- console.log(import_chalk24.default.yellow("No prompt instructions available."));
5003
+ console.log(import_chalk25.default.yellow("No prompt instructions available."));
4805
5004
  if (nextTask.architectural_brief) {
4806
- console.log(import_chalk24.default.bold("Brief:"));
5005
+ console.log(import_chalk25.default.bold("Brief:"));
4807
5006
  console.log(nextTask.architectural_brief);
4808
5007
  }
4809
5008
  }
4810
5009
  console.log("");
4811
5010
  } catch (e) {
4812
- spinner.fail(import_chalk24.default.red(`Failed to fetch task: ${e.message}`));
5011
+ spinner.fail(import_chalk25.default.red(`Failed to fetch task: ${e.message}`));
4813
5012
  }
4814
5013
  });
4815
5014
  return focus;
@@ -4820,27 +5019,27 @@ init_env();
4820
5019
 
4821
5020
  // src/commands/config.ts
4822
5021
  init_cjs_shims();
4823
- var import_commander15 = require("commander");
4824
- var import_chalk25 = __toESM(require("chalk"), 1);
5022
+ var import_commander16 = require("commander");
5023
+ var import_chalk26 = __toESM(require("chalk"), 1);
4825
5024
  init_config();
4826
5025
  function createConfigCommand() {
4827
- const config2 = new import_commander15.Command("config");
5026
+ const config2 = new import_commander16.Command("config");
4828
5027
  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) => {
4829
5028
  if (!key) {
4830
- console.log(import_chalk25.default.bold("Rigstate Configuration"));
4831
- console.log(import_chalk25.default.dim("\u2500".repeat(40)));
5029
+ console.log(import_chalk26.default.bold("Rigstate Configuration"));
5030
+ console.log(import_chalk26.default.dim("\u2500".repeat(40)));
4832
5031
  try {
4833
5032
  const apiKey = getApiKey();
4834
- console.log(`${import_chalk25.default.cyan("api_key")}: ${apiKey.substring(0, 20)}...`);
5033
+ console.log(`${import_chalk26.default.cyan("api_key")}: ${apiKey.substring(0, 20)}...`);
4835
5034
  } catch (e) {
4836
- console.log(`${import_chalk25.default.cyan("api_key")}: ${import_chalk25.default.dim("(not set)")}`);
5035
+ console.log(`${import_chalk26.default.cyan("api_key")}: ${import_chalk26.default.dim("(not set)")}`);
4837
5036
  }
4838
5037
  const projectId = getProjectId();
4839
- console.log(`${import_chalk25.default.cyan("project_id")}: ${projectId || import_chalk25.default.dim("(not set)")}`);
5038
+ console.log(`${import_chalk26.default.cyan("project_id")}: ${projectId || import_chalk26.default.dim("(not set)")}`);
4840
5039
  const apiUrl = getApiUrl();
4841
- console.log(`${import_chalk25.default.cyan("api_url")}: ${apiUrl}`);
5040
+ console.log(`${import_chalk26.default.cyan("api_url")}: ${apiUrl}`);
4842
5041
  console.log("");
4843
- console.log(import_chalk25.default.dim('Use "rigstate config <key> <value>" to set a value.'));
5042
+ console.log(import_chalk26.default.dim('Use "rigstate config <key> <value>" to set a value.'));
4844
5043
  return;
4845
5044
  }
4846
5045
  if (!value) {
@@ -4850,37 +5049,37 @@ function createConfigCommand() {
4850
5049
  const apiKey = getApiKey();
4851
5050
  console.log(apiKey);
4852
5051
  } catch (e) {
4853
- console.log(import_chalk25.default.dim("(not set)"));
5052
+ console.log(import_chalk26.default.dim("(not set)"));
4854
5053
  }
4855
5054
  break;
4856
5055
  case "project_id":
4857
- console.log(getProjectId() || import_chalk25.default.dim("(not set)"));
5056
+ console.log(getProjectId() || import_chalk26.default.dim("(not set)"));
4858
5057
  break;
4859
5058
  case "api_url":
4860
5059
  console.log(getApiUrl());
4861
5060
  break;
4862
5061
  default:
4863
- console.log(import_chalk25.default.red(`Unknown config key: ${key}`));
4864
- console.log(import_chalk25.default.dim("Valid keys: api_key, project_id, api_url"));
5062
+ console.log(import_chalk26.default.red(`Unknown config key: ${key}`));
5063
+ console.log(import_chalk26.default.dim("Valid keys: api_key, project_id, api_url"));
4865
5064
  }
4866
5065
  return;
4867
5066
  }
4868
5067
  switch (key) {
4869
5068
  case "api_key":
4870
5069
  setApiKey(value);
4871
- console.log(import_chalk25.default.green(`\u2705 api_key updated`));
5070
+ console.log(import_chalk26.default.green(`\u2705 api_key updated`));
4872
5071
  break;
4873
5072
  case "project_id":
4874
5073
  setProjectId(value);
4875
- console.log(import_chalk25.default.green(`\u2705 project_id updated`));
5074
+ console.log(import_chalk26.default.green(`\u2705 project_id updated`));
4876
5075
  break;
4877
5076
  case "api_url":
4878
5077
  setApiUrl(value);
4879
- console.log(import_chalk25.default.green(`\u2705 api_url updated`));
5078
+ console.log(import_chalk26.default.green(`\u2705 api_url updated`));
4880
5079
  break;
4881
5080
  default:
4882
- console.log(import_chalk25.default.red(`Unknown config key: ${key}`));
4883
- console.log(import_chalk25.default.dim("Valid keys: api_key, project_id, api_url"));
5081
+ console.log(import_chalk26.default.red(`Unknown config key: ${key}`));
5082
+ console.log(import_chalk26.default.dim("Valid keys: api_key, project_id, api_url"));
4884
5083
  }
4885
5084
  });
4886
5085
  return config2;
@@ -4888,25 +5087,25 @@ function createConfigCommand() {
4888
5087
 
4889
5088
  // src/commands/mcp.ts
4890
5089
  init_cjs_shims();
4891
- var import_commander16 = require("commander");
4892
- var import_chalk26 = __toESM(require("chalk"), 1);
5090
+ var import_commander17 = require("commander");
5091
+ var import_chalk27 = __toESM(require("chalk"), 1);
4893
5092
  var import_child_process6 = require("child_process");
4894
- var import_path24 = __toESM(require("path"), 1);
5093
+ var import_path25 = __toESM(require("path"), 1);
4895
5094
  var import_fs = __toESM(require("fs"), 1);
4896
5095
  var import_url2 = require("url");
4897
5096
  init_config();
4898
5097
  var __filename2 = (0, import_url2.fileURLToPath)(importMetaUrl);
4899
- var __dirname = import_path24.default.dirname(__filename2);
5098
+ var __dirname = import_path25.default.dirname(__filename2);
4900
5099
  function createMcpCommand() {
4901
- const mcp = new import_commander16.Command("mcp");
5100
+ const mcp = new import_commander17.Command("mcp");
4902
5101
  mcp.description("Run the Rigstate MCP server for AI editors").action(async () => {
4903
5102
  const possiblePaths = [
4904
5103
  // From packages/cli -> packages/mcp (sibling package)
4905
- import_path24.default.resolve(__dirname, "../../mcp/dist/index.js"),
5104
+ import_path25.default.resolve(__dirname, "../../mcp/dist/index.js"),
4906
5105
  // If installed globally or via npm
4907
- import_path24.default.resolve(__dirname, "../../../mcp/dist/index.js"),
5106
+ import_path25.default.resolve(__dirname, "../../../mcp/dist/index.js"),
4908
5107
  // Development path from packages/cli/dist
4909
- import_path24.default.resolve(__dirname, "../../../packages/mcp/dist/index.js")
5108
+ import_path25.default.resolve(__dirname, "../../../packages/mcp/dist/index.js")
4910
5109
  ];
4911
5110
  let serverPath = "";
4912
5111
  for (const p of possiblePaths) {
@@ -4916,15 +5115,15 @@ function createMcpCommand() {
4916
5115
  }
4917
5116
  }
4918
5117
  if (!serverPath) {
4919
- console.error(import_chalk26.default.red("\u274C Error: Rigstate MCP Server binary not found."));
4920
- console.error(import_chalk26.default.yellow("Please ensure that the mcp package is built:"));
4921
- console.error(import_chalk26.default.white(" cd packages/mcp && npm run build"));
5118
+ console.error(import_chalk27.default.red("\u274C Error: Rigstate MCP Server binary not found."));
5119
+ console.error(import_chalk27.default.yellow("Please ensure that the mcp package is built:"));
5120
+ console.error(import_chalk27.default.white(" cd packages/mcp && npm run build"));
4922
5121
  console.error("");
4923
- console.error(import_chalk26.default.dim("Or run directly with:"));
4924
- console.error(import_chalk26.default.white(" npx @rigstate/mcp"));
5122
+ console.error(import_chalk27.default.dim("Or run directly with:"));
5123
+ console.error(import_chalk27.default.white(" npx @rigstate/mcp"));
4925
5124
  process.exit(1);
4926
5125
  }
4927
- console.log(import_chalk26.default.dim(`Starting MCP server from: ${serverPath}`));
5126
+ console.log(import_chalk27.default.dim(`Starting MCP server from: ${serverPath}`));
4928
5127
  const env = { ...process.env };
4929
5128
  try {
4930
5129
  const apiKey = getApiKey();
@@ -4943,7 +5142,7 @@ function createMcpCommand() {
4943
5142
  stdio: ["inherit", "inherit", "inherit"]
4944
5143
  });
4945
5144
  worker.on("error", (err) => {
4946
- console.error(import_chalk26.default.red(`\u274C Failed to start MCP server: ${err.message}`));
5145
+ console.error(import_chalk27.default.red(`\u274C Failed to start MCP server: ${err.message}`));
4947
5146
  process.exit(1);
4948
5147
  });
4949
5148
  worker.on("exit", (code) => {
@@ -4957,8 +5156,8 @@ function createMcpCommand() {
4957
5156
 
4958
5157
  // src/commands/nexus.ts
4959
5158
  init_cjs_shims();
4960
- var import_commander17 = require("commander");
4961
- var import_chalk28 = __toESM(require("chalk"), 1);
5159
+ var import_commander18 = require("commander");
5160
+ var import_chalk29 = __toESM(require("chalk"), 1);
4962
5161
 
4963
5162
  // src/nexus/dispatcher.ts
4964
5163
  init_cjs_shims();
@@ -4967,7 +5166,7 @@ var import_uuid = require("uuid");
4967
5166
 
4968
5167
  // src/hive/gateway.ts
4969
5168
  init_cjs_shims();
4970
- var import_axios18 = __toESM(require("axios"), 1);
5169
+ var import_axios19 = __toESM(require("axios"), 1);
4971
5170
 
4972
5171
  // src/hive/scrubber.ts
4973
5172
  init_cjs_shims();
@@ -5026,7 +5225,7 @@ var HiveScrubber = class {
5026
5225
  };
5027
5226
 
5028
5227
  // src/hive/gateway.ts
5029
- var import_chalk27 = __toESM(require("chalk"), 1);
5228
+ var import_chalk28 = __toESM(require("chalk"), 1);
5030
5229
  var HiveGateway = class {
5031
5230
  client;
5032
5231
  enabled;
@@ -5036,9 +5235,9 @@ var HiveGateway = class {
5036
5235
  constructor(baseUrl, token) {
5037
5236
  this.enabled = !!token;
5038
5237
  if (!this.enabled) {
5039
- console.log(import_chalk27.default.dim("\u26A0\uFE0F Hive Gateway disabled (No Token provided). Running in localized mode."));
5238
+ console.log(import_chalk28.default.dim("\u26A0\uFE0F Hive Gateway disabled (No Token provided). Running in localized mode."));
5040
5239
  }
5041
- this.client = import_axios18.default.create({
5240
+ this.client = import_axios19.default.create({
5042
5241
  baseURL: baseUrl,
5043
5242
  headers: {
5044
5243
  "Authorization": `Bearer ${token}`,
@@ -5056,23 +5255,23 @@ var HiveGateway = class {
5056
5255
  if (!this.enabled) return false;
5057
5256
  const now = Date.now();
5058
5257
  if (now - this.lastSignalTime < this.MIN_INTERVAL_MS) {
5059
- console.warn(import_chalk27.default.yellow("\u23F3 Hive Gateway Throttled. Signal dropped to preventing spam."));
5258
+ console.warn(import_chalk28.default.yellow("\u23F3 Hive Gateway Throttled. Signal dropped to preventing spam."));
5060
5259
  return false;
5061
5260
  }
5062
5261
  const scrubResult = HiveScrubber.scrub(signal.ruleContent);
5063
5262
  if (scrubResult.riskScore > 20) {
5064
- console.error(import_chalk27.default.red(`\u{1F6D1} HIVE BLOCKED: Signal contains sensitive data (Risk: ${scrubResult.riskScore})`));
5263
+ console.error(import_chalk28.default.red(`\u{1F6D1} HIVE BLOCKED: Signal contains sensitive data (Risk: ${scrubResult.riskScore})`));
5065
5264
  return false;
5066
5265
  }
5067
5266
  try {
5068
- console.log(import_chalk27.default.blue(`\u{1F4E1} Uplinking to Hive... [${signal.vector}]`));
5267
+ console.log(import_chalk28.default.blue(`\u{1F4E1} Uplinking to Hive... [${signal.vector}]`));
5069
5268
  const payload = { ...signal, ruleContent: scrubResult.sanitizedContent };
5070
5269
  await this.client.post("/signal", payload);
5071
5270
  this.lastSignalTime = now;
5072
- console.log(import_chalk27.default.green("\u2705 Signal Received by Hive Core. Knowledge Shared."));
5271
+ console.log(import_chalk28.default.green("\u2705 Signal Received by Hive Core. Knowledge Shared."));
5073
5272
  return true;
5074
5273
  } catch (error) {
5075
- console.error(import_chalk27.default.red(`\u274C Hive Transmission Failed: ${error.message}`));
5274
+ console.error(import_chalk28.default.red(`\u274C Hive Transmission Failed: ${error.message}`));
5076
5275
  return false;
5077
5276
  }
5078
5277
  }
@@ -5170,15 +5369,15 @@ var NexusDispatcher = class extends import_events4.default {
5170
5369
  };
5171
5370
 
5172
5371
  // src/commands/nexus.ts
5173
- var import_inquirer3 = __toESM(require("inquirer"), 1);
5372
+ var import_inquirer4 = __toESM(require("inquirer"), 1);
5174
5373
  function createNexusCommand() {
5175
- const command = new import_commander17.Command("nexus");
5374
+ const command = new import_commander18.Command("nexus");
5176
5375
  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) => {
5177
- console.log(import_chalk28.default.bold.magenta("\n\u{1F981} Welcome to The Nexus (Phase 8)\n"));
5376
+ console.log(import_chalk29.default.bold.magenta("\n\u{1F981} Welcome to The Nexus (Phase 8)\n"));
5178
5377
  const dryRun = !options.force;
5179
5378
  if (!dryRun) {
5180
- console.log(import_chalk28.default.black.bgYellow(" WARNING ") + import_chalk28.default.yellow(" Dry-Run disabled! Eitri is authorized to write code."));
5181
- const { confirm } = await import_inquirer3.default.prompt([{
5379
+ console.log(import_chalk29.default.black.bgYellow(" WARNING ") + import_chalk29.default.yellow(" Dry-Run disabled! Eitri is authorized to write code."));
5380
+ const { confirm } = await import_inquirer4.default.prompt([{
5182
5381
  type: "confirm",
5183
5382
  name: "confirm",
5184
5383
  message: "Are you absolutely sure you want to bypass the Kill-Switch?",
@@ -5198,26 +5397,26 @@ function createNexusCommand() {
5198
5397
  };
5199
5398
  const dispatcher = new NexusDispatcher(context);
5200
5399
  dispatcher.on("order:created", (o) => {
5201
- console.log(import_chalk28.default.blue(`\u{1F195} [${o.id.slice(0, 6)}] Order Created: `) + o.intent);
5400
+ console.log(import_chalk29.default.blue(`\u{1F195} [${o.id.slice(0, 6)}] Order Created: `) + o.intent);
5202
5401
  });
5203
5402
  dispatcher.on("order:started", (o) => {
5204
- console.log(import_chalk28.default.yellow(`\u23F3 [${o.id.slice(0, 6)}] Processing...`));
5403
+ console.log(import_chalk29.default.yellow(`\u23F3 [${o.id.slice(0, 6)}] Processing...`));
5205
5404
  });
5206
5405
  dispatcher.on("order:blocked", (o) => {
5207
- console.log(import_chalk28.default.red(`\u{1F6D1} [${o.id.slice(0, 6)}] BLOCKED by Kill-Switch`));
5208
- console.log(import_chalk28.default.dim(` Target: ${o.targetAgent} | Action: ${o.action}`));
5209
- console.log(import_chalk28.default.dim(" Run with --force to execute automatically (NOT RECOMMENDED)."));
5406
+ console.log(import_chalk29.default.red(`\u{1F6D1} [${o.id.slice(0, 6)}] BLOCKED by Kill-Switch`));
5407
+ console.log(import_chalk29.default.dim(` Target: ${o.targetAgent} | Action: ${o.action}`));
5408
+ console.log(import_chalk29.default.dim(" Run with --force to execute automatically (NOT RECOMMENDED)."));
5210
5409
  });
5211
- dispatcher.on("agent:SINDRE", (o) => console.log(import_chalk28.default.cyan(`\u{1F916} Sindre (Vault): I'm on it! (${o.action})`)));
5212
- dispatcher.on("agent:EITRI", (o) => console.log(import_chalk28.default.green(`\u{1F477} Eitri (Smith): Ready to build! (${o.action})`)));
5213
- console.log(import_chalk28.default.dim("\u{1F9E0} Frank is analyzing your intent..."));
5410
+ dispatcher.on("agent:SINDRE", (o) => console.log(import_chalk29.default.cyan(`\u{1F916} Sindre (Vault): I'm on it! (${o.action})`)));
5411
+ dispatcher.on("agent:EITRI", (o) => console.log(import_chalk29.default.green(`\u{1F477} Eitri (Smith): Ready to build! (${o.action})`)));
5412
+ console.log(import_chalk29.default.dim("\u{1F9E0} Frank is analyzing your intent..."));
5214
5413
  await new Promise((r) => setTimeout(r, 800));
5215
5414
  if (intent.toLowerCase().includes("db") || intent.toLowerCase().includes("database")) {
5216
5415
  await dispatcher.dispatch("FRANK", "SINDRE", intent, "db.analyze", { raw: intent });
5217
5416
  } else if (intent.toLowerCase().includes("create") || intent.toLowerCase().includes("code")) {
5218
5417
  await dispatcher.dispatch("FRANK", "EITRI", intent, "fs.write", { path: "src/demo.ts", content: "// demo" });
5219
5418
  } else {
5220
- console.log(import_chalk28.default.gray("Frank didn't understand. Try 'create file' or 'check database'."));
5419
+ console.log(import_chalk29.default.gray("Frank didn't understand. Try 'create file' or 'check database'."));
5221
5420
  }
5222
5421
  });
5223
5422
  return command;
@@ -5228,34 +5427,34 @@ init_sync_rules();
5228
5427
 
5229
5428
  // src/commands/override.ts
5230
5429
  init_cjs_shims();
5231
- var import_commander18 = require("commander");
5232
- var import_chalk29 = __toESM(require("chalk"), 1);
5430
+ var import_commander19 = require("commander");
5431
+ var import_chalk30 = __toESM(require("chalk"), 1);
5233
5432
  init_governance();
5234
5433
  init_config();
5235
- var import_axios19 = __toESM(require("axios"), 1);
5434
+ var import_axios20 = __toESM(require("axios"), 1);
5236
5435
  function createOverrideCommand() {
5237
- const override = new import_commander18.Command("override");
5436
+ const override = new import_commander19.Command("override");
5238
5437
  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) => {
5239
5438
  const { reason } = options;
5240
- console.log(import_chalk29.default.bold(`
5439
+ console.log(import_chalk30.default.bold(`
5241
5440
  \u{1F513} Initiating Governance Override Protocol...`));
5242
5441
  const session = await getSessionState(process.cwd());
5243
5442
  if (session.status !== "SOFT_LOCK") {
5244
- console.log(import_chalk29.default.yellow(" Info: Session is not currently locked."));
5443
+ console.log(import_chalk30.default.yellow(" Info: Session is not currently locked."));
5245
5444
  return;
5246
5445
  }
5247
- console.log(import_chalk29.default.dim(` Active Violation: ${session.active_violation}`));
5248
- console.log(import_chalk29.default.dim(` Reason Provided: "${reason}"`));
5446
+ console.log(import_chalk30.default.dim(` Active Violation: ${session.active_violation}`));
5447
+ console.log(import_chalk30.default.dim(` Reason Provided: "${reason}"`));
5249
5448
  const success = await performOverride(violationId, reason, process.cwd());
5250
5449
  if (success) {
5251
- console.log(import_chalk29.default.green(` \u2705 Session UNLOCKED.`));
5252
- console.log(import_chalk29.default.dim(` This event has been logged to the Mission Report.`));
5450
+ console.log(import_chalk30.default.green(` \u2705 Session UNLOCKED.`));
5451
+ console.log(import_chalk30.default.dim(` This event has been logged to the Mission Report.`));
5253
5452
  try {
5254
5453
  const projectId = getProjectId();
5255
5454
  if (projectId) {
5256
5455
  const apiUrl = getApiUrl();
5257
5456
  const apiKey = getApiKey();
5258
- await import_axios19.default.post(`${apiUrl}/api/v1/execution-logs`, {
5457
+ await import_axios20.default.post(`${apiUrl}/api/v1/execution-logs`, {
5259
5458
  project_id: projectId,
5260
5459
  task_id: "OVERRIDE-" + Date.now(),
5261
5460
  task_title: `Governance Override: ${violationId}`,
@@ -5266,13 +5465,13 @@ function createOverrideCommand() {
5266
5465
  }, {
5267
5466
  headers: { Authorization: `Bearer ${apiKey}` }
5268
5467
  });
5269
- console.log(import_chalk29.default.dim(` \u2601 Audit log synced to Cloud.`));
5468
+ console.log(import_chalk30.default.dim(` \u2601 Audit log synced to Cloud.`));
5270
5469
  }
5271
5470
  } catch (e) {
5272
- console.log(import_chalk29.default.dim(` (Cloud audit sync failed: ${e.message})`));
5471
+ console.log(import_chalk30.default.dim(` (Cloud audit sync failed: ${e.message})`));
5273
5472
  }
5274
5473
  } else {
5275
- console.log(import_chalk29.default.red(` \u{1F6D1} Override Failed. Check project configuration.`));
5474
+ console.log(import_chalk30.default.red(` \u{1F6D1} Override Failed. Check project configuration.`));
5276
5475
  }
5277
5476
  });
5278
5477
  return override;
@@ -5280,27 +5479,27 @@ function createOverrideCommand() {
5280
5479
 
5281
5480
  // src/commands/idea.ts
5282
5481
  init_cjs_shims();
5283
- var import_commander19 = require("commander");
5284
- var import_chalk30 = __toESM(require("chalk"), 1);
5285
- var import_ora12 = __toESM(require("ora"), 1);
5286
- var import_axios20 = __toESM(require("axios"), 1);
5287
- var import_inquirer4 = __toESM(require("inquirer"), 1);
5482
+ var import_commander20 = require("commander");
5483
+ var import_chalk31 = __toESM(require("chalk"), 1);
5484
+ var import_ora13 = __toESM(require("ora"), 1);
5485
+ var import_axios21 = __toESM(require("axios"), 1);
5486
+ var import_inquirer5 = __toESM(require("inquirer"), 1);
5288
5487
  init_config();
5289
5488
  function createIdeaCommand() {
5290
- return new import_commander19.Command("idea").description("Capture a new idea or feature request").argument("[title]", "Quick title of the idea").option("-d, --desc <text>", "Detailed description").option("-t, --tag <tags>", "Comma separated tags (e.g. ui,auth)").action(async (title, options) => {
5489
+ return new import_commander20.Command("idea").description("Capture a new idea or feature request").argument("[title]", "Quick title of the idea").option("-d, --desc <text>", "Detailed description").option("-t, --tag <tags>", "Comma separated tags (e.g. ui,auth)").action(async (title, options) => {
5291
5490
  try {
5292
5491
  const apiKey = getApiKey();
5293
5492
  const apiUrl = getApiUrl();
5294
5493
  const projectId = getProjectId();
5295
5494
  if (!projectId) {
5296
- console.error(import_chalk30.default.red("Project context missing. Run rigstate link."));
5495
+ console.error(import_chalk31.default.red("Project context missing. Run rigstate link."));
5297
5496
  process.exit(1);
5298
5497
  }
5299
5498
  let ideaTitle = title;
5300
5499
  let ideaDesc = options.desc;
5301
5500
  let tags = options.tag ? options.tag.split(",") : [];
5302
5501
  if (!ideaTitle) {
5303
- const ans = await import_inquirer4.default.prompt([{
5502
+ const ans = await import_inquirer5.default.prompt([{
5304
5503
  type: "input",
5305
5504
  name: "title",
5306
5505
  message: "Idea Title:"
@@ -5308,7 +5507,7 @@ function createIdeaCommand() {
5308
5507
  ideaTitle = ans.title;
5309
5508
  }
5310
5509
  if (!ideaDesc) {
5311
- const ans = await import_inquirer4.default.prompt([{
5510
+ const ans = await import_inquirer5.default.prompt([{
5312
5511
  type: "input",
5313
5512
  name: "desc",
5314
5513
  message: "Description (Optional):"
@@ -5317,8 +5516,8 @@ function createIdeaCommand() {
5317
5516
  }
5318
5517
  if (tags.length === 0) {
5319
5518
  }
5320
- const spinner = (0, import_ora12.default)("Securing idea in the Lab...").start();
5321
- const response = await import_axios20.default.post(
5519
+ const spinner = (0, import_ora13.default)("Securing idea in the Lab...").start();
5520
+ const response = await import_axios21.default.post(
5322
5521
  `${apiUrl}/api/v1/ideas`,
5323
5522
  {
5324
5523
  project_id: projectId,
@@ -5329,14 +5528,14 @@ function createIdeaCommand() {
5329
5528
  { headers: { Authorization: `Bearer ${apiKey}` } }
5330
5529
  );
5331
5530
  if (response.data.success) {
5332
- spinner.succeed(import_chalk30.default.green("Idea Captured! \u{1F4A1}"));
5333
- console.log(import_chalk30.default.dim(`ID: ${response.data.data?.id || "Saved"}`));
5531
+ spinner.succeed(import_chalk31.default.green("Idea Captured! \u{1F4A1}"));
5532
+ console.log(import_chalk31.default.dim(`ID: ${response.data.data?.id || "Saved"}`));
5334
5533
  } else {
5335
5534
  throw new Error(response.data.error);
5336
5535
  }
5337
5536
  } catch (e) {
5338
5537
  const errorDetail = e.response?.data?.error || e.message;
5339
- console.error(import_chalk30.default.red(`
5538
+ console.error(import_chalk31.default.red(`
5340
5539
  Failed to capture idea: ${errorDetail}`));
5341
5540
  }
5342
5541
  });
@@ -5344,12 +5543,12 @@ Failed to capture idea: ${errorDetail}`));
5344
5543
 
5345
5544
  // src/commands/release.ts
5346
5545
  init_cjs_shims();
5347
- var import_commander20 = require("commander");
5348
- var import_chalk31 = __toESM(require("chalk"), 1);
5349
- var import_ora13 = __toESM(require("ora"), 1);
5350
- var import_inquirer5 = __toESM(require("inquirer"), 1);
5351
- var import_promises21 = __toESM(require("fs/promises"), 1);
5352
- var import_path25 = __toESM(require("path"), 1);
5546
+ var import_commander21 = require("commander");
5547
+ var import_chalk32 = __toESM(require("chalk"), 1);
5548
+ var import_ora14 = __toESM(require("ora"), 1);
5549
+ var import_inquirer6 = __toESM(require("inquirer"), 1);
5550
+ var import_promises22 = __toESM(require("fs/promises"), 1);
5551
+ var import_path26 = __toESM(require("path"), 1);
5353
5552
  init_config();
5354
5553
 
5355
5554
  // ../../node_modules/simple-git/dist/esm/index.js
@@ -5390,8 +5589,8 @@ function pathspec(...paths) {
5390
5589
  cache.set(key, paths);
5391
5590
  return key;
5392
5591
  }
5393
- function isPathSpec(path26) {
5394
- return path26 instanceof String && cache.has(path26);
5592
+ function isPathSpec(path27) {
5593
+ return path27 instanceof String && cache.has(path27);
5395
5594
  }
5396
5595
  function toPaths(pathSpec) {
5397
5596
  return cache.get(pathSpec) || [];
@@ -5480,8 +5679,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
5480
5679
  function forEachLineWithContent(input, callback) {
5481
5680
  return toLinesWithContent(input, true).map((line) => callback(line));
5482
5681
  }
5483
- function folderExists(path26) {
5484
- return (0, import_file_exists.exists)(path26, import_file_exists.FOLDER);
5682
+ function folderExists(path27) {
5683
+ return (0, import_file_exists.exists)(path27, import_file_exists.FOLDER);
5485
5684
  }
5486
5685
  function append(target, item) {
5487
5686
  if (Array.isArray(target)) {
@@ -5885,8 +6084,8 @@ function checkIsRepoRootTask() {
5885
6084
  commands,
5886
6085
  format: "utf-8",
5887
6086
  onError,
5888
- parser(path26) {
5889
- return /^\.(git)?$/.test(path26.trim());
6087
+ parser(path27) {
6088
+ return /^\.(git)?$/.test(path27.trim());
5890
6089
  }
5891
6090
  };
5892
6091
  }
@@ -6320,11 +6519,11 @@ function parseGrep(grep) {
6320
6519
  const paths = /* @__PURE__ */ new Set();
6321
6520
  const results = {};
6322
6521
  forEachLineWithContent(grep, (input) => {
6323
- const [path26, line, preview] = input.split(NULL);
6324
- paths.add(path26);
6325
- (results[path26] = results[path26] || []).push({
6522
+ const [path27, line, preview] = input.split(NULL);
6523
+ paths.add(path27);
6524
+ (results[path27] = results[path27] || []).push({
6326
6525
  line: asNumber(line),
6327
- path: path26,
6526
+ path: path27,
6328
6527
  preview
6329
6528
  });
6330
6529
  });
@@ -7089,14 +7288,14 @@ var init_hash_object = __esm2({
7089
7288
  init_task();
7090
7289
  }
7091
7290
  });
7092
- function parseInit(bare, path26, text) {
7291
+ function parseInit(bare, path27, text) {
7093
7292
  const response = String(text).trim();
7094
7293
  let result;
7095
7294
  if (result = initResponseRegex.exec(response)) {
7096
- return new InitSummary(bare, path26, false, result[1]);
7295
+ return new InitSummary(bare, path27, false, result[1]);
7097
7296
  }
7098
7297
  if (result = reInitResponseRegex.exec(response)) {
7099
- return new InitSummary(bare, path26, true, result[1]);
7298
+ return new InitSummary(bare, path27, true, result[1]);
7100
7299
  }
7101
7300
  let gitDir = "";
7102
7301
  const tokens = response.split(" ");
@@ -7107,7 +7306,7 @@ function parseInit(bare, path26, text) {
7107
7306
  break;
7108
7307
  }
7109
7308
  }
7110
- return new InitSummary(bare, path26, /^re/i.test(response), gitDir);
7309
+ return new InitSummary(bare, path27, /^re/i.test(response), gitDir);
7111
7310
  }
7112
7311
  var InitSummary;
7113
7312
  var initResponseRegex;
@@ -7116,9 +7315,9 @@ var init_InitSummary = __esm2({
7116
7315
  "src/lib/responses/InitSummary.ts"() {
7117
7316
  "use strict";
7118
7317
  InitSummary = class {
7119
- constructor(bare, path26, existing, gitDir) {
7318
+ constructor(bare, path27, existing, gitDir) {
7120
7319
  this.bare = bare;
7121
- this.path = path26;
7320
+ this.path = path27;
7122
7321
  this.existing = existing;
7123
7322
  this.gitDir = gitDir;
7124
7323
  }
@@ -7130,7 +7329,7 @@ var init_InitSummary = __esm2({
7130
7329
  function hasBareCommand(command) {
7131
7330
  return command.includes(bareCommand);
7132
7331
  }
7133
- function initTask(bare = false, path26, customArgs) {
7332
+ function initTask(bare = false, path27, customArgs) {
7134
7333
  const commands = ["init", ...customArgs];
7135
7334
  if (bare && !hasBareCommand(commands)) {
7136
7335
  commands.splice(1, 0, bareCommand);
@@ -7139,7 +7338,7 @@ function initTask(bare = false, path26, customArgs) {
7139
7338
  commands,
7140
7339
  format: "utf-8",
7141
7340
  parser(text) {
7142
- return parseInit(commands.includes("--bare"), path26, text);
7341
+ return parseInit(commands.includes("--bare"), path27, text);
7143
7342
  }
7144
7343
  };
7145
7344
  }
@@ -7955,12 +8154,12 @@ var init_FileStatusSummary = __esm2({
7955
8154
  "use strict";
7956
8155
  fromPathRegex = /^(.+)\0(.+)$/;
7957
8156
  FileStatusSummary = class {
7958
- constructor(path26, index, working_dir) {
7959
- this.path = path26;
8157
+ constructor(path27, index, working_dir) {
8158
+ this.path = path27;
7960
8159
  this.index = index;
7961
8160
  this.working_dir = working_dir;
7962
8161
  if (index === "R" || working_dir === "R") {
7963
- const detail = fromPathRegex.exec(path26) || [null, path26, path26];
8162
+ const detail = fromPathRegex.exec(path27) || [null, path27, path27];
7964
8163
  this.from = detail[2] || "";
7965
8164
  this.path = detail[1] || "";
7966
8165
  }
@@ -7991,14 +8190,14 @@ function splitLine(result, lineStr) {
7991
8190
  default:
7992
8191
  return;
7993
8192
  }
7994
- function data(index, workingDir, path26) {
8193
+ function data(index, workingDir, path27) {
7995
8194
  const raw = `${index}${workingDir}`;
7996
8195
  const handler = parsers6.get(raw);
7997
8196
  if (handler) {
7998
- handler(result, path26);
8197
+ handler(result, path27);
7999
8198
  }
8000
8199
  if (raw !== "##" && raw !== "!!") {
8001
- result.files.push(new FileStatusSummary(path26, index, workingDir));
8200
+ result.files.push(new FileStatusSummary(path27, index, workingDir));
8002
8201
  }
8003
8202
  }
8004
8203
  }
@@ -8311,9 +8510,9 @@ var init_simple_git_api = __esm2({
8311
8510
  next
8312
8511
  );
8313
8512
  }
8314
- hashObject(path26, write) {
8513
+ hashObject(path27, write) {
8315
8514
  return this._runTask(
8316
- hashObjectTask(path26, write === true),
8515
+ hashObjectTask(path27, write === true),
8317
8516
  trailingFunctionArgument(arguments)
8318
8517
  );
8319
8518
  }
@@ -8666,8 +8865,8 @@ var init_branch = __esm2({
8666
8865
  }
8667
8866
  });
8668
8867
  function toPath(input) {
8669
- const path26 = input.trim().replace(/^["']|["']$/g, "");
8670
- return path26 && (0, import_node_path.normalize)(path26);
8868
+ const path27 = input.trim().replace(/^["']|["']$/g, "");
8869
+ return path27 && (0, import_node_path.normalize)(path27);
8671
8870
  }
8672
8871
  var parseCheckIgnore;
8673
8872
  var init_CheckIgnore = __esm2({
@@ -8981,8 +9180,8 @@ __export2(sub_module_exports, {
8981
9180
  subModuleTask: () => subModuleTask,
8982
9181
  updateSubModuleTask: () => updateSubModuleTask
8983
9182
  });
8984
- function addSubModuleTask(repo, path26) {
8985
- return subModuleTask(["add", repo, path26]);
9183
+ function addSubModuleTask(repo, path27) {
9184
+ return subModuleTask(["add", repo, path27]);
8986
9185
  }
8987
9186
  function initSubModuleTask(customArgs) {
8988
9187
  return subModuleTask(["init", ...customArgs]);
@@ -9312,8 +9511,8 @@ var require_git = __commonJS2({
9312
9511
  }
9313
9512
  return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
9314
9513
  };
9315
- Git2.prototype.submoduleAdd = function(repo, path26, then) {
9316
- return this._runTask(addSubModuleTask2(repo, path26), trailingFunctionArgument2(arguments));
9514
+ Git2.prototype.submoduleAdd = function(repo, path27, then) {
9515
+ return this._runTask(addSubModuleTask2(repo, path27), trailingFunctionArgument2(arguments));
9317
9516
  };
9318
9517
  Git2.prototype.submoduleUpdate = function(args, then) {
9319
9518
  return this._runTask(
@@ -9903,18 +10102,18 @@ var simpleGit = gitInstanceFactory;
9903
10102
  // src/commands/release.ts
9904
10103
  var git = simpleGit();
9905
10104
  function createReleaseCommand() {
9906
- return new import_commander20.Command("release").description("Ship a new version (Changelog, Tag, Bump)").argument("[type]", "Release type (patch, minor, major)", "patch").action(async (type) => {
9907
- const spinner = (0, import_ora13.default)("Preparing release...").start();
10105
+ return new import_commander21.Command("release").description("Ship a new version (Changelog, Tag, Bump)").argument("[type]", "Release type (patch, minor, major)", "patch").action(async (type) => {
10106
+ const spinner = (0, import_ora14.default)("Preparing release...").start();
9908
10107
  try {
9909
- const { projectId, apiKey, apiUrl } = getContext2();
10108
+ const { projectId, apiKey, apiUrl } = getContext3();
9910
10109
  const status = await git.status();
9911
10110
  if (!status.isClean()) {
9912
10111
  spinner.fail("Git workspace is dirty. Commit or stash changes first.");
9913
10112
  return;
9914
10113
  }
9915
10114
  spinner.text = "Scanning completed tasks...";
9916
- const pkgPath = import_path25.default.resolve(process.cwd(), "package.json");
9917
- const pkgContent = await import_promises21.default.readFile(pkgPath, "utf-8");
10115
+ const pkgPath = import_path26.default.resolve(process.cwd(), "package.json");
10116
+ const pkgContent = await import_promises22.default.readFile(pkgPath, "utf-8");
9918
10117
  const pkg2 = JSON.parse(pkgContent);
9919
10118
  const currentVersion = pkg2.version;
9920
10119
  const [major, minor, patch] = currentVersion.split(".").map(Number);
@@ -9922,8 +10121,8 @@ function createReleaseCommand() {
9922
10121
  if (type === "major") newVersion = `${major + 1}.0.0`;
9923
10122
  if (type === "minor") newVersion = `${major}.${minor + 1}.0`;
9924
10123
  if (type === "patch") newVersion = `${major}.${minor}.${patch + 1}`;
9925
- spinner.succeed(`Bumping ${pkg2.name} from ${import_chalk31.default.dim(currentVersion)} to ${import_chalk31.default.green(newVersion)}`);
9926
- const { confirm } = await import_inquirer5.default.prompt([{
10124
+ spinner.succeed(`Bumping ${pkg2.name} from ${import_chalk32.default.dim(currentVersion)} to ${import_chalk32.default.green(newVersion)}`);
10125
+ const { confirm } = await import_inquirer6.default.prompt([{
9927
10126
  type: "confirm",
9928
10127
  name: "confirm",
9929
10128
  message: `Ship v${newVersion}? This will tag git and update changelog (if db ready).`,
@@ -9934,17 +10133,17 @@ function createReleaseCommand() {
9934
10133
  return;
9935
10134
  }
9936
10135
  pkg2.version = newVersion;
9937
- await import_promises21.default.writeFile(pkgPath, JSON.stringify(pkg2, null, 4));
9938
- const changelogPath = import_path25.default.resolve(process.cwd(), "CHANGELOG.md");
10136
+ await import_promises22.default.writeFile(pkgPath, JSON.stringify(pkg2, null, 4));
10137
+ const changelogPath = import_path26.default.resolve(process.cwd(), "CHANGELOG.md");
9939
10138
  const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
9940
10139
  const entry = `
9941
10140
  ## [${newVersion}] - ${date}
9942
10141
  - Automated release via Rigstate.
9943
10142
  `;
9944
10143
  try {
9945
- await import_promises21.default.appendFile(changelogPath, entry);
10144
+ await import_promises22.default.appendFile(changelogPath, entry);
9946
10145
  } catch {
9947
- await import_promises21.default.writeFile(changelogPath, "# Changelog\n" + entry);
10146
+ await import_promises22.default.writeFile(changelogPath, "# Changelog\n" + entry);
9948
10147
  }
9949
10148
  spinner.start("Tagging and pushing...");
9950
10149
  await git.add(["package.json", "CHANGELOG.md"]);
@@ -9952,13 +10151,13 @@ function createReleaseCommand() {
9952
10151
  await git.addTag(`v${newVersion}`);
9953
10152
  await git.push();
9954
10153
  await git.pushTags();
9955
- spinner.succeed(import_chalk31.default.bold.green(`\u{1F680} Release v${newVersion} shipped!`));
10154
+ spinner.succeed(import_chalk32.default.bold.green(`\u{1F680} Release v${newVersion} shipped!`));
9956
10155
  } catch (e) {
9957
10156
  spinner.fail(e.message);
9958
10157
  }
9959
10158
  });
9960
10159
  }
9961
- function getContext2() {
10160
+ function getContext3() {
9962
10161
  const apiKey = getApiKey();
9963
10162
  const apiUrl = getApiUrl();
9964
10163
  const projectId = getProjectId();
@@ -9968,23 +10167,23 @@ function getContext2() {
9968
10167
 
9969
10168
  // src/commands/roadmap.ts
9970
10169
  init_cjs_shims();
9971
- var import_commander21 = require("commander");
9972
- var import_chalk32 = __toESM(require("chalk"), 1);
9973
- var import_ora14 = __toESM(require("ora"), 1);
9974
- var import_axios21 = __toESM(require("axios"), 1);
10170
+ var import_commander22 = require("commander");
10171
+ var import_chalk33 = __toESM(require("chalk"), 1);
10172
+ var import_ora15 = __toESM(require("ora"), 1);
10173
+ var import_axios22 = __toESM(require("axios"), 1);
9975
10174
  init_config();
9976
10175
  function createRoadmapCommand() {
9977
- return new import_commander21.Command("roadmap").alias("tactical").description("View project roadmap and task status (Tactical View)").action(async () => {
9978
- const spinner = (0, import_ora14.default)("Fetching tactical overview...").start();
10176
+ return new import_commander22.Command("roadmap").alias("tactical").description("View project roadmap and task status (Tactical View)").action(async () => {
10177
+ const spinner = (0, import_ora15.default)("Fetching tactical overview...").start();
9979
10178
  try {
9980
10179
  const apiKey = getApiKey();
9981
10180
  const apiUrl = getApiUrl();
9982
10181
  const projectId = getProjectId();
9983
10182
  if (!projectId) {
9984
- spinner.fail(import_chalk32.default.red('Project context missing. Run "rigstate link".'));
10183
+ spinner.fail(import_chalk33.default.red('Project context missing. Run "rigstate link".'));
9985
10184
  return;
9986
10185
  }
9987
- const response = await import_axios21.default.get(
10186
+ const response = await import_axios22.default.get(
9988
10187
  `${apiUrl}/api/v1/roadmap?project_id=${projectId}`,
9989
10188
  { headers: { Authorization: `Bearer ${apiKey}` } }
9990
10189
  );
@@ -9994,11 +10193,11 @@ function createRoadmapCommand() {
9994
10193
  const tasks = response.data.data.roadmap || [];
9995
10194
  spinner.stop();
9996
10195
  if (tasks.length === 0) {
9997
- console.log(import_chalk32.default.yellow("\nRoadmap is empty. Use the web UI to define your journey."));
10196
+ console.log(import_chalk33.default.yellow("\nRoadmap is empty. Use the web UI to define your journey."));
9998
10197
  return;
9999
10198
  }
10000
- console.log("\n" + import_chalk32.default.bold.underline("\u{1F6F0}\uFE0F TACTICAL OVERVIEW: PROJECT ROADMAP"));
10001
- console.log(import_chalk32.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
10199
+ console.log("\n" + import_chalk33.default.bold.underline("\u{1F6F0}\uFE0F TACTICAL OVERVIEW: PROJECT ROADMAP"));
10200
+ console.log(import_chalk33.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
10002
10201
  const columns = {
10003
10202
  "IN_PROGRESS": [],
10004
10203
  "ACTIVE": [],
@@ -10010,14 +10209,14 @@ function createRoadmapCommand() {
10010
10209
  columns[t.status].push(t);
10011
10210
  }
10012
10211
  });
10013
- displayColumn("\u{1F525} IN PROGRESS", columns.IN_PROGRESS, import_chalk32.default.yellow);
10014
- displayColumn("\u25B6\uFE0F ACTIVE / NEXT", columns.ACTIVE, import_chalk32.default.green);
10015
- displayColumn("\u{1F512} LOCKED", columns.LOCKED, import_chalk32.default.blue);
10016
- displayColumn("\u23F3 PENDING", columns.PENDING, import_chalk32.default.gray);
10017
- console.log(import_chalk32.default.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(import_chalk32.default.dim(`Total: ${tasks.length} tasks | Run "rigstate work" to start coding.`));
10212
+ displayColumn("\u{1F525} IN PROGRESS", columns.IN_PROGRESS, import_chalk33.default.yellow);
10213
+ displayColumn("\u25B6\uFE0F ACTIVE / NEXT", columns.ACTIVE, import_chalk33.default.green);
10214
+ displayColumn("\u{1F512} LOCKED", columns.LOCKED, import_chalk33.default.blue);
10215
+ displayColumn("\u23F3 PENDING", columns.PENDING, import_chalk33.default.gray);
10216
+ console.log(import_chalk33.default.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"));
10217
+ console.log(import_chalk33.default.dim(`Total: ${tasks.length} tasks | Run "rigstate work" to start coding.`));
10019
10218
  } catch (e) {
10020
- spinner.fail(import_chalk32.default.red(`
10219
+ spinner.fail(import_chalk33.default.red(`
10021
10220
  Failed to fetch roadmap: ${e.message}`));
10022
10221
  }
10023
10222
  });
@@ -10028,57 +10227,57 @@ function displayColumn(title, items, color) {
10028
10227
  ${color.bold(title)}`);
10029
10228
  items.sort((a, b) => a.step_number - b.step_number).forEach((item) => {
10030
10229
  const id = `T-${item.step_number}`.padEnd(8);
10031
- const priority = item.priority === "MVP" ? import_chalk32.default.magenta(" [MVP]") : "";
10032
- console.log(` ${color("\u2022")} ${import_chalk32.default.bold(id)} ${item.title}${priority}`);
10230
+ const priority = item.priority === "MVP" ? import_chalk33.default.magenta(" [MVP]") : "";
10231
+ console.log(` ${color("\u2022")} ${import_chalk33.default.bold(id)} ${item.title}${priority}`);
10033
10232
  });
10034
10233
  }
10035
10234
 
10036
10235
  // src/commands/council.ts
10037
10236
  init_cjs_shims();
10038
- var import_commander22 = require("commander");
10039
- var import_chalk33 = __toESM(require("chalk"), 1);
10040
- var import_ora15 = __toESM(require("ora"), 1);
10041
- var import_inquirer6 = __toESM(require("inquirer"), 1);
10237
+ var import_commander23 = require("commander");
10238
+ var import_chalk34 = __toESM(require("chalk"), 1);
10239
+ var import_ora16 = __toESM(require("ora"), 1);
10240
+ var import_inquirer7 = __toESM(require("inquirer"), 1);
10042
10241
  init_config();
10043
10242
  function createCouncilCommand() {
10044
- return new import_commander22.Command("council").description("Trigger a multi-agent debate regarding a strategic decision").argument("[topic]", "The strategic topic or decision to debate").action(async (topic) => {
10045
- const spinner = (0, import_ora15.default)();
10243
+ return new import_commander23.Command("council").description("Trigger a multi-agent debate regarding a strategic decision").argument("[topic]", "The strategic topic or decision to debate").action(async (topic) => {
10244
+ const spinner = (0, import_ora16.default)();
10046
10245
  try {
10047
10246
  const apiKey = getApiKey();
10048
10247
  const apiUrl = getApiUrl();
10049
10248
  const projectId = getProjectId();
10050
10249
  if (!projectId) {
10051
- console.error(import_chalk33.default.red('Project context missing. Run "rigstate link".'));
10250
+ console.error(import_chalk34.default.red('Project context missing. Run "rigstate link".'));
10052
10251
  return;
10053
10252
  }
10054
10253
  let sessionTopic = topic;
10055
10254
  if (!sessionTopic) {
10056
- const ans = await import_inquirer6.default.prompt([{
10255
+ const ans = await import_inquirer7.default.prompt([{
10057
10256
  type: "input",
10058
10257
  name: "topic",
10059
10258
  message: "What strategic decision shall the Council debate?"
10060
10259
  }]);
10061
10260
  sessionTopic = ans.topic;
10062
10261
  }
10063
- console.log(import_chalk33.default.bold.magenta("\n\u2696\uFE0F CONVENING THE COUNCIL OF SOVEREIGNTY\n"));
10064
- console.log(import_chalk33.default.dim(`Topic: ${sessionTopic}`));
10065
- console.log(import_chalk33.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
10066
- console.log(import_chalk33.default.yellow("\n\u{1F9E0} Frank (Architect): Analyzing alignment with Project DNA..."));
10262
+ console.log(import_chalk34.default.bold.magenta("\n\u2696\uFE0F CONVENING THE COUNCIL OF SOVEREIGNTY\n"));
10263
+ console.log(import_chalk34.default.dim(`Topic: ${sessionTopic}`));
10264
+ console.log(import_chalk34.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
10265
+ console.log(import_chalk34.default.yellow("\n\u{1F9E0} Frank (Architect): Analyzing alignment with Project DNA..."));
10067
10266
  await sleep(1500);
10068
- console.log(import_chalk33.default.gray(' "This decision affects our backend scalability. I recommend caution."'));
10069
- console.log(import_chalk33.default.blue("\n\u{1F6E1}\uFE0F Sigrid (Curator): Checking historical precedents..."));
10267
+ console.log(import_chalk34.default.gray(' "This decision affects our backend scalability. I recommend caution."'));
10268
+ console.log(import_chalk34.default.blue("\n\u{1F6E1}\uFE0F Sigrid (Curator): Checking historical precedents..."));
10070
10269
  await sleep(1500);
10071
- console.log(import_chalk33.default.gray(` "Similar patterns in other projects led to technical debt. Let's review RLS."`));
10072
- console.log(import_chalk33.default.green("\n\u{1F4D0} Einar (Analyst): Scanning dependency impact..."));
10270
+ console.log(import_chalk34.default.gray(` "Similar patterns in other projects led to technical debt. Let's review RLS."`));
10271
+ console.log(import_chalk34.default.green("\n\u{1F4D0} Einar (Analyst): Scanning dependency impact..."));
10073
10272
  await sleep(1500);
10074
- console.log(import_chalk33.default.gray(' "Implementation will require updating 3 core services."'));
10075
- console.log(import_chalk33.default.bold.white("\n\u{1F4CB} [FINAL DECISION RECORD]"));
10076
- console.log(import_chalk33.default.white(" Status: Approved with conditions"));
10077
- console.log(import_chalk33.default.white(" Rationale: Value outweighs migration cost. Ensure SEC-SQL-01 compliance."));
10078
- console.log(import_chalk33.default.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(import_chalk33.default.green("\u2705 Decision saved to Project Brain (ADR-102)"));
10273
+ console.log(import_chalk34.default.gray(' "Implementation will require updating 3 core services."'));
10274
+ console.log(import_chalk34.default.bold.white("\n\u{1F4CB} [FINAL DECISION RECORD]"));
10275
+ console.log(import_chalk34.default.white(" Status: Approved with conditions"));
10276
+ console.log(import_chalk34.default.white(" Rationale: Value outweighs migration cost. Ensure SEC-SQL-01 compliance."));
10277
+ console.log(import_chalk34.default.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"));
10278
+ console.log(import_chalk34.default.green("\u2705 Decision saved to Project Brain (ADR-102)"));
10080
10279
  } catch (e) {
10081
- console.error(import_chalk33.default.red(`
10280
+ console.error(import_chalk34.default.red(`
10082
10281
  Council session aborted: ${e.message}`));
10083
10282
  }
10084
10283
  });
@@ -10096,7 +10295,7 @@ async function checkVersion() {
10096
10295
  var import_dotenv = __toESM(require("dotenv"), 1);
10097
10296
  var pkg = require_package();
10098
10297
  import_dotenv.default.config();
10099
- var program = new import_commander23.Command();
10298
+ var program = new import_commander24.Command();
10100
10299
  program.name("rigstate").description("CLI for Rigstate - The AI-Native Dev Studio").version(pkg.version);
10101
10300
  program.addCommand(createLoginCommand());
10102
10301
  program.addCommand(createLinkCommand());
@@ -10120,24 +10319,25 @@ program.addCommand(createIdeaCommand());
10120
10319
  program.addCommand(createReleaseCommand());
10121
10320
  program.addCommand(createRoadmapCommand());
10122
10321
  program.addCommand(createCouncilCommand());
10322
+ program.addCommand(createPlanCommand());
10123
10323
  program.hook("preAction", async () => {
10124
10324
  await checkVersion();
10125
10325
  });
10126
10326
  program.on("--help", () => {
10127
10327
  console.log("");
10128
- console.log(import_chalk34.default.bold("Examples:"));
10328
+ console.log(import_chalk35.default.bold("Examples:"));
10129
10329
  console.log("");
10130
- console.log(import_chalk34.default.cyan(" $ rigstate login sk_rigstate_your_api_key"));
10131
- console.log(import_chalk34.default.dim(" Authenticate with your Rigstate API key"));
10330
+ console.log(import_chalk35.default.cyan(" $ rigstate login sk_rigstate_your_api_key"));
10331
+ console.log(import_chalk35.default.dim(" Authenticate with your Rigstate API key"));
10132
10332
  console.log("");
10133
- console.log(import_chalk34.default.cyan(" $ rigstate scan"));
10134
- console.log(import_chalk34.default.dim(" Scan the current directory"));
10333
+ console.log(import_chalk35.default.cyan(" $ rigstate scan"));
10334
+ console.log(import_chalk35.default.dim(" Scan the current directory"));
10135
10335
  console.log("");
10136
- console.log(import_chalk34.default.cyan(" $ rigstate scan ./src --project abc123"));
10137
- console.log(import_chalk34.default.dim(" Scan a specific directory with project ID"));
10336
+ console.log(import_chalk35.default.cyan(" $ rigstate scan ./src --project abc123"));
10337
+ console.log(import_chalk35.default.dim(" Scan a specific directory with project ID"));
10138
10338
  console.log("");
10139
- console.log(import_chalk34.default.cyan(" $ rigstate scan --json"));
10140
- console.log(import_chalk34.default.dim(" Output results in JSON format (useful for IDE extensions)"));
10339
+ console.log(import_chalk35.default.cyan(" $ rigstate scan --json"));
10340
+ console.log(import_chalk35.default.dim(" Output results in JSON format (useful for IDE extensions)"));
10141
10341
  console.log("");
10142
10342
  });
10143
10343
  program.parse(process.argv);