codemapper

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Codemapper

Codemapper

Code analysis tool (
cm
) for exploring structure, symbols, dependencies, and call graphs.
All commands support
--format ai
for concise, AI-friendly output.
一款用于探索代码结构、符号、依赖关系和调用图的代码分析工具(
cm
)。
所有命令均支持
--format ai
参数,可生成简洁、适配AI的输出内容。

Code Statistics

代码统计

bash
cm stats . --format ai           # Current directory
cm stats ./src --format ai       # Specific directory
bash
cm stats . --format ai           # 当前目录
cm stats ./src --format ai       # 指定目录

Code Map

代码映射

bash
cm map . --level 2 --format ai              # Basic overview
cm map . --level 3 --format ai              # Detailed structure
cm map . --level 2 --exports-only --format ai # Public API only
cm map ./src --level 2 --format ai          # Specific directory
Detail levels:
  • Level 1: Files and directories only
  • Level 2: Files with exported symbols
  • Level 3: Files with all symbols and details
bash
cm map . --level 2 --format ai              # 基础概览
cm map . --level 3 --format ai              # 详细结构
cm map . --level 2 --exports-only --format ai # 仅显示公开API
cm map ./src --level 2 --format ai          # 指定目录
详情层级说明:
  • Level 1:仅显示文件和目录
  • Level 2:显示包含导出符号的文件
  • Level 3:显示包含所有符号及详细信息的文件

Query Symbols

查询符号

bash
cm query authenticate . --format ai         # Fuzzy search
cm query User . --exact --format ai         # Exact match
cm query validate . --show-body --format ai # Show implementation
cm query process . --exports-only --format ai # Public only
bash
cm query authenticate . --format ai         # 模糊搜索
cm query User . --exact --format ai         # 精确匹配
cm query validate . --show-body --format ai # 查看实现代码
cm query process . --exports-only --format ai # 仅显示公开符号

Call Graph Analysis

调用图分析

bash
undefined
bash
undefined

Find callers of a function

查找函数的调用方

cm callers processData . --format ai cm callers UserService.get . --format ai
cm callers processData . --format ai cm callers UserService.get . --format ai

Find callees (what a function calls)

查找被调用方(函数调用的对象)

cm callees processData . --format ai cm callees UserService . --format ai
cm callees processData . --format ai cm callees UserService . --format ai

Trace call path

追踪调用路径

cm call-path functionToFind . --format ai cm call-path functionToFind --reverse --format ai
undefined
cm call-path functionToFind . --format ai cm call-path functionToFind --reverse --format ai
undefined

Dependency Analysis

依赖关系分析

bash
cm deps . --format ai              # List all dependencies
cm deps . --circular --format ai   # Detect circular deps
cm deps . --unused --format ai     # Find unused deps
cm deps . --unused-symbols --format ai # Find unused symbols
bash
cm deps . --format ai              # 列出所有依赖
cm deps . --circular --format ai   # 检测循环依赖
cm deps . --unused --format ai     # 查找未使用的依赖
cm deps . --unused-symbols --format ai # 查找未使用的符号

Finding Tests

查找测试代码

bash
cm tests functionName . --format ai  # Find tests for function
cm untested . --format ai            # Find untested code
bash
cm tests functionName . --format ai  # 查找函数对应的测试代码
cm untested . --format ai            # 查找未覆盖测试的代码

Common Workflows

常见工作流

Code Exploration

代码探索

bash
cm map . --level 2 --format ai     # Get overview
cm query User . --format ai        # Find symbols
cm deps . --format ai              # Understand deps
bash
cm map . --level 2 --format ai     # 获取概览
cm query User . --format ai        # 查找符号
cm deps . --format ai              # 理解依赖关系

Refactoring Preparation

重构准备

bash
cm tests functionToRefactor . --format ai   # Check test coverage
cm callers functionToRefactor . --format ai # Find callers to update
cm callees functionToRefactor . --format ai # Find callees
cm deps . --circular --format ai            # Check for cycles
bash
cm tests functionToRefactor . --format ai   # 检查测试覆盖率
cm callers functionToRefactor . --format ai # 查找需要更新的调用方
cm callees functionToRefactor . --format ai # 查找被调用方
cm deps . --circular --format ai            # 检查循环依赖

Tips

小贴士

  • Use
    --format ai
    for concise output
  • Use
    --level 2
    for overview,
    --level 3
    for details
  • Use
    --exports-only
    to see public API
  • Use
    --show-body
    to see implementation details
  • Use
    --exact
    for precise matching
  • 使用
    --format ai
    参数获取简洁输出
  • 使用
    --level 2
    获取概览,
    --level 3
    查看详细信息
  • 使用
    --exports-only
    查看公开API
  • 使用
    --show-body
    查看实现细节
  • 使用
    --exact
    进行精确匹配