2061 Commits

Author SHA1 Message Date
patrick szymkowiak a3bfbf747c Merge pull request #42 from FlorianBruniaux/feat/execution-time-tracking
feat: add execution time tracking to rtk gain analytics
2026-02-02 08:32:09 +01:00
patrick szymkowiak 3ddffddc6d Merge pull request #40 from FlorianBruniaux/fix/release-workflow-trigger
fix: trigger release build after release-please creates tag
2026-02-02 08:22:57 +01:00
Florian BRUNIAUX db30d74c69 docs: add execution time tracking test guide 2026-02-02 00:14:15 +01:00
Florian BRUNIAUX 2a1e1a8ef3 feat: add execution time tracking to rtk gain analytics
Add exec_time_ms column to SQLite schema and track execution time
for all rtk commands. Display time metrics in gain summary, daily/
weekly/monthly breakdowns, and JSON/CSV exports.

Changes:
- tracking.rs: Add exec_time_ms column, TimedExecution struct
- display_helpers.rs: Add format_duration() helper, update tables
- gain.rs: Display total/avg exec time in summary and by-command
- All command modules: Apply TimedExecution timer wrapper
- Exports: Include total_time_ms and avg_time_ms in JSON/CSV

Example output:
  Total exec time:   24.6s (avg 34ms)
  rtk cargo test        7    -86.1%   349ms avg
  rtk git status      111    -84.1%     1ms avg

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-02 00:14:06 +01:00
Florian BRUNIAUX 61e4467b4f chore: set version to 0.7.1 (skip unintended 1.0.0 bump)
The previous PR #38 contained BREAKING CHANGE in the commit message,
which triggered an unintended major version bump to 1.0.0.

This commit:
- Updates manifest to 0.7.1
- Updates Cargo.toml to 0.7.1

After merging, close PR #39 without merging to skip the 1.0.0 release.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 22:21:12 +01:00
Florian BRUNIAUX 3b44ef9865 fix: trigger release build after release-please creates tag
Fixes #27

Tags created by GITHUB_TOKEN don't trigger other workflows. This change
makes release-please call release.yml directly via workflow_call after
creating a release.

Changes:
- release.yml: Add workflow_call trigger with tag input
- release.yml: Handle workflow_call in version detection
- release.yml: Upload assets for workflow_call events
- release-please.yml: Add build-release job that calls release.yml
- release-please.yml: update-latest-tag now waits for build to complete

This approach:
- Requires no PAT/secrets
- Keeps workflows separate and maintainable
- Uses workflow_call (cleaner than workflow_dispatch)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 21:36:53 +01:00
patrick szymkowiak fe4e0f9976 Merge pull request #38 from FlorianBruniaux/fix/ls-native-proxy
fix: convert rtk ls from reimplementation to native proxy
2026-02-01 21:35:16 +01:00
Florian BRUNIAUX 2176369467 fix: convert rtk ls from reimplementation to native proxy
BREAKING CHANGE: Removes --depth, --format (tree/flat/json) flags

Before: `rtk ls` was a reimplementation using WalkBuilder that didn't
support native ls flags like -l, -a, -h, -R.

After: `rtk ls` proxies to native ls, supporting all flags:
- `rtk ls -la` works
- `rtk ls -alh` works
- `rtk ls -R src/` works
- Default: `-la` when no args

Token optimization: filters "total X" line from output.

This aligns with rtk philosophy: proxy and filter, don't reimplement.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 21:22:17 +01:00
patrick szymkowiak fbfaa0053b Merge pull request #37 from pszymkowiak/release-please--branches--master--components--rtk
chore(master): release 0.7.0
v0.7.0
2026-02-01 20:08:08 +01:00
github-actions[bot] c04fe839b8 chore(master): release 0.7.0 2026-02-01 19:07:31 +00:00
patrick szymkowiak c9c64cfd30 Merge pull request #36 from FlorianBruniaux/feat/git-show
feat: discover command, auto-rewrite hook, git show
2026-02-01 20:07:12 +01:00
Florian BRUNIAUX 4bb0130695 fix: forward args in rtk git push/pull to support -u, remote, branch
rtk git push and rtk git pull now accept trailing arguments and forward
them to git. Fixes the auto-rewrite hook failing on commands like
`git push -u origin feat/branch`.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 16:38:02 +01:00
Florian BRUNIAUX ff1c7598c2 feat: add discover command, auto-rewrite hook, and git show support
- New `rtk discover` command scans Claude Code JSONL session history to
  identify missed RTK savings and suggest unhandled commands for issues.
  Modular architecture: registry (RegexSet classification), provider
  (SessionProvider trait + ClaudeProvider), report (text/json formatting).

- New PreToolUse auto-rewrite hook transparently intercepts Bash commands
  and rewrites them to rtk equivalents before execution, ensuring 100%
  adoption across all conversations including subagents.

- New `rtk git show` command with compact output: one-line commit summary
  + stat + compacted diff (reuses compact_diff from git diff).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 16:31:34 +01:00
patrick szymkowiak d3f17c3b11 Merge pull request #34 from pszymkowiak/release-please--branches--master--components--rtk v0.6.0 2026-02-01 15:43:08 +01:00
patrick szymkowiak e1813b6bbf Merge pull request #35 from FlorianBruniaux/feat/tdd-testing-skill 2026-02-01 15:41:28 +01:00
Florian BRUNIAUX 2d66726206 Add TDD skill, fix 3 failing tests, add 17 diff_cmd tests
- Fix test_analyze_logs: use normalizable paths instead of distinct IPs
- Fix test_filter_outdated: match real pnpm outdated output format
- Fix test_filter_ansi_colors: add missing Tests line for stats parsing
- Add .claude/skills/rtk-tdd/ with Red-Green-Refactor workflow
- Add testing-patterns.md reference with untested modules backlog
- Update CLAUDE.md Testing Strategy with TDD mandate and pre-commit gate
- Add 17 tests to diff_cmd.rs (similarity, truncate, compute_diff, condense)
- Test suite: 102/105 → 122/122

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 14:20:25 +01:00
github-actions[bot] 669f1d5801 chore(master): release 0.6.0 2026-02-01 10:58:18 +00:00
patrick szymkowiak ca0f68e54a Merge pull request #33 from FlorianBruniaux/feat/curl-command 2026-02-01 11:58:00 +01:00
patrick szymkowiak 0ec19c79d1 Merge pull request #32 from FlorianBruniaux/feat/js-ecosystem 2026-02-01 11:51:38 +01:00
patrick szymkowiak 2af9698353 Merge pull request #31 from FlorianBruniaux/feat/gh-expansion 2026-02-01 11:50:45 +01:00
patrick szymkowiak 3c20eb9c39 Merge pull request #30 from FlorianBruniaux/feat/git-extensions 2026-02-01 11:49:28 +01:00
patrick szymkowiak 9bfb003d90 Merge pull request #29 from FlorianBruniaux/feat/cargo-commands 2026-02-01 11:48:21 +01:00
patrick szymkowiak 6c608880e9 Merge pull request #28 from FlorianBruniaux/feat/shared-infra
feat: shared infrastructure for new commands
2026-02-01 10:05:56 +01:00
Florian BRUNIAUX 314accbfd9 feat: curl with auto-JSON detection
- Execute curl -s, auto-detect JSON responses
- JSON output piped through filter_json_string() for schema view
- Non-JSON output truncated to 30 lines with byte count

New module: src/curl_cmd.rs with 4 unit tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 23:39:55 +01:00
Florian BRUNIAUX 49b3cf293d feat: npm/npx routing, pnpm build/typecheck, --skip-env flag
- npm run: filter boilerplate (> script, npm WARN, progress)
- npx: intelligent routing to specialized filters
  (tsc, eslint, prisma, next, prettier, playwright)
- pnpm build: delegates to next_cmd filter
- pnpm typecheck: delegates to tsc_cmd filter
- --skip-env global flag: propagates SKIP_ENV_VALIDATION=1

New module: src/npm_cmd.rs with 2 unit tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 23:39:03 +01:00
Florian BRUNIAUX 517a93d0e4 feat: gh pr create/merge/diff/comment/edit + gh api
- gh pr create: capture URL + number, "ok created #N url"
- gh pr merge: "ok merged #N" confirmation
- gh pr diff: reuse compact_diff() for condensed output
- gh pr comment/edit: generic "ok {action} #N" confirmations
- gh api: auto-detect JSON, pipe through filter_json_string()

5 new tests in gh_cmd.rs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 23:37:17 +01:00
Florian BRUNIAUX bc31da8ad9 feat: git branch, fetch, stash, worktree commands
- git branch: compact listing (current/local/remote-only)
- git fetch: "ok fetched (N new refs)" confirmation
- git stash: list/show/pop/apply/drop with compact output
- git worktree: compact listing with home dir abbreviation

4 new tests in git.rs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 23:36:44 +01:00
Florian BRUNIAUX bfd5646f4e feat: cargo build/test/clippy with compact output
- cargo build: strip Compiling/Downloading lines, show errors + summary
- cargo test: show failures only + summary line
- cargo clippy: group warnings by lint rule with locations

New module: src/cargo_cmd.rs with 6 unit tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 23:35:59 +01:00
Florian BRUNIAUX 9dbc1178e7 feat: shared infrastructure for new commands
- Make compact_diff pub(crate) in git.rs for cross-module use
- Extract filter_json_string() from json_cmd.rs for reuse
- Add ok_confirmation() to utils.rs for write operation confirmations
- Add detect_package_manager() and package_manager_exec() to utils.rs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 23:34:54 +01:00
patrick szymkowiak dcfc8d91a6 Merge pull request #26 from pszymkowiak/release-please--branches--master--components--rtk
chore(master): release 0.5.2
v0.5.2
2026-01-30 16:52:20 +01:00
github-actions[bot] 038af6f648 chore(master): release 0.5.2 2026-01-30 15:49:54 +00:00
patrick szymkowiak 108d0b5ea3 Merge pull request #25 from FlorianBruniaux/fix/release-pipeline
fix: release pipeline trigger and version-agnostic package URLs
2026-01-30 16:49:35 +01:00
Florian BRUNIAUX 264539cf20 fix: release pipeline trigger and version-agnostic package URLs
Patrick reported 2 critical issues post-merge PR #23:

1. **release.yml never triggers**: release-please creates tags via GitHub API
   → no push event generated → build workflow never runs
   → v0.5.1 released without binaries

2. **README install URLs 404**: DEB/RPM URLs hardcode version 0.3.1
   → /releases/latest/download/ serves different filenames
   → all releases > 0.3.1 break installation instructions

Root cause analysis:
- release-please creates GitHub Releases (triggers `release.published` event)
- release.yml only listens to `on: push: tags` (doesn't fire for API-created tags)
- Standard pattern: release-please + binary builds = `on: release.published`

Fixes:
1. release.yml trigger:
   - Add `on: release: types: [published]` (standard release-please pattern)
   - Remove `on: push: tags: ['v*']` (dead code with release-please)
   - Update version extraction to handle `release` event
   - Split release job: upload assets (release event) vs create release (workflow_dispatch)

2. Version-agnostic package naming:
   - Create copies: rtk_0.5.0-1_amd64.deb → rtk_amd64.deb
   - Create copies: rtk-0.5.0-1.x86_64.rpm → rtk.x86_64.rpm
   - Update README URLs to use version-agnostic names
   - /releases/latest/download/ now serves stable filenames

Impact:
- release-please releases now auto-trigger binary builds
- Installation URLs work for all future releases
- No manual workflow_dispatch needed for new versions

Manual action required:
Patrick needs to re-run build for v0.5.1 via workflow_dispatch
(or create v0.5.2 with a trivial fix commit)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-30 16:29:15 +01:00
patrick szymkowiak b46ed8357f Merge pull request #24 from pszymkowiak/release-please--branches--master--components--rtk
chore(master): release 0.5.1
v0.5.1
2026-01-30 15:40:18 +01:00
github-actions[bot] c30f3a151e chore(master): release 0.5.1 2026-01-30 14:32:41 +00:00
patrick szymkowiak d773ec3ea5 Merge pull request #23 from FlorianBruniaux/master
fix: 3 issues (latest tag, ccusage fallback, versioning)
2026-01-30 15:32:24 +01:00
Florian BRUNIAUX 9e322e2aee fix: patrick's 3 issues (latest tag, ccusage fallback, versioning)
1. CRITICAL: Fix 'latest' tag creation after releases
   - Move update-latest-tag job from release.yml to release-please.yml
   - release-please creates tags via API (no push event) → must run in same workflow
   - Job now conditional on release_created output

2. IMPORTANT: Add npx fallback for ccusage + improve message
   - Check binary in PATH first, fallback to 'npx ccusage'
   - Updated message: "npm i -g ccusage (or use npx ccusage)"
   - Consistent with other JS tooling (next_cmd, tsc_cmd, prettier_cmd)

3. PROCESS: Slow down version bumps with release-please config
   - Add release-please-config.json with bump-patch-for-minor-pre-major
   - In 0.x versions: feat: → patch bump instead of minor
   - Prevents rapid version inflation (0.3.1 → 0.5.0 in 21h)

Fixes issues raised by Patrick after PR #21 merge.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-30 15:24:56 +01:00
patrick szymkowiak 62f9055899 Merge pull request #22 from pszymkowiak/release-please--branches--master--components--rtk
chore(master): release 0.5.0
v0.5.0
2026-01-30 14:24:44 +01:00
github-actions[bot] 3475992c14 chore(master): release 0.5.0 2026-01-30 13:15:53 +00:00
patrick szymkowiak 8e72e7a8b8 Merge pull request #21 from FlorianBruniaux/feature/temporal-audit-system
feat: comprehensive economics analysis and code quality improvements
2026-01-30 14:15:38 +01:00
Florian BRUNIAUX 3b847f863a fix: optimize HashMap merge and add safety checks
Applies targeted code quality improvements:

Issue #5: Reduce clones in HashMap merge
- Destructure CcusagePeriod to avoid cloning key
- Use .or_insert_with_key() for ccusage data merging
- Keep necessary clones for rtk data (HashMap ownership requirement)
- Affects: merge_daily, merge_weekly, merge_monthly

Issue #7: Replace magic number with named constant
- Add const BILLION: f64 = 1e9
- Improves readability in cache token calculation

Issue #8: Add NaN/Infinity safety check
- Guard format_usd() against invalid float values
- Return "$0.00" for non-finite inputs

Build: Clean (1 pre-existing warning)
Tests: 79/82 passing (3 pre-existing failures)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-30 14:05:50 +01:00
Florian BRUNIAUX 5b840cca49 fix: comprehensive code quality improvements
Apply systematic quality fixes identified in code audit:

Phase 1: Remove dead code (4 warnings → 0)
- Remove unused run_compact() function in gain.rs
- Remove unused track_tokens() function in tracking.rs
- Remove unused TRACKER singleton (Mutex)
- Clean up CommandRecord struct (remove unused fields)

Phase 2: Add error context and quality fixes
- Add .context() to all ? operators in cc_economics.rs (15+ callsites)
- Add .context() to all ? operators in gain.rs (10+ callsites)
- Fix bounds check panic risk in gain.rs:252 (week_start slice)
- Reduce visibility: estimate_tokens pub → private
- Replace 6 manual loops with idiomatic .collect::<Result<Vec<_>, _>>()?
- Remove residual dev comment (// psk:)
- Remove unnecessary .clone() in main.rs

Phase 3: Refactor duplication (132 lines eliminated)
- Create display_helpers.rs module with PeriodStats trait
- Unify print_daily_full/weekly/monthly in gain.rs (152 lines → 9 lines)
- Implement trait for DayStats, WeekStats, MonthStats
- Zero-overhead compile-time dispatch (monomorphization)
- Output bit-identical, all tests passing

Impact:
- Dead code: -20 lines
- Error context: Errors now actionable instead of opaque
- Duplication: -132 lines of pure duplication
- Safety: Bounds check prevents potential panic
- Idiomaticity: .collect() over manual loops

Metrics:
- Build: 0 errors, 1 warning (pre-existing cache_* fields)
- Tests: 79/82 passing (3 pre-existing failures)
- Clippy: 13 warnings (all pre-existing)
- Functional: rtk gain --daily, rtk cc-economics validated

Addresses code audit feedback from parallel session
Detailed report: claudedocs/refactoring-report.md

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-30 13:48:03 +01:00
Florian BRUNIAUX ec1cf9a56d feat: add comprehensive claude code economics analysis
Implement `rtk cc-economics` command combining ccusage spending data
with rtk savings analytics for economic impact reporting.

Features:
- Dual metric system (active vs blended cost-per-token)
- Daily/weekly/monthly granularity with ISO-8601 week alignment
- JSON/CSV export support for data analysis
- Graceful degradation when ccusage unavailable
- Real-time data merge with O(n+m) HashMap performance

Architecture:
- src/ccusage.rs: Isolated ccusage CLI interface (7 tests)
- src/cc_economics.rs: Business logic + display (10 tests)
- src/utils.rs: Shared formatting utilities (8 tests)
- Refactored gain.rs to use shared format_tokens()

Test coverage: 17 new tests, all passing
Validated with real-world data (2 months, $3.4K spent, 1.2M saved)

Addresses: #economics-integration
Impact: 24.4% cost savings identified ($830.91 active pricing)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-30 12:34:47 +01:00
patrick szymkowiak 4f0ad2e86e Merge pull request #20 from pszymkowiak/release-please--branches--master--components--rtk
chore(master): release 0.4.0
v0.4.0
2026-01-30 11:38:52 +01:00
github-actions[bot] cf8ddcbe6e chore(master): release 0.4.0 2026-01-30 10:37:17 +00:00
patrick szymkowiak 862047e387 Merge pull request #19 from FlorianBruniaux/feature/temporal-audit-system
feat: Comprehensive Temporal Audit System for Token Savings Analytics
2026-01-30 11:36:58 +01:00
Florian BRUNIAUX 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>
2026-01-30 11:12:45 +01:00
patrick szymkowiak c84a8044ee Merge pull request #18 from FlorianBruniaux/feature/auto-latest-tag
ci: automate 'latest' tag update on releases
2026-01-30 10:32:46 +01:00
Florian BRUNIAUX 3d76900469 ci: automate 'latest' tag update on releases
Add automated workflow step to update the 'latest' tag after each
successful release. This ensures 'latest' always points to the most
recent stable version without manual intervention.

The new job:
- Runs after successful release completion
- Updates 'latest' tag to point to the new semver tag
- Uses force push to move the tag reference
- Includes version info in tag annotation message

Benefits:
- Install scripts can reliably use /releases/latest/download/
- No manual tag management needed
- Consistent reference for "current stable" across platforms

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-30 10:26:20 +01:00
patrick szymkowiak e0565dacd8 Merge pull request #17 from FlorianBruniaux/docs/comprehensive-update
docs: comprehensive documentation update for v0.3.1
2026-01-30 10:03:30 +01:00