opencode icon indicating copy to clipboard operation
opencode copied to clipboard

scripts: path comparisons break on Windows (check-greys fails the pre-push hook, upgrade-opentui skips nothing)

Open Guembri01 opened this issue 1 week ago • 3 comments

Description

Two repository scripts compare paths from Bun.Glob against strings written with /. The glob returns the platform separator, so on Windows neither comparison works. The repo already normalises for this in one place (script/oxlint/anti-slop/effect/rules/no-service-constructor-imports.ts:31), so the convention exists and these two missed it.

script/check-greys.ts — fails the pre-push hook on Windows

EXCEPTIONS are written with / (/style\/token\/color\.css$/, /component\/video-editor\//, …) and matched with EXCEPTIONS.find(([re]) => re.test(file)) (:74). On Windows every scanned path is services\site\src\…, so no exception matches and the checker reports greys from the files the list exists to excuse — legacy tokens, the video editor, the font film, print.

Because bun run check is the pre-push hook, every Windows contributor is blocked until they push with --no-verify, which weakens the hook for everyone.

$ bun script/check-greys.ts
services\site\src\style\token\color.css:7  #f5f5f7  not on the scale
…
172 greys off the shared scale (script/check-greys.ts).   # exit 1

script/upgrade-opentui.ts — the skip list silently does nothing

const skip = new Set([".git", ".opencode", ".turbo", "dist", "node_modules"])
…
(file) => !file.split("/").some((part) => skip.has(part))

On Windows file.split("/") yields one part (node_modules\foo\package.json), so skip never matches and the script would rewrite the version field of every package.json under node_modules and dist.

Environment

  • opencode dev at b0cda20
  • Windows 10 22H2, Bun 1.4.5, PowerShell 5.1

Steps to reproduce

  1. Clone on Windows without Developer Mode.
  2. bun script/check-greys.ts → 172 problems, exit 1. On Linux the same command exits 0.
  3. Read script/upgrade-opentui.ts:41-43: the filter keeps node_modules and dist entries on Windows.

Expected behavior

Both scripts match on a separator-normalised path, so the same files are exempted and the same directories are skipped on every platform.

Additional context

Fixes are ready on two branches (check-greys one expression; upgrade-opentui one expression). Verified on Windows: bun script/check-greys.ts exit 1 → 0, bun run lint exit 0, and bun run check 36/36 tasks exit 0 once the checkout's 29 symlinks are materialised (they land as text files without Developer Mode, which is a separate, environment-only obstacle).

Guembri01 avatar Nov 24 '26 22:11 Guembri01

Not observed; this looks likely from reading the code.

Thanks for the precise write-up. I couldn't run this on Windows, so I confirmed it by reading the code. Both comparisons are still unchanged on the latest dev (fb56d1c):

  • script/check-greys.ts tests the EXCEPTIONS regexes, which are written with /, directly against the paths Bun.Glob returns. The script runs as part of bun run lint, which bun run check and the pre-push hook run, so with Windows backslash paths none of the exceptions match.
  • script/upgrade-opentui.ts filters with file.split("/"), so on Windows the node_modules, dist, .git, .opencode and .turbo entries are never skipped.

The check-greys half is already tracked in #63615, with a fix in the open PR #63619. #64740 was a duplicate of it. I found no issue or PR for the upgrade-opentui half, so this issue covers it.

opencodejr[bot] avatar Nov 24 '26 22:11 opencodejr[bot]

I can take the remaining script/upgrade-opentui.ts part of #66192. PR #63619 covers only the check-greys part; I would keep this change scoped to Windows-safe path filtering in the upgrade script and a focused regression test. Could a maintainer assign the issue to me? I will wait for confirmation before changing code, following CONTRIBUTING.md.

deosiree avatar Nov 24 '26 23:11 deosiree

Thanks — and good catch on #63615 / #63619; I had not found them. That changes what this issue is: the check-greys half is already covered by the open PR #63619, so the part that is genuinely new here is upgrade-opentui.

@deosiree — the upgrade-opentui half is yours. I've deleted my branch (script-path-separators) so there is nothing to conflict with, and I'd rather hand over the work than race you the way #66165 got closed.

So you don't have to re-derive it, this is the one-line change that fixes it:

 const files = (await Array.fromAsync(new Bun.Glob("**/package.json").scan({ cwd: root }))).filter(
-  (file) => !file.split("/").some((part) => skip.has(part)),
+  // The glob returns the platform separator; splitting on "/" alone would keep every skipped directory on Windows.
+  (file) => !file.replaceAll("\\", "/").split("/").some((part) => skip.has(part)),
 )

Non-obvious things I checked while doing it:

  • script/pack.ts:18 looks similar but is safe — it uses file.includes("node_modules"), which is separator-agnostic.
  • The repo already normalises this way for a path check: script/oxlint/anti-slop/effect/rules/no-service-constructor-imports.ts:31 does .replaceAll("\\", "/") on context.filename. That is the convention to match.
  • A regression test can exercise the filter expression with Windows-style inputs without spawning the script: node_modules\foo\package.json and packages\app\dist\package.json must be excluded, packages\app\package.json kept, and POSIX paths unchanged. I ran exactly that table; all six cases behaved.

One note for whoever writes the test: the root script/ folder has no test runner in CI (the root test script refuses, and bun test is guarded), so a test there may never run. A unit test is easiest if the filter is extracted, or the desktop package's script/ tests are the precedent to copy.

I'm not touching the check-greys half; #63619 owns it.

Guembri01 avatar Nov 25 '26 19:11 Guembri01