3D engine that AI agents drive
Run the packaged MCP server under bun on every pull request
Nguyen Xuan Anc56af8eabb95
diff --git a/.github/workflows/test.yml b/.github/workflows/test.ymlindex 38460306..65f2e5eb 100644--- a/.github/workflows/test.yml+++ b/.github/workflows/test.yml@@ -104,9 +104,24 @@ jobs:- run: npm run smoke:package- run: npm run smoke:mcp-package+ # Users may start the MCP server with bunx, so the packed server also runs the package smoke under bun.+ bun:+ runs-on: ubuntu-latest+ timeout-minutes: 15+ steps:+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ - uses: ./.github/actions/setup+ - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0+ with:+ bun-version: 1.4.4+ - run: npm run prepare:release+ - run: npm run smoke:mcp-package+ env:+ MCP_SERVER_RUNTIME: bun+test:if: always()- needs: [audit, size, unit, coverage, package]+ needs: [audit, size, unit, coverage, package, bun]runs-on: ubuntu-lateststeps:# A skipped size job is expected outside pull requests. Anything else that is not a success fails the check.diff --git a/README.md b/README.mdindex 136cd5b1..d2e9a080 100644--- a/README.md+++ b/README.md@@ -106,6 +106,7 @@ npx 67js-mcp --backend gpu --memory 192```Use `--backend cpu` on a machine without a GPU.+With bun, `bunx 67js-mcp` takes the same flags; CI runs the packaged server under bun on every pull request.An agent authors a [JSON recipe](docs/agent-scene.md), sets [lights and fog](docs/agent-look.md), imports [GLB assets](docs/agent-asset.md) and adds [motion](docs/agent-motion.md).It gets PNG previews back, compares up to four views in a [review grid](docs/agent-review.md) and runs [render jobs](docs/agent-render-jobs.md) for stills and MP4 video.The server accepts no arbitrary code and no remote asset URLs. The [MCP reference](docs/mcp.md) lists its tools.diff --git a/docs/ci.md b/docs/ci.mdindex b22dc31d..3867470c 100644--- a/docs/ci.md+++ b/docs/ci.md@@ -13,6 +13,7 @@ All jobs start at once.| `unit` (8 shards balanced by measured time, `scripts/shard-test-files.mjs` and `test-timings.json`) | `npm run build:lib`, then `npm run test:coverage` on one eighth of the test files; uploads its lcov and per-file timings || `coverage` | merges the shard lcov files, writes the summary, compares with `coverage-baseline.json`, uploads `lcov` || `package` | `prepare:release`, `check:links:package`, `smoke:package`, `smoke:mcp-package` |+| `bun` | `smoke:mcp-package` with `MCP_SERVER_RUNTIME=bun`: the packed MCP server runs under bun, the way `bunx 67js-mcp` starts it || `test` | waits for every job above and fails unless each one succeeded. Branch protection on `main` requires this name. |`node --test` runs each file in its own process (the Node 24 default, `--test-isolation=process`), so the unit pass is also the isolation check. `npm run test:isolated` stays as a local tool: it runs the same files four at a time and reruns a failure alone.diff --git a/scripts/smoke-mcp-package.mjs b/scripts/smoke-mcp-package.mjsindex 7f1db034..32e036b3 100644--- a/scripts/smoke-mcp-package.mjs+++ b/scripts/smoke-mcp-package.mjs@@ -66,13 +66,16 @@ for (const chunk of manifest.previewChunks) {assert.equal(createHash('sha256').update(bytes).digest('hex'), chunk.sha256);}const cli = join(installedRoot, 'bin', '67js-mcp.mjs');-const version = spawnSync(process.execPath, [cli, '--version'], { cwd: consumer, encoding: 'utf8', windowsHide: true });+// MCP_SERVER_RUNTIME runs the installed server under another runtime, such as bun, while this script stays on Node.+const serverRuntime = process.env.MCP_SERVER_RUNTIME || process.execPath;+const runtimeLabel = process.env.MCP_SERVER_RUNTIME ? `-${process.env.MCP_SERVER_RUNTIME.replace(/^.*[\/]/, '').replace(/.exe$/, '')}` : '';+const version = spawnSync(serverRuntime, [cli, '--version'], { cwd: consumer, encoding: 'utf8', windowsHide: true });assert.equal(version.status, 0, version.stderr);assert.equal(version.stdout.trim(), metadata.version);-const help = spawnSync(process.execPath, [cli, '--help'], { cwd: consumer, encoding: 'utf8', windowsHide: true });+const help = spawnSync(serverRuntime, [cli, '--help'], { cwd: consumer, encoding: 'utf8', windowsHide: true });assert.equal(help.status, 0, help.stderr);assert.match(help.stdout, /--assets/);-const invalid = spawnSync(process.execPath, [cli, '--memory', '0'], { cwd: consumer, encoding: 'utf8', windowsHide: true });+const invalid = spawnSync(serverRuntime, [cli, '--memory', '0'], { cwd: consumer, encoding: 'utf8', windowsHide: true });assert.equal(invalid.status, 1);assert.equal(invalid.stdout, '');assert.match(invalid.stderr, /32 to 384/);@@ -90,7 +93,7 @@ await mkdir(assets);await writeFile(join(assets, 'textured-rig.glb'), await createTexturedRigFixture());const results = [];for (const era of ['modern', 'legacy']) {- const transport = new PatientStdioClientTransport({ command: process.execPath,+ const transport = new PatientStdioClientTransport({ command: serverRuntime,args: [cli, '--backend', 'cpu', '--memory', '96', '--assets', assets], cwd: consumer, stderr: 'pipe' });let diagnostics = '';transport.stderr.on('data', chunk => { diagnostics += chunk.toString(); });@@ -153,7 +156,7 @@ for (const era of ['modern', 'legacy']) {const exported = (await call('scene_export_recipe', { sessionId: rig.sessionId })).structuredContent;assert.equal(exported.recipe.animation.time, 1.1);await mkdir('artifacts', { recursive: true });- await writeFile(`artifacts/mcp-package-${era}.png`, bent);+ await writeFile(`artifacts/mcp-package-${era}${runtimeLabel}.png`, bent);results.push({ era, tools: 18, connectMs, importedTexture: true, importedSkin: true, undoPngExact: true, reverseSeekPngExact: true });// Keep the final rig active to prove EOF closes its renderer and owned browser.}@@ -165,9 +168,9 @@ for (const era of ['modern', 'legacy']) {assert.throws(() => process.kill(processId, 0), /ESRCH/);}const report = { packageName: metadata.name, version: metadata.version, archiveBytes: packed.size, cli,- published, protocolOnly,+ published, protocolOnly, serverRuntime,runtimeDevelopmentDependencies: false, nativeShimVersion: true, builtOutputHashesMatch: true,sourceCommit: manifest.sourceCommit, eofWithActiveScene: !protocolOnly, results };await mkdir('artifacts', { recursive: true });-await writeFile(`artifacts/mcp-package-${published ? 'published' : protocolOnly ? 'protocol' : 'cpu'}.json`, JSON.stringify(report, null, 2));+await writeFile(`artifacts/mcp-package-${published ? 'published' : protocolOnly ? 'protocol' : 'cpu'}${runtimeLabel}.json`, JSON.stringify(report, null, 2));console.log(JSON.stringify(report));