claude-configs/skills/cognitive-memory/scripts/ensure-symlinks.sh
Cal Corum e484b2ab35 feat: cognitive-memory multi-graph support, XDG data paths, remove CORE.md auto-load
- Multi-graph: named graph routing in MCP server (graph param on all tools),
  CLI --graph flag, graphs subcommand, resolve_graph_path() in common.py
- XDG compliance: data dir resolves via COGNITIVE_MEMORY_DIR env > XDG_DATA_HOME > ~/.local/share/
- Remove CORE.md auto-loading: drop MEMORY.md symlinks, update CLAUDE.md to MCP-first recall
- Update all scripts (git-sync, ensure-symlinks, edge-proposer) for portable path resolution
- Remove symlinks step from daily systemd service
- Version bump to 3.1.0

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 14:55:12 -06:00

29 lines
922 B
Bash
Executable File

#!/bin/bash
# Ensure all Claude Code project MEMORY.md files symlink to cognitive memory CORE.md
# This makes CORE.md auto-load into every session's system prompt.
# Run by cognitive-memory-daily.service or manually.
# Resolve data directory: COGNITIVE_MEMORY_DIR > XDG_DATA_HOME > default
MEMORY_DIR="${COGNITIVE_MEMORY_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/cognitive-memory}"
CORE="$MEMORY_DIR/CORE.md"
PROJECTS="$HOME/.claude/projects"
if [ ! -f "$CORE" ]; then
echo "ERROR: CORE.md not found at $CORE"
exit 1
fi
for dir in "$PROJECTS"/*/; do
memdir="$dir/memory"
memfile="$memdir/MEMORY.md"
mkdir -p "$memdir"
# Only create/fix symlink if it doesn't already point to CORE.md
if [ -L "$memfile" ] && [ "$(readlink "$memfile")" = "$CORE" ]; then
continue
fi
# Remove existing file (regular file or broken symlink)
rm -f "$memfile"
ln -s "$CORE" "$memfile"
echo "Linked: $memfile"
done