{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "diff-apply-demo",
  "type": "registry:block",
  "title": "Diff Apply: Agent Refactor",
  "description": "Animated Code Diff example, Agent Refactor: An assistant wraps an invoice fetch in a retry with backoff: an import, a doc comment and the new body land one after another. Keep or undo each change, or all of them from the header. A take on the code diff (code review). Fits features and changelog sections.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "features",
    "changelog",
    "code-diff",
    "code-block",
    "code",
    "developer",
    "ai"
  ],
  "docs": "Live preview, examples and props: https://keyframeui.com/components/diff-apply#diff-apply-demo",
  "registryDependencies": [
    "https://keyframeui.com/r/diff-apply.json"
  ],
  "files": [
    {
      "path": "components/diff-apply-demo.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport { DiffApply } from \"@/components/ui/diff-apply\";\n\nconst before = `\nimport type { Invoice } from \"./types\";\n\nconst API = \"https://api.northwind.dev/v2\";\n\nexport async function fetchInvoice(id: string): Promise<Invoice> {\n  const res = await fetch(\\`\\${API}/invoices/\\${id}\\`);\n  if (!res.ok) {\n    throw new Error(\"Request failed\");\n  }\n  return res.json();\n}\n\nexport function formatTotal(invoice: Invoice) {\n  return new Intl.NumberFormat(\"en-US\", {\n    style: \"currency\",\n    currency: invoice.currency,\n  }).format(invoice.total / 100);\n}\n`;\n\nconst after = `\nimport type { Invoice } from \"./types\";\nimport { retry } from \"@/lib/retry\";\n\nconst API = \"https://api.northwind.dev/v2\";\n\n/** Retries 5xx responses up to 3 times, backing off from 250ms. */\nexport async function fetchInvoice(id: string): Promise<Invoice> {\n  return retry(\n    async () => {\n      const res = await fetch(\\`\\${API}/invoices/\\${id}\\`);\n      if (res.status >= 500) throw new Error(\\`Northwind \\${res.status}\\`);\n      if (!res.ok) throw new Error(\\`Invoice \\${id} not found\\`);\n      return res.json();\n    },\n    { attempts: 3, backoff: (n) => 250 * 2 ** n },\n  );\n}\n\nexport function formatTotal(invoice: Invoice) {\n  return new Intl.NumberFormat(\"en-US\", {\n    style: \"currency\",\n    currency: invoice.currency,\n  }).format(invoice.total / 100);\n}\n`;\n\nexport function DiffApplyDemo() {\n  return (\n    <div className=\"flex w-full max-w-2xl flex-col gap-3\">\n      <div className=\"flex items-center gap-2.5 px-1 text-[13px] text-zinc-600 dark:text-zinc-400\">\n        <span className=\"flex size-6 shrink-0 items-center justify-center rounded-full bg-zinc-900 text-white dark:bg-white dark:text-zinc-900\">\n          <svg aria-hidden viewBox=\"0 0 16 16\" className=\"size-3.5\" fill=\"currentColor\">\n            <path d=\"M8 1.5c.3 2.9 1.6 4.2 4.5 4.5-2.9.3-4.2 1.6-4.5 4.5-.3-2.9-1.6-4.2-4.5-4.5 2.9-.3 4.2-1.6 4.5-4.5Zm4.25 7.25c.15 1.45.8 2.1 2.25 2.25-1.45.15-2.1.8-2.25 2.25-.15-1.45-.8-2.1-2.25-2.25 1.45-.15 2.1-.8 2.25-2.25Z\" />\n          </svg>\n        </span>\n        <p className=\"min-w-0 truncate\">\n          <span className=\"font-medium text-zinc-900 dark:text-zinc-100\">Retry invoice fetches</span> when Northwind\n          returns a 5xx, with backoff\n        </p>\n      </div>\n      <DiffApply filename=\"billing/fetch-invoice.ts\" before={before} after={after} />\n    </div>\n  );\n}\n"
    }
  ]
}