fix(windows): the kernel-parity sweep loads the engine as file:// URLs (#2352)

scripts/kernel-parity.mjs handed import() a path from path.join(). On
Windows that is `C:\...`, which Node's ESM loader rejects with
ERR_UNSUPPORTED_ESM_URL_SCHEME, so the sweep could not run there at all
and contributors kept patched scratch copies. The three engine imports
now go through pathToFileURL(...).href, as the agent-eval probe scripts
already do. On macOS and Linux an ordinary path resolves to the same
file:// URL as before.

Checked on Windows 11 after npm ci, npm run build and
scripts/build-kernel.sh: the unmodified script threw at its first import;
with the fix, the C# fixtures (3/3), src/search (4/4), all of src/ as
TypeScript (261/263, 2 deferred to wasm) and every fixture language
(42/42) run to the summary line and exit 0.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Colby Mchenry
2026-10-05 17:37:39 +00:00
committed by GitHub
parent c9944147bb
commit 26e8488aed
+6 -4
View File
@@ -25,7 +25,7 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
import { fileURLToPath } from 'node:url';
import { fileURLToPath, pathToFileURL } from 'node:url';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const dist = (p) => path.join(ROOT, 'dist', p);
@@ -106,9 +106,11 @@ if (files.length === 0) {
}
// --- load the built engine ---------------------------------------------------
const { extractFromSource } = await import(dist('extraction/tree-sitter.js'));
const { initGrammars, loadGrammarsForLanguages, detectLanguage } = await import(dist('extraction/grammars.js'));
const kernel = await import(dist('extraction/kernel/index.js'));
// As file:// URLs: import() rejects a bare `C:\...` path on Windows
// (ERR_UNSUPPORTED_ESM_URL_SCHEME).
const { extractFromSource } = await import(pathToFileURL(dist('extraction/tree-sitter.js')).href);
const { initGrammars, loadGrammarsForLanguages, detectLanguage } = await import(pathToFileURL(dist('extraction/grammars.js')).href);
const kernel = await import(pathToFileURL(dist('extraction/kernel/index.js')).href);
await initGrammars();
await loadGrammarsForLanguages([...KERNEL_LANGS]);