feat(cli): add pi2 uninstall for cross-channel state cleanup

`install.sh --uninstall`, `brew uninstall`, `npm rm -g` and
`pi2 uninstall-service` each own one slice; none of them removed the
runtime directory, and deleting the binary left a running daemon behind.

`pi2 uninstall` now owns the state for every channel: disable and remove
the unit, stop the daemon, delete the runtime dir, and — with `--purge` /
`--purge-config` — the data, state and env file. On the curl channel
`--purge` also deletes the install tree, last, because the running binary
lives inside it; npm/brew/AUR trees stay with their package manager, and
the command to remove them is printed instead.

Destructive by design: the plan is always printed, `--yes` (or an
interactive `y`) is required, non-TTY runs refuse without it, and
everything a reinstall would silently lose is an explicit opt-in. The
next-steps footer names what no CLI can clean: the browser's site data and
the plugin-private copy from `:PiWebInstall`.

Docs: rewrite the install.md uninstall section around the two layers
(state vs. binaries) with a table of every path, point deployment.md at
the new command, and update the README.
This commit is contained in:
yuez committed 2026-10-30 09:40:05 +08:00
1 parent c2d1f1d960
commit 2240289426
7 files changed
+1000 -6

No files matched your search

+10 -2
View File
@@ -47,12 +47,19 @@ points `~/.local/lib/pi2d/current` at it, writes an install receipt and symlinks
`~/.local/bin/pi2`. After that, `pi2 update` upgrades it in place (verified download, SLSA
provenance check, atomic `current` switch, one-step rollback).
To uninstall:
To uninstall, first remove the daemon's local state (runtime, service unit, and — with flags —
data/state/config), then the binaries:
```bash
curl -fsSL https://raw.githubusercontent.com/zgs225/pi2d/main/scripts/install.sh | sh -s -- --uninstall
pi2 uninstall --dry-run # what would be removed
pi2 uninstall --purge --purge-config --yes # daemon state, logs, env file (curl channel: also the tree)
```
On the npm / Homebrew / AUR channels the binary tree belongs to the package manager:
`npm rm -g @yuez/pi2d`, `brew uninstall pi2d`, `sudo pacman -R pi2d-bin`. See
[Complete removal](docs/install.md#uninstall) for the full table of paths and the two things
no CLI can clean (browser site data, the plugin-private copy).
### Channel C: System packages (Homebrew, AUR)
*(Available once the release that publishes binaries has shipped)*:
@@ -127,6 +134,7 @@ pi2 install-service --write # render and write user service file
pi2 service status # unit, enabled, active, linger (--json for machines)
pi2 service enable # daemon-reload + enable --now (start|stop|disable too)
pi2 uninstall-service --write # remove user service file
pi2 uninstall [--dry-run] [--yes] [--purge] # remove local state (all channels)
pi2 status # daemon status, active instances, and health
pi2 doctor # verify node/runtime, nvim, pi, curl, sockets, protocol
pi2 --version # print version