feat: redesign discover & gain reports with command grouping#550
feat: redesign discover & gain reports with command grouping#550bz00qa wants to merge 8 commits intortk-ai:developfrom
Conversation
|
Hello, Thanks for contributing Please follow CONTRIBUTING.md guidelines, your branch should be created from develop and then merge into it, not master. |
Full review v1Contribution Guidelines
Feature branch should derive from develop and target develop for PR
CONTRIBUTING.md requires documentation updates for changes of this scope:
OUT OF SCOPEThe PR description says "redesign discover & gain reports," but the actual changes include several orthogonal behavioral changes that should be separate PRs:
strip_verbose_flags() silently removes -v, -vv, --verbose, --debug from rewritten commands. This is a destructive
The PR changes unsupported commands from returning None (pass-through unchanged) to Some("rtk proxy -f "): // Before: htop -> None (executed as-is) This is a significant behavioral change: every single unrecognized command now gets wrapped in rtk proxy -f. This
Code Quality
suggestion: "rtk context".to_string(), // Doesn't exist These commands are proposed in PR #553 (not merged). The discover report will suggest commands users can't actually
("context", "Meta Commands"), // Doesn't exist Same issue — the gain coverage report will show these as "available" commands. Missing Tests
This function handles complex edge cases (python -m, pnpm --filter, arg-only commands, flag commands) but has zero
Another complex function with zero tests. Needs:
The entire pattern detection system (context/watch/dedup) has no tests. This is a core feature of the PR with complex
The rposition() logic for attributing output to the last non-ignored command in a chain is untested. Duplicated code1- Bun/Deno/Bunx Rules (rules.rs) — Duplicates PR #548 PR #550 adds 3 new regex patterns and 3 full RtkRule entries for bun, bunx, and deno in rules.rs: // PR #550 adds these PATTERNS (rules.rs line 1763-1765 of diff): // PR #550 adds these RULES (rules.rs lines 1959-2021 of diff): PR #548 ("feat: add Bun and Deno runtime support") by the same author adds:
|
…ction - Add colorized TTY-aware discover report with table formatting - Add top token consumers section with smart base_cmd grouping - Add pattern detection (git context, watch loops, dedup opportunities) - Add base_cmd column to tracking DB with migration + backfill - Add effective_idx logic for correct output_len attribution in chains - Add consumer_base() for smart grouping (handles pnpm --filter, python -m) - Add pad_right/pad_left helpers for ANSI-safe column alignment - Add in-memory SQLite (new_in_memory) for test isolation - Refactor all tracking tests to use in-memory DB Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: bz00qa <bz00qa.hub@gmail.com>
- Add COMMAND_REGISTRY mapping commands to categories (9 categories) - Add Category column to "By Command" table - Add "Command Coverage" section showing used/available per category - Add "Routing Breakdown" section (dedicated vs proxy vs other) - Add coverage data to JSON export (ExportCoverage, ExportCategoryStats) - Add lookup_category(), print_command_coverage(), print_routing_breakdown() - Add 6 tests (registry validation, category lookup, coverage display) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: bz00qa <bz00qa.hub@gmail.com>
extract_base_cmd now strips trailing _\d+ numeric suffixes from command words, so test-generated entries like cmd1_test_19952 and cmd1_test_24604 are grouped as "rtk cmd1_test" in analytics. Includes migration to re-normalize existing base_cmd values. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: bz00qa <bz00qa.hub@gmail.com>
Dynamic column widths for Count/Total/Avg in TOP TOKEN CONSUMERS table. consumer_base() no longer includes file paths for arg-only commands (cat, find, grep, ls). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: bz00qa <bz00qa.hub@gmail.com>
classify_command() regexes require args (e.g. "find\s+"), so bare command names like "find" or "cat" from consumer_base() didn't match. Now also tries classification with a dummy arg appended. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: bz00qa <bz00qa.hub@gmail.com>
- Add cargo run/init/new/fix/audit to cargo regex - Add gh auth/workflow/gist/status/browse + more to gh regex - Handle git -c key=val before subcommand - cat/head/tail with redirects now Ignored instead of Unsupported Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: bz00qa <bz00qa.hub@gmail.com>
Replace boolean has_rtk_filter with RtkHandling enum to distinguish between commands with dedicated filters (Yes), passthrough support (Pass), and no RTK handling (No) in the consumers table. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: bz00qa <bz00qa.hub@gmail.com>
0fab6fc to
48fd7b0
Compare
…docs and tests Remove scope creep from PR rtk-ai#550: - Restore rules.rs/registry.rs to develop baseline, keep only in-scope changes - Remove strip_verbose_flags(), proxy -f routing, expanded subcommands - Remove bun/deno/bunx from COMMAND_REGISTRY (unmerged PR rtk-ai#548) - Remove context/watch/dedup from COMMAND_REGISTRY (non-existent PR rtk-ai#553) - Remove detect_patterns() and normalize_cmd_base() (deferred) - Remove PatternOpportunity from report Add missing tests: consumer_base(), effective_idx Add docs: CHANGELOG.md, README.md gain section, ARCHITECTURE.md discover module Fix clippy warnings in new test code (vec![] → array, single_match) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
thx for the detailed feedback, i have tried to respect all those mentioned and updated the PR accordingly |
|
|
|
Hey We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes No logic changes — only file moves and import path updates. What you need to doRebase your branch on git fetch origin && git rebase origin/developGit detects renames automatically. If you get import conflicts, update the paths: use crate::git; // now: use crate::cmds::git::git;
use crate::tracking; // now: use crate::core::tracking;
use crate::config; // now: use crate::core::config;
use crate::init; // now: use crate::hooks::init;
use crate::gain; // now: use crate::analytics::gain;Need help rebasing? Tag @aeppling |
Summary
Discover Report Redesign
pad_right/pad_lefthelpers)base_cmdgrouping (aggregates by first 3 words instead of exact command string)consumer_base()handles special patterns likepnpm --filter,python -m, keeping semantically related commands togetherGain Report Enhancements
ExportCoverage,ExportCategoryStats)Tracking DB Improvements
base_cmdcolumn with migration + backfill for command aggregationnew_in_memory()for test isolationeffective_idxlogic for correct output attribution in command chainsget_by_command_all()for unlimited command groupingChanges
src/discover/report.rsPatternOpportunityandTokenConsumertypes, colorized output helpers, redesignedformat_text()with pattern/consumer sections, 7 new testssrc/discover/mod.rsdetect_patterns(),normalize_cmd_base(),consumer_base(),effective_idxlogicsrc/tracking.rsbase_cmdcolumn migration,extract_base_cmd(),new_in_memory(),get_by_command_all(), refactored tests to in-memory DBsrc/gain.rsCOMMAND_REGISTRY, category column,print_command_coverage(),print_routing_breakdown(), coverage JSON export, 6 new testsTest plan
cargo fmt --all --checkpassesrtk discoverandrtk gainon a project with Claude Code history🤖 Generated with Claude Code