Open
Conversation
Add Bazel support to RTK with `rtk bazel query` for grouped, hierarchical target output. Strips stderr noise (INFO/WARNING/DEBUG), groups targets by package, and renders a depth/width-controlled tree with cumulative counts. Unsupported bazel subcommands pass through transparently. Output uses 📦 for sub-packages and 🎯 for targets, with a header showing total counts. Default --depth 1 --width 10 collapses large repos (e.g. 2,782 lines on the bazel repo) to ~8 top-level summary lines. --depth all --width all shows everything. - Limit type (number or "all") with FromStr for Clap - TreeNode with cumulative_targets/cumulative_packages for subtree counts - Width budget: sub-packages first, remaining slots for targets - Condensed truncation: (+N more sub-packages, M more targets) - detect_query_root extracts //path/... for scoped queries - Passthrough for all other bazel subcommands (build, test, etc.) - Exit code propagation, tee output recovery on failure - 24 tests covering depth, width, truncation, relative names, edge cases Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Strip progress lines, INFO/DEBUG noise, Loading/Analyzing status, Java notes, and target output paths. Keep ERROR/WARNING lines and compiler diagnostics (gcc/clang warning:/error: blocks with context). Success: "✓ bazel build (N actions)" Issues: header + error/warning blocks, truncated at 15 10 new tests including token savings verification (≥60%). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Strip build noise (progress, INFO, Loading, Analyzing) and test metadata, showing only a one-liner on success or FAIL blocks with inline test output on failure. 9 tests covering all-pass, cached, failure with inline output, build errors, and ≥60% token savings. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add filter_bazel_run() that splits stderr at the "INFO: Running command line:" sentinel, strips build noise from the build phase, and forwards binary stdout/stderr verbatim. Clean builds show only binary output; build errors show a separate build section with errors and warnings for context. Also refactors shared bazel filtering: - Add strip_timestamp() helper to normalize "(HH:MM:SS) " prefixes, replacing 6 redundant _PLAIN/_WITH_TIMESTAMP regex pairs - Simplify RUN_SENTINEL regex (timestamp handled by helper) - Fix ACTION_COUNT regex to match singular "1 total action" - Apply strip_timestamp to filter_bazel_build and filter_bazel_test 13 tests covering: clean build, warnings stripped, errors with/without warnings, binary stderr, no sentinel fallback, timestamped lines, post-sentinel INFO stripped, real-world output, and ≥60% token savings. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- remove detect-root tuple plumbing and default empty headers to // - replace recursive tree query renderer with output-driven package index - keep external repo grouping and subsection depth semantics - preserve truncation/count behavior and associated bazel query tests Co-authored-by: Codex <[email protected]>
- rewrite bazel build/test/run/query/aquery/cquery to rtk bazel - add hook test coverage for bazel rewrite and env-prefixed cases - document bazel rewrite mapping in README Co-authored-by: Codex <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for
bazel query,bazel build,bazel test, andbazel runcommands.It introduces:
rtk bazel buildrtk bazel testrtk bazel runrtk bazel querybazelsubcommandsThe implementation is in
src/bazel_cmd.rs, with command wiring insrc/main.rs.Motivation
Raw Bazel output is very noisy and expensive to consume. This change allows
rtkto shrink Bazel outputs and remove a bunch of noise, similar tocargo,go, andnpm, with compact summaries, focused diagnostics, and predictable truncation.What Changed
CLI integration
bazelcommand group insrc/main.rs.build,run,test,query, with fallback for others.--depthand--widtharguments forrtk bazel queryto handle large results (can shrink by >90%)bazel buildLoading,Analyzing,INFO, progress bars)ERROR:andWARNING:linesbazel testbazel runRunning command line:as a sentinel to identify when Bazel begins running the actual targetbazel query//) and external (starts with@package_name//) packages.--depthflag moves grouping to lower levels (e.g.--depth=1groups//srctogether, while--depth=2groups//src/foo,//src/bar, etc. separately)--widthflag limits how many packages/targets are listed per group, with the rest being summarized as(+N more...)Docs
CLAUDE.mdcommand/module table to includebazel_cmd.rs.Testing
cargo test bazel_cmd -- --nocaptureTo generate the test cases and evaluate the system, I used the https://github.com/bazelbuild/bazel repository, which uses Bazel to build itself. Here are some samples I checked:
bazel query "//src/..."bazel query "//tools/..."bazel query "kind(rule, //src/... + //tools/...)"bazel query "deps(//src:bazel-dev)"bazel build "//src:bazel-dev"bazel query "@bazel_skylib//..."