branch: elpa/aidermacs commit a684e349e795e0a8f4a406bab59ac6c701224619 Author: Mingde (Matthew) Zeng <matthew...@posteo.net> Commit: Mingde (Matthew) Zeng <matthew...@posteo.net>
Sync with aidermacs-helm and aidermacs-doom. I don't use either, so take these files with a grain of salt. --- aidermacs-doom.el | 86 +++++++++++++++++++++++++++---------------------------- aidermacs-helm.el | 43 ++++++++-------------------- aidermacs.el | 1 - 3 files changed, 55 insertions(+), 75 deletions(-) diff --git a/aidermacs-doom.el b/aidermacs-doom.el index fcdff8fe0d..f314125d1b 100644 --- a/aidermacs-doom.el +++ b/aidermacs-doom.el @@ -20,54 +20,54 @@ (vc-backend (or (buffer-file-name) default-directory))) (map! :leader (:prefix ("A" . "aidermacs") - (:prefix ("a" . "Add") - :desc "Current file" "c" #'aidermacs-add-current-file - :desc "File read-only" "f" #'aidermacs-add-current-file-read-only - :desc "Files in window" "w" #'aidermacs-add-files-in-current-window - :desc "Add Same Type Files under dir" "d" #'aidermacs-add-same-type-files-under-dir - :desc "Add files interactively" "i" #'aidermacs-add-files-interactively - :desc "Batch direct marked files" "b" #'aidermacs-batch-add-dired-marked-files - ) + ;; Core Actions + :desc "Start/Open Session" "." #'aidermacs-run-in-current-dir + :desc "Change Model" "o" #'aidermacs-change-model + :desc "Reset Session" "s" #'aidermacs-reset + :desc "Exit Session" "x" #'aidermacs-exit - (:prefix ("b" . "Buffer") - :desc "Switch to aidermacs" "b" #'aidermacs-switch-to-buffer - :desc "Clear aidermacs" "c" #'aidermacs-clear - ) + ;; Quick Actions + :desc "Add Current File" "f" #'aidermacs-add-current-file + :desc "Code Change" "c" #'aidermacs-code-change + :desc "Refactor" "r" #'aidermacs-function-or-region-refactor + :desc "Go Ahead" "g" #'aidermacs-go-ahead + :desc "Undo Change" "u" #'aidermacs-undo-last-change - (:prefix ("s" . "Send") - :desc "Line at cursor" "l" #'aidermacs-send-line-under-cursor - :desc "Paragraph at cursor, line by line" "p" #'aidermacs-send-region-by-line - :desc "Region as block" "r" #'aidermacs-send-region - ) + ;; File Commands + (:prefix ("F" . "File Commands") + :desc "Add Current File" "f" #'aidermacs-add-current-file + :desc "Add File Interactively" "i" #'aidermacs-add-files-interactively + :desc "Add Current Read-Only" "r" #'aidermacs-add-current-file-read-only + :desc "Add Current Window Files" "w" #'aidermacs-add-files-in-current-window + :desc "Add Current Directory Files" "d" #'aidermacs-add-same-type-files-under-dir + :desc "Add Dired Marked Files" "m" #'aidermacs-batch-add-dired-marked-files + :desc "Drop File Interactively" "j" #'aidermacs-drop-file + :desc "Drop Current File" "k" #'aidermacs-drop-current-file + :desc "List Files" "l" #'aidermacs-list-added-files) - (:prefix ("c" . "Code") - :desc "Architecture" "d" #'aidermacs-architect-discussion - :desc "Change" "c" #'aidermacs-code-change - :desc "Refactor Function or Region" "r" #'aidermacs-function-or-region-refactor - :desc "Implement Requirement in-place" "i" #'aidermacs-implement-todo - :desc "Undo change" "u" #'aidermacs-undo-last-change - :desc "Show last commit" "g" #'aidermacs-magit-show-last-commit - ) + ;; Code Commands + (:prefix ("C" . "Code Commands") + :desc "Code Change" "c" #'aidermacs-code-change + :desc "Refactor Code" "r" #'aidermacs-function-or-region-refactor + :desc "Implement TODO" "i" #'aidermacs-implement-todo + :desc "Write Tests" "t" #'aidermacs-write-unit-test + :desc "Fix Test" "T" #'aidermacs-fix-failing-test-under-cursor + :desc "Debug Exception" "x" #'aidermacs-debug-exception + :desc "Undo Change" "u" #'aidermacs-undo-last-change) - (:prefix ("d" . "Discuss") - :desc "Ask question" "a" #'aidermacs-ask-question - :desc "Explain Function or Region" "r" #'aidermacs-function-or-region-explain - :desc "Exception debugging" "e" #'aidermacs-debug-exception - ) + ;; Understanding + :desc "Show Last Commit" "m" #'aidermacs-magit-show-last-commit + :desc "Ask General Question" "Q" #'aidermacs-ask-question-general + :desc "Ask Question" "q" #'aidermacs-ask-question + :desc "Explain This Code" "e" #'aidermacs-function-or-region-explain + :desc "Explain This Symbol" "p" #'aidermacs-explain-symbol-under-point - (:prefix ("t" . "Test") - :desc "Write Unit Test" "w" #'aidermacs-write-unit-test - :desc "Fix Failed Test" "f" #'aidermacs-fix-failing-test-under-cursor - ) - - (:prefix ("z" . "Other") - :desc "General command" "c" #'aidermacs-general-command - :desc "Help" "h" #'aidermacs-help - ) - - :desc "Open aidermacs" "o" #'aidermacs-run - :desc "Reset aidermacs" "r" #'aidermacs-reset - :desc "Exit aidermacs" "x" #'aidermacs-exit + ;; Others + :desc "Session History" "H" #'aidermacs-show-output-history + :desc "Copy Last Aidermacs Output" "L" #'aidermacs-get-last-output + :desc "Clear Model Selection Cache" "O" #'aidermacs-clear-model-cache + :desc "Clear Buffer" "l" #'aidermacs-clear + :desc "Aider Help" "h" #'aidermacs-help )))) ;; Add the setup function to appropriate hooks diff --git a/aidermacs-helm.el b/aidermacs-helm.el index bd03576ed3..a419ed2d43 100644 --- a/aidermacs-helm.el +++ b/aidermacs-helm.el @@ -1,7 +1,7 @@ ;;; aidermacs-helm.el --- Helm completion for aidermacs.el -*- lexical-binding: t; -*- ;; Author: Mingde (Matthew) Zeng <matthew...@posteo.net> ;; Version: 0.5.0 -;; Package-Requires: ((emacs "26.1") (transient "0.3.0")) +;; Package-Requires: ((emacs "26.1") (helm "3.9.0")) ;; Keywords: ai emacs agents llm aider ai-pair-programming, convenience, tools ;; URL: https://github.com/MatthewZMD/aidermacs.el ;; Originally forked from: Kang Tu <tni...@gmail.com> Aider.el @@ -15,40 +15,21 @@ (require 'helm) (require 'cl-lib) ; For `cl-subseq` -(defun aidermacs-helm-read-string-with-history (prompt history-file-name &optional initial-input) - "Read a string with Helm completion using specified history file. -PROMPT is the prompt string. -HISTORY-FILE-NAME is the base name for history file. -INITIAL-INPUT is optional initial input string." - ;; Load history from file - (let* ((history-file (expand-file-name history-file-name user-emacs-directory)) - (history (when (file-exists-p history-file) - (with-temp-buffer - (insert-file-contents history-file) - (delete-dups (read (buffer-string)))))) - ;; Read input with helm - (input (helm-comp-read - prompt - history - :must-match nil - :name "Helm Read String" - :fuzzy t - :initial-input initial-input))) - ;; Add to history if non-empty and save - (unless (string-empty-p input) - (push input history) - (with-temp-file history-file - (let ((history-entries (cl-subseq history - 0 (min (length history) - 10000)))) ; Keep last 10000 entries - (insert (prin1-to-string history-entries))))) - input)) - (defun aidermacs-helm-read-string (prompt &optional initial-input) "Read a string with Helm completion for aidermacs, showing historical inputs. PROMPT is the prompt string. INITIAL-INPUT is optional initial input string." - (aidermacs-helm-read-string-with-history prompt "aidermacs-helm-read-string-history.el" initial-input)) + (let ((input (helm-comp-read + prompt + aidermacs-read-string-history + :must-match nil + :name "Aidermacs Input" + :fuzzy t + :initial-input initial-input))) + ;; Add to history if non-empty + (unless (string-empty-p input) + (add-to-history 'aidermacs-read-string-history input)) + input)) (declare-function aidermacs-read-string "aidermacs") diff --git a/aidermacs.el b/aidermacs.el index 3dd5316aaa..b7a81914d6 100644 --- a/aidermacs.el +++ b/aidermacs.el @@ -832,5 +832,4 @@ Returns t if the file matches any of the patterns in `aidermacs-auto-mode-files' (aidermacs-minor-mode 1)))) (provide 'aidermacs) - ;;; aidermacs.el ends here