remnote-bridge 0.1.0 → 0.1.1
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 +167 -0
- package/dist/cli/main.js +1 -1
- package/dist/mcp/index.js +1 -1
- package/package.json +11 -3
- 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/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,167 @@
|
|
|
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
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# 1. Start the daemon (launches WS server + plugin dev server)
|
|
17
|
+
remnote-bridge connect
|
|
18
|
+
|
|
19
|
+
# 2. Load the plugin in RemNote
|
|
20
|
+
# Open RemNote → Settings → Plugins → Add Local Plugin
|
|
21
|
+
# Enter: http://localhost:8080
|
|
22
|
+
|
|
23
|
+
# 3. Check system status
|
|
24
|
+
remnote-bridge health
|
|
25
|
+
|
|
26
|
+
# 4. Explore your knowledge base
|
|
27
|
+
remnote-bridge read-globe # Global document overview
|
|
28
|
+
remnote-bridge read-context # Current focus in RemNote
|
|
29
|
+
remnote-bridge search "machine learning" # Full-text search
|
|
30
|
+
remnote-bridge read-tree <remId> # Expand a subtree
|
|
31
|
+
remnote-bridge read-rem <remId> # Read Rem properties
|
|
32
|
+
|
|
33
|
+
# 5. Edit content
|
|
34
|
+
remnote-bridge edit-rem <remId> --old-str '"concept"' --new-str '"descriptor"'
|
|
35
|
+
remnote-bridge edit-tree <remId> --old-str ' old line <!--id-->' --new-str ' new line\n old line <!--id-->'
|
|
36
|
+
|
|
37
|
+
# 6. Stop the daemon
|
|
38
|
+
remnote-bridge disconnect
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Commands
|
|
42
|
+
|
|
43
|
+
### Infrastructure
|
|
44
|
+
|
|
45
|
+
| Command | Description |
|
|
46
|
+
|:--------|:------------|
|
|
47
|
+
| `connect` | Start the daemon process (WS server + plugin dev server) |
|
|
48
|
+
| `health` | Check daemon, Plugin, and SDK status |
|
|
49
|
+
| `disconnect` | Stop the daemon and release resources |
|
|
50
|
+
|
|
51
|
+
### Read
|
|
52
|
+
|
|
53
|
+
| Command | Description | Caches |
|
|
54
|
+
|:--------|:------------|:-------|
|
|
55
|
+
| `read-globe` | Global document-level overview | No |
|
|
56
|
+
| `read-context` | Current focus/page context view | No |
|
|
57
|
+
| `read-tree <remId>` | Subtree as Markdown outline | Yes |
|
|
58
|
+
| `read-rem <remId>` | Single Rem's full JSON properties | Yes |
|
|
59
|
+
| `search <query>` | Full-text search | No |
|
|
60
|
+
|
|
61
|
+
### Write
|
|
62
|
+
|
|
63
|
+
| Command | Description | Prerequisite |
|
|
64
|
+
|:--------|:------------|:-------------|
|
|
65
|
+
| `edit-rem <remId>` | Edit Rem JSON fields via str_replace | `read-rem` first |
|
|
66
|
+
| `edit-tree <remId>` | Edit tree structure via str_replace | `read-tree` first |
|
|
67
|
+
|
|
68
|
+
### Utilities
|
|
69
|
+
|
|
70
|
+
| Command | Description |
|
|
71
|
+
|:--------|:------------|
|
|
72
|
+
| `mcp` | Start the MCP Server (stdio transport) |
|
|
73
|
+
| `install skill` | Install Claude Code skill to `~/.claude/skills/remnote-bridge/` |
|
|
74
|
+
|
|
75
|
+
## MCP Server
|
|
76
|
+
|
|
77
|
+
Use `remnote-bridge mcp` as an MCP server for AI clients:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"mcpServers": {
|
|
82
|
+
"remnote-bridge": {
|
|
83
|
+
"command": "remnote-bridge",
|
|
84
|
+
"args": ["mcp"]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The MCP server exposes all CLI commands as tools, plus documentation resources.
|
|
91
|
+
|
|
92
|
+
## Claude Code Skill
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
remnote-bridge install skill
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Installs the skill to `~/.claude/skills/remnote-bridge/`, enabling Claude Code to operate your RemNote knowledge base through natural language.
|
|
99
|
+
|
|
100
|
+
## JSON Mode
|
|
101
|
+
|
|
102
|
+
All commands support `--json` for programmatic usage. In JSON mode, both input and output are JSON:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Input: all parameters packed in a JSON string
|
|
106
|
+
remnote-bridge --json read-rem '{"remId":"abc123","fields":["text","type"]}'
|
|
107
|
+
|
|
108
|
+
# Output: single-line JSON
|
|
109
|
+
# {"ok":true,"command":"read-rem","timestamp":"...","data":{...}}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Architecture
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
AI Agent (Claude Code / MCP Client)
|
|
116
|
+
↕ CLI commands (stateless short processes)
|
|
117
|
+
remnote-bridge CLI
|
|
118
|
+
↕ WebSocket IPC
|
|
119
|
+
Daemon (long-lived process: WS server + handlers + cache)
|
|
120
|
+
↕ WebSocket
|
|
121
|
+
remnote-plugin (runs inside RemNote browser)
|
|
122
|
+
↕
|
|
123
|
+
RemNote SDK → Knowledge Base
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
- **CLI commands** are stateless — each invocation is an independent OS process
|
|
127
|
+
- **Daemon** holds state: cache, WS connections, timeout timer
|
|
128
|
+
- **Plugin** runs in the browser, calls RemNote SDK on behalf of the daemon
|
|
129
|
+
- **Three safety guards** protect edits: cache existence check, optimistic concurrency detection, str_replace exact match
|
|
130
|
+
|
|
131
|
+
## Configuration
|
|
132
|
+
|
|
133
|
+
Optional config file: `.remnote-bridge.json` in project root.
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"wsPort": 3002,
|
|
138
|
+
"devServerPort": 8080,
|
|
139
|
+
"configPort": 3003,
|
|
140
|
+
"daemonTimeoutMinutes": 30,
|
|
141
|
+
"defaults": {
|
|
142
|
+
"maxNodes": 200,
|
|
143
|
+
"maxSiblings": 20,
|
|
144
|
+
"readTreeDepth": 3
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
All values have sensible defaults — the config file is not required.
|
|
150
|
+
|
|
151
|
+
## Acknowledgements
|
|
152
|
+
|
|
153
|
+
This project was inspired by and learned from:
|
|
154
|
+
|
|
155
|
+
- [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.
|
|
156
|
+
- [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.
|
|
157
|
+
|
|
158
|
+
## Roadmap
|
|
159
|
+
|
|
160
|
+
- **MCP tool decomposition** — Break the current 1:1 CLI-to-MCP mapping into finer-grained tools, giving AI agents more flexible and composable operations
|
|
161
|
+
- **Improved agent instructions** — Refine Skill documentation and MCP server instructions for better AI agent comprehension
|
|
162
|
+
- **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
|
|
163
|
+
- **Multi-language support** — Internationalization for broader accessibility
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
MIT
|
package/dist/cli/main.js
CHANGED
|
@@ -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.1')
|
|
57
57
|
.option('--json', '以 JSON 格式输出(适用于程序化调用)');
|
|
58
58
|
program
|
|
59
59
|
.command('connect')
|
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.1',
|
|
21
21
|
instructions: SERVER_INSTRUCTIONS,
|
|
22
22
|
});
|
|
23
23
|
registerInfraTools(server);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remnote-bridge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "RemNote 自动化桥接工具集:CLI + MCP Server + Plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -8,8 +8,15 @@
|
|
|
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",
|
|
@@ -31,6 +38,7 @@
|
|
|
31
38
|
"fastmcp": "latest",
|
|
32
39
|
"zod": "^3.23.0"
|
|
33
40
|
},
|
|
41
|
+
"license": "MIT",
|
|
34
42
|
"devDependencies": {
|
|
35
43
|
"typescript": "^5.4.0",
|
|
36
44
|
"tsx": "^4.7.0",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* connect 命令
|
|
3
|
-
*
|
|
4
|
-
* 启动后台守护进程(WS Server + webpack-dev-server),等待 Plugin 连接。
|
|
5
|
-
* - 已在运行 → 打印提示,退出码 0
|
|
6
|
-
* - stale PID → 清理后正常启动
|
|
7
|
-
* - 启动失败 → 退出码 1
|
|
8
|
-
*/
|
|
9
|
-
export interface ConnectOptions {
|
|
10
|
-
json?: boolean;
|
|
11
|
-
}
|
|
12
|
-
export declare function connectCommand(options?: ConnectOptions): Promise<void>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* disconnect 命令
|
|
3
|
-
*
|
|
4
|
-
* 停止守护进程,释放端口和资源。
|
|
5
|
-
* - 守护进程运行中 → 发送 SIGTERM,等待退出
|
|
6
|
-
* - 守护进程未运行 → 打印提示,退出码 0
|
|
7
|
-
*/
|
|
8
|
-
export interface DisconnectOptions {
|
|
9
|
-
json?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export declare function disconnectCommand(options?: DisconnectOptions): Promise<void>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* edit-rem 命令
|
|
3
|
-
*
|
|
4
|
-
* 通过 str_replace 编辑 Rem 的 JSON 序列化。
|
|
5
|
-
* 三道防线保证安全:缓存存在性、并发检测、精确匹配。
|
|
6
|
-
* - 退出码:0 成功 / 1 业务错误 / 2 守护进程不可达
|
|
7
|
-
*/
|
|
8
|
-
export interface EditRemOptions {
|
|
9
|
-
json?: boolean;
|
|
10
|
-
oldStr: string;
|
|
11
|
-
newStr: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function editRemCommand(remId: string, options: EditRemOptions): Promise<void>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* edit-tree 命令
|
|
3
|
-
*
|
|
4
|
-
* 通过 str_replace 编辑 Rem 子树结构(行级增/删/移/重排)。
|
|
5
|
-
* - 禁止修改已有行内容(走 edit-rem)
|
|
6
|
-
* - --json 结构化 JSON 输出
|
|
7
|
-
* - 退出码:0 成功 / 1 业务错误 / 2 守护进程不可达
|
|
8
|
-
*/
|
|
9
|
-
export interface EditTreeOptions {
|
|
10
|
-
json?: boolean;
|
|
11
|
-
oldStr: string;
|
|
12
|
-
newStr: string;
|
|
13
|
-
}
|
|
14
|
-
export declare function editTreeCommand(remId: string, options: EditTreeOptions): Promise<void>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* health 命令
|
|
3
|
-
*
|
|
4
|
-
* 检查守护进程、Plugin 连接、SDK 状态,输出 ✅/❌ 列表。
|
|
5
|
-
* - 全部健康 → 退出码 0
|
|
6
|
-
* - 部分不健康 → 退出码 1
|
|
7
|
-
* - 守护进程不可达 → 退出码 2
|
|
8
|
-
*/
|
|
9
|
-
export interface HealthOptions {
|
|
10
|
-
json?: boolean;
|
|
11
|
-
}
|
|
12
|
-
export declare function healthCommand(options?: HealthOptions): Promise<void>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* read-context 命令
|
|
3
|
-
*
|
|
4
|
-
* 读取当前上下文视图。
|
|
5
|
-
* - --mode focus|page(默认 focus)
|
|
6
|
-
* - --ancestor-levels N 向上追溯几层祖先(默认 2,仅 focus 模式)
|
|
7
|
-
* - --depth N 展开深度(默认 3,仅 page 模式)
|
|
8
|
-
* - --max-nodes N 全局节点上限(默认 200)
|
|
9
|
-
* - --max-siblings N 每个父节点下展示的 children 上限(默认 20)
|
|
10
|
-
* - --json 结构化 JSON 输出
|
|
11
|
-
*/
|
|
12
|
-
export interface ReadContextOptions {
|
|
13
|
-
json?: boolean;
|
|
14
|
-
mode?: string;
|
|
15
|
-
ancestorLevels?: string;
|
|
16
|
-
depth?: string;
|
|
17
|
-
maxNodes?: string;
|
|
18
|
-
maxSiblings?: string;
|
|
19
|
-
}
|
|
20
|
-
export declare function readContextCommand(options?: ReadContextOptions): Promise<void>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* read-globe 命令
|
|
3
|
-
*
|
|
4
|
-
* 读取知识库全局概览(仅 Document 层级)。
|
|
5
|
-
* - --depth N 控制 Document 嵌套深度(默认 -1 无限)
|
|
6
|
-
* - --max-nodes N 全局节点上限(默认 200)
|
|
7
|
-
* - --max-siblings N 每个父节点下展示的 children 上限(默认 20)
|
|
8
|
-
* - --json 结构化 JSON 输出
|
|
9
|
-
*/
|
|
10
|
-
export interface ReadGlobeOptions {
|
|
11
|
-
json?: boolean;
|
|
12
|
-
depth?: string;
|
|
13
|
-
maxNodes?: string;
|
|
14
|
-
maxSiblings?: string;
|
|
15
|
-
}
|
|
16
|
-
export declare function readGlobeCommand(options?: ReadGlobeOptions): Promise<void>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* read-rem 命令
|
|
3
|
-
*
|
|
4
|
-
* 读取单个 Rem 的完整 JSON 对象。
|
|
5
|
-
* - 默认输出 [RW] + [R] 字段(34 个)
|
|
6
|
-
* - --full 输出全部 51 个字段(含 [R-F])
|
|
7
|
-
* - --fields 指定输出字段子集
|
|
8
|
-
* - 退出码:0 成功 / 1 业务错误 / 2 守护进程不可达
|
|
9
|
-
*/
|
|
10
|
-
export interface ReadRemOptions {
|
|
11
|
-
json?: boolean;
|
|
12
|
-
fields?: string;
|
|
13
|
-
full?: boolean;
|
|
14
|
-
includePowerup?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export declare function readRemCommand(remId: string, options?: ReadRemOptions): Promise<void>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* read-tree 命令
|
|
3
|
-
*
|
|
4
|
-
* 读取 Rem 子树并序列化为带缩进的 Markdown 大纲。
|
|
5
|
-
* - --depth N 控制展开深度(默认 3,-1 = 全部展开)
|
|
6
|
-
* - --json 结构化 JSON 输出
|
|
7
|
-
* - 退出码:0 成功 / 1 业务错误 / 2 守护进程不可达
|
|
8
|
-
*/
|
|
9
|
-
export interface ReadTreeOptions {
|
|
10
|
-
json?: boolean;
|
|
11
|
-
depth?: string;
|
|
12
|
-
maxNodes?: string;
|
|
13
|
-
maxSiblings?: string;
|
|
14
|
-
ancestorLevels?: string;
|
|
15
|
-
includePowerup?: boolean;
|
|
16
|
-
}
|
|
17
|
-
export declare function readTreeCommand(remId: string, options?: ReadTreeOptions): Promise<void>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* search 命令
|
|
3
|
-
*
|
|
4
|
-
* 在知识库中按文本搜索 Rem。
|
|
5
|
-
* - --limit N 结果数量上限(默认 20)
|
|
6
|
-
* - --json 结构化 JSON 输出
|
|
7
|
-
*/
|
|
8
|
-
export interface SearchOptions {
|
|
9
|
-
json?: boolean;
|
|
10
|
-
limit?: string;
|
|
11
|
-
}
|
|
12
|
-
export declare function searchCommand(query: string, options?: SearchOptions): Promise<void>;
|
package/dist/cli/config.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 配置加载
|
|
3
|
-
*
|
|
4
|
-
* 从项目根目录读取 .remnote-bridge.json,合并默认值。
|
|
5
|
-
* 文件不存在时使用全部默认值,不报错。
|
|
6
|
-
*/
|
|
7
|
-
export interface DefaultsConfig {
|
|
8
|
-
maxNodes: number;
|
|
9
|
-
maxSiblings: number;
|
|
10
|
-
cacheMaxSize: number;
|
|
11
|
-
readTreeDepth: number;
|
|
12
|
-
readTreeAncestorLevels: number;
|
|
13
|
-
readTreeIncludePowerup: boolean;
|
|
14
|
-
readGlobeDepth: number;
|
|
15
|
-
readContextMode: 'focus' | 'page';
|
|
16
|
-
readContextAncestorLevels: number;
|
|
17
|
-
readContextDepth: number;
|
|
18
|
-
searchNumResults: number;
|
|
19
|
-
}
|
|
20
|
-
export declare const DEFAULT_DEFAULTS: Readonly<DefaultsConfig>;
|
|
21
|
-
export interface BridgeConfig {
|
|
22
|
-
wsPort: number;
|
|
23
|
-
devServerPort: number;
|
|
24
|
-
configPort: number;
|
|
25
|
-
daemonTimeoutMinutes: number;
|
|
26
|
-
defaults: DefaultsConfig;
|
|
27
|
-
}
|
|
28
|
-
export declare const DEFAULT_CONFIG: Readonly<BridgeConfig>;
|
|
29
|
-
/**
|
|
30
|
-
* 查找项目根目录(monorepo 根:包含 .git 目录的最近祖先)
|
|
31
|
-
*
|
|
32
|
-
* 从 startDir 向上查找 .git 目录,找到即返回。
|
|
33
|
-
* 到达文件系统根仍未找到时回退到 cwd。
|
|
34
|
-
*/
|
|
35
|
-
export declare function findProjectRoot(startDir?: string): string;
|
|
36
|
-
/**
|
|
37
|
-
* 加载配置。不存在时返回默认值。
|
|
38
|
-
*/
|
|
39
|
-
export declare function loadConfig(projectRoot?: string): BridgeConfig;
|
|
40
|
-
/**
|
|
41
|
-
* 获取配置文件路径
|
|
42
|
-
*/
|
|
43
|
-
export declare function configFilePath(projectRoot?: string): string;
|
|
44
|
-
/**
|
|
45
|
-
* 原子写入配置文件(写临时文件 → rename)
|
|
46
|
-
*/
|
|
47
|
-
export declare function saveConfig(filePath: string, config: BridgeConfig): void;
|
|
48
|
-
/**
|
|
49
|
-
* PID 文件路径
|
|
50
|
-
*/
|
|
51
|
-
export declare function pidFilePath(projectRoot?: string): string;
|
|
52
|
-
/**
|
|
53
|
-
* 日志文件路径
|
|
54
|
-
*/
|
|
55
|
-
export declare function logFilePath(projectRoot?: string): string;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* webpack-dev-server 子进程管理
|
|
3
|
-
*
|
|
4
|
-
* 在 remnote-plugin 目录下启动 npm run dev。
|
|
5
|
-
*/
|
|
6
|
-
export interface DevServerOptions {
|
|
7
|
-
pluginDir: string;
|
|
8
|
-
port: number;
|
|
9
|
-
onLog?: (message: string, level: 'info' | 'warn' | 'error') => void;
|
|
10
|
-
onExit?: (code: number | null) => void;
|
|
11
|
-
}
|
|
12
|
-
export declare class DevServerManager {
|
|
13
|
-
private child;
|
|
14
|
-
private options;
|
|
15
|
-
constructor(options: DevServerOptions);
|
|
16
|
-
/**
|
|
17
|
-
* 启动 webpack-dev-server。
|
|
18
|
-
* 如果 remnote-plugin 目录不存在,抛出错误。
|
|
19
|
-
*/
|
|
20
|
-
start(): void;
|
|
21
|
-
/**
|
|
22
|
-
* 停止 webpack-dev-server。
|
|
23
|
-
*/
|
|
24
|
-
stop(): Promise<void>;
|
|
25
|
-
isRunning(): boolean;
|
|
26
|
-
}
|
package/dist/cli/daemon/pid.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PID 文件管理
|
|
3
|
-
*
|
|
4
|
-
* 写入、读取、stale 检测、清理。
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* 写入 PID 文件
|
|
8
|
-
*/
|
|
9
|
-
export declare function writePid(filePath: string, pid: number): void;
|
|
10
|
-
/**
|
|
11
|
-
* 读取 PID 文件。文件不存在返回 null。
|
|
12
|
-
*/
|
|
13
|
-
export declare function readPid(filePath: string): number | null;
|
|
14
|
-
/**
|
|
15
|
-
* 删除 PID 文件
|
|
16
|
-
*/
|
|
17
|
-
export declare function removePid(filePath: string): void;
|
|
18
|
-
/**
|
|
19
|
-
* 检查进程是否存活
|
|
20
|
-
*/
|
|
21
|
-
export declare function isProcessAlive(pid: number): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* 检查守护进程状态。返回:
|
|
24
|
-
* - { running: true, pid } — 守护进程正在运行
|
|
25
|
-
* - { running: false } — 守护进程未运行(无 PID 文件或 stale)
|
|
26
|
-
*
|
|
27
|
-
* 若 PID 文件存在但进程已死(stale),自动清理 PID 文件。
|
|
28
|
-
*/
|
|
29
|
-
export declare function checkDaemon(pidPath: string): {
|
|
30
|
-
running: true;
|
|
31
|
-
pid: number;
|
|
32
|
-
} | {
|
|
33
|
-
running: false;
|
|
34
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Daemon 通信工具 — CLI 命令向守护进程发送请求的通用方法
|
|
3
|
-
*
|
|
4
|
-
* 封装 WS 连接建立、请求发送、响应等待、超时处理的完整流程。
|
|
5
|
-
* 所有业务命令(health、read-rem、edit-rem 等)均通过此函数与 daemon 通信。
|
|
6
|
-
*/
|
|
7
|
-
export declare class DaemonNotRunningError extends Error {
|
|
8
|
-
constructor();
|
|
9
|
-
}
|
|
10
|
-
export declare class DaemonUnreachableError extends Error {
|
|
11
|
-
constructor(cause: string);
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* 向守护进程发送请求并等待响应。
|
|
15
|
-
*
|
|
16
|
-
* 流程:读取 PID 文件 → 建立 WS 连接 → 发送 BridgeRequest → 等待 BridgeResponse → 关闭连接
|
|
17
|
-
*
|
|
18
|
-
* @throws DaemonNotRunningError — PID 文件不存在或进程已死
|
|
19
|
-
* @throws DaemonUnreachableError — WS 连接失败
|
|
20
|
-
* @throws Error — daemon 返回 error 字段或响应超时
|
|
21
|
-
*/
|
|
22
|
-
export declare function sendDaemonRequest(action: string, payload?: Record<string, unknown>, options?: {
|
|
23
|
-
timeout?: number;
|
|
24
|
-
}): Promise<unknown>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ContextReadHandler — read-context 请求的业务编排
|
|
3
|
-
*
|
|
4
|
-
* 职责:转发到 Plugin 获取上下文视图,返回结果。
|
|
5
|
-
*/
|
|
6
|
-
import type { DefaultsConfig } from '../config.js';
|
|
7
|
-
export interface ContextReadResult {
|
|
8
|
-
nodeCount: number;
|
|
9
|
-
outline: string;
|
|
10
|
-
breadcrumb: string[];
|
|
11
|
-
mode: 'focus' | 'page';
|
|
12
|
-
}
|
|
13
|
-
export declare class ContextReadHandler {
|
|
14
|
-
private forwardToPlugin;
|
|
15
|
-
private defaults;
|
|
16
|
-
constructor(forwardToPlugin: (action: string, payload: Record<string, unknown>) => Promise<unknown>, defaults?: DefaultsConfig);
|
|
17
|
-
handleReadContext(payload: Record<string, unknown>): Promise<ContextReadResult>;
|
|
18
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EditHandler — edit-rem 命令的编排器
|
|
3
|
-
*
|
|
4
|
-
* 在 daemon 层实现三道防线 + str_replace + 后处理校验。
|
|
5
|
-
* Plugin 只负责原子写入(write_rem_fields)。
|
|
6
|
-
*
|
|
7
|
-
* 防线 1:缓存存在性检查(必须先 read 再 edit)
|
|
8
|
-
* 防线 2:乐观并发检测(当前 JSON 与缓存 JSON 比较)
|
|
9
|
-
* 防线 3:str_replace 精确匹配(old_str 必须唯一匹配)
|
|
10
|
-
*/
|
|
11
|
-
import { RemCache } from './rem-cache.js';
|
|
12
|
-
export interface EditRemPayload {
|
|
13
|
-
remId: string;
|
|
14
|
-
oldStr: string;
|
|
15
|
-
newStr: string;
|
|
16
|
-
}
|
|
17
|
-
export interface EditRemResult {
|
|
18
|
-
ok: boolean;
|
|
19
|
-
changes: string[];
|
|
20
|
-
warnings: string[];
|
|
21
|
-
error?: string;
|
|
22
|
-
appliedChanges?: string[];
|
|
23
|
-
failedField?: string;
|
|
24
|
-
}
|
|
25
|
-
export declare class EditHandler {
|
|
26
|
-
private cache;
|
|
27
|
-
private forwardToPlugin;
|
|
28
|
-
constructor(cache: RemCache, forwardToPlugin: (action: string, payload: Record<string, unknown>) => Promise<unknown>);
|
|
29
|
-
handleEditRem(payload: EditRemPayload): Promise<EditRemResult>;
|
|
30
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GlobeReadHandler — read-globe 请求的业务编排
|
|
3
|
-
*
|
|
4
|
-
* 职责:转发到 Plugin 获取知识库概览,返回结果。
|
|
5
|
-
* globe 是低频操作,不做缓存。
|
|
6
|
-
*/
|
|
7
|
-
import type { DefaultsConfig } from '../config.js';
|
|
8
|
-
export interface GlobeReadResult {
|
|
9
|
-
nodeCount: number;
|
|
10
|
-
outline: string;
|
|
11
|
-
}
|
|
12
|
-
export declare class GlobeReadHandler {
|
|
13
|
-
private forwardToPlugin;
|
|
14
|
-
private defaults;
|
|
15
|
-
constructor(forwardToPlugin: (action: string, payload: Record<string, unknown>) => Promise<unknown>, defaults?: DefaultsConfig);
|
|
16
|
-
handleReadGlobe(payload: Record<string, unknown>): Promise<GlobeReadResult>;
|
|
17
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ReadHandler — read-rem 请求的业务编排
|
|
3
|
-
*
|
|
4
|
-
* 职责:
|
|
5
|
-
* 1. 转发到 Plugin 获取完整 RemObject
|
|
6
|
-
* 2. 序列化为 JSON 字符串并缓存(完整版本)
|
|
7
|
-
* 3. 根据 fields/full 参数过滤字段返回给 CLI
|
|
8
|
-
*/
|
|
9
|
-
import { RemCache } from './rem-cache.js';
|
|
10
|
-
export declare class ReadHandler {
|
|
11
|
-
private cache;
|
|
12
|
-
private forwardToPlugin;
|
|
13
|
-
private onLog?;
|
|
14
|
-
constructor(cache: RemCache, forwardToPlugin: (action: string, payload: Record<string, unknown>) => Promise<unknown>, onLog?: ((message: string, level: "info" | "warn" | "error") => void) | undefined);
|
|
15
|
-
handleReadRem(payload: Record<string, unknown>): Promise<unknown>;
|
|
16
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RemCache — LRU 缓存,存储 Rem 的序列化 JSON
|
|
3
|
-
*
|
|
4
|
-
* 缓存存储在 daemon 内存中,生命周期与 daemon 一致。
|
|
5
|
-
* disconnect 关闭 daemon → 缓存自然消失。
|
|
6
|
-
*/
|
|
7
|
-
export declare class RemCache {
|
|
8
|
-
private cache;
|
|
9
|
-
private maxSize;
|
|
10
|
-
constructor(maxSize?: number);
|
|
11
|
-
get(remId: string): string | null;
|
|
12
|
-
/** 获取缓存条目的创建时间(ISO 8601),不存在返回 null */
|
|
13
|
-
getCreatedAt(remId: string): string | null;
|
|
14
|
-
set(remId: string, json: string): void;
|
|
15
|
-
has(remId: string): boolean;
|
|
16
|
-
delete(remId: string): void;
|
|
17
|
-
clear(): void;
|
|
18
|
-
get size(): number;
|
|
19
|
-
}
|