project-understanding
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseProject Understanding
项目理解
Overview
概述
Automated repository intelligence via Tree-sitter indexing and PUI commands. Core principle: index once, then use focused packs (repomap/find/zoom/impact) instead of manual grep.
通过Tree-sitter索引和PUI命令实现自动化仓库智能分析。核心原则:只需索引一次,之后使用聚焦命令包(repomap/find/zoom/impact)替代手动grep。
When to Use
适用场景
- Entering new codebase: Rapidly map structure and entry points
- Planning refactors or hotfixes: Find callers and assess blast radius
- Budgeting context: Fit repository summaries into LLM token limits
- Time pressure: Reduce risk of missing indirect dependencies
- Verification: Ensure changes don't violate architectural boundaries
When NOT to Use
- Tiny repos: Manual reading is faster than indexing
- Unsupported languages: Avoid relying on symbol graphs (see )
skills/project-understanding/references/LANG_SUPPORT.md
- 接入新代码库: 快速映射结构和入口点
- 规划重构或热修复: 查找调用方并评估影响范围
- 控制上下文成本: 将仓库摘要压缩至LLM的token限制内
- 时间紧迫时: 降低遗漏间接依赖的风险
- 验证变更: 确保修改不会违反架构边界
不适用场景
- 小型仓库: 手动阅读比索引更快
- 不支持的语言: 避免依赖符号图(详见)
skills/project-understanding/references/LANG_SUPPORT.md
Language Support (Read This Early)
语言支持(请提前阅读)
- Full symbol/call graph support: Python, JavaScript, TypeScript, Go, Rust
- C/C++: Expect mostly file-level results; /
zoommay show "Symbol not found"graph - Reference:
skills/project-understanding/references/LANG_SUPPORT.md
- 完整符号/调用图支持: Python、JavaScript、TypeScript、Go、Rust
- C/C++: 预计主要返回文件级结果;/
zoom可能显示“Symbol not found”graph - 参考文档:
skills/project-understanding/references/LANG_SUPPORT.md
Command Guardrails (No Exceptions)
命令约束(无例外)
- Repo selection is the working directory. There is no flag.
--repo - Always call from the target repo. Do not run
"$PUI"inside the target repo../scripts/pui.sh - target is positional. There is no
zoomor--targetflag.--file - does not accept file paths. Use a symbol id/name or
zoom.file:line
- 仓库选择基于工作目录,没有参数。
--repo - 始终从目标仓库中调用,不要在目标仓库内运行
"$PUI"。./scripts/pui.sh - 的目标为位置参数,没有
zoom或--target参数。--file - 不接受文件路径,请使用符号ID/名称或
zoom格式。file:line
Core Workflow
核心工作流
- Set tool path once: (use
PUI="/path/to/skills/project-understanding/scripts/pui.sh"on Windows). Do NOT runpui.ps1from the target repo../scripts/pui.sh - From the repo root (no flag):
--repo- (or
"$PUI" indexafter big changes)"$PUI" index build "$PUI" repomap --depth 2 --max-tokens auto
- Locate symbols:
- to get a symbol id (avoid guessing generic names)
"$PUI" find "SymbolName" - (file paths alone will fail)
"$PUI" zoom <symbol-id|name|file:line> "$PUI" graph --symbol <symbol-id|name> --depth 2
- Assess impact:
"$PUI" impact --files path/to/file --include-tests"$PUI" impact --git-diff HEAD~1..HEAD
- 一次性设置工具路径: (Windows系统使用
PUI="/path/to/skills/project-understanding/scripts/pui.sh")。不要从目标仓库中运行pui.ps1。./scripts/pui.sh - 在仓库根目录下执行(无需参数):
--repo- (或在重大变更后使用
"$PUI" index)"$PUI" index build "$PUI" repomap --depth 2 --max-tokens auto
- 定位符号:
- 使用获取符号ID(避免猜测通用名称)
"$PUI" find "SymbolName" - 使用(单独的文件路径会执行失败)
"$PUI" zoom <symbol-id|name|file:line> - 使用
"$PUI" graph --symbol <symbol-id|name> --depth 2
- 使用
- 评估影响范围:
"$PUI" impact --files path/to/file --include-tests"$PUI" impact --git-diff HEAD~1..HEAD
Example (Lean Boost)
示例(Lean Boost)
From the repo root:
project-understanding-skillbash
PUI="$(pwd)/skills/project-understanding/scripts/pui.sh"
cd ./codebases/lean-boost
"$PUI" index
"$PUI" repomap --depth 3 --max-tokens 1200
"$PUI" find "services_manager"
"$PUI" graph --symbol 70 --depth 1 --format mermaid
"$PUI" impact --files src/uninstall/leftovers_scanner.cpp --max-tokens 800在仓库根目录下执行:
project-understanding-skillbash
PUI="$(pwd)/skills/project-understanding/scripts/pui.sh"
cd ./codebases/lean-boost
"$PUI" index
"$PUI" repomap --depth 3 --max-tokens 1200
"$PUI" find "services_manager"
"$PUI" graph --symbol 70 --depth 1 --format mermaid
"$PUI" impact --files src/uninstall/leftovers_scanner.cpp --max-tokens 800Installation
安装
The skill works out of the box. On first run it bootstraps a shared virtual environment in (or a local fallback). Repository indexes are stored in under the project root.
~/.local/share/pui/venv.pui/本工具开箱即用。首次运行时,会在中创建共享虚拟环境(或使用本地备用路径)。仓库索引存储在项目根目录下的文件夹中。
~/.local/share/pui/venv.pui/Quick Reference
快速参考
| Command | Purpose | Key Flag |
|---|---|---|
| Build/update index | |
| Directory + top files | |
| Symbol search | |
| Symbol detail | |
| Call/dependency graph | |
| Blast radius analysis | |
| High-level architecture summary | |
| Module dependency graph | |
Usage notes:
- target is positional; there is no
zoomflag.--target - does not accept file paths; use a symbol id/name or
zoom.file:line - Use first if you are unsure of symbol ids.
find
| 命令 | 用途 | 关键参数 |
|---|---|---|
| 构建/更新索引 | |
| 目录结构+核心文件展示 | |
| 符号搜索 | |
| 符号详情查看 | |
| 调用/依赖关系图 | |
| 影响范围分析 | |
| 高层架构摘要 | |
| 模块依赖关系图 | |
使用说明:
- 的目标为位置参数,没有
zoom参数。--target - 不接受文件路径,请使用符号ID/名称或
zoom格式。file:line - 若不确定符号ID,请先使用命令。
find
Impact Analysis Confidence
影响分析置信度
| Score | Meaning | Action |
|---|---|---|
| 0.9+ | Definite match | Trust & proceed |
| 0.7-0.9 | Likely (imports) | Verify manually |
| <0.7 | Heuristic/dynamic | Treat as hints |
Confidence signals are meaningful only for supported languages with symbol extraction.
| 分数 | 含义 | 操作建议 |
|---|---|---|
| 0.9+ | 明确匹配 | 直接信任并执行后续操作 |
| 0.7-0.9 | 大概率匹配(基于导入关系) | 手动验证 |
| <0.7 | 启发式/动态推断结果 | 仅作为参考提示 |
置信度评分仅对支持符号提取的语言有效。
Common Mistakes
常见错误
- Wrong script path: Running from the repo root fails. Use an absolute path or
./scripts/pui.sh.PUI=... - Skipping index: Commands will fail or show stale data. Use regularly; use
indexfor full rebuilds.index build - Wrong zoom target: needs a symbol id/name or
zoom. There is nofile:lineflag.--target - Guessing symbols: Run before
find/zoom, especially in large repos.graph - Inventing flags: There is no flag; set the repo by
--repointo it.cd - Assuming C/C++ symbol graphs: Check first.
skills/project-understanding/references/LANG_SUPPORT.md - Ignoring budget: Large repo-maps can burn 20k+ tokens. Use or
--depth.--max-tokens
- 脚本路径错误: 从仓库根目录运行会失败,请使用绝对路径或设置
./scripts/pui.sh环境变量。PUI - 跳过索引步骤: 命令会执行失败或显示过期数据。请定期使用,重大变更后使用
index进行完整重建。index build - 错误的zoom目标: 需要符号ID/名称或
zoom格式,没有file:line参数。--target - 猜测符号名称: 在大型仓库中,使用/
zoom前请先运行graph命令。find - 自定义参数: 没有参数,请通过
--repo进入目标仓库来指定。cd - 默认C/C++支持符号图: 请先查看。
skills/project-understanding/references/LANG_SUPPORT.md - 忽略token限制: 大型仓库的repomap可能消耗20k+ token,请使用或
--depth参数控制。--max-tokens
Rationalization Table
误区澄清表
| Excuse | Reality |
|---|---|
| "I can just grep for imports" | Grep misses indirect dependencies. |
| "Structure is obvious from folder names" | Folder names are not dependency graphs. Use |
| "Indexing takes too long" | Indexing is incremental; manual tracing is slower and riskier. |
| "I haven't used the tool, so I'll skip it" | First run cost is one-time; |
| "I'll just read the big files" | Reading 600+ line files burns tokens and focus. |
| "The tool should be in ./scripts here" | The script lives in the skill directory. Set |
| "I can zoom a file path" | |
| 借口 | 实际情况 |
|---|---|
| "我可以直接用grep查找导入关系" | Grep会遗漏间接依赖。索引完成后, |
| "从文件夹名称就能看出结构" | 文件夹名称不等于依赖关系图,请使用 |
| "索引太费时间" | 索引是增量式的,手动追踪依赖更慢且风险更高。 |
| "我没用过这个工具,所以跳过它" | 首次运行成本是一次性的,之后 |
| "我直接读大文件就行" | 阅读600+行的文件会消耗大量token和精力, |
| "工具应该在当前目录的./scripts里" | 脚本存放在技能目录中,请先设置 |
| "我可以用文件路径来zoom" | |
Red Flags - STOP and Index
危险信号 - 立即停止并执行索引
- You are about to publish an impact summary from manual grep alone.
- You are guessing architecture based on folder names.
- You see "Symbol not found" and keep going without checking language support or .
find - You are about to run inside the target repo.
./scripts/pui.sh - You are about to pass a file path to .
zoom - You are manually following imports through more than 2 files.
- You are hitting context window limits with large code blocks.
All of these mean: run , use //, or verify language support first.
indexrepomapfindimpact- 你打算仅通过手动grep就发布影响范围摘要。
- 你正通过文件夹名称猜测架构。
- 你看到“Symbol not found”却未检查语言支持或运行命令就继续操作。
find - 你打算在目标仓库内运行。
./scripts/pui.sh - 你打算将文件路径传递给命令。
zoom - 你手动追踪导入关系已超过2个文件。
- 你因大段代码块而遇到上下文窗口限制。
以上所有情况都意味着:先运行,使用//命令,或先验证语言支持。
indexrepomapfindimpact