Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a89309ff1 | ||
|
|
cb11a6b2d1 | ||
|
|
81882ee3ec | ||
|
|
1987ba792d | ||
|
|
a1ff1b9881 |
@@ -1,7 +1,9 @@
|
||||
#!/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.
|
||||
# Build the activity log — the list of TOOL CALLS the agent made — into /tmp/activity_log.md.
|
||||
# Only dev agents (mode=pr) get an activity-log comment — comment-only roles (pm/qa) do no tool calls.
|
||||
# NOTE: we deliberately DO NOT include the agent's prose text parts. That final "here's what I did"
|
||||
# text is just a restatement of the PR description (already published as the PR body), not a tool
|
||||
# call — so it was noise in a section titled "tool calls". The log is the record of ACTIONS taken.
|
||||
#
|
||||
# Required env (provided by the workflow step): MODE
|
||||
set -u
|
||||
@@ -11,16 +13,12 @@ if [ "$MODE" != "pr" ]; then
|
||||
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
|
||||
select(.type=="tool_use") |
|
||||
(.part.tool // "?") as $t |
|
||||
((.part.state.title // (.part.state.input | tojson | trunc(160)) // "")) as $title |
|
||||
"🔧 **" + $t + "**: `" + ($title | trunc(240)) + "`"
|
||||
' /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"
|
||||
echo "activity log: $n tool calls"
|
||||
[ "$n" -eq 0 ] && : > /tmp/activity_log.md
|
||||
head -3 /tmp/activity_log.md
|
||||
|
||||
@@ -18,14 +18,25 @@ hdr=(-H "Authorization: token $TOK" -H "Content-Type: application/json")
|
||||
post() { curl -sS -w 'comment -> HTTP %{http_code}\n' -X POST "${hdr[@]}" \
|
||||
"$API/issues/$NUM/comments" -d "$(jq -nc --arg b "$1" '{body:$b}')"; }
|
||||
|
||||
# drop machine-readable markers (DELEGATE / CLOSE_ISSUE / the BEGIN_SUBTASKS..END_SUBTASKS block)
|
||||
# drop machine-readable markers: DELEGATE / CLOSE_ISSUE, and the BEGIN_SUBTASKS..END_SUBTASKS and
|
||||
# BEGIN_PR_DESCRIPTION..END_PR_DESCRIPTION blocks (the PR description is published separately).
|
||||
reply=$(awk '
|
||||
/^[[:space:]]*BEGIN_SUBTASKS/{s=1}
|
||||
/^[[:space:]]*BEGIN_PR_DESCRIPTION/{p=1}
|
||||
/^[[:space:]]*DELEGATE:[[:space:]]*@/{next}
|
||||
/^[[:space:]]*CLOSE_ISSUE[[:space:]]*$/{next}
|
||||
s{ if(/^[[:space:]]*END_SUBTASKS/){s=0}; next }
|
||||
p{ if(/^[[:space:]]*END_PR_DESCRIPTION/){p=0}; next }
|
||||
{print}
|
||||
' /tmp/agent_out.md 2>/dev/null)
|
||||
# Strip a leading self-header the model sometimes emits ("🤖 **@pm**" on its own line) so we don't
|
||||
# double it when we prepend our own. Removes a leading run of such header lines and blank lines.
|
||||
reply=$(printf '%s' "$reply" | awk '
|
||||
BEGIN{s=1}
|
||||
s && /^[^A-Za-z0-9]*\*\*@[A-Za-z]+\*\*[[:space:]]*$/ {next}
|
||||
s && /^[[:space:]]*$/ {next}
|
||||
{s=0; print}
|
||||
')
|
||||
[ -z "$reply" ] && reply="_(Made changes without a text summary — see the diff below.)_"
|
||||
# Prefer the agent's clean delimited PR description; fall back to the whole reply.
|
||||
prdesc=$(awk '/BEGIN_PR_DESCRIPTION/{f=1;next} /END_PR_DESCRIPTION/{f=0} f' /tmp/agent_out.md)
|
||||
@@ -133,7 +144,7 @@ activity=""
|
||||
if [ -s /tmp/activity_log.md ]; then
|
||||
entries=$(wc -l < /tmp/activity_log.md 2>/dev/null || echo 0)
|
||||
log=$(cat /tmp/activity_log.md)
|
||||
activity=$(printf '\n\n---\n🤖 **@%s** — activity log (%s entries):\n<details>\n<summary>tool calls & reasoning</summary>\n\n%s\n\n</details>' "$NAME" "$entries" "$log")
|
||||
activity=$(printf '\n\n<details>\n<summary>🔧 activity — %s tool calls</summary>\n\n%s\n\n</details>' "$entries" "$log")
|
||||
fi
|
||||
|
||||
# One PR per run: publish ONLY this run's own branch ($BRANCH), never sibling
|
||||
@@ -175,6 +186,7 @@ prpost() {
|
||||
if [ "$NEW" = "true" ]; then
|
||||
prpost "$prnum" "$(printf '🤖 **@%s** — ✅ PR ready for review — @ffaerber please review & merge:\n- %s%s' "$NAME" "$url" "$activity")"
|
||||
else
|
||||
# Resume (comment is on a PR thread): include the write-up here too.
|
||||
prpost "$prnum" "$(printf '🤖 **@%s** — updated branch/PR:\n- %s\n\n%s%s' "$NAME" "$url" "$prdesc" "$activity")"
|
||||
# Resume: just link the PR — its body and the diff already carry the description, so we don't
|
||||
# repeat the full write-up in the comment (the reasoning trail below shows what this run did).
|
||||
prpost "$prnum" "$(printf '🤖 **@%s** — pushed an update to the PR:\n- %s%s' "$NAME" "$url" "$activity")"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user