# `Jido.Messaging.MsgContext.CommandParser`
[🔗](https://github.com/agentjido/jido_messaging/blob/v1.0.0/lib/jido_messaging/msg_context/command_parser.ex#L1)

Deterministic command parser for normalized inbound message text.

The parser is intentionally bounded and conservative for hot-path safety.

# `command_envelope`

```elixir
@type command_envelope() :: %{
  status: parse_status(),
  source: :body | :mention_stripped,
  prefix: String.t() | nil,
  name: String.t() | nil,
  args: String.t() | nil,
  argv: [String.t()],
  reason: reason() | nil,
  text_bytes: non_neg_integer()
}
```

# `parse_status`

```elixir
@type parse_status() :: :ok | :none | :error
```

# `reason`

```elixir
@type reason() ::
  :empty_text
  | :not_command
  | :text_too_long
  | :missing_command_name
  | :invalid_command_name
  | :invalid_prefixes
  | :invalid_text
```

# `normalize_prefixes`

```elixir
@spec normalize_prefixes(term()) :: [String.t()]
```

Returns normalized command prefixes.

# `parse`

```elixir
@spec parse(
  String.t() | nil,
  keyword()
) :: command_envelope()
```

Parses a command envelope from text.

## Options

  * `:prefixes` - accepted command prefixes (default: `["/", "!"]`)
  * `:max_text_bytes` - upper bound for parser evaluation (default: `2048`)

# `with_source`

```elixir
@spec with_source(command_envelope(), :body | :mention_stripped) :: command_envelope()
```

Re-tags a parser envelope with a specific parse source.

---

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