When a command has a `default:"withargs"` child, Kong offers the default
command's flags while parsing the parent's own tokens. A flag given
before an explicitly named sibling command was therefore parsed into the
default command's flag. The sibling was then selected, the default
command never ran, and the value was silently dropped. In block/spectre
this made `spectre divergences --server-url=X clear` act on the default
server instead of X.
```go
var cli struct {
Divergences struct {
List ListCmd `cmd:"" default:"withargs"`
Clear ClearCmd `cmd:""`
} `cmd:""`
}
```
Now, when `trace` selects a child other than the `withargs` default
(either a command or a branching argument), it checks whether any flag
owned by the default command was already parsed, and fails with an error
such as:
```
flag --server-url applies to the default command "list", not "clear"
```
The value is not moved to a same-named flag on the selected sibling,
because the two flags may differ in type or meaning.
Behaviour that is unchanged and covered by the new table-driven test
next to the existing `withargs` tests:
- `divergences --server-url=X` still runs `list` with X.
- `divergences list --server-url=X`, `divergences --server-url=X list`,
and `divergences clear --server-url=X` still work.
- Flags on the parent node, or inherited from ancestors, are still
accepted before the sibling command.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>