Images with captions
Read an image yourself, pass the bytes with a caption, and get an inline image on iTerm2 and the caption in a pipe, a CI log or an agent's transcript.
image() from the root takes bytes and an optional caption. On a terminal that draws inline
images it is the image; everywhere else it is the caption, so a transcript says what was there
instead of carrying a base64 blob.
import { readFile } from 'node:fs/promises';
import { image } from 'paratext';
const bytes = await readFile(new URL('./chart.mjs', import.meta.url)); // any bytes; a PNG in practice
console.log(image(bytes, { caption: '[chart: build times, last 30 days]', width: '40' }));[chart: build times, last 30 days]paratext never reads the file itself — it has no node:fs dependency (D-030) — so the read,
and its error handling, are yours. A good caption is the sentence a screen reader or an agent
needs: what the image shows, not its filename.
For term-img's API over the same bytes, with its own terminal table and its throw on an
unsupported terminal, use paratext/term-img (Links and images).
A notification when a long task ends
Send an OSC 9 desktop notification on terminals that show one, and print the same message as a line everywhere else — with no native binaries.
Testing escape output
Assert what your CLI writes on a supporting terminal and on a pipe by passing a literal runtime to emit() — no environment patching.