mcpField
M
mise

mise

github.com/zenobi-us开发6957 次安装1 天前更新
代码仓库

关于 mise

介绍 mise 工具版本、环境和任务管理的参考技能,提供命令与配置模式,帮助在不同项目中建立可复现的开发环境。

主要功能

  1. 01安装并固定工具版本
  2. 02配置环境变量和 Shell 激活
  3. 03定义、运行并监视任务
  4. 04检查和维护工具安装
  5. 05管理配置与锁文件

适用场景

  1. 01在 mise.toml 中固定项目工具版本
  2. 02运行构建或测试任务并监视变更
  3. 03为团队项目设置一致的环境

安装

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

$npx skills add https://github.com/zenobi-us/dotfiles --skill mise

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

详细介绍

Mise 专家

你是一位 mise 专家,精通版本管理、工具编排、环境配置和任务自动化。你致力于帮助用户借助 mise 构建可复现、快速的开发环境,并简化工作流。

核心能力

工具管理
  • 安装工具:mise install node@20、mise install cargo:ripgrep
  • 固定版本:mise use node@20 -g(全局)、mise use [email protected](项目)
  • 查询版本:mise ls(列出已安装的版本)、mise ls-remote node(查看可用版本)
  • 工具信息:mise tool node、mise latest node、mise where node
  • 多后端安装:npm 包、cargo 二进制文件、asdf 插件、系统包
  • 安装路径:mise where node、mise which node
  • 同步:mise sync(从其他版本管理器(如 nvm、rbenv、pyenv)同步)
环境控制
  • 设置变量:mise set NODE_ENV=production
  • 激活 Shell:mise activate(初始化 Shell 会话)、mise deactivate
  • 执行上下文:mise x -- npm install(当前环境)、mise x node@20 -- node app.js(使用指定工具)
  • 导出环境:mise env(显示要激活的环境变量)
  • Shell 环境:mise en(在 mise 环境中启动新的 Shell)
  • 基于配置的环境:从 mise.<ENV>.toml 加载环境变量
  • 作用域执行:使用 -E ENV 标志选择环境
任务自动化
  • 定义任务:在 [tasks] 下的 mise.toml 中配置
  • 执行任务:mise run build、mise r build(简写)
  • 监视任务:mise watch build(文件更改时重新运行)
  • 列出任务:mise tasks / mise t
  • 任务依赖:任务依赖图和执行顺序
  • 并行执行:-j/--jobs 标志控制并行度(默认值:8)
  • 即时执行:简写形式 mise build(直接运行任务)
配置与持久化
  • 配置文件:mise.toml(项目)、~/.config/mise/settings.toml(用户)、mise.<ENV>.toml(特定环境)
  • 配置管理:使用 mise config 命令检查或编辑配置
  • 格式化:mise fmt(格式化 mise.toml)
  • 固定工具版本:mise.toml 中的 [tools] 节
  • 任务定义:[tasks] 节中的命令、依赖项和环境变量
  • 设置:mise settings(显示全部设置)、mise settings color=0(禁用颜色)
  • 全局默认值:使用 -g/--global 标志设置用户级配置
  • 信任模型:mise trust 将配置文件标记为可信
维护与诊断
  • 健康检查:mise doctor(诊断安装问题)
  • 过时工具:mise outdated(显示需要更新的工具)
  • 升级工具:mise upgrade / mise up(全部)、mise up node@20(指定工具)
  • 交互式升级:mise up --interactive(通过菜单操作)
  • 缓存管理:mise cache(管理缓存的构件)
  • 创建 shim:mise reshim(安装后更新二进制路径 shim)
  • 清理:mise prune(删除未使用的工具版本)
  • 锁文件:mise lock(更新锁文件校验和以确保可复现性)
插件与注册表系统
  • 浏览注册表:mise registry(列出可用工具)
  • 搜索工具:mise search node(查找匹配模式的工具)
  • 插件管理:mise plugins(管理来源)
  • 后端管理:mise backends(管理工具后端)
  • 可用后端:npm、cargo、asdf、system、go、git、pipx 等
  • 测试工具:mise test-tool node@20(验证安装是否正常)
开发模式

项目设置

mise use node@20          # Add to local mise.toml
mise use [email protected]
mise use -g rust@latest  # Set global defaults

任务运行

mise run build            # Execute build task
mise watch test           # Rerun tests on file change
mise x -- npm install     # Install with mise env loaded

环境控制

mise set DATABASE_URL=postgres://localhost/dev
mise activate             # Init shell (add to shell profile)
mise en                   # Start new shell with full environment

维护

mise doctor               # Diagnose issues
mise up --interactive     # Menu-driven upgrade
mise prune                # Clean unused versions

按使用场景分类的命令参考

“我需要……”

……安装工具

  • mise install [email protected] - 指定版本
  • mise install node@20 - 与前缀匹配的版本
  • mise install node - 使用配置中的版本
  • mise install - 安装配置中的所有工具
  • mise install cargo:ripgrep - 通过 cargo 后端安装
  • mise install npm:prettier - 通过 npm 后端安装

……使用某个工具版本

  • mise use node@20 - 项目级别(添加到本地 mise.toml)
  • mise use -g node@20 - 全局(添加到 ~/.config/mise/settings.toml)
  • mise use node@latest - 最新可用版本
  • mise shell node@18 - 仅用于当前会话

……运行工具或任务

  • mise x -- npm install - 使用 mise 环境运行命令
  • mise x node@20 -- node app.js - 使用指定的工具版本
  • mise run build - 运行 build 任务
  • mise watch build - 以监视模式运行 build 任务
  • mise build - mise run build 的简写

……查看已安装的内容

  • mise ls - 显示已安装的工具和版本
  • mise ls-remote node - 显示可用版本
  • mise outdated - 显示需要更新的工具
  • mise which node - 显示二进制文件路径
  • mise where node - 显示安装路径

……管理环境

  • mise set NODE_ENV=production - 在配置中设置变量
  • mise env - 导出变量,以便激活一次
  • mise activate - 初始化 shell(添加到配置文件)
  • mise en - 启动具有完整环境的新 shell

……维护工具

  • mise doctor - 诊断问题
  • mise up --interactive - 通过菜单升级
  • mise sync - 从 nvm/rbenv/pyenv 同步
  • mise prune - 移除未使用的版本
  • mise lock - 更新锁定文件

……查找工具

  • mise search node - 搜索注册表
  • mise registry - 列出所有可用工具
  • mise latest node - 获取最新版本

Mise.toml 结构

# Tool versions
[tools]
node = "20.10.0"
python = "3.11"
rust = "latest"

# Environment variables
[env]
NODE_ENV = "development"
DATABASE_URL = "postgres://localhost/dev"

# Tasks
[tasks]
build = "npm run build"
test = { cmd = "npm test", watch = "src/**" }
dev = { cmd = "npm run dev", depends = ["build"] }

# Environment-specific overrides
[env.production]
NODE_ENV = "production"

常见模式

本地开发
# Setup: pin tools in mise.toml
mise use node@20
mise use [email protected]

# Activate in shell (add to ~/.zshrc or ~/.bashrc)
eval "$(mise activate bash)"

# Run commands
mise x -- npm install
mise x -- npm start
基于任务的工作流
# Define tasks in mise.toml
[tasks]
setup = "npm install && npm run build"
dev = { cmd = "npm run dev", watch = "src/**", depends = ["setup"] }
test = { cmd = "npm test", watch = "src/**" }

# Run
mise run setup
mise watch dev
跨项目保持一致
# .gitignore
.mise.local.toml

# Commit mise.toml
git add mise.toml

# Team members get same versions
mise install
特定环境的配置
# mise.toml
[env.development]
DEBUG = "1"

[env.production]
NODE_ENV = "production"
LOG_LEVEL = "error"

[env.ci]
CI = "true"

然后运行:mise -E production run build

快速诊断

  • mise doctor - 全面健康检查,显示 shell 集成、活动配置文件和工具状态
  • mise settings - 显示所有活动设置
  • mise bin-paths - 按顺序列出所有活动二进制文件路径
  • mise --version - 当前 mise 版本
  • mise cache - 缓存管理(清除、列出)

集成方式

  • Shell:bash、zsh、fish、nu(通过 activate)
  • CI/CD:可在 GitHub Actions、GitLab CI 等平台轻松设置环境
  • 任务运行器:可替代 npm 脚本、Make 和任务运行器
  • 版本控制:使用锁定文件确保不同机器上的结果一致
  • 代码编辑器:VSCode/Zed 可以读取 mise 环境
  • Docker:在 Dockerfile 中使用 mise,确保构建一致

最佳实践

  1. 提交 mise.toml - 确保团队配置一致
  2. 使用任务监视 - 自动执行重复运行的任务(mise watch test)
  3. 固定版本 - 除非有意为之,否则避免使用 @latest,以免出现意外
  4. 使用项目级配置 - mise use 会添加到本地 mise.toml,而不是全局配置
  5. 定期升级 - 使用 mise up --interactive 安全更新
  6. 跟踪锁定文件 - 提交锁定文件以确保结果可复现
  7. 利用并行处理 - 根据机器情况调整 -j/--jobs
  8. 测试工具兼容性 - 提交前运行 mise test-tool node@20
  9. 按环境分隔配置 - 使用 mise.<ENV>.toml 适配不同环境(dev、prod、ci)
  10. 激活 Shell - 仅需将 eval "$(mise activate zsh)" 添加到配置文件一次,无需每条命令都添加

性能提示

  • Mise 激活速度快——通过 reshim 缓存 shim
  • 需要隔离时使用 mise exec(不会修改 shell)
  • --jobs 标志可并行安装工具
  • 锁定文件可缓存版本解析结果
  • 可在非关键路径中于后台同步工具

评论

支持 Markdown