branch: externals/ellama
commit 72a52f787752f2d19830038b1689fe9c2b0a613e
Author: Sergey Kostyaev <[email protected]>
Commit: Sergey Kostyaev <[email protected]>

    Add blueprint plan-and-act menu action
    
    Added a blueprint-mode transient action that starts a plan-and-act agent 
loop from the current blueprint buffer and then closes that buffer.
    
    Added regression coverage for forwarding the blueprint buffer contents into 
ellama-plan-and-act and killing the source buffer after the loop starts.
---
 ellama-transient.el            | 11 ++++++++++-
 tests/test-ellama-transient.el | 22 ++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/ellama-transient.el b/ellama-transient.el
index aa6e0bdd5be..8963b47930e 100644
--- a/ellama-transient.el
+++ b/ellama-transient.el
@@ -988,7 +988,8 @@ ARGS used for transient arguments."
 (transient-define-prefix ellama-transient-blueprint-mode-menu ()
   ["Blueprint Commands"
    ["Chat"
-    ("c" "Send to chat" ellama-send-buffer-to-new-chat-then-kill)]
+    ("c" "Send to chat" ellama-send-buffer-to-new-chat-then-kill)
+    ("a" "Plan and act" ellama-transient-plan-and-act-buffer-then-kill)]
    ["System Message"
     ("s" "Set system and chat" ellama-blueprint-chat-with-system-kill-buffer)
     ("S" "Set system and quit" ellama-blueprint-set-system-kill-buffer)]
@@ -1000,6 +1001,14 @@ ARGS used for transient arguments."
     ("k" "Kill" ellama-kill-current-buffer)
     ("q" "Quit" transient-quit-one)]])
 
+(transient-define-suffix ellama-transient-plan-and-act-buffer-then-kill ()
+  "Start a plan-and-act agent loop from current buffer and kill it."
+  (interactive)
+  (ellama-plan-and-act
+   (buffer-substring-no-properties (point-min) (point-max))
+   t)
+  (ellama-kill-current-buffer))
+
 ;;;###autoload (autoload 'ellama-transient-tools-menu "ellama-transient" nil t)
 (transient-define-prefix ellama-transient-tools-menu ()
   ["Tools Commands"
diff --git a/tests/test-ellama-transient.el b/tests/test-ellama-transient.el
index 514b8f4d04f..45fd004f360 100644
--- a/tests/test-ellama-transient.el
+++ b/tests/test-ellama-transient.el
@@ -549,6 +549,28 @@
     (should (equal (nreverse chat-calls)
                    '(("Ask me" t (:ephemeral t)))))))
 
+(ert-deftest test-ellama-transient-plan-and-act-buffer-then-kill ()
+  (let ((buffer (generate-new-buffer "*ellama-blueprint-agent-test*"))
+        call
+        killed-buffer)
+    (unwind-protect
+        (progn
+          (with-current-buffer buffer
+            (insert "Implement the blueprint")
+            (cl-letf (((symbol-function 'ellama-plan-and-act)
+                       (lambda (prompt create-session &rest rest)
+                         (setq call (list prompt create-session rest))))
+                      ((symbol-function 'ellama-kill-current-buffer)
+                       (lambda ()
+                         (setq killed-buffer (current-buffer))
+                         (kill-buffer (current-buffer)))))
+              (ellama-transient-plan-and-act-buffer-then-kill)))
+          (should (equal call '("Implement the blueprint" t nil)))
+          (should (eq killed-buffer buffer))
+          (should-not (buffer-live-p buffer)))
+      (when (buffer-live-p buffer)
+        (kill-buffer buffer)))))
+
 (ert-deftest test-ellama-transient-add-image-uses-ephemeral-flag ()
   (let (calls)
     (cl-letf (((symbol-function 'ellama-context-add-image)

Reply via email to