From 8870b7c14d6dfbedf304dd87dc1ab6966a6da26d Mon Sep 17 00:00:00 2001 From: Snow Lee Date: Tue, 11 Aug 2026 09:15:49 -0700 Subject: [PATCH] feat(hook): hand the next agent session your working state (BEA-134) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every new agent session — on another machine, in a teammate's account, on another platform — re-derives the same working state from scratch. History records what a session *did*, never what it was in the middle of. AGENT_HANDOFF.md at the mount root is now that channel. It is an ordinary synced file (the sync engine has never heard of it); the UserPromptSubmit hook hands its body to a session's FIRST turn and asks every turn to overwrite it before finishing. No new hook event, no new storage, no change to internal/agenthooks. - First turn is decided by the note the hook already writes, read one line before SaveNote overwrites it — so the body is paid for once per session, not once per turn. - Bounded: 4 KB per mount, 8 KB per turn, with a truncation marker. - Multi-mount safe: each block is labelled with its own mount's path, and the reminder names every mount's file. - A scope that excludes the root (`init --only wiki`) is detected and said out loud rather than silently keeping the handoff local. - This is the first PEER-authored content the product injects into an agent's context, so each block is framed as information rather than instruction, and the provenance line goes through safeField. Co-Authored-By: Claude Opus 5 (1M context) --- README.md | 2 +- cmd/bdrive/cmds.go | 1 + cmd/bdrive/hooksync.go | 169 +++++++++++- cmd/bdrive/hooksync_test.go | 250 +++++++++++++++++- internal/webapp/cli_e2e_test.go | 93 ++++++- .../docs/guides/shared-agent-memory.md | 32 ++- web/docs/src/content/docs/reference/cli.md | 2 +- .../content/docs/reference/project-files.md | 24 +- 8 files changed, 555 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 1703ef0..8efeaf4 100644 --- a/README.md +++ b/README.md @@ -245,7 +245,7 @@ hub's own storage, never something a syncing client points at directly: | `bdrive forget ...` | Stop syncing a path *and* remove it from the hub — adds the rule to `.bdriveignore` (which syncs) and prunes in one step. Local files are never touched, here or on teammates' devices | | `bdrive url [path]` | Internal hub link for a file/folder (sign-in + membership required; `--sync` pushes first; no arg = project home). Computed locally | | `bdrive share ` | Public URL for a synced file (`--list`, `--revoke`, `--expires`) | -| `bdrive sync [folder]` | Run one sync cycle now. `--note ` stamps session context (e.g. an agent session id) onto changes — shown in `bdrive log` and hub history; keeps applying to daemon-committed changes until `--note-ttl` (default 30m) expires. `--prune` also removes from the hub what `.bdriveignore` now excludes (files stay on disk everywhere). `--hook