Summary
17 tests fail with ENOENT when the repository is checked out to a directory whose path contains a space (or any URL-special character). The code under test is fine — the failures are purely an artifact of the checkout path.
Environment
- Node.js v22.23.1, pnpm 10.x, macOS (Darwin 24.5.0)
- Repo cloned into a path containing a space, e.g.
/Users/me/money making projects/automaton
Steps to reproduce
- Clone into a directory whose path contains a space:
git clone https://github.com/Conway-Research/automaton.git "some dir/automaton"
cd "some dir/automaton" && pnpm install && pnpm build
pnpm test
Result
17 specs fail, all with the same shape:
Error: ENOENT: no such file or directory, open
'/Users/.../money%20making%20projects/automaton/src/agent/tools.ts'
Note the %20 — the real path has a space, not %20.
Affected specs:
src/__tests__/command-injection.test.ts → "Source code injection safety" (5 specs)
src/__tests__/skills-hardening.test.ts → registry / system-prompt / loader source assertions (12 specs)
Root cause
These specs locate source files with:
new URL("../agent/tools.ts", import.meta.url).pathname
URL.pathname returns a percent-encoded path, so a space becomes %20. fs.readFileSync then receives a path that doesn't exist on disk → ENOENT. CI passes because the GitHub runner's checkout path (/home/runner/work/...) has no special characters, so the bug is invisible there.
Expected
The suite should pass regardless of where the repo is checked out.
Fix
Use fileURLToPath() (from node:url) instead of .pathname — it decodes percent-encoding and is cross-platform. It also lets the fragile .replace("/src/__tests__/../", "/src/") be removed:
import { fileURLToPath } from "node:url";
const source = fs.readFileSync(
fileURLToPath(new URL("../agent/tools.ts", import.meta.url)),
"utf-8",
);
With the fix applied, both files pass (132/132) and pnpm typecheck stays green. PR opened alongside this issue.
Summary
17 tests fail with
ENOENTwhen the repository is checked out to a directory whose path contains a space (or any URL-special character). The code under test is fine — the failures are purely an artifact of the checkout path.Environment
/Users/me/money making projects/automatonSteps to reproduce
pnpm testResult
17 specs fail, all with the same shape:
Note the
%20— the real path has a space, not%20.Affected specs:
src/__tests__/command-injection.test.ts→ "Source code injection safety" (5 specs)src/__tests__/skills-hardening.test.ts→ registry / system-prompt / loader source assertions (12 specs)Root cause
These specs locate source files with:
URL.pathnamereturns a percent-encoded path, so a space becomes%20.fs.readFileSyncthen receives a path that doesn't exist on disk →ENOENT. CI passes because the GitHub runner's checkout path (/home/runner/work/...) has no special characters, so the bug is invisible there.Expected
The suite should pass regardless of where the repo is checked out.
Fix
Use
fileURLToPath()(fromnode:url) instead of.pathname— it decodes percent-encoding and is cross-platform. It also lets the fragile.replace("/src/__tests__/../", "/src/")be removed:With the fix applied, both files pass (132/132) and
pnpm typecheckstays green. PR opened alongside this issue.