@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.
@@ -165,6 +165,8 @@ __export(exports_plugin, {
165
165
  resolvePluginCliCommand: () => resolvePluginCliCommand,
166
166
  executePlugin: () => executePlugin
167
167
  });
168
+ import { existsSync as existsSync3 } from "fs";
169
+ import { resolve as resolve7 } from "path";
168
170
  import { buildPluginHostContext } from "@rig/runtime/control-plane/plugin-host-context";
169
171
  async function executePlugin(context, args) {
170
172
  const [command = "list", ...rest] = args;
@@ -192,7 +194,8 @@ async function executePlugin(context, args) {
192
194
  }
193
195
  if (context.outputMode === "text") {
194
196
  if (declarative.length === 0) {
195
- console.log("No plugins loaded. Declare plugins in rig.config.ts.");
197
+ const configExists = ["rig.config.ts", "rig.config.mts", "rig.config.json"].some((name) => existsSync3(resolve7(context.projectRoot, name)));
198
+ 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.");
196
199
  } else {
197
200
  console.log("Plugins (rig.config.ts):");
198
201
  for (const p of declarative) {
@@ -334,9 +337,9 @@ var init_plugin = __esm(() => {
334
337
  // packages/cli/src/commands.ts
335
338
  init_runner();
336
339
  import {
337
- existsSync as existsSync13
340
+ existsSync as existsSync14
338
341
  } from "fs";
339
- import { resolve as resolve22 } from "path";
342
+ import { resolve as resolve23 } from "path";
340
343
  import { readBuildConfig } from "@rig/runtime/build-time-config";
341
344
 
342
345
  // packages/cli/src/commands/browser.ts
@@ -2458,23 +2461,23 @@ import { ensureProjectMainFreshBeforeRun } from "@rig/runtime/control-plane/proj
2458
2461
 
2459
2462
  // packages/cli/src/commands/_connection-state.ts
2460
2463
  init_runner();
2461
- import { existsSync as existsSync3, mkdirSync as mkdirSync4, readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "fs";
2464
+ import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "fs";
2462
2465
  import { homedir as homedir2 } from "os";
2463
- import { dirname, resolve as resolve7 } from "path";
2466
+ import { dirname, resolve as resolve8 } from "path";
2464
2467
  function resolveGlobalConnectionsPath(env = process.env) {
2465
2468
  const explicit = env.RIG_CONNECTIONS_FILE?.trim();
2466
2469
  if (explicit)
2467
- return resolve7(explicit);
2470
+ return resolve8(explicit);
2468
2471
  const stateDir = env.RIG_GLOBAL_STATE_DIR?.trim();
2469
2472
  if (stateDir)
2470
- return resolve7(stateDir, "connections.json");
2471
- return resolve7(homedir2(), ".rig", "connections.json");
2473
+ return resolve8(stateDir, "connections.json");
2474
+ return resolve8(homedir2(), ".rig", "connections.json");
2472
2475
  }
2473
2476
  function resolveRepoConnectionPath(projectRoot) {
2474
- return resolve7(projectRoot, ".rig", "state", "connection.json");
2477
+ return resolve8(projectRoot, ".rig", "state", "connection.json");
2475
2478
  }
2476
2479
  function readJsonFile2(path) {
2477
- if (!existsSync3(path))
2480
+ if (!existsSync4(path))
2478
2481
  return null;
2479
2482
  try {
2480
2483
  return JSON.parse(readFileSync2(path, "utf8"));
@@ -2561,8 +2564,8 @@ function resolveSelectedConnection(projectRoot, options = {}) {
2561
2564
 
2562
2565
  // packages/cli/src/commands/_server-client.ts
2563
2566
  init_runner();
2564
- import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
2565
- import { resolve as resolve8 } from "path";
2567
+ import { existsSync as existsSync5, readFileSync as readFileSync3 } from "fs";
2568
+ import { resolve as resolve9 } from "path";
2566
2569
  import { ensureLocalRigServerConnection } from "@rig/runtime/local-server";
2567
2570
  var scopedGitHubBearerTokens = new Map;
2568
2571
  function cleanToken(value) {
@@ -2570,12 +2573,12 @@ function cleanToken(value) {
2570
2573
  return trimmed ? trimmed : null;
2571
2574
  }
2572
2575
  function setGitHubBearerTokenForCurrentProcess(token, projectRoot) {
2573
- const scopedKey = resolve8(projectRoot ?? process.cwd());
2576
+ const scopedKey = resolve9(projectRoot ?? process.cwd());
2574
2577
  scopedGitHubBearerTokens.set(scopedKey, cleanToken(token ?? undefined));
2575
2578
  }
2576
2579
  function readPrivateRemoteSessionToken(projectRoot) {
2577
- const path = resolve8(projectRoot, ".rig", "state", "github-auth.json");
2578
- if (!existsSync4(path))
2580
+ const path = resolve9(projectRoot, ".rig", "state", "github-auth.json");
2581
+ if (!existsSync5(path))
2579
2582
  return null;
2580
2583
  try {
2581
2584
  const parsed = JSON.parse(readFileSync3(path, "utf8"));
@@ -2585,7 +2588,7 @@ function readPrivateRemoteSessionToken(projectRoot) {
2585
2588
  }
2586
2589
  }
2587
2590
  function readGitHubBearerTokenForRemote(projectRoot) {
2588
- const scopedKey = resolve8(projectRoot);
2591
+ const scopedKey = resolve9(projectRoot);
2589
2592
  if (scopedGitHubBearerTokens.has(scopedKey))
2590
2593
  return scopedGitHubBearerTokens.get(scopedKey) ?? null;
2591
2594
  const privateSession = readPrivateRemoteSessionToken(projectRoot);
@@ -2727,7 +2730,7 @@ async function registerProjectViaServer(context, input) {
2727
2730
  return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
2728
2731
  }
2729
2732
  function sleep(ms) {
2730
- return new Promise((resolve9) => setTimeout(resolve9, ms));
2733
+ return new Promise((resolve10) => setTimeout(resolve10, ms));
2731
2734
  }
2732
2735
  function isRetryableProjectRootSwitchError(error) {
2733
2736
  if (!(error instanceof Error))
@@ -3210,7 +3213,7 @@ async function executeQueue(context, args) {
3210
3213
 
3211
3214
  // packages/cli/src/commands/agent.ts
3212
3215
  init_runner();
3213
- import { resolve as resolve10 } from "path";
3216
+ import { resolve as resolve11 } from "path";
3214
3217
  import {
3215
3218
  agentId,
3216
3219
  cleanupAgentRuntime,
@@ -3220,8 +3223,8 @@ import {
3220
3223
  } from "@rig/runtime/control-plane/runtime/isolation";
3221
3224
 
3222
3225
  // packages/cli/src/commands/_authority-runs.ts
3223
- import { existsSync as existsSync5 } from "fs";
3224
- import { resolve as resolve9 } from "path";
3226
+ import { existsSync as existsSync6 } from "fs";
3227
+ import { resolve as resolve10 } from "path";
3225
3228
  import {
3226
3229
  readAuthorityRun,
3227
3230
  readJsonlFile as readJsonlFile2,
@@ -3243,8 +3246,8 @@ function normalizeRuntimeAdapter(value) {
3243
3246
  return "claude-code";
3244
3247
  }
3245
3248
  function readLatestBeadRecord(projectRoot, taskId) {
3246
- const issuesPath = resolve9(resolveControlPlaneMonorepoRoot(projectRoot), ".beads", "issues.jsonl");
3247
- if (!existsSync5(issuesPath)) {
3249
+ const issuesPath = resolve10(resolveControlPlaneMonorepoRoot(projectRoot), ".beads", "issues.jsonl");
3250
+ if (!existsSync6(issuesPath)) {
3248
3251
  return null;
3249
3252
  }
3250
3253
  let latest = null;
@@ -3312,7 +3315,7 @@ function upsertAgentAuthorityRun(projectRoot, input) {
3312
3315
  } else if ("errorText" in next) {
3313
3316
  delete next.errorText;
3314
3317
  }
3315
- writeJsonFile3(resolve9(resolveAuthorityRunDir(projectRoot, input.runId), "run.json"), next);
3318
+ writeJsonFile3(resolve10(resolveAuthorityRunDir(projectRoot, input.runId), "run.json"), next);
3316
3319
  return next;
3317
3320
  }
3318
3321
 
@@ -3434,10 +3437,10 @@ async function executeAgent(context, args) {
3434
3437
  status: "running",
3435
3438
  startedAt: createdAt,
3436
3439
  worktreePath: runtime.workspaceDir,
3437
- artifactRoot: resolve10(runtime.workspaceDir, "artifacts", taskId),
3440
+ artifactRoot: resolve11(runtime.workspaceDir, "artifacts", taskId),
3438
3441
  logRoot: runtime.logsDir,
3439
- sessionPath: resolve10(runtime.sessionDir, "session.json"),
3440
- sessionLogPath: resolve10(runtime.logsDir, "agent-stdout.log"),
3442
+ sessionPath: resolve11(runtime.sessionDir, "session.json"),
3443
+ sessionLogPath: resolve11(runtime.logsDir, "agent-stdout.log"),
3441
3444
  pid: process.pid
3442
3445
  });
3443
3446
  const result = await runInAgentRuntime({
@@ -3457,10 +3460,10 @@ async function executeAgent(context, args) {
3457
3460
  startedAt: createdAt,
3458
3461
  completedAt: failedAt,
3459
3462
  worktreePath: runtime.workspaceDir,
3460
- artifactRoot: resolve10(runtime.workspaceDir, "artifacts", taskId),
3463
+ artifactRoot: resolve11(runtime.workspaceDir, "artifacts", taskId),
3461
3464
  logRoot: runtime.logsDir,
3462
- sessionPath: resolve10(runtime.sessionDir, "session.json"),
3463
- sessionLogPath: resolve10(runtime.logsDir, "agent-stdout.log"),
3465
+ sessionPath: resolve11(runtime.sessionDir, "session.json"),
3466
+ sessionLogPath: resolve11(runtime.logsDir, "agent-stdout.log"),
3464
3467
  pid: process.pid,
3465
3468
  errorText: result.stderr ? result.stderr.trim() : `Agent runtime command failed (${result.exitCode})`
3466
3469
  });
@@ -3477,10 +3480,10 @@ ${result.stderr.trim()}` : ""}`, result.exitCode);
3477
3480
  startedAt: createdAt,
3478
3481
  completedAt,
3479
3482
  worktreePath: runtime.workspaceDir,
3480
- artifactRoot: resolve10(runtime.workspaceDir, "artifacts", taskId),
3483
+ artifactRoot: resolve11(runtime.workspaceDir, "artifacts", taskId),
3481
3484
  logRoot: runtime.logsDir,
3482
- sessionPath: resolve10(runtime.sessionDir, "session.json"),
3483
- sessionLogPath: resolve10(runtime.logsDir, "agent-stdout.log"),
3485
+ sessionPath: resolve11(runtime.sessionDir, "session.json"),
3486
+ sessionLogPath: resolve11(runtime.logsDir, "agent-stdout.log"),
3484
3487
  pid: process.pid
3485
3488
  });
3486
3489
  return {
@@ -3556,7 +3559,7 @@ init__parsers();
3556
3559
  import {
3557
3560
  chmodSync,
3558
3561
  copyFileSync as copyFileSync2,
3559
- existsSync as existsSync6,
3562
+ existsSync as existsSync7,
3560
3563
  mkdirSync as mkdirSync5,
3561
3564
  readdirSync,
3562
3565
  readlinkSync,
@@ -3566,7 +3569,7 @@ import {
3566
3569
  unlinkSync
3567
3570
  } from "fs";
3568
3571
  import { homedir as homedir3 } from "os";
3569
- import { resolve as resolve11 } from "path";
3572
+ import { resolve as resolve12 } from "path";
3570
3573
  import { buildBinary as buildBinary2 } from "@rig/runtime/control-plane/runtime/isolation";
3571
3574
  import {
3572
3575
  computeRuntimeImageFingerprint,
@@ -3585,13 +3588,13 @@ async function runQuietBinaryProbe(binaryPath, args, cwd) {
3585
3588
 
3586
3589
  // packages/cli/src/commands/dist.ts
3587
3590
  function collectRigValidatorBuildTargets(input) {
3588
- const validatorsRoot = resolve11(input.hostProjectRoot, "packages/runtime/src/control-plane/validators");
3589
- if (!existsSync6(validatorsRoot))
3591
+ const validatorsRoot = resolve12(input.hostProjectRoot, "packages/runtime/src/control-plane/validators");
3592
+ if (!existsSync7(validatorsRoot))
3590
3593
  return [];
3591
3594
  const targets = [];
3592
3595
  const categories = readdirSync(validatorsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory());
3593
3596
  for (const category of categories) {
3594
- const categoryDir = resolve11(validatorsRoot, category.name);
3597
+ const categoryDir = resolve12(validatorsRoot, category.name);
3595
3598
  for (const entry of readdirSync(categoryDir, { withFileTypes: true })) {
3596
3599
  if (!entry.isFile() || !entry.name.endsWith(".ts"))
3597
3600
  continue;
@@ -3600,7 +3603,7 @@ function collectRigValidatorBuildTargets(input) {
3600
3603
  continue;
3601
3604
  targets.push({
3602
3605
  source: `packages/runtime/src/control-plane/validators/${category.name}/${entry.name}`,
3603
- dest: resolve11(input.imageDir, `bin/validators/${category.name}-${check}`),
3606
+ dest: resolve12(input.imageDir, `bin/validators/${category.name}-${check}`),
3604
3607
  cwd: input.hostProjectRoot
3605
3608
  });
3606
3609
  }
@@ -3609,16 +3612,16 @@ function collectRigValidatorBuildTargets(input) {
3609
3612
  }
3610
3613
  async function findLatestDistBinary(projectRoot) {
3611
3614
  const distRoot = resolveControlPlaneHostDistDir(projectRoot);
3612
- if (!existsSync6(distRoot)) {
3615
+ if (!existsSync7(distRoot)) {
3613
3616
  return null;
3614
3617
  }
3615
3618
  const entries = readdirSync(distRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.startsWith("rig-")).map((entry) => ({
3616
3619
  name: entry.name,
3617
- mtimeMs: statSync(resolve11(distRoot, entry.name)).mtimeMs
3620
+ mtimeMs: statSync(resolve12(distRoot, entry.name)).mtimeMs
3618
3621
  })).sort((a, b) => b.mtimeMs - a.mtimeMs || b.name.localeCompare(a.name));
3619
3622
  for (const { name } of entries) {
3620
- const candidate = resolve11(distRoot, name, "bin", "rig");
3621
- if (existsSync6(candidate) && await isRunnableRigBinary(candidate, projectRoot)) {
3623
+ const candidate = resolve12(distRoot, name, "bin", "rig");
3624
+ if (existsSync7(candidate) && await isRunnableRigBinary(candidate, projectRoot)) {
3622
3625
  return candidate;
3623
3626
  }
3624
3627
  }
@@ -3630,7 +3633,7 @@ async function isRunnableRigBinary(binaryPath, projectRoot) {
3630
3633
  async function runDistDoctor(projectRoot) {
3631
3634
  const bunPath = Bun.which("bun");
3632
3635
  const rigPath = Bun.which("rig");
3633
- const userBinDir = resolve11(homedir3(), ".local/bin");
3636
+ const userBinDir = resolve12(homedir3(), ".local/bin");
3634
3637
  const userBinInPath = (process.env.PATH || "").split(":").filter(Boolean).includes(userBinDir);
3635
3638
  let rigRunnable = false;
3636
3639
  if (rigPath) {
@@ -3678,15 +3681,15 @@ async function executeDist(context, args) {
3678
3681
  let source = await findLatestDistBinary(context.projectRoot);
3679
3682
  let buildDir = null;
3680
3683
  if (!source) {
3681
- buildDir = resolve11(resolveControlPlaneHostDistDir(context.projectRoot), `rig-install-${Date.now()}`);
3684
+ buildDir = resolve12(resolveControlPlaneHostDistDir(context.projectRoot), `rig-install-${Date.now()}`);
3682
3685
  await context.runCommand(["bun", "run", "packages/cli/bin/build-rig-binaries.ts", "--output-dir", buildDir]);
3683
- source = resolve11(buildDir, "bin", "rig");
3686
+ source = resolve12(buildDir, "bin", "rig");
3684
3687
  }
3685
- if (!existsSync6(source)) {
3688
+ if (!existsSync7(source)) {
3686
3689
  throw new CliError2(`Unable to locate rig binary at ${source}.`, 2);
3687
3690
  }
3688
- const installedPath = resolve11(installDir, "rig");
3689
- if (existsSync6(installedPath)) {
3691
+ const installedPath = resolve12(installDir, "rig");
3692
+ if (existsSync7(installedPath)) {
3690
3693
  unlinkSync(installedPath);
3691
3694
  }
3692
3695
  copyFileSync2(source, installedPath);
@@ -3728,22 +3731,22 @@ async function executeDist(context, args) {
3728
3731
  requireNoExtraArgs(rest, "rig dist rebuild-agent");
3729
3732
  const fp = await computeRuntimeImageFingerprint(context.projectRoot);
3730
3733
  const currentId = computeRuntimeImageId(fp);
3731
- const imagesDir = resolve11(resolveControlPlaneMonorepoRuntimeDir(context.projectRoot), "images");
3734
+ const imagesDir = resolve12(resolveControlPlaneMonorepoRuntimeDir(context.projectRoot), "images");
3732
3735
  mkdirSync5(imagesDir, { recursive: true });
3733
3736
  let pruned = 0;
3734
3737
  for (const entry of readdirSync(imagesDir, { withFileTypes: true })) {
3735
3738
  if (entry.isDirectory() && entry.name !== currentId) {
3736
- rmSync3(resolve11(imagesDir, entry.name), { recursive: true, force: true });
3739
+ rmSync3(resolve12(imagesDir, entry.name), { recursive: true, force: true });
3737
3740
  pruned++;
3738
3741
  }
3739
3742
  }
3740
3743
  if (pruned > 0 && context.outputMode === "text") {
3741
3744
  console.log(`Pruned ${pruned} stale image(s).`);
3742
3745
  }
3743
- const imageDir = resolve11(imagesDir, currentId);
3744
- mkdirSync5(resolve11(imageDir, "bin/hooks"), { recursive: true });
3745
- mkdirSync5(resolve11(imageDir, "bin/plugins"), { recursive: true });
3746
- mkdirSync5(resolve11(imageDir, "bin/validators"), { recursive: true });
3746
+ const imageDir = resolve12(imagesDir, currentId);
3747
+ mkdirSync5(resolve12(imageDir, "bin/hooks"), { recursive: true });
3748
+ mkdirSync5(resolve12(imageDir, "bin/plugins"), { recursive: true });
3749
+ mkdirSync5(resolve12(imageDir, "bin/validators"), { recursive: true });
3747
3750
  const hookNames = [
3748
3751
  "scope-guard",
3749
3752
  "import-guard",
@@ -3757,25 +3760,25 @@ async function executeDist(context, args) {
3757
3760
  ];
3758
3761
  const targets = [];
3759
3762
  const hostProjectRoot = process.env.RIG_HOST_PROJECT_ROOT?.trim() || context.projectRoot;
3760
- targets.push({ source: "packages/runtime/bin/rig-agent.ts", dest: resolve11(imageDir, "bin/rig-agent"), cwd: hostProjectRoot });
3761
- targets.push({ source: "packages/runtime/bin/rig-agent-dispatch.ts", dest: resolve11(resolveControlPlaneHostBinDir(context.projectRoot), "rig-agent"), cwd: hostProjectRoot });
3763
+ targets.push({ source: "packages/runtime/bin/rig-agent.ts", dest: resolve12(imageDir, "bin/rig-agent"), cwd: hostProjectRoot });
3764
+ targets.push({ source: "packages/runtime/bin/rig-agent-dispatch.ts", dest: resolve12(resolveControlPlaneHostBinDir(context.projectRoot), "rig-agent"), cwd: hostProjectRoot });
3762
3765
  for (const hookName of hookNames) {
3763
3766
  const src = `packages/runtime/src/control-plane/hooks/${hookName}.ts`;
3764
- targets.push({ source: src, dest: resolve11(imageDir, `bin/hooks/${hookName}`), cwd: hostProjectRoot });
3765
- targets.push({ source: src, dest: resolve11(resolveControlPlaneHostBinDir(context.projectRoot), `hooks/${hookName}`), cwd: hostProjectRoot });
3767
+ targets.push({ source: src, dest: resolve12(imageDir, `bin/hooks/${hookName}`), cwd: hostProjectRoot });
3768
+ targets.push({ source: src, dest: resolve12(resolveControlPlaneHostBinDir(context.projectRoot), `hooks/${hookName}`), cwd: hostProjectRoot });
3766
3769
  }
3767
- const pluginsDir = resolve11(context.projectRoot, "rig/plugins");
3768
- const binPluginsDir = resolve11(resolveControlPlaneHostBinDir(context.projectRoot), "plugins");
3769
- const validatorsRoot = resolve11(hostProjectRoot, "packages/runtime/src/control-plane/validators");
3770
- const binValidatorsDir = resolve11(resolveControlPlaneHostBinDir(context.projectRoot), "validators");
3770
+ const pluginsDir = resolve12(context.projectRoot, "rig/plugins");
3771
+ const binPluginsDir = resolve12(resolveControlPlaneHostBinDir(context.projectRoot), "plugins");
3772
+ const validatorsRoot = resolve12(hostProjectRoot, "packages/runtime/src/control-plane/validators");
3773
+ const binValidatorsDir = resolve12(resolveControlPlaneHostBinDir(context.projectRoot), "validators");
3771
3774
  mkdirSync5(binPluginsDir, { recursive: true });
3772
3775
  mkdirSync5(binValidatorsDir, { recursive: true });
3773
- if (existsSync6(pluginsDir)) {
3776
+ if (existsSync7(pluginsDir)) {
3774
3777
  for (const entry of readdirSync(pluginsDir, { withFileTypes: true })) {
3775
3778
  const m = entry.name.match(/^(.+)\.plugin\.(ts|js|mjs|cjs)$/);
3776
3779
  if (!m)
3777
3780
  continue;
3778
- targets.push({ source: `rig/plugins/${entry.name}`, dest: resolve11(imageDir, `bin/plugins/${m[1]}`), cwd: context.projectRoot });
3781
+ targets.push({ source: `rig/plugins/${entry.name}`, dest: resolve12(imageDir, `bin/plugins/${m[1]}`), cwd: context.projectRoot });
3779
3782
  }
3780
3783
  }
3781
3784
  targets.push(...collectRigValidatorBuildTargets({ contextProjectRoot: context.projectRoot, hostProjectRoot, imageDir }));
@@ -3786,17 +3789,17 @@ async function executeDist(context, args) {
3786
3789
  const isValidator = dest.includes("/bin/validators/");
3787
3790
  await buildBinary2(source, dest, cwd, isValidator ? { AGENT_BUN_PATH: Bun.which("bun") || "bun" } : { AGENT_PROJECT_ROOT: context.projectRoot });
3788
3791
  }
3789
- if (existsSync6(pluginsDir)) {
3792
+ if (existsSync7(pluginsDir)) {
3790
3793
  for (const entry of readdirSync(pluginsDir, { withFileTypes: true })) {
3791
3794
  const m = entry.name.match(/^(.+)\.plugin\.(ts|js|mjs|cjs)$/);
3792
3795
  if (!m)
3793
3796
  continue;
3794
3797
  const pluginName = m[1];
3795
- const imageBin = resolve11(imageDir, `bin/plugins/${pluginName}`);
3798
+ const imageBin = resolve12(imageDir, `bin/plugins/${pluginName}`);
3796
3799
  if (!pluginName)
3797
3800
  continue;
3798
- const symlinkPath = resolve11(binPluginsDir, pluginName);
3799
- if (existsSync6(imageBin)) {
3801
+ const symlinkPath = resolve12(binPluginsDir, pluginName);
3802
+ if (existsSync7(imageBin)) {
3800
3803
  try {
3801
3804
  unlinkSync(symlinkPath);
3802
3805
  } catch {}
@@ -3804,10 +3807,10 @@ async function executeDist(context, args) {
3804
3807
  }
3805
3808
  }
3806
3809
  }
3807
- if (existsSync6(validatorsRoot)) {
3810
+ if (existsSync7(validatorsRoot)) {
3808
3811
  const categories = readdirSync(validatorsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory());
3809
3812
  for (const category of categories) {
3810
- const categoryDir = resolve11(validatorsRoot, category.name);
3813
+ const categoryDir = resolve12(validatorsRoot, category.name);
3811
3814
  for (const entry of readdirSync(categoryDir, { withFileTypes: true })) {
3812
3815
  if (!entry.isFile() || !entry.name.endsWith(".ts"))
3813
3816
  continue;
@@ -3815,9 +3818,9 @@ async function executeDist(context, args) {
3815
3818
  if (!check || check === "index" || check === "shared")
3816
3819
  continue;
3817
3820
  const validatorName = `${category.name}-${check}`;
3818
- const imageBin = resolve11(imageDir, `bin/validators/${validatorName}`);
3819
- const symlinkPath = resolve11(binValidatorsDir, validatorName);
3820
- if (existsSync6(imageBin)) {
3821
+ const imageBin = resolve12(imageDir, `bin/validators/${validatorName}`);
3822
+ const symlinkPath = resolve12(binValidatorsDir, validatorName);
3823
+ if (existsSync7(imageBin)) {
3821
3824
  try {
3822
3825
  unlinkSync(symlinkPath);
3823
3826
  } catch {}
@@ -3826,18 +3829,18 @@ async function executeDist(context, args) {
3826
3829
  }
3827
3830
  }
3828
3831
  }
3829
- const agentsDir = resolve11(resolveControlPlaneMonorepoRuntimeDir(context.projectRoot), "agents");
3830
- if (existsSync6(agentsDir)) {
3832
+ const agentsDir = resolve12(resolveControlPlaneMonorepoRuntimeDir(context.projectRoot), "agents");
3833
+ if (existsSync7(agentsDir)) {
3831
3834
  let relinkCount = 0;
3832
3835
  for (const agentEntry of readdirSync(agentsDir, { withFileTypes: true })) {
3833
3836
  if (!agentEntry.isDirectory())
3834
3837
  continue;
3835
- const agentBinDir = resolve11(agentsDir, agentEntry.name, "worktree", ".rig", "bin");
3836
- if (!existsSync6(agentBinDir))
3838
+ const agentBinDir = resolve12(agentsDir, agentEntry.name, "worktree", ".rig", "bin");
3839
+ if (!existsSync7(agentBinDir))
3837
3840
  continue;
3838
3841
  const walkDir = (dir) => {
3839
3842
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
3840
- const fullPath = resolve11(dir, entry.name);
3843
+ const fullPath = resolve12(dir, entry.name);
3841
3844
  if (entry.isDirectory()) {
3842
3845
  walkDir(fullPath);
3843
3846
  } else if (entry.isSymbolicLink()) {
@@ -3872,7 +3875,7 @@ async function executeDist(context, args) {
3872
3875
  // packages/cli/src/commands/inbox.ts
3873
3876
  init_runner();
3874
3877
  import { writeFileSync as writeFileSync4 } from "fs";
3875
- import { resolve as resolve12 } from "path";
3878
+ import { resolve as resolve13 } from "path";
3876
3879
  import {
3877
3880
  listAuthorityRuns,
3878
3881
  readJsonlFile as readJsonlFile3,
@@ -4274,7 +4277,7 @@ async function listRemoteInboxRecords(context, kind, filters) {
4274
4277
  function listLocalInboxRecords(context, kind, filters) {
4275
4278
  const fileName = kind === "approvals" ? "approvals.jsonl" : "user-input.jsonl";
4276
4279
  const runs = listAuthorityRuns(context.projectRoot).filter((entry) => (!filters.run || entry.runId === filters.run) && (!filters.task || entry.taskId === filters.task));
4277
- return runs.flatMap((entry) => readJsonlFile3(resolve12(resolveAuthorityRunDir2(context.projectRoot, entry.runId), fileName)).map((record) => ({
4280
+ return runs.flatMap((entry) => readJsonlFile3(resolve13(resolveAuthorityRunDir2(context.projectRoot, entry.runId), fileName)).map((record) => ({
4278
4281
  runId: entry.runId,
4279
4282
  taskId: entry.taskId ?? undefined,
4280
4283
  record
@@ -4322,7 +4325,7 @@ async function executeInbox(context, args) {
4322
4325
  if (isRemoteConnectionSelected(context.projectRoot)) {
4323
4326
  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);
4324
4327
  }
4325
- const approvalsPath = resolve12(resolveAuthorityRunDir2(context.projectRoot, run.value), "approvals.jsonl");
4328
+ const approvalsPath = resolve13(resolveAuthorityRunDir2(context.projectRoot, run.value), "approvals.jsonl");
4326
4329
  const approvals = readJsonlFile3(approvalsPath);
4327
4330
  const resolvedAt = new Date().toISOString();
4328
4331
  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);
@@ -4378,7 +4381,7 @@ async function executeInbox(context, args) {
4378
4381
  const [key, ...restValue] = entry.split("=");
4379
4382
  return [key, restValue.join("=")];
4380
4383
  }));
4381
- const requestsPath = resolve12(resolveAuthorityRunDir2(context.projectRoot, run.value), "user-input.jsonl");
4384
+ const requestsPath = resolve13(resolveAuthorityRunDir2(context.projectRoot, run.value), "user-input.jsonl");
4382
4385
  const requests = readJsonlFile3(requestsPath);
4383
4386
  const resolvedAt = new Date().toISOString();
4384
4387
  const next = requests.map((entry) => entry.requestId === request.value || entry.id === request.value ? { ...entry, status: "resolved", answers: parsedAnswers, respondedAt: resolvedAt, resolvedAt } : entry);
@@ -4394,16 +4397,16 @@ async function executeInbox(context, args) {
4394
4397
 
4395
4398
  // packages/cli/src/commands/init.ts
4396
4399
  init_runner();
4397
- import { appendFileSync as appendFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync6, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
4400
+ import { appendFileSync as appendFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync6, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
4398
4401
  import { spawnSync } from "child_process";
4399
- import { resolve as resolve16 } from "path";
4402
+ import { resolve as resolve17 } from "path";
4400
4403
  import { buildRigInitConfigSource } from "@rig/core";
4401
4404
  import { listGitHubProjects as listGitHubProjectsDirect, resolveProjectStatusField as resolveProjectStatusFieldDirect } from "@rig/server";
4402
4405
 
4403
4406
  // packages/cli/src/commands/_pi-install.ts
4404
- import { existsSync as existsSync7, readFileSync as readFileSync4, rmSync as rmSync4 } from "fs";
4407
+ import { existsSync as existsSync8, readFileSync as readFileSync4, rmSync as rmSync4 } from "fs";
4405
4408
  import { homedir as homedir4 } from "os";
4406
- import { resolve as resolve13 } from "path";
4409
+ import { resolve as resolve14 } from "path";
4407
4410
  var PI_RIG_PACKAGE_NAME = "@h-rig/pi-rig";
4408
4411
  var LEGACY_PI_RIG_PACKAGE_NAME = "@rig/pi-rig";
4409
4412
  var LEGACY_PI_RIG_MARKER = `// Managed by Rig. Source package: @rig/pi-rig.
@@ -4419,11 +4422,11 @@ async function defaultCommandRunner(command, options = {}) {
4419
4422
  return { exitCode, stdout, stderr };
4420
4423
  }
4421
4424
  function resolvePiRigExtensionPath(homeDir) {
4422
- return resolve13(homeDir, ".pi", "agent", "extensions", "pi-rig");
4425
+ return resolve14(homeDir, ".pi", "agent", "extensions", "pi-rig");
4423
4426
  }
4424
- function resolvePiRigPackageSource(projectRoot, exists = existsSync7) {
4425
- const localPackage = resolve13(projectRoot, "packages", "pi-rig");
4426
- if (exists(resolve13(localPackage, "package.json")))
4427
+ function resolvePiRigPackageSource(projectRoot, exists = existsSync8) {
4428
+ const localPackage = resolve14(projectRoot, "packages", "pi-rig");
4429
+ if (exists(resolve14(localPackage, "package.json")))
4427
4430
  return localPackage;
4428
4431
  return `npm:${PI_RIG_PACKAGE_NAME}`;
4429
4432
  }
@@ -4474,9 +4477,9 @@ async function ensurePiBinaryAvailable(input) {
4474
4477
  ...next.exitCode === 0 ? {} : { error: (next.stderr || next.stdout).trim() || "pi --version failed after install" }
4475
4478
  };
4476
4479
  }
4477
- function removeManagedLegacyPiRigBridge(homeDir, exists = existsSync7) {
4480
+ function removeManagedLegacyPiRigBridge(homeDir, exists = existsSync8) {
4478
4481
  const extensionPath = resolvePiRigExtensionPath(homeDir);
4479
- const indexPath = resolve13(extensionPath, "index.ts");
4482
+ const indexPath = resolve14(extensionPath, "index.ts");
4480
4483
  if (!exists(indexPath))
4481
4484
  return;
4482
4485
  try {
@@ -4496,13 +4499,13 @@ async function checkPiRigInstall(input = {}) {
4496
4499
  piRig: { ok: true, label: "pi-rig global extension", detail: extensionPath }
4497
4500
  };
4498
4501
  }
4499
- const exists = input.exists ?? existsSync7;
4502
+ const exists = input.exists ?? existsSync8;
4500
4503
  const runner = input.commandRunner ?? defaultCommandRunner;
4501
4504
  const piResult = await safeRun(runner, ["pi", "--version"]);
4502
4505
  const piListResult = piResult.exitCode === 0 ? await safeRun(runner, ["pi", "list"]) : { exitCode: 1, stdout: "", stderr: "" };
4503
4506
  const listedPiRig = piListResult.exitCode === 0 && piListContainsPiRig(`${piListResult.stdout}
4504
4507
  ${piListResult.stderr}`);
4505
- const legacyBridge = exists(resolve13(extensionPath, "index.ts"));
4508
+ const legacyBridge = exists(resolve14(extensionPath, "index.ts"));
4506
4509
  const hasPiRig = listedPiRig;
4507
4510
  return {
4508
4511
  extensionPath,
@@ -4579,7 +4582,7 @@ async function buildPiSetupChecks(input = {}) {
4579
4582
 
4580
4583
  // packages/cli/src/commands/_snapshot-upload.ts
4581
4584
  import { mkdir, readdir, readFile, writeFile } from "fs/promises";
4582
- import { dirname as dirname2, resolve as resolve14, relative, sep } from "path";
4585
+ import { dirname as dirname2, resolve as resolve15, relative, sep } from "path";
4583
4586
  var SNAPSHOT_ARCHIVE_VERSION = 1;
4584
4587
  var SNAPSHOT_ARCHIVE_CONTENT_TYPE = "application/vnd.rig.snapshot+json";
4585
4588
  var DEFAULT_EXCLUDED_DIRECTORIES = new Set([
@@ -4601,15 +4604,15 @@ function assertManifestPath(root, relativePath) {
4601
4604
  if (!relativePath || relativePath.startsWith("/") || relativePath.includes("\x00")) {
4602
4605
  throw new Error(`Invalid snapshot path: ${relativePath}`);
4603
4606
  }
4604
- const resolved = resolve14(root, relativePath);
4607
+ const resolved = resolve15(root, relativePath);
4605
4608
  const relativeToRoot = relative(root, resolved);
4606
- if (relativeToRoot.startsWith("..") || relativeToRoot === ".." || resolve14(relativeToRoot) === resolved) {
4609
+ if (relativeToRoot.startsWith("..") || relativeToRoot === ".." || resolve15(relativeToRoot) === resolved) {
4607
4610
  throw new Error(`Snapshot path escapes project root: ${relativePath}`);
4608
4611
  }
4609
4612
  return resolved;
4610
4613
  }
4611
4614
  async function buildSnapshotUploadManifest(projectRoot, options = {}) {
4612
- const root = resolve14(projectRoot);
4615
+ const root = resolve15(projectRoot);
4613
4616
  const excludedDirectories = [...new Set([
4614
4617
  ...DEFAULT_EXCLUDED_DIRECTORIES,
4615
4618
  ...options.excludedDirectories ?? []
@@ -4621,7 +4624,7 @@ async function buildSnapshotUploadManifest(projectRoot, options = {}) {
4621
4624
  for (const entry of entries) {
4622
4625
  if (entry.isDirectory() && excludedSet.has(entry.name))
4623
4626
  continue;
4624
- const fullPath = resolve14(dir, entry.name);
4627
+ const fullPath = resolve15(dir, entry.name);
4625
4628
  if (entry.isDirectory()) {
4626
4629
  await visit(fullPath);
4627
4630
  continue;
@@ -4670,8 +4673,8 @@ async function uploadSnapshotArchiveViaServer(context, input) {
4670
4673
 
4671
4674
  // packages/cli/src/commands/_doctor-checks.ts
4672
4675
  init_runner();
4673
- import { existsSync as existsSync8, readFileSync as readFileSync5 } from "fs";
4674
- import { resolve as resolve15 } from "path";
4676
+ import { existsSync as existsSync9, readFileSync as readFileSync5 } from "fs";
4677
+ import { resolve as resolve16 } from "path";
4675
4678
  import { isSupportedBunVersion, MIN_SUPPORTED_BUN_VERSION } from "@rig/runtime/control-plane/setup-version";
4676
4679
  init__parsers();
4677
4680
  function check(id, label, status, detail, remediation) {
@@ -4712,8 +4715,8 @@ function repoSlugFromConfig(config) {
4712
4715
  function loadFallbackConfig(projectRoot) {
4713
4716
  const candidates = ["rig.config.ts", "rig.config.mts", "rig.config.json"];
4714
4717
  for (const name of candidates) {
4715
- const path = resolve15(projectRoot, name);
4716
- if (!existsSync8(path))
4718
+ const path = resolve16(projectRoot, name);
4719
+ if (!existsSync9(path))
4717
4720
  continue;
4718
4721
  try {
4719
4722
  const source = readFileSync5(path, "utf8");
@@ -4795,7 +4798,7 @@ async function runRigDoctorChecks(options) {
4795
4798
  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`)."));
4796
4799
  const loadedConfig = await loadConfig(projectRoot).catch(() => null);
4797
4800
  const config = loadedConfig ?? loadFallbackConfig(projectRoot);
4798
- const hasConfigFile = ["rig.config.ts", "rig.config.mts", "rig.config.json"].some((name) => existsSync8(resolve15(projectRoot, name)));
4801
+ const hasConfigFile = ["rig.config.ts", "rig.config.mts", "rig.config.json"].some((name) => existsSync9(resolve16(projectRoot, name)));
4799
4802
  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."));
4800
4803
  const taskSourceKind = config?.taskSource?.kind;
4801
4804
  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."));
@@ -4914,20 +4917,20 @@ function parseRepoSlug(value) {
4914
4917
  return { owner: match[1], repo: match[2], slug: `${match[1]}/${match[2]}` };
4915
4918
  }
4916
4919
  function ensureRigPrivateDirs(projectRoot) {
4917
- const rigDir = resolve16(projectRoot, ".rig");
4918
- mkdirSync6(resolve16(rigDir, "state"), { recursive: true });
4919
- mkdirSync6(resolve16(rigDir, "logs"), { recursive: true });
4920
- mkdirSync6(resolve16(rigDir, "runs"), { recursive: true });
4921
- mkdirSync6(resolve16(rigDir, "tmp"), { recursive: true });
4922
- mkdirSync6(resolve16(projectRoot, "artifacts"), { recursive: true });
4923
- const taskConfigPath = resolve16(rigDir, "task-config.json");
4924
- if (!existsSync9(taskConfigPath))
4920
+ const rigDir = resolve17(projectRoot, ".rig");
4921
+ mkdirSync6(resolve17(rigDir, "state"), { recursive: true });
4922
+ mkdirSync6(resolve17(rigDir, "logs"), { recursive: true });
4923
+ mkdirSync6(resolve17(rigDir, "runs"), { recursive: true });
4924
+ mkdirSync6(resolve17(rigDir, "tmp"), { recursive: true });
4925
+ mkdirSync6(resolve17(projectRoot, "artifacts"), { recursive: true });
4926
+ const taskConfigPath = resolve17(rigDir, "task-config.json");
4927
+ if (!existsSync10(taskConfigPath))
4925
4928
  writeFileSync5(taskConfigPath, `{}
4926
4929
  `, "utf-8");
4927
4930
  }
4928
4931
  function ensureGitignoreEntries(projectRoot) {
4929
- const path = resolve16(projectRoot, ".gitignore");
4930
- const existing = existsSync9(path) ? readFileSync6(path, "utf8") : "";
4932
+ const path = resolve17(projectRoot, ".gitignore");
4933
+ const existing = existsSync10(path) ? readFileSync6(path, "utf8") : "";
4931
4934
  const entries = [".rig/state/", ".rig/logs/", ".rig/runs/", ".rig/tmp/"];
4932
4935
  const missing = entries.filter((entry) => !existing.split(/\r?\n/).includes(entry));
4933
4936
  if (missing.length === 0)
@@ -4940,14 +4943,14 @@ function ensureGitignoreEntries(projectRoot) {
4940
4943
  `, "utf8");
4941
4944
  }
4942
4945
  function ensureRigConfigPackageDependencies(projectRoot) {
4943
- const path = resolve16(projectRoot, "package.json");
4944
- const existing = existsSync9(path) ? JSON.parse(readFileSync6(path, "utf8")) : {};
4946
+ const path = resolve17(projectRoot, "package.json");
4947
+ const existing = existsSync10(path) ? JSON.parse(readFileSync6(path, "utf8")) : {};
4945
4948
  const devDependencies = existing.devDependencies && typeof existing.devDependencies === "object" && !Array.isArray(existing.devDependencies) ? { ...existing.devDependencies } : {};
4946
4949
  for (const [name, spec] of Object.entries(RIG_CONFIG_DEV_DEPENDENCIES)) {
4947
4950
  devDependencies[name] = spec;
4948
4951
  }
4949
4952
  const next = {
4950
- ...existsSync9(path) ? existing : { name: "rig-project", private: true },
4953
+ ...existsSync10(path) ? existing : { name: "rig-project", private: true },
4951
4954
  devDependencies
4952
4955
  };
4953
4956
  writeFileSync5(path, `${JSON.stringify(next, null, 2)}
@@ -5199,7 +5202,7 @@ async function promptGitHubProjectConfig(context, prompts, repoSlug, githubToken
5199
5202
  };
5200
5203
  }
5201
5204
  function sleep2(ms) {
5202
- return new Promise((resolve17) => setTimeout(resolve17, ms));
5205
+ return new Promise((resolve18) => setTimeout(resolve18, ms));
5203
5206
  }
5204
5207
  function positiveIntFromEnv(name, fallback) {
5205
5208
  const value = Number.parseInt(process.env[name] ?? "", 10);
@@ -5228,7 +5231,7 @@ function remoteGitHubAuthMetadata(payload) {
5228
5231
  };
5229
5232
  }
5230
5233
  function writeRemoteGitHubAuthState(projectRoot, input) {
5231
- writeFileSync5(resolve16(projectRoot, ".rig", "state", "github-auth.json"), `${JSON.stringify({
5234
+ writeFileSync5(resolve17(projectRoot, ".rig", "state", "github-auth.json"), `${JSON.stringify({
5232
5235
  authenticated: true,
5233
5236
  source: input.source,
5234
5237
  storedOnServer: true,
@@ -5285,9 +5288,9 @@ async function runControlPlaneInit(context, options) {
5285
5288
  });
5286
5289
  ensureRigPrivateDirs(projectRoot);
5287
5290
  ensureGitignoreEntries(projectRoot);
5288
- const configTsPath = resolve16(projectRoot, "rig.config.ts");
5289
- const configJsonPath = resolve16(projectRoot, "rig.config.json");
5290
- const configExists = existsSync9(configTsPath) || existsSync9(configJsonPath);
5291
+ const configTsPath = resolve17(projectRoot, "rig.config.ts");
5292
+ const configJsonPath = resolve17(projectRoot, "rig.config.json");
5293
+ const configExists = existsSync10(configTsPath) || existsSync10(configJsonPath);
5291
5294
  if (!options.privateStateOnly) {
5292
5295
  if (configExists && !options.repair) {
5293
5296
  if (context.outputMode !== "json")
@@ -5303,7 +5306,7 @@ async function runControlPlaneInit(context, options) {
5303
5306
  }
5304
5307
  ensureRigConfigPackageDependencies(projectRoot);
5305
5308
  }
5306
- writeFileSync5(resolve16(projectRoot, ".rig", "state", "project-link.json"), `${JSON.stringify({ repoSlug: repo.slug, connection: connectionAlias, linkedAt: new Date().toISOString() }, null, 2)}
5309
+ writeFileSync5(resolve17(projectRoot, ".rig", "state", "project-link.json"), `${JSON.stringify({ repoSlug: repo.slug, connection: connectionAlias, linkedAt: new Date().toISOString() }, null, 2)}
5307
5310
  `, "utf8");
5308
5311
  const checkout = checkoutForInit(projectRoot, serverKind, options.remoteCheckout);
5309
5312
  let uploadedSnapshot = null;
@@ -5499,7 +5502,7 @@ function parseInitOptions(args) {
5499
5502
  async function runInteractiveControlPlaneInit(context, prompts) {
5500
5503
  prompts.intro?.("Initialize a Rig control-plane project");
5501
5504
  const projectRoot = context.projectRoot;
5502
- const existingConfig = existsSync9(resolve16(projectRoot, "rig.config.ts")) || existsSync9(resolve16(projectRoot, "rig.config.json"));
5505
+ const existingConfig = existsSync10(resolve17(projectRoot, "rig.config.ts")) || existsSync10(resolve17(projectRoot, "rig.config.json"));
5503
5506
  let repair = false;
5504
5507
  let privateStateOnly = false;
5505
5508
  if (existingConfig) {
@@ -5803,7 +5806,7 @@ async function executeDoctor(context, args) {
5803
5806
  // packages/cli/src/commands/_run-driver-helpers.ts
5804
5807
  init_runner();
5805
5808
  import { readFileSync as readFileSync7 } from "fs";
5806
- import { resolve as resolve17 } from "path";
5809
+ import { resolve as resolve18 } from "path";
5807
5810
  import {
5808
5811
  appendJsonlRecord as appendJsonlRecord2,
5809
5812
  readAuthorityRun as readAuthorityRun2,
@@ -5823,7 +5826,7 @@ function patchAuthorityRun(projectRoot, runId, patch) {
5823
5826
  ...patch,
5824
5827
  updatedAt: new Date().toISOString()
5825
5828
  };
5826
- writeJsonFile4(resolve17(resolveAuthorityRunDir3(projectRoot, runId), "run.json"), next);
5829
+ writeJsonFile4(resolve18(resolveAuthorityRunDir3(projectRoot, runId), "run.json"), next);
5827
5830
  return next;
5828
5831
  }
5829
5832
  function touchAuthorityRun(projectRoot, runId) {
@@ -5831,21 +5834,21 @@ function touchAuthorityRun(projectRoot, runId) {
5831
5834
  if (!current) {
5832
5835
  return;
5833
5836
  }
5834
- writeJsonFile4(resolve17(resolveAuthorityRunDir3(projectRoot, runId), "run.json"), {
5837
+ writeJsonFile4(resolve18(resolveAuthorityRunDir3(projectRoot, runId), "run.json"), {
5835
5838
  ...current,
5836
5839
  updatedAt: new Date().toISOString()
5837
5840
  });
5838
5841
  }
5839
5842
  function appendRunTimeline(projectRoot, runId, value) {
5840
- appendJsonlRecord2(resolve17(resolveAuthorityRunDir3(projectRoot, runId), "timeline.jsonl"), value);
5843
+ appendJsonlRecord2(resolve18(resolveAuthorityRunDir3(projectRoot, runId), "timeline.jsonl"), value);
5841
5844
  touchAuthorityRun(projectRoot, runId);
5842
5845
  }
5843
5846
  function appendRunLog(projectRoot, runId, value) {
5844
- appendJsonlRecord2(resolve17(resolveAuthorityRunDir3(projectRoot, runId), "logs.jsonl"), value);
5847
+ appendJsonlRecord2(resolve18(resolveAuthorityRunDir3(projectRoot, runId), "logs.jsonl"), value);
5845
5848
  touchAuthorityRun(projectRoot, runId);
5846
5849
  }
5847
5850
  function appendRunAction(projectRoot, runId, value) {
5848
- appendJsonlRecord2(resolve17(resolveAuthorityRunDir3(projectRoot, runId), "timeline.jsonl"), {
5851
+ appendJsonlRecord2(resolve18(resolveAuthorityRunDir3(projectRoot, runId), "timeline.jsonl"), {
5849
5852
  id: value.id,
5850
5853
  type: "action",
5851
5854
  actionType: value.actionType,
@@ -6030,8 +6033,8 @@ function renderSourceScopeValidation(task, validation) {
6030
6033
 
6031
6034
  // packages/cli/src/commands/inspect.ts
6032
6035
  init_runner();
6033
- import { existsSync as existsSync10, readFileSync as readFileSync8 } from "fs";
6034
- import { resolve as resolve18 } from "path";
6036
+ import { existsSync as existsSync11, readFileSync as readFileSync8 } from "fs";
6037
+ import { resolve as resolve19 } from "path";
6035
6038
  import {
6036
6039
  listAuthorityRuns as listAuthorityRuns2,
6037
6040
  readAuthorityRun as readAuthorityRun3,
@@ -6052,8 +6055,8 @@ async function executeInspect(context, args) {
6052
6055
  if (!latestRun) {
6053
6056
  throw new CliError2(`No runs found for ${requiredTask}.`);
6054
6057
  }
6055
- const logsPath = resolve18(resolveAuthorityRunDir4(context.projectRoot, latestRun.runId), "logs.jsonl");
6056
- if (!existsSync10(logsPath)) {
6058
+ const logsPath = resolve19(resolveAuthorityRunDir4(context.projectRoot, latestRun.runId), "logs.jsonl");
6059
+ if (!existsSync11(logsPath)) {
6057
6060
  throw new CliError2(`No logs found for run ${latestRun.runId}.`);
6058
6061
  }
6059
6062
  await context.runCommand(["cat", logsPath]);
@@ -6063,7 +6066,7 @@ async function executeInspect(context, args) {
6063
6066
  const { value: task, rest: remaining } = takeOption(rest, "--task");
6064
6067
  requireNoExtraArgs(remaining, "rig inspect artifacts --task <task-id>");
6065
6068
  const requiredTask = requireTask(task, "rig inspect artifacts --task <task-id>");
6066
- const artifactRoot = resolveTaskArtifactDirs(context.projectRoot, requiredTask).find((path) => existsSync10(path));
6069
+ const artifactRoot = resolveTaskArtifactDirs(context.projectRoot, requiredTask).find((path) => existsSync11(path));
6067
6070
  if (!artifactRoot) {
6068
6071
  throw new CliError2(`No artifacts found for ${requiredTask}.`);
6069
6072
  }
@@ -6120,7 +6123,7 @@ async function executeInspect(context, args) {
6120
6123
  case "failures": {
6121
6124
  requireNoExtraArgs(rest, "rig inspect failures");
6122
6125
  const failed = resolveHarnessPaths2(context.projectRoot).failedApproachesPath;
6123
- if (!existsSync10(failed)) {
6126
+ if (!existsSync11(failed)) {
6124
6127
  console.log("No failures recorded.");
6125
6128
  } else {
6126
6129
  process.stdout.write(readFileSync8(failed, "utf-8"));
@@ -6140,8 +6143,8 @@ async function executeInspect(context, args) {
6140
6143
  return { ok: true, group: "inspect", command };
6141
6144
  case "audit": {
6142
6145
  requireNoExtraArgs(rest, "rig inspect audit");
6143
- const auditPath = resolve18(resolveHarnessPaths2(context.projectRoot).logsDir, "audit.jsonl");
6144
- if (!existsSync10(auditPath)) {
6146
+ const auditPath = resolve19(resolveHarnessPaths2(context.projectRoot).logsDir, "audit.jsonl");
6147
+ if (!existsSync11(auditPath)) {
6145
6148
  console.log("No audit log found.");
6146
6149
  } else {
6147
6150
  const lines = readFileSync8(auditPath, "utf-8").split(/\r?\n/).filter(Boolean).slice(-20);
@@ -7293,7 +7296,7 @@ async function connectWorkerStream(options, ctx, state) {
7293
7296
  const buffered = [];
7294
7297
  const wsUrl = await buildRunPiEventsWebSocketUrl(options.context, options.runId);
7295
7298
  const socket = new WebSocket(wsUrl);
7296
- const closePromise = new Promise((resolve19) => {
7299
+ const closePromise = new Promise((resolve20) => {
7297
7300
  socket.onopen = () => {
7298
7301
  state.wsConnected = true;
7299
7302
  state.status = "live worker Pi WebSocket connected";
@@ -7318,7 +7321,7 @@ async function connectWorkerStream(options, ctx, state) {
7318
7321
  state.wsConnected = false;
7319
7322
  state.status = "worker Pi WebSocket disconnected";
7320
7323
  updatePiUi(ctx, state);
7321
- resolve19();
7324
+ resolve20();
7322
7325
  };
7323
7326
  });
7324
7327
  try {
@@ -7354,11 +7357,11 @@ async function connectWorkerStream(options, ctx, state) {
7354
7357
  function createRemoteBashOperations(options, state, excludeFromContext) {
7355
7358
  return {
7356
7359
  exec(command, _cwd, execOptions) {
7357
- return new Promise((resolve19, reject) => {
7360
+ return new Promise((resolve20, reject) => {
7358
7361
  const pending = {
7359
7362
  command,
7360
7363
  onData: execOptions.onData,
7361
- resolve: resolve19,
7364
+ resolve: resolve20,
7362
7365
  reject,
7363
7366
  sawChunk: false
7364
7367
  };
@@ -8169,7 +8172,7 @@ async function executeServer(context, args, options) {
8169
8172
  init_runner();
8170
8173
  import { readFileSync as readFileSync9 } from "fs";
8171
8174
  import { spawnSync as spawnSync3 } from "child_process";
8172
- import { resolve as resolve19 } from "path";
8175
+ import { resolve as resolve20 } from "path";
8173
8176
  import { cancel as cancel4, confirm as confirm2, isCancel as isCancel4 } from "@clack/prompts";
8174
8177
  import {
8175
8178
  taskArtifactDir,
@@ -8878,7 +8881,7 @@ async function executeTask(context, args, options) {
8878
8881
  const fileFlag = takeOption(rest.slice(1), "--file");
8879
8882
  let content;
8880
8883
  if (fileFlag.value) {
8881
- content = readFileSync9(resolve19(context.projectRoot, fileFlag.value), "utf-8");
8884
+ content = readFileSync9(resolve20(context.projectRoot, fileFlag.value), "utf-8");
8882
8885
  } else {
8883
8886
  content = await readStdin();
8884
8887
  }
@@ -9112,8 +9115,8 @@ async function executeTask(context, args, options) {
9112
9115
 
9113
9116
  // packages/cli/src/commands/task-run-driver.ts
9114
9117
  init_runner();
9115
- import { copyFileSync as copyFileSync3, existsSync as existsSync11, mkdirSync as mkdirSync7, readFileSync as readFileSync10, statSync as statSync2, writeFileSync as writeFileSync6 } from "fs";
9116
- import { resolve as resolve20 } from "path";
9118
+ import { copyFileSync as copyFileSync3, existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync10, statSync as statSync2, writeFileSync as writeFileSync6 } from "fs";
9119
+ import { resolve as resolve21 } from "path";
9117
9120
  import { spawn as spawn2, spawnSync as spawnSync4 } from "child_process";
9118
9121
  import { createInterface as createLineInterface } from "readline";
9119
9122
  import { loadConfig as loadConfig2 } from "@rig/core/load-config";
@@ -9196,12 +9199,12 @@ function copyUntrackedDirtyFiles(sourceRoot, targetRoot) {
9196
9199
  return 0;
9197
9200
  let copied = 0;
9198
9201
  for (const relativePath of listed.stdout.split("\x00").filter(Boolean)) {
9199
- const sourcePath = resolve20(sourceRoot, relativePath);
9200
- const targetPath = resolve20(targetRoot, relativePath);
9202
+ const sourcePath = resolve21(sourceRoot, relativePath);
9203
+ const targetPath = resolve21(targetRoot, relativePath);
9201
9204
  try {
9202
9205
  if (!statSync2(sourcePath).isFile())
9203
9206
  continue;
9204
- mkdirSync7(resolve20(targetPath, ".."), { recursive: true });
9207
+ mkdirSync7(resolve21(targetPath, ".."), { recursive: true });
9205
9208
  copyFileSync3(sourcePath, targetPath);
9206
9209
  copied += 1;
9207
9210
  } catch {}
@@ -9240,7 +9243,7 @@ function buildDirtyBaselineHandshakeEnv(input) {
9240
9243
  return { RIG_BASELINE_MODE: input.baselineMode ?? "head" };
9241
9244
  return {
9242
9245
  RIG_BASELINE_MODE: "dirty-snapshot",
9243
- RIG_DIRTY_BASELINE_READY_FILE: resolve20(input.projectRoot, ".rig", "runs", input.runId, "dirty-baseline.ready.json")
9246
+ RIG_DIRTY_BASELINE_READY_FILE: resolve21(input.projectRoot, ".rig", "runs", input.runId, "dirty-baseline.ready.json")
9244
9247
  };
9245
9248
  }
9246
9249
  function positiveInt(value, fallback) {
@@ -9351,9 +9354,9 @@ function createCommandRunner(binary) {
9351
9354
  const stderrChunks = [];
9352
9355
  child.stdout.on("data", (chunk) => stdoutChunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk))));
9353
9356
  child.stderr.on("data", (chunk) => stderrChunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk))));
9354
- return await new Promise((resolve21) => {
9355
- child.once("error", (error) => resolve21({ exitCode: 1, stderr: error.message }));
9356
- child.once("close", (code) => resolve21({
9357
+ return await new Promise((resolve22) => {
9358
+ child.once("error", (error) => resolve22({ exitCode: 1, stderr: error.message }));
9359
+ child.once("close", (code) => resolve22({
9357
9360
  exitCode: code ?? 1,
9358
9361
  stdout: Buffer.concat(stdoutChunks).toString("utf8"),
9359
9362
  stderr: Buffer.concat(stderrChunks).toString("utf8")
@@ -9427,7 +9430,7 @@ async function runTaskRunPostValidationLifecycle(input) {
9427
9430
  config,
9428
9431
  sourceTask: input.sourceTask,
9429
9432
  uploadedSnapshot: input.uploadedSnapshot,
9430
- artifactRoot: resolve20(input.projectRoot, "artifacts", taskId3),
9433
+ artifactRoot: resolve21(input.projectRoot, "artifacts", taskId3),
9431
9434
  command: ghCommand,
9432
9435
  gitCommand,
9433
9436
  steerPi,
@@ -9557,7 +9560,7 @@ function summarizeValidationFailure(projectRoot, taskId3) {
9557
9560
  return null;
9558
9561
  }
9559
9562
  for (const artifactDir of resolveTaskArtifactDirs2(projectRoot, taskId3)) {
9560
- const summary = readJsonFile3(resolve20(artifactDir, "validation-summary.json"), null);
9563
+ const summary = readJsonFile3(resolve21(artifactDir, "validation-summary.json"), null);
9561
9564
  if (!summary || summary.status !== "fail") {
9562
9565
  continue;
9563
9566
  }
@@ -9638,9 +9641,9 @@ function readTaskRunAcceptedArtifactState(input) {
9638
9641
  if (!input.taskId || !input.workspaceDir) {
9639
9642
  return { accepted: false, reason: null };
9640
9643
  }
9641
- const artifactDir = resolve20(input.workspaceDir, "artifacts", input.taskId);
9642
- const reviewStatusPath = resolve20(artifactDir, "review-status.txt");
9643
- const taskResultPath = resolve20(artifactDir, "task-result.json");
9644
+ const artifactDir = resolve21(input.workspaceDir, "artifacts", input.taskId);
9645
+ const reviewStatusPath = resolve21(artifactDir, "review-status.txt");
9646
+ const taskResultPath = resolve21(artifactDir, "task-result.json");
9644
9647
  const reviewStatus = readTaskRunReviewStatus(reviewStatusPath);
9645
9648
  if (reviewStatus !== "APPROVED") {
9646
9649
  return { accepted: false, reason: null };
@@ -9677,12 +9680,12 @@ function resolveTaskRunRetryContext(input) {
9677
9680
  if (!input.taskId || !input.workspaceDir) {
9678
9681
  return { shouldRetry: false, failureDetail: null, nextPrompt: null };
9679
9682
  }
9680
- const artifactDir = resolve20(input.workspaceDir, "artifacts", input.taskId);
9681
- const reviewStatePath = resolve20(artifactDir, "review-state.json");
9682
- const reviewFeedbackPath = resolve20(artifactDir, "review-feedback.md");
9683
- const reviewStatusPath = resolve20(artifactDir, "review-status.txt");
9684
- const failedApproachesPath = resolve20(input.workspaceDir, ".rig", "state", "failed_approaches.md");
9685
- const validationSummaryPath = resolve20(artifactDir, "validation-summary.json");
9683
+ const artifactDir = resolve21(input.workspaceDir, "artifacts", input.taskId);
9684
+ const reviewStatePath = resolve21(artifactDir, "review-state.json");
9685
+ const reviewFeedbackPath = resolve21(artifactDir, "review-feedback.md");
9686
+ const reviewStatusPath = resolve21(artifactDir, "review-status.txt");
9687
+ const failedApproachesPath = resolve21(input.workspaceDir, ".rig", "state", "failed_approaches.md");
9688
+ const validationSummaryPath = resolve21(artifactDir, "validation-summary.json");
9686
9689
  const reviewState = readJsonFile3(reviewStatePath, null);
9687
9690
  const reviewStatus = readTaskRunReviewStatus(reviewStatusPath);
9688
9691
  const reviewRejected = isTaskRunReviewRejected(reviewState);
@@ -9868,7 +9871,7 @@ function appendToolTimelineFromLog(input) {
9868
9871
  });
9869
9872
  }
9870
9873
  function readTaskRunReviewStatus(reviewStatusPath) {
9871
- if (!existsSync11(reviewStatusPath)) {
9874
+ if (!existsSync12(reviewStatusPath)) {
9872
9875
  return null;
9873
9876
  }
9874
9877
  try {
@@ -10086,15 +10089,15 @@ async function executeRigOwnedTaskRun(context, input) {
10086
10089
  const loadedAutomationConfig = await loadTaskRunAutomationConfig(context.projectRoot);
10087
10090
  const automationConfig = input.prMode ? { ...loadedAutomationConfig ?? {}, pr: { ...loadedAutomationConfig?.pr ?? {}, mode: input.prMode } } : loadedAutomationConfig;
10088
10091
  const planningClassification = classifyPlanningNeed({ config: automationConfig, sourceTask });
10089
- const planningArtifactPath = resolve20("artifacts", runtimeTaskId, "implementation-plan.md");
10092
+ const planningArtifactPath = resolve21("artifacts", runtimeTaskId, "implementation-plan.md");
10090
10093
  const persistedPlanning = {
10091
10094
  ...planningClassification,
10092
10095
  classifier: input.runtimeAdapter === "pi" ? "pi-rig-structured-policy" : "rig-structured-policy",
10093
10096
  artifactPath: planningClassification.planningRequired ? planningArtifactPath : null,
10094
10097
  classifiedAt: new Date().toISOString()
10095
10098
  };
10096
- mkdirSync7(resolve20(context.projectRoot, ".rig", "runs", input.runId), { recursive: true });
10097
- writeFileSync6(resolve20(context.projectRoot, ".rig", "runs", input.runId, "planning-classification.json"), `${JSON.stringify(persistedPlanning, null, 2)}
10099
+ mkdirSync7(resolve21(context.projectRoot, ".rig", "runs", input.runId), { recursive: true });
10100
+ writeFileSync6(resolve21(context.projectRoot, ".rig", "runs", input.runId, "planning-classification.json"), `${JSON.stringify(persistedPlanning, null, 2)}
10098
10101
  `, "utf8");
10099
10102
  patchAuthorityRun(context.projectRoot, input.runId, { planning: persistedPlanning });
10100
10103
  prompt = `${prompt}
@@ -10144,7 +10147,7 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
10144
10147
  let verificationStarted = false;
10145
10148
  let reviewStarted = false;
10146
10149
  let latestRuntimeWorkspace = resumeMode && typeof existingRunRecord?.worktreePath === "string" ? existingRunRecord.worktreePath : null;
10147
- let latestSessionDir = resumeMode && typeof existingRunRecord?.sessionPath === "string" ? resolve20(existingRunRecord.sessionPath, "..") : null;
10150
+ let latestSessionDir = resumeMode && typeof existingRunRecord?.sessionPath === "string" ? resolve21(existingRunRecord.sessionPath, "..") : null;
10148
10151
  let latestLogsDir = resumeMode && typeof existingRunRecord?.logRoot === "string" ? existingRunRecord.logRoot : null;
10149
10152
  let latestProviderCommand = null;
10150
10153
  let latestRuntimeBranch = resumeMode && typeof existingRunRecord?.branch === "string" ? existingRunRecord.branch : null;
@@ -10230,10 +10233,10 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
10230
10233
  patchAuthorityRun(context.projectRoot, input.runId, {
10231
10234
  status: "running",
10232
10235
  worktreePath: latestRuntimeWorkspace,
10233
- artifactRoot: latestRuntimeWorkspace && input.taskId ? resolve20(latestRuntimeWorkspace, "artifacts", input.taskId) : null,
10236
+ artifactRoot: latestRuntimeWorkspace && input.taskId ? resolve21(latestRuntimeWorkspace, "artifacts", input.taskId) : null,
10234
10237
  logRoot: latestLogsDir,
10235
- sessionPath: latestSessionDir ? resolve20(latestSessionDir, "session.json") : null,
10236
- sessionLogPath: latestLogsDir ? resolve20(latestLogsDir, "agent-stdout.log") : null,
10238
+ sessionPath: latestSessionDir ? resolve21(latestSessionDir, "session.json") : null,
10239
+ sessionLogPath: latestLogsDir ? resolve21(latestLogsDir, "agent-stdout.log") : null,
10237
10240
  branch: runtimeId
10238
10241
  });
10239
10242
  if (!dirtyBaselineApplied && input.baselineMode === "dirty-snapshot" && latestRuntimeWorkspace) {
@@ -10241,7 +10244,7 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
10241
10244
  const dirty = applyDirtyBaselineSnapshot({ sourceRoot: context.projectRoot, targetRoot: latestRuntimeWorkspace });
10242
10245
  const readyFile = childEnv.RIG_DIRTY_BASELINE_READY_FILE;
10243
10246
  if (readyFile) {
10244
- mkdirSync7(resolve20(readyFile, ".."), { recursive: true });
10247
+ mkdirSync7(resolve21(readyFile, ".."), { recursive: true });
10245
10248
  writeFileSync6(readyFile, `${JSON.stringify({ ...dirty, workspaceDir: latestRuntimeWorkspace, appliedAt: new Date().toISOString() }, null, 2)}
10246
10249
  `, "utf8");
10247
10250
  }
@@ -10626,7 +10629,7 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
10626
10629
  let acceptedArtifactObservedAt = null;
10627
10630
  let acceptedArtifactPollTimer = null;
10628
10631
  let acceptedArtifactKillTimer = null;
10629
- const attemptExit = await new Promise((resolve21) => {
10632
+ const attemptExit = await new Promise((resolve22) => {
10630
10633
  let settled = false;
10631
10634
  const settle = (result) => {
10632
10635
  if (settled)
@@ -10634,7 +10637,7 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
10634
10637
  settled = true;
10635
10638
  if (acceptedArtifactPollTimer)
10636
10639
  clearInterval(acceptedArtifactPollTimer);
10637
- resolve21(result);
10640
+ resolve22(result);
10638
10641
  };
10639
10642
  const pollAcceptedArtifacts = () => {
10640
10643
  const artifactState = readTaskRunAcceptedArtifactState({
@@ -10836,8 +10839,8 @@ Failed to update task source for ${input.taskId ?? runtimeTaskId} to failed: ${e
10836
10839
  }
10837
10840
  if (planningClassification.planningRequired) {
10838
10841
  const planWorkspace = latestRuntimeWorkspace ?? context.projectRoot;
10839
- const expectedPlanPath = resolve20(planWorkspace, planningArtifactPath);
10840
- if (!existsSync11(expectedPlanPath)) {
10842
+ const expectedPlanPath = resolve21(planWorkspace, planningArtifactPath);
10843
+ if (!existsSync12(expectedPlanPath)) {
10841
10844
  const failedAt = new Date().toISOString();
10842
10845
  const failureDetail = `Planning was required (${planningClassification.reason}) but ${planningArtifactPath} was not written before implementation completed.`;
10843
10846
  patchAuthorityRun(context.projectRoot, input.runId, {
@@ -11007,9 +11010,9 @@ Failed to update task source for ${input.taskId ?? runtimeTaskId} to failed: ${e
11007
11010
  });
11008
11011
  emitServerRunEvent({ type: "log", runId: input.runId, title: "Pi PR feedback fix stderr" });
11009
11012
  });
11010
- const exitCode = await new Promise((resolve21) => {
11011
- child.once("error", () => resolve21(1));
11012
- child.once("close", (code) => resolve21(code ?? 1));
11013
+ const exitCode = await new Promise((resolve22) => {
11014
+ child.once("error", () => resolve22(1));
11015
+ child.once("close", (code) => resolve22(code ?? 1));
11013
11016
  });
11014
11017
  for (const pendingLog of flushPendingClaudeToolUseLogs({
11015
11018
  runId: input.runId,
@@ -11151,8 +11154,8 @@ async function executeTest(context, args) {
11151
11154
 
11152
11155
  // packages/cli/src/commands/setup.ts
11153
11156
  init_runner();
11154
- import { existsSync as existsSync12, mkdirSync as mkdirSync8, readdirSync as readdirSync2, writeFileSync as writeFileSync7 } from "fs";
11155
- import { resolve as resolve21 } from "path";
11157
+ import { existsSync as existsSync13, mkdirSync as mkdirSync8, readdirSync as readdirSync2, writeFileSync as writeFileSync7 } from "fs";
11158
+ import { resolve as resolve22 } from "path";
11156
11159
  import { createPluginHost } from "@rig/core";
11157
11160
  import {
11158
11161
  isSupportedBunVersion as isSupportedBunVersion2,
@@ -11210,8 +11213,8 @@ function runSetupInit(projectRoot) {
11210
11213
  mkdirSync8(stateDir, { recursive: true });
11211
11214
  mkdirSync8(logsDir, { recursive: true });
11212
11215
  mkdirSync8(artifactsDir, { recursive: true });
11213
- const failuresPath = resolve21(stateDir, "failed_approaches.md");
11214
- if (!existsSync12(failuresPath)) {
11216
+ const failuresPath = resolve22(stateDir, "failed_approaches.md");
11217
+ if (!existsSync13(failuresPath)) {
11215
11218
  writeFileSync7(failuresPath, `# Failed Approaches
11216
11219
 
11217
11220
  `, "utf-8");
@@ -11229,18 +11232,18 @@ async function runSetupCheck(projectRoot) {
11229
11232
  }
11230
11233
  async function runSetupPreflight(projectRoot) {
11231
11234
  await runSetupCheck(projectRoot);
11232
- const validationRoot = resolve21(resolveControlPlaneDefinitionRoot(projectRoot), "validation");
11233
- if (existsSync12(validationRoot)) {
11235
+ const validationRoot = resolve22(resolveControlPlaneDefinitionRoot(projectRoot), "validation");
11236
+ if (existsSync13(validationRoot)) {
11234
11237
  const validators = readdirSync2(validationRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory());
11235
11238
  for (const validator of validators) {
11236
- const script = resolve21(validationRoot, validator.name, "validate.sh");
11237
- if (existsSync12(script)) {
11239
+ const script = resolve22(validationRoot, validator.name, "validate.sh");
11240
+ if (existsSync13(script)) {
11238
11241
  console.log(`OK: validator script ${script}`);
11239
11242
  }
11240
11243
  }
11241
11244
  }
11242
- const hooksRoot = resolve21(resolveControlPlaneDefinitionRoot(projectRoot), "hooks");
11243
- if (existsSync12(hooksRoot)) {
11245
+ const hooksRoot = resolve22(resolveControlPlaneDefinitionRoot(projectRoot), "hooks");
11246
+ if (existsSync13(hooksRoot)) {
11244
11247
  const hooks = readdirSync2(hooksRoot).filter((name) => name.endsWith(".sh"));
11245
11248
  for (const hook of hooks) {
11246
11249
  console.log(`OK: hook ${hook}`);
@@ -11385,7 +11388,7 @@ var PROJECT_REQUIRED_GROUPS = new Set([
11385
11388
  ]);
11386
11389
  var RIG_CONFIG_FILENAMES = ["rig.config.ts", "rig.config.mts", "rig.config.json"];
11387
11390
  function hasInitializedRigProject(projectRoot) {
11388
- return RIG_CONFIG_FILENAMES.some((name) => existsSync13(resolve22(projectRoot, name))) || existsSync13(resolve22(projectRoot, ".rig"));
11391
+ return RIG_CONFIG_FILENAMES.some((name) => existsSync14(resolve23(projectRoot, name))) || existsSync14(resolve23(projectRoot, ".rig"));
11389
11392
  }
11390
11393
  function requireInitializedRigProject(context, group) {
11391
11394
  if (hasInitializedRigProject(context.projectRoot)) {
@@ -11464,9 +11467,11 @@ ${helpText()}`);
11464
11467
  const path = await import("path");
11465
11468
  const { fileURLToPath } = await import("url");
11466
11469
  const execPath = process.execPath || "";
11470
+ const moduleDir = path.dirname(fileURLToPath(import.meta.url));
11467
11471
  const candidates = [
11468
11472
  execPath ? path.resolve(path.dirname(execPath), "..", "manifest.json") : "",
11469
- path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "package.json"),
11473
+ path.resolve(moduleDir, "..", "package.json"),
11474
+ path.resolve(moduleDir, "..", "..", "package.json"),
11470
11475
  path.resolve(process.cwd(), "packages/cli/package.json")
11471
11476
  ].filter(Boolean);
11472
11477
  for (const candidate of candidates) {