Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
Python agentaianthropicclaude-codecompressioncontext-engineeringcontext-windowcursorfastapilangchainllmmcpopenaiprompt-engineeringproxypythonragtoken-optimizationtokenstypescript
fix(opencode): hide spawned Windows console windows (#3743)
lorenzozane2157400b005b
diff --git a/headroom/providers/opencode/_dist/entry.opencode.js b/headroom/providers/opencode/_dist/entry.opencode.jsindex 0f92cf523..6d3dae693 100644--- a/headroom/providers/opencode/_dist/entry.opencode.js+++ b/headroom/providers/opencode/_dist/entry.opencode.js@@ -12544,6 +12544,9 @@ function injectOptionsEnv(args, optionIndex, state) {const callback = typeof nextArgs.at(-1) === "function" ? nextArgs.pop() : void 0;const existing = isOptions(nextArgs[optionIndex]) ? { ...nextArgs[optionIndex] } : {};existing.env = withShimEnv(existing.env, state.proxyUrl, state.excludeHosts);+ if (process.platform === "win32" && existing.windowsHide === void 0) {+ existing.windowsHide = true;+ }if (isOptions(nextArgs[optionIndex])) {nextArgs[optionIndex] = existing;} else {diff --git a/headroom/providers/opencode/hook-shim/handler.js b/headroom/providers/opencode/hook-shim/handler.jsindex 8eb545c24..deb28bf87 100644--- a/headroom/providers/opencode/hook-shim/handler.js+++ b/headroom/providers/opencode/hook-shim/handler.js@@ -65,6 +65,9 @@ function injectOptionsEnv(args, optionIndex, state) {const callback = typeof nextArgs.at(-1) === "function" ? nextArgs.pop() : void 0;const existing = isOptions(nextArgs[optionIndex]) ? { ...nextArgs[optionIndex] } : {};existing.env = withShimEnv(existing.env, state.proxyUrl, state.excludeHosts);+ if (process.platform === "win32" && existing.windowsHide === void 0) {+ existing.windowsHide = true;+ }if (isOptions(nextArgs[optionIndex])) {nextArgs[optionIndex] = existing;} else {diff --git a/plugins/opencode/src/transport.test.ts b/plugins/opencode/src/transport.test.tsindex 2b7de7a14..16c47b29d 100644--- a/plugins/opencode/src/transport.test.ts+++ b/plugins/opencode/src/transport.test.ts@@ -533,6 +533,56 @@ describe("Headroom OpenCode transport", () => {}});+ it("hides child process windows on Windows", () => {+ const originalSpawn = childProcess.spawn;+ const spawnMock = vi.fn(() => ({+ on: vi.fn(),+ once: vi.fn(),+ emit: vi.fn(),+ kill: vi.fn(),+ killed: false,+ pid: 123,+ }));+ childProcess.spawn = spawnMock as unknown as typeof childProcess.spawn;+ vi.spyOn(process, "platform", "get").mockReturnValue("win32");++ try {+ installHeadroomTransport({ proxyUrl: "http://127.0.0.1:8787/v1" });+ childProcess.spawn("node", ["agent.js"]);++ const options = (spawnMock.mock.calls[0] as unknown[])[2] as { windowsHide: boolean };+ expect(options.windowsHide).toBe(true);+ } finally {+ uninstallHeadroomTransport();+ childProcess.spawn = originalSpawn;+ }+ });++ it("preserves an explicit request to show a child process window on Windows", () => {+ const originalSpawn = childProcess.spawn;+ const spawnMock = vi.fn(() => ({+ on: vi.fn(),+ once: vi.fn(),+ emit: vi.fn(),+ kill: vi.fn(),+ killed: false,+ pid: 123,+ }));+ childProcess.spawn = spawnMock as unknown as typeof childProcess.spawn;+ vi.spyOn(process, "platform", "get").mockReturnValue("win32");++ try {+ installHeadroomTransport({ proxyUrl: "http://127.0.0.1:8787/v1" });+ childProcess.spawn("node", ["agent.js"], { windowsHide: false });++ const options = (spawnMock.mock.calls[0] as unknown[])[2] as { windowsHide: boolean };+ expect(options.windowsHide).toBe(false);+ } finally {+ uninstallHeadroomTransport();+ childProcess.spawn = originalSpawn;+ }+ });+it("injects one idempotent hook-shim --import into spawn/exec/execFile/fork children", () => {const originalSpawn = childProcess.spawn;const originalExec = childProcess.exec;diff --git a/plugins/opencode/src/transport.ts b/plugins/opencode/src/transport.tsindex 1a4b78689..cd16d5ef8 100644--- a/plugins/opencode/src/transport.ts+++ b/plugins/opencode/src/transport.ts@@ -135,6 +135,9 @@ function injectOptionsEnv(args: unknown[], optionIndex: number, state: Transportconst callback = typeof nextArgs.at(-1) === "function" ? nextArgs.pop() : undefined;const existing = isOptions(nextArgs[optionIndex]) ? { ...(nextArgs[optionIndex] as Record<string, unknown>) } : {};existing.env = withShimEnv(existing.env as NodeJS.ProcessEnv | undefined, state.proxyUrl, state.excludeHosts);+ if (process.platform === "win32" && existing.windowsHide === undefined) {+ existing.windowsHide = true;+ }if (isOptions(nextArgs[optionIndex])) {nextArgs[optionIndex] = existing;