fix(install): scaffold ~/.claude/memory dir + placeholder MEMORY.md

_blocks/memory-protocol.md references ~/.claude/memory/MEMORY.md, but the
installer previously only scaffolded agents/ hooks/ skills/ — so the first
agent that followed the block would fail reading a non-existent index.
Now mkdir -p ~/.claude/memory and, only when MEMORY.md is absent, write a
minimal placeholder (frontmatter + pointer to the block). User-edited
MEMORY.md is never overwritten.
This commit is contained in:
Parfii-bot 2026-04-21 03:07:15 +08:00
parent 30cd08b85b
commit 8625fe791b

View file

@ -60,7 +60,22 @@ mkdir -p \
"$AGENTS_DIR/_assembler/src" \
"$AGENTS_DIR/_generated" \
"$HOOKS_DIR" \
"$SKILLS_DIR/new-agent"
"$SKILLS_DIR/new-agent" \
"$HOME_DIR/.claude/memory"
# --- scaffold MEMORY.md placeholder (user-respecting) ----------------------
# _blocks/memory-protocol.md references ~/.claude/memory/MEMORY.md; without
# this file the first agent following the protocol fails on read.
MEMORY_INDEX="$HOME_DIR/.claude/memory/MEMORY.md"
if [[ ! -f "$MEMORY_INDEX" ]]; then
cat > "$MEMORY_INDEX" <<'EOF'
# Auto Memory — Index
> File-based memory index. Add entries as you save memory files under this directory.
> See `_blocks/memory-protocol.md` for format.
EOF
say "scaffolded $MEMORY_INDEX"
fi
# --- copy blocks (overwrite ours; blocks are SSoT from kit) ----------------
say "copying shared blocks -> $AGENTS_DIR/_blocks/"