Commit Graph
35 Commits
Author SHA1 Message Date
yuez 88e73c7737 feat(web): port the pi2-web-ui-design v0.1.1 UI
Sync the React console with the v0.1.1 prototype (20 CHGs): Quiet Workbench
shell, Chat IA v3, tool-family rendering, and the mobile page pill.

Shell / tokens (CHG-01/04/15/20):
- tokens.css rewritten from the prototype (three-layer light/dark/system),
  `--tabbar-h` removed, new faint/border-subtle/surface-1-2/fs-*/dur-*/reading-max
- 56px icon-only nav rail/sidebar (44x44 hit targets, CSS tooltips, active is a
  solid primary fill, no left bar), 52px topbar, merged preferences menu,
  ⌘K/Cmd-K palette
- `<600` gets a topbar page pill + page sheet; the bottom tabbar is gone

Pages (CHG-01): workspaces becomes a card grid with whole-card links and a
320px recent-activity column; status gets four metric tiles + a zero-primary
layout; connect gets a two-column hero, one primary per state and a collapsed
manual form.

Chat IA v3 (CHG-02/10-14/16-19): two columns, single-workspace tree with a
workspace switch, single-line rows with attention, body-level row popover,
session tray (todo/tasks) replacing the right panel, context ring moved into a
composer telemetry line, right-aligned user messages, queued messages as one
stream entity plus a composer status bar, and an in-place subagent child view.

Tool rendering (CHG-05/06/09): new `features/chat/tools` module — one row per
call, DTO adapter for the daemon's block shape, 11 kind families, state
semantics ("one state, one meaning"), 44px touch targets and the diff row
contrast fix.

i18n: 729 keys per language (zh/en parity checked), 0 unresolved keys.

Verification: web typecheck + 297 vitest + vite build green, root typecheck
green, `scripts/smoke.sh` green, and a new visual harness
(`scripts/ui-mock-server.mjs` + `scripts/ui-shots.mjs`, docs/ui-parity.md)
shoots 4 pages x 3 viewports x 2 themes = 24 screenshots clean with
overflow/console/primary/tabbar assertions. `scripts/e2e/ui-e2e.mjs` selectors
are updated to the new DOM; that suite still needs a real pi + nvim to run.
2026-10-26 20:28:47 +08:00
yuez a8425a51b6 docs: add the AGENTS.md index and a release skill
AGENTS.md is a 77-line index (the file itself states the <=100-line rule): quick
commands, layout, the hard invariants that keep the daemon a router rather than
an agent runtime, and pointers into docs/ and .agents/skills/.

The release skill turns docs/releasing.md into a runbook plus a checkable
artifact: scripts/verify-release.sh asserts the registry version, the SLSA
provenance attestation, a clean install from the public registry, the tarball
contents, a booting daemon serving / and a healthy /api/v1/health, and the
GitHub release. Verified against the live 0.1.2 publish.
2026-10-23 10:54:44 +08:00
yuez 181b22ad00 chore: release 0.1.2 2026-10-23 10:42:09 +08:00
yuez b3183fd4d0 chore: release 0.1.1 2026-10-23 10:37:14 +08:00
yuez 2589e6df72 build: publish the npm package as @yuez/pi2d
The unscoped name was rejected by the registry's similarity filter ("too similar
to existing packages pify, ping, pino, pm2, uid"), so the package moves under the
maintainer's npm scope, which is not subject to that heuristic.

The executable is still `pi2`, the GitHub repository is still `zgs225/pi2d` (the
trusted publisher matches on owner/repo/workflow filename, not the npm name), and
the tarball contents are unchanged. The releasing checklist also had the npm
account wrong: the registry account is `yuez`, while `zgs225` is the GitHub owner
the trusted publisher is configured against.
2026-10-23 10:31:32 +08:00
yuez 9eb7075d70 docs: document the workspace visibility knobs and the curl check 2026-10-23 10:08:15 +08:00
yuez ef0d9b9125 ci: publish npm with Trusted Publishing instead of a token
The release job now authenticates with the GitHub OIDC token: `id-token: write`,
no NPM_TOKEN anywhere near the publish step, and a guard that fails when a
leftover repository secret is still mapped in. npm 11.5.1+ is required for
trusted publishing and setup-node's node 22 ships npm 10, so the job upgrades npm
and asserts npm/node versions plus the presence of the OIDC endpoint before
publishing. Provenance then comes for free.

docs/releasing.md documents the unavoidable bootstrap: npm only offers the
trusted-publisher settings page once the package exists, so the first version is
published from the maintainer's machine and every later one from CI.
2026-10-23 10:08:15 +08:00
yuez 0193230cd3 feat(cli): flag a missing curl in pi2 doctor
`:PiWeb` signs the local browser in through curl (Neovim has no HTTP client), so
a missing binary breaks the primary onboarding path. The new `curl` check sits
with the other binary probes, warns instead of failing, and can never flip
`doctor`'s exit code.
2026-10-23 10:08:15 +08:00
yuez 64a1a98c1f feat(daemon): collapse workspace noise into a "show hidden" section
Discovery returns every pi session directory ever seen, so the console opened on
47 rows on this machine: 20 ghosts (cwd deleted) and 21 scratch dirs under /tmp
next to the real projects. Every row now carries a derived, non-persisted
`visibility`/`visibilityReason`; nothing is filtered server-side, so
`/workspace/<id>` deep links and the chat page's id lookup still resolve.

Precedence: explicit `hidden` wins; a live instance, `pinned` or `trusted`
rescues a row; then temp paths (`PI2_WORKSPACE_HIDE_TEMP`, on), ghosts
(`PI2_WORKSPACE_HIDE_GHOSTS`, on), outside roots (`PI2_WORKSPACE_HIDE_OUTSIDE_ROOTS`,
off) and staleness (`PI2_WORKSPACE_STALE_DAYS`, off). Measured on real data:
47 → 26 default rows, 0 openable rows lost.

The browser collapses the secondary rows behind a persisted toggle and dims them
with a reason badge; `workspace.add` now clears `hidden`.
2026-10-23 10:08:15 +08:00
yuez 58e247644d fix: make the pnpm workspace config installable
`allowBuilds` still held the generator placeholder, so `pnpm install` aborted
with ERR_PNPM_IGNORED_BUILDS on current pnpm — which would have failed CI before
it ran a single test.
2026-10-23 10:08:15 +08:00
yuez 62d1d9cd38 chore: license pi2d under MIT
Adds the LICENSE file (MIT, matching pi2.nvim) and ships it in the published
tarball alongside dist/ and web/dist/.
2026-10-23 10:08:15 +08:00
yuez 84869f3dc6 test(e2e): cover the console login handoff (A13) 2026-10-23 08:34:48 +08:00
yuez 51ef1c250b feat(web): consume the :PiWeb login handoff before the first route
The daemon hands the browser `http://127.0.0.1:<port>/#t=<token>`. The token is
read once, stored through the connection store (so the `pi2-connection` marker is
set too and a fresh browser does not bounce to /connect), and stripped from the
address bar and history while the query string survives.
2026-10-23 08:34:48 +08:00
yuez 9ab0830223 feat(cli): add pi2 open, pi2 pairing --public-url and the access check
`pi2 open [--print] [--no-browser]` mints a loopback browser session and hands
the URL to the platform opener without waiting for it, so "open the console" is
one command that never hangs. `pi2 pairing --public-url` (or `daemon.json.publicUrl`
/ `PI2_PUBLIC_URL`) rebuilds the printed URL and QR payload for a tailnet or
reverse-proxy base.

`pi2 doctor` gains an `access` check: ok on loopback, warn for `lan`/`tailscale`,
fail when a non-loopback bind has neither a public URL nor TLS.
2026-10-23 08:34:48 +08:00
yuez 01db49fb38 feat(daemon): add access modes and the local-browser login handshake
`PI2_ACCESS_MODE` (local|lan|tailscale) picks the bind address and the derived
CORS origins, `PI2_PUBLIC_URL` adds the external origin, and `PI2_ORIGINS` is now
additive instead of replacing the derived list. `daemon.json` and
`/api/v1/info` carry the mode and the public URL.

`POST /api/v1/console/session` is the `:PiWeb` handshake: loopback + the local
CLI token only, it mints or reuses the single "local browser" device and answers
`http://127.0.0.1:<port>/#t=<token>`. The token is stored plaintext next to
`devices.json` (0600) so repeated logins return the same credentials instead of
logging the already-open tab out; revoking the device drops it.
2026-10-23 08:34:39 +08:00
yuez 9eb857465c docs: document the npm install path, :PiWeb and remote access modes 2026-10-22 17:19:38 +08:00
yuez e32e86a377 ci: add a check pipeline and a tag-driven npm release
ci runs typecheck + unit tests + build + scripts/smoke.sh and asserts the
publishable tarball embeds dist/ and web/dist/ without leaking src/ or test/.

release verifies the tag matches package.json, runs the tests and publishes
with provenance.
2026-10-22 17:19:38 +08:00
yuez 7c98510fea build: publish pi2d to npm with the built web console
- rename the package to `pi2d`, drop `private`, publish publicly
- ship `dist/` + `web/dist/` through a `files` allowlist so the daemon
  serves the console from its own package (no build step for users)
- `prepack` rebuilds both from the tagged source on every publish
2026-10-22 17:19:38 +08:00
yuez 66682725d4 docs: point the pi2.nvim link at its real repository 2026-10-22 16:49:19 +08:00
yuez 06e70204e7 fix(web): render the chat session tree from parent/sub-session lineage
The sidebar treated every workspace session as a root and only nested the
manifest sub-agents, so sub-session files showed up as siblings (the same child
twice); sub-sessions the plugin marked hidden were listed anyway.

- build the tree from `parentId` in a pure `buildSessionTree` model: orphans are
  promoted to roots, cycles and duplicate ids are guarded, real child-session
  rows win over the manifest projection, and the routed row force-opens its
  ancestors
- honour the plugin's `:PiSessions` visibility (`visible: false`) with a "show
  hidden sub-sessions" toggle, the routed-row exception and a dedicated
  all-hidden empty state
- keep tree metadata across WS snapshots, reducer events, id migration and
  parent removal; prefer a root row for the `/chat` index and add a "back to
  parent" action
- document the session-row and `pi2:subagents` list metadata in the protocol
2026-10-22 16:45:09 +08:00
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 b02f4e9070 test(e2e): add the full web-console end-to-end gate
- API/WS driver A0–A12: auth/pairing, workspaces, instances, session create,
  real model streaming, abort, model/thinking, history paging, resync,
  multi-workspace isolation, subagents and a deterministic attention/diff
  trigger (attention-ext.ts).
- Playwright driver B1–B14 + C1–C4: guard/pairing, workspaces, chat streaming,
  abort, panels, attention, status/devices, reconnect, deep links, i18n/theme,
  responsive overflow and console errors.
- lib.sh isolates every run (runtime/data/state/agent dirs, ephemeral port,
  fresh workspaces) and reaps by /proc env; run-all.sh builds both sides.
  Document the plan and the 31/31 acceptance run.
2026-10-21 20:42:34 +08:00
yuez 0ef019f58d fix(web): make the web console work end-to-end
- Pair through the public POST /api/v1/pair and persist the device scopes;
  keep the allow-listed next deep link. Rename the manual field to pairing code.
- Authenticate the WebSocket with the raw device token (strip Bearer) and
  recover from a 401 by clearing the connection once.
- Fix chat payloads: setModel/setThinking, attention/diff responses, subagent
  dispatch items, queue ids/mode, task output and WS resume since.
- Render exactly one assistant message per turn: one-to-one snapshot/history
  merge plus a stale-delta guard after message_end (fixes PONGONG).
- Fix dialogs (content above the overlay), unknown-session deep links
  (error + retry, no silent fallback), device list/revoke, status identity and
  live pairing code, reconnect banner and Playwright selectors.
2026-10-21 20:42:19 +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 31f36302bd test(daemon): align the entries relay assertion with workspace.query{kind:entries} 2026-10-21 14:43:46 +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 721661177c feat(web): workspaces, connect and status pages plus the full chat experience
- workspaces list + new-workspace flow (add -> ensure -> navigate), server context bar
- connect: manual/pair-code redeem, QR scan with paste fallback, paired summary, disconnect
- status: info/health/resources/models/devices/connection cards with 3s visible-only polling
- chat: 3/2/1-column layout, session tree, virtualized stream, tool/thinking/todo/batch blocks,
  composer with queue chips and abort, subagents/todo/tasks panel, attention + diff review modals,
  history pagination merged with live entries
- canonical reducer reused via @protocol alias (no duplicated types)
- 63 vitest tests, typecheck + build green, zh/en parity at 411 keys
2026-10-21 13:32:34 +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 5b55e622ea feat(web): React 19 + Vite + Tailwind v4 + shadcn foundation
- design tokens ported verbatim from the product design, data-theme light/dark
- app shell: topbar, sidebar/rail/tabbar responsive nav, lang + theme menus
- ui primitives (button/card/badge/dot/chip/tabs/dialog/sheet/toast/kv/seg/progress)
- api client, reconnecting ws client, zustand stores, route guard to /connect
- full zh/en dictionaries (key parity test), 32 vitest specs, dist committed
2026-10-21 11:33:36 +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