Feature: TUI /help command lists all catalogued slash commands
  The /help slash command must dynamically list all commands from
  SLASH_COMMAND_SPECS rather than returning a hardcoded string.
  It must also support /help <command> for command-specific help.

  Background:
    Given the TUI commands module is imported
    And a TuiCommandRouter with a mock registry and state

  # ---------- /help with no arguments ----------

  Scenario: /help with no args returns header line
    When I call handle with raw input "help"
    Then the handle result should contain "Available slash commands:"

  Scenario: /help with no args lists all 70 catalogued commands
    When I call handle with raw input "help"
    Then the help result contains all 70 catalogued commands

  Scenario: /help with no args groups commands by namespace
    When I call handle with raw input "help"
    Then the handle result should contain "Session:"
    And the handle result should contain "Persona:"
    And the handle result should contain "Plan:"
    And the handle result should contain "Utility:"

  Scenario: /help with no args uses colon-namespaced format
    When I call handle with raw input "help"
    Then the handle result should contain "persona:list"
    And the handle result should contain "session:create"
    And the handle result should contain "plan:rollback"
    And the handle result should contain "context:inspect"

  Scenario: /help with no args does not contain old hardcoded listing
    When I call handle with raw input "help"
    Then the handle result should not be "Commands: /persona, /session, /help"

  # ---------- /help <command> with a known command ----------

  Scenario: /help persona:list returns command-specific help
    When I call handle with raw input "help persona:list"
    Then the handle result should contain "/persona:list"
    And the handle result should contain "Persona"
    And the handle result should contain "Display all personas"

  Scenario: /help session:export returns command-specific help
    When I call handle with raw input "help session:export"
    Then the handle result should contain "/session:export"
    And the handle result should contain "Session"
    And the handle result should contain "Export session to JSON"

  Scenario: /help help returns help command-specific help
    When I call handle with raw input "help help"
    Then the handle result should contain "/help"
    And the handle result should contain "Utility"
    And the handle result should contain "Show help"

  Scenario: /help with leading slash on command name still works
    When I call handle with raw input "help /persona:set"
    Then the handle result should contain "/persona:set"
    And the handle result should contain "Switch active persona"

  # ---------- /help <unknown> ----------

  Scenario: /help with unknown command returns not-found message
    When I call handle with raw input "help nonexistent:command"
    Then the handle result should contain "Unknown command: /nonexistent:command"

  Scenario: /help with completely unknown command returns not-found message
    When I call handle with raw input "help foobar"
    Then the handle result should contain "Unknown command: /foobar"
