@tdd_issue @tdd_issue_932 @tdd_issue_4178
Feature: TDD Issue #932 — plan apply missing --yes flag
  As a developer
  I want to verify that `agents plan apply` accepts the --yes
  flag required by the specification
  So that the bug is captured and will be caught by a regression test

  These scenarios verify that `apply` correctly handles
  `--yes`/`-y` flags as a regression guard.  Other destructive CLI
  commands (`session delete`, `project delete`, `plan correct`,
  `plan rollback`) correctly implement the `--yes`/`-y` pattern to skip
  confirmation prompts.

  Scenario: apply recognises the --yes long flag
    Given a plan CLI runner for the yes-flag test
    When I invoke apply with --yes flag and a mocked service
    Then the apply --yes invocation should not report an unknown option
    And the apply --yes output should not contain the confirmation prompt
    And the apply exit code should be 0
    And the apply should have called apply

  Scenario: apply recognises the -y short flag
    Given a plan CLI runner for the yes-flag test
    When I invoke apply with -y flag and a mocked service
    Then the apply -y invocation should not report an unknown option
    And the apply -y output should not contain the confirmation prompt
    And the apply exit code should be 0
    And the apply should have called apply

  Scenario: apply without --yes prompts for confirmation and user declines
    Given a plan CLI runner for the yes-flag test
    When I invoke apply without --yes and decline
    Then the apply output should contain "Apply cancelled."
    And the apply exit code should be 0
    And the apply should not have called apply

  Scenario: apply without --yes prompts for confirmation and user accepts
    Given a plan CLI runner for the yes-flag test
    When I invoke apply without --yes and accept
    Then the apply output should not contain "Apply cancelled."
    And the apply output should contain the confirmation prompt
    And the apply exit code should be 0
    And the apply should have called apply

  Scenario: apply catches unexpected exceptions cleanly
    Given a plan CLI runner for the yes-flag test
    When I invoke apply --yes with a service that raises an unexpected error
    Then the apply output should contain "Unexpected error"
    And the apply output should not contain "Traceback"
    And the apply exit code should be non-zero
