opencommand-plugin 0.0.11 → 0.0.12

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 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 Plugin
1
+ # OpenCommand
2
2
 
3
- OpenCode plugin for CommandCode. It starts the local OpenCommand proxy, stores CommandCode auth locally, registers the `opencommand` provider, and loads the right model list for the active CommandCode plan.
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
- ## Features
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
- - Starts/stops the Go proxy automatically.
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
- ## Auth
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
- Primary token key:
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
- Do not put this token in synced `opencode.jsonc`.
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
- ## Models in v0.0.11
65
+ ## Lokale bestanden
29
66
 
30
- The proxy detects the active CommandCode subscription through `/alpha/billing/subscriptions` and filters models:
67
+ OpenCommand gebruikt alleen lokale bestanden buiten de repo:
31
68
 
32
- - Go: open-source models only.
33
- - Pro: open-source + premium, excluding Opus.
34
- - Max / Ultra / Teams Pro: open-source + premium including Opus.
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
- If detection fails, the plugin falls back to the local proxy model endpoint and then to the Go/open-source model list.
83
+ ## Browser-cookie extractie
37
84
 
38
- ## Build
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
- ## Test
129
+ Go proxy tests:
46
130
 
47
131
  ```bash
48
- npm test -- --runInBand
132
+ cd proxy
133
+ go vet ./...
134
+ go test -race ./...
135
+ go build -o proxy main.go
49
136
  ```
50
137
 
51
- ## v0.0.8 non-blocking OpenCode startup
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
- `opencommand-plugin@0.0.8` keeps OpenCode startup non-blocking: provider registration uses cached/static models immediately, while proxy startup and CommandCode plan/model refresh run in the background. Pin `opencode.jsonc` to `opencommand-plugin@0.0.11` (or newer) instead of `@latest` to avoid stale plugin cache entries.
166
+ ### v0.0.11
54
167
 
55
- ## v0.0.9 CommandCode protocol update
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
- `opencommand-plugin@0.0.9` updates the bundled proxy to the current CommandCode CLI protocol headers (`x-command-code-version: 0.26.3`, production CLI environment, and OpenCommand project slug). Older `OPENCOMMAND_COMMAND_CODE_CLIENT_VERSION` overrides can no longer downgrade the bundled protocol version.
172
+ ### v0.0.10
58
173
 
59
- ## v0.0.11 bundled proxy
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
- `opencommand-plugin@0.0.11` ships the Go proxy binaries inside the NPM package for macOS, Linux, and Windows. OpenCode only needs the plugin package; no separate proxy install or local repo checkout is required.
177
+ ### v0.0.9
62
178
 
63
- The proxy also translates CommandCode streaming events into OpenAI-compatible chat-completion chunks/responses for `@ai-sdk/openai-compatible`.
179
+ - CommandCode protocol headers bijgewerkt naar CLI-versie `0.26.3`.
180
+ - Productie CLI-environment en OpenCommand project slug toegevoegd.
64
181
 
65
- ## v0.0.10 OpenCode autostart preload
182
+ ### v0.0.8
66
183
 
67
- `opencommand-plugin@0.0.10` starts the local proxy from the OpenCode config hook so synced `opencode.jsonc` installs do not depend on an absolute local `file://` plugin path.
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(), "packages", "proxy", "proxy"),
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];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencommand-plugin",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "OpenCommand - CommandCode API Plugin for OpenCode",
5
5
  "main": "./bin/opencode-plugin.js",
6
6
  "module": "./bin/opencode-plugin.js",