home-hosted 0.9.9 → 0.9.10

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 CHANGED
@@ -115,6 +115,39 @@ 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 list card and its detail page answer the same question; fix both.** The card is a summary of a
135
+ page someone opens *precisely because the summary was not enough* — so a fact the card states and
136
+ the page omits is worse than either alone. A stopped entry's card learned to say "not running"
137
+ where the chart's default promised "collecting…", and the detail page kept the promise on all
138
+ three of its charts, on the one screen a confused person reaches. A disabled entry's card showed a
139
+ `disabled` chip; its detail page greyed out Start and Restart and said nothing, losing the only
140
+ explanation on the way in. When you give a surface an empty state, a reason or a qualifier, grep
141
+ for the other surface that renders the same field and land it there too — and prefer a shared
142
+ component or a scan test over two call sites remembering in parallel.
143
+ - **A refused operation is a failure, never an empty success.** The backup service answers a *plan*
144
+ for every archive, including ones it cannot read: `plan.error` carries the refusal and `items` is
145
+ empty. A caller that reads only `items` reports "restored 0 items" with exit 0, which on a blank
146
+ host — the one situation where nobody can check the result — is indistinguishable from a restore
147
+ that worked. Read `error`/`needsPassword` before anything else, exit non-zero, and print `skipped`
148
+ when an apply leaves pieces behind (`src/cli/backup.ts`). The same shape is why a scoped id is
149
+ checked against the plan in **both** directions: `--exclude` with a typo excludes nothing, and an
150
+ archive restored that way carries exactly the credentials the person meant to drop.
118
151
  - **Conventional commits** — changelogen derives the changelog and `scripts/check-release-version.mjs`
119
152
  the version bump. Below 1.0 the **minor is the breaking channel**: a fix is a patch, a minor means
120
153
  someone has to read the release notes and act — ask what the user has to do, not whether the commit
@@ -183,7 +216,13 @@ These prevent defects if broken. The *why* for the non-obvious ones is in
183
216
  through the engine's admin API (atomic, never hand-edited), it runs under the same nanny a
184
217
  `persistent: true` entry uses, and its admin endpoint stays panel-side.
185
218
  - **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.
219
+ process groups vs `taskkill /T`, graceful fallbacks, no shell utilities assumed. Three Windows
220
+ behaviours no other runner here can exercise, so each is decided in **one shared helper** rather
221
+ than at the call site: a state file hand-edited in a Windows editor carries a byte-order mark or is
222
+ UTF-16, so it is read through `readStateFile` (`src/helpers/config-text.ts`) and never
223
+ `readFileSync(file, 'utf8')`; a bare command found in `node_modules/.bin` must resolve to a shim
224
+ Windows can start, never the `#!/bin/sh` script written beside it (`resolveCommand`); and text
225
+ printed **for a person to paste** is quoted for the shell it targets (`cdCommand`).
187
226
  - **Writes are atomic** (`writeFileAtomic`) and validated before commit.
188
227
 
189
228
  ## 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
  ---