Registry Mirror
Skip to content

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

Part 1 of 3 of the approved "inbox-agent-awareness" build (approval 2026-10-12, decisions 1, 2, 3, 7). Part 2 (session reminder hooks, Claude Code's Inbox tool before the first run) and part 3 (global notes, the first-open card, Settings → Agents, the install prompt) are separate PRs.

What it does

  • A person's plannotator inbox (with or without --no-open; never --background, the shim, a connection starting a stopped Inbox, or the window's Restart) connects every agent found on this computer that has no record yet (packages/server/inbox-agents.ts):
    • its own mcp add: Codex, Gemini CLI (-s user), Windsurf/Devin (-s user), Amp, Cline (--yes), Pi without the extension;
    • one key in a strictly parsed plain-JSON file: Cursor (~/.cursor/mcp.json), Kiro (~/.kiro/settings/mcp.json), the Claude desktop app (claude_desktop_config.json, with "restart the Claude app");
    • Pi / OpenCode with Plannotator's extension / plugin: inboxTool.<host> = true in config.json. Claude Code: nothing.
  • Entries run <this CLI> inbox mcp (absolute path, selfCommand()).
  • An Inbox already running (an agent started it): the command opens the window, then asks it over a new token-guarded POST /api/inbox/control/connect.
  • Every later run connects agents installed since and says so once ("Connected Amp to the Inbox (new on this computer)"). A recorded agent (turned off, removed outside Plannotator, foreign) is never added back. A plannotator-inbox entry that runs something else is never replaced.
  • Files: symlinks written at their target, CRLF / indentation / mode kept, atomic, no write when nothing changes, refused when not plain JSON / not a regular file / over 1 MiB / not UTF-8 (packages/server/agent-files.ts). Limits: 10 s per agent, 30 s in total.
  • PLANNOTATOR_INBOX_CONNECT=0 skips the step. GET /api/inbox/agents (local only) reports the records and the last run, for the card in part 3.
  • plannotator uninstall (plain and --purge) removes the entries it added (by record, then a scan of the known files). --dry-run lists them. An entry changed by hand is skipped and named.

Safety

  • Tests use fake agent CLIs on a scratch PATH and HOME (tests/helpers/fake-agents.ts). The real agent CLIs never run. The test preload, worldEnv, the CLI test sandbox and the --no-open e2e set PLANNOTATOR_INBOX_CONNECT=0. A test-sandboxed run whose home is not a scratch folder connects nothing (agentHomeAllowed).
  • The never-touch-the-real-inbox guard now also fails on a path from the real home to an agent's folder, and on connecting agents with no agent environment.

Tests

  • packages/server/inbox-agents.test.ts (27): detection, each agent's command, found / foreign / manual, failure and retry, per-agent and total limits, CRLF and indentation, refused JSONC, symlink, removed outside, the Claude app, the Pi / OpenCode switch (also off and env-locked), later runs, removal plans.
  • packages/server/inbox-connect-route.test.ts (token, single flight, Origin refused), apps/hook/server/inbox-connect-cli.test.ts (real processes: --background connects nothing, a person's run on that Inbox does, a later run connects a new agent, CONNECT=0 skips), uninstall tests.
  • bun test packages/server apps/hook/server/inbox-cli.test.ts apps/hook/server/inbox-help.test.ts tests/: 1533 pass. bun run typecheck clean.

Deviations from the approval record

  • The connect record is inbox/agents.json (DESIGN.md). The notes record (part 3) will be inbox/agent-notes.json.
  • Cline's config file is not verified, so its state comes from the record only, and uninstall runs cline mcp remove plannotator-inbox (also not verified).
  • Devin's user-scope config is read from ~/.config/devin/config.json (per devin mcp remove --help), not the mcp_config.json the harness snippet names.
  • Codex or Gemini found by its folder but without its CLI is left to the person ("manual"): Plannotator never edits TOML or JSONC itself.
  • The window's first-open card is in part 3; this PR prints the terminal lines and keeps the report for it.

…all removes what it added

A person's plannotator inbox (never --background, the shim or a connection's
start) adds a plannotator-inbox MCP server to every terminal agent it finds
that has no record yet: through the agent's own mcp add (Codex, Gemini CLI,
Windsurf/Devin, Amp, Cline, Pi without the extension), else one key in a
strictly parsed plain-JSON file (Cursor, Kiro, the Claude desktop app). Pi
and OpenCode with Plannotator's extension or plugin get inboxTool on. Claude
Code gets nothing. An Inbox an agent started is asked over the new
token-guarded /api/inbox/control/connect. Later runs connect agents installed
since and say so once; a recorded agent (turned off, removed outside, a
foreign entry) is never added back; another plannotator-inbox entry is never
replaced. PLANNOTATOR_INBOX_CONNECT=0 skips it.

plannotator uninstall (plain and --purge) removes the entries it added, by
record then by scanning the known files; --dry-run lists them.

Tests use fake agent CLIs on a scratch PATH and HOME; the preload and every
CLI test sandbox set PLANNOTATOR_INBOX_CONNECT=0, and the guard test now
fails on a path from the real home to an agent folder or a connect without
an agent environment.
…t ownership, said-once failures)

- Pi before 0.99 (no pi mcp) and any CLI whose --version line is not its own
  (cln's pi, amp.rs, another codex) are left to the person; Cline is not run.
- Codex's config.toml is read with Bun.TOML.parse (every form); GEMINI_CLI_HOME
  and a relative CODEX_HOME are honored; an entry Plannotator did not write is
  never replaced.
- JSON edits are lossless (json-edit.ts): only the one member's text changes,
  BOM, dominant line ending, numbers and escapes stay; duplicate keys refused.
- Ours = this CLI's command or the recorded one; the plannotator heuristic is
  exact-name only. Uninstall removes only entries recorded as added (or, with no
  record, ones running exactly the binary being removed).
- Copy no longer promises Settings; a lasting failure is said once.
- OpenCode 2 plugins in { package } form are found.
- Agent CLIs run in their own process group, killed on timeout; a grandchild
  holding stdout does not hold the run. Docs and the Devin snippet path.
@backnotprop

Copy link
Copy Markdown
Owner Author

Review fixes pushed (8aef65b and earlier). No force-push.

High

  • Pi, Cline and look-alike CLIs: Pi before 0.99 is left to the person. So is any CLI whose --version line is not its own shape: cln's pi digits, amp.rs and a different codex are never handed an mcp add. Cline is never run until its mcp add is verified.
  • Codex config and replacing entries: Codex's config.toml is read with Bun.TOML.parse, so every TOML form is covered. Tests cover the inline table, dotted root key, quoted header and literal header. GEMINI_CLI_HOME and a relative CODEX_HOME are honored. An entry Plannotator did not write is never replaced.

Medium

  • Lossless JSON edits (packages/server/json-edit.ts): only the one member's text is inserted or cut. The rest stays as written: compact stays compact, big integers, 1.0, \u escapes, key order and the BOM are kept, and new lines take the dominant line ending. A duplicate key on the path is refused. Uninstall removal uses the same edit. Tests cover each case.
  • "Ours": an entry is ours when it runs this CLI's command or the one its record says Plannotator wrote. The heuristic is now an exact plannotator program name or a checkout's apps/hook/server/index.ts, so my-plannotator-proxy no longer counts. Uninstall removes only entries recorded as added; with no record, only an entry that runs exactly the binary being uninstalled. The connect CLI test no longer depends on the worktree path.
  • Copy: it no longer promises Settings. A lasting failure is said once (failures in agents.json), and the run still tries again.
  • OpenCode 2: a plugins: [{ package }] entry is detected.

Low

  • Agent CLIs run in their own process group, and the group is killed on timeout. The answer comes at exit, even if a grandchild keeps stdout open (tested).
  • Docs say a connect from an agent-started Inbox uses that Inbox's environment, and that uninstall removes only what Plannotator added.
  • The marketing table and AGENTS.md are corrected: cursor-agent, kiro-cli, CODEX_HOME, Pi 0.99+, Cline, and the lossless edits.
  • The window's Devin snippet now names ~/.config/devin/config.json.

Tests: bun test packages/server apps/hook/server tests/ packages/inbox/harnesses.test.ts passes 2005, and typecheck is clean.

@backnotprop
backnotprop merged commit be0b1fa into main Oct 13, 2026
32 checks passed
@backnotprop
backnotprop deleted the feat/inbox-connect-agents branch October 13, 2026 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant