45 lines
1.7 KiB
Bash
45 lines
1.7 KiB
Bash
#!/usr/bin/env bash
|
|
# Zero-token vault sync protocol
|
|
# Commit local changes, rebase onto the remote, push to the Gitea mirror.
|
|
#
|
|
# SCOPE: only the agent-os vault tree is staged. The git repo root is the PARENT
|
|
# directory (AgentOS), so a bare `git add -A` sweeps unrelated agent work into
|
|
# "vault-sync" commits. Both the status check and the add are pathspec-scoped.
|
|
#
|
|
# ORDER: commit BEFORE `git pull --rebase`. Rebase refuses to run on a dirty tree,
|
|
# so pulling first is a silent no-op exactly when a pull is needed, and the
|
|
# subsequent push gets rejected.
|
|
#
|
|
# IDENTITY: passed per-commit with `git -c`, never repo-local config — the repo is
|
|
# shared by every agent profile, so a repo-local user.name attributes every agent's
|
|
# commits to one agent. Override with VAULT_AGENT=<name>.
|
|
# NOTE: set VAULT_AGENT (or edit the default) in your own profile's copy.
|
|
|
|
VAULT_DIR="/c/Users/fight/AgentOS/memory-systems/agent-os"
|
|
AGENT_NAME="${VAULT_AGENT:-jimmy}"
|
|
GIT_ID=(-c "user.name=$AGENT_NAME" -c "user.email=$AGENT_NAME@hermes.local")
|
|
|
|
cd "$VAULT_DIR" || exit 1
|
|
|
|
echo "=== Vault Sync $(date '+%Y-%m-%d %H:%M') (agent: $AGENT_NAME) ==="
|
|
|
|
# 1. Stage + commit local changes (vault tree only).
|
|
if [ -n "$(git status --porcelain .)" ]; then
|
|
echo "Local changes detected. Committing..."
|
|
git add -A . || exit 1
|
|
git "${GIT_ID[@]}" commit -m "vault-sync: $(date '+%Y-%m-%d %H:%M') ($AGENT_NAME)" 2>&1 | tail -3
|
|
else
|
|
echo "No local changes."
|
|
fi
|
|
|
|
# 2. Rebase onto the remote. --autostash so unrelated dirty files elsewhere in the
|
|
# repo (AgentOS holds more than this vault) cannot block the pull.
|
|
echo "Pulling latest..."
|
|
git pull --rebase --autostash 2>&1 | tail -3
|
|
|
|
# 3. Push to remote.
|
|
echo "Pushing to Gitea..."
|
|
git push 2>&1 | tail -3
|
|
|
|
echo "=== Sync Complete ==="
|