branch: elpa/aidermacs
commit 93340e76f97d342e0d12673e4d7122e318d6cab0
Author: Mingde (Matthew) Zeng <matthew...@posteo.net>
Commit: Mingde (Matthew) Zeng <matthew...@posteo.net>

    Add aidermacs-default-model and aidermacs-args options
---
 README.md                   | 24 +++++++++++++++++++++++-
 aidermacs-backend-comint.el |  2 +-
 aidermacs-models.el         | 15 ++++++++++-----
 aidermacs.el                | 38 ++++++++++++++++++++------------------
 4 files changed, 54 insertions(+), 25 deletions(-)

diff --git a/README.md b/README.md
index 57ffbf0358..fbf1f62300 100644
--- a/README.md
+++ b/README.md
@@ -86,11 +86,33 @@ With `Aidermacs`, you get:
 (use-package aidermacs
   :straight (:host github :repo "MatthewZMD/aidermacs" :files ("*.el"))
   :config
-  (setq aidermacs-args '("--model" "anthropic/claude-3-5-sonnet-20241022"))
+  (setq aidermacs-default-model "anthropic/claude-3-5-sonnet-20241022")
   (setenv "ANTHROPIC_API_KEY" anthropic-api-key)
   (global-set-key (kbd "C-c a") 'aidermacs-transient-menu))
 ```
 
+### Default Model Selection
+
+You can customize the default AI model used by Aidermacs by setting the 
`aidermacs-default-model` variable:
+
+```emacs-lisp
+(setq aidermacs-default-model "anthropic/claude-3-5-sonnet-20241022")
+```
+
+This allows you to easily switch between different AI models without modifying 
the `aidermacs-args` variable.
+
+### Customizing Aider Options with `aidermacs-args`
+
+The `aidermacs-args` variable allows you to pass any command-line options 
supported by Aider. See the [Aider configuration 
documentation](https://aider.chat/docs/config/options.html) for a full list of 
available options.
+
+For example, to set the verbosity:
+
+```emacs-lisp
+(setq aidermacs-args '("--verbose"))
+```
+
+These arguments will be appended to the Aider command when it is run. Note 
that the `--model` argument is automatically handled by 
`aidermacs-default-model` and should not be included in `aidermacs-args`.
+
 ### Sample Config With Doom Emacs
 ```emacs-lisp
 (package! aidermacs :recipe (:host github :repo "MatthewZMD/aidermacs" :files 
("*.el")))
diff --git a/aidermacs-backend-comint.el b/aidermacs-backend-comint.el
index f489eb56ac..5d05bce041 100644
--- a/aidermacs-backend-comint.el
+++ b/aidermacs-backend-comint.el
@@ -229,7 +229,7 @@ This allows for multi-line input without sending the 
command."
 (defun aidermacs-run-comint (program args buffer-name)
   "Create a comint-based buffer and run aidermacs PROGRAM with ARGS in 
BUFFER-NAME."
   (let ((comint-terminfo-terminal "eterm-color")
-        (args (append (list "--no-pretty" "--no-fancy-input") args)))
+        (args (append args (list "--no-pretty" "--no-fancy-input"))))
     (unless (comint-check-proc buffer-name)
       (apply 'make-comint-in-buffer "aidermacs" buffer-name program nil args)
       (with-current-buffer buffer-name
diff --git a/aidermacs-models.el b/aidermacs-models.el
index a011952aad..fbd0052fee 100644
--- a/aidermacs-models.el
+++ b/aidermacs-models.el
@@ -15,12 +15,17 @@
   "Model selection customization for aidermacs."
   :group 'aidermacs)
 
+(defcustom aidermacs-default-model "anthropic/claude-3-5-sonnet-20241022"
+  "Default AI model to use for aidermacs sessions."
+  :type 'string
+  :group 'aidermacs-models)
+
 (defcustom aidermacs-popular-models
-  '("anthropic/claude-3-5-sonnet-20241022"  ;; really good in practical
-    "o3-mini" ;; very powerful
-    "gemini/gemini-2.0-flash"  ;; free
-    "r1"  ;; performance match o1, price << claude sonnet. weakness: small 
context
-    "deepseek/deepseek-chat"  ;; chatgpt-4o level performance, price is 1/100. 
weakness: small context
+  '("anthropic/claude-3-5-sonnet-20241022"
+    "o3-mini"
+    "gemini/gemini-2.0-flash"
+    "r1"
+    "deepseek/deepseek-chat"
     )
   "List of available AI models for selection.
 Each model should be in the format expected by the aidermacs command line 
interface.
diff --git a/aidermacs.el b/aidermacs.el
index eecef7aa8c..1ef6167311 100644
--- a/aidermacs.el
+++ b/aidermacs.el
@@ -34,8 +34,9 @@
   :type 'string
   :group 'aidermacs)
 
-(defcustom aidermacs-args '("--model" "anthropic/claude-3-5-sonnet-20241022")
-  "Arguments to pass to the aidermacs command."
+(defcustom aidermacs-args nil
+  "Additional arguments to pass to the aidermacs command.
+The model argument will be added automatically based on 
`aidermacs-default-model'."
   :type '(repeat string)
   :group 'aidermacs)
 
@@ -205,7 +206,7 @@ Prefers existing sessions closer to current directory."
           (mapcar
            (lambda (buf)
              (when (string-match "^\\*aidermacs:\\(.*?\\)\\*$"
-                               (buffer-name buf))
+                                 (buffer-name buf))
                (cons (match-string 1 (buffer-name buf))
                      (match-string 2 (buffer-name buf)))))
            aidermacs-buffers))
@@ -224,12 +225,12 @@ Prefers existing sessions closer to current directory."
                ;; Sort by path length (deeper paths first)
                (> (length (car a)) (length (car b))))))))
          (display-root (cond
-                       ;; Use current directory for new subtree session
-                       (aidermacs-subtree-only current-dir)
-                       ;; Use closest parent if it exists
-                       (closest-parent closest-parent)
-                       ;; Fall back to project root for new non-subtree session
-                       (t root))))
+                        ;; Use current directory for new subtree session
+                        (aidermacs-subtree-only current-dir)
+                        ;; Use closest parent if it exists
+                        (closest-parent closest-parent)
+                        ;; Fall back to project root for new non-subtree 
session
+                        (t root))))
     (format "*aidermacs:%s*"
             (file-truename display-root))))
 
@@ -240,14 +241,15 @@ With the universal argument EDIT-ARGS, prompt to edit 
aidermacs-args before runn
   (interactive "P")
   (let* ((buffer-name (aidermacs-buffer-name))
          (current-args (if edit-args
-                          (split-string (read-string "Edit aidermacs 
arguments: "
-                                                   (mapconcat 'identity 
aidermacs-args " ")))
-                        aidermacs-args))
-         (final-args (append current-args
-                           (unless aidermacs-auto-commits
-                             '("--no-auto-commits"))
-                           (when aidermacs-subtree-only
-                             '("--subtree-only")))))
+                           (split-string (read-string "Edit aidermacs 
arguments: "
+                                                      (mapconcat 'identity 
aidermacs-args " ")))
+                         aidermacs-args))
+         (final-args (append (list "--model" aidermacs-default-model)
+                             current-args
+                             (unless aidermacs-auto-commits
+                               '("--no-auto-commits"))
+                             (when aidermacs-subtree-only
+                               '("--subtree-only")))))
     ;; Check if a matching buffer exists (handled by aidermacs-buffer-name)
     (if (get-buffer buffer-name)
         (aidermacs-switch-to-buffer)
@@ -262,7 +264,7 @@ This is useful for working in monorepos where you want to 
limit aider's scope."
   (interactive)
   (let ((aidermacs-subtree-only t)
         (default-directory (file-truename default-directory)))
-    (aidermacs-run nil)))
+    (aidermacs-run)))
 
 (defun aidermacs--send-command (command &optional switch-to-buffer)
   "Send COMMAND to the corresponding aidermacs process.

Reply via email to