fix: 收敛 trans 远端文本短路径

This commit is contained in:
Codex
2026-07-13 05:20:27 +02:00
parent 18937da9db
commit c04983455e
16 changed files with 498 additions and 70 deletions
+20
View File
@@ -34,6 +34,26 @@ function applyReplacementPlan(original: string, plan: ApplyPatchV2BulkReplacemen
return lines.length === 0 ? "" : `${lines.join("\n")}\n`;
}
describe("apply-patch v2 stdin preflight", () => {
test("fails immediately on an interactive TTY and points to a quoted heredoc", async () => {
const stdin = Readable.from([]) as Readable & { isTTY?: boolean };
Object.defineProperty(stdin, "isTTY", { value: true });
const stdout = new CaptureWritable();
const stderr = new CaptureWritable();
const startedAtMs = Date.now();
const exitCode = await runApplyPatchV2({ executor: {}, stdin, stdout, stderr });
expect(exitCode).toBe(2);
expect(Date.now() - startedAtMs).toBeLessThan(1000);
expect(stdout.text()).toBe("");
expect(stderr.text()).toContain("UNIDESK_APPLY_PATCH_INPUT");
expect(stderr.text()).toContain("\"code\":\"apply-patch-stdin-required\"");
expect(stderr.text()).toContain("trans <route> apply-patch <<'PATCH'");
expect(stderr.text()).toContain("\"temporaryFileRequired\":false");
});
});
describe("apply-patch v2 fs bulk update path", () => {
test("single fs update uses readFiles and applyReplacementsBulk instead of whole-file write", async () => {
const files = new Map<string, string>([["docs/test.md", "alpha\nold\nomega\n"]]);