CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

Bun

$ bun 官方出品 中风险
Oven · 代码托管与研发协同 · MIT · macos / linux / windows

基于 Zig 与 JavaScriptCore 构建的单个原生二进制,可直接运行 TypeScript、通过 bun install 管理 npm 依赖、打包资源并执行 bun test 单元测试。极快的启动速度非常适合 Agent 测试与脚本循环。

FCRS-1.0 综合评分
87 /100
良好 (Good)
中置信度 (源码/文档)
零摩擦安装命令
brew install oven-sh/bun/bun
CLI vs MCP 选型建议 仅 CLI 可用

直接在本地文件系统执行 TypeScript 脚本、装包与单元测试,无需 MCP。

Agent 友好度体检单

— 原生 JSON 输出
— 字段裁剪
✓ 无头非交互
✓ 支持 Dry-Run
— 只读模式开关
✓ 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md

当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。

FCRS-1.0 六维评分拆解

Agent 友好度 20 / 25

执行迅捷且无交互,支持 bun install --dry-run、--frozen-lockfile 与 NO_COLOR=1,但 test 与 pm ls 原生 --json 支持有限。

  • bun install --dry-run and --frozen-lockfile supported
  • Lacks universal --json flag across pm and test
安全与权限边界 21 / 25

默认拦截未授权依赖的生命周期脚本(trustedDependencies 白名单),且 install 支持 --dry-run。

  • Lifecycle postinstall scripts blocked by default unless trusted
安装与运行摩擦 14 / 15

单个原生可执行文件覆盖 macOS、Linux 与 Windows,冷启动极快。

  • Standalone binary installable via Homebrew, npm, or curl
能力覆盖与边际价值 14 / 15

将 TypeScript 执行、包管理、打包与测试集于一身。

  • Sub-second test execution and direct .ts execution
维护与来源背书 9 / 10

由 Oven 团队以 MIT 协议高频维护的官方项目。

  • Active oven-sh/bun repository
文档与可验证性 9 / 10

bun.sh/docs 官方文档清晰覆盖 CLI 子命令与运行时 API。

  • Documented CLI reference at bun.sh/docs

安全边界、鉴权与放权指南

鉴权方式
无需鉴权 本地配置文件 环境变量密钥
凭证存储位置

拉取私有包时从 ~/.npmrc、bunfig.toml 或环境变量读取 npm 仓库凭证。

潜在副作用
只读查询 本地写入 远端写入
费用与配额提示

MIT 开源免费原生二进制。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# Bun (bun) Agent Rules
- Set `NO_COLOR=1` when capturing `bun test` or `bun install` output.
- Use `bun install --frozen-lockfile` or `bun install --dry-run` before mutating lockfiles.
- Remember `bun test` does not type-check; run `tsc --noEmit` separately for TypeScript validation.

Agent 高频安全命令配方

只读查询(安全推荐)

使用 dry-run 预演依赖安装
bun install --dry-run

解析依赖并报告计划变更,不修改 node_modules 或 bun.lock。

列出已安装的依赖
bun pm ls

打印工作区中已安装的直接依赖与版本号。

受控写入与预演

无色彩输出运行单元测试
NO_COLOR=1 bun test

关闭 ANSI 转义字符干净运行内置测试运行器。

核心优势

  • + 默认通过 trustedDependencies 机制阻止第三方包执行 postinstall 脚本。
  • + 近乎瞬时的启动速度与原生 TS 运行大幅加速 Agent 脚本验证。
  • + bun install --dry-run 与 --frozen-lockfile 让依赖变更更可控。

注意事项与踩坑点

  • ! bun test 与 bun pm ls 原生 --json 支持有限(测试可使用 --reporter=junit 输出结构化 XML)。
  • ! bun test 仅转译 TypeScript 而不执行 tsc 静态类型检查。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI