@tdd_issue @tdd_issue_1023
Feature: TDD Bug #1023 — CLI commands should succeed without explicit init
  As a developer
  I want to verify that CLI commands that touch the database succeed
  without requiring an explicit `agents init` invocation first
  So that the bug is captured and will be caught by a regression test

  Bug #1023 reports that running any DB-dependent CLI command (e.g.,
  `resource add`, `project create`) in a fresh environment fails with
  `sqlite3.OperationalError: unable to open database file` even when
  `CLEVERAGENTS_AUTO_APPLY_MIGRATIONS=true` is set.  The specification
  implies that initialization should happen implicitly.

  The root cause is that `CLEVERAGENTS_AUTO_APPLY_MIGRATIONS=true`
  triggers schema migrations on an existing database but does NOT create
  the database file or its parent directory structure.  A manual
  `agents init --yes --force` is required first.

  These tests assert the expected behaviour (implicit init) and will
  fail until the bug is fixed. The @tag inverts the
  result so CI remains green while the defect is open.

  @tdd_issue @tdd_issue_4280 @tdd_expected_fail
  Scenario: Resource add succeeds in a fresh environment without explicit init
    Given a fresh isolated environment for tdd-implicit-init
    And CLEVERAGENTS_AUTO_APPLY_MIGRATIONS is set to true
    When I run the CLI command "resource add git-checkout local/tdd-test-resource --path . --branch main" without prior init
    Then the tdd-implicit-init command should exit with code 0
    And the tdd-implicit-init command output should contain "tdd-test-resource"

  @tdd_issue @tdd_issue_4280 @tdd_expected_fail
  Scenario: Project create succeeds in a fresh environment without explicit init
    Given a fresh isolated environment for tdd-implicit-init
    And CLEVERAGENTS_AUTO_APPLY_MIGRATIONS is set to true
    When I run the CLI command "project create local/tdd-test-project" without prior init
    Then the tdd-implicit-init command should exit with code 0
    And the tdd-implicit-init command output should contain "tdd-test-project"
