# `Mojentic.LLM.Tools.FilesystemGateway`
[🔗](https://github.com/svetzal/mojentic-ex/blob/v1.2.0/lib/mojentic/llm/tools/file_manager.ex#L1)

A gateway for interacting with the filesystem within a sandboxed base path.

This module provides safe filesystem operations that are restricted to a
specific base directory, preventing path traversal attacks.

# `t`

```elixir
@type t() :: %Mojentic.LLM.Tools.FilesystemGateway{base_path: String.t()}
```

# `find_files_by_glob`

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

Finds files matching a glob pattern.

# `find_files_containing`

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

Finds files containing text matching a regex pattern.

# `find_lines_matching`

```elixir
@spec find_lines_matching(t(), String.t(), String.t(), String.t()) ::
  {:ok, [map()]} | {:error, String.t()}
```

Finds all lines in a file matching a regex pattern.

# `list_all_files`

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

Lists all files recursively in a directory.

# `ls`

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

Lists files in a directory (non-recursive).

# `new`

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

Creates a new FilesystemGateway with the specified base path.

# `read`

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

Reads the content of a file.

# `resolve_path`

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

Resolves a path relative to the base path and ensures it stays within the sandbox.

# `write`

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

Writes content to a file.

---

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