create-stitchkit 0.6.23 → 0.7.0

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.
package/CHANGELOG.md CHANGED
@@ -12,6 +12,55 @@ step is overwritten by the next release.
12
12
 
13
13
  ## [Unreleased]
14
14
 
15
+ ## [0.7.0] - 2026-11-25
16
+
17
+ ### ⚠️ Breaking changes
18
+
19
+ **Who must act:** every project scaffolded from an earlier `create-stitchkit` release that still keeps local copies of `surface-manifest.ts` / `surface-conformance.ts` or mounts MCP, Agent or CLI tools without an explicit `access` policy ([migration](./UPGRADING.md#starter-uses-stitchkittesting-and-mandatory-tool-access)).
20
+
21
+ - Removed the local copies of the framework's surface manifest and conformance runner from
22
+ the application template (`packages/backend/src/surface-manifest.ts`,
23
+ `packages/backend/src/surface-manifest.test.ts`, and `scripts/surface-conformance.ts`).
24
+ `scripts/surface-snapshot.ts` and `scripts/runtime-smoke.ts` now import
25
+ `buildSurfaceManifest`, `assertSurfaceManifestSnapshot`, `assertSurfaceDiscovery`,
26
+ `SurfaceManifestSchema`, and `runSurfaceProbes` directly from `stitchkit/testing`, and
27
+ `packages/backend/src/surface.snapshot.json` uses the canonical `manifestVersion: 3`
28
+ format. Before: `import { runSurfaceConformance } from './surface-conformance'`. After:
29
+ `import { assertLiveSurface } from './surface-snapshot'` and
30
+ `import { runSurfaceProbes } from 'stitchkit/testing'`. Existing projects adopt it by
31
+ [`UPGRADING.md`](./UPGRADING.md#starter-uses-stitchkittesting-and-mandatory-tool-access).
32
+ - Updated tool mounts in the application and agent templates for mandatory `access` and
33
+ `ToolNameEntry.expose`: `packages/backend/src/index.ts` passes `access: { open: 'public' }`
34
+ to `createMcpHandler`, `packages/backend/src/cli.ts` passes
35
+ `access: { open: 'local-operator' }` to `createCli`, `packages/backend/src/tools.ts` reads
36
+ `tool.expose`, and `templates/agent/src/runtime.ts` passes
37
+ `access: { gate: context.toolFenceLifecycle }` to `mountAgent`. Before:
38
+ `createCli({ name, version, services })` and `mountAgent([], { runtimeTools, lifecycle: context.toolFenceLifecycle })`.
39
+ After: `createCli({ name, version, services, access: { open: 'local-operator' } })` and
40
+ `mountAgent([], { runtimeTools, access: { gate: context.toolFenceLifecycle } })`.
41
+
42
+ ### Added
43
+
44
+ - Newly scaffolded projects record the `create-stitchkit` package version in `project.json`
45
+ under `starter: { version }` (validated by `ProjectDeclarationSchema` in
46
+ `stitchkit/declaration`).
47
+
48
+ ### Fixed
49
+
50
+ - `acceptance:local` gives the realtime socket and the CORS admission this run's
51
+ ephemeral ports. It moved every role to ephemeral ports but kept
52
+ `PUBLIC_REALTIME_ORIGIN` and `CORS_ORIGIN` from `.env`, so on a machine where
53
+ another process listened on 3210 or 3211 the browser under test opened that
54
+ process's socket. The environment is built by `scripts/acceptance-environment.ts`,
55
+ and a test refuses any variable of `.env.example` that would still name a
56
+ deployment port. An existing project adopts it by
57
+ [`UPGRADING.md`](./UPGRADING.md#acceptance-owns-every-address).
58
+ - The package and the projects generated from it no longer carry
59
+ `.data/board.sqlite`, the reference board's local database, and a generated
60
+ project ignores `.data/`. The documents describe the default scaffold as it is:
61
+ one reference feature, a notes board, beside the `/ui` catalogue and an admin
62
+ panel on fixture data, and the template README names what depends on the board.
63
+
15
64
  ## [0.6.23] - 2026-11-21
16
65
 
17
66
  ### Changed
package/README.md CHANGED
@@ -55,7 +55,15 @@ It uses one conventional `packages/*` namespace: `backend`, `frontend`,
55
55
  machine-readable statement it makes about itself — and drive package, process,
56
56
  transport, UI and SEO identity.
57
57
 
58
- The default scaffold is domain-free. To add the runnable repository example:
58
+ The default scaffold carries no product of its own, but it is not empty. Its home
59
+ page holds one reference vertical feature — a notes board: schema, contract,
60
+ service, live channel, panel and the end-to-end check that a note posted in one
61
+ tab reaches another through the socket — beside the `/ui` catalogue and an admin
62
+ panel on fixture data that runs in development only. Replace the board with your
63
+ first feature; `docs/ADDING_A_FEATURE.md` in the generated project walks the same
64
+ slice, and its README lists what depends on the board.
65
+
66
+ To add the runnable repository example:
59
67
 
60
68
  ```bash
61
69
  bun create stitchkit my-app --example repository
package/UPGRADING.md CHANGED
@@ -26,9 +26,10 @@ changelog because the next release overwrites the entry that carried them.
26
26
 
27
27
  ## Flow
28
28
 
29
- 1. **Find your project's origin.** The scaffolder version that generated it is
30
- not recorded in the tree — check the changelog of the version you scaffolded
31
- with, or diff your tree against a fresh scaffold of your current target.
29
+ 1. **Find your project's origin.** Check `starter.version` in your repository's
30
+ `project.json` (recorded by the scaffolder). Earlier projects that omit
31
+ `starter` can check the changelog of the version they scaffolded with, or
32
+ diff their tree against a fresh scaffold of the target version.
32
33
  2. **Read every `### ⚠️ Breaking changes` in range** in
33
34
  [`CHANGELOG.md`](./CHANGELOG.md), from the version above yours up to your
34
35
  target.
@@ -60,11 +61,65 @@ the first scaffolder release with a migration channel of its own.
60
61
 
61
62
  ---
62
63
 
64
+ ## Released migration: 0.7.0
65
+
66
+ ### starter uses stitchkit/testing and mandatory tool access
67
+
68
+ **Required.** Adopt these edits together with upgrading `stitchkit` to `0.127.0`
69
+ (see [`docs/guide/upgrading.md`](../../docs/guide/upgrading.md) for the framework changes).
70
+
71
+ 1. Remove the copied surface helpers from your repository:
72
+ - Delete `packages/backend/src/surface-manifest.ts`,
73
+ `packages/backend/src/surface-manifest.test.ts`, and
74
+ `scripts/surface-conformance.ts`.
75
+ - Replace `scripts/surface-snapshot.ts` with the template version that imports
76
+ `buildSurfaceManifest`, `assertSurfaceManifestSnapshot`, `assertSurfaceDiscovery`,
77
+ and `SurfaceManifestSchema` from `stitchkit/testing`.
78
+ - Update `scripts/runtime-smoke.ts` to call `assertLiveSurface` from `./surface-snapshot`
79
+ and `runSurfaceProbes` from `stitchkit/testing` instead of `runSurfaceConformance` /
80
+ `defineSurfaceProbe`.
81
+ - Regenerate and review `packages/backend/src/surface.snapshot.json` with
82
+ `bun run surface:snapshot` (the snapshot moves to `manifestVersion: 3`).
83
+ 2. Pass explicit `access` on every tool mount:
84
+ - In `packages/backend/src/index.ts`, add `access: { open: 'public' }` (or
85
+ `access: { gate: { beforeHandle: authHook } }` when your app has authenticated
86
+ scopes) to `createMcpHandler(...)`.
87
+ - In `packages/backend/src/cli.ts`, add `access: { open: 'local-operator' }` (or your
88
+ app's gate) to `createCli(...)`.
89
+ - In an agent-template project (`src/runtime.ts`), replace
90
+ `lifecycle: context.toolFenceLifecycle` with
91
+ `access: { gate: context.toolFenceLifecycle }` in `mountAgent(...)`.
92
+ 3. In `packages/backend/src/tools.ts`, read `tool.expose` instead of `tool.transports`.
93
+ 4. Optional: record your starter origin in `project.json` under `"starter": { "version": "<version>" }`.
94
+ 5. Run `bun run check`, `bun run test`, and `bun run surface:snapshot` to confirm the
95
+ regenerated snapshot and checks pass.
96
+
97
+ ### acceptance owns every address
98
+
99
+ **Voluntary.** Worth taking on a machine that runs other projects. Without it,
100
+ `bun run acceptance:local` can test the socket of whatever else listens on the
101
+ ports in your `.env`.
102
+
103
+ 1. In `scripts/acceptance-local.ts`, in the object the environment is assigned,
104
+ add next to `PLAYWRIGHT_BASE_URL`:
105
+
106
+ ```ts
107
+ PUBLIC_REALTIME_ORIGIN: apiOrigin,
108
+ CORS_ORIGIN: webOrigin,
109
+ ```
110
+
111
+ Or take the whole file `scripts/acceptance-environment.ts` and its test from a
112
+ project generated by this release, and build the environment with it.
113
+ 2. Add `.data/` to `.gitignore`. If `.data/board.sqlite` is committed, remove it
114
+ from the repository; the board recreates it on start.
115
+ 3. Run `bun run acceptance:local` with something listening on 127.0.0.1:3211 and
116
+ check the run still passes.
117
+
63
118
  ## Released migration: 0.6.23
64
119
 
65
120
  ### watch hub reads one request
66
121
 
67
- Take it together with stitchkit 0.126.0, whose `createWatchHub` passes `read` one
122
+ **With stitchkit 0.126.0.** Take it together with stitchkit 0.126.0, whose `createWatchHub` passes `read` one
68
123
  `{ operation, args, scope, signal }` request; on 0.125.0 and earlier the entry does not compile.
69
124
 
70
125
  1. In `packages/backend/src/lib/live.ts`, change `read: async (operation) =>` to
@@ -77,7 +132,7 @@ Take it together with stitchkit 0.126.0, whose `createWatchHub` passes `read` on
77
132
 
78
133
  ### unknown operation keeps the not_found wire code
79
134
 
80
- Take it together with the stitchkit release that answers an unmatched route
135
+ **With stitchkit 0.123.0.** Take it together with stitchkit 0.123.0, which answers an unmatched route
81
136
  `UNKNOWN_OPERATION`; on an earlier stitchkit the entry is inert.
82
137
 
83
138
  1. In `packages/backend/src/transport/errors.ts`, add `UNKNOWN_OPERATION: 'not_found'` to
@@ -88,7 +143,7 @@ Take it together with the stitchkit release that answers an unmatched route
88
143
 
89
144
  ### supervision passes declared environment
90
145
 
91
- Additive, and worth taking: without it a changed `.env` stays stale in a running role until
146
+ **Voluntary.** Additive, and worth taking: without it a changed `.env` stays stale in a running role until
92
147
  `pm2 delete`.
93
148
 
94
149
  1. In `scripts/declaration.ts`, after the `config({ path: … })` call that `renderEcosystem`
@@ -104,8 +159,8 @@ Additive, and worth taking: without it a changed `.env` stays stale in a running
104
159
 
105
160
  ### Canonical query client factory
106
161
 
107
- This migration is additive, but it has a dependency order: first upgrade to a
108
- Stitchkit release that exports `createQueryClientFactory` from
162
+ **With stitchkit 0.81.0.** This migration is additive, but it has a dependency order: first upgrade to a
163
+ Stitchkit release (0.81.0+) that exports `createQueryClientFactory` from
109
164
  `stitchkit/react`. Then replace the local QueryClient construction with:
110
165
 
111
166
  ```ts
@@ -132,7 +187,7 @@ start.
132
187
 
133
188
  ### 1. The store directory has to be writable
134
189
 
135
- `BOARD_STORE_PATH` defaults to `.data/board.sqlite`, relative to the API role's
190
+ **Voluntary.** Required as an operator step when adopting the vertical feature: `BOARD_STORE_PATH` defaults to `.data/board.sqlite`, relative to the API role's
136
191
  working directory. The application creates the directory itself; what it cannot
137
192
  do is make a read-only volume writable.
138
193
 
@@ -146,7 +201,7 @@ volume instead.
146
201
 
147
202
  ### 2. Decide about the trust fence, on purpose
148
203
 
149
- `TRUSTED_HOSTS` is unset by default, and unset means **no fence**. That is
204
+ **Voluntary.** Required as an operator step when deploying over a network: `TRUSTED_HOSTS` is unset by default, and unset means **no fence**. That is
150
205
  correct on a laptop and wrong on anything a network reaches — but a fence cannot
151
206
  guess which names your deployment answers to, so it refuses to invent them.
152
207
 
@@ -162,7 +217,7 @@ and the fence reads that one rather than asking you a second time.
162
217
 
163
218
  ### 3. Nothing else
164
219
 
165
- The rest of the feature is code you either copy or do not. The framework range
220
+ **Voluntary.** The rest of the feature is code you either copy or do not. The framework range
166
221
  moved to `^0.76.1`; if you upgrade the dependency without taking the feature,
167
222
  [the framework's own guide](../../docs/guide/upgrading.md) is the one to follow.
168
223
 
@@ -170,7 +225,7 @@ moved to `^0.76.1`; if you upgrade the dependency without taking the feature,
170
225
 
171
226
  ### the approval policy names a tool that no longer exists
172
227
 
173
- One code edit, and one thing to do to a machine that was left mid-question.
228
+ **With stitchkit 0.71.0.** One code edit, and one thing to do to a machine that was left mid-question.
174
229
 
175
230
  1. **Rename the key.** In `src/runtime.ts`, inside `loop.toolApproval`, replace
176
231
  `apply_patch: 'user-approval'` with `edit_file: 'user-approval'`. While you
@@ -204,7 +259,7 @@ One code edit, and one thing to do to a machine that was left mid-question.
204
259
 
205
260
  ### the timestamp your API accepts got narrower
206
261
 
207
- Zod moved to 4.5, and `z.iso.datetime()` now requires seconds. This is not a
262
+ **Required.** Zod moved to 4.5, and `z.iso.datetime()` now requires seconds. This is not a
208
263
  code change — it is a change in what your endpoints admit, and it arrives the
209
264
  moment you install.
210
265
 
@@ -235,7 +290,7 @@ moment you install.
235
290
 
236
291
  ### a release refuses a stale artifact, and cleanup is bounded
237
292
 
238
- Two changes an existing project should take, both about a shutdown or a start
293
+ **Voluntary.** Two changes an existing project should take, both about a shutdown or a start
239
294
  that looked safe and was not.
240
295
 
241
296
  1. **Stamp the build.** Copy `scripts/build-stamp.ts` from a fresh scaffold,
@@ -263,7 +318,7 @@ No operator step: nothing about a running machine changes.
263
318
 
264
319
  ### the gate list runs, and never deploys
265
320
 
266
- The `Gates` list in the generated guides presented five commands in a row, two
321
+ **Voluntary.** The `Gates` list in the generated guides presented five commands in a row, two
267
322
  of which check a **running** deployment — with nothing in the list that starts
268
323
  one. The fix is not to add a deploy command: `bun run pm2:prod` applies your
269
324
  declared migrations and reloads the deployment you are running, so a list that
@@ -311,7 +366,7 @@ No operator step: nothing about a running machine changes.
311
366
 
312
367
  ### the declaration schema is imported
313
368
 
314
- For a project generated **before** the scaffolder version that drops the schema
369
+ **With stitchkit 0.60.0.** For a project generated **before** the scaffolder version that drops the schema
315
370
  mirror. Nothing in your tree stops working if you skip this — the copy keeps
316
371
  parsing. What you lose by skipping is the guarantee: your copy no longer moves
317
372
  when the framework's schema does, and nothing tells you.
@@ -352,7 +407,7 @@ No operator step: nothing about a running machine changes.
352
407
 
353
408
  ### the project declares itself
354
409
 
355
- Everything in this section is for a project generated **before** the scaffolder
410
+ **Required.** Everything in this section is for a project generated **before** the scaffolder
356
411
  version that introduces `project.json`.
357
412
 
358
413
  #### The declaration replaces `app.config.json`
package/dist/cli.js CHANGED
@@ -10,8 +10,12 @@ var {spawn } = globalThis.Bun;
10
10
  import { basename } from "path";
11
11
 
12
12
  // ../core/src/declaration/declaration.ts
13
+ import { z as z2 } from "zod";
14
+
15
+ // ../core/src/declaration/command.ts
13
16
  import { z } from "zod";
14
- var PROJECT_DECLARATION_SCHEMA_VERSION = 1;
17
+
18
+ // ../core/src/declaration/machine-names.ts
15
19
  var MACHINE_PATTERNS = [
16
20
  [/:\/\//, "an absolute address"],
17
21
  [/^\/\//, "a protocol-relative host"],
@@ -33,23 +37,8 @@ function refuseMachineNames(label) {
33
37
  error: (issue) => `${label} names a machine \u2014 ${namesAMachine(String(issue.input)) ?? "a value of the deployment"} is supplied by the deployment, not written in the code`
34
38
  });
35
39
  }
36
- var ProjectSlugSchema = z.string().min(1).max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "Use lowercase letters, numbers and single hyphens (for example: talk-control)");
37
- var ProjectDescriptionSchema = z.record(refuseMachineNames("A locale tag")(z.string().min(1)), refuseMachineNames("A description")(z.string().trim().min(1))).refine((value) => Object.keys(value).length > 0, "Describe the project in at least one locale");
38
- var ProjectIdentitySchema = z.object({
39
- slug: ProjectSlugSchema,
40
- name: refuseMachineNames("A project name")(z.string().trim().min(1).max(80)),
41
- version: z.string().regex(/^\d+\.\d+\.\d+$/, "Use a semantic version such as 0.1.0"),
42
- description: ProjectDescriptionSchema
43
- }).strict();
44
- var RepositoryPathSchema = z.string().min(1).refine((value) => !value.startsWith("/"), "Use a path relative to the repository root").refine((value) => namesAMachine(value) === undefined, {
45
- error: (issue) => `A path may not contain ${namesAMachine(String(issue.input)) ?? "a machine name"}`
46
- }).refine((value) => !value.split("/").includes(".."), "A path may not climb out of the repository");
47
- var BindingVariableSchema = z.string().regex(/^[A-Z][A-Z0-9_]*$/, "Name an environment variable, for example API_PORT");
48
- var ProjectListenerSchema = z.object({
49
- portVariable: BindingVariableSchema,
50
- bindVariable: BindingVariableSchema,
51
- readinessPath: refuseMachineNames("A readiness path")(z.string().startsWith("/", "Readiness is a path, for example /health"))
52
- }).strict();
40
+
41
+ // ../core/src/declaration/command.ts
53
42
  var ProjectRunModeSchema = z.enum(["development", "production"]);
54
43
  var PROJECT_SCRIPT_LAUNCHERS = [
55
44
  [/^(?:bun|npm|pnpm|yarn)$/, /^run$/],
@@ -75,53 +64,78 @@ var ProjectCommandSchema = z.object({
75
64
  args: CommandArgumentsSchema
76
65
  }).strict();
77
66
  var ProjectRoleCommandSchema = ProjectCommandSchema.refine((value) => !launchesAScript(value.executable, value.args[0]), "Start the role process itself, not a script runner: a launcher between the supervisor and the role duplicates the shutdown signal and forces the drain").refine((value) => !value.args.includes("--filter"), "A workspace filter puts a launcher between the supervisor and the role, and the shutdown signal never reaches it");
78
- var ProjectRoleSchema = z.object({
67
+
68
+ // ../core/src/declaration/declaration.ts
69
+ var PROJECT_DECLARATION_SCHEMA_VERSION = 1;
70
+ var ProjectSlugSchema = z2.string().min(1).max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "Use lowercase letters, numbers and single hyphens (for example: talk-control)");
71
+ var ProjectDescriptionSchema = z2.record(refuseMachineNames("A locale tag")(z2.string().min(1)), refuseMachineNames("A description")(z2.string().trim().min(1))).refine((value) => Object.keys(value).length > 0, "Describe the project in at least one locale");
72
+ var SemanticVersionSchema = z2.string().regex(/^\d+\.\d+\.\d+$/, "Use a semantic version such as 0.1.0");
73
+ var ProjectIdentitySchema = z2.object({
74
+ slug: ProjectSlugSchema,
75
+ name: refuseMachineNames("A project name")(z2.string().trim().min(1).max(80)),
76
+ version: SemanticVersionSchema,
77
+ description: ProjectDescriptionSchema
78
+ }).strict();
79
+ var ProjectStarterSchema = z2.strictObject({
80
+ version: SemanticVersionSchema
81
+ });
82
+ var RepositoryPathSchema = z2.string().min(1).refine((value) => !value.startsWith("/"), "Use a path relative to the repository root").refine((value) => namesAMachine(value) === undefined, {
83
+ error: (issue) => `A path may not contain ${namesAMachine(String(issue.input)) ?? "a machine name"}`
84
+ }).refine((value) => !value.split("/").includes(".."), "A path may not climb out of the repository");
85
+ var BindingVariableSchema = z2.string().regex(/^[A-Z][A-Z0-9_]*$/, "Name an environment variable, for example API_PORT");
86
+ var ProjectListenerSchema = z2.object({
87
+ portVariable: BindingVariableSchema,
88
+ bindVariable: BindingVariableSchema,
89
+ readinessPath: refuseMachineNames("A readiness path")(z2.string().startsWith("/", "Readiness is a path, for example /health"))
90
+ }).strict();
91
+ var ProjectRoleSchema = z2.object({
79
92
  name: ProjectSlugSchema,
80
93
  workingDirectory: RepositoryPathSchema.optional(),
81
- commands: z.record(ProjectRunModeSchema, ProjectRoleCommandSchema),
94
+ commands: z2.record(ProjectRunModeSchema, ProjectRoleCommandSchema),
82
95
  listener: ProjectListenerSchema.optional(),
83
- drainFloorMs: z.number().int().nonnegative()
96
+ drainFloorMs: z2.number().int().nonnegative()
84
97
  }).strict();
85
- var ProjectBuildInputSchema = z.object({
98
+ var ProjectBuildInputSchema = z2.object({
86
99
  name: ProjectSlugSchema,
87
100
  path: RepositoryPathSchema,
88
- digest: z.string().regex(/^sha256:[0-9a-f]{64}$/, 'Use a lowercase sha256 digest, as "sha256:<64 hex>"')
101
+ digest: z2.string().regex(/^sha256:[0-9a-f]{64}$/, 'Use a lowercase sha256 digest, as "sha256:<64 hex>"')
89
102
  }).strict();
90
- var ProjectBuildSchema = z.object({
103
+ var ProjectBuildSchema = z2.object({
91
104
  command: ProjectCommandSchema,
92
- artifacts: z.array(RepositoryPathSchema).min(1),
93
- inputs: z.array(ProjectBuildInputSchema).optional()
105
+ artifacts: z2.array(RepositoryPathSchema).min(1),
106
+ inputs: z2.array(ProjectBuildInputSchema).optional()
94
107
  }).strict().refine((build) => {
95
108
  const names = (build.inputs ?? []).map((input) => input.name);
96
109
  return new Set(names).size === names.length;
97
110
  }, "Two build inputs share a name \u2014 a failure could then name either of them");
98
- var ProjectRequirementPhaseSchema = z.enum(["release", "start"]);
99
- var ProjectRequirementSchema = z.object({
111
+ var ProjectRequirementPhaseSchema = z2.enum(["release", "start"]);
112
+ var ProjectRequirementSchema = z2.object({
100
113
  name: ProjectSlugSchema,
101
- phases: z.array(ProjectRequirementPhaseSchema).min(1)
114
+ phases: z2.array(ProjectRequirementPhaseSchema).min(1)
102
115
  }).strict();
103
- var ProjectMigrationsSchema = z.object({
104
- engine: refuseMachineNames("A migration engine name")(z.string().min(1).max(64)),
116
+ var ProjectMigrationsSchema = z2.object({
117
+ engine: refuseMachineNames("A migration engine name")(z2.string().min(1).max(64)),
105
118
  root: RepositoryPathSchema,
106
119
  lockfile: RepositoryPathSchema
107
120
  }).strict();
108
- var ProjectReleaseSchema = z.object({ migrations: ProjectMigrationsSchema.optional() }).strict();
109
- var ProjectEnvShapeSchema = z.enum(["string", "integer", "boolean", "url", "enum"]);
110
- var ProjectEnvVariableSchema = z.object({
121
+ var ProjectReleaseSchema = z2.object({ migrations: ProjectMigrationsSchema.optional() }).strict();
122
+ var ProjectEnvShapeSchema = z2.enum(["string", "integer", "boolean", "url", "enum"]);
123
+ var ProjectEnvVariableSchema = z2.object({
111
124
  name: BindingVariableSchema,
112
125
  shape: ProjectEnvShapeSchema,
113
- required: z.boolean(),
114
- members: z.array(refuseMachineNames("An enum member")(z.string().min(1))).min(1).optional()
126
+ required: z2.boolean(),
127
+ members: z2.array(refuseMachineNames("An enum member")(z2.string().min(1))).min(1).optional()
115
128
  }).strict().refine((value) => value.shape === "enum" === (value.members !== undefined), "An enum variable lists its members; every other shape has none");
116
- var ProjectDeclarationSchema = z.object({
117
- schemaVersion: z.literal(PROJECT_DECLARATION_SCHEMA_VERSION),
118
- kind: z.enum(["library", "application"]),
129
+ var ProjectDeclarationSchema = z2.object({
130
+ schemaVersion: z2.literal(PROJECT_DECLARATION_SCHEMA_VERSION),
131
+ kind: z2.enum(["library", "application"]),
119
132
  identity: ProjectIdentitySchema,
120
- roles: z.array(ProjectRoleSchema),
133
+ starter: ProjectStarterSchema.optional(),
134
+ roles: z2.array(ProjectRoleSchema),
121
135
  build: ProjectBuildSchema.optional(),
122
- requires: z.array(ProjectRequirementSchema),
136
+ requires: z2.array(ProjectRequirementSchema),
123
137
  release: ProjectReleaseSchema,
124
- env: z.object({ variables: z.array(ProjectEnvVariableSchema) }).strict()
138
+ env: z2.object({ variables: z2.array(ProjectEnvVariableSchema) }).strict()
125
139
  }).strict().refine((value) => value.kind === "application" ? value.roles.length > 0 : value.roles.length === 0, "An application declares at least one role; a library declares none").refine((value) => new Set(value.roles.map((role) => role.name)).size === value.roles.length, "Role names must be unique").refine((value) => new Set(value.requires.map((entry) => entry.name)).size === value.requires.length, "Name each requirement once and list its phases").refine((value) => value.requires.every((entry) => new Set(entry.phases).size === entry.phases.length), "List each phase of a requirement once").refine((value) => new Set(value.env.variables.map((entry) => entry.name)).size === value.env.variables.length, "Declare each environment variable once").refine((value) => listenerBindingProblem(value) === undefined, {
126
140
  error: (issue) => listenerBindingProblem(issue.input) ?? "Listener bindings are inconsistent"
127
141
  });
@@ -155,7 +169,7 @@ function listenerBindingProblem(value) {
155
169
  }
156
170
  return;
157
171
  }
158
- var VersionProbeSchema = z.object({ schemaVersion: z.unknown() }).loose();
172
+ var VersionProbeSchema = z2.object({ schemaVersion: z2.unknown() }).loose();
159
173
  function parseProjectDeclaration(source) {
160
174
  const probe = VersionProbeSchema.safeParse(source);
161
175
  const declared = probe.success ? probe.data.schemaVersion : undefined;
@@ -198,9 +212,13 @@ function createApplicationIdentity(destination, displayName) {
198
212
  }
199
213
  });
200
214
  }
201
- function withIdentity(declaration, identity) {
215
+ function withIdentity(declaration, identity, starterVersion) {
202
216
  const copied = parseProjectDeclaration(declaration);
203
- return parseProjectDeclaration({ ...copied, identity });
217
+ return parseProjectDeclaration({
218
+ ...copied,
219
+ identity,
220
+ ...starterVersion !== undefined && { starter: { version: starterVersion } }
221
+ });
204
222
  }
205
223
 
206
224
  // src/options.ts
@@ -273,16 +291,16 @@ function parseOptions(args) {
273
291
  import { lstat, mkdir, readdir, readFile, rm, writeFile } from "fs/promises";
274
292
  import { homedir } from "os";
275
293
  import { basename as basename2, dirname, extname, join as join2, parse, relative, resolve, sep } from "path";
276
- import { z as z3 } from "zod";
294
+ import { z as z4 } from "zod";
277
295
 
278
296
  // src/format.ts
279
297
  import { execFileSync } from "child_process";
280
298
  import { existsSync } from "fs";
281
299
  import { createRequire } from "module";
282
300
  import { join } from "path";
283
- import { z as z2 } from "zod";
284
- var ProcessReportSchema = z2.object({
285
- header: z2.object({ glibcVersionRuntime: z2.string().optional() })
301
+ import { z as z3 } from "zod";
302
+ var ProcessReportSchema = z3.object({
303
+ header: z3.object({ glibcVersionRuntime: z3.string().optional() })
286
304
  });
287
305
  function nativeBiome() {
288
306
  const requireBiome = createRequire(import.meta.resolve("@biomejs/biome/bin/biome"));
@@ -330,14 +348,22 @@ var TEMPLATE_RENAMES = new Map([
330
348
  ["_env.example.append", ".env.example"],
331
349
  ["_gitignore", ".gitignore"]
332
350
  ]);
333
- var RootManifestSchema = z3.looseObject({
334
- name: z3.string().min(1),
335
- catalog: z3.record(z3.string(), z3.string()).optional(),
336
- workspaces: z3.unknown().optional(),
337
- dependencies: z3.record(z3.string(), z3.string()).optional(),
338
- devDependencies: z3.record(z3.string(), z3.string()).optional()
351
+ var RootManifestSchema = z4.looseObject({
352
+ name: z4.string().min(1),
353
+ catalog: z4.record(z4.string(), z4.string()).optional(),
354
+ workspaces: z4.unknown().optional(),
355
+ dependencies: z4.record(z4.string(), z4.string()).optional(),
356
+ devDependencies: z4.record(z4.string(), z4.string()).optional()
357
+ });
358
+ var ScaffolderManifestSchema = z4.looseObject({
359
+ version: z4.string().min(1)
339
360
  });
361
+ async function readScaffolderVersion() {
362
+ const manifestPath = resolve(import.meta.dir, "../package.json");
363
+ return ScaffolderManifestSchema.parse(JSON.parse(await readFile(manifestPath, "utf8"))).version;
364
+ }
340
365
  var IGNORED_DIRECTORIES = new Set([
366
+ ".data",
341
367
  ".next",
342
368
  ".stitchkit",
343
369
  "coverage",
@@ -460,7 +486,8 @@ async function scaffoldProject(templateDirectory, destination, options = {}) {
460
486
  await rm(join2(resolvedDestination, "bun.lock"), { force: true });
461
487
  }
462
488
  const declarationPath = join2(resolvedDestination, "project.json");
463
- const declaration = withIdentity(JSON.parse(await readFile(declarationPath, "utf8")), identity);
489
+ const starterVersion = options.starterVersion ?? await readScaffolderVersion();
490
+ const declaration = withIdentity(JSON.parse(await readFile(declarationPath, "utf8")), identity, starterVersion);
464
491
  await writeFile(declarationPath, `${JSON.stringify(declaration, undefined, 2)}
465
492
  `);
466
493
  if (options.identityModule !== false) {