47 lines
1.5 KiB
Bash
47 lines
1.5 KiB
Bash
#!/usr/bin/env bash
|
|
# Zero-token vault change log.
|
|
# Reads the vault's publish history (the mirror subtree in the AgentOS repo) and
|
|
# writes it into the vault itself so agents can read it.
|
|
|
|
VAULT_DIR="/c/Users/fight/Documents/Obsidian Vault"
|
|
REPO_DIR="/c/Users/fight/AgentOS"
|
|
MIRROR_PATH="memory-systems/agent-os"
|
|
LOG_FILE="$VAULT_DIR/03_shared/vault-updates-log.md"
|
|
|
|
cd "$REPO_DIR" || exit 1
|
|
|
|
# Refresh from remote first (best-effort; --autostash so a dirty repo can't block it).
|
|
git pull --rebase --autostash > /dev/null 2>&1
|
|
|
|
{
|
|
echo "# Vault Updates Log"
|
|
echo ""
|
|
echo "**Generated:** $(date '+%Y-%m-%d %H:%M') PST"
|
|
echo ""
|
|
echo "---"
|
|
echo ""
|
|
echo "## Last 24 Hours"
|
|
echo ""
|
|
git log --since="24 hours ago" --oneline --no-merges -- "$MIRROR_PATH" 2>/dev/null \
|
|
|| echo "No recent commits."
|
|
echo ""
|
|
echo "---"
|
|
echo ""
|
|
echo "## Last 7 Days"
|
|
echo ""
|
|
git log --since="7 days ago" --oneline --no-merges -- "$MIRROR_PATH" 2>/dev/null | head -20
|
|
echo ""
|
|
echo "---"
|
|
echo ""
|
|
echo "## Files Changed (Last 24h)"
|
|
echo ""
|
|
# `HEAD@{24.hours.ago}` fails on a young reflog; derive the list from the log instead.
|
|
# The mirror path prefix is stripped so the list reads as vault-relative paths.
|
|
git log --since="24 hours ago" --name-only --pretty=format: -- "$MIRROR_PATH" 2>/dev/null \
|
|
| sed '/^[[:space:]]*$/d' \
|
|
| sed "s|^$MIRROR_PATH/||" \
|
|
| sort -u
|
|
} > "$LOG_FILE"
|
|
|
|
echo "Vault change log updated: $LOG_FILE"
|