Skip to content

chore: migrate toolchain to Bun#599

Merged
FL4TLiN3 merged 6 commits intomainfrom
chore/migrate-to-bun
Feb 23, 2026
Merged

chore: migrate toolchain to Bun#599
FL4TLiN3 merged 6 commits intomainfrom
chore/migrate-to-bun

Conversation

@FL4TLiN3
Copy link
Contributor

Summary

Migrate the entire Perstack monorepo toolchain from pnpm + Node.js + tsdown + Vitest to Bun as the unified runtime, package manager, test runner, and script runner.

  • Package manager: pnpm → bun (removed pnpm-workspace.yaml, pnpm-lock.yaml, added bun.lock)
  • Script runner: tsx → bun (removed tsx dependency)
  • Build system: tsdown → tsc (per-package tsconfig.build.json, removed all tsdown.config.ts)
  • Test runner: vitest → bun:test (117 test files migrated, removed vitest.config.ts)
  • Runtime: Node.js → Bun (shebangs changed to #!/usr/bin/env bun)
  • CI/CD: Updated all GitHub Actions workflows to use oven-sh/setup-bun@v2
  • Turborepo retained for build orchestration and caching

Key decisions

  • Per-package test isolation via turbo run test (bun:test mock.module() is permanent within a process)
  • Per-file test isolation for @perstack/runtime (heavy mock.module usage across files)
  • Manual happy-dom setup for React hook tests (packages/react/happydom.ts)
  • Class-based mock pattern for @perstack/skill-manager (bun:test mock() has no .prototype)

Verification

All checks pass locally:

  • Typecheck: 23/23
  • Tests: 19/19 packages
  • Build: 23/23
  • Lint: pass
  • Validation scripts: pass

Test plan

  • CI passes: typecheck, test, build, lint
  • CLI runs: bun apps/perstack/dist/bin/cli.js --help
  • MCP server runs: bun apps/base/dist/bin/server.js --help
  • E2E tests pass (requires API keys)

🤖 Generated with Claude Code

FL4TLiN3 and others added 6 commits February 22, 2026 15:08
Unify the entire toolchain under Bun: package manager, runtime,
test runner, script runner, and build system. Turborepo is retained
for build orchestration and caching.

**Package manager (pnpm → bun)**
- Replace pnpm with bun workspaces, delete pnpm-lock.yaml/pnpm-workspace.yaml
- Generate bun.lock, update all scripts from pnpm to bun

**Runtime (Node.js → Bun)**
- Change shebangs from #!/usr/bin/env node to #!/usr/bin/env bun
- Update engines field to bun >= 1.2.0 across all packages

**Build system (tsdown → tsc)**
- Replace tsdown with tsc -p tsconfig.build.json for all 23 packages
- Create per-package tsconfig.build.json with appropriate templates
- Delete all tsdown config files

**Test runner (vitest → bun:test)**
- Migrate all 117 test files from vitest to bun:test API
- Handle bun:test limitations: mock.module() cross-file leaking via
  per-package process isolation (turbo run test) and per-file isolation
  for @perstack/runtime
- Create types/bun-test.d.ts for TypeScript support
- Set up happy-dom for React component tests

**Script runner (tsx → bun)**
- Replace tsx with bun for validation scripts

**CI/CD**
- Update all GitHub Actions workflows to use oven-sh/setup-bun
- Keep Node.js setup in release workflow for npm registry publishing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- CI test step: use `bun run test` (turbo) instead of `bun test` directly
  to get per-package process isolation (prevents mock.module leaks)
- knip: add entry points for create-expert-skill and runtime test files
  (previously discovered via tsdown/vitest plugins)
- Remove unused smol-toml from root devDependencies (was used in deleted
  vitest.config.ts)
- Add empty changeset

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CI knip may not auto-discover entries from package.json bin/exports
fields. Add explicit entries to ensure consistent behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Mark collectToolDefinitionsForExpert as @public (part of runtime's
  public API, documented in README, but not imported internally)
- Previously the vitest plugin traced this through test files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Root bunfig.toml: only had coverageSkipTestFiles, but CI doesn't use
  --coverage
- packages/react/bunfig.toml: happydom preload is redundant since hook
  test files already import happydom directly

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Test files are excluded from tsconfig.json in all packages, so tsc
never resolves bun:test imports. The type declarations are unnecessary.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@FL4TLiN3 FL4TLiN3 merged commit defd4e3 into main Feb 23, 2026
11 checks passed
@FL4TLiN3 FL4TLiN3 deleted the chore/migrate-to-bun branch February 23, 2026 06:56
FL4TLiN3 added a commit that referenced this pull request Feb 23, 2026
The Bun migration (#599) removed actions/setup-node from the E2E
workflow. MCP skills using `npx` (e.g., exa-mcp-server) need Node.js
22 — the system default on ubuntu-24.04 is too old. Additionally, the
create-expert E2E test imports smol-toml directly, which needs to be
a root devDependency for reliable resolution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
FL4TLiN3 added a commit that referenced this pull request Feb 23, 2026
The Bun migration (#599) removed actions/setup-node from the E2E
workflow. MCP skills using `npx` (e.g., exa-mcp-server) need Node.js
22 — the system default on ubuntu-24.04 is too old. Additionally, the
create-expert E2E test imports smol-toml directly, which needs to be
a root devDependency for reliable resolution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
FL4TLiN3 added a commit that referenced this pull request Feb 23, 2026
The Bun migration (#599) removed actions/setup-node from the E2E
workflow. MCP skills using `npx` (e.g., exa-mcp-server) need Node.js
22 — the system default on ubuntu-24.04 is too old. Additionally,
replace direct smol-toml import in create-expert E2E test with
parsePerstackConfig from @perstack/perstack-toml.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
FL4TLiN3 added a commit that referenced this pull request Feb 23, 2026
The Bun migration (#599) removed actions/setup-node from the E2E
workflow. MCP skills using `npx` (e.g., exa-mcp-server) need Node.js
22 — the system default on ubuntu-24.04 is too old. Additionally,
replace direct smol-toml import in create-expert E2E test with
parsePerstackConfig from @perstack/perstack-toml.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
FL4TLiN3 added a commit that referenced this pull request Feb 23, 2026
The Bun migration (#599) removed actions/setup-node from the E2E
workflow. MCP skills using `npx` (e.g., exa-mcp-server) need Node.js
22 — the system default on ubuntu-24.04 is too old. Additionally,
replace direct smol-toml import in create-expert E2E test with
parsePerstackConfig from @perstack/perstack-toml.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
FL4TLiN3 added a commit that referenced this pull request Feb 24, 2026
After the bun migration (PR #599), published packages had literal
"workspace:*" in dependencies because changeset publish (npm publish)
does not resolve workspace protocol like pnpm did. Additionally,
private devDependencies were no longer bundled into dist since tsc
replaced tsdown.

Changes:
- Restore tsdown as the build tool for all packages
- Fix workspace:* to fixed versions in published packages' dependencies
- Make @perstack/skill-manager private (was incorrectly public)
- Move skill-manager to runtime's devDependencies (bundled by tsdown)
- Add skill-manager's transitive public deps to runtime's dependencies

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
FL4TLiN3 added a commit that referenced this pull request Feb 24, 2026
#616)

* Fix: restore tsdown bundling and fix workspace:* in published packages

After the bun migration (PR #599), published packages had literal
"workspace:*" in dependencies because changeset publish (npm publish)
does not resolve workspace protocol like pnpm did. Additionally,
private devDependencies were no longer bundled into dist since tsc
replaced tsdown.

Changes:
- Restore tsdown as the build tool for all packages
- Fix workspace:* to fixed versions in published packages' dependencies
- Make @perstack/skill-manager private (was incorrectly public)
- Move skill-manager to runtime's devDependencies (bundled by tsdown)
- Add skill-manager's transitive public deps to runtime's dependencies

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Chore: add changeset for tsdown restoration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix: add knip ignore for runtime transitive deps and bump all public packages

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
FL4TLiN3 added a commit that referenced this pull request Mar 3, 2026
The shebang in @perstack/base and @perstack/create-expert-skill was
changed from `#!/usr/bin/env node` to `#!/usr/bin/env bun` during the
Bun toolchain migration (#599). This breaks execution in environments
where only Node.js is available (e.g. job executor containers), causing
`/usr/bin/env: 'bun': No such file or directory`.

These scripts use no bun-specific APIs and run fine under Node.js.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
FL4TLiN3 added a commit that referenced this pull request Mar 3, 2026
* fix: add fireworks provider to Dockerfile

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: restore node shebang in published bin scripts

The shebang in @perstack/base and @perstack/create-expert-skill was
changed from `#!/usr/bin/env node` to `#!/usr/bin/env bun` during the
Bun toolchain migration (#599). This breaks execution in environments
where only Node.js is available (e.g. job executor containers), causing
`/usr/bin/env: 'bun': No such file or directory`.

These scripts use no bun-specific APIs and run fine under Node.js.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore: add changeset for shebang fix

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
FL4TLiN3 added a commit that referenced this pull request Mar 11, 2026
These files were left over from the toolchain migration to Bun (#599).
The build pipeline now uses tsdown.config.ts and these are unreferenced.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
FL4TLiN3 added a commit that referenced this pull request Mar 11, 2026
* chore: remove unused tsconfig.build.json files

These files were left over from the toolchain migration to Bun (#599).
The build pipeline now uses tsdown.config.ts and these are unreferenced.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore: add empty changeset

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant