Florian BRUNIAUX
b13d92c9ea
fix(docs): escape HTML tags in rustdoc comments
...
Fixes 6 rustdoc warnings:
- Escape <action>, <detail>, <hash>, <branch>, <stats> tags
- Use backticks for [RTK:PASSTHROUGH] marker
All rustdoc warnings now resolved.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-03 11:33:40 +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
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
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
Florian BRUNIAUX
0fc06f9509
feat: add shared utils module for JS stack commands
...
Add utils.rs with common utilities used across modern JavaScript
tooling commands:
- truncate(): Smart string truncation with ellipsis
- strip_ansi(): Remove ANSI escape codes from output
- execute_command(): Centralized command execution with error handling
These utilities enable consistent output formatting and filtering
across multiple command modules.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-01-29 11:23:26 +01:00