mirror of
https://github.com/rtk-ai/rtk.git
synced 2026-09-19 07:33:17 +08:00
feat/trigger-release
10 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d0396da1ce |
chore: merge develop into master (#499)
* fix: handle tail rewrites with read tail-lines * feat: add 32 TOML-filtered commands to hook rewrite rules (#475) Add rewrite rules for all TOML-filtered commands so the Claude Code hook automatically rewrites them to `rtk proxy <cmd>`. This ensures TOML filters apply transparently without manual `rtk` prefixing. Commands added: ansible-playbook, brew, composer, df, dotnet, du, fail2ban-client, gcloud, hadolint, helm, iptables, make, markdownlint, mix, mvn, ping, pio, poetry, pre-commit, ps, quarto, rsync, shellcheck, shopify, sops, swift, systemctl, terraform, tofu, trunk, uv, yamllint. Tests updated to use `htop` as unsupported command example since terraform is now supported via TOML filter. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix: git log --oneline no longer silently truncated to 10 entries (#461) (#478) Only inject -10 limit when RTK applies its own compact format. When user provides --oneline/--pretty/--format, respect git's default behavior (no limit). Also detect -n and --max-count as user-provided limit flags. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix: gh run view --job flag loses its value (#416) (#477) Add --job and --attempt to flags_with_value in extract_identifier_and_extra_args() so their values are not mistaken for the run identifier when placed before it. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix: rtk read no longer corrupts JSON files with glob patterns (#464) (#479) Add Language::Data variant for JSON, YAML, TOML, XML, Markdown, CSV and other data formats. These files have no comment syntax, so the MinimalFilter skips comment stripping entirely. Previously, `packages/*` in package.json was treated as a block comment start (`/*`), causing everything until the next `*/` to be stripped — corrupting the JSON structure. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix: npm routing, discover cat redirect, proxy quoted args (#480) * fix: npm routing, discover cat redirect, proxy quoted args (#470, #315, #388) #470: rtk npm now correctly routes npm subcommands (install, list, audit, etc.) without injecting "run". Previously, `rtk npm install` was executed as `npm run install`. #315: discover no longer counts `cat >`, `cat >>`, `cat |` as missed savings. These are write/pipe operations with no terminal output to compress. #388: rtk proxy now auto-splits a single quoted argument containing spaces. `rtk proxy 'head -50 file.php'` now works like `rtk proxy head -50 file.php`. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix: proxy quote-aware split, redirect detection scan all tokens, npm test routing - Proxy: replace split_whitespace with shell_split() that respects quotes (#388) e.g. 'git log --format="%H %s"' no longer splits on space inside quotes - Discover: scan all tokens for redirect operators, not just nth(1) (#315) e.g. 'cat file.txt > output.txt' now correctly detected as write - npm: replace tautological test with actual routing logic verification Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> --------- Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * feat: add 11 new TOML built-in filters (xcodebuild, jq, basedpyright, ty, skopeo, stat, biome, oxlint, jj, ssh, gcc) (#490) Closes #484, #483, #449, #448, #428, #283, #316, #195, #271, #333, #87, #376 Signed-off-by: Patrick <patrick@rtk.ai> Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix: rtk rewrite accepts multiple args without quotes (#504) * fix: rtk rewrite accepts multiple args without quotes `rtk rewrite ls -al` now works the same as `rtk rewrite "ls -al"`. Previously, args after the command were rejected or caused ENOENT. Also adds rewrite tests to benchmark.sh to prevent regression. Signed-off-by: Patrick Szymkowiak <patrick.szymkowiak@rtk-ai.app> Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * test: add Clap rewrite tests + fix benchmark false failures - Add 2 Clap try_parse_from tests for rewrite multi-args (catches the KuSh bug at unit test level, not just benchmark) - Fix git diff benchmark: use HEAD~1 on both sides for fair comparison - Skip cargo/rustc benchmarks when tools not in PATH instead of false FAIL - Benchmark: 0 fail, 4 skip (env-dependent), 52 green Signed-off-by: Patrick Szymkowiak <patrick.szymkowiak@rtk-ai.app> Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> --------- Signed-off-by: Patrick Szymkowiak <patrick.szymkowiak@rtk-ai.app> Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix: use rtk <cmd> instead of rtk proxy for TOML-filtered commands (#507) - Replace all 32 `rtk proxy <cmd>` rules with `rtk <cmd>` so TOML filters actually apply (proxy bypasses filters, giving 0% real savings) - Extract NPM_SUBCOMMANDS to module-level const to prevent test/prod drift Reported-by: FlorianBruniaux Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix: warn when no hook installed + rtk gain hook status + PR #499 fixes - hook_check: detect missing hook (not just outdated), warn with ⚠️ Only warns if ~/.claude/ exists (Claude Code user) — once per day - gain: show hook status warning (missing/outdated) in rtk gain output - ssh.toml: bump max_lines 50→200, truncate_lines_at 120→200 (Florian review) - git.rs: mark integration test #[ignore] + assert binary exists (Florian review) - Add HookStatus enum for reuse across gain/diagnostics Fixes #508, Fixes #509 Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix: address code review — hook_check edge cases - status() checks .claude/ existence (no false warning for non-CC users) - Unreadable hook file returns Outdated not Missing - Swap marker/warning order (emit warning before touching rate-limit marker) - Rename misleading test, add end-to-end status() test Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix: review iteration 2 — double-warning, case-sensitive test, ssh truncate - Refactor check_and_warn to delegate to status() (single source of truth) - Fix double-warning: skip maybe_warn() for `rtk gain` (has its own inline warning) - Fix git test: case-insensitive assertion for cross-locale compatibility - ssh.toml: keep truncate_lines_at=120 (terminal width convention) - Robust mtime handling: unwrap_or(u64::MAX) instead of nested .ok()? - Test handles all CI environments (no hook, no .claude, hook present) Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix: detect and warn RTK_DISABLED=1 overuse (#508) - discover: count RTK_DISABLED= bypassed commands, report top 5 examples - gain: lightweight 7-day JSONL scan, warn if >10% commands bypassed - registry: add has_rtk_disabled_prefix() and strip_disabled_prefix() helpers - gitignore: add .fastembed_cache/ and .next/ Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix: preserve trailing newline in tail_lines + add missing test - apply_line_window() now preserves trailing newline when input has one - Add test for tail --lines N (space form) rewrite - Add test for tail_lines without trailing newline Signed-off-by: Patrick <patrick@rtk-ai.com> Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix: respect user-specified git log limits instead of silently truncating RTK was silently capping git log output in two ways: 1. `--oneline` without `-N` defaulted to 10 entries (now 50) 2. `filter_log_output()` re-truncated even when user explicitly set `-N` 3. Lines >80 chars were truncated, hiding PR numbers and author names This matters for LLM workflows: Claude needs full commit history for rebase, squash, and changelog operations. Silent truncation caused incomplete context and repeated re-runs. Changes: - User-explicit `-N` → no line cap, wider 120-char truncation - `--oneline`/`--pretty` without `-N` → default 50 (was 10) - No flags → unchanged (default 10) - Extract `truncate_line()` helper for clarity Fixes #461 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: handle -n N and --max-count=N forms in git log limit parsing - Extract parse_user_limit() to handle all 4 forms: -20, -n 20, --max-count=20, --max-count 20 - Add token savings test for filter_log_output (≥60%) - Add 5 tests for parse_user_limit edge cases Signed-off-by: Patrick <patrick@rtk-ai.com> Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * feat: add structured dotnet support (build/test/restore/format) Integrate PR #172 by @danielmarbach onto develop: - MSBuild binlog parser (binary format, gzip, 7-bit varint) - TRX test result parser (quick-xml) - Format report JSON parser - Subcommand routing: build, test, restore, format + passthrough - Sensitive env var scrubbing (GH_TOKEN, AWS_SECRET_ACCESS_KEY, etc.) - Fallback to text parsing when binlog unavailable - 86-93% token savings on real .NET projects Maintainer fixes applied: - Removed binlog temp path from output (wastes tokens) - Dropped hook file changes (incompatible with develop architecture) - Fixed unused variable warnings 888 tests pass. Signed-off-by: Patrick <patrick@rtk-ai.com> Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * feat: add OpenCode plugin support (#300) * feat(opencode): add OpenCode plugin support Add `--opencode` flag to `rtk init` for installing a global OpenCode plugin that rewrites Bash/shell commands through `rtk rewrite`. - New plugin: hooks/opencode-rtk.ts (thin delegator to rtk rewrite) - New init modes: --opencode (OpenCode only), combinable with Claude modes - Plugin install/update/remove lifecycle with idempotent writes - Uninstall cleans up OpenCode plugin alongside Claude Code artifacts - `rtk init --show` reports OpenCode plugin status - Replace unreachable!() with bail!() in match exhaustiveness guard * docs: add OpenCode plugin documentation - README: OpenCode plugin section, install flags, troubleshooting - TROUBLESHOOTING: OpenCode-specific checklist - Update init mode table to reflect Claude Code default --------- Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> Signed-off-by: Patrick <patrick@rtk.ai> Signed-off-by: Patrick Szymkowiak <patrick.szymkowiak@rtk-ai.app> Signed-off-by: Patrick <patrick@rtk-ai.com> Co-authored-by: Qingyu Li <2310301201@stu.pku.edu.cn> Co-authored-by: Ousama Ben Younes <benyounes.ousama@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: José Almeida <57680069+zeval@users.noreply.github.com> |
||
|
|
926e6a0dd4 |
feat: TOML Part 2 — user-global config, shadow warning, rtk init templates, 4 new built-in filters (#351)
* docs: update module count to 58 (toml_filter + verify_cmd) * docs: bump version refs to 0.27.1, fix module count to 59 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: TOML DSL PR 2 — user-global config, shadow warning, init templates, 4 new filters - toml_filter: add ~/.config/rtk/filters.toml (priority 2, between project and built-in) - toml_filter: shadow warning when match_command overlaps a Rust-handled command - init: rtk init generates .rtk/filters.toml template (local) and ~/.config/rtk/filters.toml (global) - builtin_filters: add pre-commit, helm, gcloud, ansible-playbook (46/46 inline tests) - README: add "Custom Filters" section with lookup table, primitives, examples, built-in list Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(filters): add quarto-render, pnpm-build, trunk-build from rtk discover data (52/52 tests) * feat(filters): add docker-inspect, sops, docker-compose-ps built-in filters Resolves issues #279, #277, #276 as TOML-native filters (no Rust required). - docker-inspect: strip_ansi + truncate_lines_at=120 + max_lines=60 - sops: strip_ansi + strip_lines_matching blank lines + max_lines=40 - docker-compose-ps: strip_ansi + truncate_lines_at=120 + max_lines=40 6 inline tests added (2 per filter), all passing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(filters): split monolithic builtin_filters.toml into 28 individual files Replace the 848-line src/builtin_filters.toml monolith with individual files under src/filters/<name>.toml (1 filter + tests per file). Files are concatenated alphabetically by build.rs at compile time into OUT_DIR/builtin_filters.toml, then embedded via a BUILTIN_TOML constant in toml_filter.rs. The build step validates TOML syntax and detects duplicate filter names across files. Benefits: - Zero merge conflicts when multiple PRs add filters (different files) - Clear PR diffs: "+1 file of 30 lines" vs "+30 lines in 850-line file" - Easy onboarding: copy any .toml, rename, edit 3 fields — done - Build-time TOML validation catches syntax errors before tests run Changes: - build.rs (new): concat + validate src/filters/*.toml - Cargo.toml: add [build-dependencies] toml = "0.8" - src/filters/*.toml (28 files): split from monolith - src/filters/README.md (new): contributor guide - src/toml_filter.rs: BUILTIN_TOML const + 5 include_str replacements - src/builtin_filters.toml: deleted Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test(filters): add 5 new unit tests for multi-file architecture + wget filter Unit tests added (toml_filter.rs): - test_builtin_toml_has_schema_version: ensures build.rs injects schema_version - test_builtin_all_expected_filters_present: guards against accidental file deletion - test_builtin_filter_count: exact count check (fails if filter added/removed without update) - test_builtin_all_filters_have_inline_tests: prevents shipping filters with no tests - test_new_filter_discoverable_after_concat: simulates build.rs concat, verifies lookup New built-in filter: - src/filters/wget.toml: compact wget download output (strips connection/resolution noise, short-circuits on 'saved [' to 'ok (downloaded)', 2 inline tests) Test results: 661/661 unit tests, 60/60 inline TOML filter tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs: add filter-workflow.md with Mermaid diagrams Build pipeline + runtime lookup priority, both as Mermaid flowcharts. Shows the full path from src/filters/*.toml to binary to execution. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: remove dead TOML filters — wget, git-checkout, git-merge, git-remote, cargo-run These filters were never reachable: Clap routes rtk git/cargo commands to their dedicated Rust modules before run_fallback is called. The TOML engine only fires for unknown commands. Shipping dead filters gives false confidence (inline tests pass, but filters never activate in production). Also fixes P1-1 from the PR #386 review: wget was in RUST_HANDLED_COMMANDS and the shadow warning fired at compile time but did not block the build. Removed: cargo-run.toml, git-checkout.toml, git-merge.toml, git-remote.toml, wget.toml Updated test guards: count 29→24, expected list -5 names, concat test 30→25. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: remove 3 dead TOML filters + update guards (PR #351) docker-inspect, docker-compose-ps, and pnpm-build are handled by container.rs and pnpm_cmd.rs before run_fallback is reached — their TOML filters never fire. Remove the files to avoid false documentation. Update toml_filter.rs guards: expected list -3 names, count 24→21, concat test 25→22. Update CONTRIBUTING.md example count to match. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: rebase on PR #349 — apply regex anchors, make on_empty, build.rs clippy, docs macOS path - Add (\\s|$) word-boundary anchors to 6 tofu/mix match_command regexes (tofu-plan, tofu-init, tofu-validate, tofu-fmt, mix-format, mix-compile) - Add on_empty = "make: ok" to make.toml + update existing empty-output test - Fix build.rs clippy: map_or(false, ...) → is_some_and(..) - Add macOS alt path note to filter-workflow.md Mermaid diagram Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> |
||
|
|
b11fb00cde |
docs: add comprehensive functional and user guide documentation (#389)
- Create docs/FEATURES.md with all 45+ commands documented (syntax, options, examples, token savings) - Create docs/GUIDE.md with getting started, workflows per language, Claude Code integration, FAQ, troubleshooting |
||
|
|
606b86ed43 |
feat(gain): colored dashboard with efficiency meter and impact bars (#129)
* feat(gain): add colored dashboard with efficiency meter and impact bars Upgrade `rtk gain` output with rich terminal visualization: - Colored percentage cells (green ≥70%, yellow ≥40%, red <40%) - Efficiency meter: ASCII progress bar with savings percentage - Impact bars: proportional block charts per command - Styled section headers (bold green) - Command names in bright cyan - History tier indicators (▲/■/•) - Dynamic column widths for clean table alignment - KPI-style key-value layout for summary metrics All visual features are TTY-aware via std::io::IsTerminal — output degrades gracefully to plain text when piped or redirected. No new dependencies (uses existing `colored` crate). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add dashboard visualization screenshot Shows colored terminal output of `rtk gain -p` with: - Project-scoped token savings header - Efficiency meter with color gradient - Per-command table with colored Avg% and Impact bars Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> |
||
|
|
8c67a2f1e7 |
docs: update for hook-first installation mode
## README.md Updates **Quick Start section:** - Clear 3-step process: verify → install hook → test - Prominently recommend `rtk init -g` (hook-first mode) - Explain 99.5% token savings (2000 → 10 tokens) - Show alternative modes (--claude-md, local init) **Configuration section:** - New comparison table: 4 modes with token costs - Migration instructions for existing users - Clarify hook vs CLAUDE.md injection differences **Auto-Rewrite Hook section:** - Promote automated install (`rtk init -g`) as primary method - Keep manual install as fallback - Add verification step (`rtk init --show`) ## INSTALL.md Updates **Project Initialization:** - Recommend global hook-first setup (with rationale) - Show token savings: 99.5% reduction - Document local setup as alternative - Add upgrade/migration guide for existing users ## TROUBLESHOOTING.md Updates **RTK not working section:** - Option A: Automated (`rtk init -g`) - recommended - Option B: Manual install - fallback - Clarify absolute path requirement in settings.json - Add verification step ## Fixes Documentation Gaps Before: - ❌ No mode comparison - ❌ No migration guide - ❌ Manual install only - ❌ Unclear token impact After: - ✅ Clear mode comparison with use cases - ✅ Automatic migration documented - ✅ Automated install prioritized - ✅ Quantified token savings (99.5%) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> |
||
|
|
521eb1b9bc |
docs(tracking): complete API documentation + rustdoc comments
Add comprehensive documentation for tracking.rs public APIs: **New Files:** - docs/tracking.md (12 pages) - Architecture & data flow - All public APIs (12 methods, 7 types) - Usage examples (basic, CI/CD, dashboards, Rust lib) - JSON/CSV export schemas - Database schema & migrations - Integration examples (GitHub Actions, Python, Rust) - Security, performance, troubleshooting - claudedocs/TRACKING_DOCUMENTATION.md - Documentation summary & metrics **Updated Files:** - src/tracking.rs - Module-level docs (//!) - Comprehensive doc comments (///) for all public APIs - Examples with error handling - Deprecation notices for legacy functions - README.md - Pointer to docs/tracking.md after rtk gain section **Coverage:** - 7 public structs documented - 12 public methods documented - 3 utility functions documented - 20+ code examples - 3 integration examples (CI/CD, dashboards, Rust lib) - JSON/CSV/SQL schemas **Testing:** - All 6 tracking tests still pass - 100% coverage maintained Closes gap: CLI was documented, but public APIs were not. Now fully documented for external integration (CI/CD, dashboards, Rust lib usage). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> |
||
|
|
15a34aef04 |
Fix installation script URL and update project info
Updated installation instructions and clarified project details. |
||
|
|
00623cb80e |
docs: point all documentation to upstream instead of fork
## Problem Documentation incorrectly promoted the fork over upstream for installation, creating confusion about which repository is the source of truth. ## Changes ### Installation Instructions - **README.md**: Restored curl install pointing to upstream (pszymkowiak/rtk) - **README.md**: Removed "Fork with All Features" section - **INSTALL.md**: Added curl install, removed fork recommendation - **TROUBLESHOOTING.md**: All installation paths → upstream ### Repository References - **README.md**: Removed fork from repo list, issues → rtk-ai/rtk - **CLAUDE.md**: Removed fork mention from project list - **CHANGELOG.md**: Repository and issues → rtk-ai/rtk - **ROADMAP.md**: Installation instructions → upstream curl ### Scripts - **check-installation.sh**: Install instructions → upstream curl ## Result All documentation now consistently points to upstream (rtk-ai/rtk, pszymkowiak/rtk) as the source of truth for installation and issues. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> |
||
|
|
e2e8be42a7 |
docs: clarify rtk name collision and fix installation confusion
## Problem Users are accidentally installing the wrong "rtk" package: - Rust Type Kit (reachingforthejack/rtk) - type generation tool - Rust Token Killer (rtk-ai/rtk) - LLM token optimizer This causes confusion when `rtk gain` doesn't exist after installation. ## Changes ### Documentation Updates - **README.md**: Add prominent warning about name collision at top - **README.md**: Fix installation instructions with mandatory verification - **CLAUDE.md**: Add name collision warning with verification steps - **INSTALL.md**: Clarify pre-installation checks and wrong package handling ### New Files - **docs/TROUBLESHOOTING.md**: Comprehensive troubleshooting guide covering: - Wrong rtk installed (Type Kit vs Token Killer) - cargo install rtk pitfalls - Missing commands (vitest, pnpm, etc.) - PATH issues and compilation errors - **scripts/check-installation.sh**: Automated diagnostic script that verifies: - RTK installed and in PATH - Correct version (Token Killer with `rtk gain`) - Available features - Claude Code integration status - Auto-rewrite hook configuration ## Verification After these changes, users can quickly diagnose installation issues: ```bash bash scripts/check-installation.sh ``` Fixes installation confusion reported by multiple users. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> |
||
|
|
76703ca3f5 |
feat: add comprehensive temporal audit system for token savings analytics
Implement day-by-day, week-by-week, and monthly breakdowns with JSON/CSV export capabilities for in-depth token savings analysis and reporting. New Features: - Daily breakdown (--daily): Complete day-by-day statistics without 30-day limit - Weekly breakdown (--weekly): Sunday-to-Saturday week aggregations with date ranges - Monthly breakdown (--monthly): Calendar month aggregations (YYYY-MM format) - Combined view (--all): All temporal breakdowns in single output - JSON export (--format json): Structured data for APIs, dashboards, scripts - CSV export (--format csv): Tabular data for Excel, Google Sheets, data science Technical Implementation: - src/tracking.rs: Add DayStats, WeekStats, MonthStats structures with Serialize - src/tracking.rs: Implement get_all_days(), get_by_week(), get_by_month() SQL queries - src/main.rs: Extend Commands::Gain with --daily, --weekly, --monthly, --all, --format flags - src/gain.rs: Add print_daily_full(), print_weekly(), print_monthly() display functions - src/gain.rs: Implement export_json() and export_csv() for data export Documentation: - docs/AUDIT_GUIDE.md: Comprehensive guide with examples, workflows, integrations - README.md: Update Data section with new audit commands and export formats - claudedocs/audit-feature-summary.md: Technical summary and implementation details Database Scope: - Global machine storage: ~/.local/share/rtk/history.db - Shared across all projects, worktrees, and Claude sessions - 90-day retention policy with automatic cleanup - SQLite with indexed timestamp for fast aggregations Use Cases: - Trend analysis: identify daily/weekly patterns in token usage - Cost reporting: monthly savings reports for budget tracking - Data science: export CSV/JSON for pandas, R, Excel analysis - Dashboards: integrate JSON export with Chart.js, D3.js, Grafana - CI/CD: automated weekly/monthly savings reports via GitHub Actions Examples: rtk gain --daily # Day-by-day breakdown rtk gain --weekly # Weekly aggregations rtk gain --all # All breakdowns combined rtk gain --all --format json | jq . # JSON export with jq rtk gain --all --format csv # CSV for Excel/analysis Backwards Compatibility: - All existing flags (--graph, --history, --quota) preserved - Default behavior unchanged (summary view) - No database migration required - Zero breaking changes Performance: - Efficient SQL aggregations with timestamp index - No impact on rtk command execution speed - Instant queries even with 90 days of data Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> |