home-hosted 0.9.9 → 0.9.11
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/AGENTS.md +75 -1
- package/README.md +13 -0
- package/dist/cli.js +541 -233
- package/dist/cli.js.map +1 -1
- package/docs/RESTORE_DEMO.md +45 -12
- package/docs/SERVERS.md +23 -2
- package/package.json +1 -1
- package/uis/stock/dist/assets/{de-Cf0vh5VW.js → de-BP4HfMC9.js} +1 -1
- package/uis/stock/dist/assets/{es-DvlrGqi4.js → es-Cehmpy7G.js} +1 -1
- package/uis/stock/dist/assets/{fr-CRZwjDEG.js → fr-DN3eC8Ey.js} +1 -1
- package/uis/stock/dist/assets/{index-BkfQL_xe.js → index-CB6K3K2b.js} +12 -12
- package/uis/stock/dist/assets/{ja-DtLbY1Wl.js → ja-CYAuNjfG.js} +1 -1
- package/uis/stock/dist/assets/{ko-D0_fMO0J.js → ko-wQEmDRMK.js} +1 -1
- package/uis/stock/dist/assets/{ru-DQOEnxXc.js → ru-BtbhojJ0.js} +1 -1
- package/uis/stock/dist/assets/{vi-nanLxe06.js → vi-BfUCVFk_.js} +1 -1
- package/uis/stock/dist/assets/{zh-CN-M5LvmyF0.js → zh-CN-DEhi0m5s.js} +1 -1
- package/uis/stock/dist/index.html +1 -1
- package/uis/stock/dist/ui.json +3 -3
package/AGENTS.md
CHANGED
|
@@ -115,6 +115,67 @@ workspace config guard, so a busy default port turns config tests red for the wr
|
|
|
115
115
|
alerted-on gauge published as `0` from an unsampled view is indistinguishable from a healthy one
|
|
116
116
|
and silences the rule that exists to catch it. Omit the series (`src/api/metrics.ts`), and never
|
|
117
117
|
suffix `_total` a value that a user action resets.
|
|
118
|
+
- **Name the cause the fix follows, not the one the code path suggests.** Node reports a missing
|
|
119
|
+
working directory and a missing program with the same `ENOENT`, so `describeSpawnError` checks the
|
|
120
|
+
resolved `cwd` **and** whether the field holds a whole command line before it blames the command —
|
|
121
|
+
otherwise a deploy under systemd reads "`node` is not installed" while `node` is fine and only the
|
|
122
|
+
launch directory is wrong, and a pasted `node server.js` reads the same way while `node` is
|
|
123
|
+
installed. The same rule decides which advice a refused start prints: a config that needs `migrate`
|
|
124
|
+
must say so rather than "install the release", and a file that cannot be parsed must not claim a
|
|
125
|
+
migration `migrate` cannot perform. Ask what the person will *do* with the sentence before choosing
|
|
126
|
+
it — and when a function's own docstring names the misreading it exists to prevent, that is a claim
|
|
127
|
+
to test, not a description of the code.
|
|
128
|
+
- **One envelope per reader.** This API answers `{ message, code, detail }` for a thrown error and
|
|
129
|
+
`{ ok: false, error }` for a refused lifecycle action. A client that reads one field shows
|
|
130
|
+
`request failed with 409` for the other, losing the only sentence that explains the refusal while
|
|
131
|
+
the card beside it prints that sentence in full. Read both in **one** helper
|
|
132
|
+
(`failureMessage`, `src/shared/api-client.ts`) and scan for the hand-rolled fallback — a unit test
|
|
133
|
+
cannot see a call site that has not been written yet.
|
|
134
|
+
- **A state and the streak behind it are written together.** `health`, `healthFailures` and
|
|
135
|
+
`unhealthySince` describe one process's run, so a path that resets one and leaves the others
|
|
136
|
+
reports a duration that keeps counting while nothing is measured — measured as `status=crashed
|
|
137
|
+
health=unknown` beside `Unhealthy for 3m 17s` and a `Not Probed` row, on the card and the page.
|
|
138
|
+
The explicit stop had that shape and was fixed alone once; the exit paths behind it were the same
|
|
139
|
+
defect. One helper decides the trio (`setHealth`/`resetHealth` in `src/services/supervisor.ts`)
|
|
140
|
+
and a scan fails a direct assignment. **A client cannot assume the server got there** — a newer
|
|
141
|
+
UI is served against an older panel, so a UI rendering a *duration* gates it on the verdict it
|
|
142
|
+
prints beside it, not on whether the timestamp is present.
|
|
143
|
+
- **A measurement belongs to the process that produced it, and goes when that process does.**
|
|
144
|
+
`pid`, `responseMs` and `resources` are one run's numbers; a path that detaches the pid and keeps
|
|
145
|
+
them reports a stopped entry with a live CPU, RSS and probe (`Probe 2 Ms / RSS 64.2 MB / Procs 1`
|
|
146
|
+
beside `Stopped`, and `hh_server_cpu_percent` in the scrape). The two **exit** paths cleared them
|
|
147
|
+
and the explicit stop did not — and an **adopted** successor has no exit event at all, because the
|
|
148
|
+
panel is not its parent, so one helper (`endProcessReadings`) owns all four and a scan fails a
|
|
149
|
+
clear outside it. The rule is general: ask which **lifecycle** clears a field, not which function
|
|
150
|
+
happened to. `portState` is the deliberate exception — a port's occupancy outlives its process.
|
|
151
|
+
The client half is the same predicate as the paragraph above: both UIs read a reading through
|
|
152
|
+
`liveReadings` (`src/shared/server-readings.ts`), never off the frame, and never `?? 0` (a zero
|
|
153
|
+
is the value that looks like a measured idle process).
|
|
154
|
+
- **A list card and its detail page answer the same question; fix both.** The card is a summary of a
|
|
155
|
+
page someone opens *precisely because the summary was not enough* — so a fact the card states and
|
|
156
|
+
the page omits is worse than either alone. A stopped entry's card learned to say "not running"
|
|
157
|
+
where the chart's default promised "collecting…", and the detail page kept the promise on all
|
|
158
|
+
three of its charts, on the one screen a confused person reaches. A disabled entry's card showed a
|
|
159
|
+
`disabled` chip; its detail page greyed out Start and Restart and said nothing, losing the only
|
|
160
|
+
explanation on the way in. When you give a surface an empty state, a reason or a qualifier, grep
|
|
161
|
+
for the other surface that renders the same field and land it there too — and prefer a shared
|
|
162
|
+
component or a scan test over two call sites remembering in parallel.
|
|
163
|
+
- **A replaced list is sent only when *this form* changed it, and merged against what it was
|
|
164
|
+
filled with.** `destinations` and `routes` are lists a patch replaces, so a save writes the
|
|
165
|
+
sender's whole view — including entries it never saw. Deciding that against live state makes
|
|
166
|
+
another client's save look like this form's own edit: measured with two tabs on one workspace
|
|
167
|
+
settings page, a destination added in one tab was removed from `settings.json` by the other
|
|
168
|
+
saving an unrelated toggle. Keep the baseline the block was filled with and compare the draft to
|
|
169
|
+
*that* (`mergeReplacedList`); a list that was never filled must not travel, because `[]` on a
|
|
170
|
+
replaced list means "delete every entry".
|
|
171
|
+
- **A refused operation is a failure, never an empty success.** The backup service answers a *plan*
|
|
172
|
+
for every archive, including ones it cannot read: `plan.error` carries the refusal and `items` is
|
|
173
|
+
empty. A caller that reads only `items` reports "restored 0 items" with exit 0, which on a blank
|
|
174
|
+
host — the one situation where nobody can check the result — is indistinguishable from a restore
|
|
175
|
+
that worked. Read `error`/`needsPassword` before anything else, exit non-zero, and print `skipped`
|
|
176
|
+
when an apply leaves pieces behind (`src/cli/backup.ts`). The same shape is why a scoped id is
|
|
177
|
+
checked against the plan in **both** directions: `--exclude` with a typo excludes nothing, and an
|
|
178
|
+
archive restored that way carries exactly the credentials the person meant to drop.
|
|
118
179
|
- **Conventional commits** — changelogen derives the changelog and `scripts/check-release-version.mjs`
|
|
119
180
|
the version bump. Below 1.0 the **minor is the breaking channel**: a fix is a patch, a minor means
|
|
120
181
|
someone has to read the release notes and act — ask what the user has to do, not whether the commit
|
|
@@ -159,6 +220,13 @@ These prevent defects if broken. The *why* for the non-obvious ones is in
|
|
|
159
220
|
local command must not open an unauthenticated `/api` route.
|
|
160
221
|
- **A server id is only unique inside its workspace.** Anything keyed by id alone — SSE, log buffers,
|
|
161
222
|
series, route params — must key on `(workspaceId, serverId)`, or same-named servers mix frames.
|
|
223
|
+
**So must "what this panel owns."** A per-workspace service answering a panel-wide question — "is
|
|
224
|
+
this pid ours?" — asks its own workspace and silently gets the wrong answer for the others: a port
|
|
225
|
+
held by a sibling workspace's server read as a stranger, so `free-port` terminated it and `follow`
|
|
226
|
+
adopted it into the wrong workspace (two workspaces then claimed one pid). The panel is the only
|
|
227
|
+
thing that can see every workspace, so it injects the answer (`SupervisorOptions.siblingServers`)
|
|
228
|
+
and a lone supervisor has none. Such a refusal must also say **where** the holder lives: "stop that
|
|
229
|
+
server instead" is a dead end when that server is on a page this workspace cannot show.
|
|
162
230
|
- **A workspace is the ownership boundary.** Servers, secrets, logs and nanny state belong to exactly
|
|
163
231
|
one; only listener, auth, TLS, host vitals, backups, UI and `run.json` are panel-wide. Reach a
|
|
164
232
|
per-workspace service through `PanelService.requireWorkspace(id)`, never a module global.
|
|
@@ -183,7 +251,13 @@ These prevent defects if broken. The *why* for the non-obvious ones is in
|
|
|
183
251
|
through the engine's admin API (atomic, never hand-edited), it runs under the same nanny a
|
|
184
252
|
`persistent: true` entry uses, and its admin endpoint stays panel-side.
|
|
185
253
|
- **Cross-platform is a hard requirement.** Linux/macOS/Windows: `/proc` vs `ps` vs Win32_Process,
|
|
186
|
-
process groups vs `taskkill /T`, graceful fallbacks, no shell utilities assumed.
|
|
254
|
+
process groups vs `taskkill /T`, graceful fallbacks, no shell utilities assumed. Three Windows
|
|
255
|
+
behaviours no other runner here can exercise, so each is decided in **one shared helper** rather
|
|
256
|
+
than at the call site: a state file hand-edited in a Windows editor carries a byte-order mark or is
|
|
257
|
+
UTF-16, so it is read through `readStateFile` (`src/helpers/config-text.ts`) and never
|
|
258
|
+
`readFileSync(file, 'utf8')`; a bare command found in `node_modules/.bin` must resolve to a shim
|
|
259
|
+
Windows can start, never the `#!/bin/sh` script written beside it (`resolveCommand`); and text
|
|
260
|
+
printed **for a person to paste** is quoted for the shell it targets (`cdCommand`).
|
|
187
261
|
- **Writes are atomic** (`writeFileAtomic`) and validated before commit.
|
|
188
262
|
|
|
189
263
|
## How to work here
|
package/README.md
CHANGED
|
@@ -190,6 +190,7 @@ home-hosted up --foreground # stays in the foreground, logs to stderr
|
|
|
190
190
|
Description=home-hosted
|
|
191
191
|
[Service]
|
|
192
192
|
User=$YOUR_USER
|
|
193
|
+
WorkingDirectory=/srv/home-hosted
|
|
193
194
|
ExecStart=/usr/local/bin/home-hosted up --foreground
|
|
194
195
|
Environment=HHOSTED_HOME=/srv/home-hosted
|
|
195
196
|
Restart=always
|
|
@@ -197,6 +198,13 @@ Restart=always
|
|
|
197
198
|
WantedBy=multi-user.target
|
|
198
199
|
```
|
|
199
200
|
> [!CAUTION]
|
|
201
|
+
> **`WorkingDirectory` is not optional.** Relative entry paths — a server's `cwd`, a
|
|
202
|
+
> `{projectDir}` placeholder, a relative `dataEnvs` — resolve against the directory the panel is
|
|
203
|
+
> started from. systemd starts a unit in `/` unless told otherwise, so without it every relative
|
|
204
|
+
> path in your `servers.config.json` points somewhere under `/` and the entries fail to start.
|
|
205
|
+
> Docker does the same unless you pass `-w`. Set it to the directory holding the config you run
|
|
206
|
+
> from, or pin it explicitly with `Environment=HHOSTED_PROJECT=/srv/home-hosted`.
|
|
207
|
+
>
|
|
200
208
|
> Note: change `$YOUR_USER` to your actual user account, or remove for `root`.
|
|
201
209
|
> You could also change `/srv/home-hosted` to change where the data stores.
|
|
202
210
|
|
|
@@ -765,6 +773,11 @@ expose them to an unprivileged process. Adopting a self-restarted process works
|
|
|
765
773
|
its argv instead of the environment marker; a launcher whose real process is a `.cmd` shim is the one
|
|
766
774
|
case it cannot see through, and `kill` is the answer there.
|
|
767
775
|
|
|
776
|
+
A config edited in Notepad or PowerShell is read as it is: the byte-order mark Notepad's "UTF-8 with
|
|
777
|
+
BOM" adds, and the UTF-16 that `>` and `Out-File` write, are both understood. A `command` naming a
|
|
778
|
+
project dependency resolves to the `.cmd`/`.exe` shim under `node_modules/.bin` rather than the
|
|
779
|
+
`#!/bin/sh` script beside it.
|
|
780
|
+
|
|
768
781
|
</details>
|
|
769
782
|
|
|
770
783
|
---
|