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
@@ -2,6 +2,7 @@ require "fileutils"
2
2
  require "open3"
3
3
  require "pathname"
4
4
  require "ripper"
5
+ require "yaml"
5
6
  require "nitro_kit/migration_inventory"
6
7
 
7
8
  module NitroKit
@@ -9,6 +10,20 @@ module NitroKit
9
10
  ROOT = Pathname.new(File.expand_path("../..", __dir__))
10
11
  SKILLS = %w[nitro-kit-hotwire nitro-kit-rails nitro-kit-ui].freeze
11
12
  SKILL_ROOTS = [ ".agents/skills", ".claude/skills" ].freeze
13
+ # Doctor outcomes, most to least severe after :fail. Only :fail makes the
14
+ # installation unhealthy. :unverified means Doctor could not inspect the
15
+ # setup and names what to check by hand; :optional is a convention the
16
+ # application chose not to adopt; :warn is an application next step.
17
+ STATUS_COLORS = {
18
+ pass: :green,
19
+ optional: :blue,
20
+ unverified: :cyan,
21
+ warn: :yellow,
22
+ fail: :red
23
+ }.freeze
24
+ CONFIG_PATH = "config/nitro_kit/doctor.yml"
25
+ THEME_OWNERS = %w[nitro_kit application].freeze
26
+ CONFIG_KEYS = %w[theme_owner skill_roots retained_dependencies].freeze
12
27
  # nitro_kit-tailwind-v4 is the beta-era adapter that nitro_kit.css absorbed;
13
28
  # it stays managed so doctor flags a leftover link instead of ignoring it.
14
29
  MANAGED_STYLESHEETS = %w[
@@ -27,12 +42,11 @@ module NitroKit
27
42
  Each skill resolves the installed gem with `bundle show nitro_kit` and reads
28
43
  its version-matched documentation.
29
44
 
30
- For greenfield planning or broad product work, check whether Nitro Kit
31
- catalog or MCP tools are available. When they are, inventory and search the
32
- catalog by product workflow, retrieve the relevant patterns, and state what
33
- will be used, adapted, or deferred before implementation. When they are not,
34
- continue with the bundled skills, documentation, and component contracts;
35
- catalog access is optional and must never block the work. Nitro Kit Doctor
45
+ For greenfield planning or broad product work, browse the bundled
46
+ application patterns under `patterns/` in the installed gem
47
+ (`patterns/README.md`) by product workflow, read the relevant `pattern.md`
48
+ guides and reference files, and state what will be used, adapted, or
49
+ deferred before implementation. Nitro Kit Doctor
36
50
  verifies integration health, not product completeness.
37
51
 
38
52
  In a greenfield application, run `bin/rails generate phlex:install` and use
@@ -57,12 +71,35 @@ module NitroKit
57
71
 
58
72
  Check = Struct.new(:status, :label, :detail, keyword_init: true)
59
73
  LayoutExpression = Struct.new(:range, :type, :assets, :dynamic, keyword_init: true)
60
- LayoutAnalysis = Struct.new(:head_range, :stylesheets, :bootstraps, :errors, keyword_init: true)
74
+ # errors: every reason the installer must leave the layout alone.
75
+ # uninspectable: the subset that stops Doctor from verifying the head.
76
+ # defects: the subset Doctor can prove is wrong.
77
+ LayoutAnalysis = Struct.new(:head_range, :stylesheets, :bootstraps, :errors, :uninspectable, :defects, keyword_init: true)
78
+ Configuration = Struct.new(:theme_owner, :skill_roots, :retained_dependencies, :errors, :present, keyword_init: true) do
79
+ def theme_owned_by_application? = theme_owner == "application"
80
+ end
81
+
82
+ # One line after the per-check output: the verdict, then what the
83
+ # non-failing outcomes ask of the reader.
84
+ def self.summary(checks)
85
+ counts = checks.map(&:status).tally
86
+ verdict = counts[:fail] ? "Doctor found #{counts[:fail]} failure#{'s' unless counts[:fail] == 1}" : "Doctor found no failures"
87
+ notes = []
88
+ notes << "#{counts[:unverified]} UNVERIFIED to check by hand" if counts[:unverified]
89
+ notes << "#{counts[:optional]} OPTIONAL convention#{'s' unless counts[:optional] == 1} not adopted" if counts[:optional]
90
+ notes << "#{counts[:warn]} WARN next step#{'s' unless counts[:warn] == 1}" if counts[:warn]
91
+ [ verdict, *notes ].join("; ") + "."
92
+ end
61
93
 
62
94
  attr_reader :application_root
63
95
 
64
- def initialize(application_root)
96
+ def initialize(application_root, pretend: false)
65
97
  @application_root = Pathname.new(application_root)
98
+ @pretend = pretend
99
+ end
100
+
101
+ def pretend?
102
+ @pretend
66
103
  end
67
104
 
68
105
  def install
@@ -84,7 +121,7 @@ module NitroKit
84
121
  end
85
122
 
86
123
  def write_skills
87
- SKILL_ROOTS.product(SKILLS).to_h do |root, skill|
124
+ configuration.skill_roots.product(SKILLS).to_h do |root, skill|
88
125
  destination = application_root.join(root, skill, "SKILL.md")
89
126
  source = skill_source(skill)
90
127
  [ destination.relative_path_from(application_root).to_s, write(destination, source.read) ]
@@ -108,23 +145,34 @@ module NitroKit
108
145
  def checks
109
146
  [
110
147
  version_check,
148
+ configuration_check,
111
149
  agents_check,
112
150
  skills_check,
113
151
  hotwire_check,
114
152
  stimulus_loader_check,
115
153
  stylesheet_setup_check,
154
+ appearance_check,
116
155
  phlex_kit_check,
117
156
  *migration_checks
118
- ]
157
+ ].compact
119
158
  end
120
159
 
121
160
  def healthy?
122
161
  checks.none? { _1.status == :fail }
123
162
  end
124
163
 
164
+ # Host-declared Doctor exceptions from config/nitro_kit/doctor.yml. A file
165
+ # rather than a Ruby initializer so the installer and Doctor read the same
166
+ # answer without booting the application. Invalid settings fall back to the
167
+ # defaults and fail the "Doctor configuration" check.
168
+ def configuration
169
+ @configuration ||= load_configuration
170
+ end
171
+
125
172
  private
126
173
  def write(path, contents)
127
174
  return :unchanged if path.exist? && path.read == contents
175
+ return :written if pretend?
128
176
 
129
177
  FileUtils.mkdir_p(path.dirname)
130
178
  path.write(contents)
@@ -150,18 +198,98 @@ module NitroKit
150
198
  )
151
199
  end
152
200
 
153
- def skills_check
154
- missing = SKILL_ROOTS.product(SKILLS).filter_map do |root, skill|
155
- path = application_root.join(root, skill, "SKILL.md")
156
- path.relative_path_from(application_root).to_s unless path.exist? && path.read == skill_source(skill).read
201
+ def load_configuration
202
+ defaults = { theme_owner: "nitro_kit", skill_roots: SKILL_ROOTS, retained_dependencies: {} }
203
+ path = application_root.join(CONFIG_PATH)
204
+ return Configuration.new(**defaults, errors: [], present: false) unless path.file?
205
+
206
+ data = begin
207
+ YAML.safe_load(path.read) || {}
208
+ rescue Psych::Exception => error
209
+ return Configuration.new(**defaults, errors: [ "could not parse: #{error.message}" ], present: true)
157
210
  end
211
+ return Configuration.new(**defaults, errors: [ "expected a mapping of settings" ], present: true) unless data.is_a?(Hash)
212
+
213
+ errors = []
214
+ unknown = data.keys - CONFIG_KEYS
215
+ errors << "unknown settings #{unknown.join(', ')}; expected #{CONFIG_KEYS.join(', ')}" if unknown.any?
216
+
217
+ theme_owner = data.fetch("theme_owner", defaults[:theme_owner])
218
+ unless THEME_OWNERS.include?(theme_owner)
219
+ errors << "theme_owner must be one of #{THEME_OWNERS.join(', ')}"
220
+ theme_owner = defaults[:theme_owner]
221
+ end
222
+
223
+ skill_roots = data.fetch("skill_roots", SKILL_ROOTS)
224
+ unless skill_roots.is_a?(Array) && skill_roots.any? && skill_roots.uniq.size == skill_roots.size && (skill_roots - SKILL_ROOTS).empty?
225
+ errors << "skill_roots must list one or both of #{SKILL_ROOTS.join(', ')}"
226
+ skill_roots = SKILL_ROOTS
227
+ end
228
+
229
+ retained = data.fetch("retained_dependencies", {})
230
+ known = MigrationInventory::VENDORED_MODULES.keys
231
+ if !retained.is_a?(Hash)
232
+ errors << "retained_dependencies must map a package name to the reason it is retained"
233
+ retained = {}
234
+ else
235
+ invalid = retained.reject { |name, reason| known.include?(name) && reason.is_a?(String) && !reason.strip.empty? }
236
+ if invalid.any?
237
+ errors << "retained_dependencies entries need a known package (#{known.join(', ')}) and a non-empty reason: #{invalid.keys.join(', ')}"
238
+ retained = retained.except(*invalid.keys)
239
+ end
240
+ end
241
+
242
+ Configuration.new(theme_owner:, skill_roots: SKILL_ROOTS & skill_roots, retained_dependencies: retained, errors:, present: true)
243
+ end
244
+
245
+ def configuration_check
246
+ return unless configuration.present
247
+
248
+ settings = [
249
+ "theme owner #{configuration.theme_owner}",
250
+ "skill roots #{configuration.skill_roots.join(', ')}",
251
+ "#{configuration.retained_dependencies.size} retained dependenc#{configuration.retained_dependencies.one? ? 'y' : 'ies'}"
252
+ ]
158
253
  Check.new(
159
- status: missing.empty? ? :pass : :fail,
160
- label: "Project-local skills",
161
- detail: missing.empty? ? "Codex and Claude skill routers are current" : "missing or stale: #{missing.join(', ')}"
254
+ status: configuration.errors.empty? ? :pass : :fail,
255
+ label: "Doctor configuration",
256
+ detail: "#{CONFIG_PATH}: #{configuration.errors.empty? ? settings.join('; ') : "#{configuration.errors.join('; ')}; using defaults for invalid settings"}"
162
257
  )
163
258
  end
164
259
 
260
+ def skills_check
261
+ skipped = SKILL_ROOTS - configuration.skill_roots
262
+ missing = skill_paths(configuration.skill_roots).reject { current_skill?(*_1) }.map(&:first)
263
+ # A stale copy in a root the application chose not to adopt still
264
+ # misleads the agent that reads it.
265
+ stale = skill_paths(skipped).select { |path, skill| application_root.join(path).exist? && !current_skill?(path, skill) }.map(&:first)
266
+
267
+ if missing.any? || stale.any?
268
+ detail = [
269
+ ("missing or stale: #{missing.join(', ')}" if missing.any?),
270
+ ("stale outside the configured skill_roots; refresh or remove: #{stale.join(', ')}" if stale.any?)
271
+ ].compact.join("; ")
272
+ Check.new(status: :fail, label: "Project-local skills", detail:)
273
+ elsif skipped.any?
274
+ Check.new(
275
+ status: :optional,
276
+ label: "Project-local skills",
277
+ detail: "#{configuration.skill_roots.join(', ')} current; #{skipped.join(', ')} not adopted (skill_roots in #{CONFIG_PATH})"
278
+ )
279
+ else
280
+ Check.new(status: :pass, label: "Project-local skills", detail: "Codex and Claude skill routers are current")
281
+ end
282
+ end
283
+
284
+ def skill_paths(roots)
285
+ roots.product(SKILLS).map { |root, skill| [ File.join(root, skill, "SKILL.md"), skill ] }
286
+ end
287
+
288
+ def current_skill?(path, skill)
289
+ path = application_root.join(path)
290
+ path.exist? && path.read == skill_source(skill).read
291
+ end
292
+
165
293
  def hotwire_check
166
294
  missing = %w[turbo-rails stimulus-rails].reject { Gem.loaded_specs.key?(_1) }
167
295
  Check.new(
@@ -172,76 +300,183 @@ module NitroKit
172
300
  end
173
301
 
174
302
  def stimulus_loader_check
175
- javascript = application_root.glob("app/javascript/**/*.{js,ts}").select(&:file?).map(&:read)
176
- loader = if javascript.any? { _1.include?("eagerLoadControllersFrom") }
177
- "eager controller loading"
178
- elsif javascript.any? { _1.match?(/\bapplication\.register\s*\(/) }
179
- "explicit controller registration"
303
+ label = "Stimulus loader"
304
+ files = application_root.glob("app/javascript/**/*.{js,ts}").select(&:file?)
305
+ sources = files.map(&:read)
306
+ importmap = application_root.join("config/importmap.rb").file?
307
+
308
+ if sources.any? { _1.match?(/\b(?:eager|lazy)LoadControllersFrom\s*\(\s*["']controllers["']/) }
309
+ if importmap
310
+ return Check.new(
311
+ status: :pass,
312
+ label:,
313
+ detail: "importmap controller loading is configured (Nitro Kit engine pins controllers/nk/*)"
314
+ )
315
+ end
316
+
317
+ return Check.new(
318
+ status: :unverified,
319
+ label:,
320
+ detail: "importmap-style controller loading is configured, but config/importmap.rb is absent; check by hand that Nitro Kit controllers (nk--*) are registered"
321
+ )
322
+ end
323
+
324
+ registered = registered_nitro_controllers(sources)
325
+ if registered.any?
326
+ missing = nitro_controller_identifiers - registered
327
+ if missing.empty?
328
+ return Check.new(
329
+ status: :pass,
330
+ label:,
331
+ detail: "explicit Nitro Kit controller registration covers all #{nitro_controller_identifiers.size} controllers"
332
+ )
333
+ end
334
+
335
+ return Check.new(
336
+ status: :fail,
337
+ label:,
338
+ detail: "explicit Nitro Kit controller registration is missing: #{missing.join(', ')}"
339
+ )
340
+ end
341
+
342
+ if sources.any? { _1.match?(/\bapplication\.register\s*\(/) }
343
+ return Check.new(
344
+ status: :fail,
345
+ label:,
346
+ detail: "Stimulus registers controllers explicitly, but no Nitro Kit controllers are registered; missing: #{nitro_controller_identifiers.join(', ')}"
347
+ )
180
348
  end
181
349
 
182
350
  Check.new(
183
- status: loader ? :pass : :warn,
184
- label: "Stimulus loader",
185
- detail: loader ? "#{loader} is configured" : "verify the application's controller registration"
351
+ status: :unverified,
352
+ label:,
353
+ detail: "could not verify Nitro Kit Stimulus controller registration; check by hand that controllers/nk/* (#{nitro_controller_identifiers.size} controllers) are registered"
186
354
  )
187
355
  end
188
356
 
357
+ def nitro_controller_identifiers
358
+ @nitro_controller_identifiers ||= ROOT.glob("app/javascript/controllers/nk/**/*_controller.js").sort.map do |path|
359
+ path.relative_path_from(ROOT.join("app/javascript/controllers")).to_s
360
+ .delete_suffix("_controller.js")
361
+ .tr("_", "-")
362
+ .gsub("/", "--")
363
+ end
364
+ end
365
+
366
+ def registered_nitro_controllers(sources)
367
+ sources.flat_map do |source|
368
+ source.scan(/\bapplication\.register\s*\(\s*["'](nk--[a-z0-9-]+)["']/).flatten
369
+ end.uniq.sort
370
+ end
371
+
189
372
  def stylesheet_setup_check
190
- return Check.new(
191
- status: :fail,
192
- label: "Stylesheet and appearance setup",
193
- detail: "missing application layout; add AppearanceBootstrap before the ordered stylesheet entries"
194
- ) unless layout_path
373
+ label = "Stylesheet and appearance setup"
374
+ unless layout_path
375
+ other_layouts = application_root.glob("app/views/layouts/*.{erb,haml,slim}").select(&:file?)
376
+ if other_layouts.any?
377
+ return Check.new(
378
+ status: :unverified,
379
+ label:,
380
+ detail: "no conventional application layout; check by hand that #{other_layouts.map { relative(_1) }.join(', ')} load#{'s' if other_layouts.one?} #{setup_sequence(%w[nitro_kit])} before application styles"
381
+ )
382
+ end
195
383
 
196
- contents = layout_path.read
197
- analysis = analyze_layout(contents)
384
+ detail = bootstrap_required? ? "add AppearanceBootstrap before the ordered stylesheet entries" : "add the ordered stylesheet entries"
385
+ return Check.new(status: :fail, label:, detail: "missing application layout; #{detail}")
386
+ end
387
+
388
+ analysis = analyze_layout(layout_path.read)
198
389
  expected = expected_stylesheets(analysis)
199
- errors = []
200
- bootstrap_count = analysis.bootstraps.size
390
+ assets = managed_stylesheet_assets(analysis)
391
+ location = relative(layout_path)
392
+
393
+ if analysis.uninspectable.any?
394
+ defects = analysis.defects + visible_stylesheet_defects(expected, assets)
395
+ if defects.any?
396
+ return Check.new(
397
+ status: :fail,
398
+ label:,
399
+ detail: "#{location}: #{defects.join('; ')}; installer left the layout unchanged — #{analysis.errors.join('; ')}"
400
+ )
401
+ end
201
402
 
202
- if analysis.errors.any?
203
403
  return Check.new(
204
- status: :fail,
205
- label: "Stylesheet and appearance setup",
206
- detail: "#{relative(layout_path)}: installer left the layout unchanged — #{analysis.errors.join('; ')}; manually ensure AppearanceBootstrap → #{expected.join(' → ')} without discarding existing options"
404
+ status: :unverified,
405
+ label:,
406
+ detail: "#{location}: could not inspect the head — #{analysis.uninspectable.join('; ')}; check by hand that the rendered head loads #{setup_sequence(expected)}, each once, in that order"
207
407
  )
208
408
  end
209
409
 
210
- errors << "add one NitroKit::AppearanceBootstrap before every stylesheet" if bootstrap_count.zero?
410
+ errors = analysis.defects.dup
411
+ bootstrap_count = analysis.bootstraps.size
412
+ errors << "add one NitroKit::AppearanceBootstrap before every stylesheet" if bootstrap_count.zero? && bootstrap_required?
211
413
  errors << "remove duplicate NitroKit::AppearanceBootstrap entries" if bootstrap_count > 1
212
414
 
213
- assets = managed_stylesheet_assets(analysis)
214
415
  expected.each do |stylesheet|
215
416
  count = assets.count(stylesheet)
216
417
  errors << "add stylesheet #{stylesheet.inspect}" if count.zero?
217
418
  errors << "remove duplicate stylesheet #{stylesheet.inspect}" if count > 1
218
419
  end
219
420
 
220
- if (edit_error = layout_edit_error(analysis, expected))
421
+ errors.concat(obsolete_stylesheet_defects(assets))
422
+
423
+ bootstrap = analysis.bootstraps.first
424
+ first_stylesheet = analysis.stylesheets.first
425
+ bootstrap_late = bootstrap && first_stylesheet && bootstrap.range.begin >= first_stylesheet.range.begin
426
+ if errors.empty? && (bootstrap_late || assets != expected)
427
+ errors << "reorder to #{setup_sequence(expected)}"
428
+ end
429
+
430
+ if errors.any? && (edit_error = layout_edit_error(analysis, expected))
221
431
  errors << "installer left the layout unchanged: #{edit_error}"
222
432
  end
223
433
 
434
+ Check.new(
435
+ status: errors.empty? ? :pass : :fail,
436
+ label:,
437
+ detail: "#{location}: #{errors.empty? ? setup_sequence(expected, present: bootstrap) : errors.join('; ')}"
438
+ )
439
+ end
440
+
441
+ # Order problems Doctor can still prove from the static calls it found in
442
+ # a head it could not fully inspect.
443
+ def visible_stylesheet_defects(expected, assets)
444
+ defects = obsolete_stylesheet_defects(assets)
445
+ visible = assets.uniq - [ "nitro_kit-tailwind-v4" ]
446
+ defects << "reorder the visible stylesheets to #{setup_sequence(expected)}" unless visible == expected.select { visible.include?(_1) }
447
+ defects
448
+ end
449
+
450
+ def obsolete_stylesheet_defects(assets)
451
+ defects = []
224
452
  if assets.include?("nitro_kit-tailwind-v4")
225
- errors << "remove stylesheet \"nitro_kit-tailwind-v4\"; nitro_kit now includes the Tailwind v4 layer order and theme aliases"
453
+ defects << "remove stylesheet \"nitro_kit-tailwind-v4\"; nitro_kit now includes the Tailwind v4 layer order and theme aliases"
226
454
  end
227
-
228
455
  if tailwind_bundles_nitro_kit? && assets.include?("nitro_kit")
229
- errors << "remove stylesheet \"nitro_kit\"; #{TAILWIND_ENTRY} already bundles it"
456
+ defects << "remove stylesheet \"nitro_kit\"; #{TAILWIND_ENTRY} already bundles it"
230
457
  end
458
+ defects
459
+ end
231
460
 
232
- bootstrap_position = analysis.bootstraps.first&.range&.begin
233
- first_stylesheet_position = analysis.stylesheets.first&.range&.begin
234
- if errors.empty? && (bootstrap_position >= first_stylesheet_position || assets != expected)
235
- errors << "reorder to AppearanceBootstrap → #{expected.join(' → ')}"
236
- end
461
+ def appearance_check
462
+ return unless configuration.theme_owned_by_application?
237
463
 
238
464
  Check.new(
239
- status: errors.empty? ? :pass : :fail,
240
- label: "Stylesheet and appearance setup",
241
- detail: errors.empty? ? "#{relative(layout_path)}: AppearanceBootstrap → #{expected.join(' → ')}" : "#{relative(layout_path)}: #{errors.join('; ')}"
465
+ status: :optional,
466
+ label: "Appearance bootstrap",
467
+ detail: "theme_owner is application in #{CONFIG_PATH}, so AppearanceBootstrap is not required; set data-theme=\"light|dark\" on <html> or leave it unset to follow prefers-color-scheme. AppearancePicker still needs AppearanceBootstrap"
242
468
  )
243
469
  end
244
470
 
471
+ def bootstrap_required?
472
+ !configuration.theme_owned_by_application?
473
+ end
474
+
475
+ def setup_sequence(stylesheets, present: nil)
476
+ bootstrap = bootstrap_required? || present ? [ "AppearanceBootstrap" ] : []
477
+ [ *bootstrap, *stylesheets ].join(" → ")
478
+ end
479
+
245
480
  def phlex_kit_check
246
481
  ready = application_root.glob("app/components/**/*.rb").any? { _1.read.match?(/include\s+(?:\(?\s*)?NitroKit\b/) }
247
482
  Check.new(
@@ -252,9 +487,17 @@ module NitroKit
252
487
  end
253
488
 
254
489
  def migration_checks
255
- MigrationInventory.new(application_root).categories.map do |label, findings|
490
+ inventory = MigrationInventory.new(application_root, retained_dependencies: configuration.retained_dependencies)
491
+ inventory.categories.map do |label, findings|
492
+ status = if findings.empty?
493
+ :pass
494
+ elsif findings.all? { _1.status == :retained }
495
+ :optional
496
+ else
497
+ :warn
498
+ end
256
499
  Check.new(
257
- status: findings.empty? ? :pass : :warn,
500
+ status:,
258
501
  label: "Migration: #{label}",
259
502
  detail: findings.empty? ? "migrated: none found" : findings.map do |finding|
260
503
  "#{finding.status.to_s.tr('_', '-')}: #{finding.path} — #{finding.guidance}"
@@ -287,13 +530,14 @@ module NitroKit
287
530
  return contents if edit_error
288
531
 
289
532
  missing = expected - managed_stylesheet_assets(analysis)
290
- return contents if missing.empty? && analysis.bootstraps.one?
533
+ insert_bootstrap = analysis.bootstraps.empty? && bootstrap_required?
534
+ return contents if missing.empty? && !insert_bootstrap
291
535
 
292
536
  lines = contents.lines
293
537
  insertions = Hash.new { |hash, index| hash[index] = [] }
294
538
  indent = layout_indent(lines, analysis)
295
539
 
296
- if analysis.bootstraps.empty?
540
+ if insert_bootstrap
297
541
  bootstrap_index = analysis.stylesheets.first&.range&.begin || analysis.head_range.begin + 1
298
542
  insertions[bootstrap_index] << bootstrap_markup(indent)
299
543
  end
@@ -313,31 +557,38 @@ module NitroKit
313
557
 
314
558
  def analyze_layout(contents)
315
559
  errors = []
316
- errors << "multiple application layouts found: #{layout_paths.map { relative(_1) }.join(', ')}" if layout_paths.many?
560
+ uninspectable = []
561
+ defects = []
562
+ unverifiable = ->(message) { errors << message; uninspectable << message }
563
+ defect = ->(message) { errors << message; defects << message }
564
+
565
+ unverifiable.("multiple application layouts found: #{layout_paths.map { relative(_1) }.join(', ')}") if layout_paths.many?
317
566
  lines = contents.lines
318
567
  head_range, boundary_errors = if layout_path.extname == ".rb"
319
568
  phlex_head_range(contents)
320
569
  else
321
570
  erb_head_range(contents)
322
571
  end
323
- errors.concat(boundary_errors)
572
+ boundary_errors.each(&unverifiable)
324
573
 
325
574
  all_expressions = layout_path.extname == ".rb" ? phlex_layout_expressions(contents) : erb_layout_expressions(contents)
326
575
  expressions = if head_range
327
576
  all_expressions.select do |expression|
328
577
  inside = head_range.cover?(expression.range.begin) && head_range.cover?(expression.range.end)
329
578
  overlaps = head_range.cover?(expression.range.begin) || head_range.cover?(expression.range.end)
330
- errors << "#{expression.type} call on line #{expression.range.begin + 1} crosses the document head boundary" if overlaps && !inside
579
+ unverifiable.("#{expression.type} call on line #{expression.range.begin + 1} crosses the document head boundary") if overlaps && !inside
331
580
  inside
332
581
  end
333
582
  else
334
583
  []
335
584
  end
336
- outside_expressions = all_expressions - expressions
337
- outside_expressions.each do |expression|
338
- next if head_range && (head_range.cover?(expression.range.begin) || head_range.cover?(expression.range.end))
585
+ # Without a known head, Doctor cannot tell where a call renders.
586
+ if head_range && boundary_errors.empty?
587
+ (all_expressions - expressions).each do |expression|
588
+ next if head_range.cover?(expression.range.begin) || head_range.cover?(expression.range.end)
339
589
 
340
- errors << "#{expression.type} call on line #{expression.range.begin + 1} is outside the document head"
590
+ defect.("#{expression.type} call on line #{expression.range.begin + 1} is outside the document head")
591
+ end
341
592
  end
342
593
 
343
594
  stylesheets = expressions.select { _1.type == :stylesheet }
@@ -346,24 +597,32 @@ module NitroKit
346
597
 
347
598
  expressions.each do |expression|
348
599
  actual_indent = lines[expression.range.begin][/^\s*/].to_s.length
349
- errors << "#{expression.type} call on line #{expression.range.begin + 1} is conditional or nested" unless actual_indent == target_indent
600
+ unverifiable.("#{expression.type} call on line #{expression.range.begin + 1} is conditional or nested") unless actual_indent == target_indent
350
601
  end
351
602
  stylesheets.each do |expression|
352
- errors << "stylesheet call on line #{expression.range.begin + 1} has dynamic assets" if expression.dynamic
603
+ unverifiable.("stylesheet call on line #{expression.range.begin + 1} has dynamic assets") if expression.dynamic
353
604
  if (expression.assets & MANAGED_STYLESHEETS).any? && (expression.assets - MANAGED_STYLESHEETS).any?
605
+ # Doctor can still read the order; only the installer must stay out.
354
606
  errors << "stylesheet call on line #{expression.range.begin + 1} combines custom and canonical assets"
355
607
  end
356
608
  end
357
609
 
358
610
  head_contents = head_range ? lines[head_range].join : ""
359
611
  if layout_path.extname == ".erb" && head_contents.match?(/<%(?![=%#])/)
360
- errors << "head contains conditional or executable ERB"
612
+ unverifiable.("head contains conditional or executable ERB")
361
613
  end
362
614
  if head_contents.match?(/<link\b[^>]*\brel=["']stylesheet["']/i)
363
- errors << "head contains a custom stylesheet link"
615
+ unverifiable.("head contains a custom stylesheet link")
364
616
  end
365
617
 
366
- LayoutAnalysis.new(head_range: head_range || (0..0), stylesheets:, bootstraps:, errors: errors.uniq)
618
+ LayoutAnalysis.new(
619
+ head_range: head_range || (0..0),
620
+ stylesheets:,
621
+ bootstraps:,
622
+ errors: errors.uniq,
623
+ uninspectable: uninspectable.uniq,
624
+ defects: defects.uniq
625
+ )
367
626
  end
368
627
 
369
628
  def erb_head_range(contents)
@@ -238,8 +238,12 @@ module NitroKit
238
238
 
239
239
  attr_reader :application_root
240
240
 
241
- def initialize(application_root)
241
+ # retained_dependencies maps a VENDORED_MODULES package to the documented
242
+ # reason the application still uses it. Those findings become :retained
243
+ # instead of :unresolved.
244
+ def initialize(application_root, retained_dependencies: {})
242
245
  @application_root = Pathname.new(application_root)
246
+ @retained_dependencies = retained_dependencies
243
247
  end
244
248
 
245
249
  def categories
@@ -299,7 +303,8 @@ module NitroKit
299
303
 
300
304
  def vendored_dependencies
301
305
  findings = application_root.glob("vendor/javascript/{@floating-ui--*,@github--combobox-nav*}.js").map do |path|
302
- Finding.new(
306
+ name = VENDORED_MODULES.keys.find { path.basename.to_s.start_with?(_1.sub("/", "--")) }
307
+ retained_finding(name, relative(path)) || Finding.new(
303
308
  status: :unresolved,
304
309
  path: relative(path),
305
310
  guidance: "delete the vendored 1.x runtime after removing copied Nitro controllers"
@@ -311,7 +316,10 @@ module NitroKit
311
316
  next if line.lstrip.start_with?("#", "//")
312
317
 
313
318
  VENDORED_MODULES.each do |name, guidance|
314
- findings << Finding.new(status: :unresolved, path: location(path, line_number), guidance:) if line.include?(name)
319
+ next unless line.include?(name)
320
+
321
+ findings << (retained_finding(name, location(path, line_number)) ||
322
+ Finding.new(status: :unresolved, path: location(path, line_number), guidance:))
315
323
  end
316
324
  end
317
325
  end
@@ -319,6 +327,11 @@ module NitroKit
319
327
  findings.uniq { [ _1.path, _1.guidance ] }
320
328
  end
321
329
 
330
+ def retained_finding(name, path)
331
+ reason = @retained_dependencies[name]
332
+ Finding.new(status: :retained, path:, guidance: "#{name}: #{reason}") if reason
333
+ end
334
+
322
335
  def application_button_treatments
323
336
  return [] unless application_stylesheets.any? { _1.read.match?(BUTTON_TREATMENT_DEFINITION) }
324
337
 
@@ -420,6 +433,8 @@ module NitroKit
420
433
  guidance = case status
421
434
  when :application_owned
422
435
  "preserve the behavior under an application namespace; do not keep a Nitro shadow"
436
+ when :retained
437
+ "documented exceptions in config/nitro_kit/doctor.yml; remove each entry with the code that still needs it"
423
438
  else
424
439
  "apply the per-file replacement or removal listed in the category above"
425
440
  end
@@ -1,3 +1,3 @@
1
1
  module NitroKit
2
- VERSION = "2.0.0.beta.3"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -13,9 +13,9 @@ module Rails
13
13
  say JSON.pretty_generate(checks.map { { status: _1.status, label: _1.label, detail: _1.detail } })
14
14
  else
15
15
  checks.each do |check|
16
- color = { pass: :green, warn: :yellow, fail: :red }.fetch(check.status)
17
- say_status(check.status.to_s.upcase, "#{check.label}: #{check.detail}", color)
16
+ say_status(check.status.to_s.upcase, "#{check.label}: #{check.detail}", NitroKit::Installation::STATUS_COLORS.fetch(check.status))
18
17
  end
18
+ say NitroKit::Installation.summary(checks)
19
19
  end
20
20
 
21
21
  exit 1 if checks.any? { _1.status == :fail }