# `ExAthena.Lsp.ImplicitDiagnostics`
[🔗](https://github.com/udin-io/ex_athena/blob/v0.7.1/lib/ex_athena/lsp/implicit_diagnostics.ex#L1)

PostToolUse hook that automatically fetches LSP diagnostics after Edit/Write
tool calls and injects any errors or warnings into the next turn's tool-result.

When the model edits a file, the hook:

  1. Resolves the file path from the tool call's `arguments["path"]`.
  2. Looks up (or spawns) the language server for the file's extension.
  3. Sends `textDocument/didOpen` with the current file contents.
  4. Polls `publishDiagnostics` push-notifications for up to
     `:lsp_implicit_diagnostics_timeout_ms` (default 1500 ms).
  5. Filters to `:lsp_implicit_diagnostics_severities` (default `[:error, :warning]`).
  6. Returns `{:augment, text}` with a `[lsp diagnostics]` block, or
     `:ok` if there is nothing to report.

All failure paths (LSP disabled, unsupported file type, server crash, timeout)
collapse to `:ok` — the hook must never stall the agent loop.

## Configuration keys

  * `:lsp_implicit_diagnostics_enabled` — boolean, default `true`
  * `:lsp_implicit_diagnostics_timeout_ms` — poll deadline in ms, default `1500`
  * `:lsp_implicit_diagnostics_severities` — list of `:error | :warning |
    :information | :hint`, default `[:error, :warning]`

# `default_hooks_entry`

```elixir
@spec default_hooks_entry() :: map()
```

Default hook entry to merge into Loop.start's hooks map.

# `maybe_merge`

```elixir
@spec maybe_merge(ExAthena.Hooks.t()) :: ExAthena.Hooks.t()
```

Merge the default implicit-diagnostics hook into a user-supplied hooks map.

When `:lsp_implicit_diagnostics_enabled` is false (the default in tests),
returns `hooks` unchanged. Otherwise prepends the built-in entry to the
`:PostToolUse` list so user-supplied hooks still run after it.

# `post_tool_use_hook`

```elixir
@spec post_tool_use_hook(map(), String.t() | nil) :: :ok | {:augment, String.t()}
```

PostToolUse hook function. Receives the payload map and tool_use_id.

Returns `{:augment, text}` when LSP diagnostics are available, otherwise `:ok`.
Emits `[:ex_athena, :lsp, :implicit_diagnostics, :start | :stop]` telemetry events.

---

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