Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6955bc4f71 | ||
|
|
0a06c813bc | ||
|
|
c4fb117b93 | ||
|
|
eeae1fdaaa | ||
|
|
7abbbb1b8d | ||
|
|
95bc254640 | ||
|
|
75a2493dee | ||
|
|
53ac2b7ba8 | ||
|
|
4b73d0b8e9 |
+45
-18
@@ -5,6 +5,10 @@ name: agent
|
|||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
|
|
||||||
|
# Pinned opencode version — used to install it and to key the CI cache below.
|
||||||
|
env:
|
||||||
|
OPENCODE_VERSION: "1.17.13"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
agent:
|
agent:
|
||||||
@@ -44,17 +48,6 @@ jobs:
|
|||||||
# job must never hold the single runner slot for hours.
|
# job must never hold the single runner slot for hours.
|
||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
steps:
|
steps:
|
||||||
- name: Acknowledge with 👀
|
|
||||||
env:
|
|
||||||
GT: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
CID: ${{ github.event.comment.id }}
|
|
||||||
NUM: ${{ github.event.issue.number }}
|
|
||||||
run: |
|
|
||||||
B="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/issues"
|
|
||||||
if [ -n "$CID" ]; then R="$B/comments/$CID/reactions"; else R="$B/$NUM/reactions"; fi
|
|
||||||
curl -sS -X POST -H "Authorization: token $GT" -H "Content-Type: application/json" \
|
|
||||||
"$R" -d '{"content":"eyes"}' -w '\nreact -> HTTP %{http_code}\n' || true
|
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
@@ -119,6 +112,37 @@ jobs:
|
|||||||
TOKEN_INTERN: ${{ secrets.TOKEN_INTERN }}
|
TOKEN_INTERN: ${{ secrets.TOKEN_INTERN }}
|
||||||
run: bash "$SCRIPTS/route.sh"
|
run: bash "$SCRIPTS/route.sh"
|
||||||
|
|
||||||
|
- name: Acknowledge with 👀 (as the routed agent)
|
||||||
|
if: steps.prep.outputs.mode != 'skip'
|
||||||
|
env:
|
||||||
|
SELF_TOKEN: ${{ steps.prep.outputs.name == 'pm' && secrets.TOKEN_PM || steps.prep.outputs.name == 'junior' && secrets.TOKEN_JUNIOR || steps.prep.outputs.name == 'senior' && secrets.TOKEN_SENIOR || steps.prep.outputs.name == 'lead' && secrets.TOKEN_LEAD || steps.prep.outputs.name == 'qa' && secrets.TOKEN_QA || steps.prep.outputs.name == 'ops' && secrets.TOKEN_OPS || steps.prep.outputs.name == 'intern' && secrets.TOKEN_INTERN || '' }}
|
||||||
|
CID: ${{ github.event.comment.id }}
|
||||||
|
NUM: ${{ github.event.issue.number }}
|
||||||
|
run: |
|
||||||
|
[ -n "$SELF_TOKEN" ] || { echo "no agent token — skipping 👀"; exit 0; }
|
||||||
|
B="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/issues"
|
||||||
|
if [ -n "$CID" ]; then R="$B/comments/$CID/reactions"; else R="$B/$NUM/reactions"; fi
|
||||||
|
curl -sS -X POST -H "Authorization: token $SELF_TOKEN" -H "Content-Type: application/json" \
|
||||||
|
"$R" -d '{"content":"eyes"}' -w '\nreact -> HTTP %{http_code}\n' || true
|
||||||
|
|
||||||
|
- name: Cache opencode CLI
|
||||||
|
if: steps.prep.outputs.mode != 'skip'
|
||||||
|
continue-on-error: true # a cache backend hiccup must never fail an agent run
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ~/.opencode
|
||||||
|
key: opencode-${{ runner.os }}-${{ env.OPENCODE_VERSION }}
|
||||||
|
|
||||||
|
- name: Cache Playwright browsers + npm (browser agents only)
|
||||||
|
if: steps.prep.outputs.mode != 'skip' && (steps.prep.outputs.name == 'senior' || steps.prep.outputs.name == 'lead' || steps.prep.outputs.name == 'qa')
|
||||||
|
continue-on-error: true
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cache/ms-playwright
|
||||||
|
~/.npm
|
||||||
|
key: playwright-npm-${{ runner.os }}-v1
|
||||||
|
|
||||||
- name: Install opencode + provider config (+ Playwright MCP for browser agents)
|
- name: Install opencode + provider config (+ Playwright MCP for browser agents)
|
||||||
if: steps.prep.outputs.mode != 'skip'
|
if: steps.prep.outputs.mode != 'skip'
|
||||||
env:
|
env:
|
||||||
@@ -266,24 +290,27 @@ jobs:
|
|||||||
run: bash "$SCRIPTS/rescue-pr.sh" || true
|
run: bash "$SCRIPTS/rescue-pr.sh" || true
|
||||||
|
|
||||||
- name: Mark done with 🚀 (remove 👀)
|
- name: Mark done with 🚀 (remove 👀)
|
||||||
|
if: steps.prep.outputs.mode != 'skip'
|
||||||
env:
|
env:
|
||||||
GT: ${{ secrets.GITEA_TOKEN }}
|
SELF_TOKEN: ${{ steps.prep.outputs.name == 'pm' && secrets.TOKEN_PM || steps.prep.outputs.name == 'junior' && secrets.TOKEN_JUNIOR || steps.prep.outputs.name == 'senior' && secrets.TOKEN_SENIOR || steps.prep.outputs.name == 'lead' && secrets.TOKEN_LEAD || steps.prep.outputs.name == 'qa' && secrets.TOKEN_QA || steps.prep.outputs.name == 'ops' && secrets.TOKEN_OPS || steps.prep.outputs.name == 'intern' && secrets.TOKEN_INTERN || '' }}
|
||||||
CID: ${{ github.event.comment.id }}
|
CID: ${{ github.event.comment.id }}
|
||||||
NUM: ${{ github.event.issue.number }}
|
NUM: ${{ github.event.issue.number }}
|
||||||
run: |
|
run: |
|
||||||
|
[ -n "$SELF_TOKEN" ] || exit 0
|
||||||
B="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/issues"
|
B="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/issues"
|
||||||
if [ -n "$CID" ]; then R="$B/comments/$CID/reactions"; else R="$B/$NUM/reactions"; fi
|
if [ -n "$CID" ]; then R="$B/comments/$CID/reactions"; else R="$B/$NUM/reactions"; fi
|
||||||
curl -sS -X DELETE -H "Authorization: token $GT" -H "Content-Type: application/json" "$R" -d '{"content":"eyes"}' || true
|
curl -sS -X DELETE -H "Authorization: token $SELF_TOKEN" -H "Content-Type: application/json" "$R" -d '{"content":"eyes"}' || true
|
||||||
curl -sS -X POST -H "Authorization: token $GT" -H "Content-Type: application/json" "$R" -d '{"content":"rocket"}' -w '\nreact -> HTTP %{http_code}\n' || true
|
curl -sS -X POST -H "Authorization: token $SELF_TOKEN" -H "Content-Type: application/json" "$R" -d '{"content":"rocket"}' -w '\nreact -> HTTP %{http_code}\n' || true
|
||||||
|
|
||||||
- name: Mark failed with 😕 (remove 👀)
|
- name: Mark failed with 😕 (remove 👀)
|
||||||
if: failure()
|
if: failure() && steps.prep.outputs.mode != 'skip'
|
||||||
env:
|
env:
|
||||||
GT: ${{ secrets.GITEA_TOKEN }}
|
SELF_TOKEN: ${{ steps.prep.outputs.name == 'pm' && secrets.TOKEN_PM || steps.prep.outputs.name == 'junior' && secrets.TOKEN_JUNIOR || steps.prep.outputs.name == 'senior' && secrets.TOKEN_SENIOR || steps.prep.outputs.name == 'lead' && secrets.TOKEN_LEAD || steps.prep.outputs.name == 'qa' && secrets.TOKEN_QA || steps.prep.outputs.name == 'ops' && secrets.TOKEN_OPS || steps.prep.outputs.name == 'intern' && secrets.TOKEN_INTERN || '' }}
|
||||||
CID: ${{ github.event.comment.id }}
|
CID: ${{ github.event.comment.id }}
|
||||||
NUM: ${{ github.event.issue.number }}
|
NUM: ${{ github.event.issue.number }}
|
||||||
run: |
|
run: |
|
||||||
|
[ -n "$SELF_TOKEN" ] || exit 0
|
||||||
B="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/issues"
|
B="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/issues"
|
||||||
if [ -n "$CID" ]; then R="$B/comments/$CID/reactions"; else R="$B/$NUM/reactions"; fi
|
if [ -n "$CID" ]; then R="$B/comments/$CID/reactions"; else R="$B/$NUM/reactions"; fi
|
||||||
curl -sS -X DELETE -H "Authorization: token $GT" -H "Content-Type: application/json" "$R" -d '{"content":"eyes"}' || true
|
curl -sS -X DELETE -H "Authorization: token $SELF_TOKEN" -H "Content-Type: application/json" "$R" -d '{"content":"eyes"}' || true
|
||||||
curl -sS -X POST -H "Authorization: token $GT" -H "Content-Type: application/json" "$R" -d '{"content":"confused"}' -w '\nreact -> HTTP %{http_code}\n' || true
|
curl -sS -X POST -H "Authorization: token $SELF_TOKEN" -H "Content-Type: application/json" "$R" -d '{"content":"confused"}' -w '\nreact -> HTTP %{http_code}\n' || true
|
||||||
|
|||||||
@@ -26,3 +26,9 @@ jq -rs '
|
|||||||
"### comment by \($who):\n\(.body | gsub("\\s*<!-- 🤖 agent reply — do not trigger -->"; ""))\n"' \
|
"### comment by \($who):\n\(.body | gsub("\\s*<!-- 🤖 agent reply — do not trigger -->"; ""))\n"' \
|
||||||
/tmp/thread_pages.json > /tmp/thread.md 2>/dev/null || : > /tmp/thread.md
|
/tmp/thread_pages.json > /tmp/thread.md 2>/dev/null || : > /tmp/thread.md
|
||||||
echo "thread comments fetched: $(grep -c '^### comment by ' /tmp/thread.md 2>/dev/null || echo 0) (newest 100 kept)"
|
echo "thread comments fetched: $(grep -c '^### comment by ' /tmp/thread.md 2>/dev/null || echo 0) (newest 100 kept)"
|
||||||
|
|
||||||
|
# Record the newest comment id on the thread BEFORE the agent runs. publish.sh compares against
|
||||||
|
# it to detect an agent that self-posted its reply mid-run (via the gitea-api skill, despite the
|
||||||
|
# prompt telling it not to) and skips the duplicate framework reply. Ids are monotonic — no dates.
|
||||||
|
jq -rs '[ (add // [])[].id ] | max // 0' /tmp/thread_pages.json > /tmp/thread_max_cid 2>/dev/null || echo 0 > /tmp/thread_max_cid
|
||||||
|
echo "pre-run newest comment id: $(cat /tmp/thread_max_cid)"
|
||||||
|
|||||||
@@ -9,7 +9,14 @@ set -eu
|
|||||||
# --format json event schema that build-activity-log.sh parses) breaks every agent in every repo
|
# --format json event schema that build-activity-log.sh parses) breaks every agent in every repo
|
||||||
# at once. Bump deliberately by changing this default (or set OPENCODE_VERSION in the step env).
|
# at once. Bump deliberately by changing this default (or set OPENCODE_VERSION in the step env).
|
||||||
OPENCODE_VERSION="${OPENCODE_VERSION:-1.17.13}"
|
OPENCODE_VERSION="${OPENCODE_VERSION:-1.17.13}"
|
||||||
curl -fsSL https://opencode.ai/install | bash -s -- --version "$OPENCODE_VERSION"
|
# Skip the download when a cache hit already restored the pinned binary (see the Cache
|
||||||
|
# opencode CLI step in agent.yml). The installer always re-fetches otherwise.
|
||||||
|
OC_BIN="$HOME/.opencode/bin/opencode"
|
||||||
|
if [ -x "$OC_BIN" ] && "$OC_BIN" --version 2>/dev/null | grep -qF "$OPENCODE_VERSION"; then
|
||||||
|
echo "opencode $OPENCODE_VERSION already present (cache hit) — skipping install"
|
||||||
|
else
|
||||||
|
curl -fsSL https://opencode.ai/install | bash -s -- --version "$OPENCODE_VERSION"
|
||||||
|
fi
|
||||||
echo "$HOME/.opencode/bin" >> "$GITHUB_PATH"
|
echo "$HOME/.opencode/bin" >> "$GITHUB_PATH"
|
||||||
mkdir -p ~/.config/opencode
|
mkdir -p ~/.config/opencode
|
||||||
# Playwright browser MCP only for agents that need to drive a web app
|
# Playwright browser MCP only for agents that need to drive a web app
|
||||||
|
|||||||
@@ -195,7 +195,31 @@ if [ "$MODE" != "pr" ]; then
|
|||||||
done < /tmp/subtasks.txt
|
done < /tmp/subtasks.txt
|
||||||
subtext=$(printf '\n\n---\nCreated sub-issues%s (mention an agent on each when ready):%b' "${ms:+ under milestone **$ms**}" "$links")
|
subtext=$(printf '\n\n---\nCreated sub-issues%s (mention an agent on each when ready):%b' "${ms:+ under milestone **$ms**}" "$links")
|
||||||
fi
|
fi
|
||||||
|
# DEDUP GUARD (issue: @pm double-posts its report). Prompt-level "do not self-post" is ignored
|
||||||
|
# by some models, so enforce it here: if the agent ALREADY posted a comment on this thread
|
||||||
|
# during the run (any comment by $NAME newer than the pre-run newest id from fetch-thread.sh),
|
||||||
|
# its self-post IS the reply — skip the duplicate framework comment. Markers (CLOSE_ISSUE,
|
||||||
|
# DELEGATE, MERGE_PR, subtasks) were already processed above and are unaffected.
|
||||||
|
# FAIL OPEN: if the pre-run marker is missing (fetch-thread hiccup), pre_cid=0 would make the
|
||||||
|
# agent's comments from PREVIOUS runs count as self-posts and wrongly suppress the reply.
|
||||||
|
# Without the marker, skip the guard and post normally.
|
||||||
|
pre_cid=$(cat /tmp/thread_max_cid 2>/dev/null || echo "")
|
||||||
|
selfposts=0
|
||||||
|
if [ -n "$pre_cid" ]; then
|
||||||
|
: > /tmp/all_comments.json
|
||||||
|
for pg in $(seq 1 10); do
|
||||||
|
cpg=$(curl -sS "${hdr[@]}" "$API/issues/$NUM/comments?limit=50&page=$pg" 2>/dev/null) || cpg='[]'
|
||||||
|
cn=$(printf '%s' "$cpg" | jq 'if type=="array" then length else 0 end' 2>/dev/null || echo 0)
|
||||||
|
[ "${cn:-0}" -gt 0 ] && printf '%s\n' "$cpg" >> /tmp/all_comments.json
|
||||||
|
[ "${cn:-0}" -lt 50 ] && break
|
||||||
|
done
|
||||||
|
selfposts=$(jq -rs --arg n "$NAME" --argjson c "${pre_cid:-0}" '[ (add // [])[] | select(.user.login==$n) | select(.id > $c) ] | length' /tmp/all_comments.json 2>/dev/null || echo 0)
|
||||||
|
fi
|
||||||
|
if [ "${selfposts:-0}" -gt 0 ]; then
|
||||||
|
echo "agent @$NAME already posted ${selfposts} comment(s) on #$NUM during this run — skipping duplicate framework reply"
|
||||||
|
else
|
||||||
post "$(printf '%s%s%s' "$msg" "$subtext" "$activity")"
|
post "$(printf '%s%s%s' "$msg" "$subtext" "$activity")"
|
||||||
|
fi
|
||||||
|
|
||||||
# --- @pm autopilot merge: @pm is the ONLY agent that merges, and ONLY under the autopilot label ---
|
# --- @pm autopilot merge: @pm is the ONLY agent that merges, and ONLY under the autopilot label ---
|
||||||
# (@qa never merges — it approves and hands back here.) Merge with the PAT (TTOK), not the built-in
|
# (@qa never merges — it approves and hands back here.) Merge with the PAT (TTOK), not the built-in
|
||||||
@@ -310,7 +334,14 @@ if [ -n "$(git status --porcelain)" ]; then
|
|||||||
git add -A
|
git add -A
|
||||||
git commit -m "@$NAME: issue #$NUM"
|
git commit -m "@$NAME: issue #$NUM"
|
||||||
fi
|
fi
|
||||||
git push origin "HEAD:$BRANCH" || true
|
if git push origin "HEAD:$BRANCH"; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
status=$?
|
||||||
|
echo "git push failed for $BRANCH (exit $status)"
|
||||||
|
post "$(printf '⚠️ Push to branch `%s` failed (git exit %s). The PR will not open until the push succeeds. Please check the Actions log.%s' "$BRANCH" "$status" "$activity")"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
git fetch -q origin 2>/dev/null || true
|
git fetch -q origin 2>/dev/null || true
|
||||||
|
|
||||||
prbody=$(printf '%s\n\n---\nResolves #%s' "$prdesc" "$NUM")
|
prbody=$(printf '%s\n\n---\nResolves #%s' "$prdesc" "$NUM")
|
||||||
@@ -336,14 +367,21 @@ url=$(printf '%s' "$resp" | jq -r '.html_url // empty' 2>/dev/null)
|
|||||||
prnum=$(printf '%s' "$resp" | jq -r '.number // empty' 2>/dev/null)
|
prnum=$(printf '%s' "$resp" | jq -r '.number // empty' 2>/dev/null)
|
||||||
if [ -z "$url" ]; then
|
if [ -z "$url" ]; then
|
||||||
title="@$NAME: $TITLE"
|
title="@$NAME: $TITLE"
|
||||||
resp=$(curl -sS -X POST "${hdr[@]}" "$API/pulls" \
|
resp_body=/tmp/pr_create_resp.json
|
||||||
|
http_status=$(curl -sS -o "$resp_body" -w '%{http_code}' -X POST "${hdr[@]}" "$API/pulls" \
|
||||||
-d "$(jq -nc --arg t "$title" --arg h "$br" --arg b "$prbody" \
|
-d "$(jq -nc --arg t "$title" --arg h "$br" --arg b "$prbody" \
|
||||||
'{title:$t, head:$h, base:"main", body:$b}')")
|
'{title:$t, head:$h, base:"main", body:$b}')")
|
||||||
echo "PR create ($br): $resp"
|
resp=$(cat "$resp_body" 2>/dev/null || true)
|
||||||
|
echo "PR create ($br): HTTP $http_status — $resp"
|
||||||
url=$(printf '%s' "$resp" | jq -r '.html_url // empty' 2>/dev/null)
|
url=$(printf '%s' "$resp" | jq -r '.html_url // empty' 2>/dev/null)
|
||||||
prnum=$(printf '%s' "$resp" | jq -r '.number // empty' 2>/dev/null)
|
prnum=$(printf '%s' "$resp" | jq -r '.number // empty' 2>/dev/null)
|
||||||
fi
|
fi
|
||||||
[ -z "$url" ] && { echo "PR open/lookup failed for $br — posting reply on issue instead"; post "$(printf '%s%s' "$reply" "$activity")"; exit 0; }
|
if [ -z "$url" ]; then
|
||||||
|
err_msg=$(printf '%s' "$resp" | jq -r 'if type=="object" and .message then .message else "(no error message in response)" end' 2>/dev/null)
|
||||||
|
echo "PR open/lookup failed for $br — HTTP $http_status — response: $resp"
|
||||||
|
post "$(printf '⚠️ Failed to open PR for branch `%s`.\n\nHTTP status: %s\nGitea message: %s%s' "$br" "$http_status" "$err_msg" "$activity")"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# Posts to the PR thread when we have a PR number, else to the origin issue ($NUM).
|
# Posts to the PR thread when we have a PR number, else to the origin issue ($NUM).
|
||||||
prpost() {
|
prpost() {
|
||||||
|
|||||||
@@ -149,6 +149,12 @@ ${LEARN}
|
|||||||
shown by Gitea. Do NOT begin your reply with your own name, an '@${NAME}' header, or a '🤖/🔨 @you'
|
shown by Gitea. Do NOT begin your reply with your own name, an '@${NAME}' header, or a '🤖/🔨 @you'
|
||||||
line; just write the content directly.
|
line; just write the content directly.
|
||||||
|
|
||||||
|
Do NOT use the gitea-api skill to post your reply, report, or any comment on THIS thread
|
||||||
|
yourself. The automation already posts your reply exactly once — self-posting it too is what
|
||||||
|
creates the duplicate comments you must avoid. On this thread, use gitea-api only to READ, or to
|
||||||
|
take an explicit action you were asked for (add/remove a label, close the issue, merge the PR).
|
||||||
|
Your report or answer IS your reply text — write it as your reply; do not post it via the API.
|
||||||
|
|
||||||
TEAM ROSTER (who does what — hand off if a task isn't yours):
|
TEAM ROSTER (who does what — hand off if a task isn't yours):
|
||||||
${ROSTER}
|
${ROSTER}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user