feat(mem0-plugin): v0.2.5 — fix identity scoping, skill param bugs, add checklists (#5247)
This commit is contained in:
@@ -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_output
|
||||
# Input: JSON on stdin with tool_name, tool_input, tool_response
|
||||
# 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_output // ""' 2>/dev/null || echo "")
|
||||
TOOL_RESULT=$(echo "$INPUT" | jq -r '.tool_response // ""' 2>/dev/null || echo "")
|
||||
if echo "$TOOL_RESULT" | grep -qiE '(error|fatal|abort|nothing to commit|no changes)'; then
|
||||
exit 0
|
||||
fi
|
||||
@@ -52,47 +52,26 @@ if [ "$COMMIT_PROMPTS" != "true" ]; then
|
||||
fi
|
||||
|
||||
# Extract changed files from commit
|
||||
CHANGED_FILES=$(git diff-tree --no-commit-id --name-only -r HEAD 2>/dev/null | head -10 || echo "")
|
||||
CHANGED_FILES=$(git -C "$MEM0_CWD" diff-tree --no-commit-id --name-only -r HEAD 2>/dev/null | head -10 || echo "")
|
||||
if [ -z "$CHANGED_FILES" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Get the commit message
|
||||
COMMIT_MSG=$(git log -1 --format='%s' HEAD 2>/dev/null || echo "")
|
||||
COMMIT_MSG=$(git -C "$MEM0_CWD" log -1 --format='%s' HEAD 2>/dev/null || echo "")
|
||||
|
||||
# Build file list for display
|
||||
FILE_LIST=$(echo "$CHANGED_FILES" | sed 's/^/ - /' | head -5)
|
||||
FILE_COUNT=$(echo "$CHANGED_FILES" | wc -l | tr -d ' ')
|
||||
|
||||
cat <<EOF
|
||||
CTX="Commit captured: ${COMMIT_MSG}\nFiles changed (${FILE_COUNT}):\n${FILE_LIST}\n\nCommit learnings (decision, task_learning, anti_pattern, convention) are stored via add_memory with user_id=${MEM0_RESOLVED_USER_ID}, app_id=${MEM0_PROJECT_ID}, branch=${MEM0_BRANCH}."
|
||||
|
||||
## Commit captured — save as memory?
|
||||
|
||||
**Commit:** $COMMIT_MSG
|
||||
**Files changed ($FILE_COUNT):**
|
||||
$FILE_LIST
|
||||
|
||||
This commit may contain learnings worth preserving. Ask the user:
|
||||
|
||||
> **Save this change as a memory?** I can store it as one of:
|
||||
> - \`decision\` — if an architectural or design choice was made
|
||||
> - \`task_learning\` — if a strategy or approach worked well
|
||||
> - \`anti_pattern\` — if this fixes a bug or avoids a known pitfall
|
||||
> - \`convention\` — if this establishes a new pattern
|
||||
>
|
||||
> Type the category, or **skip** to move on.
|
||||
|
||||
If the user provides a category (or says yes/sure/go ahead):
|
||||
1. Summarize the commit: what changed and why (from the diff + commit message)
|
||||
2. Call \`add_memory\` with:
|
||||
- \`messages=[{"role": "user", "content": "<your summary>"}]\`
|
||||
- \`user_id="$MEM0_RESOLVED_USER_ID"\`
|
||||
- \`app_id="$MEM0_PROJECT_ID"\`
|
||||
- \`metadata={"type": "<chosen_category>", "branch": "$MEM0_BRANCH", "confidence": 0.8, "files": [<changed files>], "source": "post-commit"}\`
|
||||
- \`infer=False\`
|
||||
|
||||
If the user says skip/no/nothing: proceed normally. Do NOT ask again for the same commit.
|
||||
EOF
|
||||
jq -cn --arg ctx "$CTX" '{
|
||||
hookSpecificOutput: {
|
||||
hookEventName: "PostToolUse",
|
||||
additionalContext: $ctx
|
||||
}
|
||||
}' 2>/dev/null || true
|
||||
|
||||
# Telemetry
|
||||
python3 "$SCRIPT_DIR/telemetry.py" post_commit --files_count="$FILE_COUNT" 2>/dev/null &
|
||||
|
||||
Reference in New Issue
Block a user