Skip to content

Org Babel functions for Aider.el & Aidermacs integration

License

Notifications You must be signed in to change notification settings

emacsmirror/ob-aider

 
 

Repository files navigation

ob-aider.el

An Org Babel library for sending prompts to an already running Aider.el comint buffer directly from Org mode source blocks.

Overview

ob-aider.el allows you to interact with aider.el directly from Org mode documents. This enables you to:

  • Document your AI-assisted coding sessions in Org mode
  • Send prompts to Aider from within your Org documents
  • Create reproducible AI-assisted coding workflows

./screengif.gif

Requirements

  • Emacs 27.1 or later
  • Org mode 9.4 or later
  • aider.el

Installation

MELPA (Coming Soon)

(use-package ob-aider
  :ensure t)

Manual Installation

  1. Clone this repository:
    git clone https://github.com/localredhead/ob-aider.el.git
        
  2. Add the following to your Emacs configuration:
    (add-to-list 'load-path "/path/to/ob-aider")
    (require 'ob-aider)
    
    ;; Enable aider in org-babel
    (with-eval-after-load 'org
      (org-babel-do-load-languages
       'org-babel-load-languages
       (append org-babel-load-languages
               '((aider . t)))))
        

Using straight.el and use-package

(use-package ob-aider
  :straight (:host github :repo "levistrope/ob-aider.el")
  :after org
  :config
  (org-babel-do-load-languages
   'org-babel-load-languages
   (append org-babel-load-languages
           '((aider . t)))))

For Doom Emacs users

In your ~/.doom.d/packages.el file, add:

(package! ob-aider
  :recipe (:host github :repo "levistrope/ob-aider.el"))

In your ~/.doom.d/config.el file, add:

(use-package! ob-aider
  :after org
  :config
  (add-to-list 'org-babel-load-languages '(aider . t))
  (org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages))

Then run doom sync to install the package.

Usage

  1. Start an Aider session using M-x aider-start or your preferred method.
  2. In your Org document, create an Aider source block:
Please refactor this function to be more efficient...
  
  1. Execute the block with C-c C-c to send the prompt to the active Aider session.
  2. The response from Aider will be captured and displayed as the result of the source block.

Asynchronous Execution

For long-running prompts, you can use asynchronous execution:

Your complex prompt here...
  

Customization

You can customize the behavior of ob-aider through the following variables:

;; Set timeout for waiting for Aider responses (in seconds)
(setq ob-aider-timeout 60)

;; Set delay between checks for Aider response completion
(setq ob-aider-response-delay 0.1)

;; Set default async behavior
(setq ob-aider-default-async nil)

Troubleshooting

  • No active Aider conversation buffer found: Make sure you have started an Aider session before executing an Aider source block.
  • Response timeout: If Aider takes longer than expected to respond, you can increase the ob-aider-timeout value.

Use Cases

GPTel + ob-aider: A Powerful Combination

One of the most powerful workflows enabled by ob-aider is the combination with GPTel or similar Emacs LLM interfaces. This creates a seamless AI-assisted development environment:

Integrated AI Workflow

The combination of GPTel and ob-aider creates a synergistic workflow where:

  • GPTel helps you craft and refine prompts within your Org document
  • ob-aider sends those refined prompts to your Aider session for code generation and modification
  • Org mode documents the entire process in a single, executable document

This workflow allows you to leverage different AI tools for their respective strengths - using a general-purpose LLM to help formulate effective prompts for the code-focused Aider tool. The entire conversation history, thought process, and resulting code changes are preserved in a single Org document that can be shared, revisited, or modified later.

This integration transforms your Org documents into interactive AI-assisted development environments, where you can seamlessly move between brainstorming, prompt refinement, code generation, and documentation - all while maintaining a complete record of your development process.

Credits and Thanks

This project would not be possible without the following amazing tools:

  • GPTel - An elegant and efficient Emacs interface to OpenAI’s GPT and other LLMs
  • Aider.el - Emacs interface for Aider, the AI pair programming tool
  • Org Mode - For its incredible Babel framework that makes this integration possible

Special thanks to the developers of these tools for their contributions to the Emacs ecosystem and for making AI-assisted development more accessible within our favorite editor.

Acknowledgments

  • aider.el for the Aider Emacs integration
  • Org Babel for the literate programming framework
  • This project was 100% developed with the assistance of Claude 3 Opus and Claude 3 Sonnet, demonstrating the potential of AI-assisted development
  • The entire project was developed using GPTel to write prompts and Aider.el, showcasing the power of AI pair programming

About

Org Babel functions for Aider.el & Aidermacs integration

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages

  • Emacs Lisp 72.1%
  • Shell 20.8%
  • Makefile 7.1%