diff --git a/mem0-plugin/scripts/on_pre_compact.sh b/mem0-plugin/scripts/on_pre_compact.sh index 3448cf5f4..28a1d86af 100755 --- a/mem0-plugin/scripts/on_pre_compact.sh +++ b/mem0-plugin/scripts/on_pre_compact.sh @@ -15,6 +15,13 @@ if [ -n "${MEM0_DEBUG:-}" ]; then mkdir -p "$HOME/.mem0" && exec 2>>"$HOME/.mem0/hooks.log" fi +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INPUT=$(cat) + +# Fire REST API transcript backup in background (safety net if agent +# can't complete the add_memory call before compaction finishes) +echo "$INPUT" | python3 "$SCRIPT_DIR/on_pre_compact.py" --source=pre-compaction 2>/dev/null & + cat <<'EOF' ## CRITICAL: Pre-Compaction Session Summary diff --git a/mem0-plugin/scripts/on_session_start.sh b/mem0-plugin/scripts/on_session_start.sh index 74a5953d2..d9351c752 100755 --- a/mem0-plugin/scripts/on_session_start.sh +++ b/mem0-plugin/scripts/on_session_start.sh @@ -79,7 +79,8 @@ echo "" if [ "$SOURCE" = "startup" ]; then # First-run detection: auto-trigger onboarding for new projects - _ONBOARD_MARKER="$HOME/.mem0/.onboarded_${MEM0_PROJECT_ID}" + _SAFE_PID=$(printf '%s' "$MEM0_PROJECT_ID" | tr '/:' '--') + _ONBOARD_MARKER="$HOME/.mem0/.onboarded_${_SAFE_PID}" if [ ! -f "$_ONBOARD_MARKER" ]; then cat <<'EOF' ## Mem0 First Run — Automatic Onboarding diff --git a/mem0-plugin/scripts/on_stop_codex.sh b/mem0-plugin/scripts/on_stop_codex.sh index 983bac8de..16c5a023f 100755 --- a/mem0-plugin/scripts/on_stop_codex.sh +++ b/mem0-plugin/scripts/on_stop_codex.sh @@ -22,6 +22,8 @@ if [ -n "${MEM0_DEBUG:-}" ]; then fi SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +# shellcheck source=_identity.sh +. "$SCRIPT_DIR/_identity.sh" INPUT=$(cat) STOP_HOOK_ACTIVE=$(echo "$INPUT" | jq -r '.stop_hook_active // false' 2>/dev/null || echo "false") diff --git a/mem0-plugin/scripts/on_stop_cursor.sh b/mem0-plugin/scripts/on_stop_cursor.sh index 3e441c557..179d924ed 100755 --- a/mem0-plugin/scripts/on_stop_cursor.sh +++ b/mem0-plugin/scripts/on_stop_cursor.sh @@ -14,6 +14,8 @@ if [ -n "${MEM0_DEBUG:-}" ]; then fi SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +# shellcheck source=_identity.sh +. "$SCRIPT_DIR/_identity.sh" INPUT=$(cat) diff --git a/mem0-plugin/skills/mem0-onboard/SKILL.md b/mem0-plugin/skills/mem0-onboard/SKILL.md index e00b51f38..f5566630f 100644 --- a/mem0-plugin/skills/mem0-onboard/SKILL.md +++ b/mem0-plugin/skills/mem0-onboard/SKILL.md @@ -77,7 +77,8 @@ If the script reports an error, show the error message and suggest checking the Create a marker file so SessionStart won't re-trigger onboarding next session: ```bash -mkdir -p ~/.mem0 && touch ~/.mem0/.onboarded_ +_SAFE_PID=$(printf '%s' "" | tr '/:' '--') +mkdir -p ~/.mem0 && touch ~/.mem0/.onboarded_${_SAFE_PID} ``` This is silent — no user-facing output needed.