rails-ai-context 4.7.0 → 5.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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -0
  3. data/CLAUDE.md +23 -23
  4. data/CONTRIBUTING.md +2 -2
  5. data/README.md +13 -14
  6. data/SECURITY.md +1 -1
  7. data/docs/GUIDE.md +16 -48
  8. data/exe/rails-ai-context +15 -2
  9. data/lib/generators/rails_ai_context/install/install_generator.rb +8 -3
  10. data/lib/rails_ai_context/configuration.rb +6 -6
  11. data/lib/rails_ai_context/introspector.rb +0 -2
  12. data/lib/rails_ai_context/introspectors/view_template_introspector.rb +2 -652
  13. data/lib/rails_ai_context/legacy_cleanup.rb +60 -0
  14. data/lib/rails_ai_context/serializers/claude_rules_serializer.rb +1 -91
  15. data/lib/rails_ai_context/serializers/claude_serializer.rb +0 -2
  16. data/lib/rails_ai_context/serializers/compact_serializer_helper.rb +1 -5
  17. data/lib/rails_ai_context/serializers/copilot_instructions_serializer.rb +0 -22
  18. data/lib/rails_ai_context/serializers/copilot_serializer.rb +0 -4
  19. data/lib/rails_ai_context/serializers/cursor_rules_serializer.rb +1 -37
  20. data/lib/rails_ai_context/serializers/opencode_serializer.rb +0 -2
  21. data/lib/rails_ai_context/serializers/stack_overview_helper.rb +0 -17
  22. data/lib/rails_ai_context/serializers/tool_guide_helper.rb +8 -9
  23. data/lib/rails_ai_context/server.rb +0 -1
  24. data/lib/rails_ai_context/tasks/rails_ai_context.rake +8 -0
  25. data/lib/rails_ai_context/tools/analyze_feature.rb +0 -20
  26. data/lib/rails_ai_context/tools/get_component_catalog.rb +1 -2
  27. data/lib/rails_ai_context/tools/get_context.rb +1 -2
  28. data/lib/rails_ai_context/version.rb +1 -1
  29. data/lib/rails_ai_context/watcher.rb +7 -0
  30. data/server.json +3 -3
  31. metadata +4 -7
  32. data/lib/rails_ai_context/introspectors/accessibility_introspector.rb +0 -236
  33. data/lib/rails_ai_context/introspectors/design_token_introspector.rb +0 -365
  34. data/lib/rails_ai_context/serializers/design_system_helper.rb +0 -288
  35. data/lib/rails_ai_context/tools/get_design_system.rb +0 -544
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c780366dc085c17be730aded4bbe8548b0e5e71c5c810caed96104a9379363fa
4
- data.tar.gz: f5c46207b643df1a7dc1c5563c1d9e932f772ce5e27eb1839d9f14ddde116bd0
3
+ metadata.gz: 2fa1c4d8e9c153c1ad06c0be6824b5421638259b441f4fabc6318e2709315d4e
4
+ data.tar.gz: ecf8ae7d7cb2da0a649146940da643da4cc7c0d3b7ee955a22a0ab1964791ccf
5
5
  SHA512:
6
- metadata.gz: 934c4d703203801494a8addde164c71e56119e5701dd454574b0362d2a6d68523b6f0830654ff81eaa1d36fac7eca457374960e4e9fe54731f32431fe23ea8a4
7
- data.tar.gz: ca2bf9e27db44fb35b8d9bd984748b7fce1108a013ef7ea6ec5a01757c48187b6ce6985c529ee8bf4df7cc9abd59085da8c356b3c73052e5196b07cc9a9a3790
6
+ metadata.gz: 606d359a389873a99e361927e24a26c965491a16286ec22183e514dd6f89fcc14e2fdb1fe838b9fdde72b6cd0e6bb602196de45299afc226d5894c3ac7fdc286
7
+ data.tar.gz: 66101ebb71fd0f15229ccf480b0b280e4d01793bedbd70e2e8158ef9869799a2b29214257a1e51a37ec11da8d23f325e1b43436ab900aa0841e9f5c561996d88
data/CHANGELOG.md CHANGED
@@ -5,6 +5,44 @@ 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
+ ## [5.0.0] — 2026-04-05
9
+
10
+ ### Removed (BREAKING)
11
+
12
+ This release removes the Design & Styling surface and the Accessibility rule surface. When AI assistants consumed pre-digested design/styling context (color palettes, Tailwind class strings, canonical HTML/ERB snippets), they produced poor UI/UX output by blindly copying class strings instead of understanding visual hierarchy. The accessibility surface was asymmetric (Claude-only static rule file, no live MCP tool) and provided generic best-practice rules that didn't earn their keep.
13
+
14
+ **Design system:**
15
+ - **Removed `rails_get_design_system` MCP tool** — tool count is now **38** (was 39). Tool class `RailsAiContext::Tools::GetDesignSystem` deleted.
16
+ - **Removed `:design_tokens` introspector** — class `RailsAiContext::Introspectors::DesignTokensIntrospector` deleted.
17
+ - **Removed `ui_patterns`, `canonical_examples`, `shared_partials` keys** from `ViewTemplateIntrospector` output. The introspector now returns only `templates` and `partials`.
18
+ - **Removed `DesignSystemHelper` serializer module** — module `RailsAiContext::Serializers::DesignSystemHelper` deleted. Consumers no longer receive UI Patterns sections in rule files or compact output.
19
+ - **Removed `"design"` option** from the `include:` parameter of `rails_get_context`. Valid options are now: `schema`, `models`, `routes`, `gems`, `conventions`.
20
+
21
+ **Accessibility:**
22
+ - **Removed `:accessibility` introspector** — class `RailsAiContext::Introspectors::AccessibilityIntrospector` deleted. `ctx[:accessibility]` no longer populated.
23
+ - **Removed `discover_accessibility` cross-cut** from `rails_analyze_feature`. The tool no longer emits a `## Accessibility` section with per-feature a11y findings.
24
+ - **Removed Accessibility line** from root-file Stack Overview (no more "Accessibility: Good/OK/Needs work" label).
25
+
26
+ **Preset counts:** `:full` is now **31** (was 33); `:standard` is now **17** (was 19). Both lost `:design_tokens` and `:accessibility`.
27
+
28
+ **Legacy rule files no longer generated:**
29
+ - `.claude/rules/rails-ui-patterns.md`
30
+ - `.cursor/rules/rails-ui-patterns.mdc`
31
+ - `.github/instructions/rails-ui-patterns.instructions.md`
32
+ - `.claude/rules/rails-accessibility.md`
33
+
34
+ ### Migration notes
35
+
36
+ - **Legacy files are NOT auto-deleted.** On first run after upgrade (via `rake ai:context`, `rails-ai-context context`, install generator, or watcher), the gem detects stale `rails-ui-patterns.*` and `rails-accessibility.md` files and prompts interactively in TTY sessions, or warns (non-destructive) in non-TTY sessions. Answer `y` to remove, or delete the files manually.
37
+ - **If you depended on `rails_get_design_system`**, replace with `rails_get_component_catalog` (component-based) or read view files directly with `rails_read_file` / `rails_search_code`.
38
+ - **If you depended on `include: "design"`** in `rails_get_context`, remove that option.
39
+ - **If you depended on `ctx[:accessibility]`** (custom tools / serializers), that key is gone. Use standard a11y linters (axe-core, lighthouse) in your test suite instead.
40
+ - **The "Build or modify a view" workflow** in tool guides now starts with `rails_get_component_catalog` instead of `rails_get_design_system`.
41
+
42
+ ### Why
43
+
44
+ AI assistants that consume pre-digested summaries produce worse output than AI that reads actual source files. For design systems, class-string copying defeats the mental model required for cohesive visual hierarchy. For accessibility, generic rules ("add alt text") are universal knowledge that AI already has — the static counts didn't add actionable context, and the asymmetric distribution (Claude-only rule file, no live tool) was incoherent with the gem's charter. The gem's charter is ground truth for Rails structure (schema, associations, routes, controllers) — design-system and accessibility summaries were adjacent to that charter and actively counterproductive or inert.
45
+
8
46
  ## [4.7.0] — 2026-04-05
9
47
 
10
48
  ### Added
data/CLAUDE.md CHANGED
@@ -8,10 +8,11 @@ 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/` — 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/` — 39 MCP tools using the official mcp SDK
11
+ - `lib/rails_ai_context/introspectors/` — 31 introspectors (schema, models, routes, jobs, gems, conventions, stimulus, database_stats, controllers, views, view_templates, turbo, i18n, config, active_storage, action_text, auth, api, tests, rake_tasks, assets, devops, action_mailbox, migrations, seeds, middleware, engines, multi_database, components, performance, frontend_frameworks)
12
+ - `lib/rails_ai_context/tools/` — 38 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
- - `lib/rails_ai_context/serializers/` — Output formatters (claude, claude_rules, opencode, opencode_rules, cursor_rules, copilot, copilot_instructions, markdown, JSON, context_file_serializer, compact_serializer_helper, test_command_detection, tool_guide_helper, design_system_helper, stack_overview_helper)
14
+ - `lib/rails_ai_context/serializers/` — Output formatters (claude, claude_rules, opencode, opencode_rules, cursor_rules, copilot, copilot_instructions, markdown, JSON, context_file_serializer, compact_serializer_helper, test_command_detection, tool_guide_helper, stack_overview_helper)
15
+ - `lib/rails_ai_context/legacy_cleanup.rb` — prompts cleanup of legacy `rails-ui-patterns.*` files (v5.0.0 migration)
15
16
  - `lib/rails_ai_context/resources.rb` — MCP resources (static data AI clients read directly)
16
17
  - `lib/rails_ai_context/server.rb` — MCP server configuration (stdio + HTTP transports)
17
18
  - `lib/rails_ai_context/middleware.rb` — Rack middleware for auto-mounting MCP HTTP endpoint
@@ -35,40 +36,39 @@ structure to AI assistants via the Model Context Protocol (MCP).
35
36
  7. **Diff-aware** — context regeneration skips unchanged files
36
37
  8. **Per-assistant serializers** — each AI tool gets tailored output format
37
38
  9. **Zeitwerk autoloading** — files loaded on-demand, not all upfront
38
- 10. **Introspector presets** — `:full` (33) default, `:standard` (19) for lightweight usage
39
+ 10. **Introspector presets** — `:full` (31) default, `:standard` (17) for lightweight usage
39
40
  11. **MCP auto-discovery** — `.mcp.json` generated by install generator
40
41
  12. **Compact by default** — context files ≤150 lines, MCP tools use `detail` parameter (summary/standard/full)
41
42
  13. **Per-tool split rules** — `.claude/rules/`, `.cursor/rules/`, `.github/instructions/`
42
43
  14. **Section markers** — root file content wrapped in `<!-- BEGIN/END rails-ai-context -->` to preserve user content
43
44
  15. **generate_root_files toggle** — when false, skip root files (CLAUDE.md, etc.), only generate split rules
44
- 16. **custom_tools API** — `config.custom_tools` array lets users register additional MCP::Tool subclasses alongside the 39 built-in tools
45
- 17. **Design system extraction** — view templates analyzed for canonical examples, color palette, typography, responsive patterns, interactive states, dark mode
45
+ 16. **custom_tools API** — `config.custom_tools` array lets users register additional MCP::Tool subclasses alongside the 38 built-in tools
46
+ 17. **Legacy cleanup prompting** — v5.0.0 removed `rails_get_design_system` tool + `:design_tokens` introspector + UI pattern rule files. `LegacyCleanup.prompt_legacy_files` detects stale `rails-ui-patterns.*` files at entry points (rake, CLI, watcher, install generator) and prompts (TTY) or warns (non-TTY)
46
47
  18. **skip_tools API** — `config.skip_tools` array lets users exclude specific built-in tools (e.g. `%w[rails_security_scan]`)
47
48
  19. **Security scanning** — optional Brakeman integration via `rails_security_scan` tool (graceful degradation if not installed)
48
49
  20. **tool_mode config** — `:mcp` (default, MCP primary + CLI fallback) or `:cli` (CLI only, no MCP server needed). Selected during install.
49
- 21. **CLI tool access** — all 39 MCP tools callable from terminal: `rails ai:tool[schema]`, `rails-ai-context tool schema`. Tool name resolution: `schema` → `get_schema` → `rails_get_schema`.
50
+ 21. **CLI tool access** — all 38 MCP tools callable from terminal: `rails ai:tool[schema]`, `rails-ai-context tool schema`. Tool name resolution: `schema` → `get_schema` → `rails_get_schema`.
50
51
  22. **Shared ToolGuideHelper** — serializers use a shared module for tool reference sections, rendering MCP or CLI syntax based on `tool_mode`
51
52
  23. **Component catalog** — ViewComponent/Phlex introspection: props, slots, previews, sidecar assets, usage examples via `rails_get_component_catalog`
52
- 24. **Accessibility scanning** — ARIA attributes, semantic HTML, screen reader text, alt text, landmark roles, accessibility score via AccessibilityIntrospector
53
- 25. **Performance analysis** — N+1 query risks, missing counter_cache, missing FK indexes, eager load candidates via `rails_performance_check`
54
- 26. **Migration advisor** — migration code generation with duplicate/nonexistent column warnings, reversibility flags, table name normalization via `rails_migration_advisor`
55
- 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`
56
- 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
57
- 29. **Docs search** — bundled topic index with weighted keyword search, on-demand GitHub fetch
58
- 30. **Safe SQL queries** — defense-in-depth: regex pre-filter + SET TRANSACTION READ ONLY + timeout
59
- 31. **Log reading** — reverse file tail with level filtering and sensitive data redaction
60
- 32. **Config validation** — `http_port`, `cache_ttl`, `max_tool_response_chars`, `query_row_limit` validated on assignment with clear error messages
61
- 33. **Sensitive column redaction** — query tool redacts columns by name AND by suffix pattern (password, secret, token, key, digest, hash) to prevent alias bypass
62
- 34. **Standalone mode** — `gem install rails-ai-context && rails-ai-context init` works without Gemfile entry. CLI pre-loads gem before Rails boot, restores `$LOAD_PATH` entries stripped by `Bundler.setup`. Config from `.rails-ai-context.yml`.
63
- 35. **YAML config** — `.rails-ai-context.yml` as alternative to initializer. Supports all config options except `custom_tools` (Ruby classes) and `excluded_concerns` (regex). Precedence: initializer > YAML > defaults.
64
- 36. **Config auto-loading** — `Configuration.auto_load!` checks `configured_via_block?` flag. If initializer ran, YAML is skipped. Corrupted YAML degrades gracefully with a warning.
65
- 37. **Three install paths** — In-Gemfile (`rails generate rails_ai_context:install`), Standalone (`rails-ai-context init`), Zero config (just run `rails-ai-context serve` with defaults). Users can switch between paths freely; `.mcp.json` command is updated on re-init/re-install.
66
- 38. **Anti-Hallucination Protocol** — 6-rule verification section embedded in every generated context file (CLAUDE.md, AGENTS.md, .claude/rules/, .cursor/rules/, .github/instructions/). Targets AI failure modes: statistical priors overriding facts, pattern completion beating verification, stale context. Toggleable via `config.anti_hallucination_rules` (default: true). Rendered by `tools_anti_hallucination_section` in `tool_guide_helper.rb`, placed between intro and detail_guidance in both full and compact render methods.
53
+ 24. **Performance analysis** — N+1 query risks, missing counter_cache, missing FK indexes, eager load candidates via `rails_performance_check`
54
+ 25. **Migration advisor** — migration code generation with duplicate/nonexistent column warnings, reversibility flags, table name normalization via `rails_migration_advisor`
55
+ 26. **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`
56
+ 27. **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
57
+ 28. **Docs search** — bundled topic index with weighted keyword search, on-demand GitHub fetch
58
+ 29. **Safe SQL queries** — defense-in-depth: regex pre-filter + SET TRANSACTION READ ONLY + timeout
59
+ 30. **Log reading** — reverse file tail with level filtering and sensitive data redaction
60
+ 31. **Config validation** — `http_port`, `cache_ttl`, `max_tool_response_chars`, `query_row_limit` validated on assignment with clear error messages
61
+ 32. **Sensitive column redaction** — query tool redacts columns by name AND by suffix pattern (password, secret, token, key, digest, hash) to prevent alias bypass
62
+ 33. **Standalone mode** — `gem install rails-ai-context && rails-ai-context init` works without Gemfile entry. CLI pre-loads gem before Rails boot, restores `$LOAD_PATH` entries stripped by `Bundler.setup`. Config from `.rails-ai-context.yml`.
63
+ 34. **YAML config** — `.rails-ai-context.yml` as alternative to initializer. Supports all config options except `custom_tools` (Ruby classes) and `excluded_concerns` (regex). Precedence: initializer > YAML > defaults.
64
+ 35. **Config auto-loading** — `Configuration.auto_load!` checks `configured_via_block?` flag. If initializer ran, YAML is skipped. Corrupted YAML degrades gracefully with a warning.
65
+ 36. **Three install paths** — In-Gemfile (`rails generate rails_ai_context:install`), Standalone (`rails-ai-context init`), Zero config (just run `rails-ai-context serve` with defaults). Users can switch between paths freely; `.mcp.json` command is updated on re-init/re-install.
66
+ 37. **Anti-Hallucination Protocol** — 6-rule verification section embedded in every generated context file (CLAUDE.md, AGENTS.md, .claude/rules/, .cursor/rules/, .github/instructions/). Targets AI failure modes: statistical priors overriding facts, pattern completion beating verification, stale context. Toggleable via `config.anti_hallucination_rules` (default: true). Rendered by `tools_anti_hallucination_section` in `tool_guide_helper.rb`, placed between intro and detail_guidance in both full and compact render methods.
67
67
 
68
68
  ## Testing
69
69
 
70
70
  ```bash
71
- bundle exec rspec # Run specs (1627 examples)
71
+ bundle exec rspec # Run specs (1563 examples)
72
72
  bundle exec rubocop # Lint
73
73
  ```
74
74
 
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/ # 33 introspectors (schema, models, routes, etc.)
23
- ├── tools/ # 39 MCP tools with detail levels and pagination
22
+ ├── introspectors/ # 31 introspectors (schema, models, routes, etc.)
23
+ ├── tools/ # 38 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
@@ -66,7 +66,7 @@ rails-ai-context serve # start MCP server
66
66
 
67
67
  </div>
68
68
 
69
- Now your AI doesn't guess — it **asks your app directly.** 39 tools that query your schema, models, routes, controllers, views, and conventions on demand. It gets the right answer the first time.
69
+ Now your AI doesn't guess — it **asks your app directly.** 38 tools that query your schema, models, routes, controllers, views, and conventions on demand. It gets the right answer the first time.
70
70
 
71
71
  <br>
72
72
 
@@ -147,7 +147,7 @@ rails ai:serve
147
147
 
148
148
  ### CLI
149
149
 
150
- Same 39 tools, no server needed. Works in any terminal, any AI tool.
150
+ Same 38 tools, no server needed. Works in any terminal, any AI tool.
151
151
 
152
152
  ```bash
153
153
  rails 'ai:tool[search_code]' pattern="can_cook?" match_type=trace
@@ -215,14 +215,14 @@ rails 'ai:tool[validate]' files=app/controllers/cooks_controller.rb level=rails
215
215
  <br>
216
216
 
217
217
  ```bash
218
- # Get the design system
219
- rails 'ai:tool[design_system]' detail=standard
220
- # → your actual button classes, card patterns, color palette — copy-paste ready
221
-
222
218
  # Check existing view patterns
223
219
  rails 'ai:tool[view]' controller=dashboard
224
220
  # → templates with ivars, Turbo frames, Stimulus controllers, partial locals
225
221
 
222
+ # See existing components + usage examples
223
+ rails 'ai:tool[component_catalog]' detail=standard
224
+ # → ViewComponent/Phlex props, slots, previews, sidecar assets
225
+
226
226
  # Get Stimulus data-attributes
227
227
  rails 'ai:tool[stimulus]' controller=chart
228
228
  # → correct HTML with dashes (not underscores) + reverse view lookup
@@ -232,7 +232,7 @@ rails 'ai:tool[stimulus]' controller=chart
232
232
 
233
233
  <br>
234
234
 
235
- ## 39 Tools
235
+ ## 38 Tools
236
236
 
237
237
  Every tool is **read-only** and returns data verified against your actual app — not guesses, not training data.
238
238
 
@@ -286,7 +286,6 @@ Every tool is **read-only** and returns data verified against your actual app
286
286
  |:-----|:------------|
287
287
  | `get_view` | Templates with ivars, Turbo wiring, Stimulus refs, partial locals |
288
288
  | `get_stimulus` | HTML data-attributes (dashes!) + targets + values + actions |
289
- | `get_design_system` | Copy-paste HTML/ERB patterns for your actual components |
290
289
  | `get_partial_interface` | What locals to pass + what methods are called on them |
291
290
  | `get_turbo_map` | Broadcast → subscription wiring + mismatch warnings |
292
291
  | `get_frontend_stack` | React/Vue/Svelte/Angular, Hotwire, TypeScript, package manager |
@@ -372,7 +371,7 @@ Enabled by default. Disable with `config.anti_hallucination_rules = false` if yo
372
371
  │ Your Rails App │
373
372
  │ models + schema + routes + controllers + views + jobs │
374
373
  └────────────────────────┬────────────────────────────────┘
375
- │ introspects (33 introspectors)
374
+ │ introspects (31 introspectors)
376
375
 
377
376
  ┌─────────────────────────────────────────────────────────┐
378
377
  │ rails-ai-context │
@@ -382,7 +381,7 @@ Enabled by default. Disable with `config.anti_hallucination_rules = false` if yo
382
381
  ▼ ▼ ▼
383
382
  ┌──────────────────┐ ┌────────────┐ ┌────────────────────┐
384
383
  │ Static Files │ │ MCP Server │ │ CLI Tools │
385
- │ CLAUDE.md │ │ 39 tools │ │ Same 39 tools │
384
+ │ CLAUDE.md │ │ 38 tools │ │ Same 38 tools │
386
385
  │ .cursor/rules/ │ │ stdio/HTTP │ │ No server needed │
387
386
  │ .github/instr... │ │ .mcp.json │ │ rails 'ai:tool[X]' │
388
387
  └──────────────────┘ └────────────┘ └────────────────────┘
@@ -416,7 +415,7 @@ Both paths ask which AI tools you use and whether you want MCP or CLI mode. `.mc
416
415
  | In-Gemfile | Standalone | What it does |
417
416
  |:-----------|:-----------|:------------|
418
417
  | `rails ai:context` | `rails-ai-context context` | Generate context files |
419
- | `rails 'ai:tool[NAME]'` | `rails-ai-context tool NAME` | Run any of the 39 tools |
418
+ | `rails 'ai:tool[NAME]'` | `rails-ai-context tool NAME` | Run any of the 38 tools |
420
419
  | `rails ai:tool` | `rails-ai-context tool --list` | List all available tools |
421
420
  | `rails ai:serve` | `rails-ai-context serve` | Start MCP server (stdio) |
422
421
  | `rails ai:doctor` | `rails-ai-context doctor` | Diagnostics + AI readiness score |
@@ -431,7 +430,7 @@ Both paths ask which AI tools you use and whether you want MCP or CLI mode. `.mc
431
430
  RailsAiContext.configure do |config|
432
431
  config.ai_tools = %i[claude cursor] # Which AI tools to generate for
433
432
  config.tool_mode = :mcp # :mcp (default) or :cli
434
- config.preset = :full # :full (33 introspectors) or :standard (19)
433
+ config.preset = :full # :full (31 introspectors) or :standard (17)
435
434
  end
436
435
  ```
437
436
 
@@ -442,7 +441,7 @@ end
442
441
 
443
442
  | Option | Default | Description |
444
443
  |:-------|:--------|:------------|
445
- | `preset` | `:full` | `:full` (33 introspectors) or `:standard` (19) |
444
+ | `preset` | `:full` | `:full` (31 introspectors) or `:standard` (17) |
446
445
  | `context_mode` | `:compact` | `:compact` (150 lines) or `:full` |
447
446
  | `generate_root_files` | `true` | Set `false` for split rules only |
448
447
  | `anti_hallucination_rules` | `true` | Embed 6-rule verification protocol in generated context files |
@@ -471,7 +470,7 @@ end
471
470
  ## About
472
471
 
473
472
  Built by a Rails developer with 10+ years of production experience.<br>
474
- 1621 tests. 39 tools. 33 introspectors. Standalone or in-Gemfile.<br>
473
+ 1563 tests. 38 tools. 31 introspectors. Standalone or in-Gemfile.<br>
475
474
  MIT licensed. [Contributions welcome.](CONTRIBUTING.md)
476
475
 
477
476
  <br>
data/SECURITY.md CHANGED
@@ -30,7 +30,7 @@ If you discover a security vulnerability in rails-ai-context, please report it r
30
30
 
31
31
  ## Security Design
32
32
 
33
- - All 39 MCP tools are **read-only** and never modify your application or database.
33
+ - All 38 MCP tools are **read-only** and never modify your application or database.
34
34
  - **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.
35
35
  - **Path traversal protection** — all file-reading tools validate paths with `File.realpath()` against `Rails.root` to prevent directory escape.
36
36
  - **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
@@ -132,7 +132,7 @@ end
132
132
 
133
133
  `rails ai:context` generates **29 files** across all AI assistants:
134
134
 
135
- ### Claude Code (6 files)
135
+ ### Claude Code (5 files)
136
136
 
137
137
  | File | Purpose | Notes |
138
138
  |------|---------|-------|
@@ -140,7 +140,6 @@ end
140
140
  | `.claude/rules/rails-schema.md` | Database table listing | Auto-loaded by Claude Code alongside CLAUDE.md. |
141
141
  | `.claude/rules/rails-models.md` | Model listing with associations | Auto-loaded by Claude Code alongside CLAUDE.md. |
142
142
  | `.claude/rules/rails-context.md` | Project context and conventions | Auto-loaded by Claude Code alongside CLAUDE.md. |
143
- | `.claude/rules/rails-ui-patterns.md` | UI patterns and design tokens | Auto-loaded by Claude Code alongside CLAUDE.md. |
144
143
  | `.claude/rules/rails-mcp-tools.md` | Full MCP tool reference | Parameters, detail levels, pagination, workflow guide. |
145
144
 
146
145
  ### OpenCode (3 files)
@@ -151,17 +150,16 @@ end
151
150
  | `app/models/AGENTS.md` | Model reference | Auto-loaded by OpenCode when reading files in `app/models/`. |
152
151
  | `app/controllers/AGENTS.md` | Controller reference | Auto-loaded by OpenCode when reading files in `app/controllers/`. |
153
152
 
154
- ### Cursor (5 files)
153
+ ### Cursor (4 files)
155
154
 
156
155
  | File | Purpose | Notes |
157
156
  |------|---------|-------|
158
157
  | `.cursor/rules/rails-project.mdc` | Project overview | `alwaysApply: true` — loaded in every conversation. |
159
158
  | `.cursor/rules/rails-models.mdc` | Model reference | `globs: app/models/**/*.rb` — auto-attaches when editing models. |
160
159
  | `.cursor/rules/rails-controllers.mdc` | Controller reference | `globs: app/controllers/**/*.rb` — auto-attaches when editing controllers. |
161
- | `.cursor/rules/rails-ui-patterns.mdc` | UI patterns and design tokens | `globs: app/views/**/*.erb` — loaded when editing views. |
162
160
  | `.cursor/rules/rails-mcp-tools.mdc` | MCP tool reference | `alwaysApply: true` — always available. |
163
161
 
164
- ### GitHub Copilot (6 files)
162
+ ### GitHub Copilot (5 files)
165
163
 
166
164
  | File | Purpose | Notes |
167
165
  |------|---------|-------|
@@ -169,7 +167,6 @@ end
169
167
  | `.github/instructions/rails-models.instructions.md` | Model context | `applyTo: app/models/**/*.rb` — loaded when editing models. |
170
168
  | `.github/instructions/rails-controllers.instructions.md` | Controller context | `applyTo: app/controllers/**/*.rb` — loaded when editing controllers. |
171
169
  | `.github/instructions/rails-context.instructions.md` | Project context and conventions | `applyTo: **/*` — loaded everywhere. |
172
- | `.github/instructions/rails-ui-patterns.instructions.md` | UI patterns and design tokens | `applyTo: app/views/**/*.erb` — loaded when editing views. |
173
170
  | `.github/instructions/rails-mcp-tools.instructions.md` | MCP tool reference | `applyTo: **/*` — loaded everywhere. |
174
171
 
175
172
  ### Generic (1 file)
@@ -261,7 +258,7 @@ rails ai:context:claude # Use this instead (no quoting needed)
261
258
 
262
259
  ## CLI Tools
263
260
 
264
- All 39 MCP tools can be run directly from the terminal — no MCP server or AI client needed.
261
+ All 38 MCP tools can be run directly from the terminal — no MCP server or AI client needed.
265
262
 
266
263
  ### Rake
267
264
 
@@ -325,7 +322,7 @@ The `tool_mode` is selected during `rails generate rails_ai_context:install`.
325
322
 
326
323
  ## MCP Tools — Full Reference
327
324
 
328
- All 39 tools are **read-only** and **idempotent** — they never modify your application or database.
325
+ All 38 tools are **read-only** and **idempotent** — they never modify your application or database.
329
326
 
330
327
  ### rails_get_schema
331
328
 
@@ -707,33 +704,6 @@ rails_analyze_feature(feature: "orders")
707
704
 
708
705
  **Returns:** Markdown with sections for Models (with columns, associations, validations, scopes, enums), Controllers (with actions and filters), Routes, Services (with methods), Jobs (with queue/retry), Views (with partials and Stimulus refs), Stimulus controllers (with targets/values/actions), Tests (with counts), Related models, Concerns, Callbacks, Channels, Mailers, and Environment dependencies. Each section shows match counts.
709
706
 
710
- ### rails_get_design_system
711
-
712
- Returns the app's design system: color palette with semantic roles, component patterns with real HTML examples from actual views, typography scale, layout conventions, responsive breakpoints, and interactive state patterns.
713
-
714
- **Parameters:**
715
-
716
- | Param | Type | Description |
717
- |-------|------|-------------|
718
- | `detail` | string | `summary` (palette + components), `standard` (+ canonical page examples + design rules, default), `full` (+ typography, responsive, dark mode, animations, design tokens) |
719
-
720
- **Examples:**
721
-
722
- ```
723
- rails_get_design_system()
724
- → Color palette (primary, danger, success), component patterns (buttons, cards, inputs),
725
- canonical page examples (form page, list page), design rules
726
-
727
- rails_get_design_system(detail: "summary")
728
- → Compact: color roles + component class strings only
729
-
730
- rails_get_design_system(detail: "full")
731
- → Everything: + typography scale, responsive breakpoints, interactive states,
732
- dark mode patterns, animations, icon system, design tokens, shared partials
733
- ```
734
-
735
- **Returns:** Structured design system reference. Includes real HTML/ERB snippets from the app's actual views as canonical examples, semantic color roles (primary for CTAs, danger for destructive), component variants, typography hierarchy, spacing scale, and explicit design rules for AI to follow.
736
-
737
707
  ### rails_security_scan
738
708
 
739
709
  Runs Brakeman static security analysis on the Rails app. Detects SQL injection, XSS, mass assignment, command injection, and other vulnerabilities. Requires the `brakeman` gem — returns installation instructions if not present.
@@ -1148,7 +1118,7 @@ RailsAiContext.configure do |config|
1148
1118
  end
1149
1119
  ```
1150
1120
 
1151
- Both transports are **read-only** — they expose the same 39 tools and never modify your app.
1121
+ Both transports are **read-only** — they expose the same 38 tools and never modify your app.
1152
1122
 
1153
1123
  ---
1154
1124
 
@@ -1159,7 +1129,7 @@ Both transports are **read-only** — they expose the same 39 tools and never mo
1159
1129
  RailsAiContext.configure do |config|
1160
1130
  # --- Introspectors ---
1161
1131
 
1162
- # Presets: :full (33 introspectors, default) or :standard (19)
1132
+ # Presets: :full (31 introspectors, default) or :standard (17)
1163
1133
  config.preset = :full
1164
1134
 
1165
1135
  # Cherry-pick on top of a preset
@@ -1274,7 +1244,7 @@ end
1274
1244
  | Option | Type | Default | Description |
1275
1245
  |--------|------|---------|-------------|
1276
1246
  | `preset` | Symbol | `:full` | Introspector preset (`:full` or `:standard`) |
1277
- | `introspectors` | Array | 32 (full preset) | Which introspectors to run |
1247
+ | `introspectors` | Array | 31 (full preset) | Which introspectors to run |
1278
1248
  | `context_mode` | Symbol | `:compact` | `:compact` or `:full` |
1279
1249
  | `claude_max_lines` | Integer | `150` | Max lines for CLAUDE.md in compact mode |
1280
1250
  | `max_tool_response_chars` | Integer | `200_000` | Safety cap for MCP tool responses |
@@ -1332,7 +1302,7 @@ All split rules include an app overview file, so no context is lost when root fi
1332
1302
 
1333
1303
  ## Introspectors — Full List
1334
1304
 
1335
- ### Standard preset (19 introspectors)
1305
+ ### Standard preset (17 introspectors)
1336
1306
 
1337
1307
  Core Rails structure only. Use `config.preset = :standard` for a lighter footprint.
1338
1308
 
@@ -1349,16 +1319,14 @@ Core Rails structure only. Use `config.preset = :standard` for a lighter footpri
1349
1319
  | `migrations` | Total count, schema version, pending migrations, recent migration history with detected actions (create_table, add_column, etc.), migration statistics. |
1350
1320
  | `config` | Cache store, session store, timezone, queue adapter, mailer settings, middleware stack, initializers, credentials status, CurrentAttributes classes. |
1351
1321
  | `stimulus` | Stimulus controllers with targets, values (with types), actions, outlets, classes. Extracted from JS/TS files. |
1352
- | `view_templates` | View file contents, partial references, Stimulus data attributes, UI pattern extraction, model field usage in partials. |
1353
- | `design_tokens` | Auto-detects CSS framework (Tailwind v3/v4, Bootstrap, Sass, plain CSS) and extracts design tokens from config files and built CSS. |
1322
+ | `view_templates` | View file contents, partial references, Stimulus data attributes, model field usage in partials. |
1354
1323
  | `components` | ViewComponent/Phlex components: props, slots, previews, sidecar assets, usage examples. |
1355
1324
  | `turbo` | Turbo Frames (IDs and files), Turbo Stream templates, model broadcasts (`broadcasts_to`, `broadcasts`). |
1356
1325
  | `auth` | Devise models with modules, Rails 8 built-in auth, has_secure_password, Pundit policies, CanCanCan, CORS config, CSP config. |
1357
- | `accessibility` | ARIA attributes, semantic HTML elements, screen reader text, alt text coverage, landmark roles, accessibility score. |
1358
1326
  | `performance` | N+1 query risks, missing counter_cache, missing FK indexes, Model.all anti-patterns, eager load candidates. |
1359
1327
  | `i18n` | Default locale, available locales, locale files with key counts, backend class, parse errors. |
1360
1328
 
1361
- ### Full preset (33 introspectors) — default
1329
+ ### Full preset (31 introspectors) — default
1362
1330
 
1363
1331
  Includes all standard introspectors plus:
1364
1332
 
@@ -1481,11 +1449,11 @@ OpenCode uses **per-directory lazy-loading**: when the agent reads a file, it wa
1481
1449
 
1482
1450
  | Setup | Coverage | Notes |
1483
1451
  |-------|----------|-------|
1484
- | Rails full-stack (ERB + Hotwire) | 32/32 | All introspectors relevant |
1485
- | Rails + Inertia.js (React/Vue) | ~25/32 | Views/Turbo partially useful, backend fully covered |
1486
- | Rails API + React/Next.js SPA | ~23/32 | Schema, models, routes, API, auth, jobs — all covered |
1487
- | Rails API + mobile app | ~23/32 | Same as SPA — backend introspection is identical |
1488
- | Rails engine (mountable gem) | ~18/32 | Core introspectors (schema, models, routes, gems) work |
1452
+ | Rails full-stack (ERB + Hotwire) | 31/31 | All introspectors relevant |
1453
+ | Rails + Inertia.js (React/Vue) | ~25/31 | Views/Turbo partially useful, backend fully covered |
1454
+ | Rails API + React/Next.js SPA | ~23/31 | Schema, models, routes, API, auth, jobs — all covered |
1455
+ | Rails API + mobile app | ~23/31 | Same as SPA — backend introspection is identical |
1456
+ | Rails engine (mountable gem) | ~18/31 | Core introspectors (schema, models, routes, gems) work |
1489
1457
 
1490
1458
  Frontend introspectors (views, Turbo, Stimulus, assets) degrade gracefully — they report nothing when those features aren't present.
1491
1459
 
data/exe/rails-ai-context CHANGED
@@ -23,7 +23,7 @@ class RailsAiContextCLI < Thor
23
23
  # Let Thor pass unknown options through to ToolRunner for the tool command
24
24
  stop_on_unknown_option! :tool
25
25
 
26
- desc "tool [NAME]", "Run an MCP tool (39 available). Use --list to see all."
26
+ desc "tool [NAME]", "Run an MCP tool (38 available). Use --list to see all."
27
27
  option :json, type: :boolean, default: false, desc: "Output as JSON envelope"
28
28
  option :list, type: :boolean, default: false, desc: "List available tools"
29
29
  def tool(name = nil, *args)
@@ -74,6 +74,13 @@ class RailsAiContextCLI < Thor
74
74
  def context
75
75
  boot_rails!
76
76
 
77
+ if options[:format]
78
+ cleanup_tools = options[:format] == "all" ? nil : [ options[:format].to_sym ]
79
+ else
80
+ cleanup_tools = ::RailsAiContext.configuration.ai_tools
81
+ end
82
+ ::RailsAiContext::LegacyCleanup.prompt_legacy_files(cleanup_tools, root: Dir.pwd)
83
+
77
84
  $stderr.puts "Introspecting Rails app..."
78
85
 
79
86
  if options[:format]
@@ -151,6 +158,12 @@ class RailsAiContextCLI < Thor
151
158
  # --- Cleanup removed tools ---
152
159
  cleanup_removed_tools(previous_tools, ai_tools) if previous_tools&.any?
153
160
 
161
+ # --- One-time v5.0.0 legacy UI-pattern files cleanup prompt ---
162
+ # Boot Rails lazily: we need the gem loaded to access LegacyCleanup.
163
+ # But we avoid booting Rails here — require just the legacy_cleanup file.
164
+ require_relative "../lib/rails_ai_context/legacy_cleanup"
165
+ ::RailsAiContext::LegacyCleanup.prompt_legacy_files(ai_tools, root: Dir.pwd)
166
+
154
167
  # --- Write .rails-ai-context.yml ---
155
168
  write_yaml_config(ai_tools, tool_mode)
156
169
 
@@ -362,7 +375,7 @@ class RailsAiContextCLI < Thor
362
375
  $stderr.puts ""
363
376
  $stderr.puts "Commands:"
364
377
  $stderr.puts " rails-ai-context context # Regenerate context files"
365
- $stderr.puts " rails-ai-context tool NAME # Run any of the 39 tools"
378
+ $stderr.puts " rails-ai-context tool NAME # Run any of the 38 tools"
366
379
  if tool_mode == :mcp
367
380
  $stderr.puts " rails-ai-context serve # Start MCP server"
368
381
  end
@@ -175,7 +175,7 @@ module RailsAiContext
175
175
  # :full — all #{RailsAiContext::Configuration::PRESETS[:full].size} introspectors (default)
176
176
  # :standard — #{RailsAiContext::Configuration::PRESETS[:standard].size} core introspectors (schema, models, routes, jobs, gems,
177
177
  # conventions, controllers, tests, migrations, stimulus,
178
- # view_templates, design_tokens, config, components)
178
+ # view_templates, config, components)
179
179
  # config.preset = :full
180
180
 
181
181
  # Context mode: :compact (default, ≤150 lines) or :full (dumps everything)
@@ -429,6 +429,11 @@ module RailsAiContext
429
429
 
430
430
  require "rails_ai_context"
431
431
 
432
+ # One-time v5.0.0 legacy UI-pattern files cleanup prompt
433
+ RailsAiContext::LegacyCleanup.prompt_legacy_files(
434
+ @selected_formats, root: Rails.root
435
+ )
436
+
432
437
  @selected_formats.each do |fmt|
433
438
  begin
434
439
  result = RailsAiContext.generate_context(format: fmt)
@@ -454,9 +459,9 @@ module RailsAiContext
454
459
  say ""
455
460
  say "Commands:", :yellow
456
461
  say " rails ai:context # Regenerate context files"
457
- say " rails 'ai:tool[schema]' # Run any of the 39 tools from CLI"
462
+ say " rails 'ai:tool[schema]' # Run any of the 38 tools from CLI"
458
463
  if @tool_mode == :mcp
459
- say " rails ai:serve # Start MCP server (39 live tools)"
464
+ say " rails ai:serve # Start MCP server (38 live tools)"
460
465
  end
461
466
  say " rails ai:doctor # Check AI readiness"
462
467
  say " rails ai:inspect # Print introspection summary"
@@ -71,12 +71,12 @@ module RailsAiContext
71
71
 
72
72
  PRESETS = {
73
73
  standard: %i[schema models routes jobs gems conventions controllers tests migrations stimulus
74
- view_templates design_tokens config components
75
- turbo auth accessibility performance i18n],
76
- full: %i[schema models routes jobs gems conventions stimulus database_stats controllers views view_templates design_tokens turbo
74
+ view_templates config components
75
+ turbo auth performance i18n],
76
+ full: %i[schema models routes jobs gems conventions stimulus database_stats controllers views view_templates turbo
77
77
  i18n config active_storage action_text auth api tests rake_tasks assets
78
78
  devops action_mailbox migrations seeds middleware engines multi_database
79
- components accessibility performance frontend_frameworks]
79
+ components performance frontend_frameworks]
80
80
  }.freeze
81
81
 
82
82
  # MCP server settings
@@ -143,7 +143,7 @@ module RailsAiContext
143
143
  attr_accessor :max_file_size # Per-file read limit for tools (default: 2MB)
144
144
  attr_accessor :max_test_file_size # Test file read limit (default: 500KB)
145
145
  attr_accessor :max_schema_file_size # schema.rb / structure.sql parse limit (default: 10MB)
146
- attr_accessor :max_view_total_size # Total aggregated view content for UI patterns (default: 5MB)
146
+ attr_accessor :max_view_total_size # Total aggregated view content for template scanning (default: 5MB)
147
147
  attr_accessor :max_view_file_size # Per-view file during aggregation (default: 500KB)
148
148
  attr_accessor :max_search_results # Max search results per call (default: 100)
149
149
  attr_accessor :max_validate_files # Max files per validate call (default: 20)
@@ -151,7 +151,7 @@ module RailsAiContext
151
151
  # Additional MCP tool classes to register alongside built-in tools
152
152
  attr_accessor :custom_tools
153
153
 
154
- # Built-in tool names to skip (e.g. %w[rails_security_scan rails_get_design_system])
154
+ # Built-in tool names to skip (e.g. %w[rails_security_scan rails_query])
155
155
  attr_accessor :skip_tools
156
156
 
157
157
  # Which AI tools to generate context for (selected during install)
@@ -69,7 +69,6 @@ module RailsAiContext
69
69
  when :controllers then Introspectors::ControllerIntrospector.new(app)
70
70
  when :views then Introspectors::ViewIntrospector.new(app)
71
71
  when :view_templates then Introspectors::ViewTemplateIntrospector.new(app)
72
- when :design_tokens then Introspectors::DesignTokenIntrospector.new(app)
73
72
  when :turbo then Introspectors::TurboIntrospector.new(app)
74
73
  when :i18n then Introspectors::I18nIntrospector.new(app)
75
74
  when :config then Introspectors::ConfigIntrospector.new(app)
@@ -88,7 +87,6 @@ module RailsAiContext
88
87
  when :engines then Introspectors::EngineIntrospector.new(app)
89
88
  when :multi_database then Introspectors::MultiDatabaseIntrospector.new(app)
90
89
  when :components then Introspectors::ComponentIntrospector.new(app)
91
- when :accessibility then Introspectors::AccessibilityIntrospector.new(app)
92
90
  when :performance then Introspectors::PerformanceIntrospector.new(app)
93
91
  when :frontend_frameworks then Introspectors::FrontendFrameworkIntrospector.new(app)
94
92
  else