Skip to content

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: the clipboard reads, the files and the Typst root as they are now

razorback1624e79847325f
diff --git a/README.md b/README.md
index f259238..afca836 100644
--- a/README.md
+++ b/README.md
@@ -106,11 +106,11 @@ All commands are in [Usage](docs/usage.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. On macOS it reads only the change counter, and it reads the text when the counter changes. The text is only checked for picture cells (then a toast names `/iui grab`). It is not stored or sent. <!-- pending pkg A -->Copies that a password manager marks as concealed or transient are skipped on macOS and on X11, and sensitive copies on Wayland.
+- **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. 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 on the main screen, 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>`, mode 700, deleted after 2 days), and `~/.cache/cc-intelligent-ui/designs`. `/iui setup` on macOS changes your shell start file after you agree.
-- **Processes:** `typst`, the `perl` watcher, and short helper commands such as `pbpaste`, `osascript`, `defaults`, `fc-list` and `fc-match`. On Linux also `wl-paste`, `xclip`, `xsel` or `clipnotify` for the clipboard.
-- **Typst:** <!-- pending pkg B -->Typst runs with a narrow root, so the code in an answer cannot read other files on your computer.
+- **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). `/iui setup` on macOS changes your shell start file, only when you run it or agree to its question.
+- **Processes:** `typst`, the `perl` watcher, and short helper commands such as `perl`, `sh`, `osascript`, `defaults`, `plutil`, `fc-list` and `fc-match`. On Linux also `wl-paste`, `xclip`, `clipnotify` or `python3` (GTK 3) 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.
## Docs
diff --git a/docs/how-it-works.md b/docs/how-it-works.md
index bc076f0..279f612 100644
--- a/docs/how-it-works.md
+++ b/docs/how-it-works.md
@@ -14,7 +14,7 @@
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.
- 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 (`pbpaste` on macOS; `wl-paste`, `xclip`, `xsel` or GTK on Linux). 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.
+ 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.
`/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.
diff --git a/docs/install.md b/docs/install.md
index eee741f..02d24c9 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -60,7 +60,7 @@ The mod works on Linux with X11 and with Wayland. It uses these tools. Most Linu
- **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` or `xsel` reads the clipboard. If `clipnotify` is not installed, the mod uses GTK 3 from Python (`python3-gi`, which most GNOME desktops have) for both.
+ 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.
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:`.
diff --git a/docs/limitations.md b/docs/limitations.md
index 5269c56..a6f9136 100644
--- a/docs/limitations.md
+++ b/docs/limitations.md
@@ -36,7 +36,7 @@
- A file path is a target only when the file exists when the mod draws the answer. A link to a heading of the same text is not a target. A link, a file path or a command in a Typst drawing, in math or in an image is not a target.
- It needs `perl` (with `MIME::Base64`, a core module) to write the frames. With no `perl`, the selection and the copy work with no highlight (the mod tries one time, then writes the reason to the debug log).
- It copies at the button's up, also when `copyOnSelect` is `false` in `/config`.
-- **The cache folder:** the mod uses only its private cache folder (`$TMPDIR/cc-intelligent-ui-<uid>`, mode 700, your own and not a link). If that folder is a link, is not a folder or is not yours, the mod draws nothing and picture select is off. `/iui`, `/iui details` and a toast at the start tell you why. Remove or fix that folder, then start Claude Code again. The mod also keeps the drawing space of each answer in `~/.cache/cc-intelligent-ui/designs` (`$XDG_CACHE_HOME` if set), and deletes files there after 180 days.
+- **The cache folder:** the mod uses only its private cache folder (`$TMPDIR/cc-intelligent-ui-<uid>`, mode 700, your own and not a link). If that folder is a link, is not a folder or is not yours, the mod draws nothing and picture select is off. `/iui`, `/iui details` and a toast at the start tell you why. Remove or fix that folder, then start Claude Code again. The mod also keeps the drawing space of each answer in `~/.cache/cc-intelligent-ui/designs` (`$XDG_CACHE_HOME` if set), and deletes files there after 180 days. Fonts that it copies out of a terminal program (for example Ghostty's JetBrains Mono) are in `~/.cache/cc-intelligent-ui/fonts` (`$XDG_CACHE_HOME` if set); a copy of an older program build is deleted after 30 days.
- **A fake bold** (a terminal font with no bold face, for example Monaco): bold text gets a thin outline in its colour. These limits apply:
- A character that the terminal font does not have (for example, CJK text in Monaco) comes from another font. If that font has a bold face, the character gets both the real bold face and the outline, so it is a little bolder than in the terminal.
- Bold text in a live Typst drawing (for example, `text(weight: "bold", font: theme.mono)`) does not get the fake bold. It shows as regular text.