Repository navigation
feat(memory): private cross-device sync over your own git remote (gap #4) - #176
Merged
Merged
Conversation
) The personal store (~/.kit/memory.db) is per-machine; `syncFromExport` + encrypted backup already let you move it by hand. This wires them to an opt-in transport — YOUR private git repo — so one machine pushes and another pulls (last-write-wins via mergeDb). `kit memory push` / `kit memory pull`. Configurable WITHOUT being a backdoor, by construction: 1. Config is read ONLY from ~/.kit/sync.toml (LOCAL), never the project tree — a malicious committed .kit.toml/.kit/* in a cloned repo can't redirect your private memory to an attacker's remote. 2. The sync remote MUST differ from the project's origin (normalized compare) — your secret-dense brain can't be pushed into the project repo by mistake. 3. Payload is AES-256-GCM encrypted (backupEncrypted); the remote sees only ciphertext. Passphrase via KIT_MEMORY_PASSPHRASE, never stored. 4. Fully opt-in: no sync.toml → the command only explains setup. New module src/memory/remote-sync.ts (loadSyncConfig / normalizeRemote / assertRemoteNotProjectOrigin / pushMemory / pullMemory); push/pull wired into `kit memory`. Tested end-to-end against a local bare repo (A push → B pull → recall) plus the guards. Zero new dependencies (git + node:crypto). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
|
✅ Docker image built successfully
|
3 tasks done
sandstream
pushed a commit
that referenced
this pull request
Jun 30, 2026
…ne-time nudge Closes the usability gaps in gap #4 (#176/#178): you had to hand-write ~/.kit/sync.toml and nothing synced automatically — which made the ephemeral-container flow (push before the box is reclaimed) a manual chore. A. `kit memory sync init` — writes the LOCAL ~/.kit/sync.toml template (--remote <url> for git, or --command with --push-cmd/--pull-cmd; --auto enables the hooks; --force overwrites). Won't clobber an existing config; reminds you to set KIT_MEMORY_PASSPHRASE and to create the private repo (kit makes the branch + blob, not the repo). B. Opt-in auto-sync wired into the memory hooks: - [memory.sync] pull_on_start = true → pull+merge at SessionStart, BEFORE the "where you left off" recovery, so it reflects the merged store. - [memory.sync] push_on_end = true → index+push at SessionEnd — the missing piece for ephemeral containers. Both fail-soft (tryAutoPull/tryAutoPush never throw): a session is never blocked by sync. Notes go to stderr; the injected recovery stays on stdout. C. One-time upgrade nudge: when sync isn't configured but a non-trivial memory store exists, suggest `kit memory sync init` once (a ~/.kit marker suppresses it thereafter). New exports in remote-sync.ts: initSyncConfig, tryAutoPull, tryAutoPush, maybeSyncNudge; SyncConfig gains pullOnStart/pushOnEnd. `sync init` routed in the memory dispatcher; auto-pull/push + nudge wired into memHook. 4 new tests (init round-trip, auto-sync gating, command push_on_end, nudge once). 1952 pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
3 tasks done
sandstream
added a commit
that referenced
this pull request
Jun 30, 2026
…-time nudge (#179) Closes the usability gaps in gap #4 (#176/#178): you had to hand-write ~/.kit/sync.toml and nothing synced automatically — which made the ephemeral-container flow (push before the box is reclaimed) a manual chore. A. `kit memory sync init` — writes the LOCAL ~/.kit/sync.toml template (--remote <url> for git, or --command with --push-cmd/--pull-cmd; --auto enables the hooks; --force overwrites). Won't clobber an existing config; reminds you to set KIT_MEMORY_PASSPHRASE and to create the private repo (kit makes the branch + blob, not the repo). B. Opt-in auto-sync wired into the memory hooks: - [memory.sync] pull_on_start = true → pull+merge at SessionStart, BEFORE the "where you left off" recovery, so it reflects the merged store. - [memory.sync] push_on_end = true → index+push at SessionEnd — the missing piece for ephemeral containers. Both fail-soft (tryAutoPull/tryAutoPush never throw): a session is never blocked by sync. Notes go to stderr; the injected recovery stays on stdout. C. One-time upgrade nudge: when sync isn't configured but a non-trivial memory store exists, suggest `kit memory sync init` once (a ~/.kit marker suppresses it thereafter). New exports in remote-sync.ts: initSyncConfig, tryAutoPull, tryAutoPush, maybeSyncNudge; SyncConfig gains pullOnStart/pushOnEnd. `sync init` routed in the memory dispatcher; auto-pull/push + nudge wired into memHook. 4 new tests (init round-trip, auto-sync gating, command push_on_end, nudge once). 1952 pass. Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Memory design gap #4: the personal store (
~/.kit/memory.db) is per-machine. This wires the existing encrypted-backup +mergeDbprimitives to an opt-in transport — your own private git repo — so one machinepushes and anotherpulls (last-write-wins), with no manual file copy.kit memory push/kit memory pull.It answers the question raised in review — "can the remote be chosen, or does that open a backdoor?" — by being configurable without being a backdoor, by construction.
Type of Change
Related Issues
Changes Made
New module
src/memory/remote-sync.ts:loadSyncConfig()— reads[memory.sync]only from~/.kit/sync.toml.normalizeRemote()/assertRemoteNotProjectOrigin()— the anti-exfil guard.pushMemory()/pullMemory()— clone the private remote, encrypt/decrypt the blob, commit+push / merge.push+pullintokit memory(handlers + help).Four guards make a configurable remote safe, not a backdoor:
~/.kit/sync.toml, never the project tree. A malicious committed.kit.toml/.kit/*in a cloned repo therefore cannot redirect your private memory to an attacker's remote.origin; your secret-dense brain can't be pushed into the (often shared/public) project repo.backupEncrypted); the remote sees only ciphertext. Passphrase viaKIT_MEMORY_PASSPHRASE, never stored.sync.toml→ the command does nothing but print setup guidance.Zero new dependencies (
git+node:crypto).Testing
Test Coverage
src/memory/remote-sync.test.ts)npm test) — 1942 pass, 0 failManual Testing
push→ blob present + encrypted on the remote → machine B (empty store)pull→ recalls A's message.assertRemoteNotProjectOriginthrows when the remote equals the project origin (even across URL forms);loadSyncConfigreturns null when unconfigured and rejects a path-traversal blob filename;normalizeRemotefolds ssh/scp/https forms.pullon an empty remote reports "not found" cleanly.🤖 Generated with Claude Code
https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
Generated by Claude Code