Add help and shell completion support to CLI - #594
Draft
razor-x wants to merge 2 commits into
Draft
Conversation
Add 'seam completion <bash|fish|zsh>', which prints a completion script derived from the API definitions bundled with the CLI. The script completes command paths, per-command flags, and flag values for enum and boolean parameters. Write the same scripts to completions/ on prepack and publish them, so a system package can install them without running the CLI. Completions are always generated from the bundled definitions so that they work offline and without logging in. They may lag the definitions served by Seam when config use-remote-api-defs is enabled. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016eYkGybhEJJE3FkaqXdwLv
Help was one static page listing four examples and a single option, no matter which command it followed. Render it from the same command spec that drives completions instead, so it answers the command it is passed with: seam --help every top level command seam devices --help the commands under seam devices seam devices list --help the options seam devices list accepts Command help documents every parameter of the endpoint, marking the required ones and naming the values of enum and boolean parameters. An unrecognized command path reports itself rather than printing the root guide. Move the command spec out of lib/completion, since completions are now one of its two consumers, and keep shell quoting in the completion renderers so help can carry the full text of a description. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016eYkGybhEJJE3FkaqXdwLv
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.
This PR adds comprehensive help documentation and shell completion scripts to the Seam CLI, making it more user-friendly and discoverable.
Summary
The CLI now generates help guides and completion scripts dynamically from the API blueprint. Users can run
seam --helpto see available commands,seam <command> --helpfor command details, and install completion scripts for bash, fish, and zsh shells.Key Changes
Command Specification System (
src/lib/command-spec.ts): Created a new module that derives a structured command specification from the API blueprint, including:Help Rendering (
src/lib/render-help.ts): Implemented dynamic help guide generation that:command-line-usagelibrary for consistent formattingShell Completion Scripts: Added renderers for three shells:
src/lib/completion/render-bash.ts): Case-based completion with flag value supportsrc/lib/completion/render-zsh.ts): Descriptive completion with inline help textsrc/lib/completion/render-fish.ts): Guard-based completion with helper functionssrc/lib/completion/index.ts): Unified interface for rendering completionsCompletion Utilities (
src/lib/completion/describe.ts): Helper to safely format descriptions for shell scripts by removing special characters and truncating to fit completion menusCLI Integration (
src/bin/cli.ts): Updated the main CLI to:seam completion <shell>commands--helpflag with command path awarenessBuild Process (
prepack.ts): Extended to generate and package completion scripts in acompletions/directory during buildDocumentation (
README.md): Added sections explaining help usage and shell completion installationTesting: Added comprehensive test suites for command spec derivation, help rendering, and completion generation with a test blueprint fixture
Notable Implementation Details
https://claude.ai/code/session_016eYkGybhEJJE3FkaqXdwLv