Add show_diff chat tool and diff card

The Pipelines MCP server gains show_diff: it runs Git in a repository
inside the operator's home (default: the chat's directory) and records
the per-file patches. Without base it shows uncommitted work against
HEAD; with base it shows everything since the merge base (a pull
request preview), optionally committed changes only. Bounded at 300
files, 256 KiB per patch and 1 MiB total, with partial diffs labelled;
diff bodies share the per-chat retention budget with HTML views.

The chat draws the item as a card listing each changed file with its
stat; a row opens the existing file diff viewer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 17:08:02 +00:00
parent 79e5183469
commit 059eb1bb0d
15 changed files with 1077 additions and 16 deletions
+13 -2
View File
@@ -1,6 +1,6 @@
# Chat: Pipelines tools (show file / image / HTML, notify phone)
# Chat: Pipelines tools (show file / image / HTML / diff, notify phone)
A chat's model can call four tools that act on Pipelines, not on the harness
A chat's model can call five tools that act on Pipelines, not on the harness
or the workspace. The tools come from an MCP server that runs inside
`pipelines-server`. Each call adds an entry to the chat transcript, and the
entry is persisted.
@@ -10,6 +10,7 @@ entry is persisted.
| `show_file` | `path`, `title?` | Shows an existing file inside the operator's home. The path can be absolute, `~/…`, or relative to the chat's directory. Images render inline; other files render as a preview card. |
| `show_image` | `url_or_path`, `title?`, `alt?` | Shows a home image file (it must be `image/*`) or an `https://` URL. |
| `show_html` | `html`, `title?`, `height_hint?` | Renders model-authored HTML or SVG inline in a sandbox, with an **Open** button for full screen. |
| `show_diff` | `path?`, `base?`, `committed_only?`, `title?` | Runs Git in a repository inside the operator's home (default: the chat's directory) and shows a diff card: every changed file with its +/- counts, each opening the app's file diff viewer. Without `base`: uncommitted work (staged, unstaged, untracked) against HEAD. With `base` (e.g. `main`): everything since the merge base with it, which is what a pull request would contain, plus uncommitted work unless `committed_only`. |
| `notify` | `title`, `message`, `priority?` | Sends a phone notification through the existing ntfy "system" destination. Tapping it opens `pipelines://chat/<id>`. |
Each tool returns one short text line to the model. A refusal comes back as
@@ -58,6 +59,16 @@ Each tool returns one short text line to the model. A refusal comes back as
## Limits
- `show_diff` lists at most **300 files** (the rest are counted as omitted).
A patch over **256 KiB**, or past **1 MiB** in total, keeps its row with a
no-patch reason, and the card says the diff is partial. Binary files are
listed without a patch. `base` must be a plain revision name (no leading
`-`, no `..`, no whitespace); Git runs without pager, external diff or text
conversion, with a 30 s timeout. Renames show as a deletion plus an addition.
- Diff patches count against the same **2 MiB per chat** budget as HTML
bodies; an older diff past it keeps its summary and says it is no longer
retained.
- `show_html` documents are refused, not truncated, above **512 KiB**. The
model is told the size and the limit.
- At most **100 items are retained per chat**. HTML bodies are kept only for the