From 2524298a165a3352d1e7482876841d4f91f97abb Mon Sep 17 00:00:00 2001 From: BlueRose <378100977@qq.com> Date: Tue, 2 Jun 2026 16:37:24 +0800 Subject: [PATCH] vault backup: 2026-06-02 16:37:24 --- .../UnrealEngine/GitNexus 知识图谱.md | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/07-Other/AI/AI Agent/UnrealEngine/GitNexus 知识图谱.md b/07-Other/AI/AI Agent/UnrealEngine/GitNexus 知识图谱.md index 8baa5d5..b91518f 100644 --- a/07-Other/AI/AI Agent/UnrealEngine/GitNexus 知识图谱.md +++ b/07-Other/AI/AI Agent/UnrealEngine/GitNexus 知识图谱.md @@ -33,6 +33,46 @@ aliases: - PostToolUse - MCP:`claude mcp add gitnexus -- cmd /c npx -y gitnexus@latest mcp` +# 索引 +## 项目开发时自动索引方案 + +### SessionStart Hook(推荐) +Claude Code 会话启动时自动执行增量分析,索引最新时秒级返回。 + +`.claude/settings.json`: +```json +{ + "hooks": { + "SessionStart": [{ + "hooks": [{ + "type": "command", + "command": "npx gitnexus analyze", + "timeout": 120 + }] + }] + } +} +``` + +- **触发时机**:新会话、`/clear` 后 +- **开销**:增量分析,索引最新时 <1s +- **适用**:所有项目,`.claude/settings.json` 可提交 Git 团队共享 +- **PowerShell 路径含空格**:`cd \"D:\\path\\My Project\" && npx gitnexus analyze` + +### 备选方案 + +| 方案 | 触发点 | 优点 | 缺点 | +|------|--------|------|------| +| **PostToolUse + Bash(git commit)** | commit 后 | 提交即同步 | 每次 commit 等分析耗时 | +| **Git post-commit hook** | commit 后 | 不依赖 CC | `.git/hooks/` 不可版本控制 | +| **手动 `/gitnexus-cli`** | 用户触发 | 按需 | 易忘,索引滞后 | +| **PreToolUse 守卫** | 代码操作前 | 保证安全 | 每次操作额外等待 | + +### 建议组合 +- 日常:==SessionStart Hook==,零感知保索引新鲜 +- 大重构后:手动 `npx gitnexus analyze --force` 重建 +- 团队:Hook 配置放入 `.claude/settings.json` 提交 Git + ## 提高索引速度 > [!tip] 适用场景