Commit Graph

13 Commits

Author SHA1 Message Date
Navid EMAD 15bc0f8d6e feat(ruby): add Ruby on Rails support (rspec, rubocop, rake, bundle) (#724)
* feat(ruby): add Ruby on Rails support (rspec, rubocop, rake, bundle)

Unifies 5 competing PRs (#198, #292, #379, #534, #643) into a single
coherent implementation.

New commands:
- rtk rspec: JSON parsing with text fallback (60%+ savings)
- rtk rubocop: JSON parsing, group by cop/severity (60%+ savings)
- rtk rake test: Minitest state machine parser (85-90% savings)
- rtk bundle install: TOML filter, strip Using lines (90%+ savings)

Shared infrastructure: ruby_exec(), fallback_tail(),
exit_code_from_output(), count_tokens() in utils.rs.

Discover/rewrite rules for rspec, rubocop, rake, rails, bundle
including bundle exec and bin/ variants.

E2E smoke tests (scripts/test-ruby.sh) covering all 4 commands.
56 new unit tests + 4 inline TOML tests. All 1035 tests passing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Navid EMAD <navid.emad@yespark.fr>

* fix(ruby): use TEST= env var for rake single-file test in smoke tests

Rails' `rake test` ignores positional file args; use `TEST=path` syntax.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Navid EMAD <navid.emad@yespark.fr>

* docs(ruby): add Ruby module architecture and update attribution

Integrate ARCHITECTURE.md Ruby Module Architecture section and CLAUDE.md
module table/fork-features from PR #643. Update PR description attribution.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Navid EMAD <navid.emad@yespark.fr>

* chore: remove PULL_REQUEST_DESCRIPTION.md from repo

PR description lives on GitHub, no need to track in the codebase.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Navid EMAD <navid.emad@yespark.fr>

---------

Signed-off-by: Navid EMAD <navid.emad@yespark.fr>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 15:04:59 +01:00
Artiom Tofan 2e194efb3a fix: resolve Windows command wrapper execution (#269)
- add PATHEXT-aware command resolution via which\n- migrate affected command runners to resolved_command\n- add regression coverage for wrapper/fallback behavior
2026-03-12 15:36:19 +01:00
Florian BRUNIAUX adda2537be feat: TOML Part 1 — filter DSL engine + 14 built-in filters (#349)
* feat: TOML filter DSL + 14 built-in filters (#299)

Add a declarative TOML-based filter engine for zero-Rust command
filtering, plus 14 built-in filters targeting open issues.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: update module count to 58 (toml_filter + verify_cmd)

* docs(changelog): add TOML DSL + 14 built-in filters entry

* chore: ignore worktrees directory

* fix: address PR #349 code review (P1 + P2)

P1-1: println! — add trailing newline to TOML-filtered output
  print!("{}", filtered) → println!("{}", filtered). Fixes broken
  pipe compatibility (rtk make all | wc -l returned 0 for 1 line).

P1-2: remove dead filters — git-checkout, git-remote, git-merge, cargo-run
  Clap routes these commands to git.rs/cargo_cmd.rs before run_fallback
  is reached, so these TOML filters never activate. Tests passed but
  gave false confidence. Removed filter definitions and test sections.

P1-3: map_or instead of is_none_or (MSRV compatibility)
  is_none_or requires Rust 1.82+. Replaced with map_or(true, ...) which
  compiles on all supported toolchain versions.

P1-4: print tee hint for TOML-filtered commands on failure
  let _ = tee::tee_and_hint(...) silently discarded the hint path.
  Now follows the same pattern as runner.rs: if let Some(hint) = ... {
  println!("{}", hint); }. LLMs can now find the full output file.

P1-5: --require-all now runs integrity check
  Previously, `rtk verify --require-all` branched away from
  integrity::run_verify(). Now: filter-specific mode (--filter foo)
  skips integrity, but default and --require-all always run it first.

P2-1: RTK_NO_TOML checks value not presence
  .is_ok() matched any value including RTK_NO_TOML=0.
  Replaced with .ok().as_deref() == Some("1").

P2-5: terraform-plan regex — add word boundary after "plan"
  ^terraform\s+plan → ^terraform\s+plan(\s|$) to prevent matching
  "terraform planning" or other plan-prefixed subcommands.

P2-6: iptables regex — \b → (\s|$)
  ^iptables\b matched iptables-save and iptables-restore (\b fires at
  hyphen). Fixed to ^iptables(\s|$).

All 715 tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: add word-boundary anchors to 6 tofu/mix match_command regexes

Prevents overmatch on subcommands (e.g. `tofu planet` or `mix formats`).
Mirrors the same `(\s|$)` pattern already used by terraform-plan.

Fixes: tofu-plan, tofu-init, tofu-validate, tofu-fmt, mix-format, mix-compile

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs(changelog): add round 2 fix for tofu/mix regex overmatch (PR #349)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: address PR #349 round 3 review (BUG-1 + BUG-2 + P2 items)

- println! trailing newline on TOML-filtered output (BUG-1)
- RTK_NO_TOML check presence→value (as_deref==Ok("1")) (BUG-2)
- make filter: add on_empty="make: ok" + test (P2-3)
- TOML lookup: use basename of args[0] for absolute path support (P2-8)
- utils.rs: translate French docstrings to English (P2-9)
- main.rs: single error message on command-not-found, exit(127) (NEW)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: bump version refs to 0.27.2 and module count to 60

Fixes pre-push validation: README, CLAUDE.md, ARCHITECTURE.md were
still referencing 0.27.1 (Cargo.toml is 0.27.2). Also updates module
count from 59 to 60 to match main.rs (toml_filter + verify_cmd).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-10 10:24:07 +01:00
Charles Vien 7fbc4ef4b5 feat(gt): add Graphite CLI support (#290) 2026-03-06 13:59:39 +01:00
Itai b934466364 feat: add AWS CLI and psql modules with token-optimized output (#216)
AWS CLI (rtk aws):
- Specialized filters for sts, s3 ls, ec2, ecs, rds, cloudformation
- Generic fallback injects --output json for structured ops only
  (describe-*, list-*, get-*); mutating ops (s3 cp, deploy) pass through
- join_with_overflow() and truncate_iso_date() helpers in utils.rs

psql (rtk psql):
- Table format: strips separators/padding, outputs tab-separated
- Expanded format: compresses -[ RECORD N ]- blocks to key=val one-liners
- Passthrough for COPY results, notices, and non-table output
- 40%+ savings (table), 60%+ savings (expanded display)

Co-authored-by: itai.sagi <itai.sagi@clarityo.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 11:12:25 +01:00
heAdz0r 356c0d61a3 refactor(init): add upsert_rtk_block for idempotent CLAUDE.md management (#123)
Replace naive append-or-skip logic in run_claude_md_mode with
upsert_rtk_block() that handles all 4 cases:
- Added: no existing block → append
- Updated: stale block → replace in-place
- Unchanged: current block → no-op
- Malformed: opening marker without closing → warn safely

Includes 4 unit tests covering each case.
2026-02-15 15:15:08 +01:00
polamin 155e26423d fix: prevent UTF-8 panics on multi-byte characters (#93)
* fix: prevent UTF-8 panics on multi-byte characters (Thai, emoji, CJK)

Replace all byte-indexed string slicing (`&s[..n]`) with char-aware
operations across 10 locations in 7 files. Rust strings are UTF-8, so
byte slicing can land mid-character on Thai (3 bytes), emoji (4 bytes),
or CJK text and panic at runtime.

Fixes applied:
- git.rs: filter_log_output, format_status_output
- log_cmd.rs: error/warning message truncation (2 locations)
- env_cmd.rs: long value display, mask_value
- parser/mod.rs: truncate_output
- grep_cmd.rs: clean_line (pattern context + fallback truncation)
- wget_cmd.rs: compact_url, truncate_line, parse_error

Also adds safe_char_boundary() utility and 20 regression tests covering
Thai, emoji, and CJK input across all affected modules.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: collect chars once in compact_url to avoid redundant iteration

Address review feedback: collect chars into Vec once instead of
calling .chars() multiple times. Also fixes byte-vs-char length check.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: remove unused safe_char_boundary function and tests

Address review: function was defined but never called anywhere.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: convert remaining is_char_boundary to full .chars() approach

Address review: use consistent .chars() everywhere instead of
mixing byte-based is_char_boundary with char-based operations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 18:03:32 +01:00
Florian BRUNIAUX 60d2d252ef fix: P0 crashes + cargo check + dedup utilities + discover status
Phase 1: Fix P0 crashes (3 bugs)
- Add external_subcommand fallback for cargo/docker/kubectl
- Fixes crashes on unsupported subcommands (e.g., cargo fmt, docker build)
- All passthroughs now route gracefully instead of Clap parse errors

Phase 2: cargo check handler + refactor (-40 lines)
- Add dedicated cargo check handler (most frequently used missing command)
- Extract run_cargo_filtered() to eliminate 90 lines of duplication
- Fix filter_cargo_build() to handle "Checking" prefix (not just "Compiling")
- Normalize exit code propagation in run_test()

Phase 3: Utility deduplication (-60 lines)
- Fix utils::truncate() Unicode handling (char-aware, not byte-based)
- Remove 5 duplicated utility functions across modules:
  - 3x truncate() → use crate::utils::truncate
  - 1x strip_ansi() → use crate::utils::strip_ansi
- Replace ~60 lines of inline package manager detection with utils::package_manager_exec()
- Clean: lint_cmd, prettier_cmd, playwright_cmd now use shared utils

Phase 4: Discover reporting improvements
- Add RtkStatus enum (Existing/Passthrough/NotSupported)
- Show status column in discover report to distinguish handler types
- Prevents future misleading "build 9 git subcommands" false analyses

Cleanup:
- Remove 2 unused imports (parser::ParseError, std::collections::HashMap)
- Reduce clippy warnings from 23 to 19

Testing:
- 220 tests pass
- 88 smoke tests pass
- All manual verification complete

Net: +10 lines, -3 P0 bugs, -5 duplications, +1 feature, +1 enum

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-06 10:37:50 +01:00
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