cvc-catalog-sync-plugin 1.0.0 → 2.0.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/README.md CHANGED
@@ -1,19 +1,39 @@
1
- # CVC catalog sync
1
+ # CVC catalog, coefficients and balance
2
2
 
3
3
  [![CI](https://github.com/mikel38487/cvc-catalog-sync-plugin/actions/workflows/ci.yml/badge.svg)](https://github.com/mikel38487/cvc-catalog-sync-plugin/actions/workflows/ci.yml)
4
4
  [![CodeQL](https://github.com/mikel38487/cvc-catalog-sync-plugin/actions/workflows/codeql.yml/badge.svg)](https://github.com/mikel38487/cvc-catalog-sync-plugin/actions/workflows/codeql.yml)
5
5
  [![npm](https://img.shields.io/npm/v/cvc-catalog-sync-plugin.svg)](https://www.npmjs.com/package/cvc-catalog-sync-plugin)
6
6
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
7
7
 
8
- Keeps the CheapVibeCode route's model list in the DSH profile patch in sync with
9
- the provider catalog and with the reasoning levels published by the official
10
- CheapVibeCode installer.
8
+ One plugin for three things a CheapVibeCode route needs in a DSH profile:
11
9
 
12
- ## Install
10
+ 1. **Catalog sync** keeps `llm-pi-ai.providers.<provider>.models` and the subagent
11
+ model allowlist in step with `GET /v1/models` and with the reasoning levels
12
+ published by the official CheapVibeCode installer.
13
+ 2. **Coefficients** put the price multiplier (`×0.1` … `×10`) beside every model
14
+ of that provider in the model picker.
15
+ 3. **Balance** adds a sidebar button and a panel with the remaining balance and
16
+ the spend since the previous reading.
17
+
18
+ Each of the three has its own switch in the settings page. A switched-off
19
+ function leaves nothing behind: no route, no timer, no tool, no UI element.
20
+ Version 2.0.0 replaces two earlier plugins (`cvc-model-coeff-plugin` and
21
+ `cvc-balance-plugin`) and absorbs their features into this package, so one
22
+ plugin row in the profile patch is enough.
23
+
24
+ ## Requirements
25
+
26
+ - DeepSeek Harness `>=0.2.2-rc.3 <0.4.0`;
27
+ - Node.js 20 or newer;
28
+ - a provider route in `llm-pi-ai` whose `baseURL` points at a
29
+ `cheapvibecode.ru` host (default `https://ru.cheapvibecode.ru/v1`), with its
30
+ credential named by `apiKeyEnv` (default `CVC_DEEPSEEK_API_KEY`).
13
31
 
14
- Requires DSH `>=0.2.2-rc.3 <0.4.0`, a `cheapvibecode` route in `llm-pi-ai` with
15
- its credential named by `apiKeyEnv` (default `CVC_DEEPSEEK_API_KEY`), and Node.js
16
- 20 or newer.
32
+ If there is no such route, the catalog and the balance have nobody to read:
33
+ plan and apply report that no route was found, and the balance panel says so.
34
+ The settings page itself still works, because it is also the switchboard.
35
+
36
+ ## Install
17
37
 
18
38
  Ask the DSH agent to install the bundle from npm:
19
39
 
@@ -21,123 +41,254 @@ Ask the DSH agent to install the bundle from npm:
21
41
  install the npm bundle cvc-catalog-sync-plugin
22
42
  ```
23
43
 
24
- By hand: add `"cvc-catalog-sync-plugin": "^1.0.0"` to the dependencies of
25
- `~/.dsh/profiles/<profile>/package.json` and the package name to
26
- `dsh.profile.bundles`, then let the profile install it. For a local checkout use
44
+ By hand: add `"cvc-catalog-sync-plugin": "^2.0.0"` to the dependencies of
45
+ `~/.dsh/profiles/<profile>/package.json`, add the package name to
46
+ `dsh.profile.bundles`, and let the profile install it. The bundle ships a
47
+ compiled `client.js`, so nothing is built during installation and no
48
+ `allowBuilds` permission is needed. For a local checkout use
27
49
  `"cvc-catalog-sync-plugin": "link:<absolute path>"` instead.
28
50
 
29
- After activation the settings appear in **Settings → CVC catalog** and on the
30
- plugin's own page in **Plugins**, between the description and the component rows.
31
-
32
- ## Why it exists
33
-
34
- The CVC catalog (`GET /v1/models`) changes often, and it does **not** carry
35
- reasoning levels: only a boolean `supports_reasoning`. The levels live as a
36
- `const reasoningLevels = {...}` literal inside the official installers
37
- (`/idhw` for PowerShell, `/idhl` for bash). DSH's built-in "get models" action
38
- neither saves anything nor returns levels, so a catalog refresh otherwise means
39
- hand-editing `~/.dsh/profiles/<profile>/cordis.patch.yml`.
51
+ The package keeps the name `cvc-catalog-sync-plugin` and the composition row id
52
+ `cvc-catalog-sync`, so the profile does not need to be rewritten for the
53
+ upgrade. See [docs/UPGRADING.md](docs/UPGRADING.md) for the steps that do
54
+ change.
40
55
 
41
- ## What it does
42
-
43
- 1. On activation (after a short delay) and every `intervalHours`, it fetches
44
- `{baseURL}/models` with the route's credential and the installer's
45
- `reasoningLevels` map.
46
- 2. It builds `llm-pi-ai.providers.<provider>.models` with the installer's own
47
- rules: `name` is `display_name` after ` · `, `contextWindow` is
48
- `context_window`, `maxTokens` is `min(max_output_tokens, contextWindow)`,
49
- `input` gains `image` when the model accepts it, `none` becomes
50
- `off: none`, and `gpt-image*` / non-text-output models are skipped.
51
- 3. It writes the result through `ctx.configEditor.edit()`, which preserves the
52
- rest of the patch file, its comments and other plugins' rows, and applies the
53
- change through `dsh-hmr` without restarting DSH.
54
- 4. When `syncAllowlist` is on, the `subagent-model-selection-settings` list is
55
- pruned and extended to the same model ids, leaving other providers' entries
56
- untouched.
56
+ ## Where the settings are
57
57
 
58
- It writes only when the catalog or the subagent allowlist actually changed. A
59
- response below `minModelRatio` of the current model count is refused, so a
60
- partial or empty catalog cannot wipe a working list.
58
+ The same form appears in two places:
61
59
 
62
- ## Tool
60
+ - **Settings → CVC** — a section of the settings navigation with its own icon
61
+ (`settings.section` + `settings.section.icon`, id `cvc`, order 25);
62
+ - **Plugins → CVC catalog sync → bundle page** — a configuration block between
63
+ the bundle description and its component rows (`plugins.bundle.config`, keyed
64
+ by the package name). In the collapsed list the block renders as a one-line
65
+ summary.
63
66
 
64
- `cvc_catalog` — the manual entry point:
67
+ One group of switches at the top (**Features**) and then the parameter groups:
68
+ **Catalog**, **Coefficients**, **Balance** and **Advanced**. The switches decide
69
+ which of the first three groups has any effect; the **Advanced** group holds the
70
+ provider lookup (`providers.*`) and the level cache, and stays visible with every
71
+ function off, because it configures the lookup all three share.
65
72
 
66
- | Action | Effect |
73
+ | Switch | What it controls |
67
74
  |---|---|
68
- | `status` | Last run in this process; no network |
69
- | `plan` | Fetch, build, return the diff, write nothing |
70
- | `apply` | Fetch and write (refused by the size guard unless `force: true`) |
75
+ | Catalog sync | startup and timer runs, the `cvc_catalog` tool, `POST /cvc/run` and what the check and apply buttons can do |
76
+ | Coefficients | `GET /cvc/coefficients` and the badges in the model picker |
77
+ | Balance | `GET /cvc/balance`, the `cvc_balance` tool, the sidebar button and the panel |
71
78
 
72
- ## Settings page
79
+ The settings page and `GET /cvc/state` are not gated: they exist with all three
80
+ functions off, because the page is the switch. The check and apply buttons stay on
81
+ the page when catalog sync is off, but the run route behind them answers `404` and
82
+ the page reports the failed run.
73
83
 
74
- The plugin puts the same settings form in two places:
84
+ A change is applied through `PUT /cvc/config` and takes effect immediately:
85
+ the plugin declares every configuration field as volatile, so DSH reloads the
86
+ row without a restart. Turning a function off unmounts it, turning it on
87
+ mounts it again, in the same page session.
75
88
 
76
- - **Settings → CVC catalog** — a section in the settings navigation with its own
77
- icon (`settings.section` + `settings.section.icon`);
78
- - **Plugins → CVC catalog sync → bundle page** — a configuration block between
79
- the bundle description and its component rows (`plugins.bundle.config`, keyed
80
- by the package name), the same seat `dshmarket` and `dsh-free-search` use.
89
+ The three switches are named **Catalog sync**, **Model coefficients** and
90
+ **Balance**, and the settings page spells out what a switched-off feature
91
+ leaves behind: its route answers `404`, its timer is not created, its interface
92
+ element disappears. The page itself always stays, because it is the switch.
81
93
 
82
- Both edit every option from the configuration block below, read the current
83
- values back from the profile patch, and offer three actions:
94
+ Buttons:
84
95
 
85
- | Action | Effect |
96
+ | Button | Effect |
86
97
  |---|---|
87
- | **Save** | Validates the form and writes the row config into the profile patch through `configEditor.edit()`. Values equal to the bundle defaults remove the override, so the patch keeps only real changes. |
88
- | **Check catalog** | Fetches the catalog and the reasoning-level map, shows the diff, writes nothing. |
98
+ | **Save** | Validates the form and writes the row config into the profile patch through `configEditor.edit()`. A value equal to the schema defaults removes the override, so the patch keeps only real changes. |
99
+ | **Check catalog** | Fetches the catalog and the level map, shows the diff, writes nothing. |
89
100
  | **Apply catalog** | Same fetch, then writes the models and the subagent allowlist. Asks for confirmation first. |
101
+ | **Reset** | Puts the defaults into the form; press Save to remove the override. |
90
102
 
91
- The page also shows the last run: catalog / current / next model counts, the
92
- level source, added / removed / changed models, allowlist changes, warnings and
93
- the patch path. Check and apply use the **saved** settings, so press Save first;
94
- the page marks unsaved changes.
95
-
96
- The page talks to the host through `/cvc-catalog-sync` (`state`, `config`, `run`)
97
- on the DSH web server. The browser never receives the API key: the host resolves
98
- the credential by name. Writes require `application/json` and reject cross-site
99
- requests.
103
+ Check and apply use the **saved** settings, so press Save first; the page marks
104
+ unsaved changes. Below the buttons the page shows the last run: catalog,
105
+ current and next model counts, the level source, added, removed and changed
106
+ models, allowlist changes, warnings and the patch path.
100
107
 
101
108
  ## Configuration
102
109
 
103
110
  Override the row in the profile patch by id `cvc-catalog-sync` — or use the
104
- settings page, which writes the same row:
111
+ settings page, which writes the same row. Only the fields you want to change
112
+ need to be present:
105
113
 
106
114
  ```yaml
107
115
  - id: cvc-catalog-sync
108
116
  name: 'cvc-catalog-sync-plugin'
109
117
  config:
110
- entryId: llm-pi-ai # profile patch row that owns the routes
111
- provider: cheapvibecode # route key inside llm-pi-ai.providers
112
- apiKeyEnv: CVC_DEEPSEEK_API_KEY # credential reference, never the value
113
- baseURL: https://ru.cheapvibecode.ru/v1
114
- installerUrls: # reasoning-level maps, first reachable wins
115
- - https://ru.cheapvibecode.ru/idhw
116
- - https://ru.cheapvibecode.ru/idhl
117
- autoSync: true # startup + interval runs
118
- intervalHours: 24 # 0 disables the timer; below 1 minute it is raised
119
- startupDelayMs: 5000
120
- minModelRatio: 0.8 # refuse a smaller catalog
121
- keepModels: [] # ids to keep even when the catalog drops them
122
- syncAllowlist: true
123
- allowlistEntryId: subagent-model-selection-settings
124
- levelsCacheMinutes: 360
125
- timeoutMs: 30000
118
+ features:
119
+ catalogSync: true
120
+ coefficients: true
121
+ balance: true
122
+ providers:
123
+ match: ['cheapvibecode.ru'] # host names that identify the provider
124
+ entryId: llm-pi-ai # patch row that owns the provider routes
125
+ apiKeyEnv: CVC_DEEPSEEK_API_KEY # fallback credential name, never the value
126
+ baseURL: https://ru.cheapvibecode.ru/v1
127
+ timeoutMs: 20000
128
+ catalog:
129
+ provider: cheapvibecode # route key whose models are written
130
+ autoSync: true # startup run plus interval runs
131
+ intervalHours: 24 # 0 turns the timer off; below a minute is raised
132
+ startupDelayMs: 5000
133
+ minModelRatio: 0.8 # refuse a smaller catalog
134
+ keepModels: [] # ids kept even when the catalog drops them
135
+ installerUrls: # reasoning-level maps, first reachable wins
136
+ - https://ru.cheapvibecode.ru/idhw
137
+ - https://ru.cheapvibecode.ru/idhl
138
+ syncAllowlist: true
139
+ allowlistEntryId: subagent-model-selection-settings
140
+ levelsCacheMinutes: 360
141
+ coefficients:
142
+ refreshMinutes: 10
143
+ showFast: true
144
+ balance:
145
+ refreshSeconds: 0 # 0 means refresh on demand only; minimum 15
146
+ showDelta: true
126
147
  ```
127
148
 
128
- A route configured with `modelOverrides` is refused with an explicit error: DSH
129
- does not accept `modelOverrides` beside a `models` list, so such a route must be
130
- converted to an explicit list first.
149
+ The defaults are the same as in the table in
150
+ [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md); a value written to the patch
151
+ overrides them, and removing the field restores the default.
152
+
153
+ A configuration written for version 1.x still loads: the flat keys (`entryId`,
154
+ `provider`, `baseURL`, `apiKeyEnv`, `installerUrls`, `autoSync`,
155
+ `intervalHours`, `startupDelayMs`, `minModelRatio`, `keepModels`,
156
+ `syncAllowlist`, `allowlistEntryId`, `levelsCacheMinutes`, `timeoutMs`) are
157
+ accepted as deprecated fields and folded into the groups. `GET /cvc/state`
158
+ reports `configShape: legacy` in that case, and the settings page suggests
159
+ saving once to move to the new shape.
131
160
 
132
- Because a local bundle is linked by directory rather than copied, editing its
133
- files does not load new code by itself: DSH picks the new module up after a
134
- profile reconcile (any patch-file change) or an application restart.
161
+ ## The catalog
162
+
163
+ The CVC catalog (`GET /v1/models`) changes often and does **not** carry
164
+ reasoning levels: only a boolean `supports_reasoning`. The levels live as a
165
+ `const reasoningLevels = {...}` literal inside the official installers (`/idhw`
166
+ for PowerShell, `/idhl` for bash). DSH's built-in "get models" action neither
167
+ saves anything nor returns levels, so a catalog refresh otherwise means
168
+ hand-editing `~/.dsh/profiles/<profile>/cordis.patch.yml`.
169
+
170
+ What a run does:
171
+
172
+ 1. On activation, after `startupDelayMs`, and every `intervalHours` (when
173
+ `autoSync` is on) it fetches `{baseURL}/models` with the route's credential
174
+ and the installer's `reasoningLevels` map.
175
+ 2. It builds `llm-pi-ai.providers.<provider>.models` by the installer's own
176
+ rules: `name` is `display_name` after ` · `, `contextWindow` is
177
+ `context_window`, `maxTokens` is `min(max_output_tokens, contextWindow)`,
178
+ `input` gains `image` when the model accepts it, the `none` level becomes
179
+ `off: none`, and `gpt-image*` and models without text output are skipped.
180
+ 3. It writes the result through `ctx.configEditor.edit()`, which preserves the
181
+ rest of the patch file, its comments and other plugins' rows, and applies the
182
+ change through `dsh-hmr` without restarting DSH.
183
+ 4. With `syncAllowlist` on, `subagent-model-selection-settings.allowedModels`
184
+ is pruned and extended to the same model ids; entries of other providers are
185
+ left alone.
186
+
187
+ It writes only when the catalog or the allowlist actually changed. A response
188
+ below `minModelRatio` of the current model count is refused, so a partial or
189
+ empty catalog cannot wipe a working list.
190
+
191
+ ### The cvc_catalog tool
192
+
193
+ | Action | Effect |
194
+ |---|---|
195
+ | `status` | Last run in this process; no network |
196
+ | `plan` | Fetch, build, return the diff, write nothing |
197
+ | `apply` | Fetch and write (refused by the size guard or by a stale catalog unless `force: true`) |
198
+
199
+ Check and apply run the same steps. A run reports the catalog size, the current and
200
+ next model count, the level source, added / removed / changed models, allowlist
201
+ changes and warnings. When the API answers `409`, the reason is a refusal by the
202
+ guard or by a stale catalog, not a server failure: the page shows the reason and
203
+ suggests `force` where the tool offers it.
204
+
205
+ ## The coefficients
206
+
207
+ The multiplier comes from the same `GET /v1/models` response and is a factor on
208
+ the provider's base price, not a currency amount. The model menu and the
209
+ composer's current-model button gain a badge to the right of the name: `×0.1`,
210
+ `×3`, `×10`. The colour comes from the host theme: green up to 0.5, plain text
211
+ up to 1.5, warning up to 4, error above that. The tooltip names the fast-mode
212
+ multiplier when it differs.
213
+
214
+ Only models of a provider whose `baseURL` points at `cheapvibecode.ru` get the
215
+ badge; the same model id under another provider stays undecorated. A model
216
+ without a multiplier in the catalog gets no badge: the plugin does not guess a
217
+ price. The badge is not a control, and the `conversation.input.model.label` slot
218
+ is left to whoever owns it, so selection stays with the built-in picker.
219
+
220
+ The browser asks `GET /cvc/coefficients` every `refreshMinutes`. The answer is
221
+ served from the shared catalog cache, so a badge refresh does not cost an extra
222
+ catalog request when the cache is still fresh. **Show fast mode** controls whether
223
+ the tooltip adds the fast-mode multiplier; with it off the badge shows only the
224
+ regular multiplier.
225
+
226
+ ## The balance
227
+
228
+ The sidebar footer gains a **CVC balance** button with a small status dot: green
229
+ when every provider answered, yellow when only some did (or while a refresh is
230
+ running), red when none did, neutral when no provider is configured. The colours
231
+ are theme tokens, so the dot stays readable in the light theme.
232
+
233
+ Clicking the button opens a panel with one card per route: display name, route
234
+ key, `baseURL`, the credential name and whether the key was found, the remaining
235
+ balance in provider units, and the spend since the previous reading (when
236
+ `showDelta` is on). The panel can be dragged, remembers its position in
237
+ `localStorage` under `cvc:panel-pos`, and offers **Refresh** and **Reset
238
+ position**. It stays inside the viewport and does not write into
239
+ `document.body`.
240
+
241
+ `refreshSeconds` is `0` by default: the panel reads the balance when it is opened
242
+ or refreshed by hand. A positive value of 15 or more turns on a timer that
243
+ re-reads the balance while the panel is open; the timer stops when the panel is
244
+ closed. A value between 1 and 14 is raised to 15, and the form refuses it with a
245
+ validation error rather than silently changing the number.
246
+
247
+ An error on one provider is shown on that card and does not prevent the others
248
+ from answering. The API key itself never leaves the host: the answer carries
249
+ `keySet: true|false` and the numbers.
250
+
251
+ ### The cvc_balance tool
252
+
253
+ `status` returns the last snapshot in this process without spending a request: for
254
+ each route a `keySet` flag and the remaining units. It is meant for the agent, so
255
+ the human side is the panel, and the tool exists only while the balance function
256
+ is on.
257
+
258
+ ## HTTP contract
259
+
260
+ All routes live under one prefix, `/cvc`, and are served by the DSH web server
261
+ on the same origin as the UI.
262
+
263
+ | Method | Path | Body | Answer |
264
+ |---|---|---|---|
265
+ | GET | `/cvc/state` | — | `{version, features, config, configShape, status, lastRun, patchPath, rowId}` |
266
+ | PUT | `/cvc/config` | `{config}` | `{ok, config, features}`; on error `400` with `fields` |
267
+ | POST | `/cvc/run` | `{action: 'plan' \| 'apply', force?}` | the run result |
268
+ | GET | `/cvc/coefficients` | — | `{models, providers, fetchedAt, stale}`; `404` when the function is off |
269
+ | GET | `/cvc/balance` | — | `{providers, fetchedAt}`; `404` when the function is off |
270
+ | GET | `/cvc/health` | — | `{ok, version}` |
271
+
272
+ Cross-site requests (`Sec-Fetch-Site: cross-site`) get `403`, a write request
273
+ (`PUT` or `POST`) without `application/json` gets `415`, a body over 64 KB gets
274
+ `413`, an unknown path gets `404`, and a wrong method on a known path gets `405`.
275
+
276
+ ## Compatibility
277
+
278
+ The plugin leans on a few UI surfaces of DSH that are not part of a stable public
279
+ API: the `settings.section` and `settings.section.icon` slots, the
280
+ `plugins.bundle.config` block, the `sidebar.footer.action` button, and the
281
+ `data-model-id` / `data-provider-id` attributes the model selector writes. The
282
+ balance panel does not use `shell.overlay`; it is positioned inside the sidebar
283
+ slot. [docs/COMPATIBILITY.md](docs/COMPATIBILITY.md) lists each surface with its
284
+ failure mode and the client modules the manifest declares via
285
+ `dsh.client.inject`.
135
286
 
136
287
  ## Limits
137
288
 
138
289
  - Levels are scraped from the installer, not from an API. If both installer URLs
139
- are unreachable, existing levels are preserved and only new models fall back to
140
- the full `supports_reasoning` row; the run reports `levelsSource: none`.
290
+ are unreachable, existing levels are preserved and only new models fall back
291
+ to the full `supports_reasoning` row; the run reports `levelsSource: none`.
141
292
  - The CVC catalog is not filtered by key: `/v1/models` lists every model, while
142
293
  availability is decided per request (`403 This model is not enabled for the
143
294
  API key`). The plugin therefore cannot hide models your key cannot call.
@@ -147,6 +298,23 @@ profile reconcile (any patch-file change) or an application restart.
147
298
  `high: thinking`, and the plugin reproduces it.
148
299
  - A model whose catalog entry declares no modalities keeps the current entry's
149
300
  `input`; a declared `supports_vision: false` drops `image`.
301
+ - A route configured with `modelOverrides` is refused with an explicit error:
302
+ DSH does not accept `modelOverrides` beside a `models` list, so such a route
303
+ must be converted to an explicit list first.
304
+ - The coefficient badge is drawn in the composer model menu and on the
305
+ current-model button. The `/model` command uses its own popup without the same
306
+ row attributes, so it stays undecorated.
307
+ - Badge matching folds case, dots and underscores in a model id to a dash, because
308
+ the CheapVibeCode catalog and the DSH adapter may spell the same model
309
+ differently. When that still leaves more than one candidate, no badge is drawn.
310
+ - The balance is shown in the provider's own units, exactly as `/v1/balance`
311
+ reports them; the plugin does not convert them to money.
312
+ - Automatic runs write through the same editor, but only when the HMR service of
313
+ the host exposes a usable transaction context. On a host where it does not, the
314
+ timer computes the diff and logs a warning instead of writing; run
315
+ `cvc_catalog action=apply` or the **Apply catalog** button in that case.
316
+ - No background work while off: with all three functions switched off the plugin
317
+ starts no timer and makes no provider request.
150
318
 
151
319
  ## Verify and roll back
152
320
 
@@ -158,127 +326,53 @@ Copy-Item ~\.dsh\profiles\desktop\cordis.patch.yml ~\.dsh\profiles\desktop\cordi
158
326
  cvc_catalog action=apply
159
327
  ```
160
328
 
161
- `git` is not used for the profile; a file copy is the rollback.
329
+ The profile is not a git repository, so a file copy is the rollback.
162
330
 
163
- ## Tests
331
+ ## Development
164
332
 
165
333
  ```powershell
166
- node --test test/self-test.mjs test/integration.mjs test/settings-api.mjs test/client-render.mjs
334
+ npm install
335
+ npm test # node --test test/*.mjs
336
+ npm run build # rebuilds client.js from src/client/**
337
+ node tools/assert-pack.mjs # checks the npm tarball contents
167
338
  ```
168
339
 
169
- - `self-test.mjs` — pure functions: catalog parsing, level mapping, model build, diff.
170
- - `integration.mjs` — the tool against a fake `ctx` with the real `configEditor`
171
- contract: apply, guard, allowlist repair, edits made under the lock.
172
- - `settings-api.mjs` — the HTTP settings route: state, validation, save, run,
173
- cross-site refusal.
174
- - `client-render.mjs` — renders the settings page with a fake React, so a render
175
- error fails here instead of leaving an empty settings slot.
176
-
177
- ## Security
178
-
179
- See [SECURITY.md](SECURITY.md). Zero runtime dependencies; the plugin contacts
180
- only the configured `baseURL` and installer URLs; the API key never reaches the
181
- browser; npm releases carry provenance from GitHub Actions.
340
+ `index.js` and `lib/**` are plain ESM and run without a build step. The browser
341
+ half is compiled from `src/client/**` into `client.js`; the compiled file is
342
+ committed, so the package works from npm and from git without running a build
343
+ on the user's machine. CI rebuilds it and fails when the committed file differs
344
+ from the sources, and a separate job checks that the tarball contains the files
345
+ the package promises.
182
346
 
183
- ## License
184
-
185
- MIT © 2026 mikel38487
186
-
187
- ---
188
-
189
- # Синхронизация каталога CVC
347
+ The build uses `tsdown`, whose own `engines` field requires Node `^22.18` or
348
+ `>=24.11`, so CI builds on Node 22. Installing from npm and running the plugin
349
+ work on Node 20 or newer: the compiled `client.js` is in the package, and
350
+ installing from npm does not run a build script.
190
351
 
191
- Держит список моделей маршрута CheapVibeCode в профильном патче DSH в
192
- соответствии с каталогом провайдера и с уровнями мышления из официального
193
- установщика CheapVibeCode.
352
+ Because a locally linked bundle is linked by directory rather than copied,
353
+ editing its files does not load new code by itself: DSH picks the new module up
354
+ after a profile reconcile (any patch-file change) or an application restart.
194
355
 
195
- ## Зачем
356
+ Architecture: [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md).
357
+ Upgrading: [docs/UPGRADING.md](docs/UPGRADING.md).
358
+ Compatibility: [docs/COMPATIBILITY.md](docs/COMPATIBILITY.md).
359
+ Previews: [docs/DETAIL.md](docs/DETAIL.md) shows the settings page, the badges and
360
+ the panel in one picture.
196
361
 
197
- Каталог CVC (`GET /v1/models`) меняется часто и **не содержит** уровней
198
- мышления — только булев `supports_reasoning`. Уровни лежат литералом
199
- `const reasoningLevels = {...}` внутри установщиков (`/idhw` для PowerShell,
200
- `/idhl` для bash). Штатное действие DSH «получить список моделей» ничего не
201
- сохраняет и уровней не возвращает, поэтому обновление каталога иначе — ручная
202
- правка `~/.dsh/profiles/<профиль>/cordis.patch.yml`.
203
-
204
- ## Что делает
205
-
206
- 1. При активации (после короткой задержки) и каждые `intervalHours` забирает
207
- `{baseURL}/models` ключом маршрута и карту `reasoningLevels` установщика.
208
- 2. Собирает `llm-pi-ai.providers.<provider>.models` по правилам самого
209
- установщика: `name` — хвост `display_name` после ` · `, `contextWindow` —
210
- `context_window`, `maxTokens` — `min(max_output_tokens, contextWindow)`,
211
- `input` получает `image`, если модель его принимает, `none` превращается в
212
- `off: none`, а `gpt-image*` и модели без текстового вывода пропускаются.
213
- 3. Пишет результат через `ctx.configEditor.edit()`: сохраняются остальные
214
- строки патча, комментарии и чужие плагины, а изменение применяется через
215
- `dsh-hmr` без перезапуска DSH.
216
- 4. При включённом `syncAllowlist` список `subagent-model-selection-settings`
217
- приводится к тем же id моделей; записи других провайдеров не трогаются.
362
+ ## Security
218
363
 
219
- Запись выполняется только при реальном изменении каталога или списка
220
- `allowedModels`. Ответ меньше `minModelRatio` от текущего числа моделей
221
- отклоняется: частичный или пустой каталог не должен стирать рабочий список.
364
+ See [SECURITY.md](SECURITY.md). The plugin contacts only the provider hosts and
365
+ installer URLs from its own configuration, the API key is resolved on the host
366
+ by name and never reaches the browser, and npm releases carry provenance from
367
+ GitHub Actions.
222
368
 
223
- ## Инструмент
369
+ ## Moved from
224
370
 
225
- `cvc_catalog` — ручная точка входа:
371
+ The coefficient and balance functions come from two earlier plugins,
372
+ `cvc-model-coeff-plugin` and `cvc-balance-plugin`. Both repositories stay online
373
+ as archives and should be removed from the profile when this plugin is
374
+ installed; [docs/UPGRADING.md](docs/UPGRADING.md) has the exact steps.
226
375
 
227
- | Действие | Что делает |
228
- |---|---|
229
- | `status` | Последний прогон в этом процессе; без сети |
230
- | `plan` | Забрать, собрать, показать разницу, ничего не записывать |
231
- | `apply` | Забрать и записать (защита от усыхания каталога, обходится `force: true`) |
232
-
233
- ## Настройка
234
-
235
- Страница **Настройки → Каталог CVC** редактирует все параметры из блока ниже;
236
- та же форма открывается на странице плагина в **«Плагины»** — блоком между
237
- описанием и списком компонентов. Кнопки: **Сохранить** (проверяет
238
- форму и пишет строку в патч; значения, равные умолчаниям бандла, убирают
239
- переопределение), **Проверить каталог** (дифф без записи) и **Применить каталог**
240
- (запись моделей и списка сабагентов, с подтверждением). Там же — итог последнего
241
- прогона: счётчики, источник уровней, добавленные/удалённые/изменённые модели,
242
- правки списка, предупреждения и путь патча.
243
-
244
- Проверка и применение используют **сохранённые** настройки — сначала
245
- «Сохранить»; несохранённые изменения страница помечает.
246
-
247
- Страница общается с хостом через `/cvc-catalog-sync` (`state`, `config`, `run`)
248
- на веб-сервере DSH. Ключ в браузер не попадает: хост сам разрешает его по имени.
249
- Запись требует `application/json`, межсайтовые запросы отклоняются.
250
-
251
- Переопределение строки в профильном патче по id `cvc-catalog-sync` делает то же
252
- самое руками — блок конфигурации в примере выше. Маршрут, настроенный через
253
- `modelOverrides`, плагин отклоняет с понятной ошибкой: DSH не принимает
254
- `modelOverrides` рядом с `models`, такой маршрут нужно сначала перевести на явный
255
- список.
256
-
257
- Локальный бандл подключён ссылкой на каталог, а не копией: правка файлов сама
258
- новый код не поднимает — DSH подхватит модуль после реконсиляции профиля
259
- (любое изменение патча) или перезапуска приложения.
260
-
261
- ## Ограничения
262
-
263
- - Уровни вытаскиваются из установщика, а не из API. Если оба URL недоступны,
264
- текущие уровни сохраняются, а новые модели получают полный ряд по
265
- `supports_reasoning`; прогон сообщает `levelsSource: none`.
266
- - Каталог CVC не фильтруется по ключу: `/v1/models` показывает всё, а
267
- доступность решается конкретным запросом (`403 This model is not enabled for
268
- the API key`). Скрыть модели, которые ключ не обслуживает, плагин не может.
269
- - Схема DSH ограничивает **ключи** `reasoningEfforts`
270
- (`off/minimal/low/medium/high/xhigh/max`), а значения — произвольное проводное
271
- написание. Поэтому уровень `thinking` из установщика едет как `high: thinking`,
272
- и плагин повторяет это правило.
273
- - Модель, у которой каталог не объявил модальности, сохраняет текущий `input`;
274
- явный `supports_vision: false` убирает `image`.
275
-
276
- ## Проверка и откат
277
-
278
- ```powershell
279
- cvc_catalog action=plan
280
- Copy-Item ~\.dsh\profiles\desktop\cordis.patch.yml ~\.dsh\profiles\desktop\cordis.patch.yml.bak-manual
281
- cvc_catalog action=apply
282
- ```
376
+ ## License
283
377
 
284
- Профиль не под git; откат — копия файла.
378
+ MIT © 2026 mikel38487