mcpField
P
proto

proto

github.com/hyperb1iss开发751 次安装40 周前更新
代码仓库

关于 proto

proto 是面向开发者的命令行版本管理器,可在不同项目中统一语言和工具版本。它通过插件扩展对 Node.js、Python、Rust、Go 等工具的内置支持。

主要功能

  1. 01管理多个项目的工具版本
  2. 02在 .prototools 中固定版本
  3. 03安装并运行项目工具
  4. 04通过插件扩展工具支持
  5. 05从源代码构建指定工具

适用场景

  1. 01统一团队使用的工具版本
  2. 02无需全局安装即可运行项目工具
  3. 03启动包含多种工具的命令环境
  4. 04添加第三方工具插件

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/hyperb1iss/moonrepo-skill --skill proto

安装后在 Claude Code 中输入/proto确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

examples/
prototools-full.toml
references/
commands.md
config.md

详细介绍

proto - 可插拔的多语言版本管理器

proto 是一款面向多种编程语言的新一代版本管理器。它提供统一的界面,可通过插件管理 Node.js、npm、pnpm、yarn、Bun、Deno、Rust、Go、Python 及 800 多种工具。

何时使用 proto

  • 在不同项目中管理语言/工具版本
  • 在 .prototools 中固定版本,确保团队使用一致
  • 安装并运行工具,避免污染全局环境
  • 用一个工具替代 nvm、pyenv、rustup 和 gvm

安装

# Linux, macOS, WSL
bash <(curl -fsSL https://moonrepo.dev/install/proto.sh)

# Specific version, non-interactive
bash <(curl -fsSL https://moonrepo.dev/install/proto.sh) 1.2.3 --yes
Shell 设置
# Add to shell profile
eval "$(proto activate bash)"   # Bash
eval "$(proto activate zsh)"    # Zsh

快速参考

核心命令
proto install <tool>           # Install tool
proto install node 20.10.0     # Install specific version
proto install node --build     # Build from source (v0.45+)
proto run <tool>               # Run with detected version
proto exec node pnpm -- cmd    # Bootstrap multi-tool env (v0.53+)
proto pin <tool> <version>     # Pin version locally
proto pin <tool> --global      # Pin globally
proto versions <tool>          # List available versions
proto outdated                 # Check for updates
proto clean                    # Remove unused tools
proto upgrade                  # Upgrade proto itself
proto diagnose                 # Identify installation issues
proto debug config             # List all .prototools files
proto debug env                # Show environment info

配置:.prototools

# .prototools
node = "20.10.0"
npm = "10.2.0"
pnpm = "8.12.0"
yarn = "4.0.0"
bun = "1.0.0"
deno = "1.40.0"
rust = "1.75.0"
go = "1.21.0"
python = "3.12.0"

[plugins]
my-tool = "https://example.com/plugin.wasm"

[settings]
auto-install = true
auto-clean = true
detect-strategy = "prefer-prototools"

[env]
NODE_ENV = "development"
版本指定格式
格式示例说明
精确"20.10.0"精确版本
主版本"20"最新的 20.x.x
波浪号"~20.10"仅更新补丁版本
别名"stable"特定语言的别名

支持的工具(内置)

JavaScript/TypeScript
proto install node     # Node.js runtime
proto install npm      # npm package manager
proto install pnpm     # pnpm package manager
proto install yarn     # Yarn package manager
proto install bun      # Bun runtime
proto install deno     # Deno runtime
系统语言
proto install rust     # Rust (includes cargo)
proto install go       # Go
其他
proto install python   # Python (includes pip)

版本检测顺序

  1. CLI 参数:proto run node 18.0.0
  2. 环境变量:PROTO_NODE_VERSION=18.0.0
  3. 本地 .prototools(当前目录及父目录)
  4. 生态系统文件:.nvmrc、.node-version、package.json 中的 engines
  5. 全局 .prototools:~/.proto/.prototools

常见工作流

为团队固定版本
# Pin to local .prototools
proto pin node 20.10.0
proto pin pnpm 8.12.0

# Pin globally (user default)
proto pin node 20 --global
安装所有工具
# Install everything from .prototools
proto install
检查更新
proto outdated                    # Check for updates
proto outdated --update --latest  # Update .prototools
使用指定版本运行
proto run node 18 -- script.js    # Override version
PROTO_NODE_VERSION=18 proto run node  # Via env var
Proto Exec(v0.53+)

使用多个工具引导环境:

# Run command with multiple tools
proto exec node@24 pnpm@10 [email protected] -- pnpm run app:start

# Load tools from config
proto exec --tools-from-config -- npm test

# Interactive shell with activated tools
proto exec node pnpm -- bash
从源代码构建(v0.45+)

从源代码编译工具(适用于没有预构建二进制文件的情况):

proto install ruby --build
proto install node --build
proto install python --build

支持:Deno、Go、Moon、Node、Python、Ruby。

# .prototools
[settings.build]
install-system-packages = true
write-log-file = true

插件

添加第三方插件
proto plugin add atlas "https://raw.githubusercontent.com/.../plugin.toml"
proto install atlas
列出插件
proto plugin list           # Show all plugins
proto plugin list --versions  # With version info
插件来源
[plugins]
# Remote TOML plugin
atlas = "https://example.com/atlas/plugin.toml"

# Remote WASM plugin
custom = "https://example.com/plugin.wasm"

# GitHub releases (recommended for distribution)
my-tool = "github://org/repo"

# Local development (WASM)
local = "file://./target/wasm32-wasip1/release/plugin.wasm"
WASM 插件开发

使用 proto_pdk crate 构建面向 wasm32-wasip1 的插件:

# Build plugin
cargo build --target wasm32-wasip1 --release

# Test locally
proto install my-tool --log trace

本地开发的测试配置:

# .prototools
[settings]
unstable-lockfile = true  # Create .protolock for consistency

[plugins.tools]
my-tool = "file://./target/wasm32-wasip1/release/my_tool.wasm"

必需的 WASM 函数:

  • register_tool - 元数据(名称、类型)
  • download_prebuilt - 配置下载/安装
  • locate_executables - 定义可执行文件路径
  • load_versions - 获取可用版本

可选:native_install、detect_version_files、parse_version_file

设置

[settings]
# Auto-install missing tools
auto-install = true

# Auto-clean unused tools
auto-clean = true

# Version detection strategy
# first-available, prefer-prototools, only-prototools
detect-strategy = "prefer-prototools"

# Pin "latest" alias to local or global config
pin-latest = "local"

# Create .protolock for reproducible installs
unstable-lockfile = true

# Disable telemetry
telemetry = false

[settings.http]
# Configure proxies
proxies = ["https://internal.proxy"]
root-cert = "/path/to/cert.pem"

[settings.offline]
timeout = 500  # ms

环境变量

变量说明
PROTO_HOME安装目录(默认:~/.proto)
PROTO_LOG日志级别(trace、debug、info、warn、error)
PROTO_*_VERSION覆盖工具的版本
PROTO_ENV用于查找配置的环境
PROTO_BYPASS_VERSION_CHECK跳过版本验证
开发/测试变量
变量说明
PROTO_TEST启用测试模式(加载测试插件)
PROTO_DEBUG_COMMAND显示详细的命令执行过程
PROTO_DEBUG_WASM启用 WASM 插件调试
WASMTIME_BACKTRACE_DETAILS显示详细的 WASM 回溯信息

与 moon 集成

proto 是 moon 的工具链后端。在 .moon/toolchains.yml(v2)中配置:

# .moon/toolchains.yml
javascript:
  packageManager: "pnpm"

node:
  version: "20.10.0"

也可以通过 proto 固定 moon 自身的版本:

# .prototools
moon = "1.31.0"

CI/CD 集成

# GitHub Actions
- uses: moonrepo/setup-toolchain@v0
  with:
    auto-install: true

其他资源

详细配置请参阅:

  • references/config.md - 完整的 .prototools 参考
  • references/plugins.md - 插件开发指南
  • references/commands.md - 完整的 CLI 参考
Examples
  • examples/prototools-full.toml - Complete configuration
  • examples/plugin.toml - TOML plugin example

评论

支持 Markdown