Skip to content

fix(orchestrate): resolve test CLI paths with fileURLToPath - #384

Open
SurefireStudios wants to merge 1 commit into
cursor:mainfrom
SurefireStudios:fix/test-paths-windows
Open

SurefireStudios wants to merge 1 commit into
cursor:mainfrom
SurefireStudios:fix/test-paths-windows

Conversation

@SurefireStudios

@SurefireStudios SurefireStudios commented Sep 16, 2026

Copy link
Copy Markdown

What

Three test files in orchestrate/skills/orchestrate/scripts/__tests__/ build a filesystem path like this:

const CLI_PATH = new URL("../cli.ts", import.meta.url).pathname;

On Windows URL.pathname returns a leading-slash path:

URL.pathname     => "/C:/Users/me/plugins/orchestrate/.../cli.ts"
fileURLToPath    => "C:\Users\me\plugins\orchestrate\...\cli.ts"

spawnSync can't launch the first one, so the CLI never starts and the assertions see exit status 1 instead of the expected 2 — a failure that points at plan validation rather than at the path.

.pathname also leaves percent-encoding in place, so a checkout under a directory containing a space (/home/ci/My Project/…My%20Project) breaks the same way on any platform.

The fix

Use fileURLToPath, which is what __tests__/checkpoint-restart.test.ts in the same directory already does:

const SCRIPTS_DIR = dirname(
  fileURLToPath(new URL("../cli.ts", import.meta.url))
);

Five call sites in the repo already use fileURLToPath; these were the remaining four using .pathname. 11 lines across 3 files, no behaviour change on macOS or Linux.

Verification

Run on Windows 11, bun 1.2.10:

before after
bun test 200 pass / 9 fail 208 pass / 1 fail
bun run typecheck exit 0 exit 0
biome check (changed files) clean clean

The one failure left

operator boundary > requires a current-user 0600 operator flag still fails on Windows. It calls chmodSync(flagPath, 0o600) and NTFS has no POSIX mode bits, so isOperatorModeEnabled can never see 0600. The check itself is correct and deliberately strict, so I've left it alone — happy to add a test.skipIf(process.platform === "win32") if you'd prefer it green, but that's your call on a security-relevant test.

Why this wasn't caught

.github/workflows/validate-plugins.yml is the only workflow and it's path-filtered to marketplace.json, **/plugin.json and schemas/**. orchestrate defines test, typecheck, lint and check scripts, but nothing in CI invokes them. Glad to open a separate PR adding that job if it's wanted — didn't want to bundle a CI change into a bug fix.


Note

Low Risk
Test-only path resolution changes with no impact on production orchestrate CLI behavior.

Overview
Fixes orchestrate CLI integration tests that spawn cli.ts via spawnSync by resolving import.meta.url with fileURLToPath instead of URL.pathname.

Previously, .pathname produced invalid paths on Windows (leading /C:/…) and could leave percent-encoded segments in paths with spaces, so the CLI often failed to start and tests misreported exit codes. comment-cli, kickoff-dedupe, and prompt-plan-validation now match the existing checkpoint-restart pattern; SCRIPTS_DIR is derived via dirname of the resolved CLI path where needed.

No production CLI behavior changes—test-only path resolution for cross-platform reliability.

Reviewed by Cursor Bugbot for commit 13fe00e. Bugbot is set up for automated code reviews on this repo. Configure here.

Three test files built a filesystem path with `new URL(..., import.meta.url).pathname`.
On Windows that yields a leading-slash path (`/C:/...`) that spawnSync cannot launch, so
the CLI never starts and the assertions see exit status 1 instead of the expected 2.
`.pathname` also leaves percent-encoding in place, so a checkout under a directory with
a space breaks the same way on any platform.

Use `fileURLToPath`, matching `__tests__/checkpoint-restart.test.ts` and the four other
call sites already doing this in the repo.

On Windows: 200 pass / 9 fail -> 208 pass / 1 fail. The remaining failure is
`operator boundary > requires a current-user 0600 operator flag`, which calls
`chmodSync(flag, 0o600)`; NTFS has no POSIX mode bits, so it is left untouched.
No change in behaviour on macOS or Linux.
Copilot AI lite review requested due to automatic review settings September 16, 2026 07:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants