rails-ai-context 4.7.0 → 5.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +65 -0
- data/CLAUDE.md +23 -23
- data/CONTRIBUTING.md +2 -2
- data/README.md +14 -15
- data/SECURITY.md +4 -1
- data/docs/GUIDE.md +16 -48
- data/exe/rails-ai-context +15 -2
- data/lib/generators/rails_ai_context/install/install_generator.rb +9 -3
- data/lib/rails_ai_context/configuration.rb +6 -6
- data/lib/rails_ai_context/introspector.rb +39 -37
- data/lib/rails_ai_context/introspectors/active_storage_introspector.rb +1 -1
- data/lib/rails_ai_context/introspectors/api_introspector.rb +4 -4
- data/lib/rails_ai_context/introspectors/component_introspector.rb +5 -4
- data/lib/rails_ai_context/introspectors/convention_introspector.rb +8 -3
- data/lib/rails_ai_context/introspectors/devops_introspector.rb +4 -1
- data/lib/rails_ai_context/introspectors/gem_introspector.rb +6 -6
- data/lib/rails_ai_context/introspectors/i18n_introspector.rb +26 -6
- data/lib/rails_ai_context/introspectors/job_introspector.rb +1 -1
- data/lib/rails_ai_context/introspectors/model_introspector.rb +5 -6
- data/lib/rails_ai_context/introspectors/performance_introspector.rb +8 -8
- data/lib/rails_ai_context/introspectors/route_introspector.rb +2 -0
- data/lib/rails_ai_context/introspectors/seeds_introspector.rb +1 -1
- data/lib/rails_ai_context/introspectors/view_template_introspector.rb +2 -652
- data/lib/rails_ai_context/legacy_cleanup.rb +60 -0
- data/lib/rails_ai_context/serializers/claude_rules_serializer.rb +1 -91
- data/lib/rails_ai_context/serializers/claude_serializer.rb +0 -2
- data/lib/rails_ai_context/serializers/compact_serializer_helper.rb +1 -5
- data/lib/rails_ai_context/serializers/copilot_instructions_serializer.rb +0 -22
- data/lib/rails_ai_context/serializers/copilot_serializer.rb +0 -4
- data/lib/rails_ai_context/serializers/cursor_rules_serializer.rb +1 -37
- data/lib/rails_ai_context/serializers/opencode_serializer.rb +0 -2
- data/lib/rails_ai_context/serializers/stack_overview_helper.rb +0 -17
- data/lib/rails_ai_context/serializers/tool_guide_helper.rb +13 -9
- data/lib/rails_ai_context/server.rb +0 -1
- data/lib/rails_ai_context/tasks/rails_ai_context.rake +8 -0
- data/lib/rails_ai_context/tools/analyze_feature.rb +0 -20
- data/lib/rails_ai_context/tools/get_component_catalog.rb +1 -2
- data/lib/rails_ai_context/tools/get_context.rb +1 -2
- data/lib/rails_ai_context/version.rb +1 -1
- data/lib/rails_ai_context/watcher.rb +7 -0
- data/server.json +3 -3
- metadata +4 -7
- data/lib/rails_ai_context/introspectors/accessibility_introspector.rb +0 -236
- data/lib/rails_ai_context/introspectors/design_token_introspector.rb +0 -365
- data/lib/rails_ai_context/serializers/design_system_helper.rb +0 -288
- 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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1edfff7102dd3dd9e07d8686bb62c6017ff79492a46c36645a453b7b39a4983c
|
|
4
|
+
data.tar.gz: 2e9bb943d9986b169de0c133cb4458bb9a8678a5b32608ebf92ba80b3637c406
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ff8184662fc4c3b181d199dc0a3085935bc545cef488361b4b4596a2941630a424cff14ba175e22db244234d6a448cb6d3352863a1ff9ce3a07c28b89d2279c0
|
|
7
|
+
data.tar.gz: 79ec7f4d524a581b5dff5f67c58c1271743fe708131e5223fc91b23799e0d803561b7b713aba080662fe8f79f6e0601d0ce233a2763ab6bee1f9f50eb5ca3898
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,71 @@ 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.1.0] — 2026-04-06
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
Accuracy fixes across 8 introspectors, eliminating false positives and capturing previously-missed signals. No public API changes; all 38 MCP tools retain their contracts.
|
|
13
|
+
|
|
14
|
+
- **ApiIntrospector** — pagination detection (`detect_pagination`) was substring-matching Gemfile.lock content, producing false positives on gems that merely contain the strategy name: `happypagy`, `kaminari-i18n`, transitive `pagy` dependencies. Now uses anchored lockfile regex (`^ pagy \(`) that only matches direct top-level dependencies. Same fix applied to `kaminari`, `will_paginate`, and `graphql-pro` detection.
|
|
15
|
+
- **DevOpsIntrospector** — health-check detection (`detect_health_check`) used an unanchored word regex (`\b(?:health|up|ping|status)\b`) that matched comments, controller names, and any line containing those words. Tightened to match only quoted route strings (`"/up"`, `"/healthz"`, `"/liveness"`, etc.) or the `rails_health_check` symbol. Also newly detects `/readiness`, `/alive`, and `/healthz` routes.
|
|
16
|
+
- **PerformanceIntrospector** — schema parsing (`parse_indexed_columns`) tracked table context with a boolean-ish `current_table` variable but never cleared it on `end` lines, so `add_index` statements after a `create_table` block matched both the inner block branch AND the outer branch, producing duplicate index entries. This polluted `missing_fk_indexes` analysis. Fixed via explicit `inside_create_table` state flag with block boundary detection. Also added `m` (multiline) flag to specific-association preload regex so `.includes(...)` calls spanning multiple lines are matched.
|
|
17
|
+
- **I18nIntrospector** — `count_keys_for_locale` only read `config/locales/{locale}.yml`, missing nested locale files that are the Rails convention for gem-added translations: `config/locales/devise.en.yml`, `config/locales/en/users.yml`, `config/locales/admin/en.yml`. New `find_locale_paths` method globs all YAML under `config/locales/**/*` and selects files whose basename equals the locale, ends with `.{locale}`, or lives under a `{locale}/` subfolder. In typical Rails apps this captures 2-10x more translation keys than the previous single-file read, making `translation_coverage` percentages meaningful.
|
|
18
|
+
- **JobIntrospector** — when a job class declared `queue_as ->(job) { ... }`, `job.queue_name` returned a Proc that was then called with no arguments, crashing or returning stale values. Now returns `"dynamic"` when queue is a Proc, matching the job's actual runtime behavior (queue is resolved per-invocation).
|
|
19
|
+
- **ModelIntrospector** — source-parsed class methods in `extract_source_class_methods` emitted a spurious `"self"` entry because `def self.foo` matched both the `def self.(\w+)` branch AND the generic `def (\w+)` branch inside `class << self` tracking. Restructured as `if/elsif` so each `def` line matches exactly one pattern. Also anchored `class << self` detection with `\b` to avoid partial-word matches.
|
|
20
|
+
- **RouteIntrospector** — `call` method could raise if `Rails.application.routes` was not yet loaded or a sub-method failed mid-extraction. Added a top-level rescue that returns `{ error: msg }`, matching the error contract used by every other introspector.
|
|
21
|
+
- **SeedsIntrospector** — `has_ordering` regex (`load.*order|require.*order|seeds.*\d+`) matched unrelated code like `require 'order'` or `seeds 001` in comments. Tightened to match actual ordering patterns: `Dir[...*.rb].sort`, `load "seeds/NN_foo.rb"`, `require_relative "seeds/NN_foo"`.
|
|
22
|
+
|
|
23
|
+
### Performance
|
|
24
|
+
|
|
25
|
+
- **ConventionIntrospector** — `gem_present?` was reading `Gemfile.lock` from disk 15 times per introspection pass (once per notable gem check). Memoized into a single read: **-93% I/O** (15 reads → 1 read). ~60% faster on typical apps.
|
|
26
|
+
- **ComponentIntrospector** — `build_summary` called `extract_components` again after `call` already computed it, doubling the filesystem walk and component parsing work. Now passes the result through: **-50% work**. ~50% faster.
|
|
27
|
+
- **GemIntrospector** — `categorize_gems(specs)` internally called `detect_notable_gems(specs)` after `call` had already called it, duplicating gem-list iteration and category lookup. Now accepts the notable-gem result directly: **-50% work**.
|
|
28
|
+
- **ActiveStorageIntrospector** — `uses_direct_uploads?` globbed `**/*` across `app/views` + `app/javascript`, reading every binary, image, font, and asset in those trees. Scoped to 9 relevant extensions (`erb,haml,slim,js,ts,jsx,tsx,mjs,rb`), avoiding wasteful I/O on irrelevant files.
|
|
29
|
+
- **Total**: ~14% cumulative speedup across all 12 modified introspectors on a medium-sized Rails app (23.66ms → 20.33ms).
|
|
30
|
+
|
|
31
|
+
### Why
|
|
32
|
+
|
|
33
|
+
Introspector output feeds every MCP tool response, every context file, and every rule file this gem generates. Silent inaccuracies (false-positive pagination detection, missed locale files, phantom duplicate indexes) compound: AI assistants make decisions based on this data, and incorrect data produces incorrect code suggestions. These fixes tighten the accuracy floor without changing any public interface.
|
|
34
|
+
|
|
35
|
+
## [5.0.0] — 2026-04-05
|
|
36
|
+
|
|
37
|
+
### Removed (BREAKING)
|
|
38
|
+
|
|
39
|
+
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.
|
|
40
|
+
|
|
41
|
+
**Design system:**
|
|
42
|
+
- **Removed `rails_get_design_system` MCP tool** — tool count is now **38** (was 39). Tool class `RailsAiContext::Tools::GetDesignSystem` deleted.
|
|
43
|
+
- **Removed `:design_tokens` introspector** — class `RailsAiContext::Introspectors::DesignTokensIntrospector` deleted.
|
|
44
|
+
- **Removed `ui_patterns`, `canonical_examples`, `shared_partials` keys** from `ViewTemplateIntrospector` output. The introspector now returns only `templates` and `partials`.
|
|
45
|
+
- **Removed `DesignSystemHelper` serializer module** — module `RailsAiContext::Serializers::DesignSystemHelper` deleted. Consumers no longer receive UI Patterns sections in rule files or compact output.
|
|
46
|
+
- **Removed `"design"` option** from the `include:` parameter of `rails_get_context`. Valid options are now: `schema`, `models`, `routes`, `gems`, `conventions`.
|
|
47
|
+
|
|
48
|
+
**Accessibility:**
|
|
49
|
+
- **Removed `:accessibility` introspector** — class `RailsAiContext::Introspectors::AccessibilityIntrospector` deleted. `ctx[:accessibility]` no longer populated.
|
|
50
|
+
- **Removed `discover_accessibility` cross-cut** from `rails_analyze_feature`. The tool no longer emits a `## Accessibility` section with per-feature a11y findings.
|
|
51
|
+
- **Removed Accessibility line** from root-file Stack Overview (no more "Accessibility: Good/OK/Needs work" label).
|
|
52
|
+
|
|
53
|
+
**Preset counts:** `:full` is now **31** (was 33); `:standard` is now **17** (was 19). Both lost `:design_tokens` and `:accessibility`.
|
|
54
|
+
|
|
55
|
+
**Legacy rule files no longer generated:**
|
|
56
|
+
- `.claude/rules/rails-ui-patterns.md`
|
|
57
|
+
- `.cursor/rules/rails-ui-patterns.mdc`
|
|
58
|
+
- `.github/instructions/rails-ui-patterns.instructions.md`
|
|
59
|
+
- `.claude/rules/rails-accessibility.md`
|
|
60
|
+
|
|
61
|
+
### Migration notes
|
|
62
|
+
|
|
63
|
+
- **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.
|
|
64
|
+
- **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`.
|
|
65
|
+
- **If you depended on `include: "design"`** in `rails_get_context`, remove that option.
|
|
66
|
+
- **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.
|
|
67
|
+
- **The "Build or modify a view" workflow** in tool guides now starts with `rails_get_component_catalog` instead of `rails_get_design_system`.
|
|
68
|
+
|
|
69
|
+
### Why
|
|
70
|
+
|
|
71
|
+
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.
|
|
72
|
+
|
|
8
73
|
## [4.7.0] — 2026-04-05
|
|
9
74
|
|
|
10
75
|
### 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/` —
|
|
12
|
-
- `lib/rails_ai_context/tools/` —
|
|
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,
|
|
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` (
|
|
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
|
|
45
|
-
17. **
|
|
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
|
|
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. **
|
|
53
|
-
25. **
|
|
54
|
-
26. **
|
|
55
|
-
27. **
|
|
56
|
-
28. **
|
|
57
|
-
29. **
|
|
58
|
-
30. **
|
|
59
|
-
31. **
|
|
60
|
-
32. **
|
|
61
|
-
33. **
|
|
62
|
-
34. **
|
|
63
|
-
35. **
|
|
64
|
-
36. **
|
|
65
|
-
37. **
|
|
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 (
|
|
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/ #
|
|
23
|
-
├── tools/ #
|
|
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
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
[](https://registry.modelcontextprotocol.io)
|
|
20
20
|
[](https://github.com/crisnahine/rails-ai-context)
|
|
21
21
|
[](https://github.com/crisnahine/rails-ai-context)
|
|
22
|
-
[](https://github.com/crisnahine/rails-ai-context/actions)
|
|
23
23
|
[](LICENSE)
|
|
24
24
|
|
|
25
25
|
</div>
|
|
@@ -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.**
|
|
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
|
|
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
|
-
##
|
|
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 (
|
|
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 │ │
|
|
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
|
|
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 (
|
|
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` (
|
|
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
|
-
|
|
473
|
+
1565 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
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
| Version | Supported |
|
|
6
6
|
|---------|--------------------|
|
|
7
|
+
| 5.1.x | :white_check_mark: |
|
|
8
|
+
| 5.0.x | :white_check_mark: |
|
|
9
|
+
| 4.7.x | :white_check_mark: |
|
|
7
10
|
| 4.6.x | :white_check_mark: |
|
|
8
11
|
| 4.5.x | :white_check_mark: |
|
|
9
12
|
| 4.4.x | :white_check_mark: |
|
|
@@ -30,7 +33,7 @@ If you discover a security vulnerability in rails-ai-context, please report it r
|
|
|
30
33
|
|
|
31
34
|
## Security Design
|
|
32
35
|
|
|
33
|
-
- All
|
|
36
|
+
- All 38 MCP tools are **read-only** and never modify your application or database.
|
|
34
37
|
- **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
38
|
- **Path traversal protection** — all file-reading tools validate paths with `File.realpath()` against `Rails.root` to prevent directory escape.
|
|
36
39
|
- **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 (
|
|
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 (
|
|
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 (
|
|
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
|
|
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
|
|
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
|
|
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 (
|
|
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 |
|
|
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 (
|
|
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,
|
|
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 (
|
|
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) |
|
|
1485
|
-
| Rails + Inertia.js (React/Vue) | ~25/
|
|
1486
|
-
| Rails API + React/Next.js SPA | ~23/
|
|
1487
|
-
| Rails API + mobile app | ~23/
|
|
1488
|
-
| Rails engine (mountable gem) | ~18/
|
|
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 (
|
|
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
|
|
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,
|
|
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,10 @@ module RailsAiContext
|
|
|
454
459
|
say ""
|
|
455
460
|
say "Commands:", :yellow
|
|
456
461
|
say " rails ai:context # Regenerate context files"
|
|
457
|
-
|
|
462
|
+
tool_count = RailsAiContext::Server::TOOLS.size
|
|
463
|
+
say " rails 'ai:tool[schema]' # Run any of the #{tool_count} tools from CLI"
|
|
458
464
|
if @tool_mode == :mcp
|
|
459
|
-
say " rails ai:serve # Start MCP server (
|
|
465
|
+
say " rails ai:serve # Start MCP server (#{tool_count} live tools)"
|
|
460
466
|
end
|
|
461
467
|
say " rails ai:doctor # Check AI readiness"
|
|
462
468
|
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
|
|
75
|
-
turbo auth
|
|
76
|
-
full: %i[schema models routes jobs gems conventions stimulus database_stats controllers views view_templates
|
|
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
|
|
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
|
|
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
|
|
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)
|