-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
Problem
The CLI requires Bun to run (#!/usr/bin/env bun) but this isn't obvious until you try to use it. Users who install via npm install -g hit env: bun: No such file or directory with no guidance.
Current Bun Dependencies
Heavy usage throughout the codebase:
| Bun API | Usage | Node Equivalent |
|---|---|---|
Bun.$\cmd`` |
Shell commands (tagged template) | execa or child_process.exec |
Bun.spawn() |
Process spawning | child_process.spawn |
Bun.file().exists() |
File existence check | fs.existsSync |
Bun.file().text() |
Read file | fs.readFileSync |
Bun.write() |
Write file | fs.writeFileSync |
Bun.argv |
CLI arguments | process.argv |
Bun.sleep() |
Async delay | setTimeout promisified |
Files with Bun APIs:
bin/swarm.ts- CLI entrypointsrc/swarm-worktree.ts- HeavyBun.$usage for gitsrc/swarm-verify.ts-Bun.file,Bun.$src/swarm-decompose.ts-Bun.$src/tool-availability.ts-Bun.$,Bun.spawnsrc/agent-mail.ts-Bun.spawn,Bun.filesrc/hive.ts-Bun.spawnsrc/storage.ts-Bun.spawnsrc/skills.ts-Bun.spawn
Proposed Solution
Option A: Runtime Abstraction Layer (Recommended)
Create src/runtime.ts that exports platform-agnostic helpers:
// src/runtime.ts
export const runtime = {
spawn: async (cmd: string[], opts?: SpawnOpts) => { ... },
shell: async (cmd: string) => { ... },
fileExists: async (path: string) => { ... },
readFile: async (path: string) => { ... },
writeFile: async (path: string, content: string) => { ... },
sleep: async (ms: number) => { ... },
argv: process.argv,
};Detect runtime at startup, use Bun APIs when available, fall back to Node equivalents.
Option B: Compile to JS
Use bun build to compile to standalone JS. Problem: Bun.$ shell syntax won't survive compilation.
Option C: Require tsx
Change shebang to #!/usr/bin/env tsx and replace Bun APIs with Node equivalents. Requires tsx as a dependency.
Acceptance Criteria
-
npm install -g opencode-swarm-plugin && swarm setupworks without Bun - All existing functionality preserved
- Tests pass on both Bun and Node
- CI tests both runtimes
- README updated with Node as primary, Bun as optional
Complexity
Estimate: Medium-High (2-3 days)
Most work is mechanical replacement, but needs careful testing of shell command edge cases.
References
- Doesn't work without bunΒ #116 - Original report
- Bun Shell docs
- execa - Node shell alternative
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels