Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ PYTHON ruff_cmd.rs ruff check/format 80%+ ✓
GO go_cmd.rs go test/build/vet 75-90% ✓
golangci_cmd.rs golangci-lint 85% ✓

RUBY rake_cmd.rs rake/rails test 85-90% ✓
rspec_cmd.rs rspec 60%+ ✓
rubocop_cmd.rs rubocop 60%+ ✓

NETWORK wget_cmd.rs wget 85-95% ✓
curl_cmd.rs curl 70% ✓

Expand Down Expand Up @@ -303,6 +307,7 @@ SHARED utils.rs Helpers N/A ✓
- **JS/TS Tooling**: 8 modules (modern frontend/fullstack development)
- **Python Tooling**: 3 modules (ruff, pytest, pip)
- **Go Tooling**: 2 modules (go test/build/vet, golangci-lint)
- **Ruby Tooling**: 3 modules (rake/minitest, rspec, rubocop) + 1 TOML filter (bundle install)

---

Expand Down Expand Up @@ -605,6 +610,86 @@ pub fn run(command: &GoCommand, verbose: u8) -> Result<()> {
- Different output format (JSON API vs text)
- Distinct use case (comprehensive linting vs single-tool diagnostics)

### Ruby Module Architecture

#### Design Rationale

**Added**: 2026-03-15
**Motivation**: Ruby on Rails development support (minitest, RSpec, RuboCop, Bundler)

Ruby modules follow the standalone command pattern (like Python) with a shared `ruby_exec()` utility for auto-detecting `bundle exec`.

```
┌────────────────────────────────────────────────────────────────────────┐
│ Ruby Commands (3 modules + 1 TOML) │
└────────────────────────────────────────────────────────────────────────┘

Module Strategy Output Format Savings
─────────────────────────────────────────────────────────────────────────

rake_cmd.rs STATE MACHINE Text parser 85-90%

Minitest output (rake test / rails test):
# Running:
..F..E..
Finished in 0.123456s
1) Failure: TestSomething#test_that_fails [path:15]

→ State machine: Header → Running → Failures → Summary
→ All pass: "ok rake test: 8 runs, 0 failures"
→ Failures: summary + numbered failure details
→ Handles both standard Minitest and minitest-reporters formats

rspec_cmd.rs JSON/TEXT DUAL • JSON → 60%+ 60%+
• text fallback

rspec --format json: Structured test results
→ Extract failures with file:line, assertion message
→ Fallback to text parsing when JSON unavailable

rubocop_cmd.rs JSON PARSING JSON API 60%+

rubocop --format json:
{"files": [{"path": "x.rb", "offenses": [...]}]}
→ Group by cop name and severity
→ Format: "Layout/LineLength: 12 offenses, Style/HashSyntax: 5"

bundle-install.toml TOML FILTER Text rules 70%

bundle install/update:
→ Strip "Using" lines (cached gems), metadata, blank lines
→ Short-circuit: "ok bundle: complete" on success
```

#### Shared Infrastructure: `ruby_exec()`

```rust
// utils.rs — auto-detect bundle exec
pub fn ruby_exec(tool: &str) -> Vec<String> {
if Path::new("Gemfile").exists() {
vec!["bundle".into(), "exec".into(), tool.into()]
} else {
vec![tool.into()]
}
}
```

Used by: rake_cmd, rspec_cmd, rubocop_cmd. Ensures `bundle exec` is always used in Bundler-managed projects (handles transitive dependencies correctly).

#### Discover/Rewrite Rules

```
rake test → rtk rake test
bundle exec rake → rtk rake test
rails test → rtk rake test
bin/rails test → rtk rake test
bundle exec rspec → rtk rspec
bundle exec rubocop → rtk rubocop
bundle install → rtk bundle install
```

ENV_PREFIX auto-strips `RAILS_ENV`, `WITH_COVERAGE`, `BUNDLE_GEMFILE` and re-prepends to the rewritten command.

### Format Strategy Decision Tree

```
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ All notable changes to rtk (Rust Token Killer) will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Features

* **ruby:** add RSpec test runner filter with JSON parsing and text fallback (60%+ reduction)
* **ruby:** add RuboCop linter filter with JSON parsing, grouped by cop/severity (60%+ reduction)
* **ruby:** add minitest filter for `rake test` / `rails test` with state machine parser (85-90% reduction)
* **ruby:** add TOML filter for `bundle install/update` — strip "Using" lines (70% reduction)
* **ruby:** add `ruby_exec()` shared utility for auto-detecting `bundle exec` when Gemfile exists
* **ruby:** add discover/rewrite rules for rake, rails, rspec, rubocop, and bundle commands
>>>>>>> d78401b (docs(ruby): update CLAUDE.md module table and fork features)

## [0.30.1](https://github.com/rtk-ai/rtk/compare/v0.30.0...v0.30.1) (2026-03-18)


Expand Down
14 changes: 13 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,11 @@ rtk gain --history | grep proxy
| pip_cmd.rs | pip/uv package manager | JSON parsing, auto-detect uv (70-85% reduction) |
| go_cmd.rs | Go commands | NDJSON for test, text for build/vet (80-90% reduction) |
| golangci_cmd.rs | golangci-lint | JSON parsing, group by rule (85% reduction) |
| rake_cmd.rs | Minitest via rake/rails test | Failures only, summary line (85-90% reduction) |
| rspec_cmd.rs | RSpec test runner | JSON parsing, failures only (60%+ JSON, 30%+ text fallback) |
| rubocop_cmd.rs | RuboCop linter | JSON parsing, group by cop name (60%+ reduction) |
| tee.rs | Full output recovery | Save raw output to file on failure, print hint for LLM re-read |
| utils.rs | Shared utilities | Package manager detection, common formatting |
| utils.rs | Shared utilities | Package manager detection, ruby_exec, common formatting |
| discover/ | Claude Code history analysis | Scan JSONL sessions, classify commands, report missed savings |

## Performance Constraints
Expand Down Expand Up @@ -392,6 +395,15 @@ pub fn execute_with_filter(cmd: &str, args: &[&str]) -> Result<()> {
- **Architecture**: Standalone Python commands (mirror lint/prettier), Go sub-enum (mirror git/cargo)
- **Patterns**: JSON for structured output (ruff check, golangci-lint, pip), NDJSON streaming (go test), text state machine (pytest), text filters (go build/vet, ruff format)

### Ruby on Rails Support (2026-03-15)
- **Ruby Commands**: 3 modules for Ruby/Rails development
- `rtk rake test`: Minitest filter via rake/rails test, state machine parser (85-90% reduction)
- `rtk rspec`: RSpec test runner with JSON parsing, text fallback (60%+ reduction)
- `rtk rubocop`: RuboCop linter with JSON parsing, group by cop/severity (60%+ reduction)
- **TOML Filter**: `bundle-install.toml` for bundle install/update (strips Using lines, 70% reduction)
- **Shared Infrastructure**: `ruby_exec()` in utils.rs auto-detects `bundle exec` when Gemfile exists
- **Hook Integration**: Rewrites `rake test`, `rails test`, `bundle exec` variants, `bin/rails test`

## Testing Strategy

### TDD Workflow (mandatory)
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ rtk filters and compresses command outputs before they reach your LLM context. S
| `ruff check` | 3x | 3,000 | 600 | -80% |
| `pytest` | 4x | 8,000 | 800 | -90% |
| `go test` | 3x | 6,000 | 600 | -90% |
| `rake test` | 4x | 6,000 | 600 | -90% |
| `rspec` | 3x | 4,500 | 1,800 | -60% |
| `rubocop` | 3x | 3,000 | 1,200 | -60% |
| `docker ps` | 3x | 900 | 180 | -80% |
| **Total** | | **~118,000** | **~23,900** | **-80%** |
| **Total** | | **~131,500** | **~27,500** | **-79%** |

> Estimates based on medium-sized TypeScript/Rust projects. Actual savings vary by project size.

Expand Down Expand Up @@ -171,6 +174,8 @@ rtk playwright test # E2E results (failures only)
rtk pytest # Python tests (-90%)
rtk go test # Go tests (NDJSON, -90%)
rtk cargo test # Cargo tests (-90%)
rtk rake test # Ruby minitest (-90%)
rtk rspec # RSpec tests (JSON, -60%+)
```

### Build & Lint
Expand All @@ -184,13 +189,15 @@ rtk cargo build # Cargo build (-80%)
rtk cargo clippy # Cargo clippy (-80%)
rtk ruff check # Python linting (JSON, -80%)
rtk golangci-lint run # Go linting (JSON, -85%)
rtk rubocop # Ruby linting (JSON, -60%+)
```

### Package Managers
```bash
rtk pnpm list # Compact dependency tree
rtk pip list # Python packages (auto-detect uv)
rtk pip outdated # Outdated packages
rtk bundle install # Ruby gems (strip Using lines)
rtk prisma generate # Schema generation (no ASCII art)
```

Expand Down Expand Up @@ -351,6 +358,10 @@ cp hooks/opencode-rtk.ts ~/.config/opencode/plugins/rtk.ts
| `pip list/install` | `rtk pip ...` |
| `go test/build/vet` | `rtk go ...` |
| `golangci-lint` | `rtk golangci-lint` |
| `rake test` / `rails test` | `rtk rake test` |
| `bundle exec rspec` | `rtk rspec` |
| `bundle exec rubocop` | `rtk rubocop` |
| `bundle install/update` | `rtk bundle ...` |
| `docker ps/images/logs` | `rtk docker ...` |
| `kubectl get/logs` | `rtk kubectl ...` |
| `curl` | `rtk curl` |
Expand Down
Loading