refactor: move extension command handlers to extensions/_commands.py (PR-7/8)#3014
Open
darion-yaphet wants to merge 2 commits into
Open
refactor: move extension command handlers to extensions/_commands.py (PR-7/8)#3014darion-yaphet wants to merge 2 commits into
darion-yaphet wants to merge 2 commits into
Conversation
…(PR-7/8) Convert the flat extensions.py module into an extensions/ package and extract all extension_app and catalog_app command handlers plus their private helpers (_resolve_installed_extension, _resolve_catalog_extension, _print_extension_info) out of __init__.py into the new extensions/_commands.py, mirroring the domain-dir layout used for presets/_commands.py (PR-6) and integrations/_commands.py (PR-5). - extensions.py -> extensions/__init__.py (pure rename, 99%); intra-module relative imports bumped from `.x` to `..x` since they reference root siblings. - Root helpers (_require_specify_project, _locate_bundled_extension, load_init_options, _display_project_path) are reached through thin shims that re-fetch from the parent package at call time, so test monkeypatching of specify_cli.<helper> keeps working unchanged. - __init__.py drops ~1444 lines (3511 -> 2067); CLI surface preserved via register(app). No behavior change. Full suite failure set is identical before/after (82 pre-existing env failures, 0 new).
5da1bab to
29be5d8
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the Specify CLI by extracting specify extension * and specify extension catalog * command handlers out of the specify_cli/__init__.py monolith into a dedicated extensions/_commands.py module, while converting extensions from a flat module into a package to support the domain-dir layout.
Changes:
- Introduces
src/specify_cli/extensions/_commands.pycontaining the Typer apps (extension,catalog) and all related command handlers, plus aregister(app)entry point. - Converts
extensions.pyintoextensions/__init__.pyand updates intra-package imports accordingly. - Re-attaches the extension command group from
specify_cli/__init__.pyvia_register_extension_cmds(app)to preserve the CLI surface.
Show a summary per file
| File | Description |
|---|---|
| src/specify_cli/extensions/_commands.py | New home for extension / catalog Typer apps and all extension-related CLI handlers (registered via register(app)). |
| src/specify_cli/extensions/init.py | Converts extensions into a package and adjusts relative imports to continue referencing root-package siblings. |
| src/specify_cli/init.py | Removes inline extension command definitions and registers the new extensions command module to keep the same CLI entry points. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 3
…ry the catalog - extension add --from: sanitize the extension label before building the download filename so "../" path separators can no longer escape the downloads dir and overwrite arbitrary files - extension list --available/--all: actually query the catalog and list uninstalled extensions (filtering out installed IDs), instead of only printing a static install hint that contradicted the CLI help and docs
mnriem
requested changes
Jun 17, 2026
mnriem
left a comment
Collaborator
There was a problem hiding this comment.
Please address Copilot feedback and resolve conflicts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR-7 of the 8-part effort to break up the
specify_cli/__init__.pymonolith. Continues the domain-dir layout established in PR-5 (integrations/_commands.py) and PR-6 (presets/_commands.py).This PR moves the
extension *andcatalog *command handlers out of__init__.py. Becauseextensionswas a flat module (unlike the already-packagepresets/integrations), it is first converted to a package.Changes
extensions.py→extensions/__init__.py— pure rename (99% identical). The module's intra-file relative imports are bumped from.xto..x, since they reference root-package siblings (.._init_options,..catalogs,..agents,..integrations, andfrom .. importforload_init_options,_print_cli_warning,AGENT_CONFIG,DEFAULT_SKILLS_DIR,_get_skills_dir).extensions/_commands.py— holdsextension_app,catalog_app, all 12 command handlers (list/add/remove/search/info/update/enable/disable/set-priority+ cataloglist/add/remove), the private helpers (_resolve_installed_extension,_resolve_catalog_extension,_print_extension_info), and aregister(app)entry point.__init__.pydrops ~1444 lines (3511 → 2067). The extension command group is re-attached viaregister(app), preserving the CLI surface.Monkeypatch compatibility
Root helpers (
_require_specify_project,_locate_bundled_extension,load_init_options,_display_project_path) are reached through thin shims in_commands.pythat re-fetch from the parent package at call time. This keeps existingspecify_cli.<helper>monkeypatch targets working with no test changes.Verification
extension/catalogcommand tree loads and all--helpsurfaces respond.No behavior change — pure structural move.