@seaveyon/harness-switch 0.11.1 → 0.12.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
@@ -88,6 +88,51 @@ 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
+ ### CLI automation
122
+
123
+ 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:
124
+
125
+ ```bash
126
+ harness-switch list # harnesses, active profile, profile counts
127
+ harness-switch providers # Provider Vault entries
128
+ harness-switch doctor # read-only diagnostics
129
+ harness-switch doctor --probe --harness claude
130
+ harness-switch plan claude # drift inspection for a harness
131
+ harness-switch activate claude main --yes # activate a profile
132
+ ```
133
+
134
+ `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`).
135
+
91
136
  ## Security
92
137
 
93
138
  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.
@@ -136,6 +181,14 @@ The UI is a React SPA. Authentication uses an HttpOnly `hsw_session` cookie.
136
181
  | `POST` | `/api/transfer/export` | Create a passphrase-encrypted portable bundle |
137
182
  | `POST` | `/api/transfer/preview` | Decrypt and report profile counts and conflicts without writing |
138
183
  | `POST` | `/api/transfer/import` | Import with `skip` or `overwrite` conflict handling |
184
+ | `GET` | `/api/providers` | Provider Vault entries (no key material) |
185
+ | `POST` | `/api/providers` | Create a vault entry |
186
+ | `PATCH` | `/api/providers/:id` | Update; re-applies referencing active profiles |
187
+ | `DELETE` | `/api/providers/:id` | Delete; `409` while referenced by a profile |
188
+ | `GET` | `/api/drift` | Drift report for every harness |
189
+ | `POST` | `/api/drift/:harnessId/reapply` | Rewrite live files from the active profile |
190
+ | `POST` | `/api/drift/:harnessId/adopt` | Read live files back into the profile record |
191
+ | `GET` | `/api/doctor` | Read-only diagnostics (`?probe=1` includes the MVP-disabled, non-network probe check) |
139
192
 
140
193
  ## Background daemon (bunx / npx)
141
194
 
@@ -148,6 +201,7 @@ bunx @seaveyon/harness-switch@latest # start, or update + restart th
148
201
  bunx @seaveyon/harness-switch@latest status # pid, url, log path
149
202
  bunx @seaveyon/harness-switch@latest stop # stop the daemon
150
203
  bunx @seaveyon/harness-switch@latest server # run in the foreground instead
204
+ bunx @seaveyon/harness-switch@latest list # CLI automation (see above)
151
205
  ```
152
206
 
153
207
  `npx -y @seaveyon/harness-switch@latest` works the same way. Append `@latest`