setup-codemap-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUser Input:
text
$ARGUMENTS用户输入:
text
$ARGUMENTSGuide for setup Codemap CLI
Codemap CLI 安装指南
1. Determine setup context
1. 确定安装上下文
Ask the user where they want to store the configuration:
Options:
-
Project level (shared via git) - Configuration tracked in version control, shared with team
- CLAUDE.md updates go to:
./CLAUDE.md - Hook settings go to:
./.claude/settings.json
- CLAUDE.md updates go to:
-
Project level (personal preferences) - Configuration stays local, not tracked in git
- CLAUDE.md updates go to:
./CLAUDE.local.md - Hook settings go to:
./.claude/settings.local.json - Verify these files are listed in , add them if not
.gitignore
- CLAUDE.md updates go to:
-
User level (global) - Configuration applies to all projects for this user
- CLAUDE.md updates go to:
~/.claude/CLAUDE.md - Hook settings go to:
~/.claude/settings.json
- CLAUDE.md updates go to:
Store the user's choice and use the appropriate paths in subsequent steps.
询问用户希望将配置存储在何处:
选项:
-
项目级别(通过 git 共享) - 配置纳入版本控制,与团队共享
- CLAUDE.md 更新路径:
./CLAUDE.md - Hook 设置路径:
./.claude/settings.json
- CLAUDE.md 更新路径:
-
项目级别(个人偏好) - 配置仅保存在本地,不纳入 git 版本控制
- CLAUDE.md 更新路径:
./CLAUDE.local.md - Hook 设置路径:
./.claude/settings.local.json - 确认这些文件已列入 ,若未列入则添加
.gitignore
- CLAUDE.md 更新路径:
-
用户级别(全局) - 配置适用于该用户的所有项目
- CLAUDE.md 更新路径:
~/.claude/CLAUDE.md - Hook 设置路径:
~/.claude/settings.json
- CLAUDE.md 更新路径:
保存用户的选择,并在后续步骤中使用相应的路径。
2. Check if Codemap is already installed
2. 检查 Codemap 是否已安装
Check whether codemap is installed by running .
codemap -helpIf not installed, proceed with setup.
通过运行 检查 Codemap 是否已安装。
codemap -help若未安装,则继续进行安装。
3. Load Codemap documentation
3. 加载 Codemap 文档
Read the following documentation to understand Codemap's capabilities:
- Load https://raw.githubusercontent.com/JordanCoin/codemap/refs/heads/main/README.md to understand what Codemap is and its capabilities
阅读以下文档以了解 Codemap 的功能:
- 加载 https://raw.githubusercontent.com/JordanCoin/codemap/refs/heads/main/README.md 以了解 Codemap 是什么及其功能
4. Guide user through installation
4. 引导用户完成安装
macOS/Linux (Homebrew)
macOS/Linux (Homebrew)
bash
brew tap JordanCoin/tap && brew install codemapbash
brew tap JordanCoin/tap && brew install codemapWindows (Scoop)
Windows (Scoop)
bash
scoop bucket add codemap https://github.com/JordanCoin/scoop-codemap
scoop install codemapbash
scoop bucket add codemap https://github.com/JordanCoin/scoop-codemap
scoop install codemap5. Verify installation
5. 验证安装
After installation, verify codemap works:
bash
codemap .安装完成后,验证 Codemap 是否可用:
bash
codemap .6. Update CLAUDE.md file
6. 更新 CLAUDE.md 文件
Use the path determined in step 1. Once Codemap is successfully installed, update the appropriate CLAUDE.md file with the following content:
markdown
undefined使用步骤 1 中确定的路径。Codemap 安装成功后,将以下内容更新到对应的 CLAUDE.md 文件中:
markdown
undefinedUse Codemap CLI for Codebase Navigation
使用 Codemap CLI 进行代码库导航
Codemap CLI is available for intelligent codebase visualization and navigation.
Required Usage - You MUST use to research changes different from default branch, and + to research current working state.
codemap --diff --ref mastergit diffgit statusCodemap CLI 可用于智能代码库可视化与导航。
必填用法 - 你必须使用 来研究与默认分支不同的更改,并使用 + 来研究当前工作状态。
codemap --diff --ref mastergit diffgit statusQuick Start
快速开始
bash
codemap . # Project tree
codemap --only swift . # Just Swift files
codemap --exclude .xcassets,Fonts,.png . # Hide assets
codemap --depth 2 . # Limit depth
codemap --diff # What changed vs main
codemap --deps . # Dependency flowbash
codemap . # 项目树
codemap --only swift . # 仅显示 Swift 文件
codemap --exclude .xcassets,Fonts,.png . # 隐藏资源文件
codemap --depth 2 . # 限制树的深度
codemap --diff # 显示与主分支相比的更改
codemap --deps . # 依赖关系流Options
选项
| Flag | Description |
|---|---|
| Limit tree depth (0 = unlimited) |
| Only show files with these extensions |
| Exclude files matching patterns |
| Show files changed vs main branch |
| Branch to compare against (with --diff) |
| Dependency flow mode |
| Check who imports a file |
| City skyline visualization |
| Output JSON |
Smart pattern matching - no quotes needed:
- - any
.pngfile.png - - any
Fontsdirectory/Fonts/ - - glob pattern
*Test*
| 标志 | 描述 |
|---|---|
| 限制树的深度(0 = 无限制) |
| 仅显示带有指定扩展名的文件 |
| 排除匹配指定模式的文件 |
| 显示与主分支相比已更改的文件 |
| 对比的分支(配合 --diff 使用) |
| 依赖关系流模式 |
| 查看哪些文件导入了指定文件 |
| 城市天际线可视化模式 |
| 输出 JSON 格式 |
智能模式匹配 - 无需引号:
- - 所有
.png文件.png - - 所有
Fonts目录/Fonts/ - - glob 模式
*Test*
Diff Mode
差异模式
See what you're working on:
bash
codemap --diff
codemap --diff --ref develop
if the default branch is not `main`, but instead `master` (or something else) update content accordingly:
- use `codemap --diff --ref master` instead of regular `codemap --diff`查看当前工作内容:
bash
codemap --diff
codemap --diff --ref develop如果默认分支不是 ,而是 (或其他分支),请相应更新内容:
mainmaster- 使用 替代常规的
codemap --diff --ref mastercodemap --diff
7. Update .gitignore file
7. 更新 .gitignore 文件
Update .gitignore file to include directory:
.codemap/text
.codemap/更新 文件,添加 目录:
.gitignore.codemap/text
.codemap/8. Test Codemap
8. 测试 Codemap
Run a quick test to verify everything works:
bash
codemap .
codemap --diff运行快速测试以验证所有功能正常:
bash
codemap .
codemap --diff9. Add hooks to settings file
9. 向设置文件添加 Hooks
-
Use the settings path determined in step 1. Create the settings file if it doesn't exist and add the following content:json
{ "hooks": { "session-start": "codemap hook session-start && echo 'git diff:' && git diff --stat && echo 'git status:' && git status" } }if default branch is not, but insteadmain(or something else) update content accordingly:master- use instead of regular
codemap hook session-start --ref=mastercodemap hook session-start - For rest of commands also add flag.
--ref=master
- use
-
Ask user whether he want to add any other hooks and provide list of options with descriptions. Add hooks that he asks for.
-
使用步骤 1 中确定的设置路径。如果设置文件不存在则创建,并添加以下内容:json
{ "hooks": { "session-start": "codemap hook session-start && echo 'git diff:' && git diff --stat && echo 'git status:' && git status" } }如果默认分支不是,而是main(或其他分支),请相应更新内容:master- 使用 替代常规的
codemap hook session-start --ref=mastercodemap hook session-start - 其余命令也需添加 标志。
--ref=master
- 使用
-
询问用户是否需要添加其他 Hooks,并提供带有描述的选项列表。添加用户要求的 Hooks。
Available Hooks
可用 Hooks
| Command | Trigger | Description |
|---|---|---|
| SessionStart | Full tree, hubs, branch diff, last session context |
| PreToolUse (Edit|Write) | Who imports file + what hubs it imports |
| PostToolUse (Edit|Write) | Impact of changes (same as pre-edit) |
| UserPromptSubmit | Hub context for mentioned files + session progress |
| PreCompact | Saves hub state to .codemap/hubs.txt |
| SessionEnd | Edit timeline with line counts and stats |
| 命令 | 触发时机 | 描述 |
|---|---|---|
| SessionStart | 完整树状结构、核心模块、分支差异、上一次会话上下文 |
| PreToolUse (Edit|Write) | 查看哪些文件导入了当前文件 + 当前文件导入的核心模块 |
| PostToolUse (Edit|Write) | 更改的影响(与 pre-edit 内容相同) |
| UserPromptSubmit | 提及文件的核心模块上下文 + 会话进度 |
| PreCompact | 将核心模块状态保存到 .codemap/hubs.txt |
| SessionEnd | 包含行数统计的编辑时间线 |
Example of file with full hooks configuration
完整 Hooks 配置文件示例
json
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "codemap hook session-start"
}
]
}
],
"PreToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "codemap hook pre-edit"
}
]
}
],
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "codemap hook post-edit"
}
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "codemap hook prompt-submit"
}
]
}
],
"PreCompact": [
{
"hooks": [
{
"type": "command",
"command": "codemap hook pre-compact"
}
]
}
],
"SessionEnd": [
{
"hooks": [
{
"type": "command",
"command": "codemap hook session-stop"
}
]
}
]
}
}json
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "codemap hook session-start"
}
]
}
],
"PreToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "codemap hook pre-edit"
}
]
}
],
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "codemap hook post-edit"
}
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "codemap hook prompt-submit"
}
]
}
],
"PreCompact": [
{
"hooks": [
{
"type": "command",
"command": "codemap hook pre-compact"
}
]
}
],
"SessionEnd": [
{
"hooks": [
{
"type": "command",
"command": "codemap hook session-stop"
}
]
}
]
}
}