~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/knotless

git that lives in your Atmosphere account

knotless.dev
1 collaborator

knotless 0.13.0 Latest 2 packages, 1 image

1
10

The MCP pull_diff gives a long diff a few files at a time

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/knotless:mcp/diff-by-file

What changes

pull_diff with a long diff. A diff longer than 60,000 bytes once numbered no longer comes back whole. The tool answers with said and files, each file's path, added, removed and lines. A new paths parameter gives just those files' parts of the diff, numbered as before. A short diff comes back whole, as it always did. A path the diff doesn't change is an error that says how to list the ones it does.

The reviewer. knotless-claude-review tells Claude to read a long diff a few files at a time. It must read every file the diff changes, and name in the review any it left unread.

Why

The reviewer reads a pull only through pull_diff, and the tool returned the whole diff in one answer. Claude Code cuts off an MCP answer at 25,000 tokens. The reviewer has no file tools to read the rest, so it reviewed only the first files in path order. Maintainers dismiss reviews is 31 files and about 100 KB once numbered. Its review said "The diff was too large for me to read in full" and skipped the pages and web code.

Raising MAX_MCP_OUTPUT_TOKENS would only move the limit. Writing the diff to files for Claude's Read tool would give back the file tool the reviewer deliberately lacks. Splitting the diff by file works for any size, and helps every agent that uses the MCP.

How it was checked

Unit tests cover splitting a diff by file: a renamed file, hunk lines that look like headers, and text before the first file. They also cover what the tool answers: a short diff whole, a long one listed, a file by path, and an unknown path. The MCP test asks for a file by path through the real tool. Build and tests are left to CI.

Shortcomings

A single file longer than the limit still comes back whole when asked for by path, and a client may cut that off. In practice that's a generated or recorded file such as fixtures JSON.

🤖 Generated with Claude Code

Approved

This makes pull_diff list the files of a diff longer than 60,000 numbered bytes, with path, added, removed and lines for each. A new paths parameter returns just those files' numbered parts. A short diff still comes back whole. I read the splitting logic and found no bugs.

  • sections only counts + and - lines after the first @@, so header lines like --- a/x aren't counted, and the test covers hunk lines that look like headers.
  • An unknown path is an error that points to the listing.
  • The docs page, the reviewer prompt, the review guide and the changeset are all updated, as AGENTS.md asks.
  • The tests cover the splitting, the whole and listed answers, a path request and an unknown path, plus one MCP test through the real tool. I didn't run them or check CI.

Two small limits, neither blocking. A file whose path contains b/ could be named wrongly from the diff --git line. And a single file over the limit is still returned whole, as the body admits.

Merged as ac9f180