#!/usr/bin/env bash # Fetch the full issue thread (shared memory) into /tmp/thread.md. # Agents post as their OWN Gitea users, so .user.login IS the agent name — attribute each comment # to its real author (@pm/@qa/@junior/…). Strip the hidden `` loop-prevention marker # from bodies — it's plumbing, not conversation, and would just waste prompt tokens. # # Required env (provided by the workflow step): GT NUM GITHUB_SERVER_URL GITHUB_REPOSITORY set -eu API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}" curl -sS -H "Authorization: token $GT" "$API/issues/$NUM/comments?limit=100" 2>/dev/null \ | jq -r '.[] | ( if (.user.login == "ffaerber") then "@ffaerber (the maintainer)" else "@" + .user.login end ) as $who | "### comment by \($who):\n\(.body | gsub("\\s*"; ""))\n"' \ > /tmp/thread.md 2>/dev/null || true echo "thread comments fetched: $(grep -c '^### comment by ' /tmp/thread.md 2>/dev/null || echo 0)"