From 81aee2818cae958b9d70ce9857b15adb48ac1439 Mon Sep 17 00:00:00 2001 From: illidan127 Date: Mon, 30 Mar 2026 19:57:59 +0800 Subject: [PATCH 1/2] Add CodeBuddy agent support --- README.org | 12 ++++- agent-shell-codebuddy.el | 113 +++++++++++++++++++++++++++++++++++++++ agent-shell.el | 8 ++- 3 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 agent-shell-codebuddy.el diff --git a/README.org b/README.org index 91add92..3edb86c 100644 --- a/README.org +++ b/README.org @@ -93,6 +93,15 @@ npm install -g @blowmage/cursor-agent-acp See https://github.com/blowmage/cursor-agent-acp-npm for details. +*** CodeBuddy + +For CodeBuddy agent, install the CodeBuddy CLI and ensure ACP mode is available. +For example: + +#+begin_src bash +codebuddy --acp +#+end_src + *** Kiro CLI For Kiro CLI, install with: @@ -394,7 +403,7 @@ For API key authentication: *** Customizing Available Agents -By default, =agent-shell= includes configurations for all supported agents (Claude Agent, Gemini CLI, Codex, Goose, Qwen Code, and Auggie). You can customize which agents are available through the =agent-shell-agent-configs= variable. +By default, =agent-shell= includes configurations for all supported agents (Claude Agent, Gemini CLI, Codex, Goose, Cursor, CodeBuddy, Qwen Code, and Auggie). You can customize which agents are available through the =agent-shell-agent-configs= variable. ** Usage @@ -410,6 +419,7 @@ Start a specific agent shell session directly: - =M-x agent-shell-anthropic-start-claude-code= - Start a Claude Agent session - =M-x agent-shell-auggie-start-agent= - Start an Auggie agent session +- =M-x agent-shell-codebuddy-start-agent= - Start a CodeBuddy agent session - =M-x agent-shell-openai-start-codex= - Start a Codex agent session - =M-x agent-shell-google-start-gemini= - Start a Gemini agent session - =M-x agent-shell-goose-start-agent= - Start a Goose agent session diff --git a/agent-shell-codebuddy.el b/agent-shell-codebuddy.el new file mode 100644 index 0000000..262f80b --- /dev/null +++ b/agent-shell-codebuddy.el @@ -0,0 +1,113 @@ +;;; agent-shell-codebuddy.el --- CodeBuddy agent configurations -*- lexical-binding: t; -*- + +;; Copyright (C) 2024 Alvaro Ramirez + +;; Author: Alvaro Ramirez https://xenodium.com +;; URL: https://github.com/xenodium/agent-shell + +;; This package is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; This package is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: +;; +;; This file includes CodeBuddy-specific configurations. +;; + +;;; Code: + +(eval-when-compile + (require 'cl-lib)) +(require 'shell-maker) +(require 'acp) + +(declare-function agent-shell--indent-string "agent-shell") +(declare-function agent-shell-make-agent-config "agent-shell") +(autoload 'agent-shell-make-agent-config "agent-shell") +(declare-function agent-shell--make-acp-client "agent-shell") +(declare-function agent-shell--dwim "agent-shell") + +(defcustom agent-shell-codebuddy-acp-command + '("codebuddy" "--acp") + "Command and parameters for the CodeBuddy agent client. + +The first element is the command name, and the rest are command parameters." + :type '(repeat string) + :group 'agent-shell) + +(defcustom agent-shell-codebuddy-environment + nil + "Environment variables for the CodeBuddy agent client. + +This should be a list of environment variables to be used when +starting the CodeBuddy agent process." + :type '(repeat string) + :group 'agent-shell) + +(defun agent-shell-codebuddy-make-agent-config () + "Create a CodeBuddy agent configuration. + +Returns an agent configuration alist using `agent-shell-make-agent-config'." + (agent-shell-make-agent-config + :identifier 'codebuddy + :mode-line-name "CodeBuddy" + :buffer-name "CodeBuddy" + :shell-prompt "CodeBuddy> " + :shell-prompt-regexp "CodeBuddy> " + :icon-name "codebuddy.png" + :welcome-function #'agent-shell-codebuddy--welcome-message + :client-maker (lambda (buffer) + (agent-shell-codebuddy-make-client :buffer buffer)) + :install-instructions "Install the CodeBuddy CLI and ensure it supports ACP mode (for example, `codebuddy --acp`).")) + +(defun agent-shell-codebuddy-start-agent () + "Start an interactive CodeBuddy agent shell." + (interactive) + (agent-shell--dwim :config (agent-shell-codebuddy-make-agent-config) + :new-shell t)) + +(cl-defun agent-shell-codebuddy-make-client (&key buffer) + "Create a CodeBuddy agent ACP client with BUFFER as context." + (unless buffer + (error "Missing required argument: :buffer")) + (agent-shell--make-acp-client :command (car agent-shell-codebuddy-acp-command) + :command-params (cdr agent-shell-codebuddy-acp-command) + :environment-variables agent-shell-codebuddy-environment + :context-buffer buffer)) + +(defun agent-shell-codebuddy--welcome-message (config) + "Return CodeBuddy welcome message using `shell-maker' CONFIG." + (let ((art (agent-shell--indent-string 4 (agent-shell-codebuddy--ascii-art))) + (message (string-trim-left (shell-maker-welcome-message config) "\n"))) + (concat "\n\n" + art + "\n\n" + message))) + +(defun agent-shell-codebuddy--ascii-art () + "CodeBuddy ASCII art." + (let* ((is-dark (eq (frame-parameter nil 'background-mode) 'dark)) + (text (string-trim " + ______ __ ____ __ __ + / ____/___ ____/ /__ / __ )__ ______/ /___/ /_ __ + / / / __ \/ __ / _ \/ __ / / / / __ / __ / / / / +/ /___/ /_/ / /_/ / __/ /_/ / /_/ / /_/ / /_/ / /_/ / +\____/\____/\__,_/\___/_____/\__,_/\__,_/\__,_/\__, / + /____/ +" "\n"))) + (propertize text 'font-lock-face (if is-dark + '(:foreground "#4db6ff" :inherit fixed-pitch) + '(:foreground "#005fa3" :inherit fixed-pitch))))) + +(provide 'agent-shell-codebuddy) + +;;; agent-shell-codebuddy.el ends here diff --git a/agent-shell.el b/agent-shell.el index 4f278ee..b9ade6c 100644 --- a/agent-shell.el +++ b/agent-shell.el @@ -28,7 +28,8 @@ ;; interact with any agent powered by ACP (Agent Client Protocol). ;; ;; `agent-shell' currently provides access to Claude Code, Cursor, -;; Gemini CLI, Goose, Codex, OpenCode, Qwen, and Auggie amongst other agents. +;; CodeBuddy, Gemini CLI, Goose, Codex, OpenCode, Qwen, and Auggie +;; amongst other agents. ;; ;; This package depends on the `acp' package to provide the ACP layer ;; as per https://agentclientprotocol.com spec. @@ -50,6 +51,7 @@ (error "Please update 'shell-maker' to v0.90.1 or newer")) (require 'agent-shell-anthropic) (require 'agent-shell-auggie) +(require 'agent-shell-codebuddy) (require 'agent-shell-cline) (require 'agent-shell-completion) (require 'agent-shell-cursor) @@ -493,9 +495,10 @@ Returns an alist with all specified values." "Create a list of default agent configs. This function aggregates agents from OpenAI, Anthropic, Google, -Goose, Cursor, Auggie, and others." +Goose, Cursor, CodeBuddy, Auggie, and others." (list (agent-shell-auggie-make-agent-config) (agent-shell-anthropic-make-claude-code-config) + (agent-shell-codebuddy-make-agent-config) (agent-shell-cline-make-agent-config) (agent-shell-openai-make-codex-config) (agent-shell-cursor-make-agent-config) @@ -528,6 +531,7 @@ configuration alist for backwards compatibility." :type '(choice (const :tag "None (prompt each time)" nil) (const :tag "Auggie" auggie) (const :tag "Claude Code" claude-code) + (const :tag "CodeBuddy" codebuddy) (const :tag "Cline" cline) (const :tag "Codex" codex) (const :tag "Copilot" copilot) From 7e09aa79909760b584e534d1b0c39ed4b95ae424 Mon Sep 17 00:00:00 2001 From: illidan127 Date: Tue, 31 Mar 2026 13:30:29 +0800 Subject: [PATCH 2/2] Handle missing CodeBuddy icon and non-string image paths Avoid passing nil/non-string values into image type detection and disable the CodeBuddy icon entry to prevent invalid image handling at runtime. --- agent-shell-codebuddy.el | 2 +- agent-shell.el | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/agent-shell-codebuddy.el b/agent-shell-codebuddy.el index 262f80b..acf25f3 100644 --- a/agent-shell-codebuddy.el +++ b/agent-shell-codebuddy.el @@ -63,7 +63,7 @@ Returns an agent configuration alist using `agent-shell-make-agent-config'." :buffer-name "CodeBuddy" :shell-prompt "CodeBuddy> " :shell-prompt-regexp "CodeBuddy> " - :icon-name "codebuddy.png" + :icon-name nil :welcome-function #'agent-shell-codebuddy--welcome-message :client-maker (lambda (buffer) (agent-shell-codebuddy-make-client :buffer buffer)) diff --git a/agent-shell.el b/agent-shell.el index b9ade6c..9b94b1c 100644 --- a/agent-shell.el +++ b/agent-shell.el @@ -3441,7 +3441,8 @@ When provided, included in help-echo tooltips." (defun agent-shell--image-type-to-mime (filename) "Convert image type from FILENAME to MIME type string. Returns a MIME type like \"image/png\" or \"image/jpeg\"." - (when-let ((type (image-supported-file-p filename))) + (when-let ((type (and (stringp filename) + (image-supported-file-p filename)))) (pcase type ('svg "image/svg+xml") (_ (format "image/%s" type)))))