Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,16 @@ All of the above settings can be applied on a per-project basis using [[https://
- =C-c C-c= - Interrupt current agent operation
- =TAB and Shift-TAB= - Navigate interactive elements

When an ACP agent requests structured input, agent-shell displays the
authoritative shell and renders the form inline there. =TAB= and =Shift-TAB=
include its fields, options, and actions in normal interactive-element
navigation. Press =RET= to edit a value, toggle an option, or activate
=Submit=, =Decline=, or =Cancel=.

Form elicitation must not be used for passwords, API keys, access tokens,
payment credentials, or other secrets. agent-shell currently supports
form elicitation only; it does not advertise URL-mode elicitation.

To customize =RET= binding behaviour, you can use something like:

#+begin_src emacs-lisp :lexical no
Expand Down
26 changes: 18 additions & 8 deletions agent-shell-chat-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ so a label following it needs a full pad rather than a single newline."
(or (= beg (point-min))
(eq (char-before beg) ?\n))))

(cl-defun agent-shell-chat--ensure-overlay (&key tag beg end props rear-advance
(anchor-beg beg)
(anchor-end end))
(cl-defun agent-shell-chat--ensure-overlay
(&key tag beg end props front-advance rear-advance
(anchor-beg beg) (anchor-end end))
"Ensure a TAG overlay spans BEG..END carrying PROPS.

TAG is a symbol naming what the overlay is for (`me', `agent' and so
Expand All @@ -182,14 +182,21 @@ agent event, and each overlay write dirties its span for redisplay.
ANCHOR-BEG..ANCHOR-END default to the span, and are widened only where
an overlay is expected to sit somewhere its span no longer covers.

With REAR-ADVANCE non-nil the overlay takes in text inserted at its end
and is not `evaporate'd while empty, so it can hold properties over an
input still being typed: relabeling is event-driven, so an overlay that
stopped at the caret would never grow to cover what follows it."
FRONT-ADVANCE and REAR-ADVANCE control whether text inserted at the
corresponding boundary remains outside or enters the overlay. Live
prompt decoration uses FRONT-ADVANCE so fragments inserted immediately
before it do not become prompt chrome or disappear behind its `display'
properties. With REAR-ADVANCE non-nil
the overlay takes in text inserted at its end and is not `evaporate'd
while empty, so it can hold properties over an input still being typed:
relabeling is event-driven, so an overlay that stopped at the caret
would never grow to cover what follows it."
(let ((overlay (or (seq-find (lambda (overlay)
(eq (overlay-get overlay 'agent-shell-chat--tag) tag))
(overlays-in anchor-beg (max anchor-end (1+ anchor-beg))))
(let ((created (make-overlay beg end nil nil rear-advance)))
(let ((created
(make-overlay beg end nil
front-advance rear-advance)))
(overlay-put created 'agent-shell-chat--tag tag)
(unless rear-advance
(overlay-put created 'evaporate t))
Expand Down Expand Up @@ -562,6 +569,7 @@ above, putting the first line of a multi-line input out of reach of
(push
(agent-shell-chat--ensure-overlay
:tag 'me-surplus :beg start :end label-nl
:front-advance t
:props (list (cons 'display "")
(cons 'line-prefix "")
(cons 'wrap-prefix "")))
Expand All @@ -572,13 +580,15 @@ above, putting the first line of a multi-line input out of reach of
(push
(agent-shell-chat--ensure-overlay
:tag 'me-label :beg label-nl :end pos
:front-advance t
:props (list (cons 'before-string before)
(cons 'line-prefix "")
(cons 'wrap-prefix "")))
kept))
(push
(agent-shell-chat--ensure-overlay
:tag 'me :beg (if label-nl pos start) :end end
:front-advance t
;; Anchor on the prompt run, which the span may start before: the
;; span's start flips with `label-nl', and reuse has to survive
;; that flip rather than strand the overlay it should have moved.
Expand Down
Loading