feat(cli): superset schema, completion and config check
Lands the three self-describing/DX commands from #7103 as their own PR, rebuilt on today's main. The terminal primitives (wait, wait-output, send-keys) are a sibling PR; attach, resume-all and explain stay on #7103.
What is here
superset completion <bash|zsh>prints a completion script generated from the command tree: command names at every level (an alias already typed is walked through), each command's flags and aliases, enum values for flags (--flag=valuetoo) and positionals, and the globals. The script is printed byte for byte in every output mode (agent auto-JSON,--json,--quiet).superset schemaprints the whole command tree as JSON, sorted and with absent fields omitted, so two versions diff cleanly. Internal-only and sandbox-hidden commands are left out, exactly as--helpleaves them out.superset config checkvalidatesconfig.json: JSON syntax, the shape ofauth,apiKeyandorganizationId, token expiry, and keys this version does not read. Exits 1 on an error, 0 on warnings or when there is no file.- Docs: three sections in the CLI reference, and a "Shell & tooling" section in
superset --help.
Changed from #7103
introspectCli()is built from the audience- and sandbox-filtered tree the runner already routed on, so it cannot list a command the run cannot execute (CodeRabbit), and the slot is cleared whenrun()returns (CodeRabbit). It returnsCliDescription({ name, version, root }) and both generators take that directly.- The framework gains
{ raw: string }command results: printed verbatim under--json,--quietand agent mode, with no trailing newline added.completionreturns one instead of writing toprocess.stdoutitself, and--jsonno longer wraps the script in{ shell, script }. - The runner enforces
.enum()on positional arguments (superset completion fish→Valid values: bash, zsh). That replaces the command-level lookup CodeRabbit flagged for prototype-chain keys. No existing command declares an enum positional. config-checkkeys are a{ [K in keyof SupersetConfig]-?: check }record: a field added toSupersetConfigdoes not compile until it has a check, and a check for a removed field is an excess key. Reading moved intocheckConfigFile, which reports an unreadable file as an error instead of throwing (CodeRabbit). The expired-token warning says whether the next command will refresh.config checksets exit code 1 when the file is invalid.- Schema: adds
version,int/min/max, a separateSchemaArgshape, options sorted by name with a locale-independent comparator;enumVals→enum,envVar→env,isVariadic→variadic. - Completion: the word walk is one generator shared by the bash and zsh scripts;
visibleChildrenis shared withhelp.ts. - The runner exits quietly on EPIPE.
superset schema | headprintedError: EPIPE: broken pipe, write; this was true of every command and is only more visible with document-sized output. packages/cli-frameworkgets atestscript. It had none, so turbo and CI never ran its tests (the existing router, output, runner and interactive-help tests included).- Tests: the bash script runs in a real
bashwithCOMPREPLYassertions; the zsh script is parse-checked withzsh -n;introspectCliis exercised throughrun();checkConfigFileis tested against a missing file and a directory. - Not carried over: the
herdrsubmodule pointer, the two HTML reports, and the orchestrate SKILL.md changes.
Verified
Each shell was driven by expect in a scratch session with this worktree's build first on PATH. In every one, superset term<TAB> completed to superset terminals , superset terminals read --<TAB> listed --workspace through --json, superset ws cr<TAB> completed to superset ws create , and superset completion <TAB> offered bash zsh.
| Shell | Loaded with |
|---|---|
| zsh 5.9 | source <(superset completion zsh) |
| zsh 5.9 | _superset on fpath, autoloaded by compinit |
| bash 5.3 | source <(superset completion bash) |
bash 3.2 (macOS /bin/bash) | eval "$(superset completion bash)" |
bash 3.2 cannot source a process substitution at all (it reads zero bytes, even for source <(echo …)), so the docs give the eval form for bash.
superset schema --jsonis byte-identical across runs;SUPERSET_CLI_AUDIENCE=internaladds exactly the internal groups.superset config checkagainst a valid, invalid, expired, missing and unreadable (directory) file: exit codes 0, 1, 0, 0, 1, with the human and--jsonoutput.superset completion zshunderCLAUDE_CODE=1,--jsonand--quietis the same script;superset schemaprints JSON in every mode./ci-check: lint:fix (no warnings), sherif, typecheck and check:i18n are clean.bun run testpasses 22 of 25 turbo tasks from this worktree; the three that fail touch no file on this branch: trpc (7deriveSandboxCredentialstests, a JWT signing error from an empty secret in the local env), host-service (5 here, 8 on a pristineorigin/maincheckout in the same session), desktop (34 git-helper tests that follow the directory, not the code: the same HEAD checked out at another path passes 7758 with the one known env-sensitive failure, as doesorigin/main).- Each of the five commits typechecks and passes the framework tests on its own.
- Screenshots of every session, plus the schema and config check output: https://app.superset.sh/page/superset-schema-completion-and-config-check-1f42qt
Review follow-ups
- CodeRabbit: the generated zsh function declared
local path, which zsh ties toPATH, so it ran with an emptyPATH. Renamed tocmdpathin both shells; a test asserts nopathlocal is ever generated. - Greptile: an expired token with no refresh token was reported as logged in.
config checknow reportsloggedIn: falsewith a warning naming the coming "Session expired", and uses the same five-minute leeway asresolveAuth(one constant inconfig.ts, read by both). - Greptile:
--priority=ur<Tab>completes to--priority=urgentin both shells, including bash's split of the word at=. - Greptile: enum values are validated for variadic positionals too.
- Greptile: a raw result is one that carries only
raw;{ raw, data }is data again, and the type forbids the combination. - Greptile, alias completion: kept as is. Candidates are canonical names on purpose (
ws,t,term,auto,orgbeside their full names would be noise); an alias already typed is walked through. The sentence in the docs that promised more was reworded.
After these: the four shell sessions were re-run on the rebuilt binary (every check passes), plus --priority=u<Tab> in zsh and bash and a check that zsh's PATH is intact after completing.
Second round (cubic and CodeRabbit on the first follow-ups)
- Completion: the walk honours
--(everything after is positional, dispatch offers only the positional enum or files), skips a boolean's explicittrue/false, and skips both words of readline's split--flag = value; a free-form value attached with=falls back to filename completion in both shells. - Runner: empty output prints nothing again (the raw-result change had made it print a bare newline).
- Schema:
conflictslists an option'sconflictsWithas flag names. - Config check: whitespace-only credentials are errors (as
resolveAuthtreats them),expiresAtmust be finite (1e400parses to Infinity), and unknown keys insideauthget the same warning as top-level ones, with the key set tied to the type. - Tests: the completion fixture's enum values no longer appear in the scripts' boilerplate; the introspection teardown test runs the CLI itself; the
pathguard matches anylocalnamingpath. - Declined, with replies on the threads:
--no-<flag>candidates (not advertised by--helpeither) and alias candidates (canonical names on purpose).
Every shell check was re-run on the rebuilt binary after this round, plus new live checks for --, boolean values and --workspace=<Tab> filenames in zsh and bash.
Third round
- A boolean given as
--json=falselost the command context in bash, which splits it into--json,=,false: the walk now skips both split words, and--json=<Tab>offersfalse/true. Driving the real binary in bash 3.2 showed it hands over the unsplit word while readline still replaces only the text after=, so the--flag=prefix is added only when=is not inCOMP_WORDBREAKS. The bash tests cover both modes in a temp fixture directory (cubic's cwd finding). - Verified live in zsh 5.9, bash 5.3 and bash 3.2:
superset --json=false completion <Tab>andsuperset completion --json=false <Tab>listbash zsh,superset --json=<Tab>listsfalse true, and every earlier shell check still passes. - bash 3.2 offered no filenames for a free-form value after a space, because the fallback relied on
compopt -o default, which that bash lacks. Withoutcompoptthe script now registers withcomplete -o default, so readline completes filenames itself whenever the function offers nothing. Driven live in bash 3.2 and 5.3:--workspace <Tab>lists files and directories, a directory completes with a trailing slash,my file.jsoncomes back quoted, and command completion still ends with a space.
Summary by CodeRabbit
- New Features
- Added Bash and Zsh shell completion scripts for CLI commands, options, and values.
- Added
superset schemato output sorted JSON metadata about visible CLI commands and options. - Added
superset config checkto validate local configuration and report errors and warnings.
- Bug Fixes
- Positional arguments with configured choices are now validated.
- Raw command output no longer receives an extra newline, and broken-pipe errors are ignored.