Commit Graph
10 Commits
Author SHA1 Message Date
yuez 7e780515ac 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`.
2026-10-22 15:47:48 +08:00
yuez 5572ac0d84 fix(daemon): forward snapshot entries and map workspace errors
- Preserve the snapshot entries tail in the cache and WS frames (cold,
  cached and bus paths), so the browser receives {state, entries}.
- Await a plugin snapshot on the first subscribe of a fresh session.
- Return E_FORBIDDEN (403) for workspace paths outside PI2_WORKSPACE_ROOTS.
- Mint cli.token only after the singleton lock is held, so a second daemon
  cannot invalidate the running one.
- Add hostname/os/version/uptimeMs/pid/port to /api/v1/info and make
  /health reflect instance, workspace and auth state.
2026-10-21 20:42:02 +08:00
yuez 854d6d2997 fix(web): connect the chat to the daemon end-to-end
- ws auth frame now carries the token top-level (docs §3.3); daemon accepts payload.token too
- entries route accepts workspaceId/sessionFile so disk-only sessions page history
- chat registers session metadata and pages history for non-live sessions
- e2e asserts a real ASSISTANT reply (PONG) and waits up to 180s
- visual.sh: real daemon + pairing + Playwright screenshots of the four pages
2026-10-21 14:23:09 +08:00
yuez 2e5d6d5006 fix(daemon): propagate plugin ack payloads and route entries correctly
- CommandAck spreads the plugin payload so sessionId/results reach callers
- /sessions/:sid/entries relays workspace.query{kind:entries} (was session.entries)
- scripts/e2e: daemon -> headless nvim -> real pi prompt -> history, verified end-to-end
2026-10-21 13:29:08 +08:00
yuez 18e3e0ab4e feat(cli): runnable daemon, local CLI, doctor, service files and smoke test
- composition root wiring config/auth/workspaces/instances/http
- singleton lock + daemon.json + port retry + local cli.token (admin scope)
- pi2 attach/status/doctor/pairing/install-service
- systemd user unit + launchd plist rendering (never auto-enabled)
- smoke.sh boots the real daemon on an ephemeral port and asserts auth/static/lifecycle
- 93 new tests (263 total), tsc + build + smoke green
2026-10-21 12:45:11 +08:00
yuez a495f2ac71 feat(instances): plugin socket server and one-nvim-per-workspace supervisor
- JSONL plugin server with hello token auth, frame cap, heartbeat and E_LEASE rejection
- PluginConnection with ack correlation, snapshot cache, per-epoch seq
- lazy spawn (headless nvim), degrade-on-crash with process_exit fanout, no auto-restart
- shutdown drain/stop with SIGTERM/SIGKILL escalation, RSS resources view
- 57 tests against a generated fake nvim
2026-10-21 11:50:51 +08:00
yuez 4e98ef8658 feat(workspaces): registry and header-only disk discovery
- atomic 0600 workspaces.json with corrupt-file recovery
- discovery reads only the first JSONL line for the authoritative cwd
- cache by dir mtime+count: cold 27-37ms / warm 9.6ms on 1313 files
- 38 tests, real-machine benchmark documented in the report
2026-10-21 11:14:12 +08:00
yuez ba3719fad9 feat(daemon): HTTP/WS/SSE surface with auth, static, command routing and event relay
- Hono app + ws upgrade server, ephemeral-port friendly, idempotent close
- device tokens (sha256 + timingSafeEqual), one-time pairing, Origin allowlist
- SPA static serving with traversal protection and cache policy
- command router with 5-min clientRequestId dedupe and protocol error mapping
- 66 tests against fake InstanceManager/WorkspaceStore/Bus
2026-10-21 11:14:12 +08:00
yuez bdcab3ce29 feat(core): frozen internal interfaces and platform paths
- PluginConnection / InstanceManager / WorkspaceStore / Bus contracts
- Linux+macOS runtime/data/state dirs, hashed unix socket paths, pi agent dir
2026-10-21 10:59:43 +08:00
yuez 9d817f35b7 feat(protocol): wire contract, canonical reducer and golden fixtures
- v1 envelope across browser/daemon/plugin
- SessionState model + reducer rules (pi events + pi2:* derived events)
- fixtures for basic turn, queue/todo/attention and abort/exit
- 9 conformance tests pinning the reducer
2026-10-21 10:58:46 +08:00