remnote-bridge 0.1.0 → 0.1.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/LICENSE +21 -0
- package/README.md +229 -0
- package/dist/cli/commands/install-skill.js +51 -11
- package/dist/cli/main.js +12 -4
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/instructions.js +57 -20
- package/dist/mcp/resources/separator-flashcard.js +31 -29
- package/package.json +12 -5
- package/{skill → skills/remnote-bridge}/SKILL.md +64 -34
- package/{docs/instruction → skills/remnote-bridge/instructions}/connect.md +24 -0
- package/{docs/instruction → skills/remnote-bridge/instructions}/overall.md +52 -35
- package/dist/cli/commands/connect.d.ts +0 -12
- package/dist/cli/commands/disconnect.d.ts +0 -11
- package/dist/cli/commands/edit-rem.d.ts +0 -13
- package/dist/cli/commands/edit-tree.d.ts +0 -14
- package/dist/cli/commands/health.d.ts +0 -12
- package/dist/cli/commands/install-skill.d.ts +0 -6
- package/dist/cli/commands/read-context.d.ts +0 -20
- package/dist/cli/commands/read-globe.d.ts +0 -16
- package/dist/cli/commands/read-rem.d.ts +0 -16
- package/dist/cli/commands/read-tree.d.ts +0 -17
- package/dist/cli/commands/search.d.ts +0 -12
- package/dist/cli/config.d.ts +0 -55
- package/dist/cli/daemon/daemon.d.ts +0 -11
- package/dist/cli/daemon/dev-server.d.ts +0 -26
- package/dist/cli/daemon/pid.d.ts +0 -34
- package/dist/cli/daemon/send-request.d.ts +0 -24
- package/dist/cli/handlers/context-read-handler.d.ts +0 -18
- package/dist/cli/handlers/edit-handler.d.ts +0 -30
- package/dist/cli/handlers/globe-read-handler.d.ts +0 -17
- package/dist/cli/handlers/read-handler.d.ts +0 -16
- package/dist/cli/handlers/rem-cache.d.ts +0 -19
- package/dist/cli/handlers/tree-edit-handler.d.ts +0 -30
- package/dist/cli/handlers/tree-parser.d.ts +0 -95
- package/dist/cli/handlers/tree-read-handler.d.ts +0 -28
- package/dist/cli/main.d.ts +0 -7
- package/dist/cli/protocol.d.ts +0 -39
- package/dist/cli/server/config-server.d.ts +0 -26
- package/dist/cli/server/ws-server.d.ts +0 -68
- package/dist/cli/utils/output.d.ts +0 -11
- package/dist/mcp/daemon-client.d.ts +0 -31
- package/dist/mcp/index.d.ts +0 -7
- package/dist/mcp/instructions.d.ts +0 -1
- package/dist/mcp/resources/edit-tree-guide.d.ts +0 -1
- package/dist/mcp/resources/error-reference.d.ts +0 -1
- package/dist/mcp/resources/outline-format.d.ts +0 -1
- package/dist/mcp/resources/rem-object-fields.d.ts +0 -1
- package/dist/mcp/resources/separator-flashcard.d.ts +0 -1
- package/dist/mcp/tools/edit-tools.d.ts +0 -5
- package/dist/mcp/tools/infra-tools.d.ts +0 -5
- package/dist/mcp/tools/read-tools.d.ts +0 -5
- package/dist/mcp/types.d.ts +0 -12
- package/remnote-plugin/src/test-scripts/AGENTS.md +0 -46
- package/remnote-plugin/src/test-scripts/test-actions.ts +0 -230
- package/remnote-plugin/src/test-scripts/test-powerup-rendering.ts +0 -722
- package/remnote-plugin/src/test-scripts/test-rem-type-mapping.ts +0 -283
- package/remnote-plugin/src/test-scripts/test-richtext-builder.ts +0 -207
- package/remnote-plugin/src/test-scripts/test-richtext-matrix.ts +0 -332
- package/remnote-plugin/src/test-scripts/test-richtext-remaining.ts +0 -245
- package/remnote-plugin/src/test-scripts/test-rw-fields.ts +0 -399
- /package/{docs/instruction → skills/remnote-bridge/instructions}/disconnect.md +0 -0
- /package/{docs/instruction → skills/remnote-bridge/instructions}/edit-rem.md +0 -0
- /package/{docs/instruction → skills/remnote-bridge/instructions}/edit-tree.md +0 -0
- /package/{docs/instruction → skills/remnote-bridge/instructions}/health.md +0 -0
- /package/{docs/instruction → skills/remnote-bridge/instructions}/read-context.md +0 -0
- /package/{docs/instruction → skills/remnote-bridge/instructions}/read-globe.md +0 -0
- /package/{docs/instruction → skills/remnote-bridge/instructions}/read-rem.md +0 -0
- /package/{docs/instruction → skills/remnote-bridge/instructions}/read-tree.md +0 -0
- /package/{docs/instruction → skills/remnote-bridge/instructions}/search.md +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 remnote-bridge contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# remnote-bridge
|
|
2
|
+
|
|
3
|
+
[中文文档](./README_CN.md)
|
|
4
|
+
|
|
5
|
+
Bridge toolkit that exposes your RemNote knowledge base to AI agents. Single package — CLI, MCP Server, and Plugin all in one.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g remnote-bridge
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Super Quick Start (with AI)
|
|
14
|
+
|
|
15
|
+
One step to connect, then let AI guide you through the rest.
|
|
16
|
+
|
|
17
|
+
### Option A: Install Skill (works with Claude Code, Cursor, Windsurf, and 40+ tools)
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx skills add baobao700508/unofficial-remnote-bridge-cli -s remnote-bridge
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Option B: Configure MCP Server (for any MCP-compatible AI client)
|
|
24
|
+
|
|
25
|
+
Add the following to your AI client's MCP settings:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"mcpServers": {
|
|
30
|
+
"remnote-bridge": {
|
|
31
|
+
"command": "remnote-bridge",
|
|
32
|
+
"args": ["mcp"]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Once connected, the AI will guide you through connecting to RemNote, loading the plugin, and everything else.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# 1. Start the daemon (launches WS server + plugin dev server)
|
|
46
|
+
remnote-bridge connect
|
|
47
|
+
|
|
48
|
+
# 2. Load the plugin in RemNote
|
|
49
|
+
# Open RemNote → Settings → Plugins → Add Local Plugin
|
|
50
|
+
# Enter: http://localhost:8080
|
|
51
|
+
|
|
52
|
+
# 3. Check system status
|
|
53
|
+
remnote-bridge health
|
|
54
|
+
|
|
55
|
+
# 4. Explore your knowledge base
|
|
56
|
+
remnote-bridge read-globe # Global document overview
|
|
57
|
+
remnote-bridge read-context # Current focus in RemNote
|
|
58
|
+
remnote-bridge search "machine learning" # Full-text search
|
|
59
|
+
remnote-bridge read-tree <remId> # Expand a subtree
|
|
60
|
+
remnote-bridge read-rem <remId> # Read Rem properties
|
|
61
|
+
|
|
62
|
+
# 5. Edit content
|
|
63
|
+
remnote-bridge edit-rem <remId> --old-str '"concept"' --new-str '"descriptor"'
|
|
64
|
+
remnote-bridge edit-tree <remId> --old-str ' old line <!--id-->' --new-str ' new line\n old line <!--id-->'
|
|
65
|
+
|
|
66
|
+
# 6. Stop the daemon
|
|
67
|
+
remnote-bridge disconnect
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Commands
|
|
71
|
+
|
|
72
|
+
### Infrastructure
|
|
73
|
+
|
|
74
|
+
| Command | Description |
|
|
75
|
+
|:--------|:------------|
|
|
76
|
+
| `connect` | Start the daemon process (WS server + plugin dev server) |
|
|
77
|
+
| `health` | Check daemon, Plugin, and SDK status |
|
|
78
|
+
| `disconnect` | Stop the daemon and release resources |
|
|
79
|
+
|
|
80
|
+
### Read
|
|
81
|
+
|
|
82
|
+
| Command | Description | Caches |
|
|
83
|
+
|:--------|:------------|:-------|
|
|
84
|
+
| `read-globe` | Global document-level overview | No |
|
|
85
|
+
| `read-context` | Current focus/page context view | No |
|
|
86
|
+
| `read-tree <remId>` | Subtree as Markdown outline | Yes |
|
|
87
|
+
| `read-rem <remId>` | Single Rem's full JSON properties | Yes |
|
|
88
|
+
| `search <query>` | Full-text search | No |
|
|
89
|
+
|
|
90
|
+
### Write
|
|
91
|
+
|
|
92
|
+
| Command | Description | Prerequisite |
|
|
93
|
+
|:--------|:------------|:-------------|
|
|
94
|
+
| `edit-rem <remId>` | Edit Rem JSON fields via str_replace | `read-rem` first |
|
|
95
|
+
| `edit-tree <remId>` | Edit tree structure via str_replace | `read-tree` first |
|
|
96
|
+
|
|
97
|
+
### Utilities
|
|
98
|
+
|
|
99
|
+
| Command | Description |
|
|
100
|
+
|:--------|:------------|
|
|
101
|
+
| `mcp` | Start the MCP Server (stdio transport) |
|
|
102
|
+
| `install skill` | Install AI agent skill (via [Vercel Skills](https://github.com/vercel-labs/skills)) |
|
|
103
|
+
|
|
104
|
+
## MCP Server
|
|
105
|
+
|
|
106
|
+
Use `remnote-bridge mcp` as an MCP server for AI clients:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"mcpServers": {
|
|
111
|
+
"remnote-bridge": {
|
|
112
|
+
"command": "remnote-bridge",
|
|
113
|
+
"args": ["mcp"]
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The MCP server exposes all CLI commands as tools, plus documentation resources.
|
|
120
|
+
|
|
121
|
+
## AI Agent Skill
|
|
122
|
+
|
|
123
|
+
The Skill provides detailed instructions (SKILL.md + 11 command docs) that teach AI agents how to use remnote-bridge — including command selection, workflows, safety rules, and flashcard operations.
|
|
124
|
+
|
|
125
|
+
### Install via Vercel Skills (recommended)
|
|
126
|
+
|
|
127
|
+
Powered by the [Vercel Skills](https://github.com/vercel-labs/skills) ecosystem. Supports **40+ AI coding tools** including Claude Code, Cursor, Windsurf, GitHub Copilot, Cline, and more.
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Direct — interactive agent selection
|
|
131
|
+
npx skills add baobao700508/unofficial-remnote-bridge-cli -s remnote-bridge
|
|
132
|
+
|
|
133
|
+
# Or through the built-in wrapper (same interactive experience)
|
|
134
|
+
remnote-bridge install skill
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
The interactive installer will detect your installed AI tools and let you choose which ones to install the skill for.
|
|
138
|
+
|
|
139
|
+
### Fallback: Claude Code only
|
|
140
|
+
|
|
141
|
+
If `npx` is not available, or you prefer manual installation:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
remnote-bridge install skill --copy
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
This copies the skill files directly to `~/.claude/skills/remnote-bridge/`.
|
|
148
|
+
|
|
149
|
+
### What gets installed
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
<agent-skills-dir>/remnote-bridge/
|
|
153
|
+
├── SKILL.md # Core skill — command decisions, workflows, safety rules
|
|
154
|
+
└── instructions/ # Detailed per-command documentation
|
|
155
|
+
├── overall.md # Global overview
|
|
156
|
+
├── connect.md # connect command
|
|
157
|
+
├── read-tree.md # read-tree command
|
|
158
|
+
├── edit-tree.md # edit-tree command
|
|
159
|
+
└── ... # 8 more command docs
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## JSON Mode
|
|
163
|
+
|
|
164
|
+
All commands support `--json` for programmatic usage. In JSON mode, both input and output are JSON:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# Input: all parameters packed in a JSON string
|
|
168
|
+
remnote-bridge --json read-rem '{"remId":"abc123","fields":["text","type"]}'
|
|
169
|
+
|
|
170
|
+
# Output: single-line JSON
|
|
171
|
+
# {"ok":true,"command":"read-rem","timestamp":"...","data":{...}}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Architecture
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
AI Agent (Claude Code / MCP Client)
|
|
178
|
+
↕ CLI commands (stateless short processes)
|
|
179
|
+
remnote-bridge CLI
|
|
180
|
+
↕ WebSocket IPC
|
|
181
|
+
Daemon (long-lived process: WS server + handlers + cache)
|
|
182
|
+
↕ WebSocket
|
|
183
|
+
remnote-plugin (runs inside RemNote browser)
|
|
184
|
+
↕
|
|
185
|
+
RemNote SDK → Knowledge Base
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
- **CLI commands** are stateless — each invocation is an independent OS process
|
|
189
|
+
- **Daemon** holds state: cache, WS connections, timeout timer
|
|
190
|
+
- **Plugin** runs in the browser, calls RemNote SDK on behalf of the daemon
|
|
191
|
+
- **Three safety guards** protect edits: cache existence check, optimistic concurrency detection, str_replace exact match
|
|
192
|
+
|
|
193
|
+
## Configuration
|
|
194
|
+
|
|
195
|
+
Optional config file: `.remnote-bridge.json` in project root.
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"wsPort": 3002,
|
|
200
|
+
"devServerPort": 8080,
|
|
201
|
+
"configPort": 3003,
|
|
202
|
+
"daemonTimeoutMinutes": 30,
|
|
203
|
+
"defaults": {
|
|
204
|
+
"maxNodes": 200,
|
|
205
|
+
"maxSiblings": 20,
|
|
206
|
+
"readTreeDepth": 3
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
All values have sensible defaults — the config file is not required.
|
|
212
|
+
|
|
213
|
+
## Acknowledgements
|
|
214
|
+
|
|
215
|
+
This project was inspired by and learned from:
|
|
216
|
+
|
|
217
|
+
- [remnote-mcp-bridge](https://github.com/quentintou/remnote-mcp-bridge) by [@quentintou](https://github.com/quentintou) — The original MCP bridge connecting RemNote to AI assistants. Pioneered the idea of bridging RemNote SDK to external tools via MCP.
|
|
218
|
+
- [remnote-mcp-bridge (fork)](https://github.com/robert7/remnote-mcp-bridge) by [@robert7](https://github.com/robert7) — Extended the original with a generic, extensible WebSocket bridge architecture. Its Plugin ↔ WebSocket ↔ CLI layered design gave us valuable architectural insights.
|
|
219
|
+
|
|
220
|
+
## Roadmap
|
|
221
|
+
|
|
222
|
+
- **MCP tool decomposition** — Break the current 1:1 CLI-to-MCP mapping into finer-grained tools, giving AI agents more flexible and composable operations
|
|
223
|
+
- **Improved agent instructions** — Refine Skill documentation and MCP server instructions for better AI agent comprehension
|
|
224
|
+
- **RAG-powered search** — Research RemNote's local database structure to enable retrieval-augmented search, replacing the current SDK-based full-text search with more efficient semantic retrieval
|
|
225
|
+
- **Multi-language support** — Internationalization for broader accessibility
|
|
226
|
+
|
|
227
|
+
## License
|
|
228
|
+
|
|
229
|
+
MIT
|
|
@@ -1,16 +1,57 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* install skill 命令
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* 薄层封装 Vercel Skills CLI(npx skills add),利用其交互式选择让用户适配不同 AI 编程工具。
|
|
5
|
+
* npx 不可用时 fallback 到直接复制(仅 Claude Code)。
|
|
5
6
|
*/
|
|
6
7
|
import fs from 'fs';
|
|
7
8
|
import path from 'path';
|
|
8
9
|
import os from 'os';
|
|
10
|
+
import { spawn, execSync } from 'child_process';
|
|
11
|
+
const GITHUB_REPO = 'baobao700508/unofficial-remnote-bridge-cli';
|
|
12
|
+
const SKILL_NAME = 'remnote-bridge';
|
|
9
13
|
export async function installSkillCommand() {
|
|
14
|
+
// 检测 npx 是否可用
|
|
15
|
+
let hasNpx = false;
|
|
16
|
+
try {
|
|
17
|
+
execSync('npx --version', { stdio: 'pipe', timeout: 5000 });
|
|
18
|
+
hasNpx = true;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// npx 不可用
|
|
22
|
+
}
|
|
23
|
+
if (!hasNpx) {
|
|
24
|
+
console.log('未检测到 npx,使用内置方式安装到 Claude Code...\n');
|
|
25
|
+
copySkillFiles();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
// 直接调用 npx skills add,继承 stdio 让用户看到交互式选择界面
|
|
29
|
+
console.log(`通过 Vercel Skills CLI 安装 ${SKILL_NAME}...\n`);
|
|
30
|
+
const child = spawn('npx', ['skills', 'add', GITHUB_REPO, '-s', SKILL_NAME], {
|
|
31
|
+
stdio: 'inherit',
|
|
32
|
+
shell: true,
|
|
33
|
+
});
|
|
34
|
+
await new Promise((resolve) => {
|
|
35
|
+
child.on('close', (code) => {
|
|
36
|
+
if (code !== 0) {
|
|
37
|
+
console.log(`\nVercel Skills CLI 退出码: ${code}`);
|
|
38
|
+
console.log('如需使用内置方式安装(仅 Claude Code),请运行:');
|
|
39
|
+
console.log(' remnote-bridge install skill --copy\n');
|
|
40
|
+
process.exitCode = 1;
|
|
41
|
+
}
|
|
42
|
+
resolve();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export async function installSkillCopyCommand() {
|
|
47
|
+
copySkillFiles();
|
|
48
|
+
}
|
|
49
|
+
function copySkillFiles() {
|
|
10
50
|
// 从包安装路径计算包根(dist/cli/commands/install-skill.js → 包根)
|
|
11
51
|
const packageRoot = path.resolve(import.meta.dirname, '..', '..', '..');
|
|
12
|
-
const
|
|
13
|
-
const
|
|
52
|
+
const skillDir = path.join(packageRoot, 'skills', 'remnote-bridge');
|
|
53
|
+
const skillSource = path.join(skillDir, 'SKILL.md');
|
|
54
|
+
const instructionDir = path.join(skillDir, 'instructions');
|
|
14
55
|
if (!fs.existsSync(skillSource)) {
|
|
15
56
|
console.error(`错误: 找不到 SKILL.md: ${skillSource}`);
|
|
16
57
|
process.exitCode = 1;
|
|
@@ -19,15 +60,12 @@ export async function installSkillCommand() {
|
|
|
19
60
|
// 目标目录
|
|
20
61
|
const targetDir = path.join(os.homedir(), '.claude', 'skills', 'remnote-bridge');
|
|
21
62
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
22
|
-
// 复制 SKILL.md
|
|
23
|
-
|
|
24
|
-
const targetInstructionDir = path.join(targetDir, 'instruction');
|
|
25
|
-
// 替换相对路径 docs/instruction/ 为安装后的绝对路径
|
|
26
|
-
skillContent = skillContent.replace(/docs\/instruction\//g, targetInstructionDir + '/');
|
|
27
|
-
fs.writeFileSync(path.join(targetDir, 'SKILL.md'), skillContent, 'utf-8');
|
|
63
|
+
// 复制 SKILL.md
|
|
64
|
+
fs.copyFileSync(skillSource, path.join(targetDir, 'SKILL.md'));
|
|
28
65
|
console.log(` SKILL.md → ${targetDir}/SKILL.md`);
|
|
29
|
-
// 复制
|
|
66
|
+
// 复制 instructions/*.md
|
|
30
67
|
if (fs.existsSync(instructionDir)) {
|
|
68
|
+
const targetInstructionDir = path.join(targetDir, 'instructions');
|
|
31
69
|
fs.mkdirSync(targetInstructionDir, { recursive: true });
|
|
32
70
|
const files = fs.readdirSync(instructionDir).filter(f => f.endsWith('.md'));
|
|
33
71
|
for (const file of files) {
|
|
@@ -35,5 +73,7 @@ export async function installSkillCommand() {
|
|
|
35
73
|
console.log(` ${file} → ${targetInstructionDir}/${file}`);
|
|
36
74
|
}
|
|
37
75
|
}
|
|
38
|
-
console.log(`\nSkill 已安装到 ${targetDir}
|
|
76
|
+
console.log(`\nSkill 已安装到 ${targetDir}(仅 Claude Code)`);
|
|
77
|
+
console.log('如需安装到其他 AI 工具,请运行:');
|
|
78
|
+
console.log(` npx skills add ${GITHUB_REPO} -s ${SKILL_NAME}\n`);
|
|
39
79
|
}
|
package/dist/cli/main.js
CHANGED
|
@@ -15,7 +15,7 @@ import { editTreeCommand } from './commands/edit-tree.js';
|
|
|
15
15
|
import { readGlobeCommand } from './commands/read-globe.js';
|
|
16
16
|
import { readContextCommand } from './commands/read-context.js';
|
|
17
17
|
import { searchCommand } from './commands/search.js';
|
|
18
|
-
import { installSkillCommand } from './commands/install-skill.js';
|
|
18
|
+
import { installSkillCommand, installSkillCopyCommand } from './commands/install-skill.js';
|
|
19
19
|
const program = new Command();
|
|
20
20
|
/**
|
|
21
21
|
* --json 模式下解析 JSON 输入参数。
|
|
@@ -53,7 +53,7 @@ function parseJsonInput(command, jsonStr, requiredFields = []) {
|
|
|
53
53
|
program
|
|
54
54
|
.name('remnote-bridge')
|
|
55
55
|
.description('RemNote Bridge — CLI + MCP Server + Plugin')
|
|
56
|
-
.version('0.1.
|
|
56
|
+
.version('0.1.2')
|
|
57
57
|
.option('--json', '以 JSON 格式输出(适用于程序化调用)');
|
|
58
58
|
program
|
|
59
59
|
.command('connect')
|
|
@@ -295,6 +295,14 @@ program.command('mcp')
|
|
|
295
295
|
// install 子命令组
|
|
296
296
|
const installCmd = program.command('install').description('安装组件');
|
|
297
297
|
installCmd.command('skill')
|
|
298
|
-
.description('安装 Skill
|
|
299
|
-
.
|
|
298
|
+
.description('安装 Skill(推荐使用 npx skills add,或 --copy 直接复制)')
|
|
299
|
+
.option('--copy', '直接复制到 ~/.claude/skills/(不使用 Vercel Skills CLI)')
|
|
300
|
+
.action(async (opts) => {
|
|
301
|
+
if (opts.copy) {
|
|
302
|
+
await installSkillCopyCommand();
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
await installSkillCommand();
|
|
306
|
+
}
|
|
307
|
+
});
|
|
300
308
|
program.parse();
|
package/dist/mcp/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import { SEPARATOR_FLASHCARD_CONTENT } from './resources/separator-flashcard.js'
|
|
|
17
17
|
export async function startMcpServer() {
|
|
18
18
|
const server = new FastMCP({
|
|
19
19
|
name: 'remnote-bridge',
|
|
20
|
-
version: '0.1.
|
|
20
|
+
version: '0.1.2',
|
|
21
21
|
instructions: SERVER_INSTRUCTIONS,
|
|
22
22
|
});
|
|
23
23
|
registerInfraTools(server);
|
package/dist/mcp/instructions.js
CHANGED
|
@@ -29,21 +29,31 @@ Rem 有两个独立维度:**type**(闪卡语义)和 **isDocument**(页
|
|
|
29
29
|
| \\\`default\\\` | 普通 Rem | 正常字重 |
|
|
30
30
|
| \\\`portal\\\` | 嵌入引用容器 | 紫色边框(**只读**,不可设置) |
|
|
31
31
|
|
|
32
|
-
###
|
|
32
|
+
### 闪卡的 CLI 操作方式
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
闪卡由 Rem 的 \\\`type\\\`、\\\`backText\\\`、\\\`practiceDirection\\\` 三个字段控制。通过 CLI 创建/修改闪卡,操作的是这些**字段**,而非分隔符。
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|:-------|:-----|:-----|
|
|
38
|
-
| \\\`::\\\` | concept | 概念定义(双向) |
|
|
39
|
-
| \\\`;;\\\` | descriptor | 描述属性(正向) |
|
|
40
|
-
| \\\`>>\\\` | default | 正向问答 |
|
|
41
|
-
| \\\`<<\\\` | default | 反向问答 |
|
|
42
|
-
| \\\`<>\\\` | default | 双向问答 |
|
|
43
|
-
| \\\`>>>\\\` | default | 多行答案(子 Rem 为答案) |
|
|
44
|
-
| \\\`{{}}\\\` | default | 完形填空 |
|
|
36
|
+
**禁止**:在文本中插入分隔符(\\\`::\\\`、\\\`;;\\\`、\\\`>>\\\` 等)来创建闪卡。分隔符是 RemNote 编辑器的输入语法,CLI 无法识别。
|
|
45
37
|
|
|
46
|
-
|
|
38
|
+
| 闪卡操作 | CLI 方法 |
|
|
39
|
+
|:---------|:---------|
|
|
40
|
+
| 创建概念定义 | \\\`edit_tree\\\` 新增行 \\\`概念 ↔ 定义\\\`,再 \\\`edit_rem\\\` 设 \\\`type: "concept"\\\` |
|
|
41
|
+
| 创建正向问答 | \\\`edit_tree\\\` 新增行 \\\`问题 → 答案\\\` |
|
|
42
|
+
| 创建多行答案 | \\\`edit_tree\\\` 新增行 \\\`问题 ↓\\\`(子行自动成为答案) |
|
|
43
|
+
| 改变闪卡类型 | \\\`edit_rem\\\` 修改 \\\`type\\\`、\\\`backText\\\`、\\\`practiceDirection\\\` |
|
|
44
|
+
|
|
45
|
+
### 理解用户意图:分隔符映射
|
|
46
|
+
|
|
47
|
+
用户在 RemNote 编辑器中通过分隔符创建闪卡。当用户提到这些分隔符时,你需要理解其意图并映射到 CLI 操作:
|
|
48
|
+
|
|
49
|
+
| 用户说 / 编辑器分隔符 | 对应的 type | 对应的 practiceDirection |
|
|
50
|
+
|:----------------------|:-----------|:-----------------------|
|
|
51
|
+
| \\\`::\\\` | concept | both |
|
|
52
|
+
| \\\`;;\\\` | descriptor | forward |
|
|
53
|
+
| \\\`>>\\\` / \\\`<<\\\` / \\\`<>\\\` | default | forward / backward / both |
|
|
54
|
+
| \\\`>>>\\\` / \\\`::>\\\` / \\\`;;>\\\` | default / concept / descriptor | forward / both / forward(多行) |
|
|
55
|
+
|
|
56
|
+
完整映射表见 \\\`resource://separator-flashcard\\\`。
|
|
47
57
|
|
|
48
58
|
### 链接机制
|
|
49
59
|
|
|
@@ -66,6 +76,8 @@ RemNote 的格式设置(标题、高亮、代码等)会注入隐藏的系统
|
|
|
66
76
|
\\\`\\\`\\\`
|
|
67
77
|
connect → 启动 daemon(幂等,重复调用安全)
|
|
68
78
|
↓
|
|
79
|
+
⚠️ 用户操作:确保 RemNote 中已加载插件(见下方说明)
|
|
80
|
+
↓
|
|
69
81
|
health → 确认三层就绪(daemon / Plugin / SDK)
|
|
70
82
|
↓
|
|
71
83
|
业务操作(read / search / edit)
|
|
@@ -79,6 +91,25 @@ disconnect → 关闭 daemon,清空所有缓存
|
|
|
79
91
|
- \\\`disconnect\\\` 会销毁所有缓存,之前的 read 结果全部失效
|
|
80
92
|
- daemon 默认 30 分钟无活动自动关闭
|
|
81
93
|
|
|
94
|
+
### ⚠️ connect 后需要用户配合(重要)
|
|
95
|
+
|
|
96
|
+
\\\`connect\\\` 成功只意味着 daemon 和 webpack-dev-server 已启动,**Plugin 并未自动连接**。用户必须在 RemNote 中完成以下操作,Plugin 才能连接到 daemon:
|
|
97
|
+
|
|
98
|
+
**首次使用**(RemNote 从未加载过此插件):
|
|
99
|
+
1. 打开 RemNote 桌面端或网页端
|
|
100
|
+
2. 点击左侧边栏底部的插件图标(拼图形状)
|
|
101
|
+
3. 点击「开发你的插件」(Develop Your Plugin)
|
|
102
|
+
4. 在输入框中填入 \\\`http://localhost:8080\\\`(即 connect 输出的 webpack-dev-server 地址)
|
|
103
|
+
5. 等待插件加载完成
|
|
104
|
+
|
|
105
|
+
**非首次使用**(之前已加载过此插件):
|
|
106
|
+
- 只需**刷新 RemNote 页面**即可(浏览器 F5 或 Cmd+R),插件会自动重新连接
|
|
107
|
+
|
|
108
|
+
**你必须这样做**:
|
|
109
|
+
1. 执行 \\\`connect\\\` 后,**立即告知用户需要完成上述操作**
|
|
110
|
+
2. **不要在 connect 后直接调用业务命令**——此时 Plugin 尚未连接,命令会失败
|
|
111
|
+
3. 引导用户完成操作后,用 \\\`health\\\` 确认三层就绪,再执行业务命令
|
|
112
|
+
|
|
82
113
|
---
|
|
83
114
|
|
|
84
115
|
## 3. Common Scenarios
|
|
@@ -136,26 +167,32 @@ str_replace 操作的是格式化 JSON 文本(2 空格缩进)。oldStr 要
|
|
|
136
167
|
|
|
137
168
|
**红线**:edit_tree **禁止修改已有行的文字内容**——改内容必须用 edit_rem。edit_tree 只做结构操作。
|
|
138
169
|
|
|
139
|
-
### 场景 F
|
|
170
|
+
### 场景 F:创建 / 修改闪卡
|
|
140
171
|
|
|
141
|
-
> 用户说:"创建一个概念定义"、"做个正向问答卡"
|
|
172
|
+
> 用户说:"创建一个概念定义"、"做个正向问答卡"、"把这个改成 concept"
|
|
142
173
|
|
|
143
|
-
|
|
174
|
+
闪卡由 \\\`type\\\`、\\\`backText\\\`、\\\`practiceDirection\\\` 三个字段控制。操作方式:
|
|
144
175
|
|
|
145
|
-
|
|
176
|
+
**创建新闪卡**(\\\`edit_tree\\\` 新增行 + 箭头):
|
|
146
177
|
- 正向问答:\\\`问题 → 答案\\\`
|
|
147
|
-
- 多行答案:\\\`问题 ↓\\\`(子行自动成为答案)
|
|
148
178
|
- 双向问答:\\\`问题 ↔ 答案\\\`
|
|
179
|
+
- 多行答案:\\\`问题 ↓\\\`(子行自动成为答案)
|
|
180
|
+
- 概念定义:\\\`概念 ↔ 定义\\\`,再用 \\\`edit_rem\\\` 设 \\\`type: "concept"\\\`
|
|
181
|
+
|
|
182
|
+
**修改现有 Rem 的闪卡行为**(\\\`read_rem\\\` → \\\`edit_rem\\\`):
|
|
183
|
+
- 改类型:修改 \\\`type\\\` 字段(\\\`"default"\\\` → \\\`"concept"\\\`)
|
|
184
|
+
- 改方向:修改 \\\`practiceDirection\\\`(\\\`"forward"\\\` / \\\`"backward"\\\` / \\\`"both"\\\` / \\\`"none"\\\`)
|
|
185
|
+
- 加/改背面:修改 \\\`backText\\\` 字段
|
|
149
186
|
|
|
150
|
-
|
|
187
|
+
**禁止**:在文本内容中插入 \\\`::\\\`、\\\`;;\\\`、\\\`>>\\\` 等分隔符——这些是 RemNote 编辑器语法,CLI 不识别。
|
|
151
188
|
|
|
152
189
|
### 场景 G:排查连接问题
|
|
153
190
|
|
|
154
191
|
> 用户说:"连不上"、"命令报错了"
|
|
155
192
|
|
|
156
193
|
使用 \\\`health\\\` 检查三层状态,然后对症处理:
|
|
157
|
-
- daemon 未运行 → 执行 \\\`connect
|
|
158
|
-
- Plugin 未连接 →
|
|
194
|
+
- daemon 未运行 → 执行 \\\`connect\\\`,然后引导用户在 RemNote 中加载插件
|
|
195
|
+
- Plugin 未连接 → 提醒用户:首次使用需在 RemNote 的「开发你的插件」中填入 \\\`http://localhost:8080\\\`;非首次使用只需刷新 RemNote 页面
|
|
159
196
|
- SDK 未就绪 → 等待几秒后重试 health
|
|
160
197
|
|
|
161
198
|
---
|
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
export const SEPARATOR_FLASHCARD_CONTENT = `
|
|
2
2
|
# Separator & Flashcard Reference
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
**重要**:分隔符(\\\`::\\\`、\\\`;;\\\`、\\\`>>\\\` 等)是 RemNote 编辑器的输入语法,**CLI 不使用分隔符**。通过 CLI 创建/修改闪卡,操作的是 \\\`type\\\`、\\\`backText\\\`、\\\`practiceDirection\\\` 字段和大纲箭头(\\\`→←↔↓↑↕\\\`)。本参考表用于理解用户意图——当用户提到分隔符时,映射到对应的 CLI 操作。
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
##
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
|
13
|
-
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
|
8
|
+
## 1. 用户意图映射:编辑器分隔符 → CLI 操作
|
|
9
|
+
|
|
10
|
+
当用户提到以下分隔符时,对应的 Rem 属性为:
|
|
11
|
+
|
|
12
|
+
| 编辑器分隔符 | 用户输入示例 | type | backText | 默认 practiceDirection |
|
|
13
|
+
|:-------------|:-------------|:-----|:---------|:-----------------------|
|
|
14
|
+
| (无) | \\\`普通文本\\\` | \\\`default\\\` | \\\`null\\\` | — |
|
|
15
|
+
| \\\`::\\\` | \\\`概念 :: 定义\\\` | \\\`concept\\\` | 后半部分 | \\\`both\\\` |
|
|
16
|
+
| \\\`;;\\\` | \\\`属性 ;; 值\\\` | \\\`descriptor\\\` | 后半部分 | \\\`forward\\\` |
|
|
17
|
+
| \\\`>>\\\` | \\\`问题 >> 答案\\\` | \\\`default\\\` | 后半部分 | \\\`forward\\\` |
|
|
18
|
+
| \\\`<<\\\` | \\\`问题 << 答案\\\` | \\\`default\\\` | 后半部分 | \\\`backward\\\` |
|
|
19
|
+
| \\\`<>\\\` | \\\`问题 <> 答案\\\` | \\\`default\\\` | 后半部分 | \\\`both\\\` |
|
|
20
|
+
| \\\`>>>\\\` | \\\`问题 >>>\\\` | \\\`default\\\` | \\\`null\\\` | \\\`forward\\\`(多行) |
|
|
21
|
+
| \\\`::>\\\` | \\\`概念 ::>\\\` | \\\`concept\\\` | \\\`null\\\` | \\\`both\\\`(多行) |
|
|
22
|
+
| \\\`;;>\\\` | \\\`属性 ;;>\\\` | \\\`descriptor\\\` | \\\`null\\\` | \\\`forward\\\`(多行) |
|
|
23
|
+
| \\\`{{}}\\\` | \\\`The {{capital}} of France\\\` | \\\`default\\\` | \\\`null\\\` | \\\`forward\\\`(完形填空) |
|
|
22
24
|
|
|
23
25
|
---
|
|
24
26
|
|
|
25
|
-
##
|
|
27
|
+
## 2. CLI 操作方式:大纲箭头
|
|
26
28
|
|
|
27
|
-
在 Markdown 大纲(read_tree / edit_tree
|
|
29
|
+
在 Markdown 大纲(read_tree / edit_tree)中,practiceDirection 编码为 Unicode 箭头:
|
|
28
30
|
|
|
29
31
|
### 单行箭头(有 backText)
|
|
30
32
|
|
|
@@ -46,7 +48,7 @@ export const SEPARATOR_FLASHCARD_CONTENT = `
|
|
|
46
48
|
|
|
47
49
|
---
|
|
48
50
|
|
|
49
|
-
## practiceDirection 取值
|
|
51
|
+
## 3. practiceDirection 取值
|
|
50
52
|
|
|
51
53
|
| 值 | 含义 | 闪卡生成 |
|
|
52
54
|
|:---|:-----|:---------|
|
|
@@ -57,28 +59,28 @@ export const SEPARATOR_FLASHCARD_CONTENT = `
|
|
|
57
59
|
|
|
58
60
|
---
|
|
59
61
|
|
|
60
|
-
## CDF(Concept-Descriptor Framework)
|
|
62
|
+
## 4. CDF(Concept-Descriptor Framework)
|
|
61
63
|
|
|
62
64
|
RemNote 推荐的知识结构化方法:
|
|
63
65
|
|
|
64
|
-
- **Concept
|
|
65
|
-
- **Descriptor
|
|
66
|
+
- **Concept**(type:concept):需要理解的核心概念——"X 是什么?"
|
|
67
|
+
- **Descriptor**(type:descriptor):概念的属性/描述——"X 的 Y 是什么?"
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
在 CLI 大纲中的表现(注意:用箭头和元数据标记,不用分隔符):
|
|
68
70
|
|
|
69
71
|
\\\`\\\`\\\`
|
|
70
|
-
线性回归
|
|
71
|
-
假设
|
|
72
|
-
损失函数
|
|
72
|
+
线性回归 ↔ 最基本的回归模型 <!--id1 type:concept-->
|
|
73
|
+
假设 → 因变量与自变量呈线性关系 <!--id2 type:descriptor-->
|
|
74
|
+
损失函数 → 均方误差 (MSE) <!--id3 type:descriptor-->
|
|
73
75
|
\\\`\\\`\\\`
|
|
74
76
|
|
|
75
77
|
---
|
|
76
78
|
|
|
77
|
-
## 通过 CLI 创建闪卡
|
|
79
|
+
## 5. 通过 CLI 创建闪卡
|
|
78
80
|
|
|
79
81
|
### 使用 edit_tree 新增行
|
|
80
82
|
|
|
81
|
-
|
|
83
|
+
通过箭头创建(**禁止在文本中插入 \\\`::\\\`、\\\`;;\\\`、\\\`>>\\\` 等编辑器分隔符**):
|
|
82
84
|
|
|
83
85
|
| 要创建的闪卡类型 | edit_tree 新增行格式 | 额外步骤 |
|
|
84
86
|
|:-----------------|:--------------------|:---------|
|
|
@@ -90,7 +92,7 @@ RemNote 推荐的知识结构化方法:
|
|
|
90
92
|
| 多行正向 | \\\`问题 ↓\\\`(子行为答案) | — |
|
|
91
93
|
| 多行双向 | \\\`问题 ↕\\\`(子行为答案) | — |
|
|
92
94
|
|
|
93
|
-
### 使用 edit_rem
|
|
95
|
+
### 使用 edit_rem 修改现有 Rem 的闪卡行为
|
|
94
96
|
|
|
95
97
|
修改闪卡行为的相关字段:
|
|
96
98
|
|
|
@@ -104,7 +106,7 @@ RemNote 推荐的知识结构化方法:
|
|
|
104
106
|
|
|
105
107
|
---
|
|
106
108
|
|
|
107
|
-
## 完形填空(Cloze)
|
|
109
|
+
## 6. 完形填空(Cloze)
|
|
108
110
|
|
|
109
111
|
完形填空通过 RichText 中的 \\\`cId\\\` 标记实现:
|
|
110
112
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remnote-bridge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "RemNote 自动化桥接工具集:CLI + MCP Server + Plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -8,16 +8,22 @@
|
|
|
8
8
|
"unofficial-remnote-bridge": "./dist/cli/main.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
|
-
"dist
|
|
12
|
-
"remnote-plugin/src/",
|
|
11
|
+
"dist/**/*.js",
|
|
12
|
+
"remnote-plugin/src/bridge/",
|
|
13
|
+
"remnote-plugin/src/services/",
|
|
14
|
+
"remnote-plugin/src/utils/",
|
|
15
|
+
"remnote-plugin/src/widgets/",
|
|
16
|
+
"remnote-plugin/src/index.css",
|
|
17
|
+
"remnote-plugin/src/style.css",
|
|
18
|
+
"remnote-plugin/src/settings.ts",
|
|
19
|
+
"remnote-plugin/src/types.ts",
|
|
13
20
|
"remnote-plugin/public/",
|
|
14
21
|
"remnote-plugin/package.json",
|
|
15
22
|
"remnote-plugin/postcss.config.js",
|
|
16
23
|
"remnote-plugin/tailwind.config.js",
|
|
17
24
|
"remnote-plugin/webpack.config.js",
|
|
18
25
|
"remnote-plugin/tsconfig.json",
|
|
19
|
-
"
|
|
20
|
-
"docs/instruction/"
|
|
26
|
+
"skills/"
|
|
21
27
|
],
|
|
22
28
|
"scripts": {
|
|
23
29
|
"build": "tsc",
|
|
@@ -31,6 +37,7 @@
|
|
|
31
37
|
"fastmcp": "latest",
|
|
32
38
|
"zod": "^3.23.0"
|
|
33
39
|
},
|
|
40
|
+
"license": "MIT",
|
|
34
41
|
"devDependencies": {
|
|
35
42
|
"typescript": "^5.4.0",
|
|
36
43
|
"tsx": "^4.7.0",
|