sync-agent-history

This commit is contained in:
Harivansh Rathi 2026-04-02 17:10:24 -04:00
parent 320ae1332e
commit 329471ede6
2 changed files with 15 additions and 1 deletions

View file

@ -22,6 +22,7 @@ in
nodejs_22 nodejs_22
python3 python3
ripgrep ripgrep
rsync
rustup rustup
tree tree
uv uv

View file

@ -3,6 +3,19 @@ set -euo pipefail
remote="${AGENT_HISTORY_REMOTE:-netty}" remote="${AGENT_HISTORY_REMOTE:-netty}"
remote_root="${AGENT_HISTORY_REMOTE_ROOT:-/home/rathi/.local/share/agent-history/raw/darwin}" remote_root="${AGENT_HISTORY_REMOTE_ROOT:-/home/rathi/.local/share/agent-history/raw/darwin}"
local_rsync="$(command -v rsync || true)"
if [[ -z "$local_rsync" ]]; then
printf 'rsync is not available locally.\n' >&2
exit 1
fi
if ssh "$remote" 'command -v rsync >/dev/null 2>&1'; then
remote_rsync='rsync'
else
remote_rsync='nix --extra-experimental-features nix-command --extra-experimental-features flakes shell nixpkgs#rsync -c rsync'
printf 'Remote rsync not found on %s - using a temporary nix shell fallback.\n' "$remote" >&2
fi
remote_root_q="$(printf '%q' "$remote_root")" remote_root_q="$(printf '%q' "$remote_root")"
@ -23,7 +36,7 @@ sync_path() {
fi fi
printf 'Syncing %s -> %s:%s\n' "$src" "$remote" "$dest" printf 'Syncing %s -> %s:%s\n' "$src" "$remote" "$dest"
rsync -az "$src" "$remote:$dest" "$local_rsync" -az --rsync-path="$remote_rsync" "$src" "$remote:$dest"
} }
sync_path "$HOME/.claude/history.jsonl" "${remote_root}/claude/" sync_path "$HOME/.claude/history.jsonl" "${remote_root}/claude/"