# `Minga.CLI`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga/cli.ex#L1)

Command-line interface for Minga.

Serves as the entry point for both `mix minga <filename>` and the standalone Burrito binary (`./minga <filename>`). In Burrito mode, arguments are fetched via `Burrito.Util.Args.argv/0` which works whether running standalone or under Mix.

## Startup view

By default, Minga boots into the agentic view (controlled by the `:startup_view` config option). CLI flags can override the config:

- `--editor` forces the traditional file editing view
- File arguments open in the traditional file editing view by default
- Directory arguments open the agentic view with the directory as context
- `--no-context` opens the agentic view but skips loading the CLI file argument as preview context
- `--headless` starts only the services and agent runtime, plus the JSON-RPC Gateway

# `flags`

```elixir
@type flags() :: %{
  view_mode: view_mode(),
  no_context: boolean(),
  config_file: String.t() | nil,
  debug_log: String.t() | nil,
  headless: boolean(),
  minimal: boolean(),
  safe_mode: boolean(),
  node_name: String.t() | nil,
  short_name: boolean(),
  cookie_file: String.t() | nil,
  gateway_port: pos_integer() | nil,
  gateway_host: String.t() | nil
}
```

CLI flags that override config options.

# `parsed`

```elixir
@type parsed() ::
  {:open, file :: String.t() | nil, flags()}
  | {:attach, url :: String.t(), flags()}
  | {:sessions, url :: String.t(), flags()}
  | {:detach, flags()}
  | {:kill_session, url :: String.t(), flags()}
  | {:login, flags()}
  | {:error, String.t()}
```

Parsed CLI result.

# `view_mode`

```elixir
@type view_mode() :: :auto | :editor | :agentic
```

Startup view mode requested by CLI flags.

# `apply_flag_implications`

```elixir
@spec apply_flag_implications(flags()) :: flags()
```

Applies flag implications to a flags map.

# `apply_flag_implications`

```elixir
@spec apply_flag_implications(flags(), String.t() | nil) :: flags()
```

Applies flag implications with file-aware startup view resolution.

# `argv_startup_project_root`

```elixir
@spec argv_startup_project_root() :: String.t() | nil
```

Returns the project root inferred from the current CLI argv before startup flags are stored.

# `cwd_startup_project_root`

```elixir
@spec cwd_startup_project_root() :: String.t() | nil
```

Returns the marked project root inferred from the current working directory, if any.

# `headless_args?`

```elixir
@spec headless_args?([String.t()]) :: boolean()
```

Returns true when args request headless mode.

# `info_flag_output`

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

Returns the output for info-only flags (`--version`/`-v`, `--help`/`-h`).

These flags should print and exit without booting the supervision tree,
so the application start path can short-circuit before doing any work.
Returns `:none` when the args don't request info-only output.

# `main`

```elixir
@spec main([String.t()]) :: :ok
```

Main entry point for the CLI.

# `minimal_args?`

```elixir
@spec minimal_args?([String.t()]) :: boolean()
```

Returns true when args request minimal mode (for GIT_EDITOR use).

# `parse_args`

```elixir
@spec parse_args([String.t()]) :: parsed()
```

Parses CLI arguments into an action.

# `safe_args?`

```elixir
@spec safe_args?([String.t()]) :: boolean()
```

Returns true when args request safe mode.

# `start_from_cli`

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

Entry point used by the OTP application in release/Burrito mode.

# `startup_flags`

```elixir
@spec startup_flags() :: flags()
```

Returns the startup flags stored by the CLI, or defaults if none were set.

# `startup_project_root`

```elixir
@spec startup_project_root() :: String.t() | nil
```

Returns the project root inferred from the stored startup CLI target, if any.

# `startup_project_root_from_args`

```elixir
@spec startup_project_root_from_args([String.t()]) :: String.t() | nil
```

Returns the project root inferred from raw CLI args, if they name a project or file inside a project.

# `terminal_command?`

```elixir
@spec terminal_command?([String.t()]) :: boolean()
```

Returns true when args request a terminal-only remote command.

# `terminal_command_args?`

```elixir
@spec terminal_command_args?([String.t()]) :: boolean()
```

Returns true when args request a terminal-only remote command after parsing flags.

---

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