Files
Christian Klotz 75e6123aba fix(coding-agent): speed up external editor launch (#6903)
* fix(coding-agent): speed up external editor launch

Fixes #6774

* refactor(coding-agent): clarify external editor handling

* refactor(coding-agent): simplify external editor result

* refactor(coding-agent): model external editor lifecycle

* fix(coding-agent): rename external editor test fake

* fix(coding-agent): secure external editor temp files

* fix(coding-agent): simplify external editor temp path

* fix(coding-agent): restore system temp editor files
2026-07-22 15:49:01 +02:00

26 lines
635 B
JavaScript

import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
import { dirname } from "node:path";
const capturePath = process.argv[2];
const filePath = process.argv.at(-1);
if (!capturePath || !filePath) {
process.exit(1);
}
const directory = dirname(filePath);
writeFileSync(
capturePath,
JSON.stringify({
filePath,
content: readFileSync(filePath, "utf-8"),
entries: readdirSync(directory),
directoryMode: statSync(directory).mode & 0o777,
}),
"utf-8",
);
if (process.argv.includes("--fail")) {
process.exit(1);
}
writeFileSync(filePath, process.argv.includes("--empty") ? "" : "edited\n", "utf-8");