diff
Compare two markdown documents or fetched URLs and return a unified diff, structured hunks, or line count summary.
Instructions
Compute a diff between two markdown bodies or two URL fetches.
Key parameters:
old: { url?, markdown?, content_hash? } — left-hand side. URL form reads from cache; cache miss returns a structured
cache_misserror (no network re-fetch).new: { url?, markdown? } — right-hand side. Same cache rules as
old.output: 'unified' (default, git-style patch) | 'hunks' (structured array) | 'summary' (line counts only).
granularity: 'line' (default) | 'word' | 'section'. Section walks H1/H2/H3 boundaries and tags each hunk with
section_title.
Returns { changed, summary, unified_diff?|hunks?, truncated? }. summary always present (added/removed/modified lines + total_changed_chars). Above the 5000-line cap the engine emits truncated: true plus an approximate summary — never silently degrades.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| new | No | Right-hand side of the diff. Requires one of { url, markdown }. | |
| old | No | Left-hand side of the diff. Requires one of { url, markdown, content_hash }. | |
| output | No | Diff output shape. unified=git-style patch, hunks=structured per-section, summary=counts only (added_lines / removed_lines / modified_lines / total_changed_chars where total_changed_chars = sum of added_line_chars + removed_line_chars across the LCS edit script). Default: unified. | |
| granularity | No | Diff granularity. line=per-line LCS (default). word=token-level LCS — hunks contain only the changed tokens, tighter than line for intra-line edits. section walks H1/H2/H3 boundaries. |