@getnote/dsh-plugin 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 +150 -0
- package/cordis.patch.yml +4 -0
- package/lib/index.js +302 -0
- package/lib/index.js.map +1 -0
- package/lib/types/cli-runner.d.ts +16 -0
- package/lib/types/cli-runner.d.ts.map +1 -0
- package/lib/types/index.d.ts +14 -0
- package/lib/types/index.d.ts.map +1 -0
- package/package.json +70 -0
- package/skills/getnote-dsh/SKILL.md +27 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 GetNote
|
|
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,150 @@
|
|
|
1
|
+
# 在 DeepSeek Harness 中使用得到大脑
|
|
2
|
+
|
|
3
|
+
把得到大脑接入 DeepSeek Harness(`dsh`)。安装后,你可以直接用自然语言搜索、
|
|
4
|
+
保存和阅读笔记,不需要复制 API 请求,也不需要单独配置 MCP。
|
|
5
|
+
|
|
6
|
+
## 开始使用
|
|
7
|
+
|
|
8
|
+
### 1. 安装插件
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
dsh plugin --profile web add @getnote/dsh-plugin
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
如果你通过 `npx` 使用 DSH:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npx @deepseek-ai/dsh plugin --profile web add @getnote/dsh-plugin
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### 2. 登录得到大脑
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx @getnote/cli@latest auth login
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
命令会打开浏览器,请按页面提示完成授权。得到大脑 OpenAPI 需要得到大脑会员。
|
|
27
|
+
|
|
28
|
+
插件不要求你额外全局安装 CLI。运行笔记操作时,它会先使用本机 `PATH` 中已有的
|
|
29
|
+
`getnote`,再尝试插件环境中的 GetNote CLI;都没有时会自动通过 `npx` 调用兼容
|
|
30
|
+
版本。上面的登录授权也可以被其他支持 GetNote CLI 的 AI 工具复用。
|
|
31
|
+
|
|
32
|
+
### 3. 重启 DSH
|
|
33
|
+
|
|
34
|
+
重启 `dsh web` 后,就可以直接对 Agent 说:
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
帮我搜索得到大脑里关于 Agent Harness 的笔记
|
|
38
|
+
把 https://example.com/article 保存到得到大脑,添加“待读”标签
|
|
39
|
+
列出最近 10 条笔记
|
|
40
|
+
打开笔记 1896830231705320746
|
|
41
|
+
列出我的知识库
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 支持的能力
|
|
45
|
+
|
|
46
|
+
- 检查得到大脑登录状态
|
|
47
|
+
- 按自然语言语义搜索全部笔记
|
|
48
|
+
- 在指定知识库内搜索
|
|
49
|
+
- 保存文字、网页链接和本地图片
|
|
50
|
+
- 保存时设置标题和标签
|
|
51
|
+
- 查看最近笔记
|
|
52
|
+
- 按 ID 查看笔记详情
|
|
53
|
+
- 查看知识库列表
|
|
54
|
+
|
|
55
|
+
插件会提供一个轻量的 DSH 引导 Skill,让 Agent 优先选择这些原生工具。若你已经
|
|
56
|
+
在本机安装了更完整的 GetNote Skills,DSH 仍可正常发现并使用它们,插件不会再
|
|
57
|
+
复制一套相同 Skill,也不会覆盖你的版本。
|
|
58
|
+
|
|
59
|
+
## 常见问题
|
|
60
|
+
|
|
61
|
+
### 提示未登录怎么办?
|
|
62
|
+
|
|
63
|
+
重新执行:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npx @getnote/cli@latest auth login
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
完成授权后重启 DSH。如果仍然失败,可以运行:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npx @getnote/cli@latest doctor -o json
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 是否需要配置 API Key?
|
|
76
|
+
|
|
77
|
+
普通用户不需要手工填写 API Key。推荐使用浏览器授权,插件会复用 GetNote CLI
|
|
78
|
+
保存的登录状态。
|
|
79
|
+
|
|
80
|
+
### 插件会把凭据发给模型吗?
|
|
81
|
+
|
|
82
|
+
不会。认证由 GetNote CLI 在本地管理;插件只把笔记操作结果返回给 DSH。登录
|
|
83
|
+
状态检查也不会把 API Key 或末尾字符写入模型上下文。
|
|
84
|
+
|
|
85
|
+
### 为什么依赖 GetNote CLI?
|
|
86
|
+
|
|
87
|
+
GetNote CLI 负责浏览器授权、调用得到大脑 OpenAPI、处理异步任务和返回结构化
|
|
88
|
+
结果。插件负责把这些能力变成 DSH 原生工具。这样同一份授权可以跨终端和多个
|
|
89
|
+
AI 工具复用,也能避免重复维护两套得到大脑接口。
|
|
90
|
+
|
|
91
|
+
## 更新与卸载
|
|
92
|
+
|
|
93
|
+
更新:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
dsh plugin --profile web update @getnote/dsh-plugin
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
卸载:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
dsh plugin --profile web remove @getnote/dsh-plugin
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
卸载插件不会退出得到大脑账号。如需同时退出:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
npx @getnote/cli@latest auth logout
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## 高级配置
|
|
112
|
+
|
|
113
|
+
大多数用户不需要修改配置。需要调整长任务超时或输出上限时,可以在 profile 的
|
|
114
|
+
`cordis.patch.yml` 中覆盖插件配置:
|
|
115
|
+
|
|
116
|
+
```yaml
|
|
117
|
+
- id: getnote-tools
|
|
118
|
+
name: '@getnote/dsh-plugin'
|
|
119
|
+
inject: [tools, skills]
|
|
120
|
+
config:
|
|
121
|
+
timeoutMs: 120000
|
|
122
|
+
maxOutputBytes: 10485760
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`binaryPath` 和 `apiUrl` 仅用于开发或联调环境。
|
|
126
|
+
|
|
127
|
+
## 安全边界
|
|
128
|
+
|
|
129
|
+
- 插件只开放明确的得到大脑操作,不提供任意 Shell 参数入口。
|
|
130
|
+
- CLI 参数通过参数数组传递,不拼接 Shell 命令。
|
|
131
|
+
- 删除和批量修改等高风险能力尚未在首版开放。
|
|
132
|
+
- 插件与其他 DSH 插件一样,在当前用户权限下运行;请只从可信来源安装。
|
|
133
|
+
|
|
134
|
+
## 开发
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
npm install
|
|
138
|
+
npm run check
|
|
139
|
+
npm test
|
|
140
|
+
npm run build
|
|
141
|
+
npm pack --dry-run
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
项目通过 `@getnote/cli` 调用得到大脑能力,并随 npm 包提供一个只负责工具选择的
|
|
145
|
+
DSH 引导 Skill。推送与 `package.json` 版本一致的 `v*` tag 后,GitHub Actions
|
|
146
|
+
会执行检查、测试、构建并发布 npm 包。
|
|
147
|
+
|
|
148
|
+
## License
|
|
149
|
+
|
|
150
|
+
MIT
|
package/cordis.patch.yml
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { apply as apply$1 } from "@deepseek-ai/dsh-skill-filesystem";
|
|
3
|
+
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
4
|
+
import Schema from "@deepseek-ai/schemastery";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
import { accessSync, constants } from "node:fs";
|
|
8
|
+
import { delimiter, dirname, join } from "node:path";
|
|
9
|
+
//#region src/cli-runner.ts
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
var GetnoteCliError = class extends Error {
|
|
12
|
+
exitCode;
|
|
13
|
+
stderr;
|
|
14
|
+
constructor(message, exitCode, stderr) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.exitCode = exitCode;
|
|
17
|
+
this.stderr = stderr;
|
|
18
|
+
this.name = "GetnoteCliError";
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
function resolveGetnoteBinary() {
|
|
22
|
+
const packageJson = require.resolve("@getnote/cli/package.json");
|
|
23
|
+
const binary = process.platform === "win32" ? "getnote.exe" : "getnote";
|
|
24
|
+
return join(dirname(packageJson), "bin", binary);
|
|
25
|
+
}
|
|
26
|
+
function resolveGetnoteFromPath(pathValue = process.env.PATH ?? "", pathExtValue = process.env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM") {
|
|
27
|
+
const extensions = process.platform === "win32" ? pathExtValue.split(";").filter(Boolean) : [""];
|
|
28
|
+
for (const directory of pathValue.split(delimiter).filter(Boolean)) for (const extension of extensions) {
|
|
29
|
+
const candidate = join(directory, `getnote${extension.toLowerCase()}`);
|
|
30
|
+
try {
|
|
31
|
+
accessSync(candidate, constants.X_OK);
|
|
32
|
+
return candidate;
|
|
33
|
+
} catch {}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function resolveGetnoteInvocation(binaryPath) {
|
|
37
|
+
if (binaryPath) return {
|
|
38
|
+
command: binaryPath,
|
|
39
|
+
prefixArgs: []
|
|
40
|
+
};
|
|
41
|
+
const pathBinary = resolveGetnoteFromPath();
|
|
42
|
+
if (pathBinary) return {
|
|
43
|
+
command: pathBinary,
|
|
44
|
+
prefixArgs: []
|
|
45
|
+
};
|
|
46
|
+
try {
|
|
47
|
+
return {
|
|
48
|
+
command: resolveGetnoteBinary(),
|
|
49
|
+
prefixArgs: []
|
|
50
|
+
};
|
|
51
|
+
} catch {
|
|
52
|
+
return {
|
|
53
|
+
command: process.platform === "win32" ? "npx.cmd" : "npx",
|
|
54
|
+
prefixArgs: [
|
|
55
|
+
"--yes",
|
|
56
|
+
"--package",
|
|
57
|
+
"@getnote/cli@1.5.3",
|
|
58
|
+
"--",
|
|
59
|
+
"getnote"
|
|
60
|
+
]
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async function runGetnote(args, options = {}) {
|
|
65
|
+
const invocation = resolveGetnoteInvocation(options.binaryPath);
|
|
66
|
+
const timeoutMs = options.timeoutMs ?? 12e4;
|
|
67
|
+
const maxOutputBytes = options.maxOutputBytes ?? 10485760;
|
|
68
|
+
const commandArgs = [
|
|
69
|
+
...invocation.prefixArgs,
|
|
70
|
+
...args,
|
|
71
|
+
"--output",
|
|
72
|
+
"json"
|
|
73
|
+
];
|
|
74
|
+
return await new Promise((resolve, reject) => {
|
|
75
|
+
const child = spawn(invocation.command, commandArgs, {
|
|
76
|
+
env: {
|
|
77
|
+
...process.env,
|
|
78
|
+
...options.apiUrl ? { GETNOTE_API_URL: options.apiUrl } : {}
|
|
79
|
+
},
|
|
80
|
+
stdio: [
|
|
81
|
+
"ignore",
|
|
82
|
+
"pipe",
|
|
83
|
+
"pipe"
|
|
84
|
+
],
|
|
85
|
+
windowsHide: true,
|
|
86
|
+
signal: options.signal
|
|
87
|
+
});
|
|
88
|
+
const stdout = [];
|
|
89
|
+
const stderr = [];
|
|
90
|
+
let outputBytes = 0;
|
|
91
|
+
let settled = false;
|
|
92
|
+
let timer;
|
|
93
|
+
const finish = (callback) => {
|
|
94
|
+
if (settled) return;
|
|
95
|
+
settled = true;
|
|
96
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
97
|
+
callback();
|
|
98
|
+
};
|
|
99
|
+
const capture = (target, chunk) => {
|
|
100
|
+
outputBytes += chunk.length;
|
|
101
|
+
if (outputBytes > maxOutputBytes) {
|
|
102
|
+
child.kill("SIGTERM");
|
|
103
|
+
finish(() => reject(new GetnoteCliError(`getnote output exceeded ${maxOutputBytes} bytes`, null, Buffer.concat(stderr).toString("utf8"))));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
target.push(chunk);
|
|
107
|
+
};
|
|
108
|
+
child.stdout.on("data", (chunk) => capture(stdout, chunk));
|
|
109
|
+
child.stderr.on("data", (chunk) => capture(stderr, chunk));
|
|
110
|
+
timer = setTimeout(() => {
|
|
111
|
+
child.kill("SIGTERM");
|
|
112
|
+
finish(() => reject(new GetnoteCliError(`getnote command timed out after ${timeoutMs} ms`, null, Buffer.concat(stderr).toString("utf8"))));
|
|
113
|
+
}, timeoutMs);
|
|
114
|
+
child.on("error", (error) => {
|
|
115
|
+
finish(() => reject(new GetnoteCliError(`failed to start getnote: ${error.message}`, null, Buffer.concat(stderr).toString("utf8"))));
|
|
116
|
+
});
|
|
117
|
+
child.on("close", (code) => {
|
|
118
|
+
finish(() => {
|
|
119
|
+
const stdoutText = Buffer.concat(stdout).toString("utf8").trim();
|
|
120
|
+
const stderrText = Buffer.concat(stderr).toString("utf8").trim();
|
|
121
|
+
if (code !== 0) {
|
|
122
|
+
reject(new GetnoteCliError(stderrText || stdoutText || `getnote exited with code ${String(code)}`, code, stderrText));
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (!stdoutText) {
|
|
126
|
+
resolve(null);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
resolve(JSON.parse(stdoutText));
|
|
131
|
+
} catch {
|
|
132
|
+
resolve(stdoutText);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/index.ts
|
|
140
|
+
const name = "getnote-tools";
|
|
141
|
+
const inject = ["tools", "skills"];
|
|
142
|
+
const Config = Schema.object({
|
|
143
|
+
binaryPath: Schema.string().description("Optional absolute path to the getnote executable."),
|
|
144
|
+
apiUrl: Schema.string().description("Optional GetNote OpenAPI base URL for explicit integration testing."),
|
|
145
|
+
timeoutMs: Schema.number().min(1e3).default(12e4),
|
|
146
|
+
maxOutputBytes: Schema.number().min(1024).default(10485760)
|
|
147
|
+
});
|
|
148
|
+
function renderJson(value) {
|
|
149
|
+
if (typeof value === "string") return value;
|
|
150
|
+
return JSON.stringify(value, null, 2);
|
|
151
|
+
}
|
|
152
|
+
function runnerOptions(config, signal) {
|
|
153
|
+
return {
|
|
154
|
+
binaryPath: config.binaryPath,
|
|
155
|
+
apiUrl: config.apiUrl,
|
|
156
|
+
timeoutMs: config.timeoutMs,
|
|
157
|
+
maxOutputBytes: config.maxOutputBytes,
|
|
158
|
+
signal
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function textOutput() {
|
|
162
|
+
return {
|
|
163
|
+
schema: { type: "string" },
|
|
164
|
+
render: (_args, value) => [{
|
|
165
|
+
type: "text",
|
|
166
|
+
text: value
|
|
167
|
+
}]
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function integerInRange(value, fallback, min, max) {
|
|
171
|
+
const resolved = value ?? fallback;
|
|
172
|
+
if (!Number.isInteger(resolved) || resolved < min || resolved > max) throw new RangeError(`value must be an integer between ${min} and ${max}`);
|
|
173
|
+
return resolved;
|
|
174
|
+
}
|
|
175
|
+
function apply(ctx, config) {
|
|
176
|
+
apply$1(ctx, {
|
|
177
|
+
providerName: "getnote",
|
|
178
|
+
includeDefaultRoots: false,
|
|
179
|
+
bundledSkillDir: fileURLToPath(new URL("../skills", import.meta.url))
|
|
180
|
+
});
|
|
181
|
+
ctx.tools.register(defineTool({
|
|
182
|
+
name: "getnote_auth_status",
|
|
183
|
+
description: "Check whether the current user is authenticated with GetNote (得到大脑).",
|
|
184
|
+
parameters: {},
|
|
185
|
+
output: textOutput(),
|
|
186
|
+
async execute(_args, exec) {
|
|
187
|
+
await runGetnote(["auth", "status"], runnerOptions(config, exec.signal));
|
|
188
|
+
return "Authenticated with GetNote.";
|
|
189
|
+
}
|
|
190
|
+
}));
|
|
191
|
+
ctx.tools.register(defineTool({
|
|
192
|
+
name: "getnote_search",
|
|
193
|
+
description: "Semantically search notes in GetNote, optionally within one knowledge base.",
|
|
194
|
+
parameters: {
|
|
195
|
+
query: {
|
|
196
|
+
type: "string",
|
|
197
|
+
required: true,
|
|
198
|
+
description: "Natural-language search query."
|
|
199
|
+
},
|
|
200
|
+
knowledge_base_id: {
|
|
201
|
+
type: "string",
|
|
202
|
+
description: "Optional knowledge base/topic ID."
|
|
203
|
+
},
|
|
204
|
+
limit: {
|
|
205
|
+
type: "integer",
|
|
206
|
+
default: 10,
|
|
207
|
+
description: "Maximum results, from 1 to 10."
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
output: textOutput(),
|
|
211
|
+
async execute(args, exec) {
|
|
212
|
+
const limit = integerInRange(args.limit, 10, 1, 10);
|
|
213
|
+
const cliArgs = [
|
|
214
|
+
"search",
|
|
215
|
+
args.query,
|
|
216
|
+
"--limit",
|
|
217
|
+
String(limit)
|
|
218
|
+
];
|
|
219
|
+
if (args.knowledge_base_id) cliArgs.push("--kb", args.knowledge_base_id);
|
|
220
|
+
return renderJson(await runGetnote(cliArgs, runnerOptions(config, exec.signal)));
|
|
221
|
+
}
|
|
222
|
+
}));
|
|
223
|
+
ctx.tools.register(defineTool({
|
|
224
|
+
name: "getnote_save",
|
|
225
|
+
description: "Save text, a URL, or a local image path as a note in GetNote.",
|
|
226
|
+
parameters: {
|
|
227
|
+
content: {
|
|
228
|
+
type: "string",
|
|
229
|
+
required: true,
|
|
230
|
+
description: "Text, URL, or local image path to save."
|
|
231
|
+
},
|
|
232
|
+
title: {
|
|
233
|
+
type: "string",
|
|
234
|
+
description: "Optional note title."
|
|
235
|
+
},
|
|
236
|
+
tags: {
|
|
237
|
+
type: "array",
|
|
238
|
+
items: { type: "string" },
|
|
239
|
+
description: "Optional note tags."
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
output: textOutput(),
|
|
243
|
+
async execute(args, exec) {
|
|
244
|
+
const cliArgs = ["save", args.content];
|
|
245
|
+
if (args.title) cliArgs.push("--title", args.title);
|
|
246
|
+
for (const tag of args.tags ?? []) cliArgs.push("--tag", tag);
|
|
247
|
+
return renderJson(await runGetnote(cliArgs, runnerOptions(config, exec.signal)));
|
|
248
|
+
}
|
|
249
|
+
}));
|
|
250
|
+
ctx.tools.register(defineTool({
|
|
251
|
+
name: "getnote_list_notes",
|
|
252
|
+
description: "List recent notes from GetNote.",
|
|
253
|
+
parameters: {
|
|
254
|
+
limit: {
|
|
255
|
+
type: "integer",
|
|
256
|
+
default: 20,
|
|
257
|
+
description: "Number of notes, from 1 to 100."
|
|
258
|
+
},
|
|
259
|
+
since_id: {
|
|
260
|
+
type: "string",
|
|
261
|
+
description: "Optional pagination cursor note ID."
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
output: textOutput(),
|
|
265
|
+
async execute(args, exec) {
|
|
266
|
+
const limit = integerInRange(args.limit, 20, 1, 100);
|
|
267
|
+
const cliArgs = [
|
|
268
|
+
"notes",
|
|
269
|
+
"--limit",
|
|
270
|
+
String(limit)
|
|
271
|
+
];
|
|
272
|
+
if (args.since_id) cliArgs.push("--since-id", args.since_id);
|
|
273
|
+
return renderJson(await runGetnote(cliArgs, runnerOptions(config, exec.signal)));
|
|
274
|
+
}
|
|
275
|
+
}));
|
|
276
|
+
ctx.tools.register(defineTool({
|
|
277
|
+
name: "getnote_get_note",
|
|
278
|
+
description: "Get the complete details of one GetNote note by its string ID.",
|
|
279
|
+
parameters: { note_id: {
|
|
280
|
+
type: "string",
|
|
281
|
+
required: true,
|
|
282
|
+
description: "Note ID. Keep it as a string."
|
|
283
|
+
} },
|
|
284
|
+
output: textOutput(),
|
|
285
|
+
async execute(args, exec) {
|
|
286
|
+
return renderJson(await runGetnote(["note", args.note_id], runnerOptions(config, exec.signal)));
|
|
287
|
+
}
|
|
288
|
+
}));
|
|
289
|
+
ctx.tools.register(defineTool({
|
|
290
|
+
name: "getnote_list_knowledge_bases",
|
|
291
|
+
description: "List the current user's GetNote knowledge bases.",
|
|
292
|
+
parameters: {},
|
|
293
|
+
output: textOutput(),
|
|
294
|
+
async execute(_args, exec) {
|
|
295
|
+
return renderJson(await runGetnote(["kbs"], runnerOptions(config, exec.signal)));
|
|
296
|
+
}
|
|
297
|
+
}));
|
|
298
|
+
}
|
|
299
|
+
//#endregion
|
|
300
|
+
export { Config, GetnoteCliError, apply, inject, name, resolveGetnoteBinary, resolveGetnoteFromPath, runGetnote };
|
|
301
|
+
|
|
302
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/cli-runner.ts","../src/index.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\nimport { accessSync, constants } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { delimiter, dirname, join } from 'node:path'\n\nconst require = createRequire(import.meta.url)\n\nexport interface RunGetnoteOptions {\n binaryPath?: string\n apiUrl?: string\n signal?: AbortSignal\n timeoutMs?: number\n maxOutputBytes?: number\n}\n\nexport class GetnoteCliError extends Error {\n constructor(\n message: string,\n readonly exitCode: number | null,\n readonly stderr: string,\n ) {\n super(message)\n this.name = 'GetnoteCliError'\n }\n}\n\nexport function resolveGetnoteBinary(): string {\n const packageJson = require.resolve('@getnote/cli/package.json')\n const binary = process.platform === 'win32' ? 'getnote.exe' : 'getnote'\n return join(dirname(packageJson), 'bin', binary)\n}\n\ninterface GetnoteInvocation {\n command: string\n prefixArgs: string[]\n}\n\nexport function resolveGetnoteFromPath(\n pathValue = process.env.PATH ?? '',\n pathExtValue = process.env.PATHEXT ?? '.EXE;.CMD;.BAT;.COM',\n): string | undefined {\n const extensions = process.platform === 'win32'\n ? pathExtValue.split(';').filter(Boolean)\n : ['']\n\n for (const directory of pathValue.split(delimiter).filter(Boolean)) {\n for (const extension of extensions) {\n const candidate = join(directory, `getnote${extension.toLowerCase()}`)\n try {\n accessSync(candidate, constants.X_OK)\n return candidate\n } catch {\n // Continue searching the remaining PATH entries.\n }\n }\n }\n}\n\nfunction resolveGetnoteInvocation(binaryPath?: string): GetnoteInvocation {\n if (binaryPath) return { command: binaryPath, prefixArgs: [] }\n\n const pathBinary = resolveGetnoteFromPath()\n if (pathBinary) return { command: pathBinary, prefixArgs: [] }\n\n try {\n return { command: resolveGetnoteBinary(), prefixArgs: [] }\n } catch {\n return {\n command: process.platform === 'win32' ? 'npx.cmd' : 'npx',\n prefixArgs: ['--yes', '--package', '@getnote/cli@1.5.3', '--', 'getnote'],\n }\n }\n}\n\nexport async function runGetnote(\n args: readonly string[],\n options: RunGetnoteOptions = {},\n): Promise<unknown> {\n const invocation = resolveGetnoteInvocation(options.binaryPath)\n const timeoutMs = options.timeoutMs ?? 120_000\n const maxOutputBytes = options.maxOutputBytes ?? 10 * 1024 * 1024\n const commandArgs = [...invocation.prefixArgs, ...args, '--output', 'json']\n\n return await new Promise((resolve, reject) => {\n const child = spawn(invocation.command, commandArgs, {\n env: {\n ...process.env,\n ...(options.apiUrl ? { GETNOTE_API_URL: options.apiUrl } : {}),\n },\n stdio: ['ignore', 'pipe', 'pipe'],\n windowsHide: true,\n signal: options.signal,\n })\n\n const stdout: Buffer[] = []\n const stderr: Buffer[] = []\n let outputBytes = 0\n let settled = false\n let timer: ReturnType<typeof setTimeout> | undefined\n\n const finish = (callback: () => void) => {\n if (settled) return\n settled = true\n if (timer !== undefined) clearTimeout(timer)\n callback()\n }\n\n const capture = (target: Buffer[], chunk: Buffer) => {\n outputBytes += chunk.length\n if (outputBytes > maxOutputBytes) {\n child.kill('SIGTERM')\n finish(() => reject(new GetnoteCliError(\n `getnote output exceeded ${maxOutputBytes} bytes`,\n null,\n Buffer.concat(stderr).toString('utf8'),\n )))\n return\n }\n target.push(chunk)\n }\n\n child.stdout.on('data', (chunk: Buffer) => capture(stdout, chunk))\n child.stderr.on('data', (chunk: Buffer) => capture(stderr, chunk))\n\n timer = setTimeout(() => {\n child.kill('SIGTERM')\n finish(() => reject(new GetnoteCliError(\n `getnote command timed out after ${timeoutMs} ms`,\n null,\n Buffer.concat(stderr).toString('utf8'),\n )))\n }, timeoutMs)\n\n child.on('error', (error) => {\n finish(() => reject(new GetnoteCliError(\n `failed to start getnote: ${error.message}`,\n null,\n Buffer.concat(stderr).toString('utf8'),\n )))\n })\n\n child.on('close', (code) => {\n finish(() => {\n const stdoutText = Buffer.concat(stdout).toString('utf8').trim()\n const stderrText = Buffer.concat(stderr).toString('utf8').trim()\n if (code !== 0) {\n reject(new GetnoteCliError(\n stderrText || stdoutText || `getnote exited with code ${String(code)}`,\n code,\n stderrText,\n ))\n return\n }\n\n if (!stdoutText) {\n resolve(null)\n return\n }\n\n try {\n resolve(JSON.parse(stdoutText))\n } catch {\n // A few informational CLI commands (notably auth status in CLI 1.5)\n // still return plain text even when --output json is requested.\n resolve(stdoutText)\n }\n })\n })\n })\n}\n","import type { Context } from '@deepseek-ai/cordis'\nimport { apply as applySkillFilesystem } from '@deepseek-ai/dsh-skill-filesystem'\nimport { defineTool } from '@deepseek-ai/dsh-tools'\nimport Schema from '@deepseek-ai/schemastery'\nimport { fileURLToPath } from 'node:url'\nimport { runGetnote, type RunGetnoteOptions } from './cli-runner.js'\n\nexport const name = 'getnote-tools'\nexport const inject = ['tools', 'skills']\n\nexport interface Config {\n binaryPath?: string\n apiUrl?: string\n timeoutMs: number\n maxOutputBytes: number\n}\n\nexport const Config: Schema<Config> = Schema.object({\n binaryPath: Schema.string().description('Optional absolute path to the getnote executable.'),\n apiUrl: Schema.string().description('Optional GetNote OpenAPI base URL for explicit integration testing.'),\n timeoutMs: Schema.number().min(1_000).default(120_000),\n maxOutputBytes: Schema.number().min(1_024).default(10 * 1024 * 1024),\n})\n\nfunction renderJson(value: unknown): string {\n if (typeof value === 'string') return value\n return JSON.stringify(value, null, 2)\n}\n\nfunction runnerOptions(config: Config, signal?: AbortSignal): RunGetnoteOptions {\n return {\n binaryPath: config.binaryPath,\n apiUrl: config.apiUrl,\n timeoutMs: config.timeoutMs,\n maxOutputBytes: config.maxOutputBytes,\n signal,\n }\n}\n\nfunction textOutput() {\n return {\n schema: { type: 'string' as const },\n render: (_args: unknown, value: string) => [{ type: 'text' as const, text: value }],\n }\n}\n\nfunction integerInRange(value: number | undefined, fallback: number, min: number, max: number): number {\n const resolved = value ?? fallback\n if (!Number.isInteger(resolved) || resolved < min || resolved > max) {\n throw new RangeError(`value must be an integer between ${min} and ${max}`)\n }\n return resolved\n}\n\nexport function apply(ctx: Context, config: Config) {\n applySkillFilesystem(ctx, {\n providerName: 'getnote',\n includeDefaultRoots: false,\n bundledSkillDir: fileURLToPath(new URL('../skills', import.meta.url)),\n })\n\n ctx.tools.register(defineTool({\n name: 'getnote_auth_status',\n description: 'Check whether the current user is authenticated with GetNote (得到大脑).',\n parameters: {},\n output: textOutput(),\n async execute(_args, exec) {\n await runGetnote(['auth', 'status'], runnerOptions(config, exec.signal))\n return 'Authenticated with GetNote.'\n },\n }))\n\n ctx.tools.register(defineTool({\n name: 'getnote_search',\n description: 'Semantically search notes in GetNote, optionally within one knowledge base.',\n parameters: {\n query: { type: 'string', required: true, description: 'Natural-language search query.' },\n knowledge_base_id: { type: 'string', description: 'Optional knowledge base/topic ID.' },\n limit: { type: 'integer', default: 10, description: 'Maximum results, from 1 to 10.' },\n },\n output: textOutput(),\n async execute(args, exec) {\n const limit = integerInRange(args.limit, 10, 1, 10)\n const cliArgs = ['search', args.query, '--limit', String(limit)]\n if (args.knowledge_base_id) cliArgs.push('--kb', args.knowledge_base_id)\n return renderJson(await runGetnote(cliArgs, runnerOptions(config, exec.signal)))\n },\n }))\n\n ctx.tools.register(defineTool({\n name: 'getnote_save',\n description: 'Save text, a URL, or a local image path as a note in GetNote.',\n parameters: {\n content: { type: 'string', required: true, description: 'Text, URL, or local image path to save.' },\n title: { type: 'string', description: 'Optional note title.' },\n tags: { type: 'array', items: { type: 'string' }, description: 'Optional note tags.' },\n },\n output: textOutput(),\n async execute(args, exec) {\n const cliArgs = ['save', args.content]\n if (args.title) cliArgs.push('--title', args.title)\n for (const tag of args.tags ?? []) cliArgs.push('--tag', tag)\n return renderJson(await runGetnote(cliArgs, runnerOptions(config, exec.signal)))\n },\n }))\n\n ctx.tools.register(defineTool({\n name: 'getnote_list_notes',\n description: 'List recent notes from GetNote.',\n parameters: {\n limit: { type: 'integer', default: 20, description: 'Number of notes, from 1 to 100.' },\n since_id: { type: 'string', description: 'Optional pagination cursor note ID.' },\n },\n output: textOutput(),\n async execute(args, exec) {\n const limit = integerInRange(args.limit, 20, 1, 100)\n const cliArgs = ['notes', '--limit', String(limit)]\n if (args.since_id) cliArgs.push('--since-id', args.since_id)\n return renderJson(await runGetnote(cliArgs, runnerOptions(config, exec.signal)))\n },\n }))\n\n ctx.tools.register(defineTool({\n name: 'getnote_get_note',\n description: 'Get the complete details of one GetNote note by its string ID.',\n parameters: {\n note_id: { type: 'string', required: true, description: 'Note ID. Keep it as a string.' },\n },\n output: textOutput(),\n async execute(args, exec) {\n return renderJson(await runGetnote(['note', args.note_id], runnerOptions(config, exec.signal)))\n },\n }))\n\n ctx.tools.register(defineTool({\n name: 'getnote_list_knowledge_bases',\n description: 'List the current user\\'s GetNote knowledge bases.',\n parameters: {},\n output: textOutput(),\n async execute(_args, exec) {\n return renderJson(await runGetnote(['kbs'], runnerOptions(config, exec.signal)))\n },\n }))\n}\n\nexport {\n GetnoteCliError,\n resolveGetnoteBinary,\n resolveGetnoteFromPath,\n runGetnote,\n} from './cli-runner.js'\n"],"mappings":";;;;;;;;;AAKA,MAAM,UAAU,cAAc,YAAY,GAAG;AAU7C,IAAa,kBAAb,cAAqC,MAAM;CAG9B;CACA;CAHX,YACE,SACA,UACA,QACA;EACA,MAAM,OAAO;EAHJ,KAAA,WAAA;EACA,KAAA,SAAA;EAGT,KAAK,OAAO;CACd;AACF;AAEA,SAAgB,uBAA+B;CAC7C,MAAM,cAAc,QAAQ,QAAQ,2BAA2B;CAC/D,MAAM,SAAS,QAAQ,aAAa,UAAU,gBAAgB;CAC9D,OAAO,KAAK,QAAQ,WAAW,GAAG,OAAO,MAAM;AACjD;AAOA,SAAgB,uBACd,YAAY,QAAQ,IAAI,QAAQ,IAChC,eAAe,QAAQ,IAAI,WAAW,uBAClB;CACpB,MAAM,aAAa,QAAQ,aAAa,UACpC,aAAa,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO,IACtC,CAAC,EAAE;CAEP,KAAK,MAAM,aAAa,UAAU,MAAM,SAAS,CAAC,CAAC,OAAO,OAAO,GAC/D,KAAK,MAAM,aAAa,YAAY;EAClC,MAAM,YAAY,KAAK,WAAW,UAAU,UAAU,YAAY,GAAG;EACrE,IAAI;GACF,WAAW,WAAW,UAAU,IAAI;GACpC,OAAO;EACT,QAAQ,CAER;CACF;AAEJ;AAEA,SAAS,yBAAyB,YAAwC;CACxE,IAAI,YAAY,OAAO;EAAE,SAAS;EAAY,YAAY,CAAC;CA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AU;IAAC;IAAS;IAAW,OAAO,KAAK;GAAC;GAClD,IAAI,KAAK,UAAU,QAAQ,KAAK,cAAc,KAAK,QAAQ;GAC3D,OAAO,WAAW,MAAM,WAAW,SAAS,cAAc,QAAQ,KAAK,MAAM,CAAC,CAAC;EACjF;CACF,CAAC,CAAC;CAEF,IAAI,MAAM,SAAS,WAAW;EAC5B,MAAM;EACN,aAAa;EACb,YAAY,EACV,SAAS;GAAE,MAAM;GAAU,UAAU;GAAM,aAAa;EAAgC,EAC1F;EACA,QAAQ,WAAW;EACnB,MAAM,QAAQ,MAAM,MAAM;GACxB,OAAO,WAAW,MAAM,WAAW,CAAC,QAAQ,KAAK,OAAO,GAAG,cAAc,QAAQ,KAAK,MAAM,CAAC,CAAC;EAChG;CACF,CAAC,CAAC;CAEF,IAAI,MAAM,SAAS,WAAW;EAC5B,MAAM;EACN,aAAa;EACb,YAAY,CAAC;EACb,QAAQ,WAAW;EACnB,MAAM,QAAQ,OAAO,MAAM;GACzB,OAAO,WAAW,MAAM,WAAW,CAAC,KAAK,GAAG,cAAc,QAAQ,KAAK,MAAM,CAAC,CAAC;EACjF;CACF,CAAC,CAAC;AACJ"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface RunGetnoteOptions {
|
|
2
|
+
binaryPath?: string;
|
|
3
|
+
apiUrl?: string;
|
|
4
|
+
signal?: AbortSignal;
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
maxOutputBytes?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare class GetnoteCliError extends Error {
|
|
9
|
+
readonly exitCode: number | null;
|
|
10
|
+
readonly stderr: string;
|
|
11
|
+
constructor(message: string, exitCode: number | null, stderr: string);
|
|
12
|
+
}
|
|
13
|
+
export declare function resolveGetnoteBinary(): string;
|
|
14
|
+
export declare function resolveGetnoteFromPath(pathValue?: string, pathExtValue?: string): string | undefined;
|
|
15
|
+
export declare function runGetnote(args: readonly string[], options?: RunGetnoteOptions): Promise<unknown>;
|
|
16
|
+
//# sourceMappingURL=cli-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-runner.d.ts","sourceRoot":"","sources":["../../src/cli-runner.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,qBAAa,eAAgB,SAAQ,KAAK;IAGtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM;gBAFvB,OAAO,EAAE,MAAM,EACN,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,MAAM,EAAE,MAAM;CAK1B;AAED,wBAAgB,oBAAoB,IAAI,MAAM,CAI7C;AAOD,wBAAgB,sBAAsB,CACpC,SAAS,SAAyB,EAClC,YAAY,SAA+C,GAC1D,MAAM,GAAG,SAAS,CAgBpB;AAkBD,wBAAsB,UAAU,CAC9B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,OAAO,CAAC,CA4FlB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import Schema from '@deepseek-ai/schemastery';
|
|
3
|
+
export declare const name = "getnote-tools";
|
|
4
|
+
export declare const inject: string[];
|
|
5
|
+
export interface Config {
|
|
6
|
+
binaryPath?: string;
|
|
7
|
+
apiUrl?: string;
|
|
8
|
+
timeoutMs: number;
|
|
9
|
+
maxOutputBytes: number;
|
|
10
|
+
}
|
|
11
|
+
export declare const Config: Schema<Config>;
|
|
12
|
+
export declare function apply(ctx: Context, config: Config): void;
|
|
13
|
+
export { GetnoteCliError, resolveGetnoteBinary, resolveGetnoteFromPath, runGetnote, } from './cli-runner.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGlD,OAAO,MAAM,MAAM,0BAA0B,CAAA;AAI7C,eAAO,MAAM,IAAI,kBAAkB,CAAA;AACnC,eAAO,MAAM,MAAM,UAAsB,CAAA;AAEzC,MAAM,WAAW,MAAM;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,CAKhC,CAAA;AAgCF,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAyFjD;AAED,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,UAAU,GACX,MAAM,iBAAiB,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@getnote/dsh-plugin",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "在 DeepSeek Harness 中用自然语言搜索、保存和阅读得到大脑笔记",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./lib/index.js",
|
|
7
|
+
"types": "./lib/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/types/index.d.ts",
|
|
11
|
+
"import": "./lib/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"lib/",
|
|
16
|
+
"skills/getnote-dsh/",
|
|
17
|
+
"cordis.patch.yml",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsdown && tsc --emitDeclarationOnly --declaration --declarationMap --outDir lib/types",
|
|
23
|
+
"check": "tsc --noEmit",
|
|
24
|
+
"test": "node --test",
|
|
25
|
+
"prepare": "npm run build",
|
|
26
|
+
"prepublishOnly": "npm run check && npm test && npm run build"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"deepseek-harness",
|
|
30
|
+
"dsh-plugin",
|
|
31
|
+
"getnote",
|
|
32
|
+
"notes",
|
|
33
|
+
"knowledge-base"
|
|
34
|
+
],
|
|
35
|
+
"homepage": "https://github.com/iswalle/getnote-dsh-plugin#readme",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/iswalle/getnote-dsh-plugin.git"
|
|
39
|
+
},
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/iswalle/getnote-dsh-plugin/issues"
|
|
42
|
+
},
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
46
|
+
"@deepseek-ai/dsh-skill-filesystem": ">=0.1.0-rc.6 <1",
|
|
47
|
+
"@deepseek-ai/dsh-tools": ">=0.1.0-rc.6 <1"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
51
|
+
"@deepseek-ai/dsh-skill-filesystem": "0.1.0-rc.6",
|
|
52
|
+
"@deepseek-ai/dsh-tools": "0.1.0-rc.6",
|
|
53
|
+
"@deepseek-ai/schemastery": "^3.18.1",
|
|
54
|
+
"@types/node": "^22.0.0",
|
|
55
|
+
"tsdown": "^0.12.9",
|
|
56
|
+
"typescript": "^5.9.2"
|
|
57
|
+
},
|
|
58
|
+
"dsh": {
|
|
59
|
+
"bundle": {
|
|
60
|
+
"patch": "./cordis.patch.yml"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"engines": {
|
|
64
|
+
"node": ">=20"
|
|
65
|
+
},
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"access": "public",
|
|
68
|
+
"provenance": true
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: getnote-dsh
|
|
3
|
+
description: 在 DeepSeek Harness 中使用得到大脑。用户要搜索、保存、列出或打开得到大脑笔记,查看知识库或检查登录状态时使用。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 得到大脑(DSH)
|
|
7
|
+
|
|
8
|
+
优先使用插件提供的 `getnote_*` 原生工具完成操作:
|
|
9
|
+
|
|
10
|
+
- `getnote_auth_status`:检查登录状态。
|
|
11
|
+
- `getnote_search`:语义搜索笔记,可限定知识库。
|
|
12
|
+
- `getnote_save`:保存文字、链接或本地图片,可设置标题和标签。
|
|
13
|
+
- `getnote_list_notes`:列出最近笔记。
|
|
14
|
+
- `getnote_get_note`:按字符串 ID 打开笔记。
|
|
15
|
+
- `getnote_list_knowledge_bases`:列出知识库。
|
|
16
|
+
|
|
17
|
+
笔记 ID 必须始终按字符串处理,不得转换为数字。
|
|
18
|
+
|
|
19
|
+
如果用户请求的能力不在这些工具中,优先使用 DSH 已发现的用户级 GetNote Skill;
|
|
20
|
+
不要为了绕过工具边界自行拼接未经说明的 Shell 命令。若没有相应 Skill,说明当前
|
|
21
|
+
插件尚未支持该操作,并建议用户安装或更新 GetNote Skills。
|
|
22
|
+
|
|
23
|
+
认证由本机 GetNote CLI 管理。未登录时,请用户在终端执行:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npx @getnote/cli@latest auth login
|
|
27
|
+
```
|