chore: horus sync 2026-04-30T22:38:14Z
This commit is contained in:
+12
-25
@@ -1,8 +1,4 @@
|
||||
#!/bin/bash
|
||||
#===============================================
|
||||
# obsidian-vault sync script
|
||||
# All 3 agents run this every 5 minutes
|
||||
#===============================================
|
||||
set -euo pipefail
|
||||
|
||||
AGENT="${1:-horus}"
|
||||
@@ -12,49 +8,40 @@ LOG_FILE="$VAULT_DIR/agent-shared/daily/$(date +%Y-%m-%d).md"
|
||||
|
||||
cd "$VAULT_DIR"
|
||||
|
||||
# Update daily log
|
||||
mkdir -p "$VAULT_DIR/agent-shared/daily"
|
||||
if [ ! -f "$LOG_FILE" ]; then
|
||||
cat > "$LOG_FILE" << EOF
|
||||
# Daily Log — $(date +%Y-%m-%d)
|
||||
|
||||
## Agents Active Today
|
||||
- Horus
|
||||
- Amun
|
||||
- Cleo
|
||||
|
||||
## Session Activity
|
||||
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Check if dirty
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo "[$AGENT] Vault has changes — committing..."
|
||||
echo "[$AGENT] Committing changes..."
|
||||
git add -A
|
||||
git commit -m "chore: $AGENT sync $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
|
||||
# Push if remote exists
|
||||
if git remote get-url origin &>/dev/null; then
|
||||
git pull --rebase origin master 2>/dev/null || true
|
||||
git push origin master 2>/dev/null || echo "[$AGENT] Push failed (offline?)"
|
||||
fi
|
||||
# Push to local Gitea first (always works)
|
||||
git push gitea main 2>/dev/null && echo "[$AGENT] Pushed to Gitea" || echo "[$AGENT] Gitea push failed"
|
||||
|
||||
# Push to GitHub (if account not suspended)
|
||||
git push origin main 2>/dev/null && echo "[$AGENT] Pushed to GitHub" || echo "[$AGENT] GitHub push failed (account suspended?)"
|
||||
|
||||
# Update vault state
|
||||
python3 -c "
|
||||
import json
|
||||
from datetime import datetime
|
||||
with open('$STATE_FILE', 'r') as f:
|
||||
s = json.load(f)
|
||||
s['agents']['$AGENT']['last_commit'] = '$(git rev-parse HEAD)'
|
||||
s['agents']['$AGENT']['dirty'] = False
|
||||
s['last_sync'] = '$(date -u +%Y-%m-%dT%H:%M:%SZ)'
|
||||
s['last_sync'] = datetime.utcnow().isoformat() + 'Z'
|
||||
s['git_remote'] = 'gitea'
|
||||
with open('$STATE_FILE', 'w') as f:
|
||||
json.dump(s, f, indent=2)
|
||||
"
|
||||
echo "[$AGENT] Sync complete"
|
||||
else
|
||||
# Pull latest from others
|
||||
if git remote get-url origin &>/dev/null; then
|
||||
git pull origin master 2>/dev/null && echo "[$AGENT] Pulled latest" || echo "[$AGENT] Pull failed or no remote"
|
||||
fi
|
||||
# Pull latest
|
||||
git pull gitea main 2>/dev/null && echo "[$AGENT] Pulled from Gitea" || echo "[$AGENT] Pull from Gitea failed"
|
||||
git pull origin main 2>/dev/null && echo "[$AGENT] Pulled from GitHub" || true
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user