|
| 1 | +### Added |
| 2 | + |
| 3 | +**`prompt` and `auto` update modes now do something, and refuse to do the wrong |
| 4 | +thing.** The previous slice made the modes configurable; this wires them to the |
| 5 | +existing signed self-updater, behind three refusals. |
| 6 | + |
| 7 | +**A package-managed install is never replaced in place.** `perry update` |
| 8 | +overwrites the running executable, which is right for a tarball or `install.sh` |
| 9 | +install and wrong for every managed one: Homebrew, npm, apt and winget each keep |
| 10 | +their own record of what is installed and at what version, and overwriting the |
| 11 | +file underneath leaves that record lying. `prompt` and `auto` now detect the |
| 12 | +owner and name that owner's command instead: |
| 13 | + |
| 14 | +| owner | what Perry says to run | |
| 15 | +|---|---| |
| 16 | +| Homebrew | `brew upgrade perryts/perry/perry` | |
| 17 | +| npm | `npm install -g @perryts/perry@latest` | |
| 18 | +| apt | `sudo apt update && sudo apt install --only-upgrade perry` | |
| 19 | +| winget | `winget upgrade PerryTS.Perry` | |
| 20 | + |
| 21 | +npm gets an extra sentence, because it is the worst case: Perry ships as a |
| 22 | +wrapper package plus a per-platform binary package, so replacing the binary also |
| 23 | +desyncs it from the wrapper that launched it. |
| 24 | + |
| 25 | +**Nothing is offered after a command that failed.** The user is looking at an |
| 26 | +error; a question about upgrading is noise at the worst possible moment, and an |
| 27 | +unattended install would bury the error under progress output. Both active modes |
| 28 | +fall back to a plain notice. |
| 29 | + |
| 30 | +**An unwritable install directory is reported, not attempted.** `install.sh` |
| 31 | +targets `/usr/local/bin`, which is root-owned on a default macOS and most Linux |
| 32 | +boxes. That is now checked *before* anything is downloaded, so the outcome is |
| 33 | +one sentence naming `sudo perry update` rather than a half-finished install. Perry |
| 34 | +never escalates on its own. |
| 35 | + |
| 36 | +**`perry update --mode <off|notify|prompt|auto>`** saves the setting and exits, |
| 37 | +so the one thing people are most likely to change does not require hand-editing |
| 38 | +TOML. It is a read-modify-write through the shared loader, so the rest of the |
| 39 | +file comes back out the way it went in. |
| 40 | + |
| 41 | +**`perry doctor`** now reports the effective mode and, when there is one, the |
| 42 | +package manager that owns the binary — the two questions behind "why did it not |
| 43 | +update". |
| 44 | + |
| 45 | +<details> |
| 46 | +<summary><b>Why the channel detection fails open</b></summary> |
| 47 | + |
| 48 | +Every rule answers "is this definitely managed?", never "is this definitely |
| 49 | +unmanaged?", and an unrecognised layout resolves to self-managed. |
| 50 | + |
| 51 | +That asymmetry is deliberate. Guessing "managed" wrongly would refuse to |
| 52 | +self-update a plain tarball install — the majority case, and the one with no |
| 53 | +other upgrade path. Guessing "self-managed" wrongly costs an in-place update on |
| 54 | +a machine that had a package manager available, which is recoverable by running |
| 55 | +that manager. |
| 56 | + |
| 57 | +The paths are canonicalized before classification, because Homebrew's `perry` in |
| 58 | +`/usr/local/bin` is a symlink into the Cellar; classifying the link rather than |
| 59 | +its target would miss every Homebrew install there is. |
| 60 | + |
| 61 | +apt requires **both** a dpkg file list and a dpkg-owned path, because dpkg does |
| 62 | +not own `/usr/local` — that is `install.sh`'s directory. The path alone would |
| 63 | +misclassify a hand-placed binary; the dpkg list alone would claim a tarball |
| 64 | +install on a machine that also has the `.deb` installed somewhere else. The check |
| 65 | +is a file-existence test rather than a `dpkg -S` subprocess, since this runs on |
| 66 | +the update path of every command. |
| 67 | +</details> |
| 68 | + |
| 69 | +<details> |
| 70 | +<summary><b>Prompting needs stdin, not just stderr</b></summary> |
| 71 | + |
| 72 | +The mode gate already requires stderr to be a terminal. That is not enough to |
| 73 | +ask a question: stdin can be a pipe while stderr is a tty, and reading from it |
| 74 | +would either block the command or take whatever the pipe happened to contain as |
| 75 | +consent. `prompt` degrades to a plain notice when stdin is not a terminal. |
| 76 | + |
| 77 | +`auto` asks nothing, so it does not need stdin — but it does still require the |
| 78 | +command to have succeeded, an unmanaged install, and a writable directory. |
| 79 | +</details> |
| 80 | + |
| 81 | +<details> |
| 82 | +<summary><b>Tests</b></summary> |
| 83 | + |
| 84 | +24 new, all in the required per-pull-request job. The decision is a pure |
| 85 | +function of the mode plus four facts about the machine, so every refusal is |
| 86 | +asserted directly rather than left inside an `if` in the middle of a teardown |
| 87 | +path: |
| 88 | + |
| 89 | +- both active modes downgrade to a notice after a failed command; |
| 90 | +- both refuse on all four managed channels, and name a command for each; |
| 91 | +- both report elevation rather than attempting an unwritable install; |
| 92 | +- `prompt` degrades without stdin while `auto` does not need it. |
| 93 | + |
| 94 | +The channel table covers Homebrew under all three prefixes, npm for global, nvm |
| 95 | +and project-local layouts, apt with and without each half of its rule, both |
| 96 | +winget delivery shapes, and four unrecognised layouts that must fail open. |
| 97 | +Classification splits on both path separators rather than using |
| 98 | +`Path::components`, so the winget cases run on every host instead of only on |
| 99 | +Windows. |
| 100 | + |
| 101 | +Verified end to end: writing `mode` into a real config file that already had a |
| 102 | +`license_key` and an unknown `[update] future_key` left both intact. |
| 103 | + |
| 104 | +`cargo test -p perry`: 914 passed, 0 failed. |
| 105 | +</details> |
0 commit comments