opencommand-plugin 0.0.11 → 0.0.13
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 +149 -32
- package/dist/index.js +1 -1
- package/dist/proxy/opencommand-proxy-darwin-amd64 +0 -0
- package/dist/proxy/opencommand-proxy-darwin-arm64 +0 -0
- package/dist/proxy/opencommand-proxy-linux-amd64 +0 -0
- package/dist/proxy/opencommand-proxy-linux-arm64 +0 -0
- package/dist/proxy/opencommand-proxy-windows-amd64.exe +0 -0
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OpenCommand
|
|
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
CHANGED
|
@@ -1,21 +1,58 @@
|
|
|
1
|
-
# OpenCommand
|
|
1
|
+
# OpenCommand
|
|
2
2
|
|
|
3
|
-
OpenCode
|
|
3
|
+
OpenCommand is één OpenCode/NPM-plugin voor CommandCode. De plugin registreert de provider `opencommand`, start lokaal een OpenAI-compatible proxy en bundelt die proxy-binaries zelf in het NPM-package.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Er is dus geen losse proxy-installatie of lokale repo-checkout meer nodig in OpenCode. De Go-code staat nog wel in `proxy/`, maar alleen als broncode: bij `npm run build:proxy` worden de binaries naar `dist/proxy/` gebouwd en met `opencommand-plugin` gepubliceerd.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- Ships the proxy binaries in the NPM package for normal OpenCode installs.
|
|
9
|
-
- Uses a dynamic local port and exposes `http://localhost:<port>/v1` to OpenCode.
|
|
10
|
-
- Stores the CommandCode API token locally in `~/.opencommand/opencommand-secrets.json`.
|
|
11
|
-
- Supports `COMMAND_CODE_TOKEN` and `COMMANDCODE_API_KEY` environment overrides.
|
|
12
|
-
- Attempts local browser cookie discovery for CommandCode Studio usage scraping.
|
|
13
|
-
- Registers OpenCode provider `opencommand` using `@ai-sdk/openai-compatible`.
|
|
14
|
-
- Detects the active CommandCode plan and registers the matching OpenCode model list.
|
|
7
|
+
## Huidige structuur
|
|
15
8
|
|
|
16
|
-
|
|
9
|
+
```text
|
|
10
|
+
.
|
|
11
|
+
├── bin/opencode-plugin.js # OpenCode plugin entrypoint
|
|
12
|
+
├── src/index.ts # plugin runtime/provider/proxy manager
|
|
13
|
+
├── proxy/ # Go source voor de lokale proxy
|
|
14
|
+
├── scripts/build-proxy-binaries.mjs
|
|
15
|
+
├── tests/ # Jest tests voor plugin/runtime
|
|
16
|
+
├── package.json # NPM package: opencommand-plugin
|
|
17
|
+
└── dist/ # build output, niet getrackt
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Gebruik met OpenCode
|
|
21
|
+
|
|
22
|
+
Gebruik na publicatie:
|
|
23
|
+
|
|
24
|
+
```jsonc
|
|
25
|
+
{
|
|
26
|
+
"plugin": ["opencommand-plugin@latest"],
|
|
27
|
+
"model": "opencommand/deepseek/deepseek-v4-flash",
|
|
28
|
+
"small_model": "opencommand/deepseek/deepseek-v4-flash"
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Voor een vaste versie kun je `opencommand-plugin@0.0.12` pinnen.
|
|
33
|
+
|
|
34
|
+
Bij OpenCode-start doet de plugin dit automatisch:
|
|
35
|
+
|
|
36
|
+
1. kiest de juiste gebundelde proxybinary voor macOS/Linux/Windows;
|
|
37
|
+
2. start de proxy op een lokale poort;
|
|
38
|
+
3. schrijft `~/.opencommand/proxy-config.json` met de actieve URL;
|
|
39
|
+
4. registreert provider `opencommand` met `http://localhost:<port>/v1`;
|
|
40
|
+
5. detecteert het actieve CommandCode-plan en registreert de bijpassende modellen.
|
|
41
|
+
|
|
42
|
+
OpenCode moet opnieuw worden gestart nadat `opencode.jsonc` of de pluginversie is gewijzigd, want plugin-config wordt bij startup geladen.
|
|
43
|
+
|
|
44
|
+
## Auth-model
|
|
17
45
|
|
|
18
|
-
|
|
46
|
+
Gebruik primair een CommandCode token (`user_...`). Zet secrets niet in gesyncte `opencode.jsonc`.
|
|
47
|
+
|
|
48
|
+
Prioriteit:
|
|
49
|
+
|
|
50
|
+
1. inkomende `Authorization: Bearer user_...` requests;
|
|
51
|
+
2. `COMMAND_CODE_TOKEN`;
|
|
52
|
+
3. alias `COMMANDCODE_API_KEY`;
|
|
53
|
+
4. lokale secret `~/.opencommand/opencommand-secrets.json` met sleutel `opencommand.command_code_token`.
|
|
54
|
+
|
|
55
|
+
Voorbeeld:
|
|
19
56
|
|
|
20
57
|
```json
|
|
21
58
|
{
|
|
@@ -23,45 +60,125 @@ Primary token key:
|
|
|
23
60
|
}
|
|
24
61
|
```
|
|
25
62
|
|
|
26
|
-
|
|
63
|
+
De plugin maakt `~/.opencommand` met `0700` permissies en schrijft secrets met `0600`. `CC_SESSION_COOKIE` is alleen bedoeld voor CommandCode Studio usage scraping, niet als primaire model-auth.
|
|
27
64
|
|
|
28
|
-
##
|
|
65
|
+
## Lokale bestanden
|
|
29
66
|
|
|
30
|
-
|
|
67
|
+
OpenCommand gebruikt alleen lokale bestanden buiten de repo:
|
|
31
68
|
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
69
|
+
- `~/.opencommand/opencommand-secrets.json` — CommandCode token en optionele Studio-cookie.
|
|
70
|
+
- `~/.opencommand/proxy-config.json` — actieve proxy URL/poort.
|
|
71
|
+
- `~/.opencommand/model-cache.json` — laatst bekende plan/model-lijst.
|
|
72
|
+
|
|
73
|
+
Voorbeeld `proxy-config.json`:
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"url": "http://localhost:3000",
|
|
78
|
+
"port": 3000,
|
|
79
|
+
"updatedAt": "2026-05-19T20:00:00.000Z"
|
|
80
|
+
}
|
|
81
|
+
```
|
|
35
82
|
|
|
36
|
-
|
|
83
|
+
## Browser-cookie extractie
|
|
37
84
|
|
|
38
|
-
|
|
85
|
+
Voor usage scraping kan de plugin op macOS proberen een CommandCode Studio-cookie te vinden in Chrome, Comet, Brave, Edge of Firefox. Gevonden cookies worden lokaal opgeslagen als:
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"opencommand.cc_session_cookie": "..."
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Cookie-waarden worden niet gelogd en niet in `opencode.jsonc` opgeslagen.
|
|
94
|
+
|
|
95
|
+
## Model-detectie per plan
|
|
96
|
+
|
|
97
|
+
De proxy/plugin vraagt `/alpha/billing/subscriptions` op en filtert modellen per plan:
|
|
98
|
+
|
|
99
|
+
- `individual-go`: open-source modellen.
|
|
100
|
+
- `individual-pro`: open-source + premium, zonder Opus.
|
|
101
|
+
- `individual-max`, `individual-ultra`, `teams-pro`: open-source + premium inclusief Opus.
|
|
102
|
+
|
|
103
|
+
Als plan-detectie faalt, valt OpenCommand terug op de lokale cached/static Go/open-source lijst zodat OpenCode alsnog kan starten.
|
|
104
|
+
|
|
105
|
+
## Lokale API
|
|
106
|
+
|
|
107
|
+
De proxy biedt OpenAI-compatible endpoints:
|
|
108
|
+
|
|
109
|
+
- `POST /v1/chat/completions` — streaming en non-streaming chat completions.
|
|
110
|
+
- `GET /v1/models` — plan-gefilterde OpenAI model-lijst.
|
|
111
|
+
- `GET /v1/models/allowed` — CommandCode Studio allowed-models/usage info.
|
|
112
|
+
- `GET /v1/account/usage` — usage summary.
|
|
113
|
+
- `GET /healthz` — health check.
|
|
114
|
+
|
|
115
|
+
De proxy vertaalt OpenAI `messages`, `tools`, `tool_choice` en streaming responses naar/van het huidige CommandCode CLI-protocol.
|
|
116
|
+
|
|
117
|
+
## Development
|
|
118
|
+
|
|
119
|
+
Root package:
|
|
39
120
|
|
|
40
121
|
```bash
|
|
41
122
|
npm ci
|
|
123
|
+
npm test -- --runInBand
|
|
42
124
|
npm run build
|
|
125
|
+
npm run build:proxy
|
|
126
|
+
npm pack --dry-run
|
|
43
127
|
```
|
|
44
128
|
|
|
45
|
-
|
|
129
|
+
Go proxy tests:
|
|
46
130
|
|
|
47
131
|
```bash
|
|
48
|
-
|
|
132
|
+
cd proxy
|
|
133
|
+
go vet ./...
|
|
134
|
+
go test -race ./...
|
|
135
|
+
go build -o proxy main.go
|
|
49
136
|
```
|
|
50
137
|
|
|
51
|
-
|
|
138
|
+
`npm pack` bevat alleen de runtimebestanden:
|
|
139
|
+
|
|
140
|
+
- `README.md`
|
|
141
|
+
- `package.json`
|
|
142
|
+
- `bin/opencode-plugin.js`
|
|
143
|
+
- `dist/index.js`
|
|
144
|
+
- `dist/index.d.ts`
|
|
145
|
+
- `dist/proxy/opencommand-proxy-*`
|
|
146
|
+
|
|
147
|
+
De bronmappen `src/`, `tests/` en `proxy/` worden niet gepubliceerd in het NPM-package.
|
|
148
|
+
|
|
149
|
+
## Publicatie
|
|
150
|
+
|
|
151
|
+
Package: `opencommand-plugin`.
|
|
152
|
+
|
|
153
|
+
De publish workflow staat in `.github/workflows/npm-publish.yml`. Deze workflow bouwt/test de root package, bouwt de proxybinaries en controleert dat alle vereiste bestanden in het NPM-package zitten.
|
|
154
|
+
|
|
155
|
+
## Release notes
|
|
156
|
+
|
|
157
|
+
### v0.0.12
|
|
158
|
+
|
|
159
|
+
- OpenAI-compatible chat schema voor OpenCode requests.
|
|
160
|
+
- Deterministische samenvoeging van system/developer messages naar `params.system`.
|
|
161
|
+
- Conversie van OpenAI tool calls/results naar CommandCode `tool-call`/`tool-result` parts.
|
|
162
|
+
- Conversie van OpenAI `tools` en `tool_choice` naar CommandCode tool schema.
|
|
163
|
+
- Fixes voor CommandCode 400-errors rond `params.messages[0].role`, string content en `params.tools[0].name`.
|
|
164
|
+
- Repo-layout opgeschoond: root is nu het NPM/OpenCode package; `proxy/` is alleen Go-source voor bundled binaries.
|
|
52
165
|
|
|
53
|
-
|
|
166
|
+
### v0.0.11
|
|
54
167
|
|
|
55
|
-
|
|
168
|
+
- NPM-package bundelt proxybinaries voor macOS, Linux en Windows.
|
|
169
|
+
- OpenCode heeft alleen `opencommand-plugin` nodig; geen losse proxy-installatie.
|
|
170
|
+
- Proxy vertaalt CommandCode streaming events naar OpenAI-compatible chat-completion chunks/responses.
|
|
56
171
|
|
|
57
|
-
|
|
172
|
+
### v0.0.10
|
|
58
173
|
|
|
59
|
-
|
|
174
|
+
- Plugin start de lokale proxy vanuit de OpenCode config hook.
|
|
175
|
+
- Gesyncte `opencode.jsonc` heeft geen absolute lokale `file://` plugin path meer nodig.
|
|
60
176
|
|
|
61
|
-
|
|
177
|
+
### v0.0.9
|
|
62
178
|
|
|
63
|
-
|
|
179
|
+
- CommandCode protocol headers bijgewerkt naar CLI-versie `0.26.3`.
|
|
180
|
+
- Productie CLI-environment en OpenCommand project slug toegevoegd.
|
|
64
181
|
|
|
65
|
-
|
|
182
|
+
### v0.0.8
|
|
66
183
|
|
|
67
|
-
|
|
184
|
+
- Non-blocking OpenCode startup: cached/static models direct, proxy/plan refresh op de achtergrond.
|
package/dist/index.js
CHANGED
|
@@ -731,7 +731,7 @@ export function resolveProxyBinaryPath() {
|
|
|
731
731
|
const candidates = [
|
|
732
732
|
bundledProxyBinaryPath(),
|
|
733
733
|
path.join(os.homedir(), ".opencommand", "proxy"),
|
|
734
|
-
path.join(process.cwd(), "
|
|
734
|
+
path.join(process.cwd(), "proxy", "proxy"),
|
|
735
735
|
path.join(process.cwd(), "proxy"),
|
|
736
736
|
].filter((candidate) => Boolean(candidate));
|
|
737
737
|
return candidates.find((candidate) => fs.existsSync(candidate)) || candidates[candidates.length - 1];
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|