Skip to content

Commit 3e609fc

Browse files
authored
Feat: Add github copilot cli backend (#2)
* add github copilot cli backend * update README * add history
1 parent bc69a0c commit 3e609fc

File tree

6 files changed

+66
-2
lines changed

6 files changed

+66
-2
lines changed

HISTORY.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
** Main branch change
55

66
- Feat: add resume functionality for CLI sessions across backends, by ileixe
7+
- Feat: add support for OpenAI Codex CLI backend, by tninja

README.org

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ An Emacs interface for AI-assisted software development. *The purpose is to prov
66
- [[https://github.com/anthropics/claude-code][Claude Code]]
77
- [[https://github.com/google-gemini/gemini-cli][Gemini CLI]]
88
- [[https://github.com/openai/codex][OpenAI Codex]]
9+
- [[https://docs.github.com/en/copilot/how-tos/use-copilot-agents/use-copilot-cli][GitHub Copilot CLI]]
910

1011
- I switch across different CLI based AI tool in emacs: Claude Code / Gemini CLI / Aider / OpenAI Codex. If you also use different AI tools inside emacs, but want to keep same user interface and experience, this package is for you.
1112

@@ -45,6 +46,7 @@ An Emacs interface for AI-assisted software development. *The purpose is to prov
4546
- Claude Code IDE (`[[https://github.com/manzaltu/claude-code-ide.el][claude-code-ide.el]]`)
4647
- Gemini CLI (`[[https://github.com/linchen2chris/gemini-cli.el][gemini-cli.el]]`)
4748
- [[https://github.com/openai/codex][OpenAI codex CLI]] (`[[./ai-code-codex-cli.el][ai-code-codex-cli.el]]`)
49+
- [[https://docs.github.com/en/copilot/how-tos/use-copilot-agents/use-copilot-cli][GitHub Copilot CLI]] (`[[./ai-code-github-copilot-cli.el][ai-code-github-copilot-cli.el]]`)
4850

4951
You can add other backends by customizing the `ai-code-backends` variable.
5052

ai-code-backends.el

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@
5252
:resume nil
5353
:config "~/.gemini/settings.json"
5454
:cli "gemini")
55+
(github-copilot-cli
56+
:label "ai-code-github-copilot-cli.el"
57+
:require ai-code-github-copilot-cli
58+
:start github-copilot-cli
59+
:switch github-copilot-cli-switch-to-buffer
60+
:send github-copilot-cli-send-command
61+
:resume nil
62+
:config "~/.config/mcp-config.json" ;; https://docs.github.com/en/copilot/how-tos/use-copilot-agents/use-copilot-cli
63+
:cli "copilot")
5564
(codex
5665
:label "ai-code-codex-cli.el"
5766
:require ai-code-codex-cli

ai-code-codex-cli.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
(interactive "sCodex> ")
4343
(claude-code-send-command line))
4444

45-
4645
;;;###autoload
4746
(defun codex-cli-resume (&optional arg)
4847
"Resume a previous Codex CLI session."
@@ -53,6 +52,7 @@
5352
(claude-code--term-send-string claude-code-terminal-backend "")
5453
(with-current-buffer claude-code-terminal-backend
5554
(goto-char (point-min)))))
55+
5656
(provide 'ai-code-codex-cli)
5757

5858
;;; ai-code-codex-cli.el ends here

ai-code-github-copilot-cli.el

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
;;; ai-code-github-copilot-cli.el --- Thin wrapper for Github Copilot CLI -*- lexical-binding: t; -*-
2+
3+
;;; Commentary:
4+
;;
5+
;; Thin wrapper that reuses `claude-code' to run Github Copilot CLI.
6+
;; Provides interactive commands and aliases for the AI Code suite.
7+
;;
8+
;;; Code:
9+
10+
(require 'claude-code)
11+
12+
(defvar claude-code-program)
13+
(defvar claude-code-program-switches)
14+
(declare-function claude-code "claude-code" (&optional arg extra-switches force-prompt force-switch-to-buffer))
15+
(declare-function claude-code-resume "claude-code" (&optional arg))
16+
(declare-function claude-code-switch-to-buffer "claude-code" (&optional arg))
17+
(declare-function claude-code-send-command "claude-code" (line))
18+
19+
20+
(defgroup ai-code-github-copilot-cli nil
21+
"Github Copilot CLI integration via `claude-code'."
22+
:group 'tools
23+
:prefix "github-copilot-cli-")
24+
25+
(defcustom github-copilot-cli-program "copilot"
26+
"Path to the Github Copilot CLI executable."
27+
:type 'string
28+
:group 'ai-code-github-copilot-cli)
29+
30+
;;;###autoload
31+
(defun github-copilot-cli (&optional arg)
32+
"Start Github Copilot CLI (reuses `claude-code' startup logic)."
33+
(interactive "P")
34+
(let ((claude-code-program github-copilot-cli-program) ; override dynamically
35+
(claude-code-program-switches nil)) ; optional e.g.: '("exec" "--non-interactive")
36+
(claude-code arg)))
37+
38+
;;;###autoload
39+
(defun github-copilot-cli-switch-to-buffer ()
40+
(interactive)
41+
(claude-code-switch-to-buffer))
42+
43+
;;;###autoload
44+
(defun github-copilot-cli-send-command (line)
45+
(interactive "sCopilot> ")
46+
(claude-code-send-command line))
47+
48+
(provide 'ai-code-github-copilot-cli)
49+
50+
;;; ai-code-github-copilot-cli.el ends here

ai-code-interface.el

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
;;; ai-code-interface.el --- AI code interface for editing AI prompt files -*- lexical-binding: t; -*-
22

33
;; Author: Kang Tu <tninja@gmail.com>
4-
;; Version: 0.16
4+
;; Version: 0.20
55
;; Package-Requires: ((emacs "26.1") (transient "0.8.0") (magit "2.1.0"))
66

77
;; SPDX-License-Identifier: Apache-2.0
@@ -24,6 +24,8 @@
2424
(require 'ai-code-git)
2525
(require 'ai-code-change)
2626
(require 'ai-code-discussion)
27+
(require 'ai-code-codex-cli)
28+
(require 'ai-code-github-copilot-cli)
2729

2830
;; Forward declarations for dynamically defined backend functions
2931
(declare-function ai-code-cli-start "ai-code-backends")

0 commit comments

Comments
 (0)