Skip to content

Conversation

@zerob13
Copy link
Collaborator

@zerob13 zerob13 commented Jun 16, 2025

Pull Request Description (中文)

你的功能请求是否与某个问题有关?请描述一下。
增加了bun和uv作为runtime,去掉了原有的node runtime
牺牲了一点点兼容性,但是获得了快速的安装体验,开箱即用的舒适度以及更可靠的环境
同时包还有了几十到一百兆左右的减少

请描述你希望的解决方案
使用了
https://www.npmjs.com/package/tiny-runtime-injector
来注入 runtime

Summary by CodeRabbit

  • New Features
    • Added support for Bun and UV runtimes alongside Node.js for enhanced runtime compatibility in code execution and server management.
  • Bug Fixes
    • Improved command and argument processing to ensure accurate handling and environment setup for Bun and UV runtimes.
  • Chores
    • Updated multiple dependencies to their latest versions.
    • Removed an unused development dependency.
  • Tests
    • Added comprehensive unit tests covering runtime command processing, environment variable handling, and path expansions.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 16, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The changes introduce support for Bun and UV runtimes alongside Node, updating scripts, runtime detection, and command handling logic. The PowerpackServer now uses Bun for code execution, and the MCP client and server manager are refactored to handle Bun and UV runtimes, including registry selection. New unit tests verify these behaviors.

Changes

File(s) Change Summary
package.json Updated install scripts for Bun/UV runtimes, updated several dependencies, removed tiny-runtime-injector.
src/main/presenter/mcpPresenter/powerpackServer.ts Refactored to use Bun runtime for code execution, renamed fields/methods, updated tool descriptions and logic.
src/main/presenter/mcpPresenter/mcpClient.ts Added Bun/UV runtime support, command/argument transformation logic, runtime path detection, and environment updates.
src/main/presenter/mcpPresenter/serverManager.ts Added UV registry logic, updated MCP client instantiation to include UV registry, added getter for UV registry.
test/main/presenter/mcpClient.test.ts New test suite for MCP client covering command processing, runtime detection, environment/path expansion.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ServerManager
    participant McpClient
    participant PowerpackServer

    User->>ServerManager: startServer()
    ServerManager->>McpClient: new McpClient(npmRegistry, uvRegistry)
    ServerManager->>PowerpackServer: (unrelated to runtime setup)

    McpClient->>McpClient: Detect bunRuntimePath, uvRuntimePath
    McpClient->>McpClient: Process command/args for runtime substitution
    McpClient->>McpClient: Update environment PATH with bun/uv paths

    Note over McpClient: When executing code/tool
    McpClient->>PowerpackServer: run_node_code (uses Bun runtime)
    PowerpackServer->>PowerpackServer: executeBunCode()
Loading

Possibly related PRs

Poem

In the warren, runtimes hop anew—
Bun and UV join the crew!
Scripts now bounce with fresher flair,
While tests ensure all paths are fair.
With every hop and every run,
Our code’s more nimble—oh, what fun!
🥕✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 51f2850 and bad8bf4.

📒 Files selected for processing (1)
  • src/main/presenter/mcpPresenter/mcpClient.ts (7 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (6)
package.json (1)

44-53: Consolidate and harden runtime-install/clean scripts

  1. Six near-duplicate installRuntime:* scripts inflate package.json and are easy to forget when flags change.
    • Consider a single Node script (or Nx/Makefile) that derives platform/arch at runtime and invokes tiny-runtime-injector once.

  2. cleanRuntime uses rm -rf → fails on Windows shells. Prefer the cross-platform rimraf package (pnpm dlx rimraf runtime).

  3. tiny-runtime-injector was removed from devDependencies yet you still rely on it via npx. That works only with internet access; vendoring it (or using pnpm dlx) keeps CI/offline installs deterministic.

src/main/presenter/mcpPresenter/serverManager.ts (1)

85-90: uvRegistry may desynchronise from the registry actually used

uvRegistry is pinned based on the fastest registry before you honour serverConfig.customNpmRegistry.
If a server specifies a custom npm registry different from npmmirror, you will still pass the mirror-specific uvRegistry, which could be incorrect.

Either recompute uvRegistry inside startServer after resolving the effective npm registry, or let McpClient derive it from the registry string.

test/main/presenter/mcpClient.test.ts (2)

94-98: Make path checks platform-neutral

pathStr.includes('runtime/bun') / 'runtime/uv' will fail on Windows because path.join produces back-slashes (runtime\\bun).
Use path.normalize or a regex insensitive to separators to keep the test green on all OSes.

- return pathStr.includes('runtime/bun') || pathStr.includes('runtime/uv')
+ return /runtime[\\/](bun|uv)/.test(pathStr)

330-337: Prefer setting env vars to undefined over delete in tests

delete process.env.TEST_VAR works but triggers Biome’s no-delete rule and is marginally slower. Simpler:

- delete process.env.TEST_VAR
+ process.env.TEST_VAR = undefined

Same applies to TEST_PATH below.

src/main/presenter/mcpPresenter/inMemoryServers/powerpackServer.ts (2)

28-33: Update schema description to reference Bun instead of Node.js

RunNodeCodeArgsSchema still describes “Node.js code”.
Replace wording with “JavaScript/TypeScript code (executed by Bun)” to avoid misleading clients.


240-249: Tool name mismatch after switching to Bun

The tool is still exposed as run_node_code but now executes via Bun.
For backward compatibility keep the alias, but expose a new canonical name (e.g. run_js_code) and document that run_node_code is deprecated.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 90fc08d and 51f2850.

📒 Files selected for processing (5)
  • package.json (3 hunks)
  • src/main/presenter/mcpPresenter/inMemoryServers/powerpackServer.ts (7 hunks)
  • src/main/presenter/mcpPresenter/mcpClient.ts (7 hunks)
  • src/main/presenter/mcpPresenter/serverManager.ts (4 hunks)
  • test/main/presenter/mcpClient.test.ts (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
test/main/presenter/mcpClient.test.ts

[error] 376-376: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 390-390: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-check (x64)
🔇 Additional comments (1)
src/main/presenter/mcpPresenter/mcpClient.ts (1)

105-118: ```shell
#!/bin/bash

Show the first 200 lines of mcpClient.ts for context

sed -n '1,200p' src/main/presenter/mcpPresenter/mcpClient.ts

Show lines 200–350 to include the runtime selection logic and command execution

sed -n '200,350p' src/main/presenter/mcpPresenter/mcpClient.ts


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@zerob13 zerob13 merged commit fcf35cf into dev Jun 16, 2025
1 of 2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Aug 11, 2025
@zerob13 zerob13 deleted the refactor/inject-bun-and-uv-runtime branch September 21, 2025 14:48
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.

2 participants