@lunora/cli 1.0.0-alpha.15 → 1.0.0-alpha.150

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 (107) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +1 -1
  3. package/__assets__/package-og.svg +1 -1
  4. package/dist/bin.mjs +2 -10
  5. package/dist/index.d.mts +585 -336
  6. package/dist/index.d.ts +585 -336
  7. package/dist/index.mjs +1 -19
  8. package/dist/packem_chunks/handler.mjs +1 -150
  9. package/dist/packem_chunks/handler10.mjs +1 -22
  10. package/dist/packem_chunks/handler11.mjs +1 -192
  11. package/dist/packem_chunks/handler12.mjs +2 -131
  12. package/dist/packem_chunks/handler13.mjs +2 -65
  13. package/dist/packem_chunks/handler14.mjs +1 -58
  14. package/dist/packem_chunks/handler15.mjs +1 -79
  15. package/dist/packem_chunks/handler16.mjs +1 -43
  16. package/dist/packem_chunks/handler17.mjs +1 -105
  17. package/dist/packem_chunks/handler18.mjs +3 -170
  18. package/dist/packem_chunks/handler19.mjs +1 -89
  19. package/dist/packem_chunks/handler2.mjs +2 -114
  20. package/dist/packem_chunks/handler20.mjs +1 -94
  21. package/dist/packem_chunks/handler21.mjs +7 -311
  22. package/dist/packem_chunks/handler22.mjs +2 -0
  23. package/dist/packem_chunks/handler23.mjs +1 -0
  24. package/dist/packem_chunks/handler24.mjs +99 -0
  25. package/dist/packem_chunks/handler25.mjs +10 -0
  26. package/dist/packem_chunks/handler3.mjs +2 -204
  27. package/dist/packem_chunks/handler4.mjs +2 -33
  28. package/dist/packem_chunks/handler5.mjs +1 -49
  29. package/dist/packem_chunks/handler6.mjs +1 -91
  30. package/dist/packem_chunks/handler7.mjs +1 -42
  31. package/dist/packem_chunks/handler8.mjs +1 -174
  32. package/dist/packem_chunks/handler9.mjs +3 -16
  33. package/dist/packem_chunks/planDevCommand.mjs +7 -500
  34. package/dist/packem_chunks/runCodegenCommand.mjs +4 -52
  35. package/dist/packem_chunks/runDeployCommand.mjs +1 -504
  36. package/dist/packem_chunks/runInitCommand.mjs +1018 -1315
  37. package/dist/packem_chunks/runMigrateGenerateCommand.mjs +9 -395
  38. package/dist/packem_chunks/runResetCommand.mjs +1 -41
  39. package/dist/packem_chunks/runRpcCommand.mjs +1 -68
  40. package/dist/packem_shared/COMMANDS-DkO6XHZS.mjs +1 -0
  41. package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Dqu4Zmi0.mjs +1 -0
  42. package/dist/packem_shared/admin-token-BKmc3AUm.mjs +1 -0
  43. package/dist/packem_shared/admin-url-Ca-KI3d_.mjs +1 -0
  44. package/dist/packem_shared/advisory-gate-yaOOyUQl.mjs +1 -0
  45. package/dist/packem_shared/api-spec-BENwiyUa.mjs +1 -0
  46. package/dist/packem_shared/buildRegistryIndex-DwySASBu.mjs +1 -0
  47. package/dist/packem_shared/cli-DYGVS96x.mjs +3 -0
  48. package/dist/packem_shared/codegen-error-DJN6pTH5.mjs +3 -0
  49. package/dist/packem_shared/command-0l-ZPhIX.mjs +1 -0
  50. package/dist/packem_shared/commands-CG9qEtqR.mjs +19 -0
  51. package/dist/packem_shared/createLogger-BoSxdb2T.mjs +2 -0
  52. package/dist/packem_shared/createRecordingSpawner-SKs4R1fc.mjs +1 -0
  53. package/dist/packem_shared/deploy-target-Dvr9vxpR.mjs +1 -0
  54. package/dist/packem_shared/detect-package-manager-DXDstphE.mjs +1 -0
  55. package/dist/packem_shared/diffSnapshots-BbwCuhoN.mjs +5 -0
  56. package/dist/packem_shared/docker-CKvYE9YF.mjs +1 -0
  57. package/dist/packem_shared/import-DLyCq-2j.mjs +12 -0
  58. package/dist/packem_shared/insertSchemaExtension-DZReBZ4_.mjs +8 -0
  59. package/dist/packem_shared/lint-ignore-report-CKDXv9MQ.mjs +2 -0
  60. package/dist/packem_shared/open-url-zbbAo_D7.mjs +1 -0
  61. package/dist/packem_shared/output-format-Cv3aLqhP.mjs +2 -0
  62. package/dist/packem_shared/parseManifest-x3WsxKHz.mjs +1 -0
  63. package/dist/packem_shared/platform-diagnostics-C4TFj5Pu.mjs +4 -0
  64. package/dist/packem_shared/post-codegen-hook-DhL1RH5u.mjs +1 -0
  65. package/dist/packem_shared/prompt-cancelled-C8Sj7OqI.mjs +1 -0
  66. package/dist/packem_shared/resolve-target-CeiNrCAx.mjs +1 -0
  67. package/dist/packem_shared/runAddCommand-a_rW768_.mjs +1 -0
  68. package/dist/packem_shared/runExportCommand-BpE4AbuX.mjs +5 -0
  69. package/dist/packem_shared/schema-drift-gate-d12lMICD.mjs +1 -0
  70. package/dist/packem_shared/schemaIrToSnapshot-Dahp39qH.mjs +1 -0
  71. package/dist/packem_shared/shared-Ce9bKz5c.mjs +1 -0
  72. package/dist/packem_shared/tui-prompts-BU3irGxV.mjs +4 -0
  73. package/dist/packem_shared/vectorize-metadata-BvZbbqUD.mjs +1 -0
  74. package/dist/packem_shared/wrangler-name-CHDf3rMP.mjs +1 -0
  75. package/dist/packem_shared/wrangler-secrets-D0Tv5GWn.mjs +1 -0
  76. package/package.json +39 -17
  77. package/skills/README.md +28 -14
  78. package/skills/lunora/SKILL.md +48 -9
  79. package/skills/lunora-functions/SKILL.md +38 -3
  80. package/skills/lunora-migration-helper/SKILL.md +70 -17
  81. package/skills/lunora-performance-audit/SKILL.md +36 -6
  82. package/skills/lunora-quickstart/SKILL.md +86 -24
  83. package/skills/lunora-realtime/SKILL.md +58 -30
  84. package/dist/packem_shared/COMMANDS-D3h9Iwvl.mjs +0 -944
  85. package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs +0 -244
  86. package/dist/packem_shared/admin-url-4UzT-CI4.mjs +0 -19
  87. package/dist/packem_shared/api-spec-CtA6ilu4.mjs +0 -13
  88. package/dist/packem_shared/buildRegistryIndex-BcYe607_.mjs +0 -38
  89. package/dist/packem_shared/command-BC30oSBW.mjs +0 -14
  90. package/dist/packem_shared/commands-hl0mRqqg.mjs +0 -845
  91. package/dist/packem_shared/createLogger-B40gPzQo.mjs +0 -78
  92. package/dist/packem_shared/createRecordingSpawner-DxI3mebw.mjs +0 -43
  93. package/dist/packem_shared/detect-package-manager-DYp7n3mJ.mjs +0 -61
  94. package/dist/packem_shared/diffSnapshots-BeDvvNiF.mjs +0 -161
  95. package/dist/packem_shared/docker-hMQ97KSQ.mjs +0 -21
  96. package/dist/packem_shared/insertSchemaExtension-DAqbfr9Z.mjs +0 -64
  97. package/dist/packem_shared/open-url-Dfq6fAyT.mjs +0 -41
  98. package/dist/packem_shared/output-format-wUvAN6AL.mjs +0 -17
  99. package/dist/packem_shared/parseArgs-YXFuKdEk.mjs +0 -56
  100. package/dist/packem_shared/parseManifest--vZf2FY1.mjs +0 -94
  101. package/dist/packem_shared/resolve-target-qbsJ_5sF.mjs +0 -16
  102. package/dist/packem_shared/runAddCommand-vJdgiR5t.mjs +0 -4
  103. package/dist/packem_shared/schema-drift-gate-BtBt0as0.mjs +0 -79
  104. package/dist/packem_shared/schemaIrToSnapshot-DdsljJT-.mjs +0 -43
  105. package/dist/packem_shared/storage-B7hHSTZP.mjs +0 -84
  106. package/dist/packem_shared/tui-prompts-M6OWsuyw.mjs +0 -663
  107. package/dist/packem_shared/wrangler-name-cy4yhm9j.mjs +0 -12
package/dist/index.d.ts CHANGED
@@ -1,33 +1,35 @@
1
- import { CodegenOptions, SchemaIR } from '@lunora/codegen';
1
+ import { CodegenOptions, Finding, SchemaIR } from '@lunora/codegen';
2
2
  import '@visulima/cerebro';
3
- import { ensureDevVariables, ensureDevVarsExample, materializeRemoteWranglerConfig } from '@lunora/config';
4
- export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, type WranglerProjectValidationOptions as WranglerValidationOptions, type WranglerValidationReport, type WranglerProjectValidationResult as WranglerValidationResult, validateWranglerProject as validateWrangler, validateWranglerConfig } from '@lunora/config';
3
+ import { ensureDevVariables, ensureDevVarsExample, fillDevSecrets, LintTool, LintIgnoreOutcome } from '@lunora/config';
4
+ import 'adm-zip';
5
+ import { materializeRemoteWranglerConfig } from '@lunora/config/cloudflare';
6
+ export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, type WranglerProjectValidationOptions as WranglerValidationOptions, type WranglerValidationReport, type WranglerProjectValidationResult as WranglerValidationResult, validateWranglerProject as validateWrangler, validateWranglerConfig } from '@lunora/config/cloudflare';
5
7
  /** Every command name the CLI registers (drives the `CommandName` type + tests). */
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"];
8
+ declare const COMMANDS: readonly ["init", "add", "dev", "codegen", "build", "deploy", "containers", "prepare", "link", "deployments", "logs", "run", "insights", "reset", "migrate", "export", "import", "seed", "backup", "eval", "verify", "info", "doctor", "env", "analyze", "view", "docs", "registry", "rules", "mcp"];
7
9
  type CommandName = (typeof COMMANDS)[number];
8
10
  declare const VERSION: string;
9
11
  interface RunCliOptions {
10
12
  argv?: ReadonlyArray<string>;
11
13
  cwd?: string;
12
14
  /**
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
- */
15
+ * Inject a console-like logger so callers (tests) can capture cerebro's
16
+ * help / version / usage rendering. Omitted in production, where cerebro
17
+ * uses its default stdout/stderr logger.
18
+ */
17
19
  logger?: Console;
18
20
  }
19
21
  /**
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
- */
22
+ * Run the CLI and resolve to the process exit code. cerebro handles help,
23
+ * version, usage, and unknown commands (the latter throws, caught here as 1).
24
+ * `shouldExitProcess: false` keeps the process alive so callers/tests read the
25
+ * captured exit code.
26
+ */
25
27
  declare const runCli: (options?: RunCliOptions) => Promise<number>;
26
28
  /**
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
- */
29
+ * The `--api-spec` flag's accepted values, mirroring `@lunora/codegen`'s
30
+ * `CodegenOptions["apiSpec"]`. `"openapi"` (the default) emits `openapi.json`;
31
+ * `"openrpc"` emits `openrpc.json`; `"both"` emits both; `"none"` emits neither.
32
+ */
31
33
  type ApiSpec = NonNullable<CodegenOptions["apiSpec"]>;
32
34
  interface Logger {
33
35
  debug?: (message: string) => void;
@@ -37,11 +39,11 @@ interface Logger {
37
39
  warn: (message: string) => void;
38
40
  }
39
41
  /**
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
- */
42
+ * Narrowed view over the pail instance. `createPail` returns an intersection
43
+ * type that includes a constructor signature and `(...args: any[])` logger
44
+ * overloads, which the type-aware linter cannot safely resolve. We only ever
45
+ * call the level methods with a string, so we describe exactly that surface.
46
+ */
45
47
  interface PailLogger {
46
48
  debug: (message: string) => void;
47
49
  error: (message: string) => void;
@@ -51,25 +53,12 @@ interface PailLogger {
51
53
  }
52
54
  declare const createLogger: () => Logger;
53
55
  /**
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
- */
56
+ * Direct access to the underlying pail instance for advanced use-cases.
57
+ * A Proxy keeps the public `pail` binding lazy: the real pail is only
58
+ * constructed on first property access, so importing this module (and thus
59
+ * the package barrel) stays side-effect-free.
60
+ */
66
61
  declare const pail: PailLogger;
67
- /**
68
- * Emit a badged step line through the shared pail (the `init` flow's off-TTY
69
- * fallback for the create-astro-style transcript). The `message` may contain
70
- * newlines — `LunoraReporter` indents continuation lines under the badge so a
71
- * dimmed answer sits below its question.
72
- */
73
62
  interface CodegenCommandOptions {
74
63
  /** Which API spec(s) to emit. Defaults to codegen's `"openapi"` when omitted. */
75
64
  apiSpec?: ApiSpec;
@@ -77,33 +66,43 @@ interface CodegenCommandOptions {
77
66
  /** Output format: `pretty` (default) or `json`. */
78
67
  format?: string;
79
68
  logger: Logger;
69
+ /**
70
+ * Fail the run when any ERROR-level advisory is reported. Defaults to CI
71
+ * detection so a local `lunora codegen` stays advisory while a pipeline
72
+ * gates on it; `--no-strict-advisories` forces it off either way.
73
+ */
74
+ strictAdvisories?: boolean;
75
+ /** Deploy target the emitted `ctx.*` surface is tailored to. Resolved by the caller; falls back to `"target"` in `lunora.json`, then `"cloudflare"`. */
76
+ target?: string;
80
77
  }
81
78
  interface CodegenCommandResult {
82
79
  advisories: ReadonlyArray<{
83
80
  detail: string;
84
- level: string;
81
+ level: Finding["level"];
85
82
  name: string;
86
83
  remediation: string;
87
84
  }>;
88
85
  cronTriggers: ReadonlyArray<string>;
89
- /** Set when the run aborted on an invalid `--format` before codegen ran. */
86
+ /** Set when the run failed: an invalid `--format`, an unregistered target, or an error-level platform diagnostic. */
90
87
  error?: string;
88
+ /** ERROR-level advisories that made the run fail, when strict mode is on. */
89
+ failedAdvisories: number;
91
90
  outputDirectory: string;
92
91
  }
93
92
  declare const runCodegenCommand: (options: CodegenCommandOptions) => CodegenCommandResult;
94
- /** `lunora codegen` handler (lazy-loaded via the command's `loader`). */
95
- /** Rows per HTTP request when importing. Convex uses ~500; same here. */
96
- declare const DEFAULT_IMPORT_BATCH_SIZE = 500;
97
93
  /**
98
- * Minimal projection of `globalThis.fetch` for the export path we need
99
- * `body` as a stream-iterable, which the shared {@link FetchLike} type
100
- * intentionally hides for the JSON-only commands.
101
- */
94
+ * Minimal projection of `globalThis.fetch` for the transfer commands: `body` is
95
+ * exposed as a stream-iterable (the export path pipes it) and accepts bytes (the
96
+ * blob path uploads them). The JSON-only commands use the narrower `FetchLike`
97
+ * in `../run/handler` instead.
98
+ */
102
99
  type StreamingFetchLike = (input: string, init?: {
103
- body?: string;
100
+ body?: string | Uint8Array;
104
101
  headers?: Record<string, string>;
105
102
  method?: string;
106
103
  }) => Promise<{
104
+ /** Optional: only the storage transfer reads raw bytes, and only real `fetch` needs to supply it. */
105
+ arrayBuffer?: () => Promise<ArrayBuffer>;
107
106
  body: ReadableStream<Uint8Array> | null;
108
107
  json: () => Promise<unknown>;
109
108
  ok: boolean;
@@ -132,11 +131,70 @@ interface ExportCommandResult {
132
131
  rows: number;
133
132
  }
134
133
  /**
135
- * Stream an export. The worker emits NDJSON; we count newlines as we go and
136
- * pipe straight to the output sink, so a 10M-row export doesn't materialise
137
- * the body in memory.
138
- */
134
+ * Stream an export. The worker emits NDJSON; we count newlines as we go and
135
+ * pipe straight to the output sink, so a 10M-row export doesn't materialise
136
+ * the body in memory.
137
+ */
139
138
  declare const runExportCommand: (options: ExportCommandOptions) => Promise<ExportCommandResult>;
139
+ /** One row-scoped failure as the admin import endpoint reports it. */
140
+ interface ImportRowError {
141
+ code: string;
142
+ line: number;
143
+ message: string;
144
+ table: string;
145
+ }
146
+ /**
147
+ * The sources `--from` accepts.
148
+ *
149
+ * Only the two that cannot be detected. A Convex snapshot announces itself (a
150
+ * directory of `<table>/documents.jsonl`, or a `.zip` of one) and anything else
151
+ * is NDJSON, so naming those would advertise a control this does not implement:
152
+ * `--from ndjson` against a Convex export would have to either refuse it or
153
+ * silently import it as Convex, and the second is what an unhonoured flag
154
+ * actually did.
155
+ */
156
+ declare const IMPORT_SOURCE_NAMES: readonly ["firebase", "supabase"];
157
+ type ImportSourceName = (typeof IMPORT_SOURCE_NAMES)[number];
158
+ /**
159
+ * The storage-reference rewrite: turning a Convex storage id into the
160
+ * content-hash R2 key its blob was migrated to.
161
+ *
162
+ * Split out of `./storage-mapping` (which owns the mapping *file*) because it
163
+ * has two callers that must never diverge — the import rewrite and `--scan`,
164
+ * which runs this same walk as a dry run to propose the mapping. A detector
165
+ * that proposed columns the rewrite would not touch, or missed ones it would,
166
+ * is worse than no detector.
167
+ */
168
+ /** One reference the walk could not rewrite, with where it was found. */
169
+ interface UnresolvedStorageReference {
170
+ column: string;
171
+ storageId: string;
172
+ table: string;
173
+ }
174
+ /**
175
+ * What a run's storage references resolved to. The two failure buckets are
176
+ * deliberately separate, because they are not the same problem and do not have
177
+ * the same remedy:
178
+ *
179
+ * `unmigrated` is a reference to a blob that does not exist — the export omitted
180
+ * it, or `--include-file-storage` was not passed. Nothing the operator writes in
181
+ * a mapping file can fix it, and the data is broken after import, so it fails
182
+ * `--verify`.
183
+ *
184
+ * `ambiguous` is a string that exactly matches a blob that *did* migrate, sitting
185
+ * in a column the mapping does not name. It may be a storage reference the
186
+ * mapping forgot, or it may be user text that happens to equal an id. Failing the
187
+ * run on a coincidence is not defensible, so it warns and names the column the
188
+ * operator would add to resolve it.
189
+ */
190
+ interface StorageRemapReport {
191
+ ambiguous: UnresolvedStorageReference[];
192
+ /** Number of references rewritten to a content-hash key. */
193
+ rewritten: number;
194
+ unmigrated: UnresolvedStorageReference[];
195
+ }
196
+ /** Rows per HTTP request when importing. Convex uses ~500; same here. */
197
+ declare const DEFAULT_IMPORT_BATCH_SIZE = 500;
140
198
  interface ImportCommandOptions {
141
199
  /** Rows per HTTP request. Defaults to {@link DEFAULT_IMPORT_BATCH_SIZE}. */
142
200
  batchSize?: number;
@@ -144,88 +202,175 @@ interface ImportCommandOptions {
144
202
  fetchImpl?: StreamingFetchLike;
145
203
  /** Source NDJSON file. Required. */
146
204
  file: string;
205
+ /**
206
+ * Which reader to use. Omit to auto-detect between a Convex export snapshot
207
+ * and a plain NDJSON file; `supabase`/`firebase` must be explicit, because a
208
+ * directory of CSV or JSON has no signature that distinguishes it from
209
+ * anything else a user might point at.
210
+ */
211
+ from?: ImportSourceName;
147
212
  logger: Logger;
148
213
  prod?: boolean;
149
214
  /**
150
- * Wrap each line as `{table:&lt;name>,doc:&lt;line>}`. Use when the source NDJSON
151
- * is bare docs from a single table — Convex's `convex import --table users`
152
- * shape.
153
- */
215
+ * Scan the export for columns holding `_storage` ids and write a candidate
216
+ * `lunora/import-convex.json`. Scan-only: nothing is imported.
217
+ */
218
+ scan?: boolean;
219
+ /**
220
+ * Local directory of storage objects to migrate alongside the rows — how
221
+ * Firebase Cloud Storage arrives, after `gcloud storage cp -r`.
222
+ */
223
+ storageDir?: string;
224
+ /**
225
+ * Wrap each line as `{table:<name>,doc:<line>}`. Use when the source NDJSON
226
+ * is bare docs from a single table — Convex's `convex import --table users`
227
+ * shape.
228
+ */
154
229
  table?: string;
155
230
  token?: string;
156
231
  url?: string;
232
+ /**
233
+ * Verify per-table row parity + dangling-storage after import. Exits non-zero
234
+ * when a table's inserted count differs from its source line count, or when a
235
+ * document references a storage id that was not migrated.
236
+ */
237
+ verify?: boolean;
238
+ /**
239
+ * Also migrate Convex `_storage` blobs: read `_storage/documents.jsonl`, upload
240
+ * each blob with sha256+size verification, and build the `storageId → key` map.
241
+ * Off by default so the plain-document import path is unchanged.
242
+ */
243
+ withStorage?: boolean;
244
+ /** Confirm bulk-writing production. Required alongside `--prod`. */
245
+ yes?: boolean;
246
+ }
247
+ /**
248
+ * The JSON summary a run prints and returns — the same object either way, so a
249
+ * caller reading `body.conflicts` does not have to cast its way there.
250
+ *
251
+ * `undefined` on every path that imports nothing: a rejected source, a failed
252
+ * storage phase, or `--scan` (whose product is the mapping file it writes, not
253
+ * a return value).
254
+ */
255
+ interface ImportSummary {
256
+ conflicts: number;
257
+ errors: ImportRowError[];
258
+ inserted: Record<string, number>;
259
+ received: number;
260
+ storage?: {
261
+ ambiguous: StorageRemapReport["ambiguous"];
262
+ blobs: number;
263
+ rewritten: number;
264
+ unmigrated: StorageRemapReport["unmigrated"];
265
+ };
266
+ warnings?: string[];
157
267
  }
158
268
  interface ImportCommandResult {
159
- body: unknown;
269
+ body: ImportSummary | undefined;
160
270
  code: number;
161
271
  /** Total inserted rows across batches. */
162
272
  inserted: number;
163
273
  }
164
- /**
165
- * Stream an NDJSON file in chunks, POSTing each batch to
166
- * `/_lunora/admin/import`. We keep the line buffer bounded by `batchSize` so a
167
- * multi-GiB file imports without buffering everything in memory.
168
- */
169
274
  declare const runImportCommand: (options: ImportCommandOptions) => Promise<ImportCommandResult>;
170
275
  /**
171
- * Injectable probe for a Docker-compatible container engine. Tests pass a
172
- * stub; production uses {@link isDockerAvailable}.
173
- */
276
+ * Injectable probe for a Docker-compatible container engine. Tests pass a
277
+ * stub; production uses {@link isDockerAvailable}.
278
+ */
174
279
  type DockerProbe = () => boolean;
175
- /**
176
- * True when a Docker-compatible engine answers `docker info` — the same
177
- * prerequisite `wrangler deploy` has for building and pushing a container
178
- * image from a local Dockerfile. Quiet by design (output discarded): callers
179
- * own the messaging.
180
- */
181
280
  interface SpawnDescriptor {
182
281
  args: ReadonlyArray<string>;
183
282
  /**
184
- * Capture the child's stdout (in addition to streaming it to the parent), so
185
- * the caller can parse it used by `deploy` to read the deployed URL from
186
- * `wrangler deploy` output. Each chunk is still teed to the parent's stdout
187
- * so the user sees live progress. Mutually exclusive with `stdoutToStderr`.
188
- */
283
+ * Capture the child's stderr (in addition to streaming it to the parent).
284
+ * Needed when a tool reports the *expected* outcome as an error there
285
+ * `wrangler vectorize create-metadata-index` writes "already exists" to
286
+ * stderr, and without this the caller can only see a bare exit code and
287
+ * would warn on every re-run. Composes with `stdoutToStderr`, so a caller
288
+ * can keep stdout clean for `--format json` and still read the reason.
289
+ */
290
+ captureStderr?: boolean;
291
+ /**
292
+ * Capture the child's stdout (in addition to streaming it to the parent), so
293
+ * the caller can parse it — used by `deploy` to read the deployed URL from
294
+ * `wrangler deploy` output. Each chunk is still teed to the parent's stdout
295
+ * so the user sees live progress. Mutually exclusive with `stdoutToStderr`
296
+ * and `captureStdoutSilently`.
297
+ */
189
298
  captureStdout?: boolean;
299
+ /**
300
+ * Capture the child's stdout WITHOUT teeing it to the parent's stdout —
301
+ * for output that is parsed, never displayed (e.g. `wrangler secret list
302
+ * --format json`). Unlike `captureStdout`, nothing is written to
303
+ * `process.stdout`, so it can't interleave with — and corrupt — a
304
+ * caller's own stdout (notably `lunora deploy --format json`, which must
305
+ * emit exactly one JSON document). Mutually exclusive with `captureStdout`
306
+ * and `stdoutToStderr`.
307
+ */
308
+ captureStdoutSilently?: boolean;
190
309
  command: string;
191
310
  cwd?: string;
192
311
  env?: Readonly<Record<string, string>>;
193
312
  /**
194
- * Pipe this string into the child's stdin and close it. Used to feed
195
- * `wrangler secret put` its value without exposing it on the command
196
- * line or in env. When absent, stdin is inherited from the parent.
197
- */
313
+ * Pipe this string into the child's stdin and close it. Used to feed
314
+ * `wrangler secret put` its value without exposing it on the command
315
+ * line or in env. When absent, stdin is inherited from the parent.
316
+ */
198
317
  input?: string;
199
318
  /**
200
- * Route the child's stdout to the parent's STDERR instead of stdout. Set in
201
- * `--format json` mode so a spawned tool's human output (e.g. `wrangler
202
- * deploy`'s progress + the deployed URL) can't interleave with — and corrupt
203
- * — the single JSON document the command prints to stdout.
204
- */
319
+ * Route the child's stdout to the parent's STDERR instead of stdout. Set in
320
+ * `--format json` mode so a spawned tool's human output (e.g. `wrangler
321
+ * deploy`'s progress + the deployed URL) can't interleave with — and corrupt
322
+ * — the single JSON document the command prints to stdout.
323
+ */
205
324
  stdoutToStderr?: boolean;
206
325
  }
207
326
  interface SpawnResult {
208
327
  code: number;
209
- /** The captured stdout, present only when the descriptor set `captureStdout`. */
328
+ /** The captured stderr, present only when the descriptor set `captureStderr`. */
329
+ stderr?: string;
330
+ /** The captured stdout, present only when the descriptor set `captureStdout` or `captureStdoutSilently`. */
210
331
  stdout?: string;
211
332
  }
212
333
  /**
213
- * Injectable spawner. Tests pass a stub that just records the descriptor
214
- * instead of executing a real subprocess.
215
- */
334
+ * Injectable spawner. Tests pass a stub that just records the descriptor
335
+ * instead of executing a real subprocess.
336
+ */
216
337
  type Spawner = (descriptor: SpawnDescriptor) => Promise<SpawnResult>;
217
338
  declare const defaultSpawner: Spawner;
218
339
  interface RecordedSpawn {
219
340
  descriptor: SpawnDescriptor;
220
341
  }
221
342
  /**
222
- * Test helper: returns a spawner that records every invocation and resolves
223
- * with the configured exit code.
224
- */
343
+ * Test helper: returns a spawner that records every invocation and resolves
344
+ * with the configured exit code.
345
+ */
225
346
  declare const createRecordingSpawner: (exitCode?: number) => {
226
347
  calls: RecordedSpawn[];
227
348
  spawner: Spawner;
228
349
  };
350
+ interface SecretListRunnerResult {
351
+ code: number;
352
+ stderr: string;
353
+ stdout: string;
354
+ }
355
+ /** Runs an argv and resolves its captured output. Injected in tests. */
356
+ type SecretListRunner = (command: string, args: ReadonlyArray<string>, cwd: string) => Promise<SecretListRunnerResult>;
357
+ interface ListRemoteSecretsInputs {
358
+ cwd: string;
359
+ /** Cloudflare environment name (`--env`). */
360
+ env?: string;
361
+ /** Injected command runner; defaults to a real `wrangler secret list`. */
362
+ runner?: SecretListRunner;
363
+ /** Target a temporary-account deployment (`--temporary`). */
364
+ temporary?: boolean;
365
+ }
366
+ interface ListRemoteSecretsResult {
367
+ /** Diagnostic message when `ok` is false. */
368
+ error?: string;
369
+ /** Remote secret names (sorted), empty when none or on failure. */
370
+ names: ReadonlyArray<string>;
371
+ /** False when wrangler failed or its output could not be parsed. */
372
+ ok: boolean;
373
+ }
229
374
  type FetchLike = (input: string, init?: {
230
375
  body?: string;
231
376
  headers?: Record<string, string>;
@@ -238,11 +383,17 @@ type FetchLike = (input: string, init?: {
238
383
  }>;
239
384
  interface RunCommandOptions {
240
385
  args?: string;
386
+ /** Forge this user id for the call (dispatches through the admin-gated `runAs` op). */
387
+ as?: string;
388
+ /** JSON-encoded extra identity claims to accompany {@link RunCommandOptions.as}. */
389
+ claims?: string;
241
390
  cwd?: string;
242
391
  fetchImpl?: FetchLike;
243
392
  functionPath: string;
244
393
  logger: Logger;
245
394
  shard?: string;
395
+ /** Admin bearer for the `runAs` dispatch; resolved from the environment / `.dev.vars` when absent. */
396
+ token?: string;
246
397
  url?: string;
247
398
  }
248
399
  interface RunCommandResult {
@@ -251,7 +402,6 @@ interface RunCommandResult {
251
402
  requestUrl: string;
252
403
  }
253
404
  declare const runRpcCommand: (options: RunCommandOptions) => Promise<RunCommandResult>;
254
- /** `lunora run &lt;functionPath>` handler (lazy-loaded via the command's `loader`). */
255
405
  interface DeployCommandOptions {
256
406
  /** Override the schema-drift gate — deploy even with breaking drift and no new migration. */
257
407
  allowSchemaDrift?: boolean;
@@ -261,10 +411,10 @@ interface DeployCommandOptions {
261
411
  /** Docker-availability probe injected in tests. Defaults to a real `docker info` check. */
262
412
  dockerAvailable?: DockerProbe;
263
413
  /**
264
- * Validate, bundle, and run all pre-deploy gates without publishing
265
- * (`wrangler deploy --dry-run`). Post-deploy steps (data migrations, schema
266
- * baseline re-bless) are skipped since nothing shipped.
267
- */
414
+ * Validate, bundle, and run all pre-deploy gates without publishing
415
+ * (`wrangler deploy --dry-run`). Post-deploy steps (data migrations, schema
416
+ * baseline re-bless) are skipped since nothing shipped.
417
+ */
268
418
  dryRun?: boolean;
269
419
  env?: string;
270
420
  /** Fetch implementation injected in tests for `--migrate` RPC calls. */
@@ -275,59 +425,81 @@ interface DeployCommandOptions {
275
425
  interactive?: boolean;
276
426
  logger: Logger;
277
427
  /**
278
- * When true, after a successful `wrangler deploy`, discover and run all
279
- * pending data migrations via the worker's `/_lunora/migrate` admin RPC.
280
- * The worker must be live (exit 0) before migrations are attempted.
281
- *
282
- * Implementation note: the status RPC returns the full shard-level
283
- * migration state, but there is no single authoritative "list of pending
284
- * migration ids" that can be read client-side before running the worker.
285
- * Instead, `--migrate` runs `migrate status` followed by `migrate up` for
286
- * each migration id discovered locally via `discoverMigrations`. The
287
- * worker's `MigrationRunner` is idempotent — running `up` on an already-
288
- * applied migration is a no-op — so this approach is safe.
289
- */
428
+ * When true, after a successful `wrangler deploy`, discover and run all
429
+ * pending data migrations via the worker's `/_lunora/migrate` admin RPC.
430
+ * The worker must be live (exit 0) before migrations are attempted.
431
+ *
432
+ * Implementation note: the status RPC returns the full shard-level
433
+ * migration state, but there is no single authoritative "list of pending
434
+ * migration ids" that can be read client-side before running the worker.
435
+ * Instead, `--migrate` runs `migrate status` followed by `migrate up` for
436
+ * each migration id discovered locally via `discoverMigrations`. The
437
+ * worker's `MigrationRunner` is idempotent — running `up` on an already-
438
+ * applied migration is a no-op — so this approach is safe.
439
+ */
290
440
  migrate?: boolean;
291
441
  /** Admin bearer token for `--migrate` (falls back to `LUNORA_ADMIN_TOKEN`). */
292
442
  migrateToken?: string;
293
443
  /**
294
- * Worker URL for `--migrate`. REQUIRED when `--migrate` is set — the deploy
295
- * handler never captures the URL `wrangler deploy` published to, so there is
296
- * no safe default; omitting it would silently target `http://localhost:8787`
297
- * (the dev worker), applying the migration to local state instead of prod.
298
- */
444
+ * Worker URL for `--migrate`. REQUIRED when `--migrate` is set — the deploy
445
+ * handler never captures the URL `wrangler deploy` published to, so there is
446
+ * no safe default; omitting it would silently target `http://localhost:8787`
447
+ * (the dev worker), applying the migration to local state instead of prod.
448
+ */
299
449
  migrateUrl?: string;
300
450
  /**
301
- * Confirm a production data migration triggered via `--migrate` (the
302
- * `migrate up --prod` confirmation the standalone command requires). Without
303
- * it a `--migrate --migrate-url &lt;prod>` deploy refuses to run the migration.
304
- */
451
+ * Confirm a production data migration triggered via `--migrate` (the
452
+ * `migrate up --prod` confirmation the standalone command requires). Without
453
+ * it a `--migrate --migrate-url <prod>` deploy refuses to run the migration.
454
+ */
305
455
  migrateYes?: boolean;
306
456
  /**
307
- * Emit the bundled worker to this directory via `wrangler deploy --outdir`
308
- * (paired with `dryRun` by `lunora build`). Also writes esbuild metadata to
309
- * `&lt;outDir>/bundle-meta.json`. When unset, no artifact is written.
310
- */
457
+ * Emit the bundled worker to this directory via `wrangler deploy --outdir`
458
+ * (paired with `dryRun` by `lunora build`). Also writes esbuild metadata to
459
+ * `<outDir>/bundle-meta.json`. When unset, no artifact is written.
460
+ */
311
461
  outDir?: string;
312
462
  /**
313
- * Upload a preview version (`wrangler versions upload`) instead of a live
314
- * `wrangler deploy`. Codegen + the drift gate + validation still run, but
315
- * the post-deploy finalize (migrations, baseline re-bless, auto-link, the
316
- * production summary) is skipped — a preview never shifts live traffic.
317
- */
463
+ * Upload a preview version (`wrangler versions upload`) instead of a live
464
+ * `wrangler deploy`. Codegen + the drift gate + validation still run, but
465
+ * the post-deploy finalize (migrations, baseline re-bless, auto-link, the
466
+ * production summary) is skipped — a preview never shifts live traffic.
467
+ */
318
468
  preview?: boolean;
319
469
  /** Railpack-availability probe injected in tests. Defaults to a real `railpack --version` + `BUILDKIT_HOST` check. */
320
470
  railpackAvailable?: DockerProbe;
471
+ /** Confirm prompt for the missing-secret offer; injected in tests. Defaults to the TTY prompt. */
472
+ secretConfirm?: (message: string) => Promise<boolean>;
473
+ /** Remote-secret lister for the missing-secret offer; injected in tests. Defaults to `wrangler secret list`. */
474
+ secretLister?: (inputs: ListRemoteSecretsInputs) => Promise<ListRemoteSecretsResult>;
321
475
  skipCodegen?: boolean;
322
476
  spawner?: Spawner;
323
477
  /**
324
- * Deploy to a temporary Cloudflare account (`wrangler deploy --temporary`).
325
- * For unauthenticated use only: wrangler provisions a short-lived account +
326
- * token, deploys, and prints a claim URL; the deployment stays live ~60
327
- * minutes before the unclaimed account is deleted. Wrangler itself errors
328
- * if credentials are already present (OAuth / `CLOUDFLARE_API_TOKEN` /
329
- * global API key), so we pass the flag straight through without guarding.
330
- */
478
+ * Fail the deploy when codegen reports an ERROR-level advisory. Same
479
+ * option `lunora codegen` exposes as `--no-strict-advisories`; defaults to
480
+ * CI detection (on in CI, off locally) so a legitimately-partial target
481
+ * can still be shipped interactively. Does NOT gate platform diagnostics
482
+ * (`platform_unsupported_feature` / `platform_unknown_target`), which
483
+ * always block those mean the emitted `ctx.*` surface does not match
484
+ * what the target can serve, not merely a style nit.
485
+ */
486
+ strictAdvisories?: boolean;
487
+ /**
488
+ * Deploy target. Falls back to `"target"` in `lunora.json`, then
489
+ * `"cloudflare"`, which selects the wrangler
490
+ * toolchain — i.e. today's behavior for every project. An unregistered name
491
+ * throws rather than falling back, so a typo can never ship the app to the
492
+ * wrong provider.
493
+ */
494
+ target?: string;
495
+ /**
496
+ * Deploy to a temporary Cloudflare account (`wrangler deploy --temporary`).
497
+ * For unauthenticated use only: wrangler provisions a short-lived account +
498
+ * token, deploys, and prints a claim URL; the deployment stays live ~60
499
+ * minutes before the unclaimed account is deleted. Wrangler itself errors
500
+ * if credentials are already present (OAuth / `CLOUDFLARE_API_TOKEN` /
501
+ * global API key), so we pass the flag straight through without guarding.
502
+ */
331
503
  temporary?: boolean;
332
504
  /** Re-bless the committed schema baseline with the current shape (accepts breaking drift). */
333
505
  updateSchemaBaseline?: boolean;
@@ -337,6 +509,14 @@ interface DeployCommandResult {
337
509
  descriptor: SpawnDescriptor | undefined;
338
510
  /** Set when the run aborted before reaching the wrangler invocation. */
339
511
  error?: string;
512
+ /**
513
+ * The `.dev.vars`-shaped filename (never a full path, never a value) a
514
+ * secret minted during this run was recorded into, when the missing-
515
+ * secret gate minted one — `.dev.vars` for the default environment, or a
516
+ * `.dev.vars.<env>` sibling for an explicit `--env`. `undefined` when
517
+ * nothing was minted this run.
518
+ */
519
+ mintedSecretsFile?: string;
340
520
  /** The schema-drift gate verdict, when it ran (skipped on `--skip-codegen`). */
341
521
  schemaDrift?: {
342
522
  blocked: boolean;
@@ -348,18 +528,17 @@ interface DeployCommandResult {
348
528
  };
349
529
  }
350
530
  /**
351
- * Run a deploy, then (in `--format json` mode) serialize the structured
352
- * {@link DeployCommandResult} to stdout. Human/progress logging is routed to
353
- * stderr for json output so stdout carries only the single JSON document.
354
- */
531
+ * Run a deploy, then (in `--format json` mode) serialize the structured
532
+ * {@link DeployCommandResult} to stdout. Human/progress logging is routed to
533
+ * stderr for json output so stdout carries only the single JSON document.
534
+ */
355
535
  declare const runDeployCommand: (options: DeployCommandOptions) => Promise<DeployCommandResult>;
356
- /** `lunora deploy` handler (lazy-loaded via the command's `loader`). */
357
536
  /**
358
- * Start the codegen watch loop and return a handle to stop it. Regenerates on
359
- * startup, then on debounced changes under `lunora/` (ignoring writes to the
360
- * `_generated/` output to avoid a feedback loop). If the platform can't do a
361
- * recursive watch, it logs once and falls back to startup-only codegen.
362
- */
537
+ * Start the codegen watch loop and return a handle to stop it. Regenerates on
538
+ * startup, then on debounced changes under `lunora/` (ignoring writes to the
539
+ * `_generated/` output to avoid a feedback loop). If the platform can't do a
540
+ * recursive watch, it logs once and falls back to startup-only codegen.
541
+ */
363
542
  declare const startCodegenWatch: (options: CodegenWatcherOptions) => CodegenWatcherHandle;
364
543
  interface CodegenWatcherOptions {
365
544
  /** Which API spec(s) to emit. Defaults to codegen's `"openapi"` when omitted. */
@@ -371,23 +550,25 @@ interface CodegenWatcherOptions {
371
550
  lunoraDirectory?: string;
372
551
  /** Project root containing the `lunora/` directory. */
373
552
  projectRoot: string;
553
+ /** Deploy target the emitted `ctx.*` surface is tailored to. Resolved by the caller; falls back to `"target"` in `lunora.json`, then `"cloudflare"`. */
554
+ target?: string;
374
555
  }
375
556
  interface CodegenWatcherHandle {
376
557
  /** Stop watching and cancel any pending regeneration. */
377
558
  close: () => void;
378
559
  /**
379
- * `true` when the platform supports recursive watch and the loop is active.
380
- * `false` when `fs.watch({ recursive })` threw — startup-only codegen was run
381
- * but schema edits will NOT auto-regenerate. Callers can surface this in the
382
- * dev banner so the degraded state is visible beyond the single startup warning.
383
- */
560
+ * `true` when the platform supports recursive watch and the loop is active.
561
+ * `false` when `fs.watch({ recursive })` threw — startup-only codegen was run
562
+ * but schema edits will NOT auto-regenerate. Callers can surface this in the
563
+ * dev banner so the degraded state is visible beyond the single startup warning.
564
+ */
384
565
  watchAvailable: boolean;
385
566
  }
386
567
  /**
387
- * Start the studio server and resolve once it is listening. Loads the static
388
- * bundle + renders the host HTML once up front; serves them and proxies
389
- * `/_lunora/*` (HTTP + WS) to the worker.
390
- */
568
+ * Start the studio server and resolve once it is listening. Loads the static
569
+ * bundle + renders the host HTML once up front; serves them and proxies
570
+ * `/_lunora/*` (HTTP + WS) to the worker.
571
+ */
391
572
  declare const startStudioServer: (options: StudioServerOptions) => Promise<StudioServerHandle>;
392
573
  interface StudioServerOptions {
393
574
  /** Project root — `.dev.vars` is read from here for the admin token. */
@@ -409,6 +590,24 @@ interface StudioServerHandle {
409
590
  /** The URL to open in a browser. */
410
591
  url: string;
411
592
  }
593
+ /**
594
+ * How the dev child runs. `wrangler` is the classic `lunora dev` stack (wrangler
595
+ * worker + embedded studio + codegen watch) for a standalone class-C project.
596
+ * `vite` is a project on `@lunora/vite`: the plugin already runs the worker,
597
+ * studio, and codegen inside the Vite dev server, so `lunora dev` runs the
598
+ * project's own dev script and gets out of the way — this also covers class-B
599
+ * frameworks whose own dev server runs the worker in `workerd` (Astro 6 +
600
+ * `@astrojs/cloudflare`, which embeds `@cloudflare/vite-plugin` in `astro dev`:
601
+ * SSR + `/_lunora/*` + `ShardDO` in one process, HMR intact). `framework-worker`
602
+ * is a class-B framework whose dev server CANNOT host the `ShardDO` Durable
603
+ * Object (SvelteKit / Nuxt: their adapters use wrangler's `getPlatformProxy()`,
604
+ * which runs an empty-script Miniflare and does not emulate internal DOs); there
605
+ * `lunora dev` runs the framework's own dev server (front door, HMR, and — via
606
+ * its `@lunora/vite` plugin — studio + codegen) AND a second `wrangler dev`
607
+ * sidecar that owns the real `ShardDO` in `workerd`, wired via the committed
608
+ * `wrangler.dev.jsonc`.
609
+ */
610
+ type DevFlavor = "framework-worker" | "vite" | "wrangler";
412
611
  /** A running worker child the orchestrator controls: send signals, await its exit. */
413
612
  interface WorkerProcess {
414
613
  /** Resolves with the worker's exit code (1 if it failed to start). */
@@ -429,6 +628,14 @@ interface DevCommandOptions {
429
628
  ensureEnv?: typeof ensureDevVariables;
430
629
  /** Injection seam for tests — defaults to the real `.dev.vars.example` package-aware scaffolder. */
431
630
  ensureExample?: typeof ensureDevVarsExample;
631
+ /** Injection seam for tests — defaults to the real empty-secret/admin-token filler. */
632
+ fillSecrets?: typeof fillDevSecrets;
633
+ /** Injection seam for tests — defaults to the real free-port probe ({@link findAvailablePort}). */
634
+ findFreePort?: (preferred: number) => Promise<number>;
635
+ /** Dev flavor override (tests / callers that already detected it) — defaults to {@link detectDevFlavor}. */
636
+ flavor?: DevFlavor;
637
+ /** Injection seam for tests — defaults to the real IPv6-loopback probe ({@link hasIpv6Loopback}). */
638
+ hasIpv6Loopback?: () => boolean;
432
639
  logger: Logger;
433
640
  /** Injection seam for tests — defaults to the real remote-config materializer. */
434
641
  materializeRemote?: typeof materializeRemoteWranglerConfig;
@@ -444,6 +651,10 @@ interface DevCommandOptions {
444
651
  startWorker?: WorkerSpawner;
445
652
  /** Disable the embedded studio server. */
446
653
  studio?: boolean;
654
+ /** Deploy target the emitted `ctx.*` surface is tailored to. Resolved by the caller; falls back to `"target"` in `lunora.json`, then `"cloudflare"`. */
655
+ target?: string;
656
+ /** Disable the `wrangler dev` spawn — an external task runner owns the worker. */
657
+ worker?: boolean;
447
658
  /** `wrangler dev` port. */
448
659
  workerPort?: number;
449
660
  }
@@ -451,10 +662,10 @@ interface DevRemotePlan {
451
662
  /** Short binding labels remoted (e.g. `"DB (D1)"`), for the banner. */
452
663
  bindings: string[];
453
664
  /**
454
- * Removes the generated temp wrangler config when dev exits. Always present
455
- * and idempotent — a no-op when remote mode is off or nothing was
456
- * materialized. The dev loop calls it on every shutdown path.
457
- */
665
+ * Removes the generated temp wrangler config when dev exits. Always present
666
+ * and idempotent — a no-op when remote mode is off or nothing was
667
+ * materialized. The dev loop calls it on every shutdown path.
668
+ */
458
669
  cleanup: () => void;
459
670
  /** Whether remote mode was requested. */
460
671
  enabled: boolean;
@@ -463,57 +674,83 @@ interface DevRemotePlan {
463
674
  }
464
675
  interface DevCommandPlan {
465
676
  codegenEnabled: boolean;
677
+ /** Which stack the child runs — see {@link DevFlavor}. */
678
+ flavor: DevFlavor;
679
+ /**
680
+ * One-line redirect hint printed when a meta-framework is detected on the
681
+ * wrangler flavor: without `@lunora/vite` in the dependencies the worker
682
+ * still runs *inside* the framework's dev server, so the user should run
683
+ * their framework dev script for the full app. `undefined` for the vite
684
+ * flavor (`lunora dev` already runs the project's dev script there) and
685
+ * for a standalone project. Purely informational: the wrangler spawn runs
686
+ * regardless.
687
+ */
688
+ frameworkHint?: string;
689
+ /**
690
+ * True when `wrangler dev` was given `--ip 127.0.0.1` because the host has no
691
+ * IPv6 loopback (`::1`) — surfaced so the dev loop can note the rebind.
692
+ * Always `false` for the vite flavor (the plugin owns its own bind).
693
+ */
694
+ ipv4LoopbackForced: boolean;
466
695
  /** The remote-binding decision: which D1/KV/R2 bindings hit the deployed worker. */
467
696
  remote: DevRemotePlan;
697
+ /**
698
+ * The `wrangler dev` sidecar for the `framework-worker` flavor (SvelteKit /
699
+ * Nuxt): a second child that owns the real `ShardDO` in `workerd`, wired via
700
+ * the committed `wrangler.dev.jsonc`. `undefined` for every other flavor —
701
+ * only the two-process class-B stack has a sidecar. When present, `wrangler`
702
+ * (above) is the framework's own dev server (the front door / HMR) and this
703
+ * is the Lunora realtime plane.
704
+ */
705
+ sidecar?: SpawnDescriptor & {
706
+ tag: string;
707
+ };
468
708
  studioEnabled: boolean;
469
709
  studioPort: number;
710
+ /**
711
+ * Whether this process spawns `wrangler dev`.
712
+ *
713
+ * `--no-worker` turns it off so an external task runner (Turbo, Nx, vis, a
714
+ * Procfile) can own worker supervision while `lunora dev` still provides
715
+ * codegen-watch and Studio. Without it, `lunora dev` insisted on being the
716
+ * process root, which is what blocked running the Lunora worker as one node
717
+ * in a larger dev graph.
718
+ */
719
+ workerEnabled: boolean;
470
720
  workerOrigin: string;
471
721
  workerPort: number;
472
- /** The single child process `lunora dev` spawns: `wrangler dev`. */
722
+ /** The primary child `lunora dev` spawns: `wrangler dev` (wrangler flavor) or the framework/`vite dev` server (vite / framework-worker). */
473
723
  wrangler: SpawnDescriptor & {
474
724
  tag: string;
475
725
  };
476
726
  }
477
727
  /**
478
- * Resolve remote-binding mode into the extra `wrangler dev` args + a banner
479
- * summary. When `--remote`/`LUNORA_REMOTE` is set we materialize a temp wrangler
480
- * config with `"remote": true` on each D1/KV/R2 binding (Durable Object shards
481
- * stay local) and point `wrangler dev --config` at it, so the local worker reads
482
- * and writes the **deployed** resources. When disabled, or when there's nothing
483
- * to remote, the args stay empty and dev runs fully local.
484
- */
485
- /**
486
- * Plan `lunora dev`: it runs the worker via `wrangler dev` and nothing else as a
487
- * child process. Vite is intentionally NOT spawned — a project may not use Vite,
488
- * and when it does, the `@lunora/vite` plugin already runs the worker inside
489
- * Vite, so the user runs `vite` themselves. Pure + synchronous so it's unit-testable.
490
- */
728
+ * Plan `lunora dev`. Wrangler flavor: the worker runs via `wrangler dev` and
729
+ * nothing else as a child process. Vite flavor (`@lunora/vite` declared): the
730
+ * plugin already runs the worker inside the Vite dev server, so the one child
731
+ * is the project's own dev script (`vite dev`, `astro dev`, …) and every CLI
732
+ * sibling is disabled. Pure + synchronous so it's unit-testable.
733
+ */
491
734
  declare const planDevCommand: (options: DevCommandOptions) => DevCommandPlan;
492
735
  /**
493
- * Start codegen watch + the studio server, spawn `wrangler dev`, print the
494
- * banner, and resolve when the worker exits or the user interrupts — tearing
495
- * down the sibling servers either way. The three side-effecting pieces (worker,
496
- * studio, codegen) are injectable so this is testable without real I/O.
497
- */
736
+ * Start codegen watch + the studio server, spawn `wrangler dev`, print the
737
+ * banner, and resolve when the worker exits or the user interrupts — tearing
738
+ * down the sibling servers either way. The three side-effecting pieces (worker,
739
+ * studio, codegen) are injectable so this is testable without real I/O.
740
+ */
498
741
  declare const runDevCommand: (options: DevCommandOptions) => Promise<{
499
742
  code: number;
500
743
  plan: DevCommandPlan;
501
744
  }>;
502
- /** `lunora dev` handler (lazy-loaded via the command's `loader`). */
503
- /** Supported CI providers. */
504
- type CiProvider = "github" | "gitlab";
505
745
  type PackageManager = "pnpm" | "npm" | "yarn" | "bun";
506
- /** True when `manager` is on PATH — probed by running `&lt;manager> --version`. Injectable for tests. */
746
+ /** True when `manager` is on PATH — probed by running `<manager> --version`. Injectable for tests. */
507
747
  type PackageManagerProbe = (manager: PackageManager) => boolean;
508
- /**
509
- * The package managers actually installed on this machine, in preference order
510
- * ({@link INSTALL_PREFERENCE} pnpm > bun > yarn > npm). The first entry is the
511
- * recommended default for the install prompt; the whole list is what the user
512
- * picks from. Empty when none are found.
513
- */
748
+ /** Supported CI providers. */
749
+ type CiProvider = "github" | "gitlab";
750
+ /** The per-framework auth-UI registry items (`auth-ui` resolves to one of these). */
751
+ type AuthUiItem = "auth-ui-angular" | "auth-ui-react" | "auth-ui-solid" | "auth-ui-svelte" | "auth-ui-vue";
514
752
  /** A registry item a feature can install. */
515
- type FeatureItem = "auth" | "auth-auth0" | "auth-clerk" | "mail";
516
- /** The auth-provider choices offered for `add auth` / the init auth prompt. Each value is a registry item name. */
753
+ type FeatureItem = "auth" | "auth-auth0" | "auth-clerk" | AuthUiItem | "mail";
517
754
  /** A single file the item scaffolds into the project. */
518
755
  interface RegistryFile {
519
756
  /** Source path inside the item dir (e.g. `schema.ts`). */
@@ -529,10 +766,10 @@ interface RegistryBinding {
529
766
  value: unknown;
530
767
  }
531
768
  /**
532
- * An environment variable an item needs. Scaffolded into `.dev.vars` (Workers'
533
- * local-secrets file) on add — non-secrets get their `value`; secrets get an
534
- * empty placeholder and a reminder to run `wrangler secret put` for production.
535
- */
769
+ * An environment variable an item needs. Scaffolded into `.dev.vars` (Workers'
770
+ * local-secrets file) on add — non-secrets get their `value`; secrets get an
771
+ * empty placeholder and a reminder to run `wrangler secret put` for production.
772
+ */
536
773
  interface RegistryEnvVariable {
537
774
  /** Human note on what the variable is for. */
538
775
  description?: string;
@@ -543,6 +780,13 @@ interface RegistryEnvVariable {
543
780
  /** A default/example value for non-secret vars. */
544
781
  value?: string;
545
782
  }
783
+ /** A re-export the item needs injected into the worker entry point (class-B/C only). */
784
+ interface EntrypointReexport {
785
+ /** Optional JS comment placed above the re-export line. */
786
+ comment?: string;
787
+ /** Module specifier (e.g. `"_generated/workflows"` → `export * from "./lunora/_generated/workflows"`). */
788
+ module: string;
789
+ }
546
790
  /** The `registry.json` manifest shape. */
547
791
  interface RegistryManifest {
548
792
  /** wrangler.jsonc additions (best-effort structural edits). */
@@ -554,6 +798,8 @@ interface RegistryManifest {
554
798
  devDependencies?: Readonly<Record<string, string>>;
555
799
  /** Post-install guidance printed after the item is added (per-item next steps). */
556
800
  docs?: string;
801
+ /** Worker-entry re-exports the item needs (class-B/C only). */
802
+ entrypointReexports?: ReadonlyArray<EntrypointReexport>;
557
803
  /** Environment variables the item needs; scaffolded into `.dev.vars`. */
558
804
  envVars?: ReadonlyArray<RegistryEnvVariable>;
559
805
  files: ReadonlyArray<RegistryFile>;
@@ -593,11 +839,11 @@ interface AddCommandOptions {
593
839
  /** Override the remote registry source base (default gh:anolilab/lunora/registry). */
594
840
  source?: string;
595
841
  /**
596
- * Customize each resolved manifest after it is loaded but before the plan is
597
- * printed / reconciled — used to inject user-chosen values into otherwise
598
- * static manifests (e.g. the R2 `bucket_name` the init storage prompt asks
599
- * for). Applied to every item; return the manifest unchanged to leave it as-is.
600
- */
842
+ * Customize each resolved manifest after it is loaded but before the plan is
843
+ * printed / reconciled — used to inject user-chosen values into otherwise
844
+ * static manifests (e.g. the R2 `bucket_name` the init storage prompt asks
845
+ * for). Applied to every item; return the manifest unchanged to leave it as-is.
846
+ */
601
847
  transformManifest?: (manifest: RegistryManifest) => RegistryManifest;
602
848
  /** Skip the package.json mutation confirmation prompt. */
603
849
  yes?: boolean;
@@ -613,21 +859,20 @@ interface AddCommandResult {
613
859
  /** Files written (absolute paths). */
614
860
  written: ReadonlyArray<string>;
615
861
  }
616
- /** One resolved item: its parsed manifest plus the (possibly staged) directory it lives in. */
617
862
  /**
618
- * A feature offered in the post-scaffold multi-select. `auth`/`email` carry a
619
- * sub-prompt or alias; every other value IS the registry item name applied
620
- * directly (`storage` → the `storage` registry item, etc.).
621
- */
622
- type StackFeature = "auth" | "backup" | "crons" | "email" | "presence" | "ratelimit" | "storage";
863
+ * A feature offered in the post-scaffold multi-select. `auth`/`email` carry a
864
+ * sub-prompt or alias; every other value IS the registry item name applied
865
+ * directly (`storage` → the `storage` registry item, etc.).
866
+ */
867
+ type StackFeature = "ai" | "auth" | "auth-ui" | "backup" | "browser" | "cloudflare-access" | "crons" | "email" | "flags" | "hyperdrive" | "payment" | "presence" | "queue" | "storage" | "workflow";
623
868
  /** Customize a resolved manifest before it is written (e.g. inject the chosen R2 bucket name). */
624
869
  type OfferTransformManifest = (manifest: RegistryManifest) => RegistryManifest;
625
870
  /**
626
- * One feature ready to apply: the registry item name(s), an optional manifest
627
- * transform, and a short `label` (the feature value) shown on the combined
628
- * progress line. Built up-front by the collectors so every prompt is answered
629
- * before any apply runs.
630
- */
871
+ * One feature ready to apply: the registry item name(s), an optional manifest
872
+ * transform, and a short `label` (the feature value) shown on the combined
873
+ * progress line. Built up-front by the collectors so every prompt is answered
874
+ * before any apply runs.
875
+ */
631
876
  interface FeatureApply {
632
877
  label: string;
633
878
  names: ReadonlyArray<string>;
@@ -635,11 +880,11 @@ interface FeatureApply {
635
880
  }
636
881
  interface OfferDeps {
637
882
  /**
638
- * Apply the collected features into the new project in one batch — resolves
639
- * `true` when every item succeeds. The CLI renders this as a single progress
640
- * line whose label changes per feature; each plan's `transformManifest`
641
- * customizes that item's manifest before it is written.
642
- */
883
+ * Apply the collected features into the new project in one batch — resolves
884
+ * `true` when every item succeeds. The CLI renders this as a single progress
885
+ * line whose label changes per feature; each plan's `transformManifest`
886
+ * customizes that item's manifest before it is written.
887
+ */
643
888
  applyAll: (plans: ReadonlyArray<FeatureApply>) => Promise<boolean>;
644
889
  /** When `false`, skip all prompts and print the later-setup hint. */
645
890
  interactive: boolean;
@@ -653,13 +898,19 @@ interface OfferDeps {
653
898
  defaults?: ReadonlyArray<StackFeature>;
654
899
  }) => Promise<StackFeature[]>;
655
900
  /**
656
- * Features chosen non-interactively (the `--add` flag). When set, the
657
- * multi-select and every sub-prompt are skipped — each feature is applied with
658
- * its shipped defaults (base registry item, placeholder bindings).
659
- */
901
+ * Features chosen non-interactively (the `--add` flag). When set, the
902
+ * multi-select and every sub-prompt are skipped — each feature is applied with
903
+ * its shipped defaults (base registry item, placeholder bindings).
904
+ */
660
905
  preselected?: ReadonlyArray<StackFeature>;
661
906
  /** The new project's name — seeds smart defaults like the `project-uploads` bucket name. */
662
907
  projectName: string;
908
+ /**
909
+ * Resolve which per-framework auth-UI item (`auth-ui-react|vue|…`) fits the
910
+ * scaffolded project. Injected by the CLI (detected from the template's deps);
911
+ * defaults to `auth-ui-react` when absent so this module stays pure/testable.
912
+ */
913
+ resolveAuthUiItem?: () => string;
663
914
  /** Single-select among the auth providers (TTY-backed in production). */
664
915
  select: (message: string, options: ReadonlyArray<{
665
916
  description?: string;
@@ -674,114 +925,127 @@ interface OfferDeps {
674
925
  placeholder?: string;
675
926
  }) => Promise<string>;
676
927
  }
677
- /**
678
- * Offer the stack features (auth, email, storage, rate limiting, crons,
679
- * presence, backups) in ONE multi-select after a successful scaffold. Auth,
680
- * email, and storage run a follow-up prompt (provider / destination / bucket
681
- * name); every other feature value is applied as its registry item directly.
682
- *
683
- * Every question is asked FIRST (in selection order), then the picked features
684
- * are applied together via {@link OfferDeps.applyAll}the CLI renders that as a
685
- * single progress line whose label changes per feature, instead of one spinner
686
- * per item. Non-interactive: prints how to add them later and changes nothing.
687
- */
688
- type Template = "analog" | "astro" | "next" | "nuxt" | "react-router" | "standalone" | "sveltekit" | "tanstack-start-react" | "tanstack-start-solid";
928
+ /** One choice in the multi-select. */
929
+ interface LintToolOption {
930
+ description: string;
931
+ label: string;
932
+ value: LintTool;
933
+ }
934
+ interface LintToolOfferDeps {
935
+ /** Write the ignores for the chosen tools `applyLintIgnores` in production. */
936
+ apply: (tools: ReadonlyArray<LintTool>) => LintIgnoreOutcome[];
937
+ /** Tools already detectable in the scaffolded project pre-selected in the prompt. */
938
+ detected: ReadonlyArray<LintTool>;
939
+ /** False in CI / `--yes` / off a TTY: skip the prompt and configure whatever was detected. */
940
+ interactive: boolean;
941
+ logger: Logger;
942
+ multiSelect: (message: string, choices: ReadonlyArray<LintToolOption>, settings?: {
943
+ defaults?: ReadonlyArray<LintTool>;
944
+ }) => Promise<LintTool[]>;
945
+ }
946
+ type Template = "analog" | "astro" | "expo" | "next" | "nuxt" | "react-router" | "standalone" | "sveltekit" | "tanstack-start-react" | "tanstack-start-solid";
689
947
  interface InitCommandOptions {
690
948
  /**
691
- * Add features non-interactively after scaffolding (the `--add` flag): a
692
- * comma-separated list of `auth | email | storage | ratelimit | crons |
693
- * presence | backup`. Bypasses the interactive multi-select and sub-prompts —
694
- * each named feature is applied with its shipped defaults.
695
- */
949
+ * Add features non-interactively after scaffolding (the `--add` flag): a
950
+ * comma-separated list of `ai | auth | backup | browser | cloudflare-access | crons | email | flags | hyperdrive | payment | presence | queue | storage | workflow`.
951
+ * Bypasses the interactive multi-select and sub-prompts —
952
+ * each named feature is applied with its shipped defaults.
953
+ */
696
954
  add?: string;
697
955
  /**
698
- * When true, accept `--source` values that don't start with `gh:` /
699
- * `github:` / `https://` or that contain `..`. Defaults to false; the CLI
700
- * gate exists to stop arbitrary filesystem / scheme sources from being
701
- * pulled without the caller opting in.
702
- */
956
+ * When true, accept `--source` values that don't start with `gh:` /
957
+ * `github:` / `https://` or that contain `..`. Defaults to false; the CLI
958
+ * gate exists to stop arbitrary filesystem / scheme sources from being
959
+ * pulled without the caller opting in.
960
+ */
703
961
  allowUnsafeSource?: boolean;
704
962
  /** When set, also scaffold a CI deploy pipeline for the given provider. */
705
963
  ci?: CiProvider;
706
964
  cwd?: string;
707
965
  /**
708
- * Walk the whole flow — prompts, task list, next-steps, mascot — but make no
709
- * changes: skip the template fetch/copy, the feature applies, the dependency
710
- * install, and `git init`. Each skipped action logs a `would …` line instead.
711
- */
966
+ * Walk the whole flow — prompts, task list, next-steps, mascot — but make no
967
+ * changes: skip the template fetch/copy, the feature applies, the dependency
968
+ * install, and `git init`. Each skipped action logs a `would …` line instead.
969
+ */
712
970
  dryRun?: boolean;
713
971
  /**
714
- * Local directory containing the template subdirs (e.g. `vite/`,
715
- * `standalone/`). When provided, skips the network fetch entirely.
716
- * Useful for offline runs, the clean-machine smoke test, and unit tests.
717
- */
972
+ * Local directory containing the template subdirs (e.g. `vite/`,
973
+ * `standalone/`). When provided, skips the network fetch entirely.
974
+ * Useful for offline runs, the clean-machine smoke test, and unit tests.
975
+ */
718
976
  from?: string;
719
977
  /**
720
- * When true, configure Lunora into the CURRENT project (`cwd`) instead of
721
- * scaffolding a new directory. Finds an existing `vite.config.*` and
722
- * patches it via `patchViteConfig`, or creates a minimal one when absent.
723
- * All other scaffold options (`name`, `templateType`, `source`, `from`)
724
- * are ignored in this mode.
725
- */
978
+ * When true, configure Lunora into the CURRENT project (`cwd`) instead of
979
+ * scaffolding a new directory. Finds an existing `vite.config.*` and
980
+ * patches it via `patchViteConfig`, or creates a minimal one when absent.
981
+ * All other scaffold options (`name`, `templateType`, `source`, `from`)
982
+ * are ignored in this mode.
983
+ */
726
984
  inPlace?: boolean;
727
985
  /**
728
- * Inject the post-scaffold install offer's prompts (tests). When set, the
729
- * offer runs regardless of TTY: `confirmInstall` drives the yes/no, and
730
- * `selectManager` picks among the detected managers.
731
- */
986
+ * Inject the post-scaffold install offer's prompts (tests). When set, the
987
+ * offer runs regardless of TTY: `confirmInstall` drives the yes/no, and
988
+ * `selectManager` picks among the detected managers.
989
+ */
732
990
  installPrompt?: {
733
991
  confirmInstall: () => Promise<boolean>;
734
992
  selectManager: (managers: ReadonlyArray<PackageManager>) => Promise<PackageManager>;
735
993
  };
736
994
  /**
737
- * Force the post-scaffold "add auth / email?" offer on (the `--interactive`
738
- * flag). When omitted, the offer runs only when stdin is a TTY. `--yes`
739
- * suppresses it regardless. Has no effect once {@link prompt} is injected.
740
- */
995
+ * Force the post-scaffold "add auth / email?" offer on (the `--interactive`
996
+ * flag). When omitted, the offer runs only when stdin is a TTY. `--yes`
997
+ * suppresses it regardless. Has no effect once {@link prompt} is injected.
998
+ */
741
999
  interactive?: boolean;
1000
+ /**
1001
+ * Test seam for the lint/formatter multi-select. Separate from {@link prompt}
1002
+ * because that one is pinned to the feature-offer's value union — reusing it
1003
+ * here would only typecheck through a cast.
1004
+ */
1005
+ lintPrompt?: LintToolOfferDeps["multiSelect"];
742
1006
  logger: Logger;
743
1007
  name?: string;
744
1008
  /**
745
- * Local directory holding create-vite bases (one `template-&lt;id>/` subdir per
746
- * framework). When set with `vite`, the overlay copies the base from disk
747
- * instead of fetching `create-vite` over the network — offline mode + tests.
748
- */
1009
+ * Local directory holding create-vite bases (one `template-<id>/` subdir per
1010
+ * framework). When set with `vite`, the overlay copies the base from disk
1011
+ * instead of fetching `create-vite` over the network — offline mode + tests.
1012
+ */
749
1013
  overlayBaseFrom?: string;
750
- /** Probe for which package managers are installed (tests). Defaults to a real `&lt;pm> --version` check. */
1014
+ /** Probe for which package managers are installed (tests). Defaults to a real `<pm> --version` check. */
751
1015
  packageManagerProbe?: PackageManagerProbe;
752
1016
  /**
753
- * Inject the offer's prompts (tests). When set, the offer is treated as
754
- * interactive regardless of TTY, and these drive the feature multi-select,
755
- * the auth-provider sub-select, and the storage bucket-name text input.
756
- */
1017
+ * Inject the offer's prompts (tests). When set, the offer is treated as
1018
+ * interactive regardless of TTY, and these drive the feature multi-select,
1019
+ * the auth-provider sub-select, and the storage bucket-name text input.
1020
+ */
757
1021
  prompt?: Pick<OfferDeps, "multiSelect" | "select" | "text">;
758
1022
  /**
759
- * Override the git ref (branch, tag, or commit) the default template source
760
- * is fetched from. Takes precedence over the version-derived ref. Ignored
761
- * when `source` or `from` is set.
762
- */
1023
+ * Override the git ref (branch, tag, or commit) the default template source
1024
+ * is fetched from. Takes precedence over the version-derived ref. Ignored
1025
+ * when `source` or `from` is set.
1026
+ */
763
1027
  ref?: string;
764
1028
  /** Local registry root for the offer's `runAddCommand` (offline / tests). Mirrors `from` but for registry items. */
765
1029
  registryFrom?: string;
766
1030
  /** Override the remote registry source base for the offer (default `gh:anolilab/lunora/registry`). */
767
1031
  registrySource?: string;
768
1032
  /**
769
- * Override the remote source giget downloads from. Default:
770
- * `gh:anolilab/lunora/templates/&lt;templateType>#&lt;ref>`, where `&lt;ref>` is
771
- * the `ref` option when set, else derived from the CLI version (pre-release
772
- * channels → their branch, stable → `main`). Tests typically use `from`
773
- * instead to skip the network.
774
- */
1033
+ * Override the remote source giget downloads from. Default:
1034
+ * `gh:anolilab/lunora/templates/<templateType>#<ref>`, where `<ref>` is
1035
+ * the `ref` option when set, else derived from the CLI version (pre-release
1036
+ * channels → their branch, stable → `main`). Tests typically use `from`
1037
+ * instead to skip the network.
1038
+ */
775
1039
  source?: string;
776
1040
  /** Spawner for the post-scaffold dependency install (tests inject a recording stub). Defaults to a real subprocess. */
777
1041
  spawner?: Spawner;
778
1042
  templateType?: Template;
779
1043
  /**
780
- * Scaffold via the **create-vite overlay** for this framework (`react`,
781
- * `vue`, `solid`, `svelte`, `vanilla`) instead of a bespoke template: fetch
782
- * the official create-vite base and apply the Lunora layer on top. Takes
783
- * precedence over `templateType`.
784
- */
1044
+ * Scaffold via the **create-vite overlay** for this framework (`react`,
1045
+ * `vue`, `solid`, `svelte`, `vanilla`) instead of a bespoke template: fetch
1046
+ * the official create-vite base and apply the Lunora layer on top. Takes
1047
+ * precedence over `templateType`.
1048
+ */
785
1049
  vite?: string;
786
1050
  /** Suppress the offer entirely (the `--yes` flag): scaffold only, print the later-setup hint. */
787
1051
  yes?: boolean;
@@ -791,8 +1055,12 @@ interface InitCommandResult {
791
1055
  files: ReadonlyArray<string>;
792
1056
  target: string;
793
1057
  }
1058
+ /**
1059
+ * `lunora init` entry: scaffold (in-place or a new directory), then — on success
1060
+ * — offer to add auth + email via the registry. The offer never affects the
1061
+ * scaffold's exit code.
1062
+ */
794
1063
  declare const runInitCommand: (options: InitCommandOptions) => Promise<InitCommandResult>;
795
- /** Narrow a raw `--template` value to a known {@link Template}. */
796
1064
  interface MigrateGenerateCommandOptions {
797
1065
  cwd?: string;
798
1066
  logger: Logger;
@@ -818,29 +1086,27 @@ interface CatalogItem {
818
1086
  interface IndexItem extends CatalogItem {
819
1087
  title?: string;
820
1088
  }
821
- /** Names of the subdirectories under `root` that ship a `registry.json`. */
822
-
823
1089
  /**
824
- * Build the catalog (`index.json` contents) from a local registry root by
825
- * reading every item's `registry.json`. Used by both `lunora registry build`
826
- * and the registry tests so the committed index can't drift from the item dirs.
827
- */
1090
+ * Build the catalog (`index.json` contents) from a local registry root by
1091
+ * reading every item's `registry.json`. Used by both `lunora registry build`
1092
+ * and the registry tests so the committed index can't drift from the item dirs.
1093
+ */
828
1094
  declare const buildRegistryIndex: (root: string) => {
829
1095
  items: IndexItem[];
830
1096
  };
831
1097
  /** `lunora registry add` (one or more item names): scaffold items into the project. */
832
1098
  declare const runAddCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
833
1099
  /**
834
- * `lunora registry view` — inspect a registry item without installing it:
835
- * print its plan (files / deps / env vars) followed by the full contents of each
836
- * file it would scaffold. Resolves only the named item — no `requires` expansion.
837
- */
1100
+ * `lunora registry view` — inspect a registry item without installing it:
1101
+ * print its plan (files / deps / env vars) followed by the full contents of each
1102
+ * file it would scaffold. Resolves only the named item — no `requires` expansion.
1103
+ */
838
1104
  declare const runRegistryViewCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
839
1105
  /**
840
- * `lunora registry build` — regenerate `index.json` from the item directories
841
- * (the catalog `list` reads). With `--check`, verify the committed index matches
842
- * instead of rewriting it (exits non-zero on drift) — a CI guard.
843
- */
1106
+ * `lunora registry build` — regenerate `index.json` from the item directories
1107
+ * (the catalog `list` reads). With `--check`, verify the committed index matches
1108
+ * instead of rewriting it (exits non-zero on drift) — a CI guard.
1109
+ */
844
1110
  declare const runBuildIndexCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
845
1111
  /** Validate + narrow a parsed JSON value into a {@link RegistryManifest}. */
846
1112
  declare const parseManifest: (raw: unknown, itemName: string) => RegistryManifest;
@@ -858,23 +1124,6 @@ interface ResetCommandResult {
858
1124
  removed: ReadonlyArray<string>;
859
1125
  }
860
1126
  declare const runResetCommand: (options: ResetCommandOptions) => Promise<ResetCommandResult>;
861
- /** `lunora reset` handler (lazy-loaded via the command's `loader`). */
862
- /**
863
- * Tiny argv parser.
864
- *
865
- * Supports long options (`--name value`, `--name=value`, `--flag`), short
866
- * options (`-x value`, `-xvalue`), positional arguments (everything else, in
867
- * order), and a `--` terminator after which everything is positional.
868
- *
869
- * Intentionally small — replaces a full CLI library for the handful of
870
- * subcommands we need.
871
- */
872
- interface ParsedArgs {
873
- flags: Record<string, boolean>;
874
- options: Record<string, string>;
875
- positional: ReadonlyArray<string>;
876
- }
877
- declare const parseArgs: (argv: ReadonlyArray<string>, booleanFlags?: ReadonlySet<string>) => ParsedArgs;
878
1127
  type InsertSchemaExtensionResult = {
879
1128
  ok: true;
880
1129
  text: string;
@@ -883,12 +1132,12 @@ type InsertSchemaExtensionResult = {
883
1132
  reason: "already-applied" | "invalid-identifier" | "no-define-schema" | "non-object-argument";
884
1133
  };
885
1134
  /**
886
- * Append `.extend(&lt;key>.extension)` and a managed import to an existing
887
- * `lunora/schema.ts`. Idempotent: a second call for the same `key` returns
888
- * `already-applied` and leaves the text unchanged.
889
- * @param source the current `lunora/schema.ts` contents
890
- * @param key the registry item key (e.g. `"ratelimit"`)
891
- */
1135
+ * Append `.extend(<key>.extension)` and a managed import to an existing
1136
+ * `lunora/schema.ts`. Idempotent: a second call for the same `key` returns
1137
+ * `already-applied` and leaves the text unchanged.
1138
+ * @param source the current `lunora/schema.ts` contents
1139
+ * @param key the registry item key (e.g. `"ratelimit"`)
1140
+ */
892
1141
  declare const insertSchemaExtension: (source: string, key: string) => InsertSchemaExtensionResult;
893
1142
  /** Compact snapshot of a single global table — what we persist + diff. */
894
1143
  interface TableSnapshot {
@@ -931,10 +1180,10 @@ interface SchemaDiff {
931
1180
  unsupported: ReadonlyArray<UnsupportedEntry>;
932
1181
  }
933
1182
  /**
934
- * Map a Lunora validator kind to a SQLite type affinity — the canonical
935
- * `@lunora/d1/dialect` mapping. Re-exported under this name because
936
- * `schema-snapshot.ts` builds the persisted snapshot from it.
937
- */
1183
+ * Map a Lunora validator kind to a SQLite type affinity — the canonical
1184
+ * `@lunora/d1/dialect` mapping. Re-exported under this name because
1185
+ * `schema-snapshot.ts` builds the persisted snapshot from it.
1186
+ */
938
1187
  declare const validatorKindToSqlType: (kind: string) => ColumnSnapshot["sqlType"];
939
1188
  /** Emit `CREATE TABLE` SQL for a new global table. */
940
1189
  declare const renderCreateTable: (table: TableSnapshot) => string;
@@ -943,14 +1192,14 @@ declare const renderAddColumn: (tableName: string, columnName: string, column: C
943
1192
  declare const renderCreateIndex: (tableName: string, index: IndexSnapshot) => string;
944
1193
  declare const renderDropIndex: (tableName: string, indexName: string) => string;
945
1194
  /**
946
- * Compute a {@link SchemaDiff} from two snapshots. Pure function — no I/O.
947
- */
1195
+ * Compute a {@link SchemaDiff} from two snapshots. Pure function — no I/O.
1196
+ */
948
1197
  declare const diffSnapshots: (previous: SchemaSnapshot | undefined, next: SchemaSnapshot) => SchemaDiff;
949
1198
  /**
950
- * Render a complete migration file body from a diff. Includes a header,
951
- * each SQL statement, and (if any) a trailing comment block describing the
952
- * manual SQL the user needs to fill in for unsupported deltas.
953
- */
1199
+ * Render a complete migration file body from a diff. Includes a header,
1200
+ * each SQL statement, and (if any) a trailing comment block describing the
1201
+ * manual SQL the user needs to fill in for unsupported deltas.
1202
+ */
954
1203
  declare const renderMigrationFile: (name: string, diff: SchemaDiff, generatedAt: string) => string;
955
1204
  declare const schemaIrToSnapshot: (ir: SchemaIR) => SchemaSnapshot;
956
- 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 };
1205
+ 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 };