Files
Adnan Zahir 6ad7202fdf feat(shared-vault-sync): add commit-driven auto-push script
push-shared-vault.sh pushes the shared vault only when the worktree is clean
and the local branch is ahead of origin (fetch first); never rebases,
force-pushes, or resolves conflicts. Ships with launchd setup docs. Bump 0.1.2.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-09-01 10:33:49 +07:00

40 lines
1.9 KiB
Markdown

# shared-vault-sync
Pulls a clean shared vault at `SessionStart` without blocking Claude Code or Codex when the network is unavailable.
Target detection, in order:
1. `SHARED_VAULT_DIR` — explicit override (e.g. the `devops-shared-vault` clone path).
2. `$PWD` — when the session starts inside the shared vault itself.
3. `$PWD/Areas/DevOps` — the nested shared subrepo inside the personal vault.
A directory is treated as the shared vault only if its `AGENTS.md` contains the marker `This is the shared persistent vault` and it is inside a git work tree.
The hook skips a dirty worktree and uses `git pull --ff-only`; it never rebases, merges, or pushes.
## Install
Install `shared-vault-sync` from the `infra-plugins` marketplace, then open a new session to activate its `SessionStart` hook.
## Auto-push (launchd)
`scripts/push-shared-vault.sh` mengirim commit lokal ke remote secara **commit-driven**:
hanya jika worktree bersih **dan** branch lokal di depan `origin` (fetch dulu). Tidak pernah
rebase, force-push, atau resolve conflict; no-op saat offline atau tidak ada yang perlu di-push.
Setup (macOS launchd, interval 5 menit):
```bash
# 1. pastikan script tersedia di plugin (repo infra-plugins)
# 2. buat plist ~/Library/LaunchAgents/com.mbugroup.shared-vault-push.plist:
# - ProgramArguments: /bin/bash <infra-plugins>/plugins/shared-vault-sync/scripts/push-shared-vault.sh
# - EnvironmentVariables: SHARED_VAULT_DIR=<path ke clone shared vault>
# - StartInterval: 300
# 3. muat:
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.mbugroup.shared-vault-push.plist
launchctl kickstart -k gui/$(id -u)/com.mbugroup.shared-vault-push
```
Log push: `$PUSH_SHARED_VAULT_LOG` (default `/tmp/shared-vault-push.log`), hanya timestamp + jumlah commit.
Hook pull tetap menangani sinkronisasi masuk; agent ini menangani arah keluar. Push tetap commit-driven:
agent tidak pernah membuat komit, hanya mengirim komit yang sudah Anda buat di `Areas/DevOps`.