Add extension list command
Opened by swampadmin · 12/23/2024
Summary
Add an extension list (alias ls) command to show locally installed extensions. This is already specified in the design doc (design/extension.md) but not yet implemented.
Currently there's no way to see what extensions are installed without manually reading upstream_extensions.json. With push, pull, and rm already in place, list completes the extension management surface.
Why list (ls)
The verb list is the established convention across CLI tools for "show what's installed locally":
- Docker:
docker container ls,docker image ls,docker volume ls— consistentlylsfor enumerating local resources - npm:
npm ls— lists installed packages - brew:
brew list— lists installed formulae - pip:
pip list— lists installed packages - cargo:
cargo install --list— lists installed binaries
In contrast, search is the convention for querying a remote registry (e.g., npm search, docker search, brew search). Using list makes it immediately clear this operates on local state, not the registry.
Within swamp itself, list is already used by data list to enumerate items in a local scope. The extension command follows the same <noun> <verb> pattern as the rest of the CLI (extension push, extension pull, extension rm).
Behavior
- Reads
upstream_extensions.jsonfrom the models directory - Displays installed extensions sorted alphabetically by name
- Supports both
logandjsonoutput modes (like all swamp commands) - Default output: name, version, file count, pull date per extension
--verbose: additionally lists individual files under each extension (matching howextension rm --verboseshows per-file details)--json: always includes the fullfilesarray for structured consumers- Empty state: shows "No upstream extensions installed." with a CTA directing the user to
swamp extension pull @namespace/name
Options
--repo-dir <dir>— Repository directory (default:.)- Inherits global
--json,--verbose,--quietflags
Implementation
New files
src/presentation/output/extension_list_output.ts— output renderingsrc/cli/commands/extension_list.ts— CLI commandintegration/extension_list_test.ts— integration tests
Modified files
src/cli/commands/extension.ts— wire in the new subcommand
Reused infrastructure
readUpstreamExtensions()fromextension_pull.tscreateContext(),requireInitializedRepo(),resolveModelsDir()from existing CLI utilities
Tests
--helpshows usageextension --helpshowslistsubcommand- Requires initialized repo
- Empty repo shows "No upstream extensions installed" with CTA
--jsonwith no extensions returns{ extensions: [] }- Populated
upstream_extensions.jsondisplays entries correctly in both modes - Verbose mode shows individual files
Closed
No activity in this phase yet.
Sign in to post a ripple.