@sdxc/kit 2026.10.21 → 2026.10.24

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 (113) hide show
  1. package/README.md +84 -4
  2. package/changelog.jsonl +168 -0
  3. package/config.schema.json +154 -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 +71 -2
  23. package/dist/commands/make.js +46 -0
  24. package/dist/commands/run.d.ts +15 -11
  25. package/dist/commands/run.js +21 -16
  26. package/dist/commands/scaffold.d.ts +1 -1
  27. package/dist/commands/setup.d.ts +26 -0
  28. package/dist/commands/setup.js +33 -0
  29. package/dist/config.d.ts +52 -0
  30. package/dist/config.js +88 -1
  31. package/dist/contract.d.ts +52 -3
  32. package/dist/contract.js +124 -2
  33. package/dist/dependencies.js +7 -1
  34. package/dist/deploy/plan.d.ts +5 -0
  35. package/dist/deploy/plan.js +10 -0
  36. package/dist/destroy.js +13 -6
  37. package/dist/diagram.d.ts +32 -0
  38. package/dist/diagram.js +47 -0
  39. package/dist/doctor/checks.d.ts +2 -1
  40. package/dist/doctor/checks.js +24 -1
  41. package/dist/doctor/complexity.d.ts +13 -0
  42. package/dist/doctor/complexity.js +52 -0
  43. package/dist/doctor/crap.d.ts +14 -0
  44. package/dist/doctor/crap.js +67 -0
  45. package/dist/doctor/dependencies.d.ts +13 -0
  46. package/dist/doctor/dependencies.js +42 -0
  47. package/dist/doctor/duplication.d.ts +19 -0
  48. package/dist/doctor/duplication.js +106 -0
  49. package/dist/doctor/fan-out.d.ts +12 -0
  50. package/dist/doctor/fan-out.js +42 -0
  51. package/dist/doctor/feature-scatter.d.ts +15 -0
  52. package/dist/doctor/feature-scatter.js +84 -0
  53. package/dist/doctor/module-size.d.ts +13 -0
  54. package/dist/doctor/module-size.js +50 -0
  55. package/dist/doctor/mutation.d.ts +20 -0
  56. package/dist/doctor/mutation.js +97 -0
  57. package/dist/doctor/orphans.d.ts +13 -0
  58. package/dist/doctor/orphans.js +50 -0
  59. package/dist/doctor/project.js +8 -5
  60. package/dist/doctor/result-throws.d.ts +17 -0
  61. package/dist/doctor/result-throws.js +72 -0
  62. package/dist/doctor/test-ratio.d.ts +12 -0
  63. package/dist/doctor/test-ratio.js +31 -0
  64. package/dist/fix/commands.d.ts +37 -0
  65. package/dist/fix/commands.js +63 -0
  66. package/dist/fix/emails.d.ts +21 -0
  67. package/dist/fix/emails.js +159 -0
  68. package/dist/fix/env.d.ts +29 -0
  69. package/dist/fix/env.js +58 -0
  70. package/dist/fix/index.d.ts +11 -0
  71. package/dist/fix/index.js +11 -0
  72. package/dist/fix/models.d.ts +20 -0
  73. package/dist/fix/models.js +95 -0
  74. package/dist/lock.js +12 -2
  75. package/dist/make/binding.d.ts +42 -0
  76. package/dist/make/binding.js +237 -0
  77. package/dist/make/imports.js +7 -5
  78. package/dist/make/schema-diff.js +8 -1
  79. package/dist/models.js +7 -7
  80. package/dist/routes/modules.js +8 -5
  81. package/dist/routes/parse.js +8 -7
  82. package/dist/routes/routers.js +9 -5
  83. package/dist/setup/auth.d.ts +12 -0
  84. package/dist/setup/auth.js +209 -0
  85. package/dist/setup/billing.d.ts +11 -0
  86. package/dist/setup/billing.js +116 -0
  87. package/dist/setup/catalog.d.ts +25 -0
  88. package/dist/setup/catalog.js +34 -0
  89. package/dist/setup/credit.d.ts +13 -0
  90. package/dist/setup/credit.js +21 -0
  91. package/dist/setup/flags.d.ts +11 -0
  92. package/dist/setup/flags.js +62 -0
  93. package/dist/setup/index.d.ts +25 -0
  94. package/dist/setup/index.js +53 -0
  95. package/dist/setup/plan.d.ts +38 -0
  96. package/dist/setup/plan.js +62 -0
  97. package/dist/testing.js +3 -3
  98. package/dist/ui/layout.js +1 -1
  99. package/dist/ui/registry.d.ts +2 -2
  100. package/dist/upgrade/project.d.ts +2 -2
  101. package/dist/upgrade/prompt.js +7 -5
  102. package/package.json +11 -8
  103. package/registry/ui/attachment.json +2 -2
  104. package/registry/ui/breadcrumbs.json +6 -3
  105. package/registry/ui/group.json +6 -3
  106. package/registry/ui/link-button.json +3 -3
  107. package/registry/ui/link.json +6 -3
  108. package/registry/ui/nav-link.json +6 -3
  109. package/registry/ui/navigation-menu.json +6 -3
  110. package/registry/ui/pagination.json +3 -3
  111. package/registry/ui/sidebar.json +3 -3
  112. package/templates/app/AGENTS.md +14 -1
  113. package/templates/app/package.json +1 -1
@@ -0,0 +1,194 @@
1
+ /**
2
+ * The project's import graph over app source: each relative or `~/` edge between modules, so
3
+ * architecture diagrams and the dependency doctor check share one walk of `findModuleReferences`.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ import { readFile } from "node:fs/promises";
9
+ import { dirname, join, posix } from "node:path";
10
+ import { findModuleReferences } from "@sdxc/codemod";
11
+ import { isFailure, wrap } from "@sdxc/result";
12
+ import { isAppSource, listFiles } from "../doctor/files.js";
13
+ import { PROJECT_FOLDERS } from "../stats.js";
14
+ import { allowsDependency, layerOf } from "./layers.js";
15
+ /**
16
+ * Builds the import graph of the project at `root` from every app-source module under the
17
+ * layout folders. Specifiers that leave the project (packages, absolute URLs) are ignored.
18
+ */
19
+ export async function projectGraph(root) {
20
+ let modules = [];
21
+ let edges = [];
22
+ let known = new Set();
23
+ for (let folder of PROJECT_FOLDERS) {
24
+ for (let file of (await listFiles(root, folder)).filter(isAppSource)) {
25
+ modules.push(file);
26
+ known.add(file);
27
+ known.add(withoutExtension(file));
28
+ }
29
+ }
30
+ for (let file of modules) {
31
+ let source = await wrap(() => readFile(join(root, file), "utf8"));
32
+ if (isFailure(source))
33
+ continue;
34
+ let references = findModuleReferences(file, source.data);
35
+ if (isFailure(references))
36
+ continue;
37
+ for (let { specifier } of references.data) {
38
+ let target = resolveSpecifier(specifier, file);
39
+ if (target === null)
40
+ continue;
41
+ let resolved = resolveKnown(target, known);
42
+ if (resolved === null)
43
+ continue;
44
+ edges.push({ from: file, to: resolved, specifier });
45
+ }
46
+ }
47
+ let violations = edges.filter((edge) => !allowsDependency(edge.from, edge.to));
48
+ return {
49
+ modules,
50
+ edges,
51
+ layers: aggregateLayers(edges),
52
+ cycles: findCycles(modules, edges),
53
+ violations,
54
+ };
55
+ }
56
+ /** Rolls module edges into layer-to-layer counts. */
57
+ export function aggregateLayers(edges) {
58
+ let counts = new Map();
59
+ for (let edge of edges) {
60
+ let from = layerOf(edge.from);
61
+ let to = layerOf(edge.to);
62
+ if (from === null || to === null || from === to)
63
+ continue;
64
+ let key = `${from}->${to}`;
65
+ let existing = counts.get(key);
66
+ if (existing) {
67
+ existing.count += 1;
68
+ if (!allowsDependency(edge.from, edge.to))
69
+ existing.allowed = false;
70
+ continue;
71
+ }
72
+ counts.set(key, {
73
+ from,
74
+ to,
75
+ count: 1,
76
+ allowed: allowsDependency(edge.from, edge.to),
77
+ });
78
+ }
79
+ return [...counts.values()].sort((a, b) => a.from === b.from ? a.to.localeCompare(b.to) : a.from.localeCompare(b.from));
80
+ }
81
+ /**
82
+ * Resolves `specifier` written in `file` to a project-relative path without extension, or
83
+ * `null` when it names a package or a URL.
84
+ */
85
+ export function resolveSpecifier(specifier, file) {
86
+ if (specifier.startsWith("~/"))
87
+ return specifier.slice(2);
88
+ if (!specifier.startsWith("."))
89
+ return null;
90
+ return posix.normalize(posix.join(dirname(file).split("\\").join("/"), specifier));
91
+ }
92
+ /** Matches a resolved specifier against known modules, trying common extensions. */
93
+ function resolveKnown(target, known) {
94
+ let candidates = [
95
+ target,
96
+ `${target}.ts`,
97
+ `${target}.tsx`,
98
+ `${target}.js`,
99
+ `${target}.jsx`,
100
+ `${target}.mts`,
101
+ `${target}.cts`,
102
+ joinIndex(target),
103
+ ];
104
+ for (let candidate of candidates) {
105
+ if (candidate === null)
106
+ continue;
107
+ if (known.has(candidate))
108
+ return withPreferredExtension(candidate, known);
109
+ let bare = withoutExtension(candidate);
110
+ if (known.has(bare)) {
111
+ for (let module of known) {
112
+ if (withoutExtension(module) === bare && module.includes("."))
113
+ return module;
114
+ }
115
+ }
116
+ }
117
+ return null;
118
+ }
119
+ /** `dir/index.ts` when `target` names a folder the project holds as an index module. */
120
+ function joinIndex(target) {
121
+ if (target.endsWith("/"))
122
+ return `${target}index`;
123
+ return `${target}/index`;
124
+ }
125
+ /** The first known module path that matches `candidate`'s bare name. */
126
+ function withPreferredExtension(candidate, known) {
127
+ if (known.has(candidate) && candidate.includes("."))
128
+ return candidate;
129
+ let bare = withoutExtension(candidate);
130
+ for (let module of known) {
131
+ if (withoutExtension(module) === bare && module.includes("."))
132
+ return module;
133
+ }
134
+ return candidate;
135
+ }
136
+ /** Drops a trailing `.ts` / `.tsx` / `.js` / … extension. */
137
+ function withoutExtension(path) {
138
+ return path.replace(/\.[cm]?[jt]sx?$/, "");
139
+ }
140
+ /**
141
+ * Every cycle in the directed graph, as the modules on the cycle in visit order. A module that
142
+ * imports itself is a one-node cycle.
143
+ */
144
+ export function findCycles(modules, edges) {
145
+ let adjacency = new Map();
146
+ for (let module of modules)
147
+ adjacency.set(module, []);
148
+ for (let edge of edges) {
149
+ let list = adjacency.get(edge.from);
150
+ if (list && !list.includes(edge.to))
151
+ list.push(edge.to);
152
+ }
153
+ let index = 0;
154
+ let stack = [];
155
+ let onStack = new Set();
156
+ let indices = new Map();
157
+ let lowlink = new Map();
158
+ let cycles = [];
159
+ function strongconnect(node) {
160
+ indices.set(node, index);
161
+ lowlink.set(node, index);
162
+ index += 1;
163
+ stack.push(node);
164
+ onStack.add(node);
165
+ for (let next of adjacency.get(node) ?? []) {
166
+ if (!indices.has(next)) {
167
+ strongconnect(next);
168
+ lowlink.set(node, Math.min(lowlink.get(node), lowlink.get(next)));
169
+ }
170
+ else if (onStack.has(next)) {
171
+ lowlink.set(node, Math.min(lowlink.get(node), indices.get(next)));
172
+ }
173
+ }
174
+ if (lowlink.get(node) === indices.get(node)) {
175
+ let component = [];
176
+ let member;
177
+ do {
178
+ member = stack.pop();
179
+ if (member === undefined)
180
+ break;
181
+ onStack.delete(member);
182
+ component.push(member);
183
+ } while (member !== node);
184
+ let self = (adjacency.get(node) ?? []).includes(node);
185
+ if (component.length > 1 || self)
186
+ cycles.push(component.reverse());
187
+ }
188
+ }
189
+ for (let module of modules) {
190
+ if (!indices.has(module))
191
+ strongconnect(module);
192
+ }
193
+ return cycles.sort((a, b) => a[0].localeCompare(b[0]));
194
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The app-layout layers Clean Architecture's dependency rule maps onto: outer kinds may import
3
+ * inner ones, never the reverse, so a model never reaches a controller and a view never pulls a
4
+ * job. Ranks are the only rule; same-rank edges stay allowed.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ /**
10
+ * One kind of code the dependency rule names. Unranked paths (config, database, packages) sit
11
+ * outside the rule so anyone may import them.
12
+ */
13
+ export type Layer = "models" | "policies" | "services" | "initializers" | "http" | "jobs" | "mcp" | "emails" | "commands" | "resources" | "routes" | "bootstrap" | "test";
14
+ /** Higher rank is more inward; an import may only reach a layer at this rank or higher. */
15
+ export declare const LAYER_RANK: Readonly<Record<Layer, number>>;
16
+ /** Display order for architecture diagrams, outer first. */
17
+ export declare const LAYER_ORDER: readonly Layer[];
18
+ /**
19
+ * The layer `path` belongs to, or `null` when the path is outside the ranked kinds (config,
20
+ * database, or a package).
21
+ *
22
+ * @param path - Project-relative path with `/` separators.
23
+ */
24
+ export declare function layerOf(path: string): Layer | null;
25
+ /**
26
+ * Whether an import from `from` to `to` obeys the dependency rule. Unranked endpoints are left
27
+ * alone so config and packages stay free to import.
28
+ */
29
+ export declare function allowsDependency(from: string, to: string): boolean;
@@ -0,0 +1,81 @@
1
+ /**
2
+ * The app-layout layers Clean Architecture's dependency rule maps onto: outer kinds may import
3
+ * inner ones, never the reverse, so a model never reaches a controller and a view never pulls a
4
+ * job. Ranks are the only rule; same-rank edges stay allowed.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ /** Higher rank is more inward; an import may only reach a layer at this rank or higher. */
10
+ export const LAYER_RANK = {
11
+ models: 40,
12
+ policies: 30,
13
+ services: 30,
14
+ initializers: 30,
15
+ http: 20,
16
+ jobs: 20,
17
+ mcp: 20,
18
+ emails: 20,
19
+ commands: 20,
20
+ test: 20,
21
+ resources: 10,
22
+ routes: 10,
23
+ bootstrap: 10,
24
+ };
25
+ /** Display order for architecture diagrams, outer first. */
26
+ export const LAYER_ORDER = [
27
+ "bootstrap",
28
+ "routes",
29
+ "resources",
30
+ "http",
31
+ "jobs",
32
+ "mcp",
33
+ "emails",
34
+ "commands",
35
+ "test",
36
+ "initializers",
37
+ "services",
38
+ "policies",
39
+ "models",
40
+ ];
41
+ /** Prefixes that assign a path to a layer, most specific first. */
42
+ const LAYER_PREFIXES = [
43
+ ["app/http/", "http"],
44
+ ["app/jobs/", "jobs"],
45
+ ["app/mcp/", "mcp"],
46
+ ["app/emails/", "emails"],
47
+ ["app/commands/", "commands"],
48
+ ["app/initializers/", "initializers"],
49
+ ["app/services/", "services"],
50
+ ["app/policies/", "policies"],
51
+ ["app/models/", "models"],
52
+ ["app/test/", "test"],
53
+ ["resources/", "resources"],
54
+ ["routes/", "routes"],
55
+ ["bootstrap/", "bootstrap"],
56
+ ];
57
+ /**
58
+ * The layer `path` belongs to, or `null` when the path is outside the ranked kinds (config,
59
+ * database, or a package).
60
+ *
61
+ * @param path - Project-relative path with `/` separators.
62
+ */
63
+ export function layerOf(path) {
64
+ let normalized = path.split("\\").join("/");
65
+ for (let [prefix, layer] of LAYER_PREFIXES) {
66
+ if (normalized === prefix.slice(0, -1) || normalized.startsWith(prefix))
67
+ return layer;
68
+ }
69
+ return null;
70
+ }
71
+ /**
72
+ * Whether an import from `from` to `to` obeys the dependency rule. Unranked endpoints are left
73
+ * alone so config and packages stay free to import.
74
+ */
75
+ export function allowsDependency(from, to) {
76
+ let source = layerOf(from);
77
+ let target = layerOf(to);
78
+ if (source === null || target === null)
79
+ return true;
80
+ return LAYER_RANK[source] <= LAYER_RANK[target];
81
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Turns a {@link ProjectGraph} into Mermaid flowchart source: one node per layer that appears,
3
+ * edges labelled with import counts, and dependency-rule breaches drawn as dashed red links so
4
+ * `@sdxc/diagram` can render the same text the command prints.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { ProjectGraph } from "./graph.js";
10
+ /** Options for {@link toMermaid}. */
11
+ export interface MermaidOptions {
12
+ /** Accessible name passed to {@link toSVG} as `alt`; omitted from the Mermaid text. */
13
+ title?: string;
14
+ }
15
+ /**
16
+ * A `flowchart TB` of the project's layers. Empty projects still produce a valid one-node
17
+ * diagram so `toSVG` and `--json` have something to print. Edges that break the dependency
18
+ * rule are dashed and labelled so they read without Mermaid styling statements.
19
+ */
20
+ export declare function toMermaid(graph: ProjectGraph, _options?: MermaidOptions): string;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Turns a {@link ProjectGraph} into Mermaid flowchart source: one node per layer that appears,
3
+ * edges labelled with import counts, and dependency-rule breaches drawn as dashed red links so
4
+ * `@sdxc/diagram` can render the same text the command prints.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { LAYER_ORDER, layerOf } from "./layers.js";
10
+ /**
11
+ * A `flowchart TB` of the project's layers. Empty projects still produce a valid one-node
12
+ * diagram so `toSVG` and `--json` have something to print. Edges that break the dependency
13
+ * rule are dashed and labelled so they read without Mermaid styling statements.
14
+ */
15
+ export function toMermaid(graph, _options = {}) {
16
+ let present = new Set();
17
+ for (let edge of graph.layers) {
18
+ present.add(edge.from);
19
+ present.add(edge.to);
20
+ }
21
+ for (let module of graph.modules) {
22
+ let layer = layerOf(module);
23
+ if (layer)
24
+ present.add(layer);
25
+ }
26
+ let nodes = LAYER_ORDER.filter((layer) => present.has(layer));
27
+ if (nodes.length === 0)
28
+ nodes = ["models"];
29
+ let lines = ["flowchart TB"];
30
+ for (let layer of nodes) {
31
+ lines.push(` ${nodeId(layer)}["${escapeLabel(layer)}"]`);
32
+ }
33
+ for (let edge of graph.layers) {
34
+ let label = edge.count === 1 ? "1 import" : `${edge.count} imports`;
35
+ if (edge.allowed) {
36
+ lines.push(` ${nodeId(edge.from)} -->|${escapeLabel(label)}| ${nodeId(edge.to)}`);
37
+ }
38
+ else {
39
+ lines.push(` ${nodeId(edge.from)} -.->|${escapeLabel(`${label}, breaks rule`)}| ${nodeId(edge.to)}`);
40
+ }
41
+ }
42
+ return `${lines.join("\n")}\n`;
43
+ }
44
+ /** Stable Mermaid node id for a layer name. */
45
+ function nodeId(layer) {
46
+ return `L_${layer}`;
47
+ }
48
+ /** Mermaid breaks on `"` inside labels; keep labels plain. */
49
+ function escapeLabel(text) {
50
+ return text.replace(/"/g, "'");
51
+ }
package/dist/cli.js CHANGED
@@ -34,6 +34,10 @@ export function createSDXC(options = {}) {
34
34
  cli.map(SDXC_COMMANDS.deploy, lazy(() => import("./commands/deploy.js")));
35
35
  cli.map(SDXC_COMMANDS.destroy, lazy(() => import("./commands/destroy.js")));
36
36
  cli.map(SDXC_COMMANDS.doctor, lazy(() => import("./commands/doctor.js")));
37
+ cli.map(SDXC_COMMANDS.fix, lazy(() => import("./commands/fix.js").then((module) => ({ default: module.group }))));
38
+ cli.map(SDXC_COMMANDS.fix.env, lazy(() => import("./commands/fix.js").then((module) => ({ default: module.env }))));
39
+ cli.map(SDXC_COMMANDS.fix.models, lazy(() => import("./commands/fix.js").then((module) => ({ default: module.models }))));
40
+ cli.map(SDXC_COMMANDS.fix.emails, lazy(() => import("./commands/fix.js").then((module) => ({ default: module.emails }))));
37
41
  cli.map(SDXC_COMMANDS.init, lazy(() => import("./commands/init.js")));
38
42
  cli.map(SDXC_COMMANDS.initializers, lazy(() => import("./commands/initializers.js")));
39
43
  cli.map(SDXC_COMMANDS.middleware, lazy(() => import("./commands/middleware.js")));
@@ -41,6 +45,7 @@ export function createSDXC(options = {}) {
41
45
  cli.map(SDXC_COMMANDS.notes, lazy(() => import("./commands/notes.js")));
42
46
  cli.map(SDXC_COMMANDS.schedule, lazy(() => import("./commands/schedule.js")));
43
47
  cli.map(SDXC_COMMANDS.stats, lazy(() => import("./commands/stats.js")));
48
+ cli.map(SDXC_COMMANDS.diagram, lazy(() => import("./commands/diagram.js")));
44
49
  cli.map(SDXC_COMMANDS.make, lazy(() => import("./commands/make.js").then((module) => ({ default: module.group }))));
45
50
  cli.map(SDXC_COMMANDS.make.controller, lazy(() => import("./commands/make.js").then((module) => ({ default: module.controller }))));
46
51
  cli.map(SDXC_COMMANDS.make.middleware, lazy(() => import("./commands/make.js").then((module) => ({ default: module.middleware }))));
@@ -57,9 +62,13 @@ export function createSDXC(options = {}) {
57
62
  cli.map(SDXC_COMMANDS.make.command, lazy(() => import("./commands/make.js").then((module) => ({ default: module.command }))));
58
63
  cli.map(SDXC_COMMANDS.make.test, lazy(() => import("./commands/make.js").then((module) => ({ default: module.test }))));
59
64
  cli.map(SDXC_COMMANDS.make.stubs, lazy(() => import("./commands/make.js").then((module) => ({ default: module.stubs }))));
65
+ cli.map(SDXC_COMMANDS.make.secret, lazy(() => import("./commands/make.js").then((module) => ({ default: module.secret }))));
66
+ cli.map(SDXC_COMMANDS.make.binding, lazy(() => import("./commands/make.js").then((module) => ({ default: module.binding }))));
67
+ cli.map(SDXC_COMMANDS.make.do, lazy(() => import("./commands/make.js").then((module) => ({ default: module.durableObject }))));
60
68
  cli.map(SDXC_COMMANDS.routes, lazy(() => import("./commands/routes.js")));
61
69
  cli.map(SDXC_COMMANDS.scaffold, lazy(() => import("./commands/scaffold.js")));
62
70
  cli.map(SDXC_COMMANDS.run, lazy(() => import("./commands/run.js")));
71
+ cli.map(SDXC_COMMANDS.setup, lazy(() => import("./commands/setup.js")));
63
72
  cli.map(SDXC_COMMANDS.ui.list, lazy(() => import("./commands/ui/list.js")));
64
73
  cli.map(SDXC_COMMANDS.ui.add, lazy(() => import("./commands/ui/add.js")));
65
74
  cli.map(SDXC_COMMANDS.ui.diff, lazy(() => import("./commands/ui/diff.js")));
@@ -72,7 +72,8 @@ async function initializeGit(ctx, wanted, directory, shown) {
72
72
  ctx.stdout("git is not on the PATH, so no repository was initialized\n");
73
73
  return success(undefined);
74
74
  }
75
- if (wanted === undefined) {
75
+ let shouldInit = wanted;
76
+ if (shouldInit === undefined) {
76
77
  let answer = await ctx.prompt.confirm({
77
78
  message: `Initialize a git repository in ${shown}?`,
78
79
  default: false,
@@ -81,9 +82,9 @@ async function initializeGit(ctx, wanted, directory, shown) {
81
82
  });
82
83
  if (isFailure(answer))
83
84
  return answer;
84
- wanted = answer.data;
85
+ shouldInit = answer.data;
85
86
  }
86
- if (!wanted)
87
+ if (!shouldInit)
87
88
  return success(undefined);
88
89
  let initialized = await ctx.exec(["git", "init", "--quiet"], {
89
90
  cwd: directory,
@@ -11,11 +11,11 @@ import { basename, join } from "node:path";
11
11
  import { createCommand, ExecError, exit, failure, success, usage } from "@sdxc/cli";
12
12
  import { isFailure, isSuccess, wrap } from "@sdxc/result";
13
13
  import { SDXC_COMMANDS } from "../contract.js";
14
- import { deployFailure, formatPlan, isUnknown, migrates, parsePending } from "../deploy/plan.js";
14
+ import { deployFailure, execDetail, formatPlan, isUnknown, migrates, parsePending, } from "../deploy/plan.js";
15
15
  import { project } from "../middleware.js";
16
16
  import { lockFileAtOrAbove, packageManager } from "../package-manager.js";
17
17
  import { readManifest } from "../upgrade/project.js";
18
- import { CLI_ENTRY, commandLine, projectPath } from "./run.js";
18
+ import { commandLine, projectPath } from "./run.js";
19
19
  /**
20
20
  * Runs build, `db migrate --remote` and `deploy` in that order and stops at the first failure,
21
21
  * whose message says what production now runs. Every remote change waits for a yes: `--yes`, or
@@ -34,9 +34,10 @@ export default createCommand(SDXC_COMMANDS.deploy, {
34
34
  return usage("--skip migrate and --skip deploy leave nothing to run in production");
35
35
  }
36
36
  let root = ctx.project.root;
37
+ let entry = ctx.project.config.run.entry;
37
38
  let path = projectPath(root, ctx.env.PATH);
38
- if (!isSuccess(await wrap(() => stat(join(root, CLI_ENTRY))))) {
39
- return failure(new Error(`${CLI_ENTRY} is missing; sdxc deploy runs the app's db migrate --remote and deploy commands from it`));
39
+ if (!isSuccess(await wrap(() => stat(join(root, entry))))) {
40
+ return failure(new Error(`${entry} is missing; sdxc deploy runs the app's db migrate --remote and deploy commands from it`));
40
41
  }
41
42
  let manifest = await readManifest(root);
42
43
  if (isFailure(manifest))
@@ -61,7 +62,7 @@ export default createCommand(SDXC_COMMANDS.deploy, {
61
62
  }
62
63
  let migrations = { status: "skipped", reason: "--skip migrate" };
63
64
  if (!skip.has("migrate")) {
64
- let listing = await commandLine(root, ["db", "migrate", "--remote", "--pending"]);
65
+ let listing = await commandLine(root, entry, ["db", "migrate", "--remote", "--pending"]);
65
66
  if (isFailure(listing))
66
67
  return listing;
67
68
  let listed = await ctx.exec(listing.data, {
@@ -79,11 +80,11 @@ export default createCommand(SDXC_COMMANDS.deploy, {
79
80
  return failure(new Error("The app's command line has no db migrate command; add one that applies production migrations with --remote, or pass --skip migrate"));
80
81
  }
81
82
  else {
82
- return failure(new Error(`Listing pending migrations with db migrate --remote --pending failed; nothing was migrated or deployed: ${listed.error.message}`));
83
+ return failure(new Error(`Listing pending migrations with db migrate --remote --pending failed; nothing was migrated or deployed: ${execDetail(listed.error)}`));
83
84
  }
84
85
  }
85
86
  if (!skip.has("deploy")) {
86
- let checking = await commandLine(root, ["deploy", "--dry-run"]);
87
+ let checking = await commandLine(root, entry, ["deploy", "--dry-run"]);
87
88
  if (isFailure(checking))
88
89
  return checking;
89
90
  let checked = await ctx.exec(checking.data, {
@@ -121,7 +122,7 @@ export default createCommand(SDXC_COMMANDS.deploy, {
121
122
  return exit(1, "Not confirmed; nothing was migrated or deployed");
122
123
  }
123
124
  if (migrates(migrations)) {
124
- let command = await commandLine(root, ["db", "migrate", "--remote"]);
125
+ let command = await commandLine(root, entry, ["db", "migrate", "--remote"]);
125
126
  if (isFailure(command))
126
127
  return command;
127
128
  /** `CI=1` makes `cf` take the yes this run already got instead of asking again. */
@@ -138,7 +139,7 @@ export default createCommand(SDXC_COMMANDS.deploy, {
138
139
  ctx.stdout(`${migrated(migrations)}; deploy skipped\n`);
139
140
  return success();
140
141
  }
141
- let command = await commandLine(root, ["deploy"]);
142
+ let command = await commandLine(root, entry, ["deploy"]);
142
143
  if (isFailure(command))
143
144
  return command;
144
145
  let deployed = await ctx.exec(command.data, {
@@ -8,7 +8,7 @@
8
8
  */
9
9
  /** Removes what `sdxc make` wrote for one kind and name, after one confirmation. */
10
10
  declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
11
- readonly kind: import("@sdxc/cli").Argument<"email" | "command" | "controller" | "middleware" | "validator" | "job" | "model" | "factory" | "service" | "initializer" | "mcp">;
11
+ readonly kind: import("@sdxc/cli").Argument<"email" | "command" | "model" | "service" | "controller" | "middleware" | "validator" | "job" | "factory" | "initializer" | "mcp">;
12
12
  readonly name: import("@sdxc/cli").Argument<string>;
13
13
  }, {
14
14
  readonly yes: import("@sdxc/cli").Flag<boolean>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The `sdxc diagram` handler: prints the project's layer import graph as Mermaid, or as JSON for
3
+ * an agent, and optionally writes an SVG through `@sdxc/diagram`.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ /** Builds the architecture diagram and prints Mermaid, JSON, or the SVG path. */
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 svg: import("@sdxc/cli").ValueFlag<string, false, false, false>;
12
+ }>, readonly [import("@sdxc/cli").CommandMiddleware<{
13
+ key: typeof import("../middleware.js").CurrentProject;
14
+ value: import("../middleware.js").Project;
15
+ property: "project";
16
+ }>]>;
17
+ export default _default;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The `sdxc diagram` handler: prints the project's layer import graph as Mermaid, or as JSON for
3
+ * an agent, and optionally writes an SVG through `@sdxc/diagram`.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ import { createCommand, failure, success } from "@sdxc/cli";
9
+ import { isFailure } from "@sdxc/result";
10
+ import { SDXC_COMMANDS } from "../contract.js";
11
+ import { buildDiagram, formatDiagramSummary } from "../diagram.js";
12
+ import { project } from "../middleware.js";
13
+ /** Builds the architecture diagram and prints Mermaid, JSON, or the SVG path. */
14
+ export default createCommand(SDXC_COMMANDS.diagram, {
15
+ middleware: [project()],
16
+ /** Fails only when SVG rendering or writing fails; an empty project still prints a diagram. */
17
+ async handler(ctx) {
18
+ let result = await buildDiagram(ctx.project.root, {
19
+ svg: ctx.flags.svg,
20
+ title: "Architecture",
21
+ });
22
+ if (isFailure(result)) {
23
+ ctx.stderr(`${result.error.message}\n`);
24
+ return failure(result.error);
25
+ }
26
+ if (ctx.flags.json) {
27
+ ctx.stdout(`${JSON.stringify({
28
+ mermaid: result.data.mermaid,
29
+ modules: result.data.graph.modules,
30
+ edges: result.data.graph.edges,
31
+ layers: result.data.graph.layers,
32
+ cycles: result.data.graph.cycles,
33
+ violations: result.data.graph.violations,
34
+ svg: result.data.svgPath,
35
+ }, null, 2)}\n`);
36
+ return success();
37
+ }
38
+ if (result.data.svgPath) {
39
+ ctx.stdout(`${result.data.svgPath}\n`);
40
+ return success();
41
+ }
42
+ ctx.stdout(formatDiagramSummary(result.data.graph));
43
+ return success();
44
+ },
45
+ });
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The `sdxc fix` handlers: command-shaped repairs, `.env.example` secrets, and model/email
3
+ * registration through the same codemods `make` uses.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ /** `sdxc fix` with no member: command-shaped repairs from doctor. */
9
+ export declare const group: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Group<Omit<{
10
+ readonly description: "Apply doctor repairs the kit can make safely";
11
+ readonly flags: {
12
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
13
+ };
14
+ readonly env: import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
15
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
16
+ }>;
17
+ readonly models: import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
18
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
19
+ }>;
20
+ readonly emails: import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
21
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
22
+ }>;
23
+ }, "description" | "hidden" | "arguments" | "flags" | "tasks">, Record<never, never>, {
24
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
25
+ }>, readonly [import("@sdxc/cli").CommandMiddleware<{
26
+ key: typeof import("../middleware.js").CurrentProject;
27
+ value: import("../middleware.js").Project;
28
+ property: "project";
29
+ }>, import("@sdxc/cli").CommandMiddleware<{
30
+ key: typeof import("../middleware.js").PackageRoot;
31
+ value: string;
32
+ property: "packageRoot";
33
+ }>]>;
34
+ /** `sdxc fix env`. */
35
+ export declare const env: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
36
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
37
+ }>, readonly [import("@sdxc/cli").CommandMiddleware<{
38
+ key: typeof import("../middleware.js").CurrentProject;
39
+ value: import("../middleware.js").Project;
40
+ property: "project";
41
+ }>, import("@sdxc/cli").CommandMiddleware<{
42
+ key: typeof import("../middleware.js").PackageRoot;
43
+ value: string;
44
+ property: "packageRoot";
45
+ }>]>;
46
+ /** `sdxc fix models`. */
47
+ export declare const models: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
48
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
49
+ }>, readonly [import("@sdxc/cli").CommandMiddleware<{
50
+ key: typeof import("../middleware.js").CurrentProject;
51
+ value: import("../middleware.js").Project;
52
+ property: "project";
53
+ }>, import("@sdxc/cli").CommandMiddleware<{
54
+ key: typeof import("../middleware.js").PackageRoot;
55
+ value: string;
56
+ property: "packageRoot";
57
+ }>]>;
58
+ /** `sdxc fix emails`. */
59
+ export declare const emails: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
60
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
61
+ }>, readonly [import("@sdxc/cli").CommandMiddleware<{
62
+ key: typeof import("../middleware.js").CurrentProject;
63
+ value: import("../middleware.js").Project;
64
+ property: "project";
65
+ }>, import("@sdxc/cli").CommandMiddleware<{
66
+ key: typeof import("../middleware.js").PackageRoot;
67
+ value: string;
68
+ property: "packageRoot";
69
+ }>]>;