# REQ-001: Auto-init with Confirmation

## Metadata
- **Status:** implemented
- **Priority:** high
- **Dependencies:** REQ-000
- **Created:** 2026-03-03
- **Implemented:** 2026-03-03

## Context

iEvo is a TUI-first interactive tool. When a user runs `ievo` without arguments, the primary flow is:

1. Run startup checks (`ensure_startup`) — Claude auth, telemetry opt-in.
2. Detect whether a project exists by scanning for `.ievo/manifest.yaml` up the directory tree.
3. If no project found: **ask the user before doing anything** — do not silently mutate the filesystem.
4. If the user confirms: run `init.init(name=".")` to scaffold the project.
5. Then launch the Textual TUI dashboard.

Previously, `ievo` with no args ran `init` unconditionally. The change makes the confirmation step mandatory.

**Key implementation details:**
- Entry point: `src/ievo/cli.py` — `main()` callback decorated with `@app.callback(invoke_without_command=True)`
- Project detection: `find_project_root()` from `ievo.core.config` — returns `Path | None`
- Confirmation: `typer.confirm("No iEvo project found. Initialize here?", default=True)`
- Graceful decline: prints info message, exits with code 0 (`typer.Exit(0)`)
- Auto-init path: calls `init.init(name=".")` — same function as `ievo init .`
- After init (or if project already exists): calls `run_tui()` from `ievo.tui.app`

**Startup flow:**
```python
if ctx.invoked_subcommand is None:
    home = ensure_home()
    ensure_startup(home)
    if find_project_root() is None:
        if not typer.confirm("No iEvo project found. Initialize here?", default=True):
            info("Run ievo again when ready to initialize.")
            raise typer.Exit(0)
        init.init(name=".")
    run_tui()
```

## Acceptance Criteria

- [x] `ievo` in a directory with `.ievo/manifest.yaml` → launches TUI directly, no confirmation prompt
- [x] `ievo` in a directory without `.ievo/manifest.yaml` → prints confirmation prompt before any filesystem changes
- [x] User confirms (`y`) → `init.init(name=".")` is called, then TUI launches
- [x] User declines (`n`) → exits with code 0, no files created, no TUI launched
- [x] User confirms → real `.ievo/manifest.yaml`, `agents/`, `spec/`, `plans/` are created on disk
- [x] Default answer for the confirmation prompt is `True` (pressing Enter without typing = "yes")

## Negative Acceptance Criteria

- Does NOT affect behavior when a subcommand is explicitly given (e.g. `ievo init`, `ievo add`)
- Does NOT bypass startup checks (Claude auth, telemetry) — those still run regardless
- Does NOT run `init` more than once if project is already initialized
- Does NOT change the behavior of `ievo init` as an explicit CLI command

## Technical Notes

Files: `src/ievo/cli.py`, `tests/test_cli_app.py`
Tests: `test_main_no_project_confirms_then_inits`, `test_main_no_project_user_declines_exits`, `test_auto_init_creates_project`, `test_main_no_subcommand_launches_tui`
