rails-ai-bridge 4.1.0 → 4.3.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/.aider.conf.yml +23 -0
- data/.graphifyignore +19 -0
- data/.mutant.yml +29 -0
- data/.rubocop.yml +9 -0
- data/AGENTS.md +36 -7
- data/CHANGELOG.md +70 -0
- data/CLAUDE.md +7 -7
- data/CONTRIBUTING.md +2 -2
- data/GEMINI.md +7 -5
- data/README.md +49 -32
- data/Rakefile +2 -0
- data/SECURITY.md +10 -4
- data/docs/02-port-registry-resolution.md +1 -1
- data/docs/GUIDE.md +34 -7
- data/docs/devin-setup.md +3 -2
- data/docs/gem-general-improvements.md +12 -1
- data/docs/offline-mode.md +5 -0
- data/docs/port-registry-resolution.md +1 -1
- data/docs/registry-resolution.md +3 -3
- data/docs/skill-registry-guide.md +8 -8
- data/lib/generators/rails_ai_bridge/install/install_generator.rb +4 -0
- data/lib/rails_ai_bridge/config/introspection.rb +15 -1
- data/lib/rails_ai_bridge/config/output.rb +5 -0
- data/lib/rails_ai_bridge/config/registry.rb +47 -4
- data/lib/rails_ai_bridge/configuration.rb +2 -0
- data/lib/rails_ai_bridge/context_provider.rb +1 -1
- data/lib/rails_ai_bridge/doctor/checkers/registry_checker.rb +135 -0
- data/lib/rails_ai_bridge/doctor.rb +2 -1
- data/lib/rails_ai_bridge/engine.rb +1 -0
- data/lib/rails_ai_bridge/exclusion_helper.rb +70 -0
- data/lib/rails_ai_bridge/instrumentation.rb +30 -1
- data/lib/rails_ai_bridge/introspector.rb +11 -5
- data/lib/rails_ai_bridge/introspectors/action_mailbox_introspector.rb +6 -0
- data/lib/rails_ai_bridge/introspectors/asset_pipeline_introspector.rb +7 -0
- data/lib/rails_ai_bridge/introspectors/controller_introspector/filter_extractor.rb +118 -5
- data/lib/rails_ai_bridge/introspectors/controller_introspector.rb +10 -2
- data/lib/rails_ai_bridge/introspectors/database_stats_introspector.rb +8 -0
- data/lib/rails_ai_bridge/introspectors/devops_introspector.rb +7 -0
- data/lib/rails_ai_bridge/introspectors/i18n_introspector.rb +7 -0
- data/lib/rails_ai_bridge/introspectors/model_introspector/association_extractor.rb +2 -1
- data/lib/rails_ai_bridge/introspectors/model_introspector.rb +35 -3
- data/lib/rails_ai_bridge/introspectors/model_semantic_enrichment.rb +7 -1
- data/lib/rails_ai_bridge/introspectors/rake_task_introspector.rb +7 -0
- data/lib/rails_ai_bridge/introspectors/route_introspector.rb +57 -4
- data/lib/rails_ai_bridge/introspectors/schema/static_schema_parser.rb +4 -3
- data/lib/rails_ai_bridge/introspectors/schema/static_structure_sql_parser.rb +204 -13
- data/lib/rails_ai_bridge/introspectors/schema_introspector.rb +3 -2
- data/lib/rails_ai_bridge/introspectors/test_introspector.rb +8 -0
- data/lib/rails_ai_bridge/path_resolver.rb +67 -6
- data/lib/rails_ai_bridge/registry.rb +61 -1
- data/lib/rails_ai_bridge/resources.rb +87 -3
- data/lib/rails_ai_bridge/serializers/README.md +0 -1
- data/lib/rails_ai_bridge/serializers/formatters/providers/mcp_guide_formatter.rb +1 -0
- data/lib/rails_ai_bridge/serializers/json_serializer.rb +4 -0
- data/lib/rails_ai_bridge/serializers/providers/base_provider_serializer.rb +1 -1
- data/lib/rails_ai_bridge/serializers/providers/collaborators/rules_document_builder.rb +1 -1
- data/lib/rails_ai_bridge/serializers/providers/copilot_serializer.rb +7 -0
- data/lib/rails_ai_bridge/serializers/providers/mcp_tool_reference_formatter.rb +1 -0
- data/lib/rails_ai_bridge/serializers/shared_assistant_guidance.rb +39 -6
- data/lib/rails_ai_bridge/server.rb +4 -1
- data/lib/rails_ai_bridge/tasks/rails_ai_bridge.rake +1 -1
- data/lib/rails_ai_bridge/tools/README.md +4 -0
- data/lib/rails_ai_bridge/tools/confidence_tag.rb +34 -0
- data/lib/rails_ai_bridge/tools/explain_symbol/cli_explorer.rb +70 -0
- data/lib/rails_ai_bridge/tools/explain_symbol.rb +124 -0
- data/lib/rails_ai_bridge/tools/get_context/composer.rb +213 -0
- data/lib/rails_ai_bridge/tools/get_context/related_tests.rb +95 -0
- data/lib/rails_ai_bridge/tools/get_context/resolver.rb +320 -0
- data/lib/rails_ai_bridge/tools/get_context.rb +110 -0
- data/lib/rails_ai_bridge/tools/get_controllers.rb +19 -4
- data/lib/rails_ai_bridge/tools/get_model_details.rb +4 -3
- data/lib/rails_ai_bridge/tools/get_routes.rb +52 -7
- data/lib/rails_ai_bridge/tools/get_schema.rb +18 -2
- data/lib/rails_ai_bridge/tools/list_context_providers.rb +132 -0
- data/lib/rails_ai_bridge/tools/list_registry.rb +3 -3
- data/lib/rails_ai_bridge/tools/model_details/full_formatter.rb +3 -1
- data/lib/rails_ai_bridge/tools/model_details/single_model_formatter.rb +47 -3
- data/lib/rails_ai_bridge/tools/schema/full_formatter.rb +4 -2
- data/lib/rails_ai_bridge/tools/schema/standard_formatter.rb +20 -2
- data/lib/rails_ai_bridge/tools/schema/summary_formatter.rb +4 -2
- data/lib/rails_ai_bridge/tools/schema/table_formatter.rb +24 -3
- data/lib/rails_ai_bridge/tools/search_code.rb +31 -0
- data/lib/rails_ai_bridge/version.rb +1 -1
- data/lib/rails_ai_bridge/view_file_analyzer.rb +39 -1
- data/lib/tasks/perf.rake +27 -0
- data/rails-ai-bridge.gemspec +2 -8
- data/repomix.config.json +44 -0
- metadata +18 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d937341388cd5f16ca5c4df0bfb3e540b0aabd88f21fb7edd8a99c4109a504e2
|
|
4
|
+
data.tar.gz: 92b5ef03eed9e1a2a3c2f3161543e2f3143724e2af146b941a83b159ca9f7324
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '09bdcacd48c5a46c069a90468cd772b0179d4b5464cd48438923b27e8ac8e4895afbcaecfa08136bd70e51231d70a439dfb4ddc5b3b153488fa1f16caf1ed22c'
|
|
7
|
+
data.tar.gz: 64715803d3c38e8827dfdd9200bbed447663d5751854193f1ae5f5a818c8eb9f2a9aabbf14fc3c84bc1a79b47f48e8bf3007cd6b1f26f10c1dab98771f300f74
|
data/.aider.conf.yml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
read:
|
|
2
|
+
- AGENTS.md
|
|
3
|
+
- repomix.config.json
|
|
4
|
+
|
|
5
|
+
mcp_servers:
|
|
6
|
+
codegraph:
|
|
7
|
+
command: "/Users/igmarin/.local/bin/codegraph"
|
|
8
|
+
args:
|
|
9
|
+
- serve
|
|
10
|
+
- --mcp
|
|
11
|
+
- --path
|
|
12
|
+
- "/Volumes/minimini/Developer/Projects/rails-ai-bridge"
|
|
13
|
+
graphify:
|
|
14
|
+
command: "/Users/igmarin/.local/bin/graphify-mcp"
|
|
15
|
+
args:
|
|
16
|
+
- --graph
|
|
17
|
+
- "/Volumes/minimini/Developer/Projects/rails-ai-bridge/graphify-out/graph.json"
|
|
18
|
+
repomix:
|
|
19
|
+
command: "/opt/homebrew/bin/repomix"
|
|
20
|
+
args:
|
|
21
|
+
- --mcp
|
|
22
|
+
- --sandbox
|
|
23
|
+
- "/Volumes/minimini/Developer/Projects/rails-ai-bridge"
|
data/.graphifyignore
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.git
|
|
2
|
+
.idea
|
|
3
|
+
.cursor
|
|
4
|
+
.claude
|
|
5
|
+
.grok
|
|
6
|
+
.zed
|
|
7
|
+
.codegraph
|
|
8
|
+
graphify-out
|
|
9
|
+
repomix-output.xml
|
|
10
|
+
repomix-output.md
|
|
11
|
+
coverage
|
|
12
|
+
review-result.txt
|
|
13
|
+
rs-guard-metrics.json
|
|
14
|
+
*.gem
|
|
15
|
+
.DS_Store
|
|
16
|
+
tmp/
|
|
17
|
+
doc/
|
|
18
|
+
vendor/bundle/
|
|
19
|
+
coverage/
|
data/.mutant.yml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
# Mutant configuration for rails-ai-bridge critical paths.
|
|
3
|
+
#
|
|
4
|
+
# Run with: BUNDLE_GEMFILE=Gemfile-mutation bundle exec mutant run [subject expressions]
|
|
5
|
+
# Example: BUNDLE_GEMFILE=Gemfile-mutation bundle exec mutant run RailsAiBridge::Registry::FrontmatterParser
|
|
6
|
+
#
|
|
7
|
+
# The open-source usage mode is used because rails-ai-bridge is an
|
|
8
|
+
# open-source project. A commercial license is required for private
|
|
9
|
+
# repositories or advanced features (full operator set, isolation).
|
|
10
|
+
#
|
|
11
|
+
# Target: >80% mutation coverage on registry/tools.
|
|
12
|
+
#
|
|
13
|
+
# Subject expressions are passed on the CLI to target critical paths:
|
|
14
|
+
# RailsAiBridge::Registry — registry resolution
|
|
15
|
+
# RailsAiBridge::Tools — MCP tools
|
|
16
|
+
# RailsAiBridge::Tools::SearchCode::Validator
|
|
17
|
+
# RailsAiBridge::ViewFileAnalyzer
|
|
18
|
+
# RailsAiBridge::ExclusionHelper
|
|
19
|
+
# RailsAiBridge::Serializers — output serializers
|
|
20
|
+
usage: opensource
|
|
21
|
+
integration: rspec
|
|
22
|
+
includes:
|
|
23
|
+
- lib
|
|
24
|
+
- spec
|
|
25
|
+
requires:
|
|
26
|
+
- spec_helper
|
|
27
|
+
fail_fast: false
|
|
28
|
+
mutation:
|
|
29
|
+
timeout: 5.0
|
data/.rubocop.yml
CHANGED
|
@@ -9,6 +9,7 @@ AllCops:
|
|
|
9
9
|
- "vendor/**/*"
|
|
10
10
|
- "spec/internal/**/*"
|
|
11
11
|
- "gemfiles/**/*"
|
|
12
|
+
- ".mutant.yml"
|
|
12
13
|
Naming/FileName:
|
|
13
14
|
Exclude:
|
|
14
15
|
- "lib/rails-ai-bridge.rb"
|
|
@@ -39,6 +40,8 @@ Layout/LineLength:
|
|
|
39
40
|
Max: 180
|
|
40
41
|
Metrics/ModuleLength:
|
|
41
42
|
Max: 240
|
|
43
|
+
Exclude:
|
|
44
|
+
- "lib/rails_ai_bridge/resources.rb"
|
|
42
45
|
Metrics/MethodLength:
|
|
43
46
|
Max: 70
|
|
44
47
|
RSpec/NestedGroups:
|
|
@@ -57,6 +60,12 @@ RSpec/MultipleDescribes:
|
|
|
57
60
|
Enabled: false
|
|
58
61
|
RSpec/MessageSpies:
|
|
59
62
|
Enabled: false
|
|
63
|
+
RSpec/Output:
|
|
64
|
+
Exclude:
|
|
65
|
+
- "spec/support/perf_baseline.rb"
|
|
66
|
+
Rails/RakeEnvironment:
|
|
67
|
+
Exclude:
|
|
68
|
+
- "lib/tasks/*.rake"
|
|
60
69
|
Metrics/PerceivedComplexity:
|
|
61
70
|
Max: 35
|
|
62
71
|
Exclude:
|
data/AGENTS.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# AGENTS.md — rails-ai-bridge development guide
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Ruby gem that reads a Rails app and gives assistants that map over MCP and
|
|
4
|
+
committed context files. It does not write to the host database.
|
|
5
5
|
|
|
6
6
|
## Architecture
|
|
7
7
|
|
|
8
8
|
- `lib/rails_ai_bridge.rb` — Main entry point, public API (Zeitwerk autoloaded)
|
|
9
9
|
- `lib/rails_ai_bridge/configuration.rb` — User-facing config with presets (:standard, :full)
|
|
10
10
|
- `lib/rails_ai_bridge/introspector.rb` — Orchestrates sub-introspectors
|
|
11
|
-
- `lib/rails_ai_bridge/introspectors/` — Built-in introspector classes; `:standard` preset runs **9**, `:full` runs **
|
|
12
|
-
- `lib/rails_ai_bridge/tools/` —
|
|
13
|
-
- `lib/rails_ai_bridge/serializers/` — Output formatters (
|
|
11
|
+
- `lib/rails_ai_bridge/introspectors/` — Built-in introspector classes; `:standard` preset runs **9**, `:full` runs **27** (see `Configuration::PRESETS`). Registry: `Introspector::BUILTIN_INTROSPECTORS` (includes opt-in symbols such as `database_stats`, `non_ar_models` not listed in those presets).
|
|
12
|
+
- `lib/rails_ai_bridge/tools/` — 19 built-in MCP tools using the official mcp SDK (hosts can add more via `additional_tools`)
|
|
13
|
+
- `lib/rails_ai_bridge/serializers/` — Output formatters (claude, claude_rules, codex, cursor_rules, devin, devin_rules, copilot, copilot_instructions, gemini, rules, markdown, JSON)
|
|
14
14
|
- `lib/rails_ai_bridge/resources.rb` — MCP resources (static data AI clients read directly)
|
|
15
15
|
- `lib/rails_ai_bridge/server.rb` — MCP server configuration (stdio + HTTP transports)
|
|
16
16
|
- `lib/rails_ai_bridge/middleware.rb` — Rack middleware for auto-mounting MCP HTTP endpoint
|
|
@@ -30,10 +30,10 @@ structure to AI assistants via the Model Context Protocol (MCP).
|
|
|
30
30
|
6. **Diff-aware** — context regeneration skips unchanged files
|
|
31
31
|
7. **Per-assistant serializers** — each AI tool gets tailored output format
|
|
32
32
|
8. **Zeitwerk autoloading** — files loaded on-demand, not all upfront
|
|
33
|
-
9. **Introspector presets** — `:standard` (9 core) default, `:full` (
|
|
33
|
+
9. **Introspector presets** — `:standard` (9 core) default, `:full` (27 introspectors; optional extras such as `database_stats`, `non_ar_models`) for power users
|
|
34
34
|
10. **MCP auto-discovery** — `.mcp.json` generated by install generator
|
|
35
35
|
11. **Compact by default** — context files ≤150 lines, MCP tools use `detail` parameter (summary/standard/full)
|
|
36
|
-
12. **Per-tool split rules** — `.
|
|
36
|
+
12. **Per-tool split rules** — `.codex/`, `.cursor/rules/`, `.devin/rules/`, `.github/instructions/`
|
|
37
37
|
|
|
38
38
|
## Testing
|
|
39
39
|
|
|
@@ -54,9 +54,38 @@ Uses combustion gem for testing Rails engine behavior in isolation.
|
|
|
54
54
|
- `generate_context` returns `{ written: [], skipped: [] }` hash
|
|
55
55
|
- Zeitwerk autoloads all files — no `require_relative` needed for new classes
|
|
56
56
|
|
|
57
|
+
## Multi-Issue Workflow
|
|
58
|
+
|
|
59
|
+
When working on a milestone with 3+ issues:
|
|
60
|
+
|
|
61
|
+
- **Group** issues by independence — parallel work streams get one git worktree each
|
|
62
|
+
- **Stack** dependent PRs within a group using `gh stack` (each PR's base is the previous branch)
|
|
63
|
+
- **Merge** bottom-up: the first PR in a stack merges to `main`, then `gh stack rebase` restacks the rest
|
|
64
|
+
- **Clean up** worktrees after all PRs in a group are merged
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# One worktree per independent group
|
|
68
|
+
git worktree add ../project-worktrees/group-a -b group-a-branch
|
|
69
|
+
|
|
70
|
+
# Stack dependent PRs within a group
|
|
71
|
+
gh stack create "feat: description (#issue)"
|
|
72
|
+
|
|
73
|
+
# Restack after bottom PR merges
|
|
74
|
+
gh stack rebase
|
|
75
|
+
```
|
|
76
|
+
|
|
57
77
|
<!-- lean-ctx -->
|
|
58
78
|
## lean-ctx
|
|
59
79
|
|
|
60
80
|
Prefer lean-ctx MCP tools over native equivalents for token savings.
|
|
61
81
|
Full rules: @LEAN-CTX.md
|
|
62
82
|
<!-- /lean-ctx -->
|
|
83
|
+
|
|
84
|
+
## Code intelligence
|
|
85
|
+
|
|
86
|
+
Use these tools before dumping whole files or grepping the tree.
|
|
87
|
+
|
|
88
|
+
1. If `.codegraph/` exists, run `codegraph explore "<symbol or question>"` (or the CodeGraph MCP tools).
|
|
89
|
+
2. If `graphify-out/graph.json` exists, use Graphify (`graphify explain`, `graphify path`, or the Graphify MCP).
|
|
90
|
+
3. For a whole-repo pack, run `repomix` using `repomix.config.json`. Do not commit `repomix-output.*`.
|
|
91
|
+
4. Regenerate Graphify with `graphify extract . --backend deepseek --no-cluster` (DeepSeek is the global LLM). Rust workspaces also pass `--cargo`.
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,76 @@ 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
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [4.3.0] - 2026-08-16
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **PathResolver glob/file cap** — `config.introspection.max_files_per_path` (default `2000`) truncates `PathResolver#glob_for` and `#files_for` after a stable sort. Documented alongside `snapshot_ttl` (5s section snapshot; raise for HTTP MCP only), `cache_ttl` (30s), and `parallel_introspection` (off).
|
|
15
|
+
- **Inherited controller filters** (#190) — `rails_get_controllers` lists `before_action` / `after_action` filters from the controller and its ancestors. Filters whose `only` / `except` do not apply to any action are omitted. `detail: summary` stays at filter names; `standard` / `full` include the defining class. ActionFilter `only`/`except` conditions are parsed on Rails 7.1+.
|
|
16
|
+
- **MCP exclusion parity spec** (#186) — `spec/lib/rails_ai_bridge/mcp/exclusion_parity_spec.rb` fails when `Server::TOOLS` or resource templates grow without a policy entry, and asserts `excluded_models`, `excluded_tables`, `:regulated`, and `disabled_introspection_categories` do not leak omitted names through listing tools or `rails://` resources. Composite `rails_get_context` is a listing-surface policy row, invoked only when that tool is already in `Server::TOOLS` (#181).
|
|
17
|
+
- **`rails_explain_symbol` MCP tool** (#192) — optional in-process explanation of a `symbol` or `query` from a **local** CodeGraph index (`.codegraph/`). Runs `codegraph explore` with a timeout and argv arrays (no shell, no network). Missing index or CLI failure returns setup instructions (`codegraph init` / `codegraph index`) instead of raising. Always registered so doc-parity stays a single tool list. Built-in MCP tools: **19**.
|
|
18
|
+
- **`rails_get_context` MCP tool** (#181) — in-process composite for one model, controller, or feature (table + model + routes + controller actions/filters + cheap related tests). Reuses `[VERIFIED]` / `[INFERRED]` tags from #187. No HTTP; provider fan-out stays on a different name. Built-in MCP tools: **19**.
|
|
19
|
+
- **Confidence tags on schema and model MCP tools** (#187) — `rails_get_schema` and `rails_get_model_details` markdown now marks facts as `[VERIFIED]` (live ActiveRecord reflection or rubydex/Prism) or `[INFERRED]` (source-regex macros and static schema parses). Missing sections are omitted rather than tagged empty.
|
|
20
|
+
- **Shared anti-hallucination rules in compact assistant files** (#188) — compact Claude, Cursor, Copilot, Codex, Gemini, and `AGENTS.md` output now include a short verify-before-write block from `SharedAssistantGuidance`. Disable with `config.output.anti_hallucination_rules = false` (default: on).
|
|
21
|
+
- **`rails_get_routes` URL helpers and required params** (#191) — named routes now include the Rails path helper (from the route set's declared name, e.g. `post_path`) and required parameter names (from Journey `required_parts`). Unnamed routes are left without a helper. Summary stays a compact per-controller overview (counts plus one sample helper); standard/full list helpers and required params (paginated).
|
|
22
|
+
- **Partition-child tables in `structure.sql` introspection** (#166) — `StaticStructureSqlParser` now expands PostgreSQL `CREATE TABLE … PARTITION OF …` children as table entries with `partition_of` / `partition_bound`, and marks parents with `partitioned` / `partition_by`. `rails_get_schema` surfaces the parent/child relationship at `detail: standard` and `full`.
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- **Public docs wording** (#212) — README, GUIDE, and AGENTS/CLAUDE/GEMINI openers say what the gem does in plain language. Comparison table is four durable rows (setup, files in git, read-only, presets) instead of tool-count marketing.
|
|
27
|
+
- **Skunk CI gate ratcheted to 20 and made blocking** (#183) — measured 4.2/4.3 SkunkScore averages were 15.93, 15.97, 15.96, 16.18, 15.89 (mean ≈ 15.99). Threshold 20 leaves ~25% headroom above the worst sample. The skunk job still runs rspec first for coverage. Perf stays advisory (`continue-on-error`). Mutation stays advisory but now also targets `Tools::SearchCode::Validator`, `ViewFileAnalyzer`, and `ExclusionHelper`.
|
|
28
|
+
- **Advisory perf compare** — `rake perf:compare` takes the median of five iterations after one warmup. `introspection_time_sec` rebased to 0.028s after 4.3 schema/routes work (CI was 0.0269s on main, 0.0277s with PathResolver realpath). Context and MCP baselines stay at their 4.2 values because CI still measures well under them.
|
|
29
|
+
- **Documentation and gemspec humanization** (#189) — gemspec is one plain sentence (maps a Rails
|
|
30
|
+
app so assistants stop guessing); Windsurf dropped from the gemspec; `:full` YARD comment is 27
|
|
31
|
+
to match `Configuration::PRESETS[:full]`; README comparison uses four durable rows
|
|
32
|
+
(zero-config, committed files, read-only, presets) plus a dated checked-against line;
|
|
33
|
+
`docs/gem-general-improvements.md` marked done-in-4.1; `docs/offline-mode.md` labeled
|
|
34
|
+
5.0 / registry. SECURITY.md outbound policy unchanged (git packs only).
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
- **`Config::Introspection#preset=` accepts `nil`** — `preset = nil` now sets `@preset` to `nil` and leaves `introspectors` unchanged, so around-hooks can restore an unset preset. Named presets (`:standard`, `:regulated`, `:full`) are unchanged.
|
|
39
|
+
- **Namespaced model exclusions no longer collide on the last path segment** — `excluded_models: ['User']` still matches `User` / `Users` / `users` / `UsersController`, but not `Admin::User`, `Admin::UsersController`, `UserSession`, or `Superuser`. `excluded_models: ['Admin::User']` matches `Admin::User` and `Admin::UsersController` only. Table-only exclusions are unchanged (`patient_records` still drops `PatientRecord`).
|
|
40
|
+
- **MCP `fetch_section` honored disabled introspectors** (#186) — `Introspector#selected_introspectors` now intersects `only:` with `effective_introspectors`, so `:regulated` and `disabled_introspection_categories` cannot be bypassed by `rails_get_schema` / `rails://schema`.
|
|
41
|
+
- **Excluded association names no longer leak via model details** (#186) — associations, generated accessors, and rubydex `similar_models` that name an excluded model or table are omitted from MCP output.
|
|
42
|
+
- **`similar_models` honors `excluded_tables`** (#186) — rubydex sibling names such as `PatientRecord` are dropped when only `patient_records` is excluded (`ExclusionHelper.excluded_class_or_table?`).
|
|
43
|
+
- **Routes and controllers honor model or table exclusions** (#186) — `RouteIntrospector` and `ControllerIntrospector` omit `/users` and `UsersController` when `excluded_models` includes `User` or `excluded_tables` includes `users`. Conventions stay a non-inventory surface (`:does_not_list_models_or_tables`).
|
|
44
|
+
|
|
45
|
+
### Security
|
|
46
|
+
|
|
47
|
+
- **HTTP MCP auth defaults documented more clearly** — README and SECURITY.md now lead with: HTTP MCP is unauthenticated unless you set a token or `require_http_auth`; bind to `127.0.0.1` unless you add auth. Default remains `require_http_auth = false`.
|
|
48
|
+
- **`PathResolver` symlink escape** — existing files from `existing_file_for` and `glob_for` are accepted only when `File.realpath` stays inside the realpath of the resolved directory or the application root. File and directory symlinks under a configured path that point outside the root are omitted. Missing paths still return `nil` without calling `realpath`. Allowed roots are realpathed once per resolver instance.
|
|
49
|
+
- **`ViewFileAnalyzer` symlink escape** (#185) — existing view files are resolved with `File.realpath` and compared against the realpath of every configured `app/views` root (including custom Rails paths). A symlink under views that points outside every root now raises `SecurityError` instead of emitting the target file contents.
|
|
50
|
+
|
|
51
|
+
## [4.2.0] - 2026-08-13
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
|
|
55
|
+
- **`rails_list_context_providers` MCP tool and dynamic resources** (#147) — new tool reads the registry manifest's `context_providers` section and returns formatted markdown with provider name, type, endpoint, optional flag, and tool specs. Context providers are also registered as dynamic MCP resources (URI template `rails://context-providers/{name}`), bringing the tool count from 16 to 17.
|
|
56
|
+
- **Registry health checker for Doctor** (#145) — new `Doctor::Checkers::RegistryChecker` validates manifest existence, JSON parsing, `RegistryManifest.validate!`, resolver construction, and lockfile presence (when configured). Returns pass/warn/fail with actionable fix hints. Doctor check count: 17.
|
|
57
|
+
- **Request-level resolver memoization** (#159) — `Registry.with_request_resolver` wraps each tool invocation in a thread-local request scope so `build_resolver` is called once per request instead of once per tool. Nil results are never memoized; thread-local storage is always cleaned up (even on error).
|
|
58
|
+
- **Dependabot configuration** (#153) — `.github/dependabot.yml` with grouped updates for bundler, github-actions, and gomod ecosystems, plus automatic PR labeling.
|
|
59
|
+
- **Rails 8.1 in release workflow matrix** (#164) — `.github/workflows/release.yml` now includes Rails 8.1 alongside 7.1, 7.2, and 8.0.
|
|
60
|
+
- **Skunk score threshold CI job** (#157) — advisory CI job runs `skunk lib/` after tests generate coverage data, fails if the SkunkScore average exceeds 30. Threshold to be ratcheted down over time.
|
|
61
|
+
- **Performance regression baseline** (#160) — `spec/support/perf_baseline.json` with three metrics (introspection, context generation, MCP tool response). `rake perf:compare` fails on >20% regression. CI uploads the baseline as a 30-day artifact.
|
|
62
|
+
- **Mutation testing for critical paths** (#163) — `mutant-rspec` via separate `Gemfile-mutation` (eval'd from the main Gemfile) to avoid breaking Ruby 3.2 CI resolution. Advisory CI job targets `Registry::Resolver`, `FrontmatterParser`, `RegistryManifest`, `PackResolver`, `SkillSourceResolver`, and key tools/serializers. Initial coverage: 94.39% on `FrontmatterParser`.
|
|
63
|
+
- **YARD documentation for 9 uncovered files** (#156) — `@param`/`@return` tags added to `search_code.rb`, all 6 introspectors, `json_serializer.rb`, and `usage_formatter.rb`. `yard stats` now 100% for `lib/`.
|
|
64
|
+
- **Dedicated `UsageFormatter` spec** (#151) — comprehensive spec coverage for `Tools::UsageFormatter` formatting logic.
|
|
65
|
+
- **Registry server specs and integration tests** (#149, #150) — `server_spec.rb` extended with registry tool assertions; new `mcp/registry_integration_spec.rb` covers `rails_list_registry`, `rails_resolve_skill`, and `rails_use_skill` end-to-end through the MCP server.
|
|
66
|
+
- **Documentation parity guard spec** — `spec/lib/rails_ai_bridge/doc_parity_spec.rb` fails when README/AGENTS/CLAUDE tool or introspector counts drift from the actual constants.
|
|
67
|
+
|
|
68
|
+
### Changed
|
|
69
|
+
|
|
70
|
+
- **Standardized registry manifest and lockfile paths** (#155) — defaults changed from `config/rails_ai_bridge_registry.json` / `config/rails_ai_bridge_registry.lock` to `config/rails_ai_bridge/registry.json` / `config/rails_ai_bridge/registry.lock`. Backward-compat fallback: when the new path doesn't exist but the legacy path does, the getter returns the legacy path. Custom user paths are never overridden.
|
|
71
|
+
- **Documentation humanization and Windsurf purge** (#144, #148) — README, AGENTS.md, CLAUDE.md, CONTRIBUTING.md, and SECURITY.md updated: tool count 16→17, introspector count 26→27, serializer list humanized (alphabetical with Claude/Codex/Gemini), bogus `.Codex/rules/` path fixed to `.codex/`, Windsurf support claims removed (no serializer will be implemented), Mermaid diagrams added to docs.
|
|
72
|
+
|
|
73
|
+
### Fixed
|
|
74
|
+
|
|
75
|
+
- **`Instrumentation::InstrumentedTool` server_context parameter translation** — tools without caching received `server_context:` but expected `_server_context:`, causing `ArgumentError` when caching was disabled. `InstrumentedTool` now detects the tool's parameter name and translates accordingly.
|
|
76
|
+
- **`ContextProvider` cache key fork safety** (#162) — replaced `object_id`-based cache key with a stable digest, preventing stale cache hits after `Process.fork`.
|
|
77
|
+
|
|
8
78
|
## [4.1.0] - 2026-08-11
|
|
9
79
|
|
|
10
80
|
### Added
|
data/CLAUDE.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# CLAUDE.md — rails-ai-bridge development guide
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Ruby gem that reads a Rails app and gives assistants that map over MCP and
|
|
4
|
+
committed context files. It does not write to the host database.
|
|
5
5
|
|
|
6
6
|
## Architecture
|
|
7
7
|
|
|
@@ -9,14 +9,14 @@ structure to AI assistants via the Model Context Protocol (MCP).
|
|
|
9
9
|
- `lib/rails_ai_bridge/configuration.rb` — User-facing config with presets (:standard, :full)
|
|
10
10
|
- `lib/rails_ai_bridge/introspector.rb` — Orchestrates sub-introspectors
|
|
11
11
|
- `lib/rails_ai_bridge/introspectors/` — Built-in introspector classes; `:standard` preset
|
|
12
|
-
runs **9**, `:full` runs **
|
|
12
|
+
runs **9**, `:full` runs **27** (see `Configuration::PRESETS`). Registry:
|
|
13
13
|
`Introspector::BUILTIN_INTROSPECTORS` (includes opt-in symbols such as
|
|
14
14
|
`database_stats`, `non_ar_models` not listed in those presets).
|
|
15
|
-
- `lib/rails_ai_bridge/tools/` —
|
|
15
|
+
- `lib/rails_ai_bridge/tools/` — 19 built-in MCP tools using the official mcp SDK
|
|
16
16
|
(hosts can add more via `additional_tools`)
|
|
17
17
|
- `lib/rails_ai_bridge/serializers/` — Output formatters (claude, claude_rules,
|
|
18
|
-
cursor_rules, devin, devin_rules, copilot, copilot_instructions,
|
|
19
|
-
markdown, JSON)
|
|
18
|
+
codex, cursor_rules, devin, devin_rules, copilot, copilot_instructions,
|
|
19
|
+
gemini, rules, markdown, JSON)
|
|
20
20
|
- `lib/rails_ai_bridge/resources.rb` — MCP resources (static data AI clients read directly)
|
|
21
21
|
- `lib/rails_ai_bridge/server.rb` — MCP server configuration (stdio + HTTP transports)
|
|
22
22
|
- `lib/rails_ai_bridge/middleware.rb` — Rack middleware for auto-mounting MCP HTTP endpoint
|
|
@@ -36,7 +36,7 @@ structure to AI assistants via the Model Context Protocol (MCP).
|
|
|
36
36
|
6. **Diff-aware** — context regeneration skips unchanged files
|
|
37
37
|
7. **Per-assistant serializers** — each AI tool gets tailored output format
|
|
38
38
|
8. **Zeitwerk autoloading** — files loaded on-demand, not all upfront
|
|
39
|
-
9. **Introspector presets** — `:standard` (9 core) default, `:full` (
|
|
39
|
+
9. **Introspector presets** — `:standard` (9 core) default, `:full` (27 introspectors; optional extras such as `database_stats`, `non_ar_models`) for power users
|
|
40
40
|
10. **MCP auto-discovery** — `.mcp.json` generated by install generator
|
|
41
41
|
11. **Compact by default** — context files ≤150 lines, MCP tools use `detail` parameter (summary/standard/full)
|
|
42
42
|
12. **Per-tool split rules** — `.claude/rules/`, `.cursor/rules/`, `.devin/rules/`, `.github/instructions/`
|
data/CONTRIBUTING.md
CHANGED
|
@@ -19,13 +19,13 @@ The test suite uses [Combustion](https://github.com/pat/combustion) to boot a mi
|
|
|
19
19
|
```
|
|
20
20
|
lib/rails_ai_bridge/
|
|
21
21
|
├── introspectors/ # Built-in introspectors (schema, models, non_ar_models, routes, …)
|
|
22
|
-
├── tools/ #
|
|
22
|
+
├── tools/ # 19 built-in MCP tools (detail levels, pagination, extensible)
|
|
23
23
|
├── rubydex_adapter.rb # Rubydex API wrapper (singleton + query interface + stats)
|
|
24
24
|
├── rubydex_adapter/ # Extracted collaborators (one concern each)
|
|
25
25
|
│ ├── serializer.rb # Hash serialization (declaration_to_hash, definition_to_hash, …)
|
|
26
26
|
│ ├── indexer.rb # Graph building + source file scanning
|
|
27
27
|
│ └── method_counter.rb # Flat method counting pipeline (no nested conditionals)
|
|
28
|
-
├── serializers/ # Per-assistant formatters (claude, cursor,
|
|
28
|
+
├── serializers/ # Per-assistant formatters (claude, codex, cursor, devin, copilot, gemini, JSON)
|
|
29
29
|
├── server.rb # MCP server setup (stdio + HTTP)
|
|
30
30
|
├── engine.rb # Rails Engine for auto-integration
|
|
31
31
|
└── configuration.rb # User-facing config (presets, context_mode, limits)
|
data/GEMINI.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# GEMINI.md — rails-ai-bridge development guide
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Ruby gem that reads a Rails app and gives assistants that map over MCP and
|
|
4
|
+
committed context files. It does not write to the host database.
|
|
5
5
|
|
|
6
6
|
## Architecture
|
|
7
7
|
|
|
@@ -9,8 +9,9 @@ structure to AI assistants via the Model Context Protocol (MCP).
|
|
|
9
9
|
- `lib/rails_ai_bridge/configuration.rb` — User-facing config with presets (:standard, :full)
|
|
10
10
|
- `lib/rails_ai_bridge/introspector.rb` — Orchestrates sub-introspectors
|
|
11
11
|
- `lib/rails_ai_bridge/introspectors/` — Built-in introspector classes; `:standard` preset runs **9**, `:full` runs **26** (see `Configuration::PRESETS`). Registry: `Introspector::BUILTIN_INTROSPECTORS` (includes opt-in symbols such as `database_stats`, `non_ar_models` not listed in those presets).
|
|
12
|
-
- `lib/rails_ai_bridge/tools/` —
|
|
12
|
+
- `lib/rails_ai_bridge/tools/` — 19 built-in MCP tools using the official mcp SDK (hosts can add more via `additional_tools`)
|
|
13
13
|
- `lib/rails_ai_bridge/serializers/` — Output formatters (claude, claude_rules, cursor_rules, windsurf, windsurf_rules, copilot, copilot_instructions, rules, markdown, JSON, gemini)
|
|
14
|
+
runs **9**, `:full` runs **27** (see `Configuration::PRESETS`). Registry:
|
|
14
15
|
- `lib/rails_ai_bridge/resources.rb` — MCP resources (static data AI clients read directly)
|
|
15
16
|
- `lib/rails_ai_bridge/server.rb` — MCP server configuration (stdio + HTTP transports)
|
|
16
17
|
- `lib/rails_ai_bridge/middleware.rb` — Rack middleware for auto-mounting MCP HTTP endpoint
|
|
@@ -30,10 +31,11 @@ structure to AI assistants via the Model Context Protocol (MCP).
|
|
|
30
31
|
6. **Diff-aware** — context regeneration skips unchanged files
|
|
31
32
|
7. **Per-assistant serializers** — each AI tool gets tailored output format
|
|
32
33
|
8. **Zeitwerk autoloading** — files loaded on-demand, not all upfront
|
|
33
|
-
9. **Introspector presets** — `:standard` (9 core) default, `:full` (
|
|
34
|
+
9. **Introspector presets** — `:standard` (9 core) default, `:full` (27 introspectors;
|
|
35
|
+
optional extras such as `database_stats`, `non_ar_models`) for power users
|
|
34
36
|
10. **MCP auto-discovery** — `.mcp.json` generated by install generator
|
|
35
37
|
11. **Compact by default** — context files ≤150 lines, MCP tools use `detail` parameter (summary/standard/full)
|
|
36
|
-
12. **Per-tool split rules** — `.
|
|
38
|
+
12. **Per-tool split rules** — `.codex/`, `.cursor/rules/`, `.devin/rules/`, `.github/instructions/`
|
|
37
39
|
|
|
38
40
|
## Testing
|
|
39
41
|
|
data/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> Maps your Rails app so assistants stop guessing table names, routes, and conventions.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The install generator writes compact context files and starts a read-only MCP server. Assistants can read the files at session start, then ask for one model, table, or controller when they need detail.
|
|
8
8
|
|
|
9
9
|
[](https://rubygems.org/gems/rails-ai-bridge)
|
|
10
10
|
[](https://github.com/igmarin/rails-ai-bridge/actions)
|
|
@@ -24,7 +24,7 @@ rails-ai-bridge turns a Rails app into an AI-readable project map:
|
|
|
24
24
|
- **A read-only MCP server** lets assistants ask for exact details only when needed, such as one model, one table, one controller, or one route group.
|
|
25
25
|
- **Assistant-specific output** keeps Claude Code, Cursor, Codex, Copilot, Devin, Gemini, and JSON consumers aligned without making you hand-write context files.
|
|
26
26
|
|
|
27
|
-
The
|
|
27
|
+
The point is that generated code should match this app, not a generic Rails tutorial.
|
|
28
28
|
|
|
29
29
|
## Start here
|
|
30
30
|
|
|
@@ -52,7 +52,7 @@ This is useful when you want an AI assistant to work inside a real Rails codebas
|
|
|
52
52
|
- A team that wants shared AI guidance committed to the repo
|
|
53
53
|
- Large schemas where dumping everything into context would be noisy
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
Skip this on a tiny app or a one-off script. On a team app with real models and conventions, generated files plus MCP beat a hand-written notes file.
|
|
56
56
|
|
|
57
57
|
---
|
|
58
58
|
|
|
@@ -74,23 +74,23 @@ flowchart LR
|
|
|
74
74
|
|
|
75
75
|
1. **Introspect**: built-in scanners read your Rails app structure: schema, models, routes, controllers, gems, tests, conventions, and optional full-stack details.
|
|
76
76
|
2. **Generate**: `rails ai:bridge` writes compact, assistant-specific files such as `AGENTS.md`, `CLAUDE.md`, `.cursor/rules/`, and Copilot instructions.
|
|
77
|
-
3. **Serve**: `rails ai:serve` exposes read-only `rails_*`
|
|
77
|
+
3. **Serve**: `rails ai:serve` exposes 19 read-only `rails_*` tools so an assistant can drill into exact details on demand.
|
|
78
78
|
|
|
79
79
|
This creates two complementary layers:
|
|
80
80
|
|
|
81
81
|
| Layer | What it does | Why it matters |
|
|
82
82
|
|---|---|---|
|
|
83
|
-
| Static files |
|
|
84
|
-
| MCP tools |
|
|
83
|
+
| Static files | Overview the assistant sees when the session starts | Less time spent rediscovering models and routes |
|
|
84
|
+
| MCP tools | Exact live details when the assistant asks | Smaller prompts; fewer invented columns and helpers |
|
|
85
85
|
|
|
86
|
-
Compact files are ordered for usefulness: primary domain models, busy endpoints, recently migrated tables, and optional hot-table
|
|
86
|
+
Compact files are ordered for usefulness: primary domain models, busy endpoints, recently migrated tables, and optional hot-table hints appear before less important details.
|
|
87
87
|
|
|
88
88
|
## Safety model
|
|
89
89
|
|
|
90
90
|
- MCP tools are **read-only**. They inspect Rails structure; they do not write files or mutate the database.
|
|
91
91
|
- `database_stats` is **opt-in** because it queries PostgreSQL table statistics.
|
|
92
92
|
- Generated assistant context avoids credential values and suppresses secret-bearing config paths such as `.env*`, Rails credentials, `master.key`, private key material, and custom `config/secrets` or `config/private` files.
|
|
93
|
-
- HTTP MCP
|
|
93
|
+
- HTTP MCP is unauthenticated unless you set a token or `require_http_auth`. Bind to `127.0.0.1` unless you add auth. See [docs/mcp-security.md](docs/mcp-security.md).
|
|
94
94
|
|
|
95
95
|
---
|
|
96
96
|
|
|
@@ -152,23 +152,23 @@ Optional: `gem install rails-ai-bridge` installs the gem into your Ruby environm
|
|
|
152
152
|
|
|
153
153
|
---
|
|
154
154
|
|
|
155
|
-
##
|
|
155
|
+
## Compared with writing the files yourself, or rails-mcp-server
|
|
156
156
|
|
|
157
|
-
| | **rails-ai-bridge** | **[rails-mcp-server](https://github.com/maquina-app/rails-mcp-server)** | **
|
|
157
|
+
| | **rails-ai-bridge** | **[rails-mcp-server](https://github.com/maquina-app/rails-mcp-server)** | **Hand-written notes** |
|
|
158
158
|
| --- | --- | --- | --- |
|
|
159
|
-
|
|
|
160
|
-
|
|
|
161
|
-
|
|
|
162
|
-
|
|
|
163
|
-
| Auto-introspection | Yes — up to **27** domains (`:full`) | No — server points at projects you configure | DIY |
|
|
159
|
+
| Setup | Railtie and an install generator | Per-project `projects.yml` | You write everything |
|
|
160
|
+
| Files in git | Assistant files committed in the app | Configured projects only | Whatever you remember to commit |
|
|
161
|
+
| Read-only | Inspects structure; does not write or mutate | Yes | Yes |
|
|
162
|
+
| Presets | `:standard`, `:full`, and `:regulated` | No | No |
|
|
164
163
|
|
|
165
|
-
*
|
|
164
|
+
*Checked against rails-mcp-server README and typical manual-context workflows on 2026-08-15.
|
|
165
|
+
This table lists durable product differences, not tool or introspector counts that change release to release.*
|
|
166
166
|
|
|
167
167
|
---
|
|
168
168
|
|
|
169
|
-
## What
|
|
169
|
+
## What `rails ai:bridge` writes
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
It writes one set of files per assistant. Compact files stay near 150 lines. Split rules live next to the tool that reads them:
|
|
172
172
|
|
|
173
173
|
```text
|
|
174
174
|
your-rails-app/
|
|
@@ -229,7 +229,7 @@ Each file respects the AI tool's format and size limits. **Commit these files**
|
|
|
229
229
|
| **Models** | Associations, validations, scopes, enums, callbacks, concerns, macros (`has_secure_password`, `encrypts`, `normalizes`, etc.), **semantic tier** (`core_entity`, `pure_join`, `rich_join`, `supporting`) |
|
|
230
230
|
| **Non-AR Models** | Ruby classes under the configured logical `app/models` path that aren't ActiveRecord, tagged as `[POJO/Service]` (included in `:full`, or opt in with `:non_ar_models`) |
|
|
231
231
|
| **Routing** | Every route with HTTP verbs, paths, controller actions, API namespaces, plus compact endpoint-focus summaries for busy controllers |
|
|
232
|
-
| **Controllers** | Actions, filters, strong params, concerns, API controllers; source metadata honors configured controller paths |
|
|
232
|
+
| **Controllers** | Actions, inherited filters (with `only`/`except` and source class), strong params, concerns, API controllers; source metadata honors configured controller paths |
|
|
233
233
|
| **Views** | Layouts, templates, partials, helpers, template engines, view components |
|
|
234
234
|
| **Frontend** | Stimulus controllers, views, Turbo Frames/Streams, and broadcasts from configured Rails paths |
|
|
235
235
|
| **Background** | ActiveJob classes, mailers, Action Cable channels |
|
|
@@ -251,14 +251,15 @@ This keeps context focused and avoids unnecessary token usage while still allowi
|
|
|
251
251
|
|
|
252
252
|
## MCP Tools
|
|
253
253
|
|
|
254
|
-
The gem exposes **
|
|
254
|
+
The gem exposes **19 built-in tools** via MCP that AI clients call on-demand (hosts can append more via `config.additional_tools`):
|
|
255
255
|
|
|
256
256
|
| Tool | What it returns |
|
|
257
257
|
|------|----------------|
|
|
258
|
-
| `rails_get_schema` | Tables, columns, indexes, foreign keys |
|
|
259
|
-
| `rails_get_model_details` | Associations, validations, scopes, enums, callbacks, semantic tier, non-AR models (when enabled) |
|
|
258
|
+
| `rails_get_schema` | Tables, columns, indexes, foreign keys — tagged `[VERIFIED]` (live ActiveRecord) or `[INFERRED]` (static schema.rb / structure.sql parse) |
|
|
259
|
+
| `rails_get_model_details` | Associations, validations, scopes, enums, callbacks, source macros, semantic tier, non-AR models (when enabled) — tagged `[VERIFIED]` (reflection / rubydex) or `[INFERRED]` (source regex) |
|
|
260
|
+
| `rails_get_context` | In-process composite for one model, controller, or feature: table + model + routes + controller actions + cheap related tests (no HTTP) |
|
|
260
261
|
| `rails_get_routes` | HTTP verbs, paths, controller actions |
|
|
261
|
-
| `rails_get_controllers` | Actions, filters, strong params, concerns |
|
|
262
|
+
| `rails_get_controllers` | Actions, inherited filters (source class at standard/full), strong params, concerns |
|
|
262
263
|
| `rails_get_config` | Cache, session, timezone, middleware, initializers |
|
|
263
264
|
| `rails_get_test_info` | Test framework, factories, CI config, coverage |
|
|
264
265
|
| `rails_get_gems` | Notable gems categorized by function |
|
|
@@ -266,11 +267,13 @@ The gem exposes **16 built-in tools** via MCP that AI clients call on-demand (ho
|
|
|
266
267
|
| `rails_search_code` | Ripgrep (or Ruby) search under `Rails.root` with allowlisted extensions, pattern size cap, and optional wall-clock timeout |
|
|
267
268
|
| `rails_get_view` | View layouts, templates, partials; optional per-file detail under the configured `app/views` path |
|
|
268
269
|
| `rails_search_semantic` | Semantic code search using rubydex — find declarations by name with types, locations, and relationships |
|
|
270
|
+
| `rails_explain_symbol` | Local CodeGraph explanation for a `symbol` or `query` when `.codegraph/` exists; otherwise setup instructions |
|
|
269
271
|
| `rails_get_stimulus` | Stimulus controllers: targets, values, actions, outlets (requires `:stimulus` introspector) |
|
|
270
|
-
| `rails_list_registry` | Skill pack catalog — list skills, agents, or active packs; requires `config/
|
|
272
|
+
| `rails_list_registry` | Skill pack catalog — list skills, agents, or active packs; requires `config/rails_ai_bridge/registry.json` |
|
|
271
273
|
| `rails_resolve_skill` | Full content of a named skill or agent from the registry (priority ordering + deprecation redirects); optional `pack=` pin and `type=agent` |
|
|
272
274
|
| `rails_use_skill` | Loads a skill framed as an application directive (apply it step by step to the current task) |
|
|
273
275
|
| `rails_use_agent` | Loads an agent/workflow framed as an activation directive (follow it end to end) |
|
|
276
|
+
| `rails_list_context_providers` | Context providers declared in the registry manifest — external services (e.g. MCP servers) the bridge can query for project context; shows type, endpoint, optional flag, and tool specs |
|
|
274
277
|
|
|
275
278
|
All tools are **read-only** — they never modify your application or database.
|
|
276
279
|
|
|
@@ -307,7 +310,7 @@ A safety net (`max_tool_response_chars`, default 120K) truncates oversized respo
|
|
|
307
310
|
|
|
308
311
|
Early project-level trials suggest the biggest improvement is not always dramatic token reduction by itself. In several runs, `rails-ai-bridge` led to faster, more focused responses even when total token usage only dropped modestly.
|
|
309
312
|
|
|
310
|
-
This
|
|
313
|
+
This makes sense: compact assistant-specific files and the summary-first MCP workflow help the model find relevant code faster and start with better context.
|
|
311
314
|
|
|
312
315
|
Observed benefits so far:
|
|
313
316
|
- Less exploratory reading before the assistant reaches the relevant files
|
|
@@ -393,6 +396,11 @@ Codex reads `AGENTS.md` at the repository root. MCP can be configured in `.codex
|
|
|
393
396
|
|
|
394
397
|
### HTTP transport (alternative for all clients)
|
|
395
398
|
|
|
399
|
+
HTTP MCP is unauthenticated unless you set a token (`http_mcp_token` /
|
|
400
|
+
`RAILS_AI_BRIDGE_MCP_TOKEN`, or a resolver/JWT decoder) or
|
|
401
|
+
`require_http_auth`. Bind to `127.0.0.1` unless you add auth. The default
|
|
402
|
+
remains `require_http_auth = false`.
|
|
403
|
+
|
|
396
404
|
If stdio MCP fails (usually a Ruby version manager PATH issue), start the HTTP server instead:
|
|
397
405
|
|
|
398
406
|
```bash
|
|
@@ -410,7 +418,7 @@ RailsAiBridge.configure do |config|
|
|
|
410
418
|
end
|
|
411
419
|
```
|
|
412
420
|
|
|
413
|
-
Point your AI client to `http://
|
|
421
|
+
Point your AI client to `http://127.0.0.1:3000/mcp` (or whichever port your Rails server uses) using transport type `SSE`. See [docs/mcp-security.md](docs/mcp-security.md) and [SECURITY.md](SECURITY.md) for production hardening.
|
|
414
422
|
|
|
415
423
|
### Claude Desktop (standalone app)
|
|
416
424
|
|
|
@@ -505,6 +513,12 @@ RailsAiBridge.configure do |config|
|
|
|
505
513
|
|
|
506
514
|
# Cache TTL for MCP tool responses (seconds)
|
|
507
515
|
config.cache_ttl = 30
|
|
516
|
+
|
|
517
|
+
# Fingerprint / section snapshot TTL (default 5s). Raise for HTTP MCP only.
|
|
518
|
+
# config.snapshot_ttl = 30
|
|
519
|
+
|
|
520
|
+
# Cap PathResolver glob/file listings (default 2000, sorted then taken).
|
|
521
|
+
# config.max_files_per_path = 2000
|
|
508
522
|
end
|
|
509
523
|
```
|
|
510
524
|
|
|
@@ -537,13 +551,16 @@ end
|
|
|
537
551
|
| `additional_resources` | `{}` | Optional MCP resources merged with the built-in `rails://...` resources |
|
|
538
552
|
| `http_path` | `"/mcp"` | HTTP endpoint path |
|
|
539
553
|
| `http_port` | `6029` | HTTP server port |
|
|
540
|
-
| `cache_ttl` | `30` | Cache TTL in seconds |
|
|
554
|
+
| `cache_ttl` | `30` | Cache TTL in seconds for introspection results |
|
|
555
|
+
| `snapshot_ttl` | `5` | Fingerprint / section snapshot TTL (seconds); raise for HTTP MCP |
|
|
556
|
+
| `max_files_per_path` | `2000` | Max paths from `PathResolver#glob_for` / `#files_for` (sorted, then taken) |
|
|
541
557
|
| `watcher_formats` | `:all` | Formats regenerated by `rails ai:watch` (e.g. `%i[claude cursor]` to limit churn) |
|
|
542
558
|
| `managed_region` | `false` | Confine generated output to a marked block so hand-authored content in `CLAUDE.md` & co. survives regeneration |
|
|
559
|
+
| `anti_hallucination_rules` | `true` | Include the shared verify-before-write block in compact assistant files |
|
|
543
560
|
| `parallel_introspection` | `false` | Run introspectors concurrently (requires `concurrent-ruby`, which is already a Rails dependency) |
|
|
544
561
|
| `parallel_pool_size` | `4` | Max threads in the parallel pool; capped at the number of active introspectors so no idle threads are created |
|
|
545
562
|
| `parallel_timeout_seconds` | `10` | Per-introspector future timeout (seconds); timed-out introspectors return `{ error: "timed out after Ns" }` without blocking the others |
|
|
546
|
-
| `registry.registry_manifest_path` | `"config/
|
|
563
|
+
| `registry.registry_manifest_path` | `"config/rails_ai_bridge/registry.json"` | Path to the registry manifest JSON file for skill pack resolution |
|
|
547
564
|
| `registry.skill_cache_dir` | `"~/.rails-ai-bridge/cache"` | Directory for caching git repositories containing skill packs |
|
|
548
565
|
| `registry.skill_packs` | `nil` | Explicit pack names to load, or `nil` for auto-detection based on framework |
|
|
549
566
|
| `registry.local_registry_paths` | `[]` | Local directory paths (must contain `directory.json`) loaded at priority 0 |
|
|
@@ -686,10 +703,10 @@ To customize it in your initializer (`config/initializers/rails_ai_bridge.rb`):
|
|
|
686
703
|
rails-ai-bridge can load **skill packs** — shared collections of agent instructions — from versioned git repositories and surface them through `rails_list_registry` and rake tasks.
|
|
687
704
|
|
|
688
705
|
```ruby
|
|
689
|
-
config.registry.registry_manifest_path = "config/
|
|
706
|
+
config.registry.registry_manifest_path = "config/rails_ai_bridge/registry.json"
|
|
690
707
|
```
|
|
691
708
|
|
|
692
|
-
Quick example manifest (`config/
|
|
709
|
+
Quick example manifest (`config/rails_ai_bridge/registry.json`):
|
|
693
710
|
|
|
694
711
|
```json
|
|
695
712
|
{
|
|
@@ -835,7 +852,7 @@ Bug reports and pull requests: [github.com/igmarin/rails-ai-bridge/issues](https
|
|
|
835
852
|
|
|
836
853
|
## Acknowledgments & Origins
|
|
837
854
|
|
|
838
|
-
This gem ships as **rails-ai-bridge** (Ruby **`RailsAiBridge`**, version **4.
|
|
855
|
+
This gem ships as **rails-ai-bridge** (Ruby **`RailsAiBridge`**, version **4.3.0**). Earlier iterations of the same codebase were distributed as `rails-ai-context`.
|
|
839
856
|
|
|
840
857
|
RailsMCP evolved from
|
|
841
858
|
[crisnahine/rails-ai-context](https://github.com/crisnahine/rails-ai-context),
|