# Prose diff

An agent's rewrite of a document (a knowledge page, a process description), shown word by word against the original. Each change can be accepted or rejected on its own; undecided changes show both versions. The result is reported as text once every change is decided. With `readOnly` it only shows what changed (between two published versions, say): no decisions.

- Registry name: `prose-diff` (`@candor/prose-diff`)
- Tier: Pro. Installing it needs a Pro, Premium or Team licence key: the person runs `npx candor-ui key <key>` themselves; never ask for the key in chat or write it to a file.
- Docs: https://candor.themethodic.com/docs/prose-diff

## Install

```bash
npx candor-ui add prose-diff
```

Run `npx candor-ui@latest init` once first (https://candor.themethodic.com/get-started.md). Without the CLI: `npx shadcn@latest add @candor/prose-diff`.
It brings in: button, diff, locale, utils.
npm packages: lucide-react@^1.67.0.

## Example

```tsx
"use client"

import * as React from "react"
import { ProseDiff } from "@/components/prose-diff"

const original =
  "Customers are routed to a data region by partner tier for partner accounts and by billing country for everyone else. The platform team reviews routing every quarter."
const revised =
  "Customers are routed to a data region by the region column for every account. The platform team reviews routing every quarter."

export default function Example() {
  const [result, setResult] = React.useState<string | null>(null)
  return (
    <div className="flex max-w-xl flex-col gap-3">
      <ProseDiff original={original} revised={revised} onResolve={setResult} />
      {result && <p className="text-sm text-muted-foreground">Saved: {result}</p>}
    </div>
  )
}
```

## <ProseDiff>

Props:

- `original: string`: The text before the rewrite.
- `revised: string`: The agent's rewrite.
- `onResolve?: ((text: string) => void) | undefined`: Called with the final text when every change has a decision.
- `readOnly?: boolean | undefined` (default `false`): Show the changes without accept and reject: the header counts them, and `onResolve` is never called.
- `className?: string | undefined`

## Strings (`proseDiff`)

The fixed words, English by default. Override any of them under `proseDiff` in `<LocaleProvider strings={{ proseDiff: { … } }}>`; the table is exported as `proseDiffStrings`.

- `suggestedChanges`: Suggested changes
- `decided`: {decided} of {total} decided
- `rejectAll`: Reject all
- `acceptAll`: Accept all
- `removed`: removed:
- `added`: added:
- `acceptChange`: Accept this change
- `rejectChange`: Reject this change
- `changes`: Changes
- `changeCount`: { one: "{count} change", other: "{count} changes" }

## Rules for using Candor UI

- Components take plain typed data. Never pass model output as HTML or render it as a link; messages are typed blocks.
- A control that can't be used says why: wrap it in `<Locked reason="…">`, don't just disable it.
- Don't show a value you don't have: leave it out (it renders as —) rather than guess. An estimate is labelled as one.
- Nothing is pre-selected in a decision a person makes, and the agent is named from your app's data, never from model output.
- Your app's words go in `LocaleProvider` (fixed strings) and `TermsProvider` (nouns); entity kinds and agent roles in `EntityKindsProvider` and `AgentRolesProvider`.
