Skip to content

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 there
command.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 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

Paths go in front of the prompt so the CLI knows what is being discussed before it reads what is being asked.