# `WardrikWorkspace.Tools`

Builds the six file tools.

| Tool | Arguments | Answers |
| --- | --- | --- |
| `read_file` | `path`, `offset`, `limit` | Numbered lines, at most 2,000 or 128 KB, and the version |
| `write_file` | `path`, `content`, `version`, `append` | The new version |
| `edit_file` | `path`, `old`, `new`, `all` | How many places changed |
| `list_files` | `pattern` (a glob) | Paths, newest first, at most 500 |
| `search_files` | `pattern` (a regex), `glob`, `context` | Matching lines, at most 200 |
| `delete_file` | `path` | Whether the file was there |

`write_file` needs the version read to replace an existing file. With `append`, it needs none.
`edit_file` needs `old` to appear exactly once, unless `all` is true.

A tool that fails answers `%{ok: false, error: %{code: ..., message: ...}}`. The turn carries on.

Each call's `:resources` is its path, or the glob it lists or searches. A policy can match it, as
`write_file(notes/*)`.

# `build`

```elixir
@spec build(WardrikWorkspace.Spec.t()) :: [WardrikCore.Tool.t()]
```

Returns the file tools over `spec`.

# `failed`

```elixir
@spec failed(atom(), String.t()) :: {:ok, map()}
```

Returns a tool's failure answer, with `code` and `message`.

---

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