Skip to content

Conversation

@dspearson
Copy link

Problem

The package fails to run with Bun due to const reassignment violations. Bun properly enforces const semantics, causing runtime errors when const-declared variables are reassigned.

Error example:

803 |           swarmPrompt = enhanceSwarmPrompt(swarmPrompt, maxAgents);
                ^
error: This assignment will throw because "swarmPrompt" is a constant
    at /tmp/bunx-1000-claude-flow@alpha/node_modules/claude-flow/src/cli/simple-commands/swarm.js:803:11

381 |       const swarmPrompt = `You are orchestrating a Claude Flow Swarm using Claude Code's Tas
                  ^
note: The symbol "swarmPrompt" was declared a constant here:
   at /tmp/bunx-1000-claude-flow@alpha/node_modules/claude-flow/src/cli/simple-commands/swarm.js:381:13

Solution

Changed const to let for three variables that get reassigned later in the code:

  1. swarmPrompt (swarm.js:381) - reassigned when memory protocol enhancement is enabled via --claude flag
  2. isAvailable (coordination.js:58) - reassigned in error catch block during ruv-swarm fallback
  3. hiveMindPrompt (hive-mind.js:2009) - reassigned when memory protocol enhancement is enabled via --claude flag

Testing

✅ Verified with both package runners:

  • npx "dspearson/claude-flow#fix/bun-const-reassignment" --help ✅ Works
  • bunx "dspearson/claude-flow#fix/bun-const-reassignment" --help ✅ Works (previously failed)

Impact

  • Compatibility: Fixes runtime errors in Bun
  • Scope: Minimal - only changes variable declarations, no logic changes
  • Risk: Very low - let is functionally identical to const when variables are reassigned

Changed const declarations to let for variables that are reassigned
later in the code:
- swarmPrompt (swarm.js:381) - reassigned when memory protocol is enabled
- isAvailable (coordination.js:58) - reassigned in error fallback
- hiveMindPrompt (hive-mind.js:2009) - reassigned when memory protocol is enabled

These const reassignments cause runtime errors in Bun, which properly
enforces const semantics.

Fixes compatibility with Bun.
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