From 245a70d90f491b604d867559160635adbbad6061 Mon Sep 17 00:00:00 2001 From: kartik-mem0 Date: Fri, 22 May 2026 14:53:56 +0530 Subject: [PATCH] refactor: update mem0-plugin scripts to use tool_output instead of tool_result --- mem0-plugin/scripts/on_bash_output.sh | 4 ++-- mem0-plugin/scripts/on_post_commit.sh | 4 ++-- mem0-plugin/scripts/on_post_tool_use.sh | 2 +- mem0-plugin/scripts/on_tool_failure.sh | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mem0-plugin/scripts/on_bash_output.sh b/mem0-plugin/scripts/on_bash_output.sh index 18b505479..8b407f881 100755 --- a/mem0-plugin/scripts/on_bash_output.sh +++ b/mem0-plugin/scripts/on_bash_output.sh @@ -9,14 +9,14 @@ # typed message). This hook catches errors in COMMAND OUTPUT — e.g., # when `npm test` or `python script.py` fails with a traceback. # -# Input: JSON on stdin with tool_name, tool_input, tool_result +# Input: JSON on stdin with tool_name, tool_input, tool_output # Output: Context injected into Claude's next response (exit 0) set -uo pipefail INPUT=$(cat) -TOOL_RESULT=$(echo "$INPUT" | jq -r '.tool_result // ""' 2>/dev/null || echo "") +TOOL_RESULT=$(echo "$INPUT" | jq -r '.tool_output // ""' 2>/dev/null || echo "") # Skip short output (< 50 chars unlikely to contain a real stack trace) if [ ${#TOOL_RESULT} -lt 50 ]; then diff --git a/mem0-plugin/scripts/on_post_commit.sh b/mem0-plugin/scripts/on_post_commit.sh index 7e67d6d69..d9c29a985 100755 --- a/mem0-plugin/scripts/on_post_commit.sh +++ b/mem0-plugin/scripts/on_post_commit.sh @@ -6,7 +6,7 @@ # and prompts Claude to ask the user if this change should be stored as # a learning. # -# Input: JSON on stdin with tool_name, tool_input, tool_result +# Input: JSON on stdin with tool_name, tool_input, tool_output # Output: Context injected into Claude's next response (exit 0) # # This implements Spec #28 — interactive pre-commit memory check. @@ -31,7 +31,7 @@ case "$COMMAND" in esac # Check if the command actually succeeded (look for commit hash in output) -TOOL_RESULT=$(echo "$INPUT" | jq -r '.tool_result // ""' 2>/dev/null || echo "") +TOOL_RESULT=$(echo "$INPUT" | jq -r '.tool_output // ""' 2>/dev/null || echo "") if echo "$TOOL_RESULT" | grep -qiE '(error|fatal|abort|nothing to commit|no changes)'; then exit 0 fi diff --git a/mem0-plugin/scripts/on_post_tool_use.sh b/mem0-plugin/scripts/on_post_tool_use.sh index 49ff950e5..0f1d88275 100755 --- a/mem0-plugin/scripts/on_post_tool_use.sh +++ b/mem0-plugin/scripts/on_post_tool_use.sh @@ -5,7 +5,7 @@ # mcp__mem0__add_memory → record an add # mcp__mem0__search_memories → record a search # -# Input: JSON on stdin with tool_name, tool_input, tool_result +# Input: JSON on stdin with tool_name, tool_input, tool_output # Output: none (exit 0, non-blocking) set -uo pipefail diff --git a/mem0-plugin/scripts/on_tool_failure.sh b/mem0-plugin/scripts/on_tool_failure.sh index 2c9ff5175..7a2b9fa55 100755 --- a/mem0-plugin/scripts/on_tool_failure.sh +++ b/mem0-plugin/scripts/on_tool_failure.sh @@ -4,7 +4,7 @@ # Fires when a mem0 MCP tool call fails. Logs the failure, bumps telemetry, # and injects a retry hint so Claude can recover. # -# Input: JSON on stdin with tool_name, tool_input, tool_result, is_error +# Input: JSON on stdin with tool_name, tool_input, tool_error # Output: Context injected into Claude's next response (exit 0) set -uo pipefail @@ -17,7 +17,7 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" INPUT=$(cat) TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // ""' 2>/dev/null || echo "") -TOOL_RESULT=$(echo "$INPUT" | jq -r '.tool_result // ""' 2>/dev/null || echo "") +TOOL_RESULT=$(echo "$INPUT" | jq -r '.tool_error // ""' 2>/dev/null || echo "") TOOL_INPUT=$(echo "$INPUT" | jq -c '.tool_input // {}' 2>/dev/null || echo "{}") # Extract the short tool name (strip mcp__mem0__ prefix)