Add completion specs for yay and paru AUR helpers - #333
Closed
warp-agent-staging[bot] wants to merge 2 commits into
Closed
Add completion specs for yay and paru AUR helpers#333warp-agent-staging[bot] wants to merge 2 commits into
warp-agent-staging[bot] wants to merge 2 commits into
Conversation
pacman -S completions work because Warp ships its own command signature/generator for pacman (json/pacman.json + src/generators/pacman.rs), not because of shell-native completion. yay and paru had no such signature or generator registration, so `yay -S <partial>` fell back to plain path completion with no package suggestions at all (warpdotdev/warp#5177). - Add json/yay.json and json/paru.json, modeled on json/pacman.json, covering -U/--upgrade, -D/--database, -Q/--query, -R/--remove, -S/--sync, -T/--deptest, and -F/--files (plus root options), instead of wiring up -S alone. - Refactor src/generators/pacman.rs to expose its parsing/generator logic (list_packages, list_installed_packages_generator, list_pkg_tar_files_in_cwd_generator) so it can be shared, and add src/generators/yay.rs and src/generators/paru.rs which reuse it for -Q/-R/-U (installed packages and local .pkg.tar files are identical regardless of frontend), while using each tool's own `-Pc` (`--show --complete`) for -S/--sync. `-Pc` is yay/paru's own purpose-built, cache-backed completion command for enumerating AUR + repo packages, and is what their own bundled completion scripts use; it avoids querying the >100k-package AUR live on every keystroke, at the cost of a slower first invocation while the local cache is built. - Register yay_generators()/paru_generators() in generators/mod.rs. Co-Authored-By: Warp Agent <agent@warp.dev>
Contributor
Author
|
This PR was generated with Warp. |
- json/paru.json: add -a/--aur to -T/--deptest. paru documents -Ta as filtering a package list down to ones that appear in the AUR, and the entries were missing that option despite otherwise covering -T. - src/lib.rs: add a regression test (yay_and_paru_bind_list_all_packages_to_their_own_completion_command) that resolves yay's/paru's own dynamic completion data and asserts their list_all_packages generator runs `yay -Pc`/`paru -Pc`, not pacman's `-Slq`. all_referenced_generators_exist only checks that a JSON-referenced generator name exists somewhere in the global union of every command's generators, so it would still pass even if the yay/paru map registrations were dropped entirely (their generator name collides with pacman's). Verified this new test fails with "no dynamic completion data registered for command \"yay\"" when the yay::yay_generators()/paru::paru_generators() map entries are removed, and passes once they're restored. - src/generators/yay.rs, src/generators/paru.rs: correct the doc comment's claim about the completion cache refresh interval - both tools default --completioninterval to 7 days, not "once a day". Co-Authored-By: Warp Agent <agent@warp.dev>
Contributor
Author
|
Closing as a duplicate. This and #334 were opened by the same automated run about 80 seconds apart, both implementing yay/paru completion specs for warpdotdev/warp#5177. #334 is the one that landed (79e45eb), so this branch is now stale against Two defects in what landed — Responding as wilson: Open session · View factory task |
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.


Summary
Fixes warpdotdev/warp#5177:
yay -S <partial>(andparu -S <partial>) produce no package completions in Warp, unlikepacman -S. Also requested by APP-5382 (Linear).Root cause: Warp's
pacman -Scompletions come from this repo's ownjson/pacman.jsonspec +list_all_packagesgenerator (pacman -Slq), not from shell-native completion.yay/paruhave no equivalent spec or generator registered, so they fall back to plain path completion.This PR is the actual fix. It's referenced from a companion draft PR, warpdotdev/warp#15112, that bumps the
warp-command-signaturespin to this branch's head commit, purely so the change can be reviewed/tested end-to-end before this PR merges; that pin must be re-pointed at this PR's mergedmaincommit before warpdotdev/warp#15112 lands.Changes
json/yay.jsonandjson/paru.json, modeled directly onjson/pacman.json. Both cover-U/--upgrade,-D/--database,-Q/--query,-R/--remove,-S/--sync,-T/--deptest,-F/--files, and the shared root options — not just-S— plus each tool's own AUR-related flags (-a/--aur,--repo, yay's-N/--repo).src/generators/pacman.rsto expose its package-list parsing and the installed-package /.pkg.tar-file generators as reusable functions (list_packages,list_installed_packages_generator,list_pkg_tar_files_in_cwd_generator), following the same "one file, multiple*_generators()functions" pattern this repo already uses forapt.rs(apt-get/aptitude) andnpm.rs(npm/yarn/pnpm).src/generators/yay.rsandsrc/generators/paru.rs, which reuse that shared logic for-Q/-R/-U(installed packages and local.pkg.tarfiles don't depend on which frontend is used — they always come from the shared pacman database), and registeryay_generators()/paru_generators()ingenerators/mod.rs.Generator command choice for
-S/--sync(the actual bug)pacman -Slqonly lists official repo packages, so reusing it for yay/paru would reproduce the exact reported bug (no AUR completions).Instead, both
yay -Pc(yay --show --complete) andparu -Pc(paru --show --complete) are used. Per each tool's own man page: "Print a list of all AUR and repo packages. This allows shell completion and is not intended to be used directly by the user." This is also exactly what yay's and paru's own bundled bash/zsh completion scripts (_yay_pkg/_paru_pkg) shell out to for the same purpose — so this mirrors upstream's own approach rather than inventing a new one.Tradeoff considered: the AUR has 100k+ packages, so a live query (e.g. hitting the AUR RPC) on every keystroke would be far too slow for interactive completion.
-Pcavoids that by reading from each tool's local, periodically-refreshed completion cache (--completioninterval, default 7 days) instead of re-enumerating the AUR on every call. The cost is that the very first invocation (before any cache exists) can be slow while it's built — every completion after that is fast. This was a deliberate choice, not a blind copy of pacman's command.Verification
cargo test --workspace: 141 tests pass, including the repo's own invariants (all_referenced_generators_exist,all_command_specs_succeed_deserialization,all_command_specs_have_no_newlines) — both new JSON specs deserialize correctly and everygeneratorNamethey reference resolves to a real generator.cargo fmt --all -- --checkandcargo clippy --workspace --all-targets -- -D warnings: clean.npm run format:check(prettier): clean for the new JSON files.script/presubmitend-to-end: all green.yay/paru+ fish environment, since none was available in the sandbox this was built in. The generator commands (yay -Pc,paru -Pc,pacman -Q) are taken directly from each tool's man page and their own bundled completion scripts, not guessed, but I could not run them against a live pacman/AUR install.Co-Authored-By: Warp Agent agent@warp.dev
Revision (review findings)
-a/--aurto paru's-T/--deptest, which paru documents as filtering the given package list down to ones that appear in the AUR (-Ta) — the entries covered-Tbut were missing that flag.yay_and_paru_bind_list_all_packages_to_their_own_completion_commandinsrc/lib.rs, a regression test that resolvesyay's/paru's own dynamic completion data and asserts theirlist_all_packagesgenerator runsyay -Pc/paru -Pc, not pacman's-Slq. The existingall_referenced_generators_existtest only checks that a referenced generator name exists somewhere in the global union of every command's generators, so it would still pass even if theyay/parumap registrations ingenerators/mod.rswere dropped entirely (their generator name collides with pacman's). Verified the new test fails with "no dynamic completion data registered for command "yay"" when those registrations are removed, and passes once restored.CompletionInterval/--completionintervalis 7 days.