Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions pi-coding-agent-menu.el
Original file line number Diff line number Diff line change
Expand Up @@ -1055,18 +1055,29 @@ MESSAGES is a vector of plists from get_fork_messages."

;;;; Custom Commands

(defun pi-coding-agent-run-command (name &optional args)
"Run a pi slash command NAME with optional ARGS.
This is useful for binding extension, skill, or prompt commands from Emacs Lisp."
(interactive
(list (completing-read "Pi command: "
(mapcar (lambda (cmd) (plist-get cmd :name))
pi-coding-agent--commands)
nil t)
(read-string "Args: ")))
(when-let* ((chat-buf (pi-coding-agent--get-chat-buffer)))
(let ((full-command (if (or (null args) (string-empty-p args))
(format "/%s" name)
(format "/%s %s" name args))))
(with-current-buffer chat-buf
(pi-coding-agent--prepare-and-send full-command)))))

(defun pi-coding-agent--run-custom-command (cmd)
"Execute custom command CMD.
Always prompts for arguments - user can press Enter if none needed.
Sends the literal /command text to pi, which handles expansion."
(when-let* ((chat-buf (pi-coding-agent--get-chat-buffer)))
(let* ((name (plist-get cmd :name))
(args-string (read-string (format "/%s: " name)))
(full-command (if (string-empty-p args-string)
(format "/%s" name)
(format "/%s %s" name args-string))))
(with-current-buffer chat-buf
(pi-coding-agent--prepare-and-send full-command)))))
(let* ((name (plist-get cmd :name))
(args-string (read-string (format "/%s: " name))))
(pi-coding-agent-run-command name args-string)))

(defun pi-coding-agent-run-custom-command ()
"Select and run a custom command.
Expand Down