Files
affaan-m--everything-claude…/docs/zh-CN/commands/update-codemaps.md
T
wehub-resource-sync d48cda4081
CI / Test (ubuntu-latest, Node 18.x, bun) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, npm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, pnpm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, yarn) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 20.x, bun) (push) Failing after 17m13s
CI / Test (ubuntu-latest, Node 20.x, npm) (push) Failing after 18m42s
CI / Test (ubuntu-latest, Node 20.x, pnpm) (push) Failing after 15m0s
CI / Test (ubuntu-latest, Node 20.x, yarn) (push) Failing after 49m44s
CI / Test (ubuntu-latest, Node 22.x, bun) (push) Failing after 51m55s
CI / Test (ubuntu-latest, Node 22.x, pnpm) (push) Failing after 21m57s
CI / Test (ubuntu-latest, Node 22.x, npm) (push) Failing after 37m39s
CI / Test (ubuntu-latest, Node 22.x, yarn) (push) Failing after 34m7s
CI / Validate Components (push) Failing after 37m15s
CI / Python Tests (push) Failing after 10m1s
CI / Security Scan (push) Failing after 10m1s
CI / Lint (push) Failing after 17m12s
CI / Coverage (push) Failing after 20m19s
CI / Test (macos-latest, Node 18.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, yarn) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:55 +08:00

74 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 更新代码地图
分析代码库结构并生成简洁的架构文档。
## 步骤 1:扫描项目结构
1. 识别项目类型(单体仓库、单应用、库、微服务)
2. 查找所有源码目录(src/, lib/, app/, packages/
3. 映射入口点(main.ts, index.ts, app.py, main.go 等)
## 步骤 2:生成代码地图
`docs/CODEMAPS/`(或 `.reports/codemaps/`)中创建或更新代码地图:
| 文件 | 内容 |
|------|----------|
| `architecture.md` | 高层系统图、服务边界、数据流 |
| `backend.md` | API 路由、中间件链、服务 → 仓库映射 |
| `frontend.md` | 页面树、组件层级、状态管理流 |
| `data.md` | 数据库表、关系、迁移历史 |
| `dependencies.md` | 外部服务、第三方集成、共享库 |
### 代码地图格式
每个代码地图应为简洁风格 —— 针对 AI 上下文消费进行优化:
```markdown
# 后端架构
## 路由
POST /api/users → UserController.create → UserService.create → UserRepo.insert
GET /api/users/:id → UserController.get → UserService.findById → UserRepo.findById
## 关键文件
src/services/user.ts (业务逻辑,120行)
src/repos/user.ts (数据库访问,80行)
## 依赖项
- PostgreSQL (主要数据存储)
- Redis (会话缓存,速率限制)
- Stripe (支付处理)
```
## 步骤 3:差异检测
1. 如果存在先前的代码地图,计算差异百分比
2. 如果变更 > 30%,显示差异并在覆盖前请求用户批准
3. 如果变更 <= 30%,则原地更新
## 步骤 4:添加元数据
为每个代码地图添加一个新鲜度头部:
```markdown
<!-- Generated: 2026-02-11 | Files scanned: 142 | Token estimate: ~800 -->
```
## 步骤 5:保存分析报告
将摘要写入 `.reports/codemap-diff.txt`
* 自上次扫描以来添加/删除/修改的文件
* 检测到的新依赖项
* 架构变更(新路由、新服务等)
* 超过 90 天未更新的文档的陈旧警告
## 提示
* 关注**高层结构**,而非实现细节
* 优先使用**文件路径和函数签名**,而非完整代码块
* 为高效加载上下文,将每个代码地图保持在 **1000 个 token 以内**
* 使用 ASCII 图表表示数据流,而非冗长的描述
* 在主要功能添加或重构会话后运行