rails-ai-context 1.3.1 → 2.0.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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -0
  3. data/CLAUDE.md +5 -3
  4. data/CONTRIBUTING.md +1 -1
  5. data/README.md +40 -29
  6. data/SECURITY.md +11 -7
  7. data/docs/GUIDE.md +305 -29
  8. data/lib/rails_ai_context/configuration.rb +12 -8
  9. data/lib/rails_ai_context/doctor.rb +20 -0
  10. data/lib/rails_ai_context/introspectors/model_introspector.rb +5 -4
  11. data/lib/rails_ai_context/serializers/claude_rules_serializer.rb +34 -4
  12. data/lib/rails_ai_context/serializers/claude_serializer.rb +11 -1
  13. data/lib/rails_ai_context/serializers/copilot_instructions_serializer.rb +11 -1
  14. data/lib/rails_ai_context/serializers/cursor_rules_serializer.rb +12 -2
  15. data/lib/rails_ai_context/serializers/design_system_helper.rb +8 -7
  16. data/lib/rails_ai_context/serializers/markdown_serializer.rb +1 -1
  17. data/lib/rails_ai_context/serializers/opencode_serializer.rb +11 -1
  18. data/lib/rails_ai_context/serializers/stack_overview_helper.rb +2 -1
  19. data/lib/rails_ai_context/serializers/windsurf_rules_serializer.rb +11 -1
  20. data/lib/rails_ai_context/server.rb +19 -2
  21. data/lib/rails_ai_context/tools/analyze_feature.rb +60 -5
  22. data/lib/rails_ai_context/tools/base_tool.rb +16 -0
  23. data/lib/rails_ai_context/tools/get_callbacks.rb +279 -0
  24. data/lib/rails_ai_context/tools/get_concern.rb +392 -0
  25. data/lib/rails_ai_context/tools/get_config.rb +77 -0
  26. data/lib/rails_ai_context/tools/get_context.rb +281 -0
  27. data/lib/rails_ai_context/tools/get_controllers.rb +215 -7
  28. data/lib/rails_ai_context/tools/get_conventions.rb +264 -0
  29. data/lib/rails_ai_context/tools/get_design_system.rb +195 -21
  30. data/lib/rails_ai_context/tools/get_edit_context.rb +12 -1
  31. data/lib/rails_ai_context/tools/get_env.rb +624 -0
  32. data/lib/rails_ai_context/tools/get_gems.rb +25 -1
  33. data/lib/rails_ai_context/tools/get_helper_methods.rb +311 -0
  34. data/lib/rails_ai_context/tools/get_job_pattern.rb +419 -0
  35. data/lib/rails_ai_context/tools/get_model_details.rb +140 -26
  36. data/lib/rails_ai_context/tools/get_partial_interface.rb +452 -0
  37. data/lib/rails_ai_context/tools/get_routes.rb +11 -3
  38. data/lib/rails_ai_context/tools/get_schema.rb +64 -8
  39. data/lib/rails_ai_context/tools/get_service_pattern.rb +331 -0
  40. data/lib/rails_ai_context/tools/get_stimulus.rb +77 -0
  41. data/lib/rails_ai_context/tools/get_test_info.rb +158 -3
  42. data/lib/rails_ai_context/tools/get_turbo_map.rb +585 -0
  43. data/lib/rails_ai_context/tools/get_view.rb +50 -2
  44. data/lib/rails_ai_context/tools/search_code.rb +40 -3
  45. data/lib/rails_ai_context/tools/security_scan.rb +183 -0
  46. data/lib/rails_ai_context/tools/validate.rb +186 -27
  47. data/lib/rails_ai_context/version.rb +1 -1
  48. data/server.json +3 -3
  49. metadata +12 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d83d1237d476138591f50c4723cb10a4864aed5ed2e84b7059e53bff287af1db
4
- data.tar.gz: 3791bba4e68364ea507050f2605096ce8dff2cacf943ddd111753b768c8152cf
3
+ metadata.gz: 34ef5e454a22f9719cf4439c70867a4e2f9dc900d34e1cca0f4ecd723e3a3308
4
+ data.tar.gz: d7545c9afd73831f0f32e0808f82856e1cf48c3763308049f5ba54d453f3f452
5
5
  SHA512:
6
- metadata.gz: 4e3ceb93281e5d3674aab290728357ef75d9d0c24a7d3cee05c9380333ba4d5209b13fdad85a7f015185697d09b9c9093fafc10e628d4dbc1bb897280eb5c388
7
- data.tar.gz: 4a0240af3fc7a4ecc303c72107b62f5f5df88fafc189be1f3b19096895dccdd7242ce6e640f7d0f6f148aaed45af7e74f4bf717f773aee3b8cd77107f393c6b0
6
+ metadata.gz: f29724289bcf91b5aeb776cfac4eec673a8bb8b02016108bab7a52f9f6f52b4fe5f3045cee43053a4b6e660619800dc8ea6f0141ed5bdd812d00898d00f9d7ef
7
+ data.tar.gz: 3178d4a6347de30aaf92e13b5db4d976fe6d2c0888de60b451bc187e9ae71518186c204c97f74e37d159431c2ea149d9fc19db00ab338bce44ffda6c33ef6da3
data/CHANGELOG.md CHANGED
@@ -5,6 +5,51 @@ 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
+ ## [2.0.0] - 2026-03-24
9
+
10
+ ### Added
11
+
12
+ - **9 new MCP tools (16→25)** — `rails_get_concern` (concern methods + includers), `rails_get_callbacks` (execution order + source), `rails_get_helper_methods` (app + framework helpers + view refs), `rails_get_service_pattern` (interface, deps, side effects), `rails_get_job_pattern` (queue, retries, guards, broadcasts), `rails_get_env` (env vars, credentials keys, external services), `rails_get_partial_interface` (locals contract + usage), `rails_get_turbo_map` (stream/frame wiring + mismatch warnings), `rails_get_context` (composite cross-layer tool).
13
+ - **Phase 1 improvements** — scope definitions include lambda body, controller actions show instance variables + private methods called inline, Stimulus shows HTML data-attributes + reverse view lookup.
14
+ - **3 new validation rules** — instance variable consistency (view uses @foo but controller never sets it), Turbo Stream channel matching (broadcast without subscriber), respond_to template existence.
15
+ - **`rails_security_scan` tool** — Brakeman static security analysis via MCP. Detects SQL injection, XSS, mass assignment, and more. Optional dependency — returns install instructions if Brakeman isn't present. Supports file filtering, confidence levels (high/medium/weak), specific check selection, and three detail levels (summary/standard/full).
16
+ - **`config.skip_tools`** — users can now exclude specific built-in tools: `config.skip_tools = %w[rails_security_scan]`. Defaults to empty (all 25 tools active).
17
+ - **Schema index hints** — `get_schema` standard detail now shows `[indexed]`/`[unique]` on columns, saving a round-trip to full detail.
18
+ - **Enum backing types** — `get_model_details` now shows integer vs string backing: `status: pending(0), active(1) [integer]`.
19
+ - **Search context lines default 2** — `search_code` now returns 2 lines of context by default (was 0). Eliminates follow-up calls for context.
20
+ - **`match_type` parameter for search** — `search_code` supports `match_type:"definition"` (only `def` lines) and `match_type:"class"` (only `class`/`module` lines).
21
+ - **Controller respond_to formats** — `get_controllers` surfaces `respond_to` formats (html, json) already collected by introspector.
22
+ - **Config database/auth/assets detection** — `get_config` now shows database adapter, auth framework (Devise/Rodauth/etc), and assets stack (Tailwind/esbuild/etc).
23
+ - **Frontend stack detection** — `get_conventions` detects frontend dependencies from package.json (Tailwind, React, TypeScript, Turbo, etc).
24
+ - **Validate fix suggestions** — semantic warnings now include actionable fix hints (migration commands, `dependent:` options, index commands).
25
+ - **Prism fallback indicator** — `validate` reports when Prism is unavailable so agents know semantic checks may be skipped.
26
+ - **Factory attributes/traits** — `get_test_info` full detail parses factory files to show attributes and traits, not just names.
27
+ - **Partial render locals** — `get_view` standard detail shows what locals each partial receives based on render call scanning.
28
+ - **Edit context header** — `get_edit_context` shows enclosing class/method name in response header.
29
+ - **Gem config location hints** — `get_gems` shows config file paths for 17 common gems (Devise, Sidekiq, Pundit, etc).
30
+ - **Stimulus lifecycle detection** — `get_stimulus` detects connect/disconnect/initialize lifecycle methods.
31
+ - **Route params inline** — `get_routes` standard detail shows required params: `[id]`, `[user_id, id]`.
32
+ - **Feature test coverage gaps** — `analyze_feature` reports which models/controllers/jobs lack test files.
33
+ - **Model macros surfaced** — `get_model_details` now shows `has_secure_password`, `encrypts`, `normalizes`, `generates_token_for`, `serialize`, `store`, `broadcasts`, attachments — all previously collected but hidden.
34
+ - **Model delegations and constants** — `get_model_details` shows `delegate :x, to: :y` and constants like `STATUSES = %w[pending completed]`.
35
+ - **Association FK column hints** — `get_model_details` shows `(fk: user_id)` on belongs_to associations.
36
+ - **Schema model references** — `get_schema` full detail shows which ActiveRecord models reference each table.
37
+ - **Schema column comments** — `get_schema` full detail shows database column comments when present.
38
+ - **Action Cable adapter detection** — `get_config` detects Action Cable adapter from cable.yml.
39
+ - **Gem version display** — `get_gems` shows version numbers from Gemfile.lock.
40
+ - **Package manager detection** — `get_conventions` detects npm/yarn/pnpm/bun from lock files.
41
+ - **Exact match search** — `search_code` supports `exact_match:true` for whole-word matching with `\b` boundaries.
42
+ - **Scaled defaults for big apps** — increased `max_tool_response_chars` (120K→200K), `max_search_results` (100→200), `max_validate_files` (20→50), `cache_ttl` (30→60s), `max_file_size` (2MB→5MB), `max_test_file_size` (500KB→1MB), `max_view_total_size` (5MB→10MB), `max_view_file_size` (500KB→1MB). Schema standard pagination 15→25, full 5→10. Methods shown per model 15→25. Routes standard 100→150.
43
+ - **AI-optimal tool ordering** — schema standard sorts tables by column count (complex first), model listing sorts by association count (central models first). Stops AI from missing important tables/models buried alphabetically.
44
+ - **Cross-reference navigation hints** — schema single-table suggests `rails_get_model_details`, model detail suggests `rails_get_controllers` + `rails_get_schema` + `rails_analyze_feature`, controller detail suggests `rails_get_routes` + `rails_get_view`. Reduces AI round-trips.
45
+ - **Schema adapter in summary** — `get_schema` summary shows database adapter (postgresql/mysql/sqlite3) so AI knows query syntax immediately.
46
+ - **App size detection** — `BaseTool.app_size` returns `:small`/`:medium`/`:large` based on model/table count for auto-tuning.
47
+ - **Doctor checks for Prism and Brakeman** — `rails ai:doctor` now reports availability of Prism parser and Brakeman security scanner.
48
+
49
+ ### Fixed
50
+
51
+ - **JS fallback validator false-positives** — escaped backslashes before string-closing quotes (`"path\\"`) no longer cause false bracket mismatch errors. Replaced `prev_char` check with proper `escaped` toggle flag.
52
+
8
53
  ## [1.3.1] - 2026-03-23
9
54
 
10
55
  ### 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/` — 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/` — 15 MCP tools using the official mcp SDK
12
+ - `lib/rails_ai_context/tools/` — 25 MCP tools using the official mcp SDK
13
13
  - `lib/rails_ai_context/serializers/` — Output formatters (claude, claude_rules, opencode, opencode_rules, cursor_rules, windsurf, windsurf_rules, copilot, copilot_instructions, rules, markdown, JSON, context_file_serializer, test_command_detection)
14
14
  - `lib/rails_ai_context/resources.rb` — MCP resources (static data AI clients read directly)
15
15
  - `lib/rails_ai_context/server.rb` — MCP server configuration (stdio + HTTP transports)
@@ -39,13 +39,15 @@ structure to AI assistants via the Model Context Protocol (MCP).
39
39
  13. **Per-tool split rules** — `.claude/rules/`, `.cursor/rules/`, `.windsurf/rules/`, `.github/instructions/`
40
40
  14. **Section markers** — root file content wrapped in `<!-- BEGIN/END rails-ai-context -->` to preserve user content
41
41
  15. **generate_root_files toggle** — when false, skip root files (CLAUDE.md, etc.), only generate split rules
42
- 16. **custom_tools API** — `config.custom_tools` array lets users register additional MCP::Tool subclasses alongside the 15 built-in tools
42
+ 16. **custom_tools API** — `config.custom_tools` array lets users register additional MCP::Tool subclasses alongside the 25 built-in tools
43
43
  17. **Design system extraction** — view templates analyzed for canonical examples, color palette, typography, responsive patterns, interactive states, dark mode
44
+ 18. **skip_tools API** — `config.skip_tools` array lets users exclude specific built-in tools (e.g. `%w[rails_security_scan]`)
45
+ 19. **Security scanning** — optional Brakeman integration via `rails_security_scan` tool (graceful degradation if not installed)
44
46
 
45
47
  ## Testing
46
48
 
47
49
  ```bash
48
- bundle exec rspec # Run specs (522 examples)
50
+ bundle exec rspec # Run specs (575 examples)
49
51
  bundle exec rubocop # Lint
50
52
  ```
51
53
 
data/CONTRIBUTING.md CHANGED
@@ -19,7 +19,7 @@ The test suite uses [Combustion](https://github.com/pat/combustion) to boot a mi
19
19
  ```
20
20
  lib/rails_ai_context/
21
21
  ├── introspectors/ # 29 introspectors (schema, models, routes, etc.)
22
- ├── tools/ # 15 MCP tools with detail levels and pagination
22
+ ├── tools/ # 25 MCP tools with detail levels and pagination
23
23
  ├── serializers/ # Per-assistant formatters (claude, opencode, cursor, windsurf, copilot, JSON)
24
24
  ├── server.rb # MCP server setup (stdio + HTTP)
25
25
  ├── live_reload.rb # MCP live reload (file watcher + cache invalidation)
data/README.md CHANGED
@@ -62,7 +62,7 @@ Agent: rails_validate(files:["app/models/cook.rb"], level:"rails") → catches c
62
62
  |-------|-----------------|---------------|------------|
63
63
  | **Static files** (CLAUDE.md, .cursorrules, etc.) | App overview: stack, models, gems, architecture, UI patterns, MCP tool reference | Automatically at session start | ~150 lines, zero tool calls |
64
64
  | **Split rules** (.claude/rules/, .cursor/rules/) | Deep reference: full schema with column types, all model associations/scopes, controller listings | Conditionally — only when editing relevant files | Zero when not needed |
65
- | **Live MCP tools** (15 tools) | Real-time queries: drill into any table, model, controller action, or view on demand. Semantic validation. Design system. | On-demand via agent tool calls | ~25-100 lines per call |
65
+ | **Live MCP tools** (25 tools) | Real-time queries: drill into any table, model, controller action, or view on demand. Semantic validation. Design system. Security scanning. | On-demand via agent tool calls | ~25-100 lines per call |
66
66
 
67
67
  **Progressive disclosure:** the agent gets the map for free, reference guides when relevant, and live GPS when building.
68
68
 
@@ -72,7 +72,7 @@ Agent: rails_validate(files:["app/models/cook.rb"], level:"rails") → catches c
72
72
 
73
73
  | Setup | Tokens | What it knows |
74
74
  |-------|--------|---------------|
75
- | **rails-ai-context (full)** | **28,834** | 15 MCP tools + generated docs + split rules |
75
+ | **rails-ai-context (full)** | **28,834** | 25 MCP tools + generated docs + split rules |
76
76
  | rails-ai-context CLAUDE.md only | 33,106 | Generated docs + rules, no MCP tools |
77
77
  | Normal Claude `/init` | 40,700 | Generic CLAUDE.md only |
78
78
  | No rails-ai-context | 45,477 | Nothing — discovers everything from scratch |
@@ -97,27 +97,37 @@ But token savings is the side effect. The real value:
97
97
 
98
98
  ---
99
99
 
100
- ## 15 Live MCP Tools
100
+ ## 25 Live MCP Tools
101
101
 
102
- The gem exposes **15 read-only tools** via MCP that AI clients call on-demand:
102
+ The gem exposes **25 read-only tools** via MCP that AI clients call on-demand:
103
103
 
104
104
  | Tool | What it returns |
105
105
  |------|----------------|
106
- | `rails_get_schema` | Tables, columns, indexes, foreign keys |
107
- | `rails_get_model_details` | Associations, validations, scopes, enums, callbacks |
108
- | `rails_get_routes` | HTTP verbs, paths, controller actions |
109
- | `rails_get_controllers` | Actions, filters, strong params, concerns |
110
- | `rails_get_config` | Cache, session, timezone, middleware, initializers |
111
- | `rails_get_test_info` | Test framework, factories, CI config, coverage |
112
- | `rails_get_gems` | Notable gems categorized by function |
113
- | `rails_get_conventions` | Architecture patterns, directory structure |
114
- | `rails_search_code` | Ripgrep-powered regex search across the codebase |
115
- | `rails_get_view` | View templates, partials, Stimulus references |
116
- | `rails_get_stimulus` | Stimulus controllers — targets, values, actions, outlets |
117
- | `rails_get_edit_context` | Surgical edit helper — returns code around a match with line numbers |
118
- | `rails_validate` | Batch syntax validation for Ruby, ERB, and JavaScript files. `level:"rails"` adds semantic checks (partials, route helpers, columns, strong params, callbacks, FK indexes, Stimulus) |
119
- | `rails_analyze_feature` | Full-stack feature analysis — models, controllers, routes, services, jobs, views, Stimulus, tests, related models, env deps |
106
+ | `rails_get_schema` | Tables, columns with `[indexed]`/`[unique]` hints, indexes, foreign keys |
107
+ | `rails_get_model_details` | Associations with `dependent:`, validations, scopes, enums with backing type, callbacks |
108
+ | `rails_get_routes` | HTTP verbs, paths with `[params]`, controller actions |
109
+ | `rails_get_controllers` | Actions, filters, strong params, respond_to formats |
110
+ | `rails_get_config` | Database adapter, auth framework, assets stack, cache, session, timezone, middleware |
111
+ | `rails_get_test_info` | Test framework, factory attributes/traits, fixtures, CI config, coverage |
112
+ | `rails_get_gems` | Notable gems categorized by function with config location hints |
113
+ | `rails_get_conventions` | Architecture patterns, frontend stack, directory structure |
114
+ | `rails_search_code` | Ripgrep search with 2-line context default, `match_type:"definition"` for method defs only |
115
+ | `rails_get_view` | View templates, partials with render locals, Stimulus references |
116
+ | `rails_get_stimulus` | Stimulus controllers — targets, values, actions, outlets, lifecycle methods |
117
+ | `rails_get_edit_context` | Surgical edit helper — returns code with class/method context and line numbers |
118
+ | `rails_validate` | Syntax + semantic validation with fix suggestions (migrations, dependent options, index commands) |
119
+ | `rails_analyze_feature` | Full-stack feature analysis — models, controllers, routes, services, jobs, views, Stimulus, tests, test coverage gaps |
120
120
  | `rails_get_design_system` | App design system — color palette, component patterns with real HTML examples, typography, layout, responsive breakpoints |
121
+ | `rails_security_scan` | Brakeman static security analysis — SQL injection, XSS, mass assignment. Filter by file, confidence level, specific checks |
122
+ | `rails_get_concern` | Concern public methods, signatures, which models/controllers include it |
123
+ | `rails_get_callbacks` | Model callbacks in Rails execution order with source code |
124
+ | `rails_get_helper_methods` | Application + framework helper methods with view usage cross-references |
125
+ | `rails_get_service_pattern` | Service objects — interface, dependencies, side effects, error handling, calling convention |
126
+ | `rails_get_job_pattern` | Background jobs — queue, retries, guard clauses, service calls, Turbo broadcasts, schedules |
127
+ | `rails_get_env` | Environment variables, credentials keys (not values), external service dependencies |
128
+ | `rails_get_partial_interface` | Partial locals contract — required variables, method calls on each, usage examples |
129
+ | `rails_get_turbo_map` | Turbo Streams/Frames wiring — broadcasts, subscriptions, channel matching, mismatch warnings |
130
+ | `rails_get_context` | Composite tool — assembles schema + model + controller + routes + views in one call |
121
131
 
122
132
  ### Smart Detail Levels
123
133
 
@@ -126,8 +136,8 @@ Schema, routes, models, and controllers tools support a `detail` parameter — c
126
136
  | Level | Returns | Default limit |
127
137
  |-------|---------|---------------|
128
138
  | `summary` | Names + counts | 50 |
129
- | `standard` | Names + key details *(default)* | 15 |
130
- | `full` | Everything (indexes, FKs, constraints) | 5 |
139
+ | `standard` | Names + key details *(default)* | 25 |
140
+ | `full` | Everything (indexes, FKs, constraints) | 10 |
131
141
 
132
142
  ```ruby
133
143
  rails_get_schema(detail: "summary") # → all tables with column counts
@@ -282,7 +292,7 @@ RailsAiContext.configure do |config|
282
292
  config.excluded_paths += %w[vendor/bundle]
283
293
 
284
294
  # Cache TTL for MCP tool responses (seconds)
285
- config.cache_ttl = 30
295
+ config.cache_ttl = 60
286
296
 
287
297
  # Live reload: auto-invalidate MCP caches on file changes
288
298
  # :auto (default), true, or false
@@ -314,8 +324,8 @@ end
314
324
  | `http_path` | `"/mcp"` | HTTP endpoint path |
315
325
  | `http_port` | `6029` | HTTP server port |
316
326
  | `http_bind` | `"127.0.0.1"` | HTTP server bind address |
317
- | `cache_ttl` | `30` | Cache TTL in seconds |
318
- | `max_tool_response_chars` | `120_000` | Safety cap for MCP tool responses |
327
+ | `cache_ttl` | `60` | Cache TTL in seconds |
328
+ | `max_tool_response_chars` | `200_000` | Safety cap for MCP tool responses |
319
329
  | `live_reload` | `:auto` | `:auto`, `true`, or `false` — MCP live reload |
320
330
  | `live_reload_debounce` | `1.5` | Debounce interval in seconds |
321
331
  | **Filtering & Exclusions** | | |
@@ -328,18 +338,19 @@ end
328
338
  | `excluded_filters` | `verify_authenticity_token` etc. | Framework filter names hidden from controller output |
329
339
  | `excluded_middleware` | standard Rack/Rails middleware | Default middleware hidden from config output |
330
340
  | **File Size Limits** | | |
331
- | `max_file_size` | `2_000_000` | Per-file read limit for tools (bytes) |
332
- | `max_test_file_size` | `500_000` | Test file read limit (bytes) |
341
+ | `max_file_size` | `5_000_000` | Per-file read limit for tools (bytes) |
342
+ | `max_test_file_size` | `1_000_000` | Test file read limit (bytes) |
333
343
  | `max_schema_file_size` | `10_000_000` | schema.rb / structure.sql parse limit (bytes) |
334
- | `max_view_total_size` | `5_000_000` | Total aggregated view content for UI patterns (bytes) |
335
- | `max_view_file_size` | `500_000` | Per-view file during aggregation (bytes) |
336
- | `max_search_results` | `100` | Max search results per call |
337
- | `max_validate_files` | `20` | Max files per validate call |
344
+ | `max_view_total_size` | `10_000_000` | Total aggregated view content for UI patterns (bytes) |
345
+ | `max_view_file_size` | `1_000_000` | Per-view file during aggregation (bytes) |
346
+ | `max_search_results` | `200` | Max search results per call |
347
+ | `max_validate_files` | `50` | Max files per validate call |
338
348
  | **Search & Discovery** | | |
339
349
  | `search_extensions` | `rb js erb yml yaml json ts tsx vue svelte haml slim` | File extensions for Ruby fallback search |
340
350
  | `concern_paths` | `app/models/concerns app/controllers/concerns` | Where to look for concern source files |
341
351
  | **Extensibility** | | |
342
352
  | `custom_tools` | `[]` | Additional MCP tool classes to register alongside built-in tools |
353
+ | `skip_tools` | `[]` | Built-in tool names to exclude (e.g. `%w[rails_security_scan]`) |
343
354
  </details>
344
355
 
345
356
  ---
data/SECURITY.md CHANGED
@@ -4,9 +4,9 @@
4
4
 
5
5
  | Version | Supported |
6
6
  |---------|--------------------|
7
- | 1.3.x | :white_check_mark: |
8
- | 1.2.x | :white_check_mark: |
9
- | < 1.2 | :x: |
7
+ | 2.0.x | :white_check_mark: |
8
+ | 1.4.x | :white_check_mark: |
9
+ | < 1.4 | :x: |
10
10
 
11
11
  ## Reporting a Vulnerability
12
12
 
@@ -22,8 +22,12 @@ If you discover a security vulnerability in rails-ai-context, please report it r
22
22
 
23
23
  ## Security Design
24
24
 
25
- - All MCP tools are **read-only** and never modify your application or database.
26
- - Code search (`rails_search_code`) uses `Open3.capture2` with array arguments to prevent shell injection.
27
- - File paths are validated against path traversal attacks.
28
- - Credentials and secret values are **never** exposed only a `credentials_configured` boolean is reported (key names and values are never introspected).
25
+ - All 25 MCP tools are **read-only** and never modify your application or database.
26
+ - **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
+ - **Path traversal protection** — all file-reading tools validate paths with `File.realpath()` against `Rails.root` to prevent directory escape.
28
+ - **Command injection prevention** — code search uses `Open3.capture2` with array arguments (never shell strings). The `--` flag separator prevents pattern injection.
29
+ - **Regex DoS protection** — user-supplied regex patterns have 1-2 second timeouts via `Regexp.new(pattern, timeout:)`.
30
+ - **Credential safety** — `rails_get_env` only reads `.env.example` (never `.env`), shows credential key names only (never values), and redacts secrets. `rails_get_config` exposes adapter/framework names, not connection strings.
31
+ - **Brakeman integration** — optional `rails_security_scan` tool runs static security analysis. Graceful degradation if not installed. Users can exclude it via `config.skip_tools = %w[rails_security_scan]`.
32
+ - **File size limits** — all tools enforce configurable `max_file_size` (default 5MB) to prevent memory exhaustion on large files.
29
33
  - The gem does not make any outbound network requests.