Skip to content

feat(memory): transport = "command" for non-git memory sync (S3/rclone/scp/USB) - #178

Merged
sandstream merged 1 commit into
mainfrom
claude/headroom-kit-integration-cmjw7t
Jun 30, 2026
Merged

sandstream merged 1 commit into
mainfrom
claude/headroom-kit-integration-cmjw7t

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Description

Follow-up to gap #4 (#176). The git remote was one transport; the encrypted blob is the real unit, and you shouldn't be locked into git. This adds a second, transport-agnostic option: transport = "command", so memory can move over S3 / rclone / scp / a USB mount — anything you can script.

Type of Change

  • New feature (non-breaking change that adds functionality)

Changes Made

~/.kit/sync.toml:

[memory.sync]
transport = "command"
push_cmd = "aws s3 cp \"$KIT_MEMORY_BLOB\" s3://my-bucket/kit-memory.enc"
pull_cmd = "aws s3 cp s3://my-bucket/kit-memory.enc \"$KIT_MEMORY_BLOB\""
  • kit writes the AES-256-GCM blob to a temp path, exposes it as $KIT_MEMORY_BLOB, and runs your push_cmd (upload) / pull_cmd (download → merge).
  • SyncConfig gains a transport discriminator (git | command); pushMemory/pullMemory branch on it; the result field remote → target.
  • Same guards as git transport: the command is read only from the LOCAL ~/.kit/sync.toml (never the project tree → a cloned repo can't inject it), the payload stays encrypted (the store sees only ciphertext), and it's opt-in. (remote ≠ origin is git-specific and N/A here — the command is operator-authored.)
  • Setup help (shown when unconfigured) now documents both git and command forms.

Testing

Test Coverage

  • Added new tests (config validation; cp-based push→pull→recall round trip; empty-pull → not found)
  • All tests pass (npm test) — 1948 pass, 0 fail

Manual Testing

  1. transport = "command" without push_cmd/pull_cmd → clear config error.
  2. Round trip with cp "$KIT_MEMORY_BLOB" <store> / cp <store> "$KIT_MEMORY_BLOB" (same shape as aws s3 cp): machine A push deposits an encrypted blob → machine B pull recalls A's message.
  3. pull_cmd that produces no blob → reports "not found" cleanly.

🤖 Generated with Claude Code

https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg


Generated by Claude Code

…clone/scp/USB)

Gap #4 shipped a git-remote transport; the encrypted blob is the real unit and
git is just one way to move it. This adds a second, transport-agnostic option so
you're not locked into git: set `transport = "command"` in ~/.kit/sync.toml with
push_cmd / pull_cmd, and kit runs your command with the encrypted blob path
exposed as $KIT_MEMORY_BLOB.

  [memory.sync]
  transport = "command"
  push_cmd = "aws s3 cp \"$KIT_MEMORY_BLOB\" s3://my-bucket/kit-memory.enc"
  pull_cmd = "aws s3 cp s3://my-bucket/kit-memory.enc \"$KIT_MEMORY_BLOB\""

Same guards as the git transport: the command is read ONLY from the LOCAL
~/.kit/sync.toml (never the project tree, so a cloned repo can't inject it), the
payload stays AES-256-GCM encrypted (the store sees only ciphertext), and it's
opt-in. push encrypts → runs push_cmd; pull runs pull_cmd → merges (last-write-
wins) if a blob arrived, else reports "not found".

SyncConfig gains a `transport` discriminator (git | command); push/pull branch
on it; result field `remote` → `target` (the URL, or "command transport"). Help
text shows both forms. 3 new tests (config validation, cp-based round trip,
empty-pull) over the existing git ones. 1948 tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
@github-actions

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

@sandstream
sandstream merged commit 3c55557 into main Jun 30, 2026
17 checks passed
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
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>
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.

2 participants