branch: elpa/aidermacs
commit b56492f4f131c8b592d0a65604d5a7b2feab9bba
Author: Kang Tu <kang...@apple.com>
Commit: tninja <tni...@gmail.com>

    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
---
 README.org |  5 +++--
 aider.el   | 21 +++++++++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/README.org b/README.org
index bd4013ee21..5f36d15971 100644
--- a/README.org
+++ b/README.org
@@ -41,8 +41,9 @@ When being called with the universal argument (`C-u`), a 
prompt will offer the u
   - (`aider-add-same-type-files-under-dir`): Add all files with the same 
suffix as the current file under the current directory to Aider.
   - (`aider-batch-add-dired-marked-files`): Add multiple Dired marked files to 
the Aider buffer.
 
-*** Refactor code:
-  - (`aider-function-or-region-refactor`): If a region is selected, ask Aider 
to refactor the selected region. Otherwise, ask Aider to refactor the function 
under the cursor.
+*** 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.
 
 *** 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 82651c876c..2f26ee6951 100644
--- a/aider.el
+++ b/aider.el
@@ -139,6 +139,7 @@ Affects the system message too.")
     ("r" "Refactor Function or Region" aider-function-or-region-refactor)
     ("U" "Write Unit Test" aider-write-unit-test)
     ("T" "Fix Failing Test Under Cursor" aider-fix-failing-test-under-cursor)
+    ("i" "Implement TODOs" aider-implement-todo)
     ("m" "Show Last Commit with Magit" aider-magit-show-last-commit)
     ("u" "Undo Last Change" aider-undo-last-change)
     ]
@@ -620,6 +621,26 @@ This function assumes the cursor is on or inside a test 
function."
         (aider--send-command command t))
     (message "No test function found at cursor position.")))
 
+;;;###autoload
+(defun 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."
+  (interactive)
+  (if (not buffer-file-name)
+      (message "Current buffer is not visiting a file.")
+    (let* ((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)
+              (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))))
+           (user-command (aider-read-string "TODO implementation instruction: 
" initial-input))
+           (command (format "/architect %s" user-command)))
+      (aider-add-current-file)
+      (aider--send-command command t))))
+
 ;;; Model selection functions
 ;;;###autoload
 (defun aider-change-model ()

Reply via email to