@seaveyon/harness-switch 0.11.1 → 0.13.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 -2
- package/dist/harness-switch.js +1753 -171
- package/package.json +1 -1
- package/public/assets/main.2e820b75.css +2 -0
- package/public/assets/main.f1884118.js +1 -0
- package/public/index.html +1 -1
- package/public/assets/main.c2779d04.css +0 -2
- package/public/assets/main.c5247f86.js +0 -1
package/README.md
CHANGED
|
@@ -88,6 +88,64 @@ On the destination machine, select the bundle and enter the migration password.
|
|
|
88
88
|
|
|
89
89
|
Keep the migration password separately from the bundle. It cannot be recovered from the export file.
|
|
90
90
|
|
|
91
|
+
### Provider Vault: shared credentials
|
|
92
|
+
|
|
93
|
+
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:
|
|
94
|
+
|
|
95
|
+
- The vault owns the credential; the profile keeps a materialized cache so existing readers (transfer export, `active.json`, `env.sh`) keep working unchanged.
|
|
96
|
+
- Rotating the vault key or an endpoint re-applies every **active** profile that references the entry, so the live files follow immediately. Failures are reported as warnings.
|
|
97
|
+
- An entry that is referenced by any profile cannot be deleted (HTTP `409`).
|
|
98
|
+
- Detach a profile by clearing the provider selection in the profile form; the cached key stays as the profile's own inline key.
|
|
99
|
+
|
|
100
|
+
### Configuration drift
|
|
101
|
+
|
|
102
|
+
The dashboard's **配置漂移** panel 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:
|
|
103
|
+
|
|
104
|
+
- `in-sync` — disk matches what the profile would write,
|
|
105
|
+
- `drifted` — disk differs from what the profile would write,
|
|
106
|
+
- `missing` — the file does not exist yet,
|
|
107
|
+
- `invalid` — the live file cannot be parsed,
|
|
108
|
+
- `unknown` — nothing is active for this tool (official-login `text` files cannot be verified).
|
|
109
|
+
|
|
110
|
+
Two repair actions are offered per harness:
|
|
111
|
+
|
|
112
|
+
- **重新应用 (re-apply)** rewrites the live files from the active profile, with the usual backup-before-write and all-or-nothing rollback.
|
|
113
|
+
- **采纳现场配置 (adopt)** 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.
|
|
114
|
+
|
|
115
|
+
### Diagnostics (Doctor)
|
|
116
|
+
|
|
117
|
+
The **诊断 (Doctor)** panel runs read-only checks per harness: whether the tool's CLI is on `PATH` (`install`), whether each target's config directory exists (`configDir`), 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`).
|
|
118
|
+
|
|
119
|
+
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.
|
|
120
|
+
|
|
121
|
+
### Local Unix users
|
|
122
|
+
|
|
123
|
+
The dashboard header can switch between local login users such as `root` and `alice`. 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.
|
|
124
|
+
|
|
125
|
+
“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.
|
|
126
|
+
|
|
127
|
+
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.
|
|
128
|
+
|
|
129
|
+
### CLI automation
|
|
130
|
+
|
|
131
|
+
The same business logic is available from the terminal without opening the browser or starting any listener: the CLI builds the same service graph in-process and reads/writes the same data directory, so it works even when the daemon is not running. Every command supports `--json` for scripting:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
harness-switch list # harnesses, active profile, profile counts
|
|
135
|
+
harness-switch providers # Provider Vault entries
|
|
136
|
+
harness-switch doctor # read-only diagnostics
|
|
137
|
+
harness-switch doctor --probe --harness claude
|
|
138
|
+
harness-switch plan claude # drift inspection for a harness
|
|
139
|
+
harness-switch activate claude main --yes # activate a profile
|
|
140
|
+
harness-switch users # manageable local Unix users
|
|
141
|
+
harness-switch list --user alice # inspect alice's independent store
|
|
142
|
+
harness-switch activate codex main --user alice --yes
|
|
143
|
+
harness-switch sync --from root --to alice # one-time copy; skips conflicts
|
|
144
|
+
harness-switch sync --from root --to alice --overwrite
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
`plan <harness>` prints the drift inspection of the active profile (expected vs. current content per file); without an active profile it reports `status: unknown`. `activate` prompts for confirmation on a TTY and requires `--yes` in non-interactive terminals (CI). JSON output mirrors the HTTP API response shapes (`HarnessesResponse`, `ProvidersResponse`, `DoctorResponse`, `DriftSummary`, `ActivateResponse`), so scripts can reuse the same field names. `HSW_DATA_DIR` and `HSW_HOME_DIR` override where it reads state (defaults: `~/.harness-switch` and `$HOME`).
|
|
148
|
+
|
|
91
149
|
## Security
|
|
92
150
|
|
|
93
151
|
The service defaults to loopback only. Do **not** expose the management port directly to the public Internet. Use SSH port forwarding or a TLS-enabled reverse proxy with additional access control.
|
|
@@ -106,8 +164,9 @@ This protects against accidental plaintext disclosure in profile storage, but do
|
|
|
106
164
|
|---|---:|---|
|
|
107
165
|
| `HOST` | `127.0.0.1` | Bind address. Keep the default when using SSH tunnelling. |
|
|
108
166
|
| `PORT` | `8787` | Listening port. |
|
|
109
|
-
| `HSW_DATA_DIR` | `~/.harness-switch` |
|
|
110
|
-
| `HSW_HOME_DIR` | `$HOME` |
|
|
167
|
+
| `HSW_DATA_DIR` | `~/.harness-switch` | Control-plane and service-owner data directory; other users use `.harness-switch` in their own home. |
|
|
168
|
+
| `HSW_HOME_DIR` | `$HOME` | Service owner's home override, mainly for tests and containers. |
|
|
169
|
+
| `HSW_USERS` | auto-discovered | Comma-separated allowlist such as `root,alice`. The service owner is always manageable. |
|
|
111
170
|
| `HSW_SESSION_TTL_HOURS` | `24` | How long a Web login stays valid. Sessions survive a service restart. |
|
|
112
171
|
| `HSW_BACKUP_RETAIN` | `10` | Number of snapshots to keep. |
|
|
113
172
|
| `HSW_PUBLIC_DIR` | auto | Optional override for the built frontend directory. |
|
|
@@ -124,6 +183,10 @@ The UI is a React SPA. Authentication uses an HttpOnly `hsw_session` cookie.
|
|
|
124
183
|
| `POST` | `/api/auth/login` | `{ "password": "..." }` |
|
|
125
184
|
| `POST` | `/api/auth/logout` | Clears the session cookie |
|
|
126
185
|
| `GET` | `/api/auth/session` | `401` when unauthenticated |
|
|
186
|
+
| `GET` | `/api/users` | Manageable local users and the user selected by this session |
|
|
187
|
+
| `POST` | `/api/users/:username/select` | Select the target user for this Web session without writing harness files |
|
|
188
|
+
| `POST` | `/api/users/sync/preview` | Preview counts and conflicts for a cross-user config copy |
|
|
189
|
+
| `POST` | `/api/users/sync` | Copy profiles and referenced credentials using `skip` or `overwrite` conflicts |
|
|
127
190
|
| `GET` | `/api/harnesses` | Collection with nested profiles, form field specs, and live file paths |
|
|
128
191
|
| `GET` | `/api/harnesses/:id` | One harness |
|
|
129
192
|
| `POST` | `/api/harnesses/:id/profiles` | Create |
|
|
@@ -136,6 +199,14 @@ The UI is a React SPA. Authentication uses an HttpOnly `hsw_session` cookie.
|
|
|
136
199
|
| `POST` | `/api/transfer/export` | Create a passphrase-encrypted portable bundle |
|
|
137
200
|
| `POST` | `/api/transfer/preview` | Decrypt and report profile counts and conflicts without writing |
|
|
138
201
|
| `POST` | `/api/transfer/import` | Import with `skip` or `overwrite` conflict handling |
|
|
202
|
+
| `GET` | `/api/providers` | Provider Vault entries (no key material) |
|
|
203
|
+
| `POST` | `/api/providers` | Create a vault entry |
|
|
204
|
+
| `PATCH` | `/api/providers/:id` | Update; re-applies referencing active profiles |
|
|
205
|
+
| `DELETE` | `/api/providers/:id` | Delete; `409` while referenced by a profile |
|
|
206
|
+
| `GET` | `/api/drift` | Drift report for every harness |
|
|
207
|
+
| `POST` | `/api/drift/:harnessId/reapply` | Rewrite live files from the active profile |
|
|
208
|
+
| `POST` | `/api/drift/:harnessId/adopt` | Read live files back into the profile record |
|
|
209
|
+
| `GET` | `/api/doctor` | Read-only diagnostics (`?probe=1` includes the MVP-disabled, non-network probe check) |
|
|
139
210
|
|
|
140
211
|
## Background daemon (bunx / npx)
|
|
141
212
|
|
|
@@ -148,6 +219,7 @@ bunx @seaveyon/harness-switch@latest # start, or update + restart th
|
|
|
148
219
|
bunx @seaveyon/harness-switch@latest status # pid, url, log path
|
|
149
220
|
bunx @seaveyon/harness-switch@latest stop # stop the daemon
|
|
150
221
|
bunx @seaveyon/harness-switch@latest server # run in the foreground instead
|
|
222
|
+
bunx @seaveyon/harness-switch@latest list # CLI automation (see above)
|
|
151
223
|
```
|
|
152
224
|
|
|
153
225
|
`npx -y @seaveyon/harness-switch@latest` works the same way. Append `@latest`
|