@aiwayds/dsh-model-sync 0.1.1 → 0.1.2
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 +92 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# dsh-model-sync
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@aiwayds/dsh-model-sync) · [GitHub](https://github.com/fan56/dsh-model-sync)
|
|
4
|
+
|
|
5
|
+
A dsh (DeepSeek Harness) Cordis plugin that keeps the model catalog of your `llm-pi-ai` provider routes in step with the pi.dev gateway's model listing — written into dsh `settings.yaml` through the official settings seam (`settings.mutate`), with zero patches to dsh internals.
|
|
6
|
+
|
|
7
|
+
## Why
|
|
8
|
+
|
|
9
|
+
Model lists drift: providers ship new models, retire old ones, and adjust capabilities (`contextWindow`, `input` modalities, `thinkingFormat`, reasoning efforts). Keeping them in sync by hand is error-prone busywork. dsh-model-sync does it for you:
|
|
10
|
+
|
|
11
|
+
- **Add-only, change-only writes.** New models from pi.dev are merged in, existing ones updated, and unchanged routes are left completely untouched — the writer compares against the raw user segment and skips a route when nothing changed (`writer.ts`, `profilesEqual`, `reason: 'no-change'`).
|
|
12
|
+
- **No hand-maintained model lists.** The pi.dev remote catalog is the source of truth for the managed routes; your `settings.yaml` simply reflects it.
|
|
13
|
+
- **Scheduled refresh.** An auto round runs shortly after startup and then on a configurable interval, so the catalog stays current without any interaction.
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- **pi.dev gateway sync.** Fetches each managed route's model list from `https://pi.dev/api/models/providers/<route>` with ETag/304 revalidation and a persistent per-provider cache under `~/.dsh/models-store.json` (`remote-catalog.ts`). Transient failures and aborts keep the last-good cache; a 404/501 treats the route as absent for the round.
|
|
18
|
+
- **Default routes.** When `managedRoutes` is empty, these pi.dev routes are synced: `opencode-go`, `zai-coding-cn`, `minimax-cn`, `xiaomi-token-plan-cn` (`DEFAULT_ROUTES` in `src/index.ts`).
|
|
19
|
+
- **Two write modes** (`writeMode`):
|
|
20
|
+
- `settings` — the zero-patch pipeline: fetch → translate → `settings.mutate`. Self-contained; never touches `settings.yaml` directly, only via the official settings API.
|
|
21
|
+
- `overlay` (default, legacy) — delegates to the patched `dsh-llm-pi-ai` adapter's `piAiCatalog.refresh()` and merges pi.dev entries in memory (requires the optional patch).
|
|
22
|
+
- **Scheduled refresh.** `intervalMinutes` auto rounds (default 60) plus a `startupDelaySeconds` initial delay (default 5); each round logs the same report a manual refresh produces. `0` disarms the interval (startup-only). The interval re-arms live when the config changes (`src/index.ts`).
|
|
23
|
+
- **Change reporting / diff.** Every round reports added/removed model ids (`diffModelIds`), and in `settings` mode added/removed/changed entries against the current raw settings (`diffEntries`, `diff.ts`). Dropped and degraded entries are reported with their reasons.
|
|
24
|
+
- **`modelSync` service.** Exposes a `modelSync` service (`syncNow()`) that a UI can call to force one refresh round and read the report.
|
|
25
|
+
- **Translation rules.** pi.dev entries are translated into settings-writable model profiles (`translate.ts`): base-matching vs base-less classification, `reasoningEfforts` derivation (S2 gate), `compat` gating to `openai-completions` (S5 gate), `maxTokens` handling, and drop logic for mixed-protocol routes.
|
|
26
|
+
- **Safe-by-default options:**
|
|
27
|
+
- `keepBuiltinOnly: true` — keep built-in catalog models that are not (yet) on pi.dev, so adopting the sync doesn't delete models you already use.
|
|
28
|
+
- `dropUnserviceable: true` — drop unserviceable entries and continue; set to `false` to abort the whole route instead of writing a partial list.
|
|
29
|
+
- `forceMaxReasoningEffort` — force models with a non-empty `thinkingFormat` to max reasoning effort (ensures `reasoningEfforts` contains `max` and forces `compat.supportsReasoningEffort = true` on `openai-completions`).
|
|
30
|
+
- **Conflict-safe writes.** Writes carry the settings revision and retry once on `SETTINGS_CONFLICT` (`writer.ts`).
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
Requires Node ≥ 22.19 and a dsh profile. Install as a dsh plugin:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm i @aiwayds/dsh-model-sync
|
|
38
|
+
dsh plugin add @aiwayds/dsh-model-sync
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The package ships `cordis.patch.yml` (wired as `dsh.bundle.patch`), which mounts the plugin into the profile's assembly tree under the stable plugin id `dsh-model-sync` and registers the `model-sync` settings namespace.
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
Configure the plugin under the `model-sync` namespace in `settings.yaml` — every key is optional:
|
|
46
|
+
|
|
47
|
+
| Key | Default | Description |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| `writeMode` | `'overlay'` | `'settings'` for the zero-patch pipeline; `'overlay'` for the legacy patched-adapter mode |
|
|
50
|
+
| `intervalMinutes` | `60` | Auto-refresh interval in minutes; `0` = startup-only |
|
|
51
|
+
| `startupDelaySeconds` | `5` | Delay before the first auto refresh, so the llm adapter is ready |
|
|
52
|
+
| `refreshTimeoutMs` | `120000` | Abort budget for one refresh round's network request (min `1000`) |
|
|
53
|
+
| `managedRoutes` | `[]` | Routes to sync; empty = the default pi.dev routes |
|
|
54
|
+
| `keepBuiltinOnly` | `true` | Keep built-in-only models not present on pi.dev (smooth migration) |
|
|
55
|
+
| `dropUnserviceable` | `true` | Drop unserviceable entries; `false` aborts the route instead |
|
|
56
|
+
| `forceMaxReasoningEffort` | `false` | Force max reasoning effort on models with a non-empty `thinkingFormat` |
|
|
57
|
+
|
|
58
|
+
Example:
|
|
59
|
+
|
|
60
|
+
```yaml
|
|
61
|
+
model-sync:
|
|
62
|
+
writeMode: settings
|
|
63
|
+
intervalMinutes: 30
|
|
64
|
+
managedRoutes:
|
|
65
|
+
- opencode-go
|
|
66
|
+
- zai-coding-cn
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The plugin writes to the `llm-pi-ai` namespace (`providers.<route>.models`) — the same document the adapter consumes — and only for the routes it manages. During migration, `keepBuiltinOnly` preserves models that exist in your installed built-in catalog but aren't on pi.dev yet.
|
|
70
|
+
|
|
71
|
+
## Development
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm run build # tsc → lib/
|
|
75
|
+
npm run check # tsc --noEmit typecheck
|
|
76
|
+
npm test # node --test (pretest builds): diff / translate / writer / remote-catalog / serviceability
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Tests use per-route pi.dev fixtures under `test/fixtures/` and temp directories for the models store — they never touch the real `~/.dsh`.
|
|
80
|
+
|
|
81
|
+
Utility scripts under `scripts/`:
|
|
82
|
+
|
|
83
|
+
- `generate-builtin-snapshot.mjs` — regenerate `src/builtin-catalog-snapshot.ts` from the installed `@deepseek-ai/dsh-llm-pi-ai` catalog (`--generate` for dev, `--check` for CI).
|
|
84
|
+
- `verify-no-patch.mjs` — exits non-zero if any installed `dsh-llm-pi-ai` still carries the overlay patch signatures (`withRemoteCatalog` / `piAiCatalog`).
|
|
85
|
+
- `backup/backup-patched.mjs` — back up a patched `dsh-llm-pi-ai/lib/index.js` to `backups/`.
|
|
86
|
+
- `backup/restore-official.mjs` — restore the official unpatched `dsh-llm-pi-ai/lib/index.js` from npm, validated against the patch (`--dry-run` supported).
|
|
87
|
+
|
|
88
|
+
The repo also carries the reference patches that document the legacy overlay behavior: `docs-dsh-llm-pi-ai.patch` (pi.dev remote-catalog overlay for `dsh-llm-pi-ai`) and `docs-dsh-llm-pi-ai-compat.patch` (`supportsDeveloperRole` compat passthrough).
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiwayds/dsh-model-sync",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "dsh plugin:
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "dsh plugin: keep llm-pi-ai provider routes' model lists in step with the pi.dev gateway, written through the official settings seam",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|