Feature: Interactive REPL
  The `agents repl` command provides an interactive session for dispatching
  CLI commands without the leading `agents` prefix.

  Scenario: REPL dispatches version command
    Given the REPL is started
    When I send the input "version"
    Then the REPL output should contain "CleverAgents"
    And the REPL exit code should be 0

  Scenario: REPL handles :exit command
    Given the REPL is started
    When I send the input ":exit"
    Then the REPL should exit cleanly

  Scenario: REPL handles :quit command
    Given the REPL is started
    When I send the input ":quit"
    Then the REPL should exit cleanly

  Scenario: REPL handles :help command
    Given the REPL is started
    When I send the input ":help"
    Then the REPL output should contain "Built-in commands"
    And the REPL output should contain ":exit"

  Scenario: REPL handles unknown command gracefully
    Given the REPL is started
    When I send the input "nonexistent-cmd"
    Then the REPL output should contain "Error"

  Scenario: REPL repeats last command with !!
    Given the REPL is started
    When I send the input "version"
    And I send the input "!!"
    Then the REPL output should contain "CleverAgents"

  Scenario: REPL reports no previous command for !!
    Given the REPL is started
    When I send the input "!!"
    Then the REPL output should contain "No previous command"

  Scenario: REPL supports multi-line input
    Given the REPL is started
    When I send a multi-line version command
    Then the REPL output should contain "CleverAgents"

  Scenario: REPL with history disabled
    Given the REPL is started with --no-history
    When I send the input "version"
    Then the REPL output should contain "CleverAgents"
    And no history file should be written

  Scenario: REPL with history enabled writes history file
    Given the REPL is started with a custom history path
    When I send the input "version"
    And the REPL exits
    Then the history file should exist

  Scenario: REPL shows prompt context from environment
    Given the environment variable "CLEVERAGENTS_PROJECT" is set to "myproj"
    And the environment variable "CLEVERAGENTS_PLAN" is set to "myplan"
    When I query the REPL prompt context
    Then the prompt should contain "myproj"
    And the prompt should contain "myplan"

  Scenario: REPL handles Ctrl-C gracefully
    Given the REPL is started
    When I simulate a KeyboardInterrupt during input
    Then the REPL should continue running

  Scenario: REPL handles Ctrl-D for clean exit
    Given the REPL is started
    When I simulate an EOFError during input
    Then the REPL should exit cleanly

  Scenario: REPL handles empty input
    Given the REPL is started
    When I send an empty input line
    Then the REPL should continue without error

  Scenario: REPL dispatches config list command
    Given the REPL is started
    When I send the input "config list --format json"
    Then the REPL exit code should be 0
