@akagilnc/pi-workflow-roles 0.1.1831 → 0.1.1837
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/public-cli/main.js +182 -221
- package/dist/sitian-record-entry.js +24 -29
- package/dist/sitian-role-run-coordinates.js +28 -0
- package/package.json +1 -1
- package/scripts/build-package.mjs +2 -0
- package/src/public-cli/invocation.ts +16 -72
- package/src/public-cli/merger-run.ts +4 -16
- package/src/public-cli/run-lifecycle.ts +8 -10
- package/src/sitian-record-entry.ts +4 -0
- package/src/sitian-role-run-coordinates.ts +45 -0
package/dist/public-cli/main.js
CHANGED
|
@@ -14844,6 +14844,35 @@ var init_activation_ledger_git = __esm({
|
|
|
14844
14844
|
}
|
|
14845
14845
|
});
|
|
14846
14846
|
|
|
14847
|
+
// src/sitian-role-run-coordinates.ts
|
|
14848
|
+
import { join as join4 } from "node:path";
|
|
14849
|
+
function roleRunSessionCoordinates(options) {
|
|
14850
|
+
const ledgerHome = resolveActivationLedgerHome(
|
|
14851
|
+
options.home === void 0 ? void 0 : () => options.home
|
|
14852
|
+
);
|
|
14853
|
+
const bookKey = resolveBookKeyFromGit(options.cwd);
|
|
14854
|
+
const runDirectory = join4(
|
|
14855
|
+
activationBookDirectory(ledgerHome, bookKey),
|
|
14856
|
+
"runs",
|
|
14857
|
+
`${options.runId}@${options.role}`
|
|
14858
|
+
);
|
|
14859
|
+
const sessionDirectory = join4(runDirectory, "session");
|
|
14860
|
+
return {
|
|
14861
|
+
ledgerHome,
|
|
14862
|
+
bookKey,
|
|
14863
|
+
runDirectory,
|
|
14864
|
+
sessionDirectory,
|
|
14865
|
+
sessionFile: join4(sessionDirectory, "session.jsonl")
|
|
14866
|
+
};
|
|
14867
|
+
}
|
|
14868
|
+
var init_sitian_role_run_coordinates = __esm({
|
|
14869
|
+
"src/sitian-role-run-coordinates.ts"() {
|
|
14870
|
+
"use strict";
|
|
14871
|
+
init_activation_ledger_git();
|
|
14872
|
+
init_activation_ledger_topology();
|
|
14873
|
+
}
|
|
14874
|
+
});
|
|
14875
|
+
|
|
14847
14876
|
// src/audit-escalation.ts
|
|
14848
14877
|
function isAuditEscalationResult(value) {
|
|
14849
14878
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
@@ -15300,10 +15329,7 @@ import {
|
|
|
15300
15329
|
realpath as realpath2,
|
|
15301
15330
|
writeFile as writeFile2
|
|
15302
15331
|
} from "node:fs/promises";
|
|
15303
|
-
import { basename as basename3, isAbsolute as isAbsolute3, join as
|
|
15304
|
-
function roleRunSessionFile(sessionDirectory) {
|
|
15305
|
-
return join4(sessionDirectory, ROLE_RUN_SESSION_FILE_NAME);
|
|
15306
|
-
}
|
|
15332
|
+
import { basename as basename3, isAbsolute as isAbsolute3, join as join5, resolve as resolve4, sep as sep3 } from "node:path";
|
|
15307
15333
|
async function writeRoleInvocationLedger(source, role) {
|
|
15308
15334
|
const identity = {
|
|
15309
15335
|
role,
|
|
@@ -15315,14 +15341,14 @@ async function writeRoleInvocationLedger(source, role) {
|
|
|
15315
15341
|
sessionFile: source.sessionFile
|
|
15316
15342
|
};
|
|
15317
15343
|
await writeFile2(
|
|
15318
|
-
|
|
15344
|
+
join5(source.runDirectory, "invocation.json"),
|
|
15319
15345
|
`${JSON.stringify(identity, null, 2)}
|
|
15320
15346
|
`,
|
|
15321
15347
|
"utf8"
|
|
15322
15348
|
);
|
|
15323
15349
|
}
|
|
15324
15350
|
async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
15325
|
-
const ledgerPath =
|
|
15351
|
+
const ledgerPath = join5(runDirectory, "invocation.json");
|
|
15326
15352
|
const current = JSON.parse(await readFile4(ledgerPath, "utf8"));
|
|
15327
15353
|
await writeFile2(
|
|
15328
15354
|
ledgerPath,
|
|
@@ -15343,7 +15369,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
15343
15369
|
async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
|
|
15344
15370
|
const rolePackageRoot = packageRoot2;
|
|
15345
15371
|
const raw = JSON.parse(
|
|
15346
|
-
await readFile4(
|
|
15372
|
+
await readFile4(join5(rolePackageRoot, "package.json"), "utf8")
|
|
15347
15373
|
);
|
|
15348
15374
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
15349
15375
|
throw new Error(
|
|
@@ -15539,7 +15565,7 @@ async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
|
|
|
15539
15565
|
}
|
|
15540
15566
|
const bytes = await readFile4(absolute);
|
|
15541
15567
|
const name = `${String(index).padStart(2, "0")}-${basename3(absolute)}`;
|
|
15542
|
-
const frozenPath =
|
|
15568
|
+
const frozenPath = join5(destinationDir, name);
|
|
15543
15569
|
await writeFile2(frozenPath, bytes);
|
|
15544
15570
|
return {
|
|
15545
15571
|
provenancePath: absolute,
|
|
@@ -15554,17 +15580,9 @@ async function admitJudgeInvocation(options) {
|
|
|
15554
15580
|
requireOptionPath("--project", options.project);
|
|
15555
15581
|
}
|
|
15556
15582
|
const projectRoot = resolve4(options.project ?? options.cwd);
|
|
15557
|
-
const bookKey = resolveBookKeyFromGit(projectRoot);
|
|
15558
|
-
const ledgerHome = resolveActivationLedgerHome(() => options.home);
|
|
15559
15583
|
const runId = (options.createRunId ?? uuidv7)();
|
|
15560
|
-
const runDirectory =
|
|
15561
|
-
|
|
15562
|
-
"runs",
|
|
15563
|
-
`${runId}@judge`
|
|
15564
|
-
);
|
|
15565
|
-
const sessionDirectory = join4(runDirectory, "session");
|
|
15566
|
-
const sessionFile = roleRunSessionFile(sessionDirectory);
|
|
15567
|
-
const attachmentsDirectory = join4(runDirectory, "attachments");
|
|
15584
|
+
const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "judge", home: options.home });
|
|
15585
|
+
const attachmentsDirectory = join5(runDirectory, "attachments");
|
|
15568
15586
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
15569
15587
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
15570
15588
|
const attachments = [];
|
|
@@ -15597,7 +15615,7 @@ async function admitJudgeInvocation(options) {
|
|
|
15597
15615
|
mediaKind: a.mediaKind
|
|
15598
15616
|
}))
|
|
15599
15617
|
};
|
|
15600
|
-
const admittedRequestPath =
|
|
15618
|
+
const admittedRequestPath = join5(runDirectory, "admitted-request.json");
|
|
15601
15619
|
await writeFile2(admittedRequestPath, `${JSON.stringify(admitted, null, 2)}
|
|
15602
15620
|
`, "utf8");
|
|
15603
15621
|
await writeRoleInvocationLedger(admitted, admitted.role);
|
|
@@ -15627,7 +15645,7 @@ function buildJudgeTransportPrompt(admitted) {
|
|
|
15627
15645
|
return lines.join("\n");
|
|
15628
15646
|
}
|
|
15629
15647
|
async function ensureRunArtifactsDir(runDirectory) {
|
|
15630
|
-
const dir =
|
|
15648
|
+
const dir = join5(runDirectory, "artifacts");
|
|
15631
15649
|
await mkdir2(dir, { recursive: true });
|
|
15632
15650
|
return dir;
|
|
15633
15651
|
}
|
|
@@ -15645,17 +15663,9 @@ async function admitCoderInvocation(options) {
|
|
|
15645
15663
|
throw new CliUsageError("coder phase must be plan or apply");
|
|
15646
15664
|
}
|
|
15647
15665
|
const projectRoot = resolve4(options.project ?? options.cwd);
|
|
15648
|
-
const bookKey = resolveBookKeyFromGit(projectRoot);
|
|
15649
|
-
const ledgerHome = resolveActivationLedgerHome(() => options.home);
|
|
15650
15666
|
const runId = (options.createRunId ?? uuidv7)();
|
|
15651
|
-
const runDirectory =
|
|
15652
|
-
|
|
15653
|
-
"runs",
|
|
15654
|
-
`${runId}@coder`
|
|
15655
|
-
);
|
|
15656
|
-
const sessionDirectory = join4(runDirectory, "session");
|
|
15657
|
-
const sessionFile = roleRunSessionFile(sessionDirectory);
|
|
15658
|
-
const attachmentsDirectory = join4(runDirectory, "attachments");
|
|
15667
|
+
const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "coder", home: options.home });
|
|
15668
|
+
const attachmentsDirectory = join5(runDirectory, "attachments");
|
|
15659
15669
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
15660
15670
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
15661
15671
|
const attachments = [];
|
|
@@ -15668,7 +15678,7 @@ async function admitCoderInvocation(options) {
|
|
|
15668
15678
|
)
|
|
15669
15679
|
);
|
|
15670
15680
|
}
|
|
15671
|
-
const taskPath =
|
|
15681
|
+
const taskPath = join5(runDirectory, "task.md");
|
|
15672
15682
|
await writeFile2(taskPath, instruction, "utf8");
|
|
15673
15683
|
const admitted = {
|
|
15674
15684
|
role: "coder",
|
|
@@ -15690,7 +15700,7 @@ async function admitCoderInvocation(options) {
|
|
|
15690
15700
|
mediaKind: a.mediaKind
|
|
15691
15701
|
}))
|
|
15692
15702
|
};
|
|
15693
|
-
const admittedRequestPath =
|
|
15703
|
+
const admittedRequestPath = join5(runDirectory, "admitted-request.json");
|
|
15694
15704
|
await writeFile2(admittedRequestPath, `${JSON.stringify(admitted, null, 2)}
|
|
15695
15705
|
`, "utf8");
|
|
15696
15706
|
await writeRoleInvocationLedger(admitted, admitted.role);
|
|
@@ -15735,17 +15745,9 @@ async function admitFixerInvocation(options) {
|
|
|
15735
15745
|
throw new CliUsageError("fixer phase must be plan or apply");
|
|
15736
15746
|
}
|
|
15737
15747
|
const projectRoot = resolve4(options.project ?? options.cwd);
|
|
15738
|
-
const bookKey = resolveBookKeyFromGit(projectRoot);
|
|
15739
|
-
const ledgerHome = resolveActivationLedgerHome(() => options.home);
|
|
15740
15748
|
const runId = (options.createRunId ?? uuidv7)();
|
|
15741
|
-
const runDirectory =
|
|
15742
|
-
|
|
15743
|
-
"runs",
|
|
15744
|
-
`${runId}@fixer`
|
|
15745
|
-
);
|
|
15746
|
-
const sessionDirectory = join4(runDirectory, "session");
|
|
15747
|
-
const sessionFile = roleRunSessionFile(sessionDirectory);
|
|
15748
|
-
const attachmentsDirectory = join4(runDirectory, "attachments");
|
|
15749
|
+
const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "fixer", home: options.home });
|
|
15750
|
+
const attachmentsDirectory = join5(runDirectory, "attachments");
|
|
15749
15751
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
15750
15752
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
15751
15753
|
const attachments = [];
|
|
@@ -15779,7 +15781,7 @@ async function admitFixerInvocation(options) {
|
|
|
15779
15781
|
}
|
|
15780
15782
|
throw error;
|
|
15781
15783
|
}
|
|
15782
|
-
prerequisitesPath =
|
|
15784
|
+
prerequisitesPath = join5(runDirectory, "prerequisites.json");
|
|
15783
15785
|
await writeFile2(
|
|
15784
15786
|
prerequisitesPath,
|
|
15785
15787
|
`${JSON.stringify(prerequisites, null, 2)}
|
|
@@ -15787,7 +15789,7 @@ async function admitFixerInvocation(options) {
|
|
|
15787
15789
|
"utf8"
|
|
15788
15790
|
);
|
|
15789
15791
|
}
|
|
15790
|
-
const packetPath =
|
|
15792
|
+
const packetPath = join5(runDirectory, "fix-packet.md");
|
|
15791
15793
|
await writeFile2(packetPath, instruction, "utf8");
|
|
15792
15794
|
const admitted = {
|
|
15793
15795
|
role: "fixer",
|
|
@@ -15814,7 +15816,7 @@ async function admitFixerInvocation(options) {
|
|
|
15814
15816
|
mediaKind: a.mediaKind
|
|
15815
15817
|
}))
|
|
15816
15818
|
};
|
|
15817
|
-
const admittedRequestPath =
|
|
15819
|
+
const admittedRequestPath = join5(runDirectory, "admitted-request.json");
|
|
15818
15820
|
await writeFile2(admittedRequestPath, `${JSON.stringify(admitted, null, 2)}
|
|
15819
15821
|
`, "utf8");
|
|
15820
15822
|
await writeRoleInvocationLedger(admitted, admitted.role);
|
|
@@ -16001,17 +16003,9 @@ async function admitCollectorInvocation(options) {
|
|
|
16001
16003
|
} else {
|
|
16002
16004
|
repository = resolveGitHubRemoteRepository(projectRoot);
|
|
16003
16005
|
}
|
|
16004
|
-
const bookKey = resolveBookKeyFromGit(projectRoot);
|
|
16005
|
-
const ledgerHome = resolveActivationLedgerHome(() => options.home);
|
|
16006
16006
|
const runId = (options.createRunId ?? uuidv7)();
|
|
16007
|
-
const runDirectory =
|
|
16008
|
-
|
|
16009
|
-
"runs",
|
|
16010
|
-
`${runId}@collector`
|
|
16011
|
-
);
|
|
16012
|
-
const sessionDirectory = join4(runDirectory, "session");
|
|
16013
|
-
const sessionFile = roleRunSessionFile(sessionDirectory);
|
|
16014
|
-
const attachmentsDirectory = join4(runDirectory, "attachments");
|
|
16007
|
+
const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "collector", home: options.home });
|
|
16008
|
+
const attachmentsDirectory = join5(runDirectory, "attachments");
|
|
16015
16009
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
16016
16010
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
16017
16011
|
const attachments = [];
|
|
@@ -16033,7 +16027,7 @@ async function admitCollectorInvocation(options) {
|
|
|
16033
16027
|
} catch (error) {
|
|
16034
16028
|
throw new CliUsageError(error instanceof Error ? error.message : String(error), { cause: error });
|
|
16035
16029
|
}
|
|
16036
|
-
requestManifestPath =
|
|
16030
|
+
requestManifestPath = join5(runDirectory, "request-manifest.json");
|
|
16037
16031
|
await writeFile2(requestManifestPath, manifest.canonicalJson, "utf8");
|
|
16038
16032
|
}
|
|
16039
16033
|
const manifestDigest = manifest.digest;
|
|
@@ -16062,7 +16056,7 @@ async function admitCollectorInvocation(options) {
|
|
|
16062
16056
|
mediaKind: a.mediaKind
|
|
16063
16057
|
}))
|
|
16064
16058
|
};
|
|
16065
|
-
const admittedRequestPath =
|
|
16059
|
+
const admittedRequestPath = join5(runDirectory, "admitted-request.json");
|
|
16066
16060
|
await writeFile2(
|
|
16067
16061
|
admittedRequestPath,
|
|
16068
16062
|
`${JSON.stringify(admitted, null, 2)}
|
|
@@ -16184,7 +16178,7 @@ function parseDoctorArgv(args) {
|
|
|
16184
16178
|
}
|
|
16185
16179
|
async function resolveDoctorCaseRunsPath(options) {
|
|
16186
16180
|
const ledgerHome = resolveActivationLedgerHome(() => options.home);
|
|
16187
|
-
const defaultRuns =
|
|
16181
|
+
const defaultRuns = join5(
|
|
16188
16182
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
16189
16183
|
"issues",
|
|
16190
16184
|
String(options.issueNumber),
|
|
@@ -16242,8 +16236,8 @@ async function admitDoctorInvocation(options) {
|
|
|
16242
16236
|
);
|
|
16243
16237
|
}
|
|
16244
16238
|
const projectRoot = resolve4(options.project ?? options.cwd);
|
|
16245
|
-
const
|
|
16246
|
-
const ledgerHome =
|
|
16239
|
+
const runId = (options.createRunId ?? uuidv7)();
|
|
16240
|
+
const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "doctor", home: options.home });
|
|
16247
16241
|
let caseRunsPath;
|
|
16248
16242
|
try {
|
|
16249
16243
|
caseRunsPath = await resolveDoctorCaseRunsPath({
|
|
@@ -16279,15 +16273,7 @@ async function admitDoctorInvocation(options) {
|
|
|
16279
16273
|
{ cause: error }
|
|
16280
16274
|
);
|
|
16281
16275
|
}
|
|
16282
|
-
const
|
|
16283
|
-
const runDirectory = join4(
|
|
16284
|
-
activationBookDirectory(ledgerHome, bookKey),
|
|
16285
|
-
"runs",
|
|
16286
|
-
`${runId}@doctor`
|
|
16287
|
-
);
|
|
16288
|
-
const sessionDirectory = join4(runDirectory, "session");
|
|
16289
|
-
const sessionFile = roleRunSessionFile(sessionDirectory);
|
|
16290
|
-
const attachmentsDirectory = join4(runDirectory, "attachments");
|
|
16276
|
+
const attachmentsDirectory = join5(runDirectory, "attachments");
|
|
16291
16277
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
16292
16278
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
16293
16279
|
const attachments = [];
|
|
@@ -16324,7 +16310,7 @@ async function admitDoctorInvocation(options) {
|
|
|
16324
16310
|
mediaKind: a.mediaKind
|
|
16325
16311
|
}))
|
|
16326
16312
|
};
|
|
16327
|
-
const admittedRequestPath =
|
|
16313
|
+
const admittedRequestPath = join5(runDirectory, "admitted-request.json");
|
|
16328
16314
|
await writeFile2(
|
|
16329
16315
|
admittedRequestPath,
|
|
16330
16316
|
`${JSON.stringify(admitted, null, 2)}
|
|
@@ -16411,17 +16397,9 @@ async function admitReviewerInvocation(options) {
|
|
|
16411
16397
|
throw new CliUsageError("--base requires a nonempty revision");
|
|
16412
16398
|
}
|
|
16413
16399
|
const projectRoot = resolve4(options.project ?? options.cwd);
|
|
16414
|
-
const bookKey = resolveBookKeyFromGit(projectRoot);
|
|
16415
|
-
const ledgerHome = resolveActivationLedgerHome(() => options.home);
|
|
16416
16400
|
const runId = (options.createRunId ?? uuidv7)();
|
|
16417
|
-
const runDirectory =
|
|
16418
|
-
|
|
16419
|
-
"runs",
|
|
16420
|
-
`${runId}@reviewer`
|
|
16421
|
-
);
|
|
16422
|
-
const sessionDirectory = join4(runDirectory, "session");
|
|
16423
|
-
const sessionFile = roleRunSessionFile(sessionDirectory);
|
|
16424
|
-
const attachmentsDirectory = join4(runDirectory, "attachments");
|
|
16401
|
+
const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "reviewer", home: options.home });
|
|
16402
|
+
const attachmentsDirectory = join5(runDirectory, "attachments");
|
|
16425
16403
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
16426
16404
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
16427
16405
|
const attachments = [];
|
|
@@ -16455,7 +16433,7 @@ async function admitReviewerInvocation(options) {
|
|
|
16455
16433
|
mediaKind: a.mediaKind
|
|
16456
16434
|
}))
|
|
16457
16435
|
};
|
|
16458
|
-
const admittedRequestPath =
|
|
16436
|
+
const admittedRequestPath = join5(runDirectory, "admitted-request.json");
|
|
16459
16437
|
await writeFile2(
|
|
16460
16438
|
admittedRequestPath,
|
|
16461
16439
|
`${JSON.stringify(admitted, null, 2)}
|
|
@@ -16572,17 +16550,9 @@ async function admitMergerInvocation(options) {
|
|
|
16572
16550
|
projectRoot,
|
|
16573
16551
|
options.gitState ?? createProductionMergerGitState(projectRoot)
|
|
16574
16552
|
);
|
|
16575
|
-
const bookKey = resolveBookKeyFromGit(projectRoot);
|
|
16576
|
-
const ledgerHome = resolveActivationLedgerHome(() => options.home);
|
|
16577
16553
|
const runId = (options.createRunId ?? uuidv7)();
|
|
16578
|
-
const runDirectory =
|
|
16579
|
-
|
|
16580
|
-
"runs",
|
|
16581
|
-
`${runId}@merger`
|
|
16582
|
-
);
|
|
16583
|
-
const sessionDirectory = join4(runDirectory, "session");
|
|
16584
|
-
const sessionFile = roleRunSessionFile(sessionDirectory);
|
|
16585
|
-
const attachmentsDirectory = join4(runDirectory, "attachments");
|
|
16554
|
+
const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "merger", home: options.home });
|
|
16555
|
+
const attachmentsDirectory = join5(runDirectory, "attachments");
|
|
16586
16556
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
16587
16557
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
16588
16558
|
const attachments = [];
|
|
@@ -16619,7 +16589,7 @@ async function admitMergerInvocation(options) {
|
|
|
16619
16589
|
// Authorized checks remain available on the assignment; default none.
|
|
16620
16590
|
authorizedChecks: []
|
|
16621
16591
|
});
|
|
16622
|
-
const mergerInputPath =
|
|
16592
|
+
const mergerInputPath = join5(runDirectory, "merger-input.json");
|
|
16623
16593
|
await writeFile2(
|
|
16624
16594
|
mergerInputPath,
|
|
16625
16595
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
@@ -16652,7 +16622,7 @@ async function admitMergerInvocation(options) {
|
|
|
16652
16622
|
mediaKind: a.mediaKind
|
|
16653
16623
|
}))
|
|
16654
16624
|
};
|
|
16655
|
-
const admittedRequestPath =
|
|
16625
|
+
const admittedRequestPath = join5(runDirectory, "admitted-request.json");
|
|
16656
16626
|
await writeFile2(
|
|
16657
16627
|
admittedRequestPath,
|
|
16658
16628
|
`${JSON.stringify(admitted, null, 2)}
|
|
@@ -16689,12 +16659,13 @@ function buildMergerTransportPrompt(admitted) {
|
|
|
16689
16659
|
}
|
|
16690
16660
|
return lines.join("\n");
|
|
16691
16661
|
}
|
|
16692
|
-
var
|
|
16662
|
+
var MergerEnvelopeDerivationError, DOCTOR_ISSUE_NUMBER_PATTERN, DOCTOR_CASE_RUNS_PATH_PATTERN;
|
|
16693
16663
|
var init_invocation = __esm({
|
|
16694
16664
|
"src/public-cli/invocation.ts"() {
|
|
16695
16665
|
"use strict";
|
|
16696
16666
|
init_activation_ledger_topology();
|
|
16697
16667
|
init_activation_ledger_git();
|
|
16668
|
+
init_sitian_role_run_coordinates();
|
|
16698
16669
|
init_doctor_evidence();
|
|
16699
16670
|
init_collector_config();
|
|
16700
16671
|
init_fixer_packet();
|
|
@@ -16703,7 +16674,6 @@ var init_invocation = __esm({
|
|
|
16703
16674
|
init_sha256();
|
|
16704
16675
|
init_uuidv7();
|
|
16705
16676
|
init_cli_errors();
|
|
16706
|
-
ROLE_RUN_SESSION_FILE_NAME = "session.jsonl";
|
|
16707
16677
|
MergerEnvelopeDerivationError = class extends Error {
|
|
16708
16678
|
code = "merger-envelope-derivation";
|
|
16709
16679
|
/** Typed cause for #107 classifyPostAdmissionFailure (isTypedActivationError). */
|
|
@@ -16813,14 +16783,14 @@ var init_reviewer_dispatch = __esm({
|
|
|
16813
16783
|
import { execFile as execFile3, spawn } from "node:child_process";
|
|
16814
16784
|
import { constants, writeFileSync } from "node:fs";
|
|
16815
16785
|
import { access, readFile as readFile5, realpath as realpath3, unlink } from "node:fs/promises";
|
|
16816
|
-
import { delimiter as delimiter2, isAbsolute as isAbsolute4, join as
|
|
16786
|
+
import { delimiter as delimiter2, isAbsolute as isAbsolute4, join as join6, resolve as resolve5 } from "node:path";
|
|
16817
16787
|
import { platform } from "node:process";
|
|
16818
16788
|
import { promisify as promisify3 } from "node:util";
|
|
16819
16789
|
function isReviewerPreflightViolation(value) {
|
|
16820
16790
|
return typeof value === "string" && REVIEWER_PREFLIGHT_VIOLATIONS.includes(value);
|
|
16821
16791
|
}
|
|
16822
16792
|
function reviewerDispatchRejectionPath(runDirectory) {
|
|
16823
|
-
return
|
|
16793
|
+
return join6(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
|
|
16824
16794
|
}
|
|
16825
16795
|
async function clearReviewerDispatchRejection(runDirectory) {
|
|
16826
16796
|
try {
|
|
@@ -16862,7 +16832,7 @@ async function readReviewerDispatchRejection(runDirectory) {
|
|
|
16862
16832
|
};
|
|
16863
16833
|
}
|
|
16864
16834
|
function resolveInternalRoleEntrypoint(packageRoot2) {
|
|
16865
|
-
return
|
|
16835
|
+
return join6(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE);
|
|
16866
16836
|
}
|
|
16867
16837
|
function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
|
|
16868
16838
|
return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
|
|
@@ -17002,7 +16972,7 @@ var init_explicit_internal = __esm({
|
|
|
17002
16972
|
// src/package-resources/method-skill.ts
|
|
17003
16973
|
import { createHash as createHash3 } from "node:crypto";
|
|
17004
16974
|
import { readFile as readFile6, realpath as realpath4 } from "node:fs/promises";
|
|
17005
|
-
import { join as
|
|
16975
|
+
import { join as join7 } from "node:path";
|
|
17006
16976
|
function gitBlobOid(bytes) {
|
|
17007
16977
|
const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
|
|
17008
16978
|
const header = Buffer.from(`blob ${body.byteLength}\0`, "utf8");
|
|
@@ -17019,10 +16989,10 @@ function packagedMethodSkillRelativeDirectory(name) {
|
|
|
17019
16989
|
return `${METHOD_SKILL_RELATIVE_ROOT}/${name}`;
|
|
17020
16990
|
}
|
|
17021
16991
|
function resolvePackagedMethodSkillRoot(packageRoot2, name) {
|
|
17022
|
-
return
|
|
16992
|
+
return join7(packageRoot2, packagedMethodSkillRelativeDirectory(name));
|
|
17023
16993
|
}
|
|
17024
16994
|
function resolvePackagedMethodSkillPath(packageRoot2, name) {
|
|
17025
|
-
return
|
|
16995
|
+
return join7(resolvePackagedMethodSkillRoot(packageRoot2, name), "SKILL.md");
|
|
17026
16996
|
}
|
|
17027
16997
|
function isRecord3(value) {
|
|
17028
16998
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -17116,8 +17086,8 @@ function parseProvenance(raw, expectedName) {
|
|
|
17116
17086
|
}
|
|
17117
17087
|
async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
|
|
17118
17088
|
const rootDirectory = resolvePackagedMethodSkillRoot(packageRoot2, name);
|
|
17119
|
-
const skillPathConfigured =
|
|
17120
|
-
const provenancePath =
|
|
17089
|
+
const skillPathConfigured = join7(rootDirectory, "SKILL.md");
|
|
17090
|
+
const provenancePath = join7(rootDirectory, "provenance.json");
|
|
17121
17091
|
let provenanceRaw;
|
|
17122
17092
|
try {
|
|
17123
17093
|
provenanceRaw = await readFile6(provenancePath, "utf8");
|
|
@@ -17134,7 +17104,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
|
|
|
17134
17104
|
}
|
|
17135
17105
|
const provenance = parseProvenance(provenanceJson, name);
|
|
17136
17106
|
for (const [rel, expected] of Object.entries(provenance.files)) {
|
|
17137
|
-
const absolute =
|
|
17107
|
+
const absolute = join7(rootDirectory, rel);
|
|
17138
17108
|
let bytes;
|
|
17139
17109
|
try {
|
|
17140
17110
|
bytes = await readFile6(absolute);
|
|
@@ -17269,12 +17239,12 @@ var init_public_run_credentials = __esm({
|
|
|
17269
17239
|
|
|
17270
17240
|
// src/public-cli/run-lifecycle.ts
|
|
17271
17241
|
import { lstat as lstat2, open, readdir as readdir2, readFile as readFile7, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
|
|
17272
|
-
import { join as
|
|
17242
|
+
import { join as join8 } from "node:path";
|
|
17273
17243
|
function isV1ResumableProvider(provider) {
|
|
17274
17244
|
return V1_RESUMABLE_PROVIDERS.includes(provider);
|
|
17275
17245
|
}
|
|
17276
17246
|
function typedProviderHttpPath(runDirectory) {
|
|
17277
|
-
return
|
|
17247
|
+
return join8(runDirectory, TYPED_HTTP_FILE);
|
|
17278
17248
|
}
|
|
17279
17249
|
async function clearTypedProviderHttpObservation(runDirectory) {
|
|
17280
17250
|
try {
|
|
@@ -17313,62 +17283,61 @@ function renderResumeCommand(runId) {
|
|
|
17313
17283
|
async function writeRoleRunState(runDirectory, record4) {
|
|
17314
17284
|
const payload = { ...record4, runDirectory };
|
|
17315
17285
|
await writeFile3(
|
|
17316
|
-
|
|
17286
|
+
join8(runDirectory, RUN_STATE_FILE),
|
|
17317
17287
|
`${JSON.stringify(payload, null, 2)}
|
|
17318
17288
|
`,
|
|
17319
17289
|
"utf8"
|
|
17320
17290
|
);
|
|
17321
17291
|
}
|
|
17322
17292
|
async function readRoleRunState(runDirectory) {
|
|
17293
|
+
let raw;
|
|
17323
17294
|
try {
|
|
17324
|
-
|
|
17325
|
-
await readFile7(join7(runDirectory, RUN_STATE_FILE), "utf8")
|
|
17326
|
-
);
|
|
17327
|
-
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
17328
|
-
return void 0;
|
|
17329
|
-
}
|
|
17330
|
-
const record4 = raw;
|
|
17331
|
-
if (typeof record4.runId !== "string" || record4.runId.trim() === "") {
|
|
17332
|
-
return void 0;
|
|
17333
|
-
}
|
|
17334
|
-
if (record4.role !== "judge" && record4.role !== "coder" && record4.role !== "fixer" && record4.role !== "collector" && record4.role !== "doctor" && record4.role !== "reviewer" && record4.role !== "merger") {
|
|
17335
|
-
return void 0;
|
|
17336
|
-
}
|
|
17337
|
-
if (record4.state !== "admitted" && record4.state !== "running" && record4.state !== "resumable" && record4.state !== "terminal") {
|
|
17338
|
-
return void 0;
|
|
17339
|
-
}
|
|
17340
|
-
if (typeof record4.bookKey !== "string") return void 0;
|
|
17341
|
-
if (typeof record4.projectRoot !== "string") return void 0;
|
|
17342
|
-
if (typeof record4.sessionDirectory !== "string") return void 0;
|
|
17343
|
-
if (typeof record4.admittedRequestPath !== "string") return void 0;
|
|
17344
|
-
const runDir = typeof record4.runDirectory === "string" && record4.runDirectory.trim() !== "" ? record4.runDirectory : runDirectory;
|
|
17345
|
-
const sessionFile = typeof record4.sessionFile === "string" && record4.sessionFile.trim() !== "" ? record4.sessionFile : roleRunSessionFile(record4.sessionDirectory);
|
|
17346
|
-
let resumable;
|
|
17347
|
-
if (record4.resumable !== void 0 && record4.resumable !== null) {
|
|
17348
|
-
if (typeof record4.resumable === "object" && !Array.isArray(record4.resumable)) {
|
|
17349
|
-
const r = record4.resumable;
|
|
17350
|
-
if (r.httpStatus === 429 && typeof r.provider === "string" && isV1ResumableProvider(r.provider)) {
|
|
17351
|
-
resumable = { httpStatus: 429, provider: r.provider };
|
|
17352
|
-
}
|
|
17353
|
-
}
|
|
17354
|
-
}
|
|
17355
|
-
const phase = record4.phase === "plan" || record4.phase === "apply" ? record4.phase : void 0;
|
|
17356
|
-
return {
|
|
17357
|
-
runId: record4.runId,
|
|
17358
|
-
role: record4.role,
|
|
17359
|
-
state: record4.state,
|
|
17360
|
-
bookKey: record4.bookKey,
|
|
17361
|
-
projectRoot: record4.projectRoot,
|
|
17362
|
-
sessionDirectory: record4.sessionDirectory,
|
|
17363
|
-
sessionFile,
|
|
17364
|
-
runDirectory: runDir,
|
|
17365
|
-
admittedRequestPath: record4.admittedRequestPath,
|
|
17366
|
-
...phase === void 0 ? {} : { phase },
|
|
17367
|
-
...resumable === void 0 ? {} : { resumable }
|
|
17368
|
-
};
|
|
17295
|
+
raw = JSON.parse(await readFile7(join8(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
17369
17296
|
} catch {
|
|
17370
17297
|
return void 0;
|
|
17371
17298
|
}
|
|
17299
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
17300
|
+
return void 0;
|
|
17301
|
+
}
|
|
17302
|
+
const record4 = raw;
|
|
17303
|
+
if (typeof record4.runId !== "string" || record4.runId.trim() === "") {
|
|
17304
|
+
return void 0;
|
|
17305
|
+
}
|
|
17306
|
+
if (record4.role !== "judge" && record4.role !== "coder" && record4.role !== "fixer" && record4.role !== "collector" && record4.role !== "doctor" && record4.role !== "reviewer" && record4.role !== "merger") {
|
|
17307
|
+
return void 0;
|
|
17308
|
+
}
|
|
17309
|
+
if (record4.state !== "admitted" && record4.state !== "running" && record4.state !== "resumable" && record4.state !== "terminal") {
|
|
17310
|
+
return void 0;
|
|
17311
|
+
}
|
|
17312
|
+
if (typeof record4.bookKey !== "string") return void 0;
|
|
17313
|
+
if (typeof record4.projectRoot !== "string") return void 0;
|
|
17314
|
+
if (typeof record4.sessionDirectory !== "string") return void 0;
|
|
17315
|
+
if (typeof record4.admittedRequestPath !== "string") return void 0;
|
|
17316
|
+
const runDir = typeof record4.runDirectory === "string" && record4.runDirectory.trim() !== "" ? record4.runDirectory : runDirectory;
|
|
17317
|
+
const sessionFile = typeof record4.sessionFile === "string" && record4.sessionFile.trim() !== "" ? record4.sessionFile : join8(record4.sessionDirectory, "session.jsonl");
|
|
17318
|
+
let resumable;
|
|
17319
|
+
if (record4.resumable !== void 0 && record4.resumable !== null) {
|
|
17320
|
+
if (typeof record4.resumable === "object" && !Array.isArray(record4.resumable)) {
|
|
17321
|
+
const r = record4.resumable;
|
|
17322
|
+
if (r.httpStatus === 429 && typeof r.provider === "string" && isV1ResumableProvider(r.provider)) {
|
|
17323
|
+
resumable = { httpStatus: 429, provider: r.provider };
|
|
17324
|
+
}
|
|
17325
|
+
}
|
|
17326
|
+
}
|
|
17327
|
+
const phase = record4.phase === "plan" || record4.phase === "apply" ? record4.phase : void 0;
|
|
17328
|
+
return {
|
|
17329
|
+
runId: record4.runId,
|
|
17330
|
+
role: record4.role,
|
|
17331
|
+
state: record4.state,
|
|
17332
|
+
bookKey: record4.bookKey,
|
|
17333
|
+
projectRoot: record4.projectRoot,
|
|
17334
|
+
sessionDirectory: record4.sessionDirectory,
|
|
17335
|
+
sessionFile,
|
|
17336
|
+
runDirectory: runDir,
|
|
17337
|
+
admittedRequestPath: record4.admittedRequestPath,
|
|
17338
|
+
...phase === void 0 ? {} : { phase },
|
|
17339
|
+
...resumable === void 0 ? {} : { resumable }
|
|
17340
|
+
};
|
|
17372
17341
|
}
|
|
17373
17342
|
async function markRunAdmitted(admitted) {
|
|
17374
17343
|
await writeRoleRunState(admitted.runDirectory, {
|
|
@@ -17438,7 +17407,7 @@ async function isSessionPrincipalAvailable(sessionFile) {
|
|
|
17438
17407
|
}
|
|
17439
17408
|
}
|
|
17440
17409
|
async function acquireRunWriterLease(runDirectory) {
|
|
17441
|
-
const lockPath =
|
|
17410
|
+
const lockPath = join8(runDirectory, WRITER_LOCK_FILE);
|
|
17442
17411
|
try {
|
|
17443
17412
|
const handle = await open(lockPath, "wx");
|
|
17444
17413
|
try {
|
|
@@ -17469,7 +17438,7 @@ async function acquireRunWriterLease(runDirectory) {
|
|
|
17469
17438
|
async function findRunDirectoryById(home, runId) {
|
|
17470
17439
|
if (runId.trim() === "") return void 0;
|
|
17471
17440
|
const ledgerHome = resolveActivationLedgerHome(() => home);
|
|
17472
|
-
const booksRoot =
|
|
17441
|
+
const booksRoot = join8(ledgerHome, "books");
|
|
17473
17442
|
let bookKeys;
|
|
17474
17443
|
try {
|
|
17475
17444
|
bookKeys = await readdir2(booksRoot);
|
|
@@ -17477,7 +17446,7 @@ async function findRunDirectoryById(home, runId) {
|
|
|
17477
17446
|
return void 0;
|
|
17478
17447
|
}
|
|
17479
17448
|
for (const bookKey of bookKeys) {
|
|
17480
|
-
const runsDir =
|
|
17449
|
+
const runsDir = join8(activationBookDirectory(ledgerHome, bookKey), "runs");
|
|
17481
17450
|
let entries;
|
|
17482
17451
|
try {
|
|
17483
17452
|
entries = await readdir2(runsDir);
|
|
@@ -17486,7 +17455,7 @@ async function findRunDirectoryById(home, runId) {
|
|
|
17486
17455
|
}
|
|
17487
17456
|
for (const entry of entries) {
|
|
17488
17457
|
if (entry === `${runId}@judge` || entry.startsWith(`${runId}@`)) {
|
|
17489
|
-
return
|
|
17458
|
+
return join8(runsDir, entry);
|
|
17490
17459
|
}
|
|
17491
17460
|
}
|
|
17492
17461
|
}
|
|
@@ -18463,7 +18432,7 @@ var init_terminal = __esm({
|
|
|
18463
18432
|
// src/public-cli/settlement.ts
|
|
18464
18433
|
import { randomUUID } from "node:crypto";
|
|
18465
18434
|
import { lstat as lstat3, mkdir as mkdir3, open as open2, readFile as readFile8, readdir as readdir3, writeFile as writeFile4 } from "node:fs/promises";
|
|
18466
|
-
import { dirname as dirname6, join as
|
|
18435
|
+
import { dirname as dirname6, join as join9 } from "node:path";
|
|
18467
18436
|
function isChildDiagnosticFloodLine(line2) {
|
|
18468
18437
|
if (/^at\s+/.test(line2)) return true;
|
|
18469
18438
|
if (line2.startsWith("event:")) return true;
|
|
@@ -18716,7 +18685,7 @@ async function readSessionProviderStop(sessionFile) {
|
|
|
18716
18685
|
}
|
|
18717
18686
|
}
|
|
18718
18687
|
async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
18719
|
-
const childDirectory =
|
|
18688
|
+
const childDirectory = join9(dirname6(sessionFile), "evidence-children");
|
|
18720
18689
|
let names;
|
|
18721
18690
|
try {
|
|
18722
18691
|
names = await readdir3(childDirectory);
|
|
@@ -18727,7 +18696,7 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
|
18727
18696
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
18728
18697
|
let entries;
|
|
18729
18698
|
try {
|
|
18730
|
-
entries = await readBoundSessionEntries(
|
|
18699
|
+
entries = await readBoundSessionEntries(join9(childDirectory, file));
|
|
18731
18700
|
} catch (error) {
|
|
18732
18701
|
throw sessionReadFailure(error, "failed to read discovered evidence-child session");
|
|
18733
18702
|
}
|
|
@@ -18764,7 +18733,7 @@ async function readBoundAuditorKnownFailure(sessionFile) {
|
|
|
18764
18733
|
break;
|
|
18765
18734
|
}
|
|
18766
18735
|
}
|
|
18767
|
-
const childDirectory =
|
|
18736
|
+
const childDirectory = join9(dirname6(sessionFile), "auditor-roles");
|
|
18768
18737
|
let names;
|
|
18769
18738
|
try {
|
|
18770
18739
|
names = await readdir3(childDirectory);
|
|
@@ -18775,7 +18744,7 @@ async function readBoundAuditorKnownFailure(sessionFile) {
|
|
|
18775
18744
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
18776
18745
|
let entries;
|
|
18777
18746
|
try {
|
|
18778
|
-
entries = await readBoundSessionEntries(
|
|
18747
|
+
entries = await readBoundSessionEntries(join9(childDirectory, file));
|
|
18779
18748
|
} catch (error) {
|
|
18780
18749
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
18781
18750
|
}
|
|
@@ -19389,7 +19358,7 @@ function auditArtifactPublicationError(message, code) {
|
|
|
19389
19358
|
return error;
|
|
19390
19359
|
}
|
|
19391
19360
|
async function ensureAuditEvidenceDirectory(runDirectory) {
|
|
19392
|
-
const artifactsDir =
|
|
19361
|
+
const artifactsDir = join9(runDirectory, "artifacts");
|
|
19393
19362
|
const runStat = await lstat3(runDirectory);
|
|
19394
19363
|
if (runStat.isSymbolicLink() || !runStat.isDirectory()) {
|
|
19395
19364
|
throw auditArtifactPublicationError(
|
|
@@ -19426,7 +19395,7 @@ async function ensureAuditEvidenceDirectory(runDirectory) {
|
|
|
19426
19395
|
}
|
|
19427
19396
|
async function publishComplianceAuditIncompleteEvidence(admitted, outcome) {
|
|
19428
19397
|
const artifactsDir = await ensureAuditEvidenceDirectory(admitted.runDirectory);
|
|
19429
|
-
const evidencePath =
|
|
19398
|
+
const evidencePath = join9(artifactsDir, "audit-incomplete.json");
|
|
19430
19399
|
try {
|
|
19431
19400
|
const existing = await lstat3(evidencePath);
|
|
19432
19401
|
throw auditArtifactPublicationError(
|
|
@@ -19448,7 +19417,7 @@ async function publishComplianceAuditIncompleteEvidence(admitted, outcome) {
|
|
|
19448
19417
|
}
|
|
19449
19418
|
function auditPublicationFailureTerminal(admitted, entries, outcome, error) {
|
|
19450
19419
|
const attempt = publicationAttemptFromError(
|
|
19451
|
-
|
|
19420
|
+
join9(admitted.runDirectory, "artifacts", "audit-incomplete.json"),
|
|
19452
19421
|
error
|
|
19453
19422
|
);
|
|
19454
19423
|
const diagnostic = `audit-incomplete evidence publication failed: ${attempt.diagnostic}`;
|
|
@@ -19742,8 +19711,8 @@ async function extractNavigatorFactFromAdmittedSession(admitted) {
|
|
|
19742
19711
|
}
|
|
19743
19712
|
async function publishJudgeArtifacts(admitted, roleOutcome, sessionDirectory) {
|
|
19744
19713
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
19745
|
-
const reportPath =
|
|
19746
|
-
const evidencePath =
|
|
19714
|
+
const reportPath = join9(artifactsDir, "report.json");
|
|
19715
|
+
const evidencePath = join9(artifactsDir, "evidence.json");
|
|
19747
19716
|
await writeFile4(
|
|
19748
19717
|
reportPath,
|
|
19749
19718
|
`${JSON.stringify(
|
|
@@ -19786,8 +19755,8 @@ async function publishJudgeArtifacts(admitted, roleOutcome, sessionDirectory) {
|
|
|
19786
19755
|
}
|
|
19787
19756
|
async function publishCoderArtifacts(admitted, roleOutcome, sessionDirectory, options = {}) {
|
|
19788
19757
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
19789
|
-
const reportPath =
|
|
19790
|
-
const evidencePath =
|
|
19758
|
+
const reportPath = join9(artifactsDir, "report.json");
|
|
19759
|
+
const evidencePath = join9(artifactsDir, "evidence.json");
|
|
19791
19760
|
await writeFile4(
|
|
19792
19761
|
reportPath,
|
|
19793
19762
|
`${JSON.stringify(
|
|
@@ -19961,8 +19930,8 @@ function extractFixerMethodInvocations(entries, options) {
|
|
|
19961
19930
|
}
|
|
19962
19931
|
async function publishFixerArtifacts(admitted, roleOutcome, sessionDirectory, options) {
|
|
19963
19932
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
19964
|
-
const reportPath =
|
|
19965
|
-
const evidencePath =
|
|
19933
|
+
const reportPath = join9(artifactsDir, "report.json");
|
|
19934
|
+
const evidencePath = join9(artifactsDir, "evidence.json");
|
|
19966
19935
|
await writeFile4(
|
|
19967
19936
|
reportPath,
|
|
19968
19937
|
`${JSON.stringify(
|
|
@@ -20075,8 +20044,8 @@ async function settleLawfulFixerTerminalResult(admitted, options) {
|
|
|
20075
20044
|
}
|
|
20076
20045
|
async function publishCollectorArtifacts(admitted, roleOutcome, sessionDirectory, options = {}) {
|
|
20077
20046
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
20078
|
-
const reportPath =
|
|
20079
|
-
const evidencePath =
|
|
20047
|
+
const reportPath = join9(artifactsDir, "report.json");
|
|
20048
|
+
const evidencePath = join9(artifactsDir, "evidence.json");
|
|
20080
20049
|
await writeFile4(
|
|
20081
20050
|
reportPath,
|
|
20082
20051
|
`${JSON.stringify(
|
|
@@ -20197,8 +20166,8 @@ async function trySettleCollectorTerminalResult(admitted) {
|
|
|
20197
20166
|
}
|
|
20198
20167
|
async function publishDoctorArtifacts(admitted, roleOutcome, sessionDirectory, options = {}) {
|
|
20199
20168
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
20200
|
-
const reportPath =
|
|
20201
|
-
const evidencePath =
|
|
20169
|
+
const reportPath = join9(artifactsDir, "report.json");
|
|
20170
|
+
const evidencePath = join9(artifactsDir, "evidence.json");
|
|
20202
20171
|
await writeFile4(
|
|
20203
20172
|
reportPath,
|
|
20204
20173
|
`${JSON.stringify(
|
|
@@ -20366,8 +20335,8 @@ function extractReviewerMethodInvocations(entries, options) {
|
|
|
20366
20335
|
}
|
|
20367
20336
|
async function publishReviewerArtifacts(admitted, roleOutcome, sessionDirectory, options) {
|
|
20368
20337
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
20369
|
-
const reportPath =
|
|
20370
|
-
const evidencePath =
|
|
20338
|
+
const reportPath = join9(artifactsDir, "report.json");
|
|
20339
|
+
const evidencePath = join9(artifactsDir, "evidence.json");
|
|
20371
20340
|
await writeFile4(
|
|
20372
20341
|
reportPath,
|
|
20373
20342
|
`${JSON.stringify(
|
|
@@ -20533,8 +20502,8 @@ function extractMergerMethodInvocations(entries, options) {
|
|
|
20533
20502
|
}
|
|
20534
20503
|
async function publishMergerArtifacts(admitted, roleOutcome, sessionDirectory, options) {
|
|
20535
20504
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
20536
|
-
const reportPath =
|
|
20537
|
-
const evidencePath =
|
|
20505
|
+
const reportPath = join9(artifactsDir, "report.json");
|
|
20506
|
+
const evidencePath = join9(artifactsDir, "evidence.json");
|
|
20538
20507
|
await writeFile4(
|
|
20539
20508
|
reportPath,
|
|
20540
20509
|
`${JSON.stringify(
|
|
@@ -20705,7 +20674,7 @@ function uniqueFailureFallbackDirs(runDirectory, baseDir) {
|
|
|
20705
20674
|
return dirs;
|
|
20706
20675
|
}
|
|
20707
20676
|
async function resolveFailureArtifactsBase(runDirectory) {
|
|
20708
|
-
const artifactsDir =
|
|
20677
|
+
const artifactsDir = join9(runDirectory, "artifacts");
|
|
20709
20678
|
try {
|
|
20710
20679
|
await ensureRunArtifactsDir(runDirectory);
|
|
20711
20680
|
return { baseDir: artifactsDir };
|
|
@@ -20721,7 +20690,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
20721
20690
|
const candidates = [
|
|
20722
20691
|
...preferredCandidates,
|
|
20723
20692
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
20724
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
20693
|
+
...uniqueFallbackDirs.map((dir) => join9(dir, `${stem}.${randomUUID()}.json`))
|
|
20725
20694
|
];
|
|
20726
20695
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
20727
20696
|
const path = candidates[i];
|
|
@@ -20756,26 +20725,26 @@ async function publishFailureArtifacts(admitted, failure) {
|
|
|
20756
20725
|
admitted.runDirectory
|
|
20757
20726
|
);
|
|
20758
20727
|
const priorIssues = baseAttempt === void 0 ? [] : [baseAttempt];
|
|
20759
|
-
const underArtifacts = baseDir ===
|
|
20728
|
+
const underArtifacts = baseDir === join9(admitted.runDirectory, "artifacts");
|
|
20760
20729
|
const uniqueFallbackDirs = uniqueFailureFallbackDirs(
|
|
20761
20730
|
admitted.runDirectory,
|
|
20762
20731
|
baseDir
|
|
20763
20732
|
);
|
|
20764
20733
|
const errorCandidates = underArtifacts ? [
|
|
20765
|
-
|
|
20766
|
-
|
|
20767
|
-
|
|
20734
|
+
join9(baseDir, "error.json"),
|
|
20735
|
+
join9(baseDir, "error.settlement.json"),
|
|
20736
|
+
join9(admitted.runDirectory, "error.settlement.json")
|
|
20768
20737
|
] : [
|
|
20769
|
-
|
|
20770
|
-
|
|
20738
|
+
join9(baseDir, "error.settlement.json"),
|
|
20739
|
+
join9(baseDir, "error.json")
|
|
20771
20740
|
];
|
|
20772
20741
|
const evidenceCandidates = underArtifacts ? [
|
|
20773
|
-
|
|
20774
|
-
|
|
20775
|
-
|
|
20742
|
+
join9(baseDir, "evidence.json"),
|
|
20743
|
+
join9(baseDir, "evidence.settlement.json"),
|
|
20744
|
+
join9(admitted.runDirectory, "evidence.settlement.json")
|
|
20776
20745
|
] : [
|
|
20777
|
-
|
|
20778
|
-
|
|
20746
|
+
join9(baseDir, "evidence.settlement.json"),
|
|
20747
|
+
join9(baseDir, "evidence.json")
|
|
20779
20748
|
];
|
|
20780
20749
|
const errorPayloadBase = {
|
|
20781
20750
|
kind: "error",
|
|
@@ -20989,7 +20958,7 @@ var init_settlement = __esm({
|
|
|
20989
20958
|
|
|
20990
20959
|
// src/public-cli/coder-run.ts
|
|
20991
20960
|
import { writeFile as writeFile5 } from "node:fs/promises";
|
|
20992
|
-
import { join as
|
|
20961
|
+
import { join as join10 } from "node:path";
|
|
20993
20962
|
function buildModelArgs(model) {
|
|
20994
20963
|
if (model === void 0) return [];
|
|
20995
20964
|
return [
|
|
@@ -21149,7 +21118,7 @@ async function dispatchAdmittedCoder(input) {
|
|
|
21149
21118
|
}
|
|
21150
21119
|
try {
|
|
21151
21120
|
await writeFile5(
|
|
21152
|
-
|
|
21121
|
+
join10(admitted.runDirectory, "stderr.log"),
|
|
21153
21122
|
result2.stderr,
|
|
21154
21123
|
"utf8"
|
|
21155
21124
|
);
|
|
@@ -21363,7 +21332,7 @@ var init_coder_run = __esm({
|
|
|
21363
21332
|
|
|
21364
21333
|
// src/public-cli/collector-run.ts
|
|
21365
21334
|
import { writeFile as writeFile6 } from "node:fs/promises";
|
|
21366
|
-
import { join as
|
|
21335
|
+
import { join as join11 } from "node:path";
|
|
21367
21336
|
function buildModelArgs2(model) {
|
|
21368
21337
|
if (model === void 0) return [];
|
|
21369
21338
|
return [
|
|
@@ -21474,7 +21443,7 @@ async function dispatchAdmittedCollector(input) {
|
|
|
21474
21443
|
}
|
|
21475
21444
|
try {
|
|
21476
21445
|
await writeFile6(
|
|
21477
|
-
|
|
21446
|
+
join11(admitted.runDirectory, "stderr.log"),
|
|
21478
21447
|
result2.stderr,
|
|
21479
21448
|
"utf8"
|
|
21480
21449
|
);
|
|
@@ -21595,7 +21564,7 @@ var init_collector_run = __esm({
|
|
|
21595
21564
|
|
|
21596
21565
|
// src/public-cli/doctor-run.ts
|
|
21597
21566
|
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
21598
|
-
import { join as
|
|
21567
|
+
import { join as join12 } from "node:path";
|
|
21599
21568
|
function buildModelArgs3(model) {
|
|
21600
21569
|
if (model === void 0) return [];
|
|
21601
21570
|
return [
|
|
@@ -21700,7 +21669,7 @@ async function dispatchAdmittedDoctor(input) {
|
|
|
21700
21669
|
}
|
|
21701
21670
|
try {
|
|
21702
21671
|
await writeFile7(
|
|
21703
|
-
|
|
21672
|
+
join12(admitted.runDirectory, "stderr.log"),
|
|
21704
21673
|
result2.stderr,
|
|
21705
21674
|
"utf8"
|
|
21706
21675
|
);
|
|
@@ -21827,7 +21796,7 @@ var init_doctor_run = __esm({
|
|
|
21827
21796
|
|
|
21828
21797
|
// src/public-cli/fixer-run.ts
|
|
21829
21798
|
import { writeFile as writeFile8 } from "node:fs/promises";
|
|
21830
|
-
import { join as
|
|
21799
|
+
import { join as join13 } from "node:path";
|
|
21831
21800
|
function buildModelArgs4(model) {
|
|
21832
21801
|
if (model === void 0) return [];
|
|
21833
21802
|
return [
|
|
@@ -21996,7 +21965,7 @@ async function dispatchAdmittedFixer(input) {
|
|
|
21996
21965
|
}
|
|
21997
21966
|
try {
|
|
21998
21967
|
await writeFile8(
|
|
21999
|
-
|
|
21968
|
+
join13(admitted.runDirectory, "stderr.log"),
|
|
22000
21969
|
result2.stderr,
|
|
22001
21970
|
"utf8"
|
|
22002
21971
|
);
|
|
@@ -22219,7 +22188,7 @@ var init_fixer_run = __esm({
|
|
|
22219
22188
|
|
|
22220
22189
|
// src/public-cli/judge-run.ts
|
|
22221
22190
|
import { writeFile as writeFile9 } from "node:fs/promises";
|
|
22222
|
-
import { join as
|
|
22191
|
+
import { join as join14 } from "node:path";
|
|
22223
22192
|
function buildModelArgs5(model) {
|
|
22224
22193
|
if (model === void 0) return [];
|
|
22225
22194
|
return [
|
|
@@ -22361,7 +22330,7 @@ async function dispatchAdmittedJudge(input) {
|
|
|
22361
22330
|
}
|
|
22362
22331
|
try {
|
|
22363
22332
|
await writeFile9(
|
|
22364
|
-
|
|
22333
|
+
join14(admitted.runDirectory, "stderr.log"),
|
|
22365
22334
|
result2.stderr,
|
|
22366
22335
|
"utf8"
|
|
22367
22336
|
);
|
|
@@ -22535,7 +22504,7 @@ var init_judge_run = __esm({
|
|
|
22535
22504
|
|
|
22536
22505
|
// src/public-cli/merger-run.ts
|
|
22537
22506
|
import { mkdir as mkdir4, writeFile as writeFile10 } from "node:fs/promises";
|
|
22538
|
-
import { join as
|
|
22507
|
+
import { join as join15, resolve as resolve7 } from "node:path";
|
|
22539
22508
|
function buildModelArgs6(model) {
|
|
22540
22509
|
if (model === void 0) return [];
|
|
22541
22510
|
return [
|
|
@@ -22693,7 +22662,7 @@ async function dispatchAdmittedMerger(input) {
|
|
|
22693
22662
|
}
|
|
22694
22663
|
try {
|
|
22695
22664
|
await writeFile10(
|
|
22696
|
-
|
|
22665
|
+
join15(admitted.runDirectory, "stderr.log"),
|
|
22697
22666
|
result2.stderr,
|
|
22698
22667
|
"utf8"
|
|
22699
22668
|
);
|
|
@@ -22762,16 +22731,8 @@ async function loadMergerMethodMaterial(packageRoot2) {
|
|
|
22762
22731
|
}
|
|
22763
22732
|
async function admitMergerShellForActivationFailure(options) {
|
|
22764
22733
|
const projectRoot = resolve7(options.project ?? options.cwd);
|
|
22765
|
-
const bookKey = resolveBookKeyFromGit(projectRoot);
|
|
22766
|
-
const ledgerHome = resolveActivationLedgerHome(() => options.home);
|
|
22767
22734
|
const runId = (options.createRunId ?? uuidv7)();
|
|
22768
|
-
const runDirectory =
|
|
22769
|
-
activationBookDirectory(ledgerHome, bookKey),
|
|
22770
|
-
"runs",
|
|
22771
|
-
`${runId}@merger`
|
|
22772
|
-
);
|
|
22773
|
-
const sessionDirectory = join14(runDirectory, "session");
|
|
22774
|
-
const sessionFile = roleRunSessionFile(sessionDirectory);
|
|
22735
|
+
const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "merger", home: options.home });
|
|
22775
22736
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
22776
22737
|
await mkdir4(runDirectory, { recursive: true });
|
|
22777
22738
|
const emptyDerived = {
|
|
@@ -22781,8 +22742,8 @@ async function admitMergerShellForActivationFailure(options) {
|
|
|
22781
22742
|
expectedConflictPaths: [],
|
|
22782
22743
|
resolutionScope: []
|
|
22783
22744
|
};
|
|
22784
|
-
const admittedRequestPath =
|
|
22785
|
-
const mergerInputPath =
|
|
22745
|
+
const admittedRequestPath = join15(runDirectory, "admitted-request.json");
|
|
22746
|
+
const mergerInputPath = join15(runDirectory, "merger-input.json");
|
|
22786
22747
|
await writeFile10(
|
|
22787
22748
|
admittedRequestPath,
|
|
22788
22749
|
`${JSON.stringify(
|
|
@@ -22982,8 +22943,8 @@ async function runPublicMergerResume(argv, env, io) {
|
|
|
22982
22943
|
var init_merger_run = __esm({
|
|
22983
22944
|
"src/public-cli/merger-run.ts"() {
|
|
22984
22945
|
"use strict";
|
|
22985
|
-
init_activation_ledger_git();
|
|
22986
22946
|
init_activation_ledger_topology();
|
|
22947
|
+
init_sitian_role_run_coordinates();
|
|
22987
22948
|
init_method_skill();
|
|
22988
22949
|
init_uuidv7();
|
|
22989
22950
|
init_explicit_internal();
|
|
@@ -22998,7 +22959,7 @@ var init_merger_run = __esm({
|
|
|
22998
22959
|
|
|
22999
22960
|
// src/public-cli/reviewer-run.ts
|
|
23000
22961
|
import { writeFile as writeFile11 } from "node:fs/promises";
|
|
23001
|
-
import { join as
|
|
22962
|
+
import { join as join16 } from "node:path";
|
|
23002
22963
|
function buildModelArgs7(model) {
|
|
23003
22964
|
if (model === void 0) return [];
|
|
23004
22965
|
return [
|
|
@@ -23154,7 +23115,7 @@ async function dispatchAdmittedReviewer(input) {
|
|
|
23154
23115
|
}
|
|
23155
23116
|
try {
|
|
23156
23117
|
await writeFile11(
|
|
23157
|
-
|
|
23118
|
+
join16(admitted.runDirectory, "stderr.log"),
|
|
23158
23119
|
result2.stderr,
|
|
23159
23120
|
"utf8"
|
|
23160
23121
|
);
|
|
@@ -23386,7 +23347,7 @@ __export(cli_exports, {
|
|
|
23386
23347
|
});
|
|
23387
23348
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
23388
23349
|
import { homedir as homedir3 } from "node:os";
|
|
23389
|
-
import { join as
|
|
23350
|
+
import { join as join17 } from "node:path";
|
|
23390
23351
|
function defaultIo() {
|
|
23391
23352
|
return {
|
|
23392
23353
|
stdout: (text) => {
|
|
@@ -23401,7 +23362,7 @@ function resolveHome(env) {
|
|
|
23401
23362
|
return env.home ?? process.env.HOME ?? homedir3();
|
|
23402
23363
|
}
|
|
23403
23364
|
function resolveAgentDir(env, home) {
|
|
23404
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
23365
|
+
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join17(home, ".pi", "agent");
|
|
23405
23366
|
}
|
|
23406
23367
|
function parseThinking(value) {
|
|
23407
23368
|
if (!THINKING_LEVELS2.has(value)) {
|
|
@@ -24041,7 +24002,7 @@ var init_cli = __esm({
|
|
|
24041
24002
|
});
|
|
24042
24003
|
|
|
24043
24004
|
// src/public-cli/main.ts
|
|
24044
|
-
import { dirname as dirname7, join as
|
|
24005
|
+
import { dirname as dirname7, join as join18 } from "node:path";
|
|
24045
24006
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
24046
24007
|
|
|
24047
24008
|
// src/public-cli/host-pi-runtime.ts
|
|
@@ -24129,7 +24090,7 @@ function linkPackage(packageRoot2, name, targetDir) {
|
|
|
24129
24090
|
|
|
24130
24091
|
// src/public-cli/main.ts
|
|
24131
24092
|
var here = dirname7(fileURLToPath2(import.meta.url));
|
|
24132
|
-
var packageRoot =
|
|
24093
|
+
var packageRoot = join18(here, "..", "..");
|
|
24133
24094
|
ensureHostPiRuntimeResolvable(packageRoot);
|
|
24134
24095
|
var { runAkRole: runAkRole2 } = await Promise.resolve().then(() => (init_cli(), cli_exports));
|
|
24135
24096
|
var result = await runAkRole2(process.argv.slice(2), { packageRoot });
|