# test\(server\): run fake provider CLIs through a Node stub on every host · PR \#9567 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/9567)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: merged

Source repository: pingdotgg/t3code

Source branch: windows-tests/fake-cli

Target branch: windows-tests/symlinks

Head commit: b4e082c2d33a1197543f2c9425f1e0b82ddacbbe

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/9567)

[Commits](https://git.cafe/pingdotgg/t3code/pull/9567/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/9567/diffs?format=markdown)

## Description

---

Seven suites faked a provider CLI with a #!/bin/sh script made executable
by chmod, which Windows cannot run: the shebang is ignored and there is no
extension for PATHEXT to match, so the spawn either failed or fell through
to a real CLI on PATH. CodexTextGeneration's fake was a 120-line sh
argument parser.

Add apps/server/src/testUtils/fakeCli.ts. writeFakeCli writes the CLI's
behaviour as a Node stub and a launcher shaped for the host: a shebang
script on posix, a .cmd shim on Windows, which resolveSpawnCommand already
routes through a shell. execScriptSource covers the common case of handing
over to the mock ACP agent after an argv check. ClaudeTextGeneration, which
had its own .cmd branch, moves onto the shared helper too.

The tests that assert the agent logged SIGTERM on stop are skipped on
Windows, where the child is terminated rather than signalled.

Part of the Windows test-suite stack rooted at [#9564](https://github.com/pingdotgg/t3code/pull/9564); the manual Windows lane comes from [#9538](https://github.com/pingdotgg/t3code/pull/9538).

Model: Claude Fable 5 in Claude Code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- Macroscope's pull request summary starts here -->
<!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. -->
<!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. -->
> [!NOTE]
> ### Run fake provider CLI fixtures through a shared Node stub on Windows and POSIX hosts
> - Adds a shared `writeFakeCli` utility in [fakeCli.ts](https://github.com/pingdotgg/t3code/pull/9567/files#diff-50ced850fd20b10cd9f93043accc17be1d166da15818cdf920cd8364299e8633) that emits a Node stub module plus a platform-appropriate launcher (POSIX shell or Windows `.cmd`), replacing per-test shell-script generation across provider and text-generation test suites
> - Refactors `CursorAdapter`, `CursorProvider`, `GrokAdapter`, `GrokProvider`, `CodexTextGeneration`, `CursorTextGeneration`, `GrokTextGeneration`, and `ClaudeTextGeneration` tests to build their fake agent binaries through the shared writer
> - Adds a Windows `.cmd` wrapper for the Codex collaboration mock peer and selects it on `win32` in the integration test; adds `.cmd`/`.bat` CRLF checkout rules in [.gitattributes](https://github.com/pingdotgg/t3code/pull/9567/files#diff-618cd5b83d62060ba3d027e314a21ceaf75d36067ff820db126642944145393e)
> - Guards SIGTERM-dependent child-process exit assertions with a `win32` skip condition in `CursorAdapter`, `CursorProvider`, `GrokAdapter`, `CursorTextGeneration`, and `CodexCollabRuntime` tests, since Windows terminates processes without delivering SIGTERM
> - Risk: the new `writeFakeCli` writer is the single path for fake CLI creation; any mismatch between the generated Node stub contract and an individual test's expectations (e.g. argument validation in `execScriptSource`) will surface as fixture failures across all refactored suites
>
> <!-- Macroscope's review summary starts here -->
>
> <sup><a href="https://app.macroscope.com">Macroscope</a> summarized b4e082c.</sup>
> <!-- Macroscope's review summary ends here -->
>
<!-- Macroscope's pull request summary ends here -->

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Changes are limited to test fixtures, git attributes, and conditional test skips; no production provider or spawn logic is modified.
> 
> **Overview**
> Provider and text-generation tests no longer build fake CLIs with hand-written `#!/bin/sh` wrappers (and chmod), which fail or hit the real binary on Windows. They now go through **`writeFakeCli`** in `apps/server/src/testUtils/fakeCli.ts`, which writes a **Node stub** plus a host-specific launcher (POSIX shell script or **`.cmd` shim**), with env applied via a JSON sidecar. **`execScriptSource`** covers the common “validate argv, then import the mock ACP agent” pattern; Codex’s large shell-based fake is reimplemented in Node the same way.
> 
> **Codex collab** integration picks `codexCollabMockPeer.cmd` on `win32` (new file); **`.gitattributes`** forces CRLF for `*.cmd` / `*.bat`.
> 
> Tests that assert **SIGTERM** in an exit log are **`skipIf` on Windows**, where children are killed without that signal. Production spawn paths are unchanged—this is test/fixture plumbing for the Windows test suite.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit b4e082c2d33a1197543f2c9425f1e0b82ddacbbe. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->


