rails-ai-context 4.2.3 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5a6ff4a0b32e6be5d9109b7c603f3b7ae097cf97439f8b7a219ee374a62469d
4
- data.tar.gz: f80ea797a13825703b45ced9c9f2b94544f1c00774f00cec683194a19af8d3b9
3
+ metadata.gz: 7cd3960b55660ccf3b1c8da3c6af0aeef18ba57a9a906f02cd136b976bf66976
4
+ data.tar.gz: '0185228442a21266ba75f01375d8883dc176b6b140b764e59aafa8044fa7faed'
5
5
  SHA512:
6
- metadata.gz: 370160ebbbcd9bca03eb55171474b017c23235a7211f46ba5df52e64a33fdf3fa470acd38952a422ec7ccca770377d8415e8f0011a101622a15b3db1e5a98ee4
7
- data.tar.gz: 07df46d61e556d7290ad8768d3ecb6fc7ef3d9498c6fe646791d12c05794bfec258f15085571ae3c09aa8b10ff517b7aa5b372964f5708ad2190675c21bacfc4
6
+ metadata.gz: 117c13423c12bd5e4a204290716639c5f30fcd960290c5cd3535c5b37911567f7678341bb15f5dcff88e75f6c321a740fe8c4d7adb0a5d5a5936aa2c8b679bc0
7
+ data.tar.gz: 101b71249f3e49a40ec0bd8417a71bd76ea7b1907b36d94abf4182ead812fd76f33e9b353c9b14f1e78de680f6a1eeebf0659097cc3ec7afe4f06e7b48bf2017
data/CHANGELOG.md CHANGED
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [4.3.0] — 2026-04-01
9
+
10
+ ### Added
11
+ - **`rails_onboard`** — narrative app walkthrough (quick/standard/full) for new developers and AI agents: stack, data model, authentication, key flows, jobs, frontend, testing, getting started
12
+ - **`rails_generate_test`** — generates test scaffolding matching project patterns: detects framework (RSpec/Minitest), factories vs fixtures, assertion style, Devise helpers; covers validations, associations, scopes, enums, request specs with routes
13
+ - **`rails_diagnose`** — one-call error diagnosis: parses error → classifies (nil_reference, record_not_found, validation_failure, routing, strong_params, schema_mismatch) → gathers controller/model/schema context → shows recent git changes → pulls error logs → suggests fix
14
+ - **`rails_review_changes`** — PR/commit review context: classifies changed files, pulls per-file context (model → schema, controller → routes, migration → affected models), detects warnings (missing indexes, removed validations, no test changes)
15
+ - **Improved AI instructions** — workflow sequencing (step-by-step tool call order), `detail` parameter guidance, anti-patterns section, `get_context` promoted as power tool, app-specific footer rules from conventions introspector
16
+ - **Compact tool name list** — root files (CLAUDE.md, AGENTS.md) now include all 37 tool names in a dense format that fits within the 150-line compact mode limit
17
+
18
+ ### Changed
19
+ - Tool count: 33 → 37
20
+ - Test count: 1016 → 1052
21
+ - Root file render order: commands and rules before tool guide to prevent truncation
22
+ - Cursor rules description: fixed stale "25 tools" → "37 tools"
23
+
8
24
  ## [4.2.3] — 2026-04-01
9
25
 
10
26
  ### Fixed
data/CLAUDE.md CHANGED
@@ -9,7 +9,7 @@ structure to AI assistants via the Model Context Protocol (MCP).
9
9
  - `lib/rails_ai_context/configuration.rb` — User-facing config with presets (:standard, :full)
10
10
  - `lib/rails_ai_context/introspector.rb` — Orchestrates sub-introspectors
11
11
  - `lib/rails_ai_context/introspectors/` — 33 introspectors (schema, models, routes, jobs, gems, conventions, stimulus, database_stats, controllers, views, view_templates, design_tokens, turbo, i18n, config, active_storage, action_text, auth, api, tests, rake_tasks, assets, devops, action_mailbox, migrations, seeds, middleware, engines, multi_database, components, accessibility, performance, frontend_frameworks)
12
- - `lib/rails_ai_context/tools/` — 33 MCP tools using the official mcp SDK
12
+ - `lib/rails_ai_context/tools/` — 37 MCP tools using the official mcp SDK
13
13
  - `lib/rails_ai_context/cli/` — CLI tool runner (`tool_runner.rb`) — executes MCP tools from rake/Thor
14
14
  - `lib/rails_ai_context/serializers/` — Output formatters (claude, claude_rules, opencode, opencode_rules, cursor_rules, copilot, copilot_instructions, rules, markdown, JSON, context_file_serializer, test_command_detection, tool_guide_helper, design_system_helper, stack_overview_helper)
15
15
  - `lib/rails_ai_context/resources.rb` — MCP resources (static data AI clients read directly)
@@ -40,12 +40,12 @@ structure to AI assistants via the Model Context Protocol (MCP).
40
40
  13. **Per-tool split rules** — `.claude/rules/`, `.cursor/rules/`, `.github/instructions/`
41
41
  14. **Section markers** — root file content wrapped in `<!-- BEGIN/END rails-ai-context -->` to preserve user content
42
42
  15. **generate_root_files toggle** — when false, skip root files (CLAUDE.md, etc.), only generate split rules
43
- 16. **custom_tools API** — `config.custom_tools` array lets users register additional MCP::Tool subclasses alongside the 33 built-in tools
43
+ 16. **custom_tools API** — `config.custom_tools` array lets users register additional MCP::Tool subclasses alongside the 37 built-in tools
44
44
  17. **Design system extraction** — view templates analyzed for canonical examples, color palette, typography, responsive patterns, interactive states, dark mode
45
45
  18. **skip_tools API** — `config.skip_tools` array lets users exclude specific built-in tools (e.g. `%w[rails_security_scan]`)
46
46
  19. **Security scanning** — optional Brakeman integration via `rails_security_scan` tool (graceful degradation if not installed)
47
47
  20. **tool_mode config** — `:mcp` (default, MCP primary + CLI fallback) or `:cli` (CLI only, no MCP server needed). Selected during install.
48
- 21. **CLI tool access** — all 33 MCP tools callable from terminal: `rails ai:tool[schema]`, `rails-ai-context tool schema`. Tool name resolution: `schema` → `get_schema` → `rails_get_schema`.
48
+ 21. **CLI tool access** — all 37 MCP tools callable from terminal: `rails ai:tool[schema]`, `rails-ai-context tool schema`. Tool name resolution: `schema` → `get_schema` → `rails_get_schema`.
49
49
  22. **Shared ToolGuideHelper** — serializers use a shared module for tool reference sections, rendering MCP or CLI syntax based on `tool_mode`
50
50
  23. **Component catalog** — ViewComponent/Phlex introspection: props, slots, previews, sidecar assets, usage examples via `rails_get_component_catalog`
51
51
  24. **Accessibility scanning** — ARIA attributes, semantic HTML, screen reader text, alt text, landmark roles, accessibility score via AccessibilityIntrospector
@@ -60,7 +60,7 @@ structure to AI assistants via the Model Context Protocol (MCP).
60
60
  ## Testing
61
61
 
62
62
  ```bash
63
- bundle exec rspec # Run specs (1016 examples)
63
+ bundle exec rspec # Run specs (1052 examples)
64
64
  bundle exec rubocop # Lint
65
65
  ```
66
66
 
data/CONTRIBUTING.md CHANGED
@@ -20,7 +20,7 @@ The test suite uses [Combustion](https://github.com/pat/combustion) to boot a mi
20
20
  lib/rails_ai_context/
21
21
  ├── cli/ # CLI tool runner (tool_runner.rb) — executes MCP tools from rake/Thor
22
22
  ├── introspectors/ # 33 introspectors (schema, models, routes, etc.)
23
- ├── tools/ # 33 MCP tools with detail levels and pagination
23
+ ├── tools/ # 37 MCP tools with detail levels and pagination
24
24
  ├── serializers/ # Per-assistant formatters + shared ToolGuideHelper
25
25
  ├── server.rb # MCP server setup (stdio + HTTP)
26
26
  ├── live_reload.rb # MCP live reload (file watcher + cache invalidation)
data/README.md CHANGED
@@ -8,19 +8,19 @@
8
8
  [![MCP Registry](https://img.shields.io/badge/MCP_Registry-listed-green)](https://registry.modelcontextprotocol.io)
9
9
  [![Ruby](https://img.shields.io/badge/Ruby-3.2%20%7C%203.3%20%7C%203.4-red)](https://github.com/crisnahine/rails-ai-context)
10
10
  [![Rails](https://img.shields.io/badge/Rails-7.1%20%7C%207.2%20%7C%208.0-red)](https://github.com/crisnahine/rails-ai-context)
11
- [![Tests](https://img.shields.io/badge/Tests-1016%20passing-brightgreen)](https://github.com/crisnahine/rails-ai-context/actions)
11
+ [![Tests](https://img.shields.io/badge/Tests-1052%20passing-brightgreen)](https://github.com/crisnahine/rails-ai-context/actions)
12
12
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
13
13
 
14
14
  **Works with:** Claude Code &bull; Cursor &bull; GitHub Copilot &bull; OpenCode &bull; Any terminal
15
15
 
16
- > Built by a Rails developer with 10+ years of production experience. AI assisted — the same way it assists me shipping features at work. I designed the architecture, made every decision, reviewed every line, and wrote 1016 tests. This gem exists because I understand Rails deeply enough to know exactly what AI agents get wrong and what context they need to get it right.
16
+ > Built by a Rails developer with 10+ years of production experience. AI assisted — the same way it assists me shipping features at work. I designed the architecture, made every decision, reviewed every line, and wrote 1052 tests. This gem exists because I understand Rails deeply enough to know exactly what AI agents get wrong and what context they need to get it right.
17
17
 
18
18
  ```bash
19
19
  gem "rails-ai-context", group: :development
20
20
  rails generate rails_ai_context:install
21
21
  ```
22
22
 
23
- That's it. Your AI now has 33 tools that understand your entire Rails app — via MCP server or CLI. Zero config.
23
+ That's it. Your AI now has 37 tools that understand your entire Rails app — via MCP server or CLI. Zero config.
24
24
 
25
25
  > **[Full Guide →](docs/GUIDE.md)** — every command, every parameter, every configuration option.
26
26
 
@@ -50,7 +50,7 @@ rails 'ai:tool[schema]' table=users
50
50
  rails 'ai:tool[analyze_feature]' feature=billing
51
51
  ```
52
52
 
53
- Same 33 tools. Same output. AI agents run these as shell commands. **Works in any terminal, any AI tool, any workflow.** No MCP client required.
53
+ Same 37 tools. Same output. AI agents run these as shell commands. **Works in any terminal, any AI tool, any workflow.** No MCP client required.
54
54
 
55
55
  ---
56
56
 
@@ -174,7 +174,7 @@ Tested on a real Rails 8 app (5 models, 19 controllers, 95 routes):
174
174
 
175
175
  ---
176
176
 
177
- ## 33 Tools
177
+ ## 37 Tools
178
178
 
179
179
  Every tool is **read-only** and returns structured, token-efficient data.
180
180
 
@@ -246,7 +246,7 @@ Every tool is **read-only** and returns structured, token-efficient data.
246
246
  ▼ ▼ ▼
247
247
  ┌──────────────────┐ ┌────────────┐ ┌────────────────────┐
248
248
  │ Static Files │ │ MCP Server │ │ CLI Tools │
249
- │ CLAUDE.md │ │ 33 tools │ │ Same 33 tools │
249
+ │ CLAUDE.md │ │ 37 tools │ │ Same 37 tools │
250
250
  │ .cursor/rules/ │ │ stdio/HTTP │ │ No server needed │
251
251
  │ .github/instr... │ │ .mcp.json │ │ rails 'ai:tool[X]' │
252
252
  └──────────────────┘ └────────────┘ └────────────────────┘
@@ -282,7 +282,7 @@ MCP auto-discovery: `.mcp.json` is detected automatically by Claude Code and Cur
282
282
  | Command | What it does |
283
283
  |---------|-------------|
284
284
  | `rails ai:context` | Generate context files for your AI tools |
285
- | `rails 'ai:tool[NAME]'` | Run any of the 33 tools from the CLI |
285
+ | `rails 'ai:tool[NAME]'` | Run any of the 37 tools from the CLI |
286
286
  | `rails ai:tool` | List all available tools with short names |
287
287
  | `rails ai:serve` | Start MCP server (stdio) |
288
288
  | `rails ai:doctor` | Diagnostics + AI readiness score |
data/SECURITY.md CHANGED
@@ -26,7 +26,7 @@ If you discover a security vulnerability in rails-ai-context, please report it r
26
26
 
27
27
  ## Security Design
28
28
 
29
- - All 33 MCP tools are **read-only** and never modify your application or database.
29
+ - All 37 MCP tools are **read-only** and never modify your application or database.
30
30
  - **Sensitive file blocking** — configurable `sensitive_patterns` blocks access to `.env`, `*.key`, `*.pem`, `credentials.yml.enc` across all search and read tools. Patterns are checked in `rails_search_code`, `rails_get_edit_context`, and all new tools.
31
31
  - **Path traversal protection** — all file-reading tools validate paths with `File.realpath()` against `Rails.root` to prevent directory escape.
32
32
  - **Command injection prevention** — code search uses `Open3.capture2` with array arguments (never shell strings). The `--` flag separator prevents pattern injection.
data/docs/GUIDE.md CHANGED
@@ -252,7 +252,7 @@ rails ai:context:claude # Use this instead (no quoting needed)
252
252
 
253
253
  ## CLI Tools
254
254
 
255
- All 33 MCP tools can be run directly from the terminal — no MCP server or AI client needed.
255
+ All 37 MCP tools can be run directly from the terminal — no MCP server or AI client needed.
256
256
 
257
257
  ### Rake
258
258
 
@@ -316,7 +316,7 @@ The `tool_mode` is selected during `rails generate rails_ai_context:install`.
316
316
 
317
317
  ## MCP Tools — Full Reference
318
318
 
319
- All 33 tools are **read-only** and **idempotent** — they never modify your application or database.
319
+ All 37 tools are **read-only** and **idempotent** — they never modify your application or database.
320
320
 
321
321
  ### rails_get_schema
322
322
 
@@ -1117,7 +1117,7 @@ RailsAiContext.configure do |config|
1117
1117
  end
1118
1118
  ```
1119
1119
 
1120
- Both transports are **read-only** — they expose the same 33 tools and never modify your app.
1120
+ Both transports are **read-only** — they expose the same 37 tools and never modify your app.
1121
1121
 
1122
1122
  ---
1123
1123
 
@@ -436,9 +436,9 @@ module RailsAiContext
436
436
  say ""
437
437
  say "Commands:", :yellow
438
438
  say " rails ai:context # Regenerate context files"
439
- say " rails 'ai:tool[schema]' # Run any of the 33 tools from CLI"
439
+ say " rails 'ai:tool[schema]' # Run any of the 37 tools from CLI"
440
440
  if @tool_mode == :mcp
441
- say " rails ai:serve # Start MCP server (33 live tools)"
441
+ say " rails ai:serve # Start MCP server (37 live tools)"
442
442
  end
443
443
  say " rails ai:doctor # Check AI readiness"
444
444
  say " rails ai:inspect # Print introspection summary"
@@ -35,10 +35,10 @@ module RailsAiContext
35
35
  lines.concat(render_notable_gems)
36
36
  lines.concat(render_architecture)
37
37
  lines.concat(render_ui_patterns)
38
- lines.concat(render_mcp_guide)
39
- lines.concat(render_conventions)
40
38
  lines.concat(render_commands)
41
39
  lines.concat(render_footer)
40
+ lines.concat(render_conventions)
41
+ lines.concat(render_mcp_guide_compact)
42
42
 
43
43
  # Enforce max lines
44
44
  max = RailsAiContext.configuration.claude_max_lines
@@ -202,6 +202,10 @@ module RailsAiContext
202
202
  render_tools_guide
203
203
  end
204
204
 
205
+ def render_mcp_guide_compact
206
+ render_tools_guide_compact
207
+ end
208
+
205
209
  def render_conventions
206
210
  conv = context[:conventions]
207
211
  return [] unless conv.is_a?(Hash) && !conv[:error]
@@ -227,15 +231,30 @@ module RailsAiContext
227
231
  end
228
232
 
229
233
  def render_footer
230
- [
231
- "## Rules",
232
- "- Follow existing patterns and conventions",
233
- "- Match existing code style",
234
- "- Run tests after changes",
235
- "- Do NOT re-read files to verify edits — trust your Edit, validate syntax only",
236
- "- Stimulus controllers auto-register — no manual import in controllers/index.js needed",
237
- ""
238
- ]
234
+ test_cmd = detect_test_command
235
+ lines = [ "## Rules" ]
236
+ lines << "- Run `#{test_cmd}` after changes"
237
+ lines << "- Do NOT re-read files to verify edits — trust your Edit, validate syntax only"
238
+
239
+ # App-specific conventions from introspection
240
+ conv = context[:conventions]
241
+ if conv.is_a?(Hash) && !conv[:error]
242
+ arch = conv[:architecture] || []
243
+ lines << "- Follow #{arch.join(' + ')} architecture" if arch.any?
244
+ patterns = conv[:patterns] || []
245
+ lines << "- Use service objects for business logic" if patterns.include?("service_objects")
246
+ lines << "- Use form objects for complex forms" if patterns.include?("form_objects")
247
+ lines << "- Use query objects for complex queries" if patterns.include?("query_objects")
248
+ end
249
+
250
+ # Stimulus auto-register if detected
251
+ stimulus = context[:stimulus]
252
+ if stimulus.is_a?(Hash) && !stimulus[:error] && (stimulus[:controllers]&.any? || stimulus[:total_controllers]&.positive?)
253
+ lines << "- Stimulus controllers auto-register — no manual import in controllers/index.js needed"
254
+ end
255
+
256
+ lines << ""
257
+ lines
239
258
  end
240
259
  end
241
260
 
@@ -255,7 +255,7 @@ module RailsAiContext
255
255
  def render_mcp_tools_rule
256
256
  lines = [
257
257
  "---",
258
- "description: \"Rails tools (25) — MANDATORY, use before reading any reference files\"",
258
+ "description: \"Rails tools (37) — MANDATORY, use before reading any reference files\"",
259
259
  "alwaysApply: true",
260
260
  "---",
261
261
  ""
@@ -35,9 +35,9 @@ module RailsAiContext
35
35
  lines.concat(render_notable_gems)
36
36
  lines.concat(render_architecture)
37
37
  lines.concat(render_ui_patterns)
38
- lines.concat(render_mcp_guide)
39
- lines.concat(render_conventions)
40
38
  lines.concat(render_commands)
39
+ lines.concat(render_conventions)
40
+ lines.concat(render_mcp_guide_compact)
41
41
  lines.concat(render_footer)
42
42
 
43
43
  # Enforce max lines
@@ -168,6 +168,10 @@ module RailsAiContext
168
168
  render_tools_guide
169
169
  end
170
170
 
171
+ def render_mcp_guide_compact
172
+ render_tools_guide_compact
173
+ end
174
+
171
175
  def render_conventions
172
176
  conv = context[:conventions]
173
177
  return [] unless conv.is_a?(Hash) && !conv[:error]