# `WardrikWorkspace.Context`

Middleware that reads workspace files into the agent's instructions as each turn begins.

    middleware: [{WardrikWorkspace.Context, store: store, tree: tree, files: ["MEMORY.md"]}]

It appends a `# Your workspace` section to the instructions. The section holds:

  1. Each of `:files`, in order, with its version.
  2. The `:files` not written yet.
  3. The names of the other files at the top of the agent's tree.
  4. The trees shared with the agent.

The instructions are restored after the turn.

## Options

Takes `WardrikWorkspace`'s options, plus:

  * `:files` - paths to read into each turn. `[]` unless set.
  * `:max_bytes` - how much of `:files` to read in total. `16_384` unless set.

## Budget

The budget is shared out smallest file first, so one long file can't crowd out the others. A
file over its share is cut to its start and end. If it's in the agent's own tree, the agent is
asked to rewrite it shorter.

## Labels

The labels of the files read are added to the turn's latest message, so the run carries them.

# `text`

```elixir
@spec text(WardrikWorkspace.Spec.t(), [String.t()], pos_integer()) :: String.t()
```

Returns the workspace text for `spec`'s agent, reading `files` within `budget` bytes.

---

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