@ast-bro/cli

中文文档
4.2.0发布于 2026/08/08MIT零依赖近 30 天下载 2866

Fast, AST-based code-navigation and log-squeezing toolkit — downloads the binary on install

原始使用文档
文档目录6 节
  1. Install
  2. Usage
  3. Supported Platforms
  4. What is ast-bro?
  5. Links
  6. License

@ast-bro/cli

npm License: MIT

npm installer for ast-bro — a fast, AST-based code-navigation toolkit for source files (shape, public API, dep & call graphs, hybrid semantic search, structural rewrite, MCP server). Downloads the pre-built Rust binary on install.

Formerly @ast-outline/cli. Same project under a new scope (the ast-outline name became overloaded after the tool grew beyond outlining). The ast-outline command is still installed as a thin proxy that forwards to ast-bro, so existing scripts keep working.

Install

npm install -g @ast-bro/cli

This installs three commands, all forwarding to the same binary:

  • ast-bro — canonical name
  • sb — short alias (same tool, fewer keystrokes)
  • ast-outline — backward-compat shim

Usage

# Map the structure of a file (signatures + line ranges, no bodies)
ast-bro map src/player.rs

# Show the exact source of a specific method
ast-bro show Player.cs TakeDamage

# Compact digest of a whole module
ast-bro digest src/services/

# True public API (resolves pub use / __all__ re-exports)
ast-bro surface .

# Find all implementations of a type
ast-bro implements IDamageable src/

# Dependency graph
ast-bro deps src/auth.rs --depth 2
ast-bro reverse-deps src/auth.rs
ast-bro cycles

# Call graph (AST-accurate)
ast-bro callers TakeDamage
ast-bro callees Player.TakeDamage

# Hybrid BM25 + dense semantic search
ast-bro search "how does login work"

# Find semantically similar code
ast-bro find-related src/auth/login.rs:42

# AST-aware structural search and rewrite (with metavariables)
ast-bro run -p '$FUNC($$$)' -l rust
ast-bro run -p 'foo($A)' -r 'bar($A)' --write    # apply to disk

On first run, the CLI downloads the pre-built binary for your platform from GitHub releases and caches it locally.

PlatformCache directory
macOS~/Library/Caches/ast-bro-<version>/
Linux~/.cache/ast-bro-<version>/

Supported Platforms

PlatformStatus
macOS ARM64Pre-built binary available
Other platformsBuild from source (see below)

For unsupported platforms, build from source:

cargo install ast-bro

What is ast-bro?

ast-bro is a fast, AST-based code-navigation toolkit built for LLM coding agents and humans. It uses tree-sitter via ast-grep to parse source files and provide:

  • File shape — map / digest / show for signatures with line ranges (95% token savings vs reading full files)
  • True public API — surface resolves re-export graphs across Rust, Python, TypeScript, and more
  • Dependency graph — deps / reverse-deps / cycles / graph for import analysis
  • Call graph — callers / callees with AST accuracy across 14 languages
  • Semantic search — hybrid BM25 + dense embeddings via search and find-related
  • Structural rewrite — run for AST-aware pattern matching with metavariables (find + replace)
  • MCP server — every command exposed as an MCP tool for LLM agents

Supports Rust, Python, TypeScript, JavaScript, Java, C#, C++, Kotlin, Scala, Go, PHP, Ruby, SQL, and Markdown.

License

MIT

版本与发布记录

@ast-bro/cli 共发布 10 个版本,首次发布于 2026/05/23;过去 12 个月发布了 10 个版本。

版本发布日期距今
4.2.0latest2026/08/082 个月前
4.1.02026/08/063 个月前
4.0.02026/08/013 个月前
3.0.02026/06/134 个月前
2.4.32026/06/065 个月前
2.4.22026/06/055 个月前

关于 @ast-bro/cli 的常见问题

@ast-bro/cli 是什么?

Fast, AST-based code-navigation and log-squeezing toolkit — downloads the binary on install

如何安装 @ast-bro/cli?

在项目目录运行 npm install @ast-bro/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 ast-bro、ast-outline、sb,可以用 npx ast-bro 直接运行。

@ast-bro/cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/ast-bro__cli 是否存在。

@ast-bro/cli 可以商用吗?

@ast-bro/cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ast-bro/cli 的下载量有多少?

根据 npm 官方下载统计,@ast-bro/cli 在 2026/10/07 – 2026/11/05 这 30 天内被下载 2,866 次,日均约 96 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ast-bro/cli 还在维护吗?

最新版本 4.2.0 发布于 2026/08/08(2 个月前);至今共发布 10 个版本,其中过去 12 个月发布了 10 个;首次发布于 2026/05/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。