#!/bin/bash
# vault_commit.sh — auto-commit macro-book vault every 3h.
# Triggers the mentor-review feature by ensuring HEAD moves on edits.
# Pure mechanical: no LLM. Called by cron with no_agent=true.
# Silent: no stdout when committing, no Telegram noise.

set -euo pipefail

VAULT="/home/rpi/Obsidian-Macro"
cd "$VAULT" || { echo "vault not found: $VAULT" >&2; exit 1; }

# Skip if clean (nothing to commit)
if [ -z "$(git status --porcelain)" ]; then
    exit 0
fi

# Add all and commit. Redirect all output (silent regardless of outcome).
git add -A
git commit -m "vault: auto-commit $(date -u +%Y-%m-%dT%H:%M:%SZ)" --no-verify > /dev/null 2>&1 || true

exit 0