@lunora/cli 1.0.0-alpha.1 → 1.0.0-alpha.100

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 (60) hide show
  1. package/LICENSE.md +6 -0
  2. package/__assets__/package-og.svg +1 -1
  3. package/dist/bin.mjs +1 -1
  4. package/dist/index.d.mts +473 -344
  5. package/dist/index.d.ts +473 -344
  6. package/dist/index.mjs +10 -11
  7. package/dist/packem_chunks/handler.mjs +91 -7
  8. package/dist/packem_chunks/handler10.mjs +8 -14
  9. package/dist/packem_chunks/handler11.mjs +20 -189
  10. package/dist/packem_chunks/handler12.mjs +176 -115
  11. package/dist/packem_chunks/handler13.mjs +118 -52
  12. package/dist/packem_chunks/handler14.mjs +50 -43
  13. package/dist/packem_chunks/handler15.mjs +27 -6
  14. package/dist/packem_chunks/handler16.mjs +6 -3
  15. package/dist/packem_chunks/handler17.mjs +1 -1
  16. package/dist/packem_chunks/handler18.mjs +5 -7
  17. package/dist/packem_chunks/handler19.mjs +44 -5
  18. package/dist/packem_chunks/handler2.mjs +6 -4
  19. package/dist/packem_chunks/handler20.mjs +2 -2
  20. package/dist/packem_chunks/handler21.mjs +158 -267
  21. package/dist/packem_chunks/handler3.mjs +8 -4
  22. package/dist/packem_chunks/handler4.mjs +2 -2
  23. package/dist/packem_chunks/handler5.mjs +7 -4
  24. package/dist/packem_chunks/handler6.mjs +10 -7
  25. package/dist/packem_chunks/handler7.mjs +2 -2
  26. package/dist/packem_chunks/handler8.mjs +1 -1
  27. package/dist/packem_chunks/handler9.mjs +330 -12
  28. package/dist/packem_chunks/planDevCommand.mjs +759 -121
  29. package/dist/packem_chunks/runCodegenCommand.mjs +5 -4
  30. package/dist/packem_chunks/runDeployCommand.mjs +137 -22
  31. package/dist/packem_chunks/runInitCommand.mjs +2053 -112
  32. package/dist/packem_chunks/runMigrateGenerateCommand.mjs +98 -51
  33. package/dist/packem_chunks/runResetCommand.mjs +4 -4
  34. package/dist/packem_chunks/runRpcCommand.mjs +3 -2
  35. package/dist/packem_shared/{COMMANDS-1V_KEx35.mjs → COMMANDS-BOJIDoVY.mjs} +154 -28
  36. package/dist/packem_shared/{DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs → DEFAULT_IMPORT_BATCH_SIZE-D0VOTerB.mjs} +7 -2
  37. package/dist/packem_shared/{api-spec-CtA6ilu4.mjs → api-spec-Bx0iKbxA.mjs} +3 -1
  38. package/dist/packem_shared/{buildRegistryIndex-BcYe607_.mjs → buildRegistryIndex-BS5ig822.mjs} +1 -1
  39. package/dist/packem_shared/codegen-error-DJG-ghs_.mjs +31 -0
  40. package/dist/packem_shared/{command-BDXcJCCJ.mjs → command-lYnl4QyF.mjs} +6 -1
  41. package/dist/packem_shared/{runAddCommand-BZGkRnBs.mjs → commands-D5Yxt9VY.mjs} +331 -33
  42. package/dist/packem_shared/{createLogger-CHPNjFw2.mjs → createLogger-CIWSHrTL.mjs} +40 -8
  43. package/dist/packem_shared/{defaultSpawner-DxI3mebw.mjs → createRecordingSpawner-WuSn20kb.mjs} +23 -2
  44. package/dist/packem_shared/detect-package-manager-v4hHpQd0.mjs +62 -0
  45. package/dist/packem_shared/{diffSnapshots-RR2ZE8Ya.mjs → diffSnapshots-BeDvvNiF.mjs} +1 -1
  46. package/dist/packem_shared/{insertSchemaExtension-BuzF6-t2.mjs → insertSchemaExtension-DAqbfr9Z.mjs} +15 -10
  47. package/dist/packem_shared/{open-url-Dfq6fAyT.mjs → open-url-4PBLY9X0.mjs} +3 -2
  48. package/dist/packem_shared/{output-format-7gyGR3h8.mjs → output-format-B4642rjE.mjs} +1 -1
  49. package/dist/packem_shared/{parseManifest--vZf2FY1.mjs → parseManifest-Dbp-Q2q3.mjs} +36 -9
  50. package/dist/packem_shared/prompt-cancelled-APzX1Im-.mjs +9 -0
  51. package/dist/packem_shared/runAddCommand-D1hgfqFQ.mjs +4 -0
  52. package/dist/packem_shared/{schemaIrToSnapshot-aBTo7TM5.mjs → schemaIrToSnapshot-DdsljJT-.mjs} +1 -1
  53. package/dist/packem_shared/storage-BXU4ax4O.mjs +84 -0
  54. package/dist/packem_shared/tui-prompts-BjEN8XgP.mjs +658 -0
  55. package/dist/packem_shared/wrangler-secrets-Coni-mER.mjs +49 -0
  56. package/package.json +23 -17
  57. package/skills/lunora-quickstart/SKILL.md +26 -5
  58. package/skills/lunora-setup-storage/SKILL.md +7 -3
  59. package/dist/packem_shared/features-ocSSpZtS.mjs +0 -24
  60. package/dist/packem_shared/parseArgs-YXFuKdEk.mjs +0 -56
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CodegenOptions, SchemaIR } from '@lunora/codegen';
2
2
  import '@visulima/cerebro';
3
- import { ensureDevVariables, ensureDevVarsExample, materializeRemoteWranglerConfig } from '@lunora/config';
3
+ import { ensureDevVariables, ensureDevVarsExample, fillDevSecrets, materializeRemoteWranglerConfig } from '@lunora/config';
4
4
  export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, type WranglerProjectValidationOptions as WranglerValidationOptions, type WranglerValidationReport, type WranglerProjectValidationResult as WranglerValidationResult, validateWranglerProject as validateWrangler, validateWranglerConfig } from '@lunora/config';
5
5
  /** Every command name the CLI registers (drives the `CommandName` type + tests). */
6
6
  declare const COMMANDS: readonly ["init", "add", "dev", "codegen", "build", "deploy", "containers", "prepare", "link", "deployments", "logs", "run", "insights", "reset", "migrate", "export", "import", "seed", "backup", "verify", "info", "doctor", "env", "analyze", "view", "docs", "registry", "rules"];
@@ -10,24 +10,24 @@ interface RunCliOptions {
10
10
  argv?: ReadonlyArray<string>;
11
11
  cwd?: string;
12
12
  /**
13
- * Inject a console-like logger so callers (tests) can capture cerebro's
14
- * help / version / usage rendering. Omitted in production, where cerebro
15
- * uses its default stdout/stderr logger.
16
- */
13
+ * Inject a console-like logger so callers (tests) can capture cerebro's
14
+ * help / version / usage rendering. Omitted in production, where cerebro
15
+ * uses its default stdout/stderr logger.
16
+ */
17
17
  logger?: Console;
18
18
  }
19
19
  /**
20
- * Run the CLI and resolve to the process exit code. cerebro handles help,
21
- * version, usage, and unknown commands (the latter throws, caught here as 1).
22
- * `shouldExitProcess: false` keeps the process alive so callers/tests read the
23
- * captured exit code.
24
- */
20
+ * Run the CLI and resolve to the process exit code. cerebro handles help,
21
+ * version, usage, and unknown commands (the latter throws, caught here as 1).
22
+ * `shouldExitProcess: false` keeps the process alive so callers/tests read the
23
+ * captured exit code.
24
+ */
25
25
  declare const runCli: (options?: RunCliOptions) => Promise<number>;
26
26
  /**
27
- * The `--api-spec` flag's accepted values, mirroring `@lunora/codegen`'s
28
- * `CodegenOptions["apiSpec"]`. `"openapi"` (the default) emits `openapi.json`;
29
- * `"openrpc"` emits `openrpc.json`; `"both"` emits both; `"none"` emits neither.
30
- */
27
+ * The `--api-spec` flag's accepted values, mirroring `@lunora/codegen`'s
28
+ * `CodegenOptions["apiSpec"]`. `"openapi"` (the default) emits `openapi.json`;
29
+ * `"openrpc"` emits `openrpc.json`; `"both"` emits both; `"none"` emits neither.
30
+ */
31
31
  type ApiSpec = NonNullable<CodegenOptions["apiSpec"]>;
32
32
  interface Logger {
33
33
  debug?: (message: string) => void;
@@ -37,11 +37,11 @@ interface Logger {
37
37
  warn: (message: string) => void;
38
38
  }
39
39
  /**
40
- * Narrowed view over the pail instance. `createPail` returns an intersection
41
- * type that includes a constructor signature and `(...args: any[])` logger
42
- * overloads, which the type-aware linter cannot safely resolve. We only ever
43
- * call the level methods with a string, so we describe exactly that surface.
44
- */
40
+ * Narrowed view over the pail instance. `createPail` returns an intersection
41
+ * type that includes a constructor signature and `(...args: any[])` logger
42
+ * overloads, which the type-aware linter cannot safely resolve. We only ever
43
+ * call the level methods with a string, so we describe exactly that surface.
44
+ */
45
45
  interface PailLogger {
46
46
  debug: (message: string) => void;
47
47
  error: (message: string) => void;
@@ -51,18 +51,11 @@ interface PailLogger {
51
51
  }
52
52
  declare const createLogger: () => Logger;
53
53
  /**
54
- * Logger whose every channel writes to `process.stderr`. Used by commands in
55
- * `--format json` mode so all human/progress output stays off stdout leaving
56
- * stdout for the single JSON document the command prints, so `… --format json`
57
- * stays cleanly pipeable (`| jq`). Each line carries a one-character level tag
58
- * so the stream is still readable when a human watches it.
59
- */
60
- /**
61
- * Direct access to the underlying pail instance for advanced use-cases.
62
- * A Proxy keeps the public `pail` binding lazy: the real pail is only
63
- * constructed on first property access, so importing this module (and thus
64
- * the package barrel) stays side-effect-free.
65
- */
54
+ * Direct access to the underlying pail instance for advanced use-cases.
55
+ * A Proxy keeps the public `pail` binding lazy: the real pail is only
56
+ * constructed on first property access, so importing this module (and thus
57
+ * the package barrel) stays side-effect-free.
58
+ */
66
59
  declare const pail: PailLogger;
67
60
  interface CodegenCommandOptions {
68
61
  /** Which API spec(s) to emit. Defaults to codegen's `"openapi"` when omitted. */
@@ -85,14 +78,13 @@ interface CodegenCommandResult {
85
78
  outputDirectory: string;
86
79
  }
87
80
  declare const runCodegenCommand: (options: CodegenCommandOptions) => CodegenCommandResult;
88
- /** `lunora codegen` handler (lazy-loaded via the command's `loader`). */
89
81
  /** Rows per HTTP request when importing. Convex uses ~500; same here. */
90
82
  declare const DEFAULT_IMPORT_BATCH_SIZE = 500;
91
83
  /**
92
- * Minimal projection of `globalThis.fetch` for the export path — we need
93
- * `body` as a stream-iterable, which the shared {@link FetchLike} type
94
- * intentionally hides for the JSON-only commands.
95
- */
84
+ * Minimal projection of `globalThis.fetch` for the export path — we need
85
+ * `body` as a stream-iterable, which the shared {@link FetchLike} type
86
+ * intentionally hides for the JSON-only commands.
87
+ */
96
88
  type StreamingFetchLike = (input: string, init?: {
97
89
  body?: string;
98
90
  headers?: Record<string, string>;
@@ -126,10 +118,10 @@ interface ExportCommandResult {
126
118
  rows: number;
127
119
  }
128
120
  /**
129
- * Stream an export. The worker emits NDJSON; we count newlines as we go and
130
- * pipe straight to the output sink, so a 10M-row export doesn't materialise
131
- * the body in memory.
132
- */
121
+ * Stream an export. The worker emits NDJSON; we count newlines as we go and
122
+ * pipe straight to the output sink, so a 10M-row export doesn't materialise
123
+ * the body in memory.
124
+ */
133
125
  declare const runExportCommand: (options: ExportCommandOptions) => Promise<ExportCommandResult>;
134
126
  interface ImportCommandOptions {
135
127
  /** Rows per HTTP request. Defaults to {@link DEFAULT_IMPORT_BATCH_SIZE}. */
@@ -141,13 +133,15 @@ interface ImportCommandOptions {
141
133
  logger: Logger;
142
134
  prod?: boolean;
143
135
  /**
144
- * Wrap each line as `{table:&lt;name>,doc:&lt;line>}`. Use when the source NDJSON
145
- * is bare docs from a single table — Convex's `convex import --table users`
146
- * shape.
147
- */
136
+ * Wrap each line as `{table:&lt;name>,doc:&lt;line>}`. Use when the source NDJSON
137
+ * is bare docs from a single table — Convex's `convex import --table users`
138
+ * shape.
139
+ */
148
140
  table?: string;
149
141
  token?: string;
150
142
  url?: string;
143
+ /** Confirm bulk-writing production. Required alongside `--prod`. */
144
+ yes?: boolean;
151
145
  }
152
146
  interface ImportCommandResult {
153
147
  body: unknown;
@@ -156,46 +150,40 @@ interface ImportCommandResult {
156
150
  inserted: number;
157
151
  }
158
152
  /**
159
- * Stream an NDJSON file in chunks, POSTing each batch to
160
- * `/_lunora/admin/import`. We keep the line buffer bounded by `batchSize` so a
161
- * multi-GiB file imports without buffering everything in memory.
162
- */
153
+ * Stream an NDJSON file in chunks, POSTing each batch to
154
+ * `/_lunora/admin/import`. We keep the line buffer bounded by `batchSize` so a
155
+ * multi-GiB file imports without buffering everything in memory.
156
+ */
163
157
  declare const runImportCommand: (options: ImportCommandOptions) => Promise<ImportCommandResult>;
164
158
  /**
165
- * Injectable probe for a Docker-compatible container engine. Tests pass a
166
- * stub; production uses {@link isDockerAvailable}.
167
- */
159
+ * Injectable probe for a Docker-compatible container engine. Tests pass a
160
+ * stub; production uses {@link isDockerAvailable}.
161
+ */
168
162
  type DockerProbe = () => boolean;
169
- /**
170
- * True when a Docker-compatible engine answers `docker info` — the same
171
- * prerequisite `wrangler deploy` has for building and pushing a container
172
- * image from a local Dockerfile. Quiet by design (output discarded): callers
173
- * own the messaging.
174
- */
175
163
  interface SpawnDescriptor {
176
164
  args: ReadonlyArray<string>;
177
165
  /**
178
- * Capture the child's stdout (in addition to streaming it to the parent), so
179
- * the caller can parse it — used by `deploy` to read the deployed URL from
180
- * `wrangler deploy` output. Each chunk is still teed to the parent's stdout
181
- * so the user sees live progress. Mutually exclusive with `stdoutToStderr`.
182
- */
166
+ * Capture the child's stdout (in addition to streaming it to the parent), so
167
+ * the caller can parse it — used by `deploy` to read the deployed URL from
168
+ * `wrangler deploy` output. Each chunk is still teed to the parent's stdout
169
+ * so the user sees live progress. Mutually exclusive with `stdoutToStderr`.
170
+ */
183
171
  captureStdout?: boolean;
184
172
  command: string;
185
173
  cwd?: string;
186
174
  env?: Readonly<Record<string, string>>;
187
175
  /**
188
- * Pipe this string into the child's stdin and close it. Used to feed
189
- * `wrangler secret put` its value without exposing it on the command
190
- * line or in env. When absent, stdin is inherited from the parent.
191
- */
176
+ * Pipe this string into the child's stdin and close it. Used to feed
177
+ * `wrangler secret put` its value without exposing it on the command
178
+ * line or in env. When absent, stdin is inherited from the parent.
179
+ */
192
180
  input?: string;
193
181
  /**
194
- * Route the child's stdout to the parent's STDERR instead of stdout. Set in
195
- * `--format json` mode so a spawned tool's human output (e.g. `wrangler
196
- * deploy`'s progress + the deployed URL) can't interleave with — and corrupt
197
- * — the single JSON document the command prints to stdout.
198
- */
182
+ * Route the child's stdout to the parent's STDERR instead of stdout. Set in
183
+ * `--format json` mode so a spawned tool's human output (e.g. `wrangler
184
+ * deploy`'s progress + the deployed URL) can't interleave with — and corrupt
185
+ * — the single JSON document the command prints to stdout.
186
+ */
199
187
  stdoutToStderr?: boolean;
200
188
  }
201
189
  interface SpawnResult {
@@ -204,22 +192,46 @@ interface SpawnResult {
204
192
  stdout?: string;
205
193
  }
206
194
  /**
207
- * Injectable spawner. Tests pass a stub that just records the descriptor
208
- * instead of executing a real subprocess.
209
- */
195
+ * Injectable spawner. Tests pass a stub that just records the descriptor
196
+ * instead of executing a real subprocess.
197
+ */
210
198
  type Spawner = (descriptor: SpawnDescriptor) => Promise<SpawnResult>;
211
199
  declare const defaultSpawner: Spawner;
212
200
  interface RecordedSpawn {
213
201
  descriptor: SpawnDescriptor;
214
202
  }
215
203
  /**
216
- * Test helper: returns a spawner that records every invocation and resolves
217
- * with the configured exit code.
218
- */
204
+ * Test helper: returns a spawner that records every invocation and resolves
205
+ * with the configured exit code.
206
+ */
219
207
  declare const createRecordingSpawner: (exitCode?: number) => {
220
208
  calls: RecordedSpawn[];
221
209
  spawner: Spawner;
222
210
  };
211
+ interface SecretListRunnerResult {
212
+ code: number;
213
+ stderr: string;
214
+ stdout: string;
215
+ }
216
+ /** Runs an argv and resolves its captured output. Injected in tests. */
217
+ type SecretListRunner = (command: string, args: ReadonlyArray<string>, cwd: string) => Promise<SecretListRunnerResult>;
218
+ interface ListRemoteSecretsInputs {
219
+ cwd: string;
220
+ /** Cloudflare environment name (`--env`). */
221
+ env?: string;
222
+ /** Injected command runner; defaults to a real `wrangler secret list`. */
223
+ runner?: SecretListRunner;
224
+ /** Target a temporary-account deployment (`--temporary`). */
225
+ temporary?: boolean;
226
+ }
227
+ interface ListRemoteSecretsResult {
228
+ /** Diagnostic message when `ok` is false. */
229
+ error?: string;
230
+ /** Remote secret names (sorted), empty when none or on failure. */
231
+ names: ReadonlyArray<string>;
232
+ /** False when wrangler failed or its output could not be parsed. */
233
+ ok: boolean;
234
+ }
223
235
  type FetchLike = (input: string, init?: {
224
236
  body?: string;
225
237
  headers?: Record<string, string>;
@@ -245,7 +257,6 @@ interface RunCommandResult {
245
257
  requestUrl: string;
246
258
  }
247
259
  declare const runRpcCommand: (options: RunCommandOptions) => Promise<RunCommandResult>;
248
- /** `lunora run &lt;functionPath>` handler (lazy-loaded via the command's `loader`). */
249
260
  interface DeployCommandOptions {
250
261
  /** Override the schema-drift gate — deploy even with breaking drift and no new migration. */
251
262
  allowSchemaDrift?: boolean;
@@ -255,10 +266,10 @@ interface DeployCommandOptions {
255
266
  /** Docker-availability probe injected in tests. Defaults to a real `docker info` check. */
256
267
  dockerAvailable?: DockerProbe;
257
268
  /**
258
- * Validate, bundle, and run all pre-deploy gates without publishing
259
- * (`wrangler deploy --dry-run`). Post-deploy steps (data migrations, schema
260
- * baseline re-bless) are skipped since nothing shipped.
261
- */
269
+ * Validate, bundle, and run all pre-deploy gates without publishing
270
+ * (`wrangler deploy --dry-run`). Post-deploy steps (data migrations, schema
271
+ * baseline re-bless) are skipped since nothing shipped.
272
+ */
262
273
  dryRun?: boolean;
263
274
  env?: string;
264
275
  /** Fetch implementation injected in tests for `--migrate` RPC calls. */
@@ -269,59 +280,63 @@ interface DeployCommandOptions {
269
280
  interactive?: boolean;
270
281
  logger: Logger;
271
282
  /**
272
- * When true, after a successful `wrangler deploy`, discover and run all
273
- * pending data migrations via the worker's `/_lunora/migrate` admin RPC.
274
- * The worker must be live (exit 0) before migrations are attempted.
275
- *
276
- * Implementation note: the status RPC returns the full shard-level
277
- * migration state, but there is no single authoritative "list of pending
278
- * migration ids" that can be read client-side before running the worker.
279
- * Instead, `--migrate` runs `migrate status` followed by `migrate up` for
280
- * each migration id discovered locally via `discoverMigrations`. The
281
- * worker's `MigrationRunner` is idempotent — running `up` on an already-
282
- * applied migration is a no-op — so this approach is safe.
283
- */
283
+ * When true, after a successful `wrangler deploy`, discover and run all
284
+ * pending data migrations via the worker's `/_lunora/migrate` admin RPC.
285
+ * The worker must be live (exit 0) before migrations are attempted.
286
+ *
287
+ * Implementation note: the status RPC returns the full shard-level
288
+ * migration state, but there is no single authoritative "list of pending
289
+ * migration ids" that can be read client-side before running the worker.
290
+ * Instead, `--migrate` runs `migrate status` followed by `migrate up` for
291
+ * each migration id discovered locally via `discoverMigrations`. The
292
+ * worker's `MigrationRunner` is idempotent — running `up` on an already-
293
+ * applied migration is a no-op — so this approach is safe.
294
+ */
284
295
  migrate?: boolean;
285
296
  /** Admin bearer token for `--migrate` (falls back to `LUNORA_ADMIN_TOKEN`). */
286
297
  migrateToken?: string;
287
298
  /**
288
- * Worker URL for `--migrate`. REQUIRED when `--migrate` is set — the deploy
289
- * handler never captures the URL `wrangler deploy` published to, so there is
290
- * no safe default; omitting it would silently target `http://localhost:8787`
291
- * (the dev worker), applying the migration to local state instead of prod.
292
- */
299
+ * Worker URL for `--migrate`. REQUIRED when `--migrate` is set — the deploy
300
+ * handler never captures the URL `wrangler deploy` published to, so there is
301
+ * no safe default; omitting it would silently target `http://localhost:8787`
302
+ * (the dev worker), applying the migration to local state instead of prod.
303
+ */
293
304
  migrateUrl?: string;
294
305
  /**
295
- * Confirm a production data migration triggered via `--migrate` (the
296
- * `migrate up --prod` confirmation the standalone command requires). Without
297
- * it a `--migrate --migrate-url &lt;prod>` deploy refuses to run the migration.
298
- */
306
+ * Confirm a production data migration triggered via `--migrate` (the
307
+ * `migrate up --prod` confirmation the standalone command requires). Without
308
+ * it a `--migrate --migrate-url &lt;prod>` deploy refuses to run the migration.
309
+ */
299
310
  migrateYes?: boolean;
300
311
  /**
301
- * Emit the bundled worker to this directory via `wrangler deploy --outdir`
302
- * (paired with `dryRun` by `lunora build`). Also writes esbuild metadata to
303
- * `&lt;outDir>/bundle-meta.json`. When unset, no artifact is written.
304
- */
312
+ * Emit the bundled worker to this directory via `wrangler deploy --outdir`
313
+ * (paired with `dryRun` by `lunora build`). Also writes esbuild metadata to
314
+ * `&lt;outDir>/bundle-meta.json`. When unset, no artifact is written.
315
+ */
305
316
  outDir?: string;
306
317
  /**
307
- * Upload a preview version (`wrangler versions upload`) instead of a live
308
- * `wrangler deploy`. Codegen + the drift gate + validation still run, but
309
- * the post-deploy finalize (migrations, baseline re-bless, auto-link, the
310
- * production summary) is skipped — a preview never shifts live traffic.
311
- */
318
+ * Upload a preview version (`wrangler versions upload`) instead of a live
319
+ * `wrangler deploy`. Codegen + the drift gate + validation still run, but
320
+ * the post-deploy finalize (migrations, baseline re-bless, auto-link, the
321
+ * production summary) is skipped — a preview never shifts live traffic.
322
+ */
312
323
  preview?: boolean;
313
324
  /** Railpack-availability probe injected in tests. Defaults to a real `railpack --version` + `BUILDKIT_HOST` check. */
314
325
  railpackAvailable?: DockerProbe;
326
+ /** Confirm prompt for the missing-secret offer; injected in tests. Defaults to the TTY prompt. */
327
+ secretConfirm?: (message: string) => Promise<boolean>;
328
+ /** Remote-secret lister for the missing-secret offer; injected in tests. Defaults to `wrangler secret list`. */
329
+ secretLister?: (inputs: ListRemoteSecretsInputs) => Promise<ListRemoteSecretsResult>;
315
330
  skipCodegen?: boolean;
316
331
  spawner?: Spawner;
317
332
  /**
318
- * Deploy to a temporary Cloudflare account (`wrangler deploy --temporary`).
319
- * For unauthenticated use only: wrangler provisions a short-lived account +
320
- * token, deploys, and prints a claim URL; the deployment stays live ~60
321
- * minutes before the unclaimed account is deleted. Wrangler itself errors
322
- * if credentials are already present (OAuth / `CLOUDFLARE_API_TOKEN` /
323
- * global API key), so we pass the flag straight through without guarding.
324
- */
333
+ * Deploy to a temporary Cloudflare account (`wrangler deploy --temporary`).
334
+ * For unauthenticated use only: wrangler provisions a short-lived account +
335
+ * token, deploys, and prints a claim URL; the deployment stays live ~60
336
+ * minutes before the unclaimed account is deleted. Wrangler itself errors
337
+ * if credentials are already present (OAuth / `CLOUDFLARE_API_TOKEN` /
338
+ * global API key), so we pass the flag straight through without guarding.
339
+ */
325
340
  temporary?: boolean;
326
341
  /** Re-bless the committed schema baseline with the current shape (accepts breaking drift). */
327
342
  updateSchemaBaseline?: boolean;
@@ -342,18 +357,17 @@ interface DeployCommandResult {
342
357
  };
343
358
  }
344
359
  /**
345
- * Run a deploy, then (in `--format json` mode) serialize the structured
346
- * {@link DeployCommandResult} to stdout. Human/progress logging is routed to
347
- * stderr for json output so stdout carries only the single JSON document.
348
- */
360
+ * Run a deploy, then (in `--format json` mode) serialize the structured
361
+ * {@link DeployCommandResult} to stdout. Human/progress logging is routed to
362
+ * stderr for json output so stdout carries only the single JSON document.
363
+ */
349
364
  declare const runDeployCommand: (options: DeployCommandOptions) => Promise<DeployCommandResult>;
350
- /** `lunora deploy` handler (lazy-loaded via the command's `loader`). */
351
365
  /**
352
- * Start the codegen watch loop and return a handle to stop it. Regenerates on
353
- * startup, then on debounced changes under `lunora/` (ignoring writes to the
354
- * `_generated/` output to avoid a feedback loop). If the platform can't do a
355
- * recursive watch, it logs once and falls back to startup-only codegen.
356
- */
366
+ * Start the codegen watch loop and return a handle to stop it. Regenerates on
367
+ * startup, then on debounced changes under `lunora/` (ignoring writes to the
368
+ * `_generated/` output to avoid a feedback loop). If the platform can't do a
369
+ * recursive watch, it logs once and falls back to startup-only codegen.
370
+ */
357
371
  declare const startCodegenWatch: (options: CodegenWatcherOptions) => CodegenWatcherHandle;
358
372
  interface CodegenWatcherOptions {
359
373
  /** Which API spec(s) to emit. Defaults to codegen's `"openapi"` when omitted. */
@@ -370,18 +384,18 @@ interface CodegenWatcherHandle {
370
384
  /** Stop watching and cancel any pending regeneration. */
371
385
  close: () => void;
372
386
  /**
373
- * `true` when the platform supports recursive watch and the loop is active.
374
- * `false` when `fs.watch({ recursive })` threw — startup-only codegen was run
375
- * but schema edits will NOT auto-regenerate. Callers can surface this in the
376
- * dev banner so the degraded state is visible beyond the single startup warning.
377
- */
387
+ * `true` when the platform supports recursive watch and the loop is active.
388
+ * `false` when `fs.watch({ recursive })` threw — startup-only codegen was run
389
+ * but schema edits will NOT auto-regenerate. Callers can surface this in the
390
+ * dev banner so the degraded state is visible beyond the single startup warning.
391
+ */
378
392
  watchAvailable: boolean;
379
393
  }
380
394
  /**
381
- * Start the studio server and resolve once it is listening. Loads the static
382
- * bundle + renders the host HTML once up front; serves them and proxies
383
- * `/_lunora/*` (HTTP + WS) to the worker.
384
- */
395
+ * Start the studio server and resolve once it is listening. Loads the static
396
+ * bundle + renders the host HTML once up front; serves them and proxies
397
+ * `/_lunora/*` (HTTP + WS) to the worker.
398
+ */
385
399
  declare const startStudioServer: (options: StudioServerOptions) => Promise<StudioServerHandle>;
386
400
  interface StudioServerOptions {
387
401
  /** Project root — `.dev.vars` is read from here for the admin token. */
@@ -403,6 +417,24 @@ interface StudioServerHandle {
403
417
  /** The URL to open in a browser. */
404
418
  url: string;
405
419
  }
420
+ /**
421
+ * How the dev child runs. `wrangler` is the classic `lunora dev` stack (wrangler
422
+ * worker + embedded studio + codegen watch) for a standalone class-C project.
423
+ * `vite` is a project on `@lunora/vite`: the plugin already runs the worker,
424
+ * studio, and codegen inside the Vite dev server, so `lunora dev` runs the
425
+ * project's own dev script and gets out of the way — this also covers class-B
426
+ * frameworks whose own dev server runs the worker in `workerd` (Astro 6 +
427
+ * `@astrojs/cloudflare`, which embeds `@cloudflare/vite-plugin` in `astro dev`:
428
+ * SSR + `/_lunora/*` + `ShardDO` in one process, HMR intact). `framework-worker`
429
+ * is a class-B framework whose dev server CANNOT host the `ShardDO` Durable
430
+ * Object (SvelteKit / Nuxt: their adapters use wrangler's `getPlatformProxy()`,
431
+ * which runs an empty-script Miniflare and does not emulate internal DOs); there
432
+ * `lunora dev` runs the framework's own dev server (front door, HMR, and — via
433
+ * its `@lunora/vite` plugin — studio + codegen) AND a second `wrangler dev`
434
+ * sidecar that owns the real `ShardDO` in `workerd`, wired via the committed
435
+ * `wrangler.dev.jsonc`.
436
+ */
437
+ type DevFlavor = "framework-worker" | "vite" | "wrangler";
406
438
  /** A running worker child the orchestrator controls: send signals, await its exit. */
407
439
  interface WorkerProcess {
408
440
  /** Resolves with the worker's exit code (1 if it failed to start). */
@@ -423,6 +455,14 @@ interface DevCommandOptions {
423
455
  ensureEnv?: typeof ensureDevVariables;
424
456
  /** Injection seam for tests — defaults to the real `.dev.vars.example` package-aware scaffolder. */
425
457
  ensureExample?: typeof ensureDevVarsExample;
458
+ /** Injection seam for tests — defaults to the real empty-secret/admin-token filler. */
459
+ fillSecrets?: typeof fillDevSecrets;
460
+ /** Injection seam for tests — defaults to the real free-port probe ({@link findAvailablePort}). */
461
+ findFreePort?: (preferred: number) => Promise<number>;
462
+ /** Dev flavor override (tests / callers that already detected it) — defaults to {@link detectDevFlavor}. */
463
+ flavor?: DevFlavor;
464
+ /** Injection seam for tests — defaults to the real IPv6-loopback probe ({@link hasIpv6Loopback}). */
465
+ hasIpv6Loopback?: () => boolean;
426
466
  logger: Logger;
427
467
  /** Injection seam for tests — defaults to the real remote-config materializer. */
428
468
  materializeRemote?: typeof materializeRemoteWranglerConfig;
@@ -445,10 +485,10 @@ interface DevRemotePlan {
445
485
  /** Short binding labels remoted (e.g. `"DB (D1)"`), for the banner. */
446
486
  bindings: string[];
447
487
  /**
448
- * Removes the generated temp wrangler config when dev exits. Always present
449
- * and idempotent — a no-op when remote mode is off or nothing was
450
- * materialized. The dev loop calls it on every shutdown path.
451
- */
488
+ * Removes the generated temp wrangler config when dev exits. Always present
489
+ * and idempotent — a no-op when remote mode is off or nothing was
490
+ * materialized. The dev loop calls it on every shutdown path.
491
+ */
452
492
  cleanup: () => void;
453
493
  /** Whether remote mode was requested. */
454
494
  enabled: boolean;
@@ -457,182 +497,71 @@ interface DevRemotePlan {
457
497
  }
458
498
  interface DevCommandPlan {
459
499
  codegenEnabled: boolean;
500
+ /** Which stack the child runs — see {@link DevFlavor}. */
501
+ flavor: DevFlavor;
502
+ /**
503
+ * One-line redirect hint printed when a meta-framework is detected on the
504
+ * wrangler flavor: without `@lunora/vite` in the dependencies the worker
505
+ * still runs *inside* the framework's dev server, so the user should run
506
+ * their framework dev script for the full app. `undefined` for the vite
507
+ * flavor (`lunora dev` already runs the project's dev script there) and
508
+ * for a standalone project. Purely informational: the wrangler spawn runs
509
+ * regardless.
510
+ */
511
+ frameworkHint?: string;
512
+ /**
513
+ * True when `wrangler dev` was given `--ip 127.0.0.1` because the host has no
514
+ * IPv6 loopback (`::1`) — surfaced so the dev loop can note the rebind.
515
+ * Always `false` for the vite flavor (the plugin owns its own bind).
516
+ */
517
+ ipv4LoopbackForced: boolean;
460
518
  /** The remote-binding decision: which D1/KV/R2 bindings hit the deployed worker. */
461
519
  remote: DevRemotePlan;
520
+ /**
521
+ * The `wrangler dev` sidecar for the `framework-worker` flavor (SvelteKit /
522
+ * Nuxt): a second child that owns the real `ShardDO` in `workerd`, wired via
523
+ * the committed `wrangler.dev.jsonc`. `undefined` for every other flavor —
524
+ * only the two-process class-B stack has a sidecar. When present, `wrangler`
525
+ * (above) is the framework's own dev server (the front door / HMR) and this
526
+ * is the Lunora realtime plane.
527
+ */
528
+ sidecar?: SpawnDescriptor & {
529
+ tag: string;
530
+ };
462
531
  studioEnabled: boolean;
463
532
  studioPort: number;
464
533
  workerOrigin: string;
465
534
  workerPort: number;
466
- /** The single child process `lunora dev` spawns: `wrangler dev`. */
535
+ /** The primary child `lunora dev` spawns: `wrangler dev` (wrangler flavor) or the framework/`vite dev` server (vite / framework-worker). */
467
536
  wrangler: SpawnDescriptor & {
468
537
  tag: string;
469
538
  };
470
539
  }
471
540
  /**
472
- * Resolve remote-binding mode into the extra `wrangler dev` args + a banner
473
- * summary. When `--remote`/`LUNORA_REMOTE` is set we materialize a temp wrangler
474
- * config with `"remote": true` on each D1/KV/R2 binding (Durable Object shards
475
- * stay local) and point `wrangler dev --config` at it, so the local worker reads
476
- * and writes the **deployed** resources. When disabled, or when there's nothing
477
- * to remote, the args stay empty and dev runs fully local.
478
- */
479
- /**
480
- * Plan `lunora dev`: it runs the worker via `wrangler dev` and nothing else as a
481
- * child process. Vite is intentionally NOT spawned — a project may not use Vite,
482
- * and when it does, the `@lunora/vite` plugin already runs the worker inside
483
- * Vite, so the user runs `vite` themselves. Pure + synchronous so it's unit-testable.
484
- */
541
+ * Plan `lunora dev`. Wrangler flavor: the worker runs via `wrangler dev` and
542
+ * nothing else as a child process. Vite flavor (`@lunora/vite` declared): the
543
+ * plugin already runs the worker inside the Vite dev server, so the one child
544
+ * is the project's own dev script (`vite dev`, `astro dev`, …) and every CLI
545
+ * sibling is disabled. Pure + synchronous so it's unit-testable.
546
+ */
485
547
  declare const planDevCommand: (options: DevCommandOptions) => DevCommandPlan;
486
548
  /**
487
- * Start codegen watch + the studio server, spawn `wrangler dev`, print the
488
- * banner, and resolve when the worker exits or the user interrupts — tearing
489
- * down the sibling servers either way. The three side-effecting pieces (worker,
490
- * studio, codegen) are injectable so this is testable without real I/O.
491
- */
549
+ * Start codegen watch + the studio server, spawn `wrangler dev`, print the
550
+ * banner, and resolve when the worker exits or the user interrupts — tearing
551
+ * down the sibling servers either way. The three side-effecting pieces (worker,
552
+ * studio, codegen) are injectable so this is testable without real I/O.
553
+ */
492
554
  declare const runDevCommand: (options: DevCommandOptions) => Promise<{
493
555
  code: number;
494
556
  plan: DevCommandPlan;
495
557
  }>;
496
- /** `lunora dev` handler (lazy-loaded via the command's `loader`). */
497
558
  /** Supported CI providers. */
498
559
  type CiProvider = "github" | "gitlab";
560
+ type PackageManager = "pnpm" | "npm" | "yarn" | "bun";
561
+ /** True when `manager` is on PATH — probed by running `&lt;manager> --version`. Injectable for tests. */
562
+ type PackageManagerProbe = (manager: PackageManager) => boolean;
499
563
  /** A registry item a feature can install. */
500
564
  type FeatureItem = "auth" | "auth-auth0" | "auth-clerk" | "mail";
501
- /** The auth-provider choices offered for `add auth` / the init auth prompt. Each value is a registry item name. */
502
-
503
- /** A feature offered in the post-scaffold multi-select. `value` is the stack-feature key, not (yet) a registry item. */
504
- type StackFeature = "auth" | "email";
505
- interface OfferDeps {
506
- /** Apply one or more registry items into the new project; resolves `true` on success. */
507
- apply: (names: ReadonlyArray<FeatureItem>) => Promise<boolean>;
508
- /** When `false`, skip all prompts and print the later-setup hint. */
509
- interactive: boolean;
510
- logger: Logger;
511
- /** Multi-select among the stack features to add (TTY-backed in production). */
512
- multiSelect: (message: string, options: ReadonlyArray<{
513
- description?: string;
514
- label: string;
515
- value: StackFeature;
516
- }>, settings?: {
517
- defaults?: ReadonlyArray<StackFeature>;
518
- }) => Promise<StackFeature[]>;
519
- /** Single-select among the auth providers (TTY-backed in production). */
520
- select: (message: string, options: ReadonlyArray<{
521
- description?: string;
522
- label: string;
523
- value: FeatureItem;
524
- }>, settings?: {
525
- default?: FeatureItem;
526
- }) => Promise<FeatureItem | undefined>;
527
- }
528
- /**
529
- * Offer the stack features (authentication, transactional email) in ONE
530
- * multi-select after a successful scaffold. When auth is picked, a follow-up
531
- * single-select chooses the provider (email+password / Clerk / Auth0); email
532
- * maps to the `mail` item. Picked items are applied in selection order.
533
- * Non-interactive: prints how to add them later and changes nothing.
534
- */
535
- type Template = "astro" | "next" | "nuxt" | "standalone" | "sveltekit" | "tanstack-start-react" | "tanstack-start-solid" | "vite";
536
- interface InitCommandOptions {
537
- /**
538
- * When true, accept `--source` values that don't start with `gh:` /
539
- * `github:` / `https://` or that contain `..`. Defaults to false; the CLI
540
- * gate exists to stop arbitrary filesystem / scheme sources from being
541
- * pulled without the caller opting in.
542
- */
543
- allowUnsafeSource?: boolean;
544
- /** When set, also scaffold a CI deploy pipeline for the given provider. */
545
- ci?: CiProvider;
546
- cwd?: string;
547
- /**
548
- * Local directory containing the template subdirs (e.g. `vite/`,
549
- * `standalone/`). When provided, skips the network fetch entirely.
550
- * Useful for offline runs, the clean-machine smoke test, and unit tests.
551
- */
552
- from?: string;
553
- /**
554
- * When true, configure Lunora into the CURRENT project (`cwd`) instead of
555
- * scaffolding a new directory. Finds an existing `vite.config.*` and
556
- * patches it via `patchViteConfig`, or creates a minimal one when absent.
557
- * All other scaffold options (`name`, `templateType`, `source`, `from`)
558
- * are ignored in this mode.
559
- */
560
- inPlace?: boolean;
561
- /**
562
- * Force the post-scaffold "add auth / email?" offer on (the `--interactive`
563
- * flag). When omitted, the offer runs only when stdin is a TTY. `--yes`
564
- * suppresses it regardless. Has no effect once {@link prompt} is injected.
565
- */
566
- interactive?: boolean;
567
- logger: Logger;
568
- name?: string;
569
- /**
570
- * Inject the offer's prompts (tests). When set, the offer is treated as
571
- * interactive regardless of TTY, and these drive the feature multi-select
572
- * and the auth-provider sub-select.
573
- */
574
- prompt?: Pick<OfferDeps, "multiSelect" | "select">;
575
- /** Local registry root for the offer's `runAddCommand` (offline / tests). Mirrors `from` but for registry items. */
576
- registryFrom?: string;
577
- /** Override the remote registry source base for the offer (default `gh:anolilab/lunora/registry`). */
578
- registrySource?: string;
579
- /**
580
- * Override the remote source giget downloads from. Default:
581
- * `gh:anolilab/lunora/templates/&lt;templateType>#v&lt;cliVersion>`. Tests
582
- * typically use `from` instead to skip the network.
583
- */
584
- source?: string;
585
- templateType?: Template;
586
- /** Suppress the offer entirely (the `--yes` flag): scaffold only, print the later-setup hint. */
587
- yes?: boolean;
588
- }
589
- interface InitCommandResult {
590
- code: number;
591
- files: ReadonlyArray<string>;
592
- target: string;
593
- }
594
- /**
595
- * `lunora init` entry: scaffold (in-place or a new directory), then — on success
596
- * — offer to add auth + email via the registry. The offer never affects the
597
- * scaffold's exit code.
598
- */
599
- declare const runInitCommand: (options: InitCommandOptions) => Promise<InitCommandResult>;
600
- /** Narrow a raw `--template` value to a known {@link Template} (defaults to vite). */
601
- interface MigrateGenerateCommandOptions {
602
- cwd?: string;
603
- logger: Logger;
604
- /** Migration name slug. Defaults to `auto`. */
605
- name?: string;
606
- /** Override the current time — used by tests for deterministic file names. */
607
- now?: () => Date;
608
- }
609
- interface MigrateGenerateCommandResult {
610
- code: number;
611
- /** Whether the diff was empty (no changes detected). */
612
- empty: boolean;
613
- /** Absolute path to the migration file (empty string when nothing was written). */
614
- migrationFile: string;
615
- }
616
- declare const runMigrateGenerateCommand: (options: MigrateGenerateCommandOptions) => MigrateGenerateCommandResult;
617
- /** One catalog entry as `lunora registry list` reports it. */
618
- interface CatalogItem {
619
- description?: string;
620
- name: string;
621
- }
622
- /** A built index entry (catalog item plus its short `title`). */
623
- interface IndexItem extends CatalogItem {
624
- title?: string;
625
- }
626
- /** Names of the subdirectories under `root` that ship a `registry.json`. */
627
-
628
- /**
629
- * Build the catalog (`index.json` contents) from a local registry root by
630
- * reading every item's `registry.json`. Used by both `lunora registry build`
631
- * and the registry tests so the committed index can't drift from the item dirs.
632
- */
633
- declare const buildRegistryIndex: (root: string) => {
634
- items: IndexItem[];
635
- };
636
565
  /** A single file the item scaffolds into the project. */
637
566
  interface RegistryFile {
638
567
  /** Source path inside the item dir (e.g. `schema.ts`). */
@@ -648,10 +577,10 @@ interface RegistryBinding {
648
577
  value: unknown;
649
578
  }
650
579
  /**
651
- * An environment variable an item needs. Scaffolded into `.dev.vars` (Workers'
652
- * local-secrets file) on add — non-secrets get their `value`; secrets get an
653
- * empty placeholder and a reminder to run `wrangler secret put` for production.
654
- */
580
+ * An environment variable an item needs. Scaffolded into `.dev.vars` (Workers'
581
+ * local-secrets file) on add — non-secrets get their `value`; secrets get an
582
+ * empty placeholder and a reminder to run `wrangler secret put` for production.
583
+ */
655
584
  interface RegistryEnvVariable {
656
585
  /** Human note on what the variable is for. */
657
586
  description?: string;
@@ -662,6 +591,13 @@ interface RegistryEnvVariable {
662
591
  /** A default/example value for non-secret vars. */
663
592
  value?: string;
664
593
  }
594
+ /** A re-export the item needs injected into the worker entry point (class-B/C only). */
595
+ interface EntrypointReexport {
596
+ /** Optional JS comment placed above the re-export line. */
597
+ comment?: string;
598
+ /** Module specifier (e.g. `"_generated/workflows"` → `export * from "./lunora/_generated/workflows"`). */
599
+ module: string;
600
+ }
665
601
  /** The `registry.json` manifest shape. */
666
602
  interface RegistryManifest {
667
603
  /** wrangler.jsonc additions (best-effort structural edits). */
@@ -673,6 +609,8 @@ interface RegistryManifest {
673
609
  devDependencies?: Readonly<Record<string, string>>;
674
610
  /** Post-install guidance printed after the item is added (per-item next steps). */
675
611
  docs?: string;
612
+ /** Worker-entry re-exports the item needs (class-B/C only). */
613
+ entrypointReexports?: ReadonlyArray<EntrypointReexport>;
676
614
  /** Environment variables the item needs; scaffolded into `.dev.vars`. */
677
615
  envVars?: ReadonlyArray<RegistryEnvVariable>;
678
616
  files: ReadonlyArray<RegistryFile>;
@@ -707,8 +645,17 @@ interface AddCommandOptions {
707
645
  out?: string;
708
646
  /** Force-overwrite existing files (take the incoming copy) instead of skipping/conflicting. */
709
647
  overwrite?: boolean;
648
+ /** Override the git ref (branch, tag, or commit) items are fetched from (default: version-derived); appended to the `source` base when that is set. Ignored when `from` is set. */
649
+ ref?: string;
710
650
  /** Override the remote registry source base (default gh:anolilab/lunora/registry). */
711
651
  source?: string;
652
+ /**
653
+ * Customize each resolved manifest after it is loaded but before the plan is
654
+ * printed / reconciled — used to inject user-chosen values into otherwise
655
+ * static manifests (e.g. the R2 `bucket_name` the init storage prompt asks
656
+ * for). Applied to every item; return the manifest unchanged to leave it as-is.
657
+ */
658
+ transformManifest?: (manifest: RegistryManifest) => RegistryManifest;
712
659
  /** Skip the package.json mutation confirmation prompt. */
713
660
  yes?: boolean;
714
661
  }
@@ -723,20 +670,219 @@ interface AddCommandResult {
723
670
  /** Files written (absolute paths). */
724
671
  written: ReadonlyArray<string>;
725
672
  }
726
- /** One resolved item: its parsed manifest plus the (possibly staged) directory it lives in. */
673
+ /**
674
+ * A feature offered in the post-scaffold multi-select. `auth`/`email` carry a
675
+ * sub-prompt or alias; every other value IS the registry item name applied
676
+ * directly (`storage` → the `storage` registry item, etc.).
677
+ */
678
+ type StackFeature = "ai" | "auth" | "backup" | "browser" | "cloudflare-access" | "crons" | "email" | "flags" | "hyperdrive" | "payment" | "presence" | "queue" | "storage" | "workflow";
679
+ /** Customize a resolved manifest before it is written (e.g. inject the chosen R2 bucket name). */
680
+ type OfferTransformManifest = (manifest: RegistryManifest) => RegistryManifest;
681
+ /**
682
+ * One feature ready to apply: the registry item name(s), an optional manifest
683
+ * transform, and a short `label` (the feature value) shown on the combined
684
+ * progress line. Built up-front by the collectors so every prompt is answered
685
+ * before any apply runs.
686
+ */
687
+ interface FeatureApply {
688
+ label: string;
689
+ names: ReadonlyArray<string>;
690
+ transformManifest?: OfferTransformManifest;
691
+ }
692
+ interface OfferDeps {
693
+ /**
694
+ * Apply the collected features into the new project in one batch — resolves
695
+ * `true` when every item succeeds. The CLI renders this as a single progress
696
+ * line whose label changes per feature; each plan's `transformManifest`
697
+ * customizes that item's manifest before it is written.
698
+ */
699
+ applyAll: (plans: ReadonlyArray<FeatureApply>) => Promise<boolean>;
700
+ /** When `false`, skip all prompts and print the later-setup hint. */
701
+ interactive: boolean;
702
+ logger: Logger;
703
+ /** Multi-select among the stack features to add (TTY-backed in production). */
704
+ multiSelect: (message: string, options: ReadonlyArray<{
705
+ description?: string;
706
+ label: string;
707
+ value: StackFeature;
708
+ }>, settings?: {
709
+ defaults?: ReadonlyArray<StackFeature>;
710
+ }) => Promise<StackFeature[]>;
711
+ /**
712
+ * Features chosen non-interactively (the `--add` flag). When set, the
713
+ * multi-select and every sub-prompt are skipped — each feature is applied with
714
+ * its shipped defaults (base registry item, placeholder bindings).
715
+ */
716
+ preselected?: ReadonlyArray<StackFeature>;
717
+ /** The new project's name — seeds smart defaults like the `project-uploads` bucket name. */
718
+ projectName: string;
719
+ /** Single-select among the auth providers (TTY-backed in production). */
720
+ select: (message: string, options: ReadonlyArray<{
721
+ description?: string;
722
+ label: string;
723
+ value: FeatureItem;
724
+ }>, settings?: {
725
+ default?: FeatureItem;
726
+ }) => Promise<FeatureItem | undefined>;
727
+ /** Single-line text input (TTY-backed in production) — used for the storage bucket-name prompt. */
728
+ text: (message: string, settings?: {
729
+ default?: string;
730
+ placeholder?: string;
731
+ }) => Promise<string>;
732
+ }
733
+ type Template = "analog" | "astro" | "expo" | "next" | "nuxt" | "react-router" | "standalone" | "sveltekit" | "tanstack-start-react" | "tanstack-start-solid";
734
+ interface InitCommandOptions {
735
+ /**
736
+ * Add features non-interactively after scaffolding (the `--add` flag): a
737
+ * comma-separated list of `ai | auth | backup | browser | cloudflare-access | crons | email | flags | hyperdrive | payment | presence | queue | storage | workflow`.
738
+ * Bypasses the interactive multi-select and sub-prompts —
739
+ * each named feature is applied with its shipped defaults.
740
+ */
741
+ add?: string;
742
+ /**
743
+ * When true, accept `--source` values that don't start with `gh:` /
744
+ * `github:` / `https://` or that contain `..`. Defaults to false; the CLI
745
+ * gate exists to stop arbitrary filesystem / scheme sources from being
746
+ * pulled without the caller opting in.
747
+ */
748
+ allowUnsafeSource?: boolean;
749
+ /** When set, also scaffold a CI deploy pipeline for the given provider. */
750
+ ci?: CiProvider;
751
+ cwd?: string;
752
+ /**
753
+ * Walk the whole flow — prompts, task list, next-steps, mascot — but make no
754
+ * changes: skip the template fetch/copy, the feature applies, the dependency
755
+ * install, and `git init`. Each skipped action logs a `would …` line instead.
756
+ */
757
+ dryRun?: boolean;
758
+ /**
759
+ * Local directory containing the template subdirs (e.g. `vite/`,
760
+ * `standalone/`). When provided, skips the network fetch entirely.
761
+ * Useful for offline runs, the clean-machine smoke test, and unit tests.
762
+ */
763
+ from?: string;
764
+ /**
765
+ * When true, configure Lunora into the CURRENT project (`cwd`) instead of
766
+ * scaffolding a new directory. Finds an existing `vite.config.*` and
767
+ * patches it via `patchViteConfig`, or creates a minimal one when absent.
768
+ * All other scaffold options (`name`, `templateType`, `source`, `from`)
769
+ * are ignored in this mode.
770
+ */
771
+ inPlace?: boolean;
772
+ /**
773
+ * Inject the post-scaffold install offer's prompts (tests). When set, the
774
+ * offer runs regardless of TTY: `confirmInstall` drives the yes/no, and
775
+ * `selectManager` picks among the detected managers.
776
+ */
777
+ installPrompt?: {
778
+ confirmInstall: () => Promise<boolean>;
779
+ selectManager: (managers: ReadonlyArray<PackageManager>) => Promise<PackageManager>;
780
+ };
781
+ /**
782
+ * Force the post-scaffold "add auth / email?" offer on (the `--interactive`
783
+ * flag). When omitted, the offer runs only when stdin is a TTY. `--yes`
784
+ * suppresses it regardless. Has no effect once {@link prompt} is injected.
785
+ */
786
+ interactive?: boolean;
787
+ logger: Logger;
788
+ name?: string;
789
+ /**
790
+ * Local directory holding create-vite bases (one `template-&lt;id>/` subdir per
791
+ * framework). When set with `vite`, the overlay copies the base from disk
792
+ * instead of fetching `create-vite` over the network — offline mode + tests.
793
+ */
794
+ overlayBaseFrom?: string;
795
+ /** Probe for which package managers are installed (tests). Defaults to a real `&lt;pm> --version` check. */
796
+ packageManagerProbe?: PackageManagerProbe;
797
+ /**
798
+ * Inject the offer's prompts (tests). When set, the offer is treated as
799
+ * interactive regardless of TTY, and these drive the feature multi-select,
800
+ * the auth-provider sub-select, and the storage bucket-name text input.
801
+ */
802
+ prompt?: Pick<OfferDeps, "multiSelect" | "select" | "text">;
803
+ /**
804
+ * Override the git ref (branch, tag, or commit) the default template source
805
+ * is fetched from. Takes precedence over the version-derived ref. Ignored
806
+ * when `source` or `from` is set.
807
+ */
808
+ ref?: string;
809
+ /** Local registry root for the offer's `runAddCommand` (offline / tests). Mirrors `from` but for registry items. */
810
+ registryFrom?: string;
811
+ /** Override the remote registry source base for the offer (default `gh:anolilab/lunora/registry`). */
812
+ registrySource?: string;
813
+ /**
814
+ * Override the remote source giget downloads from. Default:
815
+ * `gh:anolilab/lunora/templates/&lt;templateType>#&lt;ref>`, where `&lt;ref>` is
816
+ * the `ref` option when set, else derived from the CLI version (pre-release
817
+ * channels → their branch, stable → `main`). Tests typically use `from`
818
+ * instead to skip the network.
819
+ */
820
+ source?: string;
821
+ /** Spawner for the post-scaffold dependency install (tests inject a recording stub). Defaults to a real subprocess. */
822
+ spawner?: Spawner;
823
+ templateType?: Template;
824
+ /**
825
+ * Scaffold via the **create-vite overlay** for this framework (`react`,
826
+ * `vue`, `solid`, `svelte`, `vanilla`) instead of a bespoke template: fetch
827
+ * the official create-vite base and apply the Lunora layer on top. Takes
828
+ * precedence over `templateType`.
829
+ */
830
+ vite?: string;
831
+ /** Suppress the offer entirely (the `--yes` flag): scaffold only, print the later-setup hint. */
832
+ yes?: boolean;
833
+ }
834
+ interface InitCommandResult {
835
+ code: number;
836
+ files: ReadonlyArray<string>;
837
+ target: string;
838
+ }
839
+ declare const runInitCommand: (options: InitCommandOptions) => Promise<InitCommandResult>;
840
+ interface MigrateGenerateCommandOptions {
841
+ cwd?: string;
842
+ logger: Logger;
843
+ /** Migration name slug. Defaults to `auto`. */
844
+ name?: string;
845
+ /** Override the current time — used by tests for deterministic file names. */
846
+ now?: () => Date;
847
+ }
848
+ interface MigrateGenerateCommandResult {
849
+ code: number;
850
+ /** Whether the diff was empty (no changes detected). */
851
+ empty: boolean;
852
+ /** Absolute path to the migration file (empty string when nothing was written). */
853
+ migrationFile: string;
854
+ }
855
+ declare const runMigrateGenerateCommand: (options: MigrateGenerateCommandOptions) => MigrateGenerateCommandResult;
856
+ /** One catalog entry as `lunora registry list` reports it. */
857
+ interface CatalogItem {
858
+ description?: string;
859
+ name: string;
860
+ }
861
+ /** A built index entry (catalog item plus its short `title`). */
862
+ interface IndexItem extends CatalogItem {
863
+ title?: string;
864
+ }
865
+ /**
866
+ * Build the catalog (`index.json` contents) from a local registry root by
867
+ * reading every item's `registry.json`. Used by both `lunora registry build`
868
+ * and the registry tests so the committed index can't drift from the item dirs.
869
+ */
870
+ declare const buildRegistryIndex: (root: string) => {
871
+ items: IndexItem[];
872
+ };
727
873
  /** `lunora registry add` (one or more item names): scaffold items into the project. */
728
874
  declare const runAddCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
729
875
  /**
730
- * `lunora registry view` — inspect a registry item without installing it:
731
- * print its plan (files / deps / env vars) followed by the full contents of each
732
- * file it would scaffold. Resolves only the named item — no `requires` expansion.
733
- */
876
+ * `lunora registry view` — inspect a registry item without installing it:
877
+ * print its plan (files / deps / env vars) followed by the full contents of each
878
+ * file it would scaffold. Resolves only the named item — no `requires` expansion.
879
+ */
734
880
  declare const runRegistryViewCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
735
881
  /**
736
- * `lunora registry build` — regenerate `index.json` from the item directories
737
- * (the catalog `list` reads). With `--check`, verify the committed index matches
738
- * instead of rewriting it (exits non-zero on drift) — a CI guard.
739
- */
882
+ * `lunora registry build` — regenerate `index.json` from the item directories
883
+ * (the catalog `list` reads). With `--check`, verify the committed index matches
884
+ * instead of rewriting it (exits non-zero on drift) — a CI guard.
885
+ */
740
886
  declare const runBuildIndexCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
741
887
  /** Validate + narrow a parsed JSON value into a {@link RegistryManifest}. */
742
888
  declare const parseManifest: (raw: unknown, itemName: string) => RegistryManifest;
@@ -754,23 +900,6 @@ interface ResetCommandResult {
754
900
  removed: ReadonlyArray<string>;
755
901
  }
756
902
  declare const runResetCommand: (options: ResetCommandOptions) => Promise<ResetCommandResult>;
757
- /** `lunora reset` handler (lazy-loaded via the command's `loader`). */
758
- /**
759
- * Tiny argv parser.
760
- *
761
- * Supports long options (`--name value`, `--name=value`, `--flag`), short
762
- * options (`-x value`, `-xvalue`), positional arguments (everything else, in
763
- * order), and a `--` terminator after which everything is positional.
764
- *
765
- * Intentionally small — replaces a full CLI library for the handful of
766
- * subcommands we need.
767
- */
768
- interface ParsedArgs {
769
- flags: Record<string, boolean>;
770
- options: Record<string, string>;
771
- positional: ReadonlyArray<string>;
772
- }
773
- declare const parseArgs: (argv: ReadonlyArray<string>, booleanFlags?: ReadonlySet<string>) => ParsedArgs;
774
903
  type InsertSchemaExtensionResult = {
775
904
  ok: true;
776
905
  text: string;
@@ -779,12 +908,12 @@ type InsertSchemaExtensionResult = {
779
908
  reason: "already-applied" | "invalid-identifier" | "no-define-schema" | "non-object-argument";
780
909
  };
781
910
  /**
782
- * Append `.extend(&lt;key>.extension)` and a managed import to an existing
783
- * `lunora/schema.ts`. Idempotent: a second call for the same `key` returns
784
- * `already-applied` and leaves the text unchanged.
785
- * @param source the current `lunora/schema.ts` contents
786
- * @param key the registry item key (e.g. `"ratelimit"`)
787
- */
911
+ * Append `.extend(&lt;key>.extension)` and a managed import to an existing
912
+ * `lunora/schema.ts`. Idempotent: a second call for the same `key` returns
913
+ * `already-applied` and leaves the text unchanged.
914
+ * @param source the current `lunora/schema.ts` contents
915
+ * @param key the registry item key (e.g. `"ratelimit"`)
916
+ */
788
917
  declare const insertSchemaExtension: (source: string, key: string) => InsertSchemaExtensionResult;
789
918
  /** Compact snapshot of a single global table — what we persist + diff. */
790
919
  interface TableSnapshot {
@@ -827,10 +956,10 @@ interface SchemaDiff {
827
956
  unsupported: ReadonlyArray<UnsupportedEntry>;
828
957
  }
829
958
  /**
830
- * Map a Lunora validator kind to a SQLite type affinity — the canonical
831
- * `@lunora/d1/dialect` mapping. Re-exported under this name because
832
- * `schema-snapshot.ts` builds the persisted snapshot from it.
833
- */
959
+ * Map a Lunora validator kind to a SQLite type affinity — the canonical
960
+ * `@lunora/d1/dialect` mapping. Re-exported under this name because
961
+ * `schema-snapshot.ts` builds the persisted snapshot from it.
962
+ */
834
963
  declare const validatorKindToSqlType: (kind: string) => ColumnSnapshot["sqlType"];
835
964
  /** Emit `CREATE TABLE` SQL for a new global table. */
836
965
  declare const renderCreateTable: (table: TableSnapshot) => string;
@@ -839,14 +968,14 @@ declare const renderAddColumn: (tableName: string, columnName: string, column: C
839
968
  declare const renderCreateIndex: (tableName: string, index: IndexSnapshot) => string;
840
969
  declare const renderDropIndex: (tableName: string, indexName: string) => string;
841
970
  /**
842
- * Compute a {@link SchemaDiff} from two snapshots. Pure function — no I/O.
843
- */
971
+ * Compute a {@link SchemaDiff} from two snapshots. Pure function — no I/O.
972
+ */
844
973
  declare const diffSnapshots: (previous: SchemaSnapshot | undefined, next: SchemaSnapshot) => SchemaDiff;
845
974
  /**
846
- * Render a complete migration file body from a diff. Includes a header,
847
- * each SQL statement, and (if any) a trailing comment block describing the
848
- * manual SQL the user needs to fill in for unsupported deltas.
849
- */
975
+ * Render a complete migration file body from a diff. Includes a header,
976
+ * each SQL statement, and (if any) a trailing comment block describing the
977
+ * manual SQL the user needs to fill in for unsupported deltas.
978
+ */
850
979
  declare const renderMigrationFile: (name: string, diff: SchemaDiff, generatedAt: string) => string;
851
980
  declare const schemaIrToSnapshot: (ir: SchemaIR) => SchemaSnapshot;
852
- export { type AddCommandOptions, type AddCommandResult, COMMANDS, type ColumnSnapshot, type CommandName, DEFAULT_IMPORT_BATCH_SIZE, type DeployCommandOptions, type DeployCommandResult, type DevCommandOptions, type DevCommandPlan, type DiffEntry, type ExportCommandOptions, type ExportCommandResult, type FetchLike, type ImportCommandOptions, type ImportCommandResult, type IndexSnapshot, type InitCommandOptions, type InitCommandResult, type InsertSchemaExtensionResult, type Logger, type MigrateGenerateCommandOptions, type MigrateGenerateCommandResult, type RecordedSpawn, type RegistryBinding, type RegistryFile, type RegistryManifest, type ResetCommandOptions, type ResetCommandResult, type RunCliOptions, type RunCommandOptions, type RunCommandResult, type SchemaDiff, type SchemaSnapshot, type SpawnDescriptor, type SpawnResult, type Spawner, type StreamingFetchLike, type TableSnapshot, type Template, type UnsupportedEntry, VERSION, buildRegistryIndex, createLogger, createRecordingSpawner, defaultSpawner, diffSnapshots, insertSchemaExtension, pail, parseArgs, parseManifest, planDevCommand, renderAddColumn, renderCreateIndex, renderCreateTable, renderDropIndex, renderDropTable, renderMigrationFile, runAddCommand, runBuildIndexCommand, runCli, runCodegenCommand, runDeployCommand, runDevCommand, runExportCommand, runImportCommand, runInitCommand, runMigrateGenerateCommand, runRegistryViewCommand, runResetCommand, runRpcCommand, schemaIrToSnapshot, validatorKindToSqlType };
981
+ export { type AddCommandOptions, type AddCommandResult, COMMANDS, type ColumnSnapshot, type CommandName, DEFAULT_IMPORT_BATCH_SIZE, type DeployCommandOptions, type DeployCommandResult, type DevCommandOptions, type DevCommandPlan, type DiffEntry, type ExportCommandOptions, type ExportCommandResult, type FetchLike, type ImportCommandOptions, type ImportCommandResult, type IndexSnapshot, type InitCommandOptions, type InitCommandResult, type InsertSchemaExtensionResult, type Logger, type MigrateGenerateCommandOptions, type MigrateGenerateCommandResult, type RecordedSpawn, type RegistryBinding, type RegistryFile, type RegistryManifest, type ResetCommandOptions, type ResetCommandResult, type RunCliOptions, type RunCommandOptions, type RunCommandResult, type SchemaDiff, type SchemaSnapshot, type SpawnDescriptor, type SpawnResult, type Spawner, type StreamingFetchLike, type TableSnapshot, type Template, type UnsupportedEntry, VERSION, buildRegistryIndex, createLogger, createRecordingSpawner, defaultSpawner, diffSnapshots, insertSchemaExtension, pail, parseManifest, planDevCommand, renderAddColumn, renderCreateIndex, renderCreateTable, renderDropIndex, renderDropTable, renderMigrationFile, runAddCommand, runBuildIndexCommand, runCli, runCodegenCommand, runDeployCommand, runDevCommand, runExportCommand, runImportCommand, runInitCommand, runMigrateGenerateCommand, runRegistryViewCommand, runResetCommand, runRpcCommand, schemaIrToSnapshot, validatorKindToSqlType };