feat(agents): add copilot adapter#128
Conversation
Greptile SummaryAdds the GitHub Copilot CLI agent adapter: a new
Confidence Score: 4/5Safe to merge with one fix: the local atomicWriteFile in hooks.go is missing a Sync call, which weakens its crash-safety guarantee relative to the shared hookutil version. The adapter is well-structured and thoroughly tested. The one issue is that the local atomicWriteFile in copilot/hooks.go omits the tmp.Sync() step that hookutil.AtomicWriteFile includes, meaning a crash after Close() but before the OS flushes buffers could corrupt the hooks file and silently disable all Copilot hooks. The fix is a one-liner and the rest of the adapter is clean. backend/internal/adapters/agent/copilot/hooks.go — the atomicWriteFile implementation needs a Sync call to match the shared hookutil version. Important Files Changed
Sequence DiagramsequenceDiagram
participant AO as AO Daemon
participant Plugin as copilot.Plugin
participant FS as Filesystem
participant Copilot as Copilot CLI
AO->>Plugin: GetAgentHooks(cfg)
Plugin->>FS: readCopilotHooks(.github/hooks/ao.json)
FS-->>Plugin: copilotHookFile (or empty)
Plugin->>Plugin: merge copilotManagedHooks (idempotent)
Plugin->>FS: atomicWriteFile (tmp → rename)
FS-->>Plugin: ok
AO->>Plugin: GetLaunchCommand(cfg)
Plugin->>Plugin: copilotBinary() [resolve once, cache]
Plugin-->>AO: ["copilot", "--allow-all-tools", "-p", prompt]
AO->>Copilot: exec(launch command)
Copilot-->>FS: fires sessionStart hook
FS->>AO: ao hooks copilot session-start → ActivityActive
Copilot-->>FS: fires permissionRequest hook
FS->>AO: ao hooks copilot permission-request → ActivityWaitingInput
Copilot-->>FS: fires agentStop hook
FS->>AO: ao hooks copilot stop → ActivityIdle
AO->>Plugin: GetRestoreCommand(cfg)
Plugin-->>AO: ["copilot", "--allow-all-tools", "--resume", agentSessionID]
AO->>Copilot: exec(restore command)
Reviews (2): Last reviewed commit: "feat(agents): add copilot adapter" | Re-trigger Greptile |
Registers the copilot harness, stacked on the agent platform. Includes its own activity deriver. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
There was a problem hiding this comment.
yyovil has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
Copilot CLI does not document a "permissionRequest" hook event. Per https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/use-hooks the documented camelCase events are sessionStart, sessionEnd, userPromptSubmitted, preToolUse, postToolUse, errorOccurred, agentStop. Writing "permissionRequest" into .github/hooks/ao.json silently disables that hook because Copilot does not recognize the key. Remap AO's permission-request sub-command onto preToolUse (the closest documented signal — fires before any tool invocation, including ones that would prompt for approval) and add a tripwire test asserting the JSON keys AO writes match the documented camelCase names. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
yyovil has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
Verified upstream Copilot CLI docs and pushed one fix. Findings re-verified against upstream docs
Changes (f1f540d)
Validation
Pushed with |
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
yyovil has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
* feat(agents): add grok adapter Registers the grok harness (xAI Grok CLI). grok installs Claude Code-compatible hooks, so it reuses the claude-code activity deriver already in the platform. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(agents): add cursor adapter Registers the cursor harness, stacked on the agent platform. Includes its own activity deriver. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(agents): add qwen adapter Registers the qwen harness, stacked on the agent platform. Includes its own activity deriver. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(agents): add copilot adapter (#128) * feat(agents): add copilot adapter Registers the copilot harness, stacked on the agent platform. Includes its own activity deriver. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Update backend/internal/adapters/agent/copilot/hooks.go Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * fix(copilot): map permission-request to documented preToolUse event Copilot CLI does not document a "permissionRequest" hook event. Per https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/use-hooks the documented camelCase events are sessionStart, sessionEnd, userPromptSubmitted, preToolUse, postToolUse, errorOccurred, agentStop. Writing "permissionRequest" into .github/hooks/ao.json silently disables that hook because Copilot does not recognize the key. Remap AO's permission-request sub-command onto preToolUse (the closest documented signal — fires before any tool invocation, including ones that would prompt for approval) and add a tripwire test asserting the JSON keys AO writes match the documented camelCase names. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * chore(copilot): gofmt the new tripwire test Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Harshit Singh Bhandari <dev@theharshitsingh.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Co-authored-by: harshitsinghbhandari <24b4506@iitb.ac.in> * feat(agents): add kimi adapter Registers the kimi harness, stacked on the agent platform. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(agents/kimi): drop approval flags on -p and --session paths Kimi rejects `--prompt` combined with `--yolo`/`--auto`/`--plan`, and rejects `--yolo`/`--auto` combined with `--session`/`--continue` (non-interactive and resumed sessions inherit the auto permission policy). The previous mapping appended one of those flags before `-p` on every launch and before `--session` on every restore, so every non-interactive launch would fail at startup. The local binary (v1.37.0) additionally has no `--auto` option at all, which would fail even on otherwise-permissible paths. - GetLaunchCommand: emit approval flags only on the interactive path (no prompt). The `-p <prompt>` path is now bare. - GetRestoreCommand: never emit approval flags; resumed sessions inherit the original session's approval settings. - Tests assert no approval/plan flag leaks onto either path for any PermissionMode, and keep the interactive mapping unchanged. Refs: https://moonshotai.github.io/kimi-code/en/reference/kimi-command.html * fix(agents/qwen): sync hook settings temp file * fix(agents/grok): delegate hook cleanup lifecycle --------- Co-authored-by: yyovil <itsyyovil@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Adds the copilot harness, stacked on #119 (agent platform). Adapter package +
Constructors()registration + resolver test. Includes its own activity deriver.🤖 Generated with Claude Code
Stack