@sdxc/kit 2026.10.21 → 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 (104) hide show
  1. package/README.md +84 -4
  2. package/changelog.jsonl +86 -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 +10 -7
  103. package/registry/ui/attachment.json +2 -2
  104. package/templates/app/AGENTS.md +14 -1
@@ -0,0 +1,116 @@
1
+ /**
2
+ * `sdxc setup billing`: `@sdxc/billing` provider initializer, webhook route stub, checkout
3
+ * secrets and an empty product catalog.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ import { failure, isFailure, success } from "@sdxc/result";
9
+ import { CONFIG_FILE, ENV_EXAMPLE_FILE, declaredBindings, exampleKeys } from "../doctor/env.js";
10
+ import { creditSetupFiles } from "./credit.js";
11
+ import { readProjectFile } from "./plan.js";
12
+ /** Builds the billing setup plan for `provider` (currently only `polar`). */
13
+ export async function planBilling(root, provider) {
14
+ if (provider !== "polar") {
15
+ return failure(new Error(`Unknown billing provider "${provider}"; this release ships polar only`));
16
+ }
17
+ let config = await readProjectFile(root, CONFIG_FILE);
18
+ if (isFailure(config))
19
+ return config;
20
+ let example = await readProjectFile(root, ENV_EXAMPLE_FILE);
21
+ let exampleText = isFailure(example) ? "" : example.data;
22
+ let bindings = declaredBindings(config.data);
23
+ let listed = exampleKeys(exampleText);
24
+ let secrets = ["POLAR_ACCESS_TOKEN", "POLAR_WEBHOOK_SECRET"];
25
+ let configAfter = config.data;
26
+ let exampleAfter = exampleText;
27
+ let edits = [];
28
+ for (let key of secrets) {
29
+ if (!bindings.has(key)) {
30
+ let env = /env\s*:\s*\{/.exec(configAfter);
31
+ if (env === null || env.index === undefined) {
32
+ return failure(new Error(`${CONFIG_FILE} has no env: { … } block to edit`));
33
+ }
34
+ let start = env.index + env[0].length;
35
+ configAfter = `${configAfter.slice(0, start)}\n\t\t\t${key}: bindings.secret(),${configAfter.slice(start)}`;
36
+ }
37
+ if (!listed.has(key)) {
38
+ if (exampleAfter === "")
39
+ exampleAfter = `${key}=\n`;
40
+ else if (exampleAfter.endsWith("\n"))
41
+ exampleAfter = `${exampleAfter}${key}=\n`;
42
+ else
43
+ exampleAfter = `${exampleAfter}\n${key}=\n`;
44
+ }
45
+ }
46
+ if (configAfter !== config.data) {
47
+ edits.push({ path: CONFIG_FILE, before: config.data, after: configAfter });
48
+ }
49
+ if (exampleAfter !== exampleText) {
50
+ edits.push({ path: ENV_EXAMPLE_FILE, before: exampleText, after: exampleAfter });
51
+ }
52
+ let files = await creditSetupFiles(root, [
53
+ { path: "app/initializers/billing.ts", content: BILLING_INITIALIZER },
54
+ { path: "config/products.ts", content: PRODUCTS },
55
+ { path: "app/http/controllers/billing-webhook.ts", content: WEBHOOK },
56
+ ]);
57
+ return success({
58
+ feature: "billing",
59
+ provider,
60
+ files,
61
+ edits,
62
+ dependencies: ["@sdxc/billing"],
63
+ notes: [
64
+ "Map the webhook route and pass polar into the handlers that need it.",
65
+ "Replace the placeholder product ids in config/products.ts with Polar's.",
66
+ "Run sdxc run typegen after the secrets land.",
67
+ ],
68
+ });
69
+ }
70
+ const BILLING_INITIALIZER = `/**
71
+ * The billing platform this app sells through, configured once. Call sites name a product by
72
+ * our own slug; vendor ids live only here and in config/products.ts.
73
+ */
74
+
75
+ import { PolarBilling } from "@sdxc/billing/providers/polar";
76
+ import { env } from "cloudflare:workers";
77
+
78
+ import { PRODUCTS } from "~/config/products";
79
+
80
+ /** The billing platform, reached through the vendor-neutral contract. */
81
+ export const polar = new PolarBilling({
82
+ accessToken: () => env.POLAR_ACCESS_TOKEN,
83
+ webhookSecret: () => env.POLAR_WEBHOOK_SECRET,
84
+ products: PRODUCTS,
85
+ meters: {},
86
+ });
87
+ `;
88
+ const PRODUCTS = `/**
89
+ * Product slugs this app sells, mapped to the vendor's product ids. Fill the ids before the
90
+ * first checkout; call sites import the slug constants, never the vendor ids.
91
+ */
92
+
93
+ /** Our own name for the subscription sold, and the only product until more are added. */
94
+ export const DEFAULT_PRODUCT = "default";
95
+
96
+ /** Slug → Polar product id. Replace the placeholder before going live. */
97
+ export const PRODUCTS: Record<string, string> = {
98
+ [DEFAULT_PRODUCT]: "00000000-0000-4000-8000-000000000000",
99
+ };
100
+ `;
101
+ const WEBHOOK = `/**
102
+ * Polar webhook endpoint: verify the signature and hand the event to @sdxc/billing.
103
+ */
104
+
105
+ import { createController } from "remix/router";
106
+
107
+ import { polar } from "~/app/initializers/billing";
108
+
109
+ /** Accepts Polar webhook deliveries. */
110
+ export default createController({
111
+ async post(ctx) {
112
+ await polar.webhooks.handle(ctx.request);
113
+ return new Response(null, { status: 204 });
114
+ },
115
+ });
116
+ `;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Features `sdxc setup` can install: each row names what the plan wires, so agents discover
3
+ * the catalog the same way they discover `make` kinds.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ /** One feature this kit release knows how to set up. */
9
+ export interface SetupFeature {
10
+ /** The verb after `sdxc setup`, such as `auth`. */
11
+ name: string;
12
+ /** One sentence of what it wires. */
13
+ description: string;
14
+ /** Provider flag values this feature accepts; empty when it has none. */
15
+ providers: readonly string[];
16
+ /** Default `--provider` when the feature has providers. */
17
+ defaultProvider?: string;
18
+ }
19
+ /**
20
+ * Features shipped in this kit release. Further rows land only when their planner has a
21
+ * deterministic file list a test can assert.
22
+ */
23
+ export declare const SETUP_FEATURES: readonly SetupFeature[];
24
+ /** Looks up a feature by name, or `null` when this release does not ship it. */
25
+ export declare function setupFeature(name: string): SetupFeature | null;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Features `sdxc setup` can install: each row names what the plan wires, so agents discover
3
+ * the catalog the same way they discover `make` kinds.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ /**
9
+ * Features shipped in this kit release. Further rows land only when their planner has a
10
+ * deterministic file list a test can assert.
11
+ */
12
+ export const SETUP_FEATURES = [
13
+ {
14
+ name: "auth",
15
+ description: "OIDC relying party, login/callback/logout, client secrets, CSP formAction, signIn() helper",
16
+ providers: ["r3-auth"],
17
+ defaultProvider: "r3-auth",
18
+ },
19
+ {
20
+ name: "billing",
21
+ description: "@sdxc/billing provider, webhook route stub, portal/checkout secrets, empty product catalog",
22
+ providers: ["polar"],
23
+ defaultProvider: "polar",
24
+ },
25
+ {
26
+ name: "flags",
27
+ description: "@sdxc/flags + engine store, empty catalog, wide-event hook ready for router middleware",
28
+ providers: [],
29
+ },
30
+ ];
31
+ /** Looks up a feature by name, or `null` when this release does not ship it. */
32
+ export function setupFeature(name) {
33
+ return SETUP_FEATURES.find((feature) => feature.name === name) ?? null;
34
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Credits setup-written files the way `make` stubs do: `@author` / `@copyright` from the
3
+ * project's package.json `author` or git `user.name`, never a kit maintainer hardcoded in.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ import type { SetupFile } from "./plan.js";
9
+ /**
10
+ * Returns `files` with each module JSDoc closed by the project's author tags. A project with
11
+ * no resolvable author leaves the sources unchanged.
12
+ */
13
+ export declare function creditSetupFiles(root: string, files: readonly SetupFile[]): Promise<SetupFile[]>;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Credits setup-written files the way `make` stubs do: `@author` / `@copyright` from the
3
+ * project's package.json `author` or git `user.name`, never a kit maintainer hardcoded in.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ import { addHeaderTags, headerTags, resolveAuthor } from "../author.js";
9
+ /**
10
+ * Returns `files` with each module JSDoc closed by the project's author tags. A project with
11
+ * no resolvable author leaves the sources unchanged.
12
+ */
13
+ export async function creditSetupFiles(root, files) {
14
+ let tags = headerTags(await resolveAuthor(root));
15
+ if (tags === "")
16
+ return [...files];
17
+ return files.map((file) => ({
18
+ path: file.path,
19
+ content: addHeaderTags(file.content, tags),
20
+ }));
21
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * `sdxc setup flags`: `@sdxc/flags` + engine store, empty catalog and a wide-event hook ready
3
+ * for the router / dispatcher middleware.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ import type { Result } from "@sdxc/result";
9
+ import type { SetupPlan } from "./plan.js";
10
+ /** Builds the flags setup plan. */
11
+ export declare function planFlags(root: string): Promise<Result<SetupPlan, Error>>;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * `sdxc setup flags`: `@sdxc/flags` + engine store, empty catalog and a wide-event hook ready
3
+ * for the router / dispatcher middleware.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ import { success } from "@sdxc/result";
9
+ import { creditSetupFiles } from "./credit.js";
10
+ /** Builds the flags setup plan. */
11
+ export async function planFlags(root) {
12
+ let files = await creditSetupFiles(root, [
13
+ { path: "app/initializers/flags.ts", content: FLAGS_INITIALIZER },
14
+ ]);
15
+ return success({
16
+ feature: "flags",
17
+ provider: null,
18
+ files,
19
+ edits: [],
20
+ dependencies: ["@sdxc/flags", "@sdxc/flags-engine"],
21
+ notes: [
22
+ "Install the flags instance on the router and job dispatcher with the package's middleware.",
23
+ "Add flag definitions to FLAG_SET and features as product needs them.",
24
+ ],
25
+ });
26
+ }
27
+ const FLAGS_INITIALIZER = `/**
28
+ * The app's feature flags: the definitions every evaluation resolves against, the typed
29
+ * catalog a call site names one by, and the instance both surfaces evaluate through.
30
+ */
31
+
32
+ import type { StoredFlagSet } from "@sdxc/flags-engine/store";
33
+
34
+ import { createEngine } from "@sdxc/flags-engine";
35
+ import { EngineProvider } from "@sdxc/flags-engine/provider";
36
+ import { InMemoryFlagStore } from "@sdxc/flags-engine/store/memory";
37
+ import { defineFlags } from "@sdxc/flags/catalog";
38
+ import { createFlags, wideEventHook } from "@sdxc/flags/client";
39
+
40
+ /**
41
+ * What every evaluation resolves against. A key absent from here resolves to the default
42
+ * its call site passed, so retiring a flag is deleting its entry and then its branch.
43
+ */
44
+ export const FLAG_SET: StoredFlagSet = {
45
+ flags: {},
46
+ };
47
+
48
+ /**
49
+ * Every flag by the name a call site reaches for. Add entries with \`flag.boolean\` /
50
+ * \`flag.number\` / \`flag.string\` as product needs them.
51
+ */
52
+ export const features = defineFlags({});
53
+
54
+ /**
55
+ * The instance both surfaces evaluate through, installed by the router's middleware and
56
+ * the job dispatcher's.
57
+ */
58
+ export const flags = createFlags({
59
+ provider: new EngineProvider(createEngine({ store: new InMemoryFlagStore(FLAG_SET) })),
60
+ hooks: [wideEventHook()],
61
+ });
62
+ `;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * `sdxc setup`: feature installers that span app code and config — list known features, print
3
+ * a plan, and with confirmation write every path the feature needs.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ import type { Result } from "@sdxc/result";
9
+ import type { SetupPlan } from "./plan.js";
10
+ export { SETUP_FEATURES, setupFeature } from "./catalog.js";
11
+ export { applyPlan, formatPlan } from "./plan.js";
12
+ export type { SetupPlan } from "./plan.js";
13
+ /** Lists the features this kit release knows, one line each. */
14
+ export declare function listFeatures(): string;
15
+ /**
16
+ * Plans `feature` for the project at `root`. Unknown features fail naming the catalog.
17
+ */
18
+ export declare function planSetup(root: string, feature: string, provider: string | undefined): Promise<Result<SetupPlan, Error>>;
19
+ /** Plans then applies, returning early when the plan itself fails. */
20
+ export declare function runSetup(root: string, feature: string, options: {
21
+ provider: string | undefined;
22
+ dryRun: boolean;
23
+ yes: boolean;
24
+ stdout: (text: string) => void;
25
+ }): Promise<Result<void, Error>>;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * `sdxc setup`: feature installers that span app code and config — list known features, print
3
+ * a plan, and with confirmation write every path the feature needs.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ import { failure, isFailure } from "@sdxc/result";
9
+ import { planAuth } from "./auth.js";
10
+ import { planBilling } from "./billing.js";
11
+ import { SETUP_FEATURES, setupFeature } from "./catalog.js";
12
+ import { planFlags } from "./flags.js";
13
+ import { applyPlan } from "./plan.js";
14
+ export { SETUP_FEATURES, setupFeature } from "./catalog.js";
15
+ export { applyPlan, formatPlan } from "./plan.js";
16
+ /** Lists the features this kit release knows, one line each. */
17
+ export function listFeatures() {
18
+ return (SETUP_FEATURES.map((feature) => `${feature.name.padEnd(10)} ${feature.description}`).join("\n") + "\n");
19
+ }
20
+ /**
21
+ * Plans `feature` for the project at `root`. Unknown features fail naming the catalog.
22
+ */
23
+ export async function planSetup(root, feature, provider) {
24
+ let known = setupFeature(feature);
25
+ if (known === null) {
26
+ return failure(new Error(`Unknown setup feature "${feature}"; this release ships ${SETUP_FEATURES.map((row) => row.name).join(", ")}`));
27
+ }
28
+ let chosen = provider ??
29
+ known.defaultProvider ??
30
+ (known.providers.length === 1 ? known.providers[0] : undefined);
31
+ if (known.providers.length > 0 && chosen === undefined) {
32
+ return failure(new Error(`setup ${feature} needs --provider ${known.providers.join("|")} (default: ${known.defaultProvider})`));
33
+ }
34
+ if (known.providers.length > 0 && chosen !== undefined && !known.providers.includes(chosen)) {
35
+ return failure(new Error(`Unknown ${feature} provider "${chosen}"; choose ${known.providers.join(", ")}`));
36
+ }
37
+ if (feature === "auth")
38
+ return planAuth(root, chosen ?? "r3-auth");
39
+ if (feature === "billing")
40
+ return planBilling(root, chosen ?? "polar");
41
+ if (feature === "flags")
42
+ return planFlags(root);
43
+ return failure(new Error(`setup ${feature} is listed but has no planner yet`));
44
+ }
45
+ /** Plans then applies, returning early when the plan itself fails. */
46
+ export async function runSetup(root, feature, options) {
47
+ let planned = await planSetup(root, feature, options.provider);
48
+ if (isFailure(planned))
49
+ return planned;
50
+ /** Without `-y`, the plan is printed and nothing is written — the agent-safe default. */
51
+ let dryRun = !options.yes || options.dryRun;
52
+ return applyPlan(root, planned.data, { dryRun, stdout: options.stdout });
53
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Shared setup plan: every path a feature will write or edit, printed before confirmation so
3
+ * `--dry-run` is the default agent path until `-y` asks to write.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ import type { Result } from "@sdxc/result";
9
+ /** One new file the plan writes. */
10
+ export interface SetupFile {
11
+ path: string;
12
+ content: string;
13
+ }
14
+ /** One existing file the plan edits. */
15
+ export interface SetupEdit {
16
+ path: string;
17
+ before: string;
18
+ after: string;
19
+ }
20
+ /** The full plan for one `sdxc setup <feature>` run. */
21
+ export interface SetupPlan {
22
+ feature: string;
23
+ provider: string | null;
24
+ files: SetupFile[];
25
+ edits: SetupEdit[];
26
+ /** Packages to add as `workspace:*` / dated pins when missing. */
27
+ dependencies: string[];
28
+ notes: string[];
29
+ }
30
+ /** Prints the plan as the operator and agent read it. */
31
+ export declare function formatPlan(plan: SetupPlan): string;
32
+ /** Writes the plan's files and edits; under `dryRun` prints diffs and changes nothing. */
33
+ export declare function applyPlan(root: string, plan: SetupPlan, options: {
34
+ dryRun: boolean;
35
+ stdout: (text: string) => void;
36
+ }): Promise<Result<void, Error>>;
37
+ /** Reads a project file, or fails naming the path. */
38
+ export declare function readProjectFile(root: string, path: string): Promise<Result<string, Error>>;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Shared setup plan: every path a feature will write or edit, printed before confirmation so
3
+ * `--dry-run` is the default agent path until `-y` asks to write.
4
+ *
5
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
6
+ * @copyright Sergio Xalambrí 2026
7
+ */
8
+ import { access, mkdir, readFile, writeFile } from "node:fs/promises";
9
+ import { dirname, join } from "node:path";
10
+ import { failure, isFailure, isSuccess, success, wrap } from "@sdxc/result";
11
+ import { unifiedDiff } from "../diff.js";
12
+ /** Prints the plan as the operator and agent read it. */
13
+ export function formatPlan(plan) {
14
+ let lines = [
15
+ `setup ${plan.feature}${plan.provider === null ? "" : ` --provider ${plan.provider}`}`,
16
+ ];
17
+ for (let file of plan.files)
18
+ lines.push(` write ${file.path}`);
19
+ for (let edit of plan.edits)
20
+ lines.push(` edit ${edit.path}`);
21
+ for (let dependency of plan.dependencies)
22
+ lines.push(` depend ${dependency}`);
23
+ for (let note of plan.notes)
24
+ lines.push(` note ${note}`);
25
+ return `${lines.join("\n")}\n`;
26
+ }
27
+ /** Writes the plan's files and edits; under `dryRun` prints diffs and changes nothing. */
28
+ export async function applyPlan(root, plan, options) {
29
+ if (options.dryRun) {
30
+ options.stdout(formatPlan(plan));
31
+ for (let file of plan.files) {
32
+ options.stdout(unifiedDiff(file.path, null, file.content));
33
+ }
34
+ for (let edit of plan.edits) {
35
+ options.stdout(unifiedDiff(edit.path, edit.before, edit.after));
36
+ }
37
+ return success(undefined);
38
+ }
39
+ for (let file of plan.files) {
40
+ let target = join(root, file.path);
41
+ if (isSuccess(await wrap(() => access(target)))) {
42
+ return failure(new Error(`${file.path} already exists; refuse to overwrite a hand-edited file`));
43
+ }
44
+ await mkdir(dirname(target), { recursive: true });
45
+ await writeFile(target, file.content);
46
+ options.stdout(`wrote ${file.path}\n`);
47
+ }
48
+ for (let edit of plan.edits) {
49
+ await writeFile(join(root, edit.path), edit.after);
50
+ options.stdout(`edited ${edit.path}\n`);
51
+ }
52
+ for (let note of plan.notes)
53
+ options.stdout(`${note}\n`);
54
+ return success(undefined);
55
+ }
56
+ /** Reads a project file, or fails naming the path. */
57
+ export async function readProjectFile(root, path) {
58
+ let source = await wrap(() => readFile(join(root, path), "utf8"));
59
+ if (isFailure(source))
60
+ return failure(new Error(`No ${path} in the project`));
61
+ return success(source.data);
62
+ }
package/dist/testing.js CHANGED
@@ -133,7 +133,7 @@ async function installed(packageRoot, dependency) {
133
133
  }
134
134
  /** Runs a script with `args` in `cwd` under `runtime`, Node by default, collecting both output streams. */
135
135
  function run(args, cwd, runtime = process.execPath) {
136
- return new Promise((settle) => {
136
+ return new Promise((resolve) => {
137
137
  let output = "";
138
138
  let child = spawn(runtime, args, { cwd, shell: false });
139
139
  child.stdout.on("data", (chunk) => {
@@ -142,7 +142,7 @@ function run(args, cwd, runtime = process.execPath) {
142
142
  child.stderr.on("data", (chunk) => {
143
143
  output += chunk.toString();
144
144
  });
145
- child.once("error", (error) => settle({ code: null, output: error.message }));
146
- child.once("close", (code) => settle({ code, output }));
145
+ child.once("error", (error) => resolve({ code: null, output: error.message }));
146
+ child.once("close", (code) => resolve({ code, output }));
147
147
  });
148
148
  }
package/dist/ui/layout.js CHANGED
@@ -111,7 +111,7 @@ async function readCompilerOptions(path, depth) {
111
111
  let options = await readCompilerOptions(file, depth + 1);
112
112
  if (isFailure(options))
113
113
  return options;
114
- inherited = { ...inherited, ...options.data };
114
+ Object.assign(inherited, options.data);
115
115
  }
116
116
  }
117
117
  let own = config.compilerOptions ?? {};
@@ -18,12 +18,12 @@ export declare const REGISTRY_ENTRY: s.Schema<{
18
18
  path: string;
19
19
  content: string;
20
20
  };
21
+ exports: string[];
21
22
  test: {
22
23
  path: string;
23
24
  content: string;
24
25
  } | null;
25
26
  changedIn: string;
26
- exports: string[];
27
27
  }, {
28
28
  name: string;
29
29
  dependencies: string[];
@@ -31,12 +31,12 @@ export declare const REGISTRY_ENTRY: s.Schema<{
31
31
  path: string;
32
32
  content: string;
33
33
  };
34
+ exports: string[];
34
35
  test: {
35
36
  path: string;
36
37
  content: string;
37
38
  } | null;
38
39
  changedIn: string;
39
- exports: string[];
40
40
  }>;
41
41
  /** A component as the installed release ships it. */
42
42
  export type RegistryEntry = s.InferOutput<typeof REGISTRY_ENTRY>;
@@ -12,16 +12,16 @@ declare const MANIFEST_SCHEMA: s.Schema<{
12
12
  name?: string | undefined;
13
13
  dependencies?: Record<string, string> | undefined;
14
14
  devDependencies?: Record<string, string> | undefined;
15
+ optionalDependencies?: Record<string, string> | undefined;
15
16
  packageManager?: string | undefined;
16
17
  scripts?: Record<string, string> | undefined;
17
- optionalDependencies?: Record<string, string> | undefined;
18
18
  }, {
19
19
  name?: string | undefined;
20
20
  dependencies?: Record<string, string> | undefined;
21
21
  devDependencies?: Record<string, string> | undefined;
22
+ optionalDependencies?: Record<string, string> | undefined;
22
23
  packageManager?: string | undefined;
23
24
  scripts?: Record<string, string> | undefined;
24
- optionalDependencies?: Record<string, string> | undefined;
25
25
  }>;
26
26
  /** The project's `package.json` fields the upgrade reads. */
27
27
  export type Manifest = s.InferOutput<typeof MANIFEST_SCHEMA>;
@@ -225,11 +225,13 @@ function agentsNote(input) {
225
225
  }
226
226
  let url = `${PACKAGE_FILES}/${RELEASE_PACKAGE}@${input.to}/${AGENTS_TEMPLATE}`;
227
227
  let markers = "`<!-- sdxc:start …-->` and `<!-- sdxc:end -->`";
228
- let state = input.agents === "missing"
229
- ? `This project has no \`${AGENTS_FILE}\`.`
230
- : input.agents === "unmarked"
231
- ? `\`${AGENTS_FILE}\` has no sdxc section, so the upgrade left it as it is.`
232
- : `\`${AGENTS_FILE}\` needs exactly one ${markers} line pair, so the upgrade left it as it is.`;
228
+ let state;
229
+ if (input.agents === "missing")
230
+ state = `This project has no \`${AGENTS_FILE}\`.`;
231
+ else if (input.agents === "unmarked")
232
+ state = `\`${AGENTS_FILE}\` has no sdxc section, so the upgrade left it as it is.`;
233
+ else
234
+ state = `\`${AGENTS_FILE}\` needs exactly one ${markers} line pair, so the upgrade left it as it is.`;
233
235
  let action = input.agents === "unbalanced"
234
236
  ? `Restore one pair around the sdxc section, which for release ${input.to} is in ${url}.`
235
237
  : `When this project is an app in the sdxc layout (it has \`bootstrap/worker.ts\`), add the section from ${url}, ${markers} lines included, to \`${AGENTS_FILE}\`, creating the file if needed; \`sdxc upgrade\` then keeps it current.`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdxc/kit",
3
- "version": "2026.10.21",
3
+ "version": "2026.10.23",
4
4
  "description": "The sdxc command line: start a Remix v3 app, generate its files, copy UI components into it and upgrade it",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -14,19 +14,22 @@
14
14
  "./lock.schema.json": "./lock.schema.json"
15
15
  },
16
16
  "dependencies": {
17
- "@sdxc/cli": "2026.10.20",
18
- "@sdxc/codemod": "2026.10.20",
19
- "@sdxc/cron": "2026.10.13",
20
- "@sdxc/json-schema": "2026.10.16",
17
+ "@sdxc/cli": "2026.10.23",
18
+ "@sdxc/codemod": "2026.10.23",
19
+ "@sdxc/cron": "2026.10.23",
20
+ "@sdxc/diagram": "2026.10.23",
21
+ "@sdxc/iife": "2026.10.23",
22
+ "@sdxc/json-schema": "2026.10.23",
21
23
  "@sdxc/jsonc": "2026.10.16",
22
24
  "@sdxc/jsonl": "2026.10.16",
23
25
  "@sdxc/result": "2026.10.13",
24
- "@sdxc/semver": "2026.10.13"
26
+ "@sdxc/semver": "2026.10.13",
27
+ "oxc-parser": "^0.154.0"
25
28
  },
26
29
  "peerDependencies": {
27
30
  "remix": "3.0.0"
28
31
  },
29
- "gitHead": "b64617ec8a697696a1fe6fb0f704fb9017b6a7a0",
32
+ "gitHead": "8e428ddf15290d44500a9618ec4d04bd7629fa99",
30
33
  "publishConfig": {
31
34
  "access": "public"
32
35
  },