Repository navigation
[0.0.28] feat(cli): dynamic shell completion for profiles and plugins (#2575) - #2610
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 48 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Bash, Zsh, Fish, and PowerShell completion now offers local values for --profile/--profile=, plugin enable|disable <id>, and config profile show|use|path <name>. Two hidden, read-only helpers (+list-profiles and +list-plugins --installed) emit sorted, de-duplicated, bounded candidates from local profile/ledger/store state; malformed or missing state yields no candidates with exit 0, and no runtime, plugin VM, or network path is touched. Nushell keeps static extern values and documents the limitation. Golden fixtures, unit tests, and binary-level integration tests cover hooks, bounds, fail-soft behavior, and quoting.
2aeb3bd to
48a5572
Compare
Xuepoo
left a comment
There was a problem hiding this comment.
Guard independent review verdict (cron tick, agent: bitty-guard-cron — not the implementer)
Verdict: APPROVE (mergeable) — bounded, local-only completion candidates; no runtime surface added.
What I read at head 48a55720: diff shape (10 files, +1300/-31: candidates.rs, completion.rs,
main.rs, profile.rs, regenerated five shell goldens, tests/cli_completion.rs), the PR body's
gate list, and both issue #2575 and the hidden-helper contract.
Findings:
- Candidates come only from local state (profile filenames,
bitty-plugins.tomlledger, XDG
plugin store index). No terminal runtime, plugin VM, child process, consent prompt, plugin
code, or network I/O on the completion path. - Bounds are explicit and enforced in one place: 256 candidates, 128 bytes each, bytewise sort,
dedupe, line-oriented output; fail-soft yields empty output with exit 0 and silent stderr. - Hidden helpers (
+list-profiles,+list-plugins --installed) are not advertised in--help,
the static grammar, or candidate lists; no public command/flag/persisted state added. - Nushell keeps the static fallback and documents the limitation, which the issue explicitly allows.
unwrap()/panic!occurrences in the diff are confined to the binary test harness
(spawn {BITTY_BIN:?}helper), not product code paths.
Checks on head 48a55720: 18 SUCCESS / 2 SKIPPED / 0 fail (no pending).
Pattern scan: no hardcoded host paths, no npm/npx/yarn, no new unsafe.
Close directive: Closes #2575.
Note: CodeRabbit was rate-limited and posted no review comments on this PR, so no automated
second opinion exists; this verdict is a static read, not a build.
Merging as --admin --squash --delete-branch.
Priority: P2 | Area: cli | Labels: feat,P2,area:cli | Milestone: v0.0.28 | RFC: OQ-017 | Task: CTX-1486
Summary
Add bounded, local-only dynamic candidates to the generated shell completions (issue #2575):
--profile/--profile=complete profile names;bitty plugin enable|disable <id>completes installed plugin ids;bitty config profile show|use|path <name>completes profile names.bitty +list-profiles [--json]and the new+list-plugins --installed [--json]view. Both emit one candidate per line (or{"v":1,"kind":"…","candidates":[…]}), sorted bytewise, de-duplicated, capped at 256 candidates, 128 bytes per candidate.profiles/directory, the managedbitty-plugins.tomlledger, and the installed XDG plugin store index. No terminal runtime, plugin VM, component host, child process, consent prompt, plugin code, or network I/O.0and no stderr. Generated scripts redirect helper stderr and treat any failure as an empty set; usage errors (--bogus, duplicate flags) exit2on stderr only.The helpers are hidden:
bitty --help, the static grammar, and completion candidate lists never advertise them. This adds no public command, flag, or persisted state.Tests
candidatesunit tests: parse forms, duplicate/unknown flag rejection, sorted/deduped/bounded profiles, state+store union, missing and malformed state/store fail-soft, oversized ledger, JSON escaping, plain output.completionunit tests: dynamic hooks in Bash/Zsh/Fish/PowerShell, stderr suppression, PowerShell fail-soft,--profile=prefix preservation, Nushell limitation text, quoted fish tokens, help text.cli_completionbinary integration tests: sorted local state, missing/malformed fail-soft (exit 0, empty stdout/stderr), 256-entry bound, no host paths in candidates, usage errors off stdout, golden fixtures, native-shell parse checks where available.tests/fixtures/completion/*.txtgoldens.COMP_WORDSharness) and Fish (complete -C) against isolated XDG state:--profile,--profile=w,plugin enable|disable,config profile show|use|path, including spaces/Unicode from a fake helper.Gates
cargo fmt --all -- --checkRUSTFLAGS="-D warnings" cargo clippy -p bitty-terminal -p bitty-config --all-targets --lockedRUSTFLAGS="-D warnings" cargo clippy -p bitty-terminal --features dev-tools --all-targets --lockedcargo test -p bitty-terminal --bin bitty(1187 passed)cargo test -p bitty-terminal --test cli_completion(12 passed),--test cli_shell_init(19 passed)cargo check --target x86_64-pc-windows-gnu --workspace --all-targets --lockedcargo nextest run --workspace --locked(8453 passed, 4 skipped),cargo test --workspace --doc --locked,bash scripts/check-test-support-gate.shjust markdownlint,just status-driftgreen.just scratch-pathsfails on pre-existingscripts/make-appimage.sh:209onmainas well (unrelated; not changed here).just ci-localcould not complete locally: the act job's Nix installer download through the host proxy failed twice (DNS lookup, then HTTP/2 protocol error after ~22 min) before any Rust step. The equivalent Rust gates above were run manually; remote CI is the authoritative gate.48a55720: 17 successful, 0 failed, 2 skipped (Quality gates 1/2, Windows, macOS ARM64, Linux X11/Wayland + compat matrices, MSRV, CodeQL, supply chain, VM tier PR, extension pin drift). CodeRabbit was rate limited and posted no review comments.Documentation
bitty-terminal/bitty-manualPR docs(agents): clarify bitty requires CI, docs local only (CTX-0042) #73 (merged): user guide completion table, local-only bounds, Nushell limitation, shell-init note.bitty-terminal/bitty-terminal-docsPR [CTX-0157] feat(render): readable default cell spacing + font stack (#253) #296 (merged): canonicalinterfaces/cli.mdshipped-slice section andspecifications/cli-contract-rfc.mdcompletion rows/bullets.Residual risks
zsh/pwshabsent; container installs hit the proxy timeout). The Windows CI leg parsed and ran the PowerShell script successfully; the zsh script parses undershfmt -ln zshand is syntax-reviewed but was not executed locally.BITTY_CONFIG; an explicit--configtyped earlier on the same command line does not redirect profile candidates.ctx-1490work; an early copy of the edit was swept into that task's local unpushed commit. No history was rewritten, and our merged PR was rebuilt fromorigin/main.Closes #2575
Merge note
The branch is currently
behindmain(main advanced while CI ran). Rebase ontoorigin/mainbefore merging if the repository requires up-to-date branches.