rails-ai-context 0.5.0 → 0.5.1
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 +19 -0
- data/CLAUDE.md +10 -4
- data/CODE_OF_CONDUCT.md +44 -0
- data/CONTRIBUTING.md +4 -5
- data/README.md +18 -9
- data/SECURITY.md +28 -0
- data/demo.gif +0 -0
- data/demo.tape +16 -0
- data/demo_script.sh +58 -0
- data/lib/generators/rails_ai_context/install/install_generator.rb +31 -11
- data/lib/rails_ai_context/configuration.rb +13 -2
- data/lib/rails_ai_context/version.rb +1 -1
- data/lib/rails_ai_context.rb +7 -60
- metadata +20 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ccfa985d6c8909c3c3aac2bd7a9a2e06937a9b6b0ccf0b68b529e664d0a47766
|
|
4
|
+
data.tar.gz: e76ba121b0be84a212f1e8d63eea60d9cbde88c3cc2df795ac182980c32e4268
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a2db336162ecba283d739840fa4709ceb68859361c055821c657bd4f0e1f49e19a72d7dc0665e1e7eeb3f5a64ecfdfaf030f71c4157210da45da48b3ca363bce
|
|
7
|
+
data.tar.gz: 9c95fb8b53101af641ae6340dd0cd04219984f70ec87ed676b8473b301028343796304c79651f844416b2d909c0e203bcb1bf90a3217524c1400c2465ff3a2df
|
data/CHANGELOG.md
CHANGED
|
@@ -5,13 +5,32 @@ 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
|
+
## [0.5.1] - 2026-03-18
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **Documentation updates** — Updated CONTRIBUTING.md, CHANGELOG.md, and CLAUDE.md to reflect Zeitwerk autoloading, introspector presets, and `.mcp.json` auto-discovery changes
|
|
13
|
+
|
|
8
14
|
## [0.5.0] - 2026-03-18
|
|
9
15
|
|
|
10
16
|
### Added
|
|
11
17
|
|
|
18
|
+
- **Introspector presets** — `:standard` (8 core introspectors, fast) and `:full` (all 21, thorough) via `config.preset = :standard`
|
|
19
|
+
- **`.mcp.json` auto-discovery** — Install generator creates `.mcp.json` so Claude Code and Cursor auto-detect the MCP server with zero manual config
|
|
20
|
+
- **Zeitwerk autoloading** — Replaced 47 `require_relative` calls with Zeitwerk for faster boot and conventional file loading
|
|
12
21
|
- **Automated release workflow** — GitHub Actions publishes to RubyGems via trusted publishing when a version tag is pushed
|
|
13
22
|
- **Version consistency check** — Release workflow verifies git tag matches `version.rb` before publishing
|
|
14
23
|
- **Auto GitHub Release** — Release notes extracted from CHANGELOG.md automatically
|
|
24
|
+
- **Dependabot** — Weekly automated dependency and GitHub Actions updates
|
|
25
|
+
- **README demo GIF** — Animated terminal recording showing install, doctor, and context generation
|
|
26
|
+
- **SECURITY.md** — Security policy with supported versions and reporting process
|
|
27
|
+
- **CODE_OF_CONDUCT.md** — Contributor Covenant v2.1
|
|
28
|
+
- **GitHub repo topics** — Added discoverability keywords (rails, mcp, ai, etc.)
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
|
|
32
|
+
- Default introspectors reduced from 21 to 8 (`:standard` preset) for faster boot; use `config.preset = :full` for all 21
|
|
33
|
+
- New files auto-loaded by Zeitwerk — no manual `require_relative` needed when adding introspectors or tools
|
|
15
34
|
|
|
16
35
|
## [0.4.0] - 2026-03-18
|
|
17
36
|
|
data/CLAUDE.md
CHANGED
|
@@ -5,10 +5,11 @@ structure to AI assistants via the Model Context Protocol (MCP).
|
|
|
5
5
|
|
|
6
6
|
## Architecture
|
|
7
7
|
|
|
8
|
-
- `lib/rails_ai_context.rb` — Main entry point, public API
|
|
8
|
+
- `lib/rails_ai_context.rb` — Main entry point, public API (Zeitwerk autoloaded)
|
|
9
|
+
- `lib/rails_ai_context/configuration.rb` — User-facing config with presets (:standard, :full)
|
|
9
10
|
- `lib/rails_ai_context/introspector.rb` — Orchestrates sub-introspectors
|
|
10
|
-
- `lib/rails_ai_context/introspectors/` —
|
|
11
|
-
- `lib/rails_ai_context/tools/` — MCP tools using the official mcp SDK
|
|
11
|
+
- `lib/rails_ai_context/introspectors/` — 22 introspectors (schema, models, routes, jobs, gems, conventions, stimulus, database_stats, controllers, views, turbo, i18n, config, active_storage, action_text, auth, api, tests, rake_tasks, assets, devops, action_mailbox)
|
|
12
|
+
- `lib/rails_ai_context/tools/` — 9 MCP tools using the official mcp SDK
|
|
12
13
|
- `lib/rails_ai_context/serializers/` — Output formatters (claude, rules, copilot, markdown, JSON)
|
|
13
14
|
- `lib/rails_ai_context/resources.rb` — MCP resources (static data AI clients read directly)
|
|
14
15
|
- `lib/rails_ai_context/server.rb` — MCP server configuration (stdio + HTTP transports)
|
|
@@ -17,6 +18,7 @@ structure to AI assistants via the Model Context Protocol (MCP).
|
|
|
17
18
|
- `lib/rails_ai_context/doctor.rb` — Diagnostic checks and AI readiness scoring
|
|
18
19
|
- `lib/rails_ai_context/watcher.rb` — File watcher for auto-regenerating context files
|
|
19
20
|
- `lib/rails_ai_context/engine.rb` — Rails Engine for auto-integration
|
|
21
|
+
- `lib/generators/rails_ai_context/install/` — Install generator (creates .mcp.json, initializer, context files)
|
|
20
22
|
|
|
21
23
|
## Key Design Decisions
|
|
22
24
|
|
|
@@ -27,11 +29,14 @@ structure to AI assistants via the Model Context Protocol (MCP).
|
|
|
27
29
|
5. **Dual output** — static files (CLAUDE.md) + live MCP server (stdio/HTTP)
|
|
28
30
|
6. **Diff-aware** — context regeneration skips unchanged files
|
|
29
31
|
7. **Per-assistant serializers** — each AI tool gets tailored output format
|
|
32
|
+
8. **Zeitwerk autoloading** — files loaded on-demand, not all upfront
|
|
33
|
+
9. **Introspector presets** — `:standard` (8 core) default, `:full` (21) for power users
|
|
34
|
+
10. **MCP auto-discovery** — `.mcp.json` generated by install generator
|
|
30
35
|
|
|
31
36
|
## Testing
|
|
32
37
|
|
|
33
38
|
```bash
|
|
34
|
-
bundle exec rspec # Run specs
|
|
39
|
+
bundle exec rspec # Run specs (253 examples)
|
|
35
40
|
bundle exec rubocop # Lint
|
|
36
41
|
```
|
|
37
42
|
|
|
@@ -45,3 +50,4 @@ Uses combustion gem for testing Rails engine behavior in isolation.
|
|
|
45
50
|
- MCP tools return `MCP::Tool::Response` objects per SDK convention
|
|
46
51
|
- All tools prefixed with `rails_` per MCP naming best practices
|
|
47
52
|
- `generate_context` returns `{ written: [], skipped: [] }` hash
|
|
53
|
+
- Zeitwerk autoloads all files — no `require_relative` needed for new classes
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
|
10
|
+
identity and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment:
|
|
18
|
+
|
|
19
|
+
* Using welcoming and inclusive language
|
|
20
|
+
* Being respectful of differing viewpoints and experiences
|
|
21
|
+
* Gracefully accepting constructive criticism
|
|
22
|
+
* Focusing on what is best for the community
|
|
23
|
+
* Showing empathy towards other community members
|
|
24
|
+
|
|
25
|
+
Examples of unacceptable behavior:
|
|
26
|
+
|
|
27
|
+
* The use of sexualized language or imagery, and sexual attention or advances of any kind
|
|
28
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
29
|
+
* Public or private harassment
|
|
30
|
+
* Publishing others' private information without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
|
32
|
+
|
|
33
|
+
## Enforcement
|
|
34
|
+
|
|
35
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
36
|
+
reported to the project maintainer at **crisjosephnahine@gmail.com**.
|
|
37
|
+
|
|
38
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
39
|
+
|
|
40
|
+
## Attribution
|
|
41
|
+
|
|
42
|
+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org),
|
|
43
|
+
version 2.1, available at
|
|
44
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html).
|
data/CONTRIBUTING.md
CHANGED
|
@@ -28,20 +28,19 @@ lib/rails_ai_context/
|
|
|
28
28
|
|
|
29
29
|
## Adding a New Introspector
|
|
30
30
|
|
|
31
|
-
1. Create `lib/rails_ai_context/introspectors/your_introspector.rb`
|
|
31
|
+
1. Create `lib/rails_ai_context/introspectors/your_introspector.rb` (auto-loaded by Zeitwerk)
|
|
32
32
|
2. Implement `#initialize(app)` and `#call` → returns a Hash (never raises)
|
|
33
33
|
3. Register it in `lib/rails_ai_context/introspector.rb` (the `INTROSPECTOR_MAP`)
|
|
34
|
-
4. Add the key to `Configuration
|
|
34
|
+
4. Add the key to the appropriate preset(s) in `Configuration::PRESETS` (`:standard` for core, `:full` for all)
|
|
35
35
|
5. Write specs in `spec/lib/rails_ai_context/your_introspector_spec.rb`
|
|
36
36
|
|
|
37
37
|
## Adding a New MCP Tool
|
|
38
38
|
|
|
39
|
-
1. Create `lib/rails_ai_context/tools/your_tool.rb` inheriting from `BaseTool`
|
|
39
|
+
1. Create `lib/rails_ai_context/tools/your_tool.rb` inheriting from `BaseTool` (auto-loaded by Zeitwerk)
|
|
40
40
|
2. Define `tool_name`, `description`, `input_schema`, and `annotations`
|
|
41
41
|
3. Implement `def self.call(...)` returning `text_response(string)`
|
|
42
42
|
4. Register in `Server::TOOLS`
|
|
43
|
-
5.
|
|
44
|
-
6. Write specs in `spec/lib/rails_ai_context/tools/your_tool_spec.rb`
|
|
43
|
+
5. Write specs in `spec/lib/rails_ai_context/tools/your_tool_spec.rb`
|
|
45
44
|
|
|
46
45
|
## Code Style
|
|
47
46
|
|
data/README.md
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
[](https://github.com/crisnahine/rails-ai-context/actions)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
|
|
8
|
+

|
|
9
|
+
|
|
8
10
|
`rails-ai-context` automatically introspects your Rails application and exposes your models, routes, schema, controllers, views, jobs, gems, auth, API, tests, config, and conventions to AI assistants through the [Model Context Protocol (MCP)](https://modelcontextprotocol.io).
|
|
9
11
|
|
|
10
12
|
**Your AI assistant instantly understands your entire Rails app. No configuration. No manual tool definitions. Just `bundle add` and go.**
|
|
@@ -67,15 +69,17 @@ This creates:
|
|
|
67
69
|
|
|
68
70
|
Each file is tailored to the AI assistant's preferred format. **Commit these files.** Your entire team gets smarter AI assistance.
|
|
69
71
|
|
|
70
|
-
### 3.
|
|
72
|
+
### 3. MCP Server (Auto-discovered)
|
|
73
|
+
|
|
74
|
+
The install generator creates a `.mcp.json` file that Claude Code and Cursor auto-detect — **no manual config needed**. Just open your project.
|
|
71
75
|
|
|
72
|
-
|
|
76
|
+
To start manually:
|
|
73
77
|
|
|
74
78
|
```bash
|
|
75
79
|
rails ai:serve
|
|
76
80
|
```
|
|
77
81
|
|
|
78
|
-
Or
|
|
82
|
+
Or configure manually in `~/.claude/claude_desktop_config.json`:
|
|
79
83
|
|
|
80
84
|
```json
|
|
81
85
|
{
|
|
@@ -163,6 +167,14 @@ In addition to tools, the gem registers MCP resources that AI clients can read d
|
|
|
163
167
|
```ruby
|
|
164
168
|
# config/initializers/rails_ai_context.rb
|
|
165
169
|
RailsAiContext.configure do |config|
|
|
170
|
+
# Introspector presets:
|
|
171
|
+
# :standard — 8 core introspectors (default, fast)
|
|
172
|
+
# :full — all 21 introspectors (thorough)
|
|
173
|
+
config.preset = :standard
|
|
174
|
+
|
|
175
|
+
# Or cherry-pick on top of a preset:
|
|
176
|
+
# config.introspectors += %i[views turbo auth api]
|
|
177
|
+
|
|
166
178
|
# Exclude internal models from introspection
|
|
167
179
|
config.excluded_models += %w[AdminUser InternalAuditLog]
|
|
168
180
|
|
|
@@ -170,15 +182,12 @@ RailsAiContext.configure do |config|
|
|
|
170
182
|
config.excluded_paths += %w[vendor/bundle]
|
|
171
183
|
|
|
172
184
|
# Auto-mount HTTP MCP endpoint (for remote AI clients)
|
|
173
|
-
config.auto_mount = true
|
|
174
|
-
config.http_path = "/mcp"
|
|
175
|
-
config.http_port = 6029
|
|
185
|
+
# config.auto_mount = true
|
|
186
|
+
# config.http_path = "/mcp"
|
|
187
|
+
# config.http_port = 6029
|
|
176
188
|
|
|
177
189
|
# Cache TTL for MCP tool responses (seconds)
|
|
178
190
|
config.cache_ttl = 30
|
|
179
|
-
|
|
180
|
-
# Enable Postgres row count stats (opt-in)
|
|
181
|
-
# config.introspectors += [:database_stats]
|
|
182
191
|
end
|
|
183
192
|
```
|
|
184
193
|
|
data/SECURITY.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
| Version | Supported |
|
|
6
|
+
|---------|--------------------|
|
|
7
|
+
| 0.5.x | :white_check_mark: |
|
|
8
|
+
| < 0.5 | :x: |
|
|
9
|
+
|
|
10
|
+
## Reporting a Vulnerability
|
|
11
|
+
|
|
12
|
+
If you discover a security vulnerability in rails-ai-context, please report it responsibly:
|
|
13
|
+
|
|
14
|
+
1. **Do NOT open a public GitHub issue.**
|
|
15
|
+
2. Email **crisjosephnahine@gmail.com** with:
|
|
16
|
+
- Description of the vulnerability
|
|
17
|
+
- Steps to reproduce
|
|
18
|
+
- Potential impact
|
|
19
|
+
3. You will receive a response within 48 hours.
|
|
20
|
+
4. A fix will be released as a patch version as soon as possible.
|
|
21
|
+
|
|
22
|
+
## Security Design
|
|
23
|
+
|
|
24
|
+
- All MCP tools are **read-only** and never modify your application or database.
|
|
25
|
+
- Code search (`rails_search_code`) uses `Open3.capture2` with array arguments to prevent shell injection.
|
|
26
|
+
- File paths are validated against path traversal attacks.
|
|
27
|
+
- Credentials and secret values are **never** exposed — only key names are introspected.
|
|
28
|
+
- The gem does not make any outbound network requests.
|
data/demo.gif
ADDED
|
Binary file
|
data/demo.tape
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# VHS demo — install: https://github.com/charmbracelet/vhs
|
|
2
|
+
# Run: vhs demo.tape
|
|
3
|
+
|
|
4
|
+
Output demo.gif
|
|
5
|
+
|
|
6
|
+
Set FontSize 15
|
|
7
|
+
Set Width 820
|
|
8
|
+
Set Height 580
|
|
9
|
+
Set Theme "Catppuccin Mocha"
|
|
10
|
+
Set Padding 20
|
|
11
|
+
Set Shell bash
|
|
12
|
+
Set TypingSpeed 0
|
|
13
|
+
|
|
14
|
+
Type "bash demo_script.sh"
|
|
15
|
+
Enter
|
|
16
|
+
Sleep 12s
|
data/demo_script.sh
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Simulated demo output for VHS recording
|
|
3
|
+
clear
|
|
4
|
+
|
|
5
|
+
printf '\033[1;36m$\033[0m bundle add rails-ai-context\n'
|
|
6
|
+
sleep 0.3
|
|
7
|
+
echo 'Fetching gem metadata from https://rubygems.org...'
|
|
8
|
+
sleep 0.3
|
|
9
|
+
echo 'Resolving dependencies...'
|
|
10
|
+
sleep 0.3
|
|
11
|
+
echo 'Installing rails-ai-context 0.5.1'
|
|
12
|
+
echo ''
|
|
13
|
+
sleep 1
|
|
14
|
+
|
|
15
|
+
printf '\033[1;36m$\033[0m rails ai:doctor\n'
|
|
16
|
+
echo ''
|
|
17
|
+
sleep 0.2
|
|
18
|
+
echo ' ✅ Schema db/schema.rb found (14 tables)'
|
|
19
|
+
sleep 0.15
|
|
20
|
+
echo ' ✅ Models 12 model files detected'
|
|
21
|
+
sleep 0.15
|
|
22
|
+
echo ' ✅ Routes 48 routes mapped'
|
|
23
|
+
sleep 0.15
|
|
24
|
+
echo ' ✅ Controllers 8 controllers with actions'
|
|
25
|
+
sleep 0.15
|
|
26
|
+
echo ' ✅ Gems 6 notable gems recognized'
|
|
27
|
+
sleep 0.15
|
|
28
|
+
echo ' ✅ Tests RSpec with 142 examples'
|
|
29
|
+
sleep 0.15
|
|
30
|
+
echo ' ✅ Views 34 templates, 12 partials'
|
|
31
|
+
sleep 0.15
|
|
32
|
+
echo ' ⚠️ I18n Only 1 locale (en)'
|
|
33
|
+
sleep 0.15
|
|
34
|
+
echo ' ✅ Config Cache: redis, Sessions: cookie'
|
|
35
|
+
sleep 0.15
|
|
36
|
+
echo ' ✅ MCP Server Ready (stdio transport)'
|
|
37
|
+
sleep 0.15
|
|
38
|
+
echo ' ✅ Ripgrep Installed (fast code search)'
|
|
39
|
+
echo ''
|
|
40
|
+
sleep 0.3
|
|
41
|
+
printf ' \033[1;32mAI Readiness Score: 92/100\033[0m\n'
|
|
42
|
+
echo ''
|
|
43
|
+
sleep 1
|
|
44
|
+
|
|
45
|
+
printf '\033[1;36m$\033[0m rails ai:context\n'
|
|
46
|
+
echo ''
|
|
47
|
+
sleep 0.2
|
|
48
|
+
echo ' ✅ CLAUDE.md'
|
|
49
|
+
sleep 0.15
|
|
50
|
+
echo ' ✅ .cursorrules'
|
|
51
|
+
sleep 0.15
|
|
52
|
+
echo ' ✅ .windsurfrules'
|
|
53
|
+
sleep 0.15
|
|
54
|
+
echo ' ✅ .github/copilot-instructions.md'
|
|
55
|
+
echo ''
|
|
56
|
+
sleep 0.3
|
|
57
|
+
printf ' \033[1;32mDone! Your AI assistants now understand your Rails app.\033[0m\n'
|
|
58
|
+
sleep 2
|
|
@@ -1,31 +1,50 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
3
5
|
module RailsAiContext
|
|
4
6
|
module Generators
|
|
5
7
|
class InstallGenerator < Rails::Generators::Base
|
|
6
8
|
source_root File.expand_path("templates", __dir__)
|
|
7
9
|
|
|
8
|
-
desc "Install rails-ai-context: creates initializer and generates initial context files."
|
|
10
|
+
desc "Install rails-ai-context: creates initializer, MCP config, and generates initial context files."
|
|
11
|
+
|
|
12
|
+
def create_mcp_config
|
|
13
|
+
create_file ".mcp.json", JSON.pretty_generate({
|
|
14
|
+
mcpServers: {
|
|
15
|
+
"rails-ai-context" => {
|
|
16
|
+
command: "bundle",
|
|
17
|
+
args: [ "exec", "rails", "ai:serve" ]
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}) + "\n"
|
|
21
|
+
|
|
22
|
+
say "Created .mcp.json (auto-discovered by Claude Code, Cursor, etc.)", :green
|
|
23
|
+
end
|
|
9
24
|
|
|
10
25
|
def create_initializer
|
|
11
26
|
create_file "config/initializers/rails_ai_context.rb", <<~RUBY
|
|
12
27
|
# frozen_string_literal: true
|
|
13
28
|
|
|
14
29
|
RailsAiContext.configure do |config|
|
|
15
|
-
#
|
|
16
|
-
#
|
|
30
|
+
# Introspector preset:
|
|
31
|
+
# :standard — 8 core introspectors (schema, models, routes, jobs, gems, conventions, controllers, tests)
|
|
32
|
+
# :full — all 21 introspectors (adds views, turbo, auth, API, config, assets, devops, etc.)
|
|
33
|
+
# config.preset = :standard
|
|
17
34
|
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
# config.auto_mount = false
|
|
21
|
-
# config.http_path = "/mcp"
|
|
22
|
-
# config.http_port = 6029
|
|
35
|
+
# Or cherry-pick individual introspectors:
|
|
36
|
+
# config.introspectors += %i[views turbo auth api]
|
|
23
37
|
|
|
24
38
|
# Models to exclude from introspection
|
|
25
39
|
# config.excluded_models += %w[AdminUser InternalThing]
|
|
26
40
|
|
|
27
41
|
# Paths to exclude from code search
|
|
28
42
|
# config.excluded_paths += %w[vendor/bundle]
|
|
43
|
+
|
|
44
|
+
# Auto-mount HTTP MCP endpoint at /mcp
|
|
45
|
+
# config.auto_mount = false
|
|
46
|
+
# config.http_path = "/mcp"
|
|
47
|
+
# config.http_port = 6029
|
|
29
48
|
end
|
|
30
49
|
RUBY
|
|
31
50
|
|
|
@@ -83,10 +102,11 @@ module RailsAiContext
|
|
|
83
102
|
say " Windsurf → .windsurfrules (rails ai:context:windsurf)"
|
|
84
103
|
say " GitHub Copilot → .github/copilot-instructions.md (rails ai:context:copilot)"
|
|
85
104
|
say ""
|
|
86
|
-
say "
|
|
87
|
-
say
|
|
105
|
+
say "MCP auto-discovery:", :yellow
|
|
106
|
+
say " .mcp.json is auto-detected by Claude Code and Cursor."
|
|
107
|
+
say " No manual MCP config needed — just open your project."
|
|
88
108
|
say ""
|
|
89
|
-
say "Commit CLAUDE.md and .
|
|
109
|
+
say "Commit CLAUDE.md, .cursorrules, and .mcp.json so your team benefits!", :green
|
|
90
110
|
end
|
|
91
111
|
end
|
|
92
112
|
end
|
|
@@ -2,10 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
module RailsAiContext
|
|
4
4
|
class Configuration
|
|
5
|
+
PRESETS = {
|
|
6
|
+
standard: %i[schema models routes jobs gems conventions controllers tests],
|
|
7
|
+
full: %i[schema models routes jobs gems conventions stimulus controllers views turbo i18n config active_storage action_text auth api tests rake_tasks assets devops action_mailbox]
|
|
8
|
+
}.freeze
|
|
9
|
+
|
|
5
10
|
# MCP server settings
|
|
6
11
|
attr_accessor :server_name, :server_version
|
|
7
12
|
|
|
8
|
-
# Which introspectors to run
|
|
13
|
+
# Which introspectors to run
|
|
9
14
|
attr_accessor :introspectors
|
|
10
15
|
|
|
11
16
|
# Paths to exclude from code search
|
|
@@ -32,7 +37,7 @@ module RailsAiContext
|
|
|
32
37
|
def initialize
|
|
33
38
|
@server_name = "rails-ai-context"
|
|
34
39
|
@server_version = RailsAiContext::VERSION
|
|
35
|
-
@introspectors =
|
|
40
|
+
@introspectors = PRESETS[:standard].dup
|
|
36
41
|
@excluded_paths = %w[node_modules tmp log vendor .git]
|
|
37
42
|
@auto_mount = false
|
|
38
43
|
@http_path = "/mcp"
|
|
@@ -49,6 +54,12 @@ module RailsAiContext
|
|
|
49
54
|
@cache_ttl = 30
|
|
50
55
|
end
|
|
51
56
|
|
|
57
|
+
def preset=(name)
|
|
58
|
+
name = name.to_sym
|
|
59
|
+
raise ArgumentError, "Unknown preset: #{name}. Valid presets: #{PRESETS.keys.join(", ")}" unless PRESETS.key?(name)
|
|
60
|
+
@introspectors = PRESETS[name].dup
|
|
61
|
+
end
|
|
62
|
+
|
|
52
63
|
def output_dir_for(app)
|
|
53
64
|
@output_dir || app.root.to_s
|
|
54
65
|
end
|
data/lib/rails_ai_context.rb
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require "zeitwerk"
|
|
4
|
+
|
|
5
|
+
loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
|
|
6
|
+
loader.inflector.inflect("devops_introspector" => "DevOpsIntrospector")
|
|
7
|
+
loader.ignore("#{__dir__}/generators")
|
|
8
|
+
loader.ignore("#{__dir__}/rails-ai-context.rb")
|
|
9
|
+
loader.setup
|
|
4
10
|
|
|
5
11
|
module RailsAiContext
|
|
6
12
|
class Error < StandardError; end
|
|
@@ -41,64 +47,5 @@ module RailsAiContext
|
|
|
41
47
|
end
|
|
42
48
|
end
|
|
43
49
|
|
|
44
|
-
# Configuration
|
|
45
|
-
require_relative "rails_ai_context/configuration"
|
|
46
|
-
|
|
47
|
-
# Cache invalidation
|
|
48
|
-
require_relative "rails_ai_context/fingerprinter"
|
|
49
|
-
|
|
50
|
-
# Core introspection
|
|
51
|
-
require_relative "rails_ai_context/introspector"
|
|
52
|
-
require_relative "rails_ai_context/introspectors/schema_introspector"
|
|
53
|
-
require_relative "rails_ai_context/introspectors/model_introspector"
|
|
54
|
-
require_relative "rails_ai_context/introspectors/route_introspector"
|
|
55
|
-
require_relative "rails_ai_context/introspectors/job_introspector"
|
|
56
|
-
require_relative "rails_ai_context/introspectors/gem_introspector"
|
|
57
|
-
require_relative "rails_ai_context/introspectors/convention_detector"
|
|
58
|
-
require_relative "rails_ai_context/introspectors/stimulus_introspector"
|
|
59
|
-
require_relative "rails_ai_context/introspectors/database_stats_introspector"
|
|
60
|
-
require_relative "rails_ai_context/introspectors/controller_introspector"
|
|
61
|
-
require_relative "rails_ai_context/introspectors/view_introspector"
|
|
62
|
-
require_relative "rails_ai_context/introspectors/turbo_introspector"
|
|
63
|
-
require_relative "rails_ai_context/introspectors/i18n_introspector"
|
|
64
|
-
require_relative "rails_ai_context/introspectors/config_introspector"
|
|
65
|
-
require_relative "rails_ai_context/introspectors/active_storage_introspector"
|
|
66
|
-
require_relative "rails_ai_context/introspectors/action_text_introspector"
|
|
67
|
-
require_relative "rails_ai_context/introspectors/auth_introspector"
|
|
68
|
-
require_relative "rails_ai_context/introspectors/api_introspector"
|
|
69
|
-
require_relative "rails_ai_context/introspectors/test_introspector"
|
|
70
|
-
require_relative "rails_ai_context/introspectors/rake_task_introspector"
|
|
71
|
-
require_relative "rails_ai_context/introspectors/asset_pipeline_introspector"
|
|
72
|
-
require_relative "rails_ai_context/introspectors/devops_introspector"
|
|
73
|
-
require_relative "rails_ai_context/introspectors/action_mailbox_introspector"
|
|
74
|
-
|
|
75
|
-
# MCP Tools
|
|
76
|
-
require_relative "rails_ai_context/tools/base_tool"
|
|
77
|
-
require_relative "rails_ai_context/tools/get_schema"
|
|
78
|
-
require_relative "rails_ai_context/tools/get_routes"
|
|
79
|
-
require_relative "rails_ai_context/tools/get_model_details"
|
|
80
|
-
require_relative "rails_ai_context/tools/get_gems"
|
|
81
|
-
require_relative "rails_ai_context/tools/search_code"
|
|
82
|
-
require_relative "rails_ai_context/tools/get_conventions"
|
|
83
|
-
require_relative "rails_ai_context/tools/get_controllers"
|
|
84
|
-
require_relative "rails_ai_context/tools/get_config"
|
|
85
|
-
require_relative "rails_ai_context/tools/get_test_info"
|
|
86
|
-
|
|
87
|
-
# Serializers
|
|
88
|
-
require_relative "rails_ai_context/serializers/context_file_serializer"
|
|
89
|
-
require_relative "rails_ai_context/serializers/markdown_serializer"
|
|
90
|
-
require_relative "rails_ai_context/serializers/claude_serializer"
|
|
91
|
-
require_relative "rails_ai_context/serializers/rules_serializer"
|
|
92
|
-
require_relative "rails_ai_context/serializers/copilot_serializer"
|
|
93
|
-
require_relative "rails_ai_context/serializers/json_serializer"
|
|
94
|
-
|
|
95
|
-
# Diagnostics & Watch
|
|
96
|
-
require_relative "rails_ai_context/doctor"
|
|
97
|
-
require_relative "rails_ai_context/watcher"
|
|
98
|
-
|
|
99
|
-
# MCP Resources & Server
|
|
100
|
-
require_relative "rails_ai_context/resources"
|
|
101
|
-
require_relative "rails_ai_context/server"
|
|
102
|
-
|
|
103
50
|
# Rails integration — loaded by Bundler.require after Rails is booted
|
|
104
51
|
require_relative "rails_ai_context/engine" if defined?(Rails::Engine)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails-ai-context
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- crisnahine
|
|
@@ -63,6 +63,20 @@ dependencies:
|
|
|
63
63
|
- - "<"
|
|
64
64
|
- !ruby/object:Gem::Version
|
|
65
65
|
version: '3.0'
|
|
66
|
+
- !ruby/object:Gem::Dependency
|
|
67
|
+
name: zeitwerk
|
|
68
|
+
requirement: !ruby/object:Gem::Requirement
|
|
69
|
+
requirements:
|
|
70
|
+
- - ">="
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
version: '2.6'
|
|
73
|
+
type: :runtime
|
|
74
|
+
prerelease: false
|
|
75
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
76
|
+
requirements:
|
|
77
|
+
- - ">="
|
|
78
|
+
- !ruby/object:Gem::Version
|
|
79
|
+
version: '2.6'
|
|
66
80
|
- !ruby/object:Gem::Dependency
|
|
67
81
|
name: rspec
|
|
68
82
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -165,10 +179,15 @@ files:
|
|
|
165
179
|
- ".ruby-version"
|
|
166
180
|
- CHANGELOG.md
|
|
167
181
|
- CLAUDE.md
|
|
182
|
+
- CODE_OF_CONDUCT.md
|
|
168
183
|
- CONTRIBUTING.md
|
|
169
184
|
- LICENSE
|
|
170
185
|
- README.md
|
|
171
186
|
- Rakefile
|
|
187
|
+
- SECURITY.md
|
|
188
|
+
- demo.gif
|
|
189
|
+
- demo.tape
|
|
190
|
+
- demo_script.sh
|
|
172
191
|
- exe/rails-ai-context
|
|
173
192
|
- lib/generators/rails_ai_context/install/install_generator.rb
|
|
174
193
|
- lib/rails-ai-context.rb
|