Interpret flags and operands for completion

This commit is contained in:
2026-11-03 03:54:22 +00:00
parent 8bb5383169
commit 4c47a0ca0b
6 changed files with 491 additions and 65 deletions

View File

@@ -1,6 +1,6 @@
# Shell completion implementation plan
Status: Stages 1–4 complete. Stage 5 is next.
Status: Stages 1–5 complete. Stage 6 is next.
Implement the [shell completion roadmap](completion.md) from baseline
`2301872`. Follow the stages in order in one sprint. Intermediate stages may
@@ -184,6 +184,8 @@ The root package suite passes with `GOWORK=off` and `GOTOOLCHAIN=local`.
## Stage 5: Interpret flags and locate value positions
Status: complete.
1. Walk the completed tail using the same canonical and alias spellings and
flag token rules as normal parsing. Factor shared token classification
from `internal/cobra/flags.go` into neutral helpers where needed; keep
@@ -216,6 +218,15 @@ The root package suite passes with `GOWORK=off` and `GOTOOLCHAIN=local`.
operands, terminators, and optional/repeated operands before a required
suffix. Keep existing normal execution tests green at the sprint boundary.
Completion: shared neutral token classification and flag lookup with normal
parsing, and extracted operand count allocation for execution and completion.
The completion walk records consumed flags and operands, locates pending or
attached values, preserves entered prefixes, and filters canonical flag names
by supplied identity. Tests cover aliases, short clusters, repeated flags,
boolean assignments, option-looking values, terminators, interspersed operands,
and operand cardinality. Root, adapter, and neutral metadata package tests pass
with `GOWORK=off` and `GOTOOLCHAIN=local`.
## Stage 6: Assemble candidates and deliver query replies
1. Produce a neutral result of candidate replacements, optional descriptions,