# `SuperPi.Env.Behaviour`
[🔗](https://github.com/oleksandr/super-pi-beam/blob/v0.1.0/lib/super_pi/env/behaviour.ex#L1)

Unified execution environment contract (`SuperPi.Env`, `REQ-SAFE-01`..`REQ-SAFE-04`).

Provides isolated filesystem, search, and OS process operations that never crash the BEAM VM.

# `edit_file`

```elixir
@callback edit_file(
  path :: String.t(),
  old_text :: String.t(),
  new_text :: String.t(),
  opts :: keyword()
) ::
  {:ok, %{replacements: non_neg_integer()}} | {:error, term()}
```

# `exec_command`

```elixir
@callback exec_command(cmd :: String.t(), args :: [String.t()], opts :: keyword()) ::
  {:ok,
   %{exit_code: integer(), output: String.t(), spilled_path: String.t() | nil}}
  | {:error, term()}
```

# `id`

```elixir
@callback id() :: String.t()
```

# `list_files`

```elixir
@callback list_files(root_dir :: String.t(), opts :: keyword()) ::
  {:ok, [String.t()]} | {:error, term()}
```

# `read_file`

```elixir
@callback read_file(path :: String.t(), opts :: keyword()) ::
  {:ok, String.t()} | {:error, term()}
```

# `scan_lines`

```elixir
@callback scan_lines(root_dir :: String.t(), pattern :: String.t(), opts :: keyword()) ::
  {:ok, [map()]} | {:error, term()}
```

# `write_file`

```elixir
@callback write_file(path :: String.t(), content :: String.t(), opts :: keyword()) ::
  :ok | {:error, term()}
```

---

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