remnote-bridge 0.1.10 → 0.1.11
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/dist/cli/commands/read-context.js +5 -3
- package/dist/cli/handlers/context-read-handler.js +5 -3
- package/dist/cli/main.js +2 -0
- package/dist/mcp/instructions.js +2 -1
- package/dist/mcp/resources/error-reference.js +3 -1
- package/dist/mcp/tools/read-tools.js +7 -1
- package/package.json +1 -1
- package/remnote-plugin/dist/index-sandbox.js +18 -18
- package/remnote-plugin/dist/index.js +18 -18
- package/remnote-plugin/src/bridge/message-router.ts +1 -1
- package/remnote-plugin/src/services/read-context.ts +13 -4
- package/skills/remnote-bridge/instructions/read-context.md +34 -8
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* - --depth N 展开深度(默认 3,仅 page 模式)
|
|
8
8
|
* - --max-nodes N 全局节点上限(默认 200)
|
|
9
9
|
* - --max-siblings N 每个父节点下展示的 children 上限(默认 20)
|
|
10
|
+
* - --focus-rem-id <remId> 指定鱼眼中心 Rem ID(仅 focus 模式,默认使用当前焦点)
|
|
10
11
|
* - --json 结构化 JSON 输出
|
|
11
12
|
*/
|
|
12
13
|
import { sendDaemonRequest, DaemonNotRunningError, DaemonUnreachableError } from '../daemon/send-request.js';
|
|
@@ -42,9 +43,10 @@ export async function readContextCommand(options = {}) {
|
|
|
42
43
|
}
|
|
43
44
|
let result;
|
|
44
45
|
try {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
const reqPayload = { mode, ancestorLevels, depth, maxNodes, maxSiblings };
|
|
47
|
+
if (options.focusRemId)
|
|
48
|
+
reqPayload.focusRemId = options.focusRemId;
|
|
49
|
+
result = await sendDaemonRequest('read_context', reqPayload);
|
|
48
50
|
}
|
|
49
51
|
catch (err) {
|
|
50
52
|
if (err instanceof DaemonNotRunningError || err instanceof DaemonUnreachableError) {
|
|
@@ -17,8 +17,10 @@ export class ContextReadHandler {
|
|
|
17
17
|
const depth = payload.depth ?? this.defaults.readContextDepth;
|
|
18
18
|
const maxNodes = payload.maxNodes ?? this.defaults.maxNodes;
|
|
19
19
|
const maxSiblings = payload.maxSiblings ?? this.defaults.maxSiblings;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const focusRemId = payload.focusRemId;
|
|
21
|
+
const pluginPayload = { mode, ancestorLevels, depth, maxNodes, maxSiblings };
|
|
22
|
+
if (focusRemId)
|
|
23
|
+
pluginPayload.focusRemId = focusRemId;
|
|
24
|
+
return await this.forwardToPlugin('read_context', pluginPayload);
|
|
23
25
|
}
|
|
24
26
|
}
|
package/dist/cli/main.js
CHANGED
|
@@ -187,6 +187,7 @@ program
|
|
|
187
187
|
.option('--depth <depth>', '展开深度(默认 3,仅 page 模式)')
|
|
188
188
|
.option('--max-nodes <maxNodes>', '全局节点上限(默认 200)')
|
|
189
189
|
.option('--max-siblings <maxSiblings>', '每个父节点下展示的 children 上限(默认 20)')
|
|
190
|
+
.option('--focus-rem-id <remId>', '指定鱼眼中心 Rem ID(仅 focus 模式,默认使用当前焦点)')
|
|
190
191
|
.action(async (jsonStr, cmdOpts) => {
|
|
191
192
|
const { json } = program.opts();
|
|
192
193
|
if (json) {
|
|
@@ -208,6 +209,7 @@ program
|
|
|
208
209
|
depth: input.depth?.toString(),
|
|
209
210
|
maxNodes: input.maxNodes?.toString(),
|
|
210
211
|
maxSiblings: input.maxSiblings?.toString(),
|
|
212
|
+
focusRemId: input.focusRemId ? String(input.focusRemId) : undefined,
|
|
211
213
|
});
|
|
212
214
|
}
|
|
213
215
|
else {
|
package/dist/mcp/instructions.js
CHANGED
|
@@ -210,7 +210,7 @@ disconnect → 关闭 daemon + headless Chrome,清空所有缓存
|
|
|
210
210
|
先用 \\\`read_context\\\` 看到用户所看到的,再做决策,沟通才能顺畅。
|
|
211
211
|
|
|
212
212
|
使用 \\\`read_context\\\`:
|
|
213
|
-
- **focus 模式**(默认):以用户当前光标所在的 Rem 为中心,构建鱼眼视图——焦点处完全展开,周围递减。焦点行以 \\\`* \\\` 前缀标记。需要用户在 RemNote 中已点击某个 Rem
|
|
213
|
+
- **focus 模式**(默认):以用户当前光标所在的 Rem 为中心,构建鱼眼视图——焦点处完全展开,周围递减。焦点行以 \\\`* \\\` 前缀标记。需要用户在 RemNote 中已点击某个 Rem。可通过 \\\`focusRemId\\\` 指定任意 Rem 作为鱼眼中心,此时不依赖用户焦点。
|
|
214
214
|
- **page 模式**:以当前打开的页面为根,均匀展开子树。
|
|
215
215
|
|
|
216
216
|
两种模式都会返回面包屑路径,帮助你理解当前位置在知识库中的层级。
|
|
@@ -404,6 +404,7 @@ newStr: 最后一个兄弟 <!--idZ-->
|
|
|
404
404
|
| orphan_detected | 删了父行但保留了子行 | 同时删除所有子行 |
|
|
405
405
|
| folded_delete | 删除有隐藏子节点的行 | 用更大 depth 重新 read_tree |
|
|
406
406
|
| children_captured | 新行插在父 Rem 和它的 children 之间,劫持了已有子节点 | 把新行插到所有兄弟的**末尾**而非紧跟父 Rem 之后(见下方说明) |
|
|
407
|
+
| focusRemId 仅在 focus 模式下有效 | page 模式下不应传 focusRemId | 去掉 focusRemId 参数,或改用 focus 模式 |
|
|
407
408
|
|
|
408
409
|
完整错误参考见 \\\`resource://error-reference\\\`。
|
|
409
410
|
`;
|
|
@@ -78,7 +78,9 @@ export const ERROR_REFERENCE_CONTENT = `
|
|
|
78
78
|
| 错误信息 | 触发命令 | 原因 | 恢复操作 |
|
|
79
79
|
|:---------|:---------|:-----|:---------|
|
|
80
80
|
| Rem not found: {remId} | read_rem / read_tree | remId 无效或 Rem 已被删除 | 使用 \\\`search\\\` 重新定位 |
|
|
81
|
-
|
|
|
81
|
+
| 指定的 Rem 不存在: {remId} | read_context (focus + focusRemId) | focusRemId 无效或 Rem 已被删除 | 使用 \\\`search\\\` 重新定位 |
|
|
82
|
+
| focusRemId 仅在 focus 模式下有效 | read_context (page + focusRemId) | page 模式下不应传 focusRemId | 去掉 focusRemId 参数,或改用 focus 模式 |
|
|
83
|
+
| 无法获取当前聚焦的 Rem | read_context (focus) | 用户未在 RemNote 中点击任何 Rem(且未指定 focusRemId) | 提醒用户在 RemNote 中点击一个 Rem,或传入 focusRemId |
|
|
82
84
|
| 无法获取当前页面 | read_context (page) | RemNote 未打开文档页面 | 提醒用户打开一个文档页面 |
|
|
83
85
|
|
|
84
86
|
---
|
|
@@ -149,7 +149,7 @@ export function registerReadTools(server) {
|
|
|
149
149
|
// -------------------------------------------------------------------------
|
|
150
150
|
server.addTool({
|
|
151
151
|
name: 'read_context',
|
|
152
|
-
description: '读取用户在 RemNote 中的当前上下文视图,生成带面包屑路径的 Markdown 大纲。\n无需指定 remId,自动获取用户当前焦点位置或打开的页面。\n\n适用场景:\n- 用户说"我现在在看什么"、"当前页面是什么"\n- 需要了解用户焦点位置以提供上下文帮助\n- 不适合查看特定 Rem(已知 remId 用 read_tree)\n\n两种模式:\n- focus(默认):以焦点 Rem 为中心的鱼眼视图。焦点完全展开(depth=3),siblings 浅层预览(depth=1),叔伯不展开。焦点行以 *
|
|
152
|
+
description: '读取用户在 RemNote 中的当前上下文视图,生成带面包屑路径的 Markdown 大纲。\n无需指定 remId,自动获取用户当前焦点位置或打开的页面。\n\n适用场景:\n- 用户说"我现在在看什么"、"当前页面是什么"\n- 需要了解用户焦点位置以提供上下文帮助\n- 不适合查看特定 Rem(已知 remId 用 read_tree)\n\n两种模式:\n- focus(默认):以焦点 Rem 为中心的鱼眼视图。焦点完全展开(depth=3),siblings 浅层预览(depth=1),叔伯不展开。焦点行以 * 前缀标记。可通过 focusRemId 指定任意 Rem 作为鱼眼中心,此时不依赖用户焦点。\n- page:以当前页面为根均匀展开子树。\n\n输出:Markdown 大纲 + 面包屑路径。不缓存。\n前提:focus 模式需用户有焦点 Rem 或指定 focusRemId,page 模式需有打开的页面。\n典型工作流:read_context 了解位置 → read_tree/read_rem 深入。',
|
|
153
153
|
parameters: z.object({
|
|
154
154
|
mode: z
|
|
155
155
|
.enum(['focus', 'page'])
|
|
@@ -171,6 +171,10 @@ export function registerReadTools(server) {
|
|
|
171
171
|
.number()
|
|
172
172
|
.optional()
|
|
173
173
|
.describe('同级节点显示上限'),
|
|
174
|
+
focusRemId: z
|
|
175
|
+
.string()
|
|
176
|
+
.optional()
|
|
177
|
+
.describe('指定鱼眼中心 Rem ID(仅 focus 模式,默认使用当前焦点)'),
|
|
174
178
|
}),
|
|
175
179
|
execute: async (args) => {
|
|
176
180
|
const payload = {};
|
|
@@ -184,6 +188,8 @@ export function registerReadTools(server) {
|
|
|
184
188
|
payload.maxNodes = args.maxNodes;
|
|
185
189
|
if (args.maxSiblings !== undefined)
|
|
186
190
|
payload.maxSiblings = args.maxSiblings;
|
|
191
|
+
if (args.focusRemId !== undefined)
|
|
192
|
+
payload.focusRemId = args.focusRemId;
|
|
187
193
|
const response = await callCli('read-context', payload);
|
|
188
194
|
const data = response.data;
|
|
189
195
|
if (data?.outline && typeof data.outline === 'string') {
|