[codex] Enforce canonical Node namespace imports (#3238)
Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
db27502aff
commit
2fa37ec183
71 files changed
+1205
-952
No files matched your search
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import { appendFileSync } from "node:fs";
|
||||
import * as NodeFS from "node:fs";
|
||||
|
||||
import * as Effect from "effect/Effect";
|
||||
|
||||
@@ -42,7 +42,7 @@ function logExit(reason: string): void {
|
||||
if (!exitLogPath) {
|
||||
return;
|
||||
}
|
||||
appendFileSync(exitLogPath, `${reason}\n`, "utf8");
|
||||
NodeFS.appendFileSync(exitLogPath, `${reason}\n`, "utf8");
|
||||
}
|
||||
|
||||
process.once("SIGTERM", () => {
|
||||
@@ -693,7 +693,7 @@ const program = Effect.gen(function* () {
|
||||
}
|
||||
const payload = event.payload;
|
||||
return Effect.sync(() => {
|
||||
appendFileSync(
|
||||
NodeFS.appendFileSync(
|
||||
requestLogPath,
|
||||
payload.endsWith("\n") ? payload : `${payload}\n`,
|
||||
"utf8",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import { spawn, type ChildProcessWithoutNullStreams } from "node:child_process";
|
||||
import process from "node:process";
|
||||
import readline from "node:readline";
|
||||
import * as NodeChildProcess from "node:child_process";
|
||||
import * as NodeProcess from "node:process";
|
||||
import * as NodeReadline from "node:readline";
|
||||
import * as NodeTimers from "node:timers";
|
||||
import { resolveSpawnCommand } from "@t3tools/shared/shell";
|
||||
import * as Effect from "effect/Effect";
|
||||
@@ -56,19 +56,19 @@ type PendingRequest = {
|
||||
reject: (error: Error) => void;
|
||||
};
|
||||
|
||||
const targetCwd = process.argv[2] ?? process.cwd();
|
||||
const targetModel = process.argv[3] ?? "gpt-5.4";
|
||||
const promptText = process.argv[4] ?? "helo";
|
||||
const targetReasoning = process.env.CURSOR_REASONING ?? "";
|
||||
const targetContext = process.env.CURSOR_CONTEXT ?? "";
|
||||
const targetFast = process.env.CURSOR_FAST ?? "";
|
||||
const agentBin = process.env.CURSOR_AGENT_BIN ?? "agent";
|
||||
const promptWaitMs = Number(process.env.CURSOR_PROMPT_WAIT_MS ?? "4000");
|
||||
const requestTimeoutMs = Number(process.env.CURSOR_REQUEST_TIMEOUT_MS ?? "20000");
|
||||
const targetCwd = NodeProcess.argv[2] ?? NodeProcess.cwd();
|
||||
const targetModel = NodeProcess.argv[3] ?? "gpt-5.4";
|
||||
const promptText = NodeProcess.argv[4] ?? "helo";
|
||||
const targetReasoning = NodeProcess.env.CURSOR_REASONING ?? "";
|
||||
const targetContext = NodeProcess.env.CURSOR_CONTEXT ?? "";
|
||||
const targetFast = NodeProcess.env.CURSOR_FAST ?? "";
|
||||
const agentBin = NodeProcess.env.CURSOR_AGENT_BIN ?? "agent";
|
||||
const promptWaitMs = Number(NodeProcess.env.CURSOR_PROMPT_WAIT_MS ?? "4000");
|
||||
const requestTimeoutMs = Number(NodeProcess.env.CURSOR_REQUEST_TIMEOUT_MS ?? "20000");
|
||||
|
||||
function logSection(title: string, value: unknown) {
|
||||
process.stdout.write(`\n=== ${title} ===\n`);
|
||||
process.stdout.write(`${JSON.stringify(value, null, 2)}\n`);
|
||||
NodeProcess.stdout.write(`\n=== ${title} ===\n`);
|
||||
NodeProcess.stdout.write(`${JSON.stringify(value, null, 2)}\n`);
|
||||
}
|
||||
|
||||
function fail(message: string): never {
|
||||
@@ -124,18 +124,18 @@ function sleep(ms: number) {
|
||||
}
|
||||
|
||||
class JsonRpcChild {
|
||||
readonly child: ChildProcessWithoutNullStreams;
|
||||
readonly child: NodeChildProcess.ChildProcessWithoutNullStreams;
|
||||
readonly pending = new Map<JsonRpcId, PendingRequest>();
|
||||
nextId = 1;
|
||||
closed = false;
|
||||
|
||||
constructor(bin: string, args: string[], cwd: string) {
|
||||
const spawnCommand = Effect.runSync(resolveSpawnCommand(bin, args));
|
||||
this.child = spawn(spawnCommand.command, spawnCommand.args, {
|
||||
this.child = NodeChildProcess.spawn(spawnCommand.command, spawnCommand.args, {
|
||||
cwd,
|
||||
shell: spawnCommand.shell,
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
env: process.env,
|
||||
env: NodeProcess.env,
|
||||
});
|
||||
|
||||
this.child.on("exit", (code, signal) => {
|
||||
@@ -155,14 +155,14 @@ class JsonRpcChild {
|
||||
this.pending.clear();
|
||||
});
|
||||
|
||||
const stdout = readline.createInterface({ input: this.child.stdout });
|
||||
const stdout = NodeReadline.createInterface({ input: this.child.stdout });
|
||||
stdout.on("line", (line) => {
|
||||
void this.handleStdoutLine(line);
|
||||
});
|
||||
|
||||
const stderr = readline.createInterface({ input: this.child.stderr });
|
||||
const stderr = NodeReadline.createInterface({ input: this.child.stderr });
|
||||
stderr.on("line", (line) => {
|
||||
process.stdout.write(`[stderr] ${line}\n`);
|
||||
NodeProcess.stdout.write(`[stderr] ${line}\n`);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ class JsonRpcChild {
|
||||
headers: [],
|
||||
...message,
|
||||
});
|
||||
process.stdout.write(`>>> ${payload}\n`);
|
||||
NodeProcess.stdout.write(`>>> ${payload}\n`);
|
||||
this.child.stdin.write(`${payload}\n`);
|
||||
}
|
||||
|
||||
@@ -240,13 +240,13 @@ class JsonRpcChild {
|
||||
return;
|
||||
}
|
||||
|
||||
process.stdout.write(`<<< ${line}\n`);
|
||||
NodeProcess.stdout.write(`<<< ${line}\n`);
|
||||
|
||||
let message: JsonRpcMessage;
|
||||
try {
|
||||
message = JSON.parse(line) as JsonRpcMessage;
|
||||
} catch (error) {
|
||||
process.stdout.write(`[parse-error] ${(error as Error).message}\n`);
|
||||
NodeProcess.stdout.write(`[parse-error] ${(error as Error).message}\n`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -435,7 +435,7 @@ async function main() {
|
||||
}
|
||||
|
||||
void main().catch((error: unknown) => {
|
||||
process.stderr.write(
|
||||
NodeProcess.stderr.write(
|
||||
`${error instanceof Error ? (error.stack ?? error.message) : String(error)}\n`,
|
||||
);
|
||||
process.exitCode = 1;
|
||||
|
||||
Reference in new issue
Block a user