### Example: Checking for LiteLLM Prices File Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-models.md Demonstrates how to use `aidermacs--find-litellm-prices-file` to get the path to the LiteLLM prices file and display it if found. ```elisp (when-let ((path (aidermacs--find-litellm-prices-file))) (message "Found litellm prices at: %s" path)) ``` -------------------------------- ### Complete Aidermacs Configuration Example Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/configuration.md A comprehensive example demonstrating how to configure various aspects of Aidermacs, including backend selection, models, chat modes, file management, behavior settings, notifications, prompts, and hooks. ```elisp (use-package aidermacs :bind (("C-c a" . aidermacs-transient-menu)) :config ;; Backend selection (setq aidermacs-backend 'comint) ;; Model configuration (setq aidermacs-default-model "claude-3-5-sonnet-20241022") (setq aidermacs-architect-model "deepseek/deepseek-reasoner") (setq aidermacs-editor-model "deepseek/deepseek-chat") ;; Chat mode (setq aidermacs-default-chat-mode 'architect) ;; File management (setq aidermacs-subtree-only nil) (setq aidermacs-global-read-only-files '("~/.aider/AI_RULES.md")) (setq aidermacs-project-read-only-files '("README.md" "CONVENTIONS.md")) ;; Behavior (setq aidermacs-auto-commits nil) (setq aidermacs-auto-accept-architect nil) (setq aidermacs-watch-files t) (setq aidermacs-show-diff-after-change t) ;; Notifications (setq aidermacs-enable-notifications t) (setq aidermacs-notify-after-seconds 120) ;; Prompts (setq aidermacs-common-prompts '("What does this code do?" "Find bugs" "Optimize for performance")) ;; Setup hooks (add-hook 'aidermacs-before-run-backend-hook (lambda () (setenv "ANTHROPIC_API_KEY" (my-get-api-key)))) :custom (aidermacs-backend 'comint) (aidermacs-default-chat-mode 'architect)) ``` -------------------------------- ### Aidermacs Session Setup Variables Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/INDEX.md Configure the core session setup for Aidermacs, including the backend, configuration file, and arguments. ```elisp aidermacs-program aidermacs-backend aidermacs-config-file aidermacs-extra-args aidermacs-before-run-backend-hook ``` -------------------------------- ### Start Aidermacs Session Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Initiates an Aidermacs session with the selected backend. It handles configuration, process launching, and buffer setup. Use this to begin an AI pair programming session. ```elisp (aidermacs-run) ``` -------------------------------- ### Configure and Start Aidermacs Session Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Sets a global keybinding to start an Aidermacs session and then interactively calls the `aidermacs-run` function. This is useful for quick access to the AI pair programming feature. ```elisp (global-set-key (kbd "C-c a") 'aidermacs-run) (call-interactively 'aidermacs-run) ``` -------------------------------- ### Install Aider for Python 3.12 with uv Source: https://github.com/matthewzmd/aidermacs/blob/main/README.md Install the aider-chat package specifically for Python 3.12 using the 'uv' tool. Use the --force flag to ensure the latest version is installed. ```bash uv tool install --force --python python3.12 aider-chat@latest ``` -------------------------------- ### Add Hook to Aidermacs Before Backend Run Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/configuration.md Add a function to the `aidermacs-before-run-backend-hook` to perform setup tasks before the Aidermacs backend starts, such as setting environment variables. ```elisp (add-hook 'aidermacs-before-run-backend-hook (lambda () (setenv "ANTHROPIC_API_KEY" (my-get-api-key)))) ``` -------------------------------- ### Setup Aider Cleanup Hooks Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-output.md Initializes hooks to ensure proper cleanup of Aider-related buffers and resources when the Aider buffer is killed. This function should be called during Aider's setup. ```elisp (aidermacs--setup-cleanup-hooks) ``` -------------------------------- ### Example: Using aidermacs--read-litellm-prices Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-models.md Demonstrates how to use `aidermacs--read-litellm-prices` to retrieve model pricing and display the count of models found. ```elisp (let ((prices (aidermacs--read-litellm-prices))) (message "Found %d models with pricing" (length prices))) ``` -------------------------------- ### Install Aidermacs from MELPA Source: https://github.com/matthewzmd/aidermacs/blob/main/RELEASE.md Install Aidermacs directly from the MELPA package repository using the `package-install` command. ```Emacs Lisp M-x package-install RET aidermacs RET ``` -------------------------------- ### Example: Calculating Price for a Model Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-models.md Demonstrates calculating the total price of a model by providing a sample model alist with a `price-str` to `aidermacs--model-total-price`. ```elisp (aidermacs--model-total-price '((id . "gpt-4o") (price-str . "($0.005/$0.015/M)"))) ; => 0.020 ``` -------------------------------- ### Aidermacs Setup Configuration Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/README.md This snippet shows how to configure Aidermacs using `use-package`. It sets keybindings, default model, default chat mode, and the backend. ```elisp (use-package aidermacs :bind (("C-c a" . aidermacs-transient-menu)) :custom (aidermacs-default-model "claude-3-5-sonnet-20241022") (aidermacs-default-chat-mode 'architect) (aidermacs-backend 'comint)) ``` -------------------------------- ### aidermacs-run Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Starts an Aidermacs session using the selected backend. It handles configuration, launches the Aider process, and sets up necessary hooks. ```APIDOC ## aidermacs-run ### Description Start an Aidermacs session using the selected backend. ### Method Elisp function call ### Endpoint N/A ### Parameters None ### Request Example ```elisp (aidermacs-run) (call-interactively 'aidermacs-run) ``` ### Response Returns nil. ### Success Response (nil) Returns nil. ``` -------------------------------- ### Example: Displaying Top 3 Cheapest Models Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-models.md Shows how to use `aidermacs--get-cheapest-models` to find the top 3 cheapest models from a list and then display their rank and ID. ```elisp (let ((top-3 (aidermacs--get-cheapest-models models 3))) (dolist (entry top-3) (message "Rank %d: %s" (cdr entry) (alist-get 'id (car entry))))) ``` -------------------------------- ### Example: Parsing OpenAI Model ID Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-models.md Provides an example of parsing an OpenAI model identifier with a date suffix using `aidermacs--parse-model-identity`. ```elisp (aidermacs--parse-model-identity "openai/gpt-4o-2024-08-06") ; => ((provider . "openai") (family . "gpt-4o") (variant . "2024-08-06") ...) ``` -------------------------------- ### Add Hook for Pre-Run Configuration in Aidermacs Source: https://github.com/matthewzmd/aidermacs/blob/main/README.md Use this hook to run custom setup code before the Aider backend starts. This is useful for setting environment variables or injecting secrets. ```elisp (add-hook 'aidermacs-before-run-backend-hook (lambda () (setenv "OPENAI_API_KEY" (password-store-get "code/openai_api_key")))) ``` -------------------------------- ### Install Aider with SOCKS Proxy Support Source: https://github.com/matthewzmd/aidermacs/blob/main/README.md Install aider-chat for Python 3.12 with SOCKS proxy support, including the 'httpx[socks]' dependency. This is useful for environments with specific network configurations. ```bash uv tool install --force --python python3.12 aider-chat@latest --with 'httpx[socks]' ``` -------------------------------- ### Example: Iterating Through Cached LiteLLM Prices Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-models.md Shows how to fetch cached LiteLLM prices using `aidermacs--get-litellm-prices` and then iterate through the returned list to display each model's identifier and price. ```elisp (let ((prices (aidermacs--get-litellm-prices))) (dolist (model prices) (message "%s: %s" (car model) (cdr model)))) ``` -------------------------------- ### aidermacs-run-backend Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-backends.md Runs Aidermacs using the selected backend (Comint or VTerm). It respects the `aidermacs-backend` setting and runs hooks before starting. ```APIDOC ## aidermacs-run-backend ### Description Run Aidermacs using the selected backend (Comint or VTerm). ### Function Signature ```elisp (aidermacs-run-backend PROGRAM ARGS BUFFER-NAME) ``` ### Parameters #### Path Parameters - **PROGRAM** (string) - Required - Path to Aider executable - **ARGS** (list) - Required - List of command-line arguments - **BUFFER-NAME** (string) - Required - Name for the Aidermacs buffer ### Return nil ### Behavior - Respects `aidermacs-backend` setting (`comint` or `vterm`) - Runs `aidermacs-before-run-backend-hook` before starting - Copies `process-environment` so environment variables set in hooks don't leak - Dispatches to `aidermacs-run-vterm` or `aidermacs-run-comint` ### Request Example ```elisp (aidermacs-run-backend "/usr/bin/aider" '("--model" "sonnet") "*aidermacs:/project*") ``` ``` -------------------------------- ### Setup Ediff Cleanup Hooks Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-output.md Sets up hooks to clean up temporary ediff files. It only adds hooks if they are not already present, ensuring temporary snapshots do not accumulate. ```elisp (aidermacs--setup-ediff-cleanup-hooks) ``` -------------------------------- ### Get Project Root Directory Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Retrieves the project root directory. It prioritizes `vc-git-root`, then falls back to the current file's directory, and finally to `default-directory`. ```elisp (aidermacs-project-root) ``` ```elisp (message "Project root: %s" (aidermacs-project-root)) ``` -------------------------------- ### Setting Environment Variables for Aider Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/data-structures.md Demonstrates how to set environment variables, such as API keys, using a hook that runs before Aider starts its backend. This ensures keys are available to the Aider process without polluting the main Emacs environment. ```elisp "ANTHROPIC_API_KEY" ; Set by user or hook "OPENAI_API_KEY" ; Set by user or hook "OPENROUTER_API_KEY" ; Set by user or hook "AIDER_MODEL" ; Default model "AIDER_EDITOR_MODEL" ; Editor model in architect "AIDER_WEAK_MODEL" ; Weak model for commits ``` ```elisp (add-hook 'aidermacs-before-run-backend-hook (lambda () (setenv "OPENAI_API_KEY" "sk-..."))) ``` -------------------------------- ### Example: Parsing Claude Model ID Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-models.md Illustrates parsing a Claude model identifier using `aidermacs--parse-model-identity`, showing how it handles models without explicit provider prefixes. ```elisp (aidermacs--parse-model-identity "claude-3-5-sonnet-20241022") ; => ((provider . nil) (family . "claude-3-5-sonnet") ...) ``` -------------------------------- ### Read LiteLLM Model Prices Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-models.md Reads model pricing information from a local LiteLLM JSON file. Searches common installation paths if the file is not found. Returns an alist of model prices or nil if the file is not found or parsing fails. ```elisp (aidermacs--read-litellm-prices) ``` -------------------------------- ### aidermacs--find-litellm-prices-file Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-models.md Locates the litellm prices file. It first checks for a user-specified path and then searches common installation directories. The result is cached to optimize subsequent calls. ```APIDOC ## `aidermacs--find-litellm-prices-file` ### Description Locate the litellm prices file. ### Method (aidermacs--find-litellm-prices-file) ### Parameters None ### Return `string` (file path) or `nil` ### Behavior - Uses user-specified path if `aidermacs-litellm-prices-file` is set - Searches common installation paths - Caches result to avoid repeated searches - Returns nil if file not found ### Example: ```elisp (when-let ((path (aidermacs--find-litellm-prices-file))) (message "Found litellm prices at: %s" path)) ``` ``` -------------------------------- ### Find LiteLLM Prices File Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-models.md Locates the LiteLLM prices file, respecting user-defined paths or searching common installation locations. The result is cached to optimize subsequent calls. Returns the file path or nil if not found. ```elisp (aidermacs--find-litellm-prices-file) ``` -------------------------------- ### Get Cheapest N Models Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-models.md Retrieves the N cheapest models from a provided list of models. Models are sorted by their total calculated price, and the result includes the rank of each model. ```elisp (aidermacs--get-cheapest-models MODELS COUNT) ``` -------------------------------- ### Check Aider Version Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Checks the installed Aider version by running `aider --version` and parsing the output. The result is cached per-workspace to avoid redundant calls. Returns the version string or nil if detection fails. ```elisp (aidermacs-aider-version) ``` ```elisp (message "Aider version: %s" (aidermacs-aider-version)) ``` -------------------------------- ### Process Aider Command Output and Changes Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-output.md Example of post-command processing logic. Detects file changes, optionally shows diffs using Ediff, and stores command output in history. Assumes `command` is defined and `aidermacs-show-diff-after-change` is configured. ```elisp ;; After Aider completes a change: (when (aidermacs--command-may-edit-files command) ;; Detect which files changed (let ((edited-files (aidermacs--detect-edited-files))) ;; Show diff for each file (when (and edited-files aidermacs-show-diff-after-change) (aidermacs--show-ediff-for-edited-files edited-files)) ;; Store output for history (aidermacs--store-output aidermacs--current-output))) ``` -------------------------------- ### Configure Aidermacs Program Path Source: https://github.com/matthewzmd/aidermacs/blob/main/README.md Set the path to the Aidermacs program executable. This is necessary if 'uv' installs 'aider' in a non-standard location, like '~/.local/bin/aider'. ```emacs-lisp (setq aidermacs-program (expand-file-name "~/.local/bin/aider")) ``` -------------------------------- ### Open Remote File with Tramp Source: https://github.com/matthewzmd/aidermacs/blob/main/README.md Example of opening a remote file using Emacs' Tramp mode for seamless Aidermacs integration with remote servers. ```emacs-lisp ;; Open a remote file via SSH (find-file "/ssh:user@remotehost:/path/to/file.py") ;; Start Aidermacs session - it will automatically detect the remote context M-x aidermacs-transient-menu ``` -------------------------------- ### Run Aidermacs in Specified Directory Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Prompts the user to select a directory and then starts an Aidermacs session within that directory, applying the `--subtree-only` flag. This allows for flexible session initiation in different project scopes. ```elisp (call-interactively 'aidermacs-run-in-directory) ``` -------------------------------- ### aidermacs-aider-version Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Checks the installed Aider version by running `aider --version` and parsing the output. The result is cached per workspace to avoid redundant calls. It returns the version string (e.g., "0.77.0") or `nil` if the version cannot be detected. ```APIDOC ## `aidermacs-aider-version` ### Description Check the installed Aider version. ### Parameters None ### Return string or nil ### Behavior - Runs `aider --version` and parses version string - Caches result per-workspace to avoid repeated calls - Returns version string like "0.77.0" or nil if detection fails ### Example ```elisp (message "Aider version: %s" (aidermacs-aider-version)) ``` ``` -------------------------------- ### Setup Automatic Aider Minor Mode Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Configures Aider's minor mode to be automatically enabled for relevant files. This function adds a hook to `find-file-hook` and is only active if not already present. ```elisp (aidermacs-setup-minor-mode) ``` -------------------------------- ### Get LiteLLM Prices with Caching Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-models.md Retrieves LiteLLM pricing information, utilizing a cache to avoid redundant reads. If the cache is expired, it calls `aidermacs--read-litellm-prices`. The cache duration is configurable. ```elisp (aidermacs--get-litellm-prices) ``` -------------------------------- ### Open or Create Aider Prompt File Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Opens the `.aider.prompt.org` file for the current project, creating it if it doesn't exist. The file name can be configured via `aidermacs-prompt-file-name`. This function may throw an error if no project root is found. ```elisp (aidermacs-open-prompt-file) ``` -------------------------------- ### aidermacs-magit-show-last-commit Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Shows the last commit using Magit. This function requires the Magit package to be installed and is only available when `aidermacs-auto-commits` is enabled. ```APIDOC ## `aidermacs-magit-show-last-commit` ### Description Show the last commit using Magit. ### Behavior - Requires Magit package - Shows HEAD commit - Only available when `aidermacs-auto-commits` is enabled ### Throws | Error | |-------| | "Magit is required to show the last commit." | ### Example ```elisp (aidermacs-magit-show-last-commit) ``` ``` -------------------------------- ### aidermacs-open-prompt-file Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Opens or creates the `.aider.prompt.org` file. This function opens the prompt file from the project root in another window and creates it with a command reference and sample prompt if it's new. ```APIDOC ## `aidermacs-open-prompt-file` ### Description Open or create the `.aider.prompt.org` file. ### Behavior - Opens prompt file from project root in other window - Creates file with command reference and sample prompt if new - File name configurable via `aidermacs-prompt-file-name` ### Throws | Error | |-------| | "Could not determine prompt file" | ### Example ```elisp (aidermacs-open-prompt-file) ``` ``` -------------------------------- ### Create Session Scratchpad (Emacs Lisp) Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Creates a temporary scratchpad file for the Aider session. This file is added to the session as read-only, opened in a separate window for editing, and has a timestamped filename. Use this for temporary notes or content related to the current session. ```elisp (aidermacs-create-session-scratchpad) ``` -------------------------------- ### Get Architect Model Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-models.md Retrieve the effective Architect model for reasoning. Returns the `aidermacs-architect-model` if set, otherwise falls back to `aidermacs-default-model`. ```elisp (message "Architect model: %s" (aidermacs-get-architect-model)) ``` -------------------------------- ### Get Weak Model Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-models.md Retrieve the effective Weak model for commit messages. Returns the `aidermacs-weak-model` if set, otherwise falls back to `aidermacs-default-model`. ```elisp (message "Weak model: %s" (aidermacs-get-weak-model)) ``` -------------------------------- ### Get Editor Model Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-models.md Retrieve the effective Editor model for code generation. Returns the `aidermacs-editor-model` if set, otherwise falls back to `aidermacs-default-model`. ```elisp (message "Editor model: %s" (aidermacs-get-editor-model)) ``` -------------------------------- ### Specify LiteLLM Prices File Path Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/configuration.md Set `aidermacs-litellm-prices-file` to a specific path if you need to manually provide the `model_prices_and_context_window.json` file for LiteLLM. Leave as `nil` for auto-detection. ```elisp (setq aidermacs-litellm-prices-file "~/.local/lib/python3.11/site-packages/litellm/model_prices_and_context_window.json") ``` -------------------------------- ### Emacs Lisp: Help Prompt Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Prompt Aider for help. This command uses the '/help' prefix. An empty input will display all available help commands. ```elisp (aidermacs-help) ``` ```elisp (aidermacs-help) ; Prompts: "/help (empty for all commands):" ``` -------------------------------- ### Aidermacs Buffer Name Pattern Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/data-structures.md Buffer names follow a pattern starting with '*aidermacs:' followed by the project root and an optional suffix for specific scopes. ```text *aidermacs:PROJECT_ROOT* *aidermacs:PROJECT_ROOT:SUFFIX* ``` ```text *aidermacs:/home/user/project* *aidermacs:/home/user/project:Additional Session* *aidermacs:/home/user/project: Files* ``` -------------------------------- ### aidermacs-create-session-scratchpad Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Creates a temporary scratchpad file for adding content to the Aider session. This file is added as read-only and opened in a new window for editing. ```APIDOC ## `aidermacs-create-session-scratchpad` ### Description Create a temporary file for adding content to the Aider session. ### Method Elisp function call ### Parameters None ### Request Example ```elisp (aidermacs-create-session-scratchpad) ``` ### Response #### Success Response (nil) Returns nil upon successful execution. ### Behavior - Creates a timestamped temp file in the system temp directory. - Adds the file to the session as read-only. - Opens the file in another window for editing. - File name format: `aidermacs-YYYYMMDD-HHMMSS.txt`. - Displays a confirmation message with the file path. ``` -------------------------------- ### Show Last Commit with Magit Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Displays the last commit using the Magit interface. This function requires the Magit package to be installed and is only available when `aidermacs-auto-commits` is enabled. ```elisp (aidermacs-magit-show-last-commit) ``` -------------------------------- ### aidermacs-run-comint Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-backends.md Launches the Aidermacs process using the Comint backend. It manages the Comint buffer, sets up syntax highlighting, and configures input handling for Aider interactions. ```APIDOC ## aidermacs-run-comint ### Description Launch Aidermacs process using Comint backend. ### Method (aidermacs-run-comint PROGRAM ARGS BUFFER-NAME) ### Parameters #### Path Parameters - **PROGRAM** (string) - Yes - Path to Aider executable - **ARGS** (list) - Yes - Command-line arguments - **BUFFER-NAME** (string) - Yes - Name for Comint buffer ### Behavior - Creates or reuses Comint buffer - Sets up syntax highlighting for Aider output - Configures multi-line input handling - Enables markdown syntax highlighting in output - Initializes output state tracking ``` -------------------------------- ### aidermacs--send-command-vterm Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-backends.md Send command to Aidermacs VTerm process. Sends command via VTerm's text insertion and updates command start time for notifications. ```APIDOC ## `aidermacs--send-command-vterm` ### Description Send command to Aidermacs VTerm process. ### Signature ```elisp (aidermacs--send-command-vterm BUFFER COMMAND) ``` ### Parameters #### Path Parameters - **BUFFER** (buffer) - Required - VTerm buffer - **COMMAND** (string) - Required - Command to send ### Return nil ### Behavior - Sends command via VTerm's text insertion - Updates command start time for notifications - Triggers output processing and file change detection ``` -------------------------------- ### Aidermacs Model Configuration Variables Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/INDEX.md Set up and manage the AI models used by Aidermacs, including default, architect, editor, and weak models, as well as price and cache settings. ```elisp aidermacs-default-model aidermacs-architect-model aidermacs-editor-model aidermacs-weak-model aidermacs-litellm-prices-file aidermacs-litellm-prices-cache-duration ``` -------------------------------- ### Clear Aidermacs Chat History Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Clears the chat history for the current Aider session by sending the `/clear` command. This is useful for starting a new conversation thread within an existing session. ```elisp (aidermacs-clear-chat-history) ``` -------------------------------- ### Run Aidermacs in Current Directory Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Starts an Aidermacs session scoped to the current directory using the `--subtree-only` flag. This is particularly useful in monorepos to limit the AI's context. ```elisp (aidermacs-run-in-current-dir) ``` -------------------------------- ### Run Aidermacs Backend Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-backends.md Initiates the Aidermacs process with a specified backend. Respects the `aidermacs-backend` setting and runs `aidermacs-before-run-backend-hook` prior to execution. Copies `process-environment` to prevent environment variable leakage. ```Elisp (aidermacs-run-backend PROGRAM ARGS BUFFER-NAME) ``` ```Elisp (aidermacs-run-backend "/usr/bin/aider" '("--model" "sonnet") "*aidermacs:/project*") ``` -------------------------------- ### Get Aidermacs Buffer Name Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Generates the name for an Aidermacs buffer, optionally selecting an existing one or appending a suffix. It formats the name based on the project path and session context. ```elisp (aidermacs-get-buffer-name) ``` ```elisp (aidermacs-get-buffer-name t) ; Select existing buffer ``` -------------------------------- ### Launch Aidermacs Process with Comint Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-backends.md Use this function to launch the Aidermacs process using Comint backend. It requires the path to the Aider executable, command-line arguments, and a name for the Comint buffer. ```elisp (aidermacs-run-comint PROGRAM ARGS BUFFER-NAME) ``` -------------------------------- ### Reset Aidermacs Session Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Resets the current Aider session by clearing the tracked files list and sending the `/reset` command to the Aider process. Use this to start fresh without terminating the session. ```elisp (aidermacs-reset) ``` -------------------------------- ### Prepare for Code Edit Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-output.md Prepares the system for capturing Aider code changes by taking file snapshots and recording modification times. Used internally before commands that may modify files. ```elisp (aidermacs--prepare-for-code-edit) ``` -------------------------------- ### Set OpenAI API Key Before Backend Run Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/README.md This hook is used to set the OpenAI API key before the Aidermacs backend starts. It retrieves the API key using a custom function `my-get-api-key`. ```elisp (add-hook 'aidermacs-before-run-backend-hook (lambda () (setenv "OPENAI_API_KEY" (my-get-api-key)))) ``` -------------------------------- ### Configure Aidermacs Thinking Tokens via Command-Line Source: https://github.com/matthewzmd/aidermacs/blob/main/README.md Set the thinking token budget for Aidermacs using the --thinking-tokens argument. This is useful for controlling the context window size for AI models. ```emacs-lisp (setq aidermacs-extra-args '("--thinking-tokens" "16k")) ``` -------------------------------- ### Fetch Models from Provider Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-models.md Fetch available models from a specified API provider. Requires the provider name and optionally an API key. Returns a list of model alists or nil if the API call fails. ```elisp (aidermacs--get-models-from-provider 'openai "sk-...") ``` -------------------------------- ### Get Aider Program Path Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Resolves and returns the path to the Aider program. It respects the `aidermacs-program` variable, caches results per-workspace, and uses `executable-find` for path resolution. Checks for `aider-ce` then `aider`. ```elisp (aidermacs-get-program) ``` ```elisp (let ((prog (aidermacs-get-program))) (message "Using: %s" prog)) ``` -------------------------------- ### List Added Files in Aider Session Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Displays all files currently in the Aider session within a dedicated Dired buffer. The buffer lists both editable and read-only files. ```elisp (aidermacs-list-added-files) ``` -------------------------------- ### Aider Prompt Regex Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/data-structures.md Use this regex to match Aider's prompt strings, including user and system prompts. ```elisp aidermacs-prompt-regexp ; "^[^[:space:]<]*>[[:space:]]+$" ; Matches: "> ", "user> ", "aider> ", etc. ``` -------------------------------- ### Add Extra Aider Arguments Source: https://github.com/matthewzmd/aidermacs/blob/main/README.md Use `aidermacs-extra-args` to pass additional command-line options to Aider. For example, to set verbosity, add "--verbose" to the list. Note that `--model` is handled separately. ```emacs-lisp ;; Set the verbosity: (add-to-list 'aidermacs-extra-args "--verbose") ``` -------------------------------- ### aidermacs-setup-minor-mode Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Sets up automatic enabling of Aider's minor mode. This function adds a hook to `find-file-hook` to auto-enable the minor mode for files in `aidermacs-auto-mode-files`. ```APIDOC ## `aidermacs-setup-minor-mode` ### Description Set up automatic enabling of aidermacs minor mode. ### Behavior - Adds hook to `find-file-hook` - Auto-enables minor mode for files in `aidermacs-auto-mode-files` - Only adds hook if not already present ### Keybindings | Key | |-------| | C-c C-n or C-RET | | C-c C-c | | C-c C-z | ### Example ```elisp (aidermacs-setup-minor-mode) ``` ``` -------------------------------- ### Configure Project Read-Only Files Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/configuration.md Specify files to be added as read-only to all Aidermacs sessions using `aidermacs-project-read-only-files`. Paths are relative to the project root. ```elisp (setq aidermacs-project-read-only-files '("CONVENTIONS.md" "README.md")) ``` -------------------------------- ### Add Same-Type Files Under Directory to Aider Session Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Adds all files with the same extension as the current file within the current directory to the Aider session. Aborts if more than 40 files would be added. ```elisp (aidermacs-add-same-type-files-under-dir) ``` -------------------------------- ### Fetch Web Content Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Fetches web content from a specified URL. This allows Aider to access online documentation and references. ```elisp (aidermacs-web "https://example.com/docs") ``` -------------------------------- ### aidermacs-help Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Prompts the user for a help question about Aider. An empty input will display all available help commands. ```APIDOC ## aidermacs-help ### Description Prompt for a help question about Aider. Uses "/help" prefix. Empty input shows all available help commands. ### Method Elisp Function ### Parameters None ### Return nil ### Example ```elisp (aidermacs-help) ``` ``` -------------------------------- ### Launch Aidermacs Process with VTerm Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-backends.md Use this function to launch an Aider process using the VTerm backend. It requires the path to the Aider executable, command-line arguments, and a name for the VTerm buffer. ```elisp (aidermacs-run-vterm PROGRAM ARGS BUFFER-NAME) ``` -------------------------------- ### Switch to Help Mode (Emacs Lisp) Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Switches Aider to 'help' mode. This mode is designed for asking questions about using Aider itself, its configuration, or troubleshooting issues. Aider will provide assistance related to the tool's usage. ```elisp (aidermacs-switch-to-help-mode) ``` -------------------------------- ### Aidermacs File Handling Configuration Variables Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/INDEX.md Configure how Aidermacs interacts with files, including global and project-specific read-only settings and prompt file naming conventions. ```elisp aidermacs-global-read-only-files aidermacs-project-read-only-files aidermacs-auto-mode-files aidermacs-prompt-file-name ``` -------------------------------- ### Configure Aidermacs in Emacs init.el Source: https://github.com/matthewzmd/aidermacs/blob/main/README.md This Emacs Lisp snippet shows how to configure Aidermacs in your init.el file. It includes setting API keys and default modes. Ensure API keys are handled securely. ```emacs-lisp (use-package aidermacs :bind (("C-c a" . aidermacs-transient-menu)) :config ; Set API_KEY in .bashrc, that will automatically picked up by aider or in elisp (setenv "ANTHROPIC_API_KEY" "sk-...") ; defun my-get-openrouter-api-key yourself elsewhere for security reasons (setenv "OPENROUTER_API_KEY" (my-get-openrouter-api-key)) :custom ; See the Configuration section below (aidermacs-default-chat-mode 'architect) (aidermacs-default-model "sonnet")) ``` -------------------------------- ### Set Aidermacs Backend Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/configuration.md Choose the backend for the Aidermacs process. 'comint' uses Emacs' built-in terminal emulation, while 'vterm' offers better terminal compatibility. ```elisp (setq aidermacs-backend 'comint) ; Default ``` ```elisp (setq aidermacs-backend 'vterm) ; Better terminal support ``` -------------------------------- ### Send Command with Prefix Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Sends a command to Aider with a specified prefix. It concatenates the prefix and command, ensuring the current file is tracked before execution. ```elisp (aidermacs-send-command-with-prefix PREFIX COMMAND) ``` ```elisp (aidermacs-send-command-with-prefix "/ask" "What does this function do?") ``` -------------------------------- ### Add Project File to Aider Session Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Adds a file from the current project to the Aider session. Can be used to add files as read-only by passing `t` or using the C-u prefix. ```elisp (aidermacs-add-project-file) ; Add project file as editable (aidermacs-add-project-file t) ; Add project file as read-only ``` -------------------------------- ### Emacs Lisp: General Question Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Ask Aider a general question without specific code context. This command uses the '/ask' prefix and is useful for broad inquiries about the codebase. ```elisp (aidermacs-question-general) ``` ```elisp (aidermacs-question-general) ; Prompts: "/ask (empty for ask mode):" ``` -------------------------------- ### Set Aidermacs Configuration File Path Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/configuration.md Specify the path to an Aider configuration file. This will be passed to Aider via the --config flag. ```elisp (setq aidermacs-config-file "/path/to/project/.aider.conf.yml") ``` -------------------------------- ### Set Aidermacs Program Path Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/configuration.md Configure the Aider program to use. Can be a single string or a list of programs to try in order. ```elisp (setq aidermacs-program "aider") ``` ```elisp (setq aidermacs-program '("/usr/local/bin/aider" "aider")) ``` -------------------------------- ### Aidermacs Prompts Configuration Variable Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/INDEX.md Define common prompts used across Aidermacs sessions. ```elisp aidermacs-common-prompts ``` -------------------------------- ### aidermacs-transient-menu Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Opens the main transient menu interface for Aidermacs, providing a keyboard-driven way to access various commands. The menu is organized into sections like Core, Persistent Modes, Utilities, File Actions, and Code Actions, allowing users to select and run commands efficiently. ```APIDOC ## `aidermacs-transient-menu` ### Description Main transient menu interface for Aidermacs. ### Parameters None ### Return nil ### Behavior - Displays organized menu of all Aidermacs commands - Grouped into sections: Core, Persistent Modes, Utilities, File Actions, Code Actions - Run commands by pressing displayed keys - Keyboard-driven workflow similar to Magit ### Menu Structure: - **Core**: Session management (start, exit, reset, clear history) - **Persistent Modes**: Code, Ask, Architect, Help modes - **Utilities**: Model selection, voice, web fetch, commit history - **File Actions**: Add/drop files, create scratchpads - **Code Actions**: Code changes, questions, testing ### Example ```elisp (global-set-key (kbd "C-c a") 'aidermacs-transient-menu) (aidermacs-transient-menu) ``` ``` -------------------------------- ### aidermacs--read-litellm-prices Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-models.md Reads model pricing information from a local litellm JSON file. It searches for `model_prices_and_context_window.json` in various standard locations and parses the pricing data. ```APIDOC ## `aidermacs--read-litellm-prices` ### Description Read model pricing information from local litellm file. ### Method (aidermacs--read-litellm-prices) ### Parameters None ### Return `alist` or `nil` ### Behavior - Searches for `model_prices_and_context_window.json` from litellm - Parses JSON and extracts pricing for each model - Returns alist mapping model-id to `((input-price . VAL) (output-price . VAL))` - Returns nil if file not found or parsing fails ### Search Paths: - `~/.aider/caches/model_prices_and_context_window.json` - `~/.local/lib/python*/site-packages/litellm/...` - `/usr/lib/python*/site-packages/litellm/...` - macOS Homebrew paths - Conda/Anaconda paths - Virtual environment paths ### Example: ```elisp (let ((prices (aidermacs--read-litellm-prices))) (message "Found %d models with pricing" (length prices))) ``` ``` -------------------------------- ### aidermacs-switch-to-help-mode Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Switches Aider to help mode, where it answers questions about using Aider, its configuration, and troubleshooting. ```APIDOC ## `aidermacs-switch-to-help-mode` ### Description Switch Aider to help mode. ### Method Elisp function call ### Parameters None ### Request Example ```elisp (aidermacs-switch-to-help-mode) ``` ### Response #### Success Response (nil) Returns nil upon successful execution. ### Behavior - Sends `/chat-mode help` command. - Updates buffer-local `aidermacs--current-mode` to `help`. - Aider answers questions about using Aider, configuration, troubleshooting. ``` -------------------------------- ### aidermacs--setup-ediff-cleanup-hooks Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-output.md Sets up hooks to clean up temporary ediff files. This function adds necessary hooks to ensure that temporary buffers used during the ediff process are properly removed, preventing accumulation. ```APIDOC ## aidermacs--setup-ediff-cleanup-hooks ### Description Set up hooks to clean up ediff temporary files. ### Parameters None ### Return nil ### Behavior - Adds hooks to clean up temporary buffers used by ediff - Only adds hooks if not already present - Ensures temporary file snapshots don't accumulate ``` -------------------------------- ### aidermacs-list-added-files Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Displays all files currently in the Aider session within a Dired buffer. ```APIDOC ## aidermacs-list-added-files ### Description Display all files currently in the Aider session in a Dired buffer. ### Function Signature ```elisp (aidermacs-list-added-files) ``` ### Parameters None ### Return Value nil ### Behavior - Queries session via `/ls` command. - Creates a special Dired buffer showing added files. - Buffer name includes " Files" suffix. - Includes both editable and read-only files. - Automatically strips the find command line to reduce clutter. ### Example ```elisp (aidermacs-list-added-files) ``` ``` -------------------------------- ### Configure LiteLLM Pricing Cache Duration Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/configuration.md Adjust `aidermacs-litellm-prices-cache-duration` to control how long LiteLLM pricing information is cached, specified in seconds. The default is 86400 seconds (1 day). ```elisp (setq aidermacs-litellm-prices-cache-duration 43200) ; 12 hours ``` -------------------------------- ### Aidermacs Output Structure Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/data-structures.md This pattern illustrates the typical output structure from Aider, including welcome messages, prompts, and responses. Useful for parsing Aider's interactions. ```text [Aider welcome message] [Repo map if applicable] > [user prompt] [Aider thinking/response] > [ready for next command] ``` -------------------------------- ### Add File to Session (Emacs Lisp) Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Adds a file to the current Aider session. The file is added as read-only. If no file path is provided, the user will be prompted to enter one. Supports adding files outside the project directory and directories themselves (with a prompt to add all files within). Dotfiles are excluded when adding directory contents. ```elisp (aidermacs-add-file-to-session &optional FILE) ``` ```elisp (aidermacs-add-file-to-session) ``` ```elisp (aidermacs-add-file-to-session "~/.aider/AI_RULES.md") ``` -------------------------------- ### aidermacs-implement-todo Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Implements TODO comments within the current context, whether it's a selected region, a specific comment line, a function, or the entire file. ```APIDOC ## `aidermacs-implement-todo` ### Description Implement TODO comments in current context. ### Method Elisp function call ### Parameters None ### Request Example ```elisp (aidermacs-implement-todo) ``` ### Response #### Success Response (nil) Returns nil upon successful execution. ``` -------------------------------- ### Emacs Lisp: Debug Exception Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Debug an exception with Aider's assistance. This command uses the '/ask' prefix, prompts for exception details, and includes code context if a region is selected. ```elisp (aidermacs-debug-exception) ``` ```elisp (aidermacs-debug-exception) ; Prompts: "/ask Debug exception:" ``` -------------------------------- ### aidermacs-run-vterm Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-backends.md Launch Aidermacs process using VTerm backend. Creates a VTerm buffer for interactive terminal experience and integrates with Emacs theme colors. ```APIDOC ## `aidermacs-run-vterm` ### Description Launch Aidermacs process using VTerm backend. ### Signature ```elisp (aidermacs-run-vterm PROGRAM ARGS BUFFER-NAME) ``` ### Parameters #### Path Parameters - **PROGRAM** (string) - Required - Path to Aider executable - **ARGS** (list) - Required - Command-line arguments - **BUFFER-NAME** (string) - Required - Name for VTerm buffer ### Return nil ### Behavior - Creates VTerm buffer for interactive terminal experience - Integrates with Emacs theme colors if `aidermacs-vterm-use-theme-colors` is non-nil - Enables file watching for AI instructions - Sets up prompt detection and ready state tracking ``` -------------------------------- ### Aidermacs File Entry Structure Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/data-structures.md Files in a session can be tracked as simple strings representing paths or as association lists with metadata like 'editable' and 'tracked' status. ```elisp "/path/to/file.py" ``` ```elisp '(file-path . ((editable . t) (tracked . t))) ``` -------------------------------- ### aidermacs-project-root Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Retrieves the root directory of the current project. It first attempts to use `vc-git-root`, then falls back to the directory of the current file, and finally defaults to `default-directory`. ```APIDOC ## `aidermacs-project-root` ### Description Get the project root directory. ### Parameters None ### Return string ### Behavior - Tries `vc-git-root` first - Falls back to directory of current file - Falls back to `default-directory` ### Example ```elisp (message "Project root: %s" (aidermacs-project-root)) ``` ``` -------------------------------- ### Parse Output for Files Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-output.md Extracts file names from Aider output text. Handles various file path formats and returns absolute paths ready for diff display. ```elisp (aidermacs--parse-output-for-files OUTPUT) ``` ```elisp (let ((files (aidermacs--parse-output-for-files output))) (dolist (f files) (message "Found: %s" f))) ``` -------------------------------- ### aidermacs-add-file Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Interactively selects and adds a file to the Aider session. It supports adding files or entire directories, and can add them as editable or read-only. ```APIDOC ## aidermacs-add-file ### Description Interactively select and add a file to the Aider session. Prompts user to select file path. If selected path is a directory, prompts for confirmation to add all files. Excludes dotfiles when adding directory contents. Supports both files and directories. ### Method Elisp Function ### Parameters #### Optional Parameters - **READ-ONLY** (boolean) - No - nil - If non-nil (or with C-u prefix), add as read-only ### Return nil ### Example ```elisp (aidermacs-add-file) (aidermacs-add-file t) ``` ``` -------------------------------- ### aidermacs-run-in-directory Source: https://github.com/matthewzmd/aidermacs/blob/main/_autodocs/api-reference-main.md Prompts the user for a directory and then runs Aidermacs with the `--subtree-only` flag within that specified directory. ```APIDOC ## aidermacs-run-in-directory ### Description Prompt for a directory and run Aidermacs with `--subtree-only` flag. ### Method Elisp function call ### Endpoint N/A ### Parameters #### Path Parameters - **DIRECTORY** (string) - Required - Directory path to run Aider in ### Request Example ```elisp (aidermacs-run-in-directory) (call-interactively 'aidermacs-run-in-directory) ``` ### Response Returns nil. ```