Files
BlueRoseNote/07-Other/AI/Obsidian/Obsidian CLI.md

93 lines
3.4 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.
# Obsidian CLI
## 参考资料
- [Obsidian CLI 详细教程:官方命令行工具,激进拥抱智能体,高效 + 自动化 + 降低 Token 消耗](https://www.bilibili.com/video/BV19TPXzAEtW/?share_source=copy_web&vd_source=fe8142e8e12816535feaeabd6f6cdc8e)
- [如何为 Obsidian 配置 AI Agent9 个必备 Skill 详解与安装指南](https://www.bilibili.com/video/BV14d9TBiE1S/?share_source=copy_web&vd_source=fe8142e8e12816535feaeabd6f6cdc8e)
## 配置步骤
### 1. 开启 CLI
Obsidian → 小齿轮Settings→ 开启**命令行界面**
### 2. 安装 Claudian 插件(可选)
Obsidian 适配 Claude Code 的插件,提供更好的集成体验。
- 仓库:[Claudian](https://github.com/YishenTu/claudian)
- 安装后需配置自定义变量
### 3. 安装 Obsidian Skills
官方 Skill 集合,包含 Markdown、Bases、Canvas、CLI、Defuddle 等能力。
- 仓库:[obsidian-skills](https://github.com/kepano/obsidian-skills)
- Defuddle 需要全局安装依赖:`npm install -g defuddle`
### 4. 安装绘图增强 Skill
支持 Excalidraw、Mermaid、Canvas 等可视化图表生成。
- 仓库:[axton-obsidian-visual-skills](https://github.com/axtonliu/axton-obsidian-visual-skills)
## 其他 Skill
| Skill | 用途 | 仓库 |
| --- | --- | --- |
| tutor-skills | 学习辅助 | [GitHub](https://github.com/bevibing/tutor-skills) |
## 外部大型代码库索引策略(以 UE 为例)
针对 Unreal Engine 这种体量的外部依赖,全量索引通常不是最优解。以下是三种可行策略:
### 方案一:软链接(最简单)
在项目根目录创建指向引擎源码的软链接,让索引工具将其视为项目内目录。
```bash
ln -s /Users/Shared/Epic\ Games/UE_5.4/Engine ./UE_Source_Link
```
> [!warning] 注意
> - 务必在 `.gitignore` 中忽略该目录
> - UE 源码文件量巨大,索引时间可能极长
### 方案二:多图谱架构(性能最优)
将引擎(静态)和项目(动态)分离为两个独立图谱,通过桥接查询关联。
1. 对 UE 引擎预生成 `engine_graph.db`(一次性)
2. 对项目生成 `project_graph.db`(持续更新)
3. 在 MCP Server 中实现双向查询:项目类 → 发现继承关系 → 自动去引擎图谱检索基类定义
### 方案三:指定多路径参数
```bash
graphify . /path/to/external/ue_source --output ./unified_graph
```
> [!note] 弊端
> 每次扫描都会重新处理外部目录,除非工具支持增量索引。
### 剪枝策略:减少索引噪音
对 UE 外部目录索引时应进行**语义剪枝**,提升 Claude 回复精准度:
| 策略 | 说明 |
| --- | --- |
| **排除 Private 目录** | 只索引 `Public/` 下的头文件(接口和宏定义),性价比最高 |
| **模块化索引** | 按需索引:渲染相关只索引 `Runtime/Renderer` + `Runtime/RenderCore`;逻辑相关只索引 `Runtime/Engine` + `Runtime/CoreUObject` |
| **头文件优先** | 仅解析 `.h` 文件,不解析 `.cpp`,大幅降低图谱复杂度同时保留类层次关系 |
### 让 Claude Code 感知外部索引
`CLAUDE.md` 中声明外部图谱的存在和使用规则:
```markdown
# External Context
- **UE Engine Source:** Indexed at `~/.cache/ue_engine_graph.db`
- **Search Rule:** If a class prefix is 'U', 'A', or 'F' and not found in the current project, use the `search_ue_engine_graph` tool via MCP.
```
这样可将外部目录转变为**只读远程知识库**——既保证响应速度,又扩展知识边界。