n2n-nexus 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +358 -0
- package/LICENSE +201 -0
- package/README.md +286 -0
- package/build/client/nexus-client.js +71 -0
- package/build/config/cli.js +11 -0
- package/build/config/index.js +16 -0
- package/build/config/paths.js +38 -0
- package/build/constants.js +22 -0
- package/build/daemon/index.js +41 -0
- package/build/daemon/server.js +791 -0
- package/build/index.js +47 -0
- package/build/server/nexus.js +98 -0
- package/build/storage/docs.js +74 -0
- package/build/storage/index.js +105 -0
- package/build/storage/logs.js +60 -0
- package/build/storage/meetings.js +276 -0
- package/build/storage/paths.js +26 -0
- package/build/storage/projects.js +75 -0
- package/build/storage/registry.js +230 -0
- package/build/storage/sqlite-meeting.js +311 -0
- package/build/storage/sqlite.js +141 -0
- package/build/storage/store.js +153 -0
- package/build/storage/tasks.js +212 -0
- package/build/types.js +1 -0
- package/build/utils/async-mutex.js +36 -0
- package/docs/ARCHITECTURE.md +205 -0
- package/docs/ARCHITECTURE_zh.md +205 -0
- package/docs/ASSISTANT_GUIDE.md +120 -0
- package/docs/README_zh.md +285 -0
- package/llms.txt +46 -0
- package/package.json +90 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# Architecture & Standards
|
|
2
|
+
|
|
3
|
+
## 🏛️ System Architecture
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
┌──────────────────────────────────────────────────┐
|
|
7
|
+
│ n2n-nexus daemon │
|
|
8
|
+
│ Standalone HTTP server · User starts manually │
|
|
9
|
+
│ │
|
|
10
|
+
│ ┌──────────────┐ ┌──────────────────────────┐ │
|
|
11
|
+
│ │ REST API │ │ Storage Layer │ │
|
|
12
|
+
│ │ /api/tools │ │ SQLite (WAL) + JSON FS │ │
|
|
13
|
+
│ │ /api/tools │ │ │ │
|
|
14
|
+
│ │ /call │ │ Single writer — no lock │ │
|
|
15
|
+
│ └──────┬───────┘ └──────────────────────────┘ │
|
|
16
|
+
│ All business logic, tool definitions, data I/O │
|
|
17
|
+
└─────────┼────────────────────────────────────────┘
|
|
18
|
+
│ HTTP (NEXUS_ENDPOINT — cross-env capable)
|
|
19
|
+
┌──────┼──────┐
|
|
20
|
+
▼ ▼ ▼
|
|
21
|
+
MCP-A MCP-B MCP-C
|
|
22
|
+
(Win) (WSL) (VM)
|
|
23
|
+
Stateless protocol adapter, one per IDE
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Core Principles
|
|
27
|
+
|
|
28
|
+
1. **Daemon is the single source of truth** — all reads/writes, business logic, and tool definitions live in the daemon.
|
|
29
|
+
2. **MCP is a stateless protocol adapter** — no tool definitions, no hardcoded names, no local data.
|
|
30
|
+
3. **Daemon decides tool capability** — MCP fetches `GET /api/tools` at startup; any daemon upgrade is immediately visible to all connected MCPs.
|
|
31
|
+
4. **No local fallback** — if the daemon is unreachable, the MCP reports an error and retries every 3 s. No split-brain degradation.
|
|
32
|
+
5. **Plain HTTP between MCP and daemon** — no SSE; AI is request-driven and doesn't need push.
|
|
33
|
+
|
|
34
|
+
### MCP Startup Flow
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
Read NEXUS_ENDPOINT (default: http://127.0.0.1:5688)
|
|
38
|
+
│
|
|
39
|
+
├─ Connect stdio transport → IDE sees MCP as ready
|
|
40
|
+
│
|
|
41
|
+
└─ Background retry loop (every 3 s)
|
|
42
|
+
│
|
|
43
|
+
├─ GET /api/tools fails
|
|
44
|
+
│ → log "[n2n-nexus] Waiting for daemon..."
|
|
45
|
+
│ → keep retrying, do not exit
|
|
46
|
+
│
|
|
47
|
+
└─ GET /api/tools succeeds
|
|
48
|
+
→ cache tool list
|
|
49
|
+
→ send notifications/tools/list_changed
|
|
50
|
+
→ IDE re-fetches: tools appear
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 💾 Data Persistence
|
|
56
|
+
|
|
57
|
+
All data lives under the daemon's storage root (default `~/.n2n-nexus`):
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
~/.n2n-nexus/
|
|
61
|
+
├── global/
|
|
62
|
+
│ ├── blueprint.md # Master strategy document
|
|
63
|
+
│ ├── discussion.json # Global chat (JSON fallback)
|
|
64
|
+
│ ├── docs_index.json # Global docs index
|
|
65
|
+
│ └── docs/ # Shared markdown documents
|
|
66
|
+
├── projects/
|
|
67
|
+
│ └── {project-id}/
|
|
68
|
+
│ ├── manifest.json # Project metadata
|
|
69
|
+
│ ├── internal_blueprint.md # Internal technical docs
|
|
70
|
+
│ └── assets/ # Binary assets (images, PDFs)
|
|
71
|
+
├── meetings/ # Meeting files (JSON fallback mode)
|
|
72
|
+
├── registry.json # Global project index
|
|
73
|
+
└── nexus.db # SQLite database (meetings, tasks, cursors)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**SQLite WAL mode**: Only the daemon process writes to SQLite directly. MCP processes never touch the DB — they go through HTTP, which serializes all writes naturally.
|
|
77
|
+
|
|
78
|
+
**Self-healing**: Core JSON files (`registry.json`, `discussion.json`) are auto-repaired if corrupted or missing.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## 🏷️ Project ID Conventions
|
|
83
|
+
|
|
84
|
+
All project IDs must follow the `[prefix]_[name]` format:
|
|
85
|
+
|
|
86
|
+
| Prefix | Category | Example |
|
|
87
|
+
|--------|----------|---------|
|
|
88
|
+
| `web_` | Websites | `web_datafrog.io` |
|
|
89
|
+
| `api_` | Backend services | `api_user-auth` |
|
|
90
|
+
| `mcp_` | MCP servers | `mcp_nexus` |
|
|
91
|
+
| `lib_` | Libraries / SDKs | `lib_crypto-core` |
|
|
92
|
+
| `chrome_` | Chrome extensions | `chrome_evisa-helper` |
|
|
93
|
+
| `vscode_` | VSCode extensions | `vscode_super-theme` |
|
|
94
|
+
| `android_` | Android apps | `android_client-app` |
|
|
95
|
+
| `ios_` | iOS apps | `ios_client-app` |
|
|
96
|
+
| `flutter_` | Flutter apps | `flutter_unified-app` |
|
|
97
|
+
| `desktop_` | Desktop apps | `desktop_main-hub` |
|
|
98
|
+
| `bot_` | Bots | `bot_auto-moderator` |
|
|
99
|
+
| `infra_` | Infrastructure / DevOps | `infra_k8s-config` |
|
|
100
|
+
| `doc_` | Documentation | `doc_coding-guide` |
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 🌐 Deployment Model
|
|
105
|
+
|
|
106
|
+
One npm package, two commands:
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
n2n-nexus
|
|
110
|
+
│
|
|
111
|
+
├─ n2n-nexus daemon Start once, keep running. Owns all data.
|
|
112
|
+
│
|
|
113
|
+
└─ n2n-nexus mcp IDE starts automatically via npx. Stateless proxy.
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Daemon** (user starts manually):
|
|
117
|
+
```bash
|
|
118
|
+
npx n2n-nexus daemon --port 5688
|
|
119
|
+
# or with explicit root
|
|
120
|
+
npx n2n-nexus daemon --root ~/.n2n-nexus --port 5688
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**MCP** (IDE configuration):
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"mcpServers": {
|
|
127
|
+
"n2n-nexus": {
|
|
128
|
+
"command": "npx",
|
|
129
|
+
"args": ["-y", "n2n-nexus", "mcp"],
|
|
130
|
+
"env": { "NEXUS_ENDPOINT": "http://127.0.0.1:5688" }
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**No required startup order**: start the IDE before the daemon — tools appear automatically once the daemon comes up. Daemon restarts are transparent; MCP reconnects and notifies the IDE.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## 📡 REST API
|
|
141
|
+
|
|
142
|
+
### Tool capability (MCP-facing)
|
|
143
|
+
```
|
|
144
|
+
GET /api/tools Return full tool definition list (JSON Schema)
|
|
145
|
+
POST /api/tools/call Execute tool call { tool, args, instanceId }
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### System
|
|
149
|
+
```
|
|
150
|
+
GET /health Health status + version
|
|
151
|
+
GET /api/storage/info Storage mode and stats
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Session & Projects
|
|
155
|
+
```
|
|
156
|
+
POST /api/session/register
|
|
157
|
+
POST /api/projects/sync
|
|
158
|
+
POST /api/projects/update
|
|
159
|
+
POST /api/projects/rename
|
|
160
|
+
POST /api/projects/delete
|
|
161
|
+
GET /api/projects/search
|
|
162
|
+
GET /api/projects/topology
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Messages & Global
|
|
166
|
+
```
|
|
167
|
+
POST /api/messages/send
|
|
168
|
+
GET /api/messages/unread
|
|
169
|
+
GET /api/global/docs
|
|
170
|
+
GET /api/global/docs/:docId
|
|
171
|
+
POST /api/global/docs/:docId
|
|
172
|
+
POST /api/global/strategy
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Meetings
|
|
176
|
+
```
|
|
177
|
+
POST /api/meetings/start
|
|
178
|
+
POST /api/meetings/end
|
|
179
|
+
POST /api/meetings/archive
|
|
180
|
+
POST /api/meetings/reopen
|
|
181
|
+
GET /api/meetings/:meetingId
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Tasks
|
|
185
|
+
```
|
|
186
|
+
POST /api/tasks
|
|
187
|
+
GET /api/tasks
|
|
188
|
+
GET /api/tasks/:taskId
|
|
189
|
+
POST /api/tasks/:taskId/update
|
|
190
|
+
POST /api/tasks/:taskId/cancel
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Maintenance
|
|
194
|
+
```
|
|
195
|
+
POST /api/maintenance/logs
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Scope Boundaries
|
|
201
|
+
|
|
202
|
+
- No cloud bridge by default.
|
|
203
|
+
- No cross-machine live sync by default — point `NEXUS_ENDPOINT` at a reachable host for that.
|
|
204
|
+
- Single daemon node; no built-in clustering.
|
|
205
|
+
- No authentication layer in the open-source baseline.
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# 架构与标准
|
|
2
|
+
|
|
3
|
+
## 🏛️ 系统架构
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
┌──────────────────────────────────────────────────┐
|
|
7
|
+
│ n2n-nexus daemon │
|
|
8
|
+
│ 独立 HTTP 服务器 · 用户手动启动,持续运行 │
|
|
9
|
+
│ │
|
|
10
|
+
│ ┌──────────────┐ ┌──────────────────────────┐ │
|
|
11
|
+
│ │ REST API │ │ 存储层 │ │
|
|
12
|
+
│ │ /api/tools │ │ SQLite(WAL)+ JSON 文件 │ │
|
|
13
|
+
│ │ /api/tools │ │ │ │
|
|
14
|
+
│ │ /call │ │ 单进程写入,无锁竞争 │ │
|
|
15
|
+
│ └──────┬───────┘ └──────────────────────────┘ │
|
|
16
|
+
│ 全部业务逻辑、工具定义、数据读写均在此处 │
|
|
17
|
+
└─────────┼────────────────────────────────────────┘
|
|
18
|
+
│ HTTP(NEXUS_ENDPOINT — 可跨环境配置)
|
|
19
|
+
┌──────┼──────┐
|
|
20
|
+
▼ ▼ ▼
|
|
21
|
+
MCP-A MCP-B MCP-C
|
|
22
|
+
(Win) (WSL) (VM)
|
|
23
|
+
无状态协议适配器,每个 IDE 一个
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### 核心原则
|
|
27
|
+
|
|
28
|
+
1. **Daemon 是唯一的真相来源** — 所有读写、业务逻辑和工具定义都在 daemon 侧。
|
|
29
|
+
2. **MCP 是无状态协议适配器** — 不含工具定义、不含 hardcode 工具名、不存本地数据。
|
|
30
|
+
3. **Daemon 决定工具能力** — MCP 启动时拉取 `GET /api/tools`;daemon 升级新工具后,所有已连接 MCP 立即获得新能力,无需更新。
|
|
31
|
+
4. **无本地降级** — daemon 不可达时,MCP 每 3 秒重试并报告错误,不做本地 fallback(避免数据分裂)。
|
|
32
|
+
5. **MCP ↔ Daemon 全部走普通 HTTP** — 不使用 SSE;AI 是请求驱动模型,不需要推送。
|
|
33
|
+
|
|
34
|
+
### MCP 启动流程
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
读取 NEXUS_ENDPOINT(默认 http://127.0.0.1:5688)
|
|
38
|
+
│
|
|
39
|
+
├─ 连接 stdio transport → IDE 认为 MCP 已就绪
|
|
40
|
+
│
|
|
41
|
+
└─ 后台重试循环(每 3 秒)
|
|
42
|
+
│
|
|
43
|
+
├─ GET /api/tools 失败
|
|
44
|
+
│ → 打印 "[n2n-nexus] Waiting for daemon..."
|
|
45
|
+
│ → 继续等待,不退出
|
|
46
|
+
│
|
|
47
|
+
└─ GET /api/tools 成功
|
|
48
|
+
→ 缓存工具列表
|
|
49
|
+
→ 发送 notifications/tools/list_changed
|
|
50
|
+
→ IDE 重新拉取,工具出现
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 💾 数据持久化
|
|
56
|
+
|
|
57
|
+
所有数据存储在 daemon 的存储根目录下(默认 `~/.n2n-nexus`):
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
~/.n2n-nexus/
|
|
61
|
+
├── global/
|
|
62
|
+
│ ├── blueprint.md # 主战略文档
|
|
63
|
+
│ ├── discussion.json # 全局聊天(JSON 回退)
|
|
64
|
+
│ ├── docs_index.json # 全局文档索引
|
|
65
|
+
│ └── docs/ # 共享 Markdown 文档
|
|
66
|
+
├── projects/
|
|
67
|
+
│ └── {project-id}/
|
|
68
|
+
│ ├── manifest.json # 项目元数据
|
|
69
|
+
│ ├── internal_blueprint.md # 内部技术文档
|
|
70
|
+
│ └── assets/ # 二进制资产(图片、PDF)
|
|
71
|
+
├── meetings/ # 会议文件(JSON 回退模式)
|
|
72
|
+
├── registry.json # 全局项目索引
|
|
73
|
+
└── nexus.db # SQLite 数据库(会议、任务、游标)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**SQLite WAL 模式**:只有 daemon 进程直接写入 SQLite。MCP 进程通过 HTTP 间接访问,天然串行,无并发冲突。
|
|
77
|
+
|
|
78
|
+
**自我修复**:核心 JSON 文件(`registry.json`、`discussion.json`)在损坏或丢失时自动重建初始状态。
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## 🏷️ 项目 ID 命名规范
|
|
83
|
+
|
|
84
|
+
所有项目 ID 必须遵循 `[prefix]_[name]` 格式:
|
|
85
|
+
|
|
86
|
+
| 前缀 | 分类 | 示例 |
|
|
87
|
+
|------|------|------|
|
|
88
|
+
| `web_` | 网站 | `web_datafrog.io` |
|
|
89
|
+
| `api_` | 后端服务 | `api_user-auth` |
|
|
90
|
+
| `mcp_` | MCP 服务器 | `mcp_nexus` |
|
|
91
|
+
| `lib_` | 库/SDK | `lib_crypto-core` |
|
|
92
|
+
| `chrome_` | Chrome 扩展 | `chrome_evisa-helper` |
|
|
93
|
+
| `vscode_` | VSCode 扩展 | `vscode_super-theme` |
|
|
94
|
+
| `android_` | Android 应用 | `android_client-app` |
|
|
95
|
+
| `ios_` | iOS 应用 | `ios_client-app` |
|
|
96
|
+
| `flutter_` | Flutter 应用 | `flutter_unified-app` |
|
|
97
|
+
| `desktop_` | 桌面应用 | `desktop_main-hub` |
|
|
98
|
+
| `bot_` | 机器人 | `bot_auto-moderator` |
|
|
99
|
+
| `infra_` | 基础设施/DevOps | `infra_k8s-config` |
|
|
100
|
+
| `doc_` | 文档 | `doc_coding-guide` |
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 🌐 发布模型
|
|
105
|
+
|
|
106
|
+
一个 npm 包,两个命令:
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
n2n-nexus
|
|
110
|
+
│
|
|
111
|
+
├─ n2n-nexus daemon 用户手动启动一次,持续运行,持有所有数据。
|
|
112
|
+
│
|
|
113
|
+
└─ n2n-nexus mcp IDE 通过 npx 自动启动,无状态代理。
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Daemon**(用户手动启动):
|
|
117
|
+
```bash
|
|
118
|
+
npx n2n-nexus daemon --port 5688
|
|
119
|
+
# 或显式指定存储路径
|
|
120
|
+
npx n2n-nexus daemon --root ~/.n2n-nexus --port 5688
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**MCP**(IDE 配置):
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"mcpServers": {
|
|
127
|
+
"n2n-nexus": {
|
|
128
|
+
"command": "npx",
|
|
129
|
+
"args": ["-y", "n2n-nexus", "mcp"],
|
|
130
|
+
"env": { "NEXUS_ENDPOINT": "http://127.0.0.1:5688" }
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**无强制启动顺序**:先开 IDE 再启动 daemon 也没问题,工具在 daemon 就绪后自动出现。Daemon 重启对 MCP 透明,自动重连后通知 IDE。
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## 📡 REST API
|
|
141
|
+
|
|
142
|
+
### 工具能力(MCP 对接)
|
|
143
|
+
```
|
|
144
|
+
GET /api/tools 返回完整工具定义列表(JSON Schema)
|
|
145
|
+
POST /api/tools/call 执行工具调用 { tool, args, instanceId }
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 系统
|
|
149
|
+
```
|
|
150
|
+
GET /health 健康状态 + 版本信息
|
|
151
|
+
GET /api/storage/info 存储模式和统计
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 会话与项目
|
|
155
|
+
```
|
|
156
|
+
POST /api/session/register
|
|
157
|
+
POST /api/projects/sync
|
|
158
|
+
POST /api/projects/update
|
|
159
|
+
POST /api/projects/rename
|
|
160
|
+
POST /api/projects/delete
|
|
161
|
+
GET /api/projects/search
|
|
162
|
+
GET /api/projects/topology
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### 消息与全局协作
|
|
166
|
+
```
|
|
167
|
+
POST /api/messages/send
|
|
168
|
+
GET /api/messages/unread
|
|
169
|
+
GET /api/global/docs
|
|
170
|
+
GET /api/global/docs/:docId
|
|
171
|
+
POST /api/global/docs/:docId
|
|
172
|
+
POST /api/global/strategy
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### 会议
|
|
176
|
+
```
|
|
177
|
+
POST /api/meetings/start
|
|
178
|
+
POST /api/meetings/end
|
|
179
|
+
POST /api/meetings/archive
|
|
180
|
+
POST /api/meetings/reopen
|
|
181
|
+
GET /api/meetings/:meetingId
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### 任务
|
|
185
|
+
```
|
|
186
|
+
POST /api/tasks
|
|
187
|
+
GET /api/tasks
|
|
188
|
+
GET /api/tasks/:taskId
|
|
189
|
+
POST /api/tasks/:taskId/update
|
|
190
|
+
POST /api/tasks/:taskId/cancel
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### 维护
|
|
194
|
+
```
|
|
195
|
+
POST /api/maintenance/logs
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## 边界说明
|
|
201
|
+
|
|
202
|
+
- 不默认提供云端桥接。
|
|
203
|
+
- 不默认提供跨机器实时同步——将 `NEXUS_ENDPOINT` 指向可达的主机地址即可实现跨机器访问。
|
|
204
|
+
- 单 daemon 节点,无内置集群能力。
|
|
205
|
+
- 开源基线不包含认证/鉴权层。
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Nexus Assistant Guide
|
|
2
|
+
|
|
3
|
+
你现在是 **n2ns Nexus** 协作网络的一员。Nexus 由一个独立运行的 **daemon** 提供所有能力——你所使用的工具均由 daemon 定义和执行,MCP 只是透明的转发层。
|
|
4
|
+
|
|
5
|
+
> **前提**:在使用任何工具之前,确认 daemon 已启动(`n2n-nexus daemon --port 5688`),你的 MCP 已连接(工具列表非空即为已连接)。
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🚦 核心原则:先发现,再操作
|
|
10
|
+
|
|
11
|
+
### 1. 了解系统全局状态
|
|
12
|
+
|
|
13
|
+
在任何任务开始前,先用以下工具了解环境:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
get_global_topology() → 获取所有项目的摘要列表 + 依赖统计
|
|
17
|
+
get_global_topology(projectId) → 获取特定项目的详细依赖子图
|
|
18
|
+
search_projects(query) → 按名称或描述搜索项目
|
|
19
|
+
read_messages(count) → 获取你尚未读取的消息(增量,自动游标)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### 2. 声明工作上下文
|
|
23
|
+
|
|
24
|
+
在写入任何项目数据前,必须先声明活跃项目:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
register_session_context(projectId) → 绑定当前会话到指定项目
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
项目 ID 格式必须为 `[prefix]_[name]`,例如:`web_datafrog.io`、`api_user-auth`、`mcp_nexus`。
|
|
31
|
+
|
|
32
|
+
### 3. 项目数据写入
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
sync_project_assets(manifest, internalDocs) → [ASYNC] 同步项目全量数据,返回 taskId
|
|
36
|
+
update_project(projectId, patch) → 部分更新 Manifest 字段
|
|
37
|
+
rename_project(oldId, newId) → [ASYNC] 重命名并级联更新所有引用
|
|
38
|
+
upload_project_asset(fileName, base64Content) → 上传二进制文件到项目库
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
异步操作返回 `taskId`,通过 `get_task(taskId)` 轮询进度(`progress` 0.0→1.0)。
|
|
42
|
+
|
|
43
|
+
### 4. 消息与协作
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
send_message(message, category?) → 发消息到活跃会议或全局聊天
|
|
47
|
+
read_messages(count?, meetingId?) → 读取你的未读消息(增量)
|
|
48
|
+
update_global_strategy(content) → 覆盖写入主战略文档
|
|
49
|
+
sync_global_doc(docId, title, content) → 创建/更新跨项目共享文档
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
消息分类(`category`):
|
|
53
|
+
- `CHAT` — 普通讨论(默认)
|
|
54
|
+
- `PROPOSAL` — 提案
|
|
55
|
+
- `DECISION` — 决策/共识
|
|
56
|
+
- `UPDATE` — 进度更新
|
|
57
|
+
- `MEETING_START` — 系统用,无需手动设置
|
|
58
|
+
|
|
59
|
+
### 5. 战术会议
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
start_meeting(topic) → 开启新会议,返回 meetingId
|
|
63
|
+
send_message("...", "PROPOSAL") → 在会议中发言
|
|
64
|
+
send_message("...", "DECISION") → 记录决策
|
|
65
|
+
end_meeting(meetingId?, summary?) → 关闭并锁定会议
|
|
66
|
+
archive_meeting(meetingId) → 存档(只读)
|
|
67
|
+
reopen_meeting(meetingId) → 重新开启
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 6. 后台任务管理
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
create_task(source_meeting_id?, metadata?) → 创建任务,返回 taskId
|
|
74
|
+
get_task(taskId) → 查询状态和进度
|
|
75
|
+
list_tasks(status?) → 列出所有任务
|
|
76
|
+
cancel_task(taskId) → 取消任务
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 7. 维护工具
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
host_maintenance(action, count) → prune 最旧 N 条日志 / clear 全部
|
|
83
|
+
host_delete_project(projectId) → [ASYNC] 永久删除项目(不可逆)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 📋 典型工作流
|
|
89
|
+
|
|
90
|
+
### 首次接入系统
|
|
91
|
+
```
|
|
92
|
+
1. get_global_topology() ← 了解有哪些项目
|
|
93
|
+
2. read_messages(20) ← 了解最近的讨论
|
|
94
|
+
3. register_session_context(id) ← 声明我在哪个项目工作
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 同步项目数据
|
|
98
|
+
```
|
|
99
|
+
1. register_session_context(projectId)
|
|
100
|
+
2. sync_project_assets(manifest, internalDocs) ← 返回 taskId
|
|
101
|
+
3. get_task(taskId) ← 轮询直到 completed
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 发起协作讨论
|
|
105
|
+
```
|
|
106
|
+
1. start_meeting("Topic")
|
|
107
|
+
2. send_message("我的提案...", "PROPOSAL")
|
|
108
|
+
3. read_messages() ← 读取其他实例的回复
|
|
109
|
+
4. send_message("已达成共识", "DECISION")
|
|
110
|
+
5. end_meeting(meetingId, "summary")
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## ⚠️ 注意事项
|
|
116
|
+
|
|
117
|
+
- `read_messages` 是**增量的**:每次调用只返回自上次读取后的新消息,游标由 daemon 自动管理,不需要传 `afterId`。
|
|
118
|
+
- 异步操作(`sync_project_assets`、`rename_project`、`host_delete_project`)立即返回 `taskId`,不阻塞。如需等待完成,轮询 `get_task`。
|
|
119
|
+
- 项目 ID 一旦被其他项目引用(`relations`),重命名会自动级联更新所有引用,不需要手动处理。
|
|
120
|
+
- daemon 重启后,你的 MCP 会自动重连并恢复工具列表,无需重启 IDE。
|