Validator finding #12 from the publish-debate-vortex hyperultradebate flagged that internal-only skill and command assets could leak into the npm payload once the dot asset roots are included.
Bun 1.3.x ignores a root .npmignore for directories listed in package.json#files, so the exclusion rules live in nested .npmignore files co-located with each published command and skill directory.
RED before nested ignores: bun test script/package-layout-exclusion.test.ts failed with expect(received).toEqual(expected), receiving .opencode/skills/__internal-fake-do-not-ship-test-artifact/SKILL.md, .agents/skills/__internal-fake-do-not-ship-test-artifact/SKILL.md, .opencode/command/__internal-fake-do-not-ship-test-artifact.md, and .agents/command/__internal-fake-do-not-ship-test-artifact.md instead of [].
GREEN after nested ignores: bun test script/package-layout-exclusion.test.ts reported 2 pass, 0 fail, 5 expect() calls.
This is the exclusion companion to script/package-layout.test.ts, the inclusion test arriving through the dev merge.
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
- script/run-ci-tests.ts: CI test sharding and isolation logic
- script/run-ci-tests.test.ts: tests for CI test target selection
- src/features/background-agent/session-route.ts: session prompt routing for background agents
- src/hooks/interactive-bash-session/parser.ts: interactive bash output parser
- src/hooks/ralph-loop/completion-promise-detector-test-input.ts: test fixture for completion promise detection
Root cause: bun build --target bun inlines top-level
var { spawn } = globalThis.Bun;
for every file that contains 'import { spawn } from "bun"'. On Node/Electron
where globalThis.Bun is undefined, this crashes with
Cannot destructure property 'spawn' of 'globalThis.Bun' as it is undefined.
26 source files had this import; the bundled output had 25 top-level destructures.
Fix:
- Add src/shared/bun-spawn-shim.ts: a thin wrapper that
- delegates to Bun.spawn/spawnSync when globalThis.Bun is present (real Bun)
- falls back to static ESM imports of node:child_process otherwise
- uses static 'import { spawn } from "node:child_process"' so Bun bundler
does NOT emit any globalThis.Bun destructures for this module
- Replace all 26 'from "bun"' spawn/spawnSync imports with relative paths to shim
- Replace 4 direct Bun.spawn() call sites with shim's spawn()
- Remove src/electron-compat.ts and script/prepend-electron-shim.ts (no longer needed)
- Update src/electron-compat.test.ts to assert 0 top-level globalThis.Bun destructures
Verification: grep -c '} = globalThis.Bun;' dist/index.js → 0 (was 25)
All 5921 tests pass (1 pre-existing timeout failure unrelated to this change).
Fixes#3797
On Node/Electron, globalThis.Bun is undefined. The Bun bundler emits top-level
var { spawn } = globalThis.Bun;
destructures from its internal modules, causing 'Cannot destructure property
of undefined' before any plugin hook is reached (25 occurrences in dist/index.js).
Fix:
- Add src/electron-compat.ts: a side-effect module that populates globalThis.Bun
with node:child_process-backed spawn/spawnSync shims when Bun is unavailable
- Add script/prepend-electron-shim.ts: post-build script that prepends the shim
code to dist/index.js, guaranteeing it runs BEFORE the top-level destructures
(Bun bundler does not preserve import side-effect evaluation order reliably)
- Update build script to run prepend-shim after bundling
- Add src/electron-compat.test.ts verifying shim position in dist
The shim only activates when globalThis.Bun is absent (real Bun runtime is
unaffected). Spawn-dependent features degrade gracefully at call time.
Fixes#3797 (follow-up to #3795/#3796)
CI ubuntu-latest has @types/node ambient types that conflict with
bun-types for CompressionStream/DecompressionStream declarations.
skipLibCheck skips checking .d.ts files from node_modules.
- Fix zod/v4 imports in background-task schema tests
- Remove ZWSP prefix from agent-key-remapper test (fixed in #3136)
- Use toMatchObject for openai-only catalog tests (fallback_models added by #3144)
- Replace z.toJSONSchema (zod v4) with zodToJsonSchema (zod v3 compat)
- Fix task-list.ts type narrowing for zod v3 inferred types