fix(session-inbox-monitor): scope pi extension to own project inbox only
Per vitya's rule an agent may only read its own directory's inbox. The first global-scan version (all ~/projects inboxes + PI_INBOX_ROOTS) was scrapped same day; rewrote as session-scoped: watches only <ctx.cwd>/.claude-inbox/, decoy test proves other inboxes untouched.
This commit is contained in:
@@ -12,8 +12,8 @@ description: >
|
||||
«настрой авто-монитор инбокса», «raise inbox monitor», «auto-arm inbox
|
||||
watcher». Headless (`claude -p`): does NOT raise — Monitor doesn't work
|
||||
there; rely on the Stop-hook inbox pickup + Notify/ntfy. Pi (pi-coding-agent)
|
||||
sessions: a global extension delivers any `.claude-inbox/` message to the
|
||||
current session regardless of cwd (see the Pi section). NOT for how to
|
||||
sessions: a global extension delivers the session's own project inbox
|
||||
messages (own directory only, see the Pi section). NOT for how to
|
||||
handle a received message (→ inter-session-peer-discipline) nor the
|
||||
multi-machine inbox backend (→ cross-machine-inbox design).
|
||||
---
|
||||
@@ -129,26 +129,26 @@ for free on session end. Headless sessions skip it and rely on the pull-model
|
||||
- **No repo writes.** The hook and its `~/.claude/settings.json` registration are
|
||||
machine-local; only this skill (docs) and `.claude-inbox/` activity are in play.
|
||||
|
||||
## Pi (pi-coding-agent) support — global extension
|
||||
## Pi (pi-coding-agent) support — session-scoped global extension
|
||||
|
||||
Same contract, pi-native, and **not cwd-scoped**: which folder the pi session
|
||||
sits in is irrelevant — every `.claude-inbox/` under the configured roots is
|
||||
watched and swept; a message pages the *current* pi session with the project
|
||||
name in the header (`[inbox] <project>/<name>` + body inline, then moved to
|
||||
`.read/`).
|
||||
Same contract, pi-native, and **session-scoped**: the extension watches ONLY the
|
||||
current session's project inbox (`<ctx.cwd>/.claude-inbox/`) — it never reads
|
||||
other projects' inboxes (vitya's rule: an agent may only read its own
|
||||
directory's inbox). Installed globally so *every* pi session has the
|
||||
capability, but each session only ever touches its own project's inbox.
|
||||
|
||||
- **Source of truth:** `.common/lib/pi-extensions/inbox-monitor.ts` (Node
|
||||
built-ins only, no npm deps). Deploy: copy to
|
||||
`~/.pi/agent/extensions/inbox-monitor.ts` (global → every pi, every
|
||||
directory), hot-reload with `/reload`. Test:
|
||||
`node --experimental-strip-types .common/lib/pi-extensions/inbox-monitor.test.mjs`.
|
||||
- **Roots:** direct children of `~/projects` by default (all inboxes live there,
|
||||
depth 1); override with `PI_INBOX_ROOTS` (pathsep-separated, `;` on Windows).
|
||||
- **PUSH:** one 15s global poll while a session is live (interactive only).
|
||||
**PULL:** `agent_settled` sweep — the pi equivalent of the CC Stop-hook
|
||||
pickup. Both share one dedup set per process; the `.read/` move is the
|
||||
cross-process guard — first sweeper (CC hook or pi) claims the message, the
|
||||
other skips it.
|
||||
`node --experimental-strip-types .common/lib/pi-extensions/inbox-monitor.test.mjs`
|
||||
(incl. decoy check — another project's inbox is never touched).
|
||||
- **Opt-in per project** — same as CC: `.claude-inbox/` dir exists OR CLAUDE.md
|
||||
line `inbox monitor: raise on start`.
|
||||
- **PUSH:** 15s poll of the session's own inbox (interactive only). **PULL:**
|
||||
`agent_settled` sweep — the pi equivalent of the CC Stop-hook pickup. Both
|
||||
share one dedup set per process; the `.read/` move is the cross-process
|
||||
guard — first sweeper (CC hook or pi) claims the message, the other skips it.
|
||||
- **Headless (`pi -p`, `ctx.hasUI === false`):** NO delivery — no watcher, no
|
||||
sweep. Messages sit in the inbox until an interactive session picks them up.
|
||||
Mirrors CC headless (external Notify there, nothing in-run) and avoids
|
||||
|
||||
Reference in New Issue
Block a user