Skip to content

Commit e2771c7

Browse files
invalidclaude
andcommitted
docs: update README with bilingual Chinese/English content
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 141358d commit e2771c7

1 file changed

Lines changed: 51 additions & 41 deletions

File tree

README.md

Lines changed: 51 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,117 @@
11
# CodeMap
22

3+
基于 AST 的代码图谱映射插件,适用于 [Claude Code](https://docs.anthropic.com/en/docs/claude-code)。扫描代码库一次,持久化结构图谱,后续会话加载紧凑切片即可恢复上下文——相比重新读取全部源码,节省约 95% token。
4+
35
AST-based code graph mapping plugin for [Claude Code](https://docs.anthropic.com/en/docs/claude-code). Scan your codebase once, persist a structural graph, and load compact slices in future sessions — saving ~95% tokens compared to re-reading all source files.
46

5-
## Features
7+
## 特性 / Features
68

7-
- **AST Parsing** — Uses tree-sitter (WASM) for accurate structural analysis, no regex guessing
8-
- **Multi-Language** — TypeScript, JavaScript, Python, Go, Rust, Java, C, C++
9-
- **Smart Slicing** — Project overview (~500 tokens) + per-module slices (~2-5k tokens) instead of full source (~200k+)
10-
- **Incremental Updates** — File hash comparison detects changes; only re-parses modified files
11-
- **Impact Analysis** — See what's affected before you refactor
12-
- **Auto-Triggering** — Skills activate automatically based on your conversation context
9+
- **AST 解析 / AST Parsing** 使用 tree-sitter (WASM) 进行精确的结构分析,非正则猜测 / Uses tree-sitter (WASM) for accurate structural analysis, no regex guessing
10+
- **多语言支持 / Multi-Language** — TypeScript, JavaScript, Python, Go, Rust, Java, C, C++
11+
- **智能切片 / Smart Slicing** 项目概览 (~500 tokens) + 按模块切片 (~2-5k tokens),替代全量源码 (~200k+) / Project overview (~500 tokens) + per-module slices (~2-5k tokens) instead of full source (~200k+)
12+
- **增量更新 / Incremental Updates** 基于文件哈希比较检测变更,仅重新解析修改的文件 / File hash comparison detects changes; only re-parses modified files
13+
- **影响分析 / Impact Analysis** 重构前查看哪些模块会受影响 / See what's affected before you refactor
14+
- **自动触发 / Auto-Triggering** Skill 根据对话上下文自动激活 / Skills activate automatically based on your conversation context
1315

14-
## Installation
16+
## 安装 / Installation
1517

1618
```bash
1719
cd cli
1820
npm install
1921
```
2022

23+
然后在 Claude Code 中注册插件,指向 `.claude-plugin/` 目录。
24+
2125
Then register the plugin in Claude Code by pointing to the `.claude-plugin/` directory.
2226

23-
## CLI Commands
27+
## CLI 命令 / CLI Commands
28+
29+
所有命令通过 `node cli/bin/codegraph.js <command>` 运行。
2430

2531
All commands are run via `node cli/bin/codegraph.js <command>`.
2632

27-
| Command | Description |
33+
| 命令 / Command | 描述 / Description |
2834
|---------|-------------|
29-
| `scan <dir>` | Full AST scan, generates `.codemap/` with graph + slices |
30-
| `status` | Show graph metadata (files, modules, last scan time) |
31-
| `query <symbol>` | Search for functions, classes, types by name |
32-
| `slice [module]` | Output project overview or a specific module slice as JSON |
33-
| `update` | Incremental update — re-parse only changed files |
34-
| `impact <target>` | Analyze which modules are affected by changing a target |
35+
| `scan <dir>` | 全量 AST 扫描,生成 `.codemap/` 图谱和切片 / Full AST scan, generates `.codemap/` with graph + slices |
36+
| `status` | 显示图谱元信息(文件数、模块、上次扫描时间)/ Show graph metadata (files, modules, last scan time) |
37+
| `query <symbol>` | 按名称搜索函数、类、类型 / Search for functions, classes, types by name |
38+
| `slice [module]` | 输出项目概览或指定模块切片(JSON)/ Output project overview or a specific module slice as JSON |
39+
| `update` | 增量更新——仅重新解析变更的文件 / Incremental update — re-parse only changed files |
40+
| `impact <target>` | 分析修改目标会影响哪些模块 / Analyze which modules are affected by changing a target |
3541

36-
### Examples
42+
### 示例 / Examples
3743

3844
```bash
39-
# Scan a project
45+
# 扫描项目 / Scan a project
4046
node cli/bin/codegraph.js scan /path/to/project
4147

42-
# Check graph status
48+
# 检查图谱状态 / Check graph status
4349
node cli/bin/codegraph.js status
4450

45-
# Query a symbol
51+
# 查询符号 / Query a symbol
4652
node cli/bin/codegraph.js query "handleLogin"
4753

48-
# Get module slice with dependencies
54+
# 获取模块切片(含依赖)/ Get module slice with dependencies
4955
node cli/bin/codegraph.js slice auth --with-deps
5056

51-
# Incremental update after code changes
57+
# 增量更新 / Incremental update after code changes
5258
node cli/bin/codegraph.js update
5359

54-
# Impact analysis before refactoring
60+
# 影响分析 / Impact analysis before refactoring
5561
node cli/bin/codegraph.js impact auth --depth 3
5662
```
5763

5864
## Skills
5965

66+
作为 Claude Code 插件安装后,以下 skill 会根据对话上下文自动触发:
67+
6068
When installed as a Claude Code plugin, these skills auto-trigger based on conversation context:
6169

62-
| Skill | Triggers On |
70+
| Skill | 触发词 / Triggers On |
6371
|-------|------------|
6472
| `/scan` | "扫描", "索引", "scan", "index", "map codebase" |
6573
| `/load` | "加载图谱", "项目结构", "load", "code structure" |
6674
| `/update` | "更新图谱", "refresh", "代码改了" |
6775
| `/query` | "查找", "谁调用了", "where is", "find function" |
6876
| `/impact` | "影响范围", "refactor impact", "change impact" |
6977

70-
## Supported Languages
78+
## 支持的语言 / Supported Languages
7179

72-
| Language | Extensions | Extracted Structures |
80+
| 语言 / Language | 扩展名 / Extensions | 提取结构 / Extracted Structures |
7381
|----------|-----------|---------------------|
74-
| TypeScript | `.ts`, `.tsx` | Functions, imports, exports, classes, interfaces, type aliases |
75-
| JavaScript | `.js`, `.jsx`, `.mjs`, `.cjs` | Functions, imports, exports, classes |
76-
| Python | `.py` | Functions (decorated), imports, `__all__` exports, classes |
77-
| Go | `.go` | Functions, methods (with receiver), imports, exported names, structs, type specs |
78-
| Rust | `.rs` | Functions, impl methods, use declarations, pub exports, structs, enums, traits |
79-
| Java | `.java` | Methods, constructors, imports, public exports, classes, interfaces, enums |
80-
| C | `.c`, `.h` | Functions, `#include`, non-static exports, structs, enums, typedefs |
81-
| C++ | `.cpp`, `.cc`, `.cxx`, `.hpp`, `.hh` | Qualified functions (`Class::method`), includes, classes, structs, namespaces |
82+
| TypeScript | `.ts`, `.tsx` | 函数、导入、导出、类、接口、类型别名 / Functions, imports, exports, classes, interfaces, type aliases |
83+
| JavaScript | `.js`, `.jsx`, `.mjs`, `.cjs` | 函数、导入、导出、类 / Functions, imports, exports, classes |
84+
| Python | `.py` | 函数(含装饰器)、导入、`__all__` 导出、类 / Functions (decorated), imports, `__all__` exports, classes |
85+
| Go | `.go` | 函数、方法(含接收者)、导入、导出名、结构体、类型声明 / Functions, methods (with receiver), imports, exported names, structs, type specs |
86+
| Rust | `.rs` | 函数、impl 方法、use 声明、pub 导出、结构体、枚举、trait / Functions, impl methods, use declarations, pub exports, structs, enums, traits |
87+
| Java | `.java` | 方法、构造器、导入、public 导出、类、接口、枚举 / Methods, constructors, imports, public exports, classes, interfaces, enums |
88+
| C | `.c`, `.h` | 函数、`#include`、非 static 导出、结构体、枚举、typedef / Functions, `#include`, non-static exports, structs, enums, typedefs |
89+
| C++ | `.cpp`, `.cc`, `.cxx`, `.hpp`, `.hh` | 限定函数名(`Class::method`)、include、类、结构体、命名空间 / Qualified functions (`Class::method`), includes, classes, structs, namespaces |
90+
91+
## 图谱结构 / Graph Structure
8292

83-
## Graph Structure
93+
扫描后生成 `.codemap/` 目录:
8494

8595
Scanning produces a `.codemap/` directory:
8696

8797
```
8898
.codemap/
89-
├── graph.json # Full structural graph
90-
├── meta.json # File hashes, timestamps, commit info
99+
├── graph.json # 完整结构图谱 / Full structural graph
100+
├── meta.json # 文件哈希、时间戳、提交信息 / File hashes, timestamps, commit info
91101
└── slices/
92-
├── _overview.json # Compact project overview (~500 tokens)
93-
├── auth.json # Per-module detailed slice
102+
├── _overview.json # 紧凑项目概览 (~500 tokens) / Compact project overview (~500 tokens)
103+
├── auth.json # 按模块的详细切片 / Per-module detailed slice
94104
├── api.json
95105
└── ...
96106
```
97107

98-
## Tests
108+
## 测试 / Tests
99109

100110
```bash
101111
cd cli
102112
npm test
103113
```
104114

105-
## License
115+
## 许可证 / License
106116

107117
[MIT](LICENSE)

0 commit comments

Comments
 (0)