@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/bin/rig.js +205 -200
- package/dist/src/commands/plugin.js +6 -1
- package/dist/src/commands.js +197 -192
- package/dist/src/index.js +205 -200
- package/package.json +6 -6
package/dist/bin/rig.js
CHANGED
|
@@ -356,6 +356,8 @@ __export(exports_plugin, {
|
|
|
356
356
|
resolvePluginCliCommand: () => resolvePluginCliCommand,
|
|
357
357
|
executePlugin: () => executePlugin
|
|
358
358
|
});
|
|
359
|
+
import { existsSync as existsSync4 } from "fs";
|
|
360
|
+
import { resolve as resolve8 } from "path";
|
|
359
361
|
import { buildPluginHostContext } from "@rig/runtime/control-plane/plugin-host-context";
|
|
360
362
|
async function executePlugin(context, args) {
|
|
361
363
|
const [command = "list", ...rest] = args;
|
|
@@ -383,7 +385,8 @@ async function executePlugin(context, args) {
|
|
|
383
385
|
}
|
|
384
386
|
if (context.outputMode === "text") {
|
|
385
387
|
if (declarative.length === 0) {
|
|
386
|
-
|
|
388
|
+
const configExists = ["rig.config.ts", "rig.config.mts", "rig.config.json"].some((name) => existsSync4(resolve8(context.projectRoot, name)));
|
|
389
|
+
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.");
|
|
387
390
|
} else {
|
|
388
391
|
console.log("Plugins (rig.config.ts):");
|
|
389
392
|
for (const p of declarative) {
|
|
@@ -528,9 +531,9 @@ import { loadPolicy as loadPolicy3 } from "@rig/runtime/control-plane/runtime/gu
|
|
|
528
531
|
// packages/cli/src/commands.ts
|
|
529
532
|
init_runner();
|
|
530
533
|
import {
|
|
531
|
-
existsSync as
|
|
534
|
+
existsSync as existsSync15
|
|
532
535
|
} from "fs";
|
|
533
|
-
import { resolve as
|
|
536
|
+
import { resolve as resolve24 } from "path";
|
|
534
537
|
import { readBuildConfig } from "@rig/runtime/build-time-config";
|
|
535
538
|
|
|
536
539
|
// packages/cli/src/commands/browser.ts
|
|
@@ -2652,23 +2655,23 @@ import { ensureProjectMainFreshBeforeRun } from "@rig/runtime/control-plane/proj
|
|
|
2652
2655
|
|
|
2653
2656
|
// packages/cli/src/commands/_connection-state.ts
|
|
2654
2657
|
init_runner();
|
|
2655
|
-
import { existsSync as
|
|
2658
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
2656
2659
|
import { homedir as homedir2 } from "os";
|
|
2657
|
-
import { dirname, resolve as
|
|
2660
|
+
import { dirname, resolve as resolve9 } from "path";
|
|
2658
2661
|
function resolveGlobalConnectionsPath(env = process.env) {
|
|
2659
2662
|
const explicit = env.RIG_CONNECTIONS_FILE?.trim();
|
|
2660
2663
|
if (explicit)
|
|
2661
|
-
return
|
|
2664
|
+
return resolve9(explicit);
|
|
2662
2665
|
const stateDir = env.RIG_GLOBAL_STATE_DIR?.trim();
|
|
2663
2666
|
if (stateDir)
|
|
2664
|
-
return
|
|
2665
|
-
return
|
|
2667
|
+
return resolve9(stateDir, "connections.json");
|
|
2668
|
+
return resolve9(homedir2(), ".rig", "connections.json");
|
|
2666
2669
|
}
|
|
2667
2670
|
function resolveRepoConnectionPath(projectRoot) {
|
|
2668
|
-
return
|
|
2671
|
+
return resolve9(projectRoot, ".rig", "state", "connection.json");
|
|
2669
2672
|
}
|
|
2670
2673
|
function readJsonFile2(path) {
|
|
2671
|
-
if (!
|
|
2674
|
+
if (!existsSync5(path))
|
|
2672
2675
|
return null;
|
|
2673
2676
|
try {
|
|
2674
2677
|
return JSON.parse(readFileSync2(path, "utf8"));
|
|
@@ -2755,8 +2758,8 @@ function resolveSelectedConnection(projectRoot, options = {}) {
|
|
|
2755
2758
|
|
|
2756
2759
|
// packages/cli/src/commands/_server-client.ts
|
|
2757
2760
|
init_runner();
|
|
2758
|
-
import { existsSync as
|
|
2759
|
-
import { resolve as
|
|
2761
|
+
import { existsSync as existsSync6, readFileSync as readFileSync3 } from "fs";
|
|
2762
|
+
import { resolve as resolve10 } from "path";
|
|
2760
2763
|
import { ensureLocalRigServerConnection } from "@rig/runtime/local-server";
|
|
2761
2764
|
var scopedGitHubBearerTokens = new Map;
|
|
2762
2765
|
function cleanToken(value) {
|
|
@@ -2764,12 +2767,12 @@ function cleanToken(value) {
|
|
|
2764
2767
|
return trimmed ? trimmed : null;
|
|
2765
2768
|
}
|
|
2766
2769
|
function setGitHubBearerTokenForCurrentProcess(token, projectRoot) {
|
|
2767
|
-
const scopedKey =
|
|
2770
|
+
const scopedKey = resolve10(projectRoot ?? process.cwd());
|
|
2768
2771
|
scopedGitHubBearerTokens.set(scopedKey, cleanToken(token ?? undefined));
|
|
2769
2772
|
}
|
|
2770
2773
|
function readPrivateRemoteSessionToken(projectRoot) {
|
|
2771
|
-
const path =
|
|
2772
|
-
if (!
|
|
2774
|
+
const path = resolve10(projectRoot, ".rig", "state", "github-auth.json");
|
|
2775
|
+
if (!existsSync6(path))
|
|
2773
2776
|
return null;
|
|
2774
2777
|
try {
|
|
2775
2778
|
const parsed = JSON.parse(readFileSync3(path, "utf8"));
|
|
@@ -2779,7 +2782,7 @@ function readPrivateRemoteSessionToken(projectRoot) {
|
|
|
2779
2782
|
}
|
|
2780
2783
|
}
|
|
2781
2784
|
function readGitHubBearerTokenForRemote(projectRoot) {
|
|
2782
|
-
const scopedKey =
|
|
2785
|
+
const scopedKey = resolve10(projectRoot);
|
|
2783
2786
|
if (scopedGitHubBearerTokens.has(scopedKey))
|
|
2784
2787
|
return scopedGitHubBearerTokens.get(scopedKey) ?? null;
|
|
2785
2788
|
const privateSession = readPrivateRemoteSessionToken(projectRoot);
|
|
@@ -2921,7 +2924,7 @@ async function registerProjectViaServer(context, input) {
|
|
|
2921
2924
|
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
2922
2925
|
}
|
|
2923
2926
|
function sleep(ms) {
|
|
2924
|
-
return new Promise((
|
|
2927
|
+
return new Promise((resolve11) => setTimeout(resolve11, ms));
|
|
2925
2928
|
}
|
|
2926
2929
|
function isRetryableProjectRootSwitchError(error) {
|
|
2927
2930
|
if (!(error instanceof Error))
|
|
@@ -3404,7 +3407,7 @@ async function executeQueue(context, args) {
|
|
|
3404
3407
|
|
|
3405
3408
|
// packages/cli/src/commands/agent.ts
|
|
3406
3409
|
init_runner();
|
|
3407
|
-
import { resolve as
|
|
3410
|
+
import { resolve as resolve12 } from "path";
|
|
3408
3411
|
import {
|
|
3409
3412
|
agentId,
|
|
3410
3413
|
cleanupAgentRuntime,
|
|
@@ -3414,8 +3417,8 @@ import {
|
|
|
3414
3417
|
} from "@rig/runtime/control-plane/runtime/isolation";
|
|
3415
3418
|
|
|
3416
3419
|
// packages/cli/src/commands/_authority-runs.ts
|
|
3417
|
-
import { existsSync as
|
|
3418
|
-
import { resolve as
|
|
3420
|
+
import { existsSync as existsSync7 } from "fs";
|
|
3421
|
+
import { resolve as resolve11 } from "path";
|
|
3419
3422
|
import {
|
|
3420
3423
|
readAuthorityRun,
|
|
3421
3424
|
readJsonlFile as readJsonlFile2,
|
|
@@ -3437,8 +3440,8 @@ function normalizeRuntimeAdapter(value) {
|
|
|
3437
3440
|
return "claude-code";
|
|
3438
3441
|
}
|
|
3439
3442
|
function readLatestBeadRecord(projectRoot, taskId) {
|
|
3440
|
-
const issuesPath =
|
|
3441
|
-
if (!
|
|
3443
|
+
const issuesPath = resolve11(resolveControlPlaneMonorepoRoot(projectRoot), ".beads", "issues.jsonl");
|
|
3444
|
+
if (!existsSync7(issuesPath)) {
|
|
3442
3445
|
return null;
|
|
3443
3446
|
}
|
|
3444
3447
|
let latest = null;
|
|
@@ -3506,7 +3509,7 @@ function upsertAgentAuthorityRun(projectRoot, input) {
|
|
|
3506
3509
|
} else if ("errorText" in next) {
|
|
3507
3510
|
delete next.errorText;
|
|
3508
3511
|
}
|
|
3509
|
-
writeJsonFile3(
|
|
3512
|
+
writeJsonFile3(resolve11(resolveAuthorityRunDir(projectRoot, input.runId), "run.json"), next);
|
|
3510
3513
|
return next;
|
|
3511
3514
|
}
|
|
3512
3515
|
|
|
@@ -3628,10 +3631,10 @@ async function executeAgent(context, args) {
|
|
|
3628
3631
|
status: "running",
|
|
3629
3632
|
startedAt: createdAt,
|
|
3630
3633
|
worktreePath: runtime.workspaceDir,
|
|
3631
|
-
artifactRoot:
|
|
3634
|
+
artifactRoot: resolve12(runtime.workspaceDir, "artifacts", taskId),
|
|
3632
3635
|
logRoot: runtime.logsDir,
|
|
3633
|
-
sessionPath:
|
|
3634
|
-
sessionLogPath:
|
|
3636
|
+
sessionPath: resolve12(runtime.sessionDir, "session.json"),
|
|
3637
|
+
sessionLogPath: resolve12(runtime.logsDir, "agent-stdout.log"),
|
|
3635
3638
|
pid: process.pid
|
|
3636
3639
|
});
|
|
3637
3640
|
const result = await runInAgentRuntime({
|
|
@@ -3651,10 +3654,10 @@ async function executeAgent(context, args) {
|
|
|
3651
3654
|
startedAt: createdAt,
|
|
3652
3655
|
completedAt: failedAt,
|
|
3653
3656
|
worktreePath: runtime.workspaceDir,
|
|
3654
|
-
artifactRoot:
|
|
3657
|
+
artifactRoot: resolve12(runtime.workspaceDir, "artifacts", taskId),
|
|
3655
3658
|
logRoot: runtime.logsDir,
|
|
3656
|
-
sessionPath:
|
|
3657
|
-
sessionLogPath:
|
|
3659
|
+
sessionPath: resolve12(runtime.sessionDir, "session.json"),
|
|
3660
|
+
sessionLogPath: resolve12(runtime.logsDir, "agent-stdout.log"),
|
|
3658
3661
|
pid: process.pid,
|
|
3659
3662
|
errorText: result.stderr ? result.stderr.trim() : `Agent runtime command failed (${result.exitCode})`
|
|
3660
3663
|
});
|
|
@@ -3671,10 +3674,10 @@ ${result.stderr.trim()}` : ""}`, result.exitCode);
|
|
|
3671
3674
|
startedAt: createdAt,
|
|
3672
3675
|
completedAt,
|
|
3673
3676
|
worktreePath: runtime.workspaceDir,
|
|
3674
|
-
artifactRoot:
|
|
3677
|
+
artifactRoot: resolve12(runtime.workspaceDir, "artifacts", taskId),
|
|
3675
3678
|
logRoot: runtime.logsDir,
|
|
3676
|
-
sessionPath:
|
|
3677
|
-
sessionLogPath:
|
|
3679
|
+
sessionPath: resolve12(runtime.sessionDir, "session.json"),
|
|
3680
|
+
sessionLogPath: resolve12(runtime.logsDir, "agent-stdout.log"),
|
|
3678
3681
|
pid: process.pid
|
|
3679
3682
|
});
|
|
3680
3683
|
return {
|
|
@@ -3750,7 +3753,7 @@ init__parsers();
|
|
|
3750
3753
|
import {
|
|
3751
3754
|
chmodSync,
|
|
3752
3755
|
copyFileSync as copyFileSync2,
|
|
3753
|
-
existsSync as
|
|
3756
|
+
existsSync as existsSync8,
|
|
3754
3757
|
mkdirSync as mkdirSync6,
|
|
3755
3758
|
readdirSync,
|
|
3756
3759
|
readlinkSync,
|
|
@@ -3760,7 +3763,7 @@ import {
|
|
|
3760
3763
|
unlinkSync
|
|
3761
3764
|
} from "fs";
|
|
3762
3765
|
import { homedir as homedir3 } from "os";
|
|
3763
|
-
import { resolve as
|
|
3766
|
+
import { resolve as resolve13 } from "path";
|
|
3764
3767
|
import { buildBinary as buildBinary2 } from "@rig/runtime/control-plane/runtime/isolation";
|
|
3765
3768
|
import {
|
|
3766
3769
|
computeRuntimeImageFingerprint,
|
|
@@ -3779,13 +3782,13 @@ async function runQuietBinaryProbe(binaryPath, args, cwd) {
|
|
|
3779
3782
|
|
|
3780
3783
|
// packages/cli/src/commands/dist.ts
|
|
3781
3784
|
function collectRigValidatorBuildTargets(input) {
|
|
3782
|
-
const validatorsRoot =
|
|
3783
|
-
if (!
|
|
3785
|
+
const validatorsRoot = resolve13(input.hostProjectRoot, "packages/runtime/src/control-plane/validators");
|
|
3786
|
+
if (!existsSync8(validatorsRoot))
|
|
3784
3787
|
return [];
|
|
3785
3788
|
const targets = [];
|
|
3786
3789
|
const categories = readdirSync(validatorsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory());
|
|
3787
3790
|
for (const category of categories) {
|
|
3788
|
-
const categoryDir =
|
|
3791
|
+
const categoryDir = resolve13(validatorsRoot, category.name);
|
|
3789
3792
|
for (const entry of readdirSync(categoryDir, { withFileTypes: true })) {
|
|
3790
3793
|
if (!entry.isFile() || !entry.name.endsWith(".ts"))
|
|
3791
3794
|
continue;
|
|
@@ -3794,7 +3797,7 @@ function collectRigValidatorBuildTargets(input) {
|
|
|
3794
3797
|
continue;
|
|
3795
3798
|
targets.push({
|
|
3796
3799
|
source: `packages/runtime/src/control-plane/validators/${category.name}/${entry.name}`,
|
|
3797
|
-
dest:
|
|
3800
|
+
dest: resolve13(input.imageDir, `bin/validators/${category.name}-${check}`),
|
|
3798
3801
|
cwd: input.hostProjectRoot
|
|
3799
3802
|
});
|
|
3800
3803
|
}
|
|
@@ -3803,16 +3806,16 @@ function collectRigValidatorBuildTargets(input) {
|
|
|
3803
3806
|
}
|
|
3804
3807
|
async function findLatestDistBinary(projectRoot) {
|
|
3805
3808
|
const distRoot = resolveControlPlaneHostDistDir(projectRoot);
|
|
3806
|
-
if (!
|
|
3809
|
+
if (!existsSync8(distRoot)) {
|
|
3807
3810
|
return null;
|
|
3808
3811
|
}
|
|
3809
3812
|
const entries = readdirSync(distRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.startsWith("rig-")).map((entry) => ({
|
|
3810
3813
|
name: entry.name,
|
|
3811
|
-
mtimeMs: statSync(
|
|
3814
|
+
mtimeMs: statSync(resolve13(distRoot, entry.name)).mtimeMs
|
|
3812
3815
|
})).sort((a, b) => b.mtimeMs - a.mtimeMs || b.name.localeCompare(a.name));
|
|
3813
3816
|
for (const { name } of entries) {
|
|
3814
|
-
const candidate =
|
|
3815
|
-
if (
|
|
3817
|
+
const candidate = resolve13(distRoot, name, "bin", "rig");
|
|
3818
|
+
if (existsSync8(candidate) && await isRunnableRigBinary(candidate, projectRoot)) {
|
|
3816
3819
|
return candidate;
|
|
3817
3820
|
}
|
|
3818
3821
|
}
|
|
@@ -3824,7 +3827,7 @@ async function isRunnableRigBinary(binaryPath, projectRoot) {
|
|
|
3824
3827
|
async function runDistDoctor(projectRoot) {
|
|
3825
3828
|
const bunPath = Bun.which("bun");
|
|
3826
3829
|
const rigPath = Bun.which("rig");
|
|
3827
|
-
const userBinDir =
|
|
3830
|
+
const userBinDir = resolve13(homedir3(), ".local/bin");
|
|
3828
3831
|
const userBinInPath = (process.env.PATH || "").split(":").filter(Boolean).includes(userBinDir);
|
|
3829
3832
|
let rigRunnable = false;
|
|
3830
3833
|
if (rigPath) {
|
|
@@ -3872,15 +3875,15 @@ async function executeDist(context, args) {
|
|
|
3872
3875
|
let source = await findLatestDistBinary(context.projectRoot);
|
|
3873
3876
|
let buildDir = null;
|
|
3874
3877
|
if (!source) {
|
|
3875
|
-
buildDir =
|
|
3878
|
+
buildDir = resolve13(resolveControlPlaneHostDistDir(context.projectRoot), `rig-install-${Date.now()}`);
|
|
3876
3879
|
await context.runCommand(["bun", "run", "packages/cli/bin/build-rig-binaries.ts", "--output-dir", buildDir]);
|
|
3877
|
-
source =
|
|
3880
|
+
source = resolve13(buildDir, "bin", "rig");
|
|
3878
3881
|
}
|
|
3879
|
-
if (!
|
|
3882
|
+
if (!existsSync8(source)) {
|
|
3880
3883
|
throw new CliError2(`Unable to locate rig binary at ${source}.`, 2);
|
|
3881
3884
|
}
|
|
3882
|
-
const installedPath =
|
|
3883
|
-
if (
|
|
3885
|
+
const installedPath = resolve13(installDir, "rig");
|
|
3886
|
+
if (existsSync8(installedPath)) {
|
|
3884
3887
|
unlinkSync(installedPath);
|
|
3885
3888
|
}
|
|
3886
3889
|
copyFileSync2(source, installedPath);
|
|
@@ -3922,22 +3925,22 @@ async function executeDist(context, args) {
|
|
|
3922
3925
|
requireNoExtraArgs(rest, "rig dist rebuild-agent");
|
|
3923
3926
|
const fp = await computeRuntimeImageFingerprint(context.projectRoot);
|
|
3924
3927
|
const currentId = computeRuntimeImageId(fp);
|
|
3925
|
-
const imagesDir =
|
|
3928
|
+
const imagesDir = resolve13(resolveControlPlaneMonorepoRuntimeDir(context.projectRoot), "images");
|
|
3926
3929
|
mkdirSync6(imagesDir, { recursive: true });
|
|
3927
3930
|
let pruned = 0;
|
|
3928
3931
|
for (const entry of readdirSync(imagesDir, { withFileTypes: true })) {
|
|
3929
3932
|
if (entry.isDirectory() && entry.name !== currentId) {
|
|
3930
|
-
rmSync3(
|
|
3933
|
+
rmSync3(resolve13(imagesDir, entry.name), { recursive: true, force: true });
|
|
3931
3934
|
pruned++;
|
|
3932
3935
|
}
|
|
3933
3936
|
}
|
|
3934
3937
|
if (pruned > 0 && context.outputMode === "text") {
|
|
3935
3938
|
console.log(`Pruned ${pruned} stale image(s).`);
|
|
3936
3939
|
}
|
|
3937
|
-
const imageDir =
|
|
3938
|
-
mkdirSync6(
|
|
3939
|
-
mkdirSync6(
|
|
3940
|
-
mkdirSync6(
|
|
3940
|
+
const imageDir = resolve13(imagesDir, currentId);
|
|
3941
|
+
mkdirSync6(resolve13(imageDir, "bin/hooks"), { recursive: true });
|
|
3942
|
+
mkdirSync6(resolve13(imageDir, "bin/plugins"), { recursive: true });
|
|
3943
|
+
mkdirSync6(resolve13(imageDir, "bin/validators"), { recursive: true });
|
|
3941
3944
|
const hookNames = [
|
|
3942
3945
|
"scope-guard",
|
|
3943
3946
|
"import-guard",
|
|
@@ -3951,25 +3954,25 @@ async function executeDist(context, args) {
|
|
|
3951
3954
|
];
|
|
3952
3955
|
const targets = [];
|
|
3953
3956
|
const hostProjectRoot = process.env.RIG_HOST_PROJECT_ROOT?.trim() || context.projectRoot;
|
|
3954
|
-
targets.push({ source: "packages/runtime/bin/rig-agent.ts", dest:
|
|
3955
|
-
targets.push({ source: "packages/runtime/bin/rig-agent-dispatch.ts", dest:
|
|
3957
|
+
targets.push({ source: "packages/runtime/bin/rig-agent.ts", dest: resolve13(imageDir, "bin/rig-agent"), cwd: hostProjectRoot });
|
|
3958
|
+
targets.push({ source: "packages/runtime/bin/rig-agent-dispatch.ts", dest: resolve13(resolveControlPlaneHostBinDir(context.projectRoot), "rig-agent"), cwd: hostProjectRoot });
|
|
3956
3959
|
for (const hookName of hookNames) {
|
|
3957
3960
|
const src = `packages/runtime/src/control-plane/hooks/${hookName}.ts`;
|
|
3958
|
-
targets.push({ source: src, dest:
|
|
3959
|
-
targets.push({ source: src, dest:
|
|
3961
|
+
targets.push({ source: src, dest: resolve13(imageDir, `bin/hooks/${hookName}`), cwd: hostProjectRoot });
|
|
3962
|
+
targets.push({ source: src, dest: resolve13(resolveControlPlaneHostBinDir(context.projectRoot), `hooks/${hookName}`), cwd: hostProjectRoot });
|
|
3960
3963
|
}
|
|
3961
|
-
const pluginsDir =
|
|
3962
|
-
const binPluginsDir =
|
|
3963
|
-
const validatorsRoot =
|
|
3964
|
-
const binValidatorsDir =
|
|
3964
|
+
const pluginsDir = resolve13(context.projectRoot, "rig/plugins");
|
|
3965
|
+
const binPluginsDir = resolve13(resolveControlPlaneHostBinDir(context.projectRoot), "plugins");
|
|
3966
|
+
const validatorsRoot = resolve13(hostProjectRoot, "packages/runtime/src/control-plane/validators");
|
|
3967
|
+
const binValidatorsDir = resolve13(resolveControlPlaneHostBinDir(context.projectRoot), "validators");
|
|
3965
3968
|
mkdirSync6(binPluginsDir, { recursive: true });
|
|
3966
3969
|
mkdirSync6(binValidatorsDir, { recursive: true });
|
|
3967
|
-
if (
|
|
3970
|
+
if (existsSync8(pluginsDir)) {
|
|
3968
3971
|
for (const entry of readdirSync(pluginsDir, { withFileTypes: true })) {
|
|
3969
3972
|
const m = entry.name.match(/^(.+)\.plugin\.(ts|js|mjs|cjs)$/);
|
|
3970
3973
|
if (!m)
|
|
3971
3974
|
continue;
|
|
3972
|
-
targets.push({ source: `rig/plugins/${entry.name}`, dest:
|
|
3975
|
+
targets.push({ source: `rig/plugins/${entry.name}`, dest: resolve13(imageDir, `bin/plugins/${m[1]}`), cwd: context.projectRoot });
|
|
3973
3976
|
}
|
|
3974
3977
|
}
|
|
3975
3978
|
targets.push(...collectRigValidatorBuildTargets({ contextProjectRoot: context.projectRoot, hostProjectRoot, imageDir }));
|
|
@@ -3980,17 +3983,17 @@ async function executeDist(context, args) {
|
|
|
3980
3983
|
const isValidator = dest.includes("/bin/validators/");
|
|
3981
3984
|
await buildBinary2(source, dest, cwd, isValidator ? { AGENT_BUN_PATH: Bun.which("bun") || "bun" } : { AGENT_PROJECT_ROOT: context.projectRoot });
|
|
3982
3985
|
}
|
|
3983
|
-
if (
|
|
3986
|
+
if (existsSync8(pluginsDir)) {
|
|
3984
3987
|
for (const entry of readdirSync(pluginsDir, { withFileTypes: true })) {
|
|
3985
3988
|
const m = entry.name.match(/^(.+)\.plugin\.(ts|js|mjs|cjs)$/);
|
|
3986
3989
|
if (!m)
|
|
3987
3990
|
continue;
|
|
3988
3991
|
const pluginName = m[1];
|
|
3989
|
-
const imageBin =
|
|
3992
|
+
const imageBin = resolve13(imageDir, `bin/plugins/${pluginName}`);
|
|
3990
3993
|
if (!pluginName)
|
|
3991
3994
|
continue;
|
|
3992
|
-
const symlinkPath =
|
|
3993
|
-
if (
|
|
3995
|
+
const symlinkPath = resolve13(binPluginsDir, pluginName);
|
|
3996
|
+
if (existsSync8(imageBin)) {
|
|
3994
3997
|
try {
|
|
3995
3998
|
unlinkSync(symlinkPath);
|
|
3996
3999
|
} catch {}
|
|
@@ -3998,10 +4001,10 @@ async function executeDist(context, args) {
|
|
|
3998
4001
|
}
|
|
3999
4002
|
}
|
|
4000
4003
|
}
|
|
4001
|
-
if (
|
|
4004
|
+
if (existsSync8(validatorsRoot)) {
|
|
4002
4005
|
const categories = readdirSync(validatorsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory());
|
|
4003
4006
|
for (const category of categories) {
|
|
4004
|
-
const categoryDir =
|
|
4007
|
+
const categoryDir = resolve13(validatorsRoot, category.name);
|
|
4005
4008
|
for (const entry of readdirSync(categoryDir, { withFileTypes: true })) {
|
|
4006
4009
|
if (!entry.isFile() || !entry.name.endsWith(".ts"))
|
|
4007
4010
|
continue;
|
|
@@ -4009,9 +4012,9 @@ async function executeDist(context, args) {
|
|
|
4009
4012
|
if (!check || check === "index" || check === "shared")
|
|
4010
4013
|
continue;
|
|
4011
4014
|
const validatorName = `${category.name}-${check}`;
|
|
4012
|
-
const imageBin =
|
|
4013
|
-
const symlinkPath =
|
|
4014
|
-
if (
|
|
4015
|
+
const imageBin = resolve13(imageDir, `bin/validators/${validatorName}`);
|
|
4016
|
+
const symlinkPath = resolve13(binValidatorsDir, validatorName);
|
|
4017
|
+
if (existsSync8(imageBin)) {
|
|
4015
4018
|
try {
|
|
4016
4019
|
unlinkSync(symlinkPath);
|
|
4017
4020
|
} catch {}
|
|
@@ -4020,18 +4023,18 @@ async function executeDist(context, args) {
|
|
|
4020
4023
|
}
|
|
4021
4024
|
}
|
|
4022
4025
|
}
|
|
4023
|
-
const agentsDir =
|
|
4024
|
-
if (
|
|
4026
|
+
const agentsDir = resolve13(resolveControlPlaneMonorepoRuntimeDir(context.projectRoot), "agents");
|
|
4027
|
+
if (existsSync8(agentsDir)) {
|
|
4025
4028
|
let relinkCount = 0;
|
|
4026
4029
|
for (const agentEntry of readdirSync(agentsDir, { withFileTypes: true })) {
|
|
4027
4030
|
if (!agentEntry.isDirectory())
|
|
4028
4031
|
continue;
|
|
4029
|
-
const agentBinDir =
|
|
4030
|
-
if (!
|
|
4032
|
+
const agentBinDir = resolve13(agentsDir, agentEntry.name, "worktree", ".rig", "bin");
|
|
4033
|
+
if (!existsSync8(agentBinDir))
|
|
4031
4034
|
continue;
|
|
4032
4035
|
const walkDir = (dir) => {
|
|
4033
4036
|
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
4034
|
-
const fullPath =
|
|
4037
|
+
const fullPath = resolve13(dir, entry.name);
|
|
4035
4038
|
if (entry.isDirectory()) {
|
|
4036
4039
|
walkDir(fullPath);
|
|
4037
4040
|
} else if (entry.isSymbolicLink()) {
|
|
@@ -4066,7 +4069,7 @@ async function executeDist(context, args) {
|
|
|
4066
4069
|
// packages/cli/src/commands/inbox.ts
|
|
4067
4070
|
init_runner();
|
|
4068
4071
|
import { writeFileSync as writeFileSync4 } from "fs";
|
|
4069
|
-
import { resolve as
|
|
4072
|
+
import { resolve as resolve14 } from "path";
|
|
4070
4073
|
import {
|
|
4071
4074
|
listAuthorityRuns,
|
|
4072
4075
|
readJsonlFile as readJsonlFile3,
|
|
@@ -4468,7 +4471,7 @@ async function listRemoteInboxRecords(context, kind, filters) {
|
|
|
4468
4471
|
function listLocalInboxRecords(context, kind, filters) {
|
|
4469
4472
|
const fileName = kind === "approvals" ? "approvals.jsonl" : "user-input.jsonl";
|
|
4470
4473
|
const runs = listAuthorityRuns(context.projectRoot).filter((entry) => (!filters.run || entry.runId === filters.run) && (!filters.task || entry.taskId === filters.task));
|
|
4471
|
-
return runs.flatMap((entry) => readJsonlFile3(
|
|
4474
|
+
return runs.flatMap((entry) => readJsonlFile3(resolve14(resolveAuthorityRunDir2(context.projectRoot, entry.runId), fileName)).map((record) => ({
|
|
4472
4475
|
runId: entry.runId,
|
|
4473
4476
|
taskId: entry.taskId ?? undefined,
|
|
4474
4477
|
record
|
|
@@ -4516,7 +4519,7 @@ async function executeInbox(context, args) {
|
|
|
4516
4519
|
if (isRemoteConnectionSelected(context.projectRoot)) {
|
|
4517
4520
|
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);
|
|
4518
4521
|
}
|
|
4519
|
-
const approvalsPath =
|
|
4522
|
+
const approvalsPath = resolve14(resolveAuthorityRunDir2(context.projectRoot, run.value), "approvals.jsonl");
|
|
4520
4523
|
const approvals = readJsonlFile3(approvalsPath);
|
|
4521
4524
|
const resolvedAt = new Date().toISOString();
|
|
4522
4525
|
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);
|
|
@@ -4572,7 +4575,7 @@ async function executeInbox(context, args) {
|
|
|
4572
4575
|
const [key, ...restValue] = entry.split("=");
|
|
4573
4576
|
return [key, restValue.join("=")];
|
|
4574
4577
|
}));
|
|
4575
|
-
const requestsPath =
|
|
4578
|
+
const requestsPath = resolve14(resolveAuthorityRunDir2(context.projectRoot, run.value), "user-input.jsonl");
|
|
4576
4579
|
const requests = readJsonlFile3(requestsPath);
|
|
4577
4580
|
const resolvedAt = new Date().toISOString();
|
|
4578
4581
|
const next = requests.map((entry) => entry.requestId === request.value || entry.id === request.value ? { ...entry, status: "resolved", answers: parsedAnswers, respondedAt: resolvedAt, resolvedAt } : entry);
|
|
@@ -4588,16 +4591,16 @@ async function executeInbox(context, args) {
|
|
|
4588
4591
|
|
|
4589
4592
|
// packages/cli/src/commands/init.ts
|
|
4590
4593
|
init_runner();
|
|
4591
|
-
import { appendFileSync as appendFileSync2, existsSync as
|
|
4594
|
+
import { appendFileSync as appendFileSync2, existsSync as existsSync11, mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
|
|
4592
4595
|
import { spawnSync } from "child_process";
|
|
4593
|
-
import { resolve as
|
|
4596
|
+
import { resolve as resolve18 } from "path";
|
|
4594
4597
|
import { buildRigInitConfigSource } from "@rig/core";
|
|
4595
4598
|
import { listGitHubProjects as listGitHubProjectsDirect, resolveProjectStatusField as resolveProjectStatusFieldDirect } from "@rig/server";
|
|
4596
4599
|
|
|
4597
4600
|
// packages/cli/src/commands/_pi-install.ts
|
|
4598
|
-
import { existsSync as
|
|
4601
|
+
import { existsSync as existsSync9, readFileSync as readFileSync4, rmSync as rmSync4 } from "fs";
|
|
4599
4602
|
import { homedir as homedir4 } from "os";
|
|
4600
|
-
import { resolve as
|
|
4603
|
+
import { resolve as resolve15 } from "path";
|
|
4601
4604
|
var PI_RIG_PACKAGE_NAME = "@h-rig/pi-rig";
|
|
4602
4605
|
var LEGACY_PI_RIG_PACKAGE_NAME = "@rig/pi-rig";
|
|
4603
4606
|
var LEGACY_PI_RIG_MARKER = `// Managed by Rig. Source package: @rig/pi-rig.
|
|
@@ -4613,11 +4616,11 @@ async function defaultCommandRunner(command, options = {}) {
|
|
|
4613
4616
|
return { exitCode, stdout, stderr };
|
|
4614
4617
|
}
|
|
4615
4618
|
function resolvePiRigExtensionPath(homeDir) {
|
|
4616
|
-
return
|
|
4619
|
+
return resolve15(homeDir, ".pi", "agent", "extensions", "pi-rig");
|
|
4617
4620
|
}
|
|
4618
|
-
function resolvePiRigPackageSource(projectRoot, exists =
|
|
4619
|
-
const localPackage =
|
|
4620
|
-
if (exists(
|
|
4621
|
+
function resolvePiRigPackageSource(projectRoot, exists = existsSync9) {
|
|
4622
|
+
const localPackage = resolve15(projectRoot, "packages", "pi-rig");
|
|
4623
|
+
if (exists(resolve15(localPackage, "package.json")))
|
|
4621
4624
|
return localPackage;
|
|
4622
4625
|
return `npm:${PI_RIG_PACKAGE_NAME}`;
|
|
4623
4626
|
}
|
|
@@ -4668,9 +4671,9 @@ async function ensurePiBinaryAvailable(input) {
|
|
|
4668
4671
|
...next.exitCode === 0 ? {} : { error: (next.stderr || next.stdout).trim() || "pi --version failed after install" }
|
|
4669
4672
|
};
|
|
4670
4673
|
}
|
|
4671
|
-
function removeManagedLegacyPiRigBridge(homeDir, exists =
|
|
4674
|
+
function removeManagedLegacyPiRigBridge(homeDir, exists = existsSync9) {
|
|
4672
4675
|
const extensionPath = resolvePiRigExtensionPath(homeDir);
|
|
4673
|
-
const indexPath =
|
|
4676
|
+
const indexPath = resolve15(extensionPath, "index.ts");
|
|
4674
4677
|
if (!exists(indexPath))
|
|
4675
4678
|
return;
|
|
4676
4679
|
try {
|
|
@@ -4690,13 +4693,13 @@ async function checkPiRigInstall(input = {}) {
|
|
|
4690
4693
|
piRig: { ok: true, label: "pi-rig global extension", detail: extensionPath }
|
|
4691
4694
|
};
|
|
4692
4695
|
}
|
|
4693
|
-
const exists = input.exists ??
|
|
4696
|
+
const exists = input.exists ?? existsSync9;
|
|
4694
4697
|
const runner = input.commandRunner ?? defaultCommandRunner;
|
|
4695
4698
|
const piResult = await safeRun(runner, ["pi", "--version"]);
|
|
4696
4699
|
const piListResult = piResult.exitCode === 0 ? await safeRun(runner, ["pi", "list"]) : { exitCode: 1, stdout: "", stderr: "" };
|
|
4697
4700
|
const listedPiRig = piListResult.exitCode === 0 && piListContainsPiRig(`${piListResult.stdout}
|
|
4698
4701
|
${piListResult.stderr}`);
|
|
4699
|
-
const legacyBridge = exists(
|
|
4702
|
+
const legacyBridge = exists(resolve15(extensionPath, "index.ts"));
|
|
4700
4703
|
const hasPiRig = listedPiRig;
|
|
4701
4704
|
return {
|
|
4702
4705
|
extensionPath,
|
|
@@ -4773,7 +4776,7 @@ async function buildPiSetupChecks(input = {}) {
|
|
|
4773
4776
|
|
|
4774
4777
|
// packages/cli/src/commands/_snapshot-upload.ts
|
|
4775
4778
|
import { mkdir, readdir, readFile, writeFile } from "fs/promises";
|
|
4776
|
-
import { dirname as dirname2, resolve as
|
|
4779
|
+
import { dirname as dirname2, resolve as resolve16, relative, sep } from "path";
|
|
4777
4780
|
var SNAPSHOT_ARCHIVE_VERSION = 1;
|
|
4778
4781
|
var SNAPSHOT_ARCHIVE_CONTENT_TYPE = "application/vnd.rig.snapshot+json";
|
|
4779
4782
|
var DEFAULT_EXCLUDED_DIRECTORIES = new Set([
|
|
@@ -4795,15 +4798,15 @@ function assertManifestPath(root, relativePath) {
|
|
|
4795
4798
|
if (!relativePath || relativePath.startsWith("/") || relativePath.includes("\x00")) {
|
|
4796
4799
|
throw new Error(`Invalid snapshot path: ${relativePath}`);
|
|
4797
4800
|
}
|
|
4798
|
-
const resolved =
|
|
4801
|
+
const resolved = resolve16(root, relativePath);
|
|
4799
4802
|
const relativeToRoot = relative(root, resolved);
|
|
4800
|
-
if (relativeToRoot.startsWith("..") || relativeToRoot === ".." ||
|
|
4803
|
+
if (relativeToRoot.startsWith("..") || relativeToRoot === ".." || resolve16(relativeToRoot) === resolved) {
|
|
4801
4804
|
throw new Error(`Snapshot path escapes project root: ${relativePath}`);
|
|
4802
4805
|
}
|
|
4803
4806
|
return resolved;
|
|
4804
4807
|
}
|
|
4805
4808
|
async function buildSnapshotUploadManifest(projectRoot, options = {}) {
|
|
4806
|
-
const root =
|
|
4809
|
+
const root = resolve16(projectRoot);
|
|
4807
4810
|
const excludedDirectories = [...new Set([
|
|
4808
4811
|
...DEFAULT_EXCLUDED_DIRECTORIES,
|
|
4809
4812
|
...options.excludedDirectories ?? []
|
|
@@ -4815,7 +4818,7 @@ async function buildSnapshotUploadManifest(projectRoot, options = {}) {
|
|
|
4815
4818
|
for (const entry of entries) {
|
|
4816
4819
|
if (entry.isDirectory() && excludedSet.has(entry.name))
|
|
4817
4820
|
continue;
|
|
4818
|
-
const fullPath =
|
|
4821
|
+
const fullPath = resolve16(dir, entry.name);
|
|
4819
4822
|
if (entry.isDirectory()) {
|
|
4820
4823
|
await visit(fullPath);
|
|
4821
4824
|
continue;
|
|
@@ -4864,8 +4867,8 @@ async function uploadSnapshotArchiveViaServer(context, input) {
|
|
|
4864
4867
|
|
|
4865
4868
|
// packages/cli/src/commands/_doctor-checks.ts
|
|
4866
4869
|
init_runner();
|
|
4867
|
-
import { existsSync as
|
|
4868
|
-
import { resolve as
|
|
4870
|
+
import { existsSync as existsSync10, readFileSync as readFileSync5 } from "fs";
|
|
4871
|
+
import { resolve as resolve17 } from "path";
|
|
4869
4872
|
import { isSupportedBunVersion, MIN_SUPPORTED_BUN_VERSION } from "@rig/runtime/control-plane/setup-version";
|
|
4870
4873
|
init__parsers();
|
|
4871
4874
|
function check(id, label, status, detail, remediation) {
|
|
@@ -4906,8 +4909,8 @@ function repoSlugFromConfig(config) {
|
|
|
4906
4909
|
function loadFallbackConfig(projectRoot) {
|
|
4907
4910
|
const candidates = ["rig.config.ts", "rig.config.mts", "rig.config.json"];
|
|
4908
4911
|
for (const name of candidates) {
|
|
4909
|
-
const path =
|
|
4910
|
-
if (!
|
|
4912
|
+
const path = resolve17(projectRoot, name);
|
|
4913
|
+
if (!existsSync10(path))
|
|
4911
4914
|
continue;
|
|
4912
4915
|
try {
|
|
4913
4916
|
const source = readFileSync5(path, "utf8");
|
|
@@ -4989,7 +4992,7 @@ async function runRigDoctorChecks(options) {
|
|
|
4989
4992
|
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`)."));
|
|
4990
4993
|
const loadedConfig = await loadConfig(projectRoot).catch(() => null);
|
|
4991
4994
|
const config = loadedConfig ?? loadFallbackConfig(projectRoot);
|
|
4992
|
-
const hasConfigFile = ["rig.config.ts", "rig.config.mts", "rig.config.json"].some((name) =>
|
|
4995
|
+
const hasConfigFile = ["rig.config.ts", "rig.config.mts", "rig.config.json"].some((name) => existsSync10(resolve17(projectRoot, name)));
|
|
4993
4996
|
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."));
|
|
4994
4997
|
const taskSourceKind = config?.taskSource?.kind;
|
|
4995
4998
|
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."));
|
|
@@ -5108,20 +5111,20 @@ function parseRepoSlug(value) {
|
|
|
5108
5111
|
return { owner: match[1], repo: match[2], slug: `${match[1]}/${match[2]}` };
|
|
5109
5112
|
}
|
|
5110
5113
|
function ensureRigPrivateDirs(projectRoot) {
|
|
5111
|
-
const rigDir =
|
|
5112
|
-
mkdirSync7(
|
|
5113
|
-
mkdirSync7(
|
|
5114
|
-
mkdirSync7(
|
|
5115
|
-
mkdirSync7(
|
|
5116
|
-
mkdirSync7(
|
|
5117
|
-
const taskConfigPath =
|
|
5118
|
-
if (!
|
|
5114
|
+
const rigDir = resolve18(projectRoot, ".rig");
|
|
5115
|
+
mkdirSync7(resolve18(rigDir, "state"), { recursive: true });
|
|
5116
|
+
mkdirSync7(resolve18(rigDir, "logs"), { recursive: true });
|
|
5117
|
+
mkdirSync7(resolve18(rigDir, "runs"), { recursive: true });
|
|
5118
|
+
mkdirSync7(resolve18(rigDir, "tmp"), { recursive: true });
|
|
5119
|
+
mkdirSync7(resolve18(projectRoot, "artifacts"), { recursive: true });
|
|
5120
|
+
const taskConfigPath = resolve18(rigDir, "task-config.json");
|
|
5121
|
+
if (!existsSync11(taskConfigPath))
|
|
5119
5122
|
writeFileSync5(taskConfigPath, `{}
|
|
5120
5123
|
`, "utf-8");
|
|
5121
5124
|
}
|
|
5122
5125
|
function ensureGitignoreEntries(projectRoot) {
|
|
5123
|
-
const path =
|
|
5124
|
-
const existing =
|
|
5126
|
+
const path = resolve18(projectRoot, ".gitignore");
|
|
5127
|
+
const existing = existsSync11(path) ? readFileSync6(path, "utf8") : "";
|
|
5125
5128
|
const entries = [".rig/state/", ".rig/logs/", ".rig/runs/", ".rig/tmp/"];
|
|
5126
5129
|
const missing = entries.filter((entry) => !existing.split(/\r?\n/).includes(entry));
|
|
5127
5130
|
if (missing.length === 0)
|
|
@@ -5134,14 +5137,14 @@ function ensureGitignoreEntries(projectRoot) {
|
|
|
5134
5137
|
`, "utf8");
|
|
5135
5138
|
}
|
|
5136
5139
|
function ensureRigConfigPackageDependencies(projectRoot) {
|
|
5137
|
-
const path =
|
|
5138
|
-
const existing =
|
|
5140
|
+
const path = resolve18(projectRoot, "package.json");
|
|
5141
|
+
const existing = existsSync11(path) ? JSON.parse(readFileSync6(path, "utf8")) : {};
|
|
5139
5142
|
const devDependencies = existing.devDependencies && typeof existing.devDependencies === "object" && !Array.isArray(existing.devDependencies) ? { ...existing.devDependencies } : {};
|
|
5140
5143
|
for (const [name, spec] of Object.entries(RIG_CONFIG_DEV_DEPENDENCIES)) {
|
|
5141
5144
|
devDependencies[name] = spec;
|
|
5142
5145
|
}
|
|
5143
5146
|
const next = {
|
|
5144
|
-
...
|
|
5147
|
+
...existsSync11(path) ? existing : { name: "rig-project", private: true },
|
|
5145
5148
|
devDependencies
|
|
5146
5149
|
};
|
|
5147
5150
|
writeFileSync5(path, `${JSON.stringify(next, null, 2)}
|
|
@@ -5393,7 +5396,7 @@ async function promptGitHubProjectConfig(context, prompts, repoSlug, githubToken
|
|
|
5393
5396
|
};
|
|
5394
5397
|
}
|
|
5395
5398
|
function sleep2(ms) {
|
|
5396
|
-
return new Promise((
|
|
5399
|
+
return new Promise((resolve19) => setTimeout(resolve19, ms));
|
|
5397
5400
|
}
|
|
5398
5401
|
function positiveIntFromEnv(name, fallback) {
|
|
5399
5402
|
const value = Number.parseInt(process.env[name] ?? "", 10);
|
|
@@ -5422,7 +5425,7 @@ function remoteGitHubAuthMetadata(payload) {
|
|
|
5422
5425
|
};
|
|
5423
5426
|
}
|
|
5424
5427
|
function writeRemoteGitHubAuthState(projectRoot, input) {
|
|
5425
|
-
writeFileSync5(
|
|
5428
|
+
writeFileSync5(resolve18(projectRoot, ".rig", "state", "github-auth.json"), `${JSON.stringify({
|
|
5426
5429
|
authenticated: true,
|
|
5427
5430
|
source: input.source,
|
|
5428
5431
|
storedOnServer: true,
|
|
@@ -5479,9 +5482,9 @@ async function runControlPlaneInit(context, options) {
|
|
|
5479
5482
|
});
|
|
5480
5483
|
ensureRigPrivateDirs(projectRoot);
|
|
5481
5484
|
ensureGitignoreEntries(projectRoot);
|
|
5482
|
-
const configTsPath =
|
|
5483
|
-
const configJsonPath =
|
|
5484
|
-
const configExists =
|
|
5485
|
+
const configTsPath = resolve18(projectRoot, "rig.config.ts");
|
|
5486
|
+
const configJsonPath = resolve18(projectRoot, "rig.config.json");
|
|
5487
|
+
const configExists = existsSync11(configTsPath) || existsSync11(configJsonPath);
|
|
5485
5488
|
if (!options.privateStateOnly) {
|
|
5486
5489
|
if (configExists && !options.repair) {
|
|
5487
5490
|
if (context.outputMode !== "json")
|
|
@@ -5497,7 +5500,7 @@ async function runControlPlaneInit(context, options) {
|
|
|
5497
5500
|
}
|
|
5498
5501
|
ensureRigConfigPackageDependencies(projectRoot);
|
|
5499
5502
|
}
|
|
5500
|
-
writeFileSync5(
|
|
5503
|
+
writeFileSync5(resolve18(projectRoot, ".rig", "state", "project-link.json"), `${JSON.stringify({ repoSlug: repo.slug, connection: connectionAlias, linkedAt: new Date().toISOString() }, null, 2)}
|
|
5501
5504
|
`, "utf8");
|
|
5502
5505
|
const checkout = checkoutForInit(projectRoot, serverKind, options.remoteCheckout);
|
|
5503
5506
|
let uploadedSnapshot = null;
|
|
@@ -5693,7 +5696,7 @@ function parseInitOptions(args) {
|
|
|
5693
5696
|
async function runInteractiveControlPlaneInit(context, prompts) {
|
|
5694
5697
|
prompts.intro?.("Initialize a Rig control-plane project");
|
|
5695
5698
|
const projectRoot = context.projectRoot;
|
|
5696
|
-
const existingConfig =
|
|
5699
|
+
const existingConfig = existsSync11(resolve18(projectRoot, "rig.config.ts")) || existsSync11(resolve18(projectRoot, "rig.config.json"));
|
|
5697
5700
|
let repair = false;
|
|
5698
5701
|
let privateStateOnly = false;
|
|
5699
5702
|
if (existingConfig) {
|
|
@@ -5997,7 +6000,7 @@ async function executeDoctor(context, args) {
|
|
|
5997
6000
|
// packages/cli/src/commands/_run-driver-helpers.ts
|
|
5998
6001
|
init_runner();
|
|
5999
6002
|
import { readFileSync as readFileSync7 } from "fs";
|
|
6000
|
-
import { resolve as
|
|
6003
|
+
import { resolve as resolve19 } from "path";
|
|
6001
6004
|
import {
|
|
6002
6005
|
appendJsonlRecord as appendJsonlRecord2,
|
|
6003
6006
|
readAuthorityRun as readAuthorityRun2,
|
|
@@ -6017,7 +6020,7 @@ function patchAuthorityRun(projectRoot, runId, patch) {
|
|
|
6017
6020
|
...patch,
|
|
6018
6021
|
updatedAt: new Date().toISOString()
|
|
6019
6022
|
};
|
|
6020
|
-
writeJsonFile4(
|
|
6023
|
+
writeJsonFile4(resolve19(resolveAuthorityRunDir3(projectRoot, runId), "run.json"), next);
|
|
6021
6024
|
return next;
|
|
6022
6025
|
}
|
|
6023
6026
|
function touchAuthorityRun(projectRoot, runId) {
|
|
@@ -6025,21 +6028,21 @@ function touchAuthorityRun(projectRoot, runId) {
|
|
|
6025
6028
|
if (!current) {
|
|
6026
6029
|
return;
|
|
6027
6030
|
}
|
|
6028
|
-
writeJsonFile4(
|
|
6031
|
+
writeJsonFile4(resolve19(resolveAuthorityRunDir3(projectRoot, runId), "run.json"), {
|
|
6029
6032
|
...current,
|
|
6030
6033
|
updatedAt: new Date().toISOString()
|
|
6031
6034
|
});
|
|
6032
6035
|
}
|
|
6033
6036
|
function appendRunTimeline(projectRoot, runId, value) {
|
|
6034
|
-
appendJsonlRecord2(
|
|
6037
|
+
appendJsonlRecord2(resolve19(resolveAuthorityRunDir3(projectRoot, runId), "timeline.jsonl"), value);
|
|
6035
6038
|
touchAuthorityRun(projectRoot, runId);
|
|
6036
6039
|
}
|
|
6037
6040
|
function appendRunLog(projectRoot, runId, value) {
|
|
6038
|
-
appendJsonlRecord2(
|
|
6041
|
+
appendJsonlRecord2(resolve19(resolveAuthorityRunDir3(projectRoot, runId), "logs.jsonl"), value);
|
|
6039
6042
|
touchAuthorityRun(projectRoot, runId);
|
|
6040
6043
|
}
|
|
6041
6044
|
function appendRunAction(projectRoot, runId, value) {
|
|
6042
|
-
appendJsonlRecord2(
|
|
6045
|
+
appendJsonlRecord2(resolve19(resolveAuthorityRunDir3(projectRoot, runId), "timeline.jsonl"), {
|
|
6043
6046
|
id: value.id,
|
|
6044
6047
|
type: "action",
|
|
6045
6048
|
actionType: value.actionType,
|
|
@@ -6224,8 +6227,8 @@ function renderSourceScopeValidation(task, validation) {
|
|
|
6224
6227
|
|
|
6225
6228
|
// packages/cli/src/commands/inspect.ts
|
|
6226
6229
|
init_runner();
|
|
6227
|
-
import { existsSync as
|
|
6228
|
-
import { resolve as
|
|
6230
|
+
import { existsSync as existsSync12, readFileSync as readFileSync8 } from "fs";
|
|
6231
|
+
import { resolve as resolve20 } from "path";
|
|
6229
6232
|
import {
|
|
6230
6233
|
listAuthorityRuns as listAuthorityRuns2,
|
|
6231
6234
|
readAuthorityRun as readAuthorityRun3,
|
|
@@ -6246,8 +6249,8 @@ async function executeInspect(context, args) {
|
|
|
6246
6249
|
if (!latestRun) {
|
|
6247
6250
|
throw new CliError2(`No runs found for ${requiredTask}.`);
|
|
6248
6251
|
}
|
|
6249
|
-
const logsPath =
|
|
6250
|
-
if (!
|
|
6252
|
+
const logsPath = resolve20(resolveAuthorityRunDir4(context.projectRoot, latestRun.runId), "logs.jsonl");
|
|
6253
|
+
if (!existsSync12(logsPath)) {
|
|
6251
6254
|
throw new CliError2(`No logs found for run ${latestRun.runId}.`);
|
|
6252
6255
|
}
|
|
6253
6256
|
await context.runCommand(["cat", logsPath]);
|
|
@@ -6257,7 +6260,7 @@ async function executeInspect(context, args) {
|
|
|
6257
6260
|
const { value: task, rest: remaining } = takeOption(rest, "--task");
|
|
6258
6261
|
requireNoExtraArgs(remaining, "rig inspect artifacts --task <task-id>");
|
|
6259
6262
|
const requiredTask = requireTask(task, "rig inspect artifacts --task <task-id>");
|
|
6260
|
-
const artifactRoot = resolveTaskArtifactDirs(context.projectRoot, requiredTask).find((path) =>
|
|
6263
|
+
const artifactRoot = resolveTaskArtifactDirs(context.projectRoot, requiredTask).find((path) => existsSync12(path));
|
|
6261
6264
|
if (!artifactRoot) {
|
|
6262
6265
|
throw new CliError2(`No artifacts found for ${requiredTask}.`);
|
|
6263
6266
|
}
|
|
@@ -6314,7 +6317,7 @@ async function executeInspect(context, args) {
|
|
|
6314
6317
|
case "failures": {
|
|
6315
6318
|
requireNoExtraArgs(rest, "rig inspect failures");
|
|
6316
6319
|
const failed = resolveHarnessPaths2(context.projectRoot).failedApproachesPath;
|
|
6317
|
-
if (!
|
|
6320
|
+
if (!existsSync12(failed)) {
|
|
6318
6321
|
console.log("No failures recorded.");
|
|
6319
6322
|
} else {
|
|
6320
6323
|
process.stdout.write(readFileSync8(failed, "utf-8"));
|
|
@@ -6334,8 +6337,8 @@ async function executeInspect(context, args) {
|
|
|
6334
6337
|
return { ok: true, group: "inspect", command };
|
|
6335
6338
|
case "audit": {
|
|
6336
6339
|
requireNoExtraArgs(rest, "rig inspect audit");
|
|
6337
|
-
const auditPath =
|
|
6338
|
-
if (!
|
|
6340
|
+
const auditPath = resolve20(resolveHarnessPaths2(context.projectRoot).logsDir, "audit.jsonl");
|
|
6341
|
+
if (!existsSync12(auditPath)) {
|
|
6339
6342
|
console.log("No audit log found.");
|
|
6340
6343
|
} else {
|
|
6341
6344
|
const lines = readFileSync8(auditPath, "utf-8").split(/\r?\n/).filter(Boolean).slice(-20);
|
|
@@ -7487,7 +7490,7 @@ async function connectWorkerStream(options, ctx, state) {
|
|
|
7487
7490
|
const buffered = [];
|
|
7488
7491
|
const wsUrl = await buildRunPiEventsWebSocketUrl(options.context, options.runId);
|
|
7489
7492
|
const socket = new WebSocket(wsUrl);
|
|
7490
|
-
const closePromise = new Promise((
|
|
7493
|
+
const closePromise = new Promise((resolve21) => {
|
|
7491
7494
|
socket.onopen = () => {
|
|
7492
7495
|
state.wsConnected = true;
|
|
7493
7496
|
state.status = "live worker Pi WebSocket connected";
|
|
@@ -7512,7 +7515,7 @@ async function connectWorkerStream(options, ctx, state) {
|
|
|
7512
7515
|
state.wsConnected = false;
|
|
7513
7516
|
state.status = "worker Pi WebSocket disconnected";
|
|
7514
7517
|
updatePiUi(ctx, state);
|
|
7515
|
-
|
|
7518
|
+
resolve21();
|
|
7516
7519
|
};
|
|
7517
7520
|
});
|
|
7518
7521
|
try {
|
|
@@ -7548,11 +7551,11 @@ async function connectWorkerStream(options, ctx, state) {
|
|
|
7548
7551
|
function createRemoteBashOperations(options, state, excludeFromContext) {
|
|
7549
7552
|
return {
|
|
7550
7553
|
exec(command, _cwd, execOptions) {
|
|
7551
|
-
return new Promise((
|
|
7554
|
+
return new Promise((resolve21, reject) => {
|
|
7552
7555
|
const pending = {
|
|
7553
7556
|
command,
|
|
7554
7557
|
onData: execOptions.onData,
|
|
7555
|
-
resolve:
|
|
7558
|
+
resolve: resolve21,
|
|
7556
7559
|
reject,
|
|
7557
7560
|
sawChunk: false
|
|
7558
7561
|
};
|
|
@@ -8363,7 +8366,7 @@ async function executeServer(context, args, options) {
|
|
|
8363
8366
|
init_runner();
|
|
8364
8367
|
import { readFileSync as readFileSync9 } from "fs";
|
|
8365
8368
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
8366
|
-
import { resolve as
|
|
8369
|
+
import { resolve as resolve21 } from "path";
|
|
8367
8370
|
import { cancel as cancel4, confirm as confirm2, isCancel as isCancel4 } from "@clack/prompts";
|
|
8368
8371
|
import {
|
|
8369
8372
|
taskArtifactDir,
|
|
@@ -9072,7 +9075,7 @@ async function executeTask(context, args, options) {
|
|
|
9072
9075
|
const fileFlag = takeOption(rest.slice(1), "--file");
|
|
9073
9076
|
let content;
|
|
9074
9077
|
if (fileFlag.value) {
|
|
9075
|
-
content = readFileSync9(
|
|
9078
|
+
content = readFileSync9(resolve21(context.projectRoot, fileFlag.value), "utf-8");
|
|
9076
9079
|
} else {
|
|
9077
9080
|
content = await readStdin();
|
|
9078
9081
|
}
|
|
@@ -9306,8 +9309,8 @@ async function executeTask(context, args, options) {
|
|
|
9306
9309
|
|
|
9307
9310
|
// packages/cli/src/commands/task-run-driver.ts
|
|
9308
9311
|
init_runner();
|
|
9309
|
-
import { copyFileSync as copyFileSync3, existsSync as
|
|
9310
|
-
import { resolve as
|
|
9312
|
+
import { copyFileSync as copyFileSync3, existsSync as existsSync13, mkdirSync as mkdirSync8, readFileSync as readFileSync10, statSync as statSync2, writeFileSync as writeFileSync6 } from "fs";
|
|
9313
|
+
import { resolve as resolve22 } from "path";
|
|
9311
9314
|
import { spawn as spawn2, spawnSync as spawnSync4 } from "child_process";
|
|
9312
9315
|
import { createInterface as createLineInterface } from "readline";
|
|
9313
9316
|
import { loadConfig as loadConfig2 } from "@rig/core/load-config";
|
|
@@ -9390,12 +9393,12 @@ function copyUntrackedDirtyFiles(sourceRoot, targetRoot) {
|
|
|
9390
9393
|
return 0;
|
|
9391
9394
|
let copied = 0;
|
|
9392
9395
|
for (const relativePath of listed.stdout.split("\x00").filter(Boolean)) {
|
|
9393
|
-
const sourcePath =
|
|
9394
|
-
const targetPath =
|
|
9396
|
+
const sourcePath = resolve22(sourceRoot, relativePath);
|
|
9397
|
+
const targetPath = resolve22(targetRoot, relativePath);
|
|
9395
9398
|
try {
|
|
9396
9399
|
if (!statSync2(sourcePath).isFile())
|
|
9397
9400
|
continue;
|
|
9398
|
-
mkdirSync8(
|
|
9401
|
+
mkdirSync8(resolve22(targetPath, ".."), { recursive: true });
|
|
9399
9402
|
copyFileSync3(sourcePath, targetPath);
|
|
9400
9403
|
copied += 1;
|
|
9401
9404
|
} catch {}
|
|
@@ -9434,7 +9437,7 @@ function buildDirtyBaselineHandshakeEnv(input) {
|
|
|
9434
9437
|
return { RIG_BASELINE_MODE: input.baselineMode ?? "head" };
|
|
9435
9438
|
return {
|
|
9436
9439
|
RIG_BASELINE_MODE: "dirty-snapshot",
|
|
9437
|
-
RIG_DIRTY_BASELINE_READY_FILE:
|
|
9440
|
+
RIG_DIRTY_BASELINE_READY_FILE: resolve22(input.projectRoot, ".rig", "runs", input.runId, "dirty-baseline.ready.json")
|
|
9438
9441
|
};
|
|
9439
9442
|
}
|
|
9440
9443
|
function positiveInt(value, fallback) {
|
|
@@ -9545,9 +9548,9 @@ function createCommandRunner(binary) {
|
|
|
9545
9548
|
const stderrChunks = [];
|
|
9546
9549
|
child.stdout.on("data", (chunk) => stdoutChunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk))));
|
|
9547
9550
|
child.stderr.on("data", (chunk) => stderrChunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk))));
|
|
9548
|
-
return await new Promise((
|
|
9549
|
-
child.once("error", (error) =>
|
|
9550
|
-
child.once("close", (code) =>
|
|
9551
|
+
return await new Promise((resolve23) => {
|
|
9552
|
+
child.once("error", (error) => resolve23({ exitCode: 1, stderr: error.message }));
|
|
9553
|
+
child.once("close", (code) => resolve23({
|
|
9551
9554
|
exitCode: code ?? 1,
|
|
9552
9555
|
stdout: Buffer.concat(stdoutChunks).toString("utf8"),
|
|
9553
9556
|
stderr: Buffer.concat(stderrChunks).toString("utf8")
|
|
@@ -9621,7 +9624,7 @@ async function runTaskRunPostValidationLifecycle(input) {
|
|
|
9621
9624
|
config,
|
|
9622
9625
|
sourceTask: input.sourceTask,
|
|
9623
9626
|
uploadedSnapshot: input.uploadedSnapshot,
|
|
9624
|
-
artifactRoot:
|
|
9627
|
+
artifactRoot: resolve22(input.projectRoot, "artifacts", taskId3),
|
|
9625
9628
|
command: ghCommand,
|
|
9626
9629
|
gitCommand,
|
|
9627
9630
|
steerPi,
|
|
@@ -9751,7 +9754,7 @@ function summarizeValidationFailure(projectRoot, taskId3) {
|
|
|
9751
9754
|
return null;
|
|
9752
9755
|
}
|
|
9753
9756
|
for (const artifactDir of resolveTaskArtifactDirs2(projectRoot, taskId3)) {
|
|
9754
|
-
const summary = readJsonFile3(
|
|
9757
|
+
const summary = readJsonFile3(resolve22(artifactDir, "validation-summary.json"), null);
|
|
9755
9758
|
if (!summary || summary.status !== "fail") {
|
|
9756
9759
|
continue;
|
|
9757
9760
|
}
|
|
@@ -9832,9 +9835,9 @@ function readTaskRunAcceptedArtifactState(input) {
|
|
|
9832
9835
|
if (!input.taskId || !input.workspaceDir) {
|
|
9833
9836
|
return { accepted: false, reason: null };
|
|
9834
9837
|
}
|
|
9835
|
-
const artifactDir =
|
|
9836
|
-
const reviewStatusPath =
|
|
9837
|
-
const taskResultPath =
|
|
9838
|
+
const artifactDir = resolve22(input.workspaceDir, "artifacts", input.taskId);
|
|
9839
|
+
const reviewStatusPath = resolve22(artifactDir, "review-status.txt");
|
|
9840
|
+
const taskResultPath = resolve22(artifactDir, "task-result.json");
|
|
9838
9841
|
const reviewStatus = readTaskRunReviewStatus(reviewStatusPath);
|
|
9839
9842
|
if (reviewStatus !== "APPROVED") {
|
|
9840
9843
|
return { accepted: false, reason: null };
|
|
@@ -9871,12 +9874,12 @@ function resolveTaskRunRetryContext(input) {
|
|
|
9871
9874
|
if (!input.taskId || !input.workspaceDir) {
|
|
9872
9875
|
return { shouldRetry: false, failureDetail: null, nextPrompt: null };
|
|
9873
9876
|
}
|
|
9874
|
-
const artifactDir =
|
|
9875
|
-
const reviewStatePath =
|
|
9876
|
-
const reviewFeedbackPath =
|
|
9877
|
-
const reviewStatusPath =
|
|
9878
|
-
const failedApproachesPath =
|
|
9879
|
-
const validationSummaryPath =
|
|
9877
|
+
const artifactDir = resolve22(input.workspaceDir, "artifacts", input.taskId);
|
|
9878
|
+
const reviewStatePath = resolve22(artifactDir, "review-state.json");
|
|
9879
|
+
const reviewFeedbackPath = resolve22(artifactDir, "review-feedback.md");
|
|
9880
|
+
const reviewStatusPath = resolve22(artifactDir, "review-status.txt");
|
|
9881
|
+
const failedApproachesPath = resolve22(input.workspaceDir, ".rig", "state", "failed_approaches.md");
|
|
9882
|
+
const validationSummaryPath = resolve22(artifactDir, "validation-summary.json");
|
|
9880
9883
|
const reviewState = readJsonFile3(reviewStatePath, null);
|
|
9881
9884
|
const reviewStatus = readTaskRunReviewStatus(reviewStatusPath);
|
|
9882
9885
|
const reviewRejected = isTaskRunReviewRejected(reviewState);
|
|
@@ -10062,7 +10065,7 @@ function appendToolTimelineFromLog(input) {
|
|
|
10062
10065
|
});
|
|
10063
10066
|
}
|
|
10064
10067
|
function readTaskRunReviewStatus(reviewStatusPath) {
|
|
10065
|
-
if (!
|
|
10068
|
+
if (!existsSync13(reviewStatusPath)) {
|
|
10066
10069
|
return null;
|
|
10067
10070
|
}
|
|
10068
10071
|
try {
|
|
@@ -10280,15 +10283,15 @@ async function executeRigOwnedTaskRun(context, input) {
|
|
|
10280
10283
|
const loadedAutomationConfig = await loadTaskRunAutomationConfig(context.projectRoot);
|
|
10281
10284
|
const automationConfig = input.prMode ? { ...loadedAutomationConfig ?? {}, pr: { ...loadedAutomationConfig?.pr ?? {}, mode: input.prMode } } : loadedAutomationConfig;
|
|
10282
10285
|
const planningClassification = classifyPlanningNeed({ config: automationConfig, sourceTask });
|
|
10283
|
-
const planningArtifactPath =
|
|
10286
|
+
const planningArtifactPath = resolve22("artifacts", runtimeTaskId, "implementation-plan.md");
|
|
10284
10287
|
const persistedPlanning = {
|
|
10285
10288
|
...planningClassification,
|
|
10286
10289
|
classifier: input.runtimeAdapter === "pi" ? "pi-rig-structured-policy" : "rig-structured-policy",
|
|
10287
10290
|
artifactPath: planningClassification.planningRequired ? planningArtifactPath : null,
|
|
10288
10291
|
classifiedAt: new Date().toISOString()
|
|
10289
10292
|
};
|
|
10290
|
-
mkdirSync8(
|
|
10291
|
-
writeFileSync6(
|
|
10293
|
+
mkdirSync8(resolve22(context.projectRoot, ".rig", "runs", input.runId), { recursive: true });
|
|
10294
|
+
writeFileSync6(resolve22(context.projectRoot, ".rig", "runs", input.runId, "planning-classification.json"), `${JSON.stringify(persistedPlanning, null, 2)}
|
|
10292
10295
|
`, "utf8");
|
|
10293
10296
|
patchAuthorityRun(context.projectRoot, input.runId, { planning: persistedPlanning });
|
|
10294
10297
|
prompt = `${prompt}
|
|
@@ -10338,7 +10341,7 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
|
|
|
10338
10341
|
let verificationStarted = false;
|
|
10339
10342
|
let reviewStarted = false;
|
|
10340
10343
|
let latestRuntimeWorkspace = resumeMode && typeof existingRunRecord?.worktreePath === "string" ? existingRunRecord.worktreePath : null;
|
|
10341
|
-
let latestSessionDir = resumeMode && typeof existingRunRecord?.sessionPath === "string" ?
|
|
10344
|
+
let latestSessionDir = resumeMode && typeof existingRunRecord?.sessionPath === "string" ? resolve22(existingRunRecord.sessionPath, "..") : null;
|
|
10342
10345
|
let latestLogsDir = resumeMode && typeof existingRunRecord?.logRoot === "string" ? existingRunRecord.logRoot : null;
|
|
10343
10346
|
let latestProviderCommand = null;
|
|
10344
10347
|
let latestRuntimeBranch = resumeMode && typeof existingRunRecord?.branch === "string" ? existingRunRecord.branch : null;
|
|
@@ -10424,10 +10427,10 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
|
|
|
10424
10427
|
patchAuthorityRun(context.projectRoot, input.runId, {
|
|
10425
10428
|
status: "running",
|
|
10426
10429
|
worktreePath: latestRuntimeWorkspace,
|
|
10427
|
-
artifactRoot: latestRuntimeWorkspace && input.taskId ?
|
|
10430
|
+
artifactRoot: latestRuntimeWorkspace && input.taskId ? resolve22(latestRuntimeWorkspace, "artifacts", input.taskId) : null,
|
|
10428
10431
|
logRoot: latestLogsDir,
|
|
10429
|
-
sessionPath: latestSessionDir ?
|
|
10430
|
-
sessionLogPath: latestLogsDir ?
|
|
10432
|
+
sessionPath: latestSessionDir ? resolve22(latestSessionDir, "session.json") : null,
|
|
10433
|
+
sessionLogPath: latestLogsDir ? resolve22(latestLogsDir, "agent-stdout.log") : null,
|
|
10431
10434
|
branch: runtimeId
|
|
10432
10435
|
});
|
|
10433
10436
|
if (!dirtyBaselineApplied && input.baselineMode === "dirty-snapshot" && latestRuntimeWorkspace) {
|
|
@@ -10435,7 +10438,7 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
|
|
|
10435
10438
|
const dirty = applyDirtyBaselineSnapshot({ sourceRoot: context.projectRoot, targetRoot: latestRuntimeWorkspace });
|
|
10436
10439
|
const readyFile = childEnv.RIG_DIRTY_BASELINE_READY_FILE;
|
|
10437
10440
|
if (readyFile) {
|
|
10438
|
-
mkdirSync8(
|
|
10441
|
+
mkdirSync8(resolve22(readyFile, ".."), { recursive: true });
|
|
10439
10442
|
writeFileSync6(readyFile, `${JSON.stringify({ ...dirty, workspaceDir: latestRuntimeWorkspace, appliedAt: new Date().toISOString() }, null, 2)}
|
|
10440
10443
|
`, "utf8");
|
|
10441
10444
|
}
|
|
@@ -10820,7 +10823,7 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
|
|
|
10820
10823
|
let acceptedArtifactObservedAt = null;
|
|
10821
10824
|
let acceptedArtifactPollTimer = null;
|
|
10822
10825
|
let acceptedArtifactKillTimer = null;
|
|
10823
|
-
const attemptExit = await new Promise((
|
|
10826
|
+
const attemptExit = await new Promise((resolve23) => {
|
|
10824
10827
|
let settled = false;
|
|
10825
10828
|
const settle = (result) => {
|
|
10826
10829
|
if (settled)
|
|
@@ -10828,7 +10831,7 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
|
|
|
10828
10831
|
settled = true;
|
|
10829
10832
|
if (acceptedArtifactPollTimer)
|
|
10830
10833
|
clearInterval(acceptedArtifactPollTimer);
|
|
10831
|
-
|
|
10834
|
+
resolve23(result);
|
|
10832
10835
|
};
|
|
10833
10836
|
const pollAcceptedArtifacts = () => {
|
|
10834
10837
|
const artifactState = readTaskRunAcceptedArtifactState({
|
|
@@ -11030,8 +11033,8 @@ Failed to update task source for ${input.taskId ?? runtimeTaskId} to failed: ${e
|
|
|
11030
11033
|
}
|
|
11031
11034
|
if (planningClassification.planningRequired) {
|
|
11032
11035
|
const planWorkspace = latestRuntimeWorkspace ?? context.projectRoot;
|
|
11033
|
-
const expectedPlanPath =
|
|
11034
|
-
if (!
|
|
11036
|
+
const expectedPlanPath = resolve22(planWorkspace, planningArtifactPath);
|
|
11037
|
+
if (!existsSync13(expectedPlanPath)) {
|
|
11035
11038
|
const failedAt = new Date().toISOString();
|
|
11036
11039
|
const failureDetail = `Planning was required (${planningClassification.reason}) but ${planningArtifactPath} was not written before implementation completed.`;
|
|
11037
11040
|
patchAuthorityRun(context.projectRoot, input.runId, {
|
|
@@ -11201,9 +11204,9 @@ Failed to update task source for ${input.taskId ?? runtimeTaskId} to failed: ${e
|
|
|
11201
11204
|
});
|
|
11202
11205
|
emitServerRunEvent({ type: "log", runId: input.runId, title: "Pi PR feedback fix stderr" });
|
|
11203
11206
|
});
|
|
11204
|
-
const exitCode = await new Promise((
|
|
11205
|
-
child.once("error", () =>
|
|
11206
|
-
child.once("close", (code) =>
|
|
11207
|
+
const exitCode = await new Promise((resolve23) => {
|
|
11208
|
+
child.once("error", () => resolve23(1));
|
|
11209
|
+
child.once("close", (code) => resolve23(code ?? 1));
|
|
11207
11210
|
});
|
|
11208
11211
|
for (const pendingLog of flushPendingClaudeToolUseLogs({
|
|
11209
11212
|
runId: input.runId,
|
|
@@ -11345,8 +11348,8 @@ async function executeTest(context, args) {
|
|
|
11345
11348
|
|
|
11346
11349
|
// packages/cli/src/commands/setup.ts
|
|
11347
11350
|
init_runner();
|
|
11348
|
-
import { existsSync as
|
|
11349
|
-
import { resolve as
|
|
11351
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync9, readdirSync as readdirSync2, writeFileSync as writeFileSync7 } from "fs";
|
|
11352
|
+
import { resolve as resolve23 } from "path";
|
|
11350
11353
|
import { createPluginHost } from "@rig/core";
|
|
11351
11354
|
import {
|
|
11352
11355
|
isSupportedBunVersion as isSupportedBunVersion2,
|
|
@@ -11404,8 +11407,8 @@ function runSetupInit(projectRoot) {
|
|
|
11404
11407
|
mkdirSync9(stateDir, { recursive: true });
|
|
11405
11408
|
mkdirSync9(logsDir, { recursive: true });
|
|
11406
11409
|
mkdirSync9(artifactsDir, { recursive: true });
|
|
11407
|
-
const failuresPath =
|
|
11408
|
-
if (!
|
|
11410
|
+
const failuresPath = resolve23(stateDir, "failed_approaches.md");
|
|
11411
|
+
if (!existsSync14(failuresPath)) {
|
|
11409
11412
|
writeFileSync7(failuresPath, `# Failed Approaches
|
|
11410
11413
|
|
|
11411
11414
|
`, "utf-8");
|
|
@@ -11423,18 +11426,18 @@ async function runSetupCheck(projectRoot) {
|
|
|
11423
11426
|
}
|
|
11424
11427
|
async function runSetupPreflight(projectRoot) {
|
|
11425
11428
|
await runSetupCheck(projectRoot);
|
|
11426
|
-
const validationRoot =
|
|
11427
|
-
if (
|
|
11429
|
+
const validationRoot = resolve23(resolveControlPlaneDefinitionRoot(projectRoot), "validation");
|
|
11430
|
+
if (existsSync14(validationRoot)) {
|
|
11428
11431
|
const validators = readdirSync2(validationRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory());
|
|
11429
11432
|
for (const validator of validators) {
|
|
11430
|
-
const script =
|
|
11431
|
-
if (
|
|
11433
|
+
const script = resolve23(validationRoot, validator.name, "validate.sh");
|
|
11434
|
+
if (existsSync14(script)) {
|
|
11432
11435
|
console.log(`OK: validator script ${script}`);
|
|
11433
11436
|
}
|
|
11434
11437
|
}
|
|
11435
11438
|
}
|
|
11436
|
-
const hooksRoot =
|
|
11437
|
-
if (
|
|
11439
|
+
const hooksRoot = resolve23(resolveControlPlaneDefinitionRoot(projectRoot), "hooks");
|
|
11440
|
+
if (existsSync14(hooksRoot)) {
|
|
11438
11441
|
const hooks = readdirSync2(hooksRoot).filter((name) => name.endsWith(".sh"));
|
|
11439
11442
|
for (const hook of hooks) {
|
|
11440
11443
|
console.log(`OK: hook ${hook}`);
|
|
@@ -11579,7 +11582,7 @@ var PROJECT_REQUIRED_GROUPS = new Set([
|
|
|
11579
11582
|
]);
|
|
11580
11583
|
var RIG_CONFIG_FILENAMES = ["rig.config.ts", "rig.config.mts", "rig.config.json"];
|
|
11581
11584
|
function hasInitializedRigProject(projectRoot) {
|
|
11582
|
-
return RIG_CONFIG_FILENAMES.some((name) =>
|
|
11585
|
+
return RIG_CONFIG_FILENAMES.some((name) => existsSync15(resolve24(projectRoot, name))) || existsSync15(resolve24(projectRoot, ".rig"));
|
|
11583
11586
|
}
|
|
11584
11587
|
function requireInitializedRigProject(context, group) {
|
|
11585
11588
|
if (hasInitializedRigProject(context.projectRoot)) {
|
|
@@ -11658,9 +11661,11 @@ ${helpText()}`);
|
|
|
11658
11661
|
const path = await import("path");
|
|
11659
11662
|
const { fileURLToPath } = await import("url");
|
|
11660
11663
|
const execPath = process.execPath || "";
|
|
11664
|
+
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
11661
11665
|
const candidates = [
|
|
11662
11666
|
execPath ? path.resolve(path.dirname(execPath), "..", "manifest.json") : "",
|
|
11663
|
-
path.resolve(
|
|
11667
|
+
path.resolve(moduleDir, "..", "package.json"),
|
|
11668
|
+
path.resolve(moduleDir, "..", "..", "package.json"),
|
|
11664
11669
|
path.resolve(process.cwd(), "packages/cli/package.json")
|
|
11665
11670
|
].filter(Boolean);
|
|
11666
11671
|
for (const candidate of candidates) {
|
|
@@ -11777,8 +11782,8 @@ async function executeGroup(context, group, args) {
|
|
|
11777
11782
|
}
|
|
11778
11783
|
}
|
|
11779
11784
|
// packages/cli/src/launcher.ts
|
|
11780
|
-
import { existsSync as
|
|
11781
|
-
import { basename as basename2, resolve as
|
|
11785
|
+
import { existsSync as existsSync16 } from "fs";
|
|
11786
|
+
import { basename as basename2, resolve as resolve25 } from "path";
|
|
11782
11787
|
import { loadDotEnvSecrets } from "@rig/runtime/baked-secrets";
|
|
11783
11788
|
import { RIG_DEFINITION_DIRNAME, RIG_STATE_DIRNAME, resolveNearestRigProjectRoot } from "@rig/runtime/layout";
|
|
11784
11789
|
function parsePolicyMode(value) {
|
|
@@ -11791,7 +11796,7 @@ function parsePolicyMode(value) {
|
|
|
11791
11796
|
throw new Error(`Invalid --policy-mode value: ${value}. Use off|observe|enforce.`);
|
|
11792
11797
|
}
|
|
11793
11798
|
function hasRigProjectMarker(candidate) {
|
|
11794
|
-
return
|
|
11799
|
+
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"));
|
|
11795
11800
|
}
|
|
11796
11801
|
function resolveProjectRoot({
|
|
11797
11802
|
envProjectRoot,
|
|
@@ -11800,19 +11805,19 @@ function resolveProjectRoot({
|
|
|
11800
11805
|
cwd = process.cwd()
|
|
11801
11806
|
}) {
|
|
11802
11807
|
if (envProjectRoot) {
|
|
11803
|
-
return
|
|
11808
|
+
return resolve25(cwd, envProjectRoot);
|
|
11804
11809
|
}
|
|
11805
11810
|
const fallbackImportDir = importDir ?? cwd;
|
|
11806
11811
|
const execName = basename2(execPath).toLowerCase();
|
|
11807
|
-
const execCandidates = execName === "rig" || execName === "rig.exe" ? [
|
|
11808
|
-
const candidates = [cwd, ...execCandidates,
|
|
11812
|
+
const execCandidates = execName === "rig" || execName === "rig.exe" ? [resolve25(execPath, "..", "..")] : [];
|
|
11813
|
+
const candidates = [cwd, ...execCandidates, resolve25(fallbackImportDir, "..")];
|
|
11809
11814
|
for (const candidate of candidates) {
|
|
11810
11815
|
const nearest = resolveNearestRigProjectRoot(candidate);
|
|
11811
11816
|
if (hasRigProjectMarker(nearest)) {
|
|
11812
11817
|
return nearest;
|
|
11813
11818
|
}
|
|
11814
11819
|
}
|
|
11815
|
-
return
|
|
11820
|
+
return resolve25(cwd);
|
|
11816
11821
|
}
|
|
11817
11822
|
function normalizeCliErrorCode(message2, isCliError) {
|
|
11818
11823
|
if (message2.startsWith("Invalid --policy-mode value:")) {
|
|
@@ -11879,7 +11884,7 @@ async function runRigCli(module, options = {}) {
|
|
|
11879
11884
|
runId: context.runId,
|
|
11880
11885
|
outcome,
|
|
11881
11886
|
eventsFile: context.eventBus.getEventsFile(),
|
|
11882
|
-
policyFile:
|
|
11887
|
+
policyFile: resolve25(projectRoot, "rig", "policy", "policy.json"),
|
|
11883
11888
|
policyMode: context.policyMode ?? policyMode ?? module.loadPolicy(projectRoot).mode
|
|
11884
11889
|
}, null, 2));
|
|
11885
11890
|
}
|