Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
113 changes: 113 additions & 0 deletions agent-shell-codebuddy.el
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.

;;; 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 nil
: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
11 changes: 8 additions & 3 deletions agent-shell.el
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -3437,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)))))
Expand Down