@sdxc/kit 2026.10.16 → 2026.10.20

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 (358) hide show
  1. package/README.md +391 -20
  2. package/changelog.jsonl +1160 -1035
  3. package/config.schema.json +47 -1
  4. package/dist/author.d.ts +36 -0
  5. package/dist/author.js +107 -0
  6. package/dist/cli.js +12 -0
  7. package/dist/commands/create.js +9 -4
  8. package/dist/commands/deploy.d.ts +23 -0
  9. package/dist/commands/deploy.js +167 -0
  10. package/dist/commands/destroy.d.ts +22 -0
  11. package/dist/commands/destroy.js +92 -0
  12. package/dist/commands/doctor.d.ts +26 -0
  13. package/dist/commands/doctor.js +65 -0
  14. package/dist/commands/initializers.d.ts +16 -0
  15. package/dist/commands/initializers.js +23 -0
  16. package/dist/commands/make.d.ts +72 -6
  17. package/dist/commands/make.js +127 -19
  18. package/dist/commands/middleware.d.ts +16 -0
  19. package/dist/commands/middleware.js +21 -0
  20. package/dist/commands/models.d.ts +18 -0
  21. package/dist/commands/models.js +29 -0
  22. package/dist/commands/notes.d.ts +17 -0
  23. package/dist/commands/notes.js +27 -0
  24. package/dist/commands/routes.d.ts +25 -0
  25. package/dist/commands/routes.js +50 -0
  26. package/dist/commands/run.d.ts +18 -2
  27. package/dist/commands/run.js +35 -12
  28. package/dist/commands/scaffold.d.ts +29 -0
  29. package/dist/commands/scaffold.js +33 -0
  30. package/dist/commands/schedule.d.ts +16 -0
  31. package/dist/commands/schedule.js +21 -0
  32. package/dist/commands/stats.d.ts +16 -0
  33. package/dist/commands/stats.js +21 -0
  34. package/dist/commands/ui/update.d.ts +6 -3
  35. package/dist/commands/ui/update.js +24 -7
  36. package/dist/commands/upgrade.d.ts +3 -1
  37. package/dist/commands/upgrade.js +88 -23
  38. package/dist/config.d.ts +18 -0
  39. package/dist/config.js +28 -1
  40. package/dist/contract.d.ts +97 -3
  41. package/dist/contract.js +360 -26
  42. package/dist/create/templates.d.ts +8 -1
  43. package/dist/create/templates.js +26 -2
  44. package/dist/dependencies.d.ts +4 -1
  45. package/dist/dependencies.js +13 -1
  46. package/dist/deploy/plan.d.ts +49 -0
  47. package/dist/deploy/plan.js +68 -0
  48. package/dist/destroy.d.ts +40 -0
  49. package/dist/destroy.js +311 -0
  50. package/dist/doctor/check.d.ts +71 -0
  51. package/dist/doctor/check.js +53 -0
  52. package/dist/doctor/checks.d.ts +23 -0
  53. package/dist/doctor/checks.js +68 -0
  54. package/dist/doctor/define.d.ts +59 -0
  55. package/dist/doctor/define.js +16 -0
  56. package/dist/doctor/emails.d.ts +18 -0
  57. package/dist/doctor/emails.js +243 -0
  58. package/dist/doctor/env.d.ts +26 -0
  59. package/dist/doctor/env.js +88 -0
  60. package/dist/doctor/files.d.ts +14 -0
  61. package/dist/doctor/files.js +34 -0
  62. package/dist/doctor/fixture.d.ts +23 -0
  63. package/dist/doctor/fixture.js +46 -0
  64. package/dist/doctor/install.d.ts +17 -0
  65. package/dist/doctor/install.js +37 -0
  66. package/dist/doctor/installed.d.ts +11 -0
  67. package/dist/doctor/installed.js +79 -0
  68. package/dist/doctor/layout.d.ts +23 -0
  69. package/dist/doctor/layout.js +83 -0
  70. package/dist/doctor/migrations.d.ts +16 -0
  71. package/dist/doctor/migrations.js +96 -0
  72. package/dist/doctor/models.d.ts +13 -0
  73. package/dist/doctor/models.js +69 -0
  74. package/dist/doctor/pins.d.ts +15 -0
  75. package/dist/doctor/pins.js +79 -0
  76. package/dist/doctor/project.d.ts +58 -0
  77. package/dist/doctor/project.js +261 -0
  78. package/dist/doctor/remix.d.ts +14 -0
  79. package/dist/doctor/remix.js +44 -0
  80. package/dist/doctor/routes.d.ts +11 -0
  81. package/dist/doctor/routes.js +49 -0
  82. package/dist/doctor/typegen.d.ts +13 -0
  83. package/dist/doctor/typegen.js +57 -0
  84. package/dist/doctor/ui.d.ts +14 -0
  85. package/dist/doctor/ui.js +51 -0
  86. package/dist/init.d.ts +5 -3
  87. package/dist/init.js +15 -7
  88. package/dist/initializers.d.ts +25 -0
  89. package/dist/initializers.js +89 -0
  90. package/dist/lock.d.ts +2 -2
  91. package/dist/make/actions.d.ts +23 -0
  92. package/dist/make/actions.js +82 -0
  93. package/dist/make/declare.d.ts +32 -4
  94. package/dist/make/declare.js +405 -27
  95. package/dist/make/email.d.ts +23 -0
  96. package/dist/make/email.js +111 -0
  97. package/dist/make/from-fields.d.ts +30 -0
  98. package/dist/make/from-fields.js +162 -0
  99. package/dist/make/from-model.d.ts +39 -0
  100. package/dist/make/from-model.js +161 -0
  101. package/dist/make/generate.d.ts +16 -5
  102. package/dist/make/generate.js +43 -14
  103. package/dist/make/guard.d.ts +35 -0
  104. package/dist/make/guard.js +73 -0
  105. package/dist/make/imports.d.ts +6 -0
  106. package/dist/make/imports.js +19 -0
  107. package/dist/make/index.d.ts +47 -4
  108. package/dist/make/index.js +287 -25
  109. package/dist/make/kinds.d.ts +31 -3
  110. package/dist/make/kinds.js +82 -9
  111. package/dist/make/mount.d.ts +25 -0
  112. package/dist/make/mount.js +135 -0
  113. package/dist/make/schema-diff.d.ts +58 -0
  114. package/dist/make/schema-diff.js +609 -0
  115. package/dist/make/schema.d.ts +76 -0
  116. package/dist/make/schema.js +206 -0
  117. package/dist/make/stubs.d.ts +7 -5
  118. package/dist/make/stubs.js +16 -5
  119. package/dist/make/test.d.ts +43 -0
  120. package/dist/make/test.js +149 -0
  121. package/dist/make/trigger.d.ts +31 -0
  122. package/dist/make/trigger.js +163 -0
  123. package/dist/models.d.ts +42 -0
  124. package/dist/models.js +149 -0
  125. package/dist/notes.d.ts +28 -0
  126. package/dist/notes.js +66 -0
  127. package/dist/reference.d.ts +27 -0
  128. package/dist/reference.js +103 -0
  129. package/dist/releases.d.ts +9 -0
  130. package/dist/releases.js +29 -8
  131. package/dist/routes/chains.d.ts +34 -0
  132. package/dist/routes/chains.js +95 -0
  133. package/dist/routes/filter.d.ts +53 -0
  134. package/dist/routes/filter.js +147 -0
  135. package/dist/routes/format.d.ts +23 -0
  136. package/dist/routes/format.js +123 -0
  137. package/dist/routes/helpers.d.ts +21 -0
  138. package/dist/routes/helpers.js +165 -0
  139. package/dist/routes/index.d.ts +56 -0
  140. package/dist/routes/index.js +167 -0
  141. package/dist/routes/modules.d.ts +116 -0
  142. package/dist/routes/modules.js +235 -0
  143. package/dist/routes/parse.d.ts +161 -0
  144. package/dist/routes/parse.js +621 -0
  145. package/dist/routes/routers.d.ts +69 -0
  146. package/dist/routes/routers.js +327 -0
  147. package/dist/scaffold/fields.d.ts +129 -0
  148. package/dist/scaffold/fields.js +421 -0
  149. package/dist/scaffold/index.d.ts +37 -0
  150. package/dist/scaffold/index.js +613 -0
  151. package/dist/scaffold/render.d.ts +51 -0
  152. package/dist/scaffold/render.js +332 -0
  153. package/dist/schedule.d.ts +45 -0
  154. package/dist/schedule.js +124 -0
  155. package/dist/stats.d.ts +37 -0
  156. package/dist/stats.js +126 -0
  157. package/dist/testing.d.ts +12 -2
  158. package/dist/testing.js +22 -3
  159. package/dist/ui/commands.d.ts +10 -3
  160. package/dist/ui/commands.js +85 -15
  161. package/dist/ui/registry.d.ts +8 -8
  162. package/dist/upgrade/agents.d.ts +49 -0
  163. package/dist/upgrade/agents.js +110 -0
  164. package/dist/upgrade/changelog.d.ts +2 -2
  165. package/dist/upgrade/project.d.ts +4 -0
  166. package/dist/upgrade/project.js +11 -1
  167. package/dist/upgrade/prompt.d.ts +11 -0
  168. package/dist/upgrade/prompt.js +50 -7
  169. package/package.json +6 -4
  170. package/registry/ui/alert-dialog.json +2 -2
  171. package/registry/ui/attachment.json +2 -2
  172. package/registry/ui/calendar.json +2 -2
  173. package/registry/ui/color-picker.json +2 -2
  174. package/registry/ui/command.json +2 -2
  175. package/registry/ui/date-picker.json +2 -2
  176. package/registry/ui/date-range-picker.json +2 -2
  177. package/registry/ui/dialog.json +2 -2
  178. package/registry/ui/file-trigger.json +2 -2
  179. package/registry/ui/heading-scope.json +2 -2
  180. package/registry/ui/message-scroller.json +2 -2
  181. package/registry/ui/number-field.json +2 -2
  182. package/registry/ui/range-calendar.json +2 -2
  183. package/registry/ui/resizable.json +2 -2
  184. package/registry/ui/select.json +2 -2
  185. package/registry/ui/shared-element.json +2 -2
  186. package/stubs/command.stub +4 -0
  187. package/stubs/command.test.stub +3 -0
  188. package/stubs/controller.api.resource.stub +23 -0
  189. package/stubs/controller.api.stub +21 -0
  190. package/stubs/controller.api.test.stub +18 -0
  191. package/stubs/controller.form.stub +40 -10
  192. package/stubs/controller.form.test.stub +61 -0
  193. package/stubs/controller.resource.form.stub +67 -0
  194. package/stubs/controller.resource.stub +28 -0
  195. package/stubs/controller.stub +15 -8
  196. package/stubs/controller.test.stub +3 -0
  197. package/stubs/email.stub +15 -38
  198. package/stubs/email.test.stub +12 -7
  199. package/stubs/factory.stub +4 -1
  200. package/stubs/initializer.stub +2 -0
  201. package/stubs/initializer.test.stub +3 -0
  202. package/stubs/job.cron.stub +4 -0
  203. package/stubs/job.stub +4 -0
  204. package/stubs/job.test.stub +3 -0
  205. package/stubs/mcp.resource.stub +3 -0
  206. package/stubs/mcp.stub +3 -0
  207. package/stubs/mcp.test.stub +3 -0
  208. package/stubs/middleware.stub +6 -1
  209. package/stubs/middleware.test.stub +3 -0
  210. package/stubs/model.stub +12 -3
  211. package/stubs/model.test.stub +3 -0
  212. package/stubs/policy.test.stub +36 -7
  213. package/stubs/scaffold.api.create.stub +34 -0
  214. package/stubs/scaffold.api.create.test.stub +37 -0
  215. package/stubs/scaffold.api.destroy.stub +34 -0
  216. package/stubs/scaffold.api.destroy.test.stub +44 -0
  217. package/stubs/scaffold.api.index.stub +23 -0
  218. package/stubs/scaffold.api.index.test.stub +31 -0
  219. package/stubs/scaffold.api.show.stub +27 -0
  220. package/stubs/scaffold.api.show.test.stub +41 -0
  221. package/stubs/scaffold.api.update.stub +44 -0
  222. package/stubs/scaffold.api.update.test.stub +46 -0
  223. package/stubs/scaffold.command.create.stub +22 -0
  224. package/stubs/scaffold.command.create.test.stub +30 -0
  225. package/stubs/scaffold.command.delete.stub +20 -0
  226. package/stubs/scaffold.command.delete.test.stub +39 -0
  227. package/stubs/scaffold.command.list.stub +18 -0
  228. package/stubs/scaffold.command.list.test.stub +31 -0
  229. package/stubs/scaffold.command.show.stub +19 -0
  230. package/stubs/scaffold.command.show.test.stub +37 -0
  231. package/stubs/scaffold.controller.destroy.stub +35 -0
  232. package/stubs/scaffold.controller.destroy.test.stub +65 -0
  233. package/stubs/scaffold.controller.edit.stub +97 -0
  234. package/stubs/scaffold.controller.edit.test.stub +91 -0
  235. package/stubs/scaffold.controller.index.stub +55 -0
  236. package/stubs/scaffold.controller.index.test.stub +32 -0
  237. package/stubs/scaffold.controller.new.stub +70 -0
  238. package/stubs/scaffold.controller.new.test.stub +81 -0
  239. package/stubs/scaffold.controller.show.stub +59 -0
  240. package/stubs/scaffold.controller.show.test.stub +43 -0
  241. package/stubs/scaffold.factory.stub +16 -0
  242. package/stubs/scaffold.form.stub +75 -0
  243. package/stubs/scaffold.mcp.create.stub +24 -0
  244. package/stubs/scaffold.mcp.create.test.stub +36 -0
  245. package/stubs/scaffold.mcp.delete.stub +31 -0
  246. package/stubs/scaffold.mcp.delete.test.stub +43 -0
  247. package/stubs/scaffold.mcp.get.stub +21 -0
  248. package/stubs/scaffold.mcp.get.test.stub +31 -0
  249. package/stubs/scaffold.mcp.list.stub +23 -0
  250. package/stubs/scaffold.mcp.list.test.stub +25 -0
  251. package/stubs/scaffold.mcp.update.stub +37 -0
  252. package/stubs/scaffold.mcp.update.test.stub +40 -0
  253. package/stubs/scaffold.migration.stub +2 -0
  254. package/stubs/scaffold.model.stub +35 -0
  255. package/stubs/scaffold.model.test.stub +25 -0
  256. package/stubs/scaffold.test-database.stub +33 -0
  257. package/stubs/scaffold.test-mcp.stub +92 -0
  258. package/stubs/scaffold.validator.stub +18 -0
  259. package/stubs/scaffold.validator.test.stub +26 -0
  260. package/stubs/service.stub +4 -0
  261. package/stubs/service.test.stub +3 -0
  262. package/stubs/validator.stub +3 -0
  263. package/stubs/validator.test.stub +3 -0
  264. package/templates/app/.env.example +16 -0
  265. package/templates/app/AGENTS.md +163 -0
  266. package/templates/app/CLAUDE.md +1 -0
  267. package/templates/app/README.md +79 -37
  268. package/templates/app/app/commands/about.test.ts +1 -1
  269. package/templates/app/app/commands/console.test.ts +26 -0
  270. package/templates/app/app/commands/console.ts +19 -0
  271. package/templates/app/app/commands/db/console.ts +6 -0
  272. package/templates/app/app/commands/db/fresh.test.ts +57 -0
  273. package/templates/app/app/commands/db/fresh.ts +37 -0
  274. package/templates/app/app/commands/db/migrate.test.ts +46 -0
  275. package/templates/app/app/commands/db/migrate.ts +88 -0
  276. package/templates/app/app/commands/db/prepare.test.ts +39 -0
  277. package/templates/app/app/commands/db/prepare.ts +35 -0
  278. package/templates/app/app/commands/db/seed.test.ts +38 -0
  279. package/templates/app/app/commands/db/seed.ts +26 -0
  280. package/templates/app/app/commands/deploy.test.ts +34 -0
  281. package/templates/app/app/commands/deploy.ts +18 -0
  282. package/templates/app/app/commands/emails/preview.test.tsx +63 -0
  283. package/templates/app/app/commands/emails/preview.ts +24 -0
  284. package/templates/app/app/commands/index.ts +72 -1
  285. package/templates/app/app/commands/typegen.test.ts +17 -0
  286. package/templates/app/app/commands/typegen.ts +16 -0
  287. package/templates/app/app/emails/index.ts +10 -0
  288. package/templates/app/app/http/controllers/api/health.tsx +15 -0
  289. package/templates/app/app/http/controllers/api/not-found.tsx +16 -0
  290. package/templates/app/app/http/controllers/api/openapi.tsx +17 -0
  291. package/templates/app/app/http/controllers/home.tsx +21 -13
  292. package/templates/app/app/http/controllers/mcp.tsx +16 -0
  293. package/templates/app/app/http/controllers/not-found.tsx +23 -18
  294. package/templates/app/app/http/controllers/robots.test.ts +18 -0
  295. package/templates/app/app/http/controllers/robots.ts +24 -0
  296. package/templates/app/app/http/controllers/sitemap.test.ts +28 -0
  297. package/templates/app/app/http/controllers/sitemap.ts +25 -0
  298. package/templates/app/app/http/middleware/access.test.ts +43 -0
  299. package/templates/app/app/http/middleware/access.ts +41 -0
  300. package/templates/app/app/http/middleware/api.ts +19 -0
  301. package/templates/app/app/http/middleware/page.test.ts +43 -0
  302. package/templates/app/app/http/middleware/page.ts +51 -0
  303. package/templates/app/app/http/middleware/server-timing.test.ts +15 -0
  304. package/templates/app/app/http/middleware/server-timing.ts +42 -0
  305. package/templates/app/app/initializers/assets.ts +1 -1
  306. package/templates/app/app/initializers/captcha.ts +11 -0
  307. package/templates/app/app/initializers/cli.ts +68 -2
  308. package/templates/app/app/initializers/database.test.ts +18 -0
  309. package/templates/app/app/initializers/database.ts +18 -0
  310. package/templates/app/app/initializers/dispatcher.ts +26 -0
  311. package/templates/app/app/initializers/honeypot.ts +11 -0
  312. package/templates/app/app/initializers/i18n.test.ts +16 -0
  313. package/templates/app/app/initializers/i18n.ts +28 -0
  314. package/templates/app/app/initializers/local-database.test.ts +33 -0
  315. package/templates/app/app/initializers/local-database.ts +53 -0
  316. package/templates/app/app/initializers/mail-transport.test.ts +27 -0
  317. package/templates/app/app/initializers/mail-transport.ts +26 -0
  318. package/templates/app/app/initializers/mail.test.ts +27 -0
  319. package/templates/app/app/initializers/mail.ts +19 -0
  320. package/templates/app/app/initializers/mcp.ts +1 -1
  321. package/templates/app/app/initializers/openapi.ts +21 -0
  322. package/templates/app/app/initializers/router.test.ts +68 -0
  323. package/templates/app/app/initializers/router.tsx +81 -25
  324. package/templates/app/app/initializers/seo.ts +15 -0
  325. package/templates/app/app/initializers/session.test.ts +34 -0
  326. package/templates/app/app/initializers/session.ts +29 -0
  327. package/templates/app/app/initializers/spam.ts +10 -0
  328. package/templates/app/app/jobs/email.test.tsx +70 -0
  329. package/templates/app/app/jobs/email.ts +16 -0
  330. package/templates/app/app/jobs/index.ts +6 -2
  331. package/templates/app/app/models/index.ts +10 -0
  332. package/templates/app/app/policies/abilities.ts +13 -0
  333. package/templates/app/app/policies/policy.test.ts +15 -0
  334. package/templates/app/app/policies/policy.ts +30 -0
  335. package/templates/app/app/services/commands.ts +30 -0
  336. package/templates/app/app/services/migrations.test.ts +92 -0
  337. package/templates/app/app/services/migrations.ts +117 -0
  338. package/templates/app/app/test/cloudflare-workers.ts +25 -0
  339. package/templates/app/app/test/local-database.ts +67 -0
  340. package/templates/app/app/test/session.ts +28 -0
  341. package/templates/app/bootstrap/cli.ts +1 -1
  342. package/templates/app/bootstrap/console.ts +13 -0
  343. package/templates/app/bootstrap/worker.ts +4 -4
  344. package/templates/app/cloudflare.config.ts +30 -2
  345. package/templates/app/config/constants.ts +19 -0
  346. package/templates/app/config/problems.ts +24 -0
  347. package/templates/app/config/security-policy.ts +34 -0
  348. package/templates/app/config/security-txt.ts +28 -0
  349. package/templates/app/database/migrations/.gitkeep +0 -0
  350. package/templates/app/database/seed.ts +12 -0
  351. package/templates/app/package.json +37 -6
  352. package/templates/app/resources/layouts/document.tsx +28 -7
  353. package/templates/app/resources/locales/en.json +10 -0
  354. package/templates/app/routes/api.ts +29 -0
  355. package/templates/app/routes/web.ts +6 -4
  356. package/templates/app/vite.config.ts +4 -0
  357. package/stubs/policy.stub +0 -13
  358. package/templates/app/config/router-context.d.ts +0 -20
@@ -0,0 +1,65 @@
1
+ /**
2
+ * The `sdxc doctor` handler: runs every built-in check and every check the project defines, and
3
+ * prints one line per check, or one JSON document with `--json`, so a person and an agent read
4
+ * the same verdict. It changes nothing; each warning and failure carries the command that fixes it.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { createCommand, exit, success } from "@sdxc/cli";
10
+ import { failure, isFailure, wrap } from "@sdxc/result";
11
+ import { SDXC_COMMANDS } from "../contract.js";
12
+ import { createDoctorContext, runChecks } from "../doctor/check.js";
13
+ import { CHECKS, formatJSON, formatText, hasFailure } from "../doctor/checks.js";
14
+ import { runProjectChecks, selects } from "../doctor/project.js";
15
+ import { packageRoot, project } from "../middleware.js";
16
+ import { lockFileAtOrAbove, packageManager } from "../package-manager.js";
17
+ import { listRoutes } from "../routes/index.js";
18
+ import { readManifest } from "../upgrade/project.js";
19
+ /**
20
+ * Exits 1 when any check fails; a warning or a skipped check leaves the exit code at 0. A name
21
+ * in `--only` or `--skip` that no check has ends the run with the names there are.
22
+ */
23
+ export default createCommand(SDXC_COMMANDS.doctor, {
24
+ middleware: [project(), packageRoot()],
25
+ /** Prints the report to stdout, in the form `--json` picks. */
26
+ async handler(ctx) {
27
+ let root = ctx.project.root;
28
+ let read = await readManifest(root);
29
+ if (isFailure(read))
30
+ return read;
31
+ let manager = await packageManager({
32
+ declared: read.data.manifest.packageManager,
33
+ findLockFile: lockFileAtOrAbove(root),
34
+ });
35
+ let context = createDoctorContext({
36
+ root,
37
+ manifest: read.data.manifest,
38
+ config: ctx.project.config,
39
+ manager,
40
+ packageRoot: ctx.packageRoot,
41
+ signal: ctx.signal,
42
+ });
43
+ let selection = { only: ctx.flags.only ?? [], skip: ctx.flags.skip ?? [] };
44
+ let builtIn = CHECKS.map((check) => check.name);
45
+ let reports = await runChecks(CHECKS.filter((check) => selects(selection, check.name)), context);
46
+ let raw = wrap(() => JSON.parse(read.data.text));
47
+ let own = await runProjectChecks(ctx, {
48
+ root,
49
+ runtime: manager.name === "bun" ? "bun" : "node",
50
+ manifest: isFailure(raw) ? {} : raw.data,
51
+ config: ctx.project.config,
52
+ routes: async () => (await listRoutes(root)).routes,
53
+ builtIn,
54
+ selection,
55
+ });
56
+ let known = new Set([...builtIn, ...own.names]);
57
+ let unknown = [...selection.only, ...selection.skip].filter((name) => !known.has(name));
58
+ if (unknown.length > 0) {
59
+ return failure(new Error(`No check is named ${unknown.join(", ")}; sdxc doctor runs ${[...known].join(", ")}`));
60
+ }
61
+ reports.push(...own.reports);
62
+ ctx.stdout(ctx.flags.json ? formatJSON(reports) : formatText(reports));
63
+ return hasFailure(reports) ? exit(1) : success();
64
+ },
65
+ });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The `sdxc initializers` handler: prints every initializer with what it exports and the
3
+ * factories that build it, as a table, or as JSON for an agent.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ /** Reads `app/initializers/` and prints what it found. */
9
+ declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
10
+ readonly json: import("@sdxc/cli").Flag<boolean>;
11
+ }>, readonly [import("@sdxc/cli").CommandMiddleware<{
12
+ key: typeof import("../middleware.js").CurrentProject;
13
+ value: import("../middleware.js").Project;
14
+ property: "project";
15
+ }>]>;
16
+ export default _default;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The `sdxc initializers` handler: prints every initializer with what it exports and the
3
+ * factories that build it, as a table, or as JSON for an agent.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ import { createCommand, success } from "@sdxc/cli";
9
+ import { SDXC_COMMANDS } from "../contract.js";
10
+ import { formatInitializers, listInitializers } from "../initializers.js";
11
+ import { project } from "../middleware.js";
12
+ /** Reads `app/initializers/` and prints what it found. */
13
+ export default createCommand(SDXC_COMMANDS.initializers, {
14
+ middleware: [project()],
15
+ /** Always succeeds once the project is found; an empty folder says so. */
16
+ async handler(ctx) {
17
+ let initializers = await listInitializers(ctx.project.root);
18
+ ctx.stdout(ctx.flags.json
19
+ ? `${JSON.stringify(initializers, null, 2)}\n`
20
+ : formatInitializers(initializers));
21
+ return success();
22
+ },
23
+ });
@@ -10,11 +10,14 @@
10
10
  export declare const controller: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
11
11
  readonly name: import("@sdxc/cli").Argument<string>;
12
12
  }, {
13
- readonly method: import("@sdxc/cli").ValueFlag<"delete" | "get" | "post" | "put" | "patch" | "form", true, false, false>;
13
+ readonly method: import("@sdxc/cli").ValueFlag<"delete" | "get" | "post" | "put" | "patch" | "form", false, false, false>;
14
14
  readonly path: import("@sdxc/cli").ValueFlag<string, false, false, false>;
15
15
  readonly routes: import("@sdxc/cli").ValueFlag<string, false, false, false>;
16
+ readonly resource: import("@sdxc/cli").ValueFlag<string, false, false, false>;
17
+ readonly actions: import("@sdxc/cli").ValueFlag<"index" | "all" | "new" | "show" | "edit" | "create" | "update" | "destroy", false, true, false>;
16
18
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
17
19
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
20
+ readonly force: import("@sdxc/cli").Flag<boolean>;
18
21
  }>, readonly [import("@sdxc/cli").CommandMiddleware<{
19
22
  key: typeof import("../middleware.js").CurrentProject;
20
23
  value: import("../middleware.js").Project;
@@ -31,6 +34,7 @@ export declare const job: import("@sdxc/cli").CommandAction<import("@sdxc/cli").
31
34
  readonly cron: import("@sdxc/cli").ValueFlag<string, false, false, false>;
32
35
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
33
36
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
37
+ readonly force: import("@sdxc/cli").Flag<boolean>;
34
38
  }>, readonly [import("@sdxc/cli").CommandMiddleware<{
35
39
  key: typeof import("../middleware.js").CurrentProject;
36
40
  value: import("../middleware.js").Project;
@@ -47,6 +51,7 @@ export declare const mcp: import("@sdxc/cli").CommandAction<import("@sdxc/cli").
47
51
  readonly resource: import("@sdxc/cli").Flag<boolean>;
48
52
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
49
53
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
54
+ readonly force: import("@sdxc/cli").Flag<boolean>;
50
55
  }>, readonly [import("@sdxc/cli").CommandMiddleware<{
51
56
  key: typeof import("../middleware.js").CurrentProject;
52
57
  value: import("../middleware.js").Project;
@@ -59,8 +64,10 @@ export declare const mcp: import("@sdxc/cli").CommandAction<import("@sdxc/cli").
59
64
  /** `sdxc make migration`, numbered within its chain. */
60
65
  export declare const migration: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
61
66
  readonly name: import("@sdxc/cli").Argument<string>;
67
+ readonly fields: import("@sdxc/cli").Argument<string[]>;
62
68
  }, {
63
69
  readonly chain: import("@sdxc/cli").ValueFlag<string, false, false, false>;
70
+ readonly fromModel: import("@sdxc/cli").ValueFlag<string, false, false, false>;
64
71
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
65
72
  }>, readonly [import("@sdxc/cli").CommandMiddleware<{
66
73
  key: typeof import("../middleware.js").CurrentProject;
@@ -76,6 +83,7 @@ export declare const factory: import("@sdxc/cli").CommandAction<import("@sdxc/cl
76
83
  readonly name: import("@sdxc/cli").Argument<string>;
77
84
  }, {
78
85
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
86
+ readonly force: import("@sdxc/cli").Flag<boolean>;
79
87
  }>, readonly [import("@sdxc/cli").CommandMiddleware<{
80
88
  key: typeof import("../middleware.js").CurrentProject;
81
89
  value: import("../middleware.js").Project;
@@ -85,12 +93,14 @@ export declare const factory: import("@sdxc/cli").CommandAction<import("@sdxc/cl
85
93
  value: string;
86
94
  property: "packageRoot";
87
95
  }>]>;
88
- /** `sdxc make middleware`. */
96
+ /** `sdxc make middleware`, which mounts the middleware on a chain under `--mount`. */
89
97
  export declare const middleware: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
90
98
  readonly name: import("@sdxc/cli").Argument<string>;
91
99
  }, {
100
+ readonly mount: import("@sdxc/cli").ValueFlag<string, false, false, false>;
92
101
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
93
102
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
103
+ readonly force: import("@sdxc/cli").Flag<boolean>;
94
104
  }>, readonly [import("@sdxc/cli").CommandMiddleware<{
95
105
  key: typeof import("../middleware.js").CurrentProject;
96
106
  value: import("../middleware.js").Project;
@@ -106,6 +116,7 @@ export declare const validator: import("@sdxc/cli").CommandAction<import("@sdxc/
106
116
  }, {
107
117
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
108
118
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
119
+ readonly force: import("@sdxc/cli").Flag<boolean>;
109
120
  }>, readonly [import("@sdxc/cli").CommandMiddleware<{
110
121
  key: typeof import("../middleware.js").CurrentProject;
111
122
  value: import("../middleware.js").Project;
@@ -115,12 +126,16 @@ export declare const validator: import("@sdxc/cli").CommandAction<import("@sdxc/
115
126
  value: string;
116
127
  property: "packageRoot";
117
128
  }>]>;
118
- /** `sdxc make model`. */
129
+ /** `sdxc make model`, with a column per field it is given, its migration and its factory. */
119
130
  export declare const model: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
120
131
  readonly name: import("@sdxc/cli").Argument<string>;
132
+ readonly fields: import("@sdxc/cli").Argument<string[]>;
121
133
  }, {
134
+ readonly chain: import("@sdxc/cli").ValueFlag<string, false, false, false>;
135
+ readonly skip: import("@sdxc/cli").ValueFlag<"migration" | "factory", false, true, false>;
122
136
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
123
137
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
138
+ readonly force: import("@sdxc/cli").Flag<boolean>;
124
139
  }>, readonly [import("@sdxc/cli").CommandMiddleware<{
125
140
  key: typeof import("../middleware.js").CurrentProject;
126
141
  value: import("../middleware.js").Project;
@@ -136,6 +151,7 @@ export declare const service: import("@sdxc/cli").CommandAction<import("@sdxc/cl
136
151
  }, {
137
152
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
138
153
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
154
+ readonly force: import("@sdxc/cli").Flag<boolean>;
139
155
  }>, readonly [import("@sdxc/cli").CommandMiddleware<{
140
156
  key: typeof import("../middleware.js").CurrentProject;
141
157
  value: import("../middleware.js").Project;
@@ -151,6 +167,7 @@ export declare const policy: import("@sdxc/cli").CommandAction<import("@sdxc/cli
151
167
  }, {
152
168
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
153
169
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
170
+ readonly force: import("@sdxc/cli").Flag<boolean>;
154
171
  }>, readonly [import("@sdxc/cli").CommandMiddleware<{
155
172
  key: typeof import("../middleware.js").CurrentProject;
156
173
  value: import("../middleware.js").Project;
@@ -166,6 +183,7 @@ export declare const initializer: import("@sdxc/cli").CommandAction<import("@sdx
166
183
  }, {
167
184
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
168
185
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
186
+ readonly force: import("@sdxc/cli").Flag<boolean>;
169
187
  }>, readonly [import("@sdxc/cli").CommandMiddleware<{
170
188
  key: typeof import("../middleware.js").CurrentProject;
171
189
  value: import("../middleware.js").Project;
@@ -176,11 +194,14 @@ export declare const initializer: import("@sdxc/cli").CommandAction<import("@sdx
176
194
  property: "packageRoot";
177
195
  }>]>;
178
196
  /** `sdxc make email`. */
197
+ /** `sdxc make email`, which declares the email with its fields as props and maps its template. */
179
198
  export declare const email: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
180
199
  readonly name: import("@sdxc/cli").Argument<string>;
200
+ readonly fields: import("@sdxc/cli").Argument<string[]>;
181
201
  }, {
182
202
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
183
203
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
204
+ readonly force: import("@sdxc/cli").Flag<boolean>;
184
205
  }>, readonly [import("@sdxc/cli").CommandMiddleware<{
185
206
  key: typeof import("../middleware.js").CurrentProject;
186
207
  value: import("../middleware.js").Project;
@@ -196,6 +217,22 @@ export declare const command: import("@sdxc/cli").CommandAction<import("@sdxc/cl
196
217
  }, {
197
218
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
198
219
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
220
+ readonly force: import("@sdxc/cli").Flag<boolean>;
221
+ }>, readonly [import("@sdxc/cli").CommandMiddleware<{
222
+ key: typeof import("../middleware.js").CurrentProject;
223
+ value: import("../middleware.js").Project;
224
+ property: "project";
225
+ }>, import("@sdxc/cli").CommandMiddleware<{
226
+ key: typeof import("../middleware.js").PackageRoot;
227
+ value: string;
228
+ property: "packageRoot";
229
+ }>]>;
230
+ /** `sdxc make test`, which writes the test of an existing file from its kind's test stub. */
231
+ export declare const test: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
232
+ readonly file: import("@sdxc/cli").Argument<string>;
233
+ }, {
234
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
235
+ readonly force: import("@sdxc/cli").Flag<boolean>;
199
236
  }>, readonly [import("@sdxc/cli").CommandMiddleware<{
200
237
  key: typeof import("../middleware.js").CurrentProject;
201
238
  value: import("../middleware.js").Project;
@@ -207,7 +244,7 @@ export declare const command: import("@sdxc/cli").CommandAction<import("@sdxc/cl
207
244
  }>]>;
208
245
  /** `sdxc make stubs`, which copies the built-in stubs of the named kinds, or every kind. */
209
246
  export declare const stubs: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
210
- readonly kinds: import("@sdxc/cli").Argument<import("../make/kinds.js").KindName[]>;
247
+ readonly kinds: import("@sdxc/cli").Argument<(import("../make/kinds.js").KindName | "scaffold")[]>;
211
248
  }, Readonly<Record<string, import("@sdxc/cli").Flag<unknown>>>>, readonly [import("@sdxc/cli").CommandMiddleware<{
212
249
  key: typeof import("../middleware.js").CurrentProject;
213
250
  value: import("../middleware.js").Project;
@@ -231,28 +268,35 @@ export declare const group: import("@sdxc/cli").CommandAction<import("@sdxc/cli"
231
268
  readonly flags: {
232
269
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
233
270
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
271
+ readonly force: import("@sdxc/cli").Flag<boolean>;
234
272
  };
235
273
  readonly tasks: true;
236
274
  readonly controller: import("@sdxc/cli").Command<{
237
275
  readonly name: import("@sdxc/cli").Argument<string>;
238
276
  }, {
239
- readonly method: import("@sdxc/cli").ValueFlag<"delete" | "get" | "post" | "put" | "patch" | "form", true, false, false>;
277
+ readonly method: import("@sdxc/cli").ValueFlag<"delete" | "get" | "post" | "put" | "patch" | "form", false, false, false>;
240
278
  readonly path: import("@sdxc/cli").ValueFlag<string, false, false, false>;
241
279
  readonly routes: import("@sdxc/cli").ValueFlag<string, false, false, false>;
280
+ readonly resource: import("@sdxc/cli").ValueFlag<string, false, false, false>;
281
+ readonly actions: import("@sdxc/cli").ValueFlag<"index" | "all" | "new" | "show" | "edit" | "create" | "update" | "destroy", false, true, false>;
242
282
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
243
283
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
284
+ readonly force: import("@sdxc/cli").Flag<boolean>;
244
285
  }>;
245
286
  readonly middleware: import("@sdxc/cli").Command<{
246
287
  readonly name: import("@sdxc/cli").Argument<string>;
247
288
  }, {
289
+ readonly mount: import("@sdxc/cli").ValueFlag<string, false, false, false>;
248
290
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
249
291
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
292
+ readonly force: import("@sdxc/cli").Flag<boolean>;
250
293
  }>;
251
294
  readonly validator: import("@sdxc/cli").Command<{
252
295
  readonly name: import("@sdxc/cli").Argument<string>;
253
296
  }, {
254
297
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
255
298
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
299
+ readonly force: import("@sdxc/cli").Flag<boolean>;
256
300
  }>;
257
301
  readonly job: import("@sdxc/cli").Command<{
258
302
  readonly name: import("@sdxc/cli").Argument<string>;
@@ -260,47 +304,60 @@ export declare const group: import("@sdxc/cli").CommandAction<import("@sdxc/cli"
260
304
  readonly cron: import("@sdxc/cli").ValueFlag<string, false, false, false>;
261
305
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
262
306
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
307
+ readonly force: import("@sdxc/cli").Flag<boolean>;
263
308
  }>;
264
309
  readonly model: import("@sdxc/cli").Command<{
265
310
  readonly name: import("@sdxc/cli").Argument<string>;
311
+ readonly fields: import("@sdxc/cli").Argument<string[]>;
266
312
  }, {
313
+ readonly chain: import("@sdxc/cli").ValueFlag<string, false, false, false>;
314
+ readonly skip: import("@sdxc/cli").ValueFlag<"migration" | "factory", false, true, false>;
267
315
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
268
316
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
317
+ readonly force: import("@sdxc/cli").Flag<boolean>;
269
318
  }>;
270
319
  readonly migration: import("@sdxc/cli").Command<{
271
320
  readonly name: import("@sdxc/cli").Argument<string>;
321
+ readonly fields: import("@sdxc/cli").Argument<string[]>;
272
322
  }, {
273
323
  readonly chain: import("@sdxc/cli").ValueFlag<string, false, false, false>;
324
+ readonly fromModel: import("@sdxc/cli").ValueFlag<string, false, false, false>;
274
325
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
275
326
  }>;
276
327
  readonly factory: import("@sdxc/cli").Command<{
277
328
  readonly name: import("@sdxc/cli").Argument<string>;
278
329
  }, {
279
330
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
331
+ readonly force: import("@sdxc/cli").Flag<boolean>;
280
332
  }>;
281
333
  readonly service: import("@sdxc/cli").Command<{
282
334
  readonly name: import("@sdxc/cli").Argument<string>;
283
335
  }, {
284
336
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
285
337
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
338
+ readonly force: import("@sdxc/cli").Flag<boolean>;
286
339
  }>;
287
340
  readonly policy: import("@sdxc/cli").Command<{
288
341
  readonly name: import("@sdxc/cli").Argument<string>;
289
342
  }, {
290
343
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
291
344
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
345
+ readonly force: import("@sdxc/cli").Flag<boolean>;
292
346
  }>;
293
347
  readonly initializer: import("@sdxc/cli").Command<{
294
348
  readonly name: import("@sdxc/cli").Argument<string>;
295
349
  }, {
296
350
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
297
351
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
352
+ readonly force: import("@sdxc/cli").Flag<boolean>;
298
353
  }>;
299
354
  readonly email: import("@sdxc/cli").Command<{
300
355
  readonly name: import("@sdxc/cli").Argument<string>;
356
+ readonly fields: import("@sdxc/cli").Argument<string[]>;
301
357
  }, {
302
358
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
303
359
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
360
+ readonly force: import("@sdxc/cli").Flag<boolean>;
304
361
  }>;
305
362
  readonly mcp: import("@sdxc/cli").Command<{
306
363
  readonly name: import("@sdxc/cli").Argument<string>;
@@ -308,15 +365,23 @@ export declare const group: import("@sdxc/cli").CommandAction<import("@sdxc/cli"
308
365
  readonly resource: import("@sdxc/cli").Flag<boolean>;
309
366
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
310
367
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
368
+ readonly force: import("@sdxc/cli").Flag<boolean>;
311
369
  }>;
312
370
  readonly command: import("@sdxc/cli").Command<{
313
371
  readonly name: import("@sdxc/cli").Argument<string>;
314
372
  }, {
315
373
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
316
374
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
375
+ readonly force: import("@sdxc/cli").Flag<boolean>;
376
+ }>;
377
+ readonly test: import("@sdxc/cli").Command<{
378
+ readonly file: import("@sdxc/cli").Argument<string>;
379
+ }, {
380
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
381
+ readonly force: import("@sdxc/cli").Flag<boolean>;
317
382
  }>;
318
383
  readonly stubs: import("@sdxc/cli").Command<{
319
- readonly kinds: import("@sdxc/cli").Argument<import("../make/kinds.js").KindName[]>;
384
+ readonly kinds: import("@sdxc/cli").Argument<(import("../make/kinds.js").KindName | "scaffold")[]>;
320
385
  }, Readonly<Record<string, import("@sdxc/cli").Flag<unknown>>>>;
321
386
  }, "description" | "hidden" | "arguments" | "flags" | "tasks">, {
322
387
  readonly kind: import("@sdxc/cli").Argument<import("../make/kinds.js").KindName>;
@@ -324,6 +389,7 @@ export declare const group: import("@sdxc/cli").CommandAction<import("@sdxc/cli"
324
389
  }, {
325
390
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
326
391
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
392
+ readonly force: import("@sdxc/cli").Flag<boolean>;
327
393
  }>, readonly [import("@sdxc/cli").CommandMiddleware<{
328
394
  key: typeof import("../middleware.js").CurrentProject;
329
395
  value: import("../middleware.js").Project;
@@ -6,11 +6,13 @@
6
6
  * @author [Sergio Xalambrí](https://sergiodxa.com)
7
7
  * @copyright Sergio Xalambrí 2026
8
8
  */
9
- import { createCommand, success } from "@sdxc/cli";
9
+ import { createCommand, success, usage } from "@sdxc/cli";
10
10
  import { isFailure } from "@sdxc/result";
11
11
  import { METHODS, SDXC_COMMANDS } from "../contract.js";
12
+ import { makeActions } from "../make/actions.js";
12
13
  import { make } from "../make/index.js";
13
14
  import { copyStubs } from "../make/stubs.js";
15
+ import { makeTest } from "../make/test.js";
14
16
  import { packageRoot, project } from "../middleware.js";
15
17
  /** The middleware every `make` handler runs behind. */
16
18
  const MAKE_MIDDLEWARE = [project(), packageRoot()];
@@ -24,16 +26,46 @@ async function run(ctx, input) {
24
26
  /** `sdxc make controller`, which declares the route and maps the controller. */
25
27
  export const controller = createCommand(SDXC_COMMANDS.make.controller, {
26
28
  middleware: MAKE_MIDDLEWARE,
27
- /** Asks for the method on a terminal, with `get` preselected. */
28
- handler: (ctx) => run(ctx, {
29
- kind: "controller",
30
- name: ctx.arguments.name,
31
- method: ctx.flags.method,
32
- path: ctx.flags.path,
33
- routes: ctx.flags.routes,
34
- test: ctx.flags.test,
35
- dryRun: ctx.flags.dryRun,
36
- }),
29
+ /**
30
+ * Asks for the method on a terminal, with `get` preselected; `--resource` guards the route,
31
+ * and `--actions` writes one controller per action, each with its own method and route.
32
+ */
33
+ async handler(ctx) {
34
+ let { flags } = ctx;
35
+ let shared = {
36
+ name: ctx.arguments.name,
37
+ routes: flags.routes,
38
+ guardedBy: flags.resource,
39
+ test: flags.test,
40
+ dryRun: flags.dryRun,
41
+ force: flags.force,
42
+ };
43
+ if (flags.actions.length > 0) {
44
+ if (flags.method !== undefined || flags.path !== undefined) {
45
+ return usage("--actions gives each controller its method and route; drop --method and --path");
46
+ }
47
+ let made = await makeActions(ctx, ctx.project, ctx.packageRoot, {
48
+ ...shared,
49
+ actions: flags.actions,
50
+ });
51
+ if (isFailure(made))
52
+ return made;
53
+ return success();
54
+ }
55
+ let method = flags.method;
56
+ if (method === undefined) {
57
+ let picked = await ctx.prompt.select({
58
+ message: "Which method?",
59
+ options: METHODS,
60
+ default: "get",
61
+ name: "method",
62
+ });
63
+ if (isFailure(picked))
64
+ return picked;
65
+ method = picked.data;
66
+ }
67
+ return run(ctx, { ...shared, kind: "controller", method, path: flags.path });
68
+ },
37
69
  });
38
70
  /** `sdxc make job`, which declares the job and maps its handler. */
39
71
  export const job = createCommand(SDXC_COMMANDS.make.job, {
@@ -45,6 +77,7 @@ export const job = createCommand(SDXC_COMMANDS.make.job, {
45
77
  cron: ctx.flags.cron,
46
78
  test: ctx.flags.test,
47
79
  dryRun: ctx.flags.dryRun,
80
+ force: ctx.flags.force,
48
81
  }),
49
82
  });
50
83
  /** `sdxc make mcp`, which declares the tool or resource and maps its handler. */
@@ -57,16 +90,22 @@ export const mcp = createCommand(SDXC_COMMANDS.make.mcp, {
57
90
  resource: ctx.flags.resource,
58
91
  test: ctx.flags.test,
59
92
  dryRun: ctx.flags.dryRun,
93
+ force: ctx.flags.force,
60
94
  }),
61
95
  });
62
96
  /** `sdxc make migration`, numbered within its chain. */
63
97
  export const migration = createCommand(SDXC_COMMANDS.make.migration, {
64
98
  middleware: MAKE_MIDDLEWARE,
65
- /** `--chain` picks one of `make.migrations`. */
99
+ /**
100
+ * `--chain` picks one of `make.migrations`; `--from-model` writes the SQL a model needs, and
101
+ * fields write the statements the name spells.
102
+ */
66
103
  handler: (ctx) => run(ctx, {
67
104
  kind: "migration",
68
105
  name: ctx.arguments.name,
106
+ fields: ctx.arguments.fields,
69
107
  chain: ctx.flags.chain,
108
+ fromModel: ctx.flags.fromModel,
70
109
  test: false,
71
110
  dryRun: ctx.flags.dryRun,
72
111
  }),
@@ -75,7 +114,13 @@ export const migration = createCommand(SDXC_COMMANDS.make.migration, {
75
114
  export const factory = createCommand(SDXC_COMMANDS.make.factory, {
76
115
  middleware: MAKE_MIDDLEWARE,
77
116
  /** Writes the factory alone. */
78
- handler: (ctx) => run(ctx, { kind: "factory", name: ctx.arguments.name, test: false, dryRun: ctx.flags.dryRun }),
117
+ handler: (ctx) => run(ctx, {
118
+ kind: "factory",
119
+ name: ctx.arguments.name,
120
+ test: false,
121
+ dryRun: ctx.flags.dryRun,
122
+ force: ctx.flags.force,
123
+ }),
79
124
  });
80
125
  /**
81
126
  * A handler for a kind that takes only `--test` and `--dry-run`.
@@ -91,15 +136,43 @@ function plain(kind) {
91
136
  name: ctx.arguments.name,
92
137
  test: ctx.flags.test,
93
138
  dryRun: ctx.flags.dryRun,
139
+ force: ctx.flags.force,
94
140
  }),
95
141
  });
96
142
  }
97
- /** `sdxc make middleware`. */
98
- export const middleware = plain("middleware");
143
+ /** `sdxc make middleware`, which mounts the middleware on a chain under `--mount`. */
144
+ export const middleware = createCommand(SDXC_COMMANDS.make.middleware, {
145
+ middleware: MAKE_MIDDLEWARE,
146
+ /** `--mount` names a router initializer or a chain module the project has. */
147
+ handler: (ctx) => run(ctx, {
148
+ kind: "middleware",
149
+ name: ctx.arguments.name,
150
+ mount: ctx.flags.mount,
151
+ test: ctx.flags.test,
152
+ dryRun: ctx.flags.dryRun,
153
+ force: ctx.flags.force,
154
+ }),
155
+ });
99
156
  /** `sdxc make validator`. */
100
157
  export const validator = plain("validator");
101
- /** `sdxc make model`. */
102
- export const model = plain("model");
158
+ /** `sdxc make model`, with a column per field it is given, its migration and its factory. */
159
+ export const model = createCommand(SDXC_COMMANDS.make.model, {
160
+ middleware: MAKE_MIDDLEWARE,
161
+ /**
162
+ * Writes the model with its fields' columns, the migration creating its table and its factory,
163
+ * each unless `--skip` names it, and the model's test unless `--no-test` says otherwise.
164
+ */
165
+ handler: (ctx) => run(ctx, {
166
+ kind: "model",
167
+ name: ctx.arguments.name,
168
+ fields: ctx.arguments.fields,
169
+ chain: ctx.flags.chain,
170
+ skip: ctx.flags.skip,
171
+ test: ctx.flags.test,
172
+ dryRun: ctx.flags.dryRun,
173
+ force: ctx.flags.force,
174
+ }),
175
+ });
103
176
  /** `sdxc make service`. */
104
177
  export const service = plain("service");
105
178
  /** `sdxc make policy`. */
@@ -107,9 +180,37 @@ export const policy = plain("policy");
107
180
  /** `sdxc make initializer`. */
108
181
  export const initializer = plain("initializer");
109
182
  /** `sdxc make email`. */
110
- export const email = plain("email");
183
+ /** `sdxc make email`, which declares the email with its fields as props and maps its template. */
184
+ export const email = createCommand(SDXC_COMMANDS.make.email, {
185
+ middleware: MAKE_MIDDLEWARE,
186
+ /** Writes the template and, unless `--no-test` or `make.tests` says otherwise, its test. */
187
+ handler: (ctx) => run(ctx, {
188
+ kind: "email",
189
+ name: ctx.arguments.name,
190
+ fields: ctx.arguments.fields,
191
+ test: ctx.flags.test,
192
+ dryRun: ctx.flags.dryRun,
193
+ force: ctx.flags.force,
194
+ }),
195
+ });
111
196
  /** `sdxc make command`, which declares the command and maps its handler on the command line. */
112
197
  export const command = plain("command");
198
+ /** `sdxc make test`, which writes the test of an existing file from its kind's test stub. */
199
+ export const test = createCommand(SDXC_COMMANDS.make.test, {
200
+ middleware: MAKE_MIDDLEWARE,
201
+ /** Reads the kind from the file's folder; a controller's route comes from its router. */
202
+ async handler(ctx) {
203
+ let made = await makeTest(ctx, ctx.project, ctx.packageRoot, {
204
+ file: ctx.arguments.file,
205
+ cwd: ctx.cwd,
206
+ dryRun: ctx.flags.dryRun,
207
+ force: ctx.flags.force,
208
+ });
209
+ if (isFailure(made))
210
+ return made;
211
+ return success();
212
+ },
213
+ });
113
214
  /** `sdxc make stubs`, which copies the built-in stubs of the named kinds, or every kind. */
114
215
  export const stubs = createCommand(SDXC_COMMANDS.make.stubs, {
115
216
  middleware: MAKE_MIDDLEWARE,
@@ -147,6 +248,13 @@ export const group = createCommand(SDXC_COMMANDS.make, {
147
248
  return picked;
148
249
  method = picked.data;
149
250
  }
150
- return run(ctx, { kind, name, method, test: ctx.flags.test, dryRun: ctx.flags.dryRun });
251
+ return run(ctx, {
252
+ kind,
253
+ name,
254
+ method,
255
+ test: ctx.flags.test,
256
+ dryRun: ctx.flags.dryRun,
257
+ force: ctx.flags.force,
258
+ });
151
259
  },
152
260
  });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The `sdxc middleware` handler: prints each router's global middleware and every module in
3
+ * `app/http/middleware/`, chains expanded in run order, as text, or as JSON for an agent.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ /** Reads the routers and the middleware folder and prints every chain. */
9
+ declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
10
+ readonly json: import("@sdxc/cli").Flag<boolean>;
11
+ }>, readonly [import("@sdxc/cli").CommandMiddleware<{
12
+ key: typeof import("../middleware.js").CurrentProject;
13
+ value: import("../middleware.js").Project;
14
+ property: "project";
15
+ }>]>;
16
+ export default _default;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The `sdxc middleware` handler: prints each router's global middleware and every module in
3
+ * `app/http/middleware/`, chains expanded in run order, as text, or as JSON for an agent.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ import { createCommand, success } from "@sdxc/cli";
9
+ import { SDXC_COMMANDS } from "../contract.js";
10
+ import { project } from "../middleware.js";
11
+ import { formatMiddleware, listMiddleware } from "../routes/chains.js";
12
+ /** Reads the routers and the middleware folder and prints every chain. */
13
+ export default createCommand(SDXC_COMMANDS.middleware, {
14
+ middleware: [project()],
15
+ /** Always succeeds once the project is found; a project without routers says so. */
16
+ async handler(ctx) {
17
+ let listing = await listMiddleware(ctx.project.root);
18
+ ctx.stdout(ctx.flags.json ? `${JSON.stringify(listing, null, 2)}\n` : formatMiddleware(listing));
19
+ return success();
20
+ },
21
+ });