@cli
Feature: Core system commands (version, info, diagnostics)
  As a user of CleverAgents
  I want version, info, and diagnostics commands
  So that I can inspect the system state and troubleshoot issues

  # -- version command --

  Scenario: Version command shows version string
    When I run the system version command
    Then the system version output should contain "1.0.0"
    And the system version output should contain "CleverAgents"

  Scenario: Version command with plain format
    When I run the system version command with format "plain"
    Then the system version output should contain "version: 1.0.0"

  Scenario: Version command with json format
    When I run the system version command with format "json"
    Then the system version json output should have key "version" with value "1.0.0"
    And the system version json output should have key "schema" with value "v3"
    And the system version json output should have key "channel" with value "stable"

  Scenario: Version command with yaml format
    When I run the system version command with format "yaml"
    Then the system version output should contain "version: 1.0.0"
    And the system version output should contain "schema: v3"

  Scenario: Version command includes python version
    When I run the system version command with format "json"
    Then the system version json output should have key "python"

  Scenario: Version command includes build metadata
    When I run the system version command with format "json"
    Then the system version json output should have key "build_date"
    And the system version json output should have key "commit"
    And the system version json output should have key "platform"

  Scenario: Version command includes dependencies
    When I run the system version command with format "json"
    Then the system version json output should have nested key "dependencies"

  # -- info command --

  Scenario: Info command shows environment details
    When I run the system info command
    Then the system info output should contain "Environment"
    And the system info output should contain "Runtime"

  Scenario: Info command with json format
    When I run the system info command with format "json"
    Then the system info json output should have key "version" with value "1.0.0"
    And the system info json output should have key "data_dir"
    And the system info json output should have key "database"
    And the system info json output should have key "server_mode"

  Scenario: Info command with plain format
    When I run the system info command with format "plain"
    Then the system info output should contain "version: 1.0.0"
    And the system info output should contain "server_mode:"

  Scenario: Info command shows provider count
    When I run the system info command with format "json"
    Then the system info json output should have key "providers_configured"

  Scenario: Info command shows automation level
    When I run the system info command with format "json"
    Then the system info json output should have key "automation"

  Scenario: Info command shows storage info
    When I run the system info command with format "json"
    Then the system info json output should have nested key "storage"

  # -- diagnostics command --

  Scenario: Diagnostics command runs checks
    When I run the system diagnostics command
    Then the system diagnostics output should contain "Checks"
    And the system diagnostics output should contain "Summary"

  Scenario: Diagnostics command with json format
    When I run the system diagnostics command with format "json"
    Then the system diagnostics json output should have key "checks"
    And the system diagnostics json output should have key "summary"
    And the system diagnostics json output should have key "recommendations"

  Scenario: Diagnostics json summary has counts
    When I run the system diagnostics command with format "json"
    Then the system diagnostics json summary should have key "total"
    And the system diagnostics json summary should have key "warnings"
    And the system diagnostics json summary should have key "errors"
    And the system diagnostics json summary should have key "duration_s"

  Scenario: Diagnostics checks include config file
    When I run the system diagnostics command with format "json"
    Then the system diagnostics checks should include "Config file"

  Scenario: Diagnostics checks include database
    When I run the system diagnostics command with format "json"
    Then the system diagnostics checks should include "Database"

  Scenario: Diagnostics checks include git
    When I run the system diagnostics command with format "json"
    Then the system diagnostics checks should include "Git"

  Scenario: Diagnostics checks include disk space
    When I run the system diagnostics command with format "json"
    Then the system diagnostics checks should include "Disk space"

  Scenario: Diagnostics checks include file permissions
    When I run the system diagnostics command with format "json"
    Then the system diagnostics checks should include "File permissions"

  Scenario: Diagnostics --check exits zero when no errors
    When I run the system diagnostics command with check flag
    Then the system diagnostics exit code should be 0

  Scenario: Diagnostics with plain format
    When I run the system diagnostics command with format "plain"
    Then the system diagnostics output should contain "checks:"
    And the system diagnostics output should contain "summary:"

  Scenario: Diagnostics recommendations are a list
    When I run the system diagnostics command with format "json"
    Then the system diagnostics json recommendations should be a list
