diff --git a/README.org b/README.org index acff85f6..c72fa1d5 100644 --- a/README.org +++ b/README.org @@ -176,6 +176,15 @@ npm install -g pi-acp See https://github.com/svkozak/pi-acp for details. + +*** For the Fabrica coding agent, install fabrica-cli + +#+begin_src bash +cargo install fabrica-cli +#+end_src + +See https://github.com/Endi1/fabrica for details. + ** Installation =agent-shell= is powered by built-in =comint-shell=, via [[https://github.com/xenodium/shell-maker][shell-maker]], available on [[https://melpa.org/#/shell-maker][MELPA]]. @@ -443,6 +452,7 @@ Start a specific agent shell session directly: - =M-x agent-shell-qwen-start= - Start a Qwen Code agent session - =M-x agent-shell-droid-start-agent= - Start a Factory Droid agent session - =M-x agent-shell-pi-start-agent= - Start a Pi coding agent session +- =M-x agent-shell-fabrica-start-agent= - Start a Fabrica coding agent session *** Setting a default agent for all new shells diff --git a/agent-shell-fabrica.el b/agent-shell-fabrica.el new file mode 100644 index 00000000..f61569de --- /dev/null +++ b/agent-shell-fabrica.el @@ -0,0 +1,114 @@ +;;; agent-shell-fabrica.el --- Fabrica coding 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 Fabrica coding agent specific configurations. +;; +;; Fabrica is a terminal-based coding agent built in Rust with built-in +;; ACP support. See https://github.com/Endi1/fabrica +;; +;; Fabrica supports multiple providers (Google Gemini, Anthropic Claude, +;; OpenAI) and includes built-in tools for file operations and shell +;; commands. +;; + +;;; 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-fabrica-acp-command + '("fabrica" "serve") + "Command and parameters for the Fabrica ACP client. + +The first element is the command name, and the rest are command parameters. + +Fabrica has built-in ACP support via its `serve' subcommand." + :type '(repeat string) + :group 'agent-shell) + +(defun agent-shell-fabrica-make-agent-config () + "Create a Fabrica coding agent configuration. + +Returns an agent configuration alist using `agent-shell-make-agent-config'." + (agent-shell-make-agent-config + :identifier 'fabrica + :mode-line-name "Fabrica" + :buffer-name "Fabrica" + :shell-prompt "Fabrica> " + :shell-prompt-regexp "Fabrica> " + :welcome-function #'agent-shell-fabrica--welcome-message + :client-maker (lambda (buffer) + (agent-shell-fabrica-make-client :buffer buffer)) + :install-instructions "Install with: cargo install fabrica-cli +See https://github.com/Endi1/fabrica for details.")) + +(defun agent-shell-fabrica-start-agent () + "Start an interactive Fabrica coding agent shell." + (interactive) + (agent-shell--dwim :config (agent-shell-fabrica-make-agent-config) + :new-shell t)) + +(cl-defun agent-shell-fabrica-make-client (&key buffer) + "Create a Fabrica client using BUFFER as context. + +Fabrica loads API keys from its own config file and/or +environment variables." + (unless buffer + (error "Missing required argument: :buffer")) + (agent-shell--make-acp-client :command (car agent-shell-fabrica-acp-command) + :command-params (cdr agent-shell-fabrica-acp-command) + :context-buffer buffer)) + +(defun agent-shell-fabrica--welcome-message (config) + "Return Fabrica welcome message using `shell-maker' CONFIG." + (let ((art (agent-shell--indent-string 4 (agent-shell-fabrica--ascii-art))) + (message (string-trim-left (shell-maker-welcome-message config) "\n"))) + (concat "\n\n" + art + "\n\n" + message))) + +(defun agent-shell-fabrica--ascii-art () + "Fabrica 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 "#e0a526" :inherit fixed-pitch) + '(:foreground "#b8860b" :inherit fixed-pitch))))) + +(provide 'agent-shell-fabrica) + +;;; agent-shell-fabrica.el ends here diff --git a/agent-shell.el b/agent-shell.el index 96abdaa9..50531b12 100644 --- a/agent-shell.el +++ b/agent-shell.el @@ -56,6 +56,7 @@ (require 'agent-shell-devcontainer) (require 'agent-shell-diff) (require 'agent-shell-experimental) +(require 'agent-shell-fabrica) (require 'agent-shell-droid) (require 'agent-shell-github) (require 'agent-shell-google) @@ -502,6 +503,7 @@ Goose, Cursor, Auggie, and others." (agent-shell-openai-make-codex-config) (agent-shell-cursor-make-agent-config) (agent-shell-droid-make-agent-config) + (agent-shell-fabrica-make-agent-config) (agent-shell-github-make-copilot-config) (agent-shell-google-make-gemini-config) (agent-shell-goose-make-agent-config)