macOS
brew install ast-greplocal Homebrew formula metadata
sudo port install ast-grepMacPorts ports tree · devel/ast-grep/Portfile · 来源: api.github.com
安装
brew install ast-greplocal Homebrew formula metadata
sudo port install ast-grepMacPorts ports tree · devel/ast-grep/Portfile · 来源: api.github.com
sudo apk add ast-grepAlpine Linux edge package indexes · ast-grep · 来源: dl-cdn.alpinelinux.org
nix profile install nixpkgs#ast-grepnixpkgs package indexes · pkgs/by-name/as/ast-grep/package.nix · 来源: api.github.com
sudo pacman -S ast-grepArch Linux sync databases · ast-grep · 来源: geo.mirror.pkgbuild.com
sudo zypper install ast-grepopenSUSE Tumbleweed package metadata · ast-grep · 来源: download.opensuse.org
scoop install main/ast-grepScoop official bucket manifest trees · bucket/ast-grep.json · 来源: api.github.com
winget install --id ast-grep.ast-grep -eWindows Package Manager source index · ast-grep.ast-grep · 来源: cdn.winget.microsoft.com
概览
Code searching, linting, rewriting
历史
ast-grep is a Rust command-line tool for structural code search, linting, and rewriting. It combines a grep-like user experience with tree-sitter-backed abstract syntax tree matching, so patterns are written as code snippets rather than as only text regular expressions.
The ast-grep repository was created in 2022 and the official docs carry a 2022-present copyright. The README presents the tool as ast-grep or sg, with a core algorithm that searches and rewrites code using tree-sitter-produced ASTs.
The project expanded beyond one-off search into project configuration, YAML lint rules, transformations, rewriters, custom languages, language injections, editor integrations, JavaScript and Python APIs, and a browser playground. The official sgconfig documentation positions sgconfig.yml as the root configuration file for multi-rule scans, similar in role to tsconfig.json or ESLint configuration.
ast-grep was packaged early across developer ecosystems rather than through a single language channel. The official README lists npm, pip, cargo, cargo-binstall, Homebrew, Scoop, mise, MacPorts, Nix shell, and source builds, while the supplied package facts add Alpine, Arch, winget, zypper, and Nix availability.
The tool gained attention because it serves several audiences with one binary: maintainers doing codemods for breaking changes, teams enforcing project-specific static rules, and security researchers writing structural queries faster than full compiler plugins.
The simplest usage is a command such as ast-grep --pattern ... --rewrite ... --lang ts. Larger projects add sgconfig.yml at the project root, define ruleDirs, and run scan; ast-grep discovers sgconfig.yml by walking up from the working directory, and can also use a home-directory sgconfig.yml for global configuration.
ast-grep is significant because it occupies the middle ground between grep, semgrep-style structural search, ESLint-style linting, and codemod frameworks. Package maintainers care because it ships as a native Rust CLI but is distributed through npm, pip, cargo, Homebrew, and OS package managers, which makes binary packaging, completions, and config discovery part of the user experience.
安全态势
没有找到 ast-grep 的匹配本地密钥处理 manifest。Nucleus 软件包元数据仍在此发布,以便未来覆盖拥有稳定的软件包 URL。
在无人值守的代理使用前,请检查该工具是否读取明文凭据、写入远程状态、发布制品或调用插件。
local files
These source-backed paths show where this package keeps local settings or durable credentials. Automic Vault can use them as review targets for secret scanning, migration, and command approval.
Config paths the tool may read or write during local use.
./sgconfig.yml~/sgconfig.yml可执行文件
| 命令 | 类型 | 暴露范围 | 备注 |
|---|---|---|---|
ast-grep | cli | 全局可执行文件 | |
sg | cli | 全局可执行文件 |
新鲜度
这些信号区分页生成时间、软件包管理器活动和上游发布比较。只有存在证据 URL 和可比较版本时,才会提示版本落后。
https://github.com/ast-grep/ast-grep
安装元数据
| 软件包键 | brew:ast-grep |
|---|---|
| 版本 | 0.44.1 |
| 软件包管理器 | Homebrew |
| 软件包管理器页面 | https://formulae.brew.sh/formula/ast-grep |
| 主页 | https://ast-grep.github.io/ |
| 仓库 | https://github.com/ast-grep/ast-grep |
| 上游文档 | https://ast-grep.github.io/ |
| 许可证 | MIT |
| 源码归档 | https://github.com/ast-grep/ast-grep/archive/refs/tags/0.44.1.tar.gz |
| 最后更新 | 2026-07-04T14:40:32Z |
| Pulse | updated |
| 构建依赖 | rust |
| Bottle | 可用 (于 arm64_linux, arm64_sequoia, arm64_sonoma, arm64_tahoe, sonoma, x86_64_linux) |
| Homebrew post-install | 未定义 |
| 服务 | 未声明 |
注册表事实
| Source Database | Homebrew formula API |
|---|---|
| Tap | homebrew/core |
| Full Name | ast-grep |
| Version Scheme | 0 |
| Revision | 0 |
| Head Version | HEAD |
| Bottle Stable Root URL | https://ghcr.io/v2/homebrew/core |
| Deprecated | no |
| Disabled | no |
| Keg Only | no |
| URL Keys |
|
源数据库匹配
匹配项来自外部软件包管理器索引,并与本地 Automic Vault 软件包链接分开显示。
ast-grep
nix profile install nixpkgs#ast-grepast-grep 0.28.1-r0
A CLI tool for code structural search, lint and rewriting
https://github.com/ast-grep/ast-grep
sudo apk add ast-grepast-grep-bash-completion 0.28.1-r0
Bash completions for ast-grep
https://github.com/ast-grep/ast-grep
sudo apk add ast-grep-bash-completionast-grep-fish-completion 0.28.1-r0
Fish completions for ast-grep
https://github.com/ast-grep/ast-grep
sudo apk add ast-grep-fish-completionast-grep-zsh-completion 0.28.1-r0
Zsh completions for ast-grep
https://github.com/ast-grep/ast-grep
sudo apk add ast-grep-zsh-completionast-grep 0.43.0-1
CLI tool for code structural search, lint and rewriting
sudo pacman -S ast-grepast-grep 0.43.0-1.1
A CLI tool for code structural search, lint and rewriting
sudo zypper install ast-grepast-grep
sudo port install ast-grepmain/ast-grep
scoop install main/ast-grepast-grep.ast-grep
winget install --id ast-grep.ast-grep -e来源线索
此页面由 av-web 从 scripts/generate-pkg-sqlite.py 生成的私有软件包 SQLite 工件提供。
View the package source record on GitHub.