# `Raxol.AgentClientProtocol.Schema.Diff`
[🔗](https://github.com/DROOdotFOO/raxol-agent/blob/raxol_agent_client_protocol-v0.1.0/packages/raxol_agent_client_protocol/lib/raxol/agent_client_protocol/schema/tool_call.ex#L145)

A diff representing file modifications.

Ported from the MIT `f1729/agent_client_protocol` (c) 2025 f1729; see NOTICE.md.

## Fixed defect

Upstream's `to_json/1` unconditionally emitted `"oldText" => nil` when
`old_text` was absent (a new-file diff), instead of omitting the key. The
ACP schema types `oldText` as optional (`string | null`); this port omits
it like every other absent-optional field, rather than emitting an
explicit wire `null`.

# `t`

```elixir
@type t() :: %Raxol.AgentClientProtocol.Schema.Diff{
  _meta: map(),
  new_text: String.t(),
  old_text: String.t() | nil,
  path: String.t()
}
```

# `from_json`

```elixir
@spec from_json(term()) :: {:ok, t()} | {:error, term()}
```

Total: never raises. Missing/non-string `path` or `newText` is the only failure mode.

# `new`

```elixir
@spec new(String.t(), String.t()) :: t()
```

# `to_json`

```elixir
@spec to_json(t()) :: map()
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
