branch: elpa/aidermacs commit b63a8d168a4a2f2aa1bfa5beedd009eb9e3d31d8 Author: Kang Tu <tni...@gmail.com> Commit: GitHub <nore...@github.com>
Feat: Enhance aider-implement-todo (#61) * feat: Add aider-implement-todo function to implement TODOs in current context * feat: Add `aider-implement-todo` function description to README * docs(readme): update aider command description * refactor: Add comment line detection to aider-implement-todo for more precise implementation context * fix: improve prompt clarity for comment implementation * docs(aider-implement-todo): clarify cursor-on-comment behavior * feat: update default AI models list and order in config --------- Co-authored-by: Kang Tu <kang...@apple.com> --- README.org | 9 ++++++--- aider.el | 21 +++++++++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/README.org b/README.org index 5f36d15971..9544b60b1a 100644 --- a/README.org +++ b/README.org @@ -28,11 +28,11 @@ When being called with the universal argument (`C-u`), a prompt will offer the u *** Model Selection: - (`aider-change-model`): Interactively select and change AI model in current aider session - Customize `aider-popular-models` to define your preferred models list. Default models are (as date of 2025-01-26): - - gemini/gemini-exp-1206 (free) - anthropic/claude-3-5-sonnet-20241022 (really good in practical) + - gpt-4o-mini + - gemini/gemini-exp-1206 (free) - r1 (performance matches o1, price << claude sonnet. weakness: small context) - deepseek/deepseek-chat (chatgpt-4o level performance, price is 1/100. weakness: small context) - - gpt-4o-mini *** More ways to add files to the Aider buffer: - use "@" in the menu to toggle add file between read-write mode and read-only mode @@ -43,7 +43,10 @@ When being called with the universal argument (`C-u`), a prompt will offer the u *** Write code: - (`aider-function-or-region-refactor`): If a region is selected, ask Aider to refactor the selected region. Otherwise, ask Aider to change / refactor the function under the cursor. - - (`aider-implement-todo`): Implement TODO comments in current context. If cursor is inside a function, implement TODOs for that function. Otherwise implement TODOs for the entire current file. + - (`aider-implement-todo`): Implement TODO comments in current context. + - If cursor is on a comment line, implement that specific comment. + - If cursor is inside a function, implement TODOs for that function. + - Otherwise implement TODOs for the entire current file. *** Explain code: - (`aider-ask-question`): Ask Aider a question about the code in the current context. If a region is selected, use the region as context. diff --git a/aider.el b/aider.el index 2f26ee6951..a94004ae94 100644 --- a/aider.el +++ b/aider.el @@ -27,7 +27,7 @@ :type 'string :group 'aider) -(defcustom aider-args '("--model" "gemini/gemini-exp-1206") +(defcustom aider-args '("--model" "anthropic/claude-3-5-sonnet-20241022") "Arguments to pass to the Aider command." :type '(repeat string) :group 'aider) @@ -624,18 +624,27 @@ This function assumes the cursor is on or inside a test function." ;;;###autoload (defun aider-implement-todo () "Implement TODO comments in current context. +If cursor is on a comment line, implement that specific comment. If cursor is inside a function, implement TODOs for that function. Otherwise implement TODOs for the entire current file." (interactive) (if (not buffer-file-name) (message "Current buffer is not visiting a file.") - (let* ((function-name (which-function)) + (let* ((current-line (string-trim (thing-at-point 'line t))) + (is-comment (and comment-start + (string-prefix-p comment-start (string-trim-left current-line)))) + (function-name (which-function)) (initial-input - (if function-name - (format "Please implement the TODO items in function '%s'. Keep the existing code structure and only implement the TODOs in comments." - function-name) + (cond + (is-comment + (format "Please implement this comment: '%s'. It is already inside current code. Please do in-place implementation. Keep the existing code structure and implement just this specific comment." + current-line)) + (function-name + (format "Please implement the TODO items in function '%s'. Keep the existing code structure and only implement the TODOs in comments." + function-name)) + (t (format "Please implement all TODO items in file '%s'. Keep the existing code structure and only implement the TODOs in comments." - (file-name-nondirectory buffer-file-name)))) + (file-name-nondirectory buffer-file-name))))) (user-command (aider-read-string "TODO implementation instruction: " initial-input)) (command (format "/architect %s" user-command))) (aider-add-current-file)