fastmod
$ fastmod 社区开源 中风险fastmod 是 Meta 开发的 Rust 工具,用于替代旧版 Python codemod,支持遵循 .gitignore 的高速多文件正则替换。无头 Agent 必须传入 --accept-all(-a)以避免交互式 TTY 阻塞,但该参数会直接原地写入且不提供 --dry-run。
brew install fastmod 本地多文件正则替换工具;若 Agent 需要内置试运行预览,建议优先使用 sd -p 或 ast-grep。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
默认交互式确认会阻塞无头终端,必须传入 --accept-all;同时缺少 --dry-run 与 --json 输出。
- Interactive confirmation is the default mode
- No
--dry-runor--jsonflags
--accept-all 会立即原地覆盖匹配文件且无预览/试运行模式,误改后只能依赖 Git 回滚。
- Non-interactive
--accept-allmutates files directly with no dry-run flag
静态 Rust 二进制,可通过 brew install fastmod、cargo install fastmod 与 GitHub Releases 安装。
- Cross-platform Rust binary
遵循 .gitignore 的高速多文件正则替换,但就 Agent 安全性而言不如 sd -p 或 ast-grep。
- Parallel Rust traversal respecting
.gitignoreand--extensions
Meta facebookincubator 旗下 Apache-2.0 开源项目,代码趋于稳定、更新较少。
- Stable
facebookincubator/fastmodrepository
README 与 --help 简明介绍了 Rust 正则语法(${1} 捕获组)及常用参数。
- README examples and
--helpoutput
安全边界、鉴权与放权指南
无需凭据;直接在本地工作区文件上执行。
100% 免费、离线、开源(Apache-2.0)。
# fastmod Agent Rules - NEVER run `fastmod` without `--accept-all` (`-a`) in headless shells (default interactive mode hangs). - Because `fastmod` has NO `--dry-run` flag, verify matches with `rg` first and only run on a clean Git working tree.
Agent 高频安全命令配方
只读查询(安全推荐)
rg -n "oldFunction\(" src/ 由于 fastmod 没有 --dry-run 参数,调用 fastmod --accept-all 前应先用 rg 检查精确匹配。
受控写入与预演
fastmod --accept-all --extensions ts,tsx -d src/ 'oldApi\((.*)\)' 'newApi(${1})' 无需交互确认直接替换 src/ 中的匹配内容;执行前请确保 git status 干净以便用 git diff 核查。
核心优势
- + 遵循
.gitignore、-g通配与--extensions的高速并行 Rust 执行引擎。 - + 基于 Rust
regex的${1}捕获组语法简洁明确。
注意事项与踩坑点
- ! 默认按片段交互确认,无头运行时必须传入
--accept-all。 - ! 不支持
--dry-run与--json:--accept-all会直接把修改写入磁盘。