@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
@@ -25,7 +25,7 @@ sdxc make migration create-tags name # then: sdxc run db migrate
25
25
  sdxc make job reports/daily --cron "0 8 * * *"
26
26
  sdxc make email welcome name # then: ctx.email.later(emails.welcome, { to, props })
27
27
  sdxc make command users/grant # then: sdxc run users grant
28
- sdxc scaffold post title body:text # model, migration, CRUD pages and tests
28
+ sdxc scaffold post title body:text # model, migration, CRUD pages, tests and a .spec
29
29
 
30
30
  sdxc run db console # SQL prompt over the local database
31
31
  sdxc run console # Bun's REPL with db and models loaded
@@ -34,12 +34,15 @@ sdxc run db fresh --seed # drop every local table, migrate, se
34
34
  sdxc run emails preview welcome # print an email from its preview(); /_emails in bun dev
35
35
  sdxc routes # every route and its controller (-g, -c, --unused)
36
36
  sdxc doctor # release drift, secrets, migrations and wiring
37
+ bunx spec run spec --allow-config # black-box .spec suite under spec/
37
38
  bun check # format, lint and types
38
39
  bun run test
39
40
  ```
40
41
 
41
- `sdxc make` writes the file where it belongs with a test beside it, and maps it so it works
42
- right away. `sdxc` comes with the project; `npm add -g @sdxc/kit` puts it on your path.
42
+ `sdxc make` writes the file where it belongs with a test beside it, and for a controller, command
43
+ or MCP tool a pairing `.spec` under `spec/` so you can exercise it as a black box. It maps the
44
+ file so it works right away. `sdxc` comes with the project; `npm add -g @sdxc/kit` puts it on
45
+ your path.
43
46
 
44
47
  `AGENTS.md` teaches an AI coding agent these commands and conventions, and `CLAUDE.md` points
45
48
  Claude Code at it. `sdxc upgrade` keeps its sdxc section current; add your own rules below it.
@@ -1,10 +1,16 @@
1
1
  /**
2
- * The `typegen` command, which hands type generation to `cf` in the project's root.
2
+ * The `typegen` command, which hands type generation to `cf` in the project's root and stamps the
3
+ * types as current even when `cf` found nothing to change.
3
4
  */
4
5
 
6
+ import { mkdir, stat, utimes, writeFile } from "node:fs/promises";
7
+ import { dirname } from "node:path";
8
+
5
9
  import { invoke } from "@sdxc/cli/test";
10
+ import { isFailure, wrap } from "@sdxc/result";
6
11
  import { describe, expect, test } from "vitest";
7
12
 
13
+ import { TYPES_FILE } from "~/app/commands/typegen";
8
14
  import { cli } from "~/app/initializers/cli";
9
15
 
10
16
  describe("typegen", () => {
@@ -14,4 +20,17 @@ describe("typegen", () => {
14
20
  expect(run.code).toBe(0);
15
21
  expect(run.exec.map((call) => call.command)).toEqual([["cf", "workers", "types"]]);
16
22
  });
23
+
24
+ test("stamps types cf left unchanged, so sdxc doctor reads them as current", async () => {
25
+ if (isFailure(await wrap(() => stat(TYPES_FILE)))) {
26
+ await mkdir(dirname(TYPES_FILE), { recursive: true });
27
+ await writeFile(TYPES_FILE, "");
28
+ }
29
+ await utimes(TYPES_FILE, new Date(0), new Date(0));
30
+ let started = Date.now();
31
+
32
+ await invoke(cli, ["typegen"], { exec: { "cf workers types": { code: 0 } } });
33
+
34
+ expect((await stat(TYPES_FILE)).mtimeMs).toBeGreaterThanOrEqual(started - 1_000);
35
+ });
17
36
  });
@@ -4,13 +4,27 @@
4
4
  * type check against what the Worker receives. Safe to run twice.
5
5
  */
6
6
 
7
+ import { utimes } from "node:fs/promises";
8
+ import { join } from "node:path";
9
+
7
10
  import { createCommand, success } from "@sdxc/cli";
8
- import { isFailure } from "@sdxc/result";
11
+ import { isFailure, wrap } from "@sdxc/result";
9
12
 
10
13
  import commandset from "~/app/commands";
11
14
  import { PROJECT_ROOT } from "~/app/initializers/local-database";
12
15
 
16
+ /** Where `cf workers types` writes the types, the file the project's tsconfig includes. */
17
+ export const TYPES_FILE = join(PROJECT_ROOT, ".cloudflare/types/index.d.ts");
18
+
19
+ /**
20
+ * Generates the types, then stamps them with the current time: `cf` keeps an unchanged file as it
21
+ * was, and the stamp is what tells `sdxc doctor` the types match the config after an edit that
22
+ * adds no binding, like a cron trigger.
23
+ */
13
24
  export default createCommand(commandset.typegen, async (ctx) => {
14
25
  let generated = await ctx.exec(["cf", "workers", "types"], { cwd: PROJECT_ROOT });
15
- return isFailure(generated) ? generated : success();
26
+ if (isFailure(generated)) return generated;
27
+ let now = new Date();
28
+ await wrap(() => utimes(TYPES_FILE, now, now));
29
+ return success();
16
30
  });
@@ -99,3 +99,10 @@ cli.map(
99
99
  commandset.typegen,
100
100
  lazy(() => import("~/app/commands/typegen")),
101
101
  );
102
+
103
+ declare module "@sdxc/cli" {
104
+ /** Types every command handler's `ctx` with what the middleware above publishes: `ctx.db`, `ctx.models`, `ctx.email` and `ctx.intl`. */
105
+ interface CLITypes {
106
+ cli: typeof cli;
107
+ }
108
+ }
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * The app's mail transport, delivering into the in-memory `send_email` stand-in tests receive
3
- * as the `EMAIL` binding.
3
+ * as the `EMAIL` binding, and its queue, handing deliveries to the `QUEUE` binding.
4
4
  */
5
5
 
6
6
  import { Mailer } from "@sdxc/mail";
7
7
  import { env } from "cloudflare:workers";
8
8
  import { describe, expect, test } from "vitest";
9
9
 
10
- import { transport } from "~/app/initializers/mail-transport";
10
+ import { queue, transport } from "~/app/initializers/mail-transport";
11
11
  import { MAIL_FROM } from "~/config/constants";
12
12
 
13
13
  describe("transport", () => {
@@ -24,4 +24,10 @@ describe("transport", () => {
24
24
  messages: [expect.objectContaining({ subject: "Welcome" })],
25
25
  });
26
26
  });
27
+
28
+ test("queues a delivery for the email job on the QUEUE binding", async () => {
29
+ await queue({ email: "welcome", to: "ada@example.com", props: {} });
30
+
31
+ expect(env.QUEUE).toMatchObject({ messages: [expect.anything()] });
32
+ });
27
33
  });
@@ -8,6 +8,7 @@
8
8
  import {
9
9
  createD1Database,
10
10
  createKVNamespace,
11
+ createQueue,
11
12
  createRateLimit,
12
13
  createSendEmail,
13
14
  } from "@sdxc/cloudflare-mocks";
@@ -16,6 +17,7 @@ import {
16
17
  export const env = {
17
18
  DB: createD1Database(),
18
19
  EMAIL: createSendEmail(),
20
+ QUEUE: createQueue(),
19
21
  RATE_LIMITER: createRateLimit(),
20
22
  SESSIONS: createKVNamespace(),
21
23
  SESSION_SECRET: "development-session-secret",
@@ -55,6 +55,7 @@
55
55
  "@pitlane/vite-plugin-remix": "0.8.0",
56
56
  "@sdxc/cloudflare-mocks": "0.0.1",
57
57
  "@sdxc/kit": "0.0.1",
58
+ "@sdxc/spec": "0.0.1",
58
59
  "@types/node": "^26.6.5",
59
60
  "cf": "1.0.0-beta.5",
60
61
  "typescript": "^6.0.3",
@@ -0,0 +1,16 @@
1
+ {
2
+ // The URL `browser`, `http` and `mcp` resolve `/path` targets against. Set APP_BASE_URL
3
+ // to point the suite at another host; the default matches `bun run dev`.
4
+ "bases": {
5
+ "web": { "env": "APP_BASE_URL", "default": "http://localhost:5173" },
6
+ },
7
+ // Applied once a run adds `--allow-config`. Pairing specs from `sdxc make` and
8
+ // `sdxc scaffold` expect these grants for a local black-box run.
9
+ "permissions": {
10
+ "allow": [
11
+ ["run", "bun"],
12
+ ["host-fs", "."],
13
+ ["net", "localhost:5173"],
14
+ ],
15
+ },
16
+ }