Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions INTEGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# og-memory-graph 集成说明

本仓库在 PilotDeck 基础上集成了 **og-memory-graph**(Outline Graph 记忆图谱服务)作为即插即用插件。

## 改动概览

相对 upstream PilotDeck,本仓库的改动:

1. **`og-memory-graph/`**(新增子目录):OG Framework A 服务 + PilotDeck 插件包。独立 Python FastAPI 服务,与 PilotDeck 主进程解耦。
2. **`ui/src/components/app-shell/MainAreaV2.tsx`**(唯一 PD 源码改动):顶栏追加 enabled 插件的 Tab 渲染,让 `plugin:<name>` 能从顶栏进入。这是通用插件能力增强,不局限于 og-memory-graph。

> 其余 PilotDeck 源码均未修改。

## og-memory-graph 子目录

```
og-memory-graph/
├── og/ # Framework A(agents/core/pipeline/storage/config/cli)
├── server/ # FastAPI(embed 页 + REST)
├── frontend/ # React embed 页(dist/ 已构建)
├── plugins/og-memory-graph/ # PilotDeck 插件包
│ ├── manifest.json
│ ├── config.json # ← 部署时填写本机路径
│ ├── server.js # Node:og6 生命周期 + /config
│ └── index.js # 前端 bundle:rpc /config → 渲染 iframe
├── plugin.json
├── pyproject.toml
└── README.md
```

## 启用步骤

### 1. 安装 og-memory-graph 服务

```bash
cd og-memory-graph
pip install -e .
cp .env.template .env # 填 API key(DeepSeek 等)
```

构建前端(若 frontend/dist 缺失):
```bash
cd frontend && npm install && npm run build && cd ..
```

### 2. 部署插件包到 PilotDeck

```bash
cp -R plugins/og-memory-graph ~/.pilotdeck/plugins/
```

编辑 `~/.pilotdeck/plugins/og-memory-graph/config.json`,填本机路径:
```json
{
"og_root": "<og-memory-graph 绝对路径>",
"python": "<python 解释器绝对路径>",
"port": 8000,
"model": "deepseek"
}
```

### 3. 运行

启动 PilotDeck → 顶栏出现「记忆图谱」Tab → 选中项目 → 插件 server.js 自动 healthcheck og6 服务(已运行则复用,否则 spawn uvicorn)→ iframe 加载 embed 页 → 自动 init cluster + 全量 build → 显示图谱/报告。

## 机制

- **同步与 PilotDeck memory 轮询对齐**:og6 服务启动时为所有 `pd-*` cluster 注册 60s 轮询,检测 memory `.md` 变化即触发增量同步。PilotDeck 侧无需改动。
- **跨进程互斥**:fcntl.flock + manifest pid 保证 init/sync/rebuild 不并发。
- **5 次同步后自动重建**:累计 5 次实质性同步后下次改做全量 rebuild,重置基线。
- **cluster_id**:`pd-{md5(workspace_path)[:8]}`,同一 project 路径稳定唯一。

详见 `og-memory-graph/README.md`。
30 changes: 30 additions & 0 deletions og-memory-graph/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Python
__pycache__/
*.py[cod]
*.egg-info/
.eggs/
build/
dist/
*.egg

# 虚拟环境
.venv/
venv/
env/

# 运行产物(部署时动态生成,不 commit)
data/
logs/
outputs/
*.log

# 敏感配置(不 commit 真实 key)
.env

# 前端
frontend/node_modules/
frontend/dist/
frontend/.vite/

# 系统
.DS_Store
88 changes: 88 additions & 0 deletions og-memory-graph/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# og-pilotdeck-integration

Outline Graph (OG) Framework A 服务 + PilotDeck「记忆图谱」即插即用插件。

本仓库是一个**独立服务**:跑 FastAPI(端口 8000)提供 OG 图谱生成 + embed 页面,PilotDeck 通过插件包以 iframe 嵌入。PilotDeck 侧仅需 1 处通用改动(顶栏显示 plugin tabs)。

## 架构

```
PilotDeck (顶栏「记忆图谱」Tab = plugin:og-memory-graph)
│ iframe
og-pilotdeck-integration (FastAPI @ 8000)
├── /embed/memory-graph ← iframe 加载的页面(frontend/)
├── /api/pd/* ← PilotDeck 专用 REST(init/sync/rebuild/status/graph)
├── /api/clusters/*/graph ← 图谱 JSON
├── /api/clusters/*/reports ← polished7 报告
└── og run a (子进程) ← Framework A pipeline:build→curate→balanced→polish
```

**插件包**(`plugins/og-memory-graph/`)部署到 `~/.pilotdeck/plugins/og-memory-graph/`:
- `server.js`:PilotDeck spawn 的 Node 进程,healthcheck og6 服务(已运行则复用,否则 spawn uvicorn),暴露 `/config`。
- `index.js`:前端 bundle,rpc 拿 og6 地址后渲染 iframe。

## 目录

```
og-pilotdeck-integration/
├── og/ # Framework A
│ ├── agents/ # 19 个 LLM Agent(build/modify/propagate/render/rewrite…)
│ ├── core/ # OutlineGraph / OGNode / OGEdge
│ ├── pipeline/ # run_cluster / curate / balanced / polish / simulation
│ ├── storage/ # GraphStore / VectorStore(ChromaDB+BM25+rerank) / YamlStore
│ ├── config/ # paths / models / constants
│ ├── cli/ # python -m og run a(仅 Framework A)
│ └── mcp_server/ # MCP stdio 工具 + watcher(60s 轮询同步) + locks(跨进程互斥)
├── server/ # FastAPI(embed 页 + REST)
├── frontend/ # React embed 页(dist/ 已构建)
├── plugins/og-memory-graph/ # PilotDeck 插件包
├── plugin.json # PilotDeck 插件清单(声明)
├── pyproject.toml
└── .env.template
```

## 安装

```bash
# 1. 安装 og 服务
cd og-pilotdeck-integration
pip install -e .
cp .env.template .env # 填 API key

# 2. 构建前端(若 frontend/dist 缺失)
cd frontend && npm install && npm run build && cd ..

# 3. 部署插件包到 PilotDeck
cp -R plugins/og-memory-graph ~/.pilotdeck/plugins/
# 编辑 ~/.pilotdeck/plugins/og-memory-graph/config.json:og_root / python / port / model
```

## 运行

```bash
# 方式 A:手动起 og6 服务(开发)
uvicorn server.main:app --port 8000 --host 127.0.0.1

# 方式 B:由 PilotDeck 插件自动管理(生产)
# 启用 PilotDeck 插件后,server.js 自动 healthcheck/spawn og6
```

启动 PilotDeck → 顶栏出现「记忆图谱」Tab → 选中项目 → iframe 加载 og6 embed 页 → 自动 init cluster + 全量 build → 显示图谱/报告。

## 核心机制

- **同步与 PilotDeck memory 轮询对齐**:og6 服务启动时 `rebuild_watchers_from_clusters()` 为所有 `pd-*` cluster 注册 60s 轮询,检测 memory `.md` 变化即触发增量 `sync_changes`。PilotDeck 侧无需改动。
- **跨进程互斥**:`og/mcp_server/locks.py`(fcntl.flock + manifest pid)保证 init/sync/rebuild 不并发;pipeline pid 死亡时 `reap_if_dead` 自动推断终态。
- **5 次同步后自动重建**:累计 5 次实质性同步后置 `pending_rebuild`,下次 sync 改做全量 `rebuild`(清空历史 + vector DB,从当前 memory 重建),重置计数。
- **cluster_id**:`pd-{md5(workspace_path)[:8]}`,同一 project 路径稳定唯一。

## 配置

`og/config/models.py` 顶部可改 API key / 模型路由(优先级高于 `.env`)。默认:
- 主模型 `deepseek-v4-pro`,辅助/裁判 `deepseek-v4-flash`。

`~/.pilotdeck/plugins/og-memory-graph/config.json`:
```json
{ "og_root": "<本仓库路径>", "python": "<python 解释器>", "port": 8000, "model": "deepseek" }
```
24 changes: 24 additions & 0 deletions og-memory-graph/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
8 changes: 8 additions & 0 deletions og-memory-graph/frontend/.oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["react", "typescript", "oxc"],
"rules": {
"react/rules-of-hooks": "error",
"react/only-export-components": ["warn", { "allowConstantExport": true }]
}
}
32 changes: 32 additions & 0 deletions og-memory-graph/frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some Oxlint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)

## React Compiler

The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).

## Expanding the Oxlint configuration

If you are developing a production application, we recommend enabling type-aware lint rules by installing `oxlint-tsgolint` and editing `.oxlintrc.json`:

```json
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["react", "typescript", "oxc"],
"options": {
"typeAware": true
},
"rules": {
"react/rules-of-hooks": "error",
"react/only-export-components": ["warn", { "allowConstantExport": true }]
}
}
```

See the [Oxlint rules documentation](https://oxc.rs/docs/guide/usage/linter/rules) for the full list of rules and categories.
13 changes: 13 additions & 0 deletions og-memory-graph/frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>frontend</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
31 changes: 31 additions & 0 deletions og-memory-graph/frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "frontend",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "oxlint",
"preview": "vite preview"
},
"dependencies": {
"@dagrejs/dagre": "^3.0.0",
"@types/dagre": "^0.7.54",
"@xyflow/react": "^12.11.1",
"react": "^19.2.7",
"react-dom": "^19.2.7",
"react-markdown": "^10.1.0",
"react-router-dom": "^7.18.1",
"remark-gfm": "^4.0.1"
},
"devDependencies": {
"@types/node": "^24.13.2",
"@types/react": "^19.2.17",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^6.0.3",
"oxlint": "^1.71.0",
"typescript": "~6.0.2",
"vite": "^8.1.1"
}
}
1 change: 1 addition & 0 deletions og-memory-graph/frontend/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading