nitro_kit 2.0.0.beta.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (326) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +37 -0
  3. data/LICENSE +21 -28
  4. data/README.md +10 -9
  5. data/app/assets/stylesheets/nitro_kit.css +1660 -1401
  6. data/app/components/nitro_kit/accordion.rb +1 -13
  7. data/app/components/nitro_kit/app_navigation.rb +0 -12
  8. data/app/components/nitro_kit/app_shell.rb +5 -11
  9. data/app/components/nitro_kit/appearance_picker.rb +1 -7
  10. data/app/components/nitro_kit/combobox.rb +366 -21
  11. data/app/components/nitro_kit/command_palette.rb +7 -20
  12. data/app/components/nitro_kit/details_table.rb +5 -11
  13. data/app/components/nitro_kit/dropzone.rb +3 -15
  14. data/app/components/nitro_kit/field.rb +20 -2
  15. data/app/components/nitro_kit/pagination.rb +2 -8
  16. data/app/components/nitro_kit/settings_layout.rb +3 -9
  17. data/app/javascript/controllers/nk/app_shell_controller.js +2 -2
  18. data/app/javascript/controllers/nk/combobox_controller.js +308 -22
  19. data/app/javascript/controllers/nk/combobox_remote.js +70 -0
  20. data/app/javascript/controllers/nk/dropzone_controller.js +2 -2
  21. data/app/javascript/controllers/nk/tabs_controller.js +2 -2
  22. data/config/locales/en.yml +3 -0
  23. data/docs/agent_guide.md +43 -13
  24. data/docs/component_contracts.md +90 -61
  25. data/docs/customization.md +173 -35
  26. data/docs/initialization_prompt.md +4 -5
  27. data/docs/migration_1_to_2.md +10 -8
  28. data/docs/patterns/application_foundation.md +5 -0
  29. data/docs/patterns/composition.md +61 -0
  30. data/docs/patterns/crud_resource.md +5 -0
  31. data/docs/patterns/inset_workspace.md +21 -22
  32. data/docs/patterns/resource_form.md +65 -0
  33. data/docs/rails_integration.md +214 -2
  34. data/lib/generators/nitro_kit/install_generator.rb +5 -4
  35. data/lib/nitro_kit/installation.rb +327 -68
  36. data/lib/nitro_kit/migration_inventory.rb +18 -3
  37. data/lib/nitro_kit/version.rb +1 -1
  38. data/lib/rails/commands/nitro_kit/nitro_kit_command.rb +2 -2
  39. data/patterns/README.md +21 -0
  40. data/patterns/account-settings/files/app/components/ui/account_settings/account_deletion.rb +72 -0
  41. data/patterns/account-settings/files/app/components/ui/account_settings/base.rb +44 -0
  42. data/patterns/account-settings/files/app/components/ui/account_settings/page.rb +57 -0
  43. data/patterns/account-settings/files/app/components/ui/account_settings/preferences.rb +68 -0
  44. data/patterns/account-settings/files/app/components/ui/account_settings/profile.rb +86 -0
  45. data/patterns/account-settings/files/app/components/ui/account_settings/security.rb +69 -0
  46. data/patterns/account-settings/files/app/components/ui/account_settings/sessions.rb +86 -0
  47. data/patterns/account-settings/files/app/controllers/settings/account_deletions_controller.rb +35 -0
  48. data/patterns/account-settings/files/app/controllers/settings/base_controller.rb +12 -0
  49. data/patterns/account-settings/files/app/controllers/settings/other_sessions_controller.rb +8 -0
  50. data/patterns/account-settings/files/app/controllers/settings/preferences_controller.rb +27 -0
  51. data/patterns/account-settings/files/app/controllers/settings/profiles_controller.rb +20 -0
  52. data/patterns/account-settings/files/app/controllers/settings/securities_controller.rb +37 -0
  53. data/patterns/account-settings/files/app/controllers/settings/sessions_controller.rb +31 -0
  54. data/patterns/account-settings/files/app/models/account_settings/account_closure.rb +33 -0
  55. data/patterns/account-settings/files/app/models/account_settings/password_change.rb +42 -0
  56. data/patterns/account-settings/files/app/models/account_settings/session_summary.rb +45 -0
  57. data/patterns/account-settings/files/app/models/concerns/user/account_configurable.rb +18 -0
  58. data/patterns/account-settings/files/config/routes/account_settings.rb +10 -0
  59. data/patterns/account-settings/files/db/migrate/20260731020000_add_account_settings.rb +27 -0
  60. data/patterns/account-settings/files/test/controllers/settings/account_settings_flow_test.rb +84 -0
  61. data/patterns/account-settings/files/test/models/account_settings/password_change_test.rb +40 -0
  62. data/patterns/account-settings/files/test/system/account_settings_test.rb +52 -0
  63. data/patterns/account-settings/item.yml +4 -0
  64. data/patterns/account-settings/pattern.md +44 -0
  65. data/patterns/application-shell/files/app/assets/stylesheets/ui/application_shell.css +267 -0
  66. data/patterns/application-shell/files/app/components/ui/application_shell.rb +184 -0
  67. data/patterns/application-shell/item.yml +4 -0
  68. data/patterns/application-shell/pattern.md +110 -0
  69. data/patterns/authentication/files/app/components/ui/authentication/base.rb +11 -0
  70. data/patterns/authentication/files/app/components/ui/authentication/page.rb +53 -0
  71. data/patterns/authentication/files/app/components/ui/email_verifications/show.rb +62 -0
  72. data/patterns/authentication/files/app/components/ui/password_resets/new.rb +65 -0
  73. data/patterns/authentication/files/app/components/ui/passwords/edit.rb +72 -0
  74. data/patterns/authentication/files/app/components/ui/sessions/new.rb +58 -0
  75. data/patterns/authentication/files/app/components/ui/verification_emails/new.rb +59 -0
  76. data/patterns/authentication/files/app/controllers/concerns/authentication.rb +66 -0
  77. data/patterns/authentication/files/app/controllers/concerns/safe_return_navigation.rb +37 -0
  78. data/patterns/authentication/files/app/controllers/email_verifications_controller.rb +39 -0
  79. data/patterns/authentication/files/app/controllers/password_resets_controller.rb +33 -0
  80. data/patterns/authentication/files/app/controllers/passwords_controller.rb +51 -0
  81. data/patterns/authentication/files/app/controllers/sessions_controller.rb +42 -0
  82. data/patterns/authentication/files/app/controllers/verification_emails_controller.rb +33 -0
  83. data/patterns/authentication/files/app/jobs/authentication_delivery_job.rb +17 -0
  84. data/patterns/authentication/files/app/mailers/authentication_mailer.rb +15 -0
  85. data/patterns/authentication/files/app/models/authentication/credentials.rb +16 -0
  86. data/patterns/authentication/files/app/models/authentication/email_request.rb +17 -0
  87. data/patterns/authentication/files/app/models/concerns/user/email_verifiable.rb +40 -0
  88. data/patterns/authentication/files/app/models/session.rb +5 -0
  89. data/patterns/authentication/files/app/views/authentication_mailer/email_verification.html.erb +3 -0
  90. data/patterns/authentication/files/app/views/authentication_mailer/email_verification.text.erb +5 -0
  91. data/patterns/authentication/files/app/views/authentication_mailer/password_reset.html.erb +3 -0
  92. data/patterns/authentication/files/app/views/authentication_mailer/password_reset.text.erb +5 -0
  93. data/patterns/authentication/files/config/routes/authentication.rb +11 -0
  94. data/patterns/authentication/files/db/migrate/20260731000000_add_authentication_and_recovery.rb +13 -0
  95. data/patterns/authentication/files/test/controllers/authentication_flow_test.rb +103 -0
  96. data/patterns/authentication/files/test/controllers/safe_return_navigation_test.rb +18 -0
  97. data/patterns/authentication/files/test/mailers/authentication_mailer_test.rb +21 -0
  98. data/patterns/authentication/files/test/models/user_email_verifiable_test.rb +36 -0
  99. data/patterns/authentication/files/test/system/authentication_flow_test.rb +23 -0
  100. data/patterns/authentication/item.yml +12 -0
  101. data/patterns/authentication/pattern.md +54 -0
  102. data/patterns/crud-resource/files/app/assets/stylesheets/ui/projects.css +4 -0
  103. data/patterns/crud-resource/files/app/components/ui/projects/form.rb +89 -0
  104. data/patterns/crud-resource/files/app/components/ui/projects/index.rb +161 -0
  105. data/patterns/crud-resource/files/app/components/ui/projects/show.rb +84 -0
  106. data/patterns/crud-resource/files/app/controllers/projects/archivals_controller.rb +23 -0
  107. data/patterns/crud-resource/files/app/controllers/projects_controller.rb +70 -0
  108. data/patterns/crud-resource/files/app/models/project/archival.rb +8 -0
  109. data/patterns/crud-resource/files/app/models/project/event.rb +12 -0
  110. data/patterns/crud-resource/files/app/models/project/filter.rb +41 -0
  111. data/patterns/crud-resource/files/app/models/project.rb +41 -0
  112. data/patterns/crud-resource/files/app/views/projects/edit.html.erb +19 -0
  113. data/patterns/crud-resource/files/app/views/projects/index.html.erb +18 -0
  114. data/patterns/crud-resource/files/app/views/projects/new.html.erb +16 -0
  115. data/patterns/crud-resource/files/app/views/projects/show.html.erb +28 -0
  116. data/patterns/crud-resource/files/config/routes/crud_resource.rb +7 -0
  117. data/patterns/crud-resource/files/db/migrate/20260720000000_create_crud_resource.rb +37 -0
  118. data/patterns/crud-resource/files/test/controllers/projects_controller_test.rb +64 -0
  119. data/patterns/crud-resource/files/test/models/project_test.rb +34 -0
  120. data/patterns/crud-resource/files/test/support/crud_resource_test_helpers.rb +25 -0
  121. data/patterns/crud-resource/files/test/system/projects_crud_test.rb +87 -0
  122. data/patterns/crud-resource/item.yml +6 -0
  123. data/patterns/crud-resource/pattern.md +48 -0
  124. data/patterns/file-uploads/files/app/assets/stylesheets/ui/uploads.css +133 -0
  125. data/patterns/file-uploads/files/app/components/ui/uploads/base.rb +30 -0
  126. data/patterns/file-uploads/files/app/components/ui/uploads/index.rb +188 -0
  127. data/patterns/file-uploads/files/app/components/ui/uploads/page.rb +33 -0
  128. data/patterns/file-uploads/files/app/controllers/uploads/base_controller.rb +29 -0
  129. data/patterns/file-uploads/files/app/controllers/uploads/direct_uploads_controller.rb +55 -0
  130. data/patterns/file-uploads/files/app/controllers/uploads/retries_controller.rb +14 -0
  131. data/patterns/file-uploads/files/app/controllers/uploads_controller.rb +40 -0
  132. data/patterns/file-uploads/files/app/jobs/upload_blob_cleanup_job.rb +9 -0
  133. data/patterns/file-uploads/files/app/jobs/upload_processing_job.rb +10 -0
  134. data/patterns/file-uploads/files/app/jobs/upload_repair_job.rb +17 -0
  135. data/patterns/file-uploads/files/app/models/concerns/team/uploadable.rb +9 -0
  136. data/patterns/file-uploads/files/app/models/upload.rb +295 -0
  137. data/patterns/file-uploads/files/config/recurring/uploads.yml +7 -0
  138. data/patterns/file-uploads/files/config/routes/uploads.rb +5 -0
  139. data/patterns/file-uploads/files/db/migrate/20260802000000_add_file_uploads.rb +30 -0
  140. data/patterns/file-uploads/files/test/controllers/uploads_flow_test.rb +77 -0
  141. data/patterns/file-uploads/files/test/fixtures/files/workspace.png.base64 +1 -0
  142. data/patterns/file-uploads/files/test/fixtures/uploads.yml +17 -0
  143. data/patterns/file-uploads/files/test/models/upload_test.rb +55 -0
  144. data/patterns/file-uploads/files/test/system/file_uploads_test.rb +30 -0
  145. data/patterns/file-uploads/item.yml +4 -0
  146. data/patterns/file-uploads/pattern.md +71 -0
  147. data/patterns/nitro-kit-1-upgrade/files/docs/nitro_kit_1_upgrade.md +57 -0
  148. data/patterns/nitro-kit-1-upgrade/item.yml +4 -0
  149. data/patterns/nitro-kit-1-upgrade/pattern.md +30 -0
  150. data/patterns/onboarding/files/app/assets/stylesheets/ui/onboarding.css +55 -0
  151. data/patterns/onboarding/files/app/components/ui/onboarding/base.rb +11 -0
  152. data/patterns/onboarding/files/app/components/ui/onboarding/branch_form.rb +36 -0
  153. data/patterns/onboarding/files/app/components/ui/onboarding/details_form.rb +67 -0
  154. data/patterns/onboarding/files/app/components/ui/onboarding/invitation_plan_form.rb +48 -0
  155. data/patterns/onboarding/files/app/components/ui/onboarding/page.rb +75 -0
  156. data/patterns/onboarding/files/app/components/ui/onboarding/review.rb +51 -0
  157. data/patterns/onboarding/files/app/components/ui/onboarding/show.rb +32 -0
  158. data/patterns/onboarding/files/app/controllers/concerns/requires_finished_onboarding.rb +14 -0
  159. data/patterns/onboarding/files/app/controllers/onboarding/base_controller.rb +30 -0
  160. data/patterns/onboarding/files/app/controllers/onboarding/branches_controller.rb +16 -0
  161. data/patterns/onboarding/files/app/controllers/onboarding/completions_controller.rb +13 -0
  162. data/patterns/onboarding/files/app/controllers/onboarding/details_controller.rb +16 -0
  163. data/patterns/onboarding/files/app/controllers/onboarding/invitation_plans_controller.rb +20 -0
  164. data/patterns/onboarding/files/app/controllers/onboardings_controller.rb +7 -0
  165. data/patterns/onboarding/files/app/jobs/onboarding_invitation_delivery_job.rb +15 -0
  166. data/patterns/onboarding/files/app/models/concerns/team/onboardable.rb +23 -0
  167. data/patterns/onboarding/files/app/models/onboarding/completion.rb +17 -0
  168. data/patterns/onboarding/files/app/models/onboarding/invitation_delivery.rb +14 -0
  169. data/patterns/onboarding/files/app/models/onboarding.rb +174 -0
  170. data/patterns/onboarding/files/config/routes/onboarding.rb +11 -0
  171. data/patterns/onboarding/files/db/migrate/20260731010000_create_onboarding.rb +60 -0
  172. data/patterns/onboarding/files/test/controllers/onboarding_flow_test.rb +62 -0
  173. data/patterns/onboarding/files/test/fixtures/onboarding_completions.yml +3 -0
  174. data/patterns/onboarding/files/test/fixtures/onboardings.yml +25 -0
  175. data/patterns/onboarding/files/test/jobs/onboarding_invitation_delivery_job_test.rb +18 -0
  176. data/patterns/onboarding/files/test/models/onboarding_test.rb +60 -0
  177. data/patterns/onboarding/files/test/system/onboarding_flow_test.rb +39 -0
  178. data/patterns/onboarding/item.yml +4 -0
  179. data/patterns/onboarding/pattern.md +53 -0
  180. data/patterns/subscription-billing/files/app/components/ui/billing/base.rb +39 -0
  181. data/patterns/subscription-billing/files/app/components/ui/billing/checkout_result.rb +64 -0
  182. data/patterns/subscription-billing/files/app/components/ui/billing/page.rb +33 -0
  183. data/patterns/subscription-billing/files/app/components/ui/billing/show.rb +149 -0
  184. data/patterns/subscription-billing/files/app/controllers/billing/base_controller.rb +16 -0
  185. data/patterns/subscription-billing/files/app/controllers/billing/checkouts_controller.rb +65 -0
  186. data/patterns/subscription-billing/files/app/controllers/billing/portals_controller.rb +18 -0
  187. data/patterns/subscription-billing/files/app/controllers/billing_controller.rb +17 -0
  188. data/patterns/subscription-billing/files/app/controllers/webhooks/stripe_events_controller.rb +21 -0
  189. data/patterns/subscription-billing/files/app/jobs/billing/stripe_event_job.rb +16 -0
  190. data/patterns/subscription-billing/files/app/jobs/billing/subscription_reconciliation_job.rb +16 -0
  191. data/patterns/subscription-billing/files/app/jobs/billing/subscription_reconciliation_sweep_job.rb +9 -0
  192. data/patterns/subscription-billing/files/app/models/billing/checkout.rb +58 -0
  193. data/patterns/subscription-billing/files/app/models/billing/plan.rb +19 -0
  194. data/patterns/subscription-billing/files/app/models/billing/stripe_event.rb +73 -0
  195. data/patterns/subscription-billing/files/app/models/billing/subscription.rb +106 -0
  196. data/patterns/subscription-billing/files/app/models/concerns/team/billable.rb +36 -0
  197. data/patterns/subscription-billing/files/config/initializers/stripe.rb +29 -0
  198. data/patterns/subscription-billing/files/config/routes/subscription_billing.rb +10 -0
  199. data/patterns/subscription-billing/files/db/migrate/20260801000000_add_subscription_billing.rb +61 -0
  200. data/patterns/subscription-billing/files/test/controllers/billing_flow_test.rb +60 -0
  201. data/patterns/subscription-billing/files/test/models/billing/subscription_test.rb +40 -0
  202. data/patterns/subscription-billing/files/test/system/subscription_billing_test.rb +28 -0
  203. data/patterns/subscription-billing/item.yml +4 -0
  204. data/patterns/subscription-billing/pattern.md +59 -0
  205. data/patterns/team-management/files/app/components/ui/invitations/acceptance.rb +33 -0
  206. data/patterns/team-management/files/app/components/ui/teams/index.rb +87 -0
  207. data/patterns/team-management/files/app/components/ui/teams/invitation_form.rb +51 -0
  208. data/patterns/team-management/files/app/components/ui/teams/member_form.rb +78 -0
  209. data/patterns/team-management/files/app/components/ui/teams/members.rb +125 -0
  210. data/patterns/team-management/files/app/controllers/invitations/acceptances_controller.rb +29 -0
  211. data/patterns/team-management/files/app/controllers/teams/base_controller.rb +18 -0
  212. data/patterns/team-management/files/app/controllers/teams/invitations_controller.rb +42 -0
  213. data/patterns/team-management/files/app/controllers/teams/memberships_controller.rb +53 -0
  214. data/patterns/team-management/files/app/controllers/teams_controller.rb +30 -0
  215. data/patterns/team-management/files/app/mailers/team_invitation_mailer.rb +10 -0
  216. data/patterns/team-management/files/app/models/concerns/current_team.rb +13 -0
  217. data/patterns/team-management/files/app/models/concerns/user_teams.rb +37 -0
  218. data/patterns/team-management/files/app/models/invitation.rb +41 -0
  219. data/patterns/team-management/files/app/models/membership.rb +45 -0
  220. data/patterns/team-management/files/app/models/team.rb +25 -0
  221. data/patterns/team-management/files/app/views/invitations/acceptances/show.html.erb +1 -0
  222. data/patterns/team-management/files/app/views/team_invitation_mailer/invite.html.erb +10 -0
  223. data/patterns/team-management/files/app/views/team_invitation_mailer/invite.text.erb +7 -0
  224. data/patterns/team-management/files/app/views/teams/index.html.erb +15 -0
  225. data/patterns/team-management/files/app/views/teams/invitations/new.html.erb +22 -0
  226. data/patterns/team-management/files/app/views/teams/memberships/edit.html.erb +22 -0
  227. data/patterns/team-management/files/app/views/teams/memberships/index.html.erb +20 -0
  228. data/patterns/team-management/files/config/routes/team_management.rb +11 -0
  229. data/patterns/team-management/files/db/migrate/20260717000000_create_team_management.rb +31 -0
  230. data/patterns/team-management/files/test/models/invitation_test.rb +28 -0
  231. data/patterns/team-management/files/test/models/membership_test.rb +29 -0
  232. data/patterns/team-management/files/test/models/team_test.rb +31 -0
  233. data/patterns/team-management/files/test/support/team_management_test_helpers.rb +22 -0
  234. data/patterns/team-management/item.yml +4 -0
  235. data/patterns/team-management/pattern.md +47 -0
  236. data/patterns/webhook-deliveries/files/app/assets/stylesheets/ui/webhooks.css +179 -0
  237. data/patterns/webhook-deliveries/files/app/components/ui/webhooks/base.rb +38 -0
  238. data/patterns/webhook-deliveries/files/app/components/ui/webhooks/delivery.rb +160 -0
  239. data/patterns/webhook-deliveries/files/app/components/ui/webhooks/endpoint.rb +149 -0
  240. data/patterns/webhook-deliveries/files/app/components/ui/webhooks/form.rb +75 -0
  241. data/patterns/webhook-deliveries/files/app/components/ui/webhooks/index.rb +142 -0
  242. data/patterns/webhook-deliveries/files/app/components/ui/webhooks/page.rb +33 -0
  243. data/patterns/webhook-deliveries/files/app/components/ui/webhooks/secret.rb +38 -0
  244. data/patterns/webhook-deliveries/files/app/controllers/webhook_deliveries/replays_controller.rb +13 -0
  245. data/patterns/webhook-deliveries/files/app/controllers/webhook_deliveries_controller.rb +7 -0
  246. data/patterns/webhook-deliveries/files/app/controllers/webhook_endpoints/secrets_controller.rb +41 -0
  247. data/patterns/webhook-deliveries/files/app/controllers/webhook_endpoints_controller.rb +67 -0
  248. data/patterns/webhook-deliveries/files/app/controllers/webhooks/base_controller.rb +15 -0
  249. data/patterns/webhook-deliveries/files/app/jobs/webhook_delivery_job.rb +9 -0
  250. data/patterns/webhook-deliveries/files/app/jobs/webhook_delivery_repair_job.rb +11 -0
  251. data/patterns/webhook-deliveries/files/app/models/concerns/team/webhookable.rb +11 -0
  252. data/patterns/webhook-deliveries/files/app/models/webhook/attempt.rb +30 -0
  253. data/patterns/webhook-deliveries/files/app/models/webhook/delivery.rb +268 -0
  254. data/patterns/webhook-deliveries/files/app/models/webhook/endpoint.rb +58 -0
  255. data/patterns/webhook-deliveries/files/app/models/webhook/event.rb +98 -0
  256. data/patterns/webhook-deliveries/files/app/models/webhook/secret_reveal.rb +53 -0
  257. data/patterns/webhook-deliveries/files/app/models/webhook/signature.rb +22 -0
  258. data/patterns/webhook-deliveries/files/app/models/webhook/transport.rb +176 -0
  259. data/patterns/webhook-deliveries/files/app/views/webhook_deliveries/show.html.erb +5 -0
  260. data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/edit.html.erb +1 -0
  261. data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/index.html.erb +6 -0
  262. data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/new.html.erb +1 -0
  263. data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/secrets/new.html.erb +1 -0
  264. data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/show.html.erb +7 -0
  265. data/patterns/webhook-deliveries/files/config/recurring/webhooks.yml +4 -0
  266. data/patterns/webhook-deliveries/files/config/routes/webhook_deliveries.rb +10 -0
  267. data/patterns/webhook-deliveries/files/db/migrate/20260803000000_add_webhook_deliveries.rb +126 -0
  268. data/patterns/webhook-deliveries/files/test/controllers/webhook_endpoints_flow_test.rb +48 -0
  269. data/patterns/webhook-deliveries/files/test/models/webhook/delivery_test.rb +70 -0
  270. data/patterns/webhook-deliveries/files/test/system/webhook_deliveries_test.rb +29 -0
  271. data/patterns/webhook-deliveries/item.yml +4 -0
  272. data/patterns/webhook-deliveries/pattern.md +120 -0
  273. data/plugins/nitro-kit/.codex-plugin/plugin.json +4 -4
  274. data/plugins/nitro-kit/skills/nitro-kit-hotwire/SKILL.md +7 -9
  275. data/plugins/nitro-kit/skills/nitro-kit-hotwire/agents/openai.yaml +1 -1
  276. data/plugins/nitro-kit/skills/nitro-kit-rails/SKILL.md +10 -9
  277. data/plugins/nitro-kit/skills/nitro-kit-rails/agents/openai.yaml +1 -1
  278. data/plugins/nitro-kit/skills/nitro-kit-ui/SKILL.md +27 -16
  279. data/plugins/nitro-kit/skills/nitro-kit-ui/agents/openai.yaml +1 -1
  280. data/src/stylesheets/nitro_kit/components/accordion.css +40 -40
  281. data/src/stylesheets/nitro_kit/components/alert.css +7 -6
  282. data/src/stylesheets/nitro_kit/components/app_navigation.css +50 -41
  283. data/src/stylesheets/nitro_kit/components/app_shell.css +371 -280
  284. data/src/stylesheets/nitro_kit/components/appearance_picker.css +38 -38
  285. data/src/stylesheets/nitro_kit/components/avatar.css +3 -3
  286. data/src/stylesheets/nitro_kit/components/avatar_stack.css +18 -18
  287. data/src/stylesheets/nitro_kit/components/badge.css +5 -2
  288. data/src/stylesheets/nitro_kit/components/button.css +57 -49
  289. data/src/stylesheets/nitro_kit/components/button_group.css +14 -14
  290. data/src/stylesheets/nitro_kit/components/checkbox.css +24 -24
  291. data/src/stylesheets/nitro_kit/components/checkbox_group.css +13 -13
  292. data/src/stylesheets/nitro_kit/components/combobox.css +152 -25
  293. data/src/stylesheets/nitro_kit/components/command_palette.css +59 -59
  294. data/src/stylesheets/nitro_kit/components/control_group.css +71 -54
  295. data/src/stylesheets/nitro_kit/components/details_table.css +9 -9
  296. data/src/stylesheets/nitro_kit/components/dialog.css +8 -12
  297. data/src/stylesheets/nitro_kit/components/dropdown.css +22 -26
  298. data/src/stylesheets/nitro_kit/components/dropzone.css +97 -100
  299. data/src/stylesheets/nitro_kit/components/empty_state.css +1 -0
  300. data/src/stylesheets/nitro_kit/components/field.css +26 -30
  301. data/src/stylesheets/nitro_kit/components/fieldset.css +2 -2
  302. data/src/stylesheets/nitro_kit/components/input.css +6 -14
  303. data/src/stylesheets/nitro_kit/components/layout.css +165 -165
  304. data/src/stylesheets/nitro_kit/components/page_header.css +3 -3
  305. data/src/stylesheets/nitro_kit/components/pagination.css +66 -49
  306. data/src/stylesheets/nitro_kit/components/pagination_bar.css +6 -6
  307. data/src/stylesheets/nitro_kit/components/palette.css +24 -22
  308. data/src/stylesheets/nitro_kit/components/progressive_image.css +38 -41
  309. data/src/stylesheets/nitro_kit/components/radio_button.css +19 -19
  310. data/src/stylesheets/nitro_kit/components/radio_button_group.css +43 -43
  311. data/src/stylesheets/nitro_kit/components/rich_text_area.css +4 -4
  312. data/src/stylesheets/nitro_kit/components/select.css +2 -2
  313. data/src/stylesheets/nitro_kit/components/settings_layout.css +17 -18
  314. data/src/stylesheets/nitro_kit/components/settings_section.css +12 -12
  315. data/src/stylesheets/nitro_kit/components/sheet.css +10 -10
  316. data/src/stylesheets/nitro_kit/components/stat_grid.css +9 -9
  317. data/src/stylesheets/nitro_kit/components/switch.css +23 -23
  318. data/src/stylesheets/nitro_kit/components/table.css +27 -27
  319. data/src/stylesheets/nitro_kit/components/tabs.css +32 -34
  320. data/src/stylesheets/nitro_kit/components/toolbar.css +6 -6
  321. data/src/stylesheets/nitro_kit/components/tooltip.css +26 -28
  322. data/src/stylesheets/nitro_kit/layers.css +2 -1
  323. data/src/stylesheets/nitro_kit/reset.css +9 -9
  324. data/src/stylesheets/nitro_kit/tailwind.css +6 -2
  325. data/src/stylesheets/nitro_kit/tokens.css +18 -9
  326. metadata +238 -2
@@ -0,0 +1,7 @@
1
+ <%= render UI::Webhooks::Endpoint.new(
2
+ endpoint: @endpoint,
3
+ deliveries: @deliveries,
4
+ revealed_secret: @revealed_secret,
5
+ notice: flash[:notice],
6
+ alert: flash[:alert]
7
+ ) %>
@@ -0,0 +1,4 @@
1
+ production:
2
+ repair_webhook_deliveries:
3
+ class: WebhookDeliveryRepairJob
4
+ schedule: every minute
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ resources :webhook_endpoints, path: "webhooks" do
4
+ resource :secret, only: %i[new create], module: :webhook_endpoints
5
+ get "secret-reveal/:token", to: "webhook_endpoints/secrets#show", as: :secret_reveal
6
+ end
7
+
8
+ resources :webhook_deliveries, only: :show do
9
+ resource :replay, only: :create, module: :webhook_deliveries
10
+ end
@@ -0,0 +1,126 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddWebhookDeliveries < ActiveRecord::Migration[8.1]
4
+ def change
5
+ team_key_type = primary_key_type_for(:teams)
6
+ user_key_type = primary_key_type_for(:users)
7
+
8
+ create_table :webhook_endpoints do |t|
9
+ t.references :team,
10
+ type: team_key_type,
11
+ null: false,
12
+ foreign_key: { on_delete: :cascade }
13
+ t.references :creator,
14
+ type: user_key_type,
15
+ null: true,
16
+ foreign_key: { to_table: :users, on_delete: :nullify }
17
+ t.string :name, null: false
18
+ t.text :url, null: false
19
+ t.text :signing_secret, null: false
20
+ t.json :event_types, null: false, default: []
21
+ t.boolean :enabled, null: false, default: true
22
+ t.timestamps
23
+ end
24
+ add_index :webhook_endpoints, [ :team_id, :name ], unique: true
25
+ endpoint_key_type = primary_key_type_for(:webhook_endpoints)
26
+
27
+ create_table :webhook_secret_reveals do |t|
28
+ t.references :endpoint,
29
+ type: endpoint_key_type,
30
+ null: false,
31
+ foreign_key: { to_table: :webhook_endpoints, on_delete: :cascade }
32
+ t.string :token_digest, null: false
33
+ t.string :secret_fingerprint, null: false
34
+ t.datetime :expires_at, null: false
35
+ t.datetime :consumed_at
36
+ t.timestamps
37
+ end
38
+ add_index :webhook_secret_reveals, :token_digest, unique: true
39
+ add_index :webhook_secret_reveals, :expires_at
40
+
41
+ create_table :webhook_events do |t|
42
+ t.references :team,
43
+ type: team_key_type,
44
+ null: false,
45
+ foreign_key: { on_delete: :cascade }
46
+ t.string :public_id, null: false
47
+ t.string :idempotency_key, null: false
48
+ t.string :event_type, null: false
49
+ t.text :body, null: false
50
+ t.string :payload_sha256, null: false
51
+ t.datetime :occurred_at, null: false
52
+ t.timestamps
53
+ end
54
+ add_index :webhook_events, :public_id, unique: true
55
+ add_index :webhook_events, [ :team_id, :idempotency_key ], unique: true
56
+ add_index :webhook_events, [ :team_id, :occurred_at ]
57
+ event_key_type = primary_key_type_for(:webhook_events)
58
+
59
+ create_table :webhook_deliveries do |t|
60
+ t.references :team,
61
+ type: team_key_type,
62
+ null: false,
63
+ foreign_key: { on_delete: :cascade }
64
+ t.references :endpoint,
65
+ type: endpoint_key_type,
66
+ null: false,
67
+ foreign_key: { to_table: :webhook_endpoints, on_delete: :cascade }
68
+ t.references :event,
69
+ type: event_key_type,
70
+ null: false,
71
+ foreign_key: { to_table: :webhook_events, on_delete: :cascade }
72
+ t.references :next_attempt_initiator,
73
+ type: user_key_type,
74
+ null: true,
75
+ foreign_key: { to_table: :users, on_delete: :nullify }
76
+ t.string :status, null: false, default: "pending"
77
+ t.string :next_attempt_kind, null: false, default: "automatic"
78
+ t.string :processing_token
79
+ t.string :processing_kind
80
+ t.datetime :processing_started_at
81
+ t.datetime :next_attempt_at, null: false
82
+ t.datetime :dispatched_at
83
+ t.datetime :completed_at
84
+ t.integer :automatic_attempts_count, null: false, default: 0
85
+ t.integer :manual_attempts_count, null: false, default: 0
86
+ t.integer :last_response_status
87
+ t.string :last_error_code
88
+ t.text :last_error_message
89
+ t.timestamps
90
+ end
91
+ add_index :webhook_deliveries, [ :endpoint_id, :event_id ], unique: true
92
+ add_index :webhook_deliveries, [ :team_id, :created_at ]
93
+ add_index :webhook_deliveries, [ :status, :next_attempt_at ]
94
+ delivery_key_type = primary_key_type_for(:webhook_deliveries)
95
+
96
+ create_table :webhook_attempts do |t|
97
+ t.references :delivery,
98
+ type: delivery_key_type,
99
+ null: false,
100
+ foreign_key: { to_table: :webhook_deliveries, on_delete: :cascade }
101
+ t.references :initiated_by,
102
+ type: user_key_type,
103
+ null: true,
104
+ foreign_key: { to_table: :users, on_delete: :nullify }
105
+ t.integer :sequence, null: false
106
+ t.string :trigger, null: false
107
+ t.string :request_id, null: false
108
+ t.text :request_url, null: false
109
+ t.integer :response_status
110
+ t.json :response_headers, null: false, default: {}
111
+ t.text :response_body
112
+ t.string :error_code
113
+ t.text :error_message
114
+ t.datetime :started_at, null: false
115
+ t.datetime :finished_at
116
+ t.timestamps
117
+ end
118
+ add_index :webhook_attempts, [ :delivery_id, :sequence ], unique: true
119
+ end
120
+
121
+ private
122
+ def primary_key_type_for(table)
123
+ column = connection.columns(table).find { |candidate| candidate.name == "id" }
124
+ column.sql_type.match?(/bigint/i) ? :bigint : column.type
125
+ end
126
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class WebhookEndpointsFlowTest < ActionDispatch::IntegrationTest
6
+ setup do
7
+ sign_in users(:ada)
8
+ switch_team teams(:analytical_engines)
9
+ end
10
+
11
+ test "manager creates an endpoint and sees its secret once" do
12
+ assert_difference "Webhook::Endpoint.count", 1 do
13
+ post webhook_endpoints_path, params: {
14
+ webhook_endpoint: {
15
+ name: "Production",
16
+ url: "https://events.example.test/webhooks",
17
+ enabled: "1",
18
+ event_types: [ "project.created" ]
19
+ }
20
+ }
21
+ end
22
+
23
+ assert_response :see_other
24
+ follow_redirect!
25
+ assert_response :success
26
+ assert_equal "no-store", response.headers["Cache-Control"]
27
+ assert_select "input[readonly][value^='whsec_']", count: 1
28
+ end
29
+
30
+ test "member cannot inspect another team's delivery" do
31
+ delivery = webhook_deliveries(:difference_engine_created)
32
+
33
+ get webhook_delivery_path(delivery)
34
+
35
+ assert_response :not_found
36
+ end
37
+
38
+ test "replay queues the same logical delivery" do
39
+ delivery = webhook_deliveries(:failed_project_created)
40
+
41
+ assert_enqueued_with job: WebhookDeliveryJob, args: [ delivery.id ] do
42
+ post webhook_delivery_replay_path(delivery)
43
+ end
44
+
45
+ assert_redirected_to webhook_delivery_path(delivery)
46
+ assert_equal delivery.event.public_id, delivery.reload.event.public_id
47
+ end
48
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class Webhook::DeliveryTest < ActiveSupport::TestCase
6
+ setup do
7
+ @team = teams(:analytical_engines)
8
+ @endpoint = @team.webhook_endpoints.create!(
9
+ creator: users(:ada),
10
+ name: "Production",
11
+ url: "https://events.example.test/webhooks",
12
+ signing_secret: "whsec_test",
13
+ event_types: Webhook::Event::TYPES
14
+ )
15
+ end
16
+
17
+ test "publishing creates one immutable subscribed delivery" do
18
+ event = Webhook::Event.publish!(
19
+ team: @team,
20
+ event_type: "project.created",
21
+ idempotency_key: "project:42:created",
22
+ data: { project: { id: 42 } }
23
+ )
24
+
25
+ assert_equal [ @endpoint ], event.deliveries.map(&:endpoint)
26
+ assert_equal event.public_id, event.payload.fetch("id")
27
+ assert_enqueued_with job: WebhookDeliveryJob, args: [ event.deliveries.first.id ]
28
+ end
29
+
30
+ test "a successful response completes an attempt" do
31
+ delivery = publish_delivery
32
+ result = Webhook::Transport::Result.new(
33
+ success: true,
34
+ retryable: false,
35
+ status: 204,
36
+ headers: {},
37
+ body: "",
38
+ error_code: nil,
39
+ error_message: nil
40
+ )
41
+ stub(Webhook::Transport).deliver { result }
42
+
43
+ delivery.deliver!
44
+
45
+ assert delivery.reload.succeeded?
46
+ assert_equal 204, delivery.last_response_status
47
+ assert_equal 1, delivery.attempts.count
48
+ end
49
+
50
+ test "manual replay preserves event identity" do
51
+ delivery = publish_delivery
52
+ delivery.update!(status: :failed, completed_at: Time.current)
53
+ event_id = delivery.event.public_id
54
+
55
+ assert_enqueued_with(job: WebhookDeliveryJob) { delivery.replay!(initiator: users(:ada)) }
56
+
57
+ assert delivery.reload.pending?
58
+ assert_equal event_id, delivery.event.public_id
59
+ end
60
+
61
+ private
62
+ def publish_delivery
63
+ Webhook::Event.publish!(
64
+ team: @team,
65
+ event_type: "project.created",
66
+ idempotency_key: "project:42:created:#{SecureRandom.uuid}",
67
+ data: { project: { id: 42 } }
68
+ ).deliveries.first
69
+ end
70
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "application_system_test_case"
4
+
5
+ class WebhookDeliveriesTest < ApplicationSystemTestCase
6
+ setup do
7
+ sign_in users(:ada)
8
+ switch_team teams(:analytical_engines)
9
+ end
10
+
11
+ test "manager configures and inspects webhook delivery" do
12
+ visit webhook_endpoints_path
13
+ click_on "Add endpoint"
14
+
15
+ fill_in "Name", with: "Production"
16
+ fill_in "Endpoint URL", with: "https://events.example.test/webhooks"
17
+ check "Project created"
18
+ click_on "Add endpoint"
19
+
20
+ assert_text "Save this signing secret now"
21
+ assert_field "Signing secret", readonly: true
22
+
23
+ visit webhook_delivery_path(webhook_deliveries(:failed_project_created))
24
+ assert_text "Delivery failed"
25
+ assert_text "Attempt history"
26
+ click_on "Replay"
27
+ assert_text "Webhook replay queued"
28
+ end
29
+ end
@@ -0,0 +1,4 @@
1
+ version: 1.2.0
2
+ title: Webhook deliveries
3
+ summary: Team-scoped signed webhook endpoints, attempts, bounded retries, replay, and delivery inspection.
4
+ tags: [webhooks, integrations, background-jobs, security, hotwire]
@@ -0,0 +1,120 @@
1
+ # Webhook deliveries
2
+
3
+ ## When to use
4
+
5
+ Use this pattern when a multi-tenant Rails application must deliver its own domain events to customer-managed HTTPS endpoints. It provides endpoint management, encrypted signing secrets, immutable event bodies, transactional delivery creation, bounded automatic retries, manual replay, attempt history, and a Nitro Kit operations UI.
6
+
7
+ Do not use it unchanged for arbitrary HTTP callbacks, internal service-to-service traffic, very high-volume event streams, or payloads containing secrets that should never leave the application. Define a narrow event contract and threat model first.
8
+
9
+ ## Composition checklist
10
+
11
+ Run the page composition checklist in the installed gem's `docs/patterns/composition.md` (`bundle show nitro_kit`) before calling any adapted route finished: the shell owns the gutter and the `h1`, and endpoint and delivery table rows carry plain View/Inspect actions without row-level destructive triggers. Destructive button treatment appears only in the endpoint `DangerZone`, its confirming Dialog submit, and the dedicated secret-rotation confirmation route. Inspect populated, empty, invalid, failed, retrying, and 390px states.
12
+
13
+ ## Install and adapt
14
+
15
+ 1. Copy the migration and merge its team and user references with the host schema.
16
+ 2. Include `Team::Webhookable` in the host `Team` model and ensure Active Record Encryption has production keys configured outside source control.
17
+ 3. Draw `config/routes/webhook_deliveries.rb`, copy the models, controllers, jobs, UI components, views, and stylesheet, and add Webhooks to the application shell.
18
+ 4. Add `config/recurring/webhooks.yml` to Solid Queue's recurring schedule or run `WebhookDeliveryRepairJob` every minute.
19
+ 5. Replace `Webhook::Event::TYPES` with the host's explicit public event contract and keep the endpoint form and tests aligned.
20
+ 6. Adapt `Webhooks::BaseController` if webhook management belongs to a permission other than team owners and administrators.
21
+
22
+ The example emits project lifecycle events. Publish one inside the same transaction as the domain change:
23
+
24
+ ```ruby
25
+ Project.transaction do
26
+ project = Current.team.projects.create!(project_params)
27
+ Webhook::Event.publish!(
28
+ team: Current.team,
29
+ event_type: "project.created",
30
+ idempotency_key: "project:#{project.id}:created",
31
+ data: { project: { id: project.id, name: project.name } }
32
+ )
33
+ end
34
+ ```
35
+
36
+ `publish!` creates one immutable event and one logical delivery for every enabled, subscribed endpoint. Reusing an idempotency key with equivalent canonical data returns that event; reusing it for different data raises `Webhook::Event::IdempotencyConflict`. Delivery rows are committed with the domain change, and `after_create_commit` queues network work only after the transaction succeeds. Do not perform outbound HTTP in a model callback or controller request.
37
+
38
+ ## Event identity and signing
39
+
40
+ The persisted JSON body contains a stable event ID, type, occurrence time, and data. Retries and manual replays reuse those exact bytes and send the event ID as `Idempotency-Key` and `X-Webhook-Id`. Receivers should durably deduplicate by event ID before applying side effects.
41
+
42
+ Each attempt sends:
43
+
44
+ - `X-Webhook-Timestamp`: the attempt's Unix timestamp.
45
+ - `X-Webhook-Signature`: `v1=` plus HMAC-SHA256 of `<timestamp>.<raw request body>`.
46
+ - `X-Webhook-Request-Id`: a unique attempt identifier for support correlation.
47
+
48
+ Verify against the raw request body before parsing JSON, reject stale timestamps, and compare in constant time:
49
+
50
+ ```ruby
51
+ timestamp = request.headers.fetch("X-Webhook-Timestamp")
52
+ provided = request.headers.fetch("X-Webhook-Signature").delete_prefix("v1=")
53
+ expected = OpenSSL::HMAC.hexdigest(
54
+ "SHA256",
55
+ endpoint_secret,
56
+ "#{timestamp}.#{request.raw_post}"
57
+ )
58
+
59
+ head :unauthorized unless
60
+ timestamp.to_i >= 5.minutes.ago.to_i &&
61
+ ActiveSupport::SecurityUtils.secure_compare(provided, expected)
62
+ ```
63
+
64
+ The controller reveals a generated `whsec_…` secret through a short-lived, single-use `Webhook::SecretReveal`. The POST stores only a random-token digest and current-secret fingerprint, then redirects to a no-store/no-referrer GET. That GET atomically consumes the token before reading the endpoint's Active Record Encryption-protected secret. Refreshing, replaying, expiring, or using a token after another rotation reveals nothing. Delivery logs and reveal rows never persist plaintext secrets or signature headers. Rotation immediately changes future signatures, including queued deliveries, so customers should coordinate rotation before submitting it. If overlap is required, model explicit current and retiring secrets with an expiry instead of weakening verification.
65
+
66
+ ## Delivery lifecycle
67
+
68
+ One `Webhook::Delivery` represents one event-endpoint pair. Its persisted states are:
69
+
70
+ - `pending`: queued or waiting for a scheduled retry.
71
+ - `delivering`: claimed by one worker with a unique processing token.
72
+ - `succeeded`: a `2xx` response was recorded.
73
+ - `failed`: a permanent failure or exhausted attempt budget.
74
+
75
+ Each claim creates a `Webhook::Attempt` before network I/O. A token prevents a stale worker from completing a claim repaired by another worker. Duplicate jobs see a non-due or in-flight record and do nothing.
76
+
77
+ Automatic delivery gets at most six attempts with delays of one minute, five minutes, thirty minutes, two hours, and eight hours. Network failures, DNS resolution failures, timeouts, HTTP `408`, `425`, `429`, and `5xx` responses retry. TLS failures, unsafe destinations, redirects, and other `4xx` responses fail without retry because operator action is required. Manual replay is separately rate-limited and bounded to ten attempts. It records the initiating user, reuses the original event identity, and performs one attempt; a failed replay does not silently begin another automatic retry chain.
78
+
79
+ `WebhookDeliveryRepairJob` requeues due pending records when an enqueue was lost. It also repairs delivery claims older than five minutes. An abandoned automatic claim can continue within the automatic budget; an abandoned manual claim fails visibly and may be replayed by an operator.
80
+
81
+ A worker can crash after the receiver applies an event but before Rails records the response. Repair therefore provides at-least-once delivery, not exactly-once delivery. The stable event ID and receiver-side deduplication are the authority for safe recovery.
82
+
83
+ ## Network safety
84
+
85
+ Customer URLs are server-side request-forgery inputs. Form validation requires HTTPS, a hostname, no embedded credentials, and no fragment, but send-time checks are authoritative:
86
+
87
+ - Resolve DNS for every attempt.
88
+ - Reject the destination if any returned address is private, loopback, link-local, documentation, benchmark, multicast, or otherwise reserved.
89
+ - Pin one validated address on the socket while retaining the original hostname for TLS certificate verification and SNI.
90
+ - Disable environment HTTP proxies, redirects, and Net::HTTP's implicit transport retries.
91
+ - Use short connect, read, and write timeouts plus a 20-second wall-clock deadline.
92
+ - Send `Accept-Encoding: identity`, reject more than 64 or 32 KB of parsed response headers, and stop reading response bodies after 16 KB.
93
+
94
+ Rechecking and pinning prevent a hostname from passing validation with a public address and reconnecting to an internal address. Rejecting mixed public/private DNS results fails closed. Keep the forbidden IPv4 and IPv6 ranges current, and add egress firewall policy in production; application checks are defense in depth, not the only network boundary.
95
+
96
+ ## Authorization and audit data
97
+
98
+ Every endpoint and delivery lookup is scoped through `Current.team`. `Webhooks::BaseController` requires the current membership to match both the current user and team and to satisfy `manager?`. A caller-supplied ID cannot select another team's endpoint, rotate its secret, inspect its payload, replay it, or remove it.
99
+
100
+ Attempts store the request URL, request ID, trigger, timestamps, selected response headers, bounded response body, status, and normalized error. Response content is untrusted and must remain escaped in HTML. The UI never renders it as HTML. Decide whether event payloads or endpoint responses may contain personal data, then set retention and erasure policy accordingly. Removing an endpoint removes its delivery history in this example.
101
+
102
+ ## Operations
103
+
104
+ Run webhook work on a dedicated Solid Queue queue with bounded concurrency. Dispatch leases keep the repair sweep from adding the same due job every minute; enqueue failures clear the lease, report through Rails, and leave the durable pending row for recovery. Alert on queue age, stale `delivering` records, exhausted automatic retries, sustained `429` or `5xx` rates, DNS/TLS failures, and repair activity. Log event, delivery, endpoint, and request IDs, but never payloads, secrets, or signature headers by default.
105
+
106
+ The example caps event bodies at 256 KB and response bodies at 16 KB. Net::HTTP bounds individual header fields; the transport adds aggregate post-parse limits and a total deadline. Put webhook egress behind an infrastructure proxy with pre-parse status-line/header limits when hostile endpoints are in scope. Also cap reverse-proxy request sizes for endpoint-management forms and database retention for old events and attempts. Expired reveal capabilities are pruned automatically; add event and attempt retention only after the product's support and audit requirements are known.
107
+
108
+ ## Tests to keep
109
+
110
+ - Publishing inside a rolled-back transaction creates no delivery or job.
111
+ - Only enabled endpoints subscribed to the event type receive one logical delivery.
112
+ - Event bytes and IDs remain stable across retries and replays.
113
+ - HMAC signatures verify against the exact raw body and attempt timestamp.
114
+ - Cross-team endpoint, delivery, replay, rotation, and removal lookups fail closed.
115
+ - Mixed, private, loopback, link-local, IPv4-mapped IPv6, and DNS-rebound destinations are rejected at send time.
116
+ - Redirects are not followed; `2xx`, permanent `4xx`, retryable status, timeout, TLS, and malformed URL behavior is explicit.
117
+ - Duplicate workers cannot create simultaneous attempts or let stale workers overwrite repaired state.
118
+ - Automatic and manual attempt budgets cannot be exceeded.
119
+ - Secrets are encrypted at rest, revealed once, omitted from logs, and changed by rotation.
120
+ - Payloads and response bodies render escaped; narrow, dark, empty, retrying, failed, and successful screens remain usable.
@@ -14,15 +14,15 @@
14
14
  "interface": {
15
15
  "displayName": "Nitro Kit",
16
16
  "shortDescription": "Build Rails UI with Nitro Kit and Hotwire",
17
- "longDescription": "Model conventional Rails resources, compose Nitro Kit components, implement Hotwire interactions from the installed gem version, and use optional catalog guidance when available.",
17
+ "longDescription": "Model conventional Rails resources, compose Nitro Kit components, implement Hotwire interactions, and adapt bundled application patterns from the installed gem version.",
18
18
  "developerName": "Mikkel Malmberg",
19
19
  "category": "Developer",
20
20
  "capabilities": ["Read", "Write"],
21
21
  "websiteURL": "https://nitrokit.dev",
22
22
  "defaultPrompt": [
23
- "Build this Rails feature on the Nitro Kit Rails path, using relevant catalog guidance when available.",
24
- "Build this Rails interface with Nitro Kit components and any relevant catalog guidance available.",
25
- "Implement this interaction with Nitro Kit, conventional Hotwire, and relevant catalog guidance when available."
23
+ "Build this Rails feature on the Nitro Kit Rails path, using relevant bundled patterns from the installed gem.",
24
+ "Build this Rails interface with Nitro Kit components and any relevant bundled patterns from the installed gem.",
25
+ "Implement this interaction with Nitro Kit, conventional Hotwire, and relevant bundled patterns from the installed gem."
26
26
  ]
27
27
  }
28
28
  }
@@ -25,17 +25,15 @@ Make the server response and stable DOM boundary the interaction API. Add Stimul
25
25
  7. Read `NITRO_KIT_ROOT/docs/browser_support.md` for the canonical
26
26
  full/reduced/unavailable no-JavaScript classification.
27
27
 
28
- ## Discover optional catalog guidance
28
+ ## Use bundled application patterns
29
29
 
30
- For a broad product workflow, check whether Nitro Kit catalog or MCP tools are
31
- available. When they are, inventory and search by workflow, retrieve relevant
32
- patterns, and state what will be used, adapted, or deferred before
33
- implementation. When they are not, continue with the installed Hotwire recipes,
34
- component contracts, and source. Catalog access is optional and must never
35
- block the work or be implied in the result.
30
+ For a broad product workflow, browse `NITRO_KIT_ROOT/patterns/README.md` by
31
+ workflow, read the relevant `pattern.md` guides and reference files under
32
+ `NITRO_KIT_ROOT/patterns/`, and state what will be used, adapted, or deferred
33
+ before implementation.
36
34
 
37
- For a focused interaction, use the catalog only when it is already available
38
- and a higher-level pattern would materially help.
35
+ For a focused interaction, consult `NITRO_KIT_ROOT/patterns/` only when a
36
+ higher-level pattern would materially help.
39
37
 
40
38
  Do not proceed with a remembered Nitro Kit 1.x API. Do not copy or recreate
41
39
  the installed gem's `nk--*` controllers under `app/javascript/controllers/nk`.
@@ -1,4 +1,4 @@
1
1
  interface:
2
2
  display_name: "Nitro Kit Hotwire"
3
3
  short_description: "Build conventional Nitro Kit Hotwire flows"
4
- default_prompt: "Use $nitro-kit-hotwire to build this interaction with Nitro Kit, conventional Hotwire, and relevant catalog guidance when available."
4
+ default_prompt: "Use $nitro-kit-hotwire to build this interaction with Nitro Kit, conventional Hotwire, and relevant bundled patterns."
@@ -23,18 +23,19 @@ established application outside the requested scope.
23
23
  8. Read the matching Hotwire recipe before implementing an interaction.
24
24
  9. Read `NITRO_KIT_ROOT/docs/browser_support.md` before claiming an
25
25
  interaction works without JavaScript.
26
+ 10. In a jsbundling-rails application, read the Bundlers section of
27
+ `NITRO_KIT_ROOT/docs/rails_integration.md`. Before wrapping Nitro
28
+ components in ERB `cache` blocks, read its Fragment caching section.
26
29
 
27
- ## Discover optional catalog guidance
30
+ ## Use bundled application patterns
28
31
 
29
- For greenfield planning or broad product work, check whether Nitro Kit catalog
30
- or MCP tools are available. When they are, inventory and search by product
31
- workflow, retrieve the relevant patterns, and state what will be used, adapted,
32
- or deferred before implementation. When they are not, continue with the
33
- installed skills, documentation, component contracts, and source. Catalog
34
- access is optional and must never block the work or be implied in the result.
32
+ For greenfield planning or broad product work, browse
33
+ `NITRO_KIT_ROOT/patterns/README.md` by product workflow, read the relevant
34
+ `pattern.md` guides and reference files under `NITRO_KIT_ROOT/patterns/`, and
35
+ state what will be used, adapted, or deferred before implementation.
35
36
 
36
- For a focused Rails change, use the catalog only when it is already available
37
- and the task could benefit from a higher-level product pattern.
37
+ For a focused Rails change, consult `NITRO_KIT_ROOT/patterns/` only when the
38
+ task could benefit from a higher-level product pattern.
38
39
 
39
40
  Never use a Nitro Kit 1.x helper, copied component, controller, or Tailwind
40
41
  contract as a substitute for the installed API.
@@ -1,4 +1,4 @@
1
1
  interface:
2
2
  display_name: "Nitro Kit Rails"
3
3
  short_description: "Build conventional Rails applications with Nitro Kit"
4
- default_prompt: "Use $nitro-kit-rails to build this feature on the Nitro Kit Rails path, using relevant catalog guidance when available."
4
+ default_prompt: "Use $nitro-kit-rails to build this feature on the Nitro Kit Rails path, using relevant bundled patterns."
@@ -18,25 +18,24 @@ Use the documentation shipped with the application's installed gem as the source
18
18
  classifications in `NITRO_KIT_ROOT/docs/browser_support.md`.
19
19
  7. Inspect the installed component source when constructor or compound-slot details remain unclear. Never guess a component API from memory.
20
20
 
21
- ## Discover optional catalog guidance
21
+ ## Use bundled application patterns
22
22
 
23
- For greenfield planning or broad product UI work, check whether Nitro Kit
24
- catalog or MCP tools are available. When they are, inventory and search by
25
- product workflow, retrieve the relevant patterns, and state what will be used,
26
- adapted, or deferred before implementation. When they are not, continue with
27
- the installed skills, documentation, component contracts, and source. Catalog
28
- access is optional and must never block the work or be implied in the result.
23
+ For greenfield planning or broad product UI work, browse
24
+ `NITRO_KIT_ROOT/patterns/README.md` by product workflow, read the relevant
25
+ `pattern.md` guides and reference files under `NITRO_KIT_ROOT/patterns/`, and
26
+ state what will be used, adapted, or deferred before implementation.
29
27
 
30
- For a focused component change, use the catalog only when it is already
31
- available and a higher-level composition would materially help.
28
+ For a focused component change, consult `NITRO_KIT_ROOT/patterns/` only when a
29
+ higher-level composition would materially help.
32
30
 
33
31
  For a Nitro Kit 1.x migration, read
34
- `NITRO_KIT_ROOT/docs/migration_1_to_2.md` before editing. Inventory product
35
- flows, behavior, application-owned button classes and Rails button helpers,
36
- joined controls, and the existing semantic color, focus, radius, density, and
37
- typography tokens first. Capture representative wide and narrow screenshots.
38
- Apply the optional catalog process above, searching by workflow rather than old
39
- component name and selecting high-level compositions before replacing atoms.
32
+ `NITRO_KIT_ROOT/docs/migration_1_to_2.md` and
33
+ `NITRO_KIT_ROOT/patterns/nitro-kit-1-upgrade/pattern.md` before editing.
34
+ Inventory product flows, behavior, application-owned button classes and Rails
35
+ button helpers, joined controls, and the existing semantic color, focus,
36
+ radius, density, and typography tokens first. Capture representative wide and
37
+ narrow screenshots. Select high-level compositions from the installed docs and
38
+ `patterns/` before replacing atoms.
40
39
 
41
40
  If the gem is not installed, say that the skill requires Nitro Kit and follow the application's requested installation scope. Do not substitute APIs from an older Nitro Kit release.
42
41
 
@@ -69,6 +68,18 @@ If the gem is not installed, say that the skill requires Nitro Kit and follow th
69
68
  `docs/patterns/application_foundation.md`. Put Settings after an
70
69
  `AppNavigation` spacer and use `SettingsLayout` with plain `SettingsSection`
71
70
  regions instead of a stack of Cards.
71
+ 10. In an application with an existing design system, read "Adopt Nitro Kit
72
+ next to an existing design system" in `docs/agent_guide.md`: host tokens
73
+ map onto `--nk-*`, Nitro owns components, and exactly one system owns the
74
+ gutter and the title scale.
75
+
76
+ ## Check the composition
77
+
78
+ Before finishing any page, including one adapted from a bundled pattern, run
79
+ `NITRO_KIT_ROOT/docs/patterns/composition.md`: exactly one element owns the
80
+ page gutter; one primary action, with destructive buttons kept off table rows
81
+ and reserved for an edit route's DangerZone and confirming submits; populated, empty, invalid, and 390px
82
+ states inspected; one `h1` at the same scale as neighboring routes.
72
83
 
73
84
  ## Preserve the boundary
74
85
 
@@ -93,7 +104,7 @@ Run the smallest relevant application tests. For component rendering, assert sem
93
104
 
94
105
  Nitro Kit Doctor verifies integration and runtime contracts, not product
95
106
  completeness. Do not use a green Doctor result as proof that every relevant
96
- screen, state, or catalog workflow has been implemented.
107
+ screen, state, or workflow has been implemented.
97
108
 
98
109
  For a migration, Doctor is an inventory, not visual proof. Run representative form and component rendering with `ActiveModel::Translation.raise_on_missing_translations` enabled when the application uses strict i18n. Compare the same representative flows in a browser at wide and narrow widths, exercise keyboard focus, and inspect computed styles for missing application classes, stacked Button content, broken compound corners, double focus rings, clipping, and theme drift. Re-audit rendered native buttons, Rails button helpers, and application-owned button classes before declaring the conversion complete. Search the whole application for `desperately_need_a_class:` and review every result, aiming for zero. Move layout and visual treatment to application-owned wrappers, remove generic class forwarding, accept incidental Nitro defaults, and keep unmatched product UI application-owned; retain only documented external-integration hooks.
99
110
 
@@ -1,4 +1,4 @@
1
1
  interface:
2
2
  display_name: "Nitro Kit UI"
3
3
  short_description: "Build Rails interfaces with Nitro Kit components"
4
- default_prompt: "Use $nitro-kit-ui to build this Rails interface with the installed Nitro Kit components and any relevant catalog guidance available."
4
+ default_prompt: "Use $nitro-kit-ui to build this Rails interface with the installed Nitro Kit components and relevant bundled patterns."