#!/bin/bash # Commit and push cognitive memory changes to Gitea. # # Syncs the default graph and any named graphs whose directory is a git repo. # Called daily by cognitive-memory-daily.service after decay/core runs. # Safe to run multiple times — only commits when there are actual changes. # # Default graph: COGNITIVE_MEMORY_DIR > XDG_DATA_HOME > ~/.local/share/cognitive-memory # Named graphs: ~/.local/share/cognitive-memory-graphs// (any with .git/) # # Location: ~/.claude/skills/cognitive-memory/scripts/memory-git-sync.sh set -uo pipefail # Note: -e intentionally omitted at the top level so that one graph's failure # does not prevent the remaining graphs from being synced. Each function call # is checked explicitly. # ── resolve directories ──────────────────────────────────────────────────────── MEMORY_DIR="${COGNITIVE_MEMORY_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/cognitive-memory}" # Named graphs live in a sibling directory: cognitive-memory-graphs// GRAPHS_BASE_DIR="${MEMORY_DIR%cognitive-memory}cognitive-memory-graphs" # ── sync function ────────────────────────────────────────────────────────────── # sync_repo