# Tasks: ReaScript-First Built-in Plugin Configuration

## Phase 1: Foundation (schema + commands)

- [x] 1.1 Add `builtin: bool = False` to `PluginDef` in `src/core/schema.py`
- [x] 1.2 Extend `ReaScriptCommand.action` to `str | list[str]`, add `plugins_to_add: list[dict]` in `commands.py`
- [x] 1.3 Add `added_plugins: list[dict]` to `ReaScriptResult`; update `write_command`/`read_result` in `commands.py`

## Phase 2: Core Implementation

- [x] 2.1 Add `_add_plugins_src()` generating `TrackFX_AddByName` + verification block in `__init__.py`
- [x] 2.2 Add `_configure_fx_params_src()` generating `TrackFX_SetParam` loop in `__init__.py`
- [x] 2.3 Refactor `_build_script()`: normalize `action` to list, emit dispatch loop calling per-action blocks in `__init__.py`
- [x] 2.4 Make `_api_check_src()` adaptive: require FX APIs only when `add_plugins`/`configure_fx_params` present in `__init__.py`
- [x] 2.5 Extract `REAPER_BUILTINS` frozenset + `get_builtin_plugins(song)` export in `src/reaper_builder/__init__.py`
- [x] 2.6 Skip VST element generation for `builtin=True` plugins in `_build_fx_chain()` in `src/reaper_builder/__init__.py`

## Phase 3: Integration

- [x] 3.1 Add `--plugins-config` flag; derive `plugins_to_add` from song, normalize action to list in `scripts/run_in_reaper.py`

## Phase 4: Testing

- [x] 4.1 Unit: multi-action dispatch generates correct per-action functions (parametrized action lists) in `test_reaper_scripting.py`
- [x] 4.2 Unit: adaptive `check_api` requires FX APIs only with `add_plugins`; backward compat for string action
- [x] 4.3 Unit: `plugins_to_add`/`added_plugins` JSON round-trip serialization in `test_reaper_scripting.py`
- [x] 4.4 Integration: `builtin=True` PluginDef skipped in RPP `.rpp` output, listed in command in `test_reaper_scripting.py`
- [x] 4.5 Regression: run full `pytest` suite; all 317 tests pass (298 existing + 19 new)
