mirror of
https://github.com/runbear-io/beardrive.git
synced 2026-08-25 08:08:08 +02:00
feat(sync): session-linked notes — stamp changes with the agent session
`bdrive sync --note <text>` stamps session context onto every op the cycle commits and persists it in the volume store (note.json, --note-ttl default 30m) so the daemon's own scans stamp it too — winning the race between one-shot hook syncs and the 3s daemon scan. The plugin sync hook extracts session_id from hook stdin JSON and passes it automatically, so history links every change to the Claude Code session that made it. Conflict-copy ops keep their own note; expired/cleared notes stop applying. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P5cxPQdSGJnjXCYY9GeWXt
This commit is contained in:
co-authored by
Claude Fable 5
parent
06bedabfd6
commit
c1f0d0f8ee
@@ -4,7 +4,20 @@
|
||||
#
|
||||
# Runs blocking on UserPromptSubmit (fresh files before Claude reads them)
|
||||
# and async on Stop (push edits out without delaying the turn).
|
||||
#
|
||||
# Hooks receive JSON on stdin with a session_id; it is passed as the sync
|
||||
# note so every change journaled during this session — including ones the
|
||||
# background daemon commits — is stamped with the Claude Code session that
|
||||
# made it, and shows up in `bdrive log` and the hub's history views.
|
||||
cd "${CLAUDE_PROJECT_DIR:-.}" || exit 0
|
||||
[ -d .bdrive ] || exit 0
|
||||
command -v bdrive >/dev/null 2>&1 || exit 0
|
||||
bdrive sync . >/dev/null 2>&1 || true
|
||||
sid=""
|
||||
if [ ! -t 0 ]; then
|
||||
sid=$(head -c 8192 | sed -n 's/.*"session_id"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -n 1)
|
||||
fi
|
||||
if [ -n "$sid" ]; then
|
||||
bdrive sync . --note "claude-code session $sid" >/dev/null 2>&1 || true
|
||||
else
|
||||
bdrive sync . >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user