chore: horus sync 2026-04-30T22:38:14Z

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