MingaAgent.ProjectView (Minga v0.1.0)

Copy Markdown View Source

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.

Summary

Types

t()

Project view handle.

Functions

Returns true when the underlying backend is still available.

Returns capability flags for this view.

Releases backend-owned resources for the view.

Returns environment variables shell commands should use for this view.

Deletes a file from the view.

Returns backend-specific diff data for the view.

Creates a direct project view rooted at project_root.

Discards view-local state.

Discards one file from view-local state.

Replaces exact text in a file in the view.

Lists a directory in the view.

Creates an overlay-backed project view rooted at project_root.

Promotes view-local changes to target.

Reads a file from the view.

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

Writes a file in the view.

Types

t()

@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.

Functions

active?(view)

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

Returns true when the underlying backend is still available.

capabilities(view)

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

Returns capability flags for this view.

close(view)

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

Releases backend-owned resources for the view.

command_env(view)

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

Returns environment variables shell commands should use for this view.

delete_file(view, relative_path)

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

Deletes a file from the view.

diff(view)

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

Returns backend-specific diff data for the view.

direct(project_root, opts \\ [])

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

Creates a direct project view rooted at project_root.

discard(view)

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

Discards view-local state.

discard_file(view, relative_path)

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

Discards one file from view-local state.

edit_file(view, relative_path, old_text, new_text)

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

Replaces exact text in a file in the view.

list_directory(view, relative_path)

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

Lists a directory in the view.

overlay(project_root, opts \\ [])

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

Creates an overlay-backed project view rooted at project_root.

promote(view, target)

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

Promotes view-local changes to target.

read_file(view, relative_path)

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

Reads a file from the view.

working_dir(view)

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

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

write_file(view, relative_path, content)

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

Writes a file in the view.