Skip to content

Inbox reminder for Qwen Code, Gemini CLI, Amp, Kiro and Codex through their own hooks - #3600

Draft
backnotprop wants to merge 4 commits into
mainfrom
feat/inbox-reminder-more-agents
Draft

backnotprop wants to merge 4 commits into
mainfrom
feat/inbox-reminder-more-agents

Conversation

@backnotprop

@backnotprop backnotprop commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Every agent that reaches the Plannotator Inbox through its MCP server now gets the Inbox reminder the way Claude Code does: when a conversation starts, and again after each compaction where the agent has such an event. The reminder obeys its on/off switch, and the person's rules follow under INBOX_RULES_LEAD.

How it works

  • One command, plannotator inbox reminder --agent <id> (packages/shared/inbox/reminder-hook.ts):
    • It prints resolveInboxReminderText for that agent, in the agent's documented hook format.
    • It prints nothing and exits 0 when the reminder is off, when the Inbox was never set up here, when the agent does not reach the Inbox through MCP (its record in inbox/agents.json), when config.json is damaged, or on any failure.
    • It reads a few small files. It never starts the Inbox and opens no connection.
    • It waits until the whole reminder is written to stdout before it exits (writeWholeToStdout), so a long reminder through a pipe is not cut off.
  • Gemini CLI, Kiro and Codex get one entry of ours in the agent's own global hook config (packages/server/inbox-reminder-hooks.ts).
    • Plannotator writes it once, after the Inbox's notes pass, only for an agent found here, reaching the Inbox, with its reminder on.
    • Writes are lossless: appendJsonArrayItem in json-edit.ts changes no other byte, and comments are kept.
    • Writes are atomic. A read-only or hard-linked file is left alone.
    • An entry the person removes never comes back, also after the agent's connection is turned off and on again.
    • Turning the agent's reach off and plannotator uninstall take it out byte for byte. A file Plannotator created is deleted.
    • Kiro: Plannotator checks again that its file is still missing right before it creates it. If the person later adds their own hooks to that file, only ours are taken out and theirs stay.
    • A moved or updated CLI: when our recorded entry runs a program path that no longer exists, the next Inbox start rewrites that one command to the current path, with the same checks as any write. An entry that is not ours is never touched.
    • Why a write was refused is kept in inbox/reminder-hooks.json for debugging. It is not shown to the person.
  • Qwen Code's hook ships in our extension. Amp's is in our plugin.
  • Settings → Agents shows the reminder switch for these agents once they are connected. Settings → Prompts has a row and a rules box for each. Both reuse the existing UI.
  • The Inbox is Bun-only, so the Pi server does not change.

Per agent (each one proven by documentation only; no live run)

Agent Mechanism What is written Docs
Qwen Code SessionStart (startup, resume, clear, compact) our extension's hooks/hooks.json: { "type": "command", "command": "plannotator inbox reminder --agent qwen", "timeout": 10000 }, no matcher; extension 1.1.0 https://raw.githubusercontent.com/QwenLM/qwen-code/main/docs/users/features/hooks.md
Gemini CLI SessionStart (startup, resume, clear); no context after a compaction (PreCompress cannot add any) ~/.gemini/settings.json hooks.SessionStart: { "matcher": "*", "hooks": [{ "name": "plannotator-inbox-reminder", "type": "command", "command": "<plannotator> inbox reminder --agent gemini", "timeout": 10000 }] } https://raw.githubusercontent.com/google-gemini/gemini-cli/main/docs/hooks/reference.md
Amp agent.start, a thread's first prompt only; { message: { content, display: false } } nothing (our plugin) https://ampcode.com/docs/plugin-api
Kiro SessionStart and PostCompact our own ~/.kiro/hooks/plannotator-inbox.json (version v1, two command hooks, timeout 10 s) https://kiro.dev/docs/cli/v3/hooks-migration/
Codex SessionStart, no matcher (startup, resume, clear, compact, fork) $CODEX_HOME/hooks.json hooks.SessionStart: { "hooks": [{ "type": "command", "command": "<plannotator> inbox reminder --agent codex", "timeout": 10 }] } https://learn.chatgpt.com/docs/hooks

Codex runs a new hook only after the person approves it in /hooks. Plannotator never writes that approval. The Inbox's connect line says so once, after the Codex note line: "Approve Plannotator's new hook in Codex with /hooks."

Wake wording

The reminder says "Their reply comes back here." only when the Inbox can really wake that agent. Otherwise it uses the existing no-wake line. No agent-facing sentence is new or reworded; only the choice between the two existing lines changed.

  • Qwen Code: the wake line only when Plannotator holds Qwen's trusted-sender token for that Qwen home (not on Windows). This reuses the Inbox's own check (qwenCanWake in inbox-qwen-trust.ts) and reads one small file.
  • Codex: always the no-wake line. The Inbox knows whether it can wake Codex (codex queue) only by running the Codex CLI, which can take seconds. The hook must stay fast and must not start the Inbox, so it does not claim the wake.
  • Gemini CLI, Amp and Kiro: the no-wake line, as before.
  • Settings → Prompts shows the same choice.

Cost at session start

The reminder branch runs after the CLI's static imports are evaluated; only the reminder module itself is loaded on demand. From source: importing the reminder module alone takes about 20 ms; a whole CLI run in the tests takes about 200 to 250 ms. Returning before the heavy imports needs a separate compiled entry, which every build and release step would have to name, so it is not in this PR. A timing on the release binary is advised before release. No network runs before the reminder is printed.

For the owner

  • New person-facing sentences:
    • "Approve Plannotator's new hook in Codex with /hooks."
    • " changed while the hook was being added; Plannotator tries again later" (kept in the failures record, not shown)
    • "Plannotator's reminder hook could not be removed: "
    • "Could not remove Plannotator's Inbox reminder hook: ." (plannotator uninstall)
  • "Uses the default for Gemini CLI" (and Amp, Kiro): the existing OpenCode 1 pattern, now with the agent's name.
  • No new fixed agent-facing text was added. Two choices to check:
    • The reminder names the tool plannotator-inbox, the MCP server's name, where it says plannotator_inbox.
    • The wake wording, above.
  • The Codex line shows only when the hook is added in the same pass as a Codex note that has not been shown yet. A person whose Codex note was shown earlier gets no line. Codex itself asks for the review at its next start.

Open, the owner's calls (not in this PR)

  • Settings → Agents shows the reminder switch on when no hook works: the Amp plugin is not installed, Qwen's extension is still 1.0.0, the Codex hook is not approved in /hooks, the write was refused, or the person removed the hook. A status line would be a UI change.
  • The Codex /hooks line: people whose Codex note was shown earlier get no line. Codex CLI warns at start; Codex Desktop and T3's codex app-server may skip the unapproved hook silently.
  • Copies outside compaction (none are per prompt): Codex, Qwen and Gemini add a copy on each resume (Codex also on fork); Amp adds one when a thread continues after Amp restarts; headless runs (codex exec, gemini -p, qwen -p) get it too.
  • Gemini gets nothing after compression. BeforeAgent (context for one turn only) would cover it without piling up.

Unverified

  • Windows quoting: the Gemini CLI, Qwen Code and Kiro hook docs do not say which shell runs a hook command on Windows (Qwen lists a shell field, bash or powershell, with no stated default). The command is quoted as before; a CLI path with a space is not proven to run under both cmd and PowerShell.

Joining up with #3598

#3598 puts the rules in note files.

Follow-up (not in this PR)

DeepSeek Harness, Devin and Windsurf, Cline, Cursor, and agents with only the MCP server and no hook of ours.

Tests

New in the review fixes:

  • A reminder past 20 KB (long custom reminder and long rules) arrives whole and is valid JSON, also through a slow reader with a 4 KB socket buffer. It fails without writeWholeToStdout.
  • The Qwen wake line with Plannotator's token for that home; the no-wake line without it or with a token for another home; Codex always no-wake; a failing check reads as no-wake.
  • A damaged config.json alone prints nothing and exits 0.
  • The prompt hosts and the reminder hosts are one list, and every hook host has a format.
  • A hook the person removed stays removed through off and on.
  • A Kiro file with the person's hooks too: removal takes out only ours.
  • A moved CLI: our recorded Codex and Kiro entries are rewritten to the current path; an existing path, and an entry not ours, are left alone; removal after the rewrite is byte for byte.

Run locally, one file at a time, all green. After the review fixes, the reminder-hook, command, reminder-hooks, qwen-trust and uninstall tests were run again:

  • packages/shared/inbox/reminder-hook.test.ts
  • apps/hook/server/inbox-reminder-command.test.ts
  • packages/server/inbox-reminder-hooks.test.ts
  • packages/server/inbox-qwen-trust.test.ts
  • packages/server/json-edit.test.ts
  • packages/server/uninstall.test.ts
  • packages/server/inbox-agent-notes.test.ts
  • packages/server/inbox-agent-notes-auto.test.ts
  • apps/qwen-code/qwen-code.test.ts
  • apps/amp-plugin/plannotator.test.ts
  • packages/shared/inbox-reminder-text.test.ts
  • apps/hook/hooks/mod/enabled.test.ts
  • packages/shared/prompts.test.ts
  • packages/shared/prompts-integration.test.ts
  • the DOM tests packages/inbox/promptsSettings.test.tsx and packages/inbox/connectLine.test.tsx
  • the scans tests/no-browser-sentinel.test.ts, tests/windows-hide-guard.test.ts and tests/child-env-guard.test.ts

Typecheck passed for core, shared, server, the mod, apps/hook server, packages/inbox and apps/inbox.

Left to CI, because they start an Inbox:

  • packages/server/inbox-prompts.test.ts and packages/server/inbox-agents-settings.test.ts (updated for the new hosts, plus a Codex case; inbox-prompts.test.ts also for the wake wording)
  • packages/inbox/reloadHosts.test.tsx
  • tests/never-touch-the-real-inbox.test.ts
  • apps/hook/server/inbox-help.test.ts
  • the e2e specs
  • the Pi typecheck (it needs vendor.sh)

…rough their own hooks

One command, plannotator inbox reminder --agent <id>, prints the shared
reminder (the person's own text and rules included) in each agent's
documented hook format, or nothing when it is off, not set up, or fails.
It never starts the Inbox.

- Qwen Code: a SessionStart hook in our extension (1.1.0).
- Amp: our plugin, on a thread's first prompt, hidden.
- Gemini CLI, Kiro, Codex: one entry of ours in the agent's global hook
  config (Kiro: a file of our own), written once, losslessly, removed byte
  for byte by reach off and plannotator uninstall.
- Codex: the connect line says once to approve the hook in /hooks;
  Plannotator never writes Codex's trust record.
- Settings: the reminder switch, Prompts rows and rules for each.
- The CLI waits for the whole reminder to reach stdout before it exits.
- The wake line only when the Inbox can really wake the agent: Qwen with
  Plannotator's trusted-sender token; Codex always gets the no-wake line.
- A damaged config.json prints nothing.
- A hook the person removed stays removed through off and on.
- Kiro: re-check the file before creating it; a shared file loses only our hook.
- A moved CLI: our recorded entry is rewritten to the current path.
- Docs: the true load order and timing; Windows quoting listed as unverified.
- The connect-run test expects hook_review on the Codex note entry: the
  same pass added Codex's reminder hook.
- The uninstall test builds the shown paths with the platform's separator,
  as the shared display path does.

This branch has not been deployed

No deployments
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