@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
|
@@ -4391,8 +4391,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4391
4391
|
settleMethod: "ak-cross-m-review",
|
|
4392
4392
|
/** Omitted public lens starts two ordinary single-axis runs (ADR 0052). */
|
|
4393
4393
|
parallelLenses: true,
|
|
4394
|
-
/** Every turn runs in a fresh worktree; durable projectRoot stays the caller project (#946). */
|
|
4395
|
-
freshExecutionCopy: true,
|
|
4396
4394
|
phases: [null],
|
|
4397
4395
|
bareCommand: false,
|
|
4398
4396
|
outputTool: REVIEWER_OUTPUT_TOOL_NAME,
|
|
@@ -4907,9 +4905,9 @@ async function readRunTerminalArtifact(runDirectory) {
|
|
|
4907
4905
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
4908
4906
|
consider(await readTerminalArtifactAtPath(join8(artifactsDir, file), file));
|
|
4909
4907
|
}
|
|
4910
|
-
for (const
|
|
4908
|
+
for (const relative4 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
4911
4909
|
consider(
|
|
4912
|
-
await readTerminalArtifactAtPath(join8(runDirectory,
|
|
4910
|
+
await readTerminalArtifactAtPath(join8(runDirectory, relative4), "error.json")
|
|
4913
4911
|
);
|
|
4914
4912
|
}
|
|
4915
4913
|
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
@@ -11146,11 +11144,11 @@ function parseAnalystCohortIssueToken(raw, flag) {
|
|
|
11146
11144
|
`${flag} requires a comma-separated list of N or book:N`
|
|
11147
11145
|
);
|
|
11148
11146
|
}
|
|
11149
|
-
const
|
|
11150
|
-
if (
|
|
11151
|
-
const rhs = trimmed.slice(
|
|
11147
|
+
const sep6 = trimmed.lastIndexOf(":");
|
|
11148
|
+
if (sep6 > 0) {
|
|
11149
|
+
const rhs = trimmed.slice(sep6 + 1);
|
|
11152
11150
|
if (ANALYST_TICKET_NUMBER_PATTERN.test(rhs)) {
|
|
11153
|
-
const bookKey = trimmed.slice(0,
|
|
11151
|
+
const bookKey = trimmed.slice(0, sep6);
|
|
11154
11152
|
if (bookKey.trim() === "") {
|
|
11155
11153
|
throw new CliUsageError(
|
|
11156
11154
|
`${flag} book:N requires a non-empty book key, got ${raw}`
|
|
@@ -15466,8 +15464,8 @@ async function clearOppositeTerminalArtifactFace(runDirectory) {
|
|
|
15466
15464
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
15467
15465
|
await removeFaceIfPresent(join28(artifactsDir, file));
|
|
15468
15466
|
}
|
|
15469
|
-
for (const
|
|
15470
|
-
await removeFaceIfPresent(join28(runDirectory,
|
|
15467
|
+
for (const relative4 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
15468
|
+
await removeFaceIfPresent(join28(runDirectory, relative4));
|
|
15471
15469
|
}
|
|
15472
15470
|
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
15473
15471
|
await removeFaceIfPresent(path);
|
|
@@ -18274,7 +18272,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
18274
18272
|
...env.stationChild === void 0 ? {} : { stationChild: env.stationChild }
|
|
18275
18273
|
};
|
|
18276
18274
|
}
|
|
18277
|
-
function roleTurnOptions(env, admitted, continuation
|
|
18275
|
+
function roleTurnOptions(env, admitted, continuation) {
|
|
18278
18276
|
const correlationId = admitted.correlationId ?? env.correlationId;
|
|
18279
18277
|
return {
|
|
18280
18278
|
packageRoot: env.packageRoot,
|
|
@@ -18285,7 +18283,6 @@ function roleTurnOptions(env, admitted, continuation, extra) {
|
|
|
18285
18283
|
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
18286
18284
|
...correlationId === void 0 || correlationId.trim() === "" ? {} : { correlationId },
|
|
18287
18285
|
continuation,
|
|
18288
|
-
...extra?.cwd === void 0 ? {} : { cwd: extra.cwd },
|
|
18289
18286
|
...env.stationChild === void 0 ? {} : { stationChild: env.stationChild }
|
|
18290
18287
|
};
|
|
18291
18288
|
}
|
|
@@ -18345,8 +18342,7 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
18345
18342
|
}
|
|
18346
18343
|
adapters = prepared.adapters;
|
|
18347
18344
|
}
|
|
18348
|
-
|
|
18349
|
-
let preparedCleanup;
|
|
18345
|
+
const env = input.env;
|
|
18350
18346
|
const buildRequestAfterLease = async () => {
|
|
18351
18347
|
let openCourtAttemptId;
|
|
18352
18348
|
const admittedForBuild = loaded.admitted;
|
|
@@ -18401,11 +18397,6 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
18401
18397
|
return turnRequest;
|
|
18402
18398
|
};
|
|
18403
18399
|
try {
|
|
18404
|
-
if (input.afterAdmittedPrepare !== void 0) {
|
|
18405
|
-
const prepared = await input.afterAdmittedPrepare(loaded.admitted);
|
|
18406
|
-
if (prepared.env !== void 0) env = prepared.env;
|
|
18407
|
-
preparedCleanup = prepared.cleanup;
|
|
18408
|
-
}
|
|
18409
18400
|
if (env.stationChild === true) {
|
|
18410
18401
|
let firstTurn;
|
|
18411
18402
|
const stationAdapters = withOnceSuccessfulBeforeDispatch(adapters);
|
|
@@ -18482,10 +18473,6 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
18482
18473
|
return { exitCode: 2 };
|
|
18483
18474
|
}
|
|
18484
18475
|
throw error;
|
|
18485
|
-
} finally {
|
|
18486
|
-
if (preparedCleanup !== void 0) {
|
|
18487
|
-
await preparedCleanup();
|
|
18488
|
-
}
|
|
18489
18476
|
}
|
|
18490
18477
|
}
|
|
18491
18478
|
async function runPostAdmissionOneShot(input) {
|
|
@@ -18643,7 +18630,7 @@ var init_seat_ticket_binding = __esm({
|
|
|
18643
18630
|
|
|
18644
18631
|
// src/public-cli/turn-request.ts
|
|
18645
18632
|
function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
18646
|
-
const cwd =
|
|
18633
|
+
const cwd = admitted.projectRoot ?? admitted.repoRoot ?? admitted.cwd;
|
|
18647
18634
|
if (cwd === void 0) throw new Error("admitted invocation missing working directory");
|
|
18648
18635
|
if (admitted.principal === void 0) throw new Error("admitted invocation missing principal");
|
|
18649
18636
|
return {
|
|
@@ -18952,13 +18939,6 @@ function initialPrompt(admitted, env) {
|
|
|
18952
18939
|
})
|
|
18953
18940
|
);
|
|
18954
18941
|
}
|
|
18955
|
-
function hostTurnCwd(env) {
|
|
18956
|
-
return env.executionCwd === void 0 ? void 0 : { cwd: env.executionCwd };
|
|
18957
|
-
}
|
|
18958
|
-
function wantsFreshExecutionCopy(role) {
|
|
18959
|
-
const record4 = roleRecord(role);
|
|
18960
|
-
return "freshExecutionCopy" in record4 && record4.freshExecutionCopy === true;
|
|
18961
|
-
}
|
|
18962
18942
|
function infraFailure(role) {
|
|
18963
18943
|
const resolveRunnerKnownFailure = seatKnownFailureResolver(role);
|
|
18964
18944
|
return resolveRunnerKnownFailure === void 0 ? {} : { resolveRunnerKnownFailure };
|
|
@@ -19049,7 +19029,6 @@ async function dispatchAdmitted(admitted, env, io) {
|
|
|
19049
19029
|
const adapters = seatAdapters(admitted, env, material);
|
|
19050
19030
|
const execute = async (activeEnv) => {
|
|
19051
19031
|
const auto = "inCallAutoResume" in record4 && record4.inCallAutoResume === true;
|
|
19052
|
-
const cwd = hostTurnCwd(activeEnv);
|
|
19053
19032
|
if (auto) {
|
|
19054
19033
|
return await runPostAdmissionResumable({
|
|
19055
19034
|
admitted,
|
|
@@ -19057,7 +19036,7 @@ async function dispatchAdmitted(admitted, env, io) {
|
|
|
19057
19036
|
io,
|
|
19058
19037
|
buildInitialRequest: () => buildInstructionSeatTurnRequest(
|
|
19059
19038
|
admitted,
|
|
19060
|
-
roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) }
|
|
19039
|
+
roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) })
|
|
19061
19040
|
),
|
|
19062
19041
|
buildResumeRequest: () => buildInstructionSeatTurnRequest(
|
|
19063
19042
|
admitted,
|
|
@@ -19067,7 +19046,7 @@ async function dispatchAdmitted(admitted, env, io) {
|
|
|
19067
19046
|
packageRoot: activeEnv.packageRoot,
|
|
19068
19047
|
...pickEngineAxis(activeEnv)
|
|
19069
19048
|
})
|
|
19070
|
-
}
|
|
19049
|
+
})
|
|
19071
19050
|
),
|
|
19072
19051
|
adapters,
|
|
19073
19052
|
...activeEnv.engine === void 0 ? {} : { effectiveEngine: activeEnv.engine }
|
|
@@ -19079,32 +19058,13 @@ async function dispatchAdmitted(admitted, env, io) {
|
|
|
19079
19058
|
io,
|
|
19080
19059
|
request: buildInstructionSeatTurnRequest(
|
|
19081
19060
|
admitted,
|
|
19082
|
-
roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) }
|
|
19061
|
+
roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) })
|
|
19083
19062
|
),
|
|
19084
19063
|
adapters,
|
|
19085
19064
|
...activeEnv.engine === void 0 ? {} : { effectiveEngine: activeEnv.engine }
|
|
19086
19065
|
});
|
|
19087
19066
|
};
|
|
19088
|
-
|
|
19089
|
-
try {
|
|
19090
|
-
if (env.executionCwd !== void 0) return await execute(env);
|
|
19091
|
-
const { withEphemeralReviewerWorktree: withEphemeralReviewerWorktree2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
19092
|
-
return await withEphemeralReviewerWorktree2({
|
|
19093
|
-
projectRoot: admitted.projectRoot,
|
|
19094
|
-
onCleanupDiagnostic: (diagnostic) => {
|
|
19095
|
-
io.stderr(`${diagnostic}
|
|
19096
|
-
`);
|
|
19097
|
-
},
|
|
19098
|
-
run: (executionCwd) => execute({ ...env, executionCwd })
|
|
19099
|
-
});
|
|
19100
|
-
} catch (error) {
|
|
19101
|
-
return await presentControlledFailure2(admitted, {
|
|
19102
|
-
timedOut: false,
|
|
19103
|
-
code: null,
|
|
19104
|
-
stderr: "",
|
|
19105
|
-
thrown: error
|
|
19106
|
-
}, adapters, env.principalAuthority, io);
|
|
19107
|
-
}
|
|
19067
|
+
return execute(env);
|
|
19108
19068
|
}
|
|
19109
19069
|
async function runOmittedLensBatch(argv, parsed, env, io) {
|
|
19110
19070
|
const { summonParallelReviewerLenses: summonParallelReviewerLenses2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
@@ -19527,9 +19487,6 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
19527
19487
|
return runAdmitted();
|
|
19528
19488
|
}
|
|
19529
19489
|
async function runPublicInstructionSeatResume(request, env, io) {
|
|
19530
|
-
const execution = {
|
|
19531
|
-
...env.executionCwd === void 0 ? {} : { cwd: env.executionCwd }
|
|
19532
|
-
};
|
|
19533
19490
|
return runPostAdmissionSeatResume({
|
|
19534
19491
|
request,
|
|
19535
19492
|
env,
|
|
@@ -19549,13 +19506,11 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
19549
19506
|
return loaded;
|
|
19550
19507
|
},
|
|
19551
19508
|
buildTurnRequest: async (admitted, effective) => {
|
|
19552
|
-
const activeEnv = execution.cwd === void 0 ? env : { ...env, executionCwd: execution.cwd };
|
|
19553
19509
|
const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
|
|
19554
19510
|
return buildInstructionSeatTurnRequest(
|
|
19555
19511
|
admitted,
|
|
19556
19512
|
{
|
|
19557
|
-
...resumeTurnRequestProjectionOptions(admitted, effective,
|
|
19558
|
-
...execution.cwd === void 0 ? {} : { cwd: execution.cwd }
|
|
19513
|
+
...resumeTurnRequestProjectionOptions(admitted, effective, env, summonsPrepared)
|
|
19559
19514
|
}
|
|
19560
19515
|
);
|
|
19561
19516
|
},
|
|
@@ -19578,25 +19533,6 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
19578
19533
|
...knownCause === void 0 ? {} : { knownCause }
|
|
19579
19534
|
});
|
|
19580
19535
|
},
|
|
19581
|
-
afterAdmittedPrepare: async (admitted) => {
|
|
19582
|
-
if (!wantsFreshExecutionCopy(admitted.role)) return {};
|
|
19583
|
-
if (execution.cwd !== void 0) {
|
|
19584
|
-
return { env: { ...env, executionCwd: execution.cwd } };
|
|
19585
|
-
}
|
|
19586
|
-
const { openEphemeralReviewerWorktree: openEphemeralReviewerWorktree2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
19587
|
-
const opened = await openEphemeralReviewerWorktree2({
|
|
19588
|
-
projectRoot: admitted.projectRoot,
|
|
19589
|
-
onCleanupDiagnostic: (diagnostic) => {
|
|
19590
|
-
io.stderr(`${diagnostic}
|
|
19591
|
-
`);
|
|
19592
|
-
}
|
|
19593
|
-
});
|
|
19594
|
-
execution.cwd = opened.executionCwd;
|
|
19595
|
-
return {
|
|
19596
|
-
env: { ...env, executionCwd: opened.executionCwd },
|
|
19597
|
-
cleanup: opened.close
|
|
19598
|
-
};
|
|
19599
|
-
},
|
|
19600
19536
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
19601
19537
|
});
|
|
19602
19538
|
}
|
|
@@ -22663,18 +22599,15 @@ var init_cli = __esm({
|
|
|
22663
22599
|
var public_role_summons_exports = {};
|
|
22664
22600
|
__export(public_role_summons_exports, {
|
|
22665
22601
|
AK_ROLE_PACKAGE_ROOT_ENV: () => AK_ROLE_PACKAGE_ROOT_ENV,
|
|
22666
|
-
openEphemeralReviewerWorktree: () => openEphemeralReviewerWorktree,
|
|
22667
22602
|
resolveSummonsPackageRoot: () => resolveSummonsPackageRoot,
|
|
22668
22603
|
summonGateOfficer: () => summonGateOfficer,
|
|
22669
22604
|
summonParallelReviewerLenses: () => summonParallelReviewerLenses,
|
|
22670
|
-
summonPublicRole: () => summonPublicRole
|
|
22671
|
-
withEphemeralReviewerWorktree: () => withEphemeralReviewerWorktree
|
|
22605
|
+
summonPublicRole: () => summonPublicRole
|
|
22672
22606
|
});
|
|
22673
22607
|
import { execFile as execFile3 } from "node:child_process";
|
|
22674
22608
|
import { existsSync as existsSync11 } from "node:fs";
|
|
22675
|
-
import {
|
|
22676
|
-
import {
|
|
22677
|
-
import { join as join40, relative as relative3, sep as sep5 } from "node:path";
|
|
22609
|
+
import { realpath as realpath7 } from "node:fs/promises";
|
|
22610
|
+
import { join as join40 } from "node:path";
|
|
22678
22611
|
import { promisify as promisify3 } from "node:util";
|
|
22679
22612
|
function createCapturingIo() {
|
|
22680
22613
|
const chunks = [];
|
|
@@ -22876,8 +22809,7 @@ async function summonPublicRole(options) {
|
|
|
22876
22809
|
...options.boundTicketNumber === void 0 ? {} : { boundTicketNumber: options.boundTicketNumber },
|
|
22877
22810
|
...options.parentRunPath === void 0 || options.parentRunPath.trim() === "" ? {} : { parentRunPath: options.parentRunPath },
|
|
22878
22811
|
...options.correlationId === void 0 || options.correlationId.trim() === "" ? {} : { correlationId: options.correlationId },
|
|
22879
|
-
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
|
|
22880
|
-
...options.executionCwd === void 0 ? {} : { executionCwd: options.executionCwd }
|
|
22812
|
+
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
|
|
22881
22813
|
}
|
|
22882
22814
|
};
|
|
22883
22815
|
} catch (error) {
|
|
@@ -22957,106 +22889,13 @@ function withReviewerLens(argv, lens) {
|
|
|
22957
22889
|
if (separator === -1) return [...argv, "--lens", lens];
|
|
22958
22890
|
return [...argv.slice(0, separator), "--lens", lens, ...argv.slice(separator)];
|
|
22959
22891
|
}
|
|
22960
|
-
async function
|
|
22892
|
+
async function resolveReviewerGitToplevel(projectRoot) {
|
|
22961
22893
|
const callerProjectRoot = await realpath7(projectRoot);
|
|
22962
|
-
|
|
22894
|
+
return await realpath7((await execFileAsync3(
|
|
22963
22895
|
"git",
|
|
22964
22896
|
["rev-parse", "--show-toplevel"],
|
|
22965
22897
|
{ cwd: callerProjectRoot }
|
|
22966
22898
|
)).stdout.trim());
|
|
22967
|
-
const callerRelative = relative3(sourceProjectRoot, callerProjectRoot);
|
|
22968
|
-
const projectRelative = callerRelative === "" || callerRelative === "." || callerRelative.startsWith(`..${sep5}`) || callerRelative === ".." ? "" : callerRelative;
|
|
22969
|
-
return { callerProjectRoot, sourceProjectRoot, projectRelative };
|
|
22970
|
-
}
|
|
22971
|
-
function reviewerSandboxPath(worktreeAxis, projectRelative) {
|
|
22972
|
-
return projectRelative === "" ? worktreeAxis : join40(worktreeAxis, projectRelative);
|
|
22973
|
-
}
|
|
22974
|
-
async function openEphemeralReviewerWorktree(options) {
|
|
22975
|
-
const { sourceProjectRoot, projectRelative } = await resolveReviewerWorktreeRoots(
|
|
22976
|
-
options.projectRoot
|
|
22977
|
-
);
|
|
22978
|
-
const { stdout: headStdout } = await execFileAsync3(
|
|
22979
|
-
"git",
|
|
22980
|
-
["rev-parse", "--verify", "HEAD^{commit}"],
|
|
22981
|
-
{ cwd: sourceProjectRoot }
|
|
22982
|
-
);
|
|
22983
|
-
const targetCommit = headStdout.trim();
|
|
22984
|
-
const root = await mkdtemp4(join40(tmpdir4(), "ak-reviewer-sandbox-"));
|
|
22985
|
-
const worktreeRoot = join40(root, "work");
|
|
22986
|
-
let registered = false;
|
|
22987
|
-
const rollback = async (cause) => {
|
|
22988
|
-
const cleanupErrors = [];
|
|
22989
|
-
if (registered) {
|
|
22990
|
-
try {
|
|
22991
|
-
await execFileAsync3("git", ["worktree", "remove", "--force", worktreeRoot], {
|
|
22992
|
-
cwd: sourceProjectRoot
|
|
22993
|
-
});
|
|
22994
|
-
} catch (error) {
|
|
22995
|
-
cleanupErrors.push(error);
|
|
22996
|
-
}
|
|
22997
|
-
}
|
|
22998
|
-
try {
|
|
22999
|
-
await rm6(root, { recursive: true, force: true });
|
|
23000
|
-
} catch (error) {
|
|
23001
|
-
cleanupErrors.push(error);
|
|
23002
|
-
}
|
|
23003
|
-
if (cleanupErrors.length > 0) {
|
|
23004
|
-
options.onCleanupDiagnostic?.([
|
|
23005
|
-
"reviewer worktree cleanup failed",
|
|
23006
|
-
...cleanupErrors.map((error) => error instanceof Error ? error.message : String(error))
|
|
23007
|
-
].join("\n"));
|
|
23008
|
-
}
|
|
23009
|
-
throw cause;
|
|
23010
|
-
};
|
|
23011
|
-
try {
|
|
23012
|
-
await execFileAsync3("git", ["worktree", "add", "--detach", worktreeRoot, targetCommit], {
|
|
23013
|
-
cwd: sourceProjectRoot
|
|
23014
|
-
});
|
|
23015
|
-
registered = true;
|
|
23016
|
-
if (projectRelative !== "") {
|
|
23017
|
-
await mkdir4(reviewerSandboxPath(worktreeRoot, projectRelative), { recursive: true });
|
|
23018
|
-
}
|
|
23019
|
-
} catch (error) {
|
|
23020
|
-
await rollback(error);
|
|
23021
|
-
}
|
|
23022
|
-
let closed = false;
|
|
23023
|
-
return {
|
|
23024
|
-
executionCwd: reviewerSandboxPath(worktreeRoot, projectRelative),
|
|
23025
|
-
close: async () => {
|
|
23026
|
-
if (closed) return;
|
|
23027
|
-
closed = true;
|
|
23028
|
-
const cleanupErrors = [];
|
|
23029
|
-
try {
|
|
23030
|
-
await execFileAsync3("git", ["worktree", "remove", worktreeRoot], {
|
|
23031
|
-
cwd: sourceProjectRoot
|
|
23032
|
-
});
|
|
23033
|
-
} catch (error) {
|
|
23034
|
-
cleanupErrors.push(error);
|
|
23035
|
-
}
|
|
23036
|
-
try {
|
|
23037
|
-
await rm6(root, { recursive: true, force: true });
|
|
23038
|
-
} catch (error) {
|
|
23039
|
-
cleanupErrors.push(error);
|
|
23040
|
-
}
|
|
23041
|
-
if (cleanupErrors.length > 0) {
|
|
23042
|
-
options.onCleanupDiagnostic?.([
|
|
23043
|
-
"reviewer worktree cleanup failed",
|
|
23044
|
-
...cleanupErrors.map((error) => error instanceof Error ? error.message : String(error))
|
|
23045
|
-
].join("\n"));
|
|
23046
|
-
}
|
|
23047
|
-
}
|
|
23048
|
-
};
|
|
23049
|
-
}
|
|
23050
|
-
async function withEphemeralReviewerWorktree(options) {
|
|
23051
|
-
const sandbox = await openEphemeralReviewerWorktree({
|
|
23052
|
-
projectRoot: options.projectRoot,
|
|
23053
|
-
...options.onCleanupDiagnostic === void 0 ? {} : { onCleanupDiagnostic: options.onCleanupDiagnostic }
|
|
23054
|
-
});
|
|
23055
|
-
try {
|
|
23056
|
-
return await options.run(sandbox.executionCwd);
|
|
23057
|
-
} finally {
|
|
23058
|
-
await sandbox.close();
|
|
23059
|
-
}
|
|
23060
22899
|
}
|
|
23061
22900
|
async function summonParallelReviewerLenses(options) {
|
|
23062
22901
|
const describeFailure = (error) => {
|
|
@@ -23074,7 +22913,6 @@ async function summonParallelReviewerLenses(options) {
|
|
|
23074
22913
|
return { completeness: failure2, correctness: failure2 };
|
|
23075
22914
|
};
|
|
23076
22915
|
let sourceProjectRoot;
|
|
23077
|
-
let projectRelative;
|
|
23078
22916
|
let targetCommit;
|
|
23079
22917
|
const statusArgs = [
|
|
23080
22918
|
"status",
|
|
@@ -23085,9 +22923,7 @@ async function summonParallelReviewerLenses(options) {
|
|
|
23085
22923
|
":(top,exclude).claude/worktrees/**"
|
|
23086
22924
|
];
|
|
23087
22925
|
try {
|
|
23088
|
-
|
|
23089
|
-
sourceProjectRoot = roots.sourceProjectRoot;
|
|
23090
|
-
projectRelative = roots.projectRelative;
|
|
22926
|
+
sourceProjectRoot = await resolveReviewerGitToplevel(options.projectRoot);
|
|
23091
22927
|
const { stdout: statusStdout } = await execFileAsync3("git", statusArgs, {
|
|
23092
22928
|
cwd: sourceProjectRoot
|
|
23093
22929
|
});
|
|
@@ -23113,65 +22949,37 @@ async function summonParallelReviewerLenses(options) {
|
|
|
23113
22949
|
} catch (error) {
|
|
23114
22950
|
return dualFailure(error);
|
|
23115
22951
|
}
|
|
23116
|
-
const
|
|
23117
|
-
|
|
23118
|
-
|
|
23119
|
-
|
|
23120
|
-
|
|
23121
|
-
|
|
23122
|
-
|
|
23123
|
-
|
|
23124
|
-
|
|
23125
|
-
|
|
23126
|
-
}
|
|
23127
|
-
|
|
23128
|
-
|
|
23129
|
-
|
|
23130
|
-
}
|
|
23131
|
-
|
|
23132
|
-
|
|
23133
|
-
|
|
23134
|
-
|
|
23135
|
-
|
|
23136
|
-
|
|
23137
|
-
|
|
23138
|
-
|
|
23139
|
-
|
|
23140
|
-
|
|
23141
|
-
|
|
23142
|
-
|
|
23143
|
-
|
|
23144
|
-
|
|
23145
|
-
|
|
23146
|
-
|
|
23147
|
-
executionCwd: sandbox,
|
|
23148
|
-
// Ordinary single-axis public semantics — not a nested court station.
|
|
23149
|
-
stationChild: false,
|
|
23150
|
-
home: options.home,
|
|
23151
|
-
...options.agentDir === void 0 ? {} : { agentDir: options.agentDir },
|
|
23152
|
-
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
23153
|
-
...options.model === void 0 ? {} : { model: options.model },
|
|
23154
|
-
...options.host === void 0 ? {} : { host: options.host },
|
|
23155
|
-
...options.engine === void 0 ? {} : { engine: options.engine },
|
|
23156
|
-
...options.engineModel === void 0 ? {} : { engineModel: options.engineModel },
|
|
23157
|
-
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
23158
|
-
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId },
|
|
23159
|
-
...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
|
|
23160
|
-
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
23161
|
-
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
23162
|
-
...options.principalAuthority === void 0 ? {} : { principalAuthority: options.principalAuthority },
|
|
23163
|
-
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
23164
|
-
});
|
|
23165
|
-
};
|
|
23166
|
-
const settled = await Promise.allSettled([
|
|
23167
|
-
summon("completeness", completenessRoot),
|
|
23168
|
-
summon("correctness", correctnessRoot)
|
|
23169
|
-
]);
|
|
23170
|
-
results = {
|
|
23171
|
-
completeness: settled[0].status === "fulfilled" ? settled[0].value : failedResult(settled[0].reason),
|
|
23172
|
-
correctness: settled[1].status === "fulfilled" ? settled[1].value : failedResult(settled[1].reason)
|
|
23173
|
-
};
|
|
23174
|
-
}
|
|
22952
|
+
const summon = (lens) => {
|
|
22953
|
+
return summonPublicRole({
|
|
22954
|
+
role: "reviewer",
|
|
22955
|
+
argv: withReviewerLens(options.argv, lens),
|
|
22956
|
+
cwd: options.cwd,
|
|
22957
|
+
// Ordinary single-axis public semantics — not a nested court station.
|
|
22958
|
+
stationChild: false,
|
|
22959
|
+
home: options.home,
|
|
22960
|
+
...options.agentDir === void 0 ? {} : { agentDir: options.agentDir },
|
|
22961
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
22962
|
+
...options.model === void 0 ? {} : { model: options.model },
|
|
22963
|
+
...options.host === void 0 ? {} : { host: options.host },
|
|
22964
|
+
...options.engine === void 0 ? {} : { engine: options.engine },
|
|
22965
|
+
...options.engineModel === void 0 ? {} : { engineModel: options.engineModel },
|
|
22966
|
+
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
22967
|
+
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId },
|
|
22968
|
+
...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
|
|
22969
|
+
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
22970
|
+
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
22971
|
+
...options.principalAuthority === void 0 ? {} : { principalAuthority: options.principalAuthority },
|
|
22972
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
22973
|
+
});
|
|
22974
|
+
};
|
|
22975
|
+
const settled = await Promise.allSettled([
|
|
22976
|
+
summon("completeness"),
|
|
22977
|
+
summon("correctness")
|
|
22978
|
+
]);
|
|
22979
|
+
let results = {
|
|
22980
|
+
completeness: settled[0].status === "fulfilled" ? settled[0].value : failedResult(settled[0].reason),
|
|
22981
|
+
correctness: settled[1].status === "fulfilled" ? settled[1].value : failedResult(settled[1].reason)
|
|
22982
|
+
};
|
|
23175
22983
|
let sealDiagnostic;
|
|
23176
22984
|
try {
|
|
23177
22985
|
const { stdout: headBeforeStdout } = await execFileAsync3(
|
|
@@ -23216,30 +23024,6 @@ ${describeFailure(error)}`;
|
|
|
23216
23024
|
correctness: withSealFailure(results.correctness)
|
|
23217
23025
|
};
|
|
23218
23026
|
}
|
|
23219
|
-
const cleanup = await Promise.allSettled(
|
|
23220
|
-
[...created].map((path) => execFileAsync3("git", ["worktree", "remove", path], { cwd: sourceProjectRoot }))
|
|
23221
|
-
);
|
|
23222
|
-
const cleanupFailures = cleanup.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
23223
|
-
if (cleanupFailures.length === 0) {
|
|
23224
|
-
const rootCleanup = await Promise.allSettled([rm6(root, { recursive: true, force: true })]);
|
|
23225
|
-
cleanupFailures.push(...rootCleanup.flatMap((result) => result.status === "rejected" ? [result.reason] : []));
|
|
23226
|
-
}
|
|
23227
|
-
if (cleanupFailures.length > 0) {
|
|
23228
|
-
const diagnostic = [
|
|
23229
|
-
"parallel reviewer worktree cleanup failed",
|
|
23230
|
-
...cleanupFailures.map((failure2) => failure2 instanceof Error ? failure2.message : String(failure2))
|
|
23231
|
-
].join("\n");
|
|
23232
|
-
const withCleanupDiagnostic = (result) => ({
|
|
23233
|
-
...result,
|
|
23234
|
-
stderr: [result.stderr, diagnostic].filter(
|
|
23235
|
-
(text) => typeof text === "string" && text !== ""
|
|
23236
|
-
).join("\n")
|
|
23237
|
-
});
|
|
23238
|
-
results = {
|
|
23239
|
-
completeness: withCleanupDiagnostic(results.completeness),
|
|
23240
|
-
correctness: withCleanupDiagnostic(results.correctness)
|
|
23241
|
-
};
|
|
23242
|
-
}
|
|
23243
23027
|
return results;
|
|
23244
23028
|
}
|
|
23245
23029
|
async function summonGateOfficer(options) {
|
|
@@ -23329,7 +23113,7 @@ import { randomUUID as randomUUID10 } from "node:crypto";
|
|
|
23329
23113
|
// src/role-envelope.ts
|
|
23330
23114
|
init_engine_detour();
|
|
23331
23115
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
23332
|
-
import { appendFile as appendFile3, mkdir as
|
|
23116
|
+
import { appendFile as appendFile3, mkdir as mkdir5, writeFile as writeFile11 } from "node:fs/promises";
|
|
23333
23117
|
import { createServer } from "node:net";
|
|
23334
23118
|
import { dirname as dirname23, join as join45 } from "node:path";
|
|
23335
23119
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -23427,7 +23211,7 @@ async function requireGatekeeperPass(options) {
|
|
|
23427
23211
|
}
|
|
23428
23212
|
|
|
23429
23213
|
// src/host-native-method.ts
|
|
23430
|
-
import { access as access4, lstat as lstat7, mkdir as
|
|
23214
|
+
import { access as access4, lstat as lstat7, mkdir as mkdir4, readdir as readdir9, readFile as readFile23, readlink, realpath as realpath8, symlink } from "node:fs/promises";
|
|
23431
23215
|
import { basename as basename10, dirname as dirname21, join as join41 } from "node:path";
|
|
23432
23216
|
var packagedMethodsDir = (root) => join41(root, "resources", "methods");
|
|
23433
23217
|
function hostMethodSkills(methods) {
|
|
@@ -23528,7 +23312,7 @@ async function installWorkspaceMethodSkills(cwd, packageRoot) {
|
|
|
23528
23312
|
const detail = stat2.isSymbolicLink() ? `symlink to ${await readlink(link)}` : "non-symlink entry";
|
|
23529
23313
|
throw new Error(`workspace method catalog conflict at ${link}: ${detail}`);
|
|
23530
23314
|
}
|
|
23531
|
-
await
|
|
23315
|
+
await mkdir4(dirname21(link), { recursive: true });
|
|
23532
23316
|
try {
|
|
23533
23317
|
await symlink(target, link);
|
|
23534
23318
|
} catch (error) {
|
|
@@ -23984,7 +23768,7 @@ init_collector_github();
|
|
|
23984
23768
|
init_atomic_write();
|
|
23985
23769
|
init_activation_ledger_topology();
|
|
23986
23770
|
import { readFile as readFile24 } from "node:fs/promises";
|
|
23987
|
-
import { join as join42, sep as
|
|
23771
|
+
import { join as join42, sep as sep5 } from "node:path";
|
|
23988
23772
|
|
|
23989
23773
|
// src/collector-tool-schemas.ts
|
|
23990
23774
|
init_open_tool_schema();
|
|
@@ -24079,7 +23863,7 @@ function resolveCollectorHandbookRoot(sessionPath) {
|
|
|
24079
23863
|
if (typeof sessionPath !== "string" || sessionPath.trim().length === 0) {
|
|
24080
23864
|
throw new Error("\u901A\u8FDB\u53F8\u624B\u518C\u8981\u6C42\u975E\u7A7A session \u8DEF\u5F84\uFF0C\u4E14\u4F4D\u4E8E books/<bookKey>/");
|
|
24081
23865
|
}
|
|
24082
|
-
const segments = sessionPath.split(
|
|
23866
|
+
const segments = sessionPath.split(sep5);
|
|
24083
23867
|
let bookKey;
|
|
24084
23868
|
for (let i = 0; i + 3 < segments.length; i += 1) {
|
|
24085
23869
|
if (segments[i] === ".ak-roles" && segments[i + 1] === "books") {
|
|
@@ -26576,11 +26360,11 @@ function reliableWindow(cwd, baseline, head) {
|
|
|
26576
26360
|
const raw = git2(cwd, ["log", "--format=%P%x1e%s", range]);
|
|
26577
26361
|
if (raw.length === 0) return [];
|
|
26578
26362
|
return raw.split("\n").flatMap((line2) => {
|
|
26579
|
-
const
|
|
26580
|
-
if (
|
|
26363
|
+
const sep6 = line2.indexOf("");
|
|
26364
|
+
if (sep6 < 0) return [];
|
|
26581
26365
|
return [{
|
|
26582
|
-
subject: line2.slice(
|
|
26583
|
-
merge: line2.slice(0,
|
|
26366
|
+
subject: line2.slice(sep6 + 1),
|
|
26367
|
+
merge: line2.slice(0, sep6).trim().includes(" ")
|
|
26584
26368
|
}];
|
|
26585
26369
|
});
|
|
26586
26370
|
}
|
|
@@ -28686,9 +28470,9 @@ async function prepareRoleEnvelope(options) {
|
|
|
28686
28470
|
let infrastructureRoundFailure;
|
|
28687
28471
|
const hostAbort = new AbortController();
|
|
28688
28472
|
const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
|
|
28689
|
-
await
|
|
28473
|
+
await mkdir5(request.runDirectory, { recursive: true });
|
|
28690
28474
|
let sessionFile = options.sessionFile ?? join45(request.runDirectory, "session", "session.jsonl");
|
|
28691
|
-
await
|
|
28475
|
+
await mkdir5(dirname23(sessionFile), { recursive: true });
|
|
28692
28476
|
if (request.continuation.kind !== "resume") {
|
|
28693
28477
|
try {
|
|
28694
28478
|
await writeFile11(
|
|
@@ -30018,8 +29802,8 @@ function createAcpRoleTurnHost(config) {
|
|
|
30018
29802
|
|
|
30019
29803
|
// src/acp-host/seat-profile-soul.ts
|
|
30020
29804
|
import { constants as constants2 } from "node:fs";
|
|
30021
|
-
import { access as access5, copyFile, lstat as lstat8, mkdir as
|
|
30022
|
-
import { dirname as dirname26, join as join48, relative as
|
|
29805
|
+
import { access as access5, copyFile, lstat as lstat8, mkdir as mkdir6, readlink as readlink2, symlink as symlink2, unlink as unlink5 } from "node:fs/promises";
|
|
29806
|
+
import { dirname as dirname26, join as join48, relative as relative3, resolve as resolve21 } from "node:path";
|
|
30023
29807
|
function seatProfileName(spec, role) {
|
|
30024
29808
|
return `${spec.namePrefix}${role}`;
|
|
30025
29809
|
}
|
|
@@ -30046,16 +29830,16 @@ async function ensureSeatProfileSoul(options) {
|
|
|
30046
29830
|
const hostRoot = dirname26(profilesRoot);
|
|
30047
29831
|
const soulPath = join48(profileDir, spec.soulFileName);
|
|
30048
29832
|
if (!await pathExists2(profileDir)) {
|
|
30049
|
-
await
|
|
29833
|
+
await mkdir6(profileDir, { recursive: true });
|
|
30050
29834
|
for (const name of ["auth.json", ".env", "config.yaml"]) {
|
|
30051
29835
|
const source = join48(hostRoot, name);
|
|
30052
29836
|
if (!await pathExists2(source)) continue;
|
|
30053
29837
|
await copyFile(source, join48(profileDir, name));
|
|
30054
29838
|
}
|
|
30055
29839
|
} else {
|
|
30056
|
-
await
|
|
29840
|
+
await mkdir6(profileDir, { recursive: true });
|
|
30057
29841
|
}
|
|
30058
|
-
const desiredLink =
|
|
29842
|
+
const desiredLink = relative3(profileDir, soulTarget);
|
|
30059
29843
|
let current;
|
|
30060
29844
|
try {
|
|
30061
29845
|
const st = await lstat8(soulPath);
|