@seaveyon/harness-switch 0.18.0 → 0.19.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 +74 -41
- package/dist/harness-switch.js +2212 -2266
- package/package.json +7 -4
- package/public/assets/main.6f32f876.js +62 -0
- package/public/assets/main.df7f242e.css +2 -0
- package/public/index.html +1 -1
- package/public/assets/main.4105ef6d.css +0 -2
- package/public/assets/main.800fe65f.js +0 -62
package/README.md
CHANGED
|
@@ -4,52 +4,80 @@
|
|
|
4
4
|
|
|
5
5
|
English | [简体中文](https://github.com/B1anker/harness-switch/blob/main/README.zh-CN.md)
|
|
6
6
|
|
|
7
|
-
**harness-switch** is a
|
|
7
|
+
**harness-switch** is a local control plane for switching the API configuration used by **Claude Code**, **Codex**, **Kimi Code**, **Pi**, and **DeepSeek Harness (DSH)**. Run it on the computer that runs those tools; open its browser UI, choose a saved profile, and activate it.
|
|
8
8
|
|
|
9
|
-
It writes
|
|
9
|
+
It writes the tools’ native configuration files directly. It is not a proxy, never receives model traffic, and does not need you to source a shell script.
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## What you get
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
| Capability | What it means |
|
|
14
|
+
|---|---|
|
|
15
|
+
| One profile per provider or use case | Switch base URL, key, model, and harness-specific options from one UI. |
|
|
16
|
+
| Safe native-file writes | Every activation is validated, transactional, backed up, and can be undone. |
|
|
17
|
+
| Credential reuse | Store a key once in Provider Vault and reuse it across profiles. |
|
|
18
|
+
| Import, export, and sync | Adopt existing configs, move encrypted bundles between machines, or copy config between Unix users. |
|
|
19
|
+
| Diagnostics | Compare the active profile with live files, detect drift, and re-apply or adopt changes. |
|
|
20
|
+
|
|
21
|
+
## Compatibility
|
|
22
|
+
|
|
23
|
+
| Area | Support |
|
|
24
|
+
|---|---|
|
|
25
|
+
| Operating systems | macOS, Windows, Linux |
|
|
26
|
+
| Runtime | Node.js >= 18.17 or Bun >= 1.2 |
|
|
27
|
+
| Browser access | Open `http://127.0.0.1:8787` on the same machine by default |
|
|
28
|
+
| Remote access | Optional SSH tunnel or a properly secured reverse proxy |
|
|
29
|
+
| Multiple local users | Unix-like hosts; Windows manages the account that starts the service |
|
|
30
|
+
|
|
31
|
+
## Get started
|
|
32
|
+
|
|
33
|
+
Start with any package runner:
|
|
14
34
|
|
|
15
35
|
```bash
|
|
16
|
-
bunx @seaveyon/harness-switch@latest
|
|
17
36
|
npx -y @seaveyon/harness-switch@latest
|
|
18
37
|
pnpm dlx @seaveyon/harness-switch@latest
|
|
38
|
+
bunx @seaveyon/harness-switch@latest
|
|
19
39
|
```
|
|
20
40
|
|
|
21
41
|
`pnpx @seaveyon/harness-switch@latest` is also supported where `pnpx` is available. Or install it globally:
|
|
22
42
|
|
|
23
43
|
```bash
|
|
24
|
-
|
|
25
|
-
# npm install -g @seaveyon/harness-switch
|
|
44
|
+
npm install -g @seaveyon/harness-switch
|
|
26
45
|
# pnpm add -g @seaveyon/harness-switch
|
|
46
|
+
# bun add -g @seaveyon/harness-switch
|
|
27
47
|
harness-switch
|
|
28
48
|
```
|
|
29
49
|
|
|
30
|
-
The command starts a background daemon on `127.0.0.1:8787
|
|
50
|
+
The command starts a background daemon on `127.0.0.1:8787` and prints the path to the generated Web password. Then:
|
|
51
|
+
|
|
52
|
+
1. Open [http://127.0.0.1:8787](http://127.0.0.1:8787) in a browser on that machine.
|
|
53
|
+
2. Sign in with the generated password.
|
|
54
|
+
3. Create a profile for one harness and select **Activate**.
|
|
55
|
+
|
|
56
|
+
Use `harness-switch status` to see the URL, log, data directory, and password-file location. On macOS and Linux, the default password file is:
|
|
31
57
|
|
|
32
58
|
```bash
|
|
33
59
|
cat ~/.harness-switch/web_password
|
|
34
60
|
```
|
|
35
61
|
|
|
36
|
-
|
|
62
|
+
### Accessing a remote machine
|
|
63
|
+
|
|
64
|
+
SSH is optional. When harness-switch runs on a remote or headless host, keep it bound to loopback and forward the port:
|
|
37
65
|
|
|
38
66
|
```bash
|
|
39
67
|
ssh -N -L 8787:127.0.0.1:8787 user@your-server
|
|
40
68
|
```
|
|
41
69
|
|
|
42
|
-
Then open <http://127.0.0.1:8787>
|
|
70
|
+
Then open <http://127.0.0.1:8787> in your local browser. Use `harness-switch status`, `stop`, or `server` to inspect, stop, or run the service in the foreground.
|
|
43
71
|
|
|
44
72
|
### Interface language
|
|
45
73
|
|
|
46
74
|
The web UI supports English and Simplified Chinese. Use the language button in the login page or dashboard header to switch languages. Chinese remains the default for existing behavior; your selection is stored in the browser and is reused on later visits. The setting affects only the web interface—it does not change profile data or generated configuration files.
|
|
47
75
|
|
|
48
|
-
##
|
|
76
|
+
## Switch a tool
|
|
49
77
|
|
|
50
78
|
Create one or more profiles per harness in the web UI. A profile holds a display name, API Base URL, API key, model, notes, and whatever extra fields that harness needs. Select **Activate** to make a profile current.
|
|
51
79
|
|
|
52
|
-
Activation writes each tool's own configuration file.
|
|
80
|
+
Activation writes each tool's own configuration file. Changes apply to the machine where harness-switch runs; it cannot change a tool already running elsewhere.
|
|
53
81
|
|
|
54
82
|
| Harness | File written | Write mode | Takes effect |
|
|
55
83
|
|---|---|---|---|
|
|
@@ -69,22 +97,22 @@ Notes on individual harnesses:
|
|
|
69
97
|
- **Pi** (`@earendil-works/pi-coding-agent`) registers a custom provider in `models.json` and points `settings.json` at it via `defaultProvider` / `defaultModel`. The API key must live in that provider entry (or `auth.json`); otherwise Pi shows "No models available" and asks for `/login`. A `--model` flag still overrides the default at runtime.
|
|
70
98
|
- **DeepSeek Harness** registers a custom `llm-pi-ai` provider, stores the API key in its separate credentials document, and updates `agent-default-model`. Existing sessions keep their selected route; newly created sessions use the activated profile.
|
|
71
99
|
|
|
72
|
-
`~/.harness-switch/env.sh`
|
|
100
|
+
`~/.harness-switch/env.sh` is only a compatibility layer for Codex’s environment-variable auth mode:
|
|
73
101
|
|
|
74
102
|
```bash
|
|
75
103
|
source ~/.harness-switch/env.sh
|
|
76
104
|
```
|
|
77
105
|
|
|
78
|
-
|
|
106
|
+
Keep in mind:
|
|
79
107
|
|
|
80
108
|
- Writing TOML goes through parse and re-serialize, so comments and layout in `config.toml` are lost. YAML and JSON keep their comments and key order.
|
|
81
|
-
-
|
|
109
|
+
- It cannot rewrite the environment of an already-running shell.
|
|
82
110
|
|
|
83
111
|
### Advanced: taking over the raw file
|
|
84
112
|
|
|
85
113
|
Any field the form does not expose can be set by editing the raw file content in the profile's **Advanced: raw configuration** section. Once edited, that file is generated from your text instead of the form fields until you select **Restore automatic generation**. Content that cannot be parsed back is rejected before it reaches disk.
|
|
86
114
|
|
|
87
|
-
|
|
115
|
+
## Keep changes safe
|
|
88
116
|
|
|
89
117
|
Before every write, the previous content of each target file is snapshotted into `~/.harness-switch/backups/`, keeping the most recent 10. The backup panel restores a snapshot verbatim, comments included. Snapshots never land next to the live file, because tools like Claude Code scan their own config directory.
|
|
90
118
|
|
|
@@ -94,7 +122,7 @@ Backup directories live in the managed user's own home, so on a root-run service
|
|
|
94
122
|
|
|
95
123
|
Switching away from a profile first reads the live file back into that profile's record, so edits you made directly in the CLI tool are not lost on the next switch.
|
|
96
124
|
|
|
97
|
-
###
|
|
125
|
+
### Recovery after an interrupted write
|
|
98
126
|
|
|
99
127
|
An in-process `try/catch` only covers a thrown error. A power cut, SIGKILL, OOM or an upgrade restart never gives it the chance to run, and the native config, the profile store and the recorded active profile can be left describing three different states.
|
|
100
128
|
|
|
@@ -107,11 +135,13 @@ PREPARED → APPLYING → METADATA_COMMITTED → COMMITTED
|
|
|
107
135
|
|
|
108
136
|
On startup the service settles whatever it finds, for every account it may manage. The boundary that matters is `METADATA_COMMITTED`: by then everything the operation set out to change is already on disk, so it rolls forward to `COMMITTED` rather than undoing a switch the user saw succeed. Anything still at `APPLYING` may be half written and is rolled back whole. A rollback that itself fails is recorded as `DEGRADED` and surfaced in the UI for a human.
|
|
109
137
|
|
|
110
|
-
Writing `active.json` now happens inside the same transaction as the native files, so the config on disk and the record of what is live can no longer disagree. Each record doubles as a receipt: the files it changed, the backup id, the target user and where it got to.
|
|
138
|
+
Writing `active.json` now happens inside the same transaction as the native files, so the config on disk and the record of what is live can no longer disagree. Each record doubles as a receipt: the files it changed, the backup id, the target user and where it got to. Each harness’s right-hand **Operation history** card lists them and offers a one-click undo that puts the native files *and* `active.json` back together, rather than just restoring a few files. The undo takes its own snapshot first. Once a backup has been rotated away, its receipt is automatically marked as no longer undoable.
|
|
111
139
|
|
|
112
140
|
`HSW_JOURNAL_RETAIN` controls how many receipts are kept; the default is 50.
|
|
113
141
|
|
|
114
|
-
|
|
142
|
+
## Bring in and move configuration
|
|
143
|
+
|
|
144
|
+
### Import configuration you already have
|
|
115
145
|
|
|
116
146
|
If you configured these tools by hand before installing harness-switch, **Import existing config** in the top bar adopts that setup instead of making you retype it.
|
|
117
147
|
|
|
@@ -121,17 +151,17 @@ Each candidate is decided on its own: store it as a standalone profile, or extra
|
|
|
121
151
|
|
|
122
152
|
**Neither the scan nor the import touches the tools' own config files.** An import writes only to harness-switch's own profile store and vault; making it take effect still requires an explicit activation. A config file that exists but cannot be parsed causes that tool to be skipped with a reason, rather than guessed at.
|
|
123
153
|
|
|
124
|
-
###
|
|
154
|
+
### Move profiles to another machine
|
|
125
155
|
|
|
126
|
-
Use **Import / Export** in the top bar to create one `.hsw-backup` file containing every Harness profile, API key, raw-file override, and current activation choice. The bundle is encrypted with a migration password you choose, so it does not depend on the source machine's `aes-256-gcm.key`.
|
|
156
|
+
Use **Import / Export** in the top bar to create one `.hsw-backup` file containing every Harness profile, Provider Vault credential and endpoint, API key, raw-file override, and current activation choice. The bundle is encrypted with a migration password you choose, so it does not depend on the source machine's `aes-256-gcm.key`.
|
|
127
157
|
|
|
128
|
-
On the destination machine, select the bundle and enter the migration password. The UI shows profile counts and same-name conflicts before it writes anything. Import keeps destination profiles by default; overwriting is an explicit choice. Restoring the exported activation state is optional.
|
|
158
|
+
On the destination machine, select the bundle and enter the migration password. The UI shows profile counts, credential counts, and same-name profile conflicts before it writes anything. Import keeps destination profiles by default; overwriting is an explicit choice. Provider Vault entries are always restored as isolated copies and never replace a destination credential; an ID conflict gets a new imported ID, and imported profiles reference that copy. Restoring the exported activation state is optional.
|
|
129
159
|
|
|
130
160
|
A Codex official-login cache (`$CODEX_HOME/auth.json`) is **excluded by default**. When a valid cache is available, you may explicitly include it in the encrypted bundle. Import offers the separate migration choice only when the bundled and destination JSON values differ. This carries a reusable Codex/ChatGPT login session: share such a bundle only with a trusted recipient, and expect upstream expiry or revocation to still require a fresh `codex login`. An existing destination cache is backed up before replacement; copied caches are written as the destination user with mode `0600`.
|
|
131
161
|
|
|
132
162
|
Keep the migration password separately from the bundle. It cannot be recovered from the export file.
|
|
133
163
|
|
|
134
|
-
### Provider Vault
|
|
164
|
+
### Reuse credentials with Provider Vault
|
|
135
165
|
|
|
136
166
|
The **Provider Vault** stores an API key once under a named entry with one or more named endpoints (each a base URL), encrypted with the same AES-256-GCM key that protects `profiles.json`. A profile can reference a vault entry instead of carrying its own key:
|
|
137
167
|
|
|
@@ -140,9 +170,11 @@ The **Provider Vault** stores an API key once under a named entry with one or mo
|
|
|
140
170
|
- An entry that is referenced by any profile cannot be deleted (HTTP `409`).
|
|
141
171
|
- Detach a profile by clearing the provider selection in the profile form; the cached key stays as the profile's own inline key.
|
|
142
172
|
|
|
143
|
-
|
|
173
|
+
## Verify and repair configuration
|
|
174
|
+
|
|
175
|
+
### Detect configuration drift
|
|
144
176
|
|
|
145
|
-
The dashboard
|
|
177
|
+
The dashboard **Diagnostics** panel also compares what the active profile would render against the actual files on disk, using parsed-value comparison for JSON/TOML/YAML so a re-render that only reorders keys does not count as drift. Each file is reported as:
|
|
146
178
|
|
|
147
179
|
- `in-sync` — disk matches what the profile would write,
|
|
148
180
|
- `drifted` — disk differs from what the profile would write,
|
|
@@ -155,15 +187,17 @@ Two repair actions are offered per harness:
|
|
|
155
187
|
- **Re-apply** rewrites the live files from the active profile, with the usual backup-before-write and all-or-nothing rollback.
|
|
156
188
|
- **Adopt live configuration** reads the live files back into the profile record (same path as the pre-switch backfill). It refuses with `409` when the profile has manual raw overrides, and never adopts content the tool itself could not parse.
|
|
157
189
|
|
|
158
|
-
###
|
|
190
|
+
### Run diagnostics
|
|
159
191
|
|
|
160
|
-
|
|
192
|
+
**Diagnostics (Doctor)** run per harness from that tool’s right-hand column: for CLI-delivered tools, whether the executable is on `PATH` (`install`; skipped for web-service harnesses such as DeepSeek Harness), whether each target file exists and is readable/writable (`files`, with a warning when a config file holding credentials is group/other-readable), whether the files parse (`parse`), and whether live state drifts from the active profile (`drift`). A global update check reports whether a newer release exists (`updatedAvailable`).
|
|
161
193
|
|
|
162
194
|
The connectivity probe is **disabled by default in the MVP**: passing `--probe` only records a `unknown`-status check that reports the active base URL and explains that no network request is made.
|
|
163
195
|
|
|
164
|
-
|
|
196
|
+
## Manage local Unix users
|
|
197
|
+
|
|
198
|
+
This optional multi-user feature is for Unix-like hosts. On Windows, harness-switch manages the account that starts it.
|
|
165
199
|
|
|
166
|
-
The dashboard header
|
|
200
|
+
The account menu at the right of the dashboard header switches between local login users such as `root` and `alice`, and keeps sign-out alongside those identity actions. Each user has independent profiles, Provider Vault, encryption key, active state and backups under their own home. Selecting a user does not write any harness file; only an explicit activation does.
|
|
167
201
|
|
|
168
202
|
“Sync user config” performs a one-time copy of another user's profiles and referenced Provider Vault credentials into the selected user. Secrets are decrypted only on the server and re-encrypted with the destination user's local key. Active state, backups and native config files are not copied. Same-name profiles are skipped by default and can be explicitly overwritten.
|
|
169
203
|
|
|
@@ -171,7 +205,7 @@ A source user's Codex official-login cache (`auth.json`) is the sole optional ex
|
|
|
171
205
|
|
|
172
206
|
Cross-user writes require access to the destination home. Managing both `root` and regular users therefore normally requires running harness-switch as root; newly created files and directories are assigned to the destination UID/GID. The Web password then grants control over every exposed user's configs, so keep the loopback bind and SSH tunnel. Use `HSW_USERS=root,alice` to restrict the manageable accounts.
|
|
173
207
|
|
|
174
|
-
|
|
208
|
+
## Automate with the CLI
|
|
175
209
|
|
|
176
210
|
The CLI talks to the running local daemon and uses the same authenticated HTTP API as the Web UI. Start the daemon once before using API-backed commands. `help` and `version` work offline; data commands support `--json` (or `-j`) for scripting:
|
|
177
211
|
|
|
@@ -273,28 +307,28 @@ The UI is a React SPA. Authentication uses an HttpOnly `hsw_session` cookie.
|
|
|
273
307
|
| `GET` | `/api/doctor` | Read-only diagnostics (`?probe=1` includes the MVP-disabled, non-network probe check) |
|
|
274
308
|
| `GET` | `/api/scan` | Providers the five tools already have on disk; read-only, credentials masked |
|
|
275
309
|
| `POST` | `/api/scan/import` | Save selected candidates as profiles or vault entries; the tools' own config is untouched |
|
|
276
|
-
| `GET` | `/api/operations` | Operation receipts, newest first |
|
|
310
|
+
| `GET` | `/api/operations` | Operation receipts, newest first (`?harness=claude` to filter) |
|
|
277
311
|
| `GET` | `/api/operations/:id` | One receipt |
|
|
278
312
|
| `POST` | `/api/operations/:id/undo` | Put the native files and the active profile back to before that operation |
|
|
279
313
|
|
|
280
314
|
Every POST/PATCH body is validated against a shared Zod schema (`packages/shared/src/schemas.ts`) that the server and the web client both build on. A malformed shape is rejected with a `400` naming the field *before* it reaches storage, instead of being persisted and only surfacing as a `500` on the next activation. Unknown fields are dropped rather than rejected, so an older client keeps working while nothing unrecognised enters the store.
|
|
281
315
|
|
|
282
|
-
## Background daemon (
|
|
316
|
+
## Background daemon (npx / pnpm / Bun)
|
|
283
317
|
|
|
284
318
|
The published CLI runs as a background daemon by default: the command returns
|
|
285
319
|
immediately, the server keeps running after the terminal is closed, and
|
|
286
320
|
re-running after a release restarts the daemon on the newest version.
|
|
287
321
|
|
|
288
322
|
```bash
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
323
|
+
npx -y @seaveyon/harness-switch@latest # start, or update + restart the daemon
|
|
324
|
+
npx -y @seaveyon/harness-switch@latest status # pid, url, log path
|
|
325
|
+
npx -y @seaveyon/harness-switch@latest stop # stop the daemon
|
|
326
|
+
npx -y @seaveyon/harness-switch@latest server # run in the foreground instead
|
|
327
|
+
npx -y @seaveyon/harness-switch@latest list # CLI automation (see above)
|
|
294
328
|
```
|
|
295
329
|
|
|
296
|
-
Replace `
|
|
297
|
-
so the package runner fetches the newest release before running. Bun
|
|
330
|
+
Replace `npx -y` with `pnpm dlx`, `pnpx`, or `bunx` as preferred. Append `@latest`
|
|
331
|
+
so the package runner fetches the newest release before running. The same executable supports both Node.js and Bun; use `node dist/harness-switch.js` or `bun dist/harness-switch.js` when running an installed build directly.
|
|
298
332
|
|
|
299
333
|
The daemon writes its PID, instance identity, and listening address to `~/.harness-switch/daemon.pid` and its log to
|
|
300
334
|
`~/.harness-switch/daemon.log` (a fresh log per start). The first run creates
|
|
@@ -305,8 +339,7 @@ new process, so the port never conflicts and the newest code wins.
|
|
|
305
339
|
Startup reports success only after the new process answers `/healthz`. `status` returns a non-zero exit code when the recorded daemon is not healthy. Before `stop` or an update sends a signal, the recorded instance identity is verified so a stale, reused PID cannot terminate an unrelated process.
|
|
306
340
|
|
|
307
341
|
The dashboard polls the npm registry and shows a one-click **update button**
|
|
308
|
-
next to the version badge when a newer release exists; it
|
|
309
|
-
`bunx <package>@latest` restart under the hood and reloads the page once the
|
|
342
|
+
next to the version badge when a newer release exists; it uses `npx -y` under Node.js or `bun x` under Bun to restart, then reloads the page once the
|
|
310
343
|
new version is up. Update logs land in `~/.harness-switch/update.log`.
|
|
311
344
|
|
|
312
345
|
Under systemd (or any supervisor), run the CLI in the foreground instead:
|