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

ty

$ ty 官方出品 低风险
Astral · 代码托管与研发协同 · MIT · macos / linux / windows

Astral 推出的 Rust 驱动 Python 类型检查器与 LSP,面向亚秒级工作区诊断而设计。ty check 支持精简输出格式、--no-progress 与规范退出码,极大加速 Agent 的改后验证闭环。

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

本地亚秒级完成增量 Rust 类型检查,直接调用 CLI 远胜 MCP 封装。

Agent 友好度体检单

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

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

FCRS-1.0 六维评分拆解

Agent 友好度 22 / 25

支持 ty check --output-format concise(以及 full、gitlab、github)、--no-progress、--color never 与 --exit-zero。

  • --output-format concise and --no-progress produce compact agent-ready lines
安全与权限边界 24 / 25

纯只读静态类型检查器,绝不执行被检 Python 模块。

  • Strictly read-only static analysis
安装与运行摩擦 14 / 15

预编译 Rust 二进制,可通过 Homebrew、PyPI、uvx 与 Astral 安装器跨平台部署。

  • Cross-platform native binary via uvx ty or brew install ty
能力覆盖与边际价值 13 / 15

在 Agent 反馈速度上大幅领先 mypy 与 pyright,但部分复杂类型规则仍在完善中。

  • Sub-second Rust type checking on medium-to-large Python repos
维护与来源背书 8 / 10

Astral 官方项目(astral-sh/ty,uv 与 ruff 同一团队)以 MIT 协议开发,目前处于快速演进阶段。

  • Maintained by Astral (astral-sh/ty)
文档与可验证性 8 / 10

docs.astral.sh/ty/ 官方文档与 --help 说明清晰规范。

  • Official docs at docs.astral.sh/ty/

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

鉴权方式
无需鉴权
凭证存储位置

离线本地 Python 类型检查器,不存储也不需要任何凭证。

潜在副作用
只读查询
费用与配额提示

MIT 开源 Rust CLI,完全免费。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# ty Agent Rules
- Pass `--output-format concise --no-progress --color never` for clean single-line diagnostics.
- Because `ty` is still maturing, cross-check edge-case typing failures against `pyright` or `mypy` if a repo pins them.

Agent 高频安全命令配方

只读查询(安全推荐)

以精简输出类型检查 Python 工作区
ty check --output-format concise --no-progress --color never .

输出紧凑的单行错误诊断,关闭进度条与 ANSI 颜色转义。

检查指定 Python 模块
ty check src/module.py

针对刚修改的文件快速执行定向类型检查。

核心优势

  • + 亚秒级 Rust 类型检查使 Agent 的编辑-验证循环几乎零等待。
  • + 原生提供 --output-format concise --no-progress --color never 避免终端渲染噪音。

注意事项与踩坑点

  • ! 相比 mypy 与 pyright 更年轻,边界类型兼容与框架插件(如 Django/Pydantic)仍在演进。
  • ! 相较 pyright --outputjson,目前缺少通用 --output-format json 选项。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI