@h-rig/cli 0.0.6-alpha.30 → 0.0.6-alpha.32

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/src/index.js CHANGED
@@ -355,6 +355,8 @@ __export(exports_plugin, {
355
355
  resolvePluginCliCommand: () => resolvePluginCliCommand,
356
356
  executePlugin: () => executePlugin
357
357
  });
358
+ import { existsSync as existsSync4 } from "fs";
359
+ import { resolve as resolve8 } from "path";
358
360
  import { buildPluginHostContext } from "@rig/runtime/control-plane/plugin-host-context";
359
361
  async function executePlugin(context, args) {
360
362
  const [command = "list", ...rest] = args;
@@ -382,7 +384,8 @@ async function executePlugin(context, args) {
382
384
  }
383
385
  if (context.outputMode === "text") {
384
386
  if (declarative.length === 0) {
385
- console.log("No plugins loaded. Declare plugins in rig.config.ts.");
387
+ const configExists = ["rig.config.ts", "rig.config.mts", "rig.config.json"].some((name) => existsSync4(resolve8(context.projectRoot, name)));
388
+ console.log(configExists ? "rig.config found but no plugins could be loaded. If the config imports @rig/* packages, run `bun install` in this project first." : "No plugins loaded. Declare plugins in rig.config.ts.");
386
389
  } else {
387
390
  console.log("Plugins (rig.config.ts):");
388
391
  for (const p of declarative) {
@@ -524,9 +527,9 @@ var init_plugin = __esm(() => {
524
527
  // packages/cli/src/commands.ts
525
528
  init_runner();
526
529
  import {
527
- existsSync as existsSync14
530
+ existsSync as existsSync15
528
531
  } from "fs";
529
- import { resolve as resolve23 } from "path";
532
+ import { resolve as resolve24 } from "path";
530
533
  import { readBuildConfig } from "@rig/runtime/build-time-config";
531
534
 
532
535
  // packages/cli/src/commands/browser.ts
@@ -2648,23 +2651,23 @@ import { ensureProjectMainFreshBeforeRun } from "@rig/runtime/control-plane/proj
2648
2651
 
2649
2652
  // packages/cli/src/commands/_connection-state.ts
2650
2653
  init_runner();
2651
- import { existsSync as existsSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "fs";
2654
+ import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "fs";
2652
2655
  import { homedir as homedir2 } from "os";
2653
- import { dirname, resolve as resolve8 } from "path";
2656
+ import { dirname, resolve as resolve9 } from "path";
2654
2657
  function resolveGlobalConnectionsPath(env = process.env) {
2655
2658
  const explicit = env.RIG_CONNECTIONS_FILE?.trim();
2656
2659
  if (explicit)
2657
- return resolve8(explicit);
2660
+ return resolve9(explicit);
2658
2661
  const stateDir = env.RIG_GLOBAL_STATE_DIR?.trim();
2659
2662
  if (stateDir)
2660
- return resolve8(stateDir, "connections.json");
2661
- return resolve8(homedir2(), ".rig", "connections.json");
2663
+ return resolve9(stateDir, "connections.json");
2664
+ return resolve9(homedir2(), ".rig", "connections.json");
2662
2665
  }
2663
2666
  function resolveRepoConnectionPath(projectRoot) {
2664
- return resolve8(projectRoot, ".rig", "state", "connection.json");
2667
+ return resolve9(projectRoot, ".rig", "state", "connection.json");
2665
2668
  }
2666
2669
  function readJsonFile2(path) {
2667
- if (!existsSync4(path))
2670
+ if (!existsSync5(path))
2668
2671
  return null;
2669
2672
  try {
2670
2673
  return JSON.parse(readFileSync2(path, "utf8"));
@@ -2751,8 +2754,8 @@ function resolveSelectedConnection(projectRoot, options = {}) {
2751
2754
 
2752
2755
  // packages/cli/src/commands/_server-client.ts
2753
2756
  init_runner();
2754
- import { existsSync as existsSync5, readFileSync as readFileSync3 } from "fs";
2755
- import { resolve as resolve9 } from "path";
2757
+ import { existsSync as existsSync6, readFileSync as readFileSync3 } from "fs";
2758
+ import { resolve as resolve10 } from "path";
2756
2759
  import { ensureLocalRigServerConnection } from "@rig/runtime/local-server";
2757
2760
  var scopedGitHubBearerTokens = new Map;
2758
2761
  function cleanToken(value) {
@@ -2760,12 +2763,12 @@ function cleanToken(value) {
2760
2763
  return trimmed ? trimmed : null;
2761
2764
  }
2762
2765
  function setGitHubBearerTokenForCurrentProcess(token, projectRoot) {
2763
- const scopedKey = resolve9(projectRoot ?? process.cwd());
2766
+ const scopedKey = resolve10(projectRoot ?? process.cwd());
2764
2767
  scopedGitHubBearerTokens.set(scopedKey, cleanToken(token ?? undefined));
2765
2768
  }
2766
2769
  function readPrivateRemoteSessionToken(projectRoot) {
2767
- const path = resolve9(projectRoot, ".rig", "state", "github-auth.json");
2768
- if (!existsSync5(path))
2770
+ const path = resolve10(projectRoot, ".rig", "state", "github-auth.json");
2771
+ if (!existsSync6(path))
2769
2772
  return null;
2770
2773
  try {
2771
2774
  const parsed = JSON.parse(readFileSync3(path, "utf8"));
@@ -2775,7 +2778,7 @@ function readPrivateRemoteSessionToken(projectRoot) {
2775
2778
  }
2776
2779
  }
2777
2780
  function readGitHubBearerTokenForRemote(projectRoot) {
2778
- const scopedKey = resolve9(projectRoot);
2781
+ const scopedKey = resolve10(projectRoot);
2779
2782
  if (scopedGitHubBearerTokens.has(scopedKey))
2780
2783
  return scopedGitHubBearerTokens.get(scopedKey) ?? null;
2781
2784
  const privateSession = readPrivateRemoteSessionToken(projectRoot);
@@ -2917,7 +2920,7 @@ async function registerProjectViaServer(context, input) {
2917
2920
  return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
2918
2921
  }
2919
2922
  function sleep(ms) {
2920
- return new Promise((resolve10) => setTimeout(resolve10, ms));
2923
+ return new Promise((resolve11) => setTimeout(resolve11, ms));
2921
2924
  }
2922
2925
  function isRetryableProjectRootSwitchError(error) {
2923
2926
  if (!(error instanceof Error))
@@ -3400,7 +3403,7 @@ async function executeQueue(context, args) {
3400
3403
 
3401
3404
  // packages/cli/src/commands/agent.ts
3402
3405
  init_runner();
3403
- import { resolve as resolve11 } from "path";
3406
+ import { resolve as resolve12 } from "path";
3404
3407
  import {
3405
3408
  agentId,
3406
3409
  cleanupAgentRuntime,
@@ -3410,8 +3413,8 @@ import {
3410
3413
  } from "@rig/runtime/control-plane/runtime/isolation";
3411
3414
 
3412
3415
  // packages/cli/src/commands/_authority-runs.ts
3413
- import { existsSync as existsSync6 } from "fs";
3414
- import { resolve as resolve10 } from "path";
3416
+ import { existsSync as existsSync7 } from "fs";
3417
+ import { resolve as resolve11 } from "path";
3415
3418
  import {
3416
3419
  readAuthorityRun,
3417
3420
  readJsonlFile as readJsonlFile2,
@@ -3433,8 +3436,8 @@ function normalizeRuntimeAdapter(value) {
3433
3436
  return "claude-code";
3434
3437
  }
3435
3438
  function readLatestBeadRecord(projectRoot, taskId) {
3436
- const issuesPath = resolve10(resolveControlPlaneMonorepoRoot(projectRoot), ".beads", "issues.jsonl");
3437
- if (!existsSync6(issuesPath)) {
3439
+ const issuesPath = resolve11(resolveControlPlaneMonorepoRoot(projectRoot), ".beads", "issues.jsonl");
3440
+ if (!existsSync7(issuesPath)) {
3438
3441
  return null;
3439
3442
  }
3440
3443
  let latest = null;
@@ -3502,7 +3505,7 @@ function upsertAgentAuthorityRun(projectRoot, input) {
3502
3505
  } else if ("errorText" in next) {
3503
3506
  delete next.errorText;
3504
3507
  }
3505
- writeJsonFile3(resolve10(resolveAuthorityRunDir(projectRoot, input.runId), "run.json"), next);
3508
+ writeJsonFile3(resolve11(resolveAuthorityRunDir(projectRoot, input.runId), "run.json"), next);
3506
3509
  return next;
3507
3510
  }
3508
3511
 
@@ -3624,10 +3627,10 @@ async function executeAgent(context, args) {
3624
3627
  status: "running",
3625
3628
  startedAt: createdAt,
3626
3629
  worktreePath: runtime.workspaceDir,
3627
- artifactRoot: resolve11(runtime.workspaceDir, "artifacts", taskId),
3630
+ artifactRoot: resolve12(runtime.workspaceDir, "artifacts", taskId),
3628
3631
  logRoot: runtime.logsDir,
3629
- sessionPath: resolve11(runtime.sessionDir, "session.json"),
3630
- sessionLogPath: resolve11(runtime.logsDir, "agent-stdout.log"),
3632
+ sessionPath: resolve12(runtime.sessionDir, "session.json"),
3633
+ sessionLogPath: resolve12(runtime.logsDir, "agent-stdout.log"),
3631
3634
  pid: process.pid
3632
3635
  });
3633
3636
  const result = await runInAgentRuntime({
@@ -3647,10 +3650,10 @@ async function executeAgent(context, args) {
3647
3650
  startedAt: createdAt,
3648
3651
  completedAt: failedAt,
3649
3652
  worktreePath: runtime.workspaceDir,
3650
- artifactRoot: resolve11(runtime.workspaceDir, "artifacts", taskId),
3653
+ artifactRoot: resolve12(runtime.workspaceDir, "artifacts", taskId),
3651
3654
  logRoot: runtime.logsDir,
3652
- sessionPath: resolve11(runtime.sessionDir, "session.json"),
3653
- sessionLogPath: resolve11(runtime.logsDir, "agent-stdout.log"),
3655
+ sessionPath: resolve12(runtime.sessionDir, "session.json"),
3656
+ sessionLogPath: resolve12(runtime.logsDir, "agent-stdout.log"),
3654
3657
  pid: process.pid,
3655
3658
  errorText: result.stderr ? result.stderr.trim() : `Agent runtime command failed (${result.exitCode})`
3656
3659
  });
@@ -3667,10 +3670,10 @@ ${result.stderr.trim()}` : ""}`, result.exitCode);
3667
3670
  startedAt: createdAt,
3668
3671
  completedAt,
3669
3672
  worktreePath: runtime.workspaceDir,
3670
- artifactRoot: resolve11(runtime.workspaceDir, "artifacts", taskId),
3673
+ artifactRoot: resolve12(runtime.workspaceDir, "artifacts", taskId),
3671
3674
  logRoot: runtime.logsDir,
3672
- sessionPath: resolve11(runtime.sessionDir, "session.json"),
3673
- sessionLogPath: resolve11(runtime.logsDir, "agent-stdout.log"),
3675
+ sessionPath: resolve12(runtime.sessionDir, "session.json"),
3676
+ sessionLogPath: resolve12(runtime.logsDir, "agent-stdout.log"),
3674
3677
  pid: process.pid
3675
3678
  });
3676
3679
  return {
@@ -3746,7 +3749,7 @@ init__parsers();
3746
3749
  import {
3747
3750
  chmodSync,
3748
3751
  copyFileSync as copyFileSync2,
3749
- existsSync as existsSync7,
3752
+ existsSync as existsSync8,
3750
3753
  mkdirSync as mkdirSync6,
3751
3754
  readdirSync,
3752
3755
  readlinkSync,
@@ -3756,7 +3759,7 @@ import {
3756
3759
  unlinkSync
3757
3760
  } from "fs";
3758
3761
  import { homedir as homedir3 } from "os";
3759
- import { resolve as resolve12 } from "path";
3762
+ import { resolve as resolve13 } from "path";
3760
3763
  import { buildBinary as buildBinary2 } from "@rig/runtime/control-plane/runtime/isolation";
3761
3764
  import {
3762
3765
  computeRuntimeImageFingerprint,
@@ -3775,13 +3778,13 @@ async function runQuietBinaryProbe(binaryPath, args, cwd) {
3775
3778
 
3776
3779
  // packages/cli/src/commands/dist.ts
3777
3780
  function collectRigValidatorBuildTargets(input) {
3778
- const validatorsRoot = resolve12(input.hostProjectRoot, "packages/runtime/src/control-plane/validators");
3779
- if (!existsSync7(validatorsRoot))
3781
+ const validatorsRoot = resolve13(input.hostProjectRoot, "packages/runtime/src/control-plane/validators");
3782
+ if (!existsSync8(validatorsRoot))
3780
3783
  return [];
3781
3784
  const targets = [];
3782
3785
  const categories = readdirSync(validatorsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory());
3783
3786
  for (const category of categories) {
3784
- const categoryDir = resolve12(validatorsRoot, category.name);
3787
+ const categoryDir = resolve13(validatorsRoot, category.name);
3785
3788
  for (const entry of readdirSync(categoryDir, { withFileTypes: true })) {
3786
3789
  if (!entry.isFile() || !entry.name.endsWith(".ts"))
3787
3790
  continue;
@@ -3790,7 +3793,7 @@ function collectRigValidatorBuildTargets(input) {
3790
3793
  continue;
3791
3794
  targets.push({
3792
3795
  source: `packages/runtime/src/control-plane/validators/${category.name}/${entry.name}`,
3793
- dest: resolve12(input.imageDir, `bin/validators/${category.name}-${check}`),
3796
+ dest: resolve13(input.imageDir, `bin/validators/${category.name}-${check}`),
3794
3797
  cwd: input.hostProjectRoot
3795
3798
  });
3796
3799
  }
@@ -3799,16 +3802,16 @@ function collectRigValidatorBuildTargets(input) {
3799
3802
  }
3800
3803
  async function findLatestDistBinary(projectRoot) {
3801
3804
  const distRoot = resolveControlPlaneHostDistDir(projectRoot);
3802
- if (!existsSync7(distRoot)) {
3805
+ if (!existsSync8(distRoot)) {
3803
3806
  return null;
3804
3807
  }
3805
3808
  const entries = readdirSync(distRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.startsWith("rig-")).map((entry) => ({
3806
3809
  name: entry.name,
3807
- mtimeMs: statSync(resolve12(distRoot, entry.name)).mtimeMs
3810
+ mtimeMs: statSync(resolve13(distRoot, entry.name)).mtimeMs
3808
3811
  })).sort((a, b) => b.mtimeMs - a.mtimeMs || b.name.localeCompare(a.name));
3809
3812
  for (const { name } of entries) {
3810
- const candidate = resolve12(distRoot, name, "bin", "rig");
3811
- if (existsSync7(candidate) && await isRunnableRigBinary(candidate, projectRoot)) {
3813
+ const candidate = resolve13(distRoot, name, "bin", "rig");
3814
+ if (existsSync8(candidate) && await isRunnableRigBinary(candidate, projectRoot)) {
3812
3815
  return candidate;
3813
3816
  }
3814
3817
  }
@@ -3820,7 +3823,7 @@ async function isRunnableRigBinary(binaryPath, projectRoot) {
3820
3823
  async function runDistDoctor(projectRoot) {
3821
3824
  const bunPath = Bun.which("bun");
3822
3825
  const rigPath = Bun.which("rig");
3823
- const userBinDir = resolve12(homedir3(), ".local/bin");
3826
+ const userBinDir = resolve13(homedir3(), ".local/bin");
3824
3827
  const userBinInPath = (process.env.PATH || "").split(":").filter(Boolean).includes(userBinDir);
3825
3828
  let rigRunnable = false;
3826
3829
  if (rigPath) {
@@ -3868,15 +3871,15 @@ async function executeDist(context, args) {
3868
3871
  let source = await findLatestDistBinary(context.projectRoot);
3869
3872
  let buildDir = null;
3870
3873
  if (!source) {
3871
- buildDir = resolve12(resolveControlPlaneHostDistDir(context.projectRoot), `rig-install-${Date.now()}`);
3874
+ buildDir = resolve13(resolveControlPlaneHostDistDir(context.projectRoot), `rig-install-${Date.now()}`);
3872
3875
  await context.runCommand(["bun", "run", "packages/cli/bin/build-rig-binaries.ts", "--output-dir", buildDir]);
3873
- source = resolve12(buildDir, "bin", "rig");
3876
+ source = resolve13(buildDir, "bin", "rig");
3874
3877
  }
3875
- if (!existsSync7(source)) {
3878
+ if (!existsSync8(source)) {
3876
3879
  throw new CliError2(`Unable to locate rig binary at ${source}.`, 2);
3877
3880
  }
3878
- const installedPath = resolve12(installDir, "rig");
3879
- if (existsSync7(installedPath)) {
3881
+ const installedPath = resolve13(installDir, "rig");
3882
+ if (existsSync8(installedPath)) {
3880
3883
  unlinkSync(installedPath);
3881
3884
  }
3882
3885
  copyFileSync2(source, installedPath);
@@ -3918,22 +3921,22 @@ async function executeDist(context, args) {
3918
3921
  requireNoExtraArgs(rest, "rig dist rebuild-agent");
3919
3922
  const fp = await computeRuntimeImageFingerprint(context.projectRoot);
3920
3923
  const currentId = computeRuntimeImageId(fp);
3921
- const imagesDir = resolve12(resolveControlPlaneMonorepoRuntimeDir(context.projectRoot), "images");
3924
+ const imagesDir = resolve13(resolveControlPlaneMonorepoRuntimeDir(context.projectRoot), "images");
3922
3925
  mkdirSync6(imagesDir, { recursive: true });
3923
3926
  let pruned = 0;
3924
3927
  for (const entry of readdirSync(imagesDir, { withFileTypes: true })) {
3925
3928
  if (entry.isDirectory() && entry.name !== currentId) {
3926
- rmSync3(resolve12(imagesDir, entry.name), { recursive: true, force: true });
3929
+ rmSync3(resolve13(imagesDir, entry.name), { recursive: true, force: true });
3927
3930
  pruned++;
3928
3931
  }
3929
3932
  }
3930
3933
  if (pruned > 0 && context.outputMode === "text") {
3931
3934
  console.log(`Pruned ${pruned} stale image(s).`);
3932
3935
  }
3933
- const imageDir = resolve12(imagesDir, currentId);
3934
- mkdirSync6(resolve12(imageDir, "bin/hooks"), { recursive: true });
3935
- mkdirSync6(resolve12(imageDir, "bin/plugins"), { recursive: true });
3936
- mkdirSync6(resolve12(imageDir, "bin/validators"), { recursive: true });
3936
+ const imageDir = resolve13(imagesDir, currentId);
3937
+ mkdirSync6(resolve13(imageDir, "bin/hooks"), { recursive: true });
3938
+ mkdirSync6(resolve13(imageDir, "bin/plugins"), { recursive: true });
3939
+ mkdirSync6(resolve13(imageDir, "bin/validators"), { recursive: true });
3937
3940
  const hookNames = [
3938
3941
  "scope-guard",
3939
3942
  "import-guard",
@@ -3947,25 +3950,25 @@ async function executeDist(context, args) {
3947
3950
  ];
3948
3951
  const targets = [];
3949
3952
  const hostProjectRoot = process.env.RIG_HOST_PROJECT_ROOT?.trim() || context.projectRoot;
3950
- targets.push({ source: "packages/runtime/bin/rig-agent.ts", dest: resolve12(imageDir, "bin/rig-agent"), cwd: hostProjectRoot });
3951
- targets.push({ source: "packages/runtime/bin/rig-agent-dispatch.ts", dest: resolve12(resolveControlPlaneHostBinDir(context.projectRoot), "rig-agent"), cwd: hostProjectRoot });
3953
+ targets.push({ source: "packages/runtime/bin/rig-agent.ts", dest: resolve13(imageDir, "bin/rig-agent"), cwd: hostProjectRoot });
3954
+ targets.push({ source: "packages/runtime/bin/rig-agent-dispatch.ts", dest: resolve13(resolveControlPlaneHostBinDir(context.projectRoot), "rig-agent"), cwd: hostProjectRoot });
3952
3955
  for (const hookName of hookNames) {
3953
3956
  const src = `packages/runtime/src/control-plane/hooks/${hookName}.ts`;
3954
- targets.push({ source: src, dest: resolve12(imageDir, `bin/hooks/${hookName}`), cwd: hostProjectRoot });
3955
- targets.push({ source: src, dest: resolve12(resolveControlPlaneHostBinDir(context.projectRoot), `hooks/${hookName}`), cwd: hostProjectRoot });
3957
+ targets.push({ source: src, dest: resolve13(imageDir, `bin/hooks/${hookName}`), cwd: hostProjectRoot });
3958
+ targets.push({ source: src, dest: resolve13(resolveControlPlaneHostBinDir(context.projectRoot), `hooks/${hookName}`), cwd: hostProjectRoot });
3956
3959
  }
3957
- const pluginsDir = resolve12(context.projectRoot, "rig/plugins");
3958
- const binPluginsDir = resolve12(resolveControlPlaneHostBinDir(context.projectRoot), "plugins");
3959
- const validatorsRoot = resolve12(hostProjectRoot, "packages/runtime/src/control-plane/validators");
3960
- const binValidatorsDir = resolve12(resolveControlPlaneHostBinDir(context.projectRoot), "validators");
3960
+ const pluginsDir = resolve13(context.projectRoot, "rig/plugins");
3961
+ const binPluginsDir = resolve13(resolveControlPlaneHostBinDir(context.projectRoot), "plugins");
3962
+ const validatorsRoot = resolve13(hostProjectRoot, "packages/runtime/src/control-plane/validators");
3963
+ const binValidatorsDir = resolve13(resolveControlPlaneHostBinDir(context.projectRoot), "validators");
3961
3964
  mkdirSync6(binPluginsDir, { recursive: true });
3962
3965
  mkdirSync6(binValidatorsDir, { recursive: true });
3963
- if (existsSync7(pluginsDir)) {
3966
+ if (existsSync8(pluginsDir)) {
3964
3967
  for (const entry of readdirSync(pluginsDir, { withFileTypes: true })) {
3965
3968
  const m = entry.name.match(/^(.+)\.plugin\.(ts|js|mjs|cjs)$/);
3966
3969
  if (!m)
3967
3970
  continue;
3968
- targets.push({ source: `rig/plugins/${entry.name}`, dest: resolve12(imageDir, `bin/plugins/${m[1]}`), cwd: context.projectRoot });
3971
+ targets.push({ source: `rig/plugins/${entry.name}`, dest: resolve13(imageDir, `bin/plugins/${m[1]}`), cwd: context.projectRoot });
3969
3972
  }
3970
3973
  }
3971
3974
  targets.push(...collectRigValidatorBuildTargets({ contextProjectRoot: context.projectRoot, hostProjectRoot, imageDir }));
@@ -3976,17 +3979,17 @@ async function executeDist(context, args) {
3976
3979
  const isValidator = dest.includes("/bin/validators/");
3977
3980
  await buildBinary2(source, dest, cwd, isValidator ? { AGENT_BUN_PATH: Bun.which("bun") || "bun" } : { AGENT_PROJECT_ROOT: context.projectRoot });
3978
3981
  }
3979
- if (existsSync7(pluginsDir)) {
3982
+ if (existsSync8(pluginsDir)) {
3980
3983
  for (const entry of readdirSync(pluginsDir, { withFileTypes: true })) {
3981
3984
  const m = entry.name.match(/^(.+)\.plugin\.(ts|js|mjs|cjs)$/);
3982
3985
  if (!m)
3983
3986
  continue;
3984
3987
  const pluginName = m[1];
3985
- const imageBin = resolve12(imageDir, `bin/plugins/${pluginName}`);
3988
+ const imageBin = resolve13(imageDir, `bin/plugins/${pluginName}`);
3986
3989
  if (!pluginName)
3987
3990
  continue;
3988
- const symlinkPath = resolve12(binPluginsDir, pluginName);
3989
- if (existsSync7(imageBin)) {
3991
+ const symlinkPath = resolve13(binPluginsDir, pluginName);
3992
+ if (existsSync8(imageBin)) {
3990
3993
  try {
3991
3994
  unlinkSync(symlinkPath);
3992
3995
  } catch {}
@@ -3994,10 +3997,10 @@ async function executeDist(context, args) {
3994
3997
  }
3995
3998
  }
3996
3999
  }
3997
- if (existsSync7(validatorsRoot)) {
4000
+ if (existsSync8(validatorsRoot)) {
3998
4001
  const categories = readdirSync(validatorsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory());
3999
4002
  for (const category of categories) {
4000
- const categoryDir = resolve12(validatorsRoot, category.name);
4003
+ const categoryDir = resolve13(validatorsRoot, category.name);
4001
4004
  for (const entry of readdirSync(categoryDir, { withFileTypes: true })) {
4002
4005
  if (!entry.isFile() || !entry.name.endsWith(".ts"))
4003
4006
  continue;
@@ -4005,9 +4008,9 @@ async function executeDist(context, args) {
4005
4008
  if (!check || check === "index" || check === "shared")
4006
4009
  continue;
4007
4010
  const validatorName = `${category.name}-${check}`;
4008
- const imageBin = resolve12(imageDir, `bin/validators/${validatorName}`);
4009
- const symlinkPath = resolve12(binValidatorsDir, validatorName);
4010
- if (existsSync7(imageBin)) {
4011
+ const imageBin = resolve13(imageDir, `bin/validators/${validatorName}`);
4012
+ const symlinkPath = resolve13(binValidatorsDir, validatorName);
4013
+ if (existsSync8(imageBin)) {
4011
4014
  try {
4012
4015
  unlinkSync(symlinkPath);
4013
4016
  } catch {}
@@ -4016,18 +4019,18 @@ async function executeDist(context, args) {
4016
4019
  }
4017
4020
  }
4018
4021
  }
4019
- const agentsDir = resolve12(resolveControlPlaneMonorepoRuntimeDir(context.projectRoot), "agents");
4020
- if (existsSync7(agentsDir)) {
4022
+ const agentsDir = resolve13(resolveControlPlaneMonorepoRuntimeDir(context.projectRoot), "agents");
4023
+ if (existsSync8(agentsDir)) {
4021
4024
  let relinkCount = 0;
4022
4025
  for (const agentEntry of readdirSync(agentsDir, { withFileTypes: true })) {
4023
4026
  if (!agentEntry.isDirectory())
4024
4027
  continue;
4025
- const agentBinDir = resolve12(agentsDir, agentEntry.name, "worktree", ".rig", "bin");
4026
- if (!existsSync7(agentBinDir))
4028
+ const agentBinDir = resolve13(agentsDir, agentEntry.name, "worktree", ".rig", "bin");
4029
+ if (!existsSync8(agentBinDir))
4027
4030
  continue;
4028
4031
  const walkDir = (dir) => {
4029
4032
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
4030
- const fullPath = resolve12(dir, entry.name);
4033
+ const fullPath = resolve13(dir, entry.name);
4031
4034
  if (entry.isDirectory()) {
4032
4035
  walkDir(fullPath);
4033
4036
  } else if (entry.isSymbolicLink()) {
@@ -4062,7 +4065,7 @@ async function executeDist(context, args) {
4062
4065
  // packages/cli/src/commands/inbox.ts
4063
4066
  init_runner();
4064
4067
  import { writeFileSync as writeFileSync4 } from "fs";
4065
- import { resolve as resolve13 } from "path";
4068
+ import { resolve as resolve14 } from "path";
4066
4069
  import {
4067
4070
  listAuthorityRuns,
4068
4071
  readJsonlFile as readJsonlFile3,
@@ -4464,7 +4467,7 @@ async function listRemoteInboxRecords(context, kind, filters) {
4464
4467
  function listLocalInboxRecords(context, kind, filters) {
4465
4468
  const fileName = kind === "approvals" ? "approvals.jsonl" : "user-input.jsonl";
4466
4469
  const runs = listAuthorityRuns(context.projectRoot).filter((entry) => (!filters.run || entry.runId === filters.run) && (!filters.task || entry.taskId === filters.task));
4467
- return runs.flatMap((entry) => readJsonlFile3(resolve13(resolveAuthorityRunDir2(context.projectRoot, entry.runId), fileName)).map((record) => ({
4470
+ return runs.flatMap((entry) => readJsonlFile3(resolve14(resolveAuthorityRunDir2(context.projectRoot, entry.runId), fileName)).map((record) => ({
4468
4471
  runId: entry.runId,
4469
4472
  taskId: entry.taskId ?? undefined,
4470
4473
  record
@@ -4512,7 +4515,7 @@ async function executeInbox(context, args) {
4512
4515
  if (isRemoteConnectionSelected(context.projectRoot)) {
4513
4516
  throw new CliError2("Remote approval resolution is not available from this CLI yet; use the server UI/API or switch to local state for direct JSONL edits.", 2);
4514
4517
  }
4515
- const approvalsPath = resolve13(resolveAuthorityRunDir2(context.projectRoot, run.value), "approvals.jsonl");
4518
+ const approvalsPath = resolve14(resolveAuthorityRunDir2(context.projectRoot, run.value), "approvals.jsonl");
4516
4519
  const approvals = readJsonlFile3(approvalsPath);
4517
4520
  const resolvedAt = new Date().toISOString();
4518
4521
  const next = approvals.map((entry) => entry.requestId === request.value || entry.id === request.value ? { ...entry, status: "resolved", decision: decision.value, note: note4.value ?? null, resolvedAt } : entry);
@@ -4568,7 +4571,7 @@ async function executeInbox(context, args) {
4568
4571
  const [key, ...restValue] = entry.split("=");
4569
4572
  return [key, restValue.join("=")];
4570
4573
  }));
4571
- const requestsPath = resolve13(resolveAuthorityRunDir2(context.projectRoot, run.value), "user-input.jsonl");
4574
+ const requestsPath = resolve14(resolveAuthorityRunDir2(context.projectRoot, run.value), "user-input.jsonl");
4572
4575
  const requests = readJsonlFile3(requestsPath);
4573
4576
  const resolvedAt = new Date().toISOString();
4574
4577
  const next = requests.map((entry) => entry.requestId === request.value || entry.id === request.value ? { ...entry, status: "resolved", answers: parsedAnswers, respondedAt: resolvedAt, resolvedAt } : entry);
@@ -4584,16 +4587,16 @@ async function executeInbox(context, args) {
4584
4587
 
4585
4588
  // packages/cli/src/commands/init.ts
4586
4589
  init_runner();
4587
- import { appendFileSync as appendFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
4590
+ import { appendFileSync as appendFileSync2, existsSync as existsSync11, mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
4588
4591
  import { spawnSync } from "child_process";
4589
- import { resolve as resolve17 } from "path";
4592
+ import { resolve as resolve18 } from "path";
4590
4593
  import { buildRigInitConfigSource } from "@rig/core";
4591
4594
  import { listGitHubProjects as listGitHubProjectsDirect, resolveProjectStatusField as resolveProjectStatusFieldDirect } from "@rig/server";
4592
4595
 
4593
4596
  // packages/cli/src/commands/_pi-install.ts
4594
- import { existsSync as existsSync8, readFileSync as readFileSync4, rmSync as rmSync4 } from "fs";
4597
+ import { existsSync as existsSync9, readFileSync as readFileSync4, rmSync as rmSync4 } from "fs";
4595
4598
  import { homedir as homedir4 } from "os";
4596
- import { resolve as resolve14 } from "path";
4599
+ import { resolve as resolve15 } from "path";
4597
4600
  var PI_RIG_PACKAGE_NAME = "@h-rig/pi-rig";
4598
4601
  var LEGACY_PI_RIG_PACKAGE_NAME = "@rig/pi-rig";
4599
4602
  var LEGACY_PI_RIG_MARKER = `// Managed by Rig. Source package: @rig/pi-rig.
@@ -4609,11 +4612,11 @@ async function defaultCommandRunner(command, options = {}) {
4609
4612
  return { exitCode, stdout, stderr };
4610
4613
  }
4611
4614
  function resolvePiRigExtensionPath(homeDir) {
4612
- return resolve14(homeDir, ".pi", "agent", "extensions", "pi-rig");
4615
+ return resolve15(homeDir, ".pi", "agent", "extensions", "pi-rig");
4613
4616
  }
4614
- function resolvePiRigPackageSource(projectRoot, exists = existsSync8) {
4615
- const localPackage = resolve14(projectRoot, "packages", "pi-rig");
4616
- if (exists(resolve14(localPackage, "package.json")))
4617
+ function resolvePiRigPackageSource(projectRoot, exists = existsSync9) {
4618
+ const localPackage = resolve15(projectRoot, "packages", "pi-rig");
4619
+ if (exists(resolve15(localPackage, "package.json")))
4617
4620
  return localPackage;
4618
4621
  return `npm:${PI_RIG_PACKAGE_NAME}`;
4619
4622
  }
@@ -4664,9 +4667,9 @@ async function ensurePiBinaryAvailable(input) {
4664
4667
  ...next.exitCode === 0 ? {} : { error: (next.stderr || next.stdout).trim() || "pi --version failed after install" }
4665
4668
  };
4666
4669
  }
4667
- function removeManagedLegacyPiRigBridge(homeDir, exists = existsSync8) {
4670
+ function removeManagedLegacyPiRigBridge(homeDir, exists = existsSync9) {
4668
4671
  const extensionPath = resolvePiRigExtensionPath(homeDir);
4669
- const indexPath = resolve14(extensionPath, "index.ts");
4672
+ const indexPath = resolve15(extensionPath, "index.ts");
4670
4673
  if (!exists(indexPath))
4671
4674
  return;
4672
4675
  try {
@@ -4686,13 +4689,13 @@ async function checkPiRigInstall(input = {}) {
4686
4689
  piRig: { ok: true, label: "pi-rig global extension", detail: extensionPath }
4687
4690
  };
4688
4691
  }
4689
- const exists = input.exists ?? existsSync8;
4692
+ const exists = input.exists ?? existsSync9;
4690
4693
  const runner = input.commandRunner ?? defaultCommandRunner;
4691
4694
  const piResult = await safeRun(runner, ["pi", "--version"]);
4692
4695
  const piListResult = piResult.exitCode === 0 ? await safeRun(runner, ["pi", "list"]) : { exitCode: 1, stdout: "", stderr: "" };
4693
4696
  const listedPiRig = piListResult.exitCode === 0 && piListContainsPiRig(`${piListResult.stdout}
4694
4697
  ${piListResult.stderr}`);
4695
- const legacyBridge = exists(resolve14(extensionPath, "index.ts"));
4698
+ const legacyBridge = exists(resolve15(extensionPath, "index.ts"));
4696
4699
  const hasPiRig = listedPiRig;
4697
4700
  return {
4698
4701
  extensionPath,
@@ -4769,7 +4772,7 @@ async function buildPiSetupChecks(input = {}) {
4769
4772
 
4770
4773
  // packages/cli/src/commands/_snapshot-upload.ts
4771
4774
  import { mkdir, readdir, readFile, writeFile } from "fs/promises";
4772
- import { dirname as dirname2, resolve as resolve15, relative, sep } from "path";
4775
+ import { dirname as dirname2, resolve as resolve16, relative, sep } from "path";
4773
4776
  var SNAPSHOT_ARCHIVE_VERSION = 1;
4774
4777
  var SNAPSHOT_ARCHIVE_CONTENT_TYPE = "application/vnd.rig.snapshot+json";
4775
4778
  var DEFAULT_EXCLUDED_DIRECTORIES = new Set([
@@ -4791,15 +4794,15 @@ function assertManifestPath(root, relativePath) {
4791
4794
  if (!relativePath || relativePath.startsWith("/") || relativePath.includes("\x00")) {
4792
4795
  throw new Error(`Invalid snapshot path: ${relativePath}`);
4793
4796
  }
4794
- const resolved = resolve15(root, relativePath);
4797
+ const resolved = resolve16(root, relativePath);
4795
4798
  const relativeToRoot = relative(root, resolved);
4796
- if (relativeToRoot.startsWith("..") || relativeToRoot === ".." || resolve15(relativeToRoot) === resolved) {
4799
+ if (relativeToRoot.startsWith("..") || relativeToRoot === ".." || resolve16(relativeToRoot) === resolved) {
4797
4800
  throw new Error(`Snapshot path escapes project root: ${relativePath}`);
4798
4801
  }
4799
4802
  return resolved;
4800
4803
  }
4801
4804
  async function buildSnapshotUploadManifest(projectRoot, options = {}) {
4802
- const root = resolve15(projectRoot);
4805
+ const root = resolve16(projectRoot);
4803
4806
  const excludedDirectories = [...new Set([
4804
4807
  ...DEFAULT_EXCLUDED_DIRECTORIES,
4805
4808
  ...options.excludedDirectories ?? []
@@ -4811,7 +4814,7 @@ async function buildSnapshotUploadManifest(projectRoot, options = {}) {
4811
4814
  for (const entry of entries) {
4812
4815
  if (entry.isDirectory() && excludedSet.has(entry.name))
4813
4816
  continue;
4814
- const fullPath = resolve15(dir, entry.name);
4817
+ const fullPath = resolve16(dir, entry.name);
4815
4818
  if (entry.isDirectory()) {
4816
4819
  await visit(fullPath);
4817
4820
  continue;
@@ -4860,8 +4863,8 @@ async function uploadSnapshotArchiveViaServer(context, input) {
4860
4863
 
4861
4864
  // packages/cli/src/commands/_doctor-checks.ts
4862
4865
  init_runner();
4863
- import { existsSync as existsSync9, readFileSync as readFileSync5 } from "fs";
4864
- import { resolve as resolve16 } from "path";
4866
+ import { existsSync as existsSync10, readFileSync as readFileSync5 } from "fs";
4867
+ import { resolve as resolve17 } from "path";
4865
4868
  import { isSupportedBunVersion, MIN_SUPPORTED_BUN_VERSION } from "@rig/runtime/control-plane/setup-version";
4866
4869
  init__parsers();
4867
4870
  function check(id, label, status, detail, remediation) {
@@ -4902,8 +4905,8 @@ function repoSlugFromConfig(config) {
4902
4905
  function loadFallbackConfig(projectRoot) {
4903
4906
  const candidates = ["rig.config.ts", "rig.config.mts", "rig.config.json"];
4904
4907
  for (const name of candidates) {
4905
- const path = resolve16(projectRoot, name);
4906
- if (!existsSync9(path))
4908
+ const path = resolve17(projectRoot, name);
4909
+ if (!existsSync10(path))
4907
4910
  continue;
4908
4911
  try {
4909
4912
  const source = readFileSync5(path, "utf8");
@@ -4985,7 +4988,7 @@ async function runRigDoctorChecks(options) {
4985
4988
  checks.push(check("bun", `bun >= ${MIN_SUPPORTED_BUN_VERSION}`, isSupportedBunVersion(bunVersion) ? "pass" : "fail", `found ${bunVersion}`, `Install Bun ${MIN_SUPPORTED_BUN_VERSION} or newer.`), check("git", "git", which("git") ? "pass" : "fail", which("git") ?? undefined, "Install git and ensure it is on PATH."), check("jq", "jq", which("jq") ? "pass" : "warn", which("jq") ?? undefined, "Install jq (for example `brew install jq`)."));
4986
4989
  const loadedConfig = await loadConfig(projectRoot).catch(() => null);
4987
4990
  const config = loadedConfig ?? loadFallbackConfig(projectRoot);
4988
- const hasConfigFile = ["rig.config.ts", "rig.config.mts", "rig.config.json"].some((name) => existsSync9(resolve16(projectRoot, name)));
4991
+ const hasConfigFile = ["rig.config.ts", "rig.config.mts", "rig.config.json"].some((name) => existsSync10(resolve17(projectRoot, name)));
4989
4992
  checks.push(config ? check("config", "rig.config loadable", "pass") : check("config", "rig.config loadable", hasConfigFile ? "fail" : "fail", hasConfigFile ? "config file exists but failed to load" : "missing rig.config.ts/json", "Run `rig init` or fix the config error."));
4990
4993
  const taskSourceKind = config?.taskSource?.kind;
4991
4994
  checks.push(taskSourceKind ? check("task-source", "task source configured", "pass", taskSourceKind) : check("task-source", "task source configured", "fail", "missing taskSource", "Configure taskSource in rig.config.ts."));
@@ -5104,20 +5107,20 @@ function parseRepoSlug(value) {
5104
5107
  return { owner: match[1], repo: match[2], slug: `${match[1]}/${match[2]}` };
5105
5108
  }
5106
5109
  function ensureRigPrivateDirs(projectRoot) {
5107
- const rigDir = resolve17(projectRoot, ".rig");
5108
- mkdirSync7(resolve17(rigDir, "state"), { recursive: true });
5109
- mkdirSync7(resolve17(rigDir, "logs"), { recursive: true });
5110
- mkdirSync7(resolve17(rigDir, "runs"), { recursive: true });
5111
- mkdirSync7(resolve17(rigDir, "tmp"), { recursive: true });
5112
- mkdirSync7(resolve17(projectRoot, "artifacts"), { recursive: true });
5113
- const taskConfigPath = resolve17(rigDir, "task-config.json");
5114
- if (!existsSync10(taskConfigPath))
5110
+ const rigDir = resolve18(projectRoot, ".rig");
5111
+ mkdirSync7(resolve18(rigDir, "state"), { recursive: true });
5112
+ mkdirSync7(resolve18(rigDir, "logs"), { recursive: true });
5113
+ mkdirSync7(resolve18(rigDir, "runs"), { recursive: true });
5114
+ mkdirSync7(resolve18(rigDir, "tmp"), { recursive: true });
5115
+ mkdirSync7(resolve18(projectRoot, "artifacts"), { recursive: true });
5116
+ const taskConfigPath = resolve18(rigDir, "task-config.json");
5117
+ if (!existsSync11(taskConfigPath))
5115
5118
  writeFileSync5(taskConfigPath, `{}
5116
5119
  `, "utf-8");
5117
5120
  }
5118
5121
  function ensureGitignoreEntries(projectRoot) {
5119
- const path = resolve17(projectRoot, ".gitignore");
5120
- const existing = existsSync10(path) ? readFileSync6(path, "utf8") : "";
5122
+ const path = resolve18(projectRoot, ".gitignore");
5123
+ const existing = existsSync11(path) ? readFileSync6(path, "utf8") : "";
5121
5124
  const entries = [".rig/state/", ".rig/logs/", ".rig/runs/", ".rig/tmp/"];
5122
5125
  const missing = entries.filter((entry) => !existing.split(/\r?\n/).includes(entry));
5123
5126
  if (missing.length === 0)
@@ -5130,14 +5133,14 @@ function ensureGitignoreEntries(projectRoot) {
5130
5133
  `, "utf8");
5131
5134
  }
5132
5135
  function ensureRigConfigPackageDependencies(projectRoot) {
5133
- const path = resolve17(projectRoot, "package.json");
5134
- const existing = existsSync10(path) ? JSON.parse(readFileSync6(path, "utf8")) : {};
5136
+ const path = resolve18(projectRoot, "package.json");
5137
+ const existing = existsSync11(path) ? JSON.parse(readFileSync6(path, "utf8")) : {};
5135
5138
  const devDependencies = existing.devDependencies && typeof existing.devDependencies === "object" && !Array.isArray(existing.devDependencies) ? { ...existing.devDependencies } : {};
5136
5139
  for (const [name, spec] of Object.entries(RIG_CONFIG_DEV_DEPENDENCIES)) {
5137
5140
  devDependencies[name] = spec;
5138
5141
  }
5139
5142
  const next = {
5140
- ...existsSync10(path) ? existing : { name: "rig-project", private: true },
5143
+ ...existsSync11(path) ? existing : { name: "rig-project", private: true },
5141
5144
  devDependencies
5142
5145
  };
5143
5146
  writeFileSync5(path, `${JSON.stringify(next, null, 2)}
@@ -5389,7 +5392,7 @@ async function promptGitHubProjectConfig(context, prompts, repoSlug, githubToken
5389
5392
  };
5390
5393
  }
5391
5394
  function sleep2(ms) {
5392
- return new Promise((resolve18) => setTimeout(resolve18, ms));
5395
+ return new Promise((resolve19) => setTimeout(resolve19, ms));
5393
5396
  }
5394
5397
  function positiveIntFromEnv(name, fallback) {
5395
5398
  const value = Number.parseInt(process.env[name] ?? "", 10);
@@ -5418,7 +5421,7 @@ function remoteGitHubAuthMetadata(payload) {
5418
5421
  };
5419
5422
  }
5420
5423
  function writeRemoteGitHubAuthState(projectRoot, input) {
5421
- writeFileSync5(resolve17(projectRoot, ".rig", "state", "github-auth.json"), `${JSON.stringify({
5424
+ writeFileSync5(resolve18(projectRoot, ".rig", "state", "github-auth.json"), `${JSON.stringify({
5422
5425
  authenticated: true,
5423
5426
  source: input.source,
5424
5427
  storedOnServer: true,
@@ -5475,9 +5478,9 @@ async function runControlPlaneInit(context, options) {
5475
5478
  });
5476
5479
  ensureRigPrivateDirs(projectRoot);
5477
5480
  ensureGitignoreEntries(projectRoot);
5478
- const configTsPath = resolve17(projectRoot, "rig.config.ts");
5479
- const configJsonPath = resolve17(projectRoot, "rig.config.json");
5480
- const configExists = existsSync10(configTsPath) || existsSync10(configJsonPath);
5481
+ const configTsPath = resolve18(projectRoot, "rig.config.ts");
5482
+ const configJsonPath = resolve18(projectRoot, "rig.config.json");
5483
+ const configExists = existsSync11(configTsPath) || existsSync11(configJsonPath);
5481
5484
  if (!options.privateStateOnly) {
5482
5485
  if (configExists && !options.repair) {
5483
5486
  if (context.outputMode !== "json")
@@ -5493,7 +5496,7 @@ async function runControlPlaneInit(context, options) {
5493
5496
  }
5494
5497
  ensureRigConfigPackageDependencies(projectRoot);
5495
5498
  }
5496
- writeFileSync5(resolve17(projectRoot, ".rig", "state", "project-link.json"), `${JSON.stringify({ repoSlug: repo.slug, connection: connectionAlias, linkedAt: new Date().toISOString() }, null, 2)}
5499
+ writeFileSync5(resolve18(projectRoot, ".rig", "state", "project-link.json"), `${JSON.stringify({ repoSlug: repo.slug, connection: connectionAlias, linkedAt: new Date().toISOString() }, null, 2)}
5497
5500
  `, "utf8");
5498
5501
  const checkout = checkoutForInit(projectRoot, serverKind, options.remoteCheckout);
5499
5502
  let uploadedSnapshot = null;
@@ -5689,7 +5692,7 @@ function parseInitOptions(args) {
5689
5692
  async function runInteractiveControlPlaneInit(context, prompts) {
5690
5693
  prompts.intro?.("Initialize a Rig control-plane project");
5691
5694
  const projectRoot = context.projectRoot;
5692
- const existingConfig = existsSync10(resolve17(projectRoot, "rig.config.ts")) || existsSync10(resolve17(projectRoot, "rig.config.json"));
5695
+ const existingConfig = existsSync11(resolve18(projectRoot, "rig.config.ts")) || existsSync11(resolve18(projectRoot, "rig.config.json"));
5693
5696
  let repair = false;
5694
5697
  let privateStateOnly = false;
5695
5698
  if (existingConfig) {
@@ -5993,7 +5996,7 @@ async function executeDoctor(context, args) {
5993
5996
  // packages/cli/src/commands/_run-driver-helpers.ts
5994
5997
  init_runner();
5995
5998
  import { readFileSync as readFileSync7 } from "fs";
5996
- import { resolve as resolve18 } from "path";
5999
+ import { resolve as resolve19 } from "path";
5997
6000
  import {
5998
6001
  appendJsonlRecord as appendJsonlRecord2,
5999
6002
  readAuthorityRun as readAuthorityRun2,
@@ -6013,7 +6016,7 @@ function patchAuthorityRun(projectRoot, runId, patch) {
6013
6016
  ...patch,
6014
6017
  updatedAt: new Date().toISOString()
6015
6018
  };
6016
- writeJsonFile4(resolve18(resolveAuthorityRunDir3(projectRoot, runId), "run.json"), next);
6019
+ writeJsonFile4(resolve19(resolveAuthorityRunDir3(projectRoot, runId), "run.json"), next);
6017
6020
  return next;
6018
6021
  }
6019
6022
  function touchAuthorityRun(projectRoot, runId) {
@@ -6021,21 +6024,21 @@ function touchAuthorityRun(projectRoot, runId) {
6021
6024
  if (!current) {
6022
6025
  return;
6023
6026
  }
6024
- writeJsonFile4(resolve18(resolveAuthorityRunDir3(projectRoot, runId), "run.json"), {
6027
+ writeJsonFile4(resolve19(resolveAuthorityRunDir3(projectRoot, runId), "run.json"), {
6025
6028
  ...current,
6026
6029
  updatedAt: new Date().toISOString()
6027
6030
  });
6028
6031
  }
6029
6032
  function appendRunTimeline(projectRoot, runId, value) {
6030
- appendJsonlRecord2(resolve18(resolveAuthorityRunDir3(projectRoot, runId), "timeline.jsonl"), value);
6033
+ appendJsonlRecord2(resolve19(resolveAuthorityRunDir3(projectRoot, runId), "timeline.jsonl"), value);
6031
6034
  touchAuthorityRun(projectRoot, runId);
6032
6035
  }
6033
6036
  function appendRunLog(projectRoot, runId, value) {
6034
- appendJsonlRecord2(resolve18(resolveAuthorityRunDir3(projectRoot, runId), "logs.jsonl"), value);
6037
+ appendJsonlRecord2(resolve19(resolveAuthorityRunDir3(projectRoot, runId), "logs.jsonl"), value);
6035
6038
  touchAuthorityRun(projectRoot, runId);
6036
6039
  }
6037
6040
  function appendRunAction(projectRoot, runId, value) {
6038
- appendJsonlRecord2(resolve18(resolveAuthorityRunDir3(projectRoot, runId), "timeline.jsonl"), {
6041
+ appendJsonlRecord2(resolve19(resolveAuthorityRunDir3(projectRoot, runId), "timeline.jsonl"), {
6039
6042
  id: value.id,
6040
6043
  type: "action",
6041
6044
  actionType: value.actionType,
@@ -6220,8 +6223,8 @@ function renderSourceScopeValidation(task, validation) {
6220
6223
 
6221
6224
  // packages/cli/src/commands/inspect.ts
6222
6225
  init_runner();
6223
- import { existsSync as existsSync11, readFileSync as readFileSync8 } from "fs";
6224
- import { resolve as resolve19 } from "path";
6226
+ import { existsSync as existsSync12, readFileSync as readFileSync8 } from "fs";
6227
+ import { resolve as resolve20 } from "path";
6225
6228
  import {
6226
6229
  listAuthorityRuns as listAuthorityRuns2,
6227
6230
  readAuthorityRun as readAuthorityRun3,
@@ -6242,8 +6245,8 @@ async function executeInspect(context, args) {
6242
6245
  if (!latestRun) {
6243
6246
  throw new CliError2(`No runs found for ${requiredTask}.`);
6244
6247
  }
6245
- const logsPath = resolve19(resolveAuthorityRunDir4(context.projectRoot, latestRun.runId), "logs.jsonl");
6246
- if (!existsSync11(logsPath)) {
6248
+ const logsPath = resolve20(resolveAuthorityRunDir4(context.projectRoot, latestRun.runId), "logs.jsonl");
6249
+ if (!existsSync12(logsPath)) {
6247
6250
  throw new CliError2(`No logs found for run ${latestRun.runId}.`);
6248
6251
  }
6249
6252
  await context.runCommand(["cat", logsPath]);
@@ -6253,7 +6256,7 @@ async function executeInspect(context, args) {
6253
6256
  const { value: task, rest: remaining } = takeOption(rest, "--task");
6254
6257
  requireNoExtraArgs(remaining, "rig inspect artifacts --task <task-id>");
6255
6258
  const requiredTask = requireTask(task, "rig inspect artifacts --task <task-id>");
6256
- const artifactRoot = resolveTaskArtifactDirs(context.projectRoot, requiredTask).find((path) => existsSync11(path));
6259
+ const artifactRoot = resolveTaskArtifactDirs(context.projectRoot, requiredTask).find((path) => existsSync12(path));
6257
6260
  if (!artifactRoot) {
6258
6261
  throw new CliError2(`No artifacts found for ${requiredTask}.`);
6259
6262
  }
@@ -6310,7 +6313,7 @@ async function executeInspect(context, args) {
6310
6313
  case "failures": {
6311
6314
  requireNoExtraArgs(rest, "rig inspect failures");
6312
6315
  const failed = resolveHarnessPaths2(context.projectRoot).failedApproachesPath;
6313
- if (!existsSync11(failed)) {
6316
+ if (!existsSync12(failed)) {
6314
6317
  console.log("No failures recorded.");
6315
6318
  } else {
6316
6319
  process.stdout.write(readFileSync8(failed, "utf-8"));
@@ -6330,8 +6333,8 @@ async function executeInspect(context, args) {
6330
6333
  return { ok: true, group: "inspect", command };
6331
6334
  case "audit": {
6332
6335
  requireNoExtraArgs(rest, "rig inspect audit");
6333
- const auditPath = resolve19(resolveHarnessPaths2(context.projectRoot).logsDir, "audit.jsonl");
6334
- if (!existsSync11(auditPath)) {
6336
+ const auditPath = resolve20(resolveHarnessPaths2(context.projectRoot).logsDir, "audit.jsonl");
6337
+ if (!existsSync12(auditPath)) {
6335
6338
  console.log("No audit log found.");
6336
6339
  } else {
6337
6340
  const lines = readFileSync8(auditPath, "utf-8").split(/\r?\n/).filter(Boolean).slice(-20);
@@ -7483,7 +7486,7 @@ async function connectWorkerStream(options, ctx, state) {
7483
7486
  const buffered = [];
7484
7487
  const wsUrl = await buildRunPiEventsWebSocketUrl(options.context, options.runId);
7485
7488
  const socket = new WebSocket(wsUrl);
7486
- const closePromise = new Promise((resolve20) => {
7489
+ const closePromise = new Promise((resolve21) => {
7487
7490
  socket.onopen = () => {
7488
7491
  state.wsConnected = true;
7489
7492
  state.status = "live worker Pi WebSocket connected";
@@ -7508,7 +7511,7 @@ async function connectWorkerStream(options, ctx, state) {
7508
7511
  state.wsConnected = false;
7509
7512
  state.status = "worker Pi WebSocket disconnected";
7510
7513
  updatePiUi(ctx, state);
7511
- resolve20();
7514
+ resolve21();
7512
7515
  };
7513
7516
  });
7514
7517
  try {
@@ -7544,11 +7547,11 @@ async function connectWorkerStream(options, ctx, state) {
7544
7547
  function createRemoteBashOperations(options, state, excludeFromContext) {
7545
7548
  return {
7546
7549
  exec(command, _cwd, execOptions) {
7547
- return new Promise((resolve20, reject) => {
7550
+ return new Promise((resolve21, reject) => {
7548
7551
  const pending = {
7549
7552
  command,
7550
7553
  onData: execOptions.onData,
7551
- resolve: resolve20,
7554
+ resolve: resolve21,
7552
7555
  reject,
7553
7556
  sawChunk: false
7554
7557
  };
@@ -8359,7 +8362,7 @@ async function executeServer(context, args, options) {
8359
8362
  init_runner();
8360
8363
  import { readFileSync as readFileSync9 } from "fs";
8361
8364
  import { spawnSync as spawnSync3 } from "child_process";
8362
- import { resolve as resolve20 } from "path";
8365
+ import { resolve as resolve21 } from "path";
8363
8366
  import { cancel as cancel4, confirm as confirm2, isCancel as isCancel4 } from "@clack/prompts";
8364
8367
  import {
8365
8368
  taskArtifactDir,
@@ -9068,7 +9071,7 @@ async function executeTask(context, args, options) {
9068
9071
  const fileFlag = takeOption(rest.slice(1), "--file");
9069
9072
  let content;
9070
9073
  if (fileFlag.value) {
9071
- content = readFileSync9(resolve20(context.projectRoot, fileFlag.value), "utf-8");
9074
+ content = readFileSync9(resolve21(context.projectRoot, fileFlag.value), "utf-8");
9072
9075
  } else {
9073
9076
  content = await readStdin();
9074
9077
  }
@@ -9302,8 +9305,8 @@ async function executeTask(context, args, options) {
9302
9305
 
9303
9306
  // packages/cli/src/commands/task-run-driver.ts
9304
9307
  init_runner();
9305
- import { copyFileSync as copyFileSync3, existsSync as existsSync12, mkdirSync as mkdirSync8, readFileSync as readFileSync10, statSync as statSync2, writeFileSync as writeFileSync6 } from "fs";
9306
- import { resolve as resolve21 } from "path";
9308
+ import { copyFileSync as copyFileSync3, existsSync as existsSync13, mkdirSync as mkdirSync8, readFileSync as readFileSync10, statSync as statSync2, writeFileSync as writeFileSync6 } from "fs";
9309
+ import { resolve as resolve22 } from "path";
9307
9310
  import { spawn as spawn2, spawnSync as spawnSync4 } from "child_process";
9308
9311
  import { createInterface as createLineInterface } from "readline";
9309
9312
  import { loadConfig as loadConfig2 } from "@rig/core/load-config";
@@ -9386,12 +9389,12 @@ function copyUntrackedDirtyFiles(sourceRoot, targetRoot) {
9386
9389
  return 0;
9387
9390
  let copied = 0;
9388
9391
  for (const relativePath of listed.stdout.split("\x00").filter(Boolean)) {
9389
- const sourcePath = resolve21(sourceRoot, relativePath);
9390
- const targetPath = resolve21(targetRoot, relativePath);
9392
+ const sourcePath = resolve22(sourceRoot, relativePath);
9393
+ const targetPath = resolve22(targetRoot, relativePath);
9391
9394
  try {
9392
9395
  if (!statSync2(sourcePath).isFile())
9393
9396
  continue;
9394
- mkdirSync8(resolve21(targetPath, ".."), { recursive: true });
9397
+ mkdirSync8(resolve22(targetPath, ".."), { recursive: true });
9395
9398
  copyFileSync3(sourcePath, targetPath);
9396
9399
  copied += 1;
9397
9400
  } catch {}
@@ -9430,7 +9433,7 @@ function buildDirtyBaselineHandshakeEnv(input) {
9430
9433
  return { RIG_BASELINE_MODE: input.baselineMode ?? "head" };
9431
9434
  return {
9432
9435
  RIG_BASELINE_MODE: "dirty-snapshot",
9433
- RIG_DIRTY_BASELINE_READY_FILE: resolve21(input.projectRoot, ".rig", "runs", input.runId, "dirty-baseline.ready.json")
9436
+ RIG_DIRTY_BASELINE_READY_FILE: resolve22(input.projectRoot, ".rig", "runs", input.runId, "dirty-baseline.ready.json")
9434
9437
  };
9435
9438
  }
9436
9439
  function positiveInt(value, fallback) {
@@ -9541,9 +9544,9 @@ function createCommandRunner(binary) {
9541
9544
  const stderrChunks = [];
9542
9545
  child.stdout.on("data", (chunk) => stdoutChunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk))));
9543
9546
  child.stderr.on("data", (chunk) => stderrChunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk))));
9544
- return await new Promise((resolve22) => {
9545
- child.once("error", (error) => resolve22({ exitCode: 1, stderr: error.message }));
9546
- child.once("close", (code) => resolve22({
9547
+ return await new Promise((resolve23) => {
9548
+ child.once("error", (error) => resolve23({ exitCode: 1, stderr: error.message }));
9549
+ child.once("close", (code) => resolve23({
9547
9550
  exitCode: code ?? 1,
9548
9551
  stdout: Buffer.concat(stdoutChunks).toString("utf8"),
9549
9552
  stderr: Buffer.concat(stderrChunks).toString("utf8")
@@ -9617,7 +9620,7 @@ async function runTaskRunPostValidationLifecycle(input) {
9617
9620
  config,
9618
9621
  sourceTask: input.sourceTask,
9619
9622
  uploadedSnapshot: input.uploadedSnapshot,
9620
- artifactRoot: resolve21(input.projectRoot, "artifacts", taskId3),
9623
+ artifactRoot: resolve22(input.projectRoot, "artifacts", taskId3),
9621
9624
  command: ghCommand,
9622
9625
  gitCommand,
9623
9626
  steerPi,
@@ -9747,7 +9750,7 @@ function summarizeValidationFailure(projectRoot, taskId3) {
9747
9750
  return null;
9748
9751
  }
9749
9752
  for (const artifactDir of resolveTaskArtifactDirs2(projectRoot, taskId3)) {
9750
- const summary = readJsonFile3(resolve21(artifactDir, "validation-summary.json"), null);
9753
+ const summary = readJsonFile3(resolve22(artifactDir, "validation-summary.json"), null);
9751
9754
  if (!summary || summary.status !== "fail") {
9752
9755
  continue;
9753
9756
  }
@@ -9828,9 +9831,9 @@ function readTaskRunAcceptedArtifactState(input) {
9828
9831
  if (!input.taskId || !input.workspaceDir) {
9829
9832
  return { accepted: false, reason: null };
9830
9833
  }
9831
- const artifactDir = resolve21(input.workspaceDir, "artifacts", input.taskId);
9832
- const reviewStatusPath = resolve21(artifactDir, "review-status.txt");
9833
- const taskResultPath = resolve21(artifactDir, "task-result.json");
9834
+ const artifactDir = resolve22(input.workspaceDir, "artifacts", input.taskId);
9835
+ const reviewStatusPath = resolve22(artifactDir, "review-status.txt");
9836
+ const taskResultPath = resolve22(artifactDir, "task-result.json");
9834
9837
  const reviewStatus = readTaskRunReviewStatus(reviewStatusPath);
9835
9838
  if (reviewStatus !== "APPROVED") {
9836
9839
  return { accepted: false, reason: null };
@@ -9867,12 +9870,12 @@ function resolveTaskRunRetryContext(input) {
9867
9870
  if (!input.taskId || !input.workspaceDir) {
9868
9871
  return { shouldRetry: false, failureDetail: null, nextPrompt: null };
9869
9872
  }
9870
- const artifactDir = resolve21(input.workspaceDir, "artifacts", input.taskId);
9871
- const reviewStatePath = resolve21(artifactDir, "review-state.json");
9872
- const reviewFeedbackPath = resolve21(artifactDir, "review-feedback.md");
9873
- const reviewStatusPath = resolve21(artifactDir, "review-status.txt");
9874
- const failedApproachesPath = resolve21(input.workspaceDir, ".rig", "state", "failed_approaches.md");
9875
- const validationSummaryPath = resolve21(artifactDir, "validation-summary.json");
9873
+ const artifactDir = resolve22(input.workspaceDir, "artifacts", input.taskId);
9874
+ const reviewStatePath = resolve22(artifactDir, "review-state.json");
9875
+ const reviewFeedbackPath = resolve22(artifactDir, "review-feedback.md");
9876
+ const reviewStatusPath = resolve22(artifactDir, "review-status.txt");
9877
+ const failedApproachesPath = resolve22(input.workspaceDir, ".rig", "state", "failed_approaches.md");
9878
+ const validationSummaryPath = resolve22(artifactDir, "validation-summary.json");
9876
9879
  const reviewState = readJsonFile3(reviewStatePath, null);
9877
9880
  const reviewStatus = readTaskRunReviewStatus(reviewStatusPath);
9878
9881
  const reviewRejected = isTaskRunReviewRejected(reviewState);
@@ -10058,7 +10061,7 @@ function appendToolTimelineFromLog(input) {
10058
10061
  });
10059
10062
  }
10060
10063
  function readTaskRunReviewStatus(reviewStatusPath) {
10061
- if (!existsSync12(reviewStatusPath)) {
10064
+ if (!existsSync13(reviewStatusPath)) {
10062
10065
  return null;
10063
10066
  }
10064
10067
  try {
@@ -10276,15 +10279,15 @@ async function executeRigOwnedTaskRun(context, input) {
10276
10279
  const loadedAutomationConfig = await loadTaskRunAutomationConfig(context.projectRoot);
10277
10280
  const automationConfig = input.prMode ? { ...loadedAutomationConfig ?? {}, pr: { ...loadedAutomationConfig?.pr ?? {}, mode: input.prMode } } : loadedAutomationConfig;
10278
10281
  const planningClassification = classifyPlanningNeed({ config: automationConfig, sourceTask });
10279
- const planningArtifactPath = resolve21("artifacts", runtimeTaskId, "implementation-plan.md");
10282
+ const planningArtifactPath = resolve22("artifacts", runtimeTaskId, "implementation-plan.md");
10280
10283
  const persistedPlanning = {
10281
10284
  ...planningClassification,
10282
10285
  classifier: input.runtimeAdapter === "pi" ? "pi-rig-structured-policy" : "rig-structured-policy",
10283
10286
  artifactPath: planningClassification.planningRequired ? planningArtifactPath : null,
10284
10287
  classifiedAt: new Date().toISOString()
10285
10288
  };
10286
- mkdirSync8(resolve21(context.projectRoot, ".rig", "runs", input.runId), { recursive: true });
10287
- writeFileSync6(resolve21(context.projectRoot, ".rig", "runs", input.runId, "planning-classification.json"), `${JSON.stringify(persistedPlanning, null, 2)}
10289
+ mkdirSync8(resolve22(context.projectRoot, ".rig", "runs", input.runId), { recursive: true });
10290
+ writeFileSync6(resolve22(context.projectRoot, ".rig", "runs", input.runId, "planning-classification.json"), `${JSON.stringify(persistedPlanning, null, 2)}
10288
10291
  `, "utf8");
10289
10292
  patchAuthorityRun(context.projectRoot, input.runId, { planning: persistedPlanning });
10290
10293
  prompt = `${prompt}
@@ -10334,7 +10337,7 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
10334
10337
  let verificationStarted = false;
10335
10338
  let reviewStarted = false;
10336
10339
  let latestRuntimeWorkspace = resumeMode && typeof existingRunRecord?.worktreePath === "string" ? existingRunRecord.worktreePath : null;
10337
- let latestSessionDir = resumeMode && typeof existingRunRecord?.sessionPath === "string" ? resolve21(existingRunRecord.sessionPath, "..") : null;
10340
+ let latestSessionDir = resumeMode && typeof existingRunRecord?.sessionPath === "string" ? resolve22(existingRunRecord.sessionPath, "..") : null;
10338
10341
  let latestLogsDir = resumeMode && typeof existingRunRecord?.logRoot === "string" ? existingRunRecord.logRoot : null;
10339
10342
  let latestProviderCommand = null;
10340
10343
  let latestRuntimeBranch = resumeMode && typeof existingRunRecord?.branch === "string" ? existingRunRecord.branch : null;
@@ -10420,10 +10423,10 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
10420
10423
  patchAuthorityRun(context.projectRoot, input.runId, {
10421
10424
  status: "running",
10422
10425
  worktreePath: latestRuntimeWorkspace,
10423
- artifactRoot: latestRuntimeWorkspace && input.taskId ? resolve21(latestRuntimeWorkspace, "artifacts", input.taskId) : null,
10426
+ artifactRoot: latestRuntimeWorkspace && input.taskId ? resolve22(latestRuntimeWorkspace, "artifacts", input.taskId) : null,
10424
10427
  logRoot: latestLogsDir,
10425
- sessionPath: latestSessionDir ? resolve21(latestSessionDir, "session.json") : null,
10426
- sessionLogPath: latestLogsDir ? resolve21(latestLogsDir, "agent-stdout.log") : null,
10428
+ sessionPath: latestSessionDir ? resolve22(latestSessionDir, "session.json") : null,
10429
+ sessionLogPath: latestLogsDir ? resolve22(latestLogsDir, "agent-stdout.log") : null,
10427
10430
  branch: runtimeId
10428
10431
  });
10429
10432
  if (!dirtyBaselineApplied && input.baselineMode === "dirty-snapshot" && latestRuntimeWorkspace) {
@@ -10431,7 +10434,7 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
10431
10434
  const dirty = applyDirtyBaselineSnapshot({ sourceRoot: context.projectRoot, targetRoot: latestRuntimeWorkspace });
10432
10435
  const readyFile = childEnv.RIG_DIRTY_BASELINE_READY_FILE;
10433
10436
  if (readyFile) {
10434
- mkdirSync8(resolve21(readyFile, ".."), { recursive: true });
10437
+ mkdirSync8(resolve22(readyFile, ".."), { recursive: true });
10435
10438
  writeFileSync6(readyFile, `${JSON.stringify({ ...dirty, workspaceDir: latestRuntimeWorkspace, appliedAt: new Date().toISOString() }, null, 2)}
10436
10439
  `, "utf8");
10437
10440
  }
@@ -10816,7 +10819,7 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
10816
10819
  let acceptedArtifactObservedAt = null;
10817
10820
  let acceptedArtifactPollTimer = null;
10818
10821
  let acceptedArtifactKillTimer = null;
10819
- const attemptExit = await new Promise((resolve22) => {
10822
+ const attemptExit = await new Promise((resolve23) => {
10820
10823
  let settled = false;
10821
10824
  const settle = (result) => {
10822
10825
  if (settled)
@@ -10824,7 +10827,7 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
10824
10827
  settled = true;
10825
10828
  if (acceptedArtifactPollTimer)
10826
10829
  clearInterval(acceptedArtifactPollTimer);
10827
- resolve22(result);
10830
+ resolve23(result);
10828
10831
  };
10829
10832
  const pollAcceptedArtifacts = () => {
10830
10833
  const artifactState = readTaskRunAcceptedArtifactState({
@@ -11026,8 +11029,8 @@ Failed to update task source for ${input.taskId ?? runtimeTaskId} to failed: ${e
11026
11029
  }
11027
11030
  if (planningClassification.planningRequired) {
11028
11031
  const planWorkspace = latestRuntimeWorkspace ?? context.projectRoot;
11029
- const expectedPlanPath = resolve21(planWorkspace, planningArtifactPath);
11030
- if (!existsSync12(expectedPlanPath)) {
11032
+ const expectedPlanPath = resolve22(planWorkspace, planningArtifactPath);
11033
+ if (!existsSync13(expectedPlanPath)) {
11031
11034
  const failedAt = new Date().toISOString();
11032
11035
  const failureDetail = `Planning was required (${planningClassification.reason}) but ${planningArtifactPath} was not written before implementation completed.`;
11033
11036
  patchAuthorityRun(context.projectRoot, input.runId, {
@@ -11197,9 +11200,9 @@ Failed to update task source for ${input.taskId ?? runtimeTaskId} to failed: ${e
11197
11200
  });
11198
11201
  emitServerRunEvent({ type: "log", runId: input.runId, title: "Pi PR feedback fix stderr" });
11199
11202
  });
11200
- const exitCode = await new Promise((resolve22) => {
11201
- child.once("error", () => resolve22(1));
11202
- child.once("close", (code) => resolve22(code ?? 1));
11203
+ const exitCode = await new Promise((resolve23) => {
11204
+ child.once("error", () => resolve23(1));
11205
+ child.once("close", (code) => resolve23(code ?? 1));
11203
11206
  });
11204
11207
  for (const pendingLog of flushPendingClaudeToolUseLogs({
11205
11208
  runId: input.runId,
@@ -11341,8 +11344,8 @@ async function executeTest(context, args) {
11341
11344
 
11342
11345
  // packages/cli/src/commands/setup.ts
11343
11346
  init_runner();
11344
- import { existsSync as existsSync13, mkdirSync as mkdirSync9, readdirSync as readdirSync2, writeFileSync as writeFileSync7 } from "fs";
11345
- import { resolve as resolve22 } from "path";
11347
+ import { existsSync as existsSync14, mkdirSync as mkdirSync9, readdirSync as readdirSync2, writeFileSync as writeFileSync7 } from "fs";
11348
+ import { resolve as resolve23 } from "path";
11346
11349
  import { createPluginHost } from "@rig/core";
11347
11350
  import {
11348
11351
  isSupportedBunVersion as isSupportedBunVersion2,
@@ -11400,8 +11403,8 @@ function runSetupInit(projectRoot) {
11400
11403
  mkdirSync9(stateDir, { recursive: true });
11401
11404
  mkdirSync9(logsDir, { recursive: true });
11402
11405
  mkdirSync9(artifactsDir, { recursive: true });
11403
- const failuresPath = resolve22(stateDir, "failed_approaches.md");
11404
- if (!existsSync13(failuresPath)) {
11406
+ const failuresPath = resolve23(stateDir, "failed_approaches.md");
11407
+ if (!existsSync14(failuresPath)) {
11405
11408
  writeFileSync7(failuresPath, `# Failed Approaches
11406
11409
 
11407
11410
  `, "utf-8");
@@ -11419,18 +11422,18 @@ async function runSetupCheck(projectRoot) {
11419
11422
  }
11420
11423
  async function runSetupPreflight(projectRoot) {
11421
11424
  await runSetupCheck(projectRoot);
11422
- const validationRoot = resolve22(resolveControlPlaneDefinitionRoot(projectRoot), "validation");
11423
- if (existsSync13(validationRoot)) {
11425
+ const validationRoot = resolve23(resolveControlPlaneDefinitionRoot(projectRoot), "validation");
11426
+ if (existsSync14(validationRoot)) {
11424
11427
  const validators = readdirSync2(validationRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory());
11425
11428
  for (const validator of validators) {
11426
- const script = resolve22(validationRoot, validator.name, "validate.sh");
11427
- if (existsSync13(script)) {
11429
+ const script = resolve23(validationRoot, validator.name, "validate.sh");
11430
+ if (existsSync14(script)) {
11428
11431
  console.log(`OK: validator script ${script}`);
11429
11432
  }
11430
11433
  }
11431
11434
  }
11432
- const hooksRoot = resolve22(resolveControlPlaneDefinitionRoot(projectRoot), "hooks");
11433
- if (existsSync13(hooksRoot)) {
11435
+ const hooksRoot = resolve23(resolveControlPlaneDefinitionRoot(projectRoot), "hooks");
11436
+ if (existsSync14(hooksRoot)) {
11434
11437
  const hooks = readdirSync2(hooksRoot).filter((name) => name.endsWith(".sh"));
11435
11438
  for (const hook of hooks) {
11436
11439
  console.log(`OK: hook ${hook}`);
@@ -11575,7 +11578,7 @@ var PROJECT_REQUIRED_GROUPS = new Set([
11575
11578
  ]);
11576
11579
  var RIG_CONFIG_FILENAMES = ["rig.config.ts", "rig.config.mts", "rig.config.json"];
11577
11580
  function hasInitializedRigProject(projectRoot) {
11578
- return RIG_CONFIG_FILENAMES.some((name) => existsSync14(resolve23(projectRoot, name))) || existsSync14(resolve23(projectRoot, ".rig"));
11581
+ return RIG_CONFIG_FILENAMES.some((name) => existsSync15(resolve24(projectRoot, name))) || existsSync15(resolve24(projectRoot, ".rig"));
11579
11582
  }
11580
11583
  function requireInitializedRigProject(context, group) {
11581
11584
  if (hasInitializedRigProject(context.projectRoot)) {
@@ -11654,9 +11657,11 @@ ${helpText()}`);
11654
11657
  const path = await import("path");
11655
11658
  const { fileURLToPath } = await import("url");
11656
11659
  const execPath = process.execPath || "";
11660
+ const moduleDir = path.dirname(fileURLToPath(import.meta.url));
11657
11661
  const candidates = [
11658
11662
  execPath ? path.resolve(path.dirname(execPath), "..", "manifest.json") : "",
11659
- path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "package.json"),
11663
+ path.resolve(moduleDir, "..", "package.json"),
11664
+ path.resolve(moduleDir, "..", "..", "package.json"),
11660
11665
  path.resolve(process.cwd(), "packages/cli/package.json")
11661
11666
  ].filter(Boolean);
11662
11667
  for (const candidate of candidates) {
@@ -11790,8 +11795,8 @@ var __testOnly = {
11790
11795
  validateRequiredBugPromptValue
11791
11796
  };
11792
11797
  // packages/cli/src/launcher.ts
11793
- import { existsSync as existsSync15 } from "fs";
11794
- import { basename as basename2, resolve as resolve24 } from "path";
11798
+ import { existsSync as existsSync16 } from "fs";
11799
+ import { basename as basename2, resolve as resolve25 } from "path";
11795
11800
  import { loadDotEnvSecrets } from "@rig/runtime/baked-secrets";
11796
11801
  import { RIG_DEFINITION_DIRNAME, RIG_STATE_DIRNAME, resolveNearestRigProjectRoot } from "@rig/runtime/layout";
11797
11802
  function parsePolicyMode(value) {
@@ -11804,7 +11809,7 @@ function parsePolicyMode(value) {
11804
11809
  throw new Error(`Invalid --policy-mode value: ${value}. Use off|observe|enforce.`);
11805
11810
  }
11806
11811
  function hasRigProjectMarker(candidate) {
11807
- return existsSync15(resolve24(candidate, RIG_DEFINITION_DIRNAME)) || existsSync15(resolve24(candidate, RIG_STATE_DIRNAME)) || existsSync15(resolve24(candidate, "rig.config.ts")) || existsSync15(resolve24(candidate, "rig.config.json")) || existsSync15(resolve24(candidate, ".git"));
11812
+ return existsSync16(resolve25(candidate, RIG_DEFINITION_DIRNAME)) || existsSync16(resolve25(candidate, RIG_STATE_DIRNAME)) || existsSync16(resolve25(candidate, "rig.config.ts")) || existsSync16(resolve25(candidate, "rig.config.json")) || existsSync16(resolve25(candidate, ".git"));
11808
11813
  }
11809
11814
  function resolveProjectRoot({
11810
11815
  envProjectRoot,
@@ -11813,19 +11818,19 @@ function resolveProjectRoot({
11813
11818
  cwd = process.cwd()
11814
11819
  }) {
11815
11820
  if (envProjectRoot) {
11816
- return resolve24(cwd, envProjectRoot);
11821
+ return resolve25(cwd, envProjectRoot);
11817
11822
  }
11818
11823
  const fallbackImportDir = importDir ?? cwd;
11819
11824
  const execName = basename2(execPath).toLowerCase();
11820
- const execCandidates = execName === "rig" || execName === "rig.exe" ? [resolve24(execPath, "..", "..")] : [];
11821
- const candidates = [cwd, ...execCandidates, resolve24(fallbackImportDir, "..")];
11825
+ const execCandidates = execName === "rig" || execName === "rig.exe" ? [resolve25(execPath, "..", "..")] : [];
11826
+ const candidates = [cwd, ...execCandidates, resolve25(fallbackImportDir, "..")];
11822
11827
  for (const candidate of candidates) {
11823
11828
  const nearest = resolveNearestRigProjectRoot(candidate);
11824
11829
  if (hasRigProjectMarker(nearest)) {
11825
11830
  return nearest;
11826
11831
  }
11827
11832
  }
11828
- return resolve24(cwd);
11833
+ return resolve25(cwd);
11829
11834
  }
11830
11835
  function normalizeCliErrorCode(message2, isCliError) {
11831
11836
  if (message2.startsWith("Invalid --policy-mode value:")) {
@@ -11892,7 +11897,7 @@ async function runRigCli(module, options = {}) {
11892
11897
  runId: context.runId,
11893
11898
  outcome,
11894
11899
  eventsFile: context.eventBus.getEventsFile(),
11895
- policyFile: resolve24(projectRoot, "rig", "policy", "policy.json"),
11900
+ policyFile: resolve25(projectRoot, "rig", "policy", "policy.json"),
11896
11901
  policyMode: context.policyMode ?? policyMode ?? module.loadPolicy(projectRoot).mode
11897
11902
  }, null, 2));
11898
11903
  }