[9/10] --pick-team-auto: auto-resolve combined sections by common prefix #197
Description
Context
Resolving a combined/ambiguous team section (e.g. "gamme-lead-client + gamme-lead-client-p1", produced when a repo matches 2+ teams at the same hierarchy level) currently always requires a manual --pick-team "combined label"=chosenTeam assignment (or the interactive p pick mode in the TUI) — see applyTeamPickInTree / resolvePickTeamAssignment in src/group.ts and github-code-search.ts.
Many of these combinations are not actually ambiguous: when one of the combined team names is a literal string-prefix of every other team name in the combo (e.g. gamme-lead-client is a prefix of gamme-lead-client-p1), the "parent" team is the obvious, unambiguous owner. Today this case is not auto-resolved because nestOverlappingLabels explicitly skips any label containing " + " (see its docstring: "Combined-label sections … are never auto-nested"), so the user still has to type the pick manually even though the answer is derivable from the names alone.
This replaces --group-by-team-prefix-consolidate (removed in a sibling issue) as the actual answer to the "reduce manual pick-team busywork" need.
Part of EPIC #125.
Solution
Add a new boolean CLI flag, --pick-team-auto, that automatically resolves combined sections at every hierarchy level using a smallest-common-prefix strategy:
- For each combined section (label containing
" + ") at any depth, split the label back into its constituent team names. - If exactly one of those team names is a literal string-prefix of all the others (the "smallest common prefix" that is itself one of the real candidate names — reusing the same prefix-comparison logic as
nestOverlappingLabels), automatically resolve the section to that team, equivalent to an implicitapplyTeamPickInTree(sections, path, thatTeam). - If no team name in the combo is a prefix of all the others (e.g.
"squad-frontend + squad-mobile"), leave the section combined and unresolved — same as today.--pick-teamremains available (and necessary) for these genuinely ambiguous cases. - Apply auto-pick before processing any explicit
--pick-teamassignments, and let explicit--pick-teamassignments always win when they target the same section (an explicit pick is a deliberate override of the automatic default). - Extend
resolvePickTeamAssignment's stderr messaging so the "N combined sections still unresolved" note only counts sections that auto-pick could not resolve. - Thread the flag through the replay command (
ReplayOptionsin src/output.ts) so a session that used--pick-team-autoreproduces identically. - Update
docs/usage/team-grouping.md(new subsection, replacing "Advanced: consolidated rendering") anddocs/reference/cli-options.md.
Acceptance Criteria
-
--pick-team-autoautomatically resolves a combined section whose team names share a common "parent" prefix, without requiring--pick-team. - A combined section with no prefix relationship among its team names is left combined/unresolved by
--pick-team-autoalone. - An explicit
--pick-teamassignment for the same section overrides the automatic resolution. - Auto-pick applies independently at every hierarchy depth, not just the top level.
- The replay command reproduces
--pick-team-autosessions exactly. -
--format jsonbehavior is unaffected by this flag beyond reflecting the resolved sections (no JSON-specific warning needed, unlike the removed consolidate flag — this changes the actual section membership, not just rendering).
Definition of Done
- Unit tests in
src/group.test.tsfor the auto-pick resolution function, covering: single common-prefix winner, no common prefix (left combined), 3+-way combos, and nested (non-top-level) sections. - CLI-level test coverage for flag wiring and replay-command emission (
src/output.test.ts). -
docs/usage/team-grouping.mdanddocs/reference/cli-options.mdupdated. -
bun test,bun run lint,bun run format:check,bun run knip,bun run build.tsall green. - Depends on the
--group-by-team-prefix-consolidateremoval issue being merged first (avoids overlapping churn ingithub-code-search.ts/src/group.ts).
Activity
[-][9/9] --pick-team-auto: auto-resolve combined sections by smallest common prefix[/-][+][9/10] --pick-team-auto: auto-resolve combined sections by common prefix[/+]Add --pick-team-auto: auto-resolve combined sections by common prefix
Remove --group-by-team-prefix-consolidate and consolidateTeamHierarchy