Claude's answers, rendered: Markdown, math, charts and diagrams drawn in the Claude Code terminal. Independent project, not affiliated with Anthropic.
TypeScript claude-code-mod
Docs: shorter and plainer install, usage, privacy, themes, how it works, development, gallery and limitations
razorback162f80728010a6
diff --git a/docs/development.md b/docs/development.mdindex c1ef11a..d8c5157 100644--- a/docs/development.md+++ b/docs/development.md@@ -10,54 +10,110 @@ cd cc-intelligent-uiclaude --plugin-dir . # once: Claude Code writes the API types to .claude-plugin/types/npx -p typescript tsc -p . # type checkclaude plugin test . # tests-sh tests/cache-sh-test.sh # the cache folder sweep (CACHE_SH) in sh, dash and bash --posix-sh tests/fonts-sh-test.sh # the copy of a font out of a terminal's program (PROGRAM_FONTS_SH and _PL) with perl-sh tests/bold-sh-test.sh # the fake bold of md.typ (term-bold=0) with the real Typst and Monaco (skips with no Monaco)-sh tests/code-sh-test.sh # code blocks of md.typ (width, header, copy button mark, row grid) with the real Typst (skips with no typst)-sh tests/root-sh-test.sh # the Typst root of a compile (STAGE_SH): answer code reads no other file, with the real Typst (its compiles skip with no typst)-sh tests/fill-sh-test.sh # the root of a pasted image's preview (FILL_SH): only fill.typ and the pasted file, with the real Typst (its compiles skip with no typst)-sh tests/check-sh-test.sh # the skill's check.sh: a private cache folder, and a block reads no other file (skips with no Typst 0.15)-sh tests/footprint-sh-test.sh # release gate: the validator's footprint is whole (no [+N chars] mark, calls line of 850 characters at most)-sh tests/gap-sh-test.sh # the gap at a page break of md.typ (seams), on and off the row grid, with the real Typst (skips with no typst)-sh tests/flip-sh-test.sh # the write of a flipped PNG or a frame (WRITE_PL) with the real perl, also two writers of one file at once-sh tests/herdr-sh-test.sh # the herdr client finder (HERDR_CLIENT_SH) with fake ps, stat, lsof and lsappinfo, in sh, dash and bash-sh tests/install-sh-test.sh # the installer site/install.sh in a sandbox HOME with a fake claude, curl and uname (shellcheck when installed)+sh tests/cache-sh-test.sh # cache folder sweep, in sh, dash and bash --posix+sh tests/fonts-sh-test.sh # copying a font out of a terminal program+sh tests/bold-sh-test.sh # fake bold with real Typst and Monaco (skips with no Monaco)+sh tests/code-sh-test.sh # code blocks: width, header, copy button, row grid (skips with no typst)+sh tests/root-sh-test.sh # the Typst root: answer code reads no other file (compiles skip with no typst)+sh tests/fill-sh-test.sh # the paste preview root: only fill.typ and the image (compiles skip with no typst)+sh tests/check-sh-test.sh # the skill's check.sh: private cache, no other file read (skips with no Typst 0.15)+sh tests/footprint-sh-test.sh # release gate: the validator footprint is whole+sh tests/gap-sh-test.sh # the gap at a page break, on and off the row grid (skips with no typst)+sh tests/flip-sh-test.sh # writing a flipped PNG or frame with real perl, also two writers at once+sh tests/herdr-sh-test.sh # the herdr client finder with fake ps, stat, lsof and lsappinfo+sh tests/install-sh-test.sh # site/install.sh in a sandbox HOME (shellcheck when installed)claude plugin validate .```-`.claude-plugin/types/` is not in git. `tsconfig.json` extends the `tsconfig.json` in it, so run Claude Code with the folder once before `tsc`.+`.claude-plugin/types/` is not in git. `tsconfig.json` extends the one in it, so run Claude Code with the folder once before `tsc`.## Release-Claude Code updates the mod only when the `version` in `.claude-plugin/plugin.json` changes. For a release, change the version and `CHANGELOG.md`, run the tests above, and tag the commit `v<version>`. Deploy the site together with the release: it serves `site/install.sh` at https://intelligentui.art/install.sh. After the deploy, check that the script is there:+1. **Bump the version** in `.claude-plugin/plugin.json`. Claude Code updates the mod only when this changes.+2. **Add a section** to `CHANGELOG.md`.+3. **Run the tests** above.+4. **Tag the commit** `v<version>`:-```-curl -fsSL https://intelligentui.art/install.sh | head -1 # #!/usr/bin/env bash-```+ ```+ git tag -a v<version> -m "cc-intelligent-ui <version>"+ ```++5. **Deploy the site** with the release. It serves `site/install.sh` at https://intelligentui.art/install.sh, and `.github/workflows/pages.yml` deploys it on a push to `main` that changes `site/`. Then check that the script is there:++ ```+ curl -fsSL https://intelligentui.art/install.sh | head -1 # #!/usr/bin/env bash+ ```## Debug log-Set `IUI_DEBUG=1` before you start Claude Code. The mod then writes trace lines to `debug.log` in the cache folder (`${TMPDIR}/cc-intelligent-ui-<uid>/`, `/tmp` when `TMPDIR` is not set).+Set `IUI_DEBUG=1` before you start Claude Code. The mod then writes `debug.log` in the cache folder (`${TMPDIR}/cc-intelligent-ui-<uid>/`, `/tmp` when `TMPDIR` is not set).-Picture select writes trace lines that start with `select:`:+Picture select lines start with `select:`:-- `select: <phase> #<order> ...`: one line for each post of a `Client`. It gives the phase and the order, the drawing's id, the page, the anchor and the head (the `Client`'s cells), the size of the `Client`'s region, the page's size in cells, the rows of the message on screen (`onScreen`), the page's top row in the message, its rows above the screen (`above`), and the selected rows of each page.-- `select: blit <id> page <n> rows <a>..<b> (<count>)` (or `plain`): one line for each blit of the highlight. It gives the time that the frame waited for the page cache (`wait`, 0 when the page is ready), the times to make the frame (`frame`) and to write it (`write`), the frame's bytes, and the time of `$.ui.blit` (`blit`).-- `select: cache start|first|pause|resume|stop|drop|built ...`: the page cache. `drop` is a page file that no drawing uses now (a redraw). `start` gives the time to read the PNG and the pages in the queue. `first` is a `down` on a page that is not ready. `built` gives the page's size, `ready in` (the time until a frame can be made), `done in` (the time until the tinted pieces are made too), the read, the number of slices, their max and their p95, the pages kept with their MB, and the pages in the queue.-- `select: words <id> page <n> <k> words in <ms> (background)`: the background probe of a page's words (`none` when it found no words).-- `select: copy <n> chars <ms>ms after the up (text <ms>ms, words cached | words probed for page <n>); native selection seen (...) | no native selection`: the copy at `up`, and whether Claude Code has a selection of its own with picture cells.+- `select: <phase> #<order> ...`: each `Client` post. The drawing's id, page, anchor and head, the region size, the page size in cells, the message rows on screen (`onScreen`), the page's top row, its rows above the screen (`above`), and the selected rows of each page.+- `select: blit <id> page <n> rows <a>..<b> (<count>)` (or `plain`): each highlight blit. Time waiting for the page cache (`wait`), to make the frame (`frame`), to write it (`write`), the frame's bytes, and the `$.ui.blit` time (`blit`).+- `select: cache start|first|pause|resume|stop|drop|built ...`: the page cache. `start`: PNG read time and queue. `first`: a `down` on a page that is not ready. `drop`: a page file no longer drawn. `built`: size, `ready in`, `done in`, read time, slice count, max and p95, pages kept with their MB, and queue.+- `select: words <id> page <n> <k> words in <ms> (background)`: the background word probe (`none` when it found no words).+- `select: copy <n> chars <ms>ms after the up (text <ms>ms, words cached | words probed for page <n>); native selection seen (...) | no native selection`: the copy at `up`, and whether Claude Code has its own selection with picture cells.- `select: native copy seen: ...`: picture cells on the clipboard, or a `$.ui.copy` with picture cells.-- `select: hover <id> page <n> target <i> (<kind>) rows <row>:<x0>-<x1>,...` (or `select: hover none`): the target under the pointer changed (`web`, `file`, `command` or `code`, and its cells; `code` is the copy button of a code block).-- `select: click <id> page <n> at <x>,<y> target <kind>|none`: one line for each click (a `clear`), with the target that it copies.+- `select: hover <id> page <n> target <i> (<kind>) rows <row>:<x0>-<x1>,...` (or `select: hover none`): the target under the pointer changed. Kind is `web`, `file`, `command` or `code` (a code block's copy button).+- `select: click <id> page <n> at <x>,<y> target <kind>|none`: each click (a `clear`) and the target it copies.## Module layout-The hooks module is `hooks/register.tsx`. It connects the hooks to the modules in `hooks/lib/`. Each module has one topic, for example `markdown.ts` (blocks and segments), `mode.ts` (light or dark), `typst.ts` (compile), `fonts.ts` (the lean font set: the fonts that a compile of plain text loads), `draw.tsx` (the pages of an answer and the link rows under them), `links.ts` (the links, file paths and commands of a text), `answer.ts` (one text through the compile and cache steps), `plan.tsx` (the plan approval question and the plan rows), `composer.tsx` (the previews of the images pasted in the draft, above the prompt box, and the files of pasted image paths, from one clipboard read), `frame.ts` (the terminal size and the watcher process, which also reports the clipboard changes), `clipboard.ts` (how the clipboard is read and watched for the `/iui grab` toast and read for a pasted image path: macOS, or the Linux tools), `copy.ts` (the text under a mouse selection of pictures), `select.ts` and `blit.ts` (picture select and its highlight), `frames.ts` (the frames of a page: the cell edges, the bands, the row pieces and the frame PNG), `pagecache.ts` (the background page cache: the build queue in slices, and the words probe), `png.ts` (PNG decode, also in steps, and the deflate pieces, in plain JavaScript), `flip.ts` (herdr in iTerm2: the pages and pictures stored with the bands of their rows moved), `probe.ts` (the drawn pages, and the words of a page that a copy reads, kept in memory) and `updates.ts` (the daily check for a new version). The values that change are in one object, `S`, in `state.ts`. The hook bodies in `register.tsx` call `$` themselves; every other `$` call is a wrapper with a short name in `api.ts` (for example `cat` for `$.fs.read`, `exec` for `$.process.run`). The `calls:` note of `claude plugin validate` names each method with the wrappers that call it (`via cat`), and a method that a hook body calls with none. The validator cuts a note at about 1,000 characters and marks the cut `[+N chars]`; the catalogue scan then cannot read the footprint. `tests/footprint-sh-test.sh` is the release gate for this: it fails on a `[+N chars]` mark in the text or the `--json` report, on a calls line (the text after `calls: `) of more than 850 characters, and on a `$` call in `hooks/` outside `api.ts` and `register.tsx`. The tests import from `hooks/register.tsx`, which exports the names that they use.--The skill for Claude is in `skills/intelligent-ui/`: `SKILL.md` (the contract, the workflow and an index), `references/` (one file for each topic: Typst, fletcher, CeTZ, plots and charts) and `scripts/check.sh` (the compile check, with the real template). `TYPST_PROMPT` in `hooks/lib/settings.ts` tells Claude when to load it.--The Typst template is `render/md.typ`. The themes are in `render/themes/` (refer to [`render/themes/README.md`](../render/themes/README.md)). The vendored Typst packages are in `render/packages/preview/`.--## Marketing images--`outcomes/build.sh` renders the samples in `outcomes/samples/` and frames them into the images in `outcomes/out/`. Refer to the [Gallery](gallery.md).+`hooks/register.tsx` is the hooks module. It connects the hooks to the modules in `hooks/lib/`, one topic each:++| Module | Topic |+| --- | --- |+| `answer.ts` | One text through compile and cache, and its states before it is ready |+| `api.ts` | The wrappers for every `$` call outside `register.tsx` |+| `blit.ts` | Picture select's highlight with `$.ui.blit` |+| `clipboard.ts` | Reading and watching the clipboard, on macOS and Linux |+| `command.ts` | The `/iui` command and its typeahead |+| `composer.tsx` | Previews of pasted images and pasted image paths |+| `copy.ts` | The text under a mouse selection of pictures |+| `designs.ts` | The drawing space kept per answer across sessions |+| `draw.tsx` | The pages of an answer and the link rows under them |+| `env.ts` | Setup at load: cache folder, Typst, terminal, font, theme |+| `epoch.ts` | Swapping all pictures at once after a resize or setting change |+| `flip.ts` | herdr in iTerm2: pictures stored with row bands reversed |+| `fonts.ts` | The lean font set |+| `frame.ts` | Terminal size and the watcher process |+| `frames.ts` | A page's frames: cell edges, row pieces, frame PNG |+| `grid.ts` | The row grid's first-line position |+| `host.ts` | Shell snippets: tty size, terminal font, light or dark for `auto` |+| `images.ts` | Which images, PDFs and Markdown files a message names |+| `links.ts` | Links, file paths and commands in a text |+| `log.ts` | The debug log |+| `markdown.ts` | Blocks, fences and segments |+| `mode.ts` | Light or dark (pure) |+| `pagecache.ts` | The background page cache and word probe |+| `pictures.tsx` | Files Claude sends: images, PDFs, Markdown |+| `plan.tsx` | The plan approval question and plan rows |+| `png.ts` | PNG decode and deflate pieces in plain JavaScript |+| `probe.ts` | Drawn pages and their words, in memory |+| `select.ts` | Picture select |+| `settings.ts` | Sizes, limits, timings, and the system prompt text |+| `setup.ts` | `/iui setup` for iTerm2 and herdr |+| `state.ts` | Shared types and the state object `S` |+| `stream.ts` | Streaming and the compile queue |+| `targets.ts` | Click targets on a page |+| `terminal.ts` | What the terminal can draw |+| `terminals.ts` | Each terminal's config: background and font |+| `themes.ts` | Themes and `/iui theme` |+| `typst.ts` | Finding Typst, measuring fonts, compiling, the Typst root |+| `updates.ts` | The daily check for a new version |++`hooks/sel.tsx` is picture select's `Client`. The tests import from `hooks/register.tsx`, which exports the names they use.++**Footprint gate.** Only hook bodies in `register.tsx` and the wrappers in `api.ts` call `$` (for example `cat` wraps `$.fs.read`, `exec` wraps `$.process.run`). The `calls:` note of `claude plugin validate` names each method and its wrappers (`via cat`). The validator cuts that note at about 1,000 characters and marks the cut `[+N chars]`, and then the catalogue scan cannot read the footprint. `tests/footprint-sh-test.sh` fails on:++- a `[+N chars]` mark in the text or the `--json` report,+- a calls line (the text after `calls: `) over 850 characters,+- a `$` call in `hooks/` outside `api.ts` and `register.tsx`.++## Other parts++- **The skill** is in `skills/intelligent-ui/`: `SKILL.md` (contract, workflow, index), `references/` (Typst, fletcher, CeTZ, plots and charts) and `scripts/check.sh` (compile check with the real template). `TYPST_PROMPT` in `hooks/lib/settings.ts` tells Claude when to load it.+- **The template** is `render/md.typ`. Themes are in `render/themes/` (see [`render/themes/README.md`](../render/themes/README.md)). Vendored Typst packages are in `render/packages/preview/`.+- **Marketing images.** `outcomes/build.sh` renders `outcomes/samples/` into `outcomes/out/`. See the [Gallery](gallery.md).diff --git a/docs/gallery.md b/docs/gallery.mdindex fba7232..fa6abc3 100644--- a/docs/gallery.md+++ b/docs/gallery.md@@ -2,7 +2,7 @@← Back to the [README](../README.md)-Real answers, drawn by Intelligent UI in Claude Code. The framed images follow your GitHub theme: you see the dark terminal in dark mode and the light terminal in light mode. The sources of the answers are in [`outcomes/samples/`](../outcomes/samples/).+Real Claude answers, drawn by Intelligent UI. The first three show a dark and a light terminal side by side. The others follow your GitHub theme. The answers' Markdown is in [`outcomes/samples/`](../outcomes/samples/).## In a dark and a light terminal@@ -12,9 +12,9 @@ Real answers, drawn by Intelligent UI in Claude Code. The framed images follow y-## Real Markdown, right in the terminal+## Markdown-Headings, an image, a table, inline math, a code block with syntax colours, a task list and a block quote.+Headings, an image, a table, inline math, highlighted code, a task list and a quote.<picture><source media="(prefers-color-scheme: dark)" srcset="../outcomes/out/1-overview-dark.png">@@ -22,7 +22,7 @@ Headings, an image, a table, inline math, a code block with syntax colours, a ta<img alt="One Claude answer with a banner image, a heading, a table, inline math, a syntax-coloured code block, a task list and a block quote, drawn in Claude Code" src="../outcomes/out/1-overview-light.png" width="640"></picture>-## LaTeX math that reads like a paper+## LaTeX mathEuler's identity, the Gaussian integral, Maxwell's equations, a matrix, a piecewise function, the Fourier transform and the Schrödinger equation.@@ -32,9 +32,9 @@ Euler's identity, the Gaussian integral, Maxwell's equations, a matrix, a piecew<img alt="Typeset LaTeX math in Claude Code: the Gaussian integral, Maxwell's equations, a rotation matrix, a piecewise function, the Fourier transform and the Schrödinger equation" src="../outcomes/out/2-math-light.png" width="800"></picture>-## A fractal, calculated as it draws+## A fractal-Typst calculates each pixel of the Mandelbrot set at render time.+The Mandelbrot set, with each pixel calculated by Typst as the answer draws.<picture><source media="(prefers-color-scheme: dark)" srcset="../outcomes/out/3-mandelbrot-dark.png">@@ -42,7 +42,7 @@ Typst calculates each pixel of the Mandelbrot set at render time.<img alt="A Mandelbrot set with smooth colouring, calculated by a live Typst block in a Claude answer" src="../outcomes/out/3-mandelbrot-light.png" width="800"></picture>-## Recursion and colour, live+## Recursion and colourA recursive fractal tree and a Lissajous curve, drawn with CeTZ.@@ -52,7 +52,7 @@ A recursive fractal tree and a Lissajous curve, drawn with CeTZ.<img alt="A recursive fractal tree with a colour gradient next to a rainbow Lissajous curve, drawn with CeTZ in a Claude answer" src="../outcomes/out/4-fractal-light.png" width="800"></picture>-## Plots with axes and a legend+## PlotsA damped oscillator and its exponential envelope, drawn with cetz-plot.diff --git a/docs/how-it-works.md b/docs/how-it-works.mdindex beb10eb..99ef916 100644--- a/docs/how-it-works.md+++ b/docs/how-it-works.md@@ -4,97 +4,108 @@## The steps-1. A `ui.render` hook on `AssistantMessage` gets each block of the answer as Markdown.-2. While Claude writes a block, Claude Code shows its own text: Claude Code gives the hook the text of a block only when the block is complete (versions 2.1.299 to 2.1.303 at least). The block is final when the model request starts its next block (a tool call, more text) or ends. If the mod did not see the request, the block is final after its text stops changing for 400 ms. Then the mod writes the block to a JSON file and runs `typst compile` with `render/md.typ`. For plain text, Typst loads only some fonts (refer to [The lean font set](#the-lean-font-set)). Long answers are cut at block boundaries into pages. One page is one PNG. The pages show one under the other with no space between them. Thus each page after the first starts with the space that its first block has under the last block of the page above it. The JSON file holds these two blocks for each cut, and Typst measures the space. On the row grid, this space is the same as in one page.-3. The hook draws one `Image` per PNG, in place of the text.-4. Text size: the mod finds the terminal font (iTerm2 profile, Ghostty, kitty or Rio config; on Linux, else fontconfig's `monospace` font; else the metrics of the theme's code font, Menlo on macOS) and the cell size in pixels. Typst then measures both fonts so that 100% looks as large as the terminal text. Body text and code use the terminal font, so at 100% they are exactly the terminal's size. The mod uses the font that the terminal draws: if the config names a font that is not installed, the terminal draws a different font, and the mod uses that font too (Ghostty and cmux on macOS, and Rio: their own font; Ghostty on Linux and kitty on Linux: the nearest font of fontconfig; kitty on macOS: Menlo; iTerm2: the user's fixed-pitch font, Menlo if you did not change it). If Ghostty's `font-family` is a list, the mod uses the first font of the list that is installed. Ghostty and cmux draw their own JetBrains Mono when their config names no font. Rio draws its own Cascadia Code NF when its config names no font (or `cascadiacode`). These fonts are not files: they are inside the program of the terminal. The first time, the mod copies the font to `~/.cache/cc-intelligent-ui/fonts/` (approximately 0.1 s for Ghostty and 0.5 s for Rio, once for each version of the terminal), so that Typst can draw it. If you set the `TYPST_FONT_PATHS` variable, Typst gets your folders and the copy. If the mod cannot copy Rio's font, it uses Cascadia Code if it is installed. If Typst does not have the terminal font, `/iui details` tells you, and the pictures use the theme's fonts. If the terminal font has no bold face (for example, Monaco), the pictures draw its bold text with a thin outline in the text colour (a fake bold, as a terminal draws it). The mod finds this with `typst fonts --variants` when it measures the fonts. In Ghostty and cmux, the mod also removes the window padding from the cell size, because Ghostty adds the padding to the pixel size that it reports.-5. If a compile fails (a bad Typst block or an unknown LaTeX command), the mod compiles once more in safe mode: Typst blocks and math show as code. A dim line under the picture names the error. If that also fails, the normal text shows.-6. Pictures are kept in `${TMPDIR}/cc-intelligent-ui-<uid>/` (`/tmp` when `TMPDIR` is not set). Folders older than 2 days are deleted at start. The drawing space of each answer at its first compile is kept in `~/.cache/cc-intelligent-ui/designs`, so that its Typst drawings keep the same share of the screen in later sessions.-7. Links: the mod finds the web links, file paths and commands in the Markdown (not in code blocks or math). It draws one dim row for each under the pages, with a `Link` (an OSC 8 link) for a web link or a file, and a `Button` that copies a command (`$.ui.copy`). It keeps a file row only when the file exists (`$.fs.exists`, kept in memory for 512 paths). Each row is one terminal row, cut at its end. The copy (step 9) counts these rows under the pages, so it still finds the page that you select. When the pages take picture select, the mod does not draw these rows (the links are live in the picture, refer to [Picture select](#picture-select)), and the copy, the plan and the Markdown files that Claude sent count 0 rows for them.-8. The plan: a `ui.render` hook on the ExitPlanMode `ToolUse` row draws the plan through the same steps. Claude Code shows that row above the approval question. The approved result row then shows only its header, so the plan does not show two times. A `tool.call` hook on ExitPlanMode asks the mod's question (`$.ui.ask`) before Claude Code asks for permission. Then a `classic.PermissionRequest` hook gives the answer to Claude Code at once, so the Claude Code dialog does not show. For an approval, the hook sends the plan (`updatedInput`) and the new permission mode (`setMode`). For the person's text, the `tool.call` hook refuses the call with that text.-9. Copy: in fullscreen mode, picture select copies the text of a picture (refer to [Picture select](#picture-select)). A copy that still puts picture cells on the clipboard is a native copy: the copy of the terminal itself on the main screen, a selection of Claude Code that starts outside a picture, or a copy of a different session. The mod never writes the clipboard for a native copy.+1. **Get the Markdown.** A `ui.render` hook on `AssistantMessage` gets each block of the answer as Markdown.+2. **Wait for the full block.** Claude Code passes a block only when it is complete, and shows its own text until then. The block is final when the model request moves on to its next block or ends, or when its text has not changed for 400 ms.+3. **Compile.** The mod writes the block to a JSON file and runs `typst compile` with `render/md.typ` in a private root (see [The Typst root](#the-typst-root)). A long answer is cut into pages at block boundaries, one PNG per page. The pages stack with no gap, so Typst measures the space between the two blocks at each cut and puts it at the top of the next page.+4. **Draw.** The hook draws one `Image` per PNG in place of the text, sized to match the terminal text (see [Text size and fonts](#text-size-and-fonts)).+5. **Safe mode.** If a compile fails (a bad Typst block or an unknown LaTeX command), the mod compiles again with Typst blocks and math as code, and a dim line names the error. If that also fails, the normal text shows.+6. **Cache.** Pictures go in `${TMPDIR}/cc-intelligent-ui-<uid>/` (`/tmp` when `TMPDIR` is not set). Folders older than 2 days are deleted at start. The drawing space of each answer goes in `~/.cache/cc-intelligent-ui/designs`, so its Typst drawings keep the same share of the screen in later sessions.+7. **Link rows.** Under the pages, the mod draws one dim row for each web link, file path and command in the Markdown: an OSC 8 `Link` for a link or an existing file, and a `Button` that copies a command. With picture select on, these rows are not drawn, because the links are live in the picture.+8. **The plan.** A `ui.render` hook on the ExitPlanMode row draws the plan. A `tool.call` hook asks the mod's own approval question, and a `classic.PermissionRequest` hook passes the answer to Claude Code, so its dialog does not show.+9. **Pasted images.** The `prompt.edit` and `prompt.change` hooks note the `[Image #N]` numbers in the draft. Hooks on `AbovePrompt` and `UserMessage` draw a small preview of each, from the PNG that Claude Code wrote at the paste. For a pasted image path, the preview uses the file that the clipboard names. Typst fills the preview's cells with `render/fill.typ`, in a root with only that template and the image.- One long-lived `perl` process (the watcher) watches the terminal size (at each SIGWINCH) and the clipboard. On macOS, it uses `/usr/bin/perl` with Apple's PerlObjCBridge and reads the change counter of the clipboard (`NSPasteboard changeCount`) every 0.3 s. This read is in the process and starts no other process (approximately 0.05% of one CPU core). On Linux, the process starts a child in a process group of its own. The child runs a tool that prints a line at each clipboard change (`wl-paste --watch`, `clipnotify` or GTK 3 from Python, refer to [Linux](install.md#linux)) and gives the mod a counter for each line. Nothing runs between two changes. When the `perl` process stops, it stops that process group. The clipboard part starts only while the mod is on and after the mod drew its first picture in this session; then the mod starts the process again with the clipboard part (and again without it after `/iui off`). When the counter changes, the mod reads the clipboard one time (on macOS a short `/usr/bin/perl` script with PerlObjCBridge; `wl-paste`, `xclip` or GTK on Linux). It never reads a password manager's copy: on macOS a copy with the type `org.nspasteboard.ConcealedType` or `org.nspasteboard.TransientType`, on Linux a copy that offers the target `x-kde-passwordManagerHint` (the mod looks before and after the read), and on Wayland also a copy marked sensitive. A change that the mod did not write is a newer copy: an older picture copy that still reads its text then does not write the clipboard. When the clipboard has picture cells that fit a page drawn in this session, the mod shows one toast that names `/iui grab`. It does not change the clipboard. The first counter after a start is not a change, so an old clipboard gets no toast. If the watcher stops, the mod starts it again after 1 s (3 times at most). At `/clear` or a resume, the watcher continues without the clipboard part. At other session ends (for example `/exit`), the mod stops it and does not start a new one.+## Text size and fonts- `/iui grab` reads the last mouse selection of Claude Code (`$.ui.selection`). With no selection (the main screen), it reads the picture cells on the clipboard. Then it writes their text with `$.ui.copy`. A `ui.copy` hook also changes a copy with picture cells (one that comes through `$.ui.copy`) to the text. The mod writes the clipboard only for picture select, a click on a link, a file path, a command or a copy button in a picture, `/iui grab`, the command `Button` of a link row (step 7) and the `ui.copy` hook.+- **Matched size.** The mod finds the terminal font and the cell size in pixels, and Typst measures both fonts, so 100% looks as large as the terminal text. Body text and code use the terminal font.+- **Font source.** The iTerm2 profile, or the Ghostty, kitty or Rio config. On Linux, else fontconfig's `monospace`. Else the theme's code font (Menlo on macOS).+- **The font the terminal really draws.** If the configured font is not installed, the mod follows the terminal's own fallback (for example Menlo for kitty on macOS, your fixed-pitch font for iTerm2).+- **Built-in fonts.** With no font configured, Ghostty and cmux draw their own JetBrains Mono, and Rio its own Cascadia Code NF. These live inside the terminal program, so the mod copies them once per terminal version to `~/.cache/cc-intelligent-ui/fonts/`.+- **Fake bold.** If the terminal font has no bold face (for example Monaco), bold text gets a thin outline, as a terminal draws it.+- **Ghostty padding.** In Ghostty and cmux, the mod removes the window padding from the cell size, because Ghostty includes it in the pixel size.- A picture cell holds its row and its column (kitty placeholder U+10EEEE plus two combining marks). The mod finds the drawn page that has these rows, at the size that it is drawn. Then it finds the position of each word on that page: it runs the probe (`typst query` on the same template, with the same inputs as the PNG compile, plus `probe=1` and `page=<n>`) only for the pages that a copy reads, and (for picture select) for the pages on the screen. The mod keeps the positions of the last 64 pages in memory. It writes nothing to disk for this, and the PNGs do not change. The mod takes the words in the selected cells.+## The Typst root-10. Pasted images: the `prompt.edit` and `prompt.change` hooks note the `[Image #N]` numbers of the draft. A `ui.render` hook on `AbovePrompt` draws a small preview of each one above the prompt box, from the PNG that Claude Code wrote at the paste, and a hook on `UserMessage` draws them the same size under a sent prompt. Typst makes a copy that fills the preview's cells (`render/fill.typ`; `contain` in place of `cover` when a cover cuts more than half a cell), in a root folder of its own with only that template and a link to the pasted PNG.+Typst blocks run as code, and Typst code can read any file under its root. So each compile gets a new private folder as its root (`STAGE_SH` in `hooks/lib/typst.ts`), removed afterwards. It holds only:-## Picture select+- `render/`: a copy of `md.typ` and links to the rest of the template.+- The JSON file of the blocks.+- A link to the theme folder.+- A link to each image that the answer names, if it is a real image file.++Other paths are not found, and `..` cannot leave the root. The network is off, and only the vendored packages in `render/packages/` load.-The selection of Claude Code copies picture cells as kitty placeholder characters, not as text (from Claude Code 2.1.305, it skips picture cells). Thus the mod selects pictures itself (`hooks/lib/select.ts`):+## Copy and the clipboard-1. Each page is in a `Box` of its size. The last child is a `Client` (`hooks/sel.tsx`) in a `Box` with a negative top margin (the page's rows), so it is over the page. The `Client` draws only an empty `Box` (anything that it draws hides the picture cells). It takes the pointer and posts the selection whole: the anchor, the head, the phase (`down`, `move`, `up` or `clear`; `hover` and `leave` with no button down, refer to item 7 below) and an order. Posts of one frame merge, so a bare event could be lost.-2. The `ui.message` hook keeps the newest selection. The selected rows are in stream order, in the rows of the whole drawing, so a drag can go on into the next page.-3. The highlight does not change the layout. Each page stays one keyed `Image`, and the mod swaps its picture with `$.ui.blit` (`hooks/lib/blit.ts`). This is one small kitty command with the same image id (`a=T`, `t=f`, the file name), so the terminal replaces the picture in place. The frame is the page with the selected cells changed: in a selected cell, each pixel of the page (straight alpha) over the opaque selection colour; in the other cells, the page as it is. A clear swaps the page's own PNG back. Cell `i` is the pixels from `round(i × pixels / cells)` to `round((i + 1) × pixels / cells)`, so the cells cover the page with no gap at any ratio.-4. The hooks runtime has no zlib, so `hooks/lib/png.ts` decodes the page in JavaScript (inflate and unfilter). For each row of cells, the mod makes a deflate piece one time (fixed Huffman codes, matches of one pixel to the left or one pixel up, ended on a byte). A row that is selected whole has a tinted piece, also made one time (in the background, or by a frame: 6 ms of them at most per frame; a row that is not made yet shows plain in that frame, and the next frame continues). A frame makes new pieces only for the first and last selected rows (partly selected), and joins the pieces into one PNG (up to approximately 3 MB for a tall page). The first highlight frame of a ready page takes approximately 2–3 ms to make. The hooks can write only text, so `perl` writes the frame (base64 on its stdin) to `<cache>/select-<id>/f-<n>.png`. The terminal reads the file after the blit. The mod deletes a frame file when 4 newer frames are written and it is 2 s old. The 2-day cleanup of the cache folder deletes the rest.-5. A new frame starts at most once in 16 ms, and only after the last one is blitted. The posts between fold into one frame of the newest selection. If Claude Code refuses a blit, the mod writes the reason one time to the debug log and shows no highlight on that page until the next `down`. The copy still works.-6. At `up`, the mod reads the words under the selected cells the same way as for a copy of these cells (`textOfRun` on the words of the probe), and copies them with `$.ui.copy`. A toast shows "copied N chars of text".-7. Links, file paths, commands and copy buttons (the click targets, `hooks/lib/targets.ts`): the probe also tags the words of a Markdown link (its URL), and the words of inline code (its text). For each code block, it also gives the box of the copy button in the block's header, with the full code and the language (a tag that is not a word, so the copy of a selection does not change). When the words of a page are known, the mod finds its targets (web links, bare URLs, file paths that exist, inline code, which is a command when it is not a file that exists, and the copy button of each code block; the text of a code block is not a target) and the cells of each, one time for each page and size. The cells of a copy button are the cells whose centres are in its box (at least the cell of its centre). An older probe gives no copy buttons, and then a code block has no target. With no button down, the `Client` posts `hover` when the pointer goes to a new cell and `leave` when it goes out. The mod then shows the target under the pointer with the same blits as a selection (step 3), and the page's own PNG when the pointer is off the targets. There is no hover highlight while a selection shows, and a `down` removes it. A `clear` (a click) on a target copies it with `$.ui.copy` (a web link's URL, a file's full path, the text of inline code, the full code of a code block). A later post of one frame replaces an earlier one, so a `hover` or a `leave` also carries the last `up` or `clear` of its `Client`, and the mod reads that one first (by its order, one time).+- **Native copy.** A copy that puts picture cells on the clipboard (the terminal's own copy, a Claude Code selection that starts outside a picture, or a copy in another session) is a native copy. The mod never rewrites it.+- **The watcher.** One long-lived `perl` process watches the terminal size and the clipboard. On macOS it reads the clipboard's change counter every 0.3 s through PerlObjCBridge. On Linux it runs `wl-paste --watch`, `clipnotify` or GTK 3 from Python (see [Linux](install.md#linux)), so nothing runs between changes. It watches the clipboard only after the first picture of the session.+- **The toast.** When the clipboard holds picture cells of a page drawn in this session, a toast names `/iui grab`. The clipboard does not change.+- **Passwords.** The mod does not read a password manager's copy (macOS concealed or transient types, the KDE password hint on Linux, or a Wayland copy marked sensitive).+- **`/iui grab`.** Reads Claude Code's last mouse selection, or on the main screen the picture cells on the clipboard, and copies their text with `$.ui.copy`. A `ui.copy` hook also turns picture cells sent through `$.ui.copy` into text.+- **From cells to text.** Each picture cell holds its row and column (the kitty placeholder U+10EEEE and two combining marks). The mod finds the drawn page with those rows, then runs a probe (`typst query` on the same template and inputs) to get the position of each word. It keeps the words of the last 64 pages in memory only.-The `Client` is in the flow, not in an absolute `Box`. Claude Code (2.1.306) moves an absolute `Box` whose top is above the screen down to row 0, with its children. Then the pointer `y` of a `Client` in such a `Box` counts from row 0 of the screen, not from the top of the page, so the selection was too high by the rows that were scrolled away. Also, the `Client` took the pointer under the page. A `Box` in the flow has its true position, also when its top is above the screen.+## Picture select-The mod draws the `Client` only from Claude Code 2.1.298 (`$.session.version()`), which has the `Client`, `ui.message`, `$.ui.blit` and `$.ui.copy`. It draws it only in fullscreen mode, and not over ssh (pages sent as bytes). A `Client` that fails (`ui.fault`) turns picture select off until a reload, and the rows are drawn again with no `Client`. The `Client` sets no key listener: with one, a click would give it the keys of the prompt until Escape, and Escape never reaches it.+Claude Code's selection copies picture cells as placeholder characters, not text (from 2.1.305 it skips them). So the mod selects pictures itself (`hooks/lib/select.ts`):-A picture selection goes when you type in the prompt (`prompt.edit`, and `prompt.change` for a recalled entry, an undo or a clear) or make a selection of Claude Code: while a picture selection shows, the mod reads `$.ui.selection()` every 250 ms with `$.clock.every` (one timer, stopped with the selection), and a new answer there removes it. No event tells a mod about a plain click outside its region. `/iui details` shows the state on the line `Picture select:`.+- **Pointer.** Over each page sits a `Client` (`hooks/sel.tsx`) that takes the pointer and posts the selection: anchor, head, and phase (`down`, `move`, `up`, `clear`, `hover`, `leave`). The `Client` is in the flow, not in an absolute `Box`, because Claude Code moves an absolute `Box` above the screen down to row 0.+- **Highlight.** The layout never changes. The mod swaps the page's picture with `$.ui.blit` (`hooks/lib/blit.ts`), one small kitty command with the same image id, at most once per 16 ms.+- **PNG in JavaScript.** The hooks have no zlib, so `hooks/lib/png.ts` decodes the page and keeps a deflate piece for each row of cells, plain and tinted. A frame joins the pieces and builds new ones only for the first and last rows. `perl` writes the frame to a file that the terminal reads.+- **Copy.** At `up`, the mod copies the words under the selected cells with `$.ui.copy`, and a toast says "copied N chars of text".+- **Click targets** (`hooks/lib/targets.ts`). The probe also tags link URLs, inline code and each code block's copy button. Hover highlights the target; a click copies it.+- **Clearing.** A selection goes when you type in the prompt or make a Claude Code selection (checked every 250 ms while a selection shows).+- **When it is on.** Fullscreen mode, Claude Code 2.1.298 or newer, not over ssh. If a `Client` fails, picture select is off until a reload. `/iui details` shows the state.### The page cache-The mod gets each page ready for the highlight before the first `down` on it (`hooks/lib/pagecache.ts`). When a page is drawn or comes on the screen (picture select on, fullscreen mode), the mod reads its PNG, decodes it, and makes the deflate piece of each row of cells, in the background. The hooks have no thread and no timer of their own. Thus the mod does this work in short slices: 4 ms at most each (8 ms when a `down` waits for the page), with `$.clock.after(0)` between two slices. Thus scrolling and drawing continue.--- The mod gets one page ready at a time. A page that you push the button on goes first. Then the pages on the screen go, the newest answer first.-- A page that goes off the screen leaves the queue, and its work stops (a `down` on it before its next slice continues that work).-- A drawing that is drawn again with new page files (a stream, a resize, a theme or size change) drops its old pages from the queue.-- When a `down` comes on a different page, the work on the page in progress pauses (if that page is ready, is on the screen, or a `down` asked for it). It continues later.-- When a page is ready, the mod continues with the tinted piece of each row (for a row that is selected whole).-- The mod keeps the decoded pages in memory, 128 MB (a page of 3392 × 4932 pixels uses approximately 74 MB). When it needs space, only pages off the screen go, the oldest first; a page on the screen and the page of the selection stay. A page that does not fit with the pages on the screen waits for a `down` on it (which goes over the budget for a short time). `/iui off` and `/iui select off` let all of it go. It writes nothing of this to disk.-- The mod also finds the words of each page on the screen: it runs the probe of that page (`typst query`, one page at a time). Thus the copy at `up` does not wait.+The mod gets each page ready before the first `down` on it (`hooks/lib/pagecache.ts`). When a page is drawn or comes on screen, the mod decodes it, builds its row pieces, and probes its words in the background. The hooks have no threads, so this runs in slices of 4 ms at most, and scrolling and drawing go on.-On Apple Silicon (bun), a page of 3392 × 4284 pixels is ready after approximately 0.24 s of work (about 60 slices of 4 ms, over a longer time). A page of 3392 × 756 pixels is ready after approximately 0.045 s. If a page is not ready at the `down`, the first highlight waits for it: the mod completes that page first, in slices of 8 ms. If the words of a page are not ready at `up`, the copy waits for the probe (approximately 0.05 s for plain text, 0.15–0.5 s for other text, 2–3 s for a page with a large Typst drawing).+- **Order.** One page at a time: a page you pressed on first, then pages on screen, newest answer first.+- **Off screen.** A page that leaves the screen leaves the queue. A redraw drops the old pages.+- **Memory.** Decoded pages use up to 128 MB, and pages off screen go first. `/iui off` and `/iui select off` free it all. Nothing is written to disk.+- **Not ready.** If a page is not ready at `down`, the mod finishes it first (about 0.25 s for a tall page on Apple Silicon).## The lean font set-At each start, Typst reads all the fonts of the computer. On macOS, this is approximately 70 ms of each compile. Plain text does not need most of these fonts. Plain text has only ASCII characters, no math outside code, no live Typst block, no image and no HTML entity. In the answers that we measured, approximately 3 of 4 blocks are plain text.+At each start, Typst reads all the fonts on the computer, about 70 ms per compile on macOS. Plain text does not need them. Plain text means ASCII only, with no math outside code, no live Typst block, no image and no HTML entity. About 3 of 4 blocks are plain text.-For plain text, Typst loads only these fonts:+For plain text, Typst loads only:- The terminal font.-- The body fonts and the code fonts of the theme, but not the CJK fonts and the emoji fonts.-- The fonts in Typst (for example, the math font).+- The theme's body and code fonts, without CJK and emoji fonts.+- Typst's own fonts (for example the math font).-The mod puts links to these font files in one folder in the cache (`fonts-<hash>`). It gives Typst `--ignore-system-fonts --font-path <folder>`. Then a block of plain text compiles in approximately 0.03–0.07 s, not 0.1–0.15 s. The PNG does not change. For ASCII text, Typst takes each character from the first font of the list that has it, and that font is in the folder. Other text can need a character that no font of the list has. Then Typst looks in all the fonts of the computer, so other text compiles with all the fonts.+The mod links these files into one cache folder (`fonts-<hash>`) and runs Typst with `--ignore-system-fonts --font-path <folder>`. The PNG does not change, because Typst takes each ASCII character from the first font of the list, and that font is in the folder.-The mod makes the folder one time in each session, after the first compile of plain text. `typst fonts --variants` gives the files. The mod does not use the folder in these conditions:+The mod makes the folder once per session, from `typst fonts --variants`. It skips the folder when:-- The first installed font of a list is a CJK font or an emoji font.+- The first installed font of a list is a CJK or emoji font.- A list has no installed font.-- One style of a font is in two files (then the order in which Typst reads the files can change the font that it uses).-- The list markers or the numbering of the theme are not ASCII.+- One style of a font is in two files.+- The theme's list markers or numbering are not ASCII.-If a compile with the folder fails, the mod compiles again with all the fonts. The probe of a copy (step 9) uses the same fonts as the PNG compile. If the folder is not there (the cleanup at start deletes folders that are older than 2 days), the mod uses all the fonts and makes the folder again.+If a compile with the folder fails, the mod compiles again with all fonts.## How `auto` is resolved-Claude Code finds the light or dark mode for `auto` by asking the terminal for its background colour (OSC 11). A mod cannot see that answer, so Intelligent UI uses these sources, in this order. The first source that gives an answer is used:+Claude Code finds light or dark for `auto` by asking the terminal for its background colour (OSC 11). A mod cannot see that answer, so Intelligent UI tries these sources in order, and the first answer wins:-1. **The iTerm2 profile:** the background colour of the profile in use (`ITERM_PROFILE`, else the default profile). Intelligent UI finds iTerm2 by `TERM_PROGRAM`. If `TERM_PROGRAM` is not set, `ITERM_PROFILE`, `ITERM_SESSION_ID` or `LC_TERMINAL=iTerm2` also show iTerm2. If the profile has separate colours for light and dark mode, Intelligent UI uses the set for iTerm2's theme (Settings > Appearance). If that theme is Automatic, Minimal or Compact, it uses the set for the OS appearance.-2. **The Ghostty config:** the `background` that `ghostty +show-config` gives. With a `theme = light:A,dark:B`, Intelligent UI reads the background from the theme file for the OS appearance. With no theme and no `background`, it uses Ghostty's default (`#282c34`, dark).- - **cmux** (Ghostty inside, found by its `CMUX_*` variables) reads the same Ghostty config, then its own config, `~/Library/Application Support/com.cmuxterm.app/config.ghostty`. The cmux themes picker (Settings > Themes, `cmux themes`) writes the theme there, and that theme wins over the Ghostty config's. A `light:A,dark:B` theme follows cmux's appearance (see below). If these configs set no `theme`, `background`, `foreground` or `palette`, cmux uses its adaptive default theme. Intelligent UI then uses cmux's appearance: `app.appearance` in `~/.config/cmux/cmux.json`, else the value in cmux's Settings. If that appearance is System, Intelligent UI uses the OS appearance. If `terminal.adaptiveDefaultTheme` is `false` in `cmux.json`, Intelligent UI uses the Ghostty rules above.-3. **The kitty config:** the `background` in `kitty.conf` and in the files that it includes (`include` lines only). The themes kitten writes such an include. If the config folder has `dark-theme.auto.conf`, `light-theme.auto.conf` or `no-preference-theme.auto.conf` (kitty 0.38 and later), Intelligent UI uses the file for the OS appearance, as kitty does (on Linux, the portal's or GNOME's colour scheme). With no `background`, it uses kitty's default (`#000000`, dark). The config folder is `KITTY_CONFIG_DIRECTORY`. If that is not set, it is the first of `$XDG_CONFIG_HOME/kitty`, `~/.config/kitty` and (on macOS) `~/Library/Preferences/kitty` that has a `kitty.conf`.-4. **The Rio config:** `config.toml` in `RIO_CONFIG_HOME`, else in `~/.config/rio` (on Linux, `$XDG_CONFIG_HOME/rio` if that is set). With an `[adaptive-theme]`, Intelligent UI reads the theme file for `force-theme`, else for the OS appearance. Else it reads the file for `theme`, else the `[colors] background`. Theme files are in the `themes` folder. With no background, it uses Rio's default (`#0F0D0E`, dark).-5. **`COLORFGBG`**, as it was when Claude Code started. Ghostty does not set it.-6. **The OS appearance:** macOS Dark or Light. On Linux, the `color-scheme` of the freedesktop portal (through `gdbus`, else `busctl`; "no preference" is light), else GNOME's `color-scheme` (`gsettings`). The mod keeps the tool that works, so each check starts one process.+1. **The iTerm2 profile:** the background of the profile in use (`ITERM_PROFILE`, else the default profile). If the profile has light and dark colours, the set for iTerm2's theme (Settings > Appearance), or for the OS appearance when that theme is Automatic, Minimal or Compact.+2. **The Ghostty config:** the `background` from `ghostty +show-config`. With `theme = light:A,dark:B`, the theme file for the OS appearance. With neither, Ghostty's default (dark).+ - **cmux** also reads its own `config.ghostty`, where the cmux themes picker writes, and that theme wins. With no theme or colours set, cmux uses its adaptive default theme, and the mod follows cmux's appearance setting (`app.appearance` in `~/.config/cmux/cmux.json`).+3. **The kitty config:** the `background` in `kitty.conf` and its `include` files. With `dark-theme.auto.conf`, `light-theme.auto.conf` or `no-preference-theme.auto.conf` (kitty 0.38 and later), the file for the OS appearance. With no `background`, kitty's default (dark).+4. **The Rio config:** `config.toml`. With `[adaptive-theme]`, the theme for `force-theme` or the OS appearance. Else the `theme` file, else `[colors] background`, else Rio's default (dark).+5. **`COLORFGBG`**, as it was when Claude Code started.+6. **The OS appearance:** macOS Dark or Light. On Linux, the freedesktop portal's `color-scheme`, else GNOME's `color-scheme`.7. **Dark.**-The terminal comes before the OS: a dark terminal on a light Mac is dark.+The terminal comes before the OS: a dark terminal on a light Mac is dark. The mod checks every 3 s, and after a change each mode's pictures compile once. `/iui probe` sends OSC 11 and shows the raw answers, to test whether they can reach the mod.-In **herdr**, `TERM_PROGRAM` is `herdr`, so it does not name the terminal that herdr runs in. Intelligent UI does these steps:+### herdr-- **Background:** herdr answers OSC 11 with the background of the terminal in front. In herdr, this is source 0, before the sources above. It also works with `herdr --remote`, where the mod runs on the remote computer. The question reads the tty that Claude Code reads (refer to [Limitations](limitations.md)), so Intelligent UI asks only at the start and when it changes to a different herdr client, never on a timer. It asks only when no key came in the prompt box for 2 s, when the mod is on and draws pictures in herdr, and when the theme was `auto` at the start or at the change of client. Claude Code reads some answers first. If no answer comes, it asks again at the next checks, 3 times at most. Then it uses the sources above. It keeps an answer while the sources above give the same mode as when the answer came. When they change (for example, the OS appearance changes and the terminal's theme follows it), it uses them.-- **Terminal and font:** herdr runs a server, and one or more clients (`herdr`, `herdr --session <name>`, `herdr session attach <name>`) attach to it from terminals. Intelligent UI finds the herdr server above its own process. Then it lists the herdr clients of this user that have a tty (one `ps`). With more than one herdr server, it keeps only the clients that connect to its own server (`lsof`). On macOS, it uses a client in the terminal app in front (`lsappinfo`, by the app's bundle id). If there are two or more such clients, it uses the one whose tty was read last (the access time of the tty changes when you type in that terminal). If the app in front has no client (for example, a browser), it keeps the client that it used before. On Linux, and when it cannot read the app in front, it uses the client whose tty was read last. The tty time alone is not sufficient: iTerm2 answers each picture that herdr sends (herdr puts `q=2`, no answer, only in the first part of the upload), so the tty of the iTerm2 client is read each time that the mod draws pictures, also when you do not type there. An answer of this type from a terminal on Linux is not known. It reads the variables of that client (Linux: `/proc/<pid>/environ`; macOS: `ps eww`; the shell that reads them keeps only the terminal's variables, `CLIENT_NAMES` in `hooks/lib/terminal.ts`) and the terminal app above it (the nearest process with no tty). The terminal app comes first, then `TERM`, `TERM_PROGRAM` and the variables of each terminal. Intelligent UI then uses that terminal's sources above (with that client's `ITERM_PROFILE`, `KITTY_CONFIG_DIRECTORY`, `GHOSTTY_BIN_DIR`, `GHOSTTY_RESOURCES_DIR`, `RIO_CONFIG_HOME` and `COLORFGBG`) and its font for the text size. It checks the client every 1 s. This check reads only the app in front and the tty times of the known clients (one small `sh` with `lsappinfo` and `stat`, approximately 0.01 s of CPU time). The full check with the process list (approximately 0.1 s of CPU time) runs only when the 1 s check finds a change (a different client, a terminal in front with no known client, or a tty that is gone), and every 10 s to find new and gone clients. When no client is attached (a detached pane), there is no 1 s check, only the full check every 10 s. The checks run only while the mod is on and Claude Code draws pictures in herdr. When the terminal changes, it reads the font and the background again and draws the pictures again.-- **iTerm2:** herdr runs a terminal of its own for each pane. It draws a picture of Claude Code (kitty placeholder cells) in the outer terminal as one kitty placement for each row, with a source rectangle: row k of a picture that is H pixels tall and R rows tall shows the source rows from floor(k × H / R), floor(H / R) rows tall. iTerm2 3.6 and 3.7 count the top of a source rectangle from the bottom of the image. When the client is iTerm2 (not with `herdr --remote`), Intelligent UI stores each picture with the band of each row at the rows that iTerm2 reads for that row (`hooks/lib/flip.ts`). Before this, a page is made exactly R × B pixels tall (B = H / R, rounded): the last row is repeated, or, when the page is taller, each row gets the band that herdr shows for it (so no rows are cut at the bottom). Thus the change is the reverse order of the bands. Pictures under rows are first made by Typst at their size in cells. The render key includes this mode, so a change of client draws new files.-- **Fallback:** if it finds no client, it uses the variables that herdr keeps of the terminal that started the herdr server: `CMUX_*` for cmux, `GHOSTTY_RESOURCES_DIR` or `GHOSTTY_BIN_DIR` for Ghostty, `KITTY_PID` or `KITTY_INSTALLATION_DIR` for kitty, `ITERM_PROFILE` for iTerm2. If it finds none, it uses `COLORFGBG`, then the OS appearance.+In herdr, `TERM_PROGRAM` is `herdr`, so it does not name the terminal around herdr.-Intelligent UI checks the theme every 3 s (in herdr, also at once when the terminal changes). After a change, each mode's pictures compile once. `/iui probe` asks the terminal for its background with OSC 11 (5 times) and shows the raw answers. This is a test of whether the answer can reach the mod. The 3 s check never uses OSC 11. Only in herdr, the mod uses OSC 11 at the start and for a new client (see above).+- **Background first.** herdr answers OSC 11 with the background of the terminal in front, so in herdr this comes before the sources above. Because the question shares Claude Code's tty, the mod asks only at start and when the herdr client changes, after 2 s with no key in the prompt, 3 times at most.+- **Which terminal.** The mod lists this user's herdr clients. On macOS it picks the one in the terminal app in front; otherwise the one whose tty was used last. It then uses that terminal's config and font.+- **Checks.** A light check every 1 s, and a full check of the process list on a change and every 10 s, only while pictures show in herdr.+- **iTerm2 under herdr.** herdr draws each picture row as its own kitty placement, and iTerm2 3.6 and 3.7 count the source rectangle from the bottom. So for an iTerm2 client, the mod stores pictures with the row bands in reverse order (`hooks/lib/flip.ts`).+- **Fallback.** With no client, the mod uses the variables herdr kept from the terminal that started it, then `COLORFGBG`, then the OS appearance.diff --git a/docs/install.md b/docs/install.mdindex 9eb5762..af2142c 100644--- a/docs/install.md+++ b/docs/install.md@@ -6,42 +6,61 @@- Claude Code 2.1.298 or later (tested on 2.1.307)- [Typst](https://typst.app) 0.15 (tested on 0.15.1)-- macOS (tested) or Linux with X11 or Wayland. It works on a Linux desktop (tested on Ubuntu 24.04 with GNOME). Refer to [Linux](#linux).-- A terminal where Claude Code draws pictures. Refer to [Terminals](#terminals).+- macOS (tested), or Linux with X11 or Wayland (tested on Ubuntu 24.04 with GNOME). Refer to [Linux](#linux).+- A terminal where Claude Code can show pictures. Refer to [Terminals](#terminals).## Terminals-- **kitty (0.28 or later), Ghostty and cmux (Ghostty inside, macOS only):** pictures work with no setting. kitty and Ghostty work on macOS and on Linux.-- **iTerm2 3.6 or later (3.7.5 tested, macOS only):** Claude Code needs `CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1` when it starts. A mod cannot set it early enough. The first time the mod runs in iTerm2, it asks to add one line to your shell's start file (`~/.zshrc`, a fish `conf.d` file, or for bash on macOS the first of `~/.bash_profile`, `~/.bash_login` and `~/.profile` that exists; it makes `~/.bash_profile` only when none of them exists). The line sets the variable in iTerm2 and herdr only, not in tmux or screen. Then close the tab, open a new iTerm2 tab, and start Claude Code there. You can also run `/iui setup` (undo: `/iui setup remove`).-- **herdr (0.9.5 tested, in Ghostty and iTerm2):** herdr is a terminal multiplexer. It draws the pictures of its panes in the terminal that it runs in, so that terminal must show kitty pictures (kitty, Ghostty or iTerm2 3.6 or later). Claude Code needs `CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1` in herdr too. The first time the mod runs in a herdr pane, it asks to add the same line to your shell's start file. If the file has the line of an older version (iTerm2 only), the mod asks to update it. Then close the pane, open a new herdr pane, and start Claude Code there. You can also run `/iui setup` (undo: `/iui setup remove`). herdr works on macOS and on Linux.- - herdr runs the shell of `SHELL` in its panes. If herdr starts with no `SHELL` in its environment (for example from a launcher or a service), its panes run `/bin/sh`, which does not read your shell's start file, so the line has no effect. Start herdr from a normal shell, or set `SHELL` for it.- - herdr hides the name of the terminal that it runs in. With the `auto` theme, the mod gets the background from herdr: herdr gives the background of the terminal in front. This also works with `herdr --remote`.- - For the font, the mod finds the herdr client that you use. You can attach to one herdr server from more than one terminal (for example Ghostty and kitty). On macOS, the mod uses the client in the terminal app in front. If that app has two or more clients, it uses the one where you typed last. If the app in front has no client (for example, a browser), the mod keeps the client that it used before. On Linux, the mod uses the client where you typed last. The mod does not use only the place where you typed last on macOS, because iTerm2 answers each picture that herdr sends, and that looks like typing in iTerm2. The mod reads the variables and the terminal app of that client, then reads the font of that terminal. When you go to a different terminal, the mod finds it at the next check (every 1 s) and draws the pictures again with that font. If you attach a new client in the app that is in front, or on Linux, the mod can find it only at the full check (every 10 s). If the mod cannot find a client, it uses the variables that herdr keeps of the terminal that started the herdr server (`GHOSTTY_RESOURCES_DIR` for Ghostty, `KITTY_PID` for kitty, `ITERM_PROFILE` for iTerm2). `/iui details` shows the terminal and how the mod found it, for example `herdr 0.9.5 (in Ghostty, the terminal in front)`, `herdr 0.9.5 (in kitty, the client you used last)` or `herdr 0.9.5 (in Ghostty, from the server's start)`.- - Pages are shorter in herdr, so that herdr can send each one to the terminal. Refer to [Limitations](limitations.md).- - In iTerm2, herdr sends each row of a picture as one part of the image, and iTerm2 counts the top of that part from the bottom of the image. Thus the rows would show in the opposite order. When the herdr client that the mod uses is iTerm2, the mod keeps the rows of each page and each picture in an order that iTerm2 shows correctly. Picture select also works. When you go to a different terminal (for example Ghostty), the mod draws the pictures again in the usual order. `/iui details` then shows `pages and pictures stored upside down by rows`. With `herdr --remote` in iTerm2, the mod cannot find the client, so the rows of the pictures show in the wrong order. Refer to [Limitations](limitations.md).-- **Rio 0.5.27 or later (not tested):** set `CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1` before you start Claude Code. Rio works on macOS and on Linux.-- **The setup line.** `/iui setup` (and a yes to the question in iTerm2 or herdr) adds this block to your shell's start file. It sets the variable in iTerm2 and herdr only, not in tmux or screen:-- ```sh- # >>> cc-intelligent-ui: Claude Code pictures in iTerm2 >>>- if { [ "$TERM_PROGRAM" = "iTerm.app" ] || [ "$TERM_PROGRAM" = "herdr" ]; } && [ -z "$TMUX" ] && [ -z "$STY" ]; then export CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1; fi- # <<< cc-intelligent-ui <<<- ```-- For fish, the line is `if test "$TERM_PROGRAM" = "iTerm.app" -o "$TERM_PROGRAM" = "herdr"; and not set -q TMUX; and not set -q STY; set -gx CLAUDE_CODE_FORCE_TERMINAL_IMAGES 1; end`. The markers stay as in older versions, whose line was for iTerm2 only. `/iui setup` replaces an older line, and `/iui setup remove` removes the block. If the mod cannot read the file, it changes nothing and shows the line to add.-- Do not put the variable in the `env` of `~/.claude/settings.json`. It then applies in every terminal, also where pictures cannot show.-- **Warp (not yet):** Warp does not draw kitty pictures with Unicode placeholders yet. The pull request [warpdotdev/warp#16312](https://github.com/warpdotdev/warp/pull/16312) adds them. The mod will support Warp when that pull request is merged.-- **WezTerm (not yet):** WezTerm does not draw kitty pictures with Unicode placeholders yet, so it shows no pictures, also with the variable set. The pull request [wezterm/wezterm#7924](https://github.com/wezterm/wezterm/pull/7924) adds them. The mod will support WezTerm when that pull request is merged.-- **Not supported:** Konsole does not draw kitty pictures with Unicode placeholders, so it shows no pictures, also with the variable set. Alacritty, Terminal.app, Windows Terminal, GNOME Terminal (and other VTE terminals), foot, VS Code, Tabby, Hyper and JetBrains terminals have no kitty pictures.-- **tmux and screen:** no pictures. Claude Code does not send pictures through tmux or screen, also with the variable set. Set `IUI_FORCE=1` to try anyway.-- **ssh:** pictures work when the terminal on your computer is kitty or Ghostty (`TERM` must come through ssh), or when you set `CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1` on the remote computer. The mod sends each picture as data, because the terminal cannot read files on the remote computer. A page larger than 4096 pixels on a side or 2 MiB shows as text. An image of that size does not show.-- Background sessions (agent view, forks, `claude attach`) cannot draw pictures.--Where pictures cannot draw, the mod shows the normal text. To see why a terminal can or cannot show pictures, run `/iui details`.+- **kitty 0.28+, Ghostty, cmux:** works with no setup. kitty and Ghostty run on macOS and Linux; cmux (Ghostty inside) on macOS only.+- **iTerm2 3.6+ (macOS, 3.7.5 tested):** needs [the setup line](#the-setup-line). The first time the mod runs in iTerm2, it asks to add it. Say yes, close the tab, and start Claude Code in a new iTerm2 tab.+- **herdr (0.9.5 tested, in Ghostty and iTerm2):** needs the setup line too, asked for the same way. Then start Claude Code in a new herdr pane. herdr must run in a terminal that shows kitty pictures (kitty, Ghostty or iTerm2 3.6+). Refer to [herdr](#herdr).+- **Rio 0.5.27+ (not tested):** set `CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1` before you start Claude Code. Runs on macOS and Linux.+- **ssh:** works when your local terminal is kitty or Ghostty (`TERM` must come through ssh), or when you set `CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1` on the remote computer. Pictures go as data, so a page over 4096 pixels on a side or over 2 MiB shows as text, and an image that large does not show.+- **tmux and screen:** no pictures. Claude Code does not send pictures through them, even with the variable set. Set `IUI_FORCE=1` to try anyway.+- **Warp and WezTerm (not yet):** they do not draw kitty pictures with Unicode placeholders. Support comes when [warpdotdev/warp#16312](https://github.com/warpdotdev/warp/pull/16312) and [wezterm/wezterm#7924](https://github.com/wezterm/wezterm/pull/7924) are merged.+- **Not supported:** Konsole (no Unicode placeholders), Alacritty, Terminal.app, Windows Terminal, GNOME Terminal and other VTE terminals, foot, VS Code, Tabby, Hyper and JetBrains terminals (no kitty pictures).+- **Background sessions** (agent view, forks, `claude attach`) cannot show pictures.++Where pictures cannot show, you see the normal text. `/iui details` tells you why.++### The setup line++iTerm2 and herdr show pictures only when `CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1` is set before Claude Code starts. A mod cannot set it early enough, so the mod adds this block to your shell's start file when you agree, or when you run `/iui setup`:++```sh+# >>> cc-intelligent-ui: Claude Code pictures in iTerm2 >>>+if { [ "$TERM_PROGRAM" = "iTerm.app" ] || [ "$TERM_PROGRAM" = "herdr" ]; } && [ -z "$TMUX" ] && [ -z "$STY" ]; then export CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1; fi+# <<< cc-intelligent-ui <<<+```++- **Where it sets the variable:** in iTerm2 and herdr only, not in tmux or screen.+- **fish:** the line is `if test "$TERM_PROGRAM" = "iTerm.app" -o "$TERM_PROGRAM" = "herdr"; and not set -q TMUX; and not set -q STY; set -gx CLAUDE_CODE_FORCE_TERMINAL_IMAGES 1; end`.+- **The start file** of the shell in `SHELL`:+ - zsh: `${ZDOTDIR:-~}/.zshrc`+ - bash on macOS: the first of `~/.bash_profile`, `~/.bash_login` and `~/.profile` that exists (a login bash reads only that one). `~/.bash_profile` is made only when none exists.+ - bash on Linux: `~/.bashrc`+ - fish: `${XDG_CONFIG_HOME:-~/.config}/fish/conf.d/cc-intelligent-ui.fish`+- **Older versions:** their line was for iTerm2 only (the markers are the same). `/iui setup` replaces it, and in herdr the mod asks to update it.+- **Undo:** `/iui setup remove`, or delete the marked lines.+- **Another shell, or a file the mod cannot read:** the mod changes nothing and shows the line to add.+- **Not in `settings.json`:** do not put the variable in the `env` of `~/.claude/settings.json`. It then applies in every terminal, also where pictures cannot show.++### herdr++- **`SHELL`:** herdr runs the shell of `SHELL` in its panes. If herdr starts without `SHELL` (for example from a launcher or a service), its panes run `/bin/sh`, which does not read your start file. Start herdr from a normal shell, or set `SHELL` for it.+- **Theme:** herdr hides the outer terminal. With the `auto` theme, the mod asks herdr for the background of the terminal in front. This also works with `herdr --remote`.+- **Font:** you can attach to one herdr server from more than one terminal. The mod uses the font of the terminal of the herdr client you use:+ - On macOS, the client in the terminal app in front (the one where you typed last if that app has two or more). If the app in front has no client (for example a browser), the mod keeps the last client.+ - On Linux, the client where you typed last.+ - The mod checks for a change every 1 s and redraws with the new font. A newly attached client in the app in front, or any new client on Linux, is found at the full check every 10 s.+ - With no client found, the mod uses the variables of the terminal that started the herdr server (`GHOSTTY_RESOURCES_DIR`, `KITTY_PID` or `ITERM_PROFILE`).+ - `/iui details` shows the terminal and how the mod found it, for example `herdr 0.9.5 (in kitty, the client you used last)`.+- **iTerm2 under herdr:** iTerm2 would show the rows of each picture in reverse order, so the mod stores pages and pictures upside down by rows. Selecting text in an answer still works, and `/iui details` shows `pages and pictures stored upside down by rows`. With `herdr --remote` in iTerm2, the mod cannot find the client and the rows show in the wrong order.+- **Shorter pages:** pages are shorter in herdr, so that herdr can pass each one on. Refer to [Limitations](limitations.md).## Install steps-There are two ways: the install script, or by hand.+Use the install script, or install by hand.### The install script@@ -51,53 +70,104 @@ In a shell, on macOS or Linux:curl -fsSL https://intelligentui.art/install.sh | bash```-You can also download the script, read it, and run it with `bash install.sh`. Its source is [`site/install.sh`](../site/install.sh). When it is done, restart Claude Code, or type `/reload-plugins` in a session. To update, run it again: each step that is done already changes nothing.+Or download the script, read it, and run `bash install.sh`. The source is [`site/install.sh`](../site/install.sh). When it is done, restart Claude Code or type `/reload-plugins`. To update, run it again: steps that are already done change nothing.-The script does these steps, in this order:+What it does:-1. **Checks.** The system must be macOS or Linux, on arm64 or x86_64. The `claude` command must be on your `PATH` (or in `~/.local/bin` or `~/.claude/local`). If Claude Code is not installed, the script tells you where to get it ([Set up Claude Code](https://code.claude.com/docs/en/setup)), changes nothing, and stops with exit code 1. If Claude Code is older than 2.1.298, it shows a warning and continues.-2. **Typst.** The script looks for Typst as the mod does: in the `PATH` of a login shell (`sh -l`; on macOS this puts `/usr/local/bin` first), then on the `PATH`, then in `/opt/homebrew/bin`, `/usr/local/bin`, `/usr/bin`, `/snap/bin`, `~/.cargo/bin`, `~/.local/bin`, `/home/linuxbrew/.linuxbrew/bin` and `~/.linuxbrew/bin`. If the first Typst that it finds is 0.15 or later, it changes nothing. If not, it downloads the official Typst 0.15.1 release file for your system from [github.com/typst/typst/releases](https://github.com/typst/typst/releases/tag/v0.15.1) (`typst-aarch64-apple-darwin`, `typst-x86_64-apple-darwin`, `typst-aarch64-unknown-linux-musl` or `typst-x86_64-unknown-linux-musl`, `.tar.xz`), with `curl` over HTTPS only. It compares the file's SHA-256 with the value written in the script. If they are not the same, it deletes the file, installs nothing and stops. Then it extracts the file in a private temporary folder (deleted at the end), makes sure that the program runs, and moves it to `~/.local/bin/typst` in one step. An older `typst` in `~/.local/bin` is replaced. Linux needs `xz` for `tar` (the `xz-utils` package on Debian and Ubuntu). The script tells you when `~/.local/bin` is not on your `PATH` (the mod finds Typst there anyway), and when an older Typst comes first, so that the mod uses that one.-3. **The mod.** With the Claude Code commands only. If the `razorback16` marketplace is not known (`claude plugin marketplace list`), it runs `claude plugin marketplace add razorback16/cc-intelligent-ui`; else `claude plugin marketplace update razorback16`. Then, if the mod is not installed for your user (`claude plugin list`), it runs `claude plugin install cc-intelligent-ui@razorback16 --scope user`; else `claude plugin update cc-intelligent-ui@razorback16 --scope user`. The script shows each command before it runs it.+1. **Checks** your system (macOS or Linux, arm64 or x86_64) and that Claude Code is installed.+2. **Typst:** if no Typst 0.15 or later is found, installs the official Typst 0.15.1 into `~/.local/bin`, after a SHA-256 check.+3. **The mod:** adds the `razorback16` marketplace and installs the mod, or updates both.+4. **Auto-update:** turns it on for the marketplace in your Claude Code `settings.json`, with a backup.+5. **iTerm2 and herdr:** if either is there, adds [the setup line](#the-setup-line) to your shell's start file, with a backup.+6. **Summary:** what changed, and how to undo each step.- The script gets the newest version only from the official source: the GitHub repository `razorback16/cc-intelligent-ui` (or its `https://github.com/...` git URL) with no ref. If the `razorback16` marketplace comes from another source, for example a fork, a pinned ref (`#v0.3.0`) or a local folder, an update can not get the newest version. Then, if your user settings (`settings.json`) declare the `razorback16` marketplace, the script runs `claude plugin marketplace remove razorback16 --scope user` (this removes only that entry) and `claude plugin marketplace add razorback16/cc-intelligent-ui`. If they do not declare it (an older Claude Code added it, or another scope declares it), `remove --scope user` would fail, so the script runs only `claude plugin marketplace add razorback16/cc-intelligent-ui`, which changes the source by itself. Then it updates the mod. Claude Code can uninstall the mod (also its copies in projects) with the old marketplace; if it does, the script installs the mod again. Your `/iui` settings are kept, because Claude Code keeps them under the name `cc-intelligent-ui@razorback16`. If the mod was disabled, it stays disabled. The script shows the old source and the command to add it back. If the old source had a newer version (for example a work folder), the script says so.+**Options** (environment variables):- If a copy of the mod from another marketplace is installed for your user (for example `cc-intelligent-ui@other`), both copies would run. The script uninstalls that copy after the `razorback16` copy is installed, and shows the command to install it again. A copy with no marketplace (`cc-intelligent-ui@skills-dir` in a skills folder of Claude Code, or `cc-intelligent-ui@inline` from `--plugin-dir`) can not be uninstalled with `claude plugin`: the script shows it with its folder and does not change it. The `razorback16` copy is used, not that one. The script does not change copies in project or local scope. It shows each one, with its project folder and the command to remove it, because in that project such a copy can be used instead of the user copy.+- `IUI_NO_TYPST=1`: skip step 2. The script does not look for Typst and downloads nothing.+- `IUI_NO_AUTO_UPDATE=1`: skip step 4. `settings.json` does not change.+- `IUI_NO_SHELL_SETUP=1`: skip step 5. No shell start file changes.- If the update of the mod or of the marketplace fails, the summary says that the mod was not updated (not that the newest version is installed), and the script ends with exit code 1.-4. **Auto-update.** The script sets this entry in your user settings, `~/.claude/settings.json` (or `$CLAUDE_CONFIG_DIR/settings.json`). This is the setting that Claude Code documents for a marketplace in `extraKnownMarketplaces`:+For example: `curl -fsSL https://intelligentui.art/install.sh | IUI_NO_TYPST=1 bash`.- ```json- "extraKnownMarketplaces": {- "razorback16": {- "source": { "source": "github", "repo": "razorback16/cc-intelligent-ui" },- "autoUpdate": true- }- }- ```+**Safety.** The script never uses `sudo`. It runs no downloaded code except the Typst program it checked. It writes each file as a new file in the same folder and renames it over the old one, with the same permissions. All its work is in functions that the last line runs, so a cut download runs nothing. Its output is plain text.- `claude plugin marketplace add` already writes the `razorback16` entry with its `source`; the script adds `"autoUpdate": true` to it. It changes only that: all other bytes of the file (keys, their order, values, spaces) stay the same. It writes a new file in the same folder and then renames it over the old one, with the same permissions. If `settings.json` is a link, the file that it points to changes. It keeps the file before this change as `settings.json.bak-iui`, only when it changed the file. Step 3 (`claude plugin marketplace add` and `install`) changed `settings.json` already, so the backup undoes only the auto-update change, not step 3. If the file is not there, it makes it. If `autoUpdate` is `true` already, it changes nothing. If `autoUpdate` is `false` (you selected **Disable auto-update**), the script keeps it, says that auto-update is off by your choice, and tells you how to turn it on. When it adds the marketplace again from GitHub (step 3), it keeps `"autoUpdate": false` for the new entry. If the file is read-only, or has more than one name (a hard link), the script does not change it. If the `razorback16` entry has another `source`, the script does not change the file. If the file is not valid JSON (for example, it has comments), the script changes nothing, shows the entry to add, and ends with exit code 1. It uses `perl` (no modules) to read and change the JSON. It never uses `sed` on JSON.-5. **Pictures in iTerm2 and herdr.** Claude Code shows pictures in iTerm2 and herdr only when `CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1` is set when it starts. If iTerm2 is installed (macOS: `/Applications/iTerm.app`, `~/Applications/iTerm.app`, or Spotlight finds it) or `herdr` is there (on the `PATH` or in the folders of step 2), the script adds the mod's own block, the same that `/iui setup` adds, to the start file of your login shell (from `SHELL`): `${ZDOTDIR:-~}/.zshrc` for zsh; for bash, `~/.bashrc` on Linux, and on macOS the first of `~/.bash_profile`, `~/.bash_login` and `~/.profile` that exists (a login bash reads only that one; the script makes `~/.bash_profile` only when none exists); `${XDG_CONFIG_HOME:-~/.config}/fish/conf.d/cc-intelligent-ui.fish` for fish. The block is between the lines `# >>> cc-intelligent-ui: Claude Code pictures in iTerm2 >>>` and `# <<< cc-intelligent-ui <<<`. It sets the variable in iTerm2 and herdr only, not in tmux or screen. An older block of the mod is replaced, not added again; if the block is there already, nothing changes. If the file is a link, the file that it points to changes. The script writes a new file in the same folder and renames it over the old one, with the same permissions, and keeps the old file as `<file>.bak-iui`. If the file can not be read, is not a regular file, is read-only, has more than one name (a hard link), or is larger than 4 MB, the script changes nothing, shows the lines to add, and ends with exit code 1. For another shell, it changes nothing and shows the line to add. Undo: `/iui setup remove` in Claude Code, or delete the marked lines.-6. **Summary.** What was installed or updated, where Typst is, the state of auto-update and of the shell setup, and how to undo each step.+**Undo:**-Options (environment variables):+- The mod: `claude plugin uninstall cc-intelligent-ui@razorback16`+- The marketplace: `claude plugin marketplace remove razorback16`. Claude Code also removes the `razorback16` entry of `extraKnownMarketplaces` from your settings.+- Only auto-update: in Claude Code, type `/plugin`, go to **Marketplaces**, select **razorback16**, then **Disable auto-update**. In Claude Code 2.1.307 this also sets `"autoUpdate": false` in the settings file that declares the marketplace. Or copy `settings.json.bak-iui` back to `settings.json` (it is the file before the auto-update change only).+- An old marketplace source the script replaced: `claude plugin marketplace remove razorback16`, then `claude plugin marketplace add <old source>` (the script shows the old source).+- A copy from another marketplace the script uninstalled: `claude plugin install <id> --scope user` (the script shows the id).+- Typst, if the script installed it: `rm ~/.local/bin/typst`+- The shell setup: `/iui setup remove` in Claude Code, or delete the lines from `# >>> cc-intelligent-ui` to `# <<< cc-intelligent-ui <<<` in the start file the script names.-- `IUI_NO_TYPST=1`: no Typst step. The script does not look for Typst and downloads nothing.-- `IUI_NO_AUTO_UPDATE=1`: no auto-update step. `settings.json` does not change.-- `IUI_NO_SHELL_SETUP=1`: no shell setup step (5). No shell start file changes.+<details>+<summary><b>Each step in detail</b></summary>-For example: `curl -fsSL https://intelligentui.art/install.sh | IUI_NO_TYPST=1 bash`.+**1. Checks**-The script never uses `sudo` and runs no downloaded code other than the Typst program that it checked. All its work is in functions that the last line runs, so a download that stops in the middle runs nothing. Its output is plain text.+- The `claude` command must be on your `PATH`, or in `~/.local/bin` or `~/.claude/local`. Without it, the script points you to [Set up Claude Code](https://code.claude.com/docs/en/setup), changes nothing, and exits with code 1.+- Claude Code older than 2.1.298 gives a warning; the script continues.-To undo:+**2. Typst**-- The mod: `claude plugin uninstall cc-intelligent-ui@razorback16`-- The marketplace: `claude plugin marketplace remove razorback16`. Claude Code also removes the `razorback16` entry of `extraKnownMarketplaces` from your settings.-- Only auto-update: in Claude Code, type `/plugin`, go to **Marketplaces**, select **razorback16**, then select **Disable auto-update**. In Claude Code 2.1.307, this also sets `"autoUpdate": false` in the settings file that declares the marketplace. Or copy `settings.json.bak-iui` back to `settings.json` (it is the file before the auto-update change only).-- The old marketplace source, if the script replaced it: `claude plugin marketplace remove razorback16`, then `claude plugin marketplace add <old source>` (the script shows the old source).-- A copy from another marketplace that the script uninstalled: `claude plugin install <id> --scope user` (the script shows the id).-- Typst, if the script installed it: `rm ~/.local/bin/typst`-- The shell setup: `/iui setup remove` in Claude Code, or delete the lines from `# >>> cc-intelligent-ui` to `# <<< cc-intelligent-ui <<<` in the start file that the script names.+- It looks for Typst as the mod does: the `PATH` of a login shell (`sh -l`; on macOS `/usr/local/bin` comes first there), then your `PATH`, then `/opt/homebrew/bin`, `/usr/local/bin`, `/usr/bin`, `/snap/bin`, `~/.cargo/bin`, `~/.local/bin`, `/home/linuxbrew/.linuxbrew/bin` and `~/.linuxbrew/bin`. If the first one it finds is 0.15 or later, nothing changes.+- Else it downloads the release file for your system from [GitHub](https://github.com/typst/typst/releases/tag/v0.15.1) (`typst-aarch64-apple-darwin`, `typst-x86_64-apple-darwin`, `typst-aarch64-unknown-linux-musl` or `typst-x86_64-unknown-linux-musl`, `.tar.xz`) with `curl`, over HTTPS only.+- On a SHA-256 mismatch with the value in the script, it deletes the file, installs nothing, and stops.+- It extracts the file in a private temporary folder (deleted at the end), checks that the program runs, and moves it to `~/.local/bin/typst`, replacing an older one there.+- Linux needs `xz` for `tar` (`xz-utils` on Debian and Ubuntu).+- It tells you when `~/.local/bin` is not on your `PATH` (the mod finds Typst there anyway), and when an older Typst comes first, so the mod would use that one.++**3. The mod**++The script uses only the `claude plugin` commands and shows each one before it runs it.++- **Marketplace:** `claude plugin marketplace add razorback16/cc-intelligent-ui` if `razorback16` is not known, else `claude plugin marketplace update razorback16`.+- **Mod:** `claude plugin install cc-intelligent-ui@razorback16 --scope user` if it is not installed for your user, else `claude plugin update cc-intelligent-ui@razorback16 --scope user`.+- **Another marketplace source.** Updates come only from the GitHub repository `razorback16/cc-intelligent-ui` (or its `https://github.com/...` URL) with no ref. If `razorback16` comes from somewhere else (a fork, a pinned ref such as `#v0.3.0`, a local folder), the script adds it again from GitHub, then updates the mod. It runs `claude plugin marketplace remove razorback16 --scope user` first only when your user `settings.json` declares the marketplace; otherwise `add` changes the source by itself.+ - If Claude Code uninstalls the mod (also its project copies) during this, the script installs it again.+ - Your `/iui` settings stay (they belong to `cc-intelligent-ui@razorback16`). A disabled mod stays disabled.+ - The script shows the old source and the command to add it back, and tells you if the old source had a newer version (for example a work folder).+- **Other copies of the mod.** A user copy from another marketplace (for example `cc-intelligent-ui@other`) would also run, so the script uninstalls it after the `razorback16` copy is in, and shows the command to install it again. These are only shown, with their folder:+ - A copy with no marketplace (`cc-intelligent-ui@skills-dir` in a Claude Code skills folder, or `cc-intelligent-ui@inline` from `--plugin-dir`). The `razorback16` copy is used, not that one.+ - Copies in project or local scope, with the command to remove them. In that project, such a copy can be used instead of the user copy.+- **A failed update** of the mod or the marketplace: the summary says the mod was not updated, and the script exits with code 1.++**4. Auto-update**++In your user settings, `~/.claude/settings.json` (or `$CLAUDE_CONFIG_DIR/settings.json`), the script adds `"autoUpdate": true` to the `razorback16` entry that `claude plugin marketplace add` wrote. This is the documented Claude Code setting:++```json+"extraKnownMarketplaces": {+ "razorback16": {+ "source": { "source": "github", "repo": "razorback16/cc-intelligent-ui" },+ "autoUpdate": true+ }+}+```++- **Only that changes.** All other bytes of the file (keys, order, values, spaces) stay the same. It edits the JSON with `perl` (no modules), never with `sed`.+- **Backup:** `settings.json.bak-iui`, only when the file changed. It undoes only the auto-update change, not step 3.+- **No file:** it makes one. **A link:** the file it points to changes.+- **`true` already:** nothing changes.+- **`false`** (you chose **Disable auto-update**): kept, also when step 3 adds the marketplace again. The script says how to turn it on.+- **Not changed:** a read-only file, a hard link (more than one name), or a `razorback16` entry with another `source`.+- **Not valid JSON** (for example, with comments): nothing changes, the script shows the entry to add, and exits with code 1.++**5. iTerm2 and herdr**++If iTerm2 is installed (macOS: `/Applications/iTerm.app`, `~/Applications/iTerm.app`, or found by Spotlight) or `herdr` is there (on the `PATH` or in the folders of step 2), the script adds the same block as `/iui setup` to the same [start file](#the-setup-line) of your login shell.++- Another shell: nothing changes; the script shows the line to add.+- An older block of the mod is replaced. If the block is there already, nothing changes. If the file is a link, the file it points to changes.+- **Backup:** `<file>.bak-iui`.+- **Not changed:** a file that cannot be read, is not a regular file, is read-only, is a hard link, or is larger than 4 MB. The script then shows the lines to add and exits with code 1.++**6. Summary**++What was installed or updated, where Typst is, the state of auto-update and of the shell setup, and how to undo each step.++</details>### By hand@@ -108,61 +178,61 @@ To undo:/plugin install cc-intelligent-ui --marketplace razorback16/cc-intelligent-ui```- Answer `y` to add the marketplace, then push Enter to install for your user. The mod starts at once, with no restart. From a shell, use `claude plugin install cc-intelligent-ui --marketplace razorback16/cc-intelligent-ui`.-3. Turn on auto-update, so that you get each new version. Refer to [Turn on auto-update](#turn-on-auto-update).-4. In iTerm2 or herdr, answer yes when the mod asks to add its line to your shell's start file, or run `/iui setup`. Refer to [Terminals](#terminals).+ Answer `y` to add the marketplace, then press Enter to install for your user. The mod starts at once, with no restart. From a shell: `claude plugin install cc-intelligent-ui --marketplace razorback16/cc-intelligent-ui`.+3. [Turn on auto-update](#turn-on-auto-update) to get each new version.+4. In iTerm2 or herdr, say yes when the mod asks to add [the setup line](#the-setup-line), or run `/iui setup`.## Install Typst on Linux-You need Typst 0.15 or later. Use one of these ways:+You need Typst 0.15 or later. Use one of these:- **Cargo** (Rust): `cargo install --locked typst-cli`. Typst goes into `~/.cargo/bin`.- **The release file:** download `typst-x86_64-unknown-linux-musl.tar.xz` (or `typst-aarch64-unknown-linux-musl.tar.xz` for ARM) from [the Typst releases](https://github.com/typst/typst/releases). Extract it and put `typst` in a folder on your `PATH`, for example `~/.local/bin`.-- **A package of your distribution, Snap (`sudo snap install typst`) or Homebrew on Linux (`brew install typst`).** Make sure that the version is 0.15 or later (`typst --version`). Some distributions have an older version.+- **A distribution package, Snap (`sudo snap install typst`) or Homebrew on Linux (`brew install typst`).** Check the version with `typst --version`: some distributions have an older one.-The mod finds Typst on the `PATH` of your login shell. It also looks in `/usr/local/bin`, `/usr/bin`, `/snap/bin`, `~/.cargo/bin`, `~/.local/bin` and the Homebrew folders.+The mod finds Typst on the `PATH` of your login shell, and also in `/usr/local/bin`, `/usr/bin`, `/snap/bin`, `~/.cargo/bin`, `~/.local/bin` and the Homebrew folders.## Linux-The mod works on Linux with X11 and with Wayland. It uses these tools. Most Linux systems have the first three.+The mod works on Linux with X11 and Wayland. It uses these tools (most systems have the first three):-- **perl** (perl 5): reads the terminal size and its cell size, and watches for a change of the size. It also writes the frame files of the highlight for picture select (with `MIME::Base64`, a core module). On macOS, `/usr/bin/perl` also watches the clipboard for the `/iui grab` toast, with Apple's PerlObjCBridge (macOS has it).-- **fontconfig** (`fc-match`, `fc-list`): finds the terminal font when the terminal's config does not name one. kitty and most terminals use fontconfig's `monospace` font. Ghostty uses its own JetBrains Mono when its config names no font. If fontconfig does not have JetBrains Mono, the mod copies the font from the Ghostty program (refer to [How it works](how-it-works.md)). The mod also uses `fc-list` to find if the font that the terminal config names is installed.-- **The light or dark mode of the desktop** (for the `auto` theme): the freedesktop portal (`org.freedesktop.appearance color-scheme`, through `gdbus` or `busctl`). GNOME, KDE Plasma and most desktops have the portal. If the portal does not answer, the mod reads GNOME's `color-scheme` (`gsettings`).-- **The clipboard** (only for the `/iui grab` toast and for `/iui grab` on the main screen, refer to [Picture cells on the clipboard](usage.md#picture-cells-on-the-clipboard)). The mod uses the first of these that it finds:- 1. **Wayland, not GNOME:** `wl-paste` from `wl-clipboard`. `wl-paste --watch` tells the mod about each clipboard change. It needs the data-control protocol of the compositor (KDE Plasma, Sway, Hyprland and other wlroots compositors have it).- 2. **X11, and GNOME on Wayland (through Xwayland):** `clipnotify` tells the mod about each clipboard change, and `xclip` reads the clipboard. If `clipnotify` or `xclip` is not installed, the mod uses GTK 3 from Python (`python3-gi`, which most GNOME desktops have) in its place. The mod does not use `xsel`: it cannot show the targets of a copy, so it cannot skip a password manager's copy (`/iui details` tells you to install `xclip`).- 3. **GNOME on Wayland with no X11 tool:** `wl-paste`. GNOME does not have the data-control protocol, so `wl-paste --watch` stops, and there is no `/iui grab` toast.+- **perl** (perl 5): reads the terminal size and cell size and watches for changes. It also writes the highlight frames for picture select (with the core module `MIME::Base64`). On macOS, `/usr/bin/perl` with Apple's PerlObjCBridge also watches the clipboard for the `/iui grab` toast.+- **fontconfig** (`fc-match`, `fc-list`): finds the terminal font when the terminal config names none, and checks that a named font is installed. kitty and most terminals use fontconfig's `monospace`. Ghostty uses its own JetBrains Mono when its config names no font; if fontconfig does not have it, the mod copies it from the Ghostty program (refer to [How it works](how-it-works.md)).+- **Light or dark mode** (for the `auto` theme): the freedesktop portal (`org.freedesktop.appearance color-scheme`, through `gdbus` or `busctl`), which GNOME, KDE Plasma and most desktops have. If it does not answer, GNOME's `color-scheme` (`gsettings`).+- **The clipboard**, only for the `/iui grab` toast and for `/iui grab` on the main screen (refer to [Picture cells on the clipboard](usage.md#picture-cells-on-the-clipboard)). The mod uses the first that works:+ 1. **Wayland, not GNOME:** `wl-paste --watch` from `wl-clipboard`. It needs the compositor's data-control protocol (KDE Plasma, Sway, Hyprland and other wlroots compositors have it).+ 2. **X11, and GNOME on Wayland (through Xwayland):** `clipnotify` to see changes and `xclip` to read. Without them, GTK 3 from Python (`python3-gi`, on most GNOME desktops). `xsel` is not used: it cannot show the targets of a copy, so the mod could not skip a password manager's copy (`/iui details` tells you to install `xclip`).+ 3. **GNOME on Wayland with no X11 tool:** `wl-paste`. GNOME has no data-control protocol, so `wl-paste --watch` stops and there is no toast.- If none of these work, there is no `/iui grab` toast. Picture select, `/iui grab` (with a selection, in fullscreen mode), Claude Code's `/copy` and the `ui.copy` hook still work. `/iui details` shows the tool in use, or why there is no toast, on the line `/iui grab hint:`.-- **"Edit the plan"** (refer to [Plan approval](usage.md#plan-approval)): VS Code (`code --wait`), else the first of VSCodium, Zed, Sublime Text, Kate, gedit and gvim that is on the `PATH`. These editors can wait until you close the file. If none is installed, the option does not show.-- **The cache folder** is in `$TMPDIR`, else in `/tmp`.+ With none of these, there is no `/iui grab` toast. Picture select, `/iui grab` (with a selection, in fullscreen), Claude Code's `/copy` and the `ui.copy` hook still work. `/iui details` shows the tool in use, or why there is no toast, on the line `/iui grab hint:`.+- **"Edit the plan"** (refer to [Plan approval](usage.md#plan-approval)): VS Code (`code --wait`), else the first on the `PATH` of VSCodium, Zed, Sublime Text, Kate, gedit and gvim (editors that can wait until you close the file). With none, the option does not show.+- **The cache folder** is in `$TMPDIR`, else `/tmp`.-`/iui setup` is for iTerm2 and herdr. On Linux it changes no file, but in a herdr pane it adds the line (to `~/.bashrc` for bash, because herdr does not start a login shell on Linux).+`/iui setup` changes no file on Linux, except in a herdr pane: there it adds the setup line (to `~/.bashrc` for bash, because herdr does not start a login shell on Linux).-To install the clipboard tools, for example:+To install the clipboard tools:-- Debian and Ubuntu: `sudo apt install wl-clipboard xclip` (`clipnotify` is not in their packages: build it from [cdown/clipnotify](https://github.com/cdown/clipnotify), or use GTK 3 from Python: `sudo apt install python3-gi gir1.2-gtk-3.0`).+- Debian and Ubuntu: `sudo apt install wl-clipboard xclip`. `clipnotify` is not packaged: build it from [cdown/clipnotify](https://github.com/cdown/clipnotify), or use GTK 3 from Python: `sudo apt install python3-gi gir1.2-gtk-3.0`.- Fedora: `sudo dnf install wl-clipboard xclip`.- Arch Linux: `sudo pacman -S wl-clipboard xclip clipnotify`.## Update-Claude Code finds a new version of the mod from the version number in its `plugin.json`. For a marketplace that is not from Anthropic, such as `razorback16`, auto-update is off by default.+Claude Code sees a new version by the version number in the mod's `plugin.json`. For a marketplace not from Anthropic, such as `razorback16`, auto-update is off by default.### Turn on auto-update-The [install script](#the-install-script) turns it on for you. To turn it on yourself:+The [install script](#the-install-script) turns it on. To do it yourself:1. In Claude Code, type `/plugin`.2. Go to **Marketplaces**, then select **razorback16**.3. Select **Enable auto-update**.-Claude Code then updates the mod in approximately 10 minutes after the first message of a session. The new version starts in the next session, or after you type `/reload-plugins`.+Claude Code then updates the mod about 10 minutes after the first message of a session. The new version starts in the next session, or after `/reload-plugins`.### Update manually-Run the [install script](#the-install-script) again, or, from a shell:+Run the [install script](#the-install-script) again, or from a shell:```claude plugin marketplace update razorback16@@ -173,15 +243,15 @@ Then type `/reload-plugins` in Claude Code, or start a new session.### The update notice-The mod looks for a new version one time each day at most, after a session starts. When there is a newer version, a toast shows the new version, your version and the update commands. A toast for one version shows one time each day at most. `/iui` and `/iui details` also show the new version.+At most once a day, after a session starts, the mod checks for a new version. If there is one, a toast shows the new version, your version and the update commands (at most once a day for each version). `/iui` and `/iui details` also show it.-- Network use: one GET request for a public file on GitHub (`https://raw.githubusercontent.com/razorback16/cc-intelligent-ui/main/.claude-plugin/plugin.json`) each day at most. The mod sends no data about you or your sessions. The request goes through Claude Code.-- `/iui updates off` stops the check and the toast (kept for later sessions). `/iui updates on` starts them again.-- The mod does not look for a new version when `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`, `DISABLE_UPDATES` or `DISABLE_AUTOUPDATER` is set, in a background session, or with `claude -p`.+- **Network:** one GET request through Claude Code for a public file on GitHub (`https://raw.githubusercontent.com/razorback16/cc-intelligent-ui/main/.claude-plugin/plugin.json`). No data about you or your sessions is sent.+- **Turn it off:** `/iui updates off` (kept for later sessions). `/iui updates on` turns it back on.+- **No check** when `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`, `DISABLE_UPDATES` or `DISABLE_AUTOUPDATER` is set, in a background session, or with `claude -p`.## Try it from a clone-To try it from a clone without installing:+To try it without installing:```git clone https://github.com/razorback16/cc-intelligent-uidiff --git a/docs/limitations.md b/docs/limitations.mdindex 2a557c8..77381b0 100644--- a/docs/limitations.md+++ b/docs/limitations.md@@ -4,12 +4,12 @@## Copy and picture select-- **Fullscreen only.** Picture select needs fullscreen mode and Claude Code 2.1.298 or newer. It does not work over ssh. Anywhere else, a copy of a picture gives picture cells, which paste as strange characters. Use `/iui grab`, Claude Code's `/copy`, or `/iui off` instead.-- **Start the drag on the picture.** On Claude Code 2.1.298 to 2.1.304, a selection that starts outside a picture (or a double or triple click) is Claude Code's own selection, and it can copy picture cells. From 2.1.305, Claude Code's selection skips pictures. A drag with a modifier key (for example Option in iTerm2) is the terminal's own selection and also copies picture cells.-- **One picture at a time.** A selection stays in the picture where it started, so you cannot select text and a picture together. There is no double click, triple click or Shift+click.-- **Whole words.** A word is copied when the selection covers its middle. In code, in long words (30 characters or more, such as paths and URLs) and in CJK text, the copy goes by character. Inline math copies as its LaTeX source (`$A = \pi r^2$`). If inline math breaks across two lines, select its first line. Display math, text in images and text in Typst drawings do not copy.-- **Clearing a selection.** A single click on normal text and Escape do not clear a picture selection, because Claude Code does not tell the mod about them. A click in a picture, a key in the prompt, a new selection, your next prompt or `/iui off` does.-- **A Claude Code selection stays on screen** when you then drag over a picture. Click normal text or push a key first.+- **Fullscreen only.** Picture select needs fullscreen mode and Claude Code 2.1.298 or newer. It does not work over ssh. Anywhere else, a copy of an answer gives picture cells, which paste as strange characters. Use `/iui grab`, Claude Code's `/copy`, or `/iui off` instead.+- **Start the drag on the answer.** On Claude Code 2.1.298 to 2.1.304, a selection that starts outside an answer (or a double or triple click) is Claude Code's own selection, and it can copy picture cells. From 2.1.305, Claude Code's selection skips pictures. A drag with a modifier key (for example Option in iTerm2) is the terminal's own selection and also copies picture cells.+- **One answer at a time.** A selection stays in the answer where it started, so you cannot select it together with normal text. There is no double click, triple click or Shift+click.+- **Whole words.** A word is copied when the selection covers its middle. In code, in long words (30 characters or more, such as paths and URLs) and in CJK text, the copy goes by character. Inline math copies as its LaTeX source (`$A = \pi r^2$`). If inline math breaks across two lines, select its first line. Display math and text in images, diagrams and Typst drawings do not copy.+- **Clearing a selection.** A single click on normal text and Escape do not clear a picture selection, because Claude Code does not tell the mod about them. A click in an answer, a key in the prompt, a new selection, your next prompt or `/iui off` does.+- **A Claude Code selection stays on screen** when you then drag over an answer. Click normal text or push a key first.- **Short waits.** The mod reads the words of a page in the background. If you release the button before they are ready, the copy takes up to 0.5 s (2–3 s for a large Typst drawing). Wait for the "copied N chars" toast before you paste. On a page that is not ready, the highlight also comes a moment after the press.- **The highlight** needs `perl`. Without it, select and copy still work, with no highlight. The colour is VS Code's, not your theme's. A page over 4 MiB has no highlight. If the terminal draws a page with a different aspect than its cells, the highlight can be off by part of a cell. After Claude Code redraws a page, the highlight comes back only when the selection changes. Ready pages use up to 128 MB of memory.- **Copy on release.** The copy happens when you release the button, even if `copyOnSelect` is off in `/config`.@@ -24,8 +24,8 @@- **A click copies; it does not open.** The terminal does not send cmd+click to Claude Code, and on macOS ctrl+click is the secondary click.- **Not every link is a target.** Code blocks are not targets: select the text. A file path is a target only if the file existed when the answer was drawn. Links to headings, and links in Typst drawings, math or images, are not targets. Until the mod knows the words of a page, hover shows nothing and a click waits.-- **The dim rows under a picture** (with the copy button of a `bash` block) do not show with picture select.-- **Without picture select** (main screen, ssh, older Claude Code, `/iui select off`), a click on a picture does nothing. Use the link rows under it. A command row copies only in fullscreen mode. A `file://` link opens in the app that your terminal chooses.+- **No link rows with picture select.** The dim rows of links, paths and commands under an answer do not show. Click them in the answer instead.+- **Without picture select** (main screen, ssh, older Claude Code, `/iui select off`), a click in an answer does nothing. Use the link rows under it. A command row copies only in fullscreen mode. A `file://` link opens in the app that your terminal chooses.## How pictures look@@ -49,7 +49,7 @@## Other features-- **Dragged image paths.** A path that you drag into the terminal does not change the clipboard, so its preview shows only after you send the prompt. If the clipboard holds the path of a different image at that time, the preview shows that image until you send.+- **Pasted image paths.** There is no preview for a pasted path over ssh. A path that you drag into the terminal does not change the clipboard, so its preview shows only after you send the prompt. If the clipboard holds the path of a different image at that time, the preview shows that image until you send.- **PDF files.** The page buttons work only in fullscreen mode. The mod shows one page at a time, with no page count, and you cannot copy text from a page. The page field gets the keyboard only when the prompt is empty; otherwise click the field to type. Esc then goes to the prompt. To close the field, click it and push Esc, or click its close mark.- **Plan approval.** A mod cannot draw Claude Code's dialog, so the mod asks its own question, with 4 options at most. There is no "keep planning" option: type a reply or push Esc. The edit option needs a GUI editor that waits until you close the file, so not vim or nano, and on Linux not `xdg-open`. Where an organization manages Claude Code, plugin permission hooks do not run, and Claude Code's dialog shows after the mod's question.- **Cache folders.** The mod uses only its private folder `$TMPDIR/cc-intelligent-ui-<uid>`, which must be yours, mode 700 and not a link. If it is not, the mod draws nothing and `/iui details` says why: fix or remove the folder, then start Claude Code again. The mod also keeps drawing spaces in `~/.cache/cc-intelligent-ui/designs` for 180 days, and fonts copied out of terminal apps in `~/.cache/cc-intelligent-ui/fonts` (fonts of an older app build are deleted after 30 days). It uses `$XDG_CACHE_HOME` when set.diff --git a/docs/privacy.md b/docs/privacy.mdindex 8d70f22..58e0a48 100644--- a/docs/privacy.md+++ b/docs/privacy.md@@ -2,11 +2,80 @@← Back to the [README](../README.md)-The mod sends nothing about you or your sessions anywhere.--- **Network:** one GET request each day at most, to `raw.githubusercontent.com`, for the public `plugin.json` of this mod. It only tells you about a new version. `/iui updates off` stops it. It also stops when `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`, `DISABLE_UPDATES` or `DISABLE_AUTOUPDATER` is set.-- **Clipboard, read:** a small `perl` process watches the clipboard while the mod is on and has drawn a picture (not over ssh). On macOS it reads only the change counter; when the counter changes, the mod reads the text once with a short `perl` script (PerlObjCBridge). On Linux a notifier (`wl-paste --watch`, `clipnotify` or GTK 3 from `python3`) tells it of each change, and it then reads the text with `wl-paste`, `xclip` or GTK. `/iui grab` with no mouse selection also reads the clipboard once. When you paste and a new `[Image #N]` has no image file from Claude Code (a pasted path of an image file), the mod reads the clipboard once to find that file (only while the mod is on and draws pictures, not over ssh); it uses the text only as a list of image paths, keeps them in memory only for the draft, and sends them nowhere. The text is only checked for picture cells (then a toast names `/iui grab`); it is kept in memory only and sent nowhere (`/iui dump` writes the last clipboard with picture cells to `copy-debug.json` in the cache folder). A password manager's copy is never read: on macOS a copy with a concealed or transient type, on Linux a copy that offers the `x-kde-passwordManagerHint` target, and on Wayland also a copy marked sensitive. (On Wayland, `wl-paste --watch` hands each new copy to `cat`, which drops it.)-- **Clipboard, written:** only at these times: when you release a picture selection, when you click a link, a file path, a command or a copy button in a picture, on `/iui grab`, when you press the command button in a link row (in fullscreen with `/iui select off`, where Claude Code gets the click), and when the mod changes a `$.ui.copy` that has picture cells to its text.-- **Files:** a private cache folder in `$TMPDIR` (`cc-intelligent-ui-<uid>`, `/tmp` when `TMPDIR` is not set; mode 700, its folders deleted after 2 days). Each compile makes a folder of its own in it (the Typst root, see below) and deletes it after the compile. Also `~/.cache/cc-intelligent-ui/designs` (files deleted after 180 days) and `~/.cache/cc-intelligent-ui/fonts` (fonts copied out of a terminal app, such as Ghostty's JetBrains Mono; `$XDG_CACHE_HOME` in place of `~/.cache` when it is set). The previews of pasted images are made in the cache folder too, from the image files that Claude Code writes when you paste, or, for a pasted path, from the image file that the path names (a JPEG or WebP first as a PNG that Typst makes). `/iui setup` (iTerm2 on macOS, and herdr) changes your shell start file, only when you run it or agree to its question. The install script adds the same block when iTerm2 or herdr is there (`IUI_NO_SHELL_SETUP=1` stops it).-- **Processes:** `typst`, the `perl` watcher, and short helper commands such as `perl`, `sh`, `osascript`, `defaults`, `plutil`, `fc-list` and `fc-match`. In herdr, only while the mod is on and pictures show (from the start), a check each second finds the herdr client that you use: `stat` of the clients' terminal devices (the time of the last key), and on macOS `lsappinfo` (the app in front); with no client attached, no check each second. Each 10 s, and when the check each second finds a change, a full check: `ps` (the list of processes), `lsof` (with more than one herdr server), and the variables of your own herdr clients (Linux: `/proc/<pid>/environ`; macOS: `ps eww`). The shell of this check keeps only `TERM`, `TERM_PROGRAM`, `COLORFGBG`, `LC_TERMINAL`, `ITERM_PROFILE`, `ITERM_SESSION_ID`, `GHOSTTY_BIN_DIR`, `GHOSTTY_RESOURCES_DIR`, `KITTY_CONFIG_DIRECTORY`, `KITTY_INSTALLATION_DIR`, `KITTY_PID`, `KITTY_WINDOW_ID`, `CMUX_SOCKET_PATH`, `CMUX_SURFACE_ID`, `CMUX_WORKSPACE_ID` and `RIO_CONFIG_HOME`; the mod (and other mods' hooks) get no other variable. It writes none of this anywhere. With the `auto` theme, a `perl` asks herdr's pane for its background (OSC 11) at the start and when you change to a different herdr client, not on a timer. On Linux also `wl-paste`, `xclip`, `clipnotify` or `python3 -I` (GTK 3; isolated, so it loads no code from the project folder) for the clipboard.-- **Typst:** each compile of an answer or a plan runs with a narrow root: a new folder with the mod's template, the theme and the images that the text names. So the code in an answer cannot read other files on your computer. The skill's `check.sh` compiles the same way, and so does the preview of a pasted image (a folder with only its template and the pasted image).+The mod sends nothing about you or your sessions anywhere. This page lists everything it reads, writes and runs.++## Network++- **One request a day at most:** a GET, through Claude Code, for the public `plugin.json` of this mod on `raw.githubusercontent.com`. It only tells you about a new version.+- **Turn it off:** `/iui updates off`. It is also off when `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`, `DISABLE_UPDATES` or `DISABLE_AUTOUPDATER` is set.++## Clipboard++### What the mod reads++- **The watcher:** a small `perl` process watches the clipboard while the mod is on and has drawn a picture (not over ssh).+ - macOS: it reads only the change counter. When the counter changes, the mod reads the text once with a short `perl` script (PerlObjCBridge).+ - Linux: a notifier (`wl-paste --watch`, `clipnotify` or GTK 3 from `python3`) reports each change. The mod then reads the text with `wl-paste`, `xclip` or GTK.+- **`/iui grab`** with no mouse selection reads the clipboard once.+- **A pasted image path:** when you paste and a new `[Image #N]` has no image file from Claude Code, the mod reads the clipboard once to find the image file the path names. This happens only while the mod is on and draws pictures, not over ssh. The text is used only as a list of image paths, kept in memory only for the draft, and sent nowhere.++### What it does with the text++- **Checks it for picture cells** only. If it finds them, a toast names `/iui grab`.+- **Keeps it in memory only** and sends it nowhere.+- **One exception:** `/iui dump` writes the last clipboard with picture cells to `copy-debug.json` in the cache folder.++### Password managers++A password manager's copy is never read:++- macOS: a copy with a concealed or transient type.+- Linux: a copy that offers the `x-kde-passwordManagerHint` target.+- Wayland: also a copy marked sensitive. (`wl-paste --watch` hands each new copy to `cat`, which drops it.)++### When the mod writes the clipboard++Only when you:++- release a selection in an answer;+- click a link, a file path, a command or a copy button in an answer;+- run `/iui grab`;+- press the command button in a link row (in fullscreen with `/iui select off`, where Claude Code gets the click).++It also writes when it changes a `$.ui.copy` that has picture cells to its text.++## Files++| Where | What | Kept |+|---|---|---|+| `$TMPDIR/cc-intelligent-ui-<uid>` (`/tmp` when `TMPDIR` is not set) | The private cache folder (mode 700): drawn pages, converted images, previews of pasted images, and one folder for each Typst compile (the [Typst root](#typst)) | Compile folders until the compile ends; other folders 2 days (not `pkg-cache`, Typst's package cache) |+| `~/.cache/cc-intelligent-ui/designs` | The size of each Typst drawing, so it keeps its size in later sessions | 180 days |+| `~/.cache/cc-intelligent-ui/fonts` | Fonts copied out of a terminal app, such as Ghostty's JetBrains Mono | |++`$XDG_CACHE_HOME` replaces `~/.cache` when it is set.++- **Previews of pasted images** come from the image files Claude Code writes when you paste, or, for a pasted path, from the file the path names. A JPEG or WebP is first made into a PNG by Typst.+- **Your shell start file:** `/iui setup` (iTerm2 on macOS, and herdr) changes it only when you run it or agree to its question. The install script adds the same block when iTerm2 or herdr is there (`IUI_NO_SHELL_SETUP=1` stops it). Everything the install script changes is in [Install](install.md#the-install-script).++## Processes++- **Always:** `typst`, the `perl` watcher, and short helper commands such as `perl`, `sh`, `osascript`, `defaults`, `plutil`, `fc-list` and `fc-match`.+- **Linux clipboard:** `wl-paste`, `xclip`, `clipnotify` or `python3 -I` (GTK 3; isolated, so it loads no code from the project folder).+- **herdr**, only while the mod is on and pictures show (from the start):+ - **Each second**, to find the herdr client you use: `stat` of the clients' terminal devices (the time of the last key) and, on macOS, `lsappinfo` (the app in front). With no client attached, there is no check each second.+ - **Each 10 s**, and when the check each second sees a change, a full check: `ps` (the process list), `lsof` (with more than one herdr server), and the environment of your own herdr clients (Linux: `/proc/<pid>/environ`; macOS: `ps eww`).+ - **Background colour:** with the `auto` theme, a `perl` asks herdr's pane for its background (OSC 11) at the start and when you change to a different herdr client. Not on a timer.++### Environment variables in the herdr check++The shell of the full check keeps only these variables. The mod, and other mods' hooks, get no other variable, and nothing is written anywhere:++`TERM`, `TERM_PROGRAM`, `COLORFGBG`, `LC_TERMINAL`, `ITERM_PROFILE`, `ITERM_SESSION_ID`, `GHOSTTY_BIN_DIR`, `GHOSTTY_RESOURCES_DIR`, `KITTY_CONFIG_DIRECTORY`, `KITTY_INSTALLATION_DIR`, `KITTY_PID`, `KITTY_WINDOW_ID`, `CMUX_SOCKET_PATH`, `CMUX_SURFACE_ID`, `CMUX_WORKSPACE_ID`, `RIO_CONFIG_HOME`.++## Typst++Each compile of an answer or a plan runs with a narrow root: a new folder with only the mod's template, the theme and the images the text names. So Typst code in an answer cannot read other files on your computer.++The same applies to the skill's `check.sh`, and to the preview of a pasted image (a folder with only its template and that image).++Typst also has no network: its proxy variables point to `http://127.0.0.1:9`, so it downloads nothing (a package the mod does not include cannot be fetched).diff --git a/docs/themes.md b/docs/themes.mdindex ad84593..7b7179b 100644--- a/docs/themes.md+++ b/docs/themes.md@@ -2,7 +2,7 @@← Back to the [README](../README.md)-A theme sets the colours, fonts and spacing of the picture. Body text always uses the terminal's own font at the terminal's text size. Three themes are in the mod:+A theme sets the colours, fonts and spacing of answers. Body text always uses your terminal's font at its text size.| Name | Looks like ||---|---|@@ -10,15 +10,16 @@ A theme sets the colours, fonts and spacing of the picture. Body text always use| `vscode-modern` | VS Code's Markdown preview with Dark Modern / Light Modern || `vscode` | The same, with the Dark+ / Light+ colours |-Each theme has a dark and a light part. The mod uses the part that agrees with Claude Code's theme. For the `auto` theme of Claude Code, refer to [How `auto` is resolved](how-it-works.md#how-auto-is-resolved).+Each theme has a dark and a light part. The mod uses the one that matches Claude Code's theme. For Claude Code's `auto` theme, refer to [How `auto` is resolved](how-it-works.md#how-auto-is-resolved).-To change the theme, run `/iui theme <name>`. To list the themes, run `/iui theme`.+- **Change the theme:** `/iui theme <name>`+- **List the themes:** `/iui theme`## Make your own theme1. Make a folder: `~/.claude/cc-intelligent-ui/themes/<name>/`.-2. Put a `theme.json` in it. Write only the keys that you change. The mod merges your file over the base theme, `vscode` (not over the default, `claude-code`).-3. Run `/iui theme <name>`. You do not have to restart.+2. Put a `theme.json` in it, with only the keys you change. The mod merges it over the `vscode` theme (not over the default, `claude-code`).+3. Run `/iui theme <name>`. No restart needed.Example: pink inline code with rounder boxes.@@ -33,13 +34,14 @@ Example: pink inline code with rounder boxes.## Rules-- A user theme with the same folder name as a built-in theme is used in its place. It is still merged over the built-in `vscode`.-- Colours are `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa`. The picture has no background, so a translucent colour (for example `#ffffff1a`) looks correct on all terminal colours.-- A value of the wrong type is ignored, and the `vscode` value is used. If the file is not valid JSON, the theme is skipped, the default theme is used, and `/iui theme` tells you why.-- For your own syntax colours, put TextMate theme files in the folder and name them: `"syntax": { "dark": "dark.tmTheme", "light": "light.tmTheme" }`. A file that you name must exist.+- **Same name as a built-in theme:** your theme is used in its place, still merged over the built-in `vscode`.+- **Colours:** `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa`. Answers have no background, so a translucent colour (for example `#ffffff1a`) looks right on any terminal colour.+- **Wrong values:** a value of the wrong type is ignored, and the `vscode` value is used.+- **Invalid JSON:** the theme is skipped, the default theme is used, and `/iui theme` tells you why.+- **Syntax colours:** put TextMate theme files in the folder and name them: `"syntax": { "dark": "dark.tmTheme", "light": "light.tmTheme" }`. A file you name must exist.-All keys, their units and their defaults are in [`render/themes/README.md`](../render/themes/README.md).+All keys, units and defaults are in [`render/themes/README.md`](../render/themes/README.md).## Licence-The `vscode` and `vscode-modern` values come from VS Code (MIT licence, Copyright (c) 2015 - present Microsoft Corporation). The `claude-code` theme uses the ANSI colours of the VS Code terminal for links and code. The `LICENSE` file is in each of those folders. Refer also to [`THIRD-PARTY-NOTICES.md`](../THIRD-PARTY-NOTICES.md).+The `vscode` and `vscode-modern` values come from VS Code (MIT licence, Copyright (c) 2015 - present Microsoft Corporation). The `claude-code` theme uses the ANSI colours of the VS Code terminal for links and code. Each of those folders has the `LICENSE` file. Refer also to [`THIRD-PARTY-NOTICES.md`](../THIRD-PARTY-NOTICES.md).diff --git a/docs/usage.md b/docs/usage.mdindex a14459b..0c2731f 100644--- a/docs/usage.md+++ b/docs/usage.md@@ -2,15 +2,15 @@← Back to the [README](../README.md)-Intelligent UI draws Claude's answers as rendered Markdown pictures. Only the drawing changes. The saved answer stays Markdown.+Intelligent UI draws Claude's answers as rendered Markdown. Only the drawing changes. The saved answer stays Markdown.## What it draws-- Headings, lists, task lists, tables, block quotes, links, footnotes and horizontal rules-- Code blocks with syntax colours, in your terminal's font (found for iTerm2, Ghostty, kitty and Rio; on Linux, else fontconfig's `monospace` font; else Menlo, SF Mono or DejaVu Sans Mono)-- Math (`$…$` and `$$…$$`, LaTeX syntax, through mitex)-- Images from ``. A relative path starts from the session's folder. Remote images show as an alt-text box.-- Live Typst: a fenced block with the language `typst` (or `typ`) is rendered, not shown as code. These packages are in the mod and work offline:+- **Markdown:** headings, lists, task lists, tables, block quotes, links, footnotes and horizontal rules.+- **Code blocks** with syntax colours, in your terminal's font. The mod reads the font from iTerm2, Ghostty, kitty and Rio. Else it uses fontconfig's `monospace` on Linux, then Menlo, SF Mono or DejaVu Sans Mono.+- **Math:** `$…$` and `$$…$$`, in LaTeX syntax.+- **Images** from ``. A relative path starts from the session's folder. Remote images show as a box with the alt text.+- **Live Typst:** a code block with the language `typst` (or `typ`) is drawn, not shown as code. These packages come with the mod and work offline:```#import "@preview/cetz:0.5.2"@@ -18,163 +18,173 @@ Intelligent UI draws Claude's answers as rendered Markdown pictures. Only the dr#import "@preview/fletcher:0.5.8" as fletcher: diagram, node, edge```- A `theme` dictionary (`theme.fg`, `theme.muted`, `theme.blue`, `theme.palette`, `theme.width`, …) is in scope, so drawings match the terminal's colours. The mod tells Claude about this in a short part of the system prompt. `theme.width` and `theme.height` give the space for a drawing. The mod keeps the size that a message had when it was drawn the first time. When the terminal size changes, the mod makes the drawings larger or smaller by the same amount.-- Files that Claude sends to you (the SendUserFile tool). The mod draws each file under the row that shows the files, in the same order:- - PNG, JPEG, WebP and SVG images. Typst changes a JPEG, WebP or SVG image into a PNG image in the cache folder. The PNG image is the size of the space for the picture in the transcript, or smaller. Typst does this one time for each version of the file and each size of the space. When the space changes, the mod shows the old PNG image until Typst makes the new one.- - PDF files. The mod draws one page of the PDF. Typst changes the page into a PNG image in the cache folder. The page fills the space for the picture in the transcript, and it can be larger than the page in the PDF. A line with the page number shows under the page, for example `‹ 3 ›`. Click `‹` or `›` to show the page before or the page after. `‹` is gray on page 1, and `›` is gray on the last page. When a page shows, Typst also makes the next page, so that `›` shows it immediately. The mod does not show the number of pages.+ A `theme` dictionary (`theme.fg`, `theme.muted`, `theme.blue`, `theme.palette`, `theme.width`, `theme.height`, …) lets a drawing use the terminal's colours and fit its space. A short part of the system prompt tells Claude about it. A drawing keeps the layout of its first draw, and scales when the terminal size changes.+- **Files that Claude sends** (the SendUserFile tool): images, PDF pages and Markdown files. See [Files that Claude sends](#files-that-claude-sends).+- **Images you paste** (`[Image #N]`): a small preview above the prompt box, and the same small images under your prompt after you send it. See [Preview of pasted images](#preview-of-pasted-images).+- **Plans** in plan mode, with the mod's own approval question. See [Plan approval](#plan-approval).- Click the page number to go to a page: a field with the page number opens above the prompt (in fullscreen mode in a wide terminal, at the side of the transcript). Type the page number and push Enter. Push Esc to close the field. If the page does not exist, the field stays open and shows `No page N`.+## Files that Claude sends- A PDF with one page has no line under it. If Typst cannot read the PDF (for example, a PDF with a password or a damaged PDF), the row shows one gray line with the error from Typst. If Typst cannot make one page, the row shows the error for that page above the line. Each row starts on page 1. The mod keeps the page of each row in memory only: a reload of the mod sets all rows to page 1 again, and an old row can lose its page when there are many rows. If the PDF gets shorter, a row on a page that is gone shows the last page.- - Markdown files (`.md` or `.markdown`, 256 KiB or less). The mod draws the file as rendered pictures, the same as an answer. A relative image path in the file starts from the folder of the file.+Each file draws under the row that lists the files, in the same order. Other files stay as the normal row.- Other files stay as the normal row. JPEG images, WebP images, SVG images, PDF files and Markdown files need Typst.+- **Images:** PNG, JPEG, WebP and SVG. Other types, such as GIF, stay as the normal row. An SVG's size is its width and height in CSS px.+- **Markdown files** (`.md` or `.markdown`, 256 KiB or less) draw like an answer. A relative image path starts from the file's folder.+- **PDF files:** one page at a time. See below.- These images are not larger than the image file. They are not wider than the transcript. The height setting (`/iui height`) sets the most rows that they can use (Typst drawings use it too): by default, half the screen and not more than 24 rows. The mod draws PNG, JPEG, WebP and SVG images only. Other image types (for example GIF) stay as the normal row. The size of an SVG image is its width and height in CSS px.-- Images that you paste into the prompt (`[Image #N]`). Before you send the prompt, a small preview of each image shows above the prompt box. After you send it, the mod draws the images under your prompt at the same size: side by side, approximately 5 rows tall, with no number (Claude Code shows the numbers there). The height setting does not apply to them. Claude Code's own `[Image #N]` rows stay under them: a mod cannot change these rows. Refer to [Preview of pasted images](#preview-of-pasted-images).-- The plan in plan mode (the ExitPlanMode tool). The mod draws the plan as a picture in the transcript, the same as an answer. Then the mod asks you to approve the plan. Refer to [Plan approval](#plan-approval).+JPEG, WebP, SVG, PDF and Markdown need Typst.++**Size.** An image is never larger than its file or wider than the transcript. `/iui height` sets the most rows it can use (by default half the screen, 24 rows at most). The same limit applies to Typst drawings in answers.++### PDF pages++- **Change page:** a line such as `‹ 3 ›` shows under the page. Click `‹` or `›`. `‹` is gray on page 1, and `›` on the last page. The mod does not show the number of pages.+- **Go to a page:** click the page number. A field opens above the prompt (at the side of the transcript in a wide fullscreen terminal). Type the number and push Enter. If the page does not exist, the field shows `No page N`. Push Esc to close it.+- **One page only:** a PDF with one page has no page line.+- **Errors:** if Typst cannot read the PDF (for example, it has a password or is damaged), the row shows the error in gray. If one page fails, its error shows above the page line.+- **Page memory:** each row starts on page 1. The mod keeps the page in memory only, so a reload goes back to page 1, and an old row can lose its page when there are many rows. If the PDF gets shorter, a page that is gone shows the last page.## Preview of pasted images-When you paste an image into the prompt box, the box shows `[Image #N]`. The mod then shows a small preview of the image above the prompt box, before you send the prompt. The number of the image (`#N`) shows in dim text at the left of its preview.+When you paste an image, the prompt box shows `[Image #N]`. The mod shows a small preview of it above the prompt box, with its number in dim text at its left.-- The preview fills its cells. Typst makes a copy of the image that has the size of the cells, one time for each image and size, in the cache folder. To fill the cells, the copy can cut a small part of an edge of the image (at most half a cell). If the shape of the image is very different from the shape of its cells (for example, a wide screenshot of one line), the copy shows all of the image, with an empty strip above and below it or at its sides. Typst runs in a folder of its own with only the pasted image, so it reads no other file. Until the copy is ready, the preview shows the image as it is. Without Typst, or if Typst cannot make the copy, the preview also shows the image as it is.-- In herdr in iTerm2, a preview shows only after the mod stores it with its rows in the order that iTerm2 shows correctly. While Typst makes the copy, there is no preview. Without Typst, or if Typst cannot make the copy, the mod stores the image as it is.-- The previews show side by side. When they do not fit in one line, they go on to the next line.-- A preview is approximately 5 rows tall, or less when the space above the prompt box is small. The image keeps its shape.-- When you delete the `[Image #N]` text, the preview of that image goes away. When you send or clear the prompt, all the previews go away.-- A pasted path of an image file (path text that you copied) also shows a preview. Claude Code writes no file for it until you send the prompt, so the mod reads the clipboard one time to find the file. It shows PNG, JPEG and WebP files (JPEG and WebP need Typst).-- The mod shows PNG images only. If Claude Code wrote no PNG file for an image, that image has no preview.-- A survey above the prompt box hides the previews until it closes.-- With `/iui off`, or in a terminal that shows no pictures, there are no previews.+- **Size:** about 5 rows tall, less when the space is small. The previews sit side by side and wrap to the next line. The image keeps its shape. It fills its cells, so up to half a cell can be cut from one edge. A very wide or tall image (for example, a screenshot of one line) shows whole, with empty space beside it.+- **Delete or clear:** delete the `[Image #N]` text and its preview goes. Send or clear the prompt and all previews go.+- **After you send:** the same small images show under your prompt, without numbers. Claude Code's own `[Image #N]` rows stay under them; a mod cannot change those. `/iui height` does not apply to pasted images.+- **Pasted image paths:** if you copy the path of an image file and paste it, the mod reads the clipboard once to find the file and shows its preview. PNG, JPEG and WebP work (JPEG and WebP need Typst). This does not work over ssh. A dragged path shows its preview only after you send (see [Limitations](limitations.md)).+- **Pasted images need a PNG:** if Claude Code saved no PNG file for an image, it has no preview.+- **Without Typst**, or until the fitted copy is ready, the preview shows the image as it is. In herdr in iTerm2, no preview shows while the fitted copy is made.+- **Hidden:** a survey above the prompt box hides the previews until it closes. With `/iui off`, or in a terminal that shows no pictures, there are no previews.## The intelligent-ui skill-The mod has a skill for Claude: `intelligent-ui`. It has the full API of Typst, fletcher, CeTZ and cetz-plot, recipes for many diagram and chart types, and a compile check. Claude loads it by itself before it writes a complex drawing, or after a drawing did not compile. For normal answers and simple drawings, Claude does not load it.+The mod gives Claude a skill, `intelligent-ui`, with the full Typst, fletcher, CeTZ and cetz-plot API, recipes for many diagrams and charts, and a compile check. Claude loads it by itself before a complex drawing, or after a drawing fails to compile. For normal answers and simple drawings, it does not.-The compile check (`scripts/check.sh` in the skill) compiles a drawing with the mod's template and your theme, in dark and light mode. It shows the errors and writes PNG images. Claude looks at the images and corrects the drawing before it answers.+The compile check (`scripts/check.sh` in the skill) compiles a drawing with your theme, in dark and light mode. Claude looks at the result and fixes the drawing before it answers.-You can also start the skill yourself: type `/cc-intelligent-ui:intelligent-ui` (or `/intelligent-ui` when no other command has that name), and then ask for the drawing.+To start it yourself, type `/cc-intelligent-ui:intelligent-ui` (or `/intelligent-ui` when no other command has that name), then ask for the drawing.## Commands+Settings that you change are kept for later sessions.+| Command | What it does ||---|---|-| `/iui` | Shows the state, the theme, the text size, the width, the image height and the row grid, a problem that keeps pictures away, and a new version when there is one |-| `/iui details` | Shows all that the mod found: where the mode comes from, the terminal font, the Typst path, why the terminal can or cannot show pictures, if picture select is on (`Picture select:`), if the `/iui grab` toast is on (`/iui grab hint:`), and the state of the update check (`Update checks:`) |-| `/iui on` / `off` | Turns the pictures on or off (kept for later sessions) |-| `/iui setup` / `setup remove` | iTerm2 (macOS only) and herdr (macOS and Linux): adds or removes the shell line that turns pictures on (then close the tab or pane and open a new one). An older line (iTerm2 only) is updated. On Linux outside herdr, it changes no file. |-| `/iui size <80–200>` | Text size in percent. 100 is the same visual size as your terminal text. |-| `/iui width` | Shows the width: the most columns that a picture can use |-| `/iui width <40–400>` | Sets the most columns that a picture can use (kept for later sessions) |-| `/iui width full` | Pictures use the full width of the terminal, the same as the text of Claude Code (kept for later sessions). This is the default. A picture is never wider than 255 columns. |-| `/iui height` | Shows the image height: the most rows that an image can use. This applies to images that Claude sends and to Typst drawings in answers. Images that you paste always show small. |-| `/iui height half` | An image uses half the terminal height, from 6 to 24 rows (kept for later sessions). This is the default. |-| `/iui height full` | An image uses the terminal height less 16 rows (kept for later sessions). The 16 rows are for the row of the file, the text around it and the prompt. |-| `/iui height <6–200>` | Sets the most rows that an image can use (kept for later sessions). An image is never taller than with `full`. |-| `/iui grid` | Shows the row grid setting: on or off |-| `/iui grid on` | Puts each line of text in a picture on the terminal rows (kept for later sessions). This is the default. Refer to [Selection and the row grid](#selection-and-the-row-grid). |-| `/iui grid off` | Lines of text in a picture have the usual spacing (kept for later sessions). |-| `/iui select` | Shows the picture select setting: on or off |-| `/iui select on` | With Claude Code 2.1.298 or newer, in fullscreen mode, a drag over a picture selects its text and copies it (kept for later sessions). This is the default. Refer to [Picture select](#picture-select-claude-code-21298-or-newer). |-| `/iui select off` | Stops picture select (kept for later sessions). Then a drag over a picture is the selection of Claude Code. From Claude Code 2.1.305, that selection skips pictures. |-| `/iui updates` | Shows the update check: on or off, and the newest version that it found |-| `/iui updates on` | Looks for a new version one time each day at most, and shows a toast when there is one (kept for later sessions). This is the default. Refer to [Update](install.md#update). |-| `/iui updates off` | Stops the check for a new version and its toast (kept for later sessions) |-| `/iui theme` | Lists the themes, shows which one is in use, and shows the folder for your own themes |-| `/iui theme <name>` | Changes to that theme (kept for later sessions) |-| `/iui grab` | Copies the text under your last mouse selection of pictures. On the main screen, it copies the text of the picture cells on the clipboard. Refer to [Copy text from a picture](#copy-text-from-a-picture). |-| `/iui dump` | Shows the last clipboard text with picture cells and how the mod read it (for a bug report). It also writes this to `copy-debug.json` in the cache folder. |-| `/iui probe` | Asks the terminal for its background colour with OSC 11 and shows the raw answers. Refer to [How `auto` is resolved](how-it-works.md#how-auto-is-resolved). |+| `/iui` | State, theme, text size, width, image height, row grid, any problem that keeps pictures away, and a new version if there is one |+| `/iui details` | All that the mod found: where the light or dark mode comes from, the terminal font, the Typst path, why pictures show or not, `Picture select:`, `/iui grab hint:` and `Update checks:` |+| `/iui on` / `off` | Pictures on or off |+| `/iui theme` | Lists the themes, the one in use, and the folder for your own themes |+| `/iui theme <name>` | Changes the theme. Default: `claude-code` |+| `/iui size <80–200>` | Text size in percent. 100 (the default) matches your terminal text |+| `/iui width` | Shows the most columns a picture can use |+| `/iui width <40–400>` | Sets the most columns a picture can use |+| `/iui width full` | Pictures use the full terminal width, like Claude Code's text, 255 columns at most. The default |+| `/iui height` | Shows the most rows an image or Typst drawing can use. Pasted images always show small |+| `/iui height half` | Half the terminal height, from 6 to 24 rows. The default |+| `/iui height full` | The terminal height less 16 rows (room for the file row, the text around it and the prompt) |+| `/iui height <6–200>` | Sets the most rows, never more than `full` |+| `/iui grid` | Shows if the row grid is on or off |+| `/iui grid on` / `off` | Puts each line of text on the terminal rows (on, the default), or uses the usual spacing (off). See [Selection and the row grid](#selection-and-the-row-grid) |+| `/iui select` | Shows if picture select is on or off |+| `/iui select on` / `off` | Drag over an answer to copy its text (on, the default). With `off`, a drag is Claude Code's own selection, which skips pictures from Claude Code 2.1.305. See [Picture select](#picture-select-claude-code-21298-or-newer) |+| `/iui updates` | Shows if the update check is on, and the newest version it found |+| `/iui updates on` / `off` | Checks for a new version once a day at most and shows a toast (on, the default), or stops the check. See [Update](install.md#update) |+| `/iui setup` / `setup remove` | Adds or removes the shell line that turns pictures on in iTerm2 (macOS) and herdr (macOS and Linux). Then open a new tab or pane. It updates an older iTerm2 line. On Linux outside herdr it changes nothing |+| `/iui grab` | Copies the text of your last selection of pictures. On the main screen, it copies the text of the picture cells on the clipboard. See [Copy text from a picture](#copy-text-from-a-picture) |+| `/iui dump` | Shows the last clipboard with picture cells and how the mod read it, for a bug report. Also writes it to `copy-debug.json` in the cache folder |+| `/iui probe` | Asks the terminal for its background colour (OSC 11) and shows the raw answers. See [How `auto` is resolved](how-it-works.md#how-auto-is-resolved) |-## Links, file paths and commands+## Copy text from a picture-In fullscreen mode, with picture select on, you click the links, file paths and commands in the picture itself. Refer to [Click a link, a file or a command](#click-a-link-a-file-or-a-command). In other conditions (the main screen, over ssh, Claude Code before 2.1.298, or `/iui select off`), a picture has no text for the terminal, so a click on a link in the picture does not open it. Then the mod shows the links, file paths and commands of an answer, a plan or a Markdown file that Claude sent in dim rows under its picture. These rows show only when the text has links, file paths or commands. Each item uses one row:+Copying an answer works as usual: drag over it, release, paste. This also works for a plan or a Markdown file that Claude sent. Text inside a diagram, a Typst drawing, an image or display math does not copy. Inline math copies as its LaTeX source.-```-↗ Typst docs https://typst.app/docs-↗ https://github.com/o/r/pull/42-↗ hooks/lib/copy.ts:42-$ brew install typst-```+This needs fullscreen mode and Claude Code 2.1.298 or newer. Run `/tui fullscreen` (`/tui default` goes back to the main screen). On the main screen, see [Picture cells on the clipboard](#picture-cells-on-the-clipboard).-- **A web link** (`http:`, `https:` or `mailto:`): the link text, then the URL. If the link text is the URL, the URL shows one time. A cmd+click on the link (or the click that your terminal uses for links) opens it.-- **A file path**, for example `hooks/lib/copy.ts:42`: a cmd+click opens the file. A relative path starts from the session's folder (for a Markdown file that Claude sent, from the folder of that file). A row shows only when the file exists.-- **A command** from a `bash`, `sh`, `zsh`, `shell`, `console` or `shell-session` code block, or from inline code that starts with `! `: a click on the row copies the full command, and a toast shows "Copied". A command with more lines shows its first line and the number of the other lines. The click works only where Claude Code gets mouse clicks (fullscreen mode).+### Picture select (Claude Code 2.1.298 or newer)-The mod does not take web links from code blocks, inline code or math. It takes file paths from the text and from inline code, but not from code blocks.+Picture select is what makes a drag over an answer copy its text. It works in fullscreen mode only, and it is on by default (`/iui select off` and `/iui select on`).-## Copy text from a picture+1. **Drag** over the answer with the left button. Start the drag on the answer. The selection shows on a blue background (VS Code's selection colour) and follows the text, as in an editor. The layout does not change.+2. **Release.** The mod copies the selected text and shows "copied N chars of text". Then paste.+3. **Clear** the selection with a click in an answer, a new selection, a key in the prompt, your next prompt, `/iui off` or `/iui select off`. A single click on normal text does not clear it (see [Limitations](limitations.md)).-We recommend fullscreen mode: run `/tui fullscreen` (`/tui default` goes back to the main screen). In fullscreen mode, picture select copies the text of a picture (an answer, a plan or a Markdown file that Claude sent). Refer to [Picture select](#picture-select-claude-code-21298-or-newer).+A selection can go on into the next page of the same answer. The copy is usually instant; on a page that is not ready yet it can take up to 0.5 s (2–3 s with a large drawing), so wait for the toast before you paste.-### Picture select (Claude Code 2.1.298 or newer)+#### Click a link, a file or a command-Picture select works in fullscreen mode only. It is on by default. `/iui select off` turns it off, and `/iui select on` turns it on again.+With picture select, the links, file paths, commands and code block copy buttons in an answer are live.-1. Drag over a picture with the left button. Start the drag on the picture. The selected cells show on a blue background (VS Code's selection colour), in the order of the text: the first row from where you started, the rows between, and the last row to the pointer. The layout does not change.-2. Release the button. The mod copies the text of the selected cells (the same words that a copy of these cells gives) and shows the toast "copied N chars of text". Then paste.-3. These remove the selection: a click with no drag in a picture (a click on a link, a file path or a command also copies it, refer to [Click a link, a file or a command](#click-a-link-a-file-or-a-command)), a new selection in a picture, a key typed in the prompt, a new selection of Claude Code (normal text), your next prompt, and `/iui off` or `/iui select off`. A single click on normal text does not (refer to [Limitations](limitations.md)).+- **Hover** over one and its cells turn blue. There is no hover highlight while a selection shows.+- **Click** it (press and release on the same cell) to copy it:-A selection can go on into the next page of the same answer.+ | Click on | Copies | Toast |+ |---|---|---|+ | A web link | Its URL | "copied the link" |+ | A file path | Its full path | "copied the path" |+ | A command | The full command | "copied the command" |+ | The copy button at the top right of a code block | All the code of the block | "copied the code" |-#### Click a link, a file or a command+- **Drag** from a link, path or command to select text as usual.-With picture select, the web links, file paths, commands and the copy buttons of code blocks in a picture are live. The dim link rows do not show under the picture.+**What counts.** A web link is a Markdown link to an `http:`, `https:` or `mailto:` URL, or a bare URL. A file path is in the text or in inline code, and the file must exist (a relative path starts from the session's folder). A command is any other inline code, for example `` `git status` ``; for `` `! cmd` `` the click copies only `cmd`. A code block's text is not a target: use its copy button or select the text. Links to headings are not targets.-- Move the pointer over a link, a file path, a command or a copy button (no button). Its cells show on the blue background. Move the pointer off it, and the background goes. While a selection shows, there is no such highlight.-- Click it (push and release the button on the same cell). The mod copies it and shows a toast: a web link copies its URL ("copied the link"), a file path copies its full path ("copied the path"), a command copies the full command ("copied the command"), and the copy button of a code block (at the top right of the block) copies all the code of the block ("copied the code").-- A drag that starts on a link, a file path or a command selects text, as on other text.+### Picture cells on the clipboard-A web link is a Markdown link to an `http:`, `https:` or `mailto:` URL, or a URL in the text. A file path is in the text or in inline code, and the file must exist (a relative path starts from the session's folder). A command is any inline code that is not a file that exists, for example `` `git status` `` (a click copies its text; for `` `! cmd` `` it copies only `cmd`). The text of a code block is not a target: to copy all of it, click its copy button, or select its text. A link to a heading in the same text is not a link for this.+On the main screen (not fullscreen), there is no picture select. The terminal does the copy itself, and it gives picture cells (kitty placeholder characters), not text. A Claude Code selection that starts outside an answer can also copy picture cells (see [Limitations](limitations.md)). The mod never changes the clipboard for such a copy, because it cannot tell which session the copy came from.-When a page is drawn or comes on the screen, the mod gets the page ready for the highlight in the background. It also finds the position of each word on the page. Thus the first highlight and the copy are fast. If you push the button on a page that is not ready, the mod gets that page ready first, and the first highlight shows a short time later. If the words of the page are not ready when you release the button, the copy waits for them: approximately 0.05 s for plain text (only ASCII characters, no math, no Typst block and no image), 0.15–0.5 s for other text, and more (2–3 s) for a page with a large Typst drawing. No toast shows while the mod does this. Only the toast of the copy shows. The mod keeps the positions in memory, so the next copy from the same page is fast.+- **Toast:** while the mod is on and has drawn a picture in this session, it watches the clipboard. When the clipboard has picture cells from this session, a toast tells you to run `/iui grab`. On Linux this needs the tools in [Linux](install.md#linux).+- **`/iui grab`:** run it in the same session. In fullscreen, it copies the text of your last mouse selection. On the main screen, it reads the picture cells on the clipboard and copies their text. If the clipboard already has the text, it says so.+- **Wrong text?** `/iui dump` shows the cells the mod found and the page it used, and writes them to `copy-debug.json` in the cache folder.+- **Fullscreen hint:** the first time the mod draws on the main screen, a toast recommends fullscreen mode (once per session).-### Picture cells on the clipboard+For the limits, see [Limitations](limitations.md).-On the main screen (not fullscreen mode), there is no picture select. The terminal copies the selection itself, not Claude Code. The copy gives picture cells (kitty placeholder characters), not text. A selection of Claude Code that starts outside a picture can also copy picture cells (refer to [Limitations](limitations.md)). The mod never changes the clipboard for such a copy, because it cannot know which session the copy is from.+## Links, file paths and commands-While the mod is on and has drawn a picture in this session, it sees each change of the clipboard (on macOS in 0.3 s or less; on Linux at once, with the tools in [Linux](install.md#linux)). When the clipboard has picture cells of a picture in this session, a toast tells you to use `/iui grab`. Run `/iui grab` in the same session. When the mod draws its first picture on the main screen, a toast recommends fullscreen mode (one time in each session).+Without picture select (the main screen, ssh, Claude Code before 2.1.298, or `/iui select off`), a click on a link in a picture does nothing. Instead, the mod lists the links, file paths and commands of an answer, a plan or a sent Markdown file in dim rows under it, one per row. The rows show only when there is something to list:-`/iui grab` puts the text on the clipboard. In fullscreen mode, it reads the last mouse selection of Claude Code and copies its text. With no selection (the main screen), it reads the picture cells on the clipboard and copies their text. If the clipboard has the text already, it tells you. If the copied text is not correct, `/iui dump` shows the cells that the mod found and the page that it used. It also writes all of this to `copy-debug.json` in the cache folder.+```+↗ Typst docs https://typst.app/docs+↗ https://github.com/o/r/pull/42+↗ hooks/lib/copy.ts:42+$ brew install typst+```-A copy of picture cells through `$.ui.copy` gets the text in place of the cells.+- **Web link** (`http:`, `https:` or `mailto:`): the link text, then the URL (once, if they are the same). Cmd+click (or your terminal's link click) opens it.+- **File path**, for example `hooks/lib/copy.ts:42`: cmd+click opens the file. A relative path starts from the session's folder (or the folder of a sent Markdown file). The row shows only if the file exists.+- **Command** from a `bash`, `sh`, `zsh`, `shell`, `console` or `shell-session` code block, or inline code that starts with `! `: click the row to copy the full command ("Copied"). A command with several lines shows its first line and the number of other lines. The click works only in fullscreen mode.-For the limits, refer to [Limitations](limitations.md).+Web links are not taken from code blocks, inline code or math. File paths are taken from the text and inline code, not from code blocks.## Selection and the row grid-The terminal draws a mouse selection as full cells, thus a selection covers full rows. Without the grid, the lines of text in a picture are not on the terminal rows. A line of body text is approximately 1.3 rows tall, and a line in a list or a table is approximately 1.6 rows tall. Thus, after some lines, the selection is not on the text that the mod copies.+The terminal draws a selection in whole rows. Without the grid, text lines in a picture do not line up with the rows (a body line is about 1.3 rows tall, a list or table line about 1.6), so after a few lines the selection drifts from the text that is copied.-The row grid (`/iui grid on`, the default) puts each line of text on the terminal rows:+The row grid (`/iui grid on`, the default) puts each line of text on the terminal rows, so the selection covers the text you get:-- Each line of body text, a list, a quote or a table uses one row (or more rows if the text is large). The middle of the text is in the middle of a row.-- Each heading, each code line and each gap between blocks uses full rows.-- The middle of a line that uses 2 rows (or 4 rows) is on the border between two rows. Thus the mod moves such a line down by half a row, and adds half a row above and below the block that holds it. For example, a level-2 heading uses 3 rows, and its text is in the middle row. Thus a selection of one row covers the full height of the text.-- If a line of body text uses 2 rows (with a large text size), the picture starts half a row down, thus body text does not move. Only a line that uses an odd number of rows (for example, some headings) gets the half rows. If the picture starts with such a heading, the picture starts at the heading.-- A heading that has the half rows has no gap below it: the half row below its text is the gap to the text under the heading. The gap above the heading stays. For example, at 100%, a level-3 heading has 2 empty rows above it and 1 empty row below it.-- The reply bullet is on the row that holds the middle of the first line. For example, the bullet is on the second row of a level-1 heading.-- Some blocks have a height that the mod cannot set, for example display math, an image or a Typst drawing. The mod adds space to such a block, so that its height is a number of full rows.+- **Text lines:** each line of body text, a list, a quote or a table uses one row (more with a large text size), with the text centred in the row.+- **Headings and code:** each heading, code line and gap between blocks uses whole rows. A level-2 heading uses 3 rows, with its text in the middle row.+- **Other blocks** (display math, images, Typst drawings) get extra space so that they use whole rows.+- **Reply bullet:** it sits on the row of the first line's text.-Thus the selection covers the text that the mod copies. The lines are closer together than without the grid, so the look is not the same as VS Code. The grid is on by default. Use `/iui grid off` for the usual spacing. For the limits, refer to [Limitations](limitations.md).+Lines are closer together than without the grid, so the look differs a little from VS Code. Use `/iui grid off` for the usual spacing. For the limits, see [Limitations](limitations.md).## Plan approval-When Claude exits plan mode, the mod draws the plan as a picture in the transcript. Under the picture, the mod shows its own question, "Approve this plan?", in place of the Claude Code dialog. A dim line above the question tells you that the rendered plan is above. The question has these options:+When Claude exits plan mode, the mod draws the plan in the transcript. Under it, the mod asks "Approve this plan?" in place of Claude Code's dialog:| Option | What it does ||---|---|-| Yes, auto-accept edits | Approves the plan. Claude Code then accepts file edits with no question (`acceptEdits` mode). |-| Yes, manually approve edits | Approves the plan. Claude Code then asks you before each file edit (`default` mode). |-| Yes, clear context + auto-accept | Approves the plan, stops the turn and runs `/clear`. Then the mod sends "Implement this plan:" and the plan as a new prompt, in `acceptEdits` mode. |-| Edit the plan | Opens the plan file in an editor. The mod waits until you close the file (10 minutes at most). Then it asks "Approve the edited plan?". When you approve, Claude gets the edited plan. |-| Type something | Sends your text to Claude as changes to the plan. Claude stays in plan mode and writes a new plan. |+| Yes, auto-accept edits | Approves. Claude Code then accepts file edits without asking (`acceptEdits` mode). |+| Yes, manually approve edits | Approves. Claude Code asks before each file edit (`default` mode). |+| Yes, clear context + auto-accept | Approves, stops the turn and runs `/clear`. Then sends "Implement this plan:" with the plan as a new prompt, in `acceptEdits` mode. |+| Edit the plan | Opens the plan file in an editor and waits until you close it (10 minutes at most). Then asks "Approve the edited plan?". Claude gets the edited plan. |+| Type something | Sends your text to Claude as changes. Claude stays in plan mode and writes a new plan. || Esc | Rejects the plan and stops the turn. |-The editor is VS Code (`code --wait`) when the `code` command is on your PATH. If `code` is not on the PATH, macOS uses TextEdit (`open -W -t`). In that case, quit TextEdit when you complete the edit. On Linux with a display, the mod uses the first of VSCodium (`codium --wait`), Zed (`zed --wait`), Sublime Text (`subl --wait`), Kate (`kate --block`), gedit (`gedit --wait`) and gvim (`gvim -f`) that is on the PATH. Close the file (or the window) when you complete the edit. Over ssh with no `code` command, and on Linux with none of these editors, the "Edit the plan" option does not show.+**Editor.** VS Code (`code --wait`) when `code` is on your PATH. Else, on macOS, TextEdit (quit TextEdit when you are done). On Linux with a display, the first of VSCodium, Zed, Sublime Text, Kate, gedit and gvim on your PATH (close the file or window when you are done). Over ssh without `code`, or on Linux with none of these, "Edit the plan" does not show.-The mod shows the plan file as it is when the question opens. Claude can write the plan file and exit plan mode in the same message. Then Claude Code sends the plan from before that write. In this case, the mod waits for the write to complete (5 seconds at most) and reads the file again. You approve the plan that you see, and Claude gets that plan.+**The plan you see is the plan Claude gets.** If Claude writes the plan file and exits plan mode in the same message, the mod waits for the write (5 s at most) and reads the file again.-The mod uses this flow only when it can draw the plan: the mod is on, Typst is installed, the terminal draws pictures, and the plan is from the main conversation (not from a subagent). In all other conditions, Claude Code shows its own dialog, as with no mod. If the flow fails, Claude Code also shows its own dialog.+**When it applies.** Only when the mod can draw the plan: the mod is on, Typst is installed, the terminal shows pictures, and the plan is from the main conversation (not a subagent). Otherwise, or if the flow fails, Claude Code shows its own dialog.-For the limits of this flow, refer to [Limitations](limitations.md).+For the limits, see [Limitations](limitations.md).diff --git a/render/themes/README.md b/render/themes/README.mdindex 9957860..322e0a9 100644--- a/render/themes/README.md+++ b/render/themes/README.md@@ -1,18 +1,21 @@# Intelligent UI themes-A theme is a folder with a `theme.json`. Intelligent UI ships three:+A theme is a folder with a `theme.json`. For how to choose and make a theme, refer to [Themes](../../docs/themes.md).| Folder | Name | Looks like ||---|---|---|| `claude-code` (default) | Claude Code | Claude Code's own Markdown in the terminal, with its dark and light themes || `vscode-modern` | VS Code Modern | VS Code's Markdown preview, Dark Modern / Light Modern |-| `vscode` | VS Code | the same, with the Dark+ / Light+ colours; every theme merges over this one |+| `vscode` | VS Code | The same, with the Dark+ / Light+ colours. Every theme merges over this one. |-Your own themes go in `~/.claude/cc-intelligent-ui/themes/<name>/theme.json`. A theme there with the same folder name as a built-in one is used in its place. It is still merged over the built-in `vscode`, like every theme. Choose a theme with `/iui theme <name>`.+- **Your themes:** `~/.claude/cc-intelligent-ui/themes/<name>/theme.json`. One with the same folder name as a built-in theme is used in its place, still merged over the built-in `vscode`.+- **Choose one:** `/iui theme <name>`.## Merging-Every key is optional. The template merges your `theme.json` over `vscode/theme.json`, so you only write what you change. A value of the wrong type (for example a colour that is not `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa`, or text where a number belongs) is ignored, and the vscode value is used. The file must be valid JSON; if it is not, Intelligent UI uses the default theme, `claude-code`, and tells you.+- **Every key is optional.** The template merges your `theme.json` over `vscode/theme.json`, so write only what you change.+- **Wrong type** (for example a colour that is not `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa`, or text where a number belongs): ignored, and the `vscode` value is used.+- **Invalid JSON:** Intelligent UI uses the default theme, `claude-code`, and tells you.Example: pink inline code, rounder boxes.@@ -27,10 +30,10 @@ Example: pink inline code, rounder boxes.## Units-- `*-px`: CSS pixels of VS Code's preview. Its body text is 14px, so 1px = 11/14 pt (the body is always 11pt; Intelligent UI scales the whole picture to your terminal).-- `*-em`: em of that element's own text.-- `size`: a fraction of the body text size. For code, `"terminal"` means the size of your terminal's own text.-- Colours: `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa`. The page is transparent, so a translucent background (for example `#ffffff1a`) looks right on any terminal colour. The terminal draws the mouse selection under the picture: it shows through a translucent background, but an opaque one (`code-bg`, `quote-bg`, `inline-code-bg`) hides it.+- **`*-px`:** CSS pixels of VS Code's preview. Its body text is 14px, so 1px = 11/14 pt. The body is always 11pt; Intelligent UI scales the whole picture to your terminal.+- **`*-em`:** em of that element's own text.+- **`size`:** a fraction of the body text size. For code, `"terminal"` means your terminal's text size.+- **Colours:** `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa`. The page is transparent, so a translucent background (for example `#ffffff1a`) looks right on any terminal colour. The terminal draws the mouse selection under the picture: a translucent background lets it show, an opaque one (`code-bg`, `quote-bg`, `inline-code-bg`) hides it.## Keys and vscode defaults@@ -62,12 +65,17 @@ Example: pink inline code, rounder boxes.| `table.pad-x-px`, `pad-y-px`, `border-px`, `header-weight` | `10`, `5`, `1`, `700` | || `rule.border-px`, `gap-em` | `1`, `1.5` | Horizontal rule |-With `/iui grid on`, the lines of text lie on the terminal's rows. Then some keys change their effect:+## With the row grid-- `text.leading-em`, `text.paragraph-em`, `heading.leading-em`, `heading.rule-pad-em`, `list.item-spacing-em` and `code-block.line-height` are not used. Each line is one row (a large heading is two or more rows; a line of an even number of rows is half a row down, with half a row more above and below its block). The gap between paragraphs and blocks is one row. The items of a tight list have no gap. The items of a loose list (a list with a blank line between its items or in an item) have a gap of one row.-- The header row of a code block has the rows of one line of code.-- `heading.above-em` and `below-em`, `rule.gap-em`, `code-block.pad-px`, `quote.pad-y-em` and `table.pad-y-px` are rounded to the nearest whole number of rows. Gaps above and below headings and rules are one row or more.-- With `table.style` `"grid"`, `table.pad-y-px` is rounded to the nearest whole number of rows and a half (half a row or more), and the table has half a row more above and below its box. Each rule is then in the middle of a row.+With `/iui grid on`, lines of text sit on the terminal's rows. Some keys then work differently:++- **Not used:** `text.leading-em`, `text.paragraph-em`, `heading.leading-em`, `heading.rule-pad-em`, `list.item-spacing-em` and `code-block.line-height`.+ - Each line is one row. A large heading is two or more rows; a line of an even number of rows sits half a row down, with half a row more above and below its block.+ - The gap between paragraphs and blocks is one row.+ - A tight list has no gap between items. A loose list (with a blank line between or inside its items) has a one-row gap.+- **Code block header:** as tall as one line of code.+- **Rounded to the nearest whole row:** `heading.above-em`, `heading.below-em`, `rule.gap-em`, `code-block.pad-px`, `quote.pad-y-em` and `table.pad-y-px`. Gaps above and below headings and rules are at least one row.+- **`table.style` `"grid"`:** `table.pad-y-px` is rounded to the nearest whole number of rows plus a half (at least half a row), and the table gets half a row more above and below its box, so each rule sits in the middle of a row.## Licence