rails-ai-context 5.39.0 → 5.39.2
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 +307 -0
- data/CONTRIBUTING.md +1 -0
- data/README.md +18 -3
- data/docs/ARCHITECTURE.md +3 -3
- data/docs/CLI.md +5 -2
- data/docs/FAQ.md +1 -1
- data/docs/GUIDE.md +12 -9
- data/docs/INTROSPECTORS.md +13 -7
- data/docs/SETUP.md +2 -1
- data/docs/TOOLS.md +119 -18
- data/docs/TROUBLESHOOTING.md +3 -3
- data/lib/generators/rails_ai_context/install/install_generator.rb +22 -9
- data/lib/rails_ai_context/ast_cache.rb +76 -2
- data/lib/rails_ai_context/brackets.rb +58 -6
- data/lib/rails_ai_context/class_declarations.rb +54 -2
- data/lib/rails_ai_context/cli/app_root.rb +12 -3
- data/lib/rails_ai_context/database_yml.rb +12 -1
- data/lib/rails_ai_context/doctor.rb +24 -1
- data/lib/rails_ai_context/erb_source.rb +41 -26
- data/lib/rails_ai_context/gem_lock.rb +4 -1
- data/lib/rails_ai_context/initializer_settings.rb +4 -2
- data/lib/rails_ai_context/install/initializer_file.rb +111 -12
- data/lib/rails_ai_context/introspectors/action_presence.rb +50 -1
- data/lib/rails_ai_context/introspectors/action_resolver.rb +14 -18
- data/lib/rails_ai_context/introspectors/api_introspector.rb +53 -16
- data/lib/rails_ai_context/introspectors/controller_introspector.rb +59 -3
- data/lib/rails_ai_context/introspectors/convention_introspector.rb +3 -4
- data/lib/rails_ai_context/introspectors/declared_constant.rb +8 -0
- data/lib/rails_ai_context/introspectors/devops_introspector.rb +30 -6
- data/lib/rails_ai_context/introspectors/eager_load.rb +2 -1
- data/lib/rails_ai_context/introspectors/env_references.rb +16 -0
- data/lib/rails_ai_context/introspectors/frontend_framework_introspector.rb +1 -0
- data/lib/rails_ai_context/introspectors/i18n_introspector.rb +1 -0
- data/lib/rails_ai_context/introspectors/job_introspector.rb +37 -9
- data/lib/rails_ai_context/introspectors/listeners/callbacks_listener.rb +2 -1
- data/lib/rails_ai_context/introspectors/listeners/env_access_listener.rb +15 -6
- data/lib/rails_ai_context/introspectors/listeners/macros_listener.rb +3 -0
- data/lib/rails_ai_context/introspectors/listeners/routes_dsl_listener.rb +12 -0
- data/lib/rails_ai_context/introspectors/listeners/validations_listener.rb +9 -4
- data/lib/rails_ai_context/introspectors/model_introspector.rb +65 -23
- data/lib/rails_ai_context/introspectors/model_record.rb +22 -5
- data/lib/rails_ai_context/introspectors/module_aliases.rb +1 -0
- data/lib/rails_ai_context/introspectors/multi_database_introspector.rb +6 -2
- data/lib/rails_ai_context/introspectors/n_plus_one_scan.rb +22 -4
- data/lib/rails_ai_context/introspectors/performance_introspector.rb +41 -2
- data/lib/rails_ai_context/introspectors/recurring_schedules.rb +18 -2
- data/lib/rails_ai_context/introspectors/render_calls.rb +40 -2
- data/lib/rails_ai_context/introspectors/route_introspector.rb +35 -4
- data/lib/rails_ai_context/introspectors/runtime_registries.rb +402 -0
- data/lib/rails_ai_context/introspectors/side_effects.rb +1 -1
- data/lib/rails_ai_context/introspectors/source_scan.rb +2 -1
- data/lib/rails_ai_context/introspectors/stimulus_introspector.rb +57 -28
- data/lib/rails_ai_context/introspectors/structure_sql_reader.rb +24 -1
- data/lib/rails_ai_context/introspectors/turbo_introspector.rb +108 -20
- data/lib/rails_ai_context/introspectors/view_introspector.rb +50 -25
- data/lib/rails_ai_context/introspectors/view_template_introspector.rb +98 -22
- data/lib/rails_ai_context/markup_source.rb +1 -0
- data/lib/rails_ai_context/negative_claim.rb +34 -0
- data/lib/rails_ai_context/portable_path.rb +5 -0
- data/lib/rails_ai_context/ruby_source.rb +102 -0
- data/lib/rails_ai_context/runtime_origin.rb +41 -0
- data/lib/rails_ai_context/schema_version.rb +22 -2
- data/lib/rails_ai_context/serializers/section_facts.rb +22 -1
- data/lib/rails_ai_context/server.rb +3 -3
- data/lib/rails_ai_context/tools/analyze_feature.rb +17 -8
- data/lib/rails_ai_context/tools/base_tool.rb +149 -1
- data/lib/rails_ai_context/tools/dependency_graph.rb +13 -14
- data/lib/rails_ai_context/tools/diagnose.rb +8 -3
- data/lib/rails_ai_context/tools/generate_test.rb +83 -38
- data/lib/rails_ai_context/tools/get_api.rb +15 -6
- data/lib/rails_ai_context/tools/get_callbacks.rb +102 -14
- data/lib/rails_ai_context/tools/get_concern.rb +51 -38
- data/lib/rails_ai_context/tools/get_context.rb +45 -15
- data/lib/rails_ai_context/tools/get_controllers.rb +153 -38
- data/lib/rails_ai_context/tools/get_conventions.rb +57 -42
- data/lib/rails_ai_context/tools/get_edit_context.rb +23 -7
- data/lib/rails_ai_context/tools/get_env.rb +58 -13
- data/lib/rails_ai_context/tools/get_helper_methods.rb +90 -69
- data/lib/rails_ai_context/tools/get_job_pattern.rb +14 -14
- data/lib/rails_ai_context/tools/get_mailers.rb +6 -1
- data/lib/rails_ai_context/tools/get_model_details.rb +131 -48
- data/lib/rails_ai_context/tools/get_partial_interface.rb +119 -64
- data/lib/rails_ai_context/tools/get_schema.rb +21 -1
- data/lib/rails_ai_context/tools/get_service_pattern.rb +21 -11
- data/lib/rails_ai_context/tools/get_stimulus.rb +2 -1
- data/lib/rails_ai_context/tools/get_test_info.rb +13 -3
- data/lib/rails_ai_context/tools/get_view.rb +32 -11
- data/lib/rails_ai_context/tools/migration_advisor.rb +18 -7
- data/lib/rails_ai_context/tools/onboard.rb +1 -1
- data/lib/rails_ai_context/tools/review_changes.rb +75 -11
- data/lib/rails_ai_context/tools/search_code.rb +23 -7
- data/lib/rails_ai_context/tools/validate.rb +11 -0
- data/lib/rails_ai_context/tools/validate_semantics.rb +167 -90
- data/lib/rails_ai_context/unbooted_settings.rb +9 -4
- data/lib/rails_ai_context/version.rb +1 -1
- metadata +5 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 15bdb8cba276a174d0528c46be02eb2d150cafd816ab369d09004a987026560d
|
|
4
|
+
data.tar.gz: e03c9cb21526bb72f913593ebe314ba091616b10420cb248a6f77a3c9f679017
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 417e473cbb705040e16d20e321a1a22761243c6dd63644c5f5773d4f2dbea73baa7cdae4d4420de6635f8b4f8597682ef96981c58471700d6b7bf2b59affa30f
|
|
7
|
+
data.tar.gz: 8a3c6dbdee3ea9679c071cd7b6f7120cb88d640f93e5d90e858624f90227e87fe73187a2bd10a761a37e397e58ad4483acb5587e371ac722c16da69162b9d49b
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,313 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [5.39.2] - 2026-12-07
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **The HTTP transport starts on Puma 8.1.4.** Puma 8.1.4 gave its launcher's
|
|
13
|
+
`setup_signals` an argument, and the server's own stop handling took none,
|
|
14
|
+
so `serve --transport http` died at start with "wrong number of arguments
|
|
15
|
+
(given 1, expected 0)". It now passes Puma's arguments through, on every
|
|
16
|
+
Puma version.
|
|
17
|
+
|
|
18
|
+
- **Text nested thousands of brackets deep no longer ends the process.**
|
|
19
|
+
Prism recurses once per level and can run out of native stack before its
|
|
20
|
+
own nesting cap; on Windows that ended the process with no error. A Ruby
|
|
21
|
+
file or ERB tag that nests brackets or interpolations deeper than 250 levels
|
|
22
|
+
is now parsed only up to that point, a HAML attribute hash that deep is left
|
|
23
|
+
unread, and `validate` says the file nests too deep and was not checked past
|
|
24
|
+
that line instead of reporting a syntax error there. Nesting by keywords
|
|
25
|
+
(`if`, `begin`) is not counted.
|
|
26
|
+
|
|
27
|
+
- **A "none" or "not found" names the class macros it could not read.** On
|
|
28
|
+
the static tier a model that calls a macro no reader expands
|
|
29
|
+
(`has_paper_trail`, `monetize`, `acts_as_list`, a `class_eval` string) got
|
|
30
|
+
answers that denied what the macro adds. The model record now carries
|
|
31
|
+
`macros_unread`, and the tools say what they did not read.
|
|
32
|
+
`rails_validate` keeps a missing column, callback method or route helper as
|
|
33
|
+
a warning, but drops `Fix: add migration` when such a macro may add the
|
|
34
|
+
column, names the macro beside a callback method it cannot find, and says
|
|
35
|
+
how many dynamic route constructs the static read left out.
|
|
36
|
+
`rails_get_callbacks` names the macro where it said "No callbacks defined",
|
|
37
|
+
and its listing names the models that have one, ten by name and the rest
|
|
38
|
+
counted. `rails_get_model_details` names every such call in one line, with
|
|
39
|
+
one count, and says when the static read expanded its validations
|
|
40
|
+
(`devise :validatable`); a `class_eval` string in the model's own file no
|
|
41
|
+
longer reads as a gem. `rails_dependency_graph` says any of the macros it
|
|
42
|
+
names may add associations, and `rails_migration_advisor` names them too, and `rails_get_controllers` says
|
|
43
|
+
that a gem's or an `on_load` hook's filters are read only with the app
|
|
44
|
+
booted, in the `ApplicationController` answer too. `rails_get_callbacks`
|
|
45
|
+
shows a callback name built by interpolation as written and says it is
|
|
46
|
+
built at runtime.
|
|
47
|
+
- **Gem macros, middleware and helpers are no longer judged by a fixed list
|
|
48
|
+
of gem names or file names alone.** `rails_get_model_details` lists every
|
|
49
|
+
class-body call no reader expands under "Other class macros", as written
|
|
50
|
+
with its arguments redacted, on both tiers, so `rolify`, `paginates_per`,
|
|
51
|
+
`attr_encrypted` and `enumerize :status, in: [...]` show up with their
|
|
52
|
+
values. `rails_onboard` titles its encrypted-data section by the
|
|
53
|
+
Active Record `encrypts` macro it reads. `rails_get_config(section:"api")`
|
|
54
|
+
reads `Rack::Attack` and `Rack::Cors` from the middleware stack on a booted
|
|
55
|
+
app, `Rack::Attack` from any initializer whose code names it, and CORS rules
|
|
56
|
+
from any initializer that inserts `Rack::Cors`, so an initializer not named
|
|
57
|
+
after the gem no longer reads as "not detected". A `cors.rb` left fully
|
|
58
|
+
commented out is reported only when no other initializer and no booted
|
|
59
|
+
stack holds `Rack::Cors`. The payload marks a stack-only find with
|
|
60
|
+
`in_stack: true`, and a static "not detected" says that middleware a gem
|
|
61
|
+
inserts at boot is not read.
|
|
62
|
+
`rails_get_helper_methods` no longer names gem helpers the app's gems do
|
|
63
|
+
not have: its table listed `pagy_nav` for pagy 43, which has none, and
|
|
64
|
+
`current_user` whatever the Devise scope. Its static `detail:"full"` answer names them
|
|
65
|
+
from the lockfile: a gem's line prints only when the lockfile holds it,
|
|
66
|
+
Pagy's `pagy_nav` and `pagy_info` only below pagy 43, and Devise's names
|
|
67
|
+
come from each `devise_for` scope the route files spell (`current_member`
|
|
68
|
+
for `devise_for :members`), or as the `current_<scope>` pattern when no
|
|
69
|
+
scope is read. The section says the names come from the lockfile and were
|
|
70
|
+
not read from the gems. `rails_validate` drops its list of Devise route names. Booted, the
|
|
71
|
+
app's `url_helpers` and view helpers answer, so Devise's
|
|
72
|
+
`session_path(resource_name)` and the like pass. Statically, those view
|
|
73
|
+
helpers pass when the lockfile has `devise` and the call passes the scope;
|
|
74
|
+
a bare `new_session_path` is still reported. A missing route helper
|
|
75
|
+
says how many dynamic route constructs, such as `devise_for`, were not read.
|
|
76
|
+
The helper Rails names a mount by is no longer reported on the static
|
|
77
|
+
tier: the mount's `as:` or its app's name (`sidekiq_web_path` for
|
|
78
|
+
`mount Sidekiq::Web`), under the names of the scopes around it
|
|
79
|
+
(`admin_sidekiq_web_path` inside `namespace :admin`), and an app engine's
|
|
80
|
+
`engine_name`. The routes payload carries those names in `mount_route_names`.
|
|
81
|
+
- **Derived tools no longer turn partial facts into conclusions.**
|
|
82
|
+
`rails_generate_test` writes a skipping example for a length rule whose
|
|
83
|
+
bound is a proc or a constant, where it wrote `.is_at_most((proc))`, which
|
|
84
|
+
raised when the spec ran; integer bounds and a literal `in:` range keep the
|
|
85
|
+
matcher. An inclusion list read as a constant's name (`in: STATUSES`) gets a
|
|
86
|
+
skipping example too, where it wrote `.in_array(STATUSES)`, which raised
|
|
87
|
+
`NameError` when the spec loaded. Devise's `:validatable` read statically
|
|
88
|
+
now carries the options Devise declares, so its email uniqueness is a conditional `skip` and no
|
|
89
|
+
longer a plain `validate_uniqueness_of(:email)` that fails. Both model test
|
|
90
|
+
generators end with a comment naming the class macros whose behaviour the
|
|
91
|
+
cases do not cover. `rails_migration_advisor` names the table's class
|
|
92
|
+
macros under the lines that name a dropped column, as it already did when
|
|
93
|
+
no line names it. `rails_review_changes` warns on a removed class macro,
|
|
94
|
+
such as `:validatable` cut from `devise` or a dropped `has_paper_trail`.
|
|
95
|
+
A macro counts as removed when no call of the same name on the new side
|
|
96
|
+
holds its symbol, string and constant arguments, so dropping
|
|
97
|
+
`after_save AuditLogger` warns, while editing a scope's lambda, adding
|
|
98
|
+
an `enum` value or moving a `serialize` coder to `coder:` does not.
|
|
99
|
+
`rails_analyze_feature` and `rails_get_context` print a model's macros, and
|
|
100
|
+
`rails_get_test_info` names the suite's shared examples.
|
|
101
|
+
- **A lookup no longer says "not found" for what a gem defines.** On a booted
|
|
102
|
+
app, a model, concern, controller, mailer, view folder, partial or helper
|
|
103
|
+
method the app's own files do not hold is looked up in the runtime, and the
|
|
104
|
+
answer names the gem, its version and the file in it, such as
|
|
105
|
+
`Devise::SessionsController` or `link_to`. A helper method a route macro
|
|
106
|
+
defines, such as Devise's `current_user`, is found too: routes Rails 8
|
|
107
|
+
draws on first use are drawn before the lookup. Nothing the gem holds is listed,
|
|
108
|
+
no gem file is read, and a constant still waiting on its autoload is
|
|
109
|
+
answered from the file Ruby registered, without loading it. A name under a
|
|
110
|
+
namespace still waiting on its autoload is "not found", and the answer says
|
|
111
|
+
what defines it was not read. On the static tier the "not found" says that
|
|
112
|
+
only the app's own files are read and a gem may define it, unless the app
|
|
113
|
+
declares the name: then it says which file declares it and why the lookup
|
|
114
|
+
does not list it, so an abstract `ApplicationRecord` reads as abstract. `rails_validate`
|
|
115
|
+
no longer reports a partial a gem's views hold on a booted app, and
|
|
116
|
+
statically says a gem may define one.
|
|
117
|
+
`rails_get_mailers` says that its listing leaves out gem mailers, and
|
|
118
|
+
`rails_get_schema` names a gem's loaded model on a table no app model reads.
|
|
119
|
+
- **A booted model answer reads the registries Rails keeps, not only the
|
|
120
|
+
source.** Callbacks, default scopes, scopes and first-party macros that a
|
|
121
|
+
gem or runtime code adds were denied ("No callbacks defined.") or dropped.
|
|
122
|
+
The booted tier now compares the model's callback chains, `default_scopes`,
|
|
123
|
+
scope methods, `nested_attributes_options`, `encrypted_attributes`,
|
|
124
|
+
`stored_attributes`, attribute aliases, non-column attributes, serialized
|
|
125
|
+
columns, `readonly_attributes` and `normalized_attributes` with what the
|
|
126
|
+
source declared, and lists each extra. Non-column attributes and serialized
|
|
127
|
+
columns are compared only on a model that has connected, since their types
|
|
128
|
+
load the schema. A counter cache column Rails 7.0
|
|
129
|
+
marks read-only for a child's `belongs_to` is left out, and a column runtime
|
|
130
|
+
code makes read-only is listed whatever its name. A callback or default scope is
|
|
131
|
+
tagged with the gem that added it, or as read from the running app. A
|
|
132
|
+
scope or macro is always tagged as read from the running app: a scope's
|
|
133
|
+
method lives in Active Record's own file, and a macro's registry keeps no
|
|
134
|
+
file. A gem's block callback is named by its `file:line` inside the gem,
|
|
135
|
+
callbacks sit where Rails runs them, and a loop's interpolated callback
|
|
136
|
+
name lists the names it made. The `rails_get_callbacks` listing prints the
|
|
137
|
+
callbacks a gem adds alike to several models once, at the end under the
|
|
138
|
+
gem, and each of those models says how many it holds from that gem. What Rails adds itself (including the scopes
|
|
139
|
+
Active Storage, Action Text and `delegated_type` make from a line the
|
|
140
|
+
source declares), the `validate` chain, and anything from outside the app
|
|
141
|
+
and its gems are left out. A gem's scope moves from Class methods to
|
|
142
|
+
Scopes, and `rails_generate_test` only asserts that it exists.
|
|
143
|
+
`rails_validate` asks the running class before reporting a missing column
|
|
144
|
+
or callback method, so a gem's `tag_list` is no longer "add migration", a
|
|
145
|
+
column the running class does not have keeps its `Fix:` line beside a macro
|
|
146
|
+
the source does not expand,
|
|
147
|
+
and a missing callback method on a model that includes a module is
|
|
148
|
+
reported again on a booted app; a method every object has, such as
|
|
149
|
+
Kernel's `format`, does not count as the model's. `rails_get_model_details`
|
|
150
|
+
says how many methods reflection reports for a model whose file defines
|
|
151
|
+
some, and lists the names a gem or the app defines beyond the file, one
|
|
152
|
+
line per gem tagged with it; Rails' own methods are left out. An unread
|
|
153
|
+
class macro is listed as written, and an unread class macro, concern or
|
|
154
|
+
base class says that what the running class holds from it is in the
|
|
155
|
+
answer and only the rest is not read. None of this entry changes the
|
|
156
|
+
static tier.
|
|
157
|
+
- **A booted controller answer reads its actions, rescue handlers and
|
|
158
|
+
`helper_method` names from the running class, not only the source.** An
|
|
159
|
+
action a `define_method` loop, a gem's `class_eval` or an `inherited` hook
|
|
160
|
+
defines read as "(no public actions)", `rails_get_context` said it was not
|
|
161
|
+
found, and `rails_validate` said to add a `def` for it. The booted tier now
|
|
162
|
+
lists such an action with its `file:line` and tag, and an `action` lookup
|
|
163
|
+
answers with that place and its routes. `rescue_from` handlers a gem or an
|
|
164
|
+
`on_load` hook adds are listed and tagged, and `rails_get_helper_methods`
|
|
165
|
+
lists the `helper_method` names a gem declares (`can?`), leaving out Rails'
|
|
166
|
+
own. It reads them from the running `ApplicationController`, and each
|
|
167
|
+
controller's own from a context another call already built, so it builds
|
|
168
|
+
no context of its own. `rails_validate` asks the running class before it reports a route's
|
|
169
|
+
action as missing, and an action the running class defines nowhere keeps
|
|
170
|
+
its `Fix:` line even beside a module it could not read, unless its own
|
|
171
|
+
`action_missing` or a template in one of its view paths could answer the
|
|
172
|
+
route. Asked for `ApplicationController`,
|
|
173
|
+
`rails_get_controllers` counts the filters its running chain holds that it
|
|
174
|
+
does not declare, names the gems that added them, and lists the rescue
|
|
175
|
+
handlers its running class holds. On the static tier, a controller whose
|
|
176
|
+
class body calls `define_method` with a computed name, or `class_eval` with
|
|
177
|
+
a string, names that call and its line where it lists actions, where an
|
|
178
|
+
action lookup misses, and in `rails_validate`'s note on a route's action.
|
|
179
|
+
- **Strong params set outside `params` are no longer left out.** A
|
|
180
|
+
`permit` call on another receiver, such as Devise's
|
|
181
|
+
`devise_parameter_sanitizer.permit(:sign_up, keys: [:name])`, was dropped,
|
|
182
|
+
so `rails_get_controllers` showed the filter and no strong params. Both
|
|
183
|
+
tiers now list it under its method, with its line and the call as written,
|
|
184
|
+
secrets filtered, and say what it permits is not expanded;
|
|
185
|
+
`ApplicationController`'s answer lists it too, and the controllers below
|
|
186
|
+
it do not. `rails_generate_test` does not take it as the controller's
|
|
187
|
+
create params. Booted, a controller built at runtime with no file of its
|
|
188
|
+
own (an ActiveAdmin resource) says where its `permitted_params` is defined
|
|
189
|
+
and that the params are not read: the app file and line that sets them, or,
|
|
190
|
+
when a gem builds the method from the app's call, that gem and its line.
|
|
191
|
+
- **Booted model details on Rails 7.0 no longer walk every model once per
|
|
192
|
+
model.** The counter cache columns a child's `belongs_to` marks read-only
|
|
193
|
+
are collected once per run.
|
|
194
|
+
|
|
195
|
+
## [5.39.1] - 2026-10-31
|
|
196
|
+
|
|
197
|
+
### Fixed
|
|
198
|
+
|
|
199
|
+
- **A comment, a string or a heredoc is no longer read as code.** About 150
|
|
200
|
+
answers came from a regex that matched text Ruby never runs: a
|
|
201
|
+
commented-out line, a word inside a string, a line inside a heredoc or an
|
|
202
|
+
`=begin` block. Each of those readers now reads only the code, through
|
|
203
|
+
Prism, the existing listeners, or the new `RubySource`, which blanks
|
|
204
|
+
comments and string bodies while keeping every line and column. The
|
|
205
|
+
sections below list what each surface stops reporting and what it now
|
|
206
|
+
finds.
|
|
207
|
+
- **ERB.** A `<%%` escape is text, as Erubi prints it. A Ruby comment inside a
|
|
208
|
+
code tag (`<% # render "old" %>`) counts for nothing, and text inside
|
|
209
|
+
`<!-- -->` is no markup, while ERB inside it still runs.
|
|
210
|
+
- **Views and partials** (`rails_get_view`, `rails_get_partial_interface`).
|
|
211
|
+
A render inside a string, a comment or plain page text is no render, and a
|
|
212
|
+
`partial:` key inside another helper's hash (`data: { partial: }`) is no
|
|
213
|
+
partial. A form builder named in a string no longer renames a record
|
|
214
|
+
render. A partial's locals leave out its own variables and what a
|
|
215
|
+
commented-out loop names, and read `local_assigns` and `defined?` only from
|
|
216
|
+
Ruby. `formats:` and `partial:` inside a string value, a jbuilder line's
|
|
217
|
+
trailing comment and a Turbo Stream builder named in a comment no longer
|
|
218
|
+
move a render site. `rails_get_view` prints the form builders (with
|
|
219
|
+
counts) and components the views it lists use, which it never printed
|
|
220
|
+
before.
|
|
221
|
+
`rails_get_helper_methods` lists every module an `include` names
|
|
222
|
+
(`include A, B`, `include Rails.application.routes.url_helpers`) and none a
|
|
223
|
+
heredoc holds.
|
|
224
|
+
- **Turbo** (`rails_get_turbo_map`). A frame, stream action or Drive
|
|
225
|
+
attribute inside an ERB comment, or a Ruby comment in a code tag, is not
|
|
226
|
+
counted. A frame's `src:` and a
|
|
227
|
+
subscription's parts on the next line of a wrapped call are read, so the
|
|
228
|
+
stream wiring stops warning about a mismatch that is not there. A
|
|
229
|
+
permanent element's id comes from its `id` attribute, never `data-id`, and
|
|
230
|
+
elements whose attributes hold ERB, or that a tag helper writes, are found.
|
|
231
|
+
`format.turbo_stream` in a comment is no stream response.
|
|
232
|
+
- **Stimulus** (`rails_get_stimulus`). A commented import, registration,
|
|
233
|
+
`extends`, `static targets`, `this.x()` call or Turbo event listener counts
|
|
234
|
+
for nothing. An arrow-function class field is an action, a wrapped import
|
|
235
|
+
is read, a class written on one line has its methods, and lifecycle lists
|
|
236
|
+
only the hooks the class defines (`this.observer.disconnect()` is no
|
|
237
|
+
hook). A commented alias entry and a commented plugin import in
|
|
238
|
+
`vite.config` are skipped.
|
|
239
|
+
- **Controllers and actions** (`rails_get_context`, `rails_get_controllers`,
|
|
240
|
+
`rails_get_edit_context`, `rails_search_code`). Only a real assignment sets
|
|
241
|
+
an ivar: `@post == x` and `@post.title = x` do not. `render action: :show`
|
|
242
|
+
and `render "edit"` are read, so are methods called under a modifier `if`
|
|
243
|
+
and filters written as `private def`. A file that declares another class
|
|
244
|
+
first no longer lends that class's method. The class a method belongs to
|
|
245
|
+
respects nesting and `class << self`, so `class Error < StandardError; end`
|
|
246
|
+
on the line above no longer names it. An action's Side Effects lines are
|
|
247
|
+
redacted as its source listing is, so a key passed to the receiver reads
|
|
248
|
+
`[FILTERED]`.
|
|
249
|
+
- **Validate** (`rails_validate`, rails level). A route or helper inside a
|
|
250
|
+
heredoc or `=begin` block no longer silences a missing-route warning, and
|
|
251
|
+
every line of a multi-line `helper_method` counts. A controller set through
|
|
252
|
+
`data: { controller: }` is checked, and one in an HTML comment is not. An
|
|
253
|
+
email address in a string is no ivar, and a comparison is no assignment. A
|
|
254
|
+
commented broadcast or subscription is not checked. The memory warning
|
|
255
|
+
reads the call: a scope or association chain (`Post.active.map`,
|
|
256
|
+
`current_user.posts.each`) warns, and a chain over `params`, a string, a
|
|
257
|
+
literal, or a call that takes arguments (`JSON.parse(body).map`,
|
|
258
|
+
`Dir.glob(x).map`) does not.
|
|
259
|
+
- **analyze_feature.** Tag-helper `data: { controller: }` is read, ERB inside
|
|
260
|
+
`data-controller` gives no names and an HTML-commented one gives none, the
|
|
261
|
+
test count reads `it(...)`, `specify` and `it { }` one-liners and skips
|
|
262
|
+
heredoc text, and every `ENV.fetch` form is listed.
|
|
263
|
+
- **Conventions and test info** (`rails_get_config(section:"conventions")`,
|
|
264
|
+
`rails_get_test_info`). The create action ends at its own `end` inside a
|
|
265
|
+
namespace module, and commented code adds no permission check, rescue,
|
|
266
|
+
read-only page, default locale or UI language. Japanese flash text with
|
|
267
|
+
kanji is Japanese. Devise test helpers and route helpers count only where
|
|
268
|
+
the code uses them.
|
|
269
|
+
- **Models, concerns and performance.** A custom validate method's body is
|
|
270
|
+
read when the def has parameters or a trailing comment. A heredoc adds no
|
|
271
|
+
structure line, makes no model abstract, and holds no concern macro. A
|
|
272
|
+
multi-line macro and an `included { }` block are read whole. A class whose
|
|
273
|
+
superclass sits on the next line is found. A comment naming
|
|
274
|
+
`Rails::Engine` makes no Rack app an engine. Strict locals read every
|
|
275
|
+
default, as Rails' own pattern does, a word in a scope's SQL string calls
|
|
276
|
+
no scope, a comparison or an `order` on a counter column is not a write,
|
|
277
|
+
and `Model.all` in a comment is not flagged.
|
|
278
|
+
- **Jobs and services** (`rails_get_job_pattern`,
|
|
279
|
+
`rails_get_service_pattern`). Commented `queue_as`, broadcasts, mailers,
|
|
280
|
+
`include` words and `.success` calls count for nothing, and heredoc text
|
|
281
|
+
adds no guard clause. `queue_as proc { }.call` is a computed queue, not a
|
|
282
|
+
Proc. A mailer whose parent is the app's own mailer base is listed. A
|
|
283
|
+
whenever runner names the job it enqueues or performs
|
|
284
|
+
(`ReportJob.new.perform`), or no class so its command shows. A rescue modifier rescues StandardError, and a service named only
|
|
285
|
+
in a comment has no caller there.
|
|
286
|
+
- **Config and data files.** The credentials example is read as YAML, so a
|
|
287
|
+
block scalar adds no key and nested keys keep their full path; one that is
|
|
288
|
+
not YAML is read line by line, by indentation. A
|
|
289
|
+
`=begin` block sets no default locale. `::ENV[...]`, `::ENV.fetch` and
|
|
290
|
+
`ENV["X"] ||=` count as ENV reads. Shards come from the database list,
|
|
291
|
+
in the guide's layout too, and `shard_count:` is no shard. A computed puma
|
|
292
|
+
setting reads as unknown, while `ENV[...] || 2` keeps its default. A
|
|
293
|
+
commented health route is no health check, an `ENV.fetch` default names the
|
|
294
|
+
adapter, doctor finds a password in a flow-style mapping, the schema
|
|
295
|
+
version comes from the `define` call, mise's `[tools.ruby]` table is read,
|
|
296
|
+
and a `CREATE TABLE` or `CREATE VIEW` inside a PostgreSQL function body or
|
|
297
|
+
string is not a table or view.
|
|
298
|
+
- **generate_test, diagnose, migration_advisor, review_changes.** A
|
|
299
|
+
paren-less `create :post` counts, a `def` inside a heredoc names no sign-in
|
|
300
|
+
helper, a string in an inclusion list is a value, and a `%r{}` format is
|
|
301
|
+
read like `/.../`. `diagnose` takes no receiver from a string.
|
|
302
|
+
`:null => false` and `{ null: false }` get the NOT NULL warning. A
|
|
303
|
+
validation moved into a
|
|
304
|
+
heredoc or wrapped in `=begin` is reported as removed.
|
|
305
|
+
- **Install and boot.** `::RailsAiContext.configure` is the gem's call, a
|
|
306
|
+
heredoc line is not, and a guard that is only a comment or closes before
|
|
307
|
+
the call does not count, in doctor and in the install alike: the install
|
|
308
|
+
wraps a call no guard covers, and upgrades a bare guard with a note after
|
|
309
|
+
it. The generator leaves heredoc text alone and keeps every magic comment
|
|
310
|
+
above the guard it adds. The static tier reads heredoc escapes and `%W`
|
|
311
|
+
and `%I` lists. The CLI finds the app a Rails 5.1 engine's `bin/rails`
|
|
312
|
+
names through `__FILE__`, and a Rails 4.2 or 5.0 engine's `test/dummy` or
|
|
313
|
+
`spec/dummy`.
|
|
314
|
+
|
|
8
315
|
## [5.39.0] - 2026-10-31
|
|
9
316
|
|
|
10
317
|
### Changed
|
data/CONTRIBUTING.md
CHANGED
|
@@ -72,6 +72,7 @@ The `ToolRunner` (`lib/rails_ai_context/cli/tool_runner.rb`) handles CLI executi
|
|
|
72
72
|
- Target Ruby 3.1 (the gem's floor). Ruby 3.2+ features (`Data.define`, `Regexp` `timeout:`, etc.) need a runtime-guarded fallback so 3.1 keeps working
|
|
73
73
|
- Support Rails 7.0 through 8.1. Guard Rails 7.1+ APIs with `respond_to?`/`defined?` so introspectors degrade cleanly on 7.0
|
|
74
74
|
- Every introspector returns a Hash. Let a failure raise: the loop in `Introspector#call` records it as `{ error: msg }` and warns, so no introspector wraps its own errors
|
|
75
|
+
- Read Ruby source with Prism or a listener. A regex kept over Ruby runs on `RubySource.code_only` or `RubySource.without_comments` text, so a comment, a string or a heredoc cannot match (the AST-vs-regex rule in `docs/INTROSPECTORS.md`)
|
|
75
76
|
- MCP tools return `MCP::Tool::Response` objects
|
|
76
77
|
- All tools must be prefixed with `rails_` and annotated as read-only
|
|
77
78
|
|
data/README.md
CHANGED
|
@@ -8,9 +8,13 @@
|
|
|
8
8
|
<h3 align="center">Your coding agent guesses your Rails app. Let it ask.</h3>
|
|
9
9
|
|
|
10
10
|
<p align="center">
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
<a href="docs/SETUP.md"><img src="https://img.shields.io/badge/works_with-555" alt="Works with"></a>
|
|
12
|
+
<a href="docs/SETUP.md#claude-code"><img src="https://img.shields.io/badge/Claude_Code-D97757?logo=claudecode&logoColor=white" alt="Claude Code"></a>
|
|
13
|
+
<a href="docs/SETUP.md#cursor"><img src="https://img.shields.io/badge/Cursor-000000?logo=cursor&logoColor=white" alt="Cursor"></a>
|
|
14
|
+
<a href="docs/SETUP.md#github-copilot"><img src="https://img.shields.io/badge/GitHub_Copilot-000000?logo=githubcopilot&logoColor=white" alt="GitHub Copilot"></a>
|
|
15
|
+
<a href="docs/SETUP.md#opencode"><img src="https://img.shields.io/badge/OpenCode-000000?logo=opencode&logoColor=white" alt="OpenCode"></a>
|
|
16
|
+
<a href="docs/SETUP.md#codex-cli"><img src="https://img.shields.io/badge/Codex_CLI-000000?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI%2BPHBhdGggZmlsbD0iI2ZmZiIgZD0iTTMgNS40IDQuNCA0bDggOC04IDhMMyAxOC42IDkuNiAxMnpNMTMgMThoOHYyaC04eiIvPjwvc3ZnPg%3D%3D" alt="Codex CLI"></a>
|
|
17
|
+
<a href="docs/CLI.md"><img src="https://img.shields.io/badge/Any_terminal-4D4D4D?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI%2BPHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMyAzaDE4YTIgMiAwIDAgMSAyIDJ2MTRhMiAyIDAgMCAxLTIgMkgzYTIgMiAwIDAgMS0yLTJWNWEyIDIgMCAwIDEgMi0yem0wIDJ2MTRoMThWNXptMyAzLjRMNy40IDdsNSA1LTUgNUw2IDE1LjYgOS42IDEyek0xMyAxNWg1djJoLTV6Ii8%2BPC9zdmc%2B" alt="Any terminal"></a>
|
|
14
18
|
</p>
|
|
15
19
|
|
|
16
20
|
<p align="center">
|
|
@@ -26,6 +30,7 @@
|
|
|
26
30
|
<p align="center">
|
|
27
31
|
<a href="https://crisnahine.github.io/rails-ai-context/">Website</a> ·
|
|
28
32
|
<a href="#try-it-in-your-rails-app">Quick start</a> ·
|
|
33
|
+
<a href="https://crisnahine.github.io/rails-ai-context/FAQ.html"><b>FAQ</b></a> ·
|
|
29
34
|
<a href="#what-it-does">What it does</a> ·
|
|
30
35
|
<a href="#a-closer-look">A closer look</a> ·
|
|
31
36
|
<a href="#how-it-works">How it works</a> ·
|
|
@@ -33,6 +38,12 @@
|
|
|
33
38
|
<a href="CONTRIBUTING.md">Contributing</a>
|
|
34
39
|
</p>
|
|
35
40
|
|
|
41
|
+
<p align="center">
|
|
42
|
+
<a href="https://crisnahine.github.io/rails-ai-context/FAQ.html"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/crisnahine/rails-ai-context/main/docs/assets/faq-dark.svg"><img src="https://raw.githubusercontent.com/crisnahine/rails-ai-context/main/docs/assets/faq-light.svg" alt="Questions before you install? Read the FAQ. Do I need MCP support in my AI tool? No. The gem works three ways. 1, MCP server: AI calls tools via the protocol, the best experience. 2, Static files: generated context files (CLAUDE.md, .cursor/rules/, etc.). 3, CLI: the same 35 tools from the terminal, no server needed. More questions the FAQ answers: What does this gem do? Which AI tools are supported? Is this safe for production? Does it work without a database? Do I need to commit the generated files? How does this compare to a hand-written CLAUDE.md?" width="860"></picture></a>
|
|
43
|
+
</p>
|
|
44
|
+
|
|
45
|
+
<br>
|
|
46
|
+
|
|
36
47
|
<p align="center">
|
|
37
48
|
<picture>
|
|
38
49
|
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/crisnahine/rails-ai-context/main/docs/assets/session-dark.svg">
|
|
@@ -425,6 +436,10 @@ MCP config written for them. Any other MCP client, such as Claude Desktop, Winds
|
|
|
425
436
|
IDE (Copilot or AI Assistant), gets an entry from `rails-ai-context mcp-entry`. A tool with no MCP at all
|
|
426
437
|
gets the CLI setup, where the context files name the shell commands.
|
|
427
438
|
|
|
439
|
+
**Still wondering about something?** [The FAQ](https://crisnahine.github.io/rails-ai-context/FAQ.html)
|
|
440
|
+
answers the rest: install, the tools, configuration, context files, performance, security, and how it
|
|
441
|
+
compares to a hand-written `CLAUDE.md` or pasting `schema.rb` into the prompt.
|
|
442
|
+
|
|
428
443
|
## What it will not do
|
|
429
444
|
|
|
430
445
|
- **Write to your app or your database from a tool.** Every tool reads. The assistant still decides
|
data/docs/ARCHITECTURE.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Architecture
|
|
4
4
|
|
|
5
|
-
**How rails-ai-context is built, and why.**
|
|
5
|
+
**How rails-ai-context is built, and why: its modules and the request lifecycle.**
|
|
6
6
|
|
|
7
7
|
[Tools Reference](TOOLS.md) · [Introspectors](INTROSPECTORS.md) · [Security](SECURITY.md) · [Custom Tools](CUSTOM_TOOLS.md)
|
|
8
8
|
|
|
@@ -137,7 +137,7 @@ Four more answer for the app's databases and for what `rails_query` runs on them
|
|
|
137
137
|
|
|
138
138
|
### AST Engine
|
|
139
139
|
|
|
140
|
-
**Prism
|
|
140
|
+
Ruby source is read with **Prism**. A regex still reads Ruby only in a case the [AST-vs-regex rule](INTROSPECTORS.md#choosing-between-ast-and-regex) allows, such as a prefilter the parse then checks, or over the text `RubySource` gives it: comments, `=begin` blocks and string bodies blanked to spaces with every line and offset kept, so a comment, a string or a heredoc cannot match. The readers that also run before the app boots (the install's read of the initializer and its guard, and the settings read without running the app) parse with the standard library's Ripper, since an app's bundle may pin Prism.
|
|
141
141
|
|
|
142
142
|
- **AstCache** - Thread-safe parse cache (`Concurrent::Map`), keyed by the SHA256 of the file's content; a stat match answers without a read for a file already two seconds older than the read that recorded it
|
|
143
143
|
- **SourceIntrospector** - Single-pass Prism Dispatcher walks the AST once, feeding every registered listener simultaneously
|
|
@@ -225,7 +225,7 @@ Result: controller and view tools automatically include relevant schema informat
|
|
|
225
225
|
|
|
226
226
|
Thor-based CLI that works standalone (no Gemfile entry):
|
|
227
227
|
|
|
228
|
-
- `AppRoot` - Decides which app a command reads before anything reads the working directory: `--app-path` as given, else the working directory, else the nearest app root above it, else the one app below it. Several below are refused by name, except by the plugin's serve, which `AppRoot.target` hands the folder of apps to route (see MCP Server), and `init`, which sets them all up
|
|
228
|
+
- `AppRoot` - Decides which app a command reads before anything reads the working directory: `--app-path` as given, else the working directory, else the nearest app root above it, else the one app below it. A root that has a `bin/rails` and no app source reads the app that `bin/rails` names below it, else its `test/dummy` or `spec/dummy` app. Several below are refused by name, except by the plugin's serve, which `AppRoot.target` hands the folder of apps to route (see MCP Server), and `init`, which sets them all up
|
|
229
229
|
- `EntryBoot` - Boots the app `AppRoot` chose for the standalone binary, or says which tier it fell back to
|
|
230
230
|
- `Refusal` - Where the plugin's serve cannot serve, answers the MCP handshake with no tools and the reason, so Claude Code does not skip the plugin; also the line parse and the `initialize` answer the router and the proxy share
|
|
231
231
|
- `ToolRunner` - Parses CLI args, resolves tool names, executes tools, formats output
|
data/docs/CLI.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# CLI Reference
|
|
4
4
|
|
|
5
|
-
**All commands available from the terminal.**
|
|
5
|
+
**All rails-ai-context commands available from the terminal, with their flags.**
|
|
6
6
|
|
|
7
7
|
[Quickstart](QUICKSTART.md) · [Tools Reference](TOOLS.md) · [Standalone](STANDALONE.md) · [Configuration](CONFIGURATION.md)
|
|
8
8
|
|
|
@@ -77,7 +77,10 @@ directory if it is an app, else the nearest app root above it (a directory with
|
|
|
77
77
|
`config/application.rb`, `config/environment.rb`, or a `bin/rails` that boots an
|
|
78
78
|
app or an engine; never `$HOME`, `node_modules` or a gem install), else the one
|
|
79
79
|
app a level or two below it - looked for everywhere but `/`, `$HOME` and the
|
|
80
|
-
directories above it, which hold too much to search. A
|
|
80
|
+
directories above it, which hold too much to search. A root found by its
|
|
81
|
+
`bin/rails` alone, with no app source, reads the app below it that `bin/rails`
|
|
82
|
+
names as `APP_PATH` (a monorepo's root), else its `test/dummy` or `spec/dummy`
|
|
83
|
+
app (an engine whose code is all in `lib/`). A walk names the app it chose on stderr, as
|
|
81
84
|
`[rails-ai-context] using app at a/`, so `serve` keeps stdout clean. A folder
|
|
82
85
|
holding several apps is refused with one `--app-path` command per app, and
|
|
83
86
|
`tool --list` there lists the tools without an app. The chosen root is the
|
data/docs/FAQ.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# FAQ
|
|
4
4
|
|
|
5
|
-
**
|
|
5
|
+
**Answers about rails-ai-context: MCP support, production safety, running without a database, generated files, and how it compares to a hand-written CLAUDE.md.**
|
|
6
6
|
|
|
7
7
|
[Quickstart](QUICKSTART.md) · [Recipes](RECIPES.md) · [Troubleshooting](TROUBLESHOOTING.md) · [Configuration](CONFIGURATION.md)
|
|
8
8
|
|
data/docs/GUIDE.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# rails-ai-context - Complete Guide
|
|
4
4
|
|
|
5
|
-
**The all-in-one reference
|
|
5
|
+
**The all-in-one rails-ai-context reference: every command, parameter and option in one file.**
|
|
6
6
|
|
|
7
7
|
[Quickstart](QUICKSTART.md) · [Tools](TOOLS.md) · [Recipes](RECIPES.md) · [FAQ](FAQ.md)
|
|
8
8
|
|
|
@@ -116,7 +116,7 @@ No Gemfile entry, no initializer, no files in your project besides config and co
|
|
|
116
116
|
|
|
117
117
|
Choices 1 and 3 set `tool_mode` to `:mcp`, choice 2 sets it to `:cli`. Choice 3 also sets `context_files` to `false`. Any other answer takes the default.
|
|
118
118
|
4. **Writes the MCP config for each selected tool** (`.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json` and `.github/mcp.json`, `opencode.json`, `.codex/config.toml`). Skipped for choice 2, which instead lists any config that still starts `rails-ai-context` and asks `Remove rails-ai-context from them? (y/N)`: CLI mode starts no MCP server. A yes takes out only the gem's entries, as step 2 does. With choice 3 it lists instead the context files an earlier setup generated, which nothing refreshes once the install writes no context files, and asks `Remove the generated parts? Lines you wrote stay. (y/N)`; a yes removes them the way step 2 does, and `.ai-context.json` with them. An existing file is merged: only the `rails-ai-context` entry is added or updated, and keys in it the gem never writes stay. An entry under that name whose command the gem did not write (one that starts the server through Docker) is kept as it is, with a note. One that does not parse as JSON, or holds comments a rewrite would drop, is left as it is, with a warning that names the entry to add by hand. Each file is read as its client reads it. VS Code's and OpenCode's take JSONC, comments and trailing commas (read under json 2.9 or later); Claude Code reads `.mcp.json` as plain JSON, and Cursor's `.cursor/mcp.json` is held to plain JSON too, so a comment or a trailing comma in either is reported as one the client cannot read, and the file left as it is. In `.codex/config.toml` the server's table is found however its name is quoted, and replaced where it stands; an entry of the gem's written as an inline table or with dotted keys is left as it is, with a warning, since a table added beside it would declare the server twice, which Codex refuses.
|
|
119
|
-
5. **Creates or updates `config/initializers/rails_ai_context.rb`.** A new file gets your three answers as live lines (`config.ai_tools`, `config.tool_mode`, `config.context_files`) and every other option commented out at its default, wrapped in `if defined?(RailsAiContext) && RailsAiContext.respond_to?(:configure)`; it passes the omakase Rubocop a new Rails app runs. In an existing file it rewrites those three lines where the value changed - keeping the line's indentation and any note of your own after it - appends any config section the file lacks, adds the guard if it is missing, and leaves the rest alone.
|
|
119
|
+
5. **Creates or updates `config/initializers/rails_ai_context.rb`.** A new file gets your three answers as live lines (`config.ai_tools`, `config.tool_mode`, `config.context_files`) and every other option commented out at its default, wrapped in `if defined?(RailsAiContext) && RailsAiContext.respond_to?(:configure)`; it passes the omakase Rubocop a new Rails app runs. In an existing file it rewrites those three lines where the value changed - keeping the line's indentation and any note of your own after it - appends any config section the file lacks, adds the guard if it is missing (below the comments the file opens with, so a magic comment still applies), upgrades a bare `if defined?(RailsAiContext)` guard, and leaves the rest alone.
|
|
120
120
|
6. **Writes `.rails-ai-context.yml`** with `ai_tools`, `tool_mode` and `context_files`. Only a key whose value changed is rewritten, where it stands; your comments and other keys are kept, and a run that changes no value leaves the file as it was.
|
|
121
121
|
7. **Adds a line to `.gitignore`**, if the file exists: `.ai-context.json` (not for choice 3). A line that is already there is not added again. `.codex/config.toml` is no longer added: it holds nothing machine-specific and is committed like the other MCP configs, so the line an earlier release added is taken out.
|
|
122
122
|
8. **Asks about a pre-commit hook:** `Install a pre-commit hook that checks staged Ruby, ERB and JavaScript files for syntax errors? (y/N)`. Only `y` installs it. The hook runs `bundle exec rails-ai-context tool validate` (`rails-ai-context tool validate` in a standalone install) on the staged `.rb`, `.erb`, `.js`, `.mjs` and `.cjs` files and stops a commit whose files do not parse (JavaScript is parsed by `node`, as [`rails_validate`](TOOLS.md#rails_validate) describes); the Rails-reference checks (`level=rails`) are left to the tool, as Brakeman would slow every commit. An app that cannot boot (an initializer that needs a variable the shell lacks, say) is still checked, from its source, and the hook shows why it did not boot; it shows whatever else the check prints to stderr too, so a check that cannot run says why. Every staged name is read whole, one with characters outside ASCII included; a name holding a comma, which the files list cannot carry, is named and left unchecked. It goes where git runs hooks (`git rev-parse --git-path hooks`), so an app checked out as a submodule, an app inside a monorepo and a repo with `core.hooksPath` set all get it where git will run it. The hook names the apps it covers and validates each one's staged files (deleted ones aside) from inside that app; installing in a second app of the same monorepo adds it to the hook, unless the hook was changed by hand, which it says, and for an app below the top of the repository the question names the repository. A hook an earlier version wrote, and nobody changed since, is brought up to date without asking again: the oldest handed validate the files a commit deletes too, and the commit failed on them, and later ones ran `rails 'ai:tool[validate]'`, which has to boot the app, with its errors thrown away, so an app that could not boot failed every commit with no reason given. Any other hook that runs `rails-ai-context` - one changed by hand, or a team's own that calls it among other checks - is left as it is, with a message. No hook is offered for an app the repository does not track yet (an app under a dotfiles repository at `$HOME`, say), nor into a `core.hooksPath` outside the repository, which every repository using it shares; both say why. No question is asked outside a git repository or when the hook already covers the app. When another `pre-commit` hook exists there it prints `Skipped pre-commit hook (existing hook found - add manually)` and moves on.
|
|
@@ -679,7 +679,7 @@ rails_get_stimulus(detail: "full")
|
|
|
679
679
|
|
|
680
680
|
### rails_get_view
|
|
681
681
|
|
|
682
|
-
Returns view template contents, partials, and Stimulus controller references. In standard detail, includes **Schema Hints** for models inferred from instance variables.
|
|
682
|
+
Returns view template contents, partials, and Stimulus controller references. In standard detail, includes **Schema Hints** for models inferred from instance variables, and opens with the form builders the views call (with counts) and the ViewComponents they render.
|
|
683
683
|
|
|
684
684
|
**Parameters:**
|
|
685
685
|
|
|
@@ -929,17 +929,20 @@ order (`load_defaults 7.1`). A method declared again shows once with the later
|
|
|
929
929
|
declaration's conditions. A block or lambda callback shows its declaration at
|
|
930
930
|
`detail: "full"`, and turbo-rails' broadcast macros (`broadcasts_refreshes`,
|
|
931
931
|
`broadcasts_to` and the rest) are listed as the commit callbacks they declare.
|
|
932
|
+
On a booted app the model's callback chains are read too, so a callback a gem
|
|
933
|
+
or runtime code adds is listed where Rails runs it, tagged with the gem or as
|
|
934
|
+
read from the running app; Rails' own callbacks are left out.
|
|
932
935
|
|
|
933
936
|
### rails_get_helper_methods
|
|
934
937
|
|
|
935
|
-
Get Rails helper modules: method signatures,
|
|
938
|
+
Get the app's Rails helper modules: method signatures, the view helpers controllers declare with `helper_method`, and which views call each helper. Helper modules that gems or `on_load` hooks add are not listed; on a booted app the `helper_method` names they declare are, and on the static tier `detail:"full"` names the helpers of gems the lockfile holds, checked against the locked version. Specify a helper for full detail, or omit to list all helpers with method counts.
|
|
936
939
|
|
|
937
940
|
**Parameters:**
|
|
938
941
|
|
|
939
942
|
| Param | Type | Description |
|
|
940
943
|
|-------|------|-------------|
|
|
941
944
|
| `helper` | string | Helper module name (e.g. `ApplicationHelper`, `UsersHelper`). Omit to list all helpers. |
|
|
942
|
-
| `detail` | string | `summary` / `standard` (default) / `full`. summary: names + method counts. standard: names + method signatures. full: method signatures + view cross-references
|
|
945
|
+
| `detail` | string | `summary` / `standard` (default) / `full`. summary: names + method counts. standard: names + method signatures. full: method signatures + view cross-references. |
|
|
943
946
|
| `limit` | integer | Max helpers to return. Default: 50. |
|
|
944
947
|
| `offset` | integer | Skip this many helpers for pagination. Default: 0. |
|
|
945
948
|
|
|
@@ -953,10 +956,10 @@ rails_get_helper_methods(helper: "ApplicationHelper")
|
|
|
953
956
|
→ Full detail: method signatures, included modules
|
|
954
957
|
|
|
955
958
|
rails_get_helper_methods(detail: "full")
|
|
956
|
-
→ All helpers with method signatures
|
|
959
|
+
→ All helpers with method signatures; statically, the helpers of gems the lockfile holds
|
|
957
960
|
```
|
|
958
961
|
|
|
959
|
-
**Returns:** Helper module listing or full detail including file path, method signatures, included modules, and (at full detail) which views reference each helper method.
|
|
962
|
+
**Returns:** Helper module listing or full detail including file path, method signatures, included modules, and (at full detail) which views reference each helper method. Booted, it names no gem's helper modules. Statically, a gem's helper names print only when the lockfile holds the gem at a version that ships them, and Devise's are named by the `devise_for` scopes the routes spell.
|
|
960
963
|
|
|
961
964
|
### rails_get_service_pattern
|
|
962
965
|
|
|
@@ -1710,7 +1713,7 @@ Runs the checks below and reports an AI readiness score (0-100). A check that do
|
|
|
1710
1713
|
| Tests | A test suite is found: the app's, or in an engine's `test/dummy` the engine's |
|
|
1711
1714
|
| Migrations | Migration files exist, counted over every database the app migrates, and in an engine's `test/dummy` the engine's own |
|
|
1712
1715
|
| Context files | Generated context files exist where `config.output_dir` puts them, and a context run would leave them as they are. A file a run would rewrite, because an older version of the gem wrote it or the app changed under it, is named; a file that is only older than the code is not. In an engine's dummy app the install at the engine's root is read, and its own context command runs there, into a copy. No row on an MCP-only install |
|
|
1713
|
-
| Initializer guard | Shown only when `config/initializers/rails_ai_context.rb`
|
|
1716
|
+
| Initializer guard | Shown only when `config/initializers/rails_ai_context.rb` makes a `RailsAiContext.configure` call no guard covers (a guard in a comment, or an `if` that ends before the call, covers nothing), or guards on `defined?(RailsAiContext)` alone |
|
|
1714
1717
|
| MCP configs | Each selected tool's MCP config file exists, parses, and holds a rails-ai-context server whose command can start: `bundle exec` only where the app's lockfile carries the gem and the bundle's copy has its executable, the `rails-ai-context` binary only where it is on PATH, and a warning when a config runs that binary in an app whose bundle carries the gem. A Codex entry that still starts with the Ruby environment an earlier release saved warns, and fails when that saved `PATH` no longer reaches its command (fix: run the install). The command is looked up, never run. Skipped in CLI-only mode |
|
|
1715
1718
|
| MCP server | MCP server can be built, with an `mcp` gem this gem supports (warns, as the boot does, when the app's bundle pins one outside that range) |
|
|
1716
1719
|
| Introspector health | Every configured introspector returns data |
|
|
@@ -1756,7 +1759,7 @@ When running the MCP server via `rails ai:serve`, **live reload** notifies conne
|
|
|
1756
1759
|
|
|
1757
1760
|
Answers never wait on it. Every tool call and resource read first checks the watched files, with `listen` or without it (a new Rails 8 app does not bundle it), and when one changed it reloads the app's code and drops the caches - so an answer sees every edit made before the call began, one made a moment earlier included, which `listen` would deliver only after its debounce. The check stats each watched directory and file and reads a directory again only when it changed: about a millisecond on a small app, about 30 ms at 10,000 files. Calls made at the same time, over HTTP, wait for one check together; calls one after another each check.
|
|
1758
1761
|
|
|
1759
|
-
A server whose app cannot reload code - `RAILS_ENV=test`, or production with eager loading, where `config.enable_reloading` is off - keeps the code it booted with. What reflection reads, such as associations and enums, then stays as of boot (validations and callbacks are read off the source, so they still follow the edit), and once a file under the app's autoload paths changes, every answer ends with a note naming it: restart the server to see the edit.
|
|
1762
|
+
A server whose app cannot reload code - `RAILS_ENV=test`, or production with eager loading, where `config.enable_reloading` is off - keeps the code it booted with. What reflection reads, such as associations and enums, then stays as of boot (validations and callbacks are read off the source, so they still follow the edit; one no source line declares is read from the running class and stays as of boot), and once a file under the app's autoload paths changes, every answer ends with a note naming it: restart the server to see the edit.
|
|
1760
1763
|
|
|
1761
1764
|
One save a reload can miss: Bootsnap's compile cache knows a Ruby file by its size and the second of its mtime, so a file saved twice within one second at the same size can reload as the first save. Every answer then names the file until it is saved again a second later ([Known limits](COMPATIBILITY.md#known-limits)).
|
|
1762
1765
|
|