Attachments
A bare string is read as a path, which is the common case. Pass an ImageAttachment for anything that must travel inline.
import { ImageAttachment } from 'activecli';
command.setAttachment('/proj/src/a.ts'); // replaces whatever was therecommand.setAttachments(['/proj/a.ts', '/proj/b.png']);command.setAttachments([new ImageAttachment('shot.png', 'image/png', base64Data)]);
command.attachments; // readonly, and emptied by send()Where each kind lands
Section titled “Where each kind lands”Where each one lands in the message differs by kind, and UserMessage handles that:
| Attachments | message.content |
|---|---|
| None | The prompt as a bare string |
| Paths only | A bare string: paths, blank line, then the prompt |
| Any image | An array of blocks: a text block, then one image block each |
| Images with an empty prompt | Image blocks only — an empty text block would read as the user having said nothing |
Why paths come first
Section titled “Why paths come first”Paths go in front of the prompt so the CLI knows what is being discussed before it reads what is being asked.
Where to go next
Section titled “Where to go next”- Nothing runs until
send()—setAttachmentreplaces,setAttachmentssets the list. - Reference: Command — the attachment properties in full.