Add @app/copilot-swe-agent as a copilot bot alias#34136
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot centralize all the bot aliases in constants.go (there's definitely another place with copilot bot aliases) |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in the latest commit. |
|
@copilot unify CopilotBotAliases and CopilotBotNames into a single list |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done. |
There was a problem hiding this comment.
Pull request overview
This PR aims to recognize @app/copilot-swe-agent as a valid Copilot bot alias so that workflows specifying it in on.bots/on.skip-bots get expanded to the full Copilot bot allowlist used by the compiled workflow’s permission checks.
Changes:
- Introduces
pkg/constants.CopilotBotNamesto centralize the Copilot-related identifiers. - Updates bot expansion logic to expand Copilot-related entries when compiling workflow bot allowlists.
- Extends tests to cover
@app/copilot-swe-agentscenarios and compiled workflow output.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/bots_test.go | Updates compiled-workflow assertion for Copilot bot allowlist expansion. |
| pkg/workflow/bot_aliases.go | Reworks Copilot bot expansion logic to use a constant-backed lookup set. |
| pkg/workflow/bot_aliases_test.go | Adds/updates unit tests for new Copilot alias expansion behavior. |
| pkg/constants/bot_constants.go | Adds a canonical Copilot identifier list used by expansion logic. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 5
| // expandBotNames expands any entry found in constants.CopilotBotNames to the | ||
| // full set of Copilot identifiers. Other entries are passed through unchanged. | ||
| // Duplicates are removed from the result. |
| // copilotBotSet is a fast-lookup set built from constants.CopilotBotNames. | ||
| // Any entry in this set triggers expansion to the full CopilotBotNames list. | ||
| var copilotBotSet = func() map[string]bool { | ||
| set := make(map[string]bool, len(constants.CopilotBotNames)) | ||
| for _, name := range constants.CopilotBotNames { | ||
| set[name] = true | ||
| } | ||
| return set | ||
| }() |
| // CopilotBotNames is the canonical list of all GitHub identifiers associated | ||
| // with the Copilot family — both runtime bot logins and recognized input aliases. | ||
| // When any entry from this list appears in a workflow's bots field, it is | ||
| // expanded to the entire set: | ||
| // | ||
| // - "copilot-swe-agent" — Copilot Coding Agent runtime login (actor: copilot-swe-agent[bot]) | ||
| // - "Copilot" — @Copilot interactive bot (actor: Copilot) | ||
| // - "copilot" — base copilot bot form + canonical shorthand alias (actor: copilot[bot]) | ||
| // - "@app/copilot-swe-agent" — GitHub App slug alias for the Copilot Coding Agent | ||
| var CopilotBotNames = []string{ | ||
| "copilot-swe-agent", | ||
| "Copilot", | ||
| "copilot", |
| { | ||
| name: "copilot-swe-agent expands to all copilot bot names", | ||
| input: []string{"copilot-swe-agent"}, | ||
| expected: []string{"copilot-swe-agent", "Copilot", "copilot", "@app/copilot-swe-agent"}, | ||
| }, |
| // The "copilot" alias must be expanded to all Copilot bot identities | ||
| assert.Contains(t, lockStr, `GH_AW_ALLOWED_BOTS: "copilot-swe-agent,Copilot,copilot,@app/copilot-swe-agent"`, | ||
| `Expected compiled workflow to expand "copilot" alias to all Copilot bot identifiers`) |
@app/copilot-swe-agentis a valid GitHub App slug for the Copilot Coding Agent but wasn't recognized as a copilot alias — users specifying it in a bot list got no expansion.Changes
pkg/workflow/bot_aliases.go: Replaced the hardcodedb == "copilot"string check with acopilotAliasesmap that includes both"copilot"and"@app/copilot-swe-agent". Both aliases now expand to the samecopilotBotNamesset.pkg/workflow/bot_aliases_test.go: Added cases for@app/copilot-swe-agentstandalone, mixed with other bots, and combined withcopilot(deduplication).