diff --git a/.gitea/workflows/agent.yml b/.gitea/workflows/agent.yml index d395dbd..0d41bc1 100644 --- a/.gitea/workflows/agent.yml +++ b/.gitea/workflows/agent.yml @@ -56,7 +56,11 @@ jobs: SCRIPTS: ${{ github.workspace }}/.agents-workflow/.gitea/workflows/scripts BODY: ${{ github.event.comment.body }} # event text via env, never inline in shell IBODY: ${{ github.event.issue.body }} - EVENT: ${{ github.event_name }} + # Comment-vs-issue discriminator. Do NOT use github.event_name here: this is a REUSABLE + # (workflow_call) workflow, so on Gitea event_name is 'workflow_call', not the original + # 'issues'/'issue_comment'. The comment id, however, is reliably present in the forwarded + # payload — empty on an issue-opened event, set on a comment event. + CID: ${{ github.event.comment.id }} IS_PR: ${{ github.event.issue.pull_request }} NUM: ${{ github.event.issue.number }} GT: ${{ secrets.GITEA_TOKEN }} diff --git a/.gitea/workflows/scripts/route.sh b/.gitea/workflows/scripts/route.sh index 482620b..7237d46 100755 --- a/.gitea/workflows/scripts/route.sh +++ b/.gitea/workflows/scripts/route.sh @@ -4,7 +4,7 @@ # /tmp/agents.json, picks which agent to run, emits step outputs (name/model/vision/mode/branch/new) # to $GITHUB_OUTPUT, configures git identity, and prepares/publishes the working branch. # -# Required env (all provided by the workflow step): BODY IBODY EVENT IS_PR NUM GT +# Required env (all provided by the workflow step): BODY IBODY CID IS_PR NUM GT # TOKEN_PM TOKEN_SENIOR TOKEN_JUNIOR TOKEN_LEAD TOKEN_QA # GITHUB_SERVER_URL GITHUB_REPOSITORY GITHUB_OUTPUT set -eu @@ -26,13 +26,15 @@ cat > /tmp/agents.json <<'JSON' } JSON # On a new issue, @pm auto-assesses. On a comment, route by the @mention. -scan="$BODY"; [ "$EVENT" = "issues" ] && scan="$IBODY" +# A comment event has a comment id (CID); an issue-opened event does not. (event_name is unreliable +# here — see agent.yml: this reusable workflow sees it as 'workflow_call'.) +if [ -n "$CID" ]; then scan="$BODY"; else scan="$IBODY"; fi name="" for a in pm junior senior lead qa; do case "$scan" in *"@$a"*) name=$a; break;; esac done if [ -z "$name" ]; then - if [ "$EVENT" = "issues" ]; then name=pm; else echo "no known agent mentioned"; exit 1; fi + if [ -z "$CID" ]; then name=pm; else echo "no known agent mentioned"; exit 1; fi fi model=$(jq -r --arg a "$name" '.[$a].model' /tmp/agents.json) vision=$(jq -r --arg a "$name" '.[$a].vision' /tmp/agents.json) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env