Skip to content

Commit 91157cb

Browse files
committed
Add GitHub Copilot coding agent integration
- add support for github copilot cli - assess correctness of `apps/editor/src/utils/agentic-cli-invocation/agents/copilot.ts`implementation. [Website] └── apps └── editor └── src ├── constants │ └── agents.ts └── utils └── agentic-cli-invocation ├── agents │ ├── antigravity.ts │ ├── claude.ts │ ├── codex.ts │ ├── copilot.ts │ ├── cursor.ts │ ├── devin.ts │ ├── grok.ts │ ├── index.ts │ └── opencode.ts ├── index.ts ├── invoke-agentic-cli.ts ├── types.ts └── utils ├── check-command-exists.ts ├── format-duration.ts ├── generate-diff-markdown.ts └── get-progress-dots.ts
1 parent 70341c3 commit 91157cb

3 files changed

Lines changed: 115 additions & 0 deletions

File tree

‎apps/editor/src/constants/agents.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@ export const AGENTS = {
8888
flags_placeholder: '',
8989
example_flags: []
9090
},
91+
'GitHub Copilot': {
92+
docs_url:
93+
'https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference',
94+
homepage_url: 'https://github.com/features/copilot',
95+
flags_placeholder: '--model claude-sonnet-5.5 --effort medium',
96+
example_flags: [
97+
'--model claude-opus-5.5 --effort high',
98+
'--model claude-sonnet-5.5 --effort medium',
99+
'--model claude-haiku-5.5 --effort low',
100+
'--model gpt-6.1-sol --effort high'
101+
]
102+
},
91103
'Grok Build': {
92104
docs_url: 'https://docs.x.ai/build/cli/headless-scripting',
93105
homepage_url: 'https://x.ai/build',
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import * as os from 'os'
2+
import { CodingAgent } from '../types'
3+
import { check_command_exists } from '../utils/check-command-exists'
4+
import { get_progress_dots } from '../utils/get-progress-dots'
5+
import { AGENTS } from '../../../constants/agents'
6+
7+
let last_action_name = ''
8+
let action_count = 0
9+
const delta_buffers = new Map<string, string>()
10+
11+
const agent_name = 'GitHub Copilot'
12+
13+
export const copilot_agent: CodingAgent = {
14+
id: 'copilot',
15+
label: agent_name,
16+
cmd: 'copilot',
17+
is_installed: () => check_command_exists('copilot'),
18+
get_documentation_url: () => AGENTS[agent_name].docs_url,
19+
get_headless_args: () => {
20+
last_action_name = ''
21+
action_count = 0
22+
delta_buffers.clear()
23+
return ['--allow-all', '--no-ask-user', '--output-format', 'json']
24+
},
25+
get_integrated_terminal_edit_args: () => ['--allow-all'],
26+
get_integrated_terminal_ask_args: () => [],
27+
get_integrated_terminal_prompt_args: (temp_prompt_path: string) => {
28+
if (os.platform() === 'win32') {
29+
return `"-i" "$(Get-Content -Raw '${temp_prompt_path.replace(/'/g, "''")}')"`
30+
}
31+
return `'-i' "$(cat '${temp_prompt_path.replace(/'/g, "'\\''")}')"`
32+
},
33+
parse_stream_line: (parsed, report_progress) => {
34+
if (parsed.type === 'tool.execution_start' && parsed.data?.toolName) {
35+
const action_name = parsed.data.toolName.replace(/_/g, ' ').toLowerCase()
36+
37+
if (action_name === last_action_name) {
38+
action_count++
39+
} else {
40+
last_action_name = action_name
41+
action_count = 1
42+
}
43+
44+
report_progress(`${action_name}${get_progress_dots(action_count)}`)
45+
} else if (
46+
parsed.type === 'assistant.message_delta' &&
47+
parsed.data?.deltaContent
48+
) {
49+
const message_id = parsed.data.messageId || 'default'
50+
const updated =
51+
(delta_buffers.get(message_id) || '') + parsed.data.deltaContent
52+
delta_buffers.set(message_id, updated)
53+
return { output: updated }
54+
} else if (parsed.type === 'assistant.message') {
55+
if (parsed.data?.messageId) {
56+
delta_buffers.delete(parsed.data.messageId)
57+
}
58+
if (parsed.data?.content) {
59+
return { output: parsed.data.content }
60+
}
61+
} else if (parsed.type === 'session.error' && parsed.data?.message) {
62+
return { output: parsed.data.message }
63+
} else if (parsed.type === 'result') {
64+
last_action_name = ''
65+
action_count = 0
66+
if (parsed.result) {
67+
const text =
68+
typeof parsed.result === 'string'
69+
? parsed.result
70+
: parsed.result.text || parsed.result.response || ''
71+
if (text) {
72+
return { output: text }
73+
}
74+
}
75+
} else if (parsed.type === 'session.idle') {
76+
last_action_name = ''
77+
action_count = 0
78+
}
79+
},
80+
parse_final_output: (parsed, current_output) => {
81+
last_action_name = ''
82+
action_count = 0
83+
84+
if (parsed.type === 'assistant.message' && parsed.data?.content) {
85+
return parsed.data.content
86+
} else if (
87+
parsed.type === 'session.error' &&
88+
parsed.data?.message &&
89+
!current_output
90+
) {
91+
return parsed.data.message
92+
} else if (parsed.type === 'result' && parsed.result) {
93+
const text =
94+
typeof parsed.result === 'string'
95+
? parsed.result
96+
: parsed.result.text || parsed.result.response || ''
97+
return text || current_output
98+
}
99+
return current_output
100+
}
101+
}

‎apps/editor/src/utils/agentic-cli-invocation/agents/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { antigravity_agent } from './antigravity'
22
import { claude_agent } from './claude'
33
import { codex_agent } from './codex'
4+
import { copilot_agent } from './copilot'
45
import { cursor_agent } from './cursor'
56
import { devin_agent } from './devin'
67
import { opencode_agent } from './opencode'
@@ -10,6 +11,7 @@ export const CLI_AGENTS = [
1011
antigravity_agent,
1112
codex_agent,
1213
claude_agent,
14+
copilot_agent,
1315
cursor_agent,
1416
devin_agent,
1517
grok_agent,

0 commit comments

Comments
 (0)