Feature: agents resource list shows devcontainer lifecycle state column
  As a CleverAgents user
  I want the resource list to show the lifecycle state for devcontainer-instance resources
  So that I can see whether a devcontainer is discovered, running, stopped, or failed

  Background:
    Given a fresh in-memory resource registry
    And built-in types are bootstrapped

  Scenario: resource list shows spec-required column headers
    Given a devcontainer-instance resource is registered
    When I run resource list with all flag
    Then the resource output should contain "Phys/Virt"
    And the resource output should contain "Children"
    And the resource output should contain "Projects"

  Scenario: resource list shows "discovered (not built)" for a new devcontainer-instance
    Given a devcontainer-instance resource is registered
    When I run resource list with all flag
    Then the resource output should contain "discovered (not built)"

  Scenario: resource list shows "running" state for a running devcontainer
    Given a devcontainer-instance resource is registered
    And the devcontainer lifecycle state is "running"
    When I run resource list with all flag
    Then the resource output should contain "running"

  Scenario: resource list shows "stopped" state for a stopped devcontainer
    Given a devcontainer-instance resource is registered
    And the devcontainer lifecycle state is "stopped"
    When I run resource list with all flag
    Then the resource output should contain "stopped"

  Scenario: resource list shows "failed" state for a failed devcontainer
    Given a devcontainer-instance resource is registered
    And the devcontainer lifecycle state is "failed"
    When I run resource list with all flag
    Then the resource output should contain "failed"

  Scenario: resource list shows empty state for non-container resources
    Given I run resource add "git-checkout" "local/my-repo" with path "/tmp/repo"
    When I run resource list
    Then the resource output should contain "local/my-repo"
    And the resource output should contain "git-checkout"

  Scenario: resource list shows warning banner when devcontainer is in discovered state
    Given a devcontainer-instance resource is registered
    When I run resource list with all flag
    Then the resource output should contain "Devcontainer discovered"

  Scenario: resource list does not show warning banner when devcontainer is running
    Given a devcontainer-instance resource is registered
    And the devcontainer lifecycle state is "running"
    When I run resource list with all flag
    Then the resource output should not contain "Devcontainer discovered"

  @tdd_issue @tdd_issue_4263 @tdd_expected_fail
  Scenario: resource list JSON output includes lifecycle_state for devcontainer-instance
    Given a devcontainer-instance resource is registered
    When I run resource list with all flag and format "json"
    Then the resource output should be valid JSON
    And the resource JSON output should contain key "lifecycle_state"

  Scenario: resource list JSON output has null lifecycle_state for non-container resources
    Given I run resource add "git-checkout" "local/my-repo" with path "/tmp/repo"
    When I run resource list with format "json"
    Then the resource output should be valid JSON
    And the resource JSON lifecycle_state should be null for non-container resources

  Scenario: resource list shows lifecycle state for container-instance resources
    Given a container-instance resource is registered
    When I run resource list with all flag
    Then the resource output should contain "discovered (not built)"

  Scenario: resource list succeeds gracefully when lifecycle tracker raises an error
    Given a devcontainer-instance resource is registered
    And the lifecycle tracker raises an error for the resource
    When I run resource list with all flag
    Then the resource list command should succeed
    And the resource output should contain "devcontainer-instance"
