From caaa3becef21ffd556e5eb090e1257057f1fc7cc Mon Sep 17 00:00:00 2001 From: Grant Horner Date: Fri, 9 Jan 2026 15:50:23 -0500 Subject: [PATCH] add copilot support --- codex.el | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/codex.el b/codex.el index be140f8..769ecd0 100644 --- a/codex.el +++ b/codex.el @@ -71,6 +71,17 @@ :group 'codex) (defvar codex--session-id nil) +(defvar codex--use-copilot nil + "In order for copilot integration to work, you need a section in your +~/.codex/config.toml like this: +[model_providers.github-copilot] +name = \"Github Copilot\" +base_url = \"https://api.githubcopilot.com\" +env_key = \"GITHUB_COPILOT_TOKEN\" +wire_api = \"chat\" +http_headers = { + Copilot-Integration-Id = \"vscode-chat\" +}") (defvar codex-mode-map (let ((map (make-sparse-keymap))) @@ -208,12 +219,14 @@ :name "codex" :buffer buf :command - (let ((resume (when (and codex--session-id (not (string-empty-p codex--session-id))) - (progn - (message "Using session %s" codex--session-id) - (list "resume" codex--session-id)))) - (skip (and codex-skip-git-repo-check (list "--skip-git-repo-check")))) - (append (list codex-command "exec") resume skip (list "--json" prompt)))))) + (let* ((resume (when (and codex--session-id (not (string-empty-p codex--session-id))) + (progn + (message "Using session %s" codex--session-id) + (list "resume" codex--session-id)))) + (skip (and codex-skip-git-repo-check (list "--skip-git-repo-check"))) + (copilot (and codex--use-copilot (list "-c" "model_provider=github-copilot" "-m" "claude-haiku-4.5"))) + (command (append (list codex-command "exec") resume skip copilot (list "--json" prompt)))) + command)))) (set-process-sentinel proc (lambda (p event)