#6087 [Other] Terminal: strata complete prints bash/zsh/fish tab completion from the CLI's own grammar
closed · @ackalker · 0 comentarios · En GitHub
Setup & installServer & APIAMD / HIPNVIDIA / CUDADocumentationWindowsLinux
Descripción
Problem and result: typing `strata ` and pressing Tab in bash, zsh or fish completes nothing; the grammar lives only in `parser()` in `strata_cli/cli.py` and no shell can see it. `strata complete --shell bash|zsh|fish` now prints a completion script to stdout, and the shell completes every subcommand, sub-subcommand and option the installed CLI actually has. Related discussion: #6086 (no earlier issue or PR about shell completion exists; searched "tab completion", "shell completion", "autocomplete", "shtab", "argcomplete"). Approach: the script is generated from `parser()` itself with the optional [`shtab`](https://github.com/iterativ/shtab) package, so there is no hand-kept second grammar that can drift: one subparser, one ~10-line handler, one test file. `shtab` is imported lazily inside the handler only — the default path (`serve`, `launch`, `status`, …) changes by zero lines, and the hash-locked Terminal bundle gains no new package. Without `shtab` the command names the package to install and exits 2, changing nothing else. No installer changes: the user adds one line to their shell profile (documented in `docs/TERMINAL.md`). Validation (Linux x86_64, Python 3.13.14 via `uv run --with pytest --with textual --with shtab …`, branch at `d2aaa061d`): Passed: - `python -m pytest tests/terminal/test_shell_completions.py` → 7 passed (scripts generated for bash/zsh/fish; each names every current top-level command; each parses with `bash -n` / `zsh -n` / `fish -n`; the missing-`shtab` path exits 2 and names the package). - Grammar neighbours: `python -m pytest tests/terminal/test_shell_completions.py tests/terminal/test_retired_entry_points.py tests/terminal/test_clean1a_strings.py tests/terminal/test_gpu_plan_main.py tests/terminal/test_update_with_model.py tests/terminal/test_no_acquisition.py` → 87 passed. - Full terminal suite: `python -m pytest -q tests/terminal` → 3060 passed, 59 skipped, 2 failed (the two failures are under Failed below). - The two failing files again, alone: `python -m pytest -q tests/terminal/test_bench_term_0213_qatui.py tests/terminal/test_runtime.py` → 62 passed, 4 skipped on this branch; the same two named cases pass on clean `main` (c77572806). - Manual: `python strata.py complete --shell bash | bash -n` ok; `complete --shell fish | fish -n` ok; `complete` without `shtab` installed → exit 2 with the install message; `strata --help` lists `complete`. - `python tools/check_links.py` → 118 pages, all local links resolve. Failed: - In the full-suite run: `test_bench_term_0213_qatui.py::TermEndsTheEngine::test_sigint_while_the_benchmark_runs_stops_the_engine` and `test_runtime.py::RuntimeTests::test_foreground_jsonl_emits_ready_and_stop_without_human_stdout` (sigint subtest). Both are 60-second process-timeout failures in SIGINT/drain tests while the whole suite loaded the machine; both pass alone on this branch and on clean `main`, and neither runs any code this PR changes. Reported as-is; I did not reproduce them alone. Not run: - CUDA/HIP/SYCL builds: the diff touches no native file (one Python CLI file, one test, one docs page). - The remaining `tools/check` steps (`py-serve`, `py-tools`, `snapshot` which needs Node), Windows and macOS runs, and interactive Tab use in a real bash/zsh/fish session (the generated scripts are syntax-checked and command-complete, but nobody pressed Tab by hand). Limits: no PowerShell script (shtab has no PowerShell target; PowerShell keeps its default completion); no value completion (profile names, model IDs) yet — subcommand/option completion comes free with the parser and is the whole scope here; `shtab` is not in the bundled wheel locks, so Terminal-bundle users install it once (the command says how). If maintainers want it inside the bundle, that is one pin in `requirements-monitor.txt` plus `python packaging/lock_wheels.py --target <t>` for the four targets — deliberately kept out of this PR (dependency change, and I can build and qualify only the Linux archive, not the Windows or macOS ones).
En el sitio
Enlaces a install, modelos, releases.