feat(shared-vault-sync): sync the nested devops-shared-vault subrepo
Detection order is now SHARED_VAULT_DIR, then $PWD, then $PWD/Areas/DevOps (the nested shared subrepo inside the personal vault). Bump to 0.1.1. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2,16 +2,33 @@
|
||||
# Pull only the designated shared vault; never block a new agent session.
|
||||
set -u
|
||||
|
||||
vault_dir="${SHARED_VAULT_DIR:-${PWD:-}}"
|
||||
|
||||
emit() {
|
||||
printf '{"continue":true,"suppressOutput":true,"hookSpecificOutput":{"additionalContext":"%s"}}\n' "$1"
|
||||
}
|
||||
|
||||
if [ ! -f "$vault_dir/AGENTS.md" ] || ! grep -Fq 'This is the shared persistent vault' "$vault_dir/AGENTS.md" || ! git -C "$vault_dir" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||
emit 'Shared vault sync skipped: set SHARED_VAULT_DIR or start the session from the shared vault.'
|
||||
is_shared_vault() {
|
||||
[ -f "$1/AGENTS.md" ] \
|
||||
&& grep -Fq 'This is the shared persistent vault' "$1/AGENTS.md" \
|
||||
&& git -C "$1" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
}
|
||||
|
||||
detect_vault() {
|
||||
# explicit override wins
|
||||
if [ -n "${SHARED_VAULT_DIR:-}" ]; then
|
||||
is_shared_vault "$SHARED_VAULT_DIR" && { printf '%s' "$SHARED_VAULT_DIR"; return 0; }
|
||||
return 1
|
||||
fi
|
||||
# session started inside the shared vault itself
|
||||
if is_shared_vault "${PWD:-}"; then printf '%s' "${PWD:-}"; return 0; fi
|
||||
# nested shared subrepo relative to the session dir (e.g. personal vault's Areas/DevOps)
|
||||
if is_shared_vault "${PWD:-}/Areas/DevOps"; then printf '%s' "${PWD:-}/Areas/DevOps"; return 0; fi
|
||||
return 1
|
||||
}
|
||||
|
||||
vault_dir="$(detect_vault)" || {
|
||||
emit 'Shared vault sync skipped: no shared vault detected (set SHARED_VAULT_DIR, or start the session from the shared vault or its Areas/DevOps subrepo).'
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -n "$(git -C "$vault_dir" status --porcelain)" ]; then
|
||||
emit 'Shared vault sync skipped: the worktree has local changes.'
|
||||
|
||||
Reference in New Issue
Block a user