content-forge/scripts/vault-sync.sh
lizikk 29bcbb89db feat: add claude-md-guardian, thinking commands, and security fixes
- Add claude-md-guardian agent with SessionStart hook for auto CLAUDE.md maintenance
- Add 6 thinking commands: /my-world, /emerge, /challenge, /connect, /today, /close
- Add my-world skill for one-shot vault context loading
- Fix command injection vulnerability in init-vault.sh (use env vars)
- Add error handling and logging to vault-sync.sh
- Update write-article skill with complete frontmatter fields
- Upgrade CLAUDE.md to v1.3.0 with cycle time tracking and exit criteria

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 16:58:43 +08:00

50 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -Eeuo pipefail
VAULT_PATH="${VAULT_PATH:-/home/kang/apps/content-forge/content-forge}"
LOG_FILE="${LOG_FILE:-/tmp/vault-sync.log}"
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" >> "$LOG_FILE"
}
# Verify vault directory exists
if [[ ! -d "$VAULT_PATH" ]]; then
log "ERROR: Vault directory does not exist: $VAULT_PATH"
exit 1
fi
cd "$VAULT_PATH" || {
log "ERROR: Failed to cd into vault: $VAULT_PATH"
exit 1
}
# Skip if no changes
if git diff --quiet && git diff --cached --quiet && [ -z "$(git ls-files --others --exclude-standard)" ]; then
log "No changes to sync"
exit 0
fi
# Get current branch dynamically
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "main")
# Stage all changes
if ! git add -A; then
log "ERROR: git add failed"
exit 1
fi
# Commit with timestamp
if ! git commit -m "vault: auto-sync $(date '+%Y-%m-%d %H:%M')"; then
log "ERROR: git commit failed"
exit 1
fi
# Push with error handling
if ! git push origin "$BRANCH"; then
log "ERROR: git push failed (branch: $BRANCH)"
exit 1
fi
log "Sync successful: pushed to $BRANCH"