openpencil/scripts/ab-corpus
Fini 2c99a2466a fix(ai-skills): keep corpus barrel browser-safe (drop loadCorpus re-export)
User hit at dev-server startup:

  Module "node:fs" has been externalized for browser compatibility.
  Cannot access "node:fs.readdirSync" in client code.

Chain: apps/web's design-parser.ts imports `parseModelOutput` from
`@zseven-w/pen-ai-skills`; main barrel re-exports everything from
`./corpus`; `./corpus/index.ts` re-exports `loadCorpus` which imports
`node:fs`. Vite pulls the whole graph into the client bundle → crash
on the first browser-side module evaluation.

Fix: remove `loadCorpus` from `./corpus/index.ts`. The barrel now
only exposes pure-string helpers (parser, scorer, aggregator, types)
— all browser-safe. `loadCorpus` stays in `corpus-loader.ts` but
Node-only consumers (`scripts/ab-corpus/run.ts`) import it directly
via a relative path. Package.json only declares the main entry in
`exports`, so sub-path imports via the package name fail at runtime
(pkg runs under Bun for the harness) — relative file path avoids
that gate.

Verification:
- `bun scripts/ab-corpus/run.ts --only X --dry-run` still runs end
  to end
- tsc --noEmit exit 0
- Full test suite 1866/1866

Browser-side verification (user): restart Vite dev server — the
design-parser import no longer pulls node:fs through the barrel.
2026-04-21 00:43:48 +08:00
..
clients feat(scripts): ab-corpus harness with multi-provider model adapters 2026-04-20 23:53:23 +08:00
apply.ts feat(scripts): ab-corpus harness with multi-provider model adapters 2026-04-20 23:53:23 +08:00
build-prompt.ts feat(scripts): ab-corpus harness with multi-provider model adapters 2026-04-20 23:53:23 +08:00
real-model.ts feat(scripts): ab-corpus harness with multi-provider model adapters 2026-04-20 23:53:23 +08:00
run.ts fix(ai-skills): keep corpus barrel browser-safe (drop loadCorpus re-export) 2026-04-21 00:43:48 +08:00
stub-model.ts feat(scripts): ab-corpus harness with multi-provider model adapters 2026-04-20 23:53:23 +08:00
write-report.ts feat(scripts): ab-corpus harness with multi-provider model adapters 2026-04-20 23:53:23 +08:00