@sdxc/kit 2026.10.20 → 2026.10.23

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 (138) hide show
  1. package/README.md +178 -93
  2. package/changelog.jsonl +97 -0
  3. package/config.schema.json +160 -0
  4. package/dist/architecture/complexity.d.ts +73 -0
  5. package/dist/architecture/complexity.js +185 -0
  6. package/dist/architecture/crap.d.ts +62 -0
  7. package/dist/architecture/crap.js +121 -0
  8. package/dist/architecture/graph.d.ts +55 -0
  9. package/dist/architecture/graph.js +194 -0
  10. package/dist/architecture/layers.d.ts +29 -0
  11. package/dist/architecture/layers.js +81 -0
  12. package/dist/architecture/mermaid.d.ts +20 -0
  13. package/dist/architecture/mermaid.js +51 -0
  14. package/dist/cli.js +9 -0
  15. package/dist/commands/create.js +4 -3
  16. package/dist/commands/deploy.js +10 -9
  17. package/dist/commands/destroy.d.ts +1 -1
  18. package/dist/commands/diagram.d.ts +17 -0
  19. package/dist/commands/diagram.js +45 -0
  20. package/dist/commands/fix.d.ts +69 -0
  21. package/dist/commands/fix.js +102 -0
  22. package/dist/commands/make.d.ts +77 -2
  23. package/dist/commands/make.js +53 -1
  24. package/dist/commands/run.d.ts +15 -11
  25. package/dist/commands/run.js +21 -16
  26. package/dist/commands/scaffold.d.ts +2 -1
  27. package/dist/commands/scaffold.js +1 -0
  28. package/dist/commands/setup.d.ts +26 -0
  29. package/dist/commands/setup.js +33 -0
  30. package/dist/config.d.ts +54 -0
  31. package/dist/config.js +92 -1
  32. package/dist/contract.d.ts +56 -3
  33. package/dist/contract.js +140 -7
  34. package/dist/dependencies.d.ts +2 -1
  35. package/dist/dependencies.js +11 -2
  36. package/dist/deploy/plan.d.ts +5 -0
  37. package/dist/deploy/plan.js +10 -0
  38. package/dist/destroy.d.ts +4 -4
  39. package/dist/destroy.js +24 -11
  40. package/dist/diagram.d.ts +32 -0
  41. package/dist/diagram.js +47 -0
  42. package/dist/doctor/checks.d.ts +2 -1
  43. package/dist/doctor/checks.js +26 -1
  44. package/dist/doctor/complexity.d.ts +13 -0
  45. package/dist/doctor/complexity.js +52 -0
  46. package/dist/doctor/crap.d.ts +14 -0
  47. package/dist/doctor/crap.js +67 -0
  48. package/dist/doctor/dependencies.d.ts +13 -0
  49. package/dist/doctor/dependencies.js +42 -0
  50. package/dist/doctor/duplication.d.ts +19 -0
  51. package/dist/doctor/duplication.js +106 -0
  52. package/dist/doctor/fan-out.d.ts +12 -0
  53. package/dist/doctor/fan-out.js +42 -0
  54. package/dist/doctor/feature-scatter.d.ts +15 -0
  55. package/dist/doctor/feature-scatter.js +84 -0
  56. package/dist/doctor/jsdoc.d.ts +44 -0
  57. package/dist/doctor/jsdoc.js +201 -0
  58. package/dist/doctor/module-size.d.ts +13 -0
  59. package/dist/doctor/module-size.js +50 -0
  60. package/dist/doctor/mutation.d.ts +20 -0
  61. package/dist/doctor/mutation.js +97 -0
  62. package/dist/doctor/orphans.d.ts +13 -0
  63. package/dist/doctor/orphans.js +50 -0
  64. package/dist/doctor/project.js +8 -5
  65. package/dist/doctor/result-throws.d.ts +17 -0
  66. package/dist/doctor/result-throws.js +72 -0
  67. package/dist/doctor/test-ratio.d.ts +12 -0
  68. package/dist/doctor/test-ratio.js +31 -0
  69. package/dist/fix/commands.d.ts +37 -0
  70. package/dist/fix/commands.js +63 -0
  71. package/dist/fix/emails.d.ts +21 -0
  72. package/dist/fix/emails.js +159 -0
  73. package/dist/fix/env.d.ts +29 -0
  74. package/dist/fix/env.js +58 -0
  75. package/dist/fix/index.d.ts +11 -0
  76. package/dist/fix/index.js +11 -0
  77. package/dist/fix/models.d.ts +20 -0
  78. package/dist/fix/models.js +95 -0
  79. package/dist/lock.js +12 -2
  80. package/dist/make/binding.d.ts +42 -0
  81. package/dist/make/binding.js +237 -0
  82. package/dist/make/generate.d.ts +11 -2
  83. package/dist/make/generate.js +47 -16
  84. package/dist/make/imports.js +7 -5
  85. package/dist/make/index.d.ts +4 -2
  86. package/dist/make/index.js +4 -1
  87. package/dist/make/kinds.d.ts +5 -0
  88. package/dist/make/kinds.js +14 -2
  89. package/dist/make/schema-diff.js +8 -1
  90. package/dist/make/stubs.d.ts +7 -2
  91. package/dist/make/stubs.js +8 -3
  92. package/dist/make/test.js +1 -0
  93. package/dist/models.js +7 -7
  94. package/dist/routes/modules.js +8 -5
  95. package/dist/routes/parse.js +8 -7
  96. package/dist/routes/routers.js +9 -5
  97. package/dist/scaffold/index.d.ts +2 -0
  98. package/dist/scaffold/index.js +13 -4
  99. package/dist/scaffold/render.d.ts +11 -1
  100. package/dist/scaffold/render.js +86 -1
  101. package/dist/setup/auth.d.ts +12 -0
  102. package/dist/setup/auth.js +209 -0
  103. package/dist/setup/billing.d.ts +11 -0
  104. package/dist/setup/billing.js +116 -0
  105. package/dist/setup/catalog.d.ts +25 -0
  106. package/dist/setup/catalog.js +34 -0
  107. package/dist/setup/credit.d.ts +13 -0
  108. package/dist/setup/credit.js +21 -0
  109. package/dist/setup/flags.d.ts +11 -0
  110. package/dist/setup/flags.js +62 -0
  111. package/dist/setup/index.d.ts +25 -0
  112. package/dist/setup/index.js +53 -0
  113. package/dist/setup/plan.d.ts +38 -0
  114. package/dist/setup/plan.js +62 -0
  115. package/dist/testing.js +3 -3
  116. package/dist/ui/layout.js +1 -1
  117. package/dist/ui/registry.d.ts +2 -2
  118. package/dist/upgrade/project.d.ts +2 -2
  119. package/dist/upgrade/prompt.js +7 -5
  120. package/package.json +10 -7
  121. package/registry/ui/attachment.json +2 -2
  122. package/registry/ui/sidebar.json +3 -3
  123. package/registry/ui/typeset.json +3 -3
  124. package/stubs/command.spec.stub +15 -0
  125. package/stubs/controller.api.spec.stub +15 -0
  126. package/stubs/controller.spec.stub +15 -0
  127. package/stubs/mcp.spec.stub +16 -0
  128. package/stubs/scaffold.migration.stub +2 -1
  129. package/stubs/scaffold.spec.stub +7 -0
  130. package/templates/app/AGENTS.md +21 -4
  131. package/templates/app/README.md +6 -3
  132. package/templates/app/app/commands/typegen.test.ts +20 -1
  133. package/templates/app/app/commands/typegen.ts +16 -2
  134. package/templates/app/app/initializers/cli.ts +7 -0
  135. package/templates/app/app/initializers/mail-transport.test.ts +8 -2
  136. package/templates/app/app/test/cloudflare-workers.ts +2 -0
  137. package/templates/app/package.json +1 -0
  138. package/templates/app/spec/config.jsonc +16 -0
@@ -14,8 +14,9 @@ export declare const controller: import("@sdxc/cli").CommandAction<import("@sdxc
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
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>;
17
+ readonly actions: import("@sdxc/cli").ValueFlag<"index" | "new" | "all" | "show" | "edit" | "create" | "update" | "destroy", false, true, false>;
18
18
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
19
+ readonly spec: import("@sdxc/cli").Flag<boolean | undefined>;
19
20
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
20
21
  readonly force: import("@sdxc/cli").Flag<boolean>;
21
22
  }>, readonly [import("@sdxc/cli").CommandMiddleware<{
@@ -50,6 +51,7 @@ export declare const mcp: import("@sdxc/cli").CommandAction<import("@sdxc/cli").
50
51
  }, {
51
52
  readonly resource: import("@sdxc/cli").Flag<boolean>;
52
53
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
54
+ readonly spec: import("@sdxc/cli").Flag<boolean | undefined>;
53
55
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
54
56
  readonly force: import("@sdxc/cli").Flag<boolean>;
55
57
  }>, readonly [import("@sdxc/cli").CommandMiddleware<{
@@ -216,6 +218,7 @@ export declare const command: import("@sdxc/cli").CommandAction<import("@sdxc/cl
216
218
  readonly name: import("@sdxc/cli").Argument<string>;
217
219
  }, {
218
220
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
221
+ readonly spec: import("@sdxc/cli").Flag<boolean | undefined>;
219
222
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
220
223
  readonly force: import("@sdxc/cli").Flag<boolean>;
221
224
  }>, readonly [import("@sdxc/cli").CommandMiddleware<{
@@ -254,6 +257,54 @@ export declare const stubs: import("@sdxc/cli").CommandAction<import("@sdxc/cli"
254
257
  value: string;
255
258
  property: "packageRoot";
256
259
  }>]>;
260
+ /** `sdxc make secret`. */
261
+ export declare const secret: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
262
+ readonly name: import("@sdxc/cli").Argument<string>;
263
+ }, {
264
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
265
+ readonly force: import("@sdxc/cli").Flag<boolean>;
266
+ }>, readonly [import("@sdxc/cli").CommandMiddleware<{
267
+ key: typeof import("../middleware.js").CurrentProject;
268
+ value: import("../middleware.js").Project;
269
+ property: "project";
270
+ }>, import("@sdxc/cli").CommandMiddleware<{
271
+ key: typeof import("../middleware.js").PackageRoot;
272
+ value: string;
273
+ property: "packageRoot";
274
+ }>]>;
275
+ /** `sdxc make binding`. */
276
+ export declare const binding: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
277
+ readonly kind: import("@sdxc/cli").Argument<"secret" | "kv" | "d1" | "r2" | "queue" | "rateLimit" | "sendEmail" | "durableObject">;
278
+ readonly name: import("@sdxc/cli").Argument<string>;
279
+ }, {
280
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
281
+ readonly force: import("@sdxc/cli").Flag<boolean>;
282
+ }>, readonly [import("@sdxc/cli").CommandMiddleware<{
283
+ key: typeof import("../middleware.js").CurrentProject;
284
+ value: import("../middleware.js").Project;
285
+ property: "project";
286
+ }>, import("@sdxc/cli").CommandMiddleware<{
287
+ key: typeof import("../middleware.js").PackageRoot;
288
+ value: string;
289
+ property: "packageRoot";
290
+ }>]>;
291
+ /** `sdxc make do`. */
292
+ export declare const durableObject: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
293
+ readonly name: import("@sdxc/cli").Argument<string>;
294
+ }, {
295
+ readonly role: import("@sdxc/cli").ValueFlag<"model" | "service", true, false, false>;
296
+ readonly binding: import("@sdxc/cli").ValueFlag<string, false, false, false>;
297
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
298
+ readonly force: import("@sdxc/cli").Flag<boolean>;
299
+ }>, readonly [import("@sdxc/cli").CommandMiddleware<{
300
+ key: typeof import("../middleware.js").CurrentProject;
301
+ value: import("../middleware.js").Project;
302
+ property: "project";
303
+ }>, import("@sdxc/cli").CommandMiddleware<{
304
+ key: typeof import("../middleware.js").PackageRoot;
305
+ value: string;
306
+ property: "packageRoot";
307
+ }>]>;
257
308
  /**
258
309
  * `sdxc make` with no kind: the contract asks for the kind and the name on a terminal, and this
259
310
  * asks a controller's method, then makes it with every flag of the kind at its default. Without
@@ -278,8 +329,9 @@ export declare const group: import("@sdxc/cli").CommandAction<import("@sdxc/cli"
278
329
  readonly path: import("@sdxc/cli").ValueFlag<string, false, false, false>;
279
330
  readonly routes: import("@sdxc/cli").ValueFlag<string, false, false, false>;
280
331
  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>;
332
+ readonly actions: import("@sdxc/cli").ValueFlag<"index" | "new" | "all" | "show" | "edit" | "create" | "update" | "destroy", false, true, false>;
282
333
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
334
+ readonly spec: import("@sdxc/cli").Flag<boolean | undefined>;
283
335
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
284
336
  readonly force: import("@sdxc/cli").Flag<boolean>;
285
337
  }>;
@@ -364,6 +416,7 @@ export declare const group: import("@sdxc/cli").CommandAction<import("@sdxc/cli"
364
416
  }, {
365
417
  readonly resource: import("@sdxc/cli").Flag<boolean>;
366
418
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
419
+ readonly spec: import("@sdxc/cli").Flag<boolean | undefined>;
367
420
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
368
421
  readonly force: import("@sdxc/cli").Flag<boolean>;
369
422
  }>;
@@ -371,6 +424,7 @@ export declare const group: import("@sdxc/cli").CommandAction<import("@sdxc/cli"
371
424
  readonly name: import("@sdxc/cli").Argument<string>;
372
425
  }, {
373
426
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
427
+ readonly spec: import("@sdxc/cli").Flag<boolean | undefined>;
374
428
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
375
429
  readonly force: import("@sdxc/cli").Flag<boolean>;
376
430
  }>;
@@ -383,6 +437,27 @@ export declare const group: import("@sdxc/cli").CommandAction<import("@sdxc/cli"
383
437
  readonly stubs: import("@sdxc/cli").Command<{
384
438
  readonly kinds: import("@sdxc/cli").Argument<(import("../make/kinds.js").KindName | "scaffold")[]>;
385
439
  }, Readonly<Record<string, import("@sdxc/cli").Flag<unknown>>>>;
440
+ readonly secret: import("@sdxc/cli").Command<{
441
+ readonly name: import("@sdxc/cli").Argument<string>;
442
+ }, {
443
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
444
+ readonly force: import("@sdxc/cli").Flag<boolean>;
445
+ }>;
446
+ readonly binding: import("@sdxc/cli").Command<{
447
+ readonly kind: import("@sdxc/cli").Argument<"secret" | "kv" | "d1" | "r2" | "queue" | "rateLimit" | "sendEmail" | "durableObject">;
448
+ readonly name: import("@sdxc/cli").Argument<string>;
449
+ }, {
450
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
451
+ readonly force: import("@sdxc/cli").Flag<boolean>;
452
+ }>;
453
+ readonly do: import("@sdxc/cli").Command<{
454
+ readonly name: import("@sdxc/cli").Argument<string>;
455
+ }, {
456
+ readonly role: import("@sdxc/cli").ValueFlag<"model" | "service", true, false, false>;
457
+ readonly binding: import("@sdxc/cli").ValueFlag<string, false, false, false>;
458
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
459
+ readonly force: import("@sdxc/cli").Flag<boolean>;
460
+ }>;
386
461
  }, "description" | "hidden" | "arguments" | "flags" | "tasks">, {
387
462
  readonly kind: import("@sdxc/cli").Argument<import("../make/kinds.js").KindName>;
388
463
  readonly name: import("@sdxc/cli").Argument<string>;
@@ -10,6 +10,7 @@ import { createCommand, success, usage } from "@sdxc/cli";
10
10
  import { isFailure } from "@sdxc/result";
11
11
  import { METHODS, SDXC_COMMANDS } from "../contract.js";
12
12
  import { makeActions } from "../make/actions.js";
13
+ import { makeBinding, makeDo, makeSecret } from "../make/binding.js";
13
14
  import { make } from "../make/index.js";
14
15
  import { copyStubs } from "../make/stubs.js";
15
16
  import { makeTest } from "../make/test.js";
@@ -37,6 +38,7 @@ export const controller = createCommand(SDXC_COMMANDS.make.controller, {
37
38
  routes: flags.routes,
38
39
  guardedBy: flags.resource,
39
40
  test: flags.test,
41
+ spec: flags.spec,
40
42
  dryRun: flags.dryRun,
41
43
  force: flags.force,
42
44
  };
@@ -89,6 +91,7 @@ export const mcp = createCommand(SDXC_COMMANDS.make.mcp, {
89
91
  name: ctx.arguments.name,
90
92
  resource: ctx.flags.resource,
91
93
  test: ctx.flags.test,
94
+ spec: ctx.flags.spec,
92
95
  dryRun: ctx.flags.dryRun,
93
96
  force: ctx.flags.force,
94
97
  }),
@@ -130,11 +133,15 @@ export const factory = createCommand(SDXC_COMMANDS.make.factory, {
130
133
  function plain(kind) {
131
134
  return createCommand(SDXC_COMMANDS.make[kind], {
132
135
  middleware: MAKE_MIDDLEWARE,
133
- /** Writes the file and, unless `--no-test` or `make.tests` says otherwise, its test. */
136
+ /**
137
+ * Writes the file and, unless `--no-test` or `make.tests` says otherwise, its test; a
138
+ * command also takes `--spec` / `make.specs` for its pairing `.spec`.
139
+ */
134
140
  handler: (ctx) => run(ctx, {
135
141
  kind,
136
142
  name: ctx.arguments.name,
137
143
  test: ctx.flags.test,
144
+ spec: "spec" in ctx.flags ? ctx.flags.spec : undefined,
138
145
  dryRun: ctx.flags.dryRun,
139
146
  force: ctx.flags.force,
140
147
  }),
@@ -226,6 +233,51 @@ export const stubs = createCommand(SDXC_COMMANDS.make.stubs, {
226
233
  return success();
227
234
  },
228
235
  });
236
+ /** `sdxc make secret`. */
237
+ export const secret = createCommand(SDXC_COMMANDS.make.secret, {
238
+ middleware: MAKE_MIDDLEWARE,
239
+ async handler(ctx) {
240
+ let made = await makeSecret(ctx, ctx.project.root, {
241
+ name: ctx.arguments.name,
242
+ dryRun: ctx.flags.dryRun,
243
+ force: ctx.flags.force,
244
+ });
245
+ if (isFailure(made))
246
+ return made;
247
+ return success();
248
+ },
249
+ });
250
+ /** `sdxc make binding`. */
251
+ export const binding = createCommand(SDXC_COMMANDS.make.binding, {
252
+ middleware: MAKE_MIDDLEWARE,
253
+ async handler(ctx) {
254
+ let made = await makeBinding(ctx, ctx.project.root, {
255
+ kind: ctx.arguments.kind,
256
+ name: ctx.arguments.name,
257
+ dryRun: ctx.flags.dryRun,
258
+ force: ctx.flags.force,
259
+ });
260
+ if (isFailure(made))
261
+ return made;
262
+ return success();
263
+ },
264
+ });
265
+ /** `sdxc make do`. */
266
+ export const durableObject = createCommand(SDXC_COMMANDS.make.do, {
267
+ middleware: MAKE_MIDDLEWARE,
268
+ async handler(ctx) {
269
+ let made = await makeDo(ctx, ctx.project.root, ctx.packageRoot, {
270
+ name: ctx.arguments.name,
271
+ role: ctx.flags.role,
272
+ binding: ctx.flags.binding,
273
+ dryRun: ctx.flags.dryRun,
274
+ force: ctx.flags.force,
275
+ });
276
+ if (isFailure(made))
277
+ return made;
278
+ return success();
279
+ },
280
+ });
229
281
  /**
230
282
  * `sdxc make` with no kind: the contract asks for the kind and the name on a terminal, and this
231
283
  * asks a controller's method, then makes it with every flag of the kind at its default. Without
@@ -1,14 +1,15 @@
1
1
  /**
2
- * The `sdxc run` handler: runs the project's own command line, `bootstrap/cli.ts`, with the
3
- * project's runtime and every token after `run` as typed, so a globally installed `sdxc` reaches
4
- * any project's commands without a package script.
2
+ * The `sdxc run` handler: runs the project's own command line with the project's runtime and
3
+ * every token after `run` as typed, so a globally installed `sdxc` reaches any project's
4
+ * commands without a package script. The entry module defaults to `bootstrap/cli.ts` and a
5
+ * project overrides it with `run.entry` in `.config/sdxc.jsonc`.
5
6
  *
6
7
  * @author [Sergio Xalambrí](https://sergiodxa.com)
7
8
  * @copyright Sergio Xalambrí 2026
8
9
  */
9
10
  import type { Result } from "@sdxc/result";
10
- /** Where the app layout puts an app's command line, relative to the project root. */
11
- export declare const CLI_ENTRY = "bootstrap/cli.ts";
11
+ /** Where an app's command line starts when `run.entry` is left at its default. */
12
+ export declare const DEFAULT_CLI_ENTRY = "bootstrap/cli.ts";
12
13
  /**
13
14
  * `PATH` with the project's `node_modules/.bin` first, as a package script has it, so a child
14
15
  * runs the project's own `cf` or `vp` in place of a global one.
@@ -18,16 +19,19 @@ export declare const CLI_ENTRY = "bootstrap/cli.ts";
18
19
  */
19
20
  export declare function projectPath(root: string, path: string | undefined): string;
20
21
  /**
21
- * The command that starts the project's command line with `args`: under Bun for a project on
22
- * Bun and under Node otherwise.
22
+ * The command that starts the project's command line at `entry` with `args`: under Bun for a
23
+ * project on Bun and under Node otherwise.
23
24
  *
24
25
  * @param root - The project root, whose `package.json` and lock file name the package manager
26
+ * @param entry - The module to start, relative to the project root
27
+ * @param args - Tokens after `sdxc run`
25
28
  */
26
- export declare function commandLine(root: string, args: readonly string[]): Promise<Result<string[], Error>>;
29
+ export declare function commandLine(root: string, entry: string, args: readonly string[]): Promise<Result<string[], Error>>;
27
30
  /**
28
- * Runs `bootstrap/cli.ts` under Bun for a project on Bun and under Node otherwise, with its
29
- * output on the terminal and the project's `node_modules/.bin` first on `PATH`, as a package
30
- * script has it; the app's exit code is `sdxc run`'s, and only the app's messages print on failure.
31
+ * Runs the configured command-line entry under Bun for a project on Bun and under Node
32
+ * otherwise, with its output on the terminal and the project's `node_modules/.bin` first on
33
+ * `PATH`, as a package script has it; the app's exit code is `sdxc run`'s, and only the app's
34
+ * messages print on failure.
31
35
  */
32
36
  declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
33
37
  readonly args: import("@sdxc/cli").Argument<string[]>;
@@ -1,7 +1,8 @@
1
1
  /**
2
- * The `sdxc run` handler: runs the project's own command line, `bootstrap/cli.ts`, with the
3
- * project's runtime and every token after `run` as typed, so a globally installed `sdxc` reaches
4
- * any project's commands without a package script.
2
+ * The `sdxc run` handler: runs the project's own command line with the project's runtime and
3
+ * every token after `run` as typed, so a globally installed `sdxc` reaches any project's
4
+ * commands without a package script. The entry module defaults to `bootstrap/cli.ts` and a
5
+ * project overrides it with `run.entry` in `.config/sdxc.jsonc`.
5
6
  *
6
7
  * @author [Sergio Xalambrí](https://sergiodxa.com)
7
8
  * @copyright Sergio Xalambrí 2026
@@ -14,8 +15,8 @@ import { SDXC_COMMANDS } from "../contract.js";
14
15
  import { project } from "../middleware.js";
15
16
  import { lockFileAtOrAbove, packageManager } from "../package-manager.js";
16
17
  import { readManifest } from "../upgrade/project.js";
17
- /** Where the app layout puts an app's command line, relative to the project root. */
18
- export const CLI_ENTRY = "bootstrap/cli.ts";
18
+ /** Where an app's command line starts when `run.entry` is left at its default. */
19
+ export const DEFAULT_CLI_ENTRY = "bootstrap/cli.ts";
19
20
  /**
20
21
  * `PATH` with the project's `node_modules/.bin` first, as a package script has it, so a child
21
22
  * runs the project's own `cf` or `vp` in place of a global one.
@@ -28,12 +29,14 @@ export function projectPath(root, path) {
28
29
  return path === undefined ? bin : `${bin}${delimiter}${path}`;
29
30
  }
30
31
  /**
31
- * The command that starts the project's command line with `args`: under Bun for a project on
32
- * Bun and under Node otherwise.
32
+ * The command that starts the project's command line at `entry` with `args`: under Bun for a
33
+ * project on Bun and under Node otherwise.
33
34
  *
34
35
  * @param root - The project root, whose `package.json` and lock file name the package manager
36
+ * @param entry - The module to start, relative to the project root
37
+ * @param args - Tokens after `sdxc run`
35
38
  */
36
- export async function commandLine(root, args) {
39
+ export async function commandLine(root, entry, args) {
37
40
  let manifest = await readManifest(root);
38
41
  if (isFailure(manifest))
39
42
  return manifest;
@@ -41,23 +44,25 @@ export async function commandLine(root, args) {
41
44
  declared: manifest.data.manifest.packageManager,
42
45
  findLockFile: lockFileAtOrAbove(root),
43
46
  });
44
- return success([manager.name === "bun" ? "bun" : "node", CLI_ENTRY, ...args]);
47
+ return success([manager.name === "bun" ? "bun" : "node", entry, ...args]);
45
48
  }
46
49
  /**
47
- * Runs `bootstrap/cli.ts` under Bun for a project on Bun and under Node otherwise, with its
48
- * output on the terminal and the project's `node_modules/.bin` first on `PATH`, as a package
49
- * script has it; the app's exit code is `sdxc run`'s, and only the app's messages print on failure.
50
+ * Runs the configured command-line entry under Bun for a project on Bun and under Node
51
+ * otherwise, with its output on the terminal and the project's `node_modules/.bin` first on
52
+ * `PATH`, as a package script has it; the app's exit code is `sdxc run`'s, and only the app's
53
+ * messages print on failure.
50
54
  */
51
55
  export default createCommand(SDXC_COMMANDS.run, {
52
56
  middleware: [project()],
53
57
  /** Fails naming the missing entry; otherwise hands the app's exit code back unchanged. */
54
58
  async handler(ctx) {
55
59
  let root = ctx.project.root;
56
- let entry = join(root, CLI_ENTRY);
57
- if (!isSuccess(await wrap(() => stat(entry)))) {
58
- return failure(new Error(`${CLI_ENTRY} not found in ${root}; an app's command line starts there`));
60
+ let entry = ctx.project.config.run.entry;
61
+ let absolute = join(root, entry);
62
+ if (!isSuccess(await wrap(() => stat(absolute)))) {
63
+ return failure(new Error(`${entry} not found in ${root}; an app's command line starts there`));
59
64
  }
60
- let command = await commandLine(root, ctx.arguments.args);
65
+ let command = await commandLine(root, entry, ctx.arguments.args);
61
66
  if (isFailure(command))
62
67
  return command;
63
68
  let ran = await ctx.exec(command.data, {
@@ -14,8 +14,9 @@ declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Co
14
14
  readonly mcp: import("@sdxc/cli").Flag<boolean>;
15
15
  readonly command: import("@sdxc/cli").Flag<boolean>;
16
16
  readonly api: import("@sdxc/cli").Flag<boolean>;
17
- readonly skip: import("@sdxc/cli").ValueFlag<"validator" | "model" | "migration" | "factory" | "policy" | "pages", false, true, false>;
17
+ readonly skip: import("@sdxc/cli").ValueFlag<"model" | "validator" | "migration" | "factory" | "policy" | "pages", false, true, false>;
18
18
  readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
19
+ readonly spec: import("@sdxc/cli").Flag<boolean | undefined>;
19
20
  readonly dryRun: import("@sdxc/cli").Flag<boolean>;
20
21
  }>, readonly [import("@sdxc/cli").CommandMiddleware<{
21
22
  key: typeof import("../middleware.js").CurrentProject;
@@ -22,6 +22,7 @@ export default createCommand(SDXC_COMMANDS.scaffold, {
22
22
  mcp: ctx.flags.mcp,
23
23
  command: ctx.flags.command,
24
24
  test: ctx.flags.test,
25
+ spec: ctx.flags.spec,
25
26
  dryRun: ctx.flags.dryRun,
26
27
  skip: ctx.flags.skip,
27
28
  api: ctx.flags.api,
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The `sdxc setup` handler: lists known features with no name, or installs auth / billing /
3
+ * flags from a printed plan (`-y` writes; without it the plan is dry-run).
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ /**
9
+ * `sdxc setup` with no feature: lists the catalog. With a feature argument, installs it.
10
+ */
11
+ declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
12
+ readonly feature: import("@sdxc/cli").Argument<string | undefined>;
13
+ }, {
14
+ readonly provider: import("@sdxc/cli").ValueFlag<string, false, false, false>;
15
+ readonly yes: import("@sdxc/cli").Flag<boolean>;
16
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
17
+ }>, readonly [import("@sdxc/cli").CommandMiddleware<{
18
+ key: typeof import("../middleware.js").CurrentProject;
19
+ value: import("../middleware.js").Project;
20
+ property: "project";
21
+ }>, import("@sdxc/cli").CommandMiddleware<{
22
+ key: typeof import("../middleware.js").PackageRoot;
23
+ value: string;
24
+ property: "packageRoot";
25
+ }>]>;
26
+ export default _default;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The `sdxc setup` handler: lists known features with no name, or installs auth / billing /
3
+ * flags from a printed plan (`-y` writes; without it the plan is dry-run).
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ import { createCommand, success } from "@sdxc/cli";
9
+ import { isFailure } from "@sdxc/result";
10
+ import { SDXC_COMMANDS } from "../contract.js";
11
+ import { packageRoot, project } from "../middleware.js";
12
+ import { listFeatures, runSetup } from "../setup/index.js";
13
+ /**
14
+ * `sdxc setup` with no feature: lists the catalog. With a feature argument, installs it.
15
+ */
16
+ export default createCommand(SDXC_COMMANDS.setup, {
17
+ middleware: [project(), packageRoot()],
18
+ async handler(ctx) {
19
+ if (ctx.arguments.feature === undefined) {
20
+ ctx.stdout(listFeatures());
21
+ return success();
22
+ }
23
+ let ran = await runSetup(ctx.project.root, ctx.arguments.feature, {
24
+ provider: ctx.flags.provider,
25
+ dryRun: ctx.flags.dryRun,
26
+ yes: ctx.flags.yes,
27
+ stdout: (text) => ctx.stdout(text),
28
+ });
29
+ if (isFailure(ran))
30
+ return ran;
31
+ return success();
32
+ },
33
+ });
package/dist/config.d.ts CHANGED
@@ -27,6 +27,7 @@ export declare const CONFIG_SCHEMA: s.Schema<{
27
27
  tests?: boolean | undefined;
28
28
  routes?: string | undefined;
29
29
  migrations?: Record<string, string> | undefined;
30
+ specs?: boolean | undefined;
30
31
  stubs?: string | undefined;
31
32
  } | undefined;
32
33
  doctor?: {
@@ -37,6 +38,32 @@ export declare const CONFIG_SCHEMA: s.Schema<{
37
38
  }[] | undefined;
38
39
  } | undefined;
39
40
  checks?: string | undefined;
41
+ complexity?: {
42
+ max?: number | undefined;
43
+ } | undefined;
44
+ moduleSize?: {
45
+ maxLines?: number | undefined;
46
+ } | undefined;
47
+ crap?: {
48
+ max?: number | undefined;
49
+ coverage?: string | undefined;
50
+ } | undefined;
51
+ testRatio?: {
52
+ min?: number | undefined;
53
+ } | undefined;
54
+ fanOut?: {
55
+ max?: number | undefined;
56
+ } | undefined;
57
+ duplication?: {
58
+ minLines?: number | undefined;
59
+ } | undefined;
60
+ mutation?: {
61
+ report?: string | undefined;
62
+ maxSurvived?: number | undefined;
63
+ } | undefined;
64
+ } | undefined;
65
+ run?: {
66
+ entry?: string | undefined;
40
67
  } | undefined;
41
68
  lock?: string | undefined;
42
69
  }, {
@@ -49,6 +76,7 @@ export declare const CONFIG_SCHEMA: s.Schema<{
49
76
  tests: boolean;
50
77
  routes: string;
51
78
  migrations: Record<string, string>;
79
+ specs: boolean;
52
80
  stubs: string;
53
81
  };
54
82
  doctor: {
@@ -59,6 +87,32 @@ export declare const CONFIG_SCHEMA: s.Schema<{
59
87
  }[];
60
88
  };
61
89
  checks: string;
90
+ complexity: {
91
+ max: number;
92
+ };
93
+ moduleSize: {
94
+ maxLines: number;
95
+ };
96
+ crap: {
97
+ max: number;
98
+ coverage: string;
99
+ };
100
+ testRatio: {
101
+ min: number;
102
+ };
103
+ fanOut: {
104
+ max: number;
105
+ };
106
+ duplication: {
107
+ minLines: number;
108
+ };
109
+ mutation: {
110
+ report: string;
111
+ maxSurvived: number;
112
+ };
113
+ };
114
+ run: {
115
+ entry: string;
62
116
  };
63
117
  lock: string;
64
118
  $schema?: string | undefined;
package/dist/config.js CHANGED
@@ -22,6 +22,7 @@ const MAKE_DEFAULTS = {
22
22
  routes: "web",
23
23
  migrations: { default: "database/migrations" },
24
24
  tests: true,
25
+ specs: true,
25
26
  stubs: ".config/sdxc/stubs",
26
27
  };
27
28
  /**
@@ -36,8 +37,42 @@ const ACCEPTED_MIGRATION_FAILURE = s.object({
36
37
  const DOCTOR_MIGRATIONS_DEFAULTS = {
37
38
  accept: [],
38
39
  };
40
+ /** The `doctor.complexity` group as a project with no such key gets it. */
41
+ const DOCTOR_COMPLEXITY_DEFAULTS = { max: 4 };
42
+ /** The `doctor.moduleSize` group as a project with no such key gets it. */
43
+ const DOCTOR_MODULE_SIZE_DEFAULTS = { maxLines: 200 };
44
+ /** The `doctor.crap` group as a project with no such key gets it. */
45
+ const DOCTOR_CRAP_DEFAULTS = { max: 12, coverage: "coverage/coverage-final.json" };
46
+ /** Integer at least 1; shared so doctor leaf schemas stay under the nested-call ceiling. */
47
+ const POSITIVE_INTEGER = s.integer().pipe(checks.min(1));
48
+ /** Integer at least 0; shared so doctor leaf schemas stay under the nested-call ceiling. */
49
+ const NON_NEGATIVE_INTEGER = s.integer().pipe(checks.min(0));
50
+ /** Integer at least 2; shared so doctor leaf schemas stay under the nested-call ceiling. */
51
+ const INTEGER_AT_LEAST_TWO = s.integer().pipe(checks.min(2));
52
+ /** Number at least 0; shared so doctor leaf schemas stay under the nested-call ceiling. */
53
+ const NON_NEGATIVE_NUMBER = s.number().pipe(checks.min(0));
54
+ /** The `doctor.testRatio` group as a project with no such key gets it. */
55
+ const DOCTOR_TEST_RATIO_DEFAULTS = { min: 0.3 };
56
+ /** The `doctor.fanOut` group as a project with no such key gets it. */
57
+ const DOCTOR_FAN_OUT_DEFAULTS = { max: 15 };
58
+ /** The `doctor.duplication` group as a project with no such key gets it. */
59
+ const DOCTOR_DUPLICATION_DEFAULTS = { minLines: 8 };
60
+ /** The `doctor.mutation` group as a project with no such key gets it. */
61
+ const DOCTOR_MUTATION_DEFAULTS = { report: "reports/mutation/mutation.json", maxSurvived: 0 };
39
62
  /** The `doctor` group as a project with no `doctor` key gets it. */
40
- const DOCTOR_DEFAULTS = { checks: ".config/sdxc/checks", migrations: DOCTOR_MIGRATIONS_DEFAULTS };
63
+ const DOCTOR_DEFAULTS = {
64
+ checks: ".config/sdxc/checks",
65
+ migrations: DOCTOR_MIGRATIONS_DEFAULTS,
66
+ complexity: DOCTOR_COMPLEXITY_DEFAULTS,
67
+ moduleSize: DOCTOR_MODULE_SIZE_DEFAULTS,
68
+ crap: DOCTOR_CRAP_DEFAULTS,
69
+ testRatio: DOCTOR_TEST_RATIO_DEFAULTS,
70
+ fanOut: DOCTOR_FAN_OUT_DEFAULTS,
71
+ duplication: DOCTOR_DUPLICATION_DEFAULTS,
72
+ mutation: DOCTOR_MUTATION_DEFAULTS,
73
+ };
74
+ /** The `run` group as a project with no `run` key gets it. */
75
+ const RUN_DEFAULTS = { entry: "bootstrap/cli.ts" };
41
76
  /**
42
77
  * Every configuration key. Each leaf carries its default, or an example when it has none, and
43
78
  * a description that becomes its comment in `sdxc init`'s output; an unknown key is an error, so
@@ -69,6 +104,9 @@ export const CONFIG_SCHEMA = s.object({
69
104
  tests: s.defaulted(s.boolean(), MAKE_DEFAULTS.tests).meta({
70
105
  description: "Write a test beside every generated file except migrations and factories",
71
106
  }),
107
+ specs: s.defaulted(s.boolean(), MAKE_DEFAULTS.specs).meta({
108
+ description: "Write a pairing .spec under spec/ for controllers, commands, MCP tools and scaffolds",
109
+ }),
72
110
  stubs: s.defaulted(s.string(), MAKE_DEFAULTS.stubs).meta({
73
111
  description: "Stubs here replace the built-in ones; `sdxc make stubs` copies them out",
74
112
  }),
@@ -84,7 +122,57 @@ export const CONFIG_SCHEMA = s.object({
84
122
  description: "Migration errors `sdxc doctor` steps past, each a file that already ran and the column its error names",
85
123
  }),
86
124
  }, { unknownKeys: "error" }), DOCTOR_MIGRATIONS_DEFAULTS),
125
+ complexity: s.defaulted(s.object({
126
+ max: s.defaulted(POSITIVE_INTEGER, DOCTOR_COMPLEXITY_DEFAULTS.max).meta({
127
+ description: "Maximum cyclomatic complexity per function; the complexity check warns above it",
128
+ }),
129
+ }, { unknownKeys: "error" }), DOCTOR_COMPLEXITY_DEFAULTS),
130
+ moduleSize: s.defaulted(s.object({
131
+ maxLines: s.defaulted(POSITIVE_INTEGER, DOCTOR_MODULE_SIZE_DEFAULTS.maxLines).meta({
132
+ description: "Maximum code lines per module; the module-size check warns above it",
133
+ }),
134
+ }, { unknownKeys: "error" }), DOCTOR_MODULE_SIZE_DEFAULTS),
135
+ crap: s.defaulted(s.object({
136
+ max: s.defaulted(POSITIVE_INTEGER, DOCTOR_CRAP_DEFAULTS.max).meta({
137
+ description: "Maximum CRAP score per function; the crap check warns above it",
138
+ }),
139
+ coverage: s.defaulted(s.string(), DOCTOR_CRAP_DEFAULTS.coverage).meta({
140
+ description: "Istanbul coverage-final.json the crap check reads, relative to the project root",
141
+ }),
142
+ }, { unknownKeys: "error" }), DOCTOR_CRAP_DEFAULTS),
143
+ testRatio: s.defaulted(s.object({
144
+ min: s.defaulted(NON_NEGATIVE_NUMBER, DOCTOR_TEST_RATIO_DEFAULTS.min).meta({
145
+ description: "Minimum tests/code ratio from sdxc stats; the test-ratio check warns below it",
146
+ }),
147
+ }, { unknownKeys: "error" }), DOCTOR_TEST_RATIO_DEFAULTS),
148
+ fanOut: s.defaulted(s.object({
149
+ max: s.defaulted(POSITIVE_INTEGER, DOCTOR_FAN_OUT_DEFAULTS.max).meta({
150
+ description: "Maximum distinct modules one file may import; the fan-out check warns above it",
151
+ }),
152
+ }, { unknownKeys: "error" }), DOCTOR_FAN_OUT_DEFAULTS),
153
+ duplication: s.defaulted(s.object({
154
+ minLines: s
155
+ .defaulted(INTEGER_AT_LEAST_TWO, DOCTOR_DUPLICATION_DEFAULTS.minLines)
156
+ .meta({
157
+ description: "Minimum consecutive code lines that count as a duplicated block",
158
+ }),
159
+ }, { unknownKeys: "error" }), DOCTOR_DUPLICATION_DEFAULTS),
160
+ mutation: s.defaulted(s.object({
161
+ report: s.defaulted(s.string(), DOCTOR_MUTATION_DEFAULTS.report).meta({
162
+ description: "Mutation report JSON the mutation check reads, relative to the project root",
163
+ }),
164
+ maxSurvived: s
165
+ .defaulted(NON_NEGATIVE_INTEGER, DOCTOR_MUTATION_DEFAULTS.maxSurvived)
166
+ .meta({
167
+ description: "Maximum surviving mutants the mutation check allows",
168
+ }),
169
+ }, { unknownKeys: "error" }), DOCTOR_MUTATION_DEFAULTS),
87
170
  }, { unknownKeys: "error" }), DOCTOR_DEFAULTS),
171
+ run: s.defaulted(s.object({
172
+ entry: s.defaulted(s.string(), RUN_DEFAULTS.entry).meta({
173
+ description: "Module `sdxc run` starts, relative to the project root; apps keep the default",
174
+ }),
175
+ }, { unknownKeys: "error" }), RUN_DEFAULTS),
88
176
  format: s.optional(s.array(s.string()).pipe(checks.minItems(1))).meta({
89
177
  description: "Command run on every file the CLI writes or edits, paths appended",
90
178
  examples: [["bunx", "vp", "fmt", "--no-error-on-unmatched-pattern"]],
@@ -171,6 +259,9 @@ function configuredPaths(config) {
171
259
  ["ui.directory", config.ui.directory],
172
260
  ["make.stubs", config.make.stubs],
173
261
  ["doctor.checks", config.doctor.checks],
262
+ ["doctor.crap.coverage", config.doctor.crap.coverage],
263
+ ["doctor.mutation.report", config.doctor.mutation.report],
264
+ ["run.entry", config.run.entry],
174
265
  ["lock", config.lock],
175
266
  ];
176
267
  for (let [chain, folder] of Object.entries(config.make.migrations)) {