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

Rename to Intelligent UI: plugin intelligent-ui, command /iui

razorback16e66e1a76f659
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json
index 9a6bd03..f490f9d 100644
--- a/.claude-plugin/marketplace.json
+++ b/.claude-plugin/marketplace.json
@@ -2,7 +2,7 @@
"name": "razorback16",
"owner": { "name": "razorback16" },
"metadata": {
- "description": "md-preview: Claude's answers drawn as rendered Markdown in your terminal"
+ "description": "Intelligent UI: Claude's answers drawn as rendered Markdown in your terminal"
},
- "plugins": [{ "name": "md-preview", "source": "./" }]
+ "plugins": [{ "name": "intelligent-ui", "source": "./" }]
}
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json
index 0d65784..217601c 100644
--- a/.claude-plugin/plugin.json
+++ b/.claude-plugin/plugin.json
@@ -1,14 +1,14 @@
{
- "name": "md-preview",
+ "name": "intelligent-ui",
"version": "0.1.0",
- "description": "Draws Claude's answers as rendered Markdown pictures, like VS Code's preview, with live Typst for diagrams, charts and math",
+ "description": "Draws Claude's answers as rendered Markdown pictures in the terminal, with live Typst for diagrams, charts and math",
"author": {
"name": "razorback16",
"url": "https://github.com/razorback16"
},
- "homepage": "https://github.com/razorback16/claude-md-preview",
- "repository": "https://github.com/razorback16/claude-md-preview",
- "documentationUrl": "https://github.com/razorback16/claude-md-preview#readme",
+ "homepage": "https://github.com/razorback16/claude-intelligent-ui",
+ "repository": "https://github.com/razorback16/claude-intelligent-ui",
+ "documentationUrl": "https://github.com/razorback16/claude-intelligent-ui#readme",
"license": "MIT",
"keywords": [
"markdown",
diff --git a/README.md b/README.md
index c9a6f57..41c3934 100644
--- a/README.md
+++ b/README.md
@@ -1,203 +1,89 @@
-# Intelligent UI
+<img alt="Introducing Intelligent UI" src="outcomes/samples/intelligent-ui.png" width="100%">
-A Claude Code mod that draws Claude's answers as rendered Markdown pictures, in Claude Code's own colours or with a look close to VS Code's Markdown preview.
+# Intelligent UI for Claude Code
-The plugin is still installed as `md-preview`, and its command is still `/md-preview`. A later version changes them to `claude-intelligent-ui` and `/iui`. Claude can also put live Typst in an answer, for diagrams, charts and math.
+**Claude's answers, rendered.** Real Markdown, math, charts and diagrams, right in your terminal.
-Only the drawing changes. The saved answer stays Markdown.
+<sub>An independent, community-made mod for Claude Code. Not affiliated with Anthropic.</sub>
-## What it draws
+Intelligent UI draws each answer from Claude as a typeset picture, with [Typst](https://typst.app). Tables line up, equations look like a paper, and Claude can draw a chart or a diagram when a picture explains more than words. Only the drawing changes. The saved answer stays Markdown.
-- 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; else Menlo, SF Mono or DejaVu Sans Mono)
-- Math (`$…$` and `$$…$$`, LaTeX syntax, through mitex)
-- Images from `![alt](path)`. 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:
+![Claude explains why an API request is slow: a timing chart shows the DB query takes 310 of 450 ms, with Amdahl's law and a table of fixes, in a dark and a light terminal](outcomes/out/0-hero-2-latency.png)
- ```
- #import "@preview/cetz:0.5.2"
- #import "@preview/cetz-plot:0.1.4": plot, chart
- #import "@preview/fletcher:0.5.8" as fletcher: diagram, node, edge
- ```
+## Why
- 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 and WebP images. Typst changes a JPEG or WebP 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.
- - 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.
+- **Rendered Markdown.** Headings, tables, task lists, block quotes and code with syntax colours, in your terminal's own font.
+- **LaTeX math.** Inline `$…$` and display `$$…$$` math, typeset.
+- **Live diagrams, charts and plots.** Claude writes Typst with CeTZ, cetz-plot and fletcher. The drawings use your theme's colours and work offline.
+- **Images and files.** Images in an answer, images that Claude sends, Markdown files that Claude sends, and images that you paste show in the transcript.
+- **Plans you can read.** In plan mode, the plan shows rendered, with an approve, edit or reject question under it.
+- **Themes that follow light and dark.** Claude Code's own colours by default, or VS Code's Markdown preview. You can make your own.
- Other files stay as the normal row. JPEG images, WebP images and Markdown files need Typst.
-- Images that you paste into the prompt (`[Image #N]`). The mod draws each image under your prompt.
+## See it
- These pictures are not larger than the image. They are not wider than the transcript. The height setting (`/md-preview 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 and WebP images only. Other image types (for example GIF and SVG) stay as the normal row.
-- 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).
+<table>
+ <tr>
+ <td width="50%">
+ <picture>
+ <source media="(prefers-color-scheme: dark)" srcset="outcomes/out/6-diagrams-dark.png">
+ <source media="(prefers-color-scheme: light)" srcset="outcomes/out/6-diagrams-light.png">
+ <img alt="A flow chart of an agent loop and a commutative diagram of the First Isomorphism Theorem, drawn with fletcher in a Claude answer" src="outcomes/out/6-diagrams-light.png" width="100%">
+ </picture>
+ </td>
+ <td width="50%">
+ <picture>
+ <source media="(prefers-color-scheme: dark)" srcset="outcomes/out/2-math-dark.png">
+ <source media="(prefers-color-scheme: light)" srcset="outcomes/out/2-math-light.png">
+ <img alt="Typeset LaTeX math in Claude Code: the Gaussian integral, Maxwell's equations, a rotation matrix and a piecewise function" src="outcomes/out/2-math-light.png" width="100%">
+ </picture>
+ </td>
+ </tr>
+</table>
-## Requirements
+More in the [gallery](docs/gallery.md): plots, fractals and a tour of all the Markdown.
-- Claude Code 2.1.301 or later (tested on 2.1.301)
-- [Typst](https://typst.app) 0.15 (tested on 0.15.1)
-- macOS (tested). Linux can work, but it is not tested.
-- A terminal where Claude Code draws pictures:
- - **kitty (0.28 or later) and Ghostty:** pictures work with no setting.
- - **iTerm2 3.6 or later (3.7.5 tested):** 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`, `~/.bash_profile` or a fish `conf.d` file). The line sets the variable in iTerm2 only, not in tmux or screen. Then close the tab, open a new iTerm2 tab, and start Claude Code there. You can also run `/md-preview setup` (undo: `/md-preview setup remove`).
- - **Rio 0.5.27 or later (not tested):** set `CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1` before you start Claude Code.
- - Do not put the variable in the `env` of `~/.claude/settings.json`. It then applies in every terminal, also where pictures cannot show.
- - **Not supported:** WezTerm, Warp and Konsole do not draw kitty pictures with Unicode placeholders, so they show 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 `MD_PREVIEW_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.
+## Quick start
- Where pictures cannot draw, the mod shows the normal text.
+You need Claude Code 2.1.301 or later, [Typst](https://typst.app) 0.15, macOS, and kitty, Ghostty or iTerm2 (iTerm2 needs a one-time `/iui setup`). Refer to [Install](docs/install.md) for all terminals.
-## Install
-
-1. Install Typst: `brew install typst` (or see [Typst's install page](https://github.com/typst/typst#installation)).
-2. At the prompt of a Claude Code session in the terminal, type:
-
- ```
- /plugin install md-preview --marketplace razorback16/claude-md-preview
- ```
-
- Answer `y` to add the marketplace, then push Enter to install for your user. The mod starts at once, with no restart.
+```
+brew install typst
+```
-From a shell:
+Then, in Claude Code:
```
-claude plugin install md-preview --marketplace razorback16/claude-md-preview
+/plugin install intelligent-ui --marketplace razorback16/claude-intelligent-ui
```
-To try it from a clone without installing: `claude --plugin-dir /path/to/claude-md-preview`.
+It works at once, with no restart.
-## Use
+## Commands
| Command | What it does |
|---|---|
-| `/md-preview` | Shows the state, the theme, the text size, the width and the image height, and a problem that keeps pictures away |
-| `/md-preview details` | Shows all that the mod found: where the mode comes from, the terminal font, the Typst path and why the terminal can or cannot show pictures |
-| `/md-preview on` / `off` | Turns the pictures on or off (kept for later sessions) |
-| `/md-preview setup` / `setup remove` | iTerm2: adds or removes the shell line that turns pictures on (then close the tab and open a new one) |
-| `/md-preview size <80–200>` | Text size in percent. 100 is the same visual size as your terminal text. |
-| `/md-preview width` | Shows the width: the most columns that a picture can use |
-| `/md-preview width <40–400>` | Sets the most columns that a picture can use (kept for later sessions) |
-| `/md-preview 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. |
-| `/md-preview height` | Shows the image height: the most rows that an image can use. This applies to images (sent or pasted) and to Typst drawings in answers. |
-| `/md-preview height half` | An image uses half the terminal height, from 6 to 24 rows (kept for later sessions). This is the default. |
-| `/md-preview 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. |
-| `/md-preview height <6–200>` | Sets the most rows that an image can use (kept for later sessions). An image is never taller than with `full`. |
-| `/md-preview theme` | Lists the themes, shows which one is in use, and shows the folder for your own themes |
-| `/md-preview theme <name>` | Changes to that theme (kept for later sessions) |
-
-### 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:
-
-| 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. |
-| 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. Over ssh and on Linux with no `code` command, the "Edit the plan" option 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 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.
-
-## Themes
-
-A theme sets the colours, fonts and spacing of the picture. Three themes are in the mod:
-
-| Name | Looks like |
-|---|---|
-| `claude-code` (default) | Claude Code's own Markdown colours, from its dark and light themes |
-| `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.
-
-### Make your own theme
-
-1. Make a folder: `~/.claude/md-preview/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 `/md-preview theme <name>`. You do not have to restart.
+| `/iui` | Shows the state and a problem that keeps pictures away |
+| `/iui on` / `off` | Turns the pictures on or off |
+| `/iui theme <name>` | Changes the theme: `claude-code`, `vscode-modern`, `vscode` or your own |
+| `/iui size <80–200>` | Text size in percent of your terminal text |
+| `/iui details` | Shows the terminal, font, mode and Typst that the mod found |
+| `/iui setup` | iTerm2: adds the shell line that turns pictures on |
-Example: pink inline code with rounder boxes.
+All commands are in [Usage](docs/usage.md).
-```json
-{
- "name": "Pink code",
- "dark": { "inline-code-fg": "#ff79c6", "inline-code-bg": "#ff79c626" },
- "light": { "inline-code-fg": "#c2185b" },
- "inline-code": { "radius-px": 8 }
-}
-```
-
-- 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 `/md-preview 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.
-
-All keys, their units and their defaults are in [`render/themes/README.md`](render/themes/README.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. The `LICENSE` file is in each of those folders.
-
-## How it works
-
-1. A `ui.render` hook on `AssistantMessage` gets each block of the answer as Markdown.
-2. While Claude writes a block, the block is hidden. 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`. Long answers are cut at block boundaries into pages. One page is one PNG.
-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, else Menlo metrics) and the cell size in pixels. Typst then measures both fonts so that 100% looks as large as the terminal text.
-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}/md-preview-<uid>/`. Folders older than 2 days are deleted at start.
-7. 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.
-
-### 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:
+## Docs
-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. If that config sets 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. 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, or GNOME's `color-scheme` on Linux.
-7. **Dark.**
-
-The terminal comes before the OS: a dark terminal on a light Mac is dark.
-
-Intelligent UI checks every 3 s. After a change, each mode's pictures compile once. `/md-preview 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 does not use OSC 11 yet.
-
-## Limitations
-
-- **Copying text from a picture does not work.** A picture fills its cells with kitty placeholder characters (U+10EEEE plus combining marks). Claude Code's mouse selection copies those cells directly to the clipboard, and no mod hook runs before that copy. So a paste gives strange characters, not the text. Use Claude Code's `/copy` to copy the last answer as Markdown (`/copy 2` for the one before it; it shows a picker for the full answer or one code block, unless "Skip the /copy picker" is on in `/config`), or turn the mod off (`/md-preview off`) to select text. To stop the clipboard write on select, set `copyOnSelect` to `false` in `/config`.
-- **Search does not find text in a picture.**
-- **While Claude writes**, the block is hidden, and Claude Code's spinner shows the progress. When the block is final, its picture shows after the compile (0.15–0.6 s). A long answer shows only when it is done. If the picture is not ready 2 s after the block is final, the normal text shows until the picture is ready. If the compile fails, the normal text stays. An earlier answer that is not in the cache (for example, after a resume) is blank for up to 1 s, then shows as text until its picture is ready.
-- **Short summaries** between tool calls stay as text.
-- **Plan approval:** a mod cannot draw the Claude Code approval dialog, so the mod shows its own question. That question can have 4 options at most. Thus it has no option to keep planning (use Type something or Esc). The edit option cannot use a terminal editor (vim, nano), because a mod has no terminal. Where an organization manages Claude Code, `classic.PermissionRequest` hooks of a plugin that you install do not run. Then the Claude Code dialog shows after the mod's question.
-- **Typst blocks:** `#page`, `#pagebreak` and `#set page` are errors. A package that is not in the mod cannot be downloaded (the network is blocked for Typst), so its block shows as code.
-- **Security:** Typst runs with `--root /`, so a Typst block can read any file that you can read and draw it in the picture. Nothing leaves the computer.
-- **The look is close to VS Code, not exact:** Typst does not use CSS. Raw HTML in Markdown is shown in a simple form or dropped. Loose lists have tight spacing.
-- **A picture that the terminal dropped from its image memory** (after many large pictures) is not sent again when you scroll back to it.
-- **Over ssh**, the mod cannot read the terminal's config on your computer. So it uses Menlo metrics for the text size, and `auto` uses `COLORFGBG` if ssh sends it. Else `auto` is dark. The mod does not use the OS appearance of the remote computer. Pages are shorter, so that each one is at most 4096 pixels tall. In tmux or screen on the remote computer, no pictures show.
-- **`auto` theme** reads the iTerm2 profile, the Ghostty, kitty and Rio configs, and the cmux settings directly. It does not read kitty's `globinclude`, `envinclude` and `geninclude` lines, or colours that you set while kitty runs. In other terminals, it uses `COLORFGBG` (set only when the terminal starts), then the OS appearance. If you change the theme of such a terminal and the OS appearance does not change, Intelligent UI does not see it. A change shows after up to 3 s.
-
-## Develop
-
-```
-git clone https://github.com/razorback16/claude-md-preview
-cd claude-md-preview
-claude --plugin-dir . # once: Claude Code writes the API types to .claude-plugin/types/
-npx -p typescript tsc -p . # type check
-claude plugin test . # tests
-claude plugin validate .
-```
+- [Install](docs/install.md): requirements and terminal support
+- [Usage](docs/usage.md): what it draws, commands, plan approval
+- [Themes](docs/themes.md): built-in themes and your own
+- [How it works](docs/how-it-works.md): the render steps and light or dark mode
+- [Limitations](docs/limitations.md): copy, search, timing and other limits
+- [Development](docs/development.md): build, test and module layout
+- [Gallery](docs/gallery.md): all the sample answers
-`.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`.
+## Disclaimer
-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) `draw.tsx` (the pages of an answer), `answer.ts` (one text through the compile and cache steps) and `plan.tsx` (the plan approval question and the plan rows). The values that change are in one object, `S`, in `state.ts`. The tests import from `hooks/register.tsx`, which exports the names that they use.
+Intelligent UI is an independent project. It is not made, supported or endorsed by Anthropic. Claude and Claude Code are trademarks of Anthropic, PBC.
## Licence
diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md
index 103da9b..7e1150f 100644
--- a/THIRD-PARTY-NOTICES.md
+++ b/THIRD-PARTY-NOTICES.md
@@ -4,7 +4,7 @@ Intelligent UI is MIT licensed (see `LICENSE`). It includes the work of others,
## Typst packages (in `render/packages/preview/`)
-These are copies of the published packages from [Typst Universe](https://typst.app/universe), so the mod works offline.
+These are copies of the published packages from [Typst Universe](https://typst.app/universe), so Intelligent UI works offline.
| Package | Version | Licence |
|---|---|---|
diff --git a/docs/development.md b/docs/development.md
new file mode 100644
index 0000000..a68de6e
--- /dev/null
+++ b/docs/development.md
@@ -0,0 +1,30 @@
+# Development
+
+← Back to the [README](../README.md)
+
+## Build and test
+
+```
+git clone https://github.com/razorback16/claude-intelligent-ui
+cd claude-intelligent-ui
+claude --plugin-dir . # once: Claude Code writes the API types to .claude-plugin/types/
+npx -p typescript tsc -p . # type check
+claude plugin test . # tests
+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`.
+
+## 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}/intelligent-ui-<uid>/`).
+
+## 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), `draw.tsx` (the pages of an answer), `answer.ts` (one text through the compile and cache steps) and `plan.tsx` (the plan approval question and the plan rows). The values that change are in one object, `S`, in `state.ts`. The tests import from `hooks/register.tsx`, which exports the names that they use.
+
+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).
diff --git a/docs/gallery.md b/docs/gallery.md
new file mode 100644
index 0000000..c7ba77f
--- /dev/null
+++ b/docs/gallery.md
@@ -0,0 +1,73 @@
+# Gallery
+
+← 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/).
+
+## In a dark and a light terminal
+
+![Claude explains why an API request is slow: a timing chart shows the DB query takes 310 of 450 ms, with Amdahl's law and a table of fixes, in a dark and a light terminal](../outcomes/out/0-hero-2-latency.png)
+
+![Claude explains attention in a transformer: the attention formula and a heat map of attention weights, in a dark and a light terminal](../outcomes/out/0-hero-1-attention.png)
+
+![Claude explains git rebase: a commit graph before and after the rebase and a table that compares merge and rebase, in a dark and a light terminal](../outcomes/out/0-hero-3-rebase.png)
+
+## Real Markdown, right in the terminal
+
+Headings, an image, a table, inline math, a code block with syntax colours, a task list and a block quote.
+
+<picture>
+ <source media="(prefers-color-scheme: dark)" srcset="../outcomes/out/1-overview-dark.png">
+ <source media="(prefers-color-scheme: light)" srcset="../outcomes/out/1-overview-light.png">
+ <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
+
+Euler's identity, the Gaussian integral, Maxwell's equations, a matrix and a piecewise function.
+
+<picture>
+ <source media="(prefers-color-scheme: dark)" srcset="../outcomes/out/2-math-dark.png">
+ <source media="(prefers-color-scheme: light)" srcset="../outcomes/out/2-math-light.png">
+ <img alt="Typeset LaTeX math in Claude Code: the Gaussian integral, Maxwell's equations, a rotation matrix and a piecewise function" src="../outcomes/out/2-math-light.png" width="800">
+</picture>
+
+## A fractal, calculated as it draws
+
+Typst calculates each pixel of the Mandelbrot set at render time.
+
+<picture>
+ <source media="(prefers-color-scheme: dark)" srcset="../outcomes/out/3-mandelbrot-dark.png">
+ <source media="(prefers-color-scheme: light)" srcset="../outcomes/out/3-mandelbrot-light.png">
+ <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
+
+A recursive fractal tree and a Lissajous curve, drawn with CeTZ.
+
+<picture>
+ <source media="(prefers-color-scheme: dark)" srcset="../outcomes/out/4-fractal-dark.png">
+ <source media="(prefers-color-scheme: light)" srcset="../outcomes/out/4-fractal-light.png">
+ <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
+
+A damped oscillator and its exponential envelope, drawn with cetz-plot.
+
+<picture>
+ <source media="(prefers-color-scheme: dark)" srcset="../outcomes/out/5-plot-dark.png">
+ <source media="(prefers-color-scheme: light)" srcset="../outcomes/out/5-plot-light.png">
+ <img alt="A function plot of a damped oscillator with its exponential envelope, axes and a legend, drawn with cetz-plot in a Claude answer" src="../outcomes/out/5-plot-light.png" width="800">
+</picture>
+
+## Flow charts and commutative diagrams
+
+An agent loop and the First Isomorphism Theorem, drawn with fletcher.
+
+<picture>
+ <source media="(prefers-color-scheme: dark)" srcset="../outcomes/out/6-diagrams-dark.png">
+ <source media="(prefers-color-scheme: light)" srcset="../outcomes/out/6-diagrams-light.png">
+ <img alt="A flow chart of an agent loop and a commutative diagram of the First Isomorphism Theorem, drawn with fletcher in a Claude answer" src="../outcomes/out/6-diagrams-light.png" width="800">
+</picture>
diff --git a/docs/how-it-works.md b/docs/how-it-works.md
new file mode 100644
index 0000000..ea4ab7e
--- /dev/null
+++ b/docs/how-it-works.md
@@ -0,0 +1,30 @@
+# How it works
+
+← Back to the [README](../README.md)
+
+## The steps
+
+1. A `ui.render` hook on `AssistantMessage` gets each block of the answer as Markdown.
+2. While Claude writes a block, the block is hidden. 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`. Long answers are cut at block boundaries into pages. One page is one PNG.
+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, else Menlo metrics) and the cell size in pixels. Typst then measures both fonts so that 100% looks as large as the terminal text.
+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}/intelligent-ui-<uid>/`. Folders older than 2 days are deleted at start. The drawing space of each answer at its first compile is kept in `~/.cache/intelligent-ui/designs`, so that its Typst drawings keep the same share of the screen in later sessions.
+7. 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.
+
+## 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:
+
+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. If that config sets 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. 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, or GNOME's `color-scheme` on Linux.
+7. **Dark.**
+
+The terminal comes before the OS: a dark terminal on a light Mac is dark.
+
+Intelligent UI checks every 3 s. 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 does not use OSC 11 yet.
diff --git a/docs/install.md b/docs/install.md
new file mode 100644
index 0000000..c6aebcd
--- /dev/null
+++ b/docs/install.md
@@ -0,0 +1,49 @@
+# Install
+
+← Back to the [README](../README.md)
+
+## Requirements
+
+- Claude Code 2.1.301 or later (tested on 2.1.301)
+- [Typst](https://typst.app) 0.15 (tested on 0.15.1)
+- macOS (tested). Linux can work, but it is not tested.
+- A terminal where Claude Code draws pictures. Refer to [Terminals](#terminals).
+
+## Terminals
+
+- **kitty (0.28 or later) and Ghostty:** pictures work with no setting.
+- **iTerm2 3.6 or later (3.7.5 tested):** 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`, `~/.bash_profile` or a fish `conf.d` file). The line sets the variable in iTerm2 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`).
+- **Rio 0.5.27 or later (not tested):** set `CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1` before you start Claude Code.
+- Do not put the variable in the `env` of `~/.claude/settings.json`. It then applies in every terminal, also where pictures cannot show.
+- **Not supported:** WezTerm, Warp and Konsole do not draw kitty pictures with Unicode placeholders, so they show 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`.
+
+## Install steps
+
+1. Install Typst: `brew install typst` (or see [Typst's install page](https://github.com/typst/typst#installation)).
+2. At the prompt of a Claude Code session in the terminal, type:
+
+ ```
+ /plugin install intelligent-ui --marketplace razorback16/claude-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:
+
+```
+claude plugin install intelligent-ui --marketplace razorback16/claude-intelligent-ui
+```
+
+## Try it from a clone
+
+To try it from a clone without installing:
+
+```
+git clone https://github.com/razorback16/claude-intelligent-ui
+claude --plugin-dir /path/to/claude-intelligent-ui
+```
diff --git a/docs/limitations.md b/docs/limitations.md
new file mode 100644
index 0000000..c1b30d5
--- /dev/null
+++ b/docs/limitations.md
@@ -0,0 +1,15 @@
+# Limitations
+
+← Back to the [README](../README.md)
+
+- **Copying text from a picture does not work.** A picture fills its cells with kitty placeholder characters (U+10EEEE plus combining marks). Claude Code's mouse selection copies those cells directly to the clipboard, and no mod hook runs before that copy. So a paste gives strange characters, not the text. Use Claude Code's `/copy` to copy the last answer as Markdown (`/copy 2` for the one before it; it shows a picker for the full answer or one code block, unless "Skip the /copy picker" is on in `/config`), or turn the mod off (`/iui off`) to select text. To stop the clipboard write on select, set `copyOnSelect` to `false` in `/config`.
+- **Search does not find text in a picture.**
+- **While Claude writes**, the block is hidden, and Claude Code's spinner shows the progress. When the block is final, its picture shows after the compile (0.15–0.6 s). A long answer shows only when it is done. If the picture is not ready 2 s after the block is final, the normal text shows until the picture is ready. If the compile fails, the normal text stays. An earlier answer that is not in the cache (for example, after a resume) is blank for up to 1 s, then shows as text until its picture is ready.
+- **Short summaries** between tool calls stay as text.
+- **Plan approval:** a mod cannot draw the Claude Code approval dialog, so the mod shows its own question. That question can have 4 options at most. Thus it has no option to keep planning (use Type something or Esc). The edit option cannot use a terminal editor (vim, nano), because a mod has no terminal. Where an organization manages Claude Code, `classic.PermissionRequest` hooks of a plugin that you install do not run. Then the Claude Code dialog shows after the mod's question.
+- **Typst blocks:** `#page`, `#pagebreak` and `#set page` are errors. A package that is not in the mod cannot be downloaded (the network is blocked for Typst), so its block shows as code.
+- **Security:** Typst runs with `--root /`, so a Typst block can read any file that you can read and draw it in the picture. Nothing leaves the computer.
+- **The look is close to VS Code, not exact:** Typst does not use CSS. Raw HTML in Markdown is shown in a simple form or dropped. Loose lists have tight spacing.
+- **A picture that the terminal dropped from its image memory** (after many large pictures) is not sent again when you scroll back to it.
+- **Over ssh**, the mod cannot read the terminal's config on your computer. So it uses Menlo metrics for the text size, and `auto` uses `COLORFGBG` if ssh sends it. Else `auto` is dark. The mod does not use the OS appearance of the remote computer. Pages are shorter, so that each one is at most 4096 pixels tall. In tmux or screen on the remote computer, no pictures show.
+- **`auto` theme** reads the iTerm2 profile, the Ghostty, kitty and Rio configs, and the cmux settings directly. It does not read kitty's `globinclude`, `envinclude` and `geninclude` lines, or colours that you set while kitty runs. In other terminals, it uses `COLORFGBG` (set only when the terminal starts), then the OS appearance. If you change the theme of such a terminal and the OS appearance does not change, Intelligent UI does not see it. A change shows after up to 3 s.
diff --git a/docs/themes.md b/docs/themes.md
new file mode 100644
index 0000000..84abdf2
--- /dev/null
+++ b/docs/themes.md
@@ -0,0 +1,45 @@
+# Themes
+
+← Back to the [README](../README.md)
+
+A theme sets the colours, fonts and spacing of the picture. Three themes are in the mod:
+
+| Name | Looks like |
+|---|---|
+| `claude-code` (default) | Claude Code's own Markdown colours, from its dark and light themes |
+| `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).
+
+To change the theme, run `/iui theme <name>`. To list the themes, run `/iui theme`.
+
+## Make your own theme
+
+1. Make a folder: `~/.claude/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.
+
+Example: pink inline code with rounder boxes.
+
+```json
+{
+ "name": "Pink code",
+ "dark": { "inline-code-fg": "#ff79c6", "inline-code-bg": "#ff79c626" },
+ "light": { "inline-code-fg": "#c2185b" },
+ "inline-code": { "radius-px": 8 }
+}
+```
+
+## 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.
+
+All keys, their units and their 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).
diff --git a/docs/usage.md b/docs/usage.md
new file mode 100644
index 0000000..5782090
--- /dev/null
+++ b/docs/usage.md
@@ -0,0 +1,71 @@
+# Usage
+
+← 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.
+
+## 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; else Menlo, SF Mono or DejaVu Sans Mono)
+- Math (`$…$` and `$$…$$`, LaTeX syntax, through mitex)
+- Images from `![alt](path)`. 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:
+
+ ```
+ #import "@preview/cetz:0.5.2"
+ #import "@preview/cetz-plot:0.1.4": plot, chart
+ #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 and WebP images. Typst changes a JPEG or WebP 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.
+ - 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.
+
+ Other files stay as the normal row. JPEG images, WebP images and Markdown files need Typst.
+- Images that you paste into the prompt (`[Image #N]`). The mod draws each image under your prompt.
+
+ These pictures are not larger than the image. 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 and WebP images only. Other image types (for example GIF and SVG) stay as the normal row.
+- 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).
+
+## Commands
+
+| Command | What it does |
+|---|---|
+| `/iui` | Shows the state, the theme, the text size, the width and the image height, and a problem that keeps pictures away |
+| `/iui details` | Shows all that the mod found: where the mode comes from, the terminal font, the Typst path and why the terminal can or cannot show pictures |
+| `/iui on` / `off` | Turns the pictures on or off (kept for later sessions) |
+| `/iui setup` / `setup remove` | iTerm2: adds or removes the shell line that turns pictures on (then close the tab and open a new one) |
+| `/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 (sent or pasted) and to Typst drawings in answers. |
+| `/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 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 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). |
+
+## 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:
+
+| 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. |
+| 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. Over ssh and on Linux with no `code` command, the "Edit the plan" option 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 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.
+
+For the limits of this flow, refer to [Limitations](limitations.md).
diff --git a/hooks/lib/command.ts b/hooks/lib/command.ts
index a2596ce..aacf6eb 100644
--- a/hooks/lib/command.ts
+++ b/hooks/lib/command.ts
@@ -1,4 +1,4 @@
-// The /md-preview command: its arguments, the typeahead rows for them, and
+// The /iui command: its arguments, the typeahead rows for them, and
// its registration.
import type { EngineInterface } from 'claude-code'
@@ -8,8 +8,8 @@ import {
} from './settings'
import { isThemeName, type ThemeInfo } from './themes'
-// `/md-preview` arguments: on, off, size <80-200>, width [40-400|full],
-// height [6-200|half|full], details (all md-preview found), or nothing (show state). A `width` or `height`
+// `/iui` arguments: on, off, size <80-200>, width [40-400|full],
+// height [6-200|half|full], details (all Intelligent UI found), or nothing (show state). A `width` or `height`
// with no value shows it.
export type Command =
| { kind: 'on' | 'off' | 'show' | 'details' | 'probe' }
@@ -50,7 +50,7 @@ export function parseCommand(args: string): Command {
return { kind: 'bad' }
}
-// The /md-preview arguments, and the sizes, widths and heights the typeahead offers.
+// The /iui arguments, and the sizes, widths and heights the typeahead offers.
const SUBCOMMANDS = [
{ name: 'on', description: 'draw answers as pictures' },
{ name: 'off', description: 'show answers as text' },
@@ -65,7 +65,7 @@ const SIZES = [80, 90, 100, 110, 120, 125, 150, 175, 200]
const WIDTHS: readonly Width[] = [80, 100, 120, 160, 200, 'full']
const HEIGHTS: readonly Height[] = ['half', 'full', 12, 24, 36]
-// Typeahead rows for `/md-preview` arguments: the word at the cursor (`token`,
+// Typeahead rows for `/iui` arguments: the word at the cursor (`token`,
// starting at `start` in `text`) completed as a subcommand, a theme name, a
// size, a width or a height. Right after `theme`, `size`, `width` or
// `height`, rows hold the word and its argument, since the typeahead asks
@@ -75,7 +75,7 @@ export function commandSuggestions(
text: string, token: string, start: number,
o: { themes: readonly ThemeInfo[]; active: string; size: number; width?: Width; height?: Height },
): Suggestion[] {
- const head = /^\s*\/md-preview\s+/.exec(text)
+ const head = /^\s*\/iui\s+/.exec(text)
if (!head || start < head[0].length) return []
const before = text.slice(head[0].length, start).trim().split(/\s+/).filter(Boolean).map(w => w.toLowerCase())
const word = token.toLowerCase()
@@ -121,11 +121,11 @@ export function commandSuggestions(
return []
}
-// /md-preview; registered at session start and again in setUp, so it is
+// /iui; registered at session start and again in setUp, so it is
// there after a hot reload too.
export async function registerCommand($: EngineInterface) {
await $.command.register({
- name: 'md-preview',
+ name: 'iui',
description: "Draw Claude's answers as rendered Markdown pictures: on, off, size <80-200> (text size in % of the terminal's), width [40-400|full] (the most columns a picture takes), height [6-200|half|full] (the most rows an image or a Typst drawing takes), theme [name] (list or switch themes)",
argumentHint: '[on|off|size <percent>|width [columns|full]|height [rows|half|full]|theme [name]]',
}).catch(() => undefined)
diff --git a/hooks/lib/draw.tsx b/hooks/lib/draw.tsx
index 066ca30..b081bd0 100644
--- a/hooks/lib/draw.tsx
+++ b/hooks/lib/draw.tsx
@@ -3,7 +3,7 @@
// drawing of its pages beside the reply bullet.
import type { EngineInterface, RenderComponent, RenderViewport, ResolveInput } from 'claude-code'
-import type { MdPreviewTheme } from '../../types'
+import type { IuiTheme } from '../../types'
import { BODY_PT, bulletOf, GUTTER, MARGIN_TOP, TEMPLATE_VERSION } from './settings'
import { INLINE_KEPT, inlined, S, type Cell, type Look, type Metrics, type Result, type Room } from './state'
import { FENCE } from './markdown'
@@ -56,7 +56,7 @@ export function renderKey(o: {
columns: number
cell: Cell
size: number
- mode: MdPreviewTheme
+ mode: IuiTheme
termFont: string
columnPt: number
templateStamp: string
diff --git a/hooks/lib/env.ts b/hooks/lib/env.ts
index bcf82d0..bf400b0 100644
--- a/hooks/lib/env.ts
+++ b/hooks/lib/env.ts
@@ -20,13 +20,13 @@ import { findTypst, measureFonts } from './typst'
// The `isOn` atom, which setUp turns off when the stored setting says so (a
// copy of its own: see state.ts).
-const isOn = atom({ plugin: 'md-preview', key: 'isOn' } as const, true)
+const isOn = atom({ plugin: 'intelligent-ui', key: 'isOn' } as const, true)
// Makes the cache folder, drops key folders not touched for 2 days, makes
// the designs folder (outside the tmp cache) and drops design files not
// touched for DESIGNS_KEPT_DAYS; prints the cache folder, the OS name and
// the designs folder.
-const CACHE_SH = `d="\${TMPDIR:-/tmp}"; d="\${d%/}/md-preview-$(id -u)"; g="\${XDG_CACHE_HOME:-$HOME/.cache}/md-preview/designs"; mkdir -p "$d" && chmod 700 "$d" && { find "$d" -mindepth 1 -maxdepth 1 -type d -mtime +2 ! -name pkg-cache -exec rm -rf {} + 2>/dev/null; mkdir -p "$g" 2>/dev/null && find "$g" -type f -mtime +${DESIGNS_KEPT_DAYS} -delete 2>/dev/null; printf '%s\\n%s\\n%s\\n' "$d" "$(uname -s)" "$g"; }`
+const CACHE_SH = `d="\${TMPDIR:-/tmp}"; d="\${d%/}/intelligent-ui-$(id -u)"; g="\${XDG_CACHE_HOME:-$HOME/.cache}/intelligent-ui/designs"; mkdir -p "$d" && chmod 700 "$d" && { find "$d" -mindepth 1 -maxdepth 1 -type d -mtime +2 ! -name pkg-cache -exec rm -rf {} + 2>/dev/null; mkdir -p "$g" 2>/dev/null && find "$g" -type f -mtime +${DESIGNS_KEPT_DAYS} -delete 2>/dev/null; printf '%s\\n%s\\n%s\\n' "$d" "$(uname -s)" "$g"; }`
// Once per load: the cache folder, Typst, the terminal and its font, the
// theme, the cell. A failed setup is tried again on the next call.
@@ -35,7 +35,7 @@ export function setUp($: EngineInterface): Promise<Env> {
await registerCommand($)
const made = await $.process.run(['sh', '-c', CACHE_SH]).catch(() => null)
const [made1 = '', os = '', made3 = ''] = (made?.stdout ?? '').split('\n')
- const cache = made1.trim() || '/tmp/md-preview'
+ const cache = made1.trim() || '/tmp/intelligent-ui'
// The key folders on disk now: a key found here is read back at once.
const listed = await $.fs.list(cache).catch(() => [])
S.onDisk = new Set(listed.filter(entry => entry.kind === 'dir' && entry.name !== 'pkg-cache').map(entry => entry.name))
@@ -50,7 +50,7 @@ export function setUp($: EngineInterface): Promise<Env> {
ssh,
background: (await $.env.get('CLAUDE_CODE_SESSION_KIND')) === 'bg',
engineForced: isSet(await $.env.get('CLAUDE_CODE_FORCE_TERMINAL_IMAGES')),
- modForced: isSet(await $.env.get('MD_PREVIEW_FORCE')),
+ modForced: isSet(await $.env.get('IUI_FORCE')),
})
const root = $.plugin.root
const template = await $.fs.stat(`${root}/render/md.typ`).catch(() => null)
@@ -64,7 +64,7 @@ export function setUp($: EngineInterface): Promise<Env> {
S.itermProfile = (await $.env.get('ITERM_PROFILE')) || undefined
S.isKitty = /kitty/i.test(term) || !!(await $.env.get('KITTY_WINDOW_ID')) || !!(await $.env.get('KITTY_PID'))
S.isRemote = ssh
- S.debug = isSet(await $.env.get('MD_PREVIEW_DEBUG'))
+ S.debug = isSet(await $.env.get('IUI_DEBUG'))
S.isIterm = isItermIn({
program,
profile: S.itermProfile,
@@ -98,14 +98,14 @@ export function setUp($: EngineInterface): Promise<Env> {
}
const termFont = await termFontOf($, program, isMac).catch(() => '')
const home = (await $.env.get('HOME')) ?? ''
- const designs = made3.trim() || (home ? `${home}/.cache/md-preview/designs` : `${cache}/designs`)
+ const designs = made3.trim() || (home ? `${home}/.cache/intelligent-ui/designs` : `${cache}/designs`)
const stored = await $.store.get('theme-name').catch(() => undefined)
const wanted = typeof stored === 'string' && stored ? stored : DEFAULT_THEME
const applied = await applyTheme($, root, home, wanted).catch(() => null)
if (!applied) S.look = { name: BASE_THEME, dir: `${root}/render/themes/${BASE_THEME}`, stamp: '0' }
else if (applied.chosen.isFallback) {
try {
- $.ui.toast(`md-preview: theme ${wanted} not found, using ${applied.chosen.name}`, { timeoutMs: 8000 })
+ $.ui.toast(`Intelligent UI: theme ${wanted} not found, using ${applied.chosen.name}`, { timeoutMs: 8000 })
} catch {}
}
S.env = {
diff --git a/hooks/lib/frame.ts b/hooks/lib/frame.ts
index a978742..de1a047 100644
--- a/hooks/lib/frame.ts
+++ b/hooks/lib/frame.ts
@@ -62,7 +62,7 @@ export function shownFor(view?: View): Frame {
}
// The columns a Markdown picture (an answer, a plan, a sent file) takes in
-// `frame`: columnsFor with /md-preview width; over ssh (`inline`) also at
+// `frame`: columnsFor with /iui width; over ssh (`inline`) also at
// most what a `{ png }` source can be wide in its cell.
export const pictureColumns = (frame: Frame, inline: boolean): number =>
columnsFor(frame.columns, S.width, inline ? frame.cell : null)
diff --git a/hooks/lib/host.ts b/hooks/lib/host.ts
index 99d51a5..dc0b471 100644
--- a/hooks/lib/host.ts
+++ b/hooks/lib/host.ts
@@ -1,9 +1,9 @@
-// Work on the host: the shell snippets md-preview runs, the tty size (one
+// Work on the host: the shell snippets Intelligent UI runs, the tty size (one
// read, and the Frame watcher's loop), the terminal's font, and light or dark for auto (the terminal's settings, then
// COLORFGBG, then the OS appearance), read again by a poll.
import type { EngineInterface } from 'claude-code'
-import type { MdPreviewTheme } from '../../types'
+import type { IuiTheme } from '../../types'
import { HOST_CHECK_MS, HOST_POLL_MS, MODES } from './settings'
import { S } from './state'
import { beginEpoch } from './epoch'
@@ -67,7 +67,7 @@ export const OSC11_PL = [
'}',
'print $r;',
].join(' ')
-// Off until /md-preview probe shows the answer reaches the mod: the poll
+// Off until /iui probe shows the answer reaches the mod: the poll
// then asks the terminal (source 1 of auto) every period.
export const USE_OSC11 = false
export const PROBE_RUNS = 5
@@ -169,7 +169,7 @@ async function readGhosttyMode($: EngineInterface): Promise<HostMode | null> {
}
const pair = ghosttyThemesOf(ghosttyValueOf(got.stdout, 'theme'))
const themeBg: { light?: string; dark?: string } = {}
- let appearance: MdPreviewTheme | null = null
+ let appearance: IuiTheme | null = null
if (pair) {
appearance = (await readOsMode($).catch(() => null))?.mode ?? null
const where = {
diff --git a/hooks/lib/images.ts b/hooks/lib/images.ts
index 6283c65..e9c6381 100644
--- a/hooks/lib/images.ts
+++ b/hooks/lib/images.ts
@@ -7,7 +7,7 @@ import { CONVERT_MAX_SIDE, MAX_IMAGE_ROWS, PICTURE_MAX_ROWS, PICTURE_MIN_ROWS, P
import { hashOf } from './draw'
// The most rows a picture under a row (or a drawing's room) takes in a
-// terminal of `terminalRows` rows (frameFor(...).rows), by `height` (/md-preview
+// terminal of `terminalRows` rows (frameFor(...).rows), by `height` (/iui
// height): half the rows within PICTURE_MIN_ROWS to PICTURE_MAX_ROWS
// (half); the rows less PICTURE_ROOM_ROWS (full); or a number, at most as
// much as full. Never under PICTURE_MIN_ROWS or over MAX_IMAGE_ROWS.
diff --git a/hooks/lib/log.ts b/hooks/lib/log.ts
index f42498d..c1aaadc 100644
--- a/hooks/lib/log.ts
+++ b/hooks/lib/log.ts
@@ -8,7 +8,7 @@ export async function logDebug($: EngineInterface, cache: string, text: string)
await $.process.run(['sh', '-c', 'cat >> "$1"', 'sh', `${cache}/debug.log`], { stdin: `[${stamp}] ${text.trimEnd()}\n` }).catch(() => undefined)
}
-// A trace line, only with MD_PREVIEW_DEBUG set (S.debug, read in setUp).
+// A trace line, only with IUI_DEBUG set (S.debug, read in setUp).
export function traceDebug($: EngineInterface, text: string) {
if (S.debug && S.env) void logDebug($, S.env.cache, text)
}
diff --git a/hooks/lib/markdown.ts b/hooks/lib/markdown.ts
index 26db1fa..f7a8904 100644
--- a/hooks/lib/markdown.ts
+++ b/hooks/lib/markdown.ts
@@ -1,4 +1,4 @@
-// Markdown as md-preview reads it: blocks, fences, the segments an answer is
+// Markdown as the mod reads it: blocks, fences, the segments an answer is
// cut into, the images it names, and a plain text of it for an Image's alt.
import { ALT_CHARS, SEGMENT_ROWS } from './settings'
@@ -59,7 +59,7 @@ export function blocksOf(md: string): Block[] {
}
// A rough count of the rows a block takes once drawn `columns` wide, its
-// text at `size` percent (/md-preview size): fewer characters a row, and
+// text at `size` percent (/iui size): fewer characters a row, and
// taller lines.
export function rowsOfBlock(block: Block, columns: number, size = 100): number {
const isCode = !!block.fence
diff --git a/hooks/lib/mode.ts b/hooks/lib/mode.ts
index eb55738..e540ca6 100644
--- a/hooks/lib/mode.ts
+++ b/hooks/lib/mode.ts
@@ -1,16 +1,16 @@
// Light or dark: Claude Code's theme setting, the OS appearance, COLORFGBG,
// a colour's luminance and the terminal's OSC 11 answer (pure; the reads on
// the host are in host.ts).
-import type { MdPreviewTheme } from '../../types'
+import type { IuiTheme } from '../../types'
-export function themeOf(value: unknown): MdPreviewTheme {
+export function themeOf(value: unknown): IuiTheme {
return typeof value === 'string' && /light/i.test(value) ? 'light' : 'dark'
}
// Claude Code's theme setting: dark, light, dark-daltonized, light-ansi, …
// are fixed; `auto`, or any other text, follows the OS. No value is Claude
// Code's default, dark.
-export type ThemeSetting = MdPreviewTheme | 'auto'
+export type ThemeSetting = IuiTheme | 'auto'
export function settingOf(value: unknown): ThemeSetting {
if (typeof value !== 'string' || !value.trim()) return 'dark'
if (/light/i.test(value)) return 'light'
@@ -19,17 +19,17 @@ export function settingOf(value: unknown): ThemeSetting {
}
// The OS appearance, and where it was read.
-export type HostMode = { mode: MdPreviewTheme; source: 'terminal' | 'iTerm2' | 'Ghostty' | 'cmux' | 'kitty' | 'Rio' | 'macOS' | 'GNOME' | 'COLORFGBG'; detail?: string }
+export type HostMode = { mode: IuiTheme; source: 'terminal' | 'iTerm2' | 'Ghostty' | 'cmux' | 'kitty' | 'Rio' | 'macOS' | 'GNOME' | 'COLORFGBG'; detail?: string }
// `defaults read -g AppleInterfaceStyle`: "Dark" in dark mode; in light mode
// the key does not exist and the command fails.
-export function modeOfMacAppearance(exitCode: number, stdout: string): MdPreviewTheme {
+export function modeOfMacAppearance(exitCode: number, stdout: string): IuiTheme {
return exitCode === 0 && /^\s*dark\s*$/i.test(stdout) ? 'dark' : 'light'
}
// `gsettings get org.gnome.desktop.interface color-scheme`: 'prefer-dark',
// 'prefer-light' or 'default'; null for anything else.
-export function modeOfGnome(stdout: string): MdPreviewTheme | null {
+export function modeOfGnome(stdout: string): IuiTheme | null {
const v = stdout.trim().replace(/^'|'$/g, '')
if (v === 'prefer-dark') return 'dark'
if (v === 'prefer-light' || v === 'default') return 'light'
@@ -38,7 +38,7 @@ export function modeOfGnome(stdout: string): MdPreviewTheme | null {
// COLORFGBG, "fg;bg" or "fg;x;bg": the last field is the background colour
// index. 0-6 and 8 are dark, 7 and 15 light; anything else is not known.
-export function modeOfColorFgBg(value: string | undefined): MdPreviewTheme | null {
+export function modeOfColorFgBg(value: string | undefined): IuiTheme | null {
const last = (value ?? '').split(';').pop()?.trim() ?? ''
if (!/^\d+$/.test(last)) return null
const bg = Number(last)
@@ -49,12 +49,12 @@ export function modeOfColorFgBg(value: string | undefined): MdPreviewTheme | nul
// The mode to draw: a fixed setting as set; auto as the OS is, dark when it
// was never read.
-export function resolveMode(setting: ThemeSetting, seen: HostMode | null): MdPreviewTheme {
+export function resolveMode(setting: ThemeSetting, seen: HostMode | null): IuiTheme {
return setting === 'auto' ? (seen?.mode ?? 'dark') : setting
}
// What the status line says about the mode.
-export function modeLine(mode: MdPreviewTheme, setting: ThemeSetting, raw: string, seen: HostMode | null): string {
+export function modeLine(mode: IuiTheme, setting: ThemeSetting, raw: string, seen: HostMode | null): string {
if (setting !== 'auto') return `mode ${mode} (Claude Code theme ${raw || mode})`
return `mode ${mode} (auto, ${seen ? `from ${seen.source}${seen.detail ? `: ${seen.detail}` : ''}` : 'OS appearance not known, dark assumed'})`
}
@@ -65,7 +65,7 @@ export function luminanceOf(c: Rgb): number {
const lin = (v: number) => (v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4)
return 0.2126 * lin(c.r) + 0.7152 * lin(c.g) + 0.0722 * lin(c.b)
}
-export const modeOfLuminance = (l: number): MdPreviewTheme => (l > 0.4 ? 'light' : 'dark')
+export const modeOfLuminance = (l: number): IuiTheme => (l > 0.4 ? 'light' : 'dark')
// A terminal's answer to OSC 11 (`ESC ] 11 ; ?`), the query Claude Code
// itself sends: `ESC ] 11 ; rgb:R/G/B` with 1-4 hex digits per channel,
@@ -77,6 +77,6 @@ export function parseOsc11(text: string): Rgb | null {
return { r: part(m[1]!), g: part(m[2]!), b: part(m[3]!) }
}
-// Control characters shown as text (\e, \a, \xNN), for /md-preview probe.
+// Control characters shown as text (\e, \a, \xNN), for /iui probe.
export const escapeControls = (text: string) =>
text.replace(/[\x00-\x1f\x7f]/g, c => (c === '\x1b' ? '\\e' : c === '\x07' ? '\\a' : `\\x${c.charCodeAt(0).toString(16).padStart(2, '0')}`))
diff --git a/hooks/lib/plan.tsx b/hooks/lib/plan.tsx
index 199220a..7f46428 100644
--- a/hooks/lib/plan.tsx
+++ b/hooks/lib/plan.tsx
@@ -1,7 +1,7 @@
-// The plan of plan mode: md-preview's own approval flow for the main loop's
+// The plan of plan mode: Intelligent UI's own approval flow for the main loop's
// ExitPlanMode, and the plan drawn as pictures in its transcript row.
//
-// The engine's approval dialog cannot be drawn by a plugin, so md-preview asks
+// The engine's approval dialog cannot be drawn by a plugin, so the mod asks
// first: the `tool.call` hook on ExitPlanMode asks its own question (decidePlan)
// before the engine raises PermissionRequest, and keeps the verdict. The
// PermissionRequest hook then answers with it at once (decisionOf), so the
@@ -25,11 +25,11 @@ export const PLAN_AUTO = 'Yes, auto-accept edits'
export const PLAN_MANUAL = 'Yes, manually approve edits'
export const PLAN_CLEAR = 'Yes, clear context + auto-accept'
export const PLAN_EDIT = 'Edit the plan'
-// The line above md-preview's question (the dialog takes 12 rows at most
+// The line above Intelligent UI's question (the dialog takes 12 rows at most
// around it, so the plan itself is in the ToolUse row above).
-export const PLAN_ASK_LINE = 'md-preview: the rendered plan is above'
+export const PLAN_ASK_LINE = 'Intelligent UI: the rendered plan is above'
// The line in the ToolUse row while the plan's pictures compile.
-export const PLAN_DRAWING = 'md-preview: drawing the plan...'
+export const PLAN_DRAWING = 'Intelligent UI: drawing the plan...'
// What the model reads when the person rejects the plan (Esc) or types changes.
export const PLAN_REJECTED = 'The user rejected the plan.'
export const PLAN_FEEDBACK = 'The user wants changes to the plan:'
@@ -84,7 +84,7 @@ export function planFileOf(input: unknown): string {
return typeof file === 'string' && file.startsWith('/') ? file : ''
}
-// The plan a row of the call shows: the text edited in md-preview's flow, else
+// The plan a row of the call shows: the text edited in the mod's flow, else
// the result's, else the call's; '' for none and for a subagent's or a
// teammate's result.
export function planShownOf(edited: string | undefined, output: unknown, input: unknown): string {
@@ -120,7 +120,7 @@ export function choiceOf(answer: string, canEdit: boolean): PlanChoice {
// mode and revises.
export const feedbackOf = (text: string) => (text ? `${PLAN_FEEDBACK} ${text}` : `${PLAN_FEEDBACK.slice(0, -1)}.`)
-// The verdict md-preview's question gave, kept for the PermissionRequest that
+// The verdict the mod's question gave, kept for the PermissionRequest that
// follows: approve (in a mode, with the plan, edited or not; `clear` starts a
// new context once the call resolves), or reject and stop the turn (Esc).
export type PlanVerdict =
@@ -171,11 +171,11 @@ async function findCode($: EngineInterface): Promise<string> {
return found
}
-// What md-preview's question decided: a verdict for the PermissionRequest, or
+// What the mod's question decided: a verdict for the PermissionRequest, or
// the person's words (a deny of the call: Claude revises the plan).
export type PlanOutcome = { kind: 'verdict'; verdict: PlanVerdict } | { kind: 'feedback'; message: string }
-// Asks md-preview's question about the plan, as often as the person edits it.
+// Asks the mod's question about the plan, as often as the person edits it.
// `plan` is the text to ask about, `callPlan` the one the call carried (an
// approval sends `plan` when they differ). `onEdited` gets each edited text
// (the ToolUse row draws it). Esc (the ask rejects; in a terminal session
@@ -281,7 +281,7 @@ export function drawPlanResult($: EngineInterface, e: Terminal, filePath?: strin
)
}
-// The line md-preview adds above its own question.
+// The line Intelligent UI adds above its own question.
export function drawAskLine($: EngineInterface, e: ResolveInput<'AskUserQuestion', 'terminal'>, dialog: RenderElement): RenderElement {
const { Box, Text } = $.ui.resolve(e)
return (
@@ -292,7 +292,7 @@ export function drawAskLine($: EngineInterface, e: ResolveInput<'AskUserQuestion
)
}
-// Whether an AskUserQuestion dialog is md-preview's plan question now asked.
+// Whether an AskUserQuestion dialog is the mod's plan question now asked.
export function isPlanQuestion(questions: unknown, asking: string): boolean {
if (!asking || !Array.isArray(questions) || questions.length !== 1) return false
const q = questions[0] as { question?: unknown; header?: unknown } | null
diff --git a/hooks/lib/settings.ts b/hooks/lib/settings.ts
index 3982abd..87280ce 100644
--- a/hooks/lib/settings.ts
+++ b/hooks/lib/settings.ts
@@ -1,10 +1,10 @@
-// md-preview's settings: sizes, limits, timings and the text it adds to
+// Intelligent UI's settings: sizes, limits, timings and the text it adds to
// Claude's system prompt.
import type { Cell } from './state'
// ---- Settings -------------------------------------------------------------
-// `/md-preview width`: the most columns a picture takes (in this range), or
+// `/iui width`: the most columns a picture takes (in this range), or
// `full`, the default: the terminal width less the bullet, as Claude Code's
// own text. An Image is at most IMAGE_MAX_COLUMNS wide, so no width goes
// past it.
@@ -24,7 +24,7 @@ export const MARGIN_TOP = 1
// The template's body text size in pt; the page width is chosen so that this
// text looks as big as the terminal's own (see fontFit).
export const BODY_PT = 11
-// `/md-preview size`: a percent on top of that match.
+// `/iui size`: a percent on top of that match.
export const DEFAULT_SIZE = 100
export const MIN_SIZE = 80
export const MAX_SIZE = 200
@@ -56,7 +56,7 @@ export const COMPILE_TIMEOUT_MS = 20000
export const ALT_CHARS = 200
// Where Typst is when the login shell's PATH does not find it. `~` is $HOME.
export const TYPST_FALLBACKS = ['/opt/homebrew/bin/typst', '/usr/local/bin/typst', '/usr/bin/typst', '/snap/bin/typst', '~/.cargo/bin/typst', '~/.local/bin/typst']
-export const NO_TYPST = 'md-preview: install Typst (brew install typst) to see rendered answers'
+export const NO_TYPST = 'Intelligent UI: install Typst (brew install typst) to see rendered answers'
// Typst downloads a package it doesn't find under --package-path; a proxy
// nobody listens on makes that fail at once, so a live block never fetches.
export const NO_NETWORK = 'http://127.0.0.1:9'
@@ -75,7 +75,7 @@ export const MODES = ['dark', 'light'] as const
// terminal's rows.
export const PICTURE_MAX_ROWS = 24
export const PICTURE_MIN_ROWS = 6
-// `/md-preview height`: the most rows an image (sent or pasted) or a Typst
+// `/iui height`: the most rows an image (sent or pasted) or a Typst
// drawing (the room of a live block or a local image in Markdown; not a
// whole Markdown page) takes. `half`, the default: as above. `full`: the
// terminal's rows less PICTURE_ROOM_ROWS. A number: that many rows, at most
@@ -124,7 +124,7 @@ Packages available offline:
#import "@preview/cetz-plot:0.1.4": plot, chart
#import "@preview/fletcher:0.5.8" as fletcher: diagram, node, edge
A \`theme\` dictionary is in scope: theme.fg, theme.muted, theme.link, theme.border, theme.accent, theme.bg, theme.code-bg, theme.red/green/blue/yellow/orange/purple, theme.palette (6 colours), theme.width (content width), theme.height (the height a drawing should fit in), theme.dark (bool).
-Default strokes in cetz, fletcher and cetz-plot are black and invisible on a dark theme, so always pass theme colours: cetz \`set-style(stroke: theme.fg)\`; fletcher \`diagram(node-stroke: theme.fg, edge-stroke: theme.fg, ...)\`; cetz-plot \`set-style(axes: (stroke: theme.fg, tick: (stroke: theme.fg)), legend: (fill: theme.bg, stroke: theme.border))\`; fills like \`theme.blue.transparentize(70%)\`; size drawings to fit theme.width × theme.height; md-preview scales them when the terminal changes.
+Default strokes in cetz, fletcher and cetz-plot are black and invisible on a dark theme, so always pass theme colours: cetz \`set-style(stroke: theme.fg)\`; fletcher \`diagram(node-stroke: theme.fg, edge-stroke: theme.fg, ...)\`; cetz-plot \`set-style(axes: (stroke: theme.fg, tick: (stroke: theme.fg)), legend: (fill: theme.bg, stroke: theme.border))\`; fills like \`theme.blue.transparentize(70%)\`; size drawings to fit theme.width × theme.height; Intelligent UI scales them when the terminal changes.
Inside a typst block, #page, #pagebreak and #set page are errors. If a block fails to compile, it is shown as code instead.
A plan (the plan file you write in plan mode) is drawn the same way when ExitPlanMode asks for approval, so the same Markdown, $math$ and typst blocks work there.
The stored text stays Markdown, so keep replies readable as plain text too.`
diff --git a/hooks/lib/setup.ts b/hooks/lib/setup.ts
index b0a9f28..1ba02b6 100644
--- a/hooks/lib/setup.ts
+++ b/hooks/lib/setup.ts
@@ -1,4 +1,4 @@
-// iTerm2 setup: the marked block /md-preview setup adds to (or removes from)
+// iTerm2 setup: the marked block /iui setup adds to (or removes from)
// the shell's start file, and the question asked once per load.
import type { EngineInterface } from 'claude-code'
@@ -10,8 +10,8 @@ import { readText } from './host'
// $.env.set comes after its terminal check, too late). So the setup adds a
// marked block to the shell's start file that sets it in iTerm2 alone, not in
// tmux or screen (Claude Code cannot draw there).
-export const SETUP_START = '# >>> md-preview: Claude Code pictures in iTerm2 >>>'
-export const SETUP_END = '# <<< md-preview <<<'
+export const SETUP_START = '# >>> intelligent-ui: Claude Code pictures in iTerm2 >>>'
+export const SETUP_END = '# <<< intelligent-ui <<<'
export type ShellRc = { path: string; kind: 'sh' | 'fish' }
// The start file the setup writes for the login shell (`SHELL`); null for a
// shell it does not know. iTerm2 starts login shells: bash reads
@@ -20,7 +20,7 @@ export function shellRcOf(o: { shell: string; home: string; zdotdir?: string; xd
const name = o.shell.split('/').pop() ?? ''
if (name === 'zsh') return { path: `${o.zdotdir || o.home}/.zshrc`, kind: 'sh' }
if (name === 'bash') return { path: `${o.home}/${o.isMac ? '.bash_profile' : '.bashrc'}`, kind: 'sh' }
- if (name === 'fish') return { path: `${o.xdgConfig || `${o.home}/.config`}/fish/conf.d/md-preview.fish`, kind: 'fish' }
+ if (name === 'fish') return { path: `${o.xdgConfig || `${o.home}/.config`}/fish/conf.d/intelligent-ui.fish`, kind: 'fish' }
return null
}
export function setupBlock(kind: ShellRc['kind']): string {
@@ -70,18 +70,18 @@ async function shellRc($: EngineInterface): Promise<ShellRc | null> {
export async function runSetup($: EngineInterface, remove: boolean): Promise<string> {
const rc = await shellRc($)
const manual = `export CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1 (only in iTerm2, not in tmux or screen)`
- if (!rc) return `md-preview does not know your shell, so it changed no file. Add this to your shell's start file: ${manual}`
+ if (!rc) return `Intelligent UI does not know your shell, so it changed no file. Add this to your shell's start file: ${manual}`
const text = (await readText($, rc.path)) ?? ''
const restart = 'Close this tab, open a new iTerm2 tab, and start Claude Code there to see pictures.'
if (remove) {
- if (!hasSetup(text)) return `${rc.path} has no md-preview block.`
+ if (!hasSetup(text)) return `${rc.path} has no Intelligent UI block.`
await $.fs.write(rc.path, withoutSetup(text))
- return `Removed the md-preview block from ${rc.path}. New iTerm2 tabs show answers as text.`
+ return `Removed the Intelligent UI block from ${rc.path}. New iTerm2 tabs show answers as text.`
}
- if (hasSetup(text)) return `${rc.path} already has the md-preview block. ${restart}`
+ if (hasSetup(text)) return `${rc.path} already has the Intelligent UI block. ${restart}`
if (rc.kind === 'fish') await $.process.run(['mkdir', '-p', rc.path.replace(/\/[^/]*$/, '')]).catch(() => null)
await $.fs.write(rc.path, withSetup(text, rc.kind))
- return `Added the md-preview block to ${rc.path}. ${restart} Undo with /md-preview setup remove.`
+ return `Added the Intelligent UI block to ${rc.path}. ${restart} Undo with /iui setup remove.`
}
// Asks once per load whether to add the setup block; "Never ask" is kept.
@@ -93,8 +93,8 @@ export async function offerSetup($: EngineInterface) {
if (rc && hasSetup((await readText($, rc.path)) ?? '')) return
const file = rc ? rc.path.replace((await $.env.get('HOME')) ?? '\u0000', '~') : "your shell's start file"
const answer = await $.ui.ask(
- `md-preview draws answers as pictures, but in iTerm2 Claude Code needs CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1 when it starts. Add one line to ${file} that sets it in iTerm2 only (not in tmux or screen)?`,
- { header: 'md-preview', options: ['Add the line', 'Not now', 'Never ask'] },
+ `Intelligent UI draws answers as pictures, but in iTerm2 Claude Code needs CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1 when it starts. Add one line to ${file} that sets it in iTerm2 only (not in tmux or screen)?`,
+ { header: 'iui', options: ['Add the line', 'Not now', 'Never ask'] },
)
if (answer === 'Never ask') await $.store.set('setup', 'never')
if (answer !== 'Add the line') return
diff --git a/hooks/lib/state.ts b/hooks/lib/state.ts
index 8ca2051..a1c7460 100644
--- a/hooks/lib/state.ts
+++ b/hooks/lib/state.ts
@@ -1,9 +1,9 @@
-// md-preview's state: the types the modules share, the values that change
+// Intelligent UI's state: the types the modules share, the values that change
// (`S`), the caches, and refresh (the `done` atom).
import { atom, update } from 'claude-code'
import type { EngineInterface } from 'claude-code'
-import type { MdPreviewTheme } from '../../types'
+import type { IuiTheme } from '../../types'
import type { ThemeInfo } from './themes'
import type { HostMode, ThemeSetting } from './mode'
import type { PlanVerdict } from './plan'
@@ -13,7 +13,7 @@ import { DEFAULT_HEIGHT, DEFAULT_SIZE, DEFAULT_WIDTH, type Height, type Width }
// `claude plugin validate` reads an atom only from a const in the file that
// reads or writes it, so each such file has a copy of its own (atom() is a
// plain description: the copies are one value).
-const done = atom({ plugin: 'md-preview', key: 'done' } as const, 0)
+const done = atom({ plugin: 'intelligent-ui', key: 'done' } as const, 0)
export type Cell = { width: number; height: number }
// The terminal now (one TIOCGWINSZ read): its columns, rows and cell in
@@ -67,7 +67,7 @@ export type Job = {
text: string
columns: number
cell: Cell
- theme: MdPreviewTheme
+ theme: IuiTheme
size: number
themeDir: string
env: Env
@@ -117,11 +117,11 @@ export const S = {
// The key folders in the cache at setUp: a key found there is read back
// at once (a reopened session), with no queue and no blank.
onDisk: new Set<string>(),
- theme: 'dark' as MdPreviewTheme,
+ theme: 'dark' as IuiTheme,
size: DEFAULT_SIZE,
- // `/md-preview width`: the most columns a picture takes, or full.
+ // `/iui width`: the most columns a picture takes, or full.
width: DEFAULT_WIDTH as Width,
- // `/md-preview height`: the most rows an image or a Typst drawing takes (half, full or a number).
+ // `/iui height`: the most rows an image or a Typst drawing takes (half, full or a number).
height: DEFAULT_HEIGHT as Height,
// The height setting of the pictures on screen: `height` once its epoch
// committed (with `shown`), so an image box changes in one step.
@@ -149,9 +149,9 @@ export const S = {
// Over ssh (set in setUp): the terminal's config and the OS appearance here
// are the remote computer's, not those of the user's screen.
isRemote: false,
- // MD_PREVIEW_DEBUG is set (setUp): trace lines go to the debug log.
+ // IUI_DEBUG is set (setUp): trace lines go to the debug log.
debug: false,
- // iTerm2 with the engine's pictures off at start: /md-preview setup can help
+ // iTerm2 with the engine's pictures off at start: /iui setup can help
// (`setupNeeded`); the question is asked once per load (`setupAsked`).
setupNeeded: false,
setupAsked: false,
@@ -160,7 +160,7 @@ export const S = {
// Streaming: model requests of the main loop in flight.
stepsLive: 0,
// The plan (plan.tsx): the main loop's running turn (`turn.start`), the
- // verdict md-preview's question gave for the PermissionRequest that follows
+ // verdict the mod's question gave for the PermissionRequest that follows
// (null: none, the engine's dialog asks), the question asked now ('': none),
// and the `code` command's path (null: not looked up yet; '': none).
mainTurnId: '',
@@ -206,7 +206,7 @@ export const converted = new Map<string, string | null>()
export const converting = new Map<string, Promise<string | null>>()
export const lastConverted = new Map<string, { stamp: string; png: string }>()
export const sentTexts = new Map<string, { stamp: string; text: string | null }>()
-// The plan: the text edited in md-preview's flow, by the call's tool_use_id
+// The plan: the text edited in Intelligent UI's flow, by the call's tool_use_id
// (its rows draw it), and the ExitPlanMode calls of subagents (drawn as the
// engine draws them).
export const editedPlans = new Map<string, string>()
diff --git a/hooks/lib/terminal.ts b/hooks/lib/terminal.ts
index 0991251..4aa7b09 100644
--- a/hooks/lib/terminal.ts
+++ b/hooks/lib/terminal.ts
@@ -4,7 +4,7 @@ import { S, type Cell } from './state'
import { GUTTER, IMAGE_MAX_COLUMNS, SEGMENT_ROWS, type Width } from './settings'
// The columns a picture takes: the viewport less the bullet, at most `width`
-// (`/md-preview width`; full: no cap) and IMAGE_MAX_COLUMNS, at least 20.
+// (`/iui width`; full: no cap) and IMAGE_MAX_COLUMNS, at least 20.
// `inlineCell`: over ssh, the cell, so a page stays INLINE_MAX_SIDE pixels
// wide at most (a wider page can not go as bytes).
export function columnsFor(viewportColumns: number | undefined, width: Width, inlineCell?: Cell | null): number {
@@ -50,7 +50,7 @@ export const isSet = (value: string | undefined) => !!value && !/^(0|false|no|of
// only for kitty and Ghostty; any other terminal draws only when
// CLAUDE_CODE_FORCE_TERMINAL_IMAGES is set. A background session never
// draws. In tmux or screen the engine draws none even when forced (it does
-// not wrap them for passthrough), so only MD_PREVIEW_FORCE tries. Over ssh
+// not wrap them for passthrough), so only IUI_FORCE tries. Over ssh
// TERM_PROGRAM and KITTY_WINDOW_ID do not come through, so TERM tells; the
// pictures then go as bytes (Env.inline), as the terminal can't read our files.
export function canDrawIn(env: { program: string; term: string; kitty: boolean; tmux: boolean; ssh: boolean; background: boolean; engineForced: boolean; modForced: boolean }): boolean {
diff --git a/hooks/lib/terminals.ts b/hooks/lib/terminals.ts
index 7e83abe..e287977 100644
--- a/hooks/lib/terminals.ts
+++ b/hooks/lib/terminals.ts
@@ -1,7 +1,7 @@
// The terminals' own settings (iTerm2, Ghostty, kitty, Rio, cmux): their
// backgrounds and fonts from their config files and profiles (pure; the
// reads on the host are in host.ts).
-import type { MdPreviewTheme } from '../../types'
+import type { IuiTheme } from '../../types'
import { luminanceOf, modeOfLuminance, type Rgb } from './mode'
// An iTerm2 profile ("New Bookmarks" entry): the one named as ITERM_PROFILE
@@ -15,7 +15,7 @@ export function pickProfile(marks: readonly unknown[], profile: string | undefin
// iTerm2's own appearance (Settings > Appearance > Theme, the
// TabStyleWithAutomaticOption default): 0 and 2 light, 1 and 3 dark;
// Automatic (4), Minimal (5), Compact (6) or no value follow the OS (null).
-export function itermAppearanceOf(stdout: string): MdPreviewTheme | null {
+export function itermAppearanceOf(stdout: string): IuiTheme | null {
const v = stdout.trim()
if (v === '0' || v === '2') return 'light'
if (v === '1' || v === '3') return 'dark'
@@ -35,7 +35,7 @@ function itermColorOf(value: unknown): Rgb | null {
// for light and dark mode uses the set `appearance` gives (the OS's when
// iTerm2 follows it; null when that is not known). `bookmarks` is the JSON of
// the plist's "New Bookmarks" array.
-export function itermModeOf(bookmarks: string, profile: string | undefined, defaultGuid: string, appearance: MdPreviewTheme | null): MdPreviewTheme | null {
+export function itermModeOf(bookmarks: string, profile: string | undefined, defaultGuid: string, appearance: IuiTheme | null): IuiTheme | null {
let list: unknown
try {
list = JSON.parse(bookmarks)
@@ -123,7 +123,7 @@ export function ghosttyThemePaths(name: string, o: { xdgConfig?: string; home: s
// `appearance` is taken from `themeBg` (each theme file's background) unless
// the config sets a background of its own (it then matches neither theme).
// Null when the appearance is needed but not known.
-export function ghosttyBackgroundOf(config: string, appearance: MdPreviewTheme | null, themeBg: { light?: string; dark?: string }): string | null {
+export function ghosttyBackgroundOf(config: string, appearance: IuiTheme | null, themeBg: { light?: string; dark?: string }): string | null {
const shown = ghosttyValueOf(config, 'background')
const pair = ghosttyThemesOf(ghosttyValueOf(config, 'theme'))
if (!pair) return shown || GHOSTTY_DEFAULT_BG
@@ -314,7 +314,7 @@ export function rioThemeNamesOf(config: Readonly<Record<string, string>>): strin
}
// Rio's `force-theme`, when it is dark or light.
-export const rioForcedOf = (config: Readonly<Record<string, string>>): MdPreviewTheme | null => {
+export const rioForcedOf = (config: Readonly<Record<string, string>>): IuiTheme | null => {
const v = config['force-theme']
return v === 'dark' || v === 'light' ? v : null
}
@@ -323,7 +323,7 @@ export const rioForcedOf = (config: Readonly<Record<string, string>>): MdPreview
// for `force-theme`, else for `appearance` (the OS); else the `theme` file's;
// else the config's `[colors] background`. A theme file replaces all the
// config's colours. `themes` holds each file's text by name (null: not found).
-export function rioBackgroundOf(config: Readonly<Record<string, string>>, appearance: MdPreviewTheme | null, themes: Readonly<Record<string, string | null>>): { bg: string; detail: string } {
+export function rioBackgroundOf(config: Readonly<Record<string, string>>, appearance: IuiTheme | null, themes: Readonly<Record<string, string | null>>): { bg: string; detail: string } {
// #rrggbbaa: the alpha is dropped.
const opaque = (bg: string) => bg.replace(/^(#?[0-9a-f]{6})[0-9a-f]{2}$/i, '$1')
const has = (name: string | undefined): name is string => !!name && typeof themes[name] === 'string'
@@ -365,7 +365,7 @@ export function jsoncOf(text: string): unknown {
}
export type CmuxAppearance = 'system' | 'light' | 'dark'
-// The cmux settings md-preview needs, from cmux.json: `app.appearance` and
+// The cmux settings Intelligent UI needs, from cmux.json: `app.appearance` and
// `terminal.adaptiveDefaultTheme` (nested objects, or dotted keys).
export function cmuxSettingsOf(json: unknown): { appearance?: CmuxAppearance; adaptive?: boolean } {
const at = (path: string): unknown => {
diff --git a/hooks/lib/themes.ts b/hooks/lib/themes.ts
index bb08e23..0c2de54 100644
--- a/hooks/lib/themes.ts
+++ b/hooks/lib/themes.ts
@@ -1,5 +1,5 @@
// Themes: a theme folder's theme.json, the built-in and user themes, the one
-// to draw with, what `/md-preview theme` lists, and the scan on the host.
+// to draw with, what `/iui theme` lists, and the scan on the host.
import type { EngineInterface } from 'claude-code'
import { BASE_THEME, DEFAULT_THEME, MODES } from './settings'
@@ -86,7 +86,7 @@ export function chooseTheme(themes: ReadonlyMap<string, ThemeInfo>, wanted: stri
return { name: BASE_THEME, dir: base?.dir ?? `${root}/render/themes/${BASE_THEME}`, isFallback: wanted !== BASE_THEME }
}
-// What `/md-preview theme` lists.
+// What `/iui theme` lists.
export function themeListing(themes: ReadonlyMap<string, ThemeInfo>, problems: readonly ThemeProblem[], active: string, userDir: string): string {
const lines = [...themes.values()]
.sort((a, b) => a.name.localeCompare(b.name))
@@ -96,12 +96,12 @@ export function themeListing(themes: ReadonlyMap<string, ThemeInfo>, problems: r
`Themes (* = active):`,
...(lines.length ? lines : ['- none found']),
...skipped,
- `User themes go in ${userDir}/<name>/theme.json. Switch with /md-preview theme <name>.`,
+ `User themes go in ${userDir}/<name>/theme.json. Switch with /iui theme <name>.`,
].join('\n')
}
// The built-in themes under render/themes and the user's under
-// ~/.claude/md-preview/themes, read fresh each call.
+// ~/.claude/intelligent-ui/themes, read fresh each call.
export async function scanThemes($: EngineInterface, root: string, home: string) {
const found: (ThemeInfo | ThemeProblem)[] = []
for (const [base, isUser] of [[`${root}/render/themes`, false], [userThemesOf(home), true]] as const) {
@@ -129,7 +129,7 @@ export async function missingSyntax($: EngineInterface, theme: ThemeInfo) {
return lost
}
-export const userThemesOf = (home: string) => `${home || '~'}/.claude/md-preview/themes`
+export const userThemesOf = (home: string) => `${home || '~'}/.claude/intelligent-ui/themes`
// The mtimes of the files a theme's pictures depend on (themeFiles): a
// change to any of them makes new keys.
diff --git a/hooks/register.tsx b/hooks/register.tsx
index 629aa59..3d19199 100644
--- a/hooks/register.tsx
+++ b/hooks/register.tsx
@@ -1,5 +1,5 @@
-// md-preview: draws Claude's answers (AssistantMessage blocks) as pictures of
-// rendered Markdown, made by Typst from the template in ../render/md.typ.
+// Intelligent UI: draws Claude's answers (AssistantMessage blocks) as pictures
+// of rendered Markdown, made by Typst from the template in ../render/md.typ.
// The stored message never changes; only its drawing does.
//
// Flow: the render hook makes a key from the text, the width, the cell size,
@@ -79,12 +79,12 @@ export {
} from './lib/plan'
// The atoms the hooks read and write (a copy of each in this file: see state.ts).
-const isOn = atom({ plugin: 'md-preview', key: 'isOn' } as const, true)
-const done = atom({ plugin: 'md-preview', key: 'done' } as const, 0)
+const isOn = atom({ plugin: 'intelligent-ui', key: 'isOn' } as const, true)
+const done = atom({ plugin: 'intelligent-ui', key: 'done' } as const, 0)
// ---- Pictures under rows ----------------------------------------------------
-// The env to draw pictures with: md-preview on, in a terminal that draws;
+// The env to draw pictures with: Intelligent UI on, in a terminal that draws;
// null otherwise (no Typst needed), with the `done` value read. Here and not
// in pictures.tsx, as it reads the atoms. The sizes come from the Frame
// (frameFor, shownFor); the viewport is noted for it (a change is settled
@@ -168,8 +168,8 @@ async function planDrawing(
return drawing
}
-// md-preview's own plan question: only on the main loop of a session drawn
-// in a terminal, with md-preview on, Typst found and a terminal that draws
+// Intelligent UI's own plan question: only on the main loop of a session drawn
+// in a terminal, with Intelligent UI on, Typst found and a terminal that draws
// (the plan's pictures need all of them). Null otherwise: the engine's
// dialog asks, as with no mod.
async function planEnv($: EngineInterface): Promise<Env | null> {
@@ -189,21 +189,21 @@ export const register: Register = on => {
return next(e)
})
- // Typeahead for /md-preview arguments; the theme list is the last scan's.
+ // Typeahead for /iui arguments; the theme list is the last scan's.
on('prompt.autocomplete', async ($, e, next) => {
const got = await next(e)
- if (!/^\s*\/md-preview\s/.test(e.text)) return got
+ if (!/^\s*\/iui\s/.test(e.text)) return got
if (!S.themeChoices.length) await setUp($).catch(() => null)
const mine = commandSuggestions(e.text, e.token, e.start, { themes: S.themeChoices, active: S.look?.name ?? DEFAULT_THEME, size: S.size, width: S.width, height: S.height })
return mine.length ? { suggestions: [...got.suggestions, ...mine] } : got
})
- on('command.run', { command: 'md-preview' }, async ($, e) => {
+ on('command.run', { command: 'iui' }, async ($, e) => {
const asked = parseCommand(e.args)
if (asked.kind === 'on' || asked.kind === 'off') {
await update($, isOn, () => asked.kind === 'on')
await $.store.set('enabled', asked.kind === 'on')
- return { text: `md-preview is ${asked.kind}.` }
+ return { text: `Intelligent UI is ${asked.kind}.` }
}
if (asked.kind === 'size') {
// The epoch begins with the setting, so no row draws it with no epoch
@@ -211,7 +211,7 @@ export const register: Register = on => {
S.size = asked.percent
beginEpoch($)
await $.store.set('size', S.size)
- return { text: `md-preview draws text at ${S.size}% of the terminal's text size (100% matches it).` }
+ return { text: `Intelligent UI draws text at ${S.size}% of the terminal's text size (100% matches it).` }
}
if (asked.kind === 'width') {
if (asked.width === undefined) await setUp($).catch(() => null)
@@ -221,8 +221,8 @@ export const register: Register = on => {
await $.store.set('width', S.width)
}
const most = typeof S.width === 'number' && S.width > IMAGE_MAX_COLUMNS ? ` (a picture is ${IMAGE_MAX_COLUMNS} columns at most)` : ''
- const head = asked.width === undefined ? 'The most columns a picture takes' : 'md-preview pictures now take at most'
- return { text: `${head}: ${widthText(S.width)}${most}. Use /md-preview width <${MIN_WIDTH}-${MAX_WIDTH}> for a cap, or /md-preview width full (the default) for no cap.` }
+ const head = asked.width === undefined ? 'The most columns a picture takes' : 'Intelligent UI pictures now take at most'
+ return { text: `${head}: ${widthText(S.width)}${most}. Use /iui width <${MIN_WIDTH}-${MAX_WIDTH}> for a cap, or /iui width full (the default) for no cap.` }
}
if (asked.kind === 'height') {
if (asked.height === undefined) await setUp($).catch(() => null)
@@ -231,8 +231,8 @@ export const register: Register = on => {
beginEpoch($)
await $.store.set('height', S.height)
}
- const head = asked.height === undefined ? 'The most rows an image or a Typst drawing takes' : 'md-preview images and Typst drawings now take at most'
- return { text: `${head}: ${heightText(S.height)}. This applies to images (sent or pasted) and to Typst drawings in answers. Use /md-preview height half (the default), /md-preview height full, or /md-preview height <${MIN_HEIGHT}-${MAX_HEIGHT}> (never more than full).` }
+ const head = asked.height === undefined ? 'The most rows an image or a Typst drawing takes' : 'Intelligent UI images and Typst drawings now take at most'
+ return { text: `${head}: ${heightText(S.height)}. This applies to images (sent or pasted) and to Typst drawings in answers. Use /iui height half (the default), /iui height full, or /iui height <${MIN_HEIGHT}-${MAX_HEIGHT}> (never more than full).` }
}
if (asked.kind === 'setup') {
await setUp($).catch(() => null)
@@ -266,7 +266,7 @@ export const register: Register = on => {
beginEpoch($)
}
if (asked.name) await $.store.set('theme-name', chosen.name)
- const head = asked.name ? `md-preview uses the theme ${chosen.name}.\n` : ''
+ const head = asked.name ? `Intelligent UI uses the theme ${chosen.name}.\n` : ''
return { text: `${head}${themeListing(themes, problems, chosen.name, userThemesOf(ready.home))}` }
}
const state = (await read($, isOn)) ? 'on' : 'off'
@@ -279,15 +279,15 @@ export const register: Register = on => {
const terminal = ready.canDraw
? `this terminal draws pictures${ready.inline ? ' (over ssh, sent as bytes)' : ''}`
: 'Claude Code draws no pictures here (it does in kitty and Ghostty, in iTerm2 3.6+ and Rio 0.5.27+ with CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1, over ssh when TERM names kitty or Ghostty or with that variable; never in tmux, screen or a background session; not in WezTerm, Warp, Konsole or others), so answers stay text'
- return { text: `md-preview is ${state}, theme ${theme}, ${modeLine(S.theme, S.setting, S.settingRaw, S.host)}, text size ${S.size}%, width ${widthText(S.width)}, image and drawing height ${heightText(S.height)}, ${font}. ${typst}; ${terminal}.` }
+ return { text: `Intelligent UI is ${state}, theme ${theme}, ${modeLine(S.theme, S.setting, S.settingRaw, S.host)}, text size ${S.size}%, width ${widthText(S.width)}, image and drawing height ${heightText(S.height)}, ${font}. ${typst}; ${terminal}.` }
}
// The short state: what is set, and only the problems that keep pictures away.
const sized = (v: number | 'full' | 'half', unit: string) => (typeof v === 'number' ? `${v} ${unit}` : v)
- const lines = [`md-preview is ${state}: theme ${theme}, ${S.theme}, text ${S.size}%, width ${sized(S.width, 'columns')}, height ${sized(S.height, 'rows')}.`]
- if (S.setupNeeded) lines.push('In iTerm2, run /md-preview setup once to show pictures.')
+ const lines = [`Intelligent UI is ${state}: theme ${theme}, ${S.theme}, text ${S.size}%, width ${sized(S.width, 'columns')}, height ${sized(S.height, 'rows')}.`]
+ if (S.setupNeeded) lines.push('In iTerm2, run /iui setup once to show pictures.')
else if (!ready.canDraw) lines.push('This terminal shows no pictures, so answers stay text. Pictures show in kitty, Ghostty and iTerm2 3.6+.')
if (!ready.typst) lines.push('Typst is not installed, so answers stay text. Install it: brew install typst')
- lines.push('Change: /md-preview on | off | size | width | height | theme. More: /md-preview details')
+ lines.push('Change: /iui on | off | size | width | height | theme. More: /iui details')
return { text: bad + lines.join('\n') }
})
@@ -308,7 +308,7 @@ export const register: Register = on => {
if (!e.surfaces.includes('terminal') || !(await read($, isOn))) return composed
const ready = S.env ?? (await setUp($).catch(() => null))
if (!ready?.typst || !ready.canDraw) return composed
- return { sections: [...composed.sections, { id: 'md-preview:typst', text: TYPST_PROMPT, scope: 'session' as const }] }
+ return { sections: [...composed.sections, { id: 'intelligent-ui:typst', text: TYPST_PROMPT, scope: 'session' as const }] }
})
// A main-loop model request: its text blocks are final when the next block
@@ -319,7 +319,7 @@ export const register: Register = on => {
S.stepsLive++
let textIndex = -1
let isDone = false
- // Never let md-preview's own work break Claude's stream.
+ // Never let Intelligent UI's own work break Claude's stream.
const settleAll = () => {
try {
finalizeAll($)
@@ -463,7 +463,7 @@ export const register: Register = on => {
// The ExitPlanMode row, above the question: the engine's row, then the plan
// as pictures, through the answers' pipeline at an answer's width (the
- // edited text once edited in md-preview's flow). A rejected, aborted or
+ // edited text once edited in Intelligent UI's flow). A rejected, aborted or
// subagent call, and a plan that fails to compile, stay as the engine draws.
on('ui.render', { component: 'ToolUse', props: { tool: 'ExitPlanMode' } }, async ($, e, next) => {
const row = await next(e)
@@ -498,7 +498,7 @@ export const register: Register = on => {
return drawn ?? next(e)
})
- // One dim line above md-preview's own question (the dialog takes at most 12
+ // One dim line above the mod's own question (the dialog takes at most 12
// rows around it, so the plan is in the row above). Any other question
// stays as the engine draws it.
on('ui.render', { component: 'AskUserQuestion' }, async ($, e, next) => {
@@ -526,7 +526,7 @@ export const register: Register = on => {
}
}).catch(($, e, next) => next(e))
- // The main loop's ExitPlanMode: md-preview asks first (the engine shows its
+ // The main loop's ExitPlanMode: the mod asks first (the engine shows its
// dialog while PermissionRequest hooks run, so a question asked there waits
// behind it). The person's words deny the call (Claude revises the plan);
// a verdict waits for the PermissionRequest below, and is dropped once the
@@ -578,7 +578,7 @@ export const register: Register = on => {
return got
}).catch(($, e, next) => next(e))
- // The PermissionRequest of that call: md-preview's verdict at once (the
+ // The PermissionRequest of that call: Intelligent UI's verdict at once (the
// engine's dialog never shows), else the engine's flow.
on('classic.PermissionRequest', async ($, e, next) => {
if (e.tool_name !== 'ExitPlanMode' || e.agent_id || !S.planVerdict) return next(e)
diff --git a/outcomes/build.sh b/outcomes/build.sh
index a41df3f..544ece4 100755
--- a/outcomes/build.sh
+++ b/outcomes/build.sh
@@ -1,11 +1,11 @@
#!/bin/sh
-# Renders the sample answers with md-preview's own template, then frames them.
+# Renders the sample answers with the mod's own template, then frames them.
# Usage: outcomes/build.sh (needs typst 0.15)
#
# The template gets the inputs the mod gives it (hooks/lib/typst.ts runTypst,
# draw.tsx sizing/fontFit/alignFirstLine, answer.ts roomOf) for a terminal of
# COLS picture columns and ROWS rows, with CELL_W x CELL_H px cells (2x
-# Retina), MesloLGS NF as the terminal font and `/md-preview height` on half.
+# Retina), MesloLGS NF as the terminal font and `/iui height` on half.
# Only the PNG resolution (PPI) is higher than the mod's, for crisp images.
set -eu
here=$(cd "$(dirname "$0")" && pwd)
diff --git a/outcomes/frame.typ b/outcomes/frame.typ
index 8c3d1cd..b357725 100644
--- a/outcomes/frame.typ
+++ b/outcomes/frame.typ
@@ -1,4 +1,4 @@
-// Outcome frame: md-preview renders in terminal windows, with a headline.
+// Outcome frame: Intelligent UI renders in terminal windows, with a headline.
// One window: --input img=<abs png> --input mode=dark|light --input ask=..
// Hero (two): --input layout=hero --input img-dark=.. --input img-light=.. --input ask=..
// Both: --input title=.. (typst compile --root / frame.typ out.png)
@@ -20,7 +20,7 @@
})
// A terminal window with Claude Code in it: the header, the prompt, the
-// answer (the md-preview picture beside the bullet), the input box and the
+// answer (the Intelligent UI picture beside the bullet), the input box and the
// mode line. Colours are from a screenshot of Claude Code 2.1.301.
#let window(img, dark, ask) = {
let c = if dark { (
diff --git a/outcomes/samples/1-overview.md b/outcomes/samples/1-overview.md
index d9c6345..c790acd 100644
--- a/outcomes/samples/1-overview.md
+++ b/outcomes/samples/1-overview.md
@@ -4,7 +4,7 @@ Here is one answer with everything Intelligent UI draws:
## Real documents, not raw text
-Claude's answers arrive with **headings**, *emphasis*, `inline code`, [links](https://github.com/razorback16/claude-md-preview) and pictures like the one above.
+Claude's answers arrive with **headings**, *emphasis*, `inline code`, [links](https://github.com/razorback16/claude-intelligent-ui) and pictures like the one above.
| Element | You write | You see |
|:--|:--|:--:|
diff --git a/render/convert.typ b/render/convert.typ
index 7633cb1..cfd25b5 100644
--- a/render/convert.typ
+++ b/render/convert.typ
@@ -1,4 +1,4 @@
-// md-preview: makes a PNG of a JPEG or WebP (the engine's Image draws PNG
+// Intelligent UI: makes a PNG of a JPEG or WebP (the engine's Image draws PNG
// only). Compiled at 72 ppi, where 1 pt is 1 pixel.
//
// Inputs: f = the image's absolute path (with --root /); maxw, maxh = the
diff --git a/render/md.typ b/render/md.typ
index fc827b0..704933e 100644
--- a/render/md.typ
+++ b/render/md.typ
@@ -1,4 +1,4 @@
-// md-preview: draws Markdown segments like VS Code's Markdown preview
+// Intelligent UI: draws Markdown segments like VS Code's Markdown preview
// (the colours come from the theme). One segment = one page = one PNG.
//
// typst compile --root / --package-path <render>/packages --format png --ppi <ppi>
@@ -70,7 +70,7 @@
}
#let design-h = pt-in("design-h", room-h)
#let doc = if "doc" in inp { json(inp.doc) } else {
- (base: "", segments: ("*md-preview:* no `doc` input given.",))
+ (base: "", segments: ("*Intelligent UI:* no `doc` input given.",))
}
#let base = str(doc.at("base", default: ""))
#let allow = doc.at("images", default: none)
@@ -138,7 +138,7 @@
)
// ---------- page and text ----------
-#set document(title: "md-preview")
+#set document(title: "Intelligent UI")
#set page(width: page-w, height: auto, margin: (left: margin-left, right: margin-right, y: margin-y), fill: none)
// CSS-like line boxes: line-height 22px at 14px.
#set text(
diff --git a/render/theme.typ b/render/theme.typ
index 67c67a3..f9d6483 100644
--- a/render/theme.typ
+++ b/render/theme.typ
@@ -1,4 +1,4 @@
-// md-preview themes: loads the active theme and merges it over the
+// Intelligent UI themes: loads the active theme and merges it over the
// built-in `vscode` theme, so a user theme only lists what it changes.
//
// --input theme-dir=<absolute folder that holds theme.json> (optional)
diff --git a/render/themes/README.md b/render/themes/README.md
index 9e2dc85..89e33e3 100644
--- a/render/themes/README.md
+++ b/render/themes/README.md
@@ -8,7 +8,7 @@ A theme is a folder with a `theme.json`. Intelligent UI ships three:
| `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 |
-Your own themes go in `~/.claude/md-preview/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 `/md-preview theme <name>`.
+Your own themes go in `~/.claude/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>`.
## Merging
@@ -36,7 +36,7 @@ Example: pink inline code, rounder boxes.
| Key | vscode default | What it does |
|---|---|---|
-| `name`, `description`, `source` | | Shown by `/md-preview theme` |
+| `name`, `description`, `source` | | Shown by `/iui theme` |
| `syntax.dark`, `syntax.light` | `dark.tmTheme`, `light.tmTheme` | Code colours: a TextMate theme file in this folder. If you leave this out, the vscode files are used. If you name a file, it must exist. |
| `fonts.body` | SF Pro Text, Helvetica Neue, Helvetica, Arial, … | Body font list (first installed one wins, per character) |
| `fonts.code` | Menlo, SF Mono, DejaVu Sans Mono, … | Code font list |
diff --git a/tests/command.test.ts b/tests/command.test.ts
index 9e01ae7..cfaf16c 100644
--- a/tests/command.test.ts
+++ b/tests/command.test.ts
@@ -12,27 +12,27 @@ const at = (text: string) => {
}
test('the first word completes as a subcommand', () => {
- expect(at('/md-preview t').map(r => r.text)).toEqual(['theme'])
- expect(at('/md-preview w').map(r => r.text)).toEqual(['width'])
- expect(at('/md-preview h').map(r => r.text)).toEqual(['height'])
- expect(at('/md-preview o').map(r => r.text)).toEqual(['on', 'off'])
- expect(at('/md-preview S').map(r => r.text)).toEqual(['size', 'setup'])
- expect(at('/md-preview x')).toEqual([])
- expect(at('/md-preview t')[0]!.description).toBe('list the themes, or switch to one')
+ expect(at('/iui t').map(r => r.text)).toEqual(['theme'])
+ expect(at('/iui w').map(r => r.text)).toEqual(['width'])
+ expect(at('/iui h').map(r => r.text)).toEqual(['height'])
+ expect(at('/iui o').map(r => r.text)).toEqual(['on', 'off'])
+ expect(at('/iui S').map(r => r.text)).toEqual(['size', 'setup'])
+ expect(at('/iui x')).toEqual([])
+ expect(at('/iui t')[0]!.description).toBe('list the themes, or switch to one')
})
test('right after theme or size, rows hold the word and its argument', () => {
- const rows = at('/md-preview theme')
+ const rows = at('/iui theme')
expect(rows.map(r => r.text)).toEqual(['theme github-light', 'theme nord', 'theme vscode', 'theme vscode-modern'])
expect(rows.map(r => r.label)).toEqual(['github-light', 'nord', 'vscode', 'vscode-modern'])
expect(rows[3]!.description).toBe('built-in, active: default look')
expect(rows[1]!.description).toBe('user: my nord')
- expect(at('/md-preview size').map(r => r.text)).toContain('size 150')
- const widths = at('/md-preview width')
+ expect(at('/iui size').map(r => r.text)).toContain('size 150')
+ const widths = at('/iui width')
expect(widths.map(r => r.text)).toEqual(['width 80', 'width 100', 'width 120', 'width 160', 'width 200', 'width full'])
// full is the default; with no width given, it is current.
expect(widths.at(-1)!.description).toBe('current')
- const heights = at('/md-preview height')
+ const heights = at('/iui height')
expect(heights.map(r => r.text)).toEqual(['height half', 'height full', 'height 12', 'height 24', 'height 36'])
expect(heights.map(r => r.label)).toEqual(['half', 'full', '12 rows', '24 rows', '36 rows'])
// half is the default; with no height given, it is current.
@@ -41,27 +41,27 @@ test('right after theme or size, rows hold the word and its argument', () => {
})
test('a theme name or size completes after its word', () => {
- expect(at('/md-preview theme vs').map(r => r.text)).toEqual(['vscode', 'vscode-modern'])
- expect(at('/md-preview theme N').map(r => r.text)).toEqual(['nord'])
- expect(at('/md-preview size 1').map(r => r.text)).toEqual(['100', '110', '120', '125', '150', '175'])
- expect(at('/md-preview size 10')[0]!.description).toBe('current')
- expect(at('/md-preview theme nord extra')).toEqual([])
- expect(at('/md-preview width 1').map(r => r.text)).toEqual(['100', '120', '160'])
- expect(at('/md-preview width f').map(r => r.label)).toEqual(['full'])
+ expect(at('/iui theme vs').map(r => r.text)).toEqual(['vscode', 'vscode-modern'])
+ expect(at('/iui theme N').map(r => r.text)).toEqual(['nord'])
+ expect(at('/iui size 1').map(r => r.text)).toEqual(['100', '110', '120', '125', '150', '175'])
+ expect(at('/iui size 10')[0]!.description).toBe('current')
+ expect(at('/iui theme nord extra')).toEqual([])
+ expect(at('/iui width 1').map(r => r.text)).toEqual(['100', '120', '160'])
+ expect(at('/iui width f').map(r => r.label)).toEqual(['full'])
const set = (text: string) => commandSuggestions(text, /\S+$/.exec(text)![0], text.lastIndexOf(' ') + 1, { ...o, width: 160 })
- expect(set('/md-preview width 16')[0]!.description).toBe('current')
- expect(set('/md-preview width f')[0]!.description).toBe('the default')
- expect(at('/md-preview height f').map(r => r.text)).toEqual(['full'])
- expect(at('/md-preview height 2').map(r => r.text)).toEqual(['24'])
+ expect(set('/iui width 16')[0]!.description).toBe('current')
+ expect(set('/iui width f')[0]!.description).toBe('the default')
+ expect(at('/iui height f').map(r => r.text)).toEqual(['full'])
+ expect(at('/iui height 2').map(r => r.text)).toEqual(['24'])
const tall = (text: string) => commandSuggestions(text, /\S+$/.exec(text)![0], text.lastIndexOf(' ') + 1, { ...o, height: 24 })
- expect(tall('/md-preview height 2')[0]!.description).toBe('current')
- expect(tall('/md-preview height h')[0]!.description).toBe('the default: half the terminal')
+ expect(tall('/iui height 2')[0]!.description).toBe('current')
+ expect(tall('/iui height h')[0]!.description).toBe('the default: half the terminal')
})
test('other prompts and the command name itself get no rows', () => {
- expect(at('/md-preview')).toEqual([])
- expect(at('/md-previewx t')).toEqual([])
- expect(at('tell me about /md-preview t')).toEqual([])
+ expect(at('/iui')).toEqual([])
+ expect(at('/iuix t')).toEqual([])
+ expect(at('tell me about /iui t')).toEqual([])
expect(at('/other theme')).toEqual([])
})
@@ -74,7 +74,7 @@ test('the hook adds theme rows from the themes found at start', async ($, on) =>
e.path.endsWith('/render/themes') ? { value: ['vscode', 'vscode-modern', 'nord'].map(name => ({ name, kind: 'dir', size: 0, mtimeMs: 0, isLink: false })) } : next(e))
on('fs.read', async ($: any, e: any, next: any) =>
/\/render\/themes\/[^/]+\/theme\.json$/.test(e.path) ? { value: '{"description":"d"}' } : next(e))
- const text = '/md-preview theme n'
+ const text = '/iui theme n'
const got = await ($ as any).prompt.autocomplete({ text, cursor: text.length, token: 'n', start: text.length - 1 })
expect(got.suggestions.map((r: any) => r.text)).toEqual(['nord'])
const other = await ($ as any).prompt.autocomplete({ text: 'hello', cursor: 5, token: 'hello', start: 0 })
diff --git a/tests/draw.test.ts b/tests/draw.test.ts
index 51a8205..02a0823 100644
--- a/tests/draw.test.ts
+++ b/tests/draw.test.ts
@@ -8,14 +8,14 @@ import {
const base = { program: '', term: 'xterm-256color', kitty: false, tmux: false, ssh: false, background: false, engineForced: false, modForced: false }
-test('tmux and screen draw no pictures, even with the engine forced; only MD_PREVIEW_FORCE tries', () => {
+test('tmux and screen draw no pictures, even with the engine forced; only IUI_FORCE tries', () => {
expect(canDrawIn({ ...base, term: 'xterm-kitty', tmux: true })).toBe(false)
expect(canDrawIn({ ...base, program: 'ghostty', tmux: true, engineForced: true })).toBe(false)
expect(canDrawIn({ ...base, term: 'screen-256color', tmux: true, engineForced: true })).toBe(false)
expect(canDrawIn({ ...base, tmux: true, modForced: true })).toBe(true)
})
-test('a background session never draws pictures, not even with MD_PREVIEW_FORCE', () => {
+test('a background session never draws pictures, not even with IUI_FORCE', () => {
expect(canDrawIn({ ...base, program: 'ghostty', background: true })).toBe(false)
expect(canDrawIn({ ...base, term: 'xterm-kitty', background: true, engineForced: true, modForced: true })).toBe(false)
})
@@ -78,13 +78,13 @@ const PNG = 'iVBORw0KGgoAAAANSUhEUgAABkAAAABACAYAAAAAAAAA'
// With no tty, the watcher exits 1 at once.
type Tty = { line?: string; watcher?: number; metrics?: (n: number) => string }
-// The PID wrapper md-preview runs Typst through (typst.ts wrapPid).
+// The PID wrapper Intelligent UI runs Typst through (typst.ts wrapPid).
const WRAP = 'echo $$; exec "$@"'
-// `stored`: what md-preview kept in its store before (a setting); `design`:
+// `stored`: what Intelligent UI kept in its store before (a setting); `design`:
// the text of every design file (none: they are missing).
function world(on: any, vars: Record<string, string>, head = HEAD, stored: Record<string, unknown> = {}, design?: string, tty?: Tty) {
- // md-preview's store in memory (as mock.store), and its writes by key.
+ // Intelligent UI's store in memory (as mock.store), and its writes by key.
const store = new Map(Object.entries(stored))
const kept: Record<string, unknown> = {}
on('store.get', async ($: any, e: any) => ({ value: store.get(e.key) }))
@@ -116,7 +116,7 @@ function world(on: any, vars: Record<string, string>, head = HEAD, stored: Recor
const logs: string[] = []
const killers = new Map<string, () => void>()
let pids = 4242
- // Every call md-preview makes to a process or a file (counted by kind).
+ // Every call Intelligent UI makes to a process or a file (counted by kind).
const calls: string[] = []
// The tty: its size reads (each one's time), and a new size.
const sizeReads: number[] = []
@@ -175,7 +175,7 @@ function world(on: any, vars: Record<string, string>, head = HEAD, stored: Recor
logs.push(e.init?.stdin ?? '')
return ok('')
}
- if (/md-preview-/.test(cmd)) return ok('/c\nDarwin\n')
+ if (/intelligent-ui-/.test(cmd)) return ok('/c\nDarwin\n')
if (cmd.includes('command -v typst')) return ok('/usr/bin/typst\n')
if (argv[0] === '/usr/bin/typst' && argv[1] === 'eval') return ok('{}')
if (cmd.includes('od -An')) return ok(`${head}\n@\n`)
@@ -215,7 +215,7 @@ function world(on: any, vars: Record<string, string>, head = HEAD, stored: Recor
const ENGINE = { type: 'Text', props: {}, children: ['engine drawing'] }
const message = (requestId: string, text: string) =>
({
- plugin: 'md-preview', surface: 'terminal', component: 'AssistantMessage', requestId,
+ plugin: 'intelligent-ui', surface: 'terminal', component: 'AssistantMessage', requestId,
props: { text, isFirstOfReply: true }, viewport: { columns: 100, rows: 40 },
}) as any
const props = (text: string) => ({ text, isFirstOfReply: true }) as any
@@ -224,7 +224,7 @@ const images = (tree: any): any[] =>
test('over ssh in kitty, a page goes as PNG bytes, read once', async ($, on) => {
const { clock, reads } = world(on, { SSH_CONNECTION: '10.0.0.2 50000 10.0.0.1 22', TERM: 'xterm-kitty' })
- const ran = await $.command.run({ command: 'md-preview', args: 'details' } as any)
+ const ran = await $.command.run({ command: 'iui', args: 'details' } as any)
expect(ran.text).toContain('over ssh, sent as bytes')
const ui = await $.ui.mount(message('ssh-1', 'Some **bold** text.'))
await clock.settle()
@@ -239,7 +239,7 @@ test('over ssh in kitty, a page goes as PNG bytes, read once', async ($, on) =>
test('over ssh, a page over 4096 px tall draws as text', async ($, on) => {
const { clock, reads } = world(on, { SSH_TTY: '/dev/pts/1', TERM: 'xterm-ghostty' }, TALL)
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const ui = await $.ui.mount(message('ssh-2', 'Some **bold** text.'))
await clock.settle()
await ui.redraw(props('Some **bold** text.'))
@@ -249,7 +249,7 @@ test('over ssh, a page over 4096 px tall draws as text', async ($, on) => {
test('locally, a page goes as a file name', async ($, on) => {
const { clock, reads } = world(on, { TERM: 'xterm-kitty' })
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const ui = await $.ui.mount(message('local-1', 'Some **bold** text.'))
await clock.settle()
await ui.redraw(props('Some **bold** text.'))
@@ -261,7 +261,7 @@ test('locally, a page goes as a file name', async ($, on) => {
test('in tmux with the engine forced, answers stay text', async ($, on) => {
const { clock } = world(on, { TMUX: '/tmp/tmux-501/default,1,0', TERM: 'tmux-256color', CLAUDE_CODE_FORCE_TERMINAL_IMAGES: '1' })
- const ran = await $.command.run({ command: 'md-preview', args: '' } as any)
+ const ran = await $.command.run({ command: 'iui', args: '' } as any)
expect(ran.text).toContain('This terminal shows no pictures')
const ui = await $.ui.mount(message('tmux-1', 'Some **bold** text.'))
await clock.settle()
@@ -275,14 +275,14 @@ const wide = (requestId: string, text: string) => ({ ...message(requestId, text)
test('a kept width caps the pictures; width full draws at the terminal width once its epoch commits, 255 columns at most', async ($, on) => {
const { clock, kept } = world(on, { TERM: 'xterm-kitty' }, HEAD, { width: 160 })
- const ran = await $.command.run({ command: 'md-preview', args: '' } as any)
+ const ran = await $.command.run({ command: 'iui', args: '' } as any)
expect(ran.text).toContain('width 160 columns')
const ui = await $.ui.mount(wide('w-1', 'Some **bold** text.'))
await clock.settle()
await ui.redraw(props('Some **bold** text.'))
const [first] = images(await ui.drawn())
expect(first.props.columns).toBe(160)
- const set = await $.command.run({ command: 'md-preview', args: 'width full' } as any)
+ const set = await $.command.run({ command: 'iui', args: 'width full' } as any)
expect(set.text).toContain('full (the terminal width)')
expect(kept.width).toBe('full')
// Another key (the columns are in it): compiled again, then drawn wider
@@ -297,12 +297,12 @@ test('a kept width caps the pictures; width full draws at the terminal width onc
test('width with no value shows it; a bad value is refused; a bad kept value is the default', async ($, on) => {
const { kept } = world(on, { TERM: 'xterm-kitty' }, HEAD, { width: 20 })
- const shown = await $.command.run({ command: 'md-preview', args: 'width' } as any)
+ const shown = await $.command.run({ command: 'iui', args: 'width' } as any)
expect(shown.text).toContain('The most columns a picture takes: full (the terminal width)')
- const bad = await $.command.run({ command: 'md-preview', args: 'width 39' } as any)
+ const bad = await $.command.run({ command: 'iui', args: 'width 39' } as any)
expect(bad.text).toContain('Not understood: "width 39"')
expect(kept.width).toBe(undefined)
- const set = await $.command.run({ command: 'md-preview', args: 'width 400' } as any)
+ const set = await $.command.run({ command: 'iui', args: 'width 400' } as any)
expect(set.text).toContain('400 columns (a picture is 255 columns at most)')
expect(kept.width).toBe(400)
})
@@ -311,7 +311,7 @@ test('width with no value shows it; a bad value is refused; a bad kept value is
test('while a new size compiles, the old picture draws at its own box, never stretched', async ($, on) => {
const { clock, hold, release } = world(on, { TERM: 'xterm-kitty' }, HEAD, { width: 160 })
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const ui = await $.ui.mount(wide('box-1', 'Some **bold** text.'))
await clock.settle()
await ui.redraw(props('Some **bold** text.'))
@@ -319,7 +319,7 @@ test('while a new size compiles, the old picture draws at its own box, never str
expect(first.props.columns).toBe(160)
expect(first.props.source.generation).toBe(undefined)
hold()
- await $.command.run({ command: 'md-preview', args: 'width full' } as any)
+ await $.command.run({ command: 'iui', args: 'width full' } as any)
await clock.settle()
await clock.advance(COMMIT_MIN_MS)
await ui.redraw(props('Some **bold** text.'))
@@ -337,7 +337,7 @@ test('while a new size compiles, the old picture draws at its own box, never str
test('the pages column never shrinks: the layout never squeezes a page (fitBox sizes it)', async ($, on) => {
const { clock } = world(on, { TERM: 'xterm-kitty' })
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const ui = await $.ui.mount(message('shrink-1', 'Some **bold** text.'))
await clock.settle()
await ui.redraw(props('Some **bold** text.'))
@@ -355,7 +355,7 @@ const sized = (requestId: string, text: string, columns: number, rows = 40) => (
test('after the viewport gets narrower, nothing compiles until it is quiet; meanwhile the old picture fits the room, its aspect kept', async ($, on) => {
const { clock, compiles } = world(on, { TERM: 'xterm-kitty' }, HEAD, {}, undefined, { line: TTY })
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const ui = await $.ui.mount(sized('f-1', 'Some **bold** text.', 120))
await clock.settle()
await ui.redraw(props('Some **bold** text.'))
@@ -390,7 +390,7 @@ const bulletOf = (tree: any): number => tree.children.find((c: any) => c.type ==
test('an old page wider than the room after a narrowing draws at the room, its aspect kept and its bullet scaled', async ($, on) => {
const { clock, hold } = world(on, { TERM: 'xterm-kitty' }, HEAD, {}, undefined, { line: '40 213 3408 1360' })
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const text = '# A title\n\nSome **bold** text.'
const ui = await $.ui.mount(sized('room-1', text, 213))
await clock.settle()
@@ -419,7 +419,7 @@ test('an old page wider than the room after a narrowing draws at the room, its a
test('an old page narrower than the room draws at its own box', async ($, on) => {
const { clock, hold } = world(on, { TERM: 'xterm-kitty' }, HEAD, { width: 160 })
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const ui = await $.ui.mount(wide('own-1', 'Some **bold** text.'))
await clock.settle()
await ui.redraw(props('Some **bold** text.'))
@@ -435,7 +435,7 @@ test('an old page narrower than the room draws at its own box', async ($, on) =>
test('the row memo misses when the viewport columns change, and hits when only onScreen changes', async ($, on) => {
const { clock, calls } = world(on, { TERM: 'xterm-kitty' })
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const ui = await $.ui.mount(message('memo-1', 'Some **bold** text.'))
await clock.settle()
await ui.redraw(props('Some **bold** text.'))
@@ -458,31 +458,31 @@ test('the row memo misses when the viewport columns change, and hits when only o
// The epoch trace lines a size change writes to the debug log.
async function traceOf($: any, on: any, vars: Record<string, string>): Promise<string[]> {
const { clock, logs } = world(on, vars)
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const ui = await $.ui.mount(message('trace-1', 'Some **bold** text.'))
await clock.settle()
await ui.redraw(props('Some **bold** text.'))
- await $.command.run({ command: 'md-preview', args: 'size 120' } as any)
+ await $.command.run({ command: 'iui', args: 'size 120' } as any)
await ui.redraw(props('Some **bold** text.'))
await clock.settle()
await clock.advance(COMMIT_MIN_MS)
return logs.filter(l => / epoch \d+ /.test(l))
}
-test('with MD_PREVIEW_DEBUG, an epoch writes one trace line at its begin and one at its commit', async ($, on) => {
- const trace = await traceOf($, on, { TERM: 'xterm-kitty', MD_PREVIEW_DEBUG: '1' })
+test('with IUI_DEBUG, an epoch writes one trace line at its begin and one at its commit', async ($, on) => {
+ const trace = await traceOf($, on, { TERM: 'xterm-kitty', IUI_DEBUG: '1' })
expect(trace.length).toBe(2)
expect(trace[0]).toMatch(/epoch \d+ begin: target 100x40 cell \d+(\.\d+)?x\d+(\.\d+)?; cancelled 0 running, dropped 0 queued/)
expect(trace[1]).toMatch(/epoch \d+ commit after \d+ ms \(ready\): 1 jobs queued, 0 waiting, 0 running, 0 converting/)
})
-test('with no MD_PREVIEW_DEBUG, an epoch writes no trace line', async ($, on) => {
+test('with no IUI_DEBUG, an epoch writes no trace line', async ($, on) => {
expect(await traceOf($, on, { TERM: 'xterm-kitty' })).toEqual([])
})
test('a drag (5 watcher lines in a row) compiles nothing and reads no tty until it is quiet, then once', async ($, on) => {
const { clock, compiles, emit, sizeReads } = world(on, { TERM: 'xterm-kitty' }, HEAD, {}, undefined, { line: TTY })
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const ui = await $.ui.mount(sized('drag-1', 'Some **bold** text.', 200))
await clock.settle()
await ui.redraw(props('Some **bold** text.'))
@@ -515,7 +515,7 @@ test('two rows, one compile held: both keep the old picture, then both swap in o
if (e.key === 'done') redraws++
return next(e)
})
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const a = await $.ui.mount(wide('two-a', 'First **answer**.'))
const b = await $.ui.mount(wide('two-b', 'Second **answer**.'))
await clock.settle()
@@ -526,7 +526,7 @@ test('two rows, one compile held: both keep the old picture, then both swap in o
expect(compiles.length).toBe(2)
redraws = 0
hold('Second')
- await $.command.run({ command: 'md-preview', args: 'width full' } as any)
+ await $.command.run({ command: 'iui', args: 'width full' } as any)
await clock.settle()
await clock.advance(COMMIT_MIN_MS)
await a.redraw(props('First **answer**.'))
@@ -549,7 +549,7 @@ test('two rows, one compile held: both keep the old picture, then both swap in o
test('a redraw with a new onScreen makes no file or process call and draws the same picture', async ($, on) => {
const { clock, calls } = world(on, { TERM: 'xterm-kitty' })
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const ui = await $.ui.mount(message('scroll-1', 'Some **bold** text.'))
await clock.settle()
await ui.redraw(props('Some **bold** text.'))
@@ -564,7 +564,7 @@ test('a redraw with a new onScreen makes no file or process call and draws the s
test('a font size change with the same columns compiles once, with a new key', async ($, on) => {
const { clock, compiles, emit } = world(on, { TERM: 'xterm-kitty' }, HEAD, {}, undefined, { line: TTY })
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const ui = await $.ui.mount(sized('f-2', 'Some **bold** text.', 120))
await clock.settle()
await ui.redraw(props('Some **bold** text.'))
@@ -590,7 +590,7 @@ test('a font size change with the same columns compiles once, with a new key', a
test('a font size change that changes the font metrics is still one compile wave, with the new metrics', async ($, on) => {
const other = '{"term":null,"menlo":{"adv":0.6,"xh":0.5,"avg":0.6},"body":{"adv":0.6,"xh":0.5,"avg":0.5}}'
const { clock, compiles, emit } = world(on, { TERM: 'xterm-kitty' }, HEAD, {}, undefined, { line: TTY, metrics: n => (n === 1 ? '{}' : other) })
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const ui = await $.ui.mount(sized('f-3', 'Some **bold** text.', 120))
await clock.settle()
await ui.redraw(props('Some **bold** text.'))
@@ -607,7 +607,7 @@ test('a font size change that changes the font metrics is still one compile wave
test('a height change only compiles a message with a Typst block again, not a plain one', async ($, on) => {
const { clock, compiles, emit } = world(on, { TERM: 'xterm-kitty' }, HEAD, {}, undefined, { line: TTY })
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const diagram = await $.ui.mount(sized('h-1', DIAGRAM, 120))
const plain = await $.ui.mount(sized('h-2', 'Some **bold** text.', 120))
await clock.settle()
@@ -628,7 +628,7 @@ test('a height change only compiles a message with a Typst block again, not a pl
test('a watcher that exits 1 (no tty) starts no reads', async ($, on) => {
const { clock, sizeReads } = world(on, { TERM: 'xterm-kitty' }, HEAD, {}, undefined, { watcher: 1 })
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
await clock.advance(30000)
expect(sizeReads.length).toBe(1)
})
@@ -639,7 +639,7 @@ const DIAGRAM = 'A plot:\n\n```typst\n#rect(width: theme.width, height: theme.he
test('a first render of a diagram: the design is the space now (factor 1), kept once the compile ends', async ($, on) => {
const { clock, compiles, files } = world(on, { TERM: 'xterm-kitty' })
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const ui = await $.ui.mount(message('room-1', DIAGRAM))
await clock.settle()
await ui.redraw(props(DIAGRAM))
@@ -661,7 +661,7 @@ test('a first render of a diagram: the design is the space now (factor 1), kept
test('a first render at any width sends design-w equal to width (factor exactly 1)', async ($, on) => {
const { clock, compiles } = world(on, { TERM: 'xterm-kitty' })
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
for (const [i, columns] of [117, 83, 251].entries()) {
// A plain row settles the new viewport first (it has no design).
const settle = await $.ui.mount({ ...message(`room-pre-${i}`, `Plain ${i}.`), viewport: { columns, rows: 37 } })
@@ -681,7 +681,7 @@ test('a first render at any width sends design-w equal to width (factor exactly
test('a resize while the first compile runs: the compile is killed, the next uses the same design, one design file', async ($, on) => {
const { clock, compiles, files, hold, release, kills } = world(on, { TERM: 'xterm-kitty' })
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
hold()
const ui = await $.ui.mount(sized('race-1', DIAGRAM, 100))
await clock.settle()
@@ -707,7 +707,7 @@ test('a resize while the first compile runs: the compile is killed, the next use
test('a diagram with a kept design scales from it, and the design is not written again', async ($, on) => {
const { clock, compiles, files } = world(on, { TERM: 'xterm-kitty' }, HEAD, {}, '500 200')
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const ui = await $.ui.mount(message('room-3', DIAGRAM))
await clock.settle()
await ui.redraw(props(DIAGRAM))
diff --git a/tests/images.test.ts b/tests/images.test.ts
index 29efb53..981d9fe 100644
--- a/tests/images.test.ts
+++ b/tests/images.test.ts
@@ -164,14 +164,14 @@ test('the [Image #N] marks of a prompt, each once', () => {
})
test('the pasted-image path follows Claude Code folder names', () => {
- expect(projectSlug('/Users/subhagato/Development/apps/claude-md-preview')).toBe('-Users-subhagato-Development-apps-claude-md-preview')
+ expect(projectSlug('/Users/subhagato/Development/apps/claude-intelligent-ui')).toBe('-Users-subhagato-Development-apps-claude-intelligent-ui')
expect(projectSlug('/home/me/my_app.v2')).toBe('-home-me-my-app-v2')
expect(claudeTmpOf({ uid: '501\n', isMac: true })).toBe('/private/tmp/claude-501')
expect(claudeTmpOf({ uid: '1000', isMac: false })).toBe('/tmp/claude-1000')
expect(claudeTmpOf({ tmpdir: '/scratch/', uid: '1000', isMac: false })).toBe('/scratch/claude-1000')
expect(claudeTmpOf({ uid: '', isMac: true })).toBe('')
- const dir = pasteDirOf('/private/tmp/claude-501', '/Users/subhagato/Development/apps/claude-md-preview', 'f8bb4b84-0e51-456a-9e49-8e5db49500ae')
- expect(pastedImagePath(dir, 5)).toBe('/private/tmp/claude-501/-Users-subhagato-Development-apps-claude-md-preview/f8bb4b84-0e51-456a-9e49-8e5db49500ae/images/5.png')
+ const dir = pasteDirOf('/private/tmp/claude-501', '/Users/subhagato/Development/apps/claude-intelligent-ui', 'f8bb4b84-0e51-456a-9e49-8e5db49500ae')
+ expect(pastedImagePath(dir, 5)).toBe('/private/tmp/claude-501/-Users-subhagato-Development-apps-claude-intelligent-ui/f8bb4b84-0e51-456a-9e49-8e5db49500ae/images/5.png')
})
// ---- The render hooks -------------------------------------------------------
@@ -201,7 +201,7 @@ const TALL = '89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 02 80 00 00
// ends only when this settles.
function world(on: any, o: {
vars?: Record<string, string>
- // What md-preview kept in its store before (a setting).
+ // What Intelligent UI kept in its store before (a setting).
stored?: Record<string, unknown>
files?: Record<string, string>
texts?: Record<string, string>
@@ -216,7 +216,7 @@ function world(on: any, o: {
holdRun?: { at: number; until: Promise<void> }
holdCompile?: Promise<void>
} = {}) {
- // md-preview's store in memory (as mock.store), and its writes by key;
+ // Intelligent UI's store in memory (as mock.store), and its writes by key;
// `redrawsAt`: by key, the `done` writes (redraws) made when its write ended.
const store = new Map(Object.entries(o.stored ?? {}))
const kept: Record<string, unknown> = {}
@@ -257,7 +257,7 @@ function world(on: any, o: {
w.done()
}
}
- // The children md-preview spawns: the Frame watcher (it exits 1: no tty)
+ // The children Intelligent UI spawns: the Frame watcher (it exits 1: no tty)
// and a Markdown compile through the PID wrapper (typst.ts wrapPid).
let pids = 4242
on('process.spawn', async function* ($: any, e: any) {
@@ -275,7 +275,7 @@ function world(on: any, o: {
const argv: string[] = e.argv
const cmd = argv.join(' ')
if (argv[0] === 'kill') return ok('')
- if (/md-preview-/.test(cmd)) return ok('/c\nDarwin\n')
+ if (/intelligent-ui-/.test(cmd)) return ok('/c\nDarwin\n')
if (argv[0] === 'id' && argv[1] === '-u') return ok('501\n')
if (cmd.includes('command -v typst')) return o.typst ? ok('/usr/bin/typst\n') : ok('', 1)
if (argv[0] === '/usr/bin/typst' && argv[1] === 'eval') return ok('{}')
@@ -342,7 +342,7 @@ function world(on: any, o: {
const sent = (output: unknown, isErrored = false, id = 'tu-1') =>
({
- plugin: 'md-preview', surface: 'terminal', component: 'ToolResult', requestId: id,
+ plugin: 'intelligent-ui', surface: 'terminal', component: 'ToolResult', requestId: id,
props: { tool_use_id: id, tool: 'SendUserFile', output, isErrored }, viewport: { columns: 100, rows: 40 },
}) as any
const attach = (path: string, isImage = true) => ({ attachments: [{ path, size: 1000, isImage, ...(isImage ? { media_type: 'image/png' } : {}) }] })
@@ -350,13 +350,13 @@ const attach = (path: string, isImage = true) => ({ attachments: [{ path, size:
const attachAll = (...paths: string[]) => ({ attachments: paths.map(path => ({ path, size: 1000, isImage: /\.(png|jpe?g|webp)$/i.test(path) })) })
const prompt = (text: string, origin: any = { kind: 'composer' }, id = 'u-1') =>
({
- plugin: 'md-preview', surface: 'terminal', component: 'UserMessage', requestId: id,
+ plugin: 'intelligent-ui', surface: 'terminal', component: 'UserMessage', requestId: id,
props: { text, origin, isExpanded: true }, viewport: { columns: 100, rows: 40 },
}) as any
const images = (tree: any): any[] =>
tree && typeof tree === 'object' ? [...(tree.type === 'Image' ? [tree] : []), ...(tree.children ?? []).flatMap(images)] : []
// Sets the mod up (as the first answer would) before a row draws.
-const ready = ($: any) => $.command.run({ command: 'md-preview', args: '' } as any)
+const ready = ($: any) => $.command.run({ command: 'iui', args: '' } as any)
test('a PNG Claude sends draws under its row, at its own size', async ($, on) => {
const { heads } = world(on, { files: { '/t/icon.png': HEAD } })
@@ -576,7 +576,7 @@ test('the same Markdown in two folders compiles twice; an answer still uses the
await a.redraw(sent(attachAll('/t/a/n.md'), false, 'tu-a').props)
await b.redraw(sent(attachAll('/t/b/n.md'), false, 'tu-b').props)
expect(images(await a.drawn())[0].props.source.file).not.toBe(images(await b.drawn())[0].props.source.file)
- const answer = { plugin: 'md-preview', surface: 'terminal', component: 'AssistantMessage', requestId: 'r-1', props: { text: '# Same', isFirstOfReply: true }, viewport: { columns: 100, rows: 40 } } as any
+ const answer = { plugin: 'intelligent-ui', surface: 'terminal', component: 'AssistantMessage', requestId: 'r-1', props: { text: '# Same', isFirstOfReply: true }, viewport: { columns: 100, rows: 40 } } as any
await $.ui.mount(answer)
await clock.settle()
expect(docs.map(d => d.base)).toEqual(['/t/a', '/t/b', '/w/app'])
@@ -681,7 +681,7 @@ test('a Markdown file is read again only when its stat changes, seen at the next
await clock.settle()
expect(reads).toEqual(['/t/n.md'])
// A refresh (here a setting) draws the row anew: the new stat is seen.
- await $.command.run({ command: 'md-preview', args: 'size 100' } as any)
+ await $.command.run({ command: 'iui', args: 'size 100' } as any)
await clock.settle()
await ui.redraw(sent(attachAll('/t/n.md')).props)
await clock.settle()
@@ -731,10 +731,10 @@ test('a message from another agent or a notification is not changed', async ($,
}
})
-test('with md-preview off, rows stay as they are', async ($, on) => {
+test('with Intelligent UI off, rows stay as they are', async ($, on) => {
world(on, { files: { '/t/icon.png': HEAD, [`${PASTED}/5.png`]: HEAD }, dirs: [PASTED] })
await ready($)
- await $.command.run({ command: 'md-preview', args: 'off' } as any)
+ await $.command.run({ command: 'iui', args: 'off' } as any)
expect(await (await $.ui.mount(sent(attach('/t/icon.png')))).drawn()).toMatchObject(ENGINE)
expect(await (await $.ui.mount(prompt('[Image #5] hi'))).drawn()).toMatchObject(ENGINE)
})
@@ -757,7 +757,7 @@ test('a kept height caps sent and pasted images; height full draws them taller a
expect(images(await ui.drawn())[0].props.rows).toBe(12)
const pasted = await $.ui.mount(prompt('[Image #5] tall'))
expect(images(await pasted.drawn())[0].props.rows).toBe(12)
- const set = await $.command.run({ command: 'md-preview', args: 'height full' } as any)
+ const set = await $.command.run({ command: 'iui', args: 'height full' } as any)
expect(set.text).toContain('full (the terminal height less 16 rows)')
expect(kept.height).toBe('full')
// The epoch is open: the box on screen stays.
@@ -770,13 +770,13 @@ test('a kept height caps sent and pasted images; height full draws them taller a
await pasted.redraw(prompt('[Image #5] tall').props)
expect(images(await pasted.drawn())[0].props.rows).toBe(24)
// A number is never more than full.
- await $.command.run({ command: 'md-preview', args: 'height 36' } as any)
+ await $.command.run({ command: 'iui', args: 'height 36' } as any)
expect(kept.height).toBe(36)
await clock.advance(COMMIT_MIN_MS)
await ui.redraw(sent(attach('/t/tall.png')).props)
expect(images(await ui.drawn())[0].props.rows).toBe(24)
// Half, the default: half of 40 rows.
- await $.command.run({ command: 'md-preview', args: 'height half' } as any)
+ await $.command.run({ command: 'iui', args: 'height half' } as any)
await clock.advance(COMMIT_MIN_MS)
await ui.redraw(sent(attach('/t/tall.png')).props)
expect(images(await ui.drawn())[0].props.rows).toBe(20)
@@ -792,8 +792,8 @@ test('a height command while an epoch is open keeps the image box until the comm
const ui = await $.ui.mount(sent(output))
expect(images(await ui.drawn()).map(i => i.props.rows)).toEqual([12, 10])
// An epoch is open (a new text size), then the height changes.
- await $.command.run({ command: 'md-preview', args: 'size 90' } as any)
- await $.command.run({ command: 'md-preview', args: 'height full' } as any)
+ await $.command.run({ command: 'iui', args: 'size 90' } as any)
+ await $.command.run({ command: 'iui', args: 'height full' } as any)
await ui.redraw(sent(output).props)
expect(images(await ui.drawn())[0].props.rows).toBe(12)
expect(converts[1]).toContain('maxh=768')
@@ -815,7 +815,7 @@ test('in an open epoch a JPEG with no PNG made in this load (a resumed session)
const until = new Promise<void>(done => (release = done))
const { clock, converts } = world(on, { typst: true, holdRun: { at: 1, until }, files: { '/t/photo.jpg': JPEG } })
await ready($)
- await $.command.run({ command: 'md-preview', args: 'height full' } as any)
+ await $.command.run({ command: 'iui', args: 'height full' } as any)
const ui = await $.ui.mount(sent(attachAll('/t/photo.jpg')))
// Nothing under the row for it until the commit; only the target's PNG is made.
expect(images(await ui.drawn()).length).toBe(0)
@@ -836,7 +836,7 @@ test('a size, width or height command begins its epoch (one redraw) before the s
await ready($)
for (const [args, key] of [['size 90', 'size'], ['width 80', 'width'], ['height full', 'height']] as const) {
const before = redraws()
- await $.command.run({ command: 'md-preview', args } as any)
+ await $.command.run({ command: 'iui', args } as any)
expect(redrawsAt[key]).toBe(before + 1)
}
})
@@ -849,7 +849,7 @@ test('a new height makes a new PNG of a JPEG in the background; the last one dra
const ui = await $.ui.mount(sent(attachAll('/t/photo.jpg')))
const first = images(await ui.drawn())[0].props.source.file
expect(converts[0]).toContain('maxh=640')
- await $.command.run({ command: 'md-preview', args: 'height full' } as any)
+ await $.command.run({ command: 'iui', args: 'height full' } as any)
await ui.redraw(sent(attachAll('/t/photo.jpg')).props)
expect(images(await ui.drawn())[0].props.source.file).toBe(first)
// 24 rows of 32 px.
@@ -866,7 +866,7 @@ test('a background run that ends while the row draws still draws its PNG', async
await ready($)
const ui = await $.ui.mount(sent(attachAll('/t/photo.jpg')))
const first = images(await ui.drawn())[0].props.source.file
- await $.command.run({ command: 'md-preview', args: 'height full' } as any)
+ await $.command.run({ command: 'iui', args: 'height full' } as any)
await ui.redraw(sent(attachAll('/t/photo.jpg')).props)
expect(converts.length).toBe(2)
await clock.settle()
@@ -878,12 +878,12 @@ test('a background run that ends while the row draws still draws its PNG', async
test('height with no value shows it; a bad value is refused; a bad kept value is the default', async ($, on) => {
const { kept } = world(on, { stored: { height: 3 } })
- const shown = await $.command.run({ command: 'md-preview', args: 'height' } as any)
+ const shown = await $.command.run({ command: 'iui', args: 'height' } as any)
expect(shown.text).toContain('The most rows an image or a Typst drawing takes: half (half the terminal, 6 to 24 rows)')
expect(shown.text).toContain('This applies to images (sent or pasted) and to Typst drawings in answers.')
- const bad = await $.command.run({ command: 'md-preview', args: 'height 5' } as any)
+ const bad = await $.command.run({ command: 'iui', args: 'height 5' } as any)
expect(bad.text).toContain('Not understood: "height 5"')
expect(kept.height).toBe(undefined)
- await $.command.run({ command: 'md-preview', args: 'height 200' } as any)
+ await $.command.run({ command: 'iui', args: 'height 200' } as any)
expect(kept.height).toBe(200)
})
diff --git a/tests/mode.test.ts b/tests/mode.test.ts
index 32000f7..57b9e59 100644
--- a/tests/mode.test.ts
+++ b/tests/mode.test.ts
@@ -11,7 +11,7 @@ test('with the theme on auto, the mode comes from the OS appearance, read every
on('config.set', async ($: any, e: any) => ({ value: e.value }))
on('process.run', async ($: any, e: any, next: any) => {
const argv: string[] = e.argv
- if (argv[0] === 'sh' && /md-preview-/.test(argv.join(' '))) return { value: { exitCode: 0, stdout: '/tmp/mdp\nDarwin\n', stderr: '', isStdoutTruncated: false, isStderrTruncated: false } }
+ if (argv[0] === 'sh' && /intelligent-ui-/.test(argv.join(' '))) return { value: { exitCode: 0, stdout: '/tmp/mdp\nDarwin\n', stderr: '', isStdoutTruncated: false, isStderrTruncated: false } }
if (argv[0] === 'defaults' && argv.includes('AppleInterfaceStyle')) {
reads.push('macOS')
return { value: osDark
@@ -20,14 +20,14 @@ test('with the theme on auto, the mode comes from the OS appearance, read every
}
return next(e)
})
- const ran = await $.command.run({ command: 'md-preview', args: 'details' } as any)
+ const ran = await $.command.run({ command: 'iui', args: 'details' } as any)
expect(ran.text).toContain('mode light (auto, from macOS)')
expect(reads.length).toBe(1)
// The OS goes dark: the next poll, 3 s on, sees it; one read per period.
osDark = true
await clock.advance(3000)
expect(reads.length).toBe(2)
- const later = await $.command.run({ command: 'md-preview', args: 'details' } as any)
+ const later = await $.command.run({ command: 'iui', args: 'details' } as any)
expect(later.text).toContain('mode dark (auto, from macOS)')
await clock.advance(6000)
expect(reads.length).toBe(4)
@@ -35,19 +35,19 @@ test('with the theme on auto, the mode comes from the OS appearance, read every
await $.config.set({ key: 'theme', value: 'light-daltonized' } as any)
await clock.advance(9000)
expect(reads.length).toBe(4)
- const fixed = await $.command.run({ command: 'md-preview', args: 'details' } as any)
+ const fixed = await $.command.run({ command: 'iui', args: 'details' } as any)
expect(fixed.text).toContain('mode light (Claude Code theme light-daltonized)')
await $.config.set({ key: 'theme', value: 'auto' } as any)
await clock.settle()
expect(reads.length).toBe(5)
await clock.advance(3000)
expect(reads.length).toBe(6)
- const again = await $.command.run({ command: 'md-preview', args: 'details' } as any)
+ const again = await $.command.run({ command: 'iui', args: 'details' } as any)
expect(again.text).toContain('mode dark (auto, from macOS)')
})
-// /md-preview probe asks the terminal 5 times and shows each raw answer.
-test('/md-preview probe shows the raw OSC 11 answers and the mode they give', async ($, on) => {
+// /iui probe asks the terminal 5 times and shows each raw answer.
+test('/iui probe shows the raw OSC 11 answers and the mode they give', async ($, on) => {
mock.store(on)
mock.env(on, { HOME: '/fake-home' })
const answers = ['\x1b]11;rgb:ffff/ffff/ffff\x07', '', 'x', null, '\x1b]11;rgb:1d1d/2525/2a2a\x1b\\']
@@ -57,7 +57,7 @@ test('/md-preview probe shows the raw OSC 11 answers and the mode they give', as
const a = answers[i++]
return { value: { exitCode: a === null ? 1 : 0, stdout: a ?? '', stderr: '', isStdoutTruncated: false, isStderrTruncated: false } }
})
- const ran = await $.command.run({ command: 'md-preview', args: 'probe' } as any)
+ const ran = await $.command.run({ command: 'iui', args: 'probe' } as any)
expect(i).toBe(5)
expect(ran.text).toContain('1: "\\e]11;rgb:ffff/ffff/ffff\\a" -> luminance 1.000, light')
expect(ran.text).toContain('2: no answer in 300 ms')
@@ -83,17 +83,17 @@ test('with the theme on auto, a dark iTerm2 profile on a light Mac draws dark',
on('process.run', async ($: any, e: any, next: any) => {
const argv: string[] = e.argv
const cmd = argv.join(' ')
- if (argv[0] === 'sh' && /md-preview-/.test(cmd)) return ok('/tmp/mdp\nDarwin\n')
+ if (argv[0] === 'sh' && /intelligent-ui-/.test(cmd)) return ok('/tmp/mdp\nDarwin\n')
if (argv[0] === 'sh' && cmd.includes('TabStyleWithAutomaticOption')) return ok(`${style}@\nG1\n@\n${marks}\n`)
if (argv[0] === 'defaults' && argv.includes('AppleInterfaceStyle')) return ok('', 1)
return next(e)
})
- const ran = await $.command.run({ command: 'md-preview', args: 'details' } as any)
+ const ran = await $.command.run({ command: 'iui', args: 'details' } as any)
expect(ran.text).toContain('mode dark (auto, from iTerm2: profile Default background)')
// iTerm2 on Automatic follows the light Mac: the profile's light colours.
style = '4\n'
await clock.advance(3000)
- const later = await $.command.run({ command: 'md-preview', args: 'details' } as any)
+ const later = await $.command.run({ command: 'iui', args: 'details' } as any)
expect(later.text).toContain('mode light (auto, from iTerm2: profile Default background)')
})
@@ -110,21 +110,21 @@ test('with the theme on auto, Ghostty draws as its background is', async ($, on)
on('process.run', async ($: any, e: any, next: any) => {
const argv: string[] = e.argv
const cmd = argv.join(' ')
- if (argv[0] === 'sh' && /md-preview-/.test(cmd)) return ok('/tmp/mdp\nDarwin\n')
+ if (argv[0] === 'sh' && /intelligent-ui-/.test(cmd)) return ok('/tmp/mdp\nDarwin\n')
if (argv[0] === 'sh' && cmd.includes('+show-config')) return ok(config)
if (argv[0] === 'defaults' && argv.includes('AppleInterfaceStyle')) return osDark ? ok('Dark\n') : ok('', 1)
return next(e)
})
const files: Record<string, string> = { '/R/themes/Day': 'background = #f7f7f7\n', '/h/.config/ghostty/themes/Night': 'background = #191724\n' }
on('fs.read', async ($: any, e: any, next: any) => (e.path in files ? { value: files[e.path] } : e.path.includes('ghostty') || e.path.startsWith('/R/') ? { deny: 'no such file' } as any : next(e)))
- const ran = await $.command.run({ command: 'md-preview', args: 'details' } as any)
+ const ran = await $.command.run({ command: 'iui', args: 'details' } as any)
expect(ran.text).toContain('mode dark (auto, from Ghostty: default background)')
config = 'theme = light:Day,dark:Night\nbackground = #f7f7f7\n'
await clock.advance(3000)
- expect((await $.command.run({ command: 'md-preview', args: 'details' } as any)).text).toContain('mode light (auto, from Ghostty: theme Day background)')
+ expect((await $.command.run({ command: 'iui', args: 'details' } as any)).text).toContain('mode light (auto, from Ghostty: theme Day background)')
osDark = true
await clock.advance(3000)
- expect((await $.command.run({ command: 'md-preview', args: 'details' } as any)).text).toContain('mode dark (auto, from Ghostty: theme Night background)')
+ expect((await $.command.run({ command: 'iui', args: 'details' } as any)).text).toContain('mode dark (auto, from Ghostty: theme Night background)')
})
// kitty on a light Mac: kitty.conf's included theme is dark; once auto theme
@@ -138,7 +138,7 @@ test('with the theme on auto, kitty draws as its config or auto theme is', async
const ok = (stdout: string, exitCode = 0) => ({ value: { exitCode, stdout, stderr: '', isStdoutTruncated: false, isStderrTruncated: false } })
on('process.run', async ($: any, e: any, next: any) => {
const argv: string[] = e.argv
- if (argv[0] === 'sh' && /md-preview-/.test(argv.join(' '))) return ok('/tmp/mdp\nDarwin\n')
+ if (argv[0] === 'sh' && /intelligent-ui-/.test(argv.join(' '))) return ok('/tmp/mdp\nDarwin\n')
if (argv[0] === 'defaults' && argv.includes('AppleInterfaceStyle')) return osDark ? ok('Dark\n') : ok('', 1)
return next(e)
})
@@ -149,16 +149,16 @@ test('with the theme on auto, kitty draws as its config or auto theme is', async
const inKitty = (path: string) => path.includes('kitty')
on('fs.exists', async ($: any, e: any, next: any) => (inKitty(e.path) ? { value: e.path in files } : next(e)))
on('fs.read', async ($: any, e: any, next: any) => (e.path in files ? { value: files[e.path] } : inKitty(e.path) ? ({ deny: 'no such file' } as any) : next(e)))
- const ran = await $.command.run({ command: 'md-preview', args: 'details' } as any)
+ const ran = await $.command.run({ command: 'iui', args: 'details' } as any)
expect(ran.text).toContain('mode dark (auto, from kitty: config background)')
expect(ran.text).toContain('terminal font JetBrains Mono')
files['/h/.config/kitty/dark-theme.auto.conf'] = 'background #191724\n'
files['/h/.config/kitty/light-theme.auto.conf'] = 'background #fafafa\n'
await clock.advance(3000)
- expect((await $.command.run({ command: 'md-preview', args: 'details' } as any)).text).toContain('mode light (auto, from kitty: light-theme.auto.conf background)')
+ expect((await $.command.run({ command: 'iui', args: 'details' } as any)).text).toContain('mode light (auto, from kitty: light-theme.auto.conf background)')
osDark = true
await clock.advance(3000)
- expect((await $.command.run({ command: 'md-preview', args: 'details' } as any)).text).toContain('mode dark (auto, from kitty: dark-theme.auto.conf background)')
+ expect((await $.command.run({ command: 'iui', args: 'details' } as any)).text).toContain('mode dark (auto, from kitty: dark-theme.auto.conf background)')
})
// Rio on a dark Mac with an [adaptive-theme]: the OS picks the theme file;
@@ -171,7 +171,7 @@ test('with the theme on auto, Rio draws as its adaptive theme is', async ($, on)
const ok = (stdout: string, exitCode = 0) => ({ value: { exitCode, stdout, stderr: '', isStdoutTruncated: false, isStderrTruncated: false } })
on('process.run', async ($: any, e: any, next: any) => {
const argv: string[] = e.argv
- if (argv[0] === 'sh' && /md-preview-/.test(argv.join(' '))) return ok('/tmp/mdp\nDarwin\n')
+ if (argv[0] === 'sh' && /intelligent-ui-/.test(argv.join(' '))) return ok('/tmp/mdp\nDarwin\n')
if (argv[0] === 'defaults' && argv.includes('AppleInterfaceStyle')) return ok('Dark\n')
return next(e)
})
@@ -181,12 +181,12 @@ test('with the theme on auto, Rio draws as its adaptive theme is', async ($, on)
'/h/.config/rio/themes/night.toml': '[colors]\nbackground = "#191724"\n',
}
on('fs.read', async ($: any, e: any, next: any) => (e.path in files ? { value: files[e.path] } : e.path.includes('/rio/') ? ({ deny: 'no such file' } as any) : next(e)))
- const ran = await $.command.run({ command: 'md-preview', args: 'details' } as any)
+ const ran = await $.command.run({ command: 'iui', args: 'details' } as any)
expect(ran.text).toContain('mode dark (auto, from Rio: theme night background)')
expect(ran.text).toContain('terminal font Iosevka')
files['/h/.config/rio/config.toml'] = 'force-theme = "light"\n' + files['/h/.config/rio/config.toml']
await clock.advance(3000)
- expect((await $.command.run({ command: 'md-preview', args: 'details' } as any)).text).toContain('mode light (auto, from Rio: theme day background)')
+ expect((await $.command.run({ command: 'iui', args: 'details' } as any)).text).toContain('mode light (auto, from Rio: theme day background)')
})
// Over ssh the configs and the OS here are the remote computer's: auto uses
@@ -201,7 +201,7 @@ for (const colorFgBg of [undefined, '0;15']) {
const ok = (stdout: string, exitCode = 0) => ({ value: { exitCode, stdout, stderr: '', isStdoutTruncated: false, isStderrTruncated: false } })
on('process.run', async ($: any, e: any, next: any) => {
const argv: string[] = e.argv
- if (argv[0] === 'sh' && /md-preview-/.test(argv.join(' '))) return ok('/tmp/mdp\nDarwin\n')
+ if (argv[0] === 'sh' && /intelligent-ui-/.test(argv.join(' '))) return ok('/tmp/mdp\nDarwin\n')
if (argv[0] === 'defaults' && argv.includes('AppleInterfaceStyle')) {
asked.push('macOS')
return ok('', 1)
@@ -210,7 +210,7 @@ for (const colorFgBg of [undefined, '0;15']) {
})
on('fs.exists', async ($: any, e: any, next: any) => (e.path.includes('kitty') ? (asked.push(e.path), { value: false }) : next(e)))
on('fs.read', async ($: any, e: any, next: any) => (e.path.includes('kitty') ? (asked.push(e.path), { deny: 'no such file' } as any) : next(e)))
- const ran = await $.command.run({ command: 'md-preview', args: 'details' } as any)
+ const ran = await $.command.run({ command: 'iui', args: 'details' } as any)
expect(ran.text).toContain(colorFgBg ? 'mode light (auto, from COLORFGBG)' : 'mode dark (auto, OS appearance not known, dark assumed)')
expect(ran.text).toContain('terminal font not known (Menlo assumed)')
expect(asked).toEqual([])
@@ -229,7 +229,7 @@ test('with the theme on auto, cmux draws as its appearance is', async ($, on) =>
on('process.run', async ($: any, e: any, next: any) => {
const argv: string[] = e.argv
const cmd = argv.join(' ')
- if (argv[0] === 'sh' && /md-preview-/.test(cmd)) return ok('/tmp/mdp\nDarwin\n')
+ if (argv[0] === 'sh' && /intelligent-ui-/.test(cmd)) return ok('/tmp/mdp\nDarwin\n')
if (argv[0] === 'sh' && cmd.includes('+show-config')) return ok('font-family = Menlo\n')
if (argv[0] === 'defaults' && argv.includes('com.cmuxterm.app')) return ok(saved)
if (argv[0] === 'defaults' && argv.includes('AppleInterfaceStyle')) return ok('', 1)
@@ -237,15 +237,15 @@ test('with the theme on auto, cmux draws as its appearance is', async ($, on) =>
})
let cmuxJson: string | null = null
on('fs.read', async ($: any, e: any, next: any) => (e.path === '/h/.config/cmux/cmux.json' ? (cmuxJson === null ? ({ deny: 'no such file' } as any) : { value: cmuxJson }) : next(e)))
- const ran = await $.command.run({ command: 'md-preview', args: 'details' } as any)
+ const ran = await $.command.run({ command: 'iui', args: 'details' } as any)
expect(ran.text).toContain('mode light (auto, from cmux: adaptive default theme, appearance system)')
saved = 'dark\n'
await clock.advance(3000)
- expect((await $.command.run({ command: 'md-preview', args: 'details' } as any)).text).toContain('mode dark (auto, from cmux: adaptive default theme, appearance dark)')
+ expect((await $.command.run({ command: 'iui', args: 'details' } as any)).text).toContain('mode dark (auto, from cmux: adaptive default theme, appearance dark)')
saved = 'system\n'
cmuxJson = '{\n // off\n "terminal": { "adaptiveDefaultTheme": false, },\n}'
await clock.advance(3000)
- expect((await $.command.run({ command: 'md-preview', args: 'details' } as any)).text).toContain('mode dark (auto, from Ghostty: default background)')
+ expect((await $.command.run({ command: 'iui', args: 'details' } as any)).text).toContain('mode dark (auto, from Ghostty: default background)')
})
// iTerm2 whose TERM_PROGRAM did not come through: ITERM_PROFILE says iTerm2.
@@ -260,11 +260,11 @@ test('with the theme on auto, iTerm2 with no TERM_PROGRAM is found by ITERM_PROF
on('process.run', async ($: any, e: any, next: any) => {
const argv: string[] = e.argv
const cmd = argv.join(' ')
- if (argv[0] === 'sh' && /md-preview-/.test(cmd)) return ok('/tmp/mdp\nDarwin\n')
+ if (argv[0] === 'sh' && /intelligent-ui-/.test(cmd)) return ok('/tmp/mdp\nDarwin\n')
if (argv[0] === 'sh' && cmd.includes('TabStyleWithAutomaticOption')) return ok(`1\n@\nG1\n@\n${marks}\n`)
if (argv[0] === 'defaults' && argv.includes('AppleInterfaceStyle')) return ok('', 1)
return next(e)
})
- const ran = await $.command.run({ command: 'md-preview', args: 'details' } as any)
+ const ran = await $.command.run({ command: 'iui', args: 'details' } as any)
expect(ran.text).toContain('mode dark (auto, from iTerm2: profile Default background)')
})
diff --git a/tests/plan.test.ts b/tests/plan.test.ts
index d19e43a..238813d 100644
--- a/tests/plan.test.ts
+++ b/tests/plan.test.ts
@@ -83,7 +83,7 @@ test('the editor: VS Code when found, else TextEdit on a local Mac, else none',
expect(editorArgv({ code: '', isMac: false, isRemote: false }, '/h/p.md')).toBe(null)
})
-test('only the question md-preview asks now is the plan question', () => {
+test('only the question Intelligent UI asks now is the plan question', () => {
const q = (question: string, header = PLAN_HEADER) => [{ question, header, options: [], multiSelect: false }]
expect(isPlanQuestion(q(PLAN_QUESTION), PLAN_QUESTION)).toBe(true)
expect(isPlanQuestion(q(PLAN_QUESTION), '')).toBe(false)
@@ -110,8 +110,8 @@ const PLAN = '# Plan\n\n1. Read the code.\n2. Change it.'
const EDITED = '# Plan\n\n1. Read the code.\n2. Change it.\n3. Test it.'
// A Mac terminal that draws (forced), with Typst, session sid-1 in /w/app.
-// `answers` answer md-preview's questions in order (null: Esc). The engine's
-// ExitPlanMode raises PermissionRequest as the engine does: md-preview's
+// `answers` answer the mod's questions in order (null: Esc). The engine's
+// ExitPlanMode raises PermissionRequest as the engine does: Intelligent UI's
// decision, else the engine's dialog (`engineAsks`, which approves).
function world($: any, on: any, o: {
vars?: Record<string, string>
@@ -136,7 +136,7 @@ function world($: any, on: any, o: {
let engineAsks = 0
const answers = [...(o.answers ?? [])]
const files = new Map<string, string>([[FILE, PLAN]])
- // The children md-preview spawns: the Frame watcher (it exits 1: no tty)
+ // The children Intelligent UI spawns: the Frame watcher (it exits 1: no tty)
// and a compile through the PID wrapper (typst.ts wrapPid).
let pids = 4242
on('process.spawn', async function* ($: any, e: any) {
@@ -157,7 +157,7 @@ function world($: any, on: any, o: {
const argv: string[] = e.argv
const cmd = argv.join(' ')
if (argv[0] === 'kill') return ok('')
- if (/md-preview-/.test(cmd)) return ok('/c\nDarwin\n')
+ if (/intelligent-ui-/.test(cmd)) return ok('/c\nDarwin\n')
if (cmd.includes('command -v typst')) return ok('/usr/bin/typst\n')
if (cmd.includes('command -v code')) return o.code ? ok('/usr/local/bin/code\n') : ok('', 1)
if (argv[0] === '/usr/bin/typst' && argv[1] === 'eval') return ok('{}')
@@ -219,7 +219,7 @@ function world($: any, on: any, o: {
const use = (o: { id?: string; input?: unknown; output?: unknown; isRunning?: boolean; isErrored?: boolean } = {}) =>
({
- plugin: 'md-preview', surface: 'terminal', component: 'ToolUse', requestId: o.id ?? 'tu-plan',
+ plugin: 'intelligent-ui', surface: 'terminal', component: 'ToolUse', requestId: o.id ?? 'tu-plan',
props: {
tool_use_id: o.id ?? 'tu-plan', tool: 'ExitPlanMode', input: o.input ?? { plan: PLAN, planFilePath: FILE },
isRunning: o.isRunning ?? true, isErrored: o.isErrored ?? false, isInterrupted: false, output: o.output,
@@ -228,12 +228,12 @@ const use = (o: { id?: string; input?: unknown; output?: unknown; isRunning?: bo
}) as any
const result = (output: unknown, isErrored = false, id = 'tu-plan') =>
({
- plugin: 'md-preview', surface: 'terminal', component: 'ToolResult', requestId: id,
+ plugin: 'intelligent-ui', surface: 'terminal', component: 'ToolResult', requestId: id,
props: { tool_use_id: id, tool: 'ExitPlanMode', output, isErrored }, viewport: { columns: 100, rows: 40 },
}) as any
const dialog = (question: string, header = PLAN_HEADER, id = 'tu-ask') =>
({
- plugin: 'md-preview', surface: 'terminal', component: 'AskUserQuestion', requestId: id,
+ plugin: 'intelligent-ui', surface: 'terminal', component: 'AskUserQuestion', requestId: id,
props: { tool: 'AskUserQuestion', questions: [{ question, header, options: [{ label: 'A', description: '' }, { label: 'B', description: '' }], multiSelect: false }] },
viewport: { columns: 100, rows: 40 },
}) as any
@@ -243,7 +243,7 @@ const images = (tree: any): any[] =>
const texts = (tree: any): string[] =>
typeof tree === 'string' ? [tree] : tree && typeof tree === 'object' ? (tree.children ?? []).flatMap(texts) : []
// Sets the mod up (as the first answer would) before a row draws.
-const ready = ($: any) => $.command.run({ command: 'md-preview', args: '' } as any)
+const ready = ($: any) => $.command.run({ command: 'iui', args: '' } as any)
// ExitPlanMode as the engine calls it: the plan and its file on the envelope.
const exitPlan = ($: any, more: Record<string, unknown> = {}) =>
$.tool.call({ tool: 'ExitPlanMode', tool_use_id: 'tu-plan', plan: PLAN, planFilePath: FILE, ...more } as any)
@@ -443,10 +443,10 @@ test('clear context: once approved, the turn ends, /clear runs and the plan is s
expect(w.submits).toMatchObject([{ text: `Implement this plan:\n\n${PLAN}`, origin: { kind: 'plugin', asUser: true } }])
})
-test('with md-preview off, the engine dialog asks and the row stays as the engine draws it', async ($, on) => {
+test('with Intelligent UI off, the engine dialog asks and the row stays as the engine draws it', async ($, on) => {
const off = world($, on, { answers: [PLAN_AUTO] })
await ready($)
- await $.command.run({ command: 'md-preview', args: 'off' } as any)
+ await $.command.run({ command: 'iui', args: 'off' } as any)
const got: any = await exitPlan($)
expect(got.result.plan).toBe(PLAN)
expect(off.asked).toEqual([])
@@ -495,10 +495,10 @@ test('a verdict whose PermissionRequest never came does not reach a later call',
expect(w.engineAsks()).toBe(1)
})
-test('the line above the dialog is for the md-preview question alone', async ($, on) => {
+test('the line above the dialog is for the Intelligent UI question alone', async ($, on) => {
let during: any = null
let other: any = null
- // Draws the dialogs while md-preview's question is asked.
+ // Draws the dialogs while Intelligent UI's question is asked.
const w = world($, on, {
answers: [PLAN_AUTO],
onAsk: async () => {
diff --git a/tests/pure.test.ts b/tests/pure.test.ts
index 0b9c687..5b12344 100644
--- a/tests/pure.test.ts
+++ b/tests/pure.test.ts
@@ -446,22 +446,22 @@ test('a theme folder is usable only with a theme.json object', () => {
test('a user theme replaces the built-in one of its name; a broken one is only reported', () => {
const found = [
- themeEntry('nord', '/home/.claude/md-preview/themes/nord', true, '{"description":"mine"}'),
+ themeEntry('nord', '/home/.claude/intelligent-ui/themes/nord', true, '{"description":"mine"}'),
themeEntry('vscode', '/mod/render/themes/vscode', false, '{"name":"VS Code"}'),
themeEntry('nord', '/mod/render/themes/nord', false, '{"description":"built-in"}'),
- themeEntry('vscode', '/home/.claude/md-preview/themes/vscode', true, '{not json'),
- themeEntry('solar', '/home/.claude/md-preview/themes/solar', true, '[1]'),
+ themeEntry('vscode', '/home/.claude/intelligent-ui/themes/vscode', true, '{not json'),
+ themeEntry('solar', '/home/.claude/intelligent-ui/themes/solar', true, '[1]'),
]
const { themes, problems } = pickThemes(found)
expect([...themes.keys()].sort()).toEqual(['nord', 'vscode'])
expect(themes.get('nord')).toMatchObject({ isUser: true, description: 'mine' })
expect(themes.get('vscode')).toMatchObject({ isUser: false, dir: '/mod/render/themes/vscode' })
expect(problems.map(p => p.name).sort()).toEqual(['solar', 'vscode'])
- const listing = themeListing(themes, problems, 'nord', '/home/.claude/md-preview/themes')
+ const listing = themeListing(themes, problems, 'nord', '/home/.claude/intelligent-ui/themes')
expect(listing).toContain('* nord (user): mine')
expect(listing).toContain('- vscode (built-in)')
expect(listing).toContain('skipped solar (user)')
- expect(listing).toContain('/home/.claude/md-preview/themes/<name>/theme.json')
+ expect(listing).toContain('/home/.claude/intelligent-ui/themes/<name>/theme.json')
})
test('a missing theme falls back to the base theme, even before it is on disk', () => {
diff --git a/tests/render.test.ts b/tests/render.test.ts
index a338a4f..8cc89e3 100644
--- a/tests/render.test.ts
+++ b/tests/render.test.ts
@@ -5,7 +5,7 @@ const ENGINE = { type: 'Text', props: {}, children: ['engine drawing'] }
const message = (requestId: string, props: Record<string, unknown>) =>
({
- plugin: 'md-preview',
+ plugin: 'intelligent-ui',
surface: 'terminal',
component: 'AssistantMessage',
requestId,
@@ -16,8 +16,8 @@ const message = (requestId: string, props: Record<string, unknown>) =>
test('with the mod off, an answer draws as the engine draws it', async ($, on) => {
mock.store(on)
on('ui.render', () => ENGINE as any)
- const ran = await $.command.run({ command: 'md-preview', args: 'off' } as any)
- expect(ran.text).toBe('md-preview is off.')
+ const ran = await $.command.run({ command: 'iui', args: 'off' } as any)
+ expect(ran.text).toBe('Intelligent UI is off.')
const mounted = await $.ui.mount(message('off-1', {}))
expect(await mounted.drawn()).toMatchObject(ENGINE)
})
diff --git a/tests/setup.test.ts b/tests/setup.test.ts
index db6b41f..9ffa74c 100644
--- a/tests/setup.test.ts
+++ b/tests/setup.test.ts
@@ -7,7 +7,7 @@ test('the setup writes the start file of the login shell', () => {
expect(shellRcOf({ shell: '/bin/zsh', home: '/h', zdotdir: '/z', isMac: true })!.path).toBe('/z/.zshrc')
expect(shellRcOf({ shell: '/bin/bash', home: '/h', isMac: true })!.path).toBe('/h/.bash_profile')
expect(shellRcOf({ shell: '/bin/bash', home: '/h', isMac: false })!.path).toBe('/h/.bashrc')
- expect(shellRcOf({ shell: '/opt/homebrew/bin/fish', home: '/h', isMac: true })).toEqual({ path: '/h/.config/fish/conf.d/md-preview.fish', kind: 'fish' })
+ expect(shellRcOf({ shell: '/opt/homebrew/bin/fish', home: '/h', isMac: true })).toEqual({ path: '/h/.config/fish/conf.d/intelligent-ui.fish', kind: 'fish' })
expect(shellRcOf({ shell: '/bin/tcsh', home: '/h', isMac: true })).toBe(null)
})
@@ -31,7 +31,7 @@ test('adding the block twice keeps one; removing it gives the file back', () =>
expect(withoutSetup(`a\n${SETUP_START}\nb`)).toBe(`a\n${SETUP_START}\nb`)
})
-test('/md-preview setup and setup remove are commands', () => {
+test('/iui setup and setup remove are commands', () => {
expect(parseCommand('setup')).toEqual({ kind: 'setup', remove: false })
expect(parseCommand('Setup Remove')).toEqual({ kind: 'setup', remove: true })
expect(parseCommand('setup now')).toEqual({ kind: 'bad' })
@@ -55,7 +55,7 @@ const iterm = (on: any, files: Record<string, string>, answer: string | null) =>
on('ui.toast', async ($: any, e: any) => (toasts.push(e.text), { value: undefined }))
on('ui.log', async ($: any, e: any) => (logs.push(e.text), { value: undefined }))
on('process.run', async ($: any, e: any, next: any) =>
- e.argv[0] === 'sh' && /md-preview-/.test(e.argv.join(' '))
+ e.argv[0] === 'sh' && /intelligent-ui-/.test(e.argv.join(' '))
? { value: { exitCode: 0, stdout: '/tmp/mdp\nDarwin\n', stderr: '', isStdoutTruncated: false, isStderrTruncated: false } }
: next(e))
on('fs.read', async ($: any, e: any, next: any) => (e.path in files ? { value: files[e.path] } : e.path.startsWith('/h/') ? { deny: 'no such file' } : next(e)))
@@ -71,27 +71,27 @@ const iterm = (on: any, files: Record<string, string>, answer: string | null) =>
test('in iTerm2 with pictures off, the plugin asks once and adds the block on yes', async ($, on) => {
const files: Record<string, string> = { '/h/.zshrc': 'export A=1\n' }
const { asked, clock, toasts, logs } = iterm(on, files, 'Add the line')
- const shown = await $.command.run({ command: 'md-preview', args: '' } as any)
- expect(shown.text).toContain('run /md-preview setup once')
+ const shown = await $.command.run({ command: 'iui', args: '' } as any)
+ expect(shown.text).toContain('run /iui setup once')
await clock.settle()
expect(asked.length).toBe(1)
expect(asked[0]).toContain('~/.zshrc')
expect(hasSetup(files['/h/.zshrc']!)).toBe(true)
expect(Object.keys(files)).toEqual(['/h/.zshrc'])
expect(toasts.filter(t => /tab/.test(t))).toEqual(['Close this tab and open a new iTerm2 tab to see pictures.'])
- expect(logs.some(l => l.includes('Added the md-preview block to /h/.zshrc') && l.includes('Close this tab'))).toBe(true)
- const again = await $.command.run({ command: 'md-preview', args: 'setup' } as any)
- expect(again.text).toContain('already has the md-preview block')
+ expect(logs.some(l => l.includes('Added the Intelligent UI block to /h/.zshrc') && l.includes('Close this tab'))).toBe(true)
+ const again = await $.command.run({ command: 'iui', args: 'setup' } as any)
+ expect(again.text).toContain('already has the Intelligent UI block')
expect(again.text).toContain('Close this tab, open a new iTerm2 tab')
- const removed = await $.command.run({ command: 'md-preview', args: 'setup remove' } as any)
- expect(removed.text).toContain('Removed the md-preview block from /h/.zshrc')
+ const removed = await $.command.run({ command: 'iui', args: 'setup remove' } as any)
+ expect(removed.text).toContain('Removed the Intelligent UI block from /h/.zshrc')
expect(files['/h/.zshrc']).toBe('export A=1\n')
})
test('a dismissed question changes no file', async ($, on) => {
const files: Record<string, string> = { '/h/.zshrc': 'export A=1\n' }
const { asked, clock } = iterm(on, files, null)
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
await clock.settle()
expect(asked.length).toBe(1)
expect(files['/h/.zshrc']).toBe('export A=1\n')
diff --git a/tests/stream.test.ts b/tests/stream.test.ts
index e981d4a..3eb73d7 100644
--- a/tests/stream.test.ts
+++ b/tests/stream.test.ts
@@ -30,7 +30,7 @@ function world(on: any, o: { fail?: boolean; slow?: Promise<void>; tall?: boolea
on('process.run', async ($: any, e: any, next: any) => {
const argv: string[] = e.argv
const cmd = argv.join(' ')
- if (/md-preview-/.test(cmd)) return ok('/c\nDarwin\n')
+ if (/intelligent-ui-/.test(cmd)) return ok('/c\nDarwin\n')
if (cmd.includes('command -v typst')) return ok('/usr/bin/typst\n')
if (argv[0] === '/usr/bin/typst' && argv[1] === 'eval') return ok('{}')
if (argv[0] === 'kill') return ok('')
@@ -73,7 +73,7 @@ function world(on: any, o: { fail?: boolean; slow?: Promise<void>; tall?: boolea
const message = (requestId: string, text: string) =>
({
- plugin: 'md-preview', surface: 'terminal', component: 'AssistantMessage', requestId,
+ plugin: 'intelligent-ui', surface: 'terminal', component: 'AssistantMessage', requestId,
props: { text, isFirstOfReply: true }, viewport: { columns: 100, rows: 40 },
}) as any
const props = (text: string) => ({ text, isFirstOfReply: true }) as any
@@ -101,7 +101,7 @@ test('a block draws nothing while it streams, and its picture once the request e
on('ui.render', () => ENGINE as any)
const end = request(on)
// Ready the mod (setUp) before the stream starts.
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const stream = ($ as any).turn.step({ turnId: 't', index: 0, model: 'm', messageCount: 1 })
await stream.next()
const ui = await $.ui.mount(message('live-1', '# Ti'))
@@ -124,7 +124,7 @@ test('a block draws nothing while it streams, and its picture once the request e
test('a block whose compile fails draws as text', async ($, on) => {
const { clock } = world(on, { fail: true })
on('ui.render', () => ENGINE as any)
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const ui = await $.ui.mount(message('fail-1', 'Some **bold** text.'))
await clock.settle()
await ui.redraw(props('Some **bold** text.'))
@@ -134,7 +134,7 @@ test('a block whose compile fails draws as text', async ($, on) => {
test('with no request seen, a changing block is final after 400 ms still', async ($, on) => {
const { clock, compiled } = world(on)
on('ui.render', () => ENGINE as any)
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const ui = await $.ui.mount(message('reload-1', 'One'))
await clock.settle()
// Seen once (resumed, so final at once); a change outside a request is live.
@@ -155,7 +155,7 @@ test('a resumed block compiles at once, blank for at most 1 s, then its text unt
const slow = new Promise<void>(r => (finish = r))
const { clock, compiled } = world(on, { slow })
on('ui.render', () => ENGINE as any)
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const ui = await $.ui.mount(message('old-1', 'An old answer.'))
expect(isBlank(await ui.drawn())).toBe(true)
await clock.settle()
@@ -173,7 +173,7 @@ test('a text block is final when its request moves on to a tool call, before the
const { clock, compiled } = world(on)
on('ui.render', () => ENGINE as any)
const end = request(on, [{ kind: 'tool', index: 1, id: 'toolu_1', name: 'Write' }])
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const stream = ($ as any).turn.step({ turnId: 't', index: 0, model: 'm', messageCount: 1 })
await stream.next()
const ui = await $.ui.mount(message('tool-1', 'Let me write the file.'))
@@ -192,7 +192,7 @@ test('a diagram keeps its design only after its final text compiled, never while
const { clock, compiled, designs } = world(on)
on('ui.render', () => ENGINE as any)
const end = request(on)
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const stream = ($ as any).turn.step({ turnId: 't', index: 0, model: 'm', messageCount: 1 })
await stream.next()
const text = '# Title\n\n```typst\n#rect(width: theme.width)\n```'
@@ -212,7 +212,7 @@ test('a diagram keeps its design only after its final text compiled, never while
test('a page over 255 rows: its segment is cut in two and compiled once more', async ($, on) => {
const { clock, counts } = world(on, { tall: true })
on('ui.render', () => ENGINE as any)
- await $.command.run({ command: 'md-preview', args: '' } as any)
+ await $.command.run({ command: 'iui', args: '' } as any)
const text = Array.from({ length: 12 }, (_, i) => `Paragraph ${i} ${'word '.repeat(40)}`.trim()).join('\n\n')
const ui = await $.ui.mount(message('tall-1', text))
await clock.settle()
diff --git a/tests/themes.test.ts b/tests/themes.test.ts
index 99ebbfb..7426922 100644
--- a/tests/themes.test.ts
+++ b/tests/themes.test.ts
@@ -1,9 +1,9 @@
import { expect, mock, test } from 'claude-code/testing'
// A theme tree in memory: built-in themes under the mod's render/themes, user
-// themes under $HOME/.claude/md-preview/themes.
+// themes under $HOME/.claude/intelligent-ui/themes.
const HOME = '/fake-home'
-const USER = `${HOME}/.claude/md-preview/themes`
+const USER = `${HOME}/.claude/intelligent-ui/themes`
const files: Record<string, string> = {
'render/themes/vscode/theme.json': '{"name":"VS Code","description":"built-in look"}',
'render/themes/vscode-modern/theme.json': '{"name":"VS Code Modern","description":"modern look"}',
@@ -45,9 +45,9 @@ const withThemes = (on: any, stored: Record<string, unknown> = {}) => {
return kept
}
-test('/md-preview theme lists built-in and user themes; a user theme wins and a broken one is reported', async ($, on) => {
+test('/iui theme lists built-in and user themes; a user theme wins and a broken one is reported', async ($, on) => {
withThemes(on)
- const ran = await $.command.run({ command: 'md-preview', args: 'theme' } as any)
+ const ran = await $.command.run({ command: 'iui', args: 'theme' } as any)
expect(ran.text).toContain('* claude-code (built-in): default look')
expect(ran.text).toContain('- vscode-modern (built-in): modern look')
expect(ran.text).toContain('- vscode (built-in): built-in look')
@@ -59,17 +59,17 @@ test('/md-preview theme lists built-in and user themes; a user theme wins and a
expect(ran.text).toContain('- Own (user): own colours')
})
-test('/md-preview theme <name> switches and stores the name as typed; an unknown one is refused', async ($, on) => {
+test('/iui theme <name> switches and stores the name as typed; an unknown one is refused', async ($, on) => {
const store = withThemes(on)
- const set = await $.command.run({ command: 'md-preview', args: 'theme Sun.Light' } as any)
- expect(set.text).toContain('md-preview uses the theme Sun.Light.')
+ const set = await $.command.run({ command: 'iui', args: 'theme Sun.Light' } as any)
+ expect(set.text).toContain('Intelligent UI uses the theme Sun.Light.')
expect(set.text).toContain('* Sun.Light (user)')
expect(store['theme-name']).toBe('Sun.Light')
- const shown = await $.command.run({ command: 'md-preview', args: '' } as any)
+ const shown = await $.command.run({ command: 'iui', args: '' } as any)
expect(shown.text).toContain('theme Sun.Light')
- const bad = await $.command.run({ command: 'md-preview', args: 'theme sun.light' } as any)
+ const bad = await $.command.run({ command: 'iui', args: 'theme sun.light' } as any)
expect(bad.text).toContain('No usable theme named sun.light.')
- const broken = await $.command.run({ command: 'md-preview', args: 'theme Broken' } as any)
+ const broken = await $.command.run({ command: 'iui', args: 'theme Broken' } as any)
expect(broken.text).toContain('No usable theme named Broken.')
expect(store['theme-name']).toBe('Sun.Light')
})
@@ -81,7 +81,7 @@ test('a stored theme that is gone falls back to claude-code, with one toast', as
toasts.push(String(e.text ?? e.message ?? JSON.stringify(e)))
return { value: undefined }
})
- const ran = await $.command.run({ command: 'md-preview', args: 'theme' } as any)
+ const ran = await $.command.run({ command: 'iui', args: 'theme' } as any)
expect(ran.text).toContain('* claude-code (built-in)')
- expect(toasts.filter(t => t.includes('md-preview: theme gone not found, using claude-code')).length).toBe(1)
+ expect(toasts.filter(t => t.includes('Intelligent UI: theme gone not found, using claude-code')).length).toBe(1)
})
diff --git a/types/index.d.ts b/types/index.d.ts
index ffbc6ca..446f9af 100644
--- a/types/index.d.ts
+++ b/types/index.d.ts
@@ -1,9 +1,9 @@
-// The values md-preview keeps in $.state.
-export type MdPreviewTheme = 'dark' | 'light'
+// The values Intelligent UI keeps in $.state.
+export type IuiTheme = 'dark' | 'light'
declare module 'claude-code' {
interface PluginState {
- 'md-preview': {
+ 'intelligent-ui': {
// Whether answers are drawn as pictures (also kept in $.store as `enabled`).
isOn: boolean
// Goes up each time a render finishes or the setup changes, so the