feat: add Ruby and Rails CLI support (rspec, rubocop, bundle, rails)#292
Open
navidemad wants to merge 1 commit intortk-ai:masterfrom
Open
feat: add Ruby and Rails CLI support (rspec, rubocop, bundle, rails)#292navidemad wants to merge 1 commit intortk-ai:masterfrom
navidemad wants to merge 1 commit intortk-ai:masterfrom
Conversation
Add 4 new command modules for the Ruby on Rails ecosystem with shared infrastructure, discover registry integration, and hook rewrites. 96+ unit tests, 527 total passing. New commands: - rtk rspec: JSON parsing with text fallback (60%+ / 30%+ savings) - rtk rubocop: JSON parsing, group by cop/severity (60%+ savings) - rtk bundle list/outdated/install/update: text parsing (10-30%) - rtk rails test/routes/db:migrate/status/rollback/generate (40-50%+) Shared infrastructure: - ruby_exec() auto-detects bundle exec when Gemfile declares gem - fallback_tail() last-resort filter with diagnostic logging - count_tokens() shared test helper (deduplicated from 4 modules) - exit_code_from_output() returns 128+signal on Unix Hook rewrites cover rspec, rubocop, bundle, rails, rake, and bin/bundle exec variants via .claude/hooks/rtk-rewrite.sh.
9 tasks
|
Partially duplicate of #198 But great additions ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Summary
Adds comprehensive Ruby and Rails ecosystem support to RTK with 4 new command modules covering the full Rails development workflow, plus shared infrastructure and discover registry integration.
Includes 97 unit tests across the 4 new modules and an E2E smoke test script (
scripts/test-rails.sh) that creates a real Rails app and exercises all commands.🚀 New Commands
rtk rspec--format jsonautomatically. Falls back to text parsing when user specifies a custom format.rtk rubocop--format json, groups offenses by cop name and severity. Skips JSON in autocorrect mode (-a,-A).rtk bundlelist,outdated,install,updatertk railstest,routes,db:migrate,db:migrate:status,db:rollback,generatetest, route grouping forroutes, migration summaries fordb:*.🛠 Key Design Decisions (Click to expand)
--format jsonunless user specified-f/--format. Detects autocorrect mode (-a,-A) in rubocop to skip JSON.fallback_tail(). Logs serde error on final fallback for debugging.fallback_tail()instead of feeding JSON through the text parser.saturating_subthroughout,extract_countreturnsOption<usize>to distinguish0from parse error.exit_code_from_outputreturns128 + signalon Unix per convention, ANSI stripping at filter entry points.🏗 Shared Infrastructure & Registry (Click to expand)
Shared Infrastructure (
utils.rs)ruby_exec()— Auto-detectsbundle execwhen Gemfile declares the tool gem.gemfile_mentions_gem()avoids false positives (e.g.,guardrails≠rails).fallback_tail()— Last-resort filter fallback showing final N lines with diagnostic logging.count_tokens()— Shared test helper for token savings assertions (deduplicated from 4 modules).exit_code_from_output()— Signal-aware exit code extraction: returns128 + signalon Unix per convention.Discover Registry
(?:bundle\s+exec\s+)?so the subcommand lands in capture group 1.db:migrate:statusordered beforedb:migrateto avoid prefix match.test: 50%routes: 50%db:migrate:status: 40%db:migrate/db:rollback: 40%generate/g: 20%🪝 Hook Integration
The
.claude/hooks/rtk-rewrite.shfile now correctly rewrites the following commands:rtk rspecrspec,bundle exec rspec,bin/rspecrtk rubocoprubocop,bundle exec rubocoprtk bundle …bundle list|outdated|install|updatertk rails …rails test|routes|db:migrate|…rtk rails …rake routes|db:migrate|db:rollback|…rtk rails …bin/rails …,bundle exec rails …🧪 How to Test
Tip
Running the E2E smoke tests requires Ruby, Bundler, and the Rails gem to be installed locally.