rolemodel-rails 2.8.0 → 2.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -1
  3. data/lib/generators/rolemodel/README.md +1 -0
  4. data/lib/generators/rolemodel/agent_docs/README.md +14 -0
  5. data/lib/generators/rolemodel/agent_docs/USAGE +10 -0
  6. data/lib/generators/rolemodel/agent_docs/agent_docs_generator.rb +22 -0
  7. data/lib/generators/rolemodel/agent_docs/templates/.claude/settings.json +15 -0
  8. data/lib/generators/rolemodel/agent_docs/templates/.github/instructions/conventions.instructions.md +9 -0
  9. data/lib/generators/rolemodel/agent_docs/templates/AGENTS.md.tt +26 -0
  10. data/lib/generators/rolemodel/agent_docs/templates/CLAUDE.md +1 -0
  11. data/lib/generators/rolemodel/agent_docs/templates/docs/CONVENTIONS.md +18 -0
  12. data/lib/generators/rolemodel/agent_docs/templates/docs/conventions/callbacks.md +5 -0
  13. data/lib/generators/rolemodel/agent_docs/templates/docs/conventions/controllers.md +3 -0
  14. data/lib/generators/rolemodel/agent_docs/templates/docs/conventions/eager-loading.md +5 -0
  15. data/lib/generators/rolemodel/agent_docs/templates/docs/conventions/logic-in-models.md +7 -0
  16. data/lib/generators/rolemodel/agent_docs/templates/docs/conventions/migrations.md +7 -0
  17. data/lib/generators/rolemodel/agent_docs/templates/docs/conventions/no-sql-strings.md +11 -0
  18. data/lib/generators/rolemodel/agent_docs/templates/docs/conventions/partial-locals.md +3 -0
  19. data/lib/generators/rolemodel/agent_docs/templates/docs/conventions/reproduce-the-bug.md +5 -0
  20. data/lib/generators/rolemodel/agent_docs/templates/docs/conventions/reuse-scopes.md +3 -0
  21. data/lib/generators/rolemodel/agent_docs/templates/docs/conventions/stimulus.md +3 -0
  22. data/lib/generators/rolemodel/agent_docs/templates/docs/conventions/string-enums.md +3 -0
  23. data/lib/generators/rolemodel/agent_docs/templates/docs/conventions/system-spec-assertions.md +17 -0
  24. data/lib/generators/rolemodel/agent_docs/templates/docs/conventions/test-layers.md +3 -0
  25. data/lib/generators/rolemodel/agent_docs/templates/docs/conventions/views-and-forms.md +9 -0
  26. data/lib/generators/rolemodel/all_generator.rb +1 -0
  27. data/lib/generators/rolemodel/core_setup/README.md +3 -0
  28. data/lib/generators/rolemodel/core_setup/USAGE +4 -4
  29. data/lib/generators/rolemodel/core_setup/core_setup_generator.rb +3 -1
  30. data/lib/generators/rolemodel/github/README.md +1 -1
  31. data/lib/generators/rolemodel/github/github_generator.rb +1 -5
  32. data/lib/generators/rolemodel/github/templates/workflows/ci.yml.tt +14 -71
  33. data/lib/generators/rolemodel/linters/rubocop/templates/.rubocop.yml +17 -0
  34. data/lib/rolemodel/engine.rb +2 -0
  35. data/lib/rolemodel/version.rb +1 -1
  36. metadata +23 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2eae463b96705a0478a97b06daf586e4022499a8d53cca46ba6c91ab2cf1d41c
4
- data.tar.gz: 174fcab3a6f7b8a4e29434a0ee123a9b853fb3ef7006e9cefc1199721083bbe6
3
+ metadata.gz: 1544b6265be0457f98b6273536b191316aa14c34798360e4fe0582f1f0f407ae
4
+ data.tar.gz: 4663c282bc2bad26c21a96d5a851291ca7ebd9ed7fdfe443646df7a1932af5e6
5
5
  SHA512:
6
- metadata.gz: ab6a232a25594bf86544265511deb2174f148ed29bfd945f9f561ac19cbeed3c26503206045b5f3dfc3065b83ad049d9ea821e9558e8a7238fa512cbc722ca88
7
- data.tar.gz: a12296267725fd071c2db0fe5a57ebc4fa623f18a55b19c109d0399ad7be19df00c4f5c412da46f93ccac8bac50d7f8eb0a468766c9caf66a417ccbcb6a97226
6
+ metadata.gz: 0441af8eb9399c2d31795768daa4deefdad23dc623c40b412c53b4fdc3d53edf3b9eb47c3dc5ce54f726ab6e5e54cf5c7bffdb1581ffab4849f7f2d99cb0890b
7
+ data.tar.gz: e23edd7583193869bce7a5236c920fffde5dbcbb522c472cb3786ff5ad4b99d0554daedf1ff7c9fc221d90d350aa2089a71e6b2bb0d7addc11b3b7a31d903ade
data/README.md CHANGED
@@ -77,6 +77,7 @@ bin/rails g
77
77
  ## Generators
78
78
 
79
79
  * [Core Setup](./lib/generators/rolemodel/core_setup)
80
+ * [Agent Docs](./lib/generators/rolemodel/agent_docs)
80
81
  * [Github](./lib/generators/rolemodel/github)
81
82
  * [Heroku](./lib/generators/rolemodel/heroku)
82
83
  * [Readme](./lib/generators/rolemodel/readme)
@@ -129,7 +130,7 @@ Generators that leave behind conventions a coding agent needs to follow also ins
129
130
  | `rolemodel:turbo:modals` | `turbo-modals` |
130
131
  | `rolemodel:turbo:form` | `dynamic-forms` |
131
132
  | `rolemodel:soft_destroyable` | `soft-destroyable` |
132
- | `rolemodel:core_setup` | `polymorphic-parent-resources`, `rake-tasks` |
133
+ | `rolemodel:core_setup` | `controller-patterns`, `polymorphic-parent-resources`, `rake-tasks` |
133
134
 
134
135
  ## Utilities
135
136
 
@@ -4,6 +4,7 @@
4
4
 
5
5
  ## What you get
6
6
 
7
+ * [Agent Docs](./agent_docs)
7
8
  * [Editors](./editors)
8
9
  * [Github](./github)
9
10
  * [GoodJob](./good_job)
@@ -0,0 +1,14 @@
1
+ # Agent Docs Generator
2
+
3
+ [USAGE](./USAGE)
4
+
5
+ The agent instructions and conventions a new RoleModel app starts with. `rolemodel:core_setup` runs it.
6
+
7
+ ## What you get
8
+
9
+ - `AGENTS.md`, with `CLAUDE.md` pointing at it. Fill in its first sentence: what the app is, and the one fact that changes how every task in it is approached.
10
+ - `docs/CONVENTIONS.md`, an index of the files in `docs/conventions/`. Each entry carries a `<!-- paths: -->` glob naming the files it applies to.
11
+ - `.github/instructions/conventions.instructions.md`, which points Copilot (including code review) at the same conventions.
12
+ - `.claude/hooks/surface_conventions.rb`, registered in `.claude/settings.json`. Before Claude Code edits a file, the hook lists the conventions whose globs match it. It's downloaded from the [`scaffold-docs`](https://github.com/RoleModel/skills/tree/main/skills/scaffold-docs) skill, so there's one copy to maintain, and it needs Ruby on the `PATH`.
13
+
14
+ The conventions assume the stack `core_setup` installs (Slim, SimpleForm, Optics, Turbo, RSpec with Playwright) and the [`controller-patterns`](https://github.com/RoleModel/skills/tree/main/skills/controller-patterns) skill. For an existing app, use the `scaffold-docs` and `generate-conventions` skills instead.
@@ -0,0 +1,10 @@
1
+ Description:
2
+ Adds AGENTS.md and RoleModel's starting conventions for a new app
3
+
4
+ Writes AGENTS.md (with CLAUDE.md pointing at it), docs/CONVENTIONS.md and
5
+ the convention files it indexes, and Copilot instructions that point at
6
+ them. It also installs the surface_conventions hook from RoleModel/skills,
7
+ which shows Claude Code the conventions that apply to each file it edits.
8
+
9
+ Example:
10
+ rails generate rolemodel:agent_docs
@@ -0,0 +1,22 @@
1
+ module Rolemodel
2
+ class AgentDocsGenerator < GeneratorBase
3
+ HOOK_URL = 'https://raw.githubusercontent.com/RoleModel/skills/main/skills/scaffold-docs/assets/surface_conventions.rb'.freeze
4
+
5
+ source_root File.expand_path('templates', __dir__)
6
+
7
+ def install_docs
8
+ directory '.', '.'
9
+ end
10
+
11
+ def install_hook
12
+ get HOOK_URL, '.claude/hooks/surface_conventions.rb'
13
+ chmod '.claude/hooks/surface_conventions.rb', 0o755
14
+ end
15
+
16
+ private
17
+
18
+ def project_name
19
+ Rails.application.class.module_parent_name.titleize
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,15 @@
1
+ {
2
+ "hooks": {
3
+ "PreToolUse": [
4
+ {
5
+ "matcher": "^(Edit|Write)$",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "\"${CLAUDE_PROJECT_DIR}/.claude/hooks/surface_conventions.rb\""
10
+ }
11
+ ]
12
+ }
13
+ ]
14
+ }
15
+ }
@@ -0,0 +1,9 @@
1
+ ---
2
+ applyTo: "app/**/*,spec/**/*,db/migrate/**/*,lib/**/*,config/**/*"
3
+ ---
4
+
5
+ # Conventions
6
+
7
+ `docs/CONVENTIONS.md` is the source of truth for this repo's conventions. Each entry carries a `<!-- paths: ... -->` comment naming the files it applies to. Read the convention files whose paths match what you're changing, and follow what they say — not the one-line index summary.
8
+
9
+ The branch name or PR title carries a ticket ID like `ABC-123`. Whenever the `linear` MCP server is connected, fetch that issue with `linear-get_issue` and read its description and acceptance criteria before writing or reviewing code — every time, not only when something looks off. Flag changes that contradict the ticket and requirements the diff doesn't address. No ID, or no server: work against these conventions alone and don't block on it.
@@ -0,0 +1,26 @@
1
+ # <%= project_name %>
2
+
3
+ <One sentence: what this app is, plus the one fact that changes how every task in it is approached.>
4
+
5
+ ## How We Build
6
+
7
+ - Deliver the smallest change that adds value. Speculative complexity makes the next change harder, so never pre-solve a hypothetical case; flag real uncertainty in one line and move on.
8
+ - Make the change easy, then make the easy change. When extending something, ask whether it's still the right shape, and reshape it first if not.
9
+ - Think like a Rubyist: prefer polymorphism to conditionals, and Rails conventions to custom machinery.
10
+ - Fix root causes, never symptoms. When reusing a method exposes a bug, fix that method rather than writing a near-copy around it.
11
+ - Testability is a code virtue: write code that looks test-first even when it wasn't. Test behavior, not implementation, and don't over-constrain.
12
+ - Prefer a clearer name or an extracted method to a comment.
13
+
14
+ ## Before Editing
15
+
16
+ - Read `docs/CONVENTIONS.md`, then the convention files relevant to the task.
17
+ - No new gems, top-level directories, base classes, or JS libraries without asking. If no existing pattern fits, stop and say so.
18
+ - Keep changes minimal and focused; preserve unrelated work in a dirty tree.
19
+ - Write a focused failing test before implementing feature behavior.
20
+
21
+ ## Verification
22
+
23
+ - `bin/setup` once per checkout; `bin/dev` to run the app.
24
+ - `bundle exec rspec spec/path/to_spec.rb` for the specs your change touches. CI runs the full suite; don't run it locally.
25
+ - `bundle exec rubocop -a`
26
+ - `yarn eslint`
@@ -0,0 +1,18 @@
1
+ # Conventions
2
+
3
+ Read the entries below, then the files relevant to the task.
4
+
5
+ - [Controllers follow the controller-patterns skill](conventions/controllers.md) — load the skill before writing a controller or route; no custom actions. <!-- paths: app/controllers/**/*.rb, config/routes.rb -->
6
+ - [Logic lives in models](conventions/logic-in-models.md) — models, POROs and form objects; app/services only for external boundaries; jobs call one method. <!-- paths: app/controllers/**/*.rb, app/jobs/**/*.rb, app/models/**/*.rb, app/forms/**/*.rb, app/services/**/*.rb -->
7
+ - [Callbacks stay guarded](conventions/callbacks.md) — the record, its siblings, or a Turbo refresh; guarded state-transition jobs; never mail or API calls. <!-- paths: app/models/**/*.rb -->
8
+ - [String-backed enums, referenced by key](conventions/string-enums.md) — explicit string values, never a magic string. <!-- paths: app/models/**/*.rb, db/migrate/*.rb, spec/factories/**/*.rb -->
9
+ - [Queries live in model scopes](conventions/reuse-scopes.md) — named scopes, no order/where/group_by in templates. <!-- paths: app/controllers/**/*.rb, app/jobs/**/*.rb, app/models/**/*.rb, app/views/**/*.slim -->
10
+ - [No SQL strings in queries](conventions/no-sql-strings.md) — hashes, ranges, association joins, in_order_of; Arel only as a last resort. <!-- paths: app/**/*.rb, lib/**/*.rb, spec/**/*.rb -->
11
+ - [Eager load in the query that feeds the view](conventions/eager-loading.md) — includes up front; includes plus joins becomes eager_load. <!-- paths: app/controllers/**/*.rb, app/models/**/*.rb, app/jobs/**/*.rb, app/views/**/*.slim -->
12
+ - [Views are Slim; forms are simple_form](conventions/views-and-forms.md) — Slim, simple_form and app/inputs, render records by to_partial_path, shared partials in app/views/application, Optics. <!-- paths: app/views/**/*.slim, app/inputs/**/*.rb, app/helpers/**/*.rb, app/assets/stylesheets/**/*.css -->
13
+ - [Partials declare their locals](conventions/partial-locals.md) — locals on the first line; never an instance variable. <!-- paths: app/views/**/_*.slim -->
14
+ - [Reach for Turbo before Stimulus](conventions/stimulus.md) — TurboForm and Turbo refreshes first; Stimulus only for browser-only interactions. <!-- paths: app/javascript/**/*.js, app/views/**/*.slim -->
15
+ - [Generate migrations; never renumber one](conventions/migrations.md) — generator timestamps, data__ migrations with their own models, schema.rb column order. <!-- paths: db/migrate/*.rb, db/schema.rb -->
16
+ - [Test layers](conventions/test-layers.md) — system specs for flows, request specs for page-less endpoints, no controller specs. <!-- paths: spec/**/*.rb -->
17
+ - [A fix ships with the spec that proves it](conventions/reproduce-the-bug.md) — failing-first specs with factories; don't stub the app's own models. <!-- paths: spec/**/*.rb -->
18
+ - [System specs assert what a user sees](conventions/system-spec-assertions.md) — labels and text for targets, data_test for scoping, flash for success. <!-- paths: spec/system/**/*.rb, app/views/**/*.slim -->
@@ -0,0 +1,5 @@
1
+ # Callbacks stay guarded
2
+
3
+ A callback derives the record's own attributes, keeps its siblings consistent, or broadcasts a Turbo refresh. It may enqueue a job for a specific state transition, but only behind a guard like `if: -> { saved_change_to_status?(to: 'closed') }`. A callback never sends mail or calls an external API directly.
4
+
5
+ An unguarded side effect runs on every save path, including factories, imports, and the console.
@@ -0,0 +1,3 @@
1
+ # Controllers follow the controller-patterns skill
2
+
3
+ Load the `controller-patterns` skill before writing or reshaping a controller or route, and match one of its shapes. There are no custom actions: an action that doesn't fit is a resource of its own.
@@ -0,0 +1,5 @@
1
+ # Eager load in the query that feeds the view
2
+
3
+ Load the associations a view or job walks with `includes` in the query that fetches the records, not with per-row lookups.
4
+
5
+ `includes` silently turns into one large joined `eager_load` when the same association is also joined or filtered on.
@@ -0,0 +1,7 @@
1
+ # Logic lives in models
2
+
3
+ Put a business rule or state transition in a named model method, or in a PORO under `app/models/`. Put input spanning several records in a form object in `app/forms/` that includes `ActiveModel::Model` and `ActiveModel::Attributes`.
4
+
5
+ `app/services/` is for boundaries with the outside world (third-party APIs, uploads, webhook consumers). Don't add a service for domain logic.
6
+
7
+ A controller holds control flow only (see the controller-patterns skill). A job loads its records and calls one model method.
@@ -0,0 +1,7 @@
1
+ # Generate migrations; never renumber one
2
+
3
+ Create a migration with `bin/rails generate migration`, never by hand-writing the timestamp: round `...0000` versions collide. The `schema_migrations` table tracks applied migrations by their timestamp prefix alone, so never change a committed migration's timestamp.
4
+
5
+ Generate a migration that changes data as `bin/rails generate migration data__<short_description>`, so data migrations stand apart from schema changes in `db/migrate/`. It declares its own models, so later changes to the app's models can't change what it does. Name each after its table and inherit from `ActiveRecord::Base`: `class Issue < ActiveRecord::Base; end`. A table with a `type` column also needs `self.inheritance_column = nil`. Back-fill with one `update_all` per distinct value rather than one per row.
6
+
7
+ `db/schema.rb` dumps columns in the local database's physical order. Before committing it, check that no column moved without a migration causing it; order follows the order migrations landed on the default branch.
@@ -0,0 +1,11 @@
1
+ # No SQL strings in queries
2
+
3
+ Build queries from ActiveRecord, never from SQL string fragments. That rules out `select('...')`, `order('...')`, `pluck('...')`, `joins('...')`, `group('...')`, `where('start_date < ?', date)`, string `update_all`, and `Arel.sql(...)`.
4
+
5
+ Use instead:
6
+
7
+ - Hash conditions and open-ended ranges: `where(start_date: ...date)`, `where(archived_at: nil)`.
8
+ - Association joins and nested hashes: `joins(:team).order(teams: { name: :asc })`.
9
+ - `in_order_of(:status, %w[active pending archived])` for a custom sort order.
10
+
11
+ If a query seems to need raw SQL (a JSONB `->>` lookup, Postgres `DISTINCT ON`, `NULLS LAST`), redesign it: store the value in a real column, or narrow the rows with a scope and pick in Ruby. An Arel node is the last resort, and worth a note in the PR.
@@ -0,0 +1,3 @@
1
+ # Partials declare their locals
2
+
3
+ A partial declares its locals on the first line with `-# locals: (widget:)`. It never reads an instance variable. When a partial isn't a record's, render it with the shorthand `render 'widgets/fields', f:`, not `render partial:`.
@@ -0,0 +1,5 @@
1
+ # A fix ships with the spec that proves it
2
+
3
+ A bug fix includes a spec that fails without the fix. Build real records with factories, and don't stub the app's own models.
4
+
5
+ A spec that stubs the collaborator holding the bug passes whether or not the fix is there.
@@ -0,0 +1,3 @@
1
+ # Queries live in model scopes
2
+
3
+ Chain the model's existing scopes before writing a query, and add a missing query as a named scope on the model, not inline in a controller, job, or template. Templates render what they're given: no `order`, `where`, or `group_by` in Slim.
@@ -0,0 +1,3 @@
1
+ # Reach for Turbo before Stimulus
2
+
3
+ Dynamic page behavior is server-rendered: a dependent or conditional form uses TurboForm (the `dynamic-forms` skill), and a page that changes after an action redirects and morphs with a Turbo refresh. Stimulus is for interactions only the browser can do (drag-and-drop, Tom Select), using the controllers the gem's generators install. No inline JavaScript in templates. A new Stimulus controller is a question to raise in the PR.
@@ -0,0 +1,3 @@
1
+ # String-backed enums, referenced by key
2
+
3
+ Declare enums with explicit string values on a string column, like `enum :status, { active: 'active', archived: 'archived' }`. Reference values by key, predicate, scope, or factory trait, never as a raw string.
@@ -0,0 +1,17 @@
1
+ # System specs assert what a user sees
2
+
3
+ Select by what the user sees, never by CSS class or DOM structure:
4
+
5
+ - Click targets and form fields by their visible text or label: `click_on "Yes, I'm Sure"`, `fill_in 'Name', with: 'Bob'`. A field without a label uses its name attribute: `fill_in 'user[name]', with: 'Bob'`.
6
+ - Scope to one part of the page with a `data-testid` from `dom_id`, and select it with the `data_test` helper:
7
+
8
+ ```slim
9
+ tr data-testid=dom_id(widget)
10
+ td = link_to 'Edit', edit_widget_path(widget)
11
+ ```
12
+
13
+ ```ruby
14
+ within(data_test(widget)) { click_on 'Edit' }
15
+ ```
16
+
17
+ End every interaction with an assertion on its visible result. For a create, update or destroy, that's usually the flash message: `expect(page).to have_content 'Successfully Created Widget'`.
@@ -0,0 +1,3 @@
1
+ # Test layers
2
+
3
+ Cover a user flow with a system spec on the default `rack_test` driver, and add `js: true` (Playwright) only when the behavior needs JavaScript. Cover an endpoint with no page of its own (a webhook, a turbo_stream or JSON endpoint) with a request spec in `spec/requests/`. Don't write controller specs. Unit-test logic in the model that holds it, and policies in `spec/policies/`.
@@ -0,0 +1,9 @@
1
+ # Views are Slim; forms are simple_form
2
+
3
+ Templates are Slim. Build every form with `simple_form_for`, `simple_fields_for` for nested attributes, and `f.association` for `belongs_to` selects. Reach for the custom inputs in `app/inputs/` before adding one.
4
+
5
+ Every input option earns its place: drop options that restate a default. A `label_method` repeated across forms becomes `to_label` on the model; an option every input of a type needs becomes a custom input or wrapper.
6
+
7
+ Render records with `render @widget` or `render @widgets`, which find the partial through `to_partial_path`. Name a partial only when no record owns it.
8
+
9
+ Shared partials live in `app/views/application/`, the fallback lookup path for a bare `render`, never in `app/views/shared/`. Check there and in `app/helpers/` for an existing partial or helper before writing a new one. Style with Optics classes and tokens (the `optics-context` skill), not one-off CSS.
@@ -20,6 +20,7 @@ module Rolemodel
20
20
  generate 'rolemodel:saas:all'
21
21
  generate 'rolemodel:mailers'
22
22
  generate 'rolemodel:linters:all'
23
+ generate 'rolemodel:agent_docs'
23
24
  generate 'rolemodel:ui_components:all'
24
25
  generate 'rolemodel:source_map'
25
26
  generate 'rolemodel:good_job'
@@ -31,9 +31,12 @@ app you can push straight to Heroku right after generation.
31
31
  - [GitHub](../github) — standard GitHub configuration
32
32
  - [Readme](../readme) — standard project README
33
33
  - [Linters](../linters) — Rubocop and ESLint
34
+ - [Agent Docs](../agent_docs) — `AGENTS.md`, conventions, and the hook that surfaces them
34
35
  - [Heroku](../heroku) — standard Heroku deployment configuration
35
36
  - [Sentry](../sentry) — error monitoring for Ruby and JavaScript
36
37
  - [Lograge](../lograge) — condensed request logging
38
+ - The [`controller-patterns`](https://github.com/RoleModel/skills/tree/main/skills/controller-patterns)
39
+ agent skill for RoleModel's controller shapes, installed into `.agents/skills`
37
40
  - The [`polymorphic-parent-resources`](https://github.com/RoleModel/skills/tree/main/skills/polymorphic-parent-resources)
38
41
  and [`rake-tasks`](https://github.com/RoleModel/skills/tree/main/skills/rake-tasks) agent skills for
39
42
  `resource_for` and `Rolemodel::Utility::TaskTools`, installed into `.agents/skills`
@@ -2,10 +2,10 @@ Description:
2
2
  Runs the core generators every new Rails app should have
3
3
 
4
4
  Sets up Slim, Webpack, Optics, SimpleForm, Tom Select, testing (RSpec &
5
- friends), Turbo, flash messages, GitHub config, README, linters, Heroku
6
- deployment, Sentry, and Lograge. It also installs the agent skills for
7
- resource_for and TaskTools. The result is an app that is ready to push
8
- directly to Heroku.
5
+ friends), Turbo, flash messages, GitHub config, README, linters, agent
6
+ docs and conventions, Heroku deployment, Sentry, and Lograge. It also installs the agent skills for
7
+ controller patterns, resource_for, and TaskTools. The result is an app
8
+ that is ready to push directly to Heroku.
9
9
 
10
10
  Pass an icon library flag (--material, --phosphor, --tabler, --feather,
11
11
  --lucide, or --custom) to choose the Optics icons up front.
@@ -7,8 +7,9 @@ module Rolemodel
7
7
  class_option :skip_deployable, type: :boolean, default: false, desc: 'skip generators for app deployment (Heroku, Sentry, Lograge)'
8
8
 
9
9
  def install_agent_skills
10
- say 'Installing agent skills for the rolemodel_rails utilities', :green
10
+ say 'Installing agent skills', :green
11
11
 
12
+ install_skill 'controller-patterns'
12
13
  install_skill 'polymorphic-parent-resources'
13
14
  install_skill 'rake-tasks'
14
15
  end
@@ -26,6 +27,7 @@ module Rolemodel
26
27
  generate 'rolemodel:github'
27
28
  generate 'rolemodel:readme'
28
29
  generate 'rolemodel:linters:all'
30
+ generate 'rolemodel:agent_docs'
29
31
  return if options.skip_deployable?
30
32
 
31
33
  generate 'rolemodel:heroku'
@@ -7,7 +7,7 @@ It doesn't need to be run first, but the parallel_tests generator must be run in
7
7
  ## What you get
8
8
 
9
9
  - CI workflow
10
- - A sensible default `ci.yml` to get you started with Github Actions. This will run linters, model tests, and system tests.
10
+ - A `ci.yml` that calls RoleModel/actions' reusable [`rails-ci.yml`](https://github.com/RoleModel/actions#rails-ci-reusable-workflow) workflow: RuboCop, ESLint, Brakeman, and the full RSpec suite in parallel. Pass `--no-playwright` to run system tests in Chrome instead of Playwright.
11
11
  - Along with the `ci.yml`, your `database.yml` will be modified to be able to be run in GHA.
12
12
  - Deploy workflows
13
13
  - `deploy-staging.yml` deploys to Heroku on every push to `main` (or manually); `deploy-production.yml` deploys manually via `workflow_dispatch`.
@@ -6,17 +6,13 @@ module Rolemodel
6
6
  source_root File.expand_path('templates', __dir__)
7
7
 
8
8
  class_option :playwright, type: :boolean, default: true,
9
- desc: 'Request Playwright Setup in CI workflow for system tests?'
9
+ desc: 'Install Playwright in CI for system tests? (otherwise Chrome)'
10
10
 
11
11
  def set_rm_actions_version
12
12
  tags = `git ls-remote --tags #{GITHUB_ACTIONS_REPO}` rescue 'refs/tags/v3'
13
13
  @rm_actions_version = tags.scan(%r{refs/tags/v(\d+)\s*$}).flatten.max_by(&:to_i)
14
14
  end
15
15
 
16
- def set_webdriver
17
- @webdriver = options.playwright? ? 'playwright' : 'selenium'
18
- end
19
-
20
16
  def install_github_config
21
17
  directory 'workflows', '.github/workflows', force: true
22
18
  template 'pull_request_template.md', '.github/pull_request_template.md'
@@ -2,80 +2,23 @@ name: CI
2
2
 
3
3
  on:
4
4
  push:
5
+ branches: [main]
5
6
  pull_request:
6
7
 
7
8
  concurrency:
8
- group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
9
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number }}-${{ github.event.ref }}
9
10
  cancel-in-progress: true
10
11
 
11
- env:
12
- CI: true
13
- RAILS_ENV: test
14
- POSTGRES_USER: postgres
15
- POSTGRES_PASSWORD: password
16
-
17
12
  jobs:
18
- project-stats:
19
- name: Project Stats
20
- runs-on: blacksmith-4vcpu-ubuntu-2404
21
- timeout-minutes: 3
22
- steps:
23
- - uses: actions/checkout@v6
24
- - uses: RoleModel/actions/project-stats@v<%= @rm_actions_version %>
25
-
26
- compile-assets:
27
- name: Compile Assets
28
- runs-on: blacksmith-8vcpu-ubuntu-2404
29
- timeout-minutes: 5
30
- steps:
31
- - uses: actions/checkout@v6
32
- - uses: RoleModel/actions/compile-assets@v<%= @rm_actions_version %>
33
- id: check-asset-cache
34
-
35
- non-system-test:
36
- name: Linting & Ruby Non-System Tests
37
- runs-on: blacksmith-4vcpu-ubuntu-2404
38
- timeout-minutes: 5
39
- services:
40
- postgres:
41
- image: postgres:17
42
- ports: [ "5432:5432" ]
43
- env:
44
- POSTGRES_USER: postgres
45
- POSTGRES_PASSWORD: password
46
-
47
- steps:
48
- - uses: actions/checkout@v6
49
- - uses: ruby/setup-ruby@v1
50
- with: { bundler-cache: true }
51
- - run: bin/bundler-audit
52
- - run: bin/brakeman --quiet --no-pager --exit-on-warn --exit-on-error
53
- - run: bundle exec rubocop --format github
54
- - uses: RoleModel/actions/linting-and-non-system-tests@v<%= @rm_actions_version %>
55
- with:
56
- needs-compiled-assets: false
57
-
58
- system-test:
59
- name: Ruby System Tests
60
- runs-on: blacksmith-8vcpu-ubuntu-2404
61
- timeout-minutes: 15
62
- needs: compile-assets
63
- services:
64
- postgres:
65
- image: postgres:17
66
- ports: [ "5432:5432" ]
67
- env:
68
- POSTGRES_USER: postgres
69
- POSTGRES_PASSWORD: password
70
-
71
- steps:
72
- - uses: actions/checkout@v6
73
- # Uncomment the following if your app require VIPS for processing ActiveStorage variant images in system tests.
74
- # - name: Setup vips
75
- # run: |
76
- # sudo apt-get update
77
- # sudo apt-get install -y libvips
78
- - uses: RoleModel/actions/system-tests@v<%= @rm_actions_version %>
79
- with:
80
- web-driver: <%= @webdriver %>
81
- # failure-screenshot-dir: tmp/screenshots
13
+ ci:
14
+ uses: RoleModel/actions/.github/workflows/rails-ci.yml@v<%= @rm_actions_version %>
15
+ with:
16
+ # apt_packages: libvips # if ActiveStorage variants are processed in system tests
17
+ <% if options.playwright? -%>
18
+ playwright: true
19
+ <% end -%>
20
+ rubocop_command: bundle exec rubocop --format github
21
+ js_lint_command: yarn eslint
22
+ dependency_audit_command: bin/brakeman --quiet --no-pager --exit-on-warn --exit-on-error
23
+ failure-screenshot-dir: tmp/screenshots
24
+ secrets: inherit
@@ -70,5 +70,22 @@ Style/EachWithObject:
70
70
  Style/Documentation:
71
71
  Enabled: false
72
72
 
73
+ Style/ItBlockParameter:
74
+ EnforcedStyle: always
75
+
76
+ Style/EndlessMethod:
77
+ EnforcedStyle: require_single_line
78
+
79
+ Style/TrailingCommaInArrayLiteral:
80
+ EnforcedStyleForMultiline: consistent_comma
81
+
82
+ Style/TrailingCommaInHashLiteral:
83
+ EnforcedStyleForMultiline: consistent_comma
84
+
85
+ # Parent and child setters keep inverted index/new/create conditions,
86
+ # even when the controller doesn't define all three.
87
+ Rails/LexicallyScopedActionFilter:
88
+ Enabled: false
89
+
73
90
  Cops/NoChromeTag:
74
91
  AutoCorrect: contextual
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'rails'
4
+
3
5
  module Rolemodel
4
6
  class Engine < ::Rails::Engine
5
7
  require_relative 'generator_base'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rolemodel
4
- VERSION = '2.8.0'
4
+ VERSION = '2.9.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rolemodel-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 2.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - RoleModel Software Inc
@@ -192,6 +192,28 @@ files:
192
192
  - exe/rmr
193
193
  - lib/generators/rolemodel/README.md
194
194
  - lib/generators/rolemodel/USAGE
195
+ - lib/generators/rolemodel/agent_docs/README.md
196
+ - lib/generators/rolemodel/agent_docs/USAGE
197
+ - lib/generators/rolemodel/agent_docs/agent_docs_generator.rb
198
+ - lib/generators/rolemodel/agent_docs/templates/.claude/settings.json
199
+ - lib/generators/rolemodel/agent_docs/templates/.github/instructions/conventions.instructions.md
200
+ - lib/generators/rolemodel/agent_docs/templates/AGENTS.md.tt
201
+ - lib/generators/rolemodel/agent_docs/templates/CLAUDE.md
202
+ - lib/generators/rolemodel/agent_docs/templates/docs/CONVENTIONS.md
203
+ - lib/generators/rolemodel/agent_docs/templates/docs/conventions/callbacks.md
204
+ - lib/generators/rolemodel/agent_docs/templates/docs/conventions/controllers.md
205
+ - lib/generators/rolemodel/agent_docs/templates/docs/conventions/eager-loading.md
206
+ - lib/generators/rolemodel/agent_docs/templates/docs/conventions/logic-in-models.md
207
+ - lib/generators/rolemodel/agent_docs/templates/docs/conventions/migrations.md
208
+ - lib/generators/rolemodel/agent_docs/templates/docs/conventions/no-sql-strings.md
209
+ - lib/generators/rolemodel/agent_docs/templates/docs/conventions/partial-locals.md
210
+ - lib/generators/rolemodel/agent_docs/templates/docs/conventions/reproduce-the-bug.md
211
+ - lib/generators/rolemodel/agent_docs/templates/docs/conventions/reuse-scopes.md
212
+ - lib/generators/rolemodel/agent_docs/templates/docs/conventions/stimulus.md
213
+ - lib/generators/rolemodel/agent_docs/templates/docs/conventions/string-enums.md
214
+ - lib/generators/rolemodel/agent_docs/templates/docs/conventions/system-spec-assertions.md
215
+ - lib/generators/rolemodel/agent_docs/templates/docs/conventions/test-layers.md
216
+ - lib/generators/rolemodel/agent_docs/templates/docs/conventions/views-and-forms.md
195
217
  - lib/generators/rolemodel/all_generator.rb
196
218
  - lib/generators/rolemodel/core_setup/README.md
197
219
  - lib/generators/rolemodel/core_setup/USAGE