Verify shell completion transport

This commit is contained in:
2026-11-03 03:45:47 +00:00
parent 10a799a2b7
commit 1d193c87fe
4 changed files with 285 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
# Shell completion implementation plan
Status: ready for implementation.
Status: Stage 1 complete. Stage 2 is next.
Implement the [shell completion roadmap](completion.md) from baseline
`2301872`. Follow the stages in order in one sprint. Intermediate stages may
@@ -14,6 +14,8 @@ names, candidate ordering, and backend mechanics private.
## Stage 1: Prove the shell transport
Status: complete.
1. Use the Cobra version pinned in the root module. In a disposable prototype,
generate scripts with `GenBashCompletionV2(w, true)`,
`GenZshCompletion(w)`, and `GenFishCompletion(w, true)`. Give the generator
@@ -41,6 +43,23 @@ names, candidate ordering, and backend mechanics private.
evidence. Carry forward only the adapter and fixtures needed for the final
implementation; do not commit disposable prototype machinery.
Completion: generated scripts using Cobra v1.10.1 and exercised them through
interactive Bash 5.3.9, Zsh 5.9, and Fish 4.2.1 with a fixture that records the
query and the executed edited line. In the tested attached-value cases the
query includes the entered flag and value; a static candidate contains the value
alone, and the shell script preserves the flag prefix. Explicit empty words,
quoted prior arguments, short clusters, file and directory hints, and no-file
replies were exercised. Zsh's generated word splitting lost the attached flag
context when a path contained an escaped space. Fish split quoted prior words,
passed escapes in current words, and treated directory-only replies as ordinary
file completion. The adapter adjusts those scripts and preserves the first `=`
as the flag/value separator. The opt-in `TestCompletionShells` regression checks
actual edited lines for these cases. Run it with Bash, Zsh, Fish, Python pexpect,
and Bash completion installed using `COMMANDKIT_COMPLETION_SHELLS=1
GOWORK=off GOTOOLCHAIN=local go test -count=1 -run '^TestCompletionShells$'
./internal/cobra`. Zsh and Fish were extracted into a disposable directory for
this run; the focused adapter suite and the full interactive matrix pass.
## Stage 2: Capture completion hints
1. Add the following public API in the root package. Add