rails-ai-context 0.15.0 → 0.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 840dab1aeabc3323d5aca5702d95e712f7a013f24d05327424674262eee46de9
4
- data.tar.gz: 2eed45a1bc5e79b9806f691c9e88ca2ced55660d53b74f56d8f354963c9ee497
3
+ metadata.gz: 36149e337f1a334d91a8a59cce1df6b090e621cafbb08886114f775d93cbd643
4
+ data.tar.gz: 45bc13bd494a4b4de5742f29b0919a9c77515f4c301c3f347f9235caec08d8a2
5
5
  SHA512:
6
- metadata.gz: ac390f1d5b6b148f33fdac979d98269695fed76bceaaaab6b18c0682819a271a8dfdbaaab00f6c35eaaa2a867f652bc46c8d3d88199c5cd3bd1a87e20a0b3320
7
- data.tar.gz: 0eb688c270bf08ddb5b70fc3dfbcca19432de3c6922c8a0f784081d82c117458fc3e136a56a962ee3988a9263a1ae9d9eff48716e4321e57bbc92d533622b249
6
+ metadata.gz: 05aa1e4216100cc18572615abf83ea1e22cb1faf77b594a9cb9fea4a4bfab2919a18189a5648455598b051aa6e8b89db00c39ae7ad3018f82aa95bb4bc760064
7
+ data.tar.gz: eb59ad0f7fa0c3df2147bb31f1f9b85a69a1a461fd248ade6f97928ed775d727537ddab744aea83284ed6931a0ab997e6c5c46f6e0f716cc5a5f4724b6f4890f
data/CHANGELOG.md CHANGED
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.15.2] - 2026-03-22
9
+
10
+ ### Fixed
11
+
12
+ - **Test command detection** — Serializers now use detected test framework (minitest → `rails test`, rspec → `bundle exec rspec`) instead of hardcoding `bundle exec rspec`. Default is `rails test` (the Rails default). Contributed by @curi (PR #13).
13
+
14
+ ## [0.15.1] - 2026-03-22
15
+
16
+ ### Fixed
17
+
18
+ - **Copilot serializer** — Show all model associations (not capped at 3), use human-readable architecture/pattern labels.
19
+ - **OpenCode rules serializer** — Filter framework controllers (Devise) from AGENTS.md output, show all associations, match `before_action` with `!`/`?` suffixes.
20
+
8
21
  ## [0.15.0] - 2026-03-22
9
22
 
10
23
  ### Security
@@ -278,7 +278,7 @@ module RailsAiContext
278
278
  case framework
279
279
  when "rspec" then "bundle exec rspec"
280
280
  when "minitest" then "rails test"
281
- else "bundle exec rspec"
281
+ else "rails test"
282
282
  end
283
283
  end
284
284
 
@@ -307,7 +307,7 @@ module RailsAiContext
307
307
  case framework
308
308
  when "rspec" then "bundle exec rspec"
309
309
  when "minitest" then "rails test"
310
- else "bundle exec rspec"
310
+ else "rails test"
311
311
  end
312
312
  end
313
313
 
@@ -58,7 +58,7 @@ module RailsAiContext
58
58
  lines << "## Models (#{models.size})"
59
59
  models.keys.sort.first(25).each do |name|
60
60
  data = models[name]
61
- assocs = (data[:associations] || []).first(3).map { |a| "#{a[:type]} :#{a[:name]}" }.join(", ")
61
+ assocs = (data[:associations] || []).map { |a| "#{a[:type]} :#{a[:name]}" }.join(", ")
62
62
  line = "- **#{name}**"
63
63
  line += " — #{assocs}" unless assocs.empty?
64
64
  lines << line
@@ -73,9 +73,11 @@ module RailsAiContext
73
73
  arch = conv[:architecture] || []
74
74
  patterns = conv[:patterns] || []
75
75
  if arch.any? || patterns.any?
76
+ arch_labels = RailsAiContext::Tools::GetConventions::ARCH_LABELS rescue {}
77
+ pattern_labels = RailsAiContext::Tools::GetConventions::PATTERN_LABELS rescue {}
76
78
  lines << "## Architecture"
77
- arch.each { |p| lines << "- #{p}" }
78
- patterns.first(10).each { |p| lines << "- #{p}" }
79
+ arch.each { |p| lines << "- #{arch_labels[p] || p}" }
80
+ patterns.first(10).each { |p| lines << "- #{pattern_labels[p] || p}" }
79
81
  lines << ""
80
82
  end
81
83
  end
@@ -135,11 +137,21 @@ module RailsAiContext
135
137
  lines << "## Conventions"
136
138
  lines << "- Follow existing patterns and naming conventions"
137
139
  lines << "- Use MCP tools to check schema before writing migrations"
138
- lines << "- Run `bundle exec rspec` after changes"
140
+ lines << "- Run `#{detect_test_command}` after changes"
139
141
  lines << ""
140
142
 
141
143
  lines.join("\n")
142
144
  end
145
+
146
+ def detect_test_command
147
+ tests = context[:tests]
148
+ framework = tests.is_a?(Hash) ? tests[:framework] : nil
149
+ case framework
150
+ when "rspec" then "bundle exec rspec"
151
+ when "minitest" then "rails test"
152
+ else "rails test"
153
+ end
154
+ end
143
155
  end
144
156
 
145
157
  # Internal: full-mode Copilot serializer (wraps MarkdownSerializer)
@@ -503,6 +503,16 @@ module RailsAiContext
503
503
  _This context file is auto-generated. Run `rails ai:context` to regenerate._
504
504
  MD
505
505
  end
506
+
507
+ def detect_test_command
508
+ tests = context[:tests]
509
+ framework = tests.is_a?(Hash) ? tests[:framework] : nil
510
+ case framework
511
+ when "rspec" then "bundle exec rspec"
512
+ when "minitest" then "rails test"
513
+ else "rails test"
514
+ end
515
+ end
506
516
  end
507
517
  end
508
518
  end
@@ -61,7 +61,7 @@ module RailsAiContext
61
61
 
62
62
  models.keys.sort.first(30).each do |name|
63
63
  data = models[name]
64
- assocs = (data[:associations] || []).first(3).map { |a| "#{a[:type]} :#{a[:name]}" }.join(", ")
64
+ assocs = (data[:associations] || []).map { |a| "#{a[:type]} :#{a[:name]}" }.join(", ")
65
65
  vals = (data[:validations] || []).size
66
66
  line = "- **#{name}**"
67
67
  line += " (table: #{data[:table_name]})" if data[:table_name]
@@ -93,8 +93,12 @@ module RailsAiContext
93
93
  controllers = data[:controllers] || {}
94
94
  return nil if controllers.empty?
95
95
 
96
+ # Filter out framework-internal controllers
97
+ framework = %w[DeviseController Devise::OmniauthCallbacksController]
98
+ app_controllers = controllers.reject { |name, _| framework.include?(name) }
99
+
96
100
  lines = [
97
- "# Controllers (#{controllers.size})",
101
+ "# Controllers (#{app_controllers.size})",
98
102
  "",
99
103
  "> Auto-generated by rails-ai-context. Do not edit manually.",
100
104
  "> Read controller files directly when editing. Use MCP tools for reference only.",
@@ -107,20 +111,20 @@ module RailsAiContext
107
111
  app_ctrl = File.join(root, "app", "controllers", "application_controller.rb")
108
112
  if File.exist?(app_ctrl)
109
113
  source = File.read(app_ctrl)
110
- before_actions = source.scan(/before_action\s+:(\w+)/).flatten
114
+ before_actions = source.scan(/before_action\s+:([\w!?]+)/).flatten
111
115
  lines << "**Global before_actions:** #{before_actions.join(', ')}" << "" if before_actions.any?
112
116
  end
113
117
  rescue; end
114
118
 
115
- controllers.keys.sort.first(25).each do |name|
116
- info = controllers[name]
117
- actions = (info[:actions] || []).map { |a| a.is_a?(Hash) ? a[:name] : a }.compact.first(6)
119
+ app_controllers.keys.sort.first(25).each do |name|
120
+ info = app_controllers[name]
121
+ actions = (info[:actions] || []).map { |a| a.is_a?(Hash) ? a[:name] : a }.compact
118
122
  line = "- **#{name}**"
119
123
  line += " — #{actions.join(", ")}" unless actions.empty?
120
124
  lines << line
121
125
  end
122
126
 
123
- lines << "- _...#{controllers.size - 25} more_" if controllers.size > 25
127
+ lines << "- _...#{app_controllers.size - 25} more_" if app_controllers.size > 25
124
128
 
125
129
  # List service objects
126
130
  begin
@@ -233,7 +233,7 @@ module RailsAiContext
233
233
  case framework
234
234
  when "rspec" then "bundle exec rspec"
235
235
  when "minitest" then "rails test"
236
- else "bundle exec rspec"
236
+ else "rails test"
237
237
  end
238
238
  end
239
239
 
@@ -259,7 +259,7 @@ module RailsAiContext
259
259
  case framework
260
260
  when "rspec" then "bundle exec rspec"
261
261
  when "minitest" then "rails test"
262
- else "bundle exec rspec"
262
+ else "rails test"
263
263
  end
264
264
  end
265
265
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsAiContext
4
- VERSION = "0.15.0"
4
+ VERSION = "0.15.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-ai-context
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.15.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - crisnahine