fix(extensions): wire up list --available catalog query + harden add --from path traversal
What
Wires up the long-advertised extension list --available / --all catalog listing, and hardens extension add --from against path traversal. Split out of the PR-7 structural refactor (#3014) so the behavior change is reviewed on its own, with tests.
Depends on #3014. This branch is built on top of
refactor/split-init-pr7because the handler lives inextensions/_commands.py, which that refactor introduces. Until #3014 merges, its structural-move commit will also show in this diff; it disappears once #3014 lands inmain.
Why
The --available / --all flags have existed since the original extension system (#1551), and their help text has always advertised "Show available extensions from catalog." But the implementation was a stub — it printed a static specify extension add <name> hint and never queried the catalog, even though ExtensionCatalog already existed. This is a long-standing dead/misleading-flag fix, not a new feature, and it's orthogonal to the refactor — which is why it's pulled out of #3014.
Changes
extension list --available/--all: query the catalog and list uninstalled extensions (filtering out installed IDs).--availablelists catalog-only;--alllists installed + available; discovery-only entries are marked; a clear error is surfaced and the command exits non-zero when the catalog is unavailable.extension add --from <url>: sanitize the extension label before building the download filename, so../-style separators can no longer escape the downloads cache dir (path traversal).
Tests
test_extension_list_available.py— catalog query, installed-ID filtering, discovery-only entries, empty catalog, catalog-error exit,--allshowing both sections.test_extension_add_path_traversal.py— a traversal label is sanitized so the download stays inside the downloads dir.
Both suites verified red against the pre-fix behavior and green after.
Please address Copilot feedback
Please address Copilot feedback
Please address Copilot feedback
Please address Copilot feedback
Please address Copilot feedback
Please address Copilot feedback. And fix test & lint errors. Maybe pull in upstream/main?