Feature: Plan CLI commands new coverage
  As a developer
  I want to cover the remaining uncovered lines in plan.py
  So that plan diff (with/without correction), plan artifacts, and _get_apply_service are fully tested

  # ---------- plan diff with --correction flag (lines 1856-1867) ----------

  Scenario: Plan diff with correction flag shows correction panel
    Given new_cov no service mocks are needed
    When new_cov I run plan diff for "plan-100" with correction "corr-42"
    Then new_cov the exit code should be 0
    And new_cov the output should contain "Correction Diff"
    And new_cov the output should contain "corr-42"
    And new_cov the output should contain "plan-100"

  # ---------- plan diff without correction (lines 1869-1871) ----------

  Scenario: Plan diff without correction calls service diff
    Given new_cov the apply service diff returns "--- a/app.py\n+++ b/app.py\n@@ -1 +1 @@"
    When new_cov I run plan diff for "plan-200"
    Then new_cov the exit code should be 0
    And new_cov the output should contain "app.py"

  Scenario: Plan diff without correction with json format
    Given new_cov the apply service diff returns '{"entries": [], "summary": {}}'
    When new_cov I run plan diff for "plan-201" with format "json"
    Then new_cov the exit code should be 0
    And new_cov the output should contain "entries"

  # ---------- plan diff error paths ----------

  Scenario: Plan diff raises PlanError
    Given new_cov the apply service diff raises PlanError "changeset missing"
    When new_cov I run plan diff for "plan-bad"
    Then new_cov the exit code should be nonzero
    And new_cov the output should contain "Diff Error"
    And new_cov the output should contain "changeset missing"

  Scenario: Plan diff raises CleverAgentsError
    Given new_cov the apply service diff raises CleverAgentsError "backend down"
    When new_cov I run plan diff for "plan-err"
    Then new_cov the exit code should be nonzero
    And new_cov the output should contain "Error"
    And new_cov the output should contain "backend down"

  # ---------- plan artifacts (lines 1901-1904) ----------

  Scenario: Plan artifacts calls service artifacts
    Given new_cov the apply service artifacts returns "changeset_id: cs-999\nfiles: 3"
    When new_cov I run plan artifacts for "plan-300"
    Then new_cov the exit code should be 0
    And new_cov the output should contain "cs-999"

  Scenario: Plan artifacts with json format
    Given new_cov the apply service artifacts returns '{"changeset_id": "cs-abc", "files": 5}'
    When new_cov I run plan artifacts for "plan-301" with format "json"
    Then new_cov the exit code should be 0
    And new_cov the output should contain "cs-abc"

  # ---------- plan artifacts error paths ----------

  Scenario: Plan artifacts raises PlanError
    Given new_cov the apply service artifacts raises PlanError "plan not found"
    When new_cov I run plan artifacts for "plan-missing"
    Then new_cov the exit code should be nonzero
    And new_cov the output should contain "Artifacts Error"
    And new_cov the output should contain "plan not found"

  Scenario: Plan artifacts raises CleverAgentsError
    Given new_cov the apply service artifacts raises CleverAgentsError "timeout"
    When new_cov I run plan artifacts for "plan-timeout"
    Then new_cov the exit code should be nonzero
    And new_cov the output should contain "Error"
    And new_cov the output should contain "timeout"

  # ---------- _get_apply_service real body (lines 1817-1822) ----------

  Scenario: _get_apply_service imports PlanApplyService and creates it
    Given new_cov a mocked lifecycle service for apply service creation
    When new_cov I call _get_apply_service directly
    Then new_cov the returned object should be a PlanApplyService instance
    And new_cov PlanApplyService was constructed with the lifecycle service
