- .gitignore: Add backups/ to stop noisy session backup rotation diffs - Remove tracked backup files from index - skills/cognitive-memory/mcp_server.py: Auto-push to Gitea on memory_store and memory_relate - skills/cognitive-memory/scripts/memory-git-sync.sh: New git commit+push script - skills/cognitive-memory/systemd/cognitive-memory-daily.service: Add git sync as fallback Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
47 lines
1.4 KiB
Bash
Executable File
47 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Commit and push cognitive memory changes to Gitea (cal/claude-memory)
|
|
#
|
|
# Called daily by cognitive-memory-daily.service after decay/core/symlinks.
|
|
# Only commits if there are actual changes. Safe to run multiple times.
|
|
#
|
|
# Location: ~/.claude/skills/cognitive-memory/scripts/memory-git-sync.sh
|
|
# Repo: ~/.claude/memory/ -> https://git.manticorum.com/cal/claude-memory.git
|
|
|
|
set -euo pipefail
|
|
|
|
MEMORY_DIR="$HOME/.claude/memory"
|
|
|
|
cd "$MEMORY_DIR"
|
|
|
|
# Check if there are any changes to commit
|
|
if git diff --quiet && git diff --cached --quiet && [ -z "$(git ls-files --others --exclude-standard)" ]; then
|
|
echo "memory-git-sync: no changes to commit"
|
|
exit 0
|
|
fi
|
|
|
|
# Stage all changes (.gitignore handles exclusions)
|
|
git add -A
|
|
|
|
# Build a commit message from what changed
|
|
ADDED=$(git diff --cached --name-only --diff-filter=A | wc -l)
|
|
MODIFIED=$(git diff --cached --name-only --diff-filter=M | wc -l)
|
|
DELETED=$(git diff --cached --name-only --diff-filter=D | wc -l)
|
|
EDGES=$(git diff --cached --name-only --diff-filter=ACM | grep -c '^graph/edges/' || true)
|
|
|
|
MSG="daily sync: ${ADDED} added, ${MODIFIED} modified, ${DELETED} deleted"
|
|
if [ "$EDGES" -gt 0 ]; then
|
|
MSG="$MSG (${EDGES} edges)"
|
|
fi
|
|
|
|
git commit -m "$MSG" --no-gpg-sign 2>/dev/null || {
|
|
echo "memory-git-sync: commit failed (pre-commit hook?)"
|
|
exit 1
|
|
}
|
|
|
|
git push origin main 2>/dev/null || {
|
|
echo "memory-git-sync: push failed"
|
|
exit 1
|
|
}
|
|
|
|
echo "memory-git-sync: pushed to origin/main"
|