From 6c9bb7c58b0d859b6838fbc5b59174e7bb7476bc Mon Sep 17 00:00:00 2001 From: bchanot Date: Wed, 28 Oct 2026 14:16:50 +0100 Subject: [PATCH] feat(memory): templates born v2 (format: 2, no Index); session banner names a v1 registry --- agents/onboarder.md | 2 +- hooks/session-start.sh | 13 +++++++++++++ lib/tests/memory.test.sh | 12 ++++++++++++ templates/memory/blockers.md | 21 ++++++++------------- templates/memory/decisions.md | 25 +++++++++---------------- templates/memory/evals.md | 21 ++++++++------------- templates/memory/learnings.md | 19 +++++++------------ 7 files changed, 58 insertions(+), 55 deletions(-) diff --git a/agents/onboarder.md b/agents/onboarder.md index bcedd11..10e0405 100644 --- a/agents/onboarder.md +++ b/agents/onboarder.md @@ -123,7 +123,7 @@ ls ${PROJECT_ROOT}/.claude/tasks/TODO.md ${PROJECT_ROOT}/.claude/memory/ 2>/dev/ # TODO ``` -- **.claude/memory/ missing** → `mkdir -p ${PROJECT_ROOT}/.claude/memory`, then for each of the 5 registries (`decisions.md`, `learnings.md`, `blockers.md`, `journal.md`, `evals.md`): if the file does not exist in `${PROJECT_ROOT}/.claude/memory/`, copy from `~/.claude/templates/memory/.md` (YAML schema + empty index + inline template comment). If a registry file already exists → skip (do NOT overwrite). +- **.claude/memory/ missing** → `mkdir -p ${PROJECT_ROOT}/.claude/memory`, then for each of the 5 registries (`decisions.md`, `learnings.md`, `blockers.md`, `journal.md`, `evals.md`): if the file does not exist in `${PROJECT_ROOT}/.claude/memory/`, copy from `~/.claude/templates/memory/.md` (YAML schema with `format: 2` + inline template comment; no Index, entries go through `lib/memory.sh`). If a registry file already exists → skip (do NOT overwrite). - **.claude/audits/ missing** → `mkdir -p ${PROJECT_ROOT}/.claude/audits` (empty — populated later by `/onboard` audit phase). **Do NOT overwrite existing content.** diff --git a/hooks/session-start.sh b/hooks/session-start.sh index bcc75bc..6a2a340 100644 --- a/hooks/session-start.sh +++ b/hooks/session-start.sh @@ -266,6 +266,19 @@ if [ -n "$REPO_DIR" ] && [ -f "$REPO_DIR/CLAUDE.global.md" ]; then fi unset _claude_lines fi +# Registry v1 (BDR-125 phase 4a): a project registry without `format: 2`. +# The lib names each v1 registry on stderr (`memory: v1: `). +_mem_lib="$(dirname "${BASH_SOURCE[0]}")/../lib/memory.sh" +if [ -f "$_mem_lib" ] && [ -d .claude/memory ]; then + _v1=$(bash "$_mem_lib" check .claude/memory 2>&1 >/dev/null \ + | grep -c '^memory: v1:' || true) + if [ "${_v1:-0}" -gt 0 ]; then + printf "│ ⚠️ %-44s│\n" "registry v1: ${_v1} file(s) (memory.sh check)" + fi + unset _v1 +fi +unset _mem_lib + # Version check: compare local vs remote (non-blocking) _remote_ver="" if [ -n "$REPO_DIR" ] && [ -d "$REPO_DIR/.git" ] && [ -z "${SESSION_START_OFFLINE:-}" ]; then diff --git a/lib/tests/memory.test.sh b/lib/tests/memory.test.sh index ea0aefe..3b1e985 100755 --- a/lib/tests/memory.test.sh +++ b/lib/tests/memory.test.sh @@ -381,5 +381,17 @@ check T14o-no-restore-noise "$(tr -d ' ' < rs)" 0 # T12 this repo's registries pass the check check T12-live-check "$(bash "$MEM" -C "$ROOT" check >/dev/null 2>&1; echo $?)" 0 +# T13 templates are born v2; the session banner names a v1 project only +for t in decisions learnings blockers evals; do + check "T13-template-$t-v2" "$(sed -n 2p "$ROOT/templates/memory/$t.md")" 'format: 2' + check "T13b-template-$t-no-index" "$(grep -c '^## Index$' "$ROOT/templates/memory/$t.md")" 0 +done +banner() { (cd "$1" && SESSION_START_OFFLINE=1 bash "$ROOT/hooks/session-start.sh" \ + /dev/null) | grep -c "${2:-registry v1}"; } +check T13c-banner-v1-v2 "$(banner "$FIX/v1h" 'registry v1: 1 file(s) (memory.sh check)')/$(banner "$FIX")" 1/0 +cp "$FIX/v1h/.claude/memory/blockers.md" v1h.bak +printf -- '---\nformat: 2\n---\n' > "$FIX/v1h/.claude/memory/blockers.md" +check T13d-banner-flips-off "$(banner "$FIX/v1h")" 0 +cat v1h.bak > "$FIX/v1h/.claude/memory/blockers.md" echo "PASS=$pass FAIL=$fail" [ "$fail" -eq 0 ] diff --git a/templates/memory/blockers.md b/templates/memory/blockers.md index 0fa558b..e1293c4 100644 --- a/templates/memory/blockers.md +++ b/templates/memory/blockers.md @@ -1,4 +1,5 @@ --- +format: 2 type: blockers_registry entry_prefix: BLK schema: @@ -17,19 +18,13 @@ rules: # Blockers registry (BLK) -## Index + diff --git a/templates/memory/decisions.md b/templates/memory/decisions.md index a8bf0f9..8896d5b 100644 --- a/templates/memory/decisions.md +++ b/templates/memory/decisions.md @@ -1,4 +1,5 @@ --- +format: 2 type: decisions_registry entry_prefix: BDR schema: @@ -19,22 +20,14 @@ rules: # Decisions registry (BDR) -## Index + diff --git a/templates/memory/evals.md b/templates/memory/evals.md index c531351..176701d 100644 --- a/templates/memory/evals.md +++ b/templates/memory/evals.md @@ -1,4 +1,5 @@ --- +format: 2 type: evals_registry entry_prefix: EVAL schema: @@ -18,19 +19,13 @@ rules: # Evals registry (EVAL) -## Index + diff --git a/templates/memory/learnings.md b/templates/memory/learnings.md index 7705a8b..527c5c7 100644 --- a/templates/memory/learnings.md +++ b/templates/memory/learnings.md @@ -1,4 +1,5 @@ --- +format: 2 type: learnings_registry entry_prefix: LRN schema: @@ -16,18 +17,12 @@ rules: # Learnings registry (LRN) -## Index +