Skip to content

filter package.json passthrough tasks from shell completions#9

Draft
kjanat wants to merge 1 commit intomasterfrom
claude/deduplicate-monorepo-tasks-co3WG
Draft

filter package.json passthrough tasks from shell completions#9
kjanat wants to merge 1 commit intomasterfrom
claude/deduplicate-monorepo-tasks-co3WG

Conversation

@kjanat
Copy link
Copy Markdown
Owner

@kjanat kjanat commented May 5, 2026

Summary

This change improves shell completion behavior by filtering out package.json tasks that are passthrough wrappers to turbo.json tasks. This follows the canonical Turborepo pattern where package.json scripts like "build": "turbo run build" delegate to turbo, and such passthroughs should not clutter completion suggestions.

Key Changes

  • Passthrough detection: Added logic to identify when a package.json task shares its name with a turbo.json task, treating it as a passthrough wrapper
  • Completion filtering: package.json passthrough tasks are now excluded from completion candidates entirely, while still being surfaced by runner list for transparency
  • Duplicate handling: Updated the duplicate detection logic to count only "effective" (non-passthrough) tasks, ensuring correct qualification of remaining candidates
  • Test coverage: Added two comprehensive test cases:
    • package_json_passthrough_to_turbo_collapses_to_bare_name: Verifies that a passthrough task results in only the bare name appearing once
    • passthrough_swallow_keeps_unrelated_runner_qualified_forms: Ensures that when other task sources (e.g., Makefile) also define the same task name, they retain their qualified forms for disambiguation

Implementation Details

  • Uses a HashMap<&str, HashSet<TaskSource>> to track all sources for each task name
  • The is_turbo_passthrough closure checks if a task is from package.json AND has a corresponding turbo.json source
  • Passthrough tasks are skipped during both the effective count calculation and candidate generation loops
  • The change maintains backward compatibility with runner list and runner build commands, which continue to surface all sources per their existing priority ordering

https://claude.ai/code/session_01S5a1HBiSU1YBeRbebcbLWf

In a Turborepo monorepo, the canonical wiring is a root package.json
with `"build": "turbo run build"` mirroring a same-named entry in
turbo.json. Tab completion was emitting both the package.json and
turbo.json qualified forms (`package.json:build`, `turbo.json:build`)
plus the bare name — three candidates for what is functionally one
task.

When a task name appears in both sources, drop the package.json entry
from completion candidates entirely. This is consistent with the
existing run-priority order (TurboJson > PackageJson), so `runner build`
was already dispatching through turbo. `runner list` keeps showing both
sources for transparency, and a typed `package.json:build` still works.

If a third source (e.g. Makefile) also defines the name, both turbo and
the third source keep their qualified forms — only the package.json
wrapper is suppressed.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

📝 Walkthrough

Walkthrough

The pull request refines task completion generation in task_candidates_from to detect and handle a "turbo passthrough" scenario: when a task exists in both package.json and turbo.json, the package.json entry is excluded from completion candidates. Duplicate detection logic is updated to only count effective (non-passthrough) tasks, ensuring correct qualification of candidate names.

Changes

Turbo Passthrough Completion Handling

Layer / File(s) Summary
Passthrough Detection & Data Shape
src/cli.rs (lines 52–78)
Introduces sources_for_name mapping and is_turbo_passthrough logic to identify when a task exists in both package.json and turbo.json, swallowing the package.json variant from consideration.
Candidate Generation
src/cli.rs (lines 79–85, 108–117)
Updates is_duplicate computation to use effective_count (excluding swallowed passthrough tasks) and ensures bare candidate emission respects the post-passthrough candidate set.
Test Coverage
src/cli.rs (lines 185–270)
Adds two tests: one validating that passthrough swallowing collapses package.json/turbo.json build pairs to a single bare candidate, and another confirming passthrough swallowing doesn't suppress legitimate qualified forms for unrelated sources.

Poem

Avast, ye duplicates be gone!
When turbo claims what package swore,
We swallow one and sail along,
With bare names clean, no mess galore—
The passthrough's fixed, completion's strong! 🏴‍☠️

🚥 Pre-merge checks | ✅ 6 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Changelog Update ⚠️ Warning Source code modified (src/cli.rs with passthrough filtering logic and tests) but CHANGELOG.md Unreleased section is empty. No version bump detected, so changes must be documented under Unreleased. Add entry to CHANGELOG.md under ## [Unreleased] describing the package.json passthrough task filtering feature and completion behavior changes.
Semver Version Bump Validation ⚠️ Warning PR modifies src/cli.rs (adds passthrough filtering feature) but version remained at 0.5.0 while master is at 0.6.0. Version is LOWER than target, violating SemVer. Update Cargo.toml version to 0.6.0 or higher (at minimum match master; if feature, could be 0.7.0 for MINOR bump) to reflect backward-compatible feature addition.
✅ Passed checks (6 passed)
Check name Status Explanation
Description check ✅ Passed The description is comprehensive and directly related to the changeset, providing clear context about passthrough detection, completion filtering, and test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Agents.Md Documentation Updated ✅ Passed No AGENTS.md file exists anywhere in the repository. The custom check is conditional on the existence of such a file. Since the prerequisite condition is not met, the check does not apply.
Title check ✅ Passed The title clearly describes the main change—filtering passthrough tasks from completions—and follows conventional commit style with a lowercase verb, staying focused and concrete.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/deduplicate-monorepo-tasks-co3WG

Comment @coderabbitai help to get the list of available commands and usage tips.

@kjanat kjanat self-assigned this May 8, 2026
@kjanat kjanat changed the title Filter package.json passthrough tasks from shell completions filter package.json passthrough tasks from shell completions May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants