dsh-llm-codebuddy 1.2.1 → 1.3.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/README.md +67 -105
- package/cli.js +88 -0
- package/package.json +8 -4
- package/install.ps1 +0 -13
package/README.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# DSH CodeBuddy Provider
|
|
2
2
|
|
|
3
|
-
为 DeepSeek Harness(DSH)增加
|
|
4
|
-
|
|
5
|
-
调整模型参数并使用 CodeBuddy 模型。
|
|
3
|
+
为 DeepSeek Harness(DSH)增加 `CodeBuddy 中国区` Provider。安装后可直接在
|
|
4
|
+
DSH WebUI 中填写 API Key、获取模型、调整模型参数并使用 CodeBuddy 模型。
|
|
6
5
|
|
|
7
6
|
> [!IMPORTANT]
|
|
8
7
|
> API Key 由 **WorkBuddy** 提供,本插件使用该 Key 调用供 CodeBuddy 使用的模型服务。
|
|
@@ -11,62 +10,44 @@
|
|
|
11
10
|
|
|
12
11
|
## 功能
|
|
13
12
|
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
- 支持编辑模型 ID
|
|
13
|
+
- WebUI 中直接添加 `CodeBuddy 中国区`;
|
|
14
|
+
- 只需填写从 WorkBuddy 获取的 API Key;
|
|
15
|
+
- 自动获取 CodeBuddy 当前可用模型;
|
|
16
|
+
- 支持编辑模型 ID、名称、上下文窗口和最大输出 Token;
|
|
18
17
|
- 支持添加、删除模型以及重新同步模型目录;
|
|
19
18
|
- 支持 `minimal / low / medium / high / xhigh / max` 思考程度;
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
- 插件独立安装,不修改 DSH 全局安装目录。
|
|
19
|
+
- 输入新 API Key 可替换旧值,留空保存则保留原值;
|
|
20
|
+
- 模型接口暂时不可用时使用内置目录兜底;
|
|
21
|
+
- 独立安装,不修改 DSH 全局安装目录。
|
|
24
22
|
|
|
25
|
-
##
|
|
23
|
+
## 环境要求
|
|
26
24
|
|
|
27
|
-
- Windows、Linux
|
|
25
|
+
- Windows、Linux 或 macOS;
|
|
28
26
|
- Node.js `>= 22.19.0`;
|
|
29
|
-
-
|
|
30
|
-
-
|
|
27
|
+
- 已安装 DSH;
|
|
28
|
+
- 已验证 DSH `0.1.0-rc.6`。
|
|
31
29
|
|
|
32
|
-
> DSH
|
|
33
|
-
>
|
|
30
|
+
> DSH 仍处于预发布阶段。未来版本如果调整插件接口,本插件可能需要同步升级;
|
|
31
|
+
> DSH 普通更新不会覆盖本插件。
|
|
34
32
|
|
|
35
33
|
## 安装
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
发布到 npm 后执行:
|
|
35
|
+
推荐使用一键安装命令:
|
|
40
36
|
|
|
41
37
|
```powershell
|
|
42
|
-
|
|
43
|
-
dsh plugin --profile headless add dsh-llm-codebuddy
|
|
38
|
+
npx --yes dsh-llm-codebuddy@latest install
|
|
44
39
|
```
|
|
45
40
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
### 从 GitHub 安装
|
|
49
|
-
|
|
50
|
-
```powershell
|
|
51
|
-
dsh plugin --profile web add github:Axiaohungry/dsh-llm-codebuddy
|
|
52
|
-
dsh plugin --profile headless add github:Axiaohungry/dsh-llm-codebuddy
|
|
53
|
-
```
|
|
41
|
+
该命令会为 DSH 的 `web` 和 `headless` Profile 安装插件。完成后重启 DSH。
|
|
54
42
|
|
|
55
|
-
|
|
43
|
+
也可以分别安装:
|
|
56
44
|
|
|
57
45
|
```powershell
|
|
58
|
-
dsh plugin --profile web add
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
### 从源码安装
|
|
62
|
-
|
|
63
|
-
```powershell
|
|
64
|
-
git clone https://github.com/Axiaohungry/dsh-llm-codebuddy.git
|
|
65
|
-
cd dsh-llm-codebuddy
|
|
66
|
-
.\install.ps1
|
|
46
|
+
dsh plugin --profile web add dsh-llm-codebuddy@latest
|
|
47
|
+
dsh plugin --profile headless add dsh-llm-codebuddy@latest
|
|
67
48
|
```
|
|
68
49
|
|
|
69
|
-
|
|
50
|
+
只使用 WebUI 时,仅执行第一条即可。
|
|
70
51
|
|
|
71
52
|
## WebUI 配置
|
|
72
53
|
|
|
@@ -75,110 +56,91 @@ cd dsh-llm-codebuddy
|
|
|
75
56
|
3. 选择 `CodeBuddy 中国区`。
|
|
76
57
|
4. 输入从 WorkBuddy 获取的 API Key 并保存。
|
|
77
58
|
5. 点击该 Provider 的“编辑”,展开“自定义设置”。
|
|
78
|
-
6.
|
|
59
|
+
6. 点击“获取可用模型”,选择需要的模型并导入。
|
|
79
60
|
7. 按需修改模型参数,然后保存。
|
|
80
61
|
|
|
81
|
-
|
|
62
|
+
再次编辑已配置的 Provider 时,会直接显示上次保存的模型目录。
|
|
82
63
|
|
|
83
|
-
##
|
|
64
|
+
## API Key 替换
|
|
84
65
|
|
|
85
|
-
-
|
|
86
|
-
-
|
|
87
|
-
-
|
|
88
|
-
- 新模型缺少容量时:上下文窗口默认为 `262144`,最大输出默认为 `32768`;
|
|
89
|
-
- 点击“恢复默认模型”:删除自定义目录,恢复适配器目录。
|
|
66
|
+
- 输入新的 API Key 并保存:替换原 Key;
|
|
67
|
+
- API Key 输入框留空并保存:保留原 Key;
|
|
68
|
+
- 更换 Key 后建议重新点击“获取可用模型”,同步新账号的模型权限。
|
|
90
69
|
|
|
91
|
-
|
|
92
|
-
CodeBuddy 仍可能拒绝请求。
|
|
70
|
+
API Key 由 DSH 凭据服务保存,不会写入模型目录或插件源码。
|
|
93
71
|
|
|
94
|
-
##
|
|
72
|
+
## 模型配置
|
|
95
73
|
|
|
96
|
-
|
|
97
|
-
|
|
74
|
+
- 没有自定义目录:使用 CodeBuddy 在线目录,失败时使用内置目录;
|
|
75
|
+
- 保存自定义目录:仅向 DSH 提供目录中保留的模型;
|
|
76
|
+
- 已知模型字段留空:继承在线目录或内置目录中的值;
|
|
77
|
+
- 新模型缺少容量:上下文窗口默认 `262144`,最大输出默认 `32768`;
|
|
78
|
+
- 点击“恢复默认模型”:删除自定义目录并恢复适配器目录。
|
|
79
|
+
|
|
80
|
+
配置值超过服务端真实限制时,CodeBuddy 仍可能拒绝请求。
|
|
81
|
+
|
|
82
|
+
## 思考程度
|
|
98
83
|
|
|
99
|
-
|
|
84
|
+
DSH 显示思考程度选项,插件把选中的档位转换为 `reasoning_effort` 并发送给
|
|
85
|
+
CodeBuddy。模型推理由 CodeBuddy 云端执行。
|
|
100
86
|
|
|
101
87
|
```text
|
|
102
88
|
minimal / low / medium / high / xhigh / max
|
|
103
89
|
```
|
|
104
90
|
|
|
105
|
-
|
|
91
|
+
当前不提供 `off`,因为 CodeBuddy 模型目录中的模型属于推理模型。未选择档位时,
|
|
92
|
+
使用 CodeBuddy 对应模型的默认值。
|
|
106
93
|
|
|
107
94
|
## 更新
|
|
108
95
|
|
|
109
|
-
|
|
96
|
+
重新运行安装命令即可更新到最新版:
|
|
110
97
|
|
|
111
98
|
```powershell
|
|
112
|
-
|
|
113
|
-
dsh plugin --profile headless add dsh-llm-codebuddy@latest
|
|
99
|
+
npx --yes dsh-llm-codebuddy@latest install
|
|
114
100
|
```
|
|
115
101
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
```powershell
|
|
119
|
-
dsh plugin --profile web add github:Axiaohungry/dsh-llm-codebuddy#v1.2.1
|
|
120
|
-
dsh plugin --profile headless add github:Axiaohungry/dsh-llm-codebuddy#v1.2.1
|
|
121
|
-
```
|
|
102
|
+
更新完成后重启 DSH。模型配置和 API Key 不会被覆盖。
|
|
122
103
|
|
|
123
104
|
## 卸载
|
|
124
105
|
|
|
125
106
|
```powershell
|
|
126
|
-
|
|
127
|
-
dsh plugin --profile headless remove dsh-llm-codebuddy
|
|
107
|
+
npx --yes dsh-llm-codebuddy@latest uninstall
|
|
128
108
|
```
|
|
129
109
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
## 打包与发布
|
|
110
|
+
卸载命令会:
|
|
133
111
|
|
|
134
|
-
|
|
112
|
+
1. 备份 `~/.dsh/settings.yaml`;
|
|
113
|
+
2. 只删除 `llm-pi-ai.providers.codebuddy-cn` 配置;
|
|
114
|
+
3. 保留其他 Provider 和 DSH 设置;
|
|
115
|
+
4. 从 `web`、`headless` Profile 移除插件;
|
|
116
|
+
5. 保留 API Key 凭据,方便以后重新安装。
|
|
135
117
|
|
|
136
|
-
|
|
118
|
+
完成后重启 DSH。备份文件名类似:
|
|
137
119
|
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
git add .
|
|
141
|
-
git commit -m "发布 dsh-llm-codebuddy v1.2.1"
|
|
142
|
-
git branch -M main
|
|
143
|
-
git remote add origin git@github.com:Axiaohungry/dsh-llm-codebuddy.git
|
|
144
|
-
git push -u origin main
|
|
145
|
-
git tag v1.2.1
|
|
146
|
-
git push origin v1.2.1
|
|
120
|
+
```text
|
|
121
|
+
settings.yaml.codebuddy-backup-2026-08-14T12-00-00-000Z
|
|
147
122
|
```
|
|
148
123
|
|
|
149
|
-
|
|
124
|
+
源码仓库、本地安装包和 API Key 不会被删除。
|
|
150
125
|
|
|
151
|
-
|
|
126
|
+
## 常见问题
|
|
152
127
|
|
|
153
|
-
|
|
154
|
-
npm ci --ignore-scripts
|
|
155
|
-
npm run check
|
|
156
|
-
npm pack
|
|
157
|
-
```
|
|
128
|
+
### 安装后看不到 CodeBuddy
|
|
158
129
|
|
|
159
|
-
|
|
130
|
+
确认已经重启 DSH,并检查 Web Profile:
|
|
160
131
|
|
|
161
132
|
```powershell
|
|
162
|
-
dsh plugin --profile web
|
|
133
|
+
dsh plugin --profile web list --depth 0
|
|
163
134
|
```
|
|
164
135
|
|
|
165
|
-
###
|
|
166
|
-
|
|
167
|
-
首次发布:
|
|
168
|
-
|
|
169
|
-
```powershell
|
|
170
|
-
npm login
|
|
171
|
-
npm publish
|
|
172
|
-
```
|
|
136
|
+
### 获取模型失败
|
|
173
137
|
|
|
174
|
-
|
|
138
|
+
确认 API Key 来自 WorkBuddy 且仍然有效,然后重新输入 Key 并点击“获取可用模型”。
|
|
139
|
+
接口临时不可用时,插件仍会提供内置模型目录。
|
|
175
140
|
|
|
176
|
-
|
|
141
|
+
### 卸载后仍显示旧页面
|
|
177
142
|
|
|
178
|
-
|
|
179
|
-
- API Key 由 DSH 凭据服务保存,插件不把密钥写入模型目录;
|
|
180
|
-
- npm 包只包含 `package.json` 中 `files` 指定的运行文件和文档;
|
|
181
|
-
- 发布前务必使用 `npm pack --dry-run` 检查包内容。
|
|
143
|
+
关闭正在运行的 DSH,再重新启动。已经运行的进程不会自动卸载内存中的插件。
|
|
182
144
|
|
|
183
145
|
## 工作原理
|
|
184
146
|
|
|
@@ -190,7 +152,7 @@ DSH Agent → 本插件 → CodeBuddy /v2/chat/completions
|
|
|
190
152
|
```
|
|
191
153
|
|
|
192
154
|
- DSH:负责 Agent 循环、上下文、工具调用和权限;
|
|
193
|
-
- WorkBuddy
|
|
155
|
+
- WorkBuddy:提供 API Key;
|
|
194
156
|
- 插件:负责 Provider 注册、模型目录转换和请求兼容;
|
|
195
157
|
- CodeBuddy:负责模型推理并返回结果。
|
|
196
158
|
|
package/cli.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { copyFileSync, existsSync, mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { homedir, tmpdir } from "node:os";
|
|
5
|
+
import { dirname, join, resolve } from "node:path";
|
|
6
|
+
import { spawnSync } from "node:child_process";
|
|
7
|
+
import { parseDocument } from "yaml";
|
|
8
|
+
|
|
9
|
+
const PACKAGE = "dsh-llm-codebuddy";
|
|
10
|
+
const PROVIDER_PATH = ["llm-pi-ai", "providers", "codebuddy-cn"];
|
|
11
|
+
|
|
12
|
+
function dshHome() {
|
|
13
|
+
return resolve(process.env.DSH_HOME || join(homedir(), ".dsh"));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function profileHasPlugin(home, profile) {
|
|
17
|
+
const file = join(home, "profiles", profile, "package.json");
|
|
18
|
+
if (!existsSync(file)) return false;
|
|
19
|
+
const json = JSON.parse(readFileSync(file, "utf8"));
|
|
20
|
+
return Boolean(json.dependencies?.[PACKAGE] || json.devDependencies?.[PACKAGE]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function runDsh(args) {
|
|
24
|
+
const result = spawnSync(process.platform === "win32" ? "dsh.cmd" : "dsh", args, {
|
|
25
|
+
stdio: "inherit",
|
|
26
|
+
shell: process.platform === "win32",
|
|
27
|
+
});
|
|
28
|
+
if (result.error) throw result.error;
|
|
29
|
+
if (result.status !== 0) throw new Error(`dsh ${args.join(" ")} 执行失败(退出码 ${result.status})`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function cleanSettings(file) {
|
|
33
|
+
if (!existsSync(file)) return undefined;
|
|
34
|
+
const source = readFileSync(file, "utf8");
|
|
35
|
+
const document = parseDocument(source);
|
|
36
|
+
if (document.errors.length) throw new Error(`无法解析 ${file}:${document.errors[0].message}`);
|
|
37
|
+
if (!document.hasIn(PROVIDER_PATH)) return undefined;
|
|
38
|
+
|
|
39
|
+
document.deleteIn(PROVIDER_PATH);
|
|
40
|
+
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
41
|
+
const backup = `${file}.codebuddy-backup-${stamp}`;
|
|
42
|
+
const temporary = join(dirname(file), `.settings-codebuddy-${process.pid}.tmp`);
|
|
43
|
+
copyFileSync(file, backup);
|
|
44
|
+
writeFileSync(temporary, String(document), "utf8");
|
|
45
|
+
renameSync(temporary, file);
|
|
46
|
+
return backup;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function install() {
|
|
50
|
+
for (const profile of ["web", "headless"]) {
|
|
51
|
+
runDsh(["plugin", "--profile", profile, "add", `${PACKAGE}@latest`]);
|
|
52
|
+
}
|
|
53
|
+
console.log("CodeBuddy Provider 已安装。请重启 DSH 后进行配置。");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function uninstall(home = dshHome()) {
|
|
57
|
+
const backup = cleanSettings(join(home, "settings.yaml"));
|
|
58
|
+
for (const profile of ["web", "headless"]) {
|
|
59
|
+
if (profileHasPlugin(home, profile)) runDsh(["plugin", "--profile", profile, "remove", PACKAGE]);
|
|
60
|
+
}
|
|
61
|
+
console.log(backup ? `CodeBuddy 配置已清理,备份:${backup}` : "未发现 CodeBuddy Provider 配置。");
|
|
62
|
+
console.log("插件已卸载,API Key 凭据保持不变。请重启 DSH。");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function selfTest() {
|
|
66
|
+
const root = mkdtempSync(join(tmpdir(), "dsh-codebuddy-cli-"));
|
|
67
|
+
try {
|
|
68
|
+
const file = join(root, "settings.yaml");
|
|
69
|
+
writeFileSync(file, "llm-pi-ai:\n providers:\n opencode-go:\n apiKeyEnv: OPENCODE_GO_API_KEY\n codebuddy-cn:\n apiKeyEnv: CODEBUDDY_CN_API_KEY\n", "utf8");
|
|
70
|
+
const backup = cleanSettings(file);
|
|
71
|
+
const result = parseDocument(readFileSync(file, "utf8"));
|
|
72
|
+
if (!backup || !existsSync(backup) || result.hasIn(PROVIDER_PATH) || !result.hasIn(["llm-pi-ai", "providers", "opencode-go"])) {
|
|
73
|
+
throw new Error("uninstall settings cleanup self-test failed");
|
|
74
|
+
}
|
|
75
|
+
console.log("CLI-SELF-TEST-OK");
|
|
76
|
+
} finally {
|
|
77
|
+
rmSync(root, { recursive: true, force: true });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const command = process.argv[2];
|
|
82
|
+
if (command === "install") install();
|
|
83
|
+
else if (command === "uninstall") uninstall();
|
|
84
|
+
else if (command === "--self-test") selfTest();
|
|
85
|
+
else {
|
|
86
|
+
console.log("用法:dsh-llm-codebuddy <install|uninstall>");
|
|
87
|
+
process.exitCode = 1;
|
|
88
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-llm-codebuddy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "使用 WorkBuddy API Key 为 DeepSeek Harness 接入 CodeBuddy 模型",
|
|
5
5
|
"author": "Axiaohungry",
|
|
6
6
|
"keywords": [
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
"exports": {
|
|
17
17
|
".": "./index.js"
|
|
18
18
|
},
|
|
19
|
+
"bin": {
|
|
20
|
+
"dsh-llm-codebuddy": "cli.js"
|
|
21
|
+
},
|
|
19
22
|
"repository": {
|
|
20
23
|
"type": "git",
|
|
21
24
|
"url": "git+https://github.com/Axiaohungry/dsh-llm-codebuddy.git"
|
|
@@ -26,13 +29,13 @@
|
|
|
26
29
|
},
|
|
27
30
|
"files": [
|
|
28
31
|
"index.js",
|
|
32
|
+
"cli.js",
|
|
29
33
|
"cordis.patch.yml",
|
|
30
|
-
"install.ps1",
|
|
31
34
|
"README.md",
|
|
32
35
|
"LICENSE"
|
|
33
36
|
],
|
|
34
37
|
"scripts": {
|
|
35
|
-
"check": "node --check index.js"
|
|
38
|
+
"check": "node --check index.js && node --check cli.js && node cli.js --self-test"
|
|
36
39
|
},
|
|
37
40
|
"dsh": {
|
|
38
41
|
"bundle": {
|
|
@@ -45,7 +48,8 @@
|
|
|
45
48
|
"@deepseek-ai/dsh-llm": "0.1.0-rc.6",
|
|
46
49
|
"@deepseek-ai/dsh-llm-pi-ai": "0.1.0-rc.6",
|
|
47
50
|
"@deepseek-ai/dsh-settings": "0.1.0-rc.6",
|
|
48
|
-
"@earendil-works/pi-ai": "0.82.1"
|
|
51
|
+
"@earendil-works/pi-ai": "0.82.1",
|
|
52
|
+
"yaml": "2.8.1"
|
|
49
53
|
},
|
|
50
54
|
"engines": {
|
|
51
55
|
"node": ">=22.19.0"
|
package/install.ps1
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
$ErrorActionPreference = 'Stop'
|
|
2
|
-
|
|
3
|
-
Push-Location $PSScriptRoot
|
|
4
|
-
try {
|
|
5
|
-
npm install --ignore-scripts --no-audit --no-fund
|
|
6
|
-
dsh plugin --profile web add $PSScriptRoot
|
|
7
|
-
dsh plugin --profile headless add $PSScriptRoot
|
|
8
|
-
}
|
|
9
|
-
finally {
|
|
10
|
-
Pop-Location
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
Write-Host 'CodeBuddy Provider 已安装。请重启 DSH,然后在“设置 → 模型 → 添加提供方”中选择 CodeBuddy 中国区。'
|