Repository navigation
feat: add GitHub Copilot CLI agent adapter - #15
Merged
Merged
Conversation
Adds CopilotAdapter for the standalone `copilot` binary (npm @github/copilot, GA since Feb 2026) -- not the retired `gh copilot` extension, which now just shells out to this same binary. Flags verified against a real `copilot --help` (v1.0.86) and against a real end-to-end `secfoo run --skill sast --agent copilot` invocation, not just docs (the pre-GA extension used different flags entirely, and these change often). Also fixes report/markdown.py's strip_preamble(): it assumed every agent emits a literal top-level "# <Skill> Report" heading to anchor on, but real testing against Copilot CLI found it unpromptedly runs its own native security-scan tool first (an unrelated "##"/"###" preamble) and then never emits that single top-level heading at all, so the anchor search found nothing and left the whole duplicated block in the stored report. Adds a fallback anchor on "## 1. Executive Summary" -- every skill's contract requires that as its first numbered section regardless of agent, so it's a safe backstop that doesn't change behavior for any already-compliant agent. Verified against the actual captured Copilot report: 713 lines down to 281, landing exactly on the real content. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…atch The fallback added for the copilot adapter matched any "## 1. <text>" heading, not specifically "## 1. Executive Summary". That's too loose: a preamble that numbers its own unrelated section "1." (a plan, a to-do list) would get matched instead of the real report, cutting to that wrong, earlier point instead of skipping the preamble entirely. Tightens the regex to the literal "## 1. Executive Summary" text -- every skill's contract requires that exact phrase (skills/renderer.py), so it's no less general, just no longer over-matching. Adds a regression test for the false-positive this closes, and re-verified against both real captured Copilot reports from earlier end-to-end testing to confirm the actual fix still works. Co-Authored-By: Claude Sonnet 5 <[email protected]>
5 tasks done
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this change, and why?
Adds
CopilotAdapterfor the GitHub Copilot CLI (Initiative 1 of the Q4 sprint plan) — the standalonecopilotbinary (npm@github/copilot, GA since Feb 2026), not the retiredgh copilotGitHub CLI extension, which is now just a thin wrapper around this same binary.Flags were verified against a real installed
copilot --help(v1.0.86), not just docs — the CLI ships updates often and flags have already drifted once (the pre-GA extension used a different flag set entirely).--allow-all-toolsis required for non-interactive mode per the CLI's own--helptext; deliberately does not pass the broader--allow-all/--yolo/--allow-all-paths/--allow-all-urls, matching the minimal-grant pattern the other adapters already use.A real, verified quirk, and the fix that goes with it
Real end-to-end testing (
secfoo run --agent copilotagainst a live target, run twice, two different skills) surfaced a genuine behavior: Copilot CLI unpromptedly runs its own native security-scanning tool first — emitting an unrelated##/###preamble — before going on to produce the skill's actual requested report, and never writes the required top-level# <Skill> Reportheading at all.report/markdown.py'sstrip_preamble()only knew how to anchor on that heading, so it found nothing and left the whole duplicated block in the stored report (roughly 2x the expected length, confirmed on captured real output — 713 lines down to the real 281).Fixed by adding a fallback anchor on the literal
## 1. Executive Summarytext — every skill's contract requires that exact phrase as its first numbered section (skills/renderer.py), so it's a safe, skill-agnostic backstop that never fires for an already-compliant agent (the primary heading anchor always wins when both are present). The fallback was deliberately made an exact match rather than "any numbered section 1" after finding that a looser version would wrongly match an unrelated preamble that numbers its own "1." section (e.g. a to-do list) — verified with a regression test for that specific false positive.Both fixes were re-verified against the actual captured Copilot output from real runs, not just synthetic test strings.
Known follow-up, intentionally not addressed here
Real testing also surfaced a pre-existing, agent-agnostic risk in
runner.py/storage/repository.py: if any agent's SAST report ever parses to zero findings (a malformed/incomplete answer, not necessarily Copilot-specific — reproduced the same way with aclaude-labeled run too),close_stale_sast_findings()has no way to distinguish "genuinely clean rescan" from "couldn't parse the report," and silently marks every previously-open finding for that project as closed. Verified end-to-end: a real, still-open SQL injection finding flipped toclosedfrom a malformed report with zero code changes needed to trigger it. This is out of scope for an adapter PR (it's shared lifecycle-tracking logic, not agent-specific), but flagging it here since Copilot's demonstrated unpredictability makes it materially more likely to trigger than with the steadier existing agents — worth its own issue/fix.Testing
pytest testspasses (643 passed)ruff checkclean on every new/changed filesecfoo run --skill sast --agent copilotandsecfoo run --skill sast --skill secret-scanning --agent copilot, both against a live GitHub target, from a clean checkout of this exact branch (not just the dev working tree)is_available()verified as genuine black-box behavior (PATH stripped of the binary →no), not just mockedtests/test_agents/test_copilot.py(8 tests),tests/test_report/test_markdown.py(3 new tests covering the fallback and its false-positive fix)🤖 Generated with Claude Code