feat(cli)!: merge the daemon into pi2 as the daemon subcommand

`pi2 daemon [start] [flags]` now starts the web-console daemon. The
`pi2d` executable, its bin entry and its entry module are removed: the
daemon keeps its lock -> token -> plugin socket -> listen -> daemon.json
lifecycle, its single stdout line (`pi2 daemon listening on ...`) and the
signal handling that leaves managed nvim instances running.

Service files are renamed to `pi2.service` / `com.pi2.daemon`, and the
smoke and e2e harnesses start the daemon through `pi2 daemon`.

BREAKING CHANGE: the `pi2d` command no longer exists; use `pi2 daemon`
(or `pi2 daemon start`). Existing systemd/launchd units installed under
the old names must be reinstalled with `pi2 install-service --write`.
This commit is contained in:
yuez committed 2026-10-22 15:47:48 +08:00
1 parent b02f4e9070
commit 7e780515ac
38 files changed
+295 -232

No files matched your search

+4 -4
View File
@@ -30,7 +30,7 @@ fail() {
echo "--- daemon log ---"; tail -60 "$LOG" 2>/dev/null || true
echo "--- instance logs ---"; ls -la "$STATE/instances" 2>/dev/null || true; tail -80 "$STATE"/instances/*.log 2>/dev/null || true
echo "--- nvim web log ---"; find "$STATE" -name 'pi2-web.log' -exec tail -80 {} \; 2>/dev/null || true
echo "--- processes ---"; ps -eo pid,ppid,etime,args | grep -E "nvim|pi --mode|node .*pi2d" | grep -v grep || true
echo "--- processes ---"; ps -eo pid,ppid,etime,args | grep -E "nvim|pi --mode|node .*pi2\.js daemon" | grep -v grep || true
echo "--- sessions endpoint ---"; curl -sS -H "Authorization: Bearer $TOKEN" "$BASE/api/v1/workspaces/$WSID/sessions" 2>/dev/null | head -c 2000 || true
echo
echo "--- state ---"; ls -la "$STATE" "$RUN" 2>/dev/null || true
@@ -39,13 +39,13 @@ fail() {
command -v jq >/dev/null || { echo "jq is required"; exit 2; }
command -v pi >/dev/null || { echo "pi CLI is required"; exit 2; }
[ -f "$REPO/dist/cli/pi2d.js" ] || { echo "run: npx tsc -p tsconfig.json"; exit 2; }
[ -f "$REPO/dist/cli/pi2.js" ] || { echo "run: npx tsc -p tsconfig.json"; exit 2; }
echo "==> workspace $WS"
printf '# e2e\n' > "$WS/README.md"
echo "==> starting pi2d"
node "$REPO/dist/cli/pi2d.js" --foreground --port 0 >"$LOG" 2>&1 &
echo "==> starting pi2 daemon"
node "$REPO/dist/cli/pi2.js" daemon --foreground --port 0 >"$LOG" 2>&1 &
DPID=$!
cleanup() {
kill "$DPID" 2>/dev/null || true