54 lines
2.1 KiB
Markdown
Executable File
54 lines
2.1 KiB
Markdown
Executable File
# 织忆 Obsidian 插件 — 实现参考
|
||
|
||
> 本文件记录 `~/projects/memoryweave/plugins/obsidian/` 的具体实现细节。
|
||
|
||
## 插件功能清单
|
||
|
||
| 子任务 | 文件 | 状态 |
|
||
|--------|------|------|
|
||
| E5.1.1 插件骨架 | `manifest.json`, `main.ts`, `styles.css` | ✅ |
|
||
| E5.1.2 记忆侧边栏面板 | `src/MemoryView.ts` | ✅ |
|
||
| E5.1.3 实体图谱视图(D3) | `src/GraphView.ts` | ✅ |
|
||
| E5.1.4 记忆搜索模态框 | `src/SearchModal.ts` | ✅ |
|
||
| E5.1.5 实体详情视图 | `src/GraphView.ts`(点击节点递归展开) | ✅ |
|
||
| E5.1.6 蒸馏状态面板 | `src/MemoryView.ts`(顶部红色警告条,30s 轮询) | ✅ |
|
||
|
||
## API 端点使用
|
||
|
||
| 功能 | 端点 | 方法 |
|
||
|------|------|------|
|
||
| 统计 | `/api/v1/stats` | GET |
|
||
| 记忆列表 | `/api/v1/memories?namespace=&limit=&offset=` | GET |
|
||
| 语义搜索 | `/api/v1/search/recall` | POST |
|
||
| 图谱邻居 | `/api/v1/graph/navigate?entity=&depth=1` | GET |
|
||
| 图谱导出 | `/api/v1/graph/export?namespace=&limit=` | GET |
|
||
| PageRank | `/api/v1/graph/pagerank?limit=` | GET |
|
||
| 按实体查记忆 | `/api/v1/memories/by-entity/{entity}` | GET |
|
||
| 蒸馏状态 | `/api/v1/distill/status` | GET |
|
||
| 蒸馏配额 | `/api/v1/distill/quota` | GET |
|
||
|
||
## 构建与安装
|
||
|
||
```bash
|
||
# 构建
|
||
cd ~/projects/memoryweave/plugins/obsidian
|
||
npm install # 只需运行一次
|
||
node esbuild.config.mjs
|
||
|
||
# 安装
|
||
make install-obsidian
|
||
|
||
# 或手动
|
||
mkdir -p ~/.obsidian/plugins/zhiyi-memory/
|
||
cp main.js manifest.json styles.css ~/.obsidian/plugins/zhiyi-memory/
|
||
```
|
||
|
||
## 图谱渲染关键代码
|
||
|
||
D3.js 从 CDN 动态加载,GraphView 使用 `forceSimulation` + `forceLink` + `forceManyBody` + `forceCenter` + `forceCollide`。节点颜色按 category 区分,中心节点(当前选中实体)红色高亮。点击节点递归调用 `fetchNeighbors` 加载下一层。
|
||
|
||
## 已解决的技术问题
|
||
|
||
1. **npm 路径错误**:`~/.local/bin/npm` → 实际路径 `~/.local/lib/npm/bin/npm-cli.js`(修复方法见 openclaw skill)
|
||
2. **TypeScript LSP 无 obsidian 类型**:正常,Obsidian host 运行时提供,esbuild 不受影响
|
||
3. **CORS 预检**:Go 中间件处理 OPTIONS 请求,返回 204 |