dsh-opencode-go 0.1.0
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 +121 -0
- package/THIRD_PARTY_NOTICES.md +3 -0
- package/cordis.patch.yml +3 -0
- package/docs/independent-package.md +13 -0
- package/docs/verification.md +50 -0
- package/examples/headless.patch.yml +4 -0
- package/examples/migrate-from-fork.patch.yml +3 -0
- package/lib/build-info.json +10 -0
- package/lib/client.js +853 -0
- package/lib/index.js +1158 -0
- package/lib/types/adapter.d.ts +101 -0
- package/lib/types/catalog.d.ts +95 -0
- package/lib/types/client/Section.d.ts +26 -0
- package/lib/types/client/index.d.ts +34 -0
- package/lib/types/client/locales.d.ts +50 -0
- package/lib/types/client/section-controller.d.ts +175 -0
- package/lib/types/client/staged-form.d.ts +184 -0
- package/lib/types/config.d.ts +52 -0
- package/lib/types/conversion/config.d.ts +4 -0
- package/lib/types/conversion/context.d.ts +49 -0
- package/lib/types/conversion/index.d.ts +5 -0
- package/lib/types/conversion/replay.d.ts +62 -0
- package/lib/types/conversion/stream.d.ts +42 -0
- package/lib/types/index.d.ts +51 -0
- package/package.json +174 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DeepSeek
|
|
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,121 @@
|
|
|
1
|
+
# dsh-opencode-go
|
|
2
|
+
|
|
3
|
+
可独立构建、打包和安装的 DeepSeek Harness OpenCode Go 插件。包含模型适配器和 Web 设置页,无需修改 DSH 源码或重新构建 DSH。
|
|
4
|
+
|
|
5
|
+
## 兼容版本
|
|
6
|
+
|
|
7
|
+
当前适配并验证 **DSH `0.1.6-alpha.1`**,依赖使用明确版本。npm 的 DSH `latest` 标签仍指向较旧版本,请勿省略版本号后假定兼容。未验证其他 DSH 版本、Desktop 或其他操作系统。
|
|
8
|
+
|
|
9
|
+
插件依赖 DSH 的公开服务接口;OpenCode Go 的请求头、模型目录和转换逻辑由本项目维护。无需安装或挂载 `dsh-llm-pi-ai` 才能使用本适配器;DSH 默认组合可以继续挂载它以服务其他提供方。
|
|
10
|
+
|
|
11
|
+
## 安装
|
|
12
|
+
|
|
13
|
+
在已经安装兼容版本 DSH 的环境执行:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
dsh plugin --profile web add dsh-opencode-go
|
|
17
|
+
dsh --profile web --dump-config
|
|
18
|
+
dsh web
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
配置树应出现 `dsh-opencode-go` 层和 `id: opencode-go`。Web 设置中打开 **OpenCode Go**,保存 API Key,再在模型选择器选择该提供方的模型。安装插件不会自动更改默认模型。
|
|
22
|
+
|
|
23
|
+
Headless 用户先把以下内容保存为当前目录下的 `headless.patch.yml`,选择默认模型:
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
- id: agent-default-model
|
|
27
|
+
config:
|
|
28
|
+
provider: opencode-go
|
|
29
|
+
model: deepseek-v4.1-flash
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
再独立安装到 Headless profile:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
dsh plugin --profile headless add dsh-opencode-go
|
|
36
|
+
read -s OPENCODE_API_KEY
|
|
37
|
+
export OPENCODE_API_KEY
|
|
38
|
+
dsh --profile headless --patch ./headless.patch.yml "你好"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
安装器若提示 pnpm 拦截依赖构建脚本,按提示在该 profile 的 `pnpm-workspace.yaml` 中逐项声明 `allowBuilds`。本次测试对 `@google/genai` 和 `protobufjs` 均设置为 `false`,未执行这些脚本;OpenCode Go 测试路径不需要它们。无需全局放开安装脚本。
|
|
42
|
+
|
|
43
|
+
### 从已有二次开发版本迁移
|
|
44
|
+
|
|
45
|
+
本插件使用配置行 `id: opencode-go`,设置命名空间仍是 `llm-opencode-go`,凭据引用仍是 `OPENCODE_API_KEY`。现有二次开发版内置行 `id: llm-opencode-go` 必须停用,避免两个适配器竞争同一个提供方路由。
|
|
46
|
+
|
|
47
|
+
把以下停用行合并进对应 profile 的 `cordis.patch.yml`,保留已有的其他配置行:
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
- id: llm-opencode-go
|
|
51
|
+
disabled: true
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
无需删除原仓库代码;停用旧行后由外部安装包提供功能。
|
|
55
|
+
|
|
56
|
+
如果通用 pi-ai 的配置也声明了 `opencode-go` 路由,请移除该路由配置。其他提供方可继续使用。
|
|
57
|
+
|
|
58
|
+
## 配置
|
|
59
|
+
|
|
60
|
+
修改对应 profile 的 `cordis.patch.yml`:
|
|
61
|
+
|
|
62
|
+
```yaml
|
|
63
|
+
- id: opencode-go
|
|
64
|
+
config:
|
|
65
|
+
enabled: true
|
|
66
|
+
apiKeyEnv: OPENCODE_API_KEY
|
|
67
|
+
baseURL: https://opencode.ai/zen/go/v1
|
|
68
|
+
refreshMinutes: 60
|
|
69
|
+
streamIdleTimeoutMs: 300000
|
|
70
|
+
maxRequestImageBytes: 20971520
|
|
71
|
+
requestImagePixelBudget: 4194304
|
|
72
|
+
requestImageMaxBytes: 1048576
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
所有字段均有默认值。`apiKeyEnv` 是凭据引用名,不是密钥;存在 credentials 服务时使用该服务,否则读取进程环境。Web 设置可覆盖基础配置,后续请求读取新值。禁用开关或移除密钥会撤销路由,设置页仍可访问。
|
|
76
|
+
|
|
77
|
+
## 请求与模型行为
|
|
78
|
+
|
|
79
|
+
- 每次请求包含 Harness User-Agent 和 `x-opencode-session`;同一会话保持相同值,无会话 ID 的请求使用独立随机值。
|
|
80
|
+
- 模型目录取 pi-ai 目录及本项目补充表与网关 `/models` 的交集。未知协议的模型不会猜测加入。
|
|
81
|
+
- 实时目录获取失败时,请求目录可回退到本地表;显式模型发现会报告失败。
|
|
82
|
+
- 保留流式输出、工具调用、历史回放及支持图片的模型转换;输入图片须有 DSH attachment 服务。
|
|
83
|
+
- 模型看到会话内容和工具定义,不增加隐藏系统提示。会话请求头用于网关路由;图片编码和历史前缀影响缓存复用。
|
|
84
|
+
|
|
85
|
+
## 从源码构建与打包
|
|
86
|
+
|
|
87
|
+
需要 Node.js `^22.19.0 || >=24.0.0` 和 npm。所有依赖从 npm 获取,不使用 `workspace:`、本机路径或 DSH 源码别名。
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
npm ci
|
|
91
|
+
npm test
|
|
92
|
+
npm pack
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`npm test` 先构建,再执行测试;`npm pack` 也会构建。产物是 `dsh-opencode-go-0.1.0.tgz`,包含 Host、Client、声明文件及 bundle 配置,不包含源码、测试或密钥。
|
|
96
|
+
|
|
97
|
+
## 验证与维护
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
npm run typecheck
|
|
101
|
+
npm test
|
|
102
|
+
npm run verify:installed -- /path/to/isolated-consumer
|
|
103
|
+
npm run verify:headless -- /path/to/isolated-consumer
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
后两项使用隔离目录中的已安装包。准备方式和实际验证记录见 [验证说明](docs/verification.md)。架构与代码来源见 [独立发布决策](docs/independent-package.md)和 [第三方声明](THIRD_PARTY_NOTICES.md)。
|
|
107
|
+
|
|
108
|
+
测试使用本地模拟网关,不会发送真实 OpenCode Go API 请求。真实账号、额度和网关当前模型可用性须在配置自己的密钥后验证。
|
|
109
|
+
|
|
110
|
+
## 卸载
|
|
111
|
+
|
|
112
|
+
```sh
|
|
113
|
+
dsh plugin --profile web remove dsh-opencode-go
|
|
114
|
+
dsh plugin --profile headless remove dsh-opencode-go
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
重启相应应用后移除插件;如默认模型仍指向 `opencode-go`,请选择其他提供方。凭据和历史会话由 DSH 管理。
|
|
118
|
+
|
|
119
|
+
## 发布
|
|
120
|
+
|
|
121
|
+
维护者在有发布权限的 npm 账号下执行 `npm publish --access public`。发布前执行 `npm run typecheck`、`npm test` 和 `npm publish --dry-run`;发布后检查 registry 版本并用包名验证安装。每次更新递增版本号,已发布的版本不可覆盖。构建脚本从 `package.json` 读取 Client 模块 ID。
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
The adapter, settings UI, and `src/conversion/{context,stream,replay}.ts` derive from DeepSeek Harness, copyright (c) 2026 DeepSeek, under the MIT license included in LICENSE. The conversion modules are maintained in this package because the published DSH pi-ai package does not export its conversion helpers. Wire protocol implementations remain supplied by `@earendil-works/pi-ai`.
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Independent package decision
|
|
2
|
+
|
|
3
|
+
The plugin owns its Host adapter, Web settings entry, build, package manifest, activation layer, and tests. It consumes DSH through published npm exports. The source tree and build have no reference to a DSH checkout.
|
|
4
|
+
|
|
5
|
+
The Host depends on DSH services through peer dependencies so Cordis service classes and LLM error identities remain shared with the application. The Client resolves React, the store, and UI primitives through the DSH module table. UI type packages are optional peers because headless installations do not mount those services; this project's development dependencies supply the types and test runtime libraries.
|
|
6
|
+
|
|
7
|
+
The package's bundle inserts `id: opencode-go`. The original fork's `llm-opencode-go` row can be disabled by a profile patch. Plugin registration does not select the user's default model or replace another provider automatically.
|
|
8
|
+
|
|
9
|
+
Published `@deepseek-ai/dsh-llm-pi-ai` versions `0.1.5-rc.2` and `0.1.6-alpha.1` do not export `./conversion`. This package therefore carries the request-history, stream, and replay conversion modules under `src/conversion`, with the upstream MIT license. It does not import unpublished files or bundle the whole adapter. Protocol transport remains implemented by pi-ai. Conversion maintenance is now this project's responsibility; a future public conversion library can replace these modules once published and tested.
|
|
10
|
+
|
|
11
|
+
The build uses esbuild and lightningcss directly. Node imports stay external; the browser factory follows DSH's `window.__ModuleLoader__.load` format, embeds CSS Modules, and allows only the declared platform module imports. A package-level builder is sufficient for this single external plugin; extracting a general DSH build-tool package would require a separate release and is not a prerequisite for installation.
|
|
12
|
+
|
|
13
|
+
The initial source derives from the user's working copy of DeepSeek Harness on branch `oh-my-dsh`, whose HEAD was `2c8555b323f3b49eac743bafd527f9f3238bf548`, including the uncommitted OpenCode Go settings changes present when this project was created. Runtime conversion modules retain their published behavior. The original checkout is unchanged by this extraction.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Verification
|
|
2
|
+
|
|
3
|
+
Verified on macOS with Node.js 24.14.1 and npm-installed DSH 0.1.6-alpha.1. The plugin's dependencies came from npm, with no workspace aliases, symlinks into a checkout, or unpublished DSH exports.
|
|
4
|
+
|
|
5
|
+
## Local checks
|
|
6
|
+
|
|
7
|
+
- `npm run typecheck`: strict Host and Client programs against installed declarations.
|
|
8
|
+
- `npm test`: builds both artifacts, then runs the adapter, catalog, configuration, settings, loader, image/history conversion, and browser-factory suites.
|
|
9
|
+
- `npm pack`: builds a distributable tarball containing the bundle patch, Host ESM, browser module factory, type declarations, license, and documentation.
|
|
10
|
+
|
|
11
|
+
The published UI primitives bundle references a missing source map. Vitest prints an upstream missing-map warning; it does not affect execution or assertions.
|
|
12
|
+
|
|
13
|
+
## Isolated installed checks
|
|
14
|
+
|
|
15
|
+
Create an empty temporary consumer directory and install the compatible CLI plus the tarball there:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm init -y
|
|
19
|
+
npm install --ignore-scripts @deepseek-ai/dsh@0.1.6-alpha.1 /absolute/path/to/dsh-opencode-go-0.1.0.tgz
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Set `DSH_HOME` to that consumer's `home` directory before invoking its CLI. Install the bundle into the headless profile:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
DSH_HOME="$PWD/home" ./node_modules/.bin/dsh plugin --profile headless add /absolute/path/to/dsh-opencode-go-0.1.0.tgz
|
|
26
|
+
DSH_HOME="$PWD/home" ./node_modules/.bin/dsh --profile headless --dump-config
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The tested pnpm installation initially stopped for dependency build-policy decisions. In the temporary profile's `pnpm-workspace.yaml`, set `allowBuilds` entries for `@google/genai` and `protobufjs` to `false`, preserving other generated fields, then repeat installation. This keeps those scripts disabled. The second installation completed and added the bundle to the profile manifest.
|
|
30
|
+
|
|
31
|
+
From this plugin project, run:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npm run verify:installed -- /absolute/path/to/consumer
|
|
35
|
+
npm run verify:headless -- /absolute/path/to/consumer
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The installed smoke resolves the tarball's module and its shared DSH services from the consumer, mounts them through the actual Cordis Loader without an import mock, queries the catalog, streams three requests, checks session-header stability and isolation, checks authorization and User-Agent, and disposes the adapter to verify route removal. The fixture gateway binds an OS-allocated loopback port and closes it after the test.
|
|
39
|
+
|
|
40
|
+
The headless smoke invokes the consumer's official `dsh --profile headless` launcher with a temporary profile overlay and a local gateway. It selects the OpenCode Go provider, completes a task with `standalone-ok`, checks the outgoing session header, and removes the temporary overlay. The test has a bounded child-process timeout and waits for teardown.
|
|
41
|
+
|
|
42
|
+
## Browser verification
|
|
43
|
+
|
|
44
|
+
The tarball was installed into a separate Web profile in the same temporary Harness home. The official `dsh web` server started on an OS-allocated port. Browser inspection confirmed the OpenCode Go settings entry, API-key field, advanced configuration, and a successful model-list response. Toggling the provider off and on updated the page through the Host settings service. No real API key was entered, and no real paid model completion was requested.
|
|
45
|
+
|
|
46
|
+
The browser-factory test additionally evaluates the distributed `lib/client.js` against the published React/store/UI module table, checks the package ID, mounts the settings section, and verifies CSS insertion.
|
|
47
|
+
|
|
48
|
+
## Limits
|
|
49
|
+
|
|
50
|
+
Real paid OpenCode Go completions, Desktop, non-macOS platforms, and other DSH releases are not verified. The automated gateway tests preserve the adapter's request and replay semantics but cannot establish account validity or live provider availability.
|