@cli_streaming
Feature: CLI Streaming Integration
  As a developer using CleverAgents
  I want to see real-time progress when generating plans
  So that I can track the AI's progress and debug issues

  Background:
    Given a temporary directory
    And I initialize a new project named "streaming-test"
    And I add a test file to the project

  Scenario: Tell command without streaming flag works as before
    When I run tell command "add error handling" without streaming
    Then the command should complete successfully
    And the output should contain "Plan created"
    And the output should not contain "Loading context"

  Scenario: Tell command with streaming flag shows real-time progress
    When I run tell command "add error handling" with streaming
    Then the command should complete successfully
    And the output should contain "Starting plan generation"
    And the output should contain "Loading context files"
    And the output should contain "Analyzing requirements"
    And the output should contain "Generating plan"
    And the output should contain "Validating plan"

  Scenario: Streaming output shows timing information
    When I run tell command "add tests" with streaming
    Then the command should complete successfully
    And the output should match the pattern "✓.*\(\d+\.\d+s\)"

  Scenario: Streaming shows node completion checkmarks
    When I run tell command "refactor code" with streaming
    Then the command should complete successfully
    And the output should contain "✓ Loading context files"
    And the output should contain "✓ Analyzing requirements"
    And the output should contain "✓ Generating plan"

  Scenario: Streaming tell honors actor selection
    Given actor overrides are stubbed with default "openai" and alternates "anthropic"
    When I run tell command "use defaults" with streaming
    And I run tell command "use override" with streaming and actor "anthropic"
    Then the actor resolver should resolve actors "openai,anthropic" in order
    And actor stub "openai" should record 1 streaming call(s)
    And actor stub "anthropic" should record 1 streaming call(s)

  Scenario: Streaming progress updates in real-time
    When I run tell command "add documentation" with streaming
    Then each node should show progress before completion
    And timing should be sequential

  Scenario: Non-streaming mode is faster for simple commands
    When I measure time for tell command "simple change" without streaming
    And I measure time for tell command "another simple change" with streaming
    Then both commands should complete successfully
    And both should create valid plans

  Scenario: Streaming handles errors gracefully
    Given the AI provider is configured to fail
    When I run tell command "this will fail" with streaming
    Then the command should fail with an error message
    And the output should show which node failed
    And the error message should be user-friendly

  Scenario: Streaming works with custom plan names
    When I run tell command "add feature" with name "custom-plan" and streaming
    Then the command should complete successfully
    And a plan named "custom-plan" should exist
    And the output should show streaming progress

  Scenario: Streaming output is properly formatted with Rich
    When I run tell command "add logging" with streaming
    Then the command should complete successfully
    And the output should use colored text
    And the output should have proper indentation
    And checkmarks and spinners should be properly rendered

  Scenario: Multiple sequential streaming commands work correctly
    When I run tell command "first change" with streaming
    And I wait for completion
    And I run tell command "second change" with streaming
    Then both commands should complete successfully
    And each should show independent progress

  Scenario: Streaming works with large context
    Given I add 10 files to the project
    When I run tell command "refactor all files" with streaming
    Then the command should complete successfully
    And the loading context step should take longer
    And all workflow stages should complete

  Scenario: Streaming handles interruption gracefully
    When I run tell command "long operation" with streaming
    Then the command should complete successfully
    And no corrupted state should remain
    And all workflow stages should complete

  Scenario: Streaming progress persists across checkpoints
    When I run tell command "complex task" with streaming
    Then the command should complete successfully
    And checkpoint data should be saved
    And the workflow should be resumable if interrupted

  Scenario: Streaming shows validation failures clearly
    Given the AI provider generates invalid code
    When I run tell command "add feature" with streaming
    Then the validation node should show an error
    And the output should explain the validation failure
    And suggestions for fixing should be provided

  Scenario: Streaming output works in non-TTY environments
    When I run tell command "add feature" with streaming
    Then the command should complete successfully
    And the output should be plain text
    And progress information should still be visible

  Scenario: Help text documents streaming flag
    When I run "agents tell --help"
    Then the output should contain "--stream"
    And the description should mention "real-time progress"

  Scenario: Streaming tell forwards actor options to provider
    Given actor overrides are stubbed with default "alpha" and alternates ""
    And actor stub "alpha" uses config blob {"provider": "alpha", "model": "alpha-model", "options": {"temperature": 0.2}, "graph_descriptor": {"nodes": 1}, "initial_context": {"branch": "main"}}
    And I have a context file with 1 python files
    When I run tell command "add feature" with streaming
    Then provider stub "alpha" should receive actor context with options {"temperature": 0.2} graph {"nodes": 1} initial context {"branch": "main"}
