Showing the changes to apps/server/scripts (2 of 71 files). Show all
Unified · Split
| @@ -1,6 +1,6 @@ | |||
| 1 | #!/usr/bin/env node | 1 | #!/usr/bin/env node |
| 2 | // @effect-diagnostics nodeBuiltinImport:off | 2 | // @effect-diagnostics nodeBuiltinImport:off |
| 3 | import { appendFileSync } from "node:fs"; | 3 | import * as NodeFS from "node:fs"; |
| 4 | 4 | ||
| 5 | import * as Effect from "effect/Effect"; | 5 | import * as Effect from "effect/Effect"; |
| 6 | 6 | ||
| @@ -42,7 +42,7 @@ function logExit(reason: string): void { · 35 unmodified lines | |||
| 42 | if (!exitLogPath) { | 42 | if (!exitLogPath) { |
| 43 | return; | 43 | return; |
| 44 | } | 44 | } |
| 45 | appendFileSync(exitLogPath, `${reason}\n`, "utf8"); | 45 | NodeFS.appendFileSync(exitLogPath, `${reason}\n`, "utf8"); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | process.once("SIGTERM", () => { | 48 | process.once("SIGTERM", () => { |
| @@ -693,7 +693,7 @@ const program = Effect.gen(function* () { · 644 unmodified lines | |||
| 693 | } | 693 | } |
| 694 | const payload = event.payload; | 694 | const payload = event.payload; |
| 695 | return Effect.sync(() => { | 695 | return Effect.sync(() => { |
| 696 | appendFileSync( | 696 | NodeFS.appendFileSync( |
| 697 | requestLogPath, | 697 | requestLogPath, |
| 698 | payload.endsWith("\n") ? payload : `${payload}\n`, | 698 | payload.endsWith("\n") ? payload : `${payload}\n`, |
| 699 | "utf8", | 699 | "utf8", |
| @@ -1,7 +1,7 @@ | |||
| 1 | // @effect-diagnostics nodeBuiltinImport:off | 1 | // @effect-diagnostics nodeBuiltinImport:off |
| 2 | import { spawn, type ChildProcessWithoutNullStreams } from "node:child_process"; | 2 | import * as NodeChildProcess from "node:child_process"; |
| 3 | import process from "node:process"; | 3 | import * as NodeProcess from "node:process"; |
| 4 | import readline from "node:readline"; | 4 | import * as NodeReadline from "node:readline"; |
| 5 | import * as NodeTimers from "node:timers"; | 5 | import * as NodeTimers from "node:timers"; |
| 6 | import { resolveSpawnCommand } from "@t3tools/shared/shell"; | 6 | import { resolveSpawnCommand } from "@t3tools/shared/shell"; |
| 7 | import * as Effect from "effect/Effect"; | 7 | import * as Effect from "effect/Effect"; |
| @@ -56,19 +56,19 @@ type PendingRequest = { · 48 unmodified lines | |||
| 56 | reject: (error: Error) => void; | 56 | reject: (error: Error) => void; |
| 57 | }; | 57 | }; |
| 58 | 58 | ||
| 59 | const targetCwd = process.argv[2] ?? process.cwd(); | 59 | const targetCwd = NodeProcess.argv[2] ?? NodeProcess.cwd(); |
| 60 | const targetModel = process.argv[3] ?? "gpt-5.4"; | 60 | const targetModel = NodeProcess.argv[3] ?? "gpt-5.4"; |
| 61 | const promptText = process.argv[4] ?? "helo"; | 61 | const promptText = NodeProcess.argv[4] ?? "helo"; |
| 62 | const targetReasoning = process.env.CURSOR_REASONING ?? ""; | 62 | const targetReasoning = NodeProcess.env.CURSOR_REASONING ?? ""; |
| 63 | const targetContext = process.env.CURSOR_CONTEXT ?? ""; | 63 | const targetContext = NodeProcess.env.CURSOR_CONTEXT ?? ""; |
| 64 | const targetFast = process.env.CURSOR_FAST ?? ""; | 64 | const targetFast = NodeProcess.env.CURSOR_FAST ?? ""; |
| 65 | const agentBin = process.env.CURSOR_AGENT_BIN ?? "agent"; | 65 | const agentBin = NodeProcess.env.CURSOR_AGENT_BIN ?? "agent"; |
| 66 | const promptWaitMs = Number(process.env.CURSOR_PROMPT_WAIT_MS ?? "4000"); | 66 | const promptWaitMs = Number(NodeProcess.env.CURSOR_PROMPT_WAIT_MS ?? "4000"); |
| 67 | const requestTimeoutMs = Number(process.env.CURSOR_REQUEST_TIMEOUT_MS ?? "20000"); | 67 | const requestTimeoutMs = Number(NodeProcess.env.CURSOR_REQUEST_TIMEOUT_MS ?? "20000"); |
| 68 | 68 | ||
| 69 | function logSection(title: string, value: unknown) { | 69 | function logSection(title: string, value: unknown) { |
| 70 | process.stdout.write(`\n=== ${title} ===\n`); | 70 | NodeProcess.stdout.write(`\n=== ${title} ===\n`); |
| 71 | process.stdout.write(`${JSON.stringify(value, null, 2)}\n`); | 71 | NodeProcess.stdout.write(`${JSON.stringify(value, null, 2)}\n`); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | function fail(message: string): never { | 74 | function fail(message: string): never { |
| @@ -124,18 +124,18 @@ function sleep(ms: number) { · 49 unmodified lines | |||
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | class JsonRpcChild { | 126 | class JsonRpcChild { |
| 127 | readonly child: ChildProcessWithoutNullStreams; | 127 | readonly child: NodeChildProcess.ChildProcessWithoutNullStreams; |
| 128 | readonly pending = new Map<JsonRpcId, PendingRequest>(); | 128 | readonly pending = new Map<JsonRpcId, PendingRequest>(); |
| 129 | nextId = 1; | 129 | nextId = 1; |
| 130 | closed = false; | 130 | closed = false; |
| 131 | 131 | ||
| 132 | constructor(bin: string, args: string[], cwd: string) { | 132 | constructor(bin: string, args: string[], cwd: string) { |
| 133 | const spawnCommand = Effect.runSync(resolveSpawnCommand(bin, args)); | 133 | const spawnCommand = Effect.runSync(resolveSpawnCommand(bin, args)); |
| 134 | this.child = spawn(spawnCommand.command, spawnCommand.args, { | 134 | this.child = NodeChildProcess.spawn(spawnCommand.command, spawnCommand.args, { |
| 135 | cwd, | 135 | cwd, |
| 136 | shell: spawnCommand.shell, | 136 | shell: spawnCommand.shell, |
| 137 | stdio: ["pipe", "pipe", "pipe"], | 137 | stdio: ["pipe", "pipe", "pipe"], |
| 138 | env: process.env, | 138 | env: NodeProcess.env, |
| 139 | }); | 139 | }); |
| 140 | 140 | ||
| 141 | this.child.on("exit", (code, signal) => { | 141 | this.child.on("exit", (code, signal) => { |
| @@ -155,14 +155,14 @@ class JsonRpcChild { · 13 unmodified lines | |||
| 155 | this.pending.clear(); | 155 | this.pending.clear(); |
| 156 | }); | 156 | }); |
| 157 | 157 | ||
| 158 | const stdout = readline.createInterface({ input: this.child.stdout }); | 158 | const stdout = NodeReadline.createInterface({ input: this.child.stdout }); |
| 159 | stdout.on("line", (line) => { | 159 | stdout.on("line", (line) => { |
| 160 | void this.handleStdoutLine(line); | 160 | void this.handleStdoutLine(line); |
| 161 | }); | 161 | }); |
| 162 | 162 | ||
| 163 | const stderr = readline.createInterface({ input: this.child.stderr }); | 163 | const stderr = NodeReadline.createInterface({ input: this.child.stderr }); |
| 164 | stderr.on("line", (line) => { | 164 | stderr.on("line", (line) => { |
| 165 | process.stdout.write(`[stderr] ${line}\n`); | 165 | NodeProcess.stdout.write(`[stderr] ${line}\n`); |
| 166 | }); | 166 | }); |
| 167 | } | 167 | } |
| 168 | 168 | ||
| @@ -175,7 +175,7 @@ class JsonRpcChild { · 6 unmodified lines | |||
| 175 | headers: [], | 175 | headers: [], |
| 176 | ...message, | 176 | ...message, |
| 177 | }); | 177 | }); |
| 178 | process.stdout.write(`>>> ${payload}\n`); | 178 | NodeProcess.stdout.write(`>>> ${payload}\n`); |
| 179 | this.child.stdin.write(`${payload}\n`); | 179 | this.child.stdin.write(`${payload}\n`); |
| 180 | } | 180 | } |
| 181 | 181 | ||
| @@ -240,13 +240,13 @@ class JsonRpcChild { · 58 unmodified lines | |||
| 240 | return; | 240 | return; |
| 241 | } | 241 | } |
| 242 | 242 | ||
| 243 | process.stdout.write(`<<< ${line}\n`); | 243 | NodeProcess.stdout.write(`<<< ${line}\n`); |
| 244 | 244 | ||
| 245 | let message: JsonRpcMessage; | 245 | let message: JsonRpcMessage; |
| 246 | try { | 246 | try { |
| 247 | message = JSON.parse(line) as JsonRpcMessage; | 247 | message = JSON.parse(line) as JsonRpcMessage; |
| 248 | } catch (error) { | 248 | } catch (error) { |
| 249 | process.stdout.write(`[parse-error] ${(error as Error).message}\n`); | 249 | NodeProcess.stdout.write(`[parse-error] ${(error as Error).message}\n`); |
| 250 | return; | 250 | return; |
| 251 | } | 251 | } |
| 252 | 252 | ||
| @@ -435,7 +435,7 @@ async function main() { · 182 unmodified lines | |||
| 435 | } | 435 | } |
| 436 | 436 | ||
| 437 | void main().catch((error: unknown) => { | 437 | void main().catch((error: unknown) => { |
| 438 | process.stderr.write( | 438 | NodeProcess.stderr.write( |
| 439 | `${error instanceof Error ? (error.stack ?? error.message) : String(error)}\n`, | 439 | `${error instanceof Error ? (error.stack ?? error.message) : String(error)}\n`, |
| 440 | ); | 440 | ); |
| 441 | process.exitCode = 1; | 441 | process.exitCode = 1; |