rails-ai-context 3.1.0 → 4.1.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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +82 -0
  3. data/CLAUDE.md +12 -6
  4. data/CONTRIBUTING.md +2 -2
  5. data/README.md +17 -10
  6. data/SECURITY.md +6 -3
  7. data/docs/GUIDE.md +20 -16
  8. data/lib/generators/rails_ai_context/install/install_generator.rb +212 -34
  9. data/lib/rails_ai_context/cli/tool_runner.rb +1 -0
  10. data/lib/rails_ai_context/configuration.rb +9 -2
  11. data/lib/rails_ai_context/introspector.rb +4 -0
  12. data/lib/rails_ai_context/introspectors/accessibility_introspector.rb +188 -0
  13. data/lib/rails_ai_context/introspectors/api_introspector.rb +47 -1
  14. data/lib/rails_ai_context/introspectors/auth_introspector.rb +88 -1
  15. data/lib/rails_ai_context/introspectors/component_introspector.rb +195 -0
  16. data/lib/rails_ai_context/introspectors/controller_introspector.rb +57 -2
  17. data/lib/rails_ai_context/introspectors/convention_detector.rb +27 -3
  18. data/lib/rails_ai_context/introspectors/design_token_introspector.rb +70 -1
  19. data/lib/rails_ai_context/introspectors/frontend_framework_introspector.rb +426 -0
  20. data/lib/rails_ai_context/introspectors/gem_introspector.rb +32 -0
  21. data/lib/rails_ai_context/introspectors/job_introspector.rb +43 -1
  22. data/lib/rails_ai_context/introspectors/model_introspector.rb +57 -0
  23. data/lib/rails_ai_context/introspectors/performance_introspector.rb +293 -0
  24. data/lib/rails_ai_context/introspectors/schema_introspector.rb +89 -1
  25. data/lib/rails_ai_context/introspectors/stimulus_introspector.rb +62 -3
  26. data/lib/rails_ai_context/introspectors/test_introspector.rb +37 -1
  27. data/lib/rails_ai_context/introspectors/turbo_introspector.rb +177 -1
  28. data/lib/rails_ai_context/introspectors/view_introspector.rb +62 -1
  29. data/lib/rails_ai_context/introspectors/view_template_introspector.rb +39 -1
  30. data/lib/rails_ai_context/serializers/claude_rules_serializer.rb +63 -1
  31. data/lib/rails_ai_context/serializers/stack_overview_helper.rb +29 -0
  32. data/lib/rails_ai_context/serializers/tool_guide_helper.rb +25 -6
  33. data/lib/rails_ai_context/server.rb +6 -1
  34. data/lib/rails_ai_context/tasks/rails_ai_context.rake +33 -0
  35. data/lib/rails_ai_context/tools/analyze_feature.rb +53 -7
  36. data/lib/rails_ai_context/tools/dependency_graph.rb +201 -0
  37. data/lib/rails_ai_context/tools/get_component_catalog.rb +175 -0
  38. data/lib/rails_ai_context/tools/get_context.rb +18 -6
  39. data/lib/rails_ai_context/tools/get_controllers.rb +18 -0
  40. data/lib/rails_ai_context/tools/get_conventions.rb +19 -0
  41. data/lib/rails_ai_context/tools/get_design_system.rb +32 -0
  42. data/lib/rails_ai_context/tools/get_edit_context.rb +10 -1
  43. data/lib/rails_ai_context/tools/get_frontend_stack.rb +160 -0
  44. data/lib/rails_ai_context/tools/get_model_details.rb +27 -0
  45. data/lib/rails_ai_context/tools/get_schema.rb +26 -0
  46. data/lib/rails_ai_context/tools/get_stimulus.rb +43 -2
  47. data/lib/rails_ai_context/tools/get_test_info.rb +28 -0
  48. data/lib/rails_ai_context/tools/get_turbo_map.rb +81 -14
  49. data/lib/rails_ai_context/tools/get_view.rb +14 -1
  50. data/lib/rails_ai_context/tools/migration_advisor.rb +394 -0
  51. data/lib/rails_ai_context/tools/performance_check.rb +137 -0
  52. data/lib/rails_ai_context/tools/search_code.rb +6 -0
  53. data/lib/rails_ai_context/tools/security_scan.rb +23 -2
  54. data/lib/rails_ai_context/tools/validate.rb +35 -0
  55. data/lib/rails_ai_context/version.rb +1 -1
  56. metadata +13 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6bdb0dcbde3c7abfab69bee14e661afc8a260fe3d00faa99ecc4becbc58a19b
4
- data.tar.gz: deacfa10c6c188d0482fc82199f085b4f13cbf24b0cf06e0977074ecf67864d8
3
+ metadata.gz: af24e6340b8328b0526c9f030d60b495f4cb1e7130b7f16cadd039e2b9912aab
4
+ data.tar.gz: e74d337f614f853fec1bacaff748bea4b212ed96034c22b5fd3d75326da6fc13
5
5
  SHA512:
6
- metadata.gz: bf049844c52cd8b88371a352907b08c9863668424ae37f9393d72c7210501c21fcc2ea3df797e59184b603b98e723f0bd07ebb4e36503852344c27d96970a308
7
- data.tar.gz: ab5cf1f7f4031d605db8f076da5544ede9c1aa48d426dc57482a45551d46741c687caaaf0e8722932d8d982c6a9af5c86f425e117a80bcb88b36d2d1d761040f
6
+ metadata.gz: 9e8d9261310e038cce1cc20ba21d81d203eec2d813dcf318aa3f2071da646a67dc11fd812671a0d982d6d0d234ed84c2079144be3b62863b311e09d0b12181f9
7
+ data.tar.gz: 3f6001ba2d788b76e4a6e7b576a9447e7eed91df1a0b689dba679a3c6fbd876db1278e7ebd70637b35bedb01e2e77b1546cf3b96d8c5d37536f1f053fd35f9d3
data/CHANGELOG.md CHANGED
@@ -5,6 +5,88 @@ 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.1.0] — 2026-03-29
9
+
10
+ ### Added
11
+ - New `rails_get_frontend_stack` tool: detects React/Vue/Svelte/Angular, Inertia/react-rails mounting, state management, TypeScript config, monorepo layout, package manager
12
+ - New `FrontendFrameworkIntrospector`: parses package.json (JSON.parse with BOM-safe reading), config/vite.json, config/shakapacker.yml, tsconfig.json
13
+ - Frontend framework detection covers patterns 3 (hybrid SPA), 4 (API+SPA), and 7 (Turbo Native)
14
+ - API introspector: OpenAPI/Swagger spec detection, CORS config parsing, API codegen tool detection (openapi-typescript, graphql-codegen, orval)
15
+ - Auth introspector: JWT strategy (devise-jwt, Doorkeeper config), HTTP token auth detection
16
+ - Turbo introspector: Turbo Native detection (turbo_native_app?, native navigation patterns, native conditionals in views)
17
+ - Gem introspector: 6 new notable gems (devise-jwt, rswag-api, rswag-ui, grape-swagger, apipie-rails, hotwire-native-rails)
18
+ - Optional config: `frontend_paths`, `mobile_paths` (auto-detected if nil, user override for edge cases)
19
+ - Install generator: re-install now updates `ai_tools` and `tool_mode` selections, adds missing config sections without removing existing settings
20
+ - Install generator: prompts to remove generated files when AI tools are deselected (per-tool chooser)
21
+ - `rails ai:context:cursor` (and other format tasks) now auto-adds the format to `config.ai_tools`
22
+ - CLI tool_runner: warns on invalid enum values instead of silent fallback
23
+
24
+ ### Fixed
25
+ - `analyze_feature` crash on nil/empty input — now returns helpful prompt
26
+ - `analyze_feature` with nonexistent feature — returns clean "no match" instead of scaffolded empty sections
27
+ - `migration_advisor` crash on empty/invalid action — now validates with "Did you mean?" suggestions
28
+ - `migration_advisor` generates broken SQL with empty table/column — now validates required params
29
+ - `migration_advisor` doesn't normalize table names — "Cook" now auto-resolves to "cooks"
30
+ - `migration_advisor` no duplicate column/index detection — now warns on existing columns, indexes, and FKs
31
+ - `migration_advisor` no nonexistent column detection — now warns on remove/rename/change_type/add_index for missing columns
32
+ - `edit_context` "File not found" with no hint — now suggests full path with "Did you mean?"
33
+ - `performance_check` model filter fails for multi-word models — "BrandProfile" now resolves to "brand_profiles"
34
+ - `performance_check` unknown model silently ignored — now returns "not found" with suggestions
35
+ - `turbo_map` stream filter misses dynamic broadcasts — multi-line call handling + snippet fallback + fuzzy prefix matching
36
+ - `turbo_map` controller filter misses job broadcasts — now includes broadcasts matching filtered subscriptions' streams
37
+ - `security_scan` wrong check name examples — added CHECK_ALIASES mapping (CheckXSS → CheckCrossSiteScripting, sql → CheckSQL, etc.)
38
+ - `search_code` unknown match_type silently ignored — now returns error with valid values
39
+ - `validate` unknown level silently ignored — now returns error with valid values
40
+ - `get_view` no "Did you mean?" on wrong controller — now uses `find_closest_match`
41
+ - `get_context` plural model name ("Cooks") produces mixed output — now normalizes via singularize/classify, fails fast when not found
42
+ - `component_catalog` specific component returns generic "no components" — now acknowledges the input
43
+ - `stimulus` doesn't strip `_controller` suffix — now auto-strips for lookup
44
+ - `controller_introspector_spec` rate_limit test crashes on Rails 7.1 — split into source-parsing test (no class loading)
45
+
46
+ ### Changed
47
+ - Full preset: 31 → 32 introspectors (added :frontend_frameworks)
48
+ - Tool count: 29 → 30
49
+ - Test count: 817 → 893
50
+ - Install generator always writes `config.ai_tools` and `config.tool_mode` uncommented for re-install detection
51
+
52
+ ## [4.0.0] — 2026-03-26
53
+
54
+ ### Added
55
+
56
+ - 4 new MCP tools: `rails_get_component_catalog`, `rails_performance_check`, `rails_dependency_graph`, `rails_migration_advisor`
57
+ - 3 new introspectors: ComponentIntrospector (ViewComponent/Phlex), AccessibilityIntrospector (ARIA/a11y), PerformanceIntrospector (N+1/indexes)
58
+ - ViewComponent/Phlex component catalog: props, slots, previews, sidecar assets, usage examples
59
+ - Accessibility scanning: ARIA attributes, semantic HTML, screen reader text, alt text, landmark roles, accessibility score
60
+ - Performance analysis: N+1 query risks, missing counter_cache, missing FK indexes, Model.all anti-patterns, eager load candidates
61
+ - Dependency graph generation in Mermaid or text format
62
+ - Migration code generation with reversibility warnings and affected model detection
63
+ - Component and accessibility split rules for Claude, Cursor, Copilot, and OpenCode
64
+ - Stimulus cross-controller composition detection
65
+ - Stimulus import graph and complexity metrics
66
+ - Turbo 8 morph meta and permanent element detection
67
+ - Turbo Drive configuration scanning (data-turbo-*, preload)
68
+ - Form builder detection (form_with, simple_form, formtastic)
69
+ - Semantic HTML element counting
70
+ - DaisyUI theme and component detection
71
+ - Font loading strategy detection (@font-face, Google Fonts, system fonts)
72
+ - CSS @layer and PostCSS plugin detection
73
+ - Convention fingerprint with SolidQueue/SolidCache/SolidCable awareness
74
+ - Dynamic directory detection in app/
75
+ - Controller rate_limit and rescue_from extraction
76
+ - Model encryption, normalizes, and generates_token_for details
77
+ - Schema check constraints, enum types, and generated columns
78
+ - Factory trait extraction and test count by category
79
+ - Expanded NOTABLE_GEMS list (30+ new gems including dry-rb, Solid stack)
80
+ - Job retry_on/discard_on and perform argument extraction
81
+
82
+ ### Changed
83
+
84
+ - Standard preset: 13 → 14 introspectors (added :components)
85
+ - Full preset: 28 → 31 introspectors (added :components, :accessibility, :performance)
86
+ - Tool count: 25 → 29
87
+ - Test count: 681 → 806 examples
88
+ - Combustion test app expanded with Stimulus controllers, ViewComponents, accessible views, factories
89
+
8
90
  ## [3.1.0] - 2026-03-26
9
91
 
10
92
  ### Fixed
data/CLAUDE.md CHANGED
@@ -8,8 +8,8 @@ structure to AI assistants via the Model Context Protocol (MCP).
8
8
  - `lib/rails_ai_context.rb` — Main entry point, public API (Zeitwerk autoloaded)
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
- - `lib/rails_ai_context/introspectors/` — 29 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)
12
- - `lib/rails_ai_context/tools/` — 25 MCP tools using the official mcp SDK
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/` — 30 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)
@@ -34,24 +34,30 @@ structure to AI assistants via the Model Context Protocol (MCP).
34
34
  7. **Diff-aware** — context regeneration skips unchanged files
35
35
  8. **Per-assistant serializers** — each AI tool gets tailored output format
36
36
  9. **Zeitwerk autoloading** — files loaded on-demand, not all upfront
37
- 10. **Introspector presets** — `:full` (28) default, `:standard` (13 core) for lightweight usage
37
+ 10. **Introspector presets** — `:full` (32) default, `:standard` (14 core) for lightweight usage
38
38
  11. **MCP auto-discovery** — `.mcp.json` generated by install generator
39
39
  12. **Compact by default** — context files ≤150 lines, MCP tools use `detail` parameter (summary/standard/full)
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 25 built-in tools
43
+ 16. **custom_tools API** — `config.custom_tools` array lets users register additional MCP::Tool subclasses alongside the 30 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 25 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 30 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
+ 23. **Component catalog** — ViewComponent/Phlex introspection: props, slots, previews, sidecar assets, usage examples via `rails_get_component_catalog`
51
+ 24. **Accessibility scanning** — ARIA attributes, semantic HTML, screen reader text, alt text, landmark roles, accessibility score via AccessibilityIntrospector
52
+ 25. **Performance analysis** — N+1 query risks, missing counter_cache, missing FK indexes, eager load candidates via `rails_performance_check`
53
+ 26. **Migration advisor** — migration code generation with duplicate/nonexistent column warnings, reversibility flags, table name normalization via `rails_migration_advisor`
54
+ 27. **Frontend framework detection** — auto-detects React/Vue/Svelte/Angular from package.json, Vite/Shakapacker/Webpacker config, TypeScript setup, monorepo layout, package manager via `rails_get_frontend_stack`
55
+ 28. **Install generator idempotency** — re-install preserves existing config, only adds new sections, updates ai_tools/tool_mode selections, prompts per-tool file cleanup for removed tools
50
56
 
51
57
  ## Testing
52
58
 
53
59
  ```bash
54
- bundle exec rspec # Run specs (681 examples)
60
+ bundle exec rspec # Run specs (893 examples)
55
61
  bundle exec rubocop # Lint
56
62
  ```
57
63
 
data/CONTRIBUTING.md CHANGED
@@ -19,8 +19,8 @@ The test suite uses [Combustion](https://github.com/pat/combustion) to boot a mi
19
19
  ```
20
20
  lib/rails_ai_context/
21
21
  ├── cli/ # CLI tool runner (tool_runner.rb) — executes MCP tools from rake/Thor
22
- ├── introspectors/ # 29 introspectors (schema, models, routes, etc.)
23
- ├── tools/ # 25 MCP tools with detail levels and pagination
22
+ ├── introspectors/ # 33 introspectors (schema, models, routes, etc.)
23
+ ├── tools/ # 30 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
@@ -9,14 +9,14 @@
9
9
 
10
10
  **Works with:** Claude Code &bull; Cursor &bull; GitHub Copilot &bull; OpenCode &bull; Any terminal
11
11
 
12
- > 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 681 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.
12
+ > 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 893 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.
13
13
 
14
14
  ```bash
15
15
  gem "rails-ai-context", group: :development
16
16
  rails generate rails_ai_context:install
17
17
  ```
18
18
 
19
- That's it. Your AI now has 25 tools that understand your entire Rails app — via MCP server or CLI. Zero config.
19
+ That's it. Your AI now has 30 tools that understand your entire Rails app — via MCP server or CLI. Zero config.
20
20
 
21
21
  > **[Full Guide →](docs/GUIDE.md)** — every command, every parameter, every configuration option.
22
22
 
@@ -46,7 +46,7 @@ rails 'ai:tool[schema]' table=users
46
46
  rails 'ai:tool[analyze_feature]' feature=billing
47
47
  ```
48
48
 
49
- Same 25 tools. Same output. AI agents run these as shell commands. **Works in any terminal, any AI tool, any workflow.** No MCP client required.
49
+ Same 30 tools. Same output. AI agents run these as shell commands. **Works in any terminal, any AI tool, any workflow.** No MCP client required.
50
50
 
51
51
  ---
52
52
 
@@ -170,7 +170,7 @@ Tested on a real Rails 8 app (5 models, 19 controllers, 95 routes):
170
170
 
171
171
  ---
172
172
 
173
- ## 25 Tools
173
+ ## 30 Tools
174
174
 
175
175
  Every tool is **read-only** and returns structured, token-efficient data.
176
176
 
@@ -209,6 +209,13 @@ Every tool is **read-only** and returns structured, token-efficient data.
209
209
  | **Services & Jobs** | | | |
210
210
  | `get_service_pattern` | `rails_get_service_pattern` | `rails 'ai:tool[service_pattern]'` | Interface, dependencies, side effects, callers |
211
211
  | `get_job_pattern` | `rails_get_job_pattern` | `rails 'ai:tool[job_pattern]'` | Queue, retries, guard clauses, broadcasts, schedules |
212
+ | **Components & Quality** | | | |
213
+ | `get_component_catalog` | `rails_get_component_catalog` | `rails 'ai:tool[component_catalog]'` | ViewComponent/Phlex: props, slots, previews, sidecar assets, usage |
214
+ | `performance_check` | `rails_performance_check` | `rails 'ai:tool[performance_check]'` | N+1 risks, missing indexes, counter_cache, eager load candidates |
215
+ | `dependency_graph` | `rails_dependency_graph` | `rails 'ai:tool[dependency_graph]'` | Model/service dependency graph in Mermaid or text format |
216
+ | `migration_advisor` | `rails_migration_advisor` | `rails 'ai:tool[migration_advisor]'` | Migration code generation with reversibility + affected models |
217
+ | **Frontend** | | | |
218
+ | `get_frontend_stack` | `rails_get_frontend_stack` | `rails 'ai:tool[frontend_stack]'` | React/Vue/Svelte/Angular, Inertia, TypeScript, package manager |
212
219
 
213
220
  > **[Full parameter docs →](docs/GUIDE.md)**
214
221
 
@@ -221,7 +228,7 @@ Every tool is **read-only** and returns structured, token-efficient data.
221
228
  │ Your Rails App │
222
229
  │ models + schema + routes + controllers + views + jobs │
223
230
  └────────────────────────┬────────────────────────────────┘
224
- │ introspects (29 introspectors)
231
+ │ introspects (33 introspectors)
225
232
 
226
233
  ┌─────────────────────────────────────────────────────────┐
227
234
  │ rails-ai-context │
@@ -231,7 +238,7 @@ Every tool is **read-only** and returns structured, token-efficient data.
231
238
  ▼ ▼ ▼
232
239
  ┌──────────────────┐ ┌────────────┐ ┌────────────────────┐
233
240
  │ Static Files │ │ MCP Server │ │ CLI Tools │
234
- │ CLAUDE.md │ │ 25 tools │ │ Same 25 tools │
241
+ │ CLAUDE.md │ │ 30 tools │ │ Same 30 tools │
235
242
  │ .cursor/rules/ │ │ stdio/HTTP │ │ No server needed │
236
243
  │ .github/instr... │ │ .mcp.json │ │ rails 'ai:tool[X]' │
237
244
  └──────────────────┘ └────────────┘ └────────────────────┘
@@ -267,7 +274,7 @@ MCP auto-discovery: `.mcp.json` is detected automatically by Claude Code and Cur
267
274
  | Command | What it does |
268
275
  |---------|-------------|
269
276
  | `rails ai:context` | Generate context files for your AI tools |
270
- | `rails 'ai:tool[NAME]'` | Run any of the 25 tools from the CLI |
277
+ | `rails 'ai:tool[NAME]'` | Run any of the 30 tools from the CLI |
271
278
  | `rails ai:tool` | List all available tools with short names |
272
279
  | `rails ai:serve` | Start MCP server (stdio) |
273
280
  | `rails ai:doctor` | Diagnostics + AI readiness score |
@@ -287,7 +294,7 @@ RailsAiContext.configure do |config|
287
294
  # Tool mode: :mcp (default, MCP + CLI fallback) or :cli (CLI only)
288
295
  # config.tool_mode = :mcp
289
296
 
290
- # Presets: :full (28 introspectors, default) or :standard (13 core)
297
+ # Presets: :full (32 introspectors, default) or :standard (14 core)
291
298
  # config.preset = :full
292
299
 
293
300
  # Exclude models from introspection
@@ -305,7 +312,7 @@ end
305
312
  |--------|---------|-------------|
306
313
  | **Presets & Introspectors** | | |
307
314
  | `preset` | `:full` | Introspector preset (`:full` or `:standard`) |
308
- | `introspectors` | 28 (full) | Array of introspector symbols |
315
+ | `introspectors` | 32 (full) | Array of introspector symbols |
309
316
  | **Context Generation** | | |
310
317
  | `context_mode` | `:compact` | `:compact` (≤150 lines) or `:full` (dump everything) |
311
318
  | `claude_max_lines` | `150` | Max lines for CLAUDE.md in compact mode |
@@ -340,7 +347,7 @@ end
340
347
  ```bash
341
348
  git clone https://github.com/crisnahine/rails-ai-context.git
342
349
  cd rails-ai-context && bundle install
343
- bundle exec rspec # 681 examples
350
+ bundle exec rspec # 893 examples
344
351
  bundle exec rubocop # Lint
345
352
  ```
346
353
 
data/SECURITY.md CHANGED
@@ -4,8 +4,11 @@
4
4
 
5
5
  | Version | Supported |
6
6
  |---------|--------------------|
7
- | 3.0.x | :white_check_mark: |
8
- | 2.0.x | :white_check_mark: |
7
+ | 4.1.x | :white_check_mark: |
8
+ | 4.0.x | :white_check_mark: |
9
+ | 3.1.x | :white_check_mark: |
10
+ | 3.0.x | :x: |
11
+ | 2.0.x | :x: |
9
12
  | < 2.0 | :x: |
10
13
 
11
14
  ## Reporting a Vulnerability
@@ -22,7 +25,7 @@ If you discover a security vulnerability in rails-ai-context, please report it r
22
25
 
23
26
  ## Security Design
24
27
 
25
- - All 25 MCP tools are **read-only** and never modify your application or database.
28
+ - All 30 MCP tools are **read-only** and never modify your application or database.
26
29
  - **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.
27
30
  - **Path traversal protection** — all file-reading tools validate paths with `File.realpath()` against `Rails.root` to prevent directory escape.
28
31
  - **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
@@ -40,7 +40,7 @@ rails ai:context
40
40
  This creates:
41
41
  1. `config/initializers/rails_ai_context.rb` — configuration file
42
42
  2. `.mcp.json` — MCP auto-discovery for Claude Code and Cursor
43
- 3. 25 context files — tailored for each AI assistant
43
+ 3. 29 context files — tailored for each AI assistant
44
44
 
45
45
  ### Existing project
46
46
 
@@ -124,7 +124,7 @@ end
124
124
 
125
125
  ## Generated Files
126
126
 
127
- `rails ai:context` generates **25 files** across all AI assistants:
127
+ `rails ai:context` generates **29 files** across all AI assistants:
128
128
 
129
129
  ### Claude Code (6 files)
130
130
 
@@ -184,7 +184,7 @@ Commit **all files except `.ai-context.json`** (which is gitignored). This gives
184
184
 
185
185
  | Command | Mode | Format | Description |
186
186
  |---------|------|--------|-------------|
187
- | `rails ai:context` | compact | all | Generate all 25 context files |
187
+ | `rails ai:context` | compact | all | Generate all 29 context files |
188
188
  | `rails ai:context:full` | full | all | Generate all files in full mode |
189
189
  | `rails ai:context:claude` | compact | Claude | CLAUDE.md + .claude/rules/ |
190
190
  | `rails ai:context:opencode` | compact | OpenCode | AGENTS.md + per-directory AGENTS.md |
@@ -252,7 +252,7 @@ rails ai:context:claude # Use this instead (no quoting needed)
252
252
 
253
253
  ## CLI Tools
254
254
 
255
- All 25 MCP tools can be run directly from the terminal — no MCP server or AI client needed.
255
+ All 30 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 25 tools are **read-only** and **idempotent** — they never modify your application or database.
319
+ All 30 tools are **read-only** and **idempotent** — they never modify your application or database.
320
320
 
321
321
  ### rails_get_schema
322
322
 
@@ -996,7 +996,7 @@ All tools that support `detail` use these three levels. Default limits vary by t
996
996
  | Level | What it returns | Schema default limit | Best for |
997
997
  |-------|----------------|---------------------|----------|
998
998
  | `summary` | Names + counts | 50 | Getting the landscape, understanding what exists |
999
- | `standard` | Names + key details | 25 | Working context, column types, action names |
999
+ | `standard` | Names + key details | 29 | Working context, column types, action names |
1000
1000
  | `full` | Everything | 10 | Deep inspection, indexes, FKs, constraints |
1001
1001
 
1002
1002
  Other tools default to higher limits (e.g. models/controllers/stimulus: 50 for all levels, routes: 100/200).
@@ -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 25 tools and never modify your app.
1120
+ Both transports are **read-only** — they expose the same 30 tools and never modify your app.
1121
1121
 
1122
1122
  ---
1123
1123
 
@@ -1128,7 +1128,7 @@ Both transports are **read-only** — they expose the same 25 tools and never mo
1128
1128
  RailsAiContext.configure do |config|
1129
1129
  # --- Introspectors ---
1130
1130
 
1131
- # Presets: :full (28 introspectors, default) or :standard (13 core)
1131
+ # Presets: :full (32 introspectors, default) or :standard (14 core)
1132
1132
  config.preset = :full
1133
1133
 
1134
1134
  # Cherry-pick on top of a preset
@@ -1243,7 +1243,7 @@ end
1243
1243
  | Option | Type | Default | Description |
1244
1244
  |--------|------|---------|-------------|
1245
1245
  | `preset` | Symbol | `:full` | Introspector preset (`:full` or `:standard`) |
1246
- | `introspectors` | Array | 28 (full preset) | Which introspectors to run |
1246
+ | `introspectors` | Array | 32 (full preset) | Which introspectors to run |
1247
1247
  | `context_mode` | Symbol | `:compact` | `:compact` or `:full` |
1248
1248
  | `claude_max_lines` | Integer | `150` | Max lines for CLAUDE.md in compact mode |
1249
1249
  | `max_tool_response_chars` | Integer | `200_000` | Safety cap for MCP tool responses |
@@ -1300,7 +1300,7 @@ All split rules include an app overview file, so no context is lost when root fi
1300
1300
 
1301
1301
  ## Introspectors — Full List
1302
1302
 
1303
- ### Standard preset (13 introspectors)
1303
+ ### Standard preset (14 introspectors)
1304
1304
 
1305
1305
  Core Rails structure only. Use `config.preset = :standard` for a lighter footprint.
1306
1306
 
@@ -1319,8 +1319,9 @@ Core Rails structure only. Use `config.preset = :standard` for a lighter footpri
1319
1319
  | `stimulus` | Stimulus controllers with targets, values (with types), actions, outlets, classes. Extracted from JS/TS files. |
1320
1320
  | `view_templates` | View file contents, partial references, Stimulus data attributes, UI pattern extraction, model field usage in partials. |
1321
1321
  | `design_tokens` | Auto-detects CSS framework (Tailwind v3/v4, Bootstrap, Sass, plain CSS) and extracts design tokens from config files and built CSS. |
1322
+ | `components` | ViewComponent/Phlex components: props, slots, previews, sidecar assets, usage examples. |
1322
1323
 
1323
- ### Full preset (28 introspectors) — default
1324
+ ### Full preset (32 introspectors) — default
1324
1325
 
1325
1326
  Includes all standard introspectors plus:
1326
1327
 
@@ -1341,6 +1342,9 @@ Includes all standard introspectors plus:
1341
1342
  | `middleware` | Custom Rack middleware in app/middleware/ with detected patterns (auth, rate limiting, tenant isolation, logging). Full middleware stack. |
1342
1343
  | `engines` | Mounted Rails engines from routes.rb with paths and descriptions for 23+ known engines (Sidekiq::Web, Flipper::UI, PgHero, ActiveAdmin, etc.). |
1343
1344
  | `multi_database` | Multiple databases, replicas, sharding config, model-specific `connects_to` declarations. database.yml parsing fallback. |
1345
+ | `accessibility` | ARIA attributes, semantic HTML elements, screen reader text, alt text coverage, landmark roles, accessibility score. |
1346
+ | `performance` | N+1 query risks, missing counter_cache, missing FK indexes, Model.all anti-patterns, eager load candidates. |
1347
+ | `frontend_frameworks` | Frontend JS framework detection (React/Vue/Svelte/Angular), mounting strategy (Inertia/react-rails), TypeScript config, state management, package manager. |
1344
1348
  | `database_stats` | PostgreSQL approximate row counts via `pg_stat_user_tables`. **Opt-in only** — not in any preset, add manually: `config.introspectors += [:database_stats]`. |
1345
1349
 
1346
1350
  ### Using the standard preset
@@ -1432,11 +1436,11 @@ OpenCode uses **per-directory lazy-loading**: when the agent reads a file, it wa
1432
1436
 
1433
1437
  | Setup | Coverage | Notes |
1434
1438
  |-------|----------|-------|
1435
- | Rails full-stack (ERB + Hotwire) | 29/29 | All introspectors relevant |
1436
- | Rails + Inertia.js (React/Vue) | ~22/29 | Views/Turbo partially useful, backend fully covered |
1437
- | Rails API + React/Next.js SPA | ~20/29 | Schema, models, routes, API, auth, jobs — all covered |
1438
- | Rails API + mobile app | ~20/29 | Same as SPA — backend introspection is identical |
1439
- | Rails engine (mountable gem) | ~15/29 | Core introspectors (schema, models, routes, gems) work |
1439
+ | Rails full-stack (ERB + Hotwire) | 32/32 | All introspectors relevant |
1440
+ | Rails + Inertia.js (React/Vue) | ~25/32 | Views/Turbo partially useful, backend fully covered |
1441
+ | Rails API + React/Next.js SPA | ~23/32 | Schema, models, routes, API, auth, jobs — all covered |
1442
+ | Rails API + mobile app | ~23/32 | Same as SPA — backend introspection is identical |
1443
+ | Rails engine (mountable gem) | ~18/32 | Core introspectors (schema, models, routes, gems) work |
1440
1444
 
1441
1445
  Frontend introspectors (views, Turbo, Stimulus, assets) degrade gracefully — they report nothing when those features aren't present.
1442
1446