# `MingaAgent.ProjectView`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_agent/project_view.ex#L1)

Facade for workspace-local project file access.

A project view gives agent code one stable API for direct project files and isolated overlay-backed files. Paths are logical paths relative to `project_root`; callers never use frontend labels, tab labels, or backend worktree paths.

# `t`

```elixir
@type t() :: %MingaAgent.ProjectView{
  backend: module(),
  id: String.t(),
  project_root: String.t(),
  ref: MingaAgent.ProjectView.Backend.ref(),
  workspace_id: non_neg_integer() | nil
}
```

Project view handle.

# `active?`

```elixir
@spec active?(t()) :: boolean()
```

Returns true when the underlying backend is still available.

# `capabilities`

```elixir
@spec capabilities(t()) :: MingaAgent.ProjectView.Backend.capabilities()
```

Returns capability flags for this view.

# `close`

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

Releases backend-owned resources for the view.

# `command_env`

```elixir
@spec command_env(t()) :: [{String.t(), String.t()}] | {:error, term()}
```

Returns environment variables shell commands should use for this view.

# `delete_file`

```elixir
@spec delete_file(t(), String.t()) :: :ok | {:error, term()}
```

Deletes a file from the view.

# `diff`

```elixir
@spec diff(t()) :: {:ok, [map()]} | {:error, term()}
```

Returns backend-specific diff data for the view.

# `direct`

```elixir
@spec direct(
  String.t(),
  keyword()
) :: {:ok, t()} | {:error, term()}
```

Creates a direct project view rooted at `project_root`.

# `discard`

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

Discards view-local state.

# `discard_file`

```elixir
@spec discard_file(t(), String.t()) :: :ok | {:error, term()}
```

Discards one file from view-local state.

# `edit_file`

```elixir
@spec edit_file(t(), String.t(), String.t(), String.t()) :: :ok | {:error, term()}
```

Replaces exact text in a file in the view.

# `list_directory`

```elixir
@spec list_directory(t(), String.t()) ::
  {:ok, [MingaAgent.ProjectView.Backend.directory_entry()]} | {:error, term()}
```

Lists a directory in the view.

# `overlay`

```elixir
@spec overlay(
  String.t(),
  keyword()
) :: {:ok, t()} | {:error, term()}
```

Creates an overlay-backed project view rooted at `project_root`.

# `promote`

```elixir
@spec promote(t(), term()) :: :ok | {:conflict, map()} | {:error, term()}
```

Promotes view-local changes to `target`.

# `read_file`

```elixir
@spec read_file(t(), String.t()) :: {:ok, binary()} | {:error, term()}
```

Reads a file from the view.

# `working_dir`

```elixir
@spec working_dir(t()) :: String.t() | {:error, term()}
```

Returns the directory shell commands should run in for this view.

# `write_file`

```elixir
@spec write_file(t(), String.t(), binary()) :: :ok | {:error, term()}
```

Writes a file in the view.

---

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