rails-ai-context 0.7.0 → 0.7.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 +11 -0
- data/CONTRIBUTING.md +4 -4
- data/README.md +69 -19
- data/SECURITY.md +3 -2
- data/demo_script.sh +20 -4
- data/lib/rails_ai_context/introspectors/schema_introspector.rb +2 -2
- data/lib/rails_ai_context/serializers/claude_rules_serializer.rb +51 -1
- data/lib/rails_ai_context/serializers/claude_serializer.rb +41 -13
- data/lib/rails_ai_context/serializers/copilot_instructions_serializer.rb +50 -1
- data/lib/rails_ai_context/serializers/copilot_serializer.rb +34 -11
- data/lib/rails_ai_context/serializers/cursor_rules_serializer.rb +50 -3
- data/lib/rails_ai_context/serializers/rules_serializer.rb +32 -11
- data/lib/rails_ai_context/serializers/windsurf_rules_serializer.rb +33 -1
- data/lib/rails_ai_context/serializers/windsurf_serializer.rb +12 -10
- data/lib/rails_ai_context/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7aa2c43d22465356700ded7ac615f4d38ba24e1bee512658dc1ec43196935e9c
|
|
4
|
+
data.tar.gz: f718d8e2c3b790294e212c557216cd2babd99459fea3a5f1245f9ad09329e52d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c4c9d908941193ffd7cda89bc8a5da67a9531ffd09e723382eebc39c7ac77a06faa3958bf4048f550d0d3a5883edf9f8a67a2b62c65130847589db53d954fe5d
|
|
7
|
+
data.tar.gz: 38a1f37c770eff7680ed3b0acb43627a5ba36b8168eafbf087907d8e5445103ec4cc06b4cb08103e48baf772c710d6333278759789f3bcc44e7b745787cc9b11
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,17 @@ 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.7.1] - 2026-03-19
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Full MCP tool reference in all context files** — every generated file (CLAUDE.md, .cursorrules, .windsurfrules, copilot-instructions.md) now includes complete tool documentation with parameters, detail levels, pagination examples, and usage workflow. Dedicated `rails-mcp-tools` split rule files added for Claude, Cursor, Windsurf, and Copilot.
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- **Schema version parsing** — versions with underscores (e.g. `2024_01_15_123456`) were truncated to the first digit group. Now captures the full version string.
|
|
17
|
+
- **Documentation** — updated README (detail levels, pagination, generated file tree, config options), SECURITY.md (supported versions), CONTRIBUTING.md (project structure), gemspec (post-install message), demo_script.sh (all 17 generated files).
|
|
18
|
+
|
|
8
19
|
## [0.7.0] - 2026-03-19
|
|
9
20
|
|
|
10
21
|
### Added
|
data/CONTRIBUTING.md
CHANGED
|
@@ -18,12 +18,12 @@ The test suite uses [Combustion](https://github.com/pat/combustion) to boot a mi
|
|
|
18
18
|
|
|
19
19
|
```
|
|
20
20
|
lib/rails_ai_context/
|
|
21
|
-
├── introspectors/ #
|
|
22
|
-
├── tools/ # MCP
|
|
23
|
-
├── serializers/ #
|
|
21
|
+
├── introspectors/ # 27 introspectors (schema, models, routes, etc.)
|
|
22
|
+
├── tools/ # 9 MCP tools with detail levels and pagination
|
|
23
|
+
├── serializers/ # Per-assistant formatters (claude, cursor, windsurf, copilot, JSON)
|
|
24
24
|
├── server.rb # MCP server setup (stdio + HTTP)
|
|
25
25
|
├── engine.rb # Rails Engine for auto-integration
|
|
26
|
-
└── configuration.rb # User-facing config
|
|
26
|
+
└── configuration.rb # User-facing config (presets, context_mode, limits)
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
## Adding a New Introspector
|
data/README.md
CHANGED
|
@@ -61,13 +61,26 @@ rails generate rails_ai_context:install
|
|
|
61
61
|
rails ai:context
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
This creates:
|
|
65
|
-
- `CLAUDE.md` — for Claude Code (with behavioral rules)
|
|
66
|
-
- `.cursorrules` — for Cursor (compact rules format)
|
|
67
|
-
- `.windsurfrules` — for Windsurf (compact rules format)
|
|
68
|
-
- `.github/copilot-instructions.md` — for GitHub Copilot (task-oriented)
|
|
64
|
+
This creates context files **and** split rule files for each AI assistant:
|
|
69
65
|
|
|
70
|
-
|
|
66
|
+
```
|
|
67
|
+
CLAUDE.md # ≤150 lines (compact mode)
|
|
68
|
+
.claude/rules/rails-schema.md # Auto-loaded by Claude Code
|
|
69
|
+
.claude/rules/rails-models.md # Auto-loaded by Claude Code
|
|
70
|
+
.cursorrules # Legacy format (compact)
|
|
71
|
+
.cursor/rules/rails-project.mdc # Always-on project overview
|
|
72
|
+
.cursor/rules/rails-models.mdc # Auto-attaches in app/models/
|
|
73
|
+
.cursor/rules/rails-controllers.mdc # Auto-attaches in app/controllers/
|
|
74
|
+
.windsurfrules # ≤5,800 chars (within 6K limit)
|
|
75
|
+
.windsurf/rules/rails-context.md # New rules format
|
|
76
|
+
.github/copilot-instructions.md # ≤500 lines (compact mode)
|
|
77
|
+
.github/instructions/rails-models.instructions.md # applyTo: app/models/
|
|
78
|
+
.github/instructions/rails-controllers.instructions.md # applyTo: app/controllers/
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Each file is tailored to the AI assistant's preferred format and respects its size limits. **Commit these files.** Your entire team gets smarter AI assistance.
|
|
82
|
+
|
|
83
|
+
> **Context modes:** The default `:compact` mode generates small, focused files that point to MCP tools for details. Use `rails ai:context:full` to dump everything into the files instead (good for small apps).
|
|
71
84
|
|
|
72
85
|
### 3. MCP Server
|
|
73
86
|
|
|
@@ -182,6 +195,29 @@ The gem exposes 9 tools via MCP that AI clients can call:
|
|
|
182
195
|
|
|
183
196
|
All tools are **read-only** — they never modify your application or database.
|
|
184
197
|
|
|
198
|
+
### Detail Levels & Pagination
|
|
199
|
+
|
|
200
|
+
Tools support a `detail` parameter so AI assistants can start with an overview, then drill into specifics — critical for apps with hundreds of models or tables:
|
|
201
|
+
|
|
202
|
+
| Detail Level | What it returns | Default limit |
|
|
203
|
+
|-------------|-----------------|---------------|
|
|
204
|
+
| `summary` | Names + counts (e.g. "users — 12 columns, 3 indexes") | 50 |
|
|
205
|
+
| `standard` | Names + key details (e.g. column names and types) | 15 |
|
|
206
|
+
| `full` | Everything including indexes, FKs, constraints | 5 |
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
# AI calls summary first to understand the landscape
|
|
210
|
+
rails_get_schema(detail: "summary")
|
|
211
|
+
|
|
212
|
+
# Then drills into a specific table
|
|
213
|
+
rails_get_schema(table: "users")
|
|
214
|
+
|
|
215
|
+
# Pagination for large schemas
|
|
216
|
+
rails_get_schema(detail: "summary", limit: 20, offset: 40)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Schema and routes tools also support `limit` and `offset` for pagination. A configurable safety net (`max_tool_response_chars`, default 120K) truncates oversized responses with hints to use filters.
|
|
220
|
+
|
|
185
221
|
## MCP Resources
|
|
186
222
|
|
|
187
223
|
In addition to tools, the gem registers MCP resources that AI clients can read directly:
|
|
@@ -239,13 +275,24 @@ In addition to tools, the gem registers MCP resources that AI clients can read d
|
|
|
239
275
|
# config/initializers/rails_ai_context.rb
|
|
240
276
|
RailsAiContext.configure do |config|
|
|
241
277
|
# Introspector presets:
|
|
242
|
-
# :standard —
|
|
278
|
+
# :standard — 9 core introspectors (default, fast)
|
|
243
279
|
# :full — all 26 introspectors (thorough)
|
|
244
280
|
config.preset = :standard
|
|
245
281
|
|
|
246
282
|
# Or cherry-pick on top of a preset:
|
|
247
283
|
# config.introspectors += %i[views turbo auth api]
|
|
248
284
|
|
|
285
|
+
# Context mode for generated files (CLAUDE.md, .cursorrules, etc.)
|
|
286
|
+
# :compact — smart, ≤150 lines, references MCP tools (default)
|
|
287
|
+
# :full — dumps everything into context files (good for small apps)
|
|
288
|
+
# config.context_mode = :compact
|
|
289
|
+
|
|
290
|
+
# Max lines for CLAUDE.md in compact mode
|
|
291
|
+
# config.claude_max_lines = 150
|
|
292
|
+
|
|
293
|
+
# Max response size for MCP tool results (safety net for large apps)
|
|
294
|
+
# config.max_tool_response_chars = 120_000
|
|
295
|
+
|
|
249
296
|
# Exclude internal models from introspection
|
|
250
297
|
config.excluded_models += %w[AdminUser InternalAuditLog]
|
|
251
298
|
|
|
@@ -289,13 +336,13 @@ This gives AI assistants context about your frontend JavaScript alongside your b
|
|
|
289
336
|
|
|
290
337
|
## Supported AI Assistants
|
|
291
338
|
|
|
292
|
-
| AI Assistant |
|
|
293
|
-
|
|
294
|
-
| Claude Code | `CLAUDE.md` |
|
|
295
|
-
| Cursor | `.cursorrules` |
|
|
296
|
-
| Windsurf | `.windsurfrules` |
|
|
297
|
-
| GitHub Copilot | `.github/copilot-instructions.md` |
|
|
298
|
-
| JSON (generic) | `.ai-context.json` |
|
|
339
|
+
| AI Assistant | Main File | Split Rules | Command |
|
|
340
|
+
|--------------|-----------|------------|---------|
|
|
341
|
+
| Claude Code | `CLAUDE.md` | `.claude/rules/*.md` | `rails ai:context:claude` |
|
|
342
|
+
| Cursor | `.cursorrules` | `.cursor/rules/*.mdc` | `rails ai:context:cursor` |
|
|
343
|
+
| Windsurf | `.windsurfrules` | `.windsurf/rules/*.md` | `rails ai:context:windsurf` |
|
|
344
|
+
| GitHub Copilot | `.github/copilot-instructions.md` | `.github/instructions/*.instructions.md` | `rails ai:context:copilot` |
|
|
345
|
+
| JSON (generic) | `.ai-context.json` | — | `rails ai:context:json` |
|
|
299
346
|
|
|
300
347
|
---
|
|
301
348
|
|
|
@@ -321,11 +368,12 @@ Introspectors that target frontend concerns (views, Turbo, Stimulus, assets) are
|
|
|
321
368
|
|
|
322
369
|
| Command | Description |
|
|
323
370
|
|---------|-------------|
|
|
324
|
-
| `rails ai:context` | Generate all context files (skips unchanged) |
|
|
325
|
-
| `rails ai:context:
|
|
326
|
-
| `rails ai:context:
|
|
327
|
-
| `rails ai:context:
|
|
328
|
-
| `rails ai:context:
|
|
371
|
+
| `rails ai:context` | Generate all context files + split rules (skips unchanged) |
|
|
372
|
+
| `rails ai:context:full` | Generate all files in full mode (dumps everything) |
|
|
373
|
+
| `rails ai:context:claude` | Generate CLAUDE.md + .claude/rules/ |
|
|
374
|
+
| `rails ai:context:cursor` | Generate .cursorrules + .cursor/rules/ |
|
|
375
|
+
| `rails ai:context:windsurf` | Generate .windsurfrules + .windsurf/rules/ |
|
|
376
|
+
| `rails ai:context:copilot` | Generate copilot-instructions.md + .github/instructions/ |
|
|
329
377
|
| `rails ai:context:json` | Generate .ai-context.json only |
|
|
330
378
|
| `rails ai:serve` | Start MCP server (stdio, for Claude Code) |
|
|
331
379
|
| `rails ai:serve_http` | Start MCP server (HTTP, for remote clients) |
|
|
@@ -333,6 +381,8 @@ Introspectors that target frontend concerns (views, Turbo, Stimulus, assets) are
|
|
|
333
381
|
| `rails ai:doctor` | Run diagnostics and report AI readiness score |
|
|
334
382
|
| `rails ai:watch` | Watch for changes and auto-regenerate context files |
|
|
335
383
|
|
|
384
|
+
> You can also override context mode via environment variable: `CONTEXT_MODE=full rails ai:context`
|
|
385
|
+
|
|
336
386
|
> **zsh users:** The bracket syntax `rails ai:context_for[claude]` requires quoting in zsh (`rails 'ai:context_for[claude]'`). The named tasks above (`rails ai:context:claude`) work without quoting in any shell.
|
|
337
387
|
|
|
338
388
|
---
|
data/SECURITY.md
CHANGED
data/demo_script.sh
CHANGED
|
@@ -8,7 +8,7 @@ echo 'Fetching gem metadata from https://rubygems.org...'
|
|
|
8
8
|
sleep 0.3
|
|
9
9
|
echo 'Resolving dependencies...'
|
|
10
10
|
sleep 0.3
|
|
11
|
-
echo 'Installing rails-ai-context 0.
|
|
11
|
+
echo 'Installing rails-ai-context 0.7.0'
|
|
12
12
|
echo ''
|
|
13
13
|
sleep 1
|
|
14
14
|
|
|
@@ -46,12 +46,28 @@ printf '\033[1;36m$\033[0m rails ai:context\n'
|
|
|
46
46
|
echo ''
|
|
47
47
|
sleep 0.2
|
|
48
48
|
echo ' ✅ CLAUDE.md'
|
|
49
|
-
sleep 0.
|
|
49
|
+
sleep 0.1
|
|
50
|
+
echo ' ✅ .claude/rules/rails-schema.md'
|
|
51
|
+
sleep 0.1
|
|
52
|
+
echo ' ✅ .claude/rules/rails-models.md'
|
|
53
|
+
sleep 0.1
|
|
50
54
|
echo ' ✅ .cursorrules'
|
|
51
|
-
sleep 0.
|
|
55
|
+
sleep 0.1
|
|
56
|
+
echo ' ✅ .cursor/rules/rails-project.mdc'
|
|
57
|
+
sleep 0.1
|
|
58
|
+
echo ' ✅ .cursor/rules/rails-models.mdc'
|
|
59
|
+
sleep 0.1
|
|
60
|
+
echo ' ✅ .cursor/rules/rails-controllers.mdc'
|
|
61
|
+
sleep 0.1
|
|
52
62
|
echo ' ✅ .windsurfrules'
|
|
53
|
-
sleep 0.
|
|
63
|
+
sleep 0.1
|
|
64
|
+
echo ' ✅ .windsurf/rules/rails-context.md'
|
|
65
|
+
sleep 0.1
|
|
54
66
|
echo ' ✅ .github/copilot-instructions.md'
|
|
67
|
+
sleep 0.1
|
|
68
|
+
echo ' ✅ .github/instructions/rails-models.instructions.md'
|
|
69
|
+
sleep 0.1
|
|
70
|
+
echo ' ✅ .github/instructions/rails-controllers.instructions.md'
|
|
55
71
|
echo ''
|
|
56
72
|
sleep 0.3
|
|
57
73
|
printf ' \033[1;32mDone! Your AI assistants now understand your Rails app.\033[0m\n'
|
|
@@ -100,8 +100,8 @@ module RailsAiContext
|
|
|
100
100
|
def current_schema_version
|
|
101
101
|
if File.exist?(schema_file_path)
|
|
102
102
|
content = File.read(schema_file_path)
|
|
103
|
-
match = content.match(/version:\s*(\
|
|
104
|
-
match ? match[1] : nil
|
|
103
|
+
match = content.match(/version:\s*([\d_]+)/)
|
|
104
|
+
match ? match[1].delete("_") : nil
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
107
|
|
|
@@ -22,7 +22,8 @@ module RailsAiContext
|
|
|
22
22
|
|
|
23
23
|
files = {
|
|
24
24
|
"rails-schema.md" => render_schema_reference,
|
|
25
|
-
"rails-models.md" => render_models_reference
|
|
25
|
+
"rails-models.md" => render_models_reference,
|
|
26
|
+
"rails-mcp-tools.md" => render_mcp_tools_reference
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
files.each do |filename, content|
|
|
@@ -92,6 +93,55 @@ module RailsAiContext
|
|
|
92
93
|
|
|
93
94
|
lines.join("\n")
|
|
94
95
|
end
|
|
96
|
+
|
|
97
|
+
def render_mcp_tools_reference # rubocop:disable Metrics/MethodLength
|
|
98
|
+
lines = [
|
|
99
|
+
"# MCP Tool Reference",
|
|
100
|
+
"",
|
|
101
|
+
"All introspection tools support a `detail` parameter:",
|
|
102
|
+
"- `summary` — names + counts (default limit: 50)",
|
|
103
|
+
"- `standard` — names + key details (default limit: 15, this is the default)",
|
|
104
|
+
"- `full` — everything including indexes, FKs (default limit: 5)",
|
|
105
|
+
"",
|
|
106
|
+
"## rails_get_schema",
|
|
107
|
+
"Params: `table`, `detail`, `limit`, `offset`, `format`",
|
|
108
|
+
"- `rails_get_schema(detail:\"summary\")` — all tables with column counts",
|
|
109
|
+
"- `rails_get_schema(table:\"users\")` — full detail for one table",
|
|
110
|
+
"- `rails_get_schema(detail:\"summary\", limit:20, offset:40)` — paginate",
|
|
111
|
+
"",
|
|
112
|
+
"## rails_get_model_details",
|
|
113
|
+
"Params: `model`, `detail`",
|
|
114
|
+
"- `rails_get_model_details(detail:\"summary\")` — list all model names",
|
|
115
|
+
"- `rails_get_model_details(model:\"User\")` — associations, validations, scopes, enums, callbacks",
|
|
116
|
+
"- `rails_get_model_details(detail:\"full\")` — all models with full association lists",
|
|
117
|
+
"",
|
|
118
|
+
"## rails_get_routes",
|
|
119
|
+
"Params: `controller`, `detail`, `limit`, `offset`",
|
|
120
|
+
"- `rails_get_routes(detail:\"summary\")` — route counts per controller",
|
|
121
|
+
"- `rails_get_routes(controller:\"users\")` — routes for one controller",
|
|
122
|
+
"- `rails_get_routes(detail:\"full\", limit:50)` — full table with route names",
|
|
123
|
+
"",
|
|
124
|
+
"## rails_get_controllers",
|
|
125
|
+
"Params: `controller`, `detail`",
|
|
126
|
+
"- `rails_get_controllers(detail:\"summary\")` — names + action counts",
|
|
127
|
+
"- `rails_get_controllers(controller:\"UsersController\")` — actions, filters, strong params",
|
|
128
|
+
"",
|
|
129
|
+
"## Other tools (no detail param)",
|
|
130
|
+
"- `rails_get_config` — cache store, session, timezone, middleware, initializers",
|
|
131
|
+
"- `rails_get_test_info` — test framework, factories/fixtures, CI config, coverage",
|
|
132
|
+
"- `rails_get_gems` — notable gems categorized by function",
|
|
133
|
+
"- `rails_get_conventions` — architecture patterns, directory structure",
|
|
134
|
+
"- `rails_search_code(pattern:\"regex\", file_type:\"rb\", max_results:20)` — codebase search",
|
|
135
|
+
"",
|
|
136
|
+
"## Workflow",
|
|
137
|
+
"1. Start with `detail:\"summary\"` to understand the landscape",
|
|
138
|
+
"2. Drill into specifics with filters (`table:`, `model:`, `controller:`)",
|
|
139
|
+
"3. Use `detail:\"full\"` only when you need indexes, FKs, constraints",
|
|
140
|
+
"4. Paginate large results with `limit` and `offset`"
|
|
141
|
+
]
|
|
142
|
+
|
|
143
|
+
lines.join("\n")
|
|
144
|
+
end
|
|
95
145
|
end
|
|
96
146
|
end
|
|
97
147
|
end
|
|
@@ -158,22 +158,50 @@ module RailsAiContext
|
|
|
158
158
|
lines
|
|
159
159
|
end
|
|
160
160
|
|
|
161
|
-
def render_mcp_guide
|
|
161
|
+
def render_mcp_guide # rubocop:disable Metrics/MethodLength
|
|
162
162
|
[
|
|
163
|
-
"## MCP
|
|
163
|
+
"## MCP Tool Reference",
|
|
164
164
|
"",
|
|
165
|
-
"This project exposes MCP tools. Always
|
|
166
|
-
"then drill into specifics with `detail:\"full\"
|
|
165
|
+
"This project exposes live MCP tools. **Always start with `detail:\"summary\"`**,",
|
|
166
|
+
"then drill into specifics with a filter or `detail:\"full\"`.",
|
|
167
167
|
"",
|
|
168
|
-
"
|
|
169
|
-
"
|
|
170
|
-
"
|
|
171
|
-
"
|
|
172
|
-
"
|
|
173
|
-
"
|
|
174
|
-
"
|
|
175
|
-
"
|
|
176
|
-
"
|
|
168
|
+
"### Detail levels (schema, routes, models, controllers)",
|
|
169
|
+
"",
|
|
170
|
+
"| Level | Returns | Default limit |",
|
|
171
|
+
"|-------|---------|---------------|",
|
|
172
|
+
"| `summary` | Names + counts | 50 |",
|
|
173
|
+
"| `standard` | Names + key details | 15 (default) |",
|
|
174
|
+
"| `full` | Everything (indexes, FKs, etc.) | 5 |",
|
|
175
|
+
"",
|
|
176
|
+
"### rails_get_schema",
|
|
177
|
+
"Params: `table`, `detail`, `limit`, `offset`, `format`",
|
|
178
|
+
"- `rails_get_schema(detail:\"summary\")` — all tables with column counts",
|
|
179
|
+
"- `rails_get_schema(table:\"users\")` — full detail for one table",
|
|
180
|
+
"- `rails_get_schema(detail:\"summary\", limit:20, offset:40)` — paginate",
|
|
181
|
+
"",
|
|
182
|
+
"### rails_get_model_details",
|
|
183
|
+
"Params: `model`, `detail`",
|
|
184
|
+
"- `rails_get_model_details(detail:\"summary\")` — list all model names",
|
|
185
|
+
"- `rails_get_model_details(model:\"User\")` — associations, validations, scopes, enums, callbacks",
|
|
186
|
+
"- `rails_get_model_details(detail:\"full\")` — all models with full association lists",
|
|
187
|
+
"",
|
|
188
|
+
"### rails_get_routes",
|
|
189
|
+
"Params: `controller`, `detail`, `limit`, `offset`",
|
|
190
|
+
"- `rails_get_routes(detail:\"summary\")` — route counts per controller",
|
|
191
|
+
"- `rails_get_routes(controller:\"users\")` — routes for one controller",
|
|
192
|
+
"- `rails_get_routes(detail:\"full\", limit:50)` — full table with route names",
|
|
193
|
+
"",
|
|
194
|
+
"### rails_get_controllers",
|
|
195
|
+
"Params: `controller`, `detail`",
|
|
196
|
+
"- `rails_get_controllers(detail:\"summary\")` — names + action counts",
|
|
197
|
+
"- `rails_get_controllers(controller:\"UsersController\")` — actions, filters, strong params",
|
|
198
|
+
"",
|
|
199
|
+
"### Other tools (no detail param)",
|
|
200
|
+
"- `rails_get_config` — cache store, session, timezone, middleware, initializers",
|
|
201
|
+
"- `rails_get_test_info` — test framework, factories/fixtures, CI config, coverage",
|
|
202
|
+
"- `rails_get_gems` — notable gems categorized by function (auth, background jobs, etc.)",
|
|
203
|
+
"- `rails_get_conventions` — architecture patterns, directory structure, config files",
|
|
204
|
+
"- `rails_search_code(pattern:\"regex\", file_type:\"rb\", max_results:20)` — ripgrep search",
|
|
177
205
|
""
|
|
178
206
|
]
|
|
179
207
|
end
|
|
@@ -20,7 +20,8 @@ module RailsAiContext
|
|
|
20
20
|
|
|
21
21
|
files = {
|
|
22
22
|
"rails-models.instructions.md" => render_models_instructions,
|
|
23
|
-
"rails-controllers.instructions.md" => render_controllers_instructions
|
|
23
|
+
"rails-controllers.instructions.md" => render_controllers_instructions,
|
|
24
|
+
"rails-mcp-tools.instructions.md" => render_mcp_tools_instructions
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
files.each do |filename, content|
|
|
@@ -89,6 +90,54 @@ module RailsAiContext
|
|
|
89
90
|
|
|
90
91
|
lines.join("\n")
|
|
91
92
|
end
|
|
93
|
+
|
|
94
|
+
def render_mcp_tools_instructions # rubocop:disable Metrics/MethodLength
|
|
95
|
+
lines = [
|
|
96
|
+
"---",
|
|
97
|
+
"applyTo: \"**/*\"",
|
|
98
|
+
"---",
|
|
99
|
+
"",
|
|
100
|
+
"# MCP Tool Reference",
|
|
101
|
+
"",
|
|
102
|
+
"This project has MCP tools for live introspection.",
|
|
103
|
+
"**Start with `detail:\"summary\"`, then drill into specifics.**",
|
|
104
|
+
"",
|
|
105
|
+
"## Detail levels (schema, routes, models, controllers)",
|
|
106
|
+
"- `summary` — names + counts (default limit: 50)",
|
|
107
|
+
"- `standard` — names + key details (default limit: 15, this is the default)",
|
|
108
|
+
"- `full` — everything including indexes, FKs (default limit: 5)",
|
|
109
|
+
"",
|
|
110
|
+
"## rails_get_schema",
|
|
111
|
+
"Params: `table`, `detail`, `limit`, `offset`, `format`",
|
|
112
|
+
"- `rails_get_schema(detail:\"summary\")` — all tables with column counts",
|
|
113
|
+
"- `rails_get_schema(table:\"users\")` — full detail for one table",
|
|
114
|
+
"- `rails_get_schema(detail:\"summary\", limit:20, offset:40)` — paginate",
|
|
115
|
+
"",
|
|
116
|
+
"## rails_get_model_details",
|
|
117
|
+
"Params: `model`, `detail`",
|
|
118
|
+
"- `rails_get_model_details(detail:\"summary\")` — list all model names",
|
|
119
|
+
"- `rails_get_model_details(model:\"User\")` — full associations, validations, scopes",
|
|
120
|
+
"",
|
|
121
|
+
"## rails_get_routes",
|
|
122
|
+
"Params: `controller`, `detail`, `limit`, `offset`",
|
|
123
|
+
"- `rails_get_routes(detail:\"summary\")` — route counts per controller",
|
|
124
|
+
"- `rails_get_routes(controller:\"users\")` — routes for one controller",
|
|
125
|
+
"",
|
|
126
|
+
"## rails_get_controllers",
|
|
127
|
+
"Params: `controller`, `detail`",
|
|
128
|
+
"- `rails_get_controllers(detail:\"summary\")` — names + action counts",
|
|
129
|
+
"- `rails_get_controllers(controller:\"UsersController\")` — actions, filters, params",
|
|
130
|
+
"",
|
|
131
|
+
"## Other tools",
|
|
132
|
+
"- `rails_get_config` — cache store, session, timezone, middleware",
|
|
133
|
+
"- `rails_get_test_info` — test framework, factories/fixtures, CI config",
|
|
134
|
+
"- `rails_get_gems` — notable gems categorized by function",
|
|
135
|
+
"- `rails_get_conventions` — architecture patterns, directory structure",
|
|
136
|
+
"- `rails_search_code(pattern:\"regex\", file_type:\"rb\", max_results:20)` — codebase search"
|
|
137
|
+
]
|
|
138
|
+
|
|
139
|
+
lines.join("\n")
|
|
140
|
+
end
|
|
92
141
|
end
|
|
93
142
|
end
|
|
94
143
|
end
|
|
@@ -81,20 +81,43 @@ module RailsAiContext
|
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
# MCP tools
|
|
84
|
-
lines << "## MCP
|
|
84
|
+
lines << "## MCP Tool Reference"
|
|
85
85
|
lines << ""
|
|
86
86
|
lines << "This project has MCP tools for live introspection."
|
|
87
|
-
lines << "
|
|
87
|
+
lines << "**Always start with `detail:\"summary\"`, then drill into specifics.**"
|
|
88
88
|
lines << ""
|
|
89
|
-
lines << "
|
|
90
|
-
lines << "- `
|
|
91
|
-
lines << "- `
|
|
92
|
-
lines << "- `
|
|
93
|
-
lines << "
|
|
94
|
-
lines << "
|
|
95
|
-
lines << "
|
|
96
|
-
lines << "- `
|
|
97
|
-
lines << "- `
|
|
89
|
+
lines << "### Detail levels (schema, routes, models, controllers)"
|
|
90
|
+
lines << "- `summary` — names + counts (default limit: 50)"
|
|
91
|
+
lines << "- `standard` — names + key details (default limit: 15, this is the default)"
|
|
92
|
+
lines << "- `full` — everything including indexes, FKs (default limit: 5)"
|
|
93
|
+
lines << ""
|
|
94
|
+
lines << "### rails_get_schema"
|
|
95
|
+
lines << "Params: `table`, `detail`, `limit`, `offset`, `format`"
|
|
96
|
+
lines << "- `rails_get_schema(detail:\"summary\")` — all tables with column counts"
|
|
97
|
+
lines << "- `rails_get_schema(table:\"users\")` — full detail for one table"
|
|
98
|
+
lines << "- `rails_get_schema(detail:\"summary\", limit:20, offset:40)` — paginate"
|
|
99
|
+
lines << ""
|
|
100
|
+
lines << "### rails_get_model_details"
|
|
101
|
+
lines << "Params: `model`, `detail`"
|
|
102
|
+
lines << "- `rails_get_model_details(detail:\"summary\")` — list all model names"
|
|
103
|
+
lines << "- `rails_get_model_details(model:\"User\")` — associations, validations, scopes, enums"
|
|
104
|
+
lines << ""
|
|
105
|
+
lines << "### rails_get_routes"
|
|
106
|
+
lines << "Params: `controller`, `detail`, `limit`, `offset`"
|
|
107
|
+
lines << "- `rails_get_routes(detail:\"summary\")` — route counts per controller"
|
|
108
|
+
lines << "- `rails_get_routes(controller:\"users\")` — routes for one controller"
|
|
109
|
+
lines << ""
|
|
110
|
+
lines << "### rails_get_controllers"
|
|
111
|
+
lines << "Params: `controller`, `detail`"
|
|
112
|
+
lines << "- `rails_get_controllers(detail:\"summary\")` — names + action counts"
|
|
113
|
+
lines << "- `rails_get_controllers(controller:\"UsersController\")` — actions, filters, params"
|
|
114
|
+
lines << ""
|
|
115
|
+
lines << "### Other tools"
|
|
116
|
+
lines << "- `rails_get_config` — cache store, session, timezone, middleware"
|
|
117
|
+
lines << "- `rails_get_test_info` — test framework, factories/fixtures, CI config"
|
|
118
|
+
lines << "- `rails_get_gems` — notable gems categorized by function"
|
|
119
|
+
lines << "- `rails_get_conventions` — architecture patterns, directory structure"
|
|
120
|
+
lines << "- `rails_search_code(pattern:\"regex\", file_type:\"rb\", max_results:20)` — codebase search"
|
|
98
121
|
lines << ""
|
|
99
122
|
|
|
100
123
|
# Conventions
|
|
@@ -24,7 +24,8 @@ module RailsAiContext
|
|
|
24
24
|
files = {
|
|
25
25
|
"rails-project.mdc" => render_project_rule,
|
|
26
26
|
"rails-models.mdc" => render_models_rule,
|
|
27
|
-
"rails-controllers.mdc" => render_controllers_rule
|
|
27
|
+
"rails-controllers.mdc" => render_controllers_rule,
|
|
28
|
+
"rails-mcp-tools.mdc" => render_mcp_tools_rule
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
files.each do |filename, content|
|
|
@@ -85,8 +86,8 @@ module RailsAiContext
|
|
|
85
86
|
end
|
|
86
87
|
|
|
87
88
|
lines << ""
|
|
88
|
-
lines << "
|
|
89
|
-
lines << "
|
|
89
|
+
lines << "MCP tools available — see rails-mcp-tools.mdc for full reference."
|
|
90
|
+
lines << "Always call with detail:\"summary\" first, then drill into specifics."
|
|
90
91
|
|
|
91
92
|
lines.join("\n")
|
|
92
93
|
end
|
|
@@ -152,6 +153,52 @@ module RailsAiContext
|
|
|
152
153
|
|
|
153
154
|
lines.join("\n")
|
|
154
155
|
end
|
|
156
|
+
|
|
157
|
+
# Always-on MCP tool reference
|
|
158
|
+
def render_mcp_tools_rule # rubocop:disable Metrics/MethodLength
|
|
159
|
+
lines = [
|
|
160
|
+
"---",
|
|
161
|
+
"description: \"MCP tool reference with parameters and examples\"",
|
|
162
|
+
"alwaysApply: true",
|
|
163
|
+
"---",
|
|
164
|
+
"",
|
|
165
|
+
"# MCP Tool Reference",
|
|
166
|
+
"",
|
|
167
|
+
"Detail levels: summary | standard (default) | full",
|
|
168
|
+
"",
|
|
169
|
+
"## rails_get_schema",
|
|
170
|
+
"Params: table, detail, limit, offset, format",
|
|
171
|
+
"- `rails_get_schema(detail:\"summary\")` — all tables with column counts",
|
|
172
|
+
"- `rails_get_schema(table:\"users\")` — full detail for one table",
|
|
173
|
+
"- `rails_get_schema(detail:\"summary\", limit:20, offset:40)` — paginate",
|
|
174
|
+
"",
|
|
175
|
+
"## rails_get_model_details",
|
|
176
|
+
"Params: model, detail",
|
|
177
|
+
"- `rails_get_model_details(detail:\"summary\")` — list model names",
|
|
178
|
+
"- `rails_get_model_details(model:\"User\")` — full detail",
|
|
179
|
+
"",
|
|
180
|
+
"## rails_get_routes",
|
|
181
|
+
"Params: controller, detail, limit, offset",
|
|
182
|
+
"- `rails_get_routes(detail:\"summary\")` — counts per controller",
|
|
183
|
+
"- `rails_get_routes(controller:\"users\")` — one controller",
|
|
184
|
+
"",
|
|
185
|
+
"## rails_get_controllers",
|
|
186
|
+
"Params: controller, detail",
|
|
187
|
+
"- `rails_get_controllers(detail:\"summary\")` — names + action counts",
|
|
188
|
+
"- `rails_get_controllers(controller:\"UsersController\")` — full detail",
|
|
189
|
+
"",
|
|
190
|
+
"## Other tools",
|
|
191
|
+
"- `rails_get_config` — cache, session, middleware",
|
|
192
|
+
"- `rails_get_test_info` — framework, factories, CI",
|
|
193
|
+
"- `rails_get_gems` — categorized gems",
|
|
194
|
+
"- `rails_get_conventions` — architecture patterns",
|
|
195
|
+
"- `rails_search_code(pattern:\"regex\", file_type:\"rb\", max_results:20)`",
|
|
196
|
+
"",
|
|
197
|
+
"Start with detail:\"summary\", then drill into specifics."
|
|
198
|
+
]
|
|
199
|
+
|
|
200
|
+
lines.join("\n")
|
|
201
|
+
end
|
|
155
202
|
end
|
|
156
203
|
end
|
|
157
204
|
end
|
|
@@ -74,17 +74,38 @@ module RailsAiContext
|
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
# MCP tools
|
|
77
|
-
lines << "## MCP
|
|
78
|
-
lines << "
|
|
79
|
-
lines << "
|
|
80
|
-
lines << "
|
|
81
|
-
lines << "
|
|
82
|
-
lines << "
|
|
83
|
-
lines << "
|
|
84
|
-
lines << "-
|
|
85
|
-
lines << "-
|
|
86
|
-
lines << "-
|
|
87
|
-
lines << "
|
|
77
|
+
lines << "## MCP Tool Reference"
|
|
78
|
+
lines << ""
|
|
79
|
+
lines << "All introspection tools support detail:\"summary\"|\"standard\"|\"full\"."
|
|
80
|
+
lines << "Start with summary, drill into specifics with a filter."
|
|
81
|
+
lines << ""
|
|
82
|
+
lines << "### rails_get_schema"
|
|
83
|
+
lines << "Params: table, detail, limit, offset, format"
|
|
84
|
+
lines << "- `rails_get_schema(detail:\"summary\")` — all tables with column counts"
|
|
85
|
+
lines << "- `rails_get_schema(table:\"users\")` — full detail for one table"
|
|
86
|
+
lines << "- `rails_get_schema(detail:\"summary\", limit:20, offset:40)` — paginate"
|
|
87
|
+
lines << ""
|
|
88
|
+
lines << "### rails_get_model_details"
|
|
89
|
+
lines << "Params: model, detail"
|
|
90
|
+
lines << "- `rails_get_model_details(detail:\"summary\")` — list model names"
|
|
91
|
+
lines << "- `rails_get_model_details(model:\"User\")` — full associations, validations, scopes"
|
|
92
|
+
lines << ""
|
|
93
|
+
lines << "### rails_get_routes"
|
|
94
|
+
lines << "Params: controller, detail, limit, offset"
|
|
95
|
+
lines << "- `rails_get_routes(detail:\"summary\")` — route counts per controller"
|
|
96
|
+
lines << "- `rails_get_routes(controller:\"users\")` — routes for one controller"
|
|
97
|
+
lines << ""
|
|
98
|
+
lines << "### rails_get_controllers"
|
|
99
|
+
lines << "Params: controller, detail"
|
|
100
|
+
lines << "- `rails_get_controllers(detail:\"summary\")` — names + action counts"
|
|
101
|
+
lines << "- `rails_get_controllers(controller:\"UsersController\")` — full detail"
|
|
102
|
+
lines << ""
|
|
103
|
+
lines << "### Other tools"
|
|
104
|
+
lines << "- `rails_get_config` — cache, session, middleware, timezone"
|
|
105
|
+
lines << "- `rails_get_test_info` — framework, factories, CI"
|
|
106
|
+
lines << "- `rails_get_gems` — categorized gem analysis"
|
|
107
|
+
lines << "- `rails_get_conventions` — architecture patterns"
|
|
108
|
+
lines << "- `rails_search_code(pattern:\"regex\", file_type:\"rb\", max_results:20)`"
|
|
88
109
|
lines << ""
|
|
89
110
|
|
|
90
111
|
# Rules
|
|
@@ -21,7 +21,8 @@ module RailsAiContext
|
|
|
21
21
|
skipped = []
|
|
22
22
|
|
|
23
23
|
files = {
|
|
24
|
-
"rails-context.md" => render_context_rule
|
|
24
|
+
"rails-context.md" => render_context_rule,
|
|
25
|
+
"rails-mcp-tools.md" => render_mcp_tools_rule
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
files.each do |filename, content|
|
|
@@ -47,6 +48,37 @@ module RailsAiContext
|
|
|
47
48
|
# Reuse WindsurfSerializer content
|
|
48
49
|
WindsurfSerializer.new(context).call
|
|
49
50
|
end
|
|
51
|
+
|
|
52
|
+
def render_mcp_tools_rule # rubocop:disable Metrics/MethodLength
|
|
53
|
+
lines = [
|
|
54
|
+
"# MCP Tool Reference",
|
|
55
|
+
"",
|
|
56
|
+
"Detail levels: summary | standard (default) | full",
|
|
57
|
+
"",
|
|
58
|
+
"## Schema",
|
|
59
|
+
"rails_get_schema(table:\"name\"|detail:\"summary\"|limit:N|offset:N)",
|
|
60
|
+
"",
|
|
61
|
+
"## Models",
|
|
62
|
+
"rails_get_model_details(model:\"Name\"|detail:\"summary\")",
|
|
63
|
+
"",
|
|
64
|
+
"## Routes",
|
|
65
|
+
"rails_get_routes(controller:\"name\"|detail:\"summary\"|limit:N|offset:N)",
|
|
66
|
+
"",
|
|
67
|
+
"## Controllers",
|
|
68
|
+
"rails_get_controllers(controller:\"Name\"|detail:\"summary\")",
|
|
69
|
+
"",
|
|
70
|
+
"## Other",
|
|
71
|
+
"- rails_get_config — cache, session, middleware",
|
|
72
|
+
"- rails_get_test_info — framework, factories, CI",
|
|
73
|
+
"- rails_get_gems — categorized gems",
|
|
74
|
+
"- rails_get_conventions — architecture patterns",
|
|
75
|
+
"- rails_search_code(pattern:\"regex\"|file_type:\"rb\"|max_results:N)",
|
|
76
|
+
"",
|
|
77
|
+
"Start with detail:\"summary\", then drill into specifics."
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
lines.join("\n")
|
|
81
|
+
end
|
|
50
82
|
end
|
|
51
83
|
end
|
|
52
84
|
end
|
|
@@ -71,17 +71,19 @@ module RailsAiContext
|
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
-
# MCP tools
|
|
75
|
-
lines << "# MCP
|
|
76
|
-
lines << "
|
|
77
|
-
lines << "-
|
|
78
|
-
lines << "-
|
|
79
|
-
lines << "-
|
|
80
|
-
lines << "-
|
|
81
|
-
lines << "-
|
|
74
|
+
# MCP tools — compact but complete (character budget is tight)
|
|
75
|
+
lines << "# MCP Tools (detail:\"summary\"|\"standard\"|\"full\")"
|
|
76
|
+
lines << "- rails_get_schema(table:\"name\"|detail:\"summary\"|limit:N|offset:N)"
|
|
77
|
+
lines << "- rails_get_model_details(model:\"Name\"|detail:\"summary\")"
|
|
78
|
+
lines << "- rails_get_routes(controller:\"name\"|detail:\"summary\"|limit:N|offset:N)"
|
|
79
|
+
lines << "- rails_get_controllers(controller:\"Name\"|detail:\"summary\")"
|
|
80
|
+
lines << "- rails_get_config — cache, session, middleware"
|
|
81
|
+
lines << "- rails_get_test_info — framework, factories, CI"
|
|
82
|
+
lines << "- rails_get_gems — categorized gems"
|
|
83
|
+
lines << "- rails_get_conventions — architecture patterns"
|
|
84
|
+
lines << "- rails_search_code(pattern:\"regex\"|file_type:\"rb\"|max_results:N)"
|
|
85
|
+
lines << "Start with detail:\"summary\", then drill into specifics."
|
|
82
86
|
lines << ""
|
|
83
|
-
|
|
84
|
-
# Conventions
|
|
85
87
|
lines << "# Rules"
|
|
86
88
|
lines << "- Follow existing patterns"
|
|
87
89
|
lines << "- Check schema via MCP before writing migrations"
|
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.7.
|
|
4
|
+
version: 0.7.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- crisnahine
|
|
@@ -265,8 +265,8 @@ metadata:
|
|
|
265
265
|
post_install_message: |
|
|
266
266
|
rails-ai-context installed! Quick start:
|
|
267
267
|
rails generate rails_ai_context:install
|
|
268
|
-
rails ai:context # generate
|
|
269
|
-
rails ai:context:
|
|
268
|
+
rails ai:context # generate context files (compact mode)
|
|
269
|
+
rails ai:context:full # full dump (good for small apps)
|
|
270
270
|
rails ai:serve # start MCP server for Claude Code / Cursor
|
|
271
271
|
rdoc_options: []
|
|
272
272
|
require_paths:
|