spec-kit
spec-kit copied to clipboard
refactor: move preset command handlers to presets/_commands.py (PR-6/8)
Summary
PR-6 of the __init__.py split (continues PR-5's integration co-location). Moves the preset command group out of src/specify_cli/__init__.py into a co-located presets/_commands.py, trimming __init__.py toward a thin registration layer.
Two commits:
presets.py→presets/package — pure structural move so command handlers can live beside the preset domain logic (mirrorsintegrations/).presets.pybecomespresets/__init__.py; package-relative imports rebased one level deeper. Public import surface (from specify_cli.presets import ...) unchanged.- Move handlers to
presets/_commands.py— thepreset_app/preset_catalog_appTyper groups and all 12 handlers (list,add,remove,search,resolve,info,set-priority,enable,disable,catalog list/add/remove) move out;__init__.pyregisters them via_register_preset_cmds(app).
__init__.py drops ~620 lines in the preset region.
Design notes
- Handlers lazy-import root helpers (
_require_specify_project,get_speckit_version,_locate_bundled_preset,_display_project_path) viafrom .. importinside each function, so test monkeypatching ofspecify_cli.<helper>keeps working — same pattern PR-5 used. _locate_bundled_presetkept as an explicit re-export in__init__.pyfor that resolution path.
Test plan
- [x]
python -c "import specify_cli"— OK - [x]
specify preset --help— full command surface intact - [x]
uvx ruff check src/— All checks passed - [x] Full suite: 3344 passed, 40 skipped
- [x] No patch-path updates needed (lazy imports preserve monkeypatch targets)