Skip to content

Commit 1c3c0a6

Browse files
committed
refactor: migrate scripts and dependencies to use Bun
- Updated package.json to replace npm commands with Bun equivalents for build, typecheck, lint, test, and other scripts. - Changed shebangs in various scripts from node to bun. - Modified launch script to suggest Bun for installing Electron. - Updated runtime harness server and test scripts to use Bun for execution. - Added a new test results file to track the last run status.
1 parent 4c9abb2 commit 1c3c0a6

20 files changed

+205
-4867
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Setup Bun
1616
uses: oven-sh/setup-bun@v2
1717
with:
18-
bun-version: "1.3.10"
18+
bun-version: "latest"
1919

2020
- name: Install dependencies
2121
run: bun install --frozen-lockfile

.github/workflows/sync-github-project.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,15 @@ jobs:
2323
- name: Checkout
2424
uses: actions/checkout@v4
2525

26-
- name: Setup Node
27-
uses: actions/setup-node@v4
26+
- name: Setup Bun
27+
uses: oven-sh/setup-bun@v2
2828
with:
29-
node-version: "20"
30-
cache: "npm"
29+
bun-version: "latest"
3130

3231
- name: Install dependencies
33-
run: npm ci
32+
run: bun install --frozen-lockfile
3433

3534
- name: Sync GitHub Project (milestones, labels, issues)
3635
env:
3736
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38-
run: npm run sync:github-project
37+
run: bun run sync:github-project

.vscode/tasks.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"label": "harness:serve",
66
"type": "shell",
7-
"command": "node scripts/runtime-harness-server.mjs",
7+
"command": "bun scripts/runtime-harness-server.mjs",
88
"isBackground": true,
99
"problemMatcher": {
1010
"owner": "cortex-harness",
@@ -27,7 +27,7 @@
2727
{
2828
"label": "harness:stop",
2929
"type": "shell",
30-
"command": "pkill -f 'node scripts/runtime-harness-server.mjs' || true",
30+
"command": "pkill -f 'bun scripts/runtime-harness-server.mjs' || true",
3131
"presentation": {
3232
"reveal": "never",
3333
"panel": "shared"

BUN_MIGRATION_REPORT.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
Migrating CORTEX from Node.js + npm to Bun is **low-risk, fully compatible, and meaningfully faster for CI**. Every CI step—install, lint, typecheck, and unit tests—ran correctly under Bun with zero code changes required. The largest single win is the package install step: `bun install` with a warm global cache resolves in **~13 ms** versus npm ci's constant **~7–8 s** regardless of cache. Across all CI steps the end-to-end savings in a cold run sit around 25%; on a warm-cache hit the install alone cuts from 8 s to 0.013 s—a roughly **600×** improvement.
1212

13-
The migration surface is narrow: two CI workflow lines, two lines in `docs/development.md`, and one `trustedDependencies` field already added to `package.json`. No TypeScript source files need to change.
13+
The migration surface remains low-risk: CI/workflow setup now uses Bun latest, package scripts invoke Bun directly, and script launchers/shebangs use Bun entrypoints. No TypeScript feature modules required changes.
1414

1515
---
1616

@@ -88,21 +88,21 @@ By default Bun sandboxes lifecycle scripts for security. Two transitive dependen
8888
]
8989
```
9090

91-
#### 2. Script shebangs use `#!/usr/bin/env node`
91+
#### 2. Script shebangs now use `#!/usr/bin/env bun`
9292

93-
All scripts in `scripts/` declare `#!/usr/bin/env node`. Since Bun exposes a `node` compatibility shim in its `PATH`, these run correctly today. Updating shebangs to `#!/usr/bin/env bun` is optional and can be done incrementally.
93+
Script entrypoints in `scripts/` were updated to Bun shebangs so direct execution no longer relies on the Node compatibility shim.
9494

95-
#### 3. Scripts spawn `node` explicitly for subprocesses
95+
#### 3. Scripts spawn Bun explicitly for subprocesses
9696

97-
`scripts/run-electron-runtime-smoke.mjs` spawns `node scripts/runtime-harness-server.mjs` as a child process. Under a Bun CI environment `node` is still available (Bun installs its own `node` wrapper), so this works without changes.
97+
`scripts/run-electron-runtime-smoke.mjs` now spawns `bun scripts/runtime-harness-server.mjs` for child-process consistency.
9898

9999
#### 4. `dev:harness` and `sync:github-project` scripts
100100

101-
These use `node scripts/...` in the `package.json` `scripts` block. They work with `bun run` today (Bun delegates to the `node` wrapper). Optionally they can be updated to `bun scripts/...` for consistency.
101+
These now use `bun scripts/...` in the `package.json` `scripts` block.
102102

103103
#### 5. Electron optional dependency version duplication
104104

105-
`package.json` lists `electron` in both `devDependencies` (^41.0.0) and `optionalDependencies` (^37.2.0). Bun resolves the higher range (^41). npm behaves the same. This pre-existing duplication is unrelated to the migration.
105+
`package.json` lists `electron` in both `devDependencies` and `optionalDependencies` (both set to `latest`). This duplication remains intentional for current install behavior.
106106

107107
#### 6. `lockfileVersion: 1` in `bun.lock`
108108

@@ -142,7 +142,7 @@ Replace Node.js setup + npm with the official Bun GitHub Action.
142142
- name: Setup Bun
143143
uses: oven-sh/setup-bun@v2
144144
with:
145-
bun-version: "1.3.10"
145+
bun-version: "latest"
146146

147147
- name: Install dependencies
148148
run: bun install --frozen-lockfile
@@ -175,27 +175,25 @@ Prerequisites updated to list Bun 1.2+ as the supported package manager and show
175175

176176
| Task | Effort | Notes |
177177
|---|---|---|
178-
| Replace `node scripts/...` with `bun scripts/...` in `package.json` scripts | Trivial | Works with both today |
179-
| Update `#!/usr/bin/env node` shebangs to `#!/usr/bin/env bun` | Low | Speeds up script cold start slightly |
180178
| Remove `package-lock.json` once team fully migrated | Trivial | One `git rm` |
181-
| Pin a specific Bun version in CI instead of `latest` | Done | Already set to `1.3.10`; bump deliberately when upgrading |
179+
| Keep Bun on `latest` in CI | Done | Current policy tracks newest Bun releases |
182180

183181
---
184182

185183
## Risk Assessment
186184

187185
| Risk | Likelihood | Impact | Mitigation |
188186
|---|---|---|---|
189-
| Bun release breaks a CI step | Low | Medium | Pin Bun version in CI |
187+
| Bun release breaks a CI step | Low | Medium | Temporarily pin Bun to a known-good version in CI |
190188
| Postinstall sandbox blocks new dep | Low | Low | Add to `trustedDependencies` |
191-
| Electron spawn via `node` wrapper fails | Very Low | Medium | Use explicit `bun` binary path if needed |
189+
| Bun subprocess path mismatch | Very Low | Medium | Use absolute Bun binary path if needed |
192190
| Vitest incompatibility with future Bun version | Very Low | High | Vitest runs on the underlying Bun JavaScriptCore; keep Vitest version pinned |
193191

194192
---
195193

196194
## Conclusion
197195

198-
The CORTEX toolchain is already Bun-compatible with only the config changes included in this PR. No TypeScript source, no tests, no shaders, and no runtime code needed modification. The migration delivers:
196+
The CORTEX toolchain is Bun-first and uses Bun latest across CI and scripts. No TypeScript source, no tests, and no shaders needed modification; only tooling/config/script invocation surfaces were updated. The migration delivers:
199197

200198
- **~25 % faster** end-to-end cold CI runs
201199
- **~75–90 % faster** installs on cached runs (the step that previously dominated CI time)

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ This is the "dreaming" phase that prevents catastrophic forgetting and forces ab
6464
## Quick Start
6565

6666
```sh
67-
npm install
68-
npm run build # type-check
69-
npm run test:unit # unit tests
70-
npm run dev:harness # start the browser runtime harness at http://127.0.0.1:4173
67+
bun install
68+
bun run build # type-check
69+
bun run test:unit # unit tests
70+
bun run dev:harness # start the browser runtime harness at http://127.0.0.1:4173
7171
```
7272

7373
## Documentation

0 commit comments

Comments
 (0)