feat(cli): migrate child json recovery callers

This commit is contained in:
Codex
2026-07-02 19:25:27 +00:00
parent 51512f3d7b
commit 146ecc5e82
9 changed files with 254 additions and 142 deletions
+29 -1
View File
@@ -4,7 +4,7 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import { test } from "bun:test";
import { resolveCliChildJsonObject } from "./cli-child-json-recovery";
import { resolveCliChildJsonCommandResult, resolveCliChildJsonObject } from "./cli-child-json-recovery";
test("child JSON recovery reads full JSON from CLI stdout dump wrapper", async () => {
const dir = await mkdtemp(join(tmpdir(), "unidesk-cli-child-json-dump-"));
@@ -34,6 +34,34 @@ test("child JSON recovery reads full JSON from CLI stdout dump wrapper", async (
assert.equal(resolved.diagnostics.dumpJsonOk, true);
});
test("child JSON recovery command-result helper keeps dump diagnostics", async () => {
const dir = await mkdtemp(join(tmpdir(), "unidesk-cli-child-json-result-dump-"));
const dumpPath = join(dir, "dump.json");
await writeFile(dumpPath, JSON.stringify({ ok: true, verified: true, bytes: 123 }) + "\n");
const resolved = resolveCliChildJsonCommandResult({
result: {
stdout: JSON.stringify({
ok: true,
data: {
outputTruncated: true,
reason: "stdout-json-bytes-exceeded-threshold",
dump: { path: dumpPath },
},
}),
stderr: "",
exitCode: 0,
timedOut: false,
},
requestedStdoutType: "trans download verification JSON",
acceptParsed: (value) => value.ok === true && value.verified === true,
});
assert.equal(resolved.source, "dump");
assert.equal(resolved.parsed?.verified, true);
assert.equal(resolved.diagnostics.requestedStdoutType, "trans download verification JSON");
assert.equal(resolved.diagnostics.dumpPath, dumpPath);
});
test("child JSON recovery falls back to artifact after trans truncation summary", () => {
const summary = {
code: "ssh-truncation-summary",