Files
openclaw/scripts/memory-integrity-check.sh

28 lines
859 B
Bash
Raw Normal View History

#!/usr/bin/env bash
set -euo pipefail
WORKSPACE="${WORKSPACE:-/home/openclaw/.openclaw/workspace}"
cd "$WORKSPACE"
fail(){
echo "$1" >&2
exit 1
}
[[ -f "MEMORY.md" ]] || fail "missing: MEMORY.md"
[[ -d "memory" ]] || fail "missing: memory/ directory"
# At least one daily memory note.
if ! find memory -maxdepth 1 -type f -regextype posix-extended -regex '.*/[0-9]{4}-[0-9]{2}-[0-9]{2}\.md' | grep -q .; then
fail "missing: memory/YYYY-MM-DD.md daily files"
fi
# Key files must not be empty.
[[ -s "MEMORY.md" ]] || fail "empty: MEMORY.md"
first_daily_file="$(find memory -maxdepth 1 -type f -regextype posix-extended -regex '.*/[0-9]{4}-[0-9]{2}-[0-9]{2}\.md' | sort | head -n1)"
[[ -n "$first_daily_file" ]] || fail "missing: daily memory file"
[[ -s "$first_daily_file" ]] || fail "empty: $first_daily_file"
echo "ok: memory integrity passed"