## ADDED Requirements ### Requirement: Workflow listing The CLI SHALL provide a `list` command that displays all discovered workflows and their descriptions. #### Scenario: List workflows - **WHEN** `ion list` is run - **THEN** all discovered workflows SHALL be listed with name, description, and source (bundled/project) ### Requirement: Workflow execution The CLI SHALL provide a `run` command that executes a workflow by name with optional arguments. #### Scenario: Run workflow with message - **WHEN** `ion run analyze "analyze the codebase"` is run - **THEN** the `analyze` workflow SHALL execute with the provided user message #### Scenario: Run in specific directory - **WHEN** `ion run build --cwd /path/to/project` is run - **THEN** the workflow SHALL use the specified working directory #### Scenario: Run with specific store - **WHEN** `ion run deploy --store sqlite --db-path ./ion.db` is run - **THEN** the specified store backend SHALL be used ### Requirement: Workflow approval commands The CLI SHALL provide `approve` and `reject` commands for responding to approval gates. #### Scenario: Approve a paused workflow - **WHEN** `ion approve ` is run - **THEN** the workflow SHALL resume from the paused approval node #### Scenario: Approve with comment - **WHEN** `ion approve "looks good"` is run - **THEN** the comment SHALL be recorded and available as `$nodeId.output` #### Scenario: Reject with reason - **WHEN** `ion reject "needs changes"` is run - **THEN** `$REJECTION_REASON` SHALL be set to "needs changes" - **THEN** if `on_reject` is configured, the handler SHALL execute ### Requirement: Workflow run management The CLI SHALL provide `status`, `runs`, `resume`, `abandon`, and `cleanup` commands. #### Scenario: Show running workflows - **WHEN** `ion status` is run - **THEN** all active (running + paused) workflow runs SHALL be displayed #### Scenario: List recent runs - **WHEN** `ion runs` is run - **THEN** recent workflow runs SHALL be listed with status and timestamps #### Scenario: Resume failed run - **WHEN** `ion resume ` is run - **THEN** the failed run SHALL be resumed, skipping completed nodes #### Scenario: Abandon run - **WHEN** `ion abandon ` is run - **THEN** the run SHALL be marked as cancelled #### Scenario: Cleanup old runs - **WHEN** `ion cleanup` is run (default 7 days) - **THEN** runs older than the retention period SHALL have their artifacts removed ### Requirement: SOP-to-YAML conversion The CLI SHALL provide a `convert` command to transpile `.sop.md` files to `.yaml`. #### Scenario: Convert SOP to YAML - **WHEN** `ion convert workflow.sop.md` is run - **THEN** a `workflow.yaml` SHALL be written with the equivalent DAG representation ### Requirement: Machine-readable output Workflow commands SHALL support `--json` flag for machine-readable output. #### Scenario: JSON output for automation - **WHEN** `ion list --json` is run - **THEN** output SHALL be valid JSON array of workflow objects