@akagilnc/pi-workflow-roles 0.1.4889 → 0.1.4911
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/acp-host/production-host.js +70 -286
- package/dist/headless-host/production-host.js +65 -281
- package/dist/migrate-book-topology.js +19 -18
- package/dist/packaged-role-registry.js +0 -2
- package/dist/public-cli/instruction-seat-run.js +5 -58
- package/dist/public-cli/main.js +56 -272
- package/dist/public-cli/post-admission.js +3 -18
- package/dist/public-cli/turn-request.js +1 -1
- package/dist/public-role-summons.js +38 -190
- package/dist/role-run-relocation.js +16 -4
- package/package.json +1 -1
- package/src/book-topology-runs-migrator.ts +1 -4
- package/src/packaged-role-registry.ts +0 -2
- package/src/public-cli/instruction-seat-run.ts +5 -56
- package/src/public-cli/post-admission.ts +2 -32
- package/src/public-cli/turn-request.ts +1 -7
- package/src/public-role-summons.ts +58 -268
- package/src/role-run-relocation.ts +18 -17
|
@@ -156,8 +156,6 @@ const PUBLIC_ROLE_RECORDS = [
|
|
|
156
156
|
settleMethod: "ak-cross-m-review",
|
|
157
157
|
/** Omitted public lens starts two ordinary single-axis runs (ADR 0052). */
|
|
158
158
|
parallelLenses: true,
|
|
159
|
-
/** Every turn runs in a fresh worktree; durable projectRoot stays the caller project (#946). */
|
|
160
|
-
freshExecutionCopy: true,
|
|
161
159
|
phases: [null],
|
|
162
160
|
bareCommand: false,
|
|
163
161
|
outputTool: REVIEWER_OUTPUT_TOOL_NAME,
|
|
@@ -42,13 +42,6 @@ function initialPrompt(admitted, env) {
|
|
|
42
42
|
packageRoot: env.packageRoot,
|
|
43
43
|
}));
|
|
44
44
|
}
|
|
45
|
-
function hostTurnCwd(env) {
|
|
46
|
-
return env.executionCwd === undefined ? undefined : { cwd: env.executionCwd };
|
|
47
|
-
}
|
|
48
|
-
function wantsFreshExecutionCopy(role) {
|
|
49
|
-
const record = roleRecord(role);
|
|
50
|
-
return "freshExecutionCopy" in record && record.freshExecutionCopy === true;
|
|
51
|
-
}
|
|
52
45
|
function infraFailure(role) {
|
|
53
46
|
const resolveRunnerKnownFailure = seatKnownFailureResolver(role);
|
|
54
47
|
return resolveRunnerKnownFailure === undefined ? {} : { resolveRunnerKnownFailure };
|
|
@@ -153,20 +146,19 @@ async function dispatchAdmitted(admitted, env, io) {
|
|
|
153
146
|
const adapters = seatAdapters(admitted, env, material);
|
|
154
147
|
const execute = async (activeEnv) => {
|
|
155
148
|
const auto = "inCallAutoResume" in record && record.inCallAutoResume === true;
|
|
156
|
-
const cwd = hostTurnCwd(activeEnv);
|
|
157
149
|
if (auto) {
|
|
158
150
|
return await runPostAdmissionResumable({
|
|
159
151
|
admitted,
|
|
160
152
|
env: activeEnv,
|
|
161
153
|
io,
|
|
162
|
-
buildInitialRequest: () => buildInstructionSeatTurnRequest(admitted, roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) }
|
|
154
|
+
buildInitialRequest: () => buildInstructionSeatTurnRequest(admitted, roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) })),
|
|
163
155
|
buildResumeRequest: () => buildInstructionSeatTurnRequest(admitted, roleTurnOptions(activeEnv, admitted, {
|
|
164
156
|
kind: "resume",
|
|
165
157
|
prompt: buildAutoResumeContinuationPrompt({
|
|
166
158
|
packageRoot: activeEnv.packageRoot,
|
|
167
159
|
...pickEngineAxis(activeEnv),
|
|
168
160
|
}),
|
|
169
|
-
}
|
|
161
|
+
})),
|
|
170
162
|
adapters,
|
|
171
163
|
...(activeEnv.engine === undefined ? {} : { effectiveEngine: activeEnv.engine }),
|
|
172
164
|
});
|
|
@@ -175,33 +167,12 @@ async function dispatchAdmitted(admitted, env, io) {
|
|
|
175
167
|
admitted,
|
|
176
168
|
env: activeEnv,
|
|
177
169
|
io,
|
|
178
|
-
request: buildInstructionSeatTurnRequest(admitted, roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) }
|
|
170
|
+
request: buildInstructionSeatTurnRequest(admitted, roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) })),
|
|
179
171
|
adapters,
|
|
180
172
|
...(activeEnv.engine === undefined ? {} : { effectiveEngine: activeEnv.engine }),
|
|
181
173
|
});
|
|
182
174
|
};
|
|
183
|
-
|
|
184
|
-
return execute(env);
|
|
185
|
-
try {
|
|
186
|
-
if (env.executionCwd !== undefined)
|
|
187
|
-
return await execute(env);
|
|
188
|
-
const { withEphemeralReviewerWorktree } = await import("../public-role-summons.js");
|
|
189
|
-
return await withEphemeralReviewerWorktree({
|
|
190
|
-
projectRoot: admitted.projectRoot,
|
|
191
|
-
onCleanupDiagnostic: (diagnostic) => {
|
|
192
|
-
io.stderr(`${diagnostic}\n`);
|
|
193
|
-
},
|
|
194
|
-
run: (executionCwd) => execute({ ...env, executionCwd }),
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
catch (error) {
|
|
198
|
-
return await presentControlledFailure(admitted, {
|
|
199
|
-
timedOut: false,
|
|
200
|
-
code: null,
|
|
201
|
-
stderr: "",
|
|
202
|
-
thrown: error,
|
|
203
|
-
}, adapters, env.principalAuthority, io);
|
|
204
|
-
}
|
|
175
|
+
return execute(env);
|
|
205
176
|
}
|
|
206
177
|
/**
|
|
207
178
|
* Omitted lens on a parallel-lens seat: two ordinary single-axis runs, no parent run.
|
|
@@ -647,9 +618,6 @@ export async function runPublicInstructionSeat(argv, env, io, role, parseArgv) {
|
|
|
647
618
|
return runAdmitted();
|
|
648
619
|
}
|
|
649
620
|
export async function runPublicInstructionSeatResume(request, env, io) {
|
|
650
|
-
const execution = {
|
|
651
|
-
...(env.executionCwd === undefined ? {} : { cwd: env.executionCwd }),
|
|
652
|
-
};
|
|
653
621
|
return runPostAdmissionSeatResume({
|
|
654
622
|
request,
|
|
655
623
|
env,
|
|
@@ -671,11 +639,9 @@ export async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
671
639
|
return loaded;
|
|
672
640
|
},
|
|
673
641
|
buildTurnRequest: async (admitted, effective) => {
|
|
674
|
-
const activeEnv = execution.cwd === undefined ? env : { ...env, executionCwd: execution.cwd };
|
|
675
642
|
const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
|
|
676
643
|
return buildInstructionSeatTurnRequest(admitted, {
|
|
677
|
-
...resumeTurnRequestProjectionOptions(admitted, effective,
|
|
678
|
-
...(execution.cwd === undefined ? {} : { cwd: execution.cwd }),
|
|
644
|
+
...resumeTurnRequestProjectionOptions(admitted, effective, env, summonsPrepared),
|
|
679
645
|
});
|
|
680
646
|
},
|
|
681
647
|
adapters: {
|
|
@@ -697,25 +663,6 @@ export async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
697
663
|
...(knownCause === undefined ? {} : { knownCause }),
|
|
698
664
|
});
|
|
699
665
|
},
|
|
700
|
-
afterAdmittedPrepare: async (admitted) => {
|
|
701
|
-
if (!wantsFreshExecutionCopy(admitted.role))
|
|
702
|
-
return {};
|
|
703
|
-
if (execution.cwd !== undefined) {
|
|
704
|
-
return { env: { ...env, executionCwd: execution.cwd } };
|
|
705
|
-
}
|
|
706
|
-
const { openEphemeralReviewerWorktree } = await import("../public-role-summons.js");
|
|
707
|
-
const opened = await openEphemeralReviewerWorktree({
|
|
708
|
-
projectRoot: admitted.projectRoot,
|
|
709
|
-
onCleanupDiagnostic: (diagnostic) => {
|
|
710
|
-
io.stderr(`${diagnostic}\n`);
|
|
711
|
-
},
|
|
712
|
-
});
|
|
713
|
-
execution.cwd = opened.executionCwd;
|
|
714
|
-
return {
|
|
715
|
-
env: { ...env, executionCwd: opened.executionCwd },
|
|
716
|
-
cleanup: opened.close,
|
|
717
|
-
};
|
|
718
|
-
},
|
|
719
666
|
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
720
667
|
});
|
|
721
668
|
}
|
package/dist/public-cli/main.js
CHANGED
|
@@ -15653,8 +15653,6 @@ var init_packaged_role_registry = __esm({
|
|
|
15653
15653
|
settleMethod: "ak-cross-m-review",
|
|
15654
15654
|
/** Omitted public lens starts two ordinary single-axis runs (ADR 0052). */
|
|
15655
15655
|
parallelLenses: true,
|
|
15656
|
-
/** Every turn runs in a fresh worktree; durable projectRoot stays the caller project (#946). */
|
|
15657
|
-
freshExecutionCopy: true,
|
|
15658
15656
|
phases: [null],
|
|
15659
15657
|
bareCommand: false,
|
|
15660
15658
|
outputTool: REVIEWER_OUTPUT_TOOL_NAME,
|
|
@@ -17827,9 +17825,9 @@ async function readRunTerminalArtifact(runDirectory) {
|
|
|
17827
17825
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
17828
17826
|
consider(await readTerminalArtifactAtPath(join11(artifactsDir, file), file));
|
|
17829
17827
|
}
|
|
17830
|
-
for (const
|
|
17828
|
+
for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
17831
17829
|
consider(
|
|
17832
|
-
await readTerminalArtifactAtPath(join11(runDirectory,
|
|
17830
|
+
await readTerminalArtifactAtPath(join11(runDirectory, relative3), "error.json")
|
|
17833
17831
|
);
|
|
17834
17832
|
}
|
|
17835
17833
|
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
@@ -22472,11 +22470,11 @@ function parseAnalystCohortIssueToken(raw, flag) {
|
|
|
22472
22470
|
`${flag} requires a comma-separated list of N or book:N`
|
|
22473
22471
|
);
|
|
22474
22472
|
}
|
|
22475
|
-
const
|
|
22476
|
-
if (
|
|
22477
|
-
const rhs = trimmed.slice(
|
|
22473
|
+
const sep5 = trimmed.lastIndexOf(":");
|
|
22474
|
+
if (sep5 > 0) {
|
|
22475
|
+
const rhs = trimmed.slice(sep5 + 1);
|
|
22478
22476
|
if (ANALYST_TICKET_NUMBER_PATTERN.test(rhs)) {
|
|
22479
|
-
const bookKey = trimmed.slice(0,
|
|
22477
|
+
const bookKey = trimmed.slice(0, sep5);
|
|
22480
22478
|
if (bookKey.trim() === "") {
|
|
22481
22479
|
throw new CliUsageError(
|
|
22482
22480
|
`${flag} book:N requires a non-empty book key, got ${raw}`
|
|
@@ -25740,8 +25738,8 @@ async function clearOppositeTerminalArtifactFace(runDirectory) {
|
|
|
25740
25738
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
25741
25739
|
await removeFaceIfPresent(join27(artifactsDir, file));
|
|
25742
25740
|
}
|
|
25743
|
-
for (const
|
|
25744
|
-
await removeFaceIfPresent(join27(runDirectory,
|
|
25741
|
+
for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
25742
|
+
await removeFaceIfPresent(join27(runDirectory, relative3));
|
|
25745
25743
|
}
|
|
25746
25744
|
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
25747
25745
|
await removeFaceIfPresent(path);
|
|
@@ -27645,7 +27643,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
27645
27643
|
...env.stationChild === void 0 ? {} : { stationChild: env.stationChild }
|
|
27646
27644
|
};
|
|
27647
27645
|
}
|
|
27648
|
-
function roleTurnOptions(env, admitted, continuation
|
|
27646
|
+
function roleTurnOptions(env, admitted, continuation) {
|
|
27649
27647
|
const correlationId = admitted.correlationId ?? env.correlationId;
|
|
27650
27648
|
return {
|
|
27651
27649
|
packageRoot: env.packageRoot,
|
|
@@ -27656,7 +27654,6 @@ function roleTurnOptions(env, admitted, continuation, extra) {
|
|
|
27656
27654
|
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
27657
27655
|
...correlationId === void 0 || correlationId.trim() === "" ? {} : { correlationId },
|
|
27658
27656
|
continuation,
|
|
27659
|
-
...extra?.cwd === void 0 ? {} : { cwd: extra.cwd },
|
|
27660
27657
|
...env.stationChild === void 0 ? {} : { stationChild: env.stationChild }
|
|
27661
27658
|
};
|
|
27662
27659
|
}
|
|
@@ -27716,8 +27713,7 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
27716
27713
|
}
|
|
27717
27714
|
adapters = prepared.adapters;
|
|
27718
27715
|
}
|
|
27719
|
-
|
|
27720
|
-
let preparedCleanup;
|
|
27716
|
+
const env = input.env;
|
|
27721
27717
|
const buildRequestAfterLease = async () => {
|
|
27722
27718
|
let openCourtAttemptId;
|
|
27723
27719
|
const admittedForBuild = loaded.admitted;
|
|
@@ -27772,11 +27768,6 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
27772
27768
|
return turnRequest;
|
|
27773
27769
|
};
|
|
27774
27770
|
try {
|
|
27775
|
-
if (input.afterAdmittedPrepare !== void 0) {
|
|
27776
|
-
const prepared = await input.afterAdmittedPrepare(loaded.admitted);
|
|
27777
|
-
if (prepared.env !== void 0) env = prepared.env;
|
|
27778
|
-
preparedCleanup = prepared.cleanup;
|
|
27779
|
-
}
|
|
27780
27771
|
if (env.stationChild === true) {
|
|
27781
27772
|
let firstTurn;
|
|
27782
27773
|
const stationAdapters = withOnceSuccessfulBeforeDispatch(adapters);
|
|
@@ -27853,10 +27844,6 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
27853
27844
|
return { exitCode: 2 };
|
|
27854
27845
|
}
|
|
27855
27846
|
throw error;
|
|
27856
|
-
} finally {
|
|
27857
|
-
if (preparedCleanup !== void 0) {
|
|
27858
|
-
await preparedCleanup();
|
|
27859
|
-
}
|
|
27860
27847
|
}
|
|
27861
27848
|
}
|
|
27862
27849
|
async function runPostAdmissionOneShot(input) {
|
|
@@ -28014,7 +28001,7 @@ var init_seat_ticket_binding = __esm({
|
|
|
28014
28001
|
|
|
28015
28002
|
// src/public-cli/turn-request.ts
|
|
28016
28003
|
function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
28017
|
-
const cwd =
|
|
28004
|
+
const cwd = admitted.projectRoot ?? admitted.repoRoot ?? admitted.cwd;
|
|
28018
28005
|
if (cwd === void 0) throw new Error("admitted invocation missing working directory");
|
|
28019
28006
|
if (admitted.principal === void 0) throw new Error("admitted invocation missing principal");
|
|
28020
28007
|
return {
|
|
@@ -28106,18 +28093,15 @@ var init_turn_request = __esm({
|
|
|
28106
28093
|
var public_role_summons_exports = {};
|
|
28107
28094
|
__export(public_role_summons_exports, {
|
|
28108
28095
|
AK_ROLE_PACKAGE_ROOT_ENV: () => AK_ROLE_PACKAGE_ROOT_ENV,
|
|
28109
|
-
openEphemeralReviewerWorktree: () => openEphemeralReviewerWorktree,
|
|
28110
28096
|
resolveSummonsPackageRoot: () => resolveSummonsPackageRoot,
|
|
28111
28097
|
summonGateOfficer: () => summonGateOfficer,
|
|
28112
28098
|
summonParallelReviewerLenses: () => summonParallelReviewerLenses,
|
|
28113
|
-
summonPublicRole: () => summonPublicRole
|
|
28114
|
-
withEphemeralReviewerWorktree: () => withEphemeralReviewerWorktree
|
|
28099
|
+
summonPublicRole: () => summonPublicRole
|
|
28115
28100
|
});
|
|
28116
28101
|
import { execFile as execFile3 } from "node:child_process";
|
|
28117
28102
|
import { existsSync as existsSync9 } from "node:fs";
|
|
28118
|
-
import {
|
|
28119
|
-
import {
|
|
28120
|
-
import { join as join30, relative as relative3, sep as sep5 } from "node:path";
|
|
28103
|
+
import { realpath as realpath6 } from "node:fs/promises";
|
|
28104
|
+
import { join as join30 } from "node:path";
|
|
28121
28105
|
import { promisify as promisify3 } from "node:util";
|
|
28122
28106
|
function createCapturingIo() {
|
|
28123
28107
|
const chunks = [];
|
|
@@ -28319,8 +28303,7 @@ async function summonPublicRole(options) {
|
|
|
28319
28303
|
...options.boundTicketNumber === void 0 ? {} : { boundTicketNumber: options.boundTicketNumber },
|
|
28320
28304
|
...options.parentRunPath === void 0 || options.parentRunPath.trim() === "" ? {} : { parentRunPath: options.parentRunPath },
|
|
28321
28305
|
...options.correlationId === void 0 || options.correlationId.trim() === "" ? {} : { correlationId: options.correlationId },
|
|
28322
|
-
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
|
|
28323
|
-
...options.executionCwd === void 0 ? {} : { executionCwd: options.executionCwd }
|
|
28306
|
+
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
|
|
28324
28307
|
}
|
|
28325
28308
|
};
|
|
28326
28309
|
} catch (error) {
|
|
@@ -28400,106 +28383,13 @@ function withReviewerLens(argv2, lens) {
|
|
|
28400
28383
|
if (separator === -1) return [...argv2, "--lens", lens];
|
|
28401
28384
|
return [...argv2.slice(0, separator), "--lens", lens, ...argv2.slice(separator)];
|
|
28402
28385
|
}
|
|
28403
|
-
async function
|
|
28386
|
+
async function resolveReviewerGitToplevel(projectRoot) {
|
|
28404
28387
|
const callerProjectRoot = await realpath6(projectRoot);
|
|
28405
|
-
|
|
28388
|
+
return await realpath6((await execFileAsync3(
|
|
28406
28389
|
"git",
|
|
28407
28390
|
["rev-parse", "--show-toplevel"],
|
|
28408
28391
|
{ cwd: callerProjectRoot }
|
|
28409
28392
|
)).stdout.trim());
|
|
28410
|
-
const callerRelative = relative3(sourceProjectRoot, callerProjectRoot);
|
|
28411
|
-
const projectRelative = callerRelative === "" || callerRelative === "." || callerRelative.startsWith(`..${sep5}`) || callerRelative === ".." ? "" : callerRelative;
|
|
28412
|
-
return { callerProjectRoot, sourceProjectRoot, projectRelative };
|
|
28413
|
-
}
|
|
28414
|
-
function reviewerSandboxPath(worktreeAxis, projectRelative) {
|
|
28415
|
-
return projectRelative === "" ? worktreeAxis : join30(worktreeAxis, projectRelative);
|
|
28416
|
-
}
|
|
28417
|
-
async function openEphemeralReviewerWorktree(options) {
|
|
28418
|
-
const { sourceProjectRoot, projectRelative } = await resolveReviewerWorktreeRoots(
|
|
28419
|
-
options.projectRoot
|
|
28420
|
-
);
|
|
28421
|
-
const { stdout: headStdout } = await execFileAsync3(
|
|
28422
|
-
"git",
|
|
28423
|
-
["rev-parse", "--verify", "HEAD^{commit}"],
|
|
28424
|
-
{ cwd: sourceProjectRoot }
|
|
28425
|
-
);
|
|
28426
|
-
const targetCommit = headStdout.trim();
|
|
28427
|
-
const root = await mkdtemp3(join30(tmpdir3(), "ak-reviewer-sandbox-"));
|
|
28428
|
-
const worktreeRoot = join30(root, "work");
|
|
28429
|
-
let registered = false;
|
|
28430
|
-
const rollback = async (cause) => {
|
|
28431
|
-
const cleanupErrors = [];
|
|
28432
|
-
if (registered) {
|
|
28433
|
-
try {
|
|
28434
|
-
await execFileAsync3("git", ["worktree", "remove", "--force", worktreeRoot], {
|
|
28435
|
-
cwd: sourceProjectRoot
|
|
28436
|
-
});
|
|
28437
|
-
} catch (error) {
|
|
28438
|
-
cleanupErrors.push(error);
|
|
28439
|
-
}
|
|
28440
|
-
}
|
|
28441
|
-
try {
|
|
28442
|
-
await rm4(root, { recursive: true, force: true });
|
|
28443
|
-
} catch (error) {
|
|
28444
|
-
cleanupErrors.push(error);
|
|
28445
|
-
}
|
|
28446
|
-
if (cleanupErrors.length > 0) {
|
|
28447
|
-
options.onCleanupDiagnostic?.([
|
|
28448
|
-
"reviewer worktree cleanup failed",
|
|
28449
|
-
...cleanupErrors.map((error) => error instanceof Error ? error.message : String(error))
|
|
28450
|
-
].join("\n"));
|
|
28451
|
-
}
|
|
28452
|
-
throw cause;
|
|
28453
|
-
};
|
|
28454
|
-
try {
|
|
28455
|
-
await execFileAsync3("git", ["worktree", "add", "--detach", worktreeRoot, targetCommit], {
|
|
28456
|
-
cwd: sourceProjectRoot
|
|
28457
|
-
});
|
|
28458
|
-
registered = true;
|
|
28459
|
-
if (projectRelative !== "") {
|
|
28460
|
-
await mkdir4(reviewerSandboxPath(worktreeRoot, projectRelative), { recursive: true });
|
|
28461
|
-
}
|
|
28462
|
-
} catch (error) {
|
|
28463
|
-
await rollback(error);
|
|
28464
|
-
}
|
|
28465
|
-
let closed = false;
|
|
28466
|
-
return {
|
|
28467
|
-
executionCwd: reviewerSandboxPath(worktreeRoot, projectRelative),
|
|
28468
|
-
close: async () => {
|
|
28469
|
-
if (closed) return;
|
|
28470
|
-
closed = true;
|
|
28471
|
-
const cleanupErrors = [];
|
|
28472
|
-
try {
|
|
28473
|
-
await execFileAsync3("git", ["worktree", "remove", worktreeRoot], {
|
|
28474
|
-
cwd: sourceProjectRoot
|
|
28475
|
-
});
|
|
28476
|
-
} catch (error) {
|
|
28477
|
-
cleanupErrors.push(error);
|
|
28478
|
-
}
|
|
28479
|
-
try {
|
|
28480
|
-
await rm4(root, { recursive: true, force: true });
|
|
28481
|
-
} catch (error) {
|
|
28482
|
-
cleanupErrors.push(error);
|
|
28483
|
-
}
|
|
28484
|
-
if (cleanupErrors.length > 0) {
|
|
28485
|
-
options.onCleanupDiagnostic?.([
|
|
28486
|
-
"reviewer worktree cleanup failed",
|
|
28487
|
-
...cleanupErrors.map((error) => error instanceof Error ? error.message : String(error))
|
|
28488
|
-
].join("\n"));
|
|
28489
|
-
}
|
|
28490
|
-
}
|
|
28491
|
-
};
|
|
28492
|
-
}
|
|
28493
|
-
async function withEphemeralReviewerWorktree(options) {
|
|
28494
|
-
const sandbox = await openEphemeralReviewerWorktree({
|
|
28495
|
-
projectRoot: options.projectRoot,
|
|
28496
|
-
...options.onCleanupDiagnostic === void 0 ? {} : { onCleanupDiagnostic: options.onCleanupDiagnostic }
|
|
28497
|
-
});
|
|
28498
|
-
try {
|
|
28499
|
-
return await options.run(sandbox.executionCwd);
|
|
28500
|
-
} finally {
|
|
28501
|
-
await sandbox.close();
|
|
28502
|
-
}
|
|
28503
28393
|
}
|
|
28504
28394
|
async function summonParallelReviewerLenses(options) {
|
|
28505
28395
|
const describeFailure = (error) => {
|
|
@@ -28517,7 +28407,6 @@ async function summonParallelReviewerLenses(options) {
|
|
|
28517
28407
|
return { completeness: failure, correctness: failure };
|
|
28518
28408
|
};
|
|
28519
28409
|
let sourceProjectRoot;
|
|
28520
|
-
let projectRelative;
|
|
28521
28410
|
let targetCommit;
|
|
28522
28411
|
const statusArgs = [
|
|
28523
28412
|
"status",
|
|
@@ -28528,9 +28417,7 @@ async function summonParallelReviewerLenses(options) {
|
|
|
28528
28417
|
":(top,exclude).claude/worktrees/**"
|
|
28529
28418
|
];
|
|
28530
28419
|
try {
|
|
28531
|
-
|
|
28532
|
-
sourceProjectRoot = roots.sourceProjectRoot;
|
|
28533
|
-
projectRelative = roots.projectRelative;
|
|
28420
|
+
sourceProjectRoot = await resolveReviewerGitToplevel(options.projectRoot);
|
|
28534
28421
|
const { stdout: statusStdout } = await execFileAsync3("git", statusArgs, {
|
|
28535
28422
|
cwd: sourceProjectRoot
|
|
28536
28423
|
});
|
|
@@ -28556,65 +28443,37 @@ async function summonParallelReviewerLenses(options) {
|
|
|
28556
28443
|
} catch (error) {
|
|
28557
28444
|
return dualFailure(error);
|
|
28558
28445
|
}
|
|
28559
|
-
const
|
|
28560
|
-
|
|
28561
|
-
|
|
28562
|
-
|
|
28563
|
-
|
|
28564
|
-
|
|
28565
|
-
|
|
28566
|
-
|
|
28567
|
-
|
|
28568
|
-
|
|
28569
|
-
}
|
|
28570
|
-
|
|
28571
|
-
|
|
28572
|
-
|
|
28573
|
-
}
|
|
28574
|
-
|
|
28575
|
-
|
|
28576
|
-
|
|
28577
|
-
|
|
28578
|
-
|
|
28579
|
-
|
|
28580
|
-
|
|
28581
|
-
|
|
28582
|
-
|
|
28583
|
-
|
|
28584
|
-
|
|
28585
|
-
|
|
28586
|
-
|
|
28587
|
-
|
|
28588
|
-
|
|
28589
|
-
|
|
28590
|
-
executionCwd: sandbox,
|
|
28591
|
-
// Ordinary single-axis public semantics — not a nested court station.
|
|
28592
|
-
stationChild: false,
|
|
28593
|
-
home: options.home,
|
|
28594
|
-
...options.agentDir === void 0 ? {} : { agentDir: options.agentDir },
|
|
28595
|
-
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
28596
|
-
...options.model === void 0 ? {} : { model: options.model },
|
|
28597
|
-
...options.host === void 0 ? {} : { host: options.host },
|
|
28598
|
-
...options.engine === void 0 ? {} : { engine: options.engine },
|
|
28599
|
-
...options.engineModel === void 0 ? {} : { engineModel: options.engineModel },
|
|
28600
|
-
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
28601
|
-
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId },
|
|
28602
|
-
...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
|
|
28603
|
-
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
28604
|
-
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
28605
|
-
...options.principalAuthority === void 0 ? {} : { principalAuthority: options.principalAuthority },
|
|
28606
|
-
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
28607
|
-
});
|
|
28608
|
-
};
|
|
28609
|
-
const settled = await Promise.allSettled([
|
|
28610
|
-
summon("completeness", completenessRoot),
|
|
28611
|
-
summon("correctness", correctnessRoot)
|
|
28612
|
-
]);
|
|
28613
|
-
results = {
|
|
28614
|
-
completeness: settled[0].status === "fulfilled" ? settled[0].value : failedResult(settled[0].reason),
|
|
28615
|
-
correctness: settled[1].status === "fulfilled" ? settled[1].value : failedResult(settled[1].reason)
|
|
28616
|
-
};
|
|
28617
|
-
}
|
|
28446
|
+
const summon = (lens) => {
|
|
28447
|
+
return summonPublicRole({
|
|
28448
|
+
role: "reviewer",
|
|
28449
|
+
argv: withReviewerLens(options.argv, lens),
|
|
28450
|
+
cwd: options.cwd,
|
|
28451
|
+
// Ordinary single-axis public semantics — not a nested court station.
|
|
28452
|
+
stationChild: false,
|
|
28453
|
+
home: options.home,
|
|
28454
|
+
...options.agentDir === void 0 ? {} : { agentDir: options.agentDir },
|
|
28455
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
28456
|
+
...options.model === void 0 ? {} : { model: options.model },
|
|
28457
|
+
...options.host === void 0 ? {} : { host: options.host },
|
|
28458
|
+
...options.engine === void 0 ? {} : { engine: options.engine },
|
|
28459
|
+
...options.engineModel === void 0 ? {} : { engineModel: options.engineModel },
|
|
28460
|
+
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
28461
|
+
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId },
|
|
28462
|
+
...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
|
|
28463
|
+
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
28464
|
+
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
28465
|
+
...options.principalAuthority === void 0 ? {} : { principalAuthority: options.principalAuthority },
|
|
28466
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
28467
|
+
});
|
|
28468
|
+
};
|
|
28469
|
+
const settled = await Promise.allSettled([
|
|
28470
|
+
summon("completeness"),
|
|
28471
|
+
summon("correctness")
|
|
28472
|
+
]);
|
|
28473
|
+
let results = {
|
|
28474
|
+
completeness: settled[0].status === "fulfilled" ? settled[0].value : failedResult(settled[0].reason),
|
|
28475
|
+
correctness: settled[1].status === "fulfilled" ? settled[1].value : failedResult(settled[1].reason)
|
|
28476
|
+
};
|
|
28618
28477
|
let sealDiagnostic;
|
|
28619
28478
|
try {
|
|
28620
28479
|
const { stdout: headBeforeStdout } = await execFileAsync3(
|
|
@@ -28659,30 +28518,6 @@ ${describeFailure(error)}`;
|
|
|
28659
28518
|
correctness: withSealFailure(results.correctness)
|
|
28660
28519
|
};
|
|
28661
28520
|
}
|
|
28662
|
-
const cleanup = await Promise.allSettled(
|
|
28663
|
-
[...created].map((path) => execFileAsync3("git", ["worktree", "remove", path], { cwd: sourceProjectRoot }))
|
|
28664
|
-
);
|
|
28665
|
-
const cleanupFailures = cleanup.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
28666
|
-
if (cleanupFailures.length === 0) {
|
|
28667
|
-
const rootCleanup = await Promise.allSettled([rm4(root, { recursive: true, force: true })]);
|
|
28668
|
-
cleanupFailures.push(...rootCleanup.flatMap((result) => result.status === "rejected" ? [result.reason] : []));
|
|
28669
|
-
}
|
|
28670
|
-
if (cleanupFailures.length > 0) {
|
|
28671
|
-
const diagnostic = [
|
|
28672
|
-
"parallel reviewer worktree cleanup failed",
|
|
28673
|
-
...cleanupFailures.map((failure) => failure instanceof Error ? failure.message : String(failure))
|
|
28674
|
-
].join("\n");
|
|
28675
|
-
const withCleanupDiagnostic = (result) => ({
|
|
28676
|
-
...result,
|
|
28677
|
-
stderr: [result.stderr, diagnostic].filter(
|
|
28678
|
-
(text) => typeof text === "string" && text !== ""
|
|
28679
|
-
).join("\n")
|
|
28680
|
-
});
|
|
28681
|
-
results = {
|
|
28682
|
-
completeness: withCleanupDiagnostic(results.completeness),
|
|
28683
|
-
correctness: withCleanupDiagnostic(results.correctness)
|
|
28684
|
-
};
|
|
28685
|
-
}
|
|
28686
28521
|
return results;
|
|
28687
28522
|
}
|
|
28688
28523
|
async function summonGateOfficer(options) {
|
|
@@ -28987,13 +28822,6 @@ function initialPrompt(admitted, env) {
|
|
|
28987
28822
|
})
|
|
28988
28823
|
);
|
|
28989
28824
|
}
|
|
28990
|
-
function hostTurnCwd(env) {
|
|
28991
|
-
return env.executionCwd === void 0 ? void 0 : { cwd: env.executionCwd };
|
|
28992
|
-
}
|
|
28993
|
-
function wantsFreshExecutionCopy(role) {
|
|
28994
|
-
const record4 = roleRecord(role);
|
|
28995
|
-
return "freshExecutionCopy" in record4 && record4.freshExecutionCopy === true;
|
|
28996
|
-
}
|
|
28997
28825
|
function infraFailure(role) {
|
|
28998
28826
|
const resolveRunnerKnownFailure = seatKnownFailureResolver(role);
|
|
28999
28827
|
return resolveRunnerKnownFailure === void 0 ? {} : { resolveRunnerKnownFailure };
|
|
@@ -29084,7 +28912,6 @@ async function dispatchAdmitted(admitted, env, io) {
|
|
|
29084
28912
|
const adapters = seatAdapters(admitted, env, material);
|
|
29085
28913
|
const execute = async (activeEnv) => {
|
|
29086
28914
|
const auto = "inCallAutoResume" in record4 && record4.inCallAutoResume === true;
|
|
29087
|
-
const cwd = hostTurnCwd(activeEnv);
|
|
29088
28915
|
if (auto) {
|
|
29089
28916
|
return await runPostAdmissionResumable({
|
|
29090
28917
|
admitted,
|
|
@@ -29092,7 +28919,7 @@ async function dispatchAdmitted(admitted, env, io) {
|
|
|
29092
28919
|
io,
|
|
29093
28920
|
buildInitialRequest: () => buildInstructionSeatTurnRequest(
|
|
29094
28921
|
admitted,
|
|
29095
|
-
roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) }
|
|
28922
|
+
roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) })
|
|
29096
28923
|
),
|
|
29097
28924
|
buildResumeRequest: () => buildInstructionSeatTurnRequest(
|
|
29098
28925
|
admitted,
|
|
@@ -29102,7 +28929,7 @@ async function dispatchAdmitted(admitted, env, io) {
|
|
|
29102
28929
|
packageRoot: activeEnv.packageRoot,
|
|
29103
28930
|
...pickEngineAxis(activeEnv)
|
|
29104
28931
|
})
|
|
29105
|
-
}
|
|
28932
|
+
})
|
|
29106
28933
|
),
|
|
29107
28934
|
adapters,
|
|
29108
28935
|
...activeEnv.engine === void 0 ? {} : { effectiveEngine: activeEnv.engine }
|
|
@@ -29114,32 +28941,13 @@ async function dispatchAdmitted(admitted, env, io) {
|
|
|
29114
28941
|
io,
|
|
29115
28942
|
request: buildInstructionSeatTurnRequest(
|
|
29116
28943
|
admitted,
|
|
29117
|
-
roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) }
|
|
28944
|
+
roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) })
|
|
29118
28945
|
),
|
|
29119
28946
|
adapters,
|
|
29120
28947
|
...activeEnv.engine === void 0 ? {} : { effectiveEngine: activeEnv.engine }
|
|
29121
28948
|
});
|
|
29122
28949
|
};
|
|
29123
|
-
|
|
29124
|
-
try {
|
|
29125
|
-
if (env.executionCwd !== void 0) return await execute(env);
|
|
29126
|
-
const { withEphemeralReviewerWorktree: withEphemeralReviewerWorktree2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
29127
|
-
return await withEphemeralReviewerWorktree2({
|
|
29128
|
-
projectRoot: admitted.projectRoot,
|
|
29129
|
-
onCleanupDiagnostic: (diagnostic) => {
|
|
29130
|
-
io.stderr(`${diagnostic}
|
|
29131
|
-
`);
|
|
29132
|
-
},
|
|
29133
|
-
run: (executionCwd) => execute({ ...env, executionCwd })
|
|
29134
|
-
});
|
|
29135
|
-
} catch (error) {
|
|
29136
|
-
return await presentControlledFailure2(admitted, {
|
|
29137
|
-
timedOut: false,
|
|
29138
|
-
code: null,
|
|
29139
|
-
stderr: "",
|
|
29140
|
-
thrown: error
|
|
29141
|
-
}, adapters, env.principalAuthority, io);
|
|
29142
|
-
}
|
|
28950
|
+
return execute(env);
|
|
29143
28951
|
}
|
|
29144
28952
|
async function runOmittedLensBatch(argv2, parsed, env, io) {
|
|
29145
28953
|
const { summonParallelReviewerLenses: summonParallelReviewerLenses2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
@@ -29562,9 +29370,6 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
29562
29370
|
return runAdmitted();
|
|
29563
29371
|
}
|
|
29564
29372
|
async function runPublicInstructionSeatResume(request, env, io) {
|
|
29565
|
-
const execution = {
|
|
29566
|
-
...env.executionCwd === void 0 ? {} : { cwd: env.executionCwd }
|
|
29567
|
-
};
|
|
29568
29373
|
return runPostAdmissionSeatResume({
|
|
29569
29374
|
request,
|
|
29570
29375
|
env,
|
|
@@ -29584,13 +29389,11 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
29584
29389
|
return loaded;
|
|
29585
29390
|
},
|
|
29586
29391
|
buildTurnRequest: async (admitted, effective) => {
|
|
29587
|
-
const activeEnv = execution.cwd === void 0 ? env : { ...env, executionCwd: execution.cwd };
|
|
29588
29392
|
const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
|
|
29589
29393
|
return buildInstructionSeatTurnRequest(
|
|
29590
29394
|
admitted,
|
|
29591
29395
|
{
|
|
29592
|
-
...resumeTurnRequestProjectionOptions(admitted, effective,
|
|
29593
|
-
...execution.cwd === void 0 ? {} : { cwd: execution.cwd }
|
|
29396
|
+
...resumeTurnRequestProjectionOptions(admitted, effective, env, summonsPrepared)
|
|
29594
29397
|
}
|
|
29595
29398
|
);
|
|
29596
29399
|
},
|
|
@@ -29613,25 +29416,6 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
29613
29416
|
...knownCause === void 0 ? {} : { knownCause }
|
|
29614
29417
|
});
|
|
29615
29418
|
},
|
|
29616
|
-
afterAdmittedPrepare: async (admitted) => {
|
|
29617
|
-
if (!wantsFreshExecutionCopy(admitted.role)) return {};
|
|
29618
|
-
if (execution.cwd !== void 0) {
|
|
29619
|
-
return { env: { ...env, executionCwd: execution.cwd } };
|
|
29620
|
-
}
|
|
29621
|
-
const { openEphemeralReviewerWorktree: openEphemeralReviewerWorktree2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
29622
|
-
const opened = await openEphemeralReviewerWorktree2({
|
|
29623
|
-
projectRoot: admitted.projectRoot,
|
|
29624
|
-
onCleanupDiagnostic: (diagnostic) => {
|
|
29625
|
-
io.stderr(`${diagnostic}
|
|
29626
|
-
`);
|
|
29627
|
-
}
|
|
29628
|
-
});
|
|
29629
|
-
execution.cwd = opened.executionCwd;
|
|
29630
|
-
return {
|
|
29631
|
-
env: { ...env, executionCwd: opened.executionCwd },
|
|
29632
|
-
cleanup: opened.close
|
|
29633
|
-
};
|
|
29634
|
-
},
|
|
29635
29419
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
29636
29420
|
});
|
|
29637
29421
|
}
|
|
@@ -29692,7 +29476,7 @@ var init_analyst_book_key = __esm({
|
|
|
29692
29476
|
|
|
29693
29477
|
// src/atomic-write.ts
|
|
29694
29478
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
29695
|
-
import { rename as rename3, rm as
|
|
29479
|
+
import { rename as rename3, rm as rm4, writeFile as writeFile9 } from "node:fs/promises";
|
|
29696
29480
|
import { dirname as dirname16, join as join31 } from "node:path";
|
|
29697
29481
|
async function writeFileAtomically(destination, contents) {
|
|
29698
29482
|
const parent = dirname16(destination);
|
|
@@ -29701,7 +29485,7 @@ async function writeFileAtomically(destination, contents) {
|
|
|
29701
29485
|
await writeFile9(temporary, contents);
|
|
29702
29486
|
await rename3(temporary, destination);
|
|
29703
29487
|
} catch (error) {
|
|
29704
|
-
await
|
|
29488
|
+
await rm4(temporary, { force: true }).catch(() => void 0);
|
|
29705
29489
|
throw error;
|
|
29706
29490
|
}
|
|
29707
29491
|
}
|