Full sync - all projects, memory, configs
This commit is contained in:
24
extract_assistant_turns.sh
Executable file
24
extract_assistant_turns.sh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Extract assistant turns from session file
|
||||
session_file="$1"
|
||||
|
||||
# Extract messages with user and assistant roles, format for auto-memory-hook
|
||||
jq -r 'select(.type=="message") | select(.message.role=="user" or .message.role=="assistant") | [.message.role, (.message.content // [] | map(select(.type=="text") | .text) | join(" "))] | @tsv' "$session_file" | \
|
||||
while IFS=$'\t' read -r role content; do
|
||||
if [ "$role" = "user" ]; then
|
||||
user_msg="$content"
|
||||
elif [ "$role" = "assistant" ]; then
|
||||
if [ -n "$user_msg" ]; then
|
||||
# Create JSON for auto-memory-hook
|
||||
jq -n --arg user "$user_msg" --arg assistant "$content" \
|
||||
--arg agent_id "case" --arg session "main" \
|
||||
'{user: $user, assistant: $assistant, agent_id: $agent_id, session: $session}'
|
||||
user_msg="" # Reset for next pair
|
||||
fi
|
||||
fi
|
||||
done | tail -10 | while read -r json_line; do
|
||||
echo "$json_line" | python3 /home/wdjones/.openclaw/workspace/tools/auto-memory-hook.py
|
||||
done
|
||||
|
||||
echo "Auto-memory indexing completed"
|
||||
Reference in New Issue
Block a user