Moved application code from ~/.claude/skills/cognitive-memory/ to its own project directory. The skill layer (SKILL.md, SCHEMA.md) remains in the skill directory for Claude Code to read. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
48 lines
1.6 KiB
Bash
Executable File
48 lines
1.6 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: cognitive-memory data dir -> https://git.manticorum.com/cal/claude-memory.git
|
|
|
|
set -euo pipefail
|
|
|
|
# Resolve data directory: COGNITIVE_MEMORY_DIR > XDG_DATA_HOME > default
|
|
MEMORY_DIR="${COGNITIVE_MEMORY_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/cognitive-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"
|