Skip to content

[9/10] --pick-team-auto: auto-resolve combined sections by common prefix #197

Description

@shouze

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 implicit applyTeamPickInTree(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-team remains available (and necessary) for these genuinely ambiguous cases.
  • Apply auto-pick before processing any explicit --pick-team assignments, and let explicit --pick-team assignments 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 (ReplayOptions in src/output.ts) so a session that used --pick-team-auto reproduces identically.
  • Update docs/usage/team-grouping.md (new subsection, replacing "Advanced: consolidated rendering") and docs/reference/cli-options.md.

Acceptance Criteria

  • --pick-team-auto automatically 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-auto alone.
  • An explicit --pick-team assignment 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-auto sessions exactly.
  • --format json behavior 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.ts for 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.md and docs/reference/cli-options.md updated.
  • bun test, bun run lint, bun run format:check, bun run knip, bun run build.ts all green.
  • Depends on the --group-by-team-prefix-consolidate removal issue being merged first (avoids overlapping churn in github-code-search.ts / src/group.ts).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions