# `Minga.Extension.Supervisor`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga/extension/supervisor.ex#L1)

DynamicSupervisor managing extension process trees.

Each extension gets its own child under this supervisor. If an extension
crashes, only that extension restarts. The editor and other extensions
are unaffected.

## Lifecycle

1. Config eval registers extensions in `Extension.Registry`
2. `start_all/0` reads the registry and starts each extension
3. `stop_all/0` terminates all running extensions (used by reload)

# `start_opts`

```elixir
@type start_opts() :: [
  command_registry: GenServer.server(),
  keymap: GenServer.server()
]
```

Options for extension start/stop that inject collaborator dependencies.

* `:command_registry` — the `Minga.Command.Registry` server to register
  commands with (default: `Minga.Command.Registry`)
* `:keymap` — the `Minga.Keymap.Active` server to register keybindings
  with (default: `Minga.Keymap.Active`)

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `list_extensions`

```elixir
@spec list_extensions() :: [{atom(), String.t(), Minga.Extension.extension_status()}]
```

Returns a summary of all extensions: `[{name, version, status}]`.

# `list_extensions`

```elixir
@spec list_extensions(GenServer.server()) :: [
  {atom(), String.t(), Minga.Extension.extension_status()}
]
```

# `start_all`

```elixir
@spec start_all() :: :ok
```

Starts all extensions declared in the registry.

Processes extensions in order:
1. Install all hex extensions via a single Mix.install/2 call
2. Clone/checkout all git extensions to local cache
3. Compile and start all extensions (path, git, hex)

Errors at any stage are logged to *Messages* and stored in the
registry as `:load_error` without affecting other extensions.

# `start_all`

```elixir
@spec start_all(GenServer.server(), GenServer.server()) :: :ok
```

# `start_extension`

```elixir
@spec start_extension(
  GenServer.server(),
  GenServer.server(),
  atom(),
  Minga.Extension.Registry.entry(),
  start_opts()
) :: {:ok, pid()} | {:error, term()}
```

Starts a single extension by name.

For path extensions, compiles the module from the local directory.
Git and hex extensions must be resolved to a local path or loaded
via Mix.install before calling this function.

# `start_link`

```elixir
@spec start_link(keyword()) :: Supervisor.on_start()
```

Starts the extension supervisor.

# `stop_all`

```elixir
@spec stop_all() :: :ok
```

Stops all running extensions and purges their modules.

Used by config reload to cleanly tear down before re-loading.

# `stop_all`

```elixir
@spec stop_all(GenServer.server(), GenServer.server()) :: :ok
```

# `stop_extension`

```elixir
@spec stop_extension(
  GenServer.server(),
  GenServer.server(),
  atom(),
  Minga.Extension.Registry.entry(),
  start_opts()
) :: :ok
```

Stops a single extension, terminates its process, and purges the module.

---

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