#!/usr/bin/env bash # Build activity log (tool calls + reasoning) from the event stream into /tmp/activity_log.md. # Only dev agents (mode=pr) get an activity-log comment — comment-only roles (pm/qa) # do no tool calls, so a trail would be empty/noise. # # Required env (provided by the workflow step): MODE set -u if [ "$MODE" != "pr" ]; then echo "skipping activity log for comment-mode agent"; : > /tmp/activity_log.md; exit 0 fi jq -r ' def trunc(n): if length > n then (.[0:n] + "…") else . end; select(.type=="tool_use" or .type=="text") | if .type=="text" then "💬 " + ((.part.text // "") | trunc(4000)) else (.part.tool // "?") as $t | ((.part.state.title // (.part.state.input | tojson | trunc(160)) // "")) as $title | "🔧 **" + $t + "**: `" + ($title | trunc(240)) + "`" end ' /tmp/events.jsonl > /tmp/activity_log.md 2>/dev/null || true n=$(wc -l < /tmp/activity_log.md 2>/dev/null || echo 0) echo "activity log: $n entries" [ "$n" -eq 0 ] && : > /tmp/activity_log.md head -3 /tmp/activity_log.md