@lunora/cli 1.0.0-alpha.2 → 1.0.0-alpha.200

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 (109) hide show
  1. package/LICENSE.md +33 -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 +797 -358
  6. package/dist/index.d.ts +797 -358
  7. package/dist/index.mjs +1 -19
  8. package/dist/packem_chunks/handler.mjs +1 -76
  9. package/dist/packem_chunks/handler10.mjs +2 -22
  10. package/dist/packem_chunks/handler11.mjs +2 -192
  11. package/dist/packem_chunks/handler12.mjs +1 -131
  12. package/dist/packem_chunks/handler13.mjs +1 -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 +3 -41
  16. package/dist/packem_chunks/handler17.mjs +1 -105
  17. package/dist/packem_chunks/handler18.mjs +1 -172
  18. package/dist/packem_chunks/handler19.mjs +7 -89
  19. package/dist/packem_chunks/handler2.mjs +2 -114
  20. package/dist/packem_chunks/handler20.mjs +2 -94
  21. package/dist/packem_chunks/handler21.mjs +2 -311
  22. package/dist/packem_chunks/handler22.mjs +3 -0
  23. package/dist/packem_chunks/handler23.mjs +3 -0
  24. package/dist/packem_chunks/handler24.mjs +1 -0
  25. package/dist/packem_chunks/handler25.mjs +99 -0
  26. package/dist/packem_chunks/handler26.mjs +10 -0
  27. package/dist/packem_chunks/handler3.mjs +1 -204
  28. package/dist/packem_chunks/handler4.mjs +1 -33
  29. package/dist/packem_chunks/handler5.mjs +1 -49
  30. package/dist/packem_chunks/handler6.mjs +1 -91
  31. package/dist/packem_chunks/handler7.mjs +3 -42
  32. package/dist/packem_chunks/handler8.mjs +1 -174
  33. package/dist/packem_chunks/handler9.mjs +1 -16
  34. package/dist/packem_chunks/planDevCommand.mjs +7 -543
  35. package/dist/packem_chunks/runCodegenCommand.mjs +4 -52
  36. package/dist/packem_chunks/runDeployCommand.mjs +1 -504
  37. package/dist/packem_chunks/runInitCommand.mjs +1141 -565
  38. package/dist/packem_chunks/runMigrateGenerateCommand.mjs +9 -395
  39. package/dist/packem_chunks/runResetCommand.mjs +1 -41
  40. package/dist/packem_chunks/runRpcCommand.mjs +1 -68
  41. package/dist/packem_shared/COMMANDS-su5nmqYP.mjs +1 -0
  42. package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Nf7GsE6v.mjs +1 -0
  43. package/dist/packem_shared/admin-token-rxXZbVMZ.mjs +1 -0
  44. package/dist/packem_shared/admin-url-Cil3Or6N.mjs +1 -0
  45. package/dist/packem_shared/advisory-gate-Cl8IEFIj.mjs +1 -0
  46. package/dist/packem_shared/api-spec-lYyq4vL6.mjs +1 -0
  47. package/dist/packem_shared/buildRegistryIndex-Zi3bBqpc.mjs +1 -0
  48. package/dist/packem_shared/cli-RB-BoDnW.mjs +3 -0
  49. package/dist/packem_shared/codegen-error-C04fGQjf.mjs +3 -0
  50. package/dist/packem_shared/command-DwC11Cwe.mjs +1 -0
  51. package/dist/packem_shared/commands-BOgN2nF7.mjs +19 -0
  52. package/dist/packem_shared/createLogger-hGafwf-3.mjs +2 -0
  53. package/dist/packem_shared/createRecordingSpawner-DJlNacZ6.mjs +1 -0
  54. package/dist/packem_shared/deploy-target-D9GPy_tq.mjs +1 -0
  55. package/dist/packem_shared/detect-package-manager-DSaAqRof.mjs +1 -0
  56. package/dist/packem_shared/diffSnapshots-CIOFQN_a.mjs +5 -0
  57. package/dist/packem_shared/docker-DpVxvYpL.mjs +1 -0
  58. package/dist/packem_shared/health-probe-QEPfFdgJ.mjs +1 -0
  59. package/dist/packem_shared/import-CrVGrOt3.mjs +12 -0
  60. package/dist/packem_shared/insertSchemaExtension-DY4pA8wE.mjs +8 -0
  61. package/dist/packem_shared/lint-ignore-report-CDbcbtv7.mjs +2 -0
  62. package/dist/packem_shared/open-url-EnKy--w-.mjs +1 -0
  63. package/dist/packem_shared/output-format-DfogXx0p.mjs +2 -0
  64. package/dist/packem_shared/parseManifest-CwPTKdtS.mjs +1 -0
  65. package/dist/packem_shared/path-containment-CgxYZggb.mjs +1 -0
  66. package/dist/packem_shared/platform-diagnostics-uOXqysk3.mjs +4 -0
  67. package/dist/packem_shared/post-codegen-hook-DRdEoTsQ.mjs +1 -0
  68. package/dist/packem_shared/prompt-cancelled-C8Sj7OqI.mjs +1 -0
  69. package/dist/packem_shared/resolve-DZAGzg67.mjs +1 -0
  70. package/dist/packem_shared/resolve-target-C_ZloTvd.mjs +1 -0
  71. package/dist/packem_shared/runAddCommand-BXz-PXbb.mjs +1 -0
  72. package/dist/packem_shared/runExportCommand-DmXKEWSq.mjs +5 -0
  73. package/dist/packem_shared/schema-drift-gate-AscQpYH5.mjs +1 -0
  74. package/dist/packem_shared/schemaIrToSnapshot-qpRoV7HY.mjs +1 -0
  75. package/dist/packem_shared/shared-D-zCOmgY.mjs +1 -0
  76. package/dist/packem_shared/tui-prompts-Dd0pDuNr.mjs +4 -0
  77. package/dist/packem_shared/vectorize-metadata-DbziRKpX.mjs +1 -0
  78. package/dist/packem_shared/wrangler-name-Dsk5K1f-.mjs +1 -0
  79. package/dist/packem_shared/wrangler-secrets-CE7jcf8E.mjs +1 -0
  80. package/package.json +43 -19
  81. package/skills/README.md +35 -17
  82. package/skills/lunora/SKILL.md +65 -9
  83. package/skills/lunora-functions/SKILL.md +38 -3
  84. package/skills/lunora-migration-helper/SKILL.md +70 -17
  85. package/skills/lunora-performance-audit/SKILL.md +36 -6
  86. package/skills/lunora-quickstart/SKILL.md +90 -24
  87. package/skills/lunora-realtime/SKILL.md +58 -30
  88. package/skills/lunora-setup-storage/SKILL.md +7 -3
  89. package/dist/packem_shared/COMMANDS-1V_KEx35.mjs +0 -905
  90. package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs +0 -244
  91. package/dist/packem_shared/admin-url-4UzT-CI4.mjs +0 -19
  92. package/dist/packem_shared/api-spec-CtA6ilu4.mjs +0 -13
  93. package/dist/packem_shared/buildRegistryIndex-BcYe607_.mjs +0 -38
  94. package/dist/packem_shared/command-BDXcJCCJ.mjs +0 -14
  95. package/dist/packem_shared/createLogger-CHPNjFw2.mjs +0 -73
  96. package/dist/packem_shared/defaultSpawner-DxI3mebw.mjs +0 -43
  97. package/dist/packem_shared/diffSnapshots-RR2ZE8Ya.mjs +0 -161
  98. package/dist/packem_shared/docker-hMQ97KSQ.mjs +0 -21
  99. package/dist/packem_shared/features-ocSSpZtS.mjs +0 -24
  100. package/dist/packem_shared/insertSchemaExtension-BuzF6-t2.mjs +0 -59
  101. package/dist/packem_shared/open-url-Dfq6fAyT.mjs +0 -41
  102. package/dist/packem_shared/output-format-7gyGR3h8.mjs +0 -17
  103. package/dist/packem_shared/parseArgs-YXFuKdEk.mjs +0 -56
  104. package/dist/packem_shared/parseManifest--vZf2FY1.mjs +0 -94
  105. package/dist/packem_shared/resolve-target-qbsJ_5sF.mjs +0 -16
  106. package/dist/packem_shared/runAddCommand-BZGkRnBs.mjs +0 -693
  107. package/dist/packem_shared/schema-drift-gate-BtBt0as0.mjs +0 -79
  108. package/dist/packem_shared/schemaIrToSnapshot-aBTo7TM5.mjs +0 -43
  109. package/dist/packem_shared/wrangler-name-cy4yhm9j.mjs +0 -12
package/dist/index.d.mts CHANGED
@@ -1,33 +1,33 @@
1
- import { CodegenOptions, SchemaIR } from '@lunora/codegen';
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';
1
+ import { CodegenOptions, Finding, SchemaIR } from '@lunora/codegen';
2
+ import { ensureDevVariables, ensureDevVarsExample, fillDevSecrets, LintTool, LintIgnoreOutcome } from '@lunora/config';
3
+ import { materializeRemoteWranglerConfig } from '@lunora/config/cloudflare';
4
+ 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
5
  /** 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"];
6
+ 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
7
  type CommandName = (typeof COMMANDS)[number];
8
8
  declare const VERSION: string;
9
9
  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. */
@@ -71,33 +64,43 @@ interface CodegenCommandOptions {
71
64
  /** Output format: `pretty` (default) or `json`. */
72
65
  format?: string;
73
66
  logger: Logger;
67
+ /**
68
+ * Fail the run when any ERROR-level advisory is reported. Defaults to CI
69
+ * detection so a local `lunora codegen` stays advisory while a pipeline
70
+ * gates on it; `--no-strict-advisories` forces it off either way.
71
+ */
72
+ strictAdvisories?: boolean;
73
+ /** Deploy target the emitted `ctx.*` surface is tailored to. Resolved by the caller; falls back to `"target"` in `lunora.json`, then `"cloudflare"`. */
74
+ target?: string;
74
75
  }
75
76
  interface CodegenCommandResult {
76
77
  advisories: ReadonlyArray<{
77
78
  detail: string;
78
- level: string;
79
+ level: Finding["level"];
79
80
  name: string;
80
81
  remediation: string;
81
82
  }>;
82
83
  cronTriggers: ReadonlyArray<string>;
83
- /** Set when the run aborted on an invalid `--format` before codegen ran. */
84
+ /** Set when the run failed: an invalid `--format`, an unregistered target, or an error-level platform diagnostic. */
84
85
  error?: string;
86
+ /** ERROR-level advisories that made the run fail, when strict mode is on. */
87
+ failedAdvisories: number;
85
88
  outputDirectory: string;
86
89
  }
87
90
  declare const runCodegenCommand: (options: CodegenCommandOptions) => CodegenCommandResult;
88
- /** `lunora codegen` handler (lazy-loaded via the command's `loader`). */
89
- /** Rows per HTTP request when importing. Convex uses ~500; same here. */
90
- declare const DEFAULT_IMPORT_BATCH_SIZE = 500;
91
91
  /**
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
- */
92
+ * Minimal projection of `globalThis.fetch` for the transfer commands: `body` is
93
+ * exposed as a stream-iterable (the export path pipes it) and accepts bytes (the
94
+ * blob path uploads them). The JSON-only commands use the narrower `FetchLike`
95
+ * in `../run/handler` instead.
96
+ */
96
97
  type StreamingFetchLike = (input: string, init?: {
97
- body?: string;
98
+ body?: string | Uint8Array;
98
99
  headers?: Record<string, string>;
99
100
  method?: string;
100
101
  }) => Promise<{
102
+ /** Optional: only the storage transfer reads raw bytes, and only real `fetch` needs to supply it. */
103
+ arrayBuffer?: () => Promise<ArrayBuffer>;
101
104
  body: ReadableStream<Uint8Array> | null;
102
105
  json: () => Promise<unknown>;
103
106
  ok: boolean;
@@ -126,11 +129,70 @@ interface ExportCommandResult {
126
129
  rows: number;
127
130
  }
128
131
  /**
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
- */
132
+ * Stream an export. The worker emits NDJSON; we count newlines as we go and
133
+ * pipe straight to the output sink, so a 10M-row export doesn't materialise
134
+ * the body in memory.
135
+ */
133
136
  declare const runExportCommand: (options: ExportCommandOptions) => Promise<ExportCommandResult>;
137
+ /** One row-scoped failure as the admin import endpoint reports it. */
138
+ interface ImportRowError {
139
+ code: string;
140
+ line: number;
141
+ message: string;
142
+ table: string;
143
+ }
144
+ /**
145
+ * The sources `--from` accepts.
146
+ *
147
+ * Only the two that cannot be detected. A Convex snapshot announces itself (a
148
+ * directory of `<table>/documents.jsonl`, or a `.zip` of one) and anything else
149
+ * is NDJSON, so naming those would advertise a control this does not implement:
150
+ * `--from ndjson` against a Convex export would have to either refuse it or
151
+ * silently import it as Convex, and the second is what an unhonoured flag
152
+ * actually did.
153
+ */
154
+ declare const IMPORT_SOURCE_NAMES: readonly ["firebase", "supabase"];
155
+ type ImportSourceName = (typeof IMPORT_SOURCE_NAMES)[number];
156
+ /**
157
+ * The storage-reference rewrite: turning a Convex storage id into the
158
+ * content-hash R2 key its blob was migrated to.
159
+ *
160
+ * Split out of `./storage-mapping` (which owns the mapping *file*) because it
161
+ * has two callers that must never diverge — the import rewrite and `--scan`,
162
+ * which runs this same walk as a dry run to propose the mapping. A detector
163
+ * that proposed columns the rewrite would not touch, or missed ones it would,
164
+ * is worse than no detector.
165
+ */
166
+ /** One reference the walk could not rewrite, with where it was found. */
167
+ interface UnresolvedStorageReference {
168
+ column: string;
169
+ storageId: string;
170
+ table: string;
171
+ }
172
+ /**
173
+ * What a run's storage references resolved to. The two failure buckets are
174
+ * deliberately separate, because they are not the same problem and do not have
175
+ * the same remedy:
176
+ *
177
+ * `unmigrated` is a reference to a blob that does not exist — the export omitted
178
+ * it, or `--include-file-storage` was not passed. Nothing the operator writes in
179
+ * a mapping file can fix it, and the data is broken after import, so it fails
180
+ * `--verify`.
181
+ *
182
+ * `ambiguous` is a string that exactly matches a blob that *did* migrate, sitting
183
+ * in a column the mapping does not name. It may be a storage reference the
184
+ * mapping forgot, or it may be user text that happens to equal an id. Failing the
185
+ * run on a coincidence is not defensible, so it warns and names the column the
186
+ * operator would add to resolve it.
187
+ */
188
+ interface StorageRemapReport {
189
+ ambiguous: UnresolvedStorageReference[];
190
+ /** Number of references rewritten to a content-hash key. */
191
+ rewritten: number;
192
+ unmigrated: UnresolvedStorageReference[];
193
+ }
194
+ /** Rows per HTTP request when importing. Convex uses ~500; same here. */
195
+ declare const DEFAULT_IMPORT_BATCH_SIZE = 500;
134
196
  interface ImportCommandOptions {
135
197
  /** Rows per HTTP request. Defaults to {@link DEFAULT_IMPORT_BATCH_SIZE}. */
136
198
  batchSize?: number;
@@ -138,88 +200,196 @@ interface ImportCommandOptions {
138
200
  fetchImpl?: StreamingFetchLike;
139
201
  /** Source NDJSON file. Required. */
140
202
  file: string;
203
+ /**
204
+ * Which reader to use. Omit to auto-detect between a Convex export snapshot
205
+ * and a plain NDJSON file; `supabase`/`firebase` must be explicit, because a
206
+ * directory of CSV or JSON has no signature that distinguishes it from
207
+ * anything else a user might point at.
208
+ */
209
+ from?: ImportSourceName;
141
210
  logger: Logger;
142
211
  prod?: boolean;
143
212
  /**
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
- */
213
+ * Scan the export for columns holding `_storage` ids and write a candidate
214
+ * `lunora/import-convex.json`. Scan-only: nothing is imported.
215
+ */
216
+ scan?: boolean;
217
+ /**
218
+ * Local directory of storage objects to migrate alongside the rows — how
219
+ * Firebase Cloud Storage arrives, after `gcloud storage cp -r`.
220
+ */
221
+ storageDir?: string;
222
+ /**
223
+ * Wrap each line as `{table:<name>,doc:<line>}`. Use when the source NDJSON
224
+ * is bare docs from a single table — Convex's `convex import --table users`
225
+ * shape.
226
+ */
148
227
  table?: string;
149
228
  token?: string;
150
229
  url?: string;
230
+ /**
231
+ * Verify per-table row parity + dangling-storage after import. Exits non-zero
232
+ * when a table's inserted count differs from its source line count, or when a
233
+ * document references a storage id that was not migrated.
234
+ */
235
+ verify?: boolean;
236
+ /**
237
+ * Also migrate Convex `_storage` blobs: read `_storage/documents.jsonl`, upload
238
+ * each blob with sha256+size verification, and build the `storageId → key` map.
239
+ * Off by default so the plain-document import path is unchanged.
240
+ */
241
+ withStorage?: boolean;
242
+ /** Confirm bulk-writing production. Required alongside `--prod`. */
243
+ yes?: boolean;
244
+ }
245
+ /**
246
+ * The JSON summary a run prints and returns — the same object either way, so a
247
+ * caller reading `body.conflicts` does not have to cast its way there.
248
+ *
249
+ * `undefined` on every path that imports nothing: a rejected source, a failed
250
+ * storage phase, or `--scan` (whose product is the mapping file it writes, not
251
+ * a return value).
252
+ */
253
+ interface ImportSummary {
254
+ conflicts: number;
255
+ errors: ImportRowError[];
256
+ inserted: Record<string, number>;
257
+ received: number;
258
+ storage?: {
259
+ ambiguous: StorageRemapReport["ambiguous"];
260
+ blobs: number;
261
+ rewritten: number;
262
+ unmigrated: StorageRemapReport["unmigrated"];
263
+ };
264
+ warnings?: string[];
151
265
  }
152
266
  interface ImportCommandResult {
153
- body: unknown;
267
+ body: ImportSummary | undefined;
154
268
  code: number;
155
269
  /** Total inserted rows across batches. */
156
270
  inserted: number;
157
271
  }
158
- /**
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
- */
163
272
  declare const runImportCommand: (options: ImportCommandOptions) => Promise<ImportCommandResult>;
164
273
  /**
165
- * Injectable probe for a Docker-compatible container engine. Tests pass a
166
- * stub; production uses {@link isDockerAvailable}.
167
- */
274
+ * Injectable probe for a Docker-compatible container engine. Tests pass a
275
+ * stub; production uses {@link isDockerAvailable}.
276
+ */
168
277
  type DockerProbe = () => boolean;
169
278
  /**
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
- */
279
+ * The shared `/_lunora/health` probe used by `lunora verify --health-url` and
280
+ * `lunora deploy --health-check`.
281
+ *
282
+ * Both commands ask the same question — "does this deployment answer?" — so
283
+ * they ask it through one implementation with one error-message shape. The
284
+ * runtime auto-registers both routes (`packages/runtime/src/health-routes.ts`):
285
+ * `/_lunora/health/ready` is the readiness gate ("can this version serve"), and
286
+ * `/_lunora/health` is the aggregate that also exists on older deployments.
287
+ *
288
+ * The probe is transport-only: it never throws, and reports its verdict as an
289
+ * `{ error }` message the caller decides what to do with.
290
+ */
291
+ /**
292
+ * Minimal fetch surface the probe needs — a subset of the global `fetch`,
293
+ * injectable so a test can feed a canned response without a network.
294
+ */
295
+ type HealthFetch = (url: string) => Promise<{
296
+ ok: boolean;
297
+ status: number;
298
+ }>;
175
299
  interface SpawnDescriptor {
176
300
  args: ReadonlyArray<string>;
177
301
  /**
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
- */
302
+ * Capture the child's stderr (in addition to streaming it to the parent).
303
+ * Needed when a tool reports the *expected* outcome as an error there
304
+ * `wrangler vectorize create-metadata-index` writes "already exists" to
305
+ * stderr, and without this the caller can only see a bare exit code and
306
+ * would warn on every re-run. Composes with `stdoutToStderr`, so a caller
307
+ * can keep stdout clean for `--format json` and still read the reason.
308
+ */
309
+ captureStderr?: boolean;
310
+ /**
311
+ * Capture the child's stdout (in addition to streaming it to the parent), so
312
+ * the caller can parse it — used by `deploy` to read the deployed URL from
313
+ * `wrangler deploy` output. Each chunk is still teed to the parent's stdout
314
+ * so the user sees live progress. Mutually exclusive with `stdoutToStderr`
315
+ * and `captureStdoutSilently`.
316
+ */
183
317
  captureStdout?: boolean;
318
+ /**
319
+ * Capture the child's stdout WITHOUT teeing it to the parent's stdout —
320
+ * for output that is parsed, never displayed (e.g. `wrangler secret list
321
+ * --format json`). Unlike `captureStdout`, nothing is written to
322
+ * `process.stdout`, so it can't interleave with — and corrupt — a
323
+ * caller's own stdout (notably `lunora deploy --format json`, which must
324
+ * emit exactly one JSON document). Mutually exclusive with `captureStdout`
325
+ * and `stdoutToStderr`.
326
+ */
327
+ captureStdoutSilently?: boolean;
184
328
  command: string;
185
329
  cwd?: string;
186
330
  env?: Readonly<Record<string, string>>;
187
331
  /**
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
- */
332
+ * Pipe this string into the child's stdin and close it. Used to feed
333
+ * `wrangler secret put` its value without exposing it on the command
334
+ * line or in env. When absent, stdin is inherited from the parent.
335
+ */
192
336
  input?: string;
193
337
  /**
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
- */
338
+ * Route the child's stdout to the parent's STDERR instead of stdout. Set in
339
+ * `--format json` mode so a spawned tool's human output (e.g. `wrangler
340
+ * deploy`'s progress + the deployed URL) can't interleave with — and corrupt
341
+ * — the single JSON document the command prints to stdout.
342
+ */
199
343
  stdoutToStderr?: boolean;
200
344
  }
201
345
  interface SpawnResult {
202
346
  code: number;
203
- /** The captured stdout, present only when the descriptor set `captureStdout`. */
347
+ /** The captured stderr, present only when the descriptor set `captureStderr`. */
348
+ stderr?: string;
349
+ /** The captured stdout, present only when the descriptor set `captureStdout` or `captureStdoutSilently`. */
204
350
  stdout?: string;
205
351
  }
206
352
  /**
207
- * Injectable spawner. Tests pass a stub that just records the descriptor
208
- * instead of executing a real subprocess.
209
- */
353
+ * Injectable spawner. Tests pass a stub that just records the descriptor
354
+ * instead of executing a real subprocess.
355
+ */
210
356
  type Spawner = (descriptor: SpawnDescriptor) => Promise<SpawnResult>;
211
357
  declare const defaultSpawner: Spawner;
212
358
  interface RecordedSpawn {
213
359
  descriptor: SpawnDescriptor;
214
360
  }
215
361
  /**
216
- * Test helper: returns a spawner that records every invocation and resolves
217
- * with the configured exit code.
218
- */
362
+ * Test helper: returns a spawner that records every invocation and resolves
363
+ * with the configured exit code.
364
+ */
219
365
  declare const createRecordingSpawner: (exitCode?: number) => {
220
366
  calls: RecordedSpawn[];
221
367
  spawner: Spawner;
222
368
  };
369
+ interface SecretListRunnerResult {
370
+ code: number;
371
+ stderr: string;
372
+ stdout: string;
373
+ }
374
+ /** Runs an argv and resolves its captured output. Injected in tests. */
375
+ type SecretListRunner = (command: string, args: ReadonlyArray<string>, cwd: string) => Promise<SecretListRunnerResult>;
376
+ interface ListRemoteSecretsInputs {
377
+ cwd: string;
378
+ /** Cloudflare environment name (`--env`). */
379
+ env?: string;
380
+ /** Injected command runner; defaults to a real `wrangler secret list`. */
381
+ runner?: SecretListRunner;
382
+ /** Target a temporary-account deployment (`--temporary`). */
383
+ temporary?: boolean;
384
+ }
385
+ interface ListRemoteSecretsResult {
386
+ /** Diagnostic message when `ok` is false. */
387
+ error?: string;
388
+ /** Remote secret names (sorted), empty when none or on failure. */
389
+ names: ReadonlyArray<string>;
390
+ /** False when wrangler failed or its output could not be parsed. */
391
+ ok: boolean;
392
+ }
223
393
  type FetchLike = (input: string, init?: {
224
394
  body?: string;
225
395
  headers?: Record<string, string>;
@@ -232,11 +402,17 @@ type FetchLike = (input: string, init?: {
232
402
  }>;
233
403
  interface RunCommandOptions {
234
404
  args?: string;
405
+ /** Forge this user id for the call (dispatches through the admin-gated `runAs` op). */
406
+ as?: string;
407
+ /** JSON-encoded extra identity claims to accompany {@link RunCommandOptions.as}. */
408
+ claims?: string;
235
409
  cwd?: string;
236
410
  fetchImpl?: FetchLike;
237
411
  functionPath: string;
238
412
  logger: Logger;
239
413
  shard?: string;
414
+ /** Admin bearer for the `runAs` dispatch; resolved from the environment / `.dev.vars` when absent. */
415
+ token?: string;
240
416
  url?: string;
241
417
  }
242
418
  interface RunCommandResult {
@@ -245,7 +421,6 @@ interface RunCommandResult {
245
421
  requestUrl: string;
246
422
  }
247
423
  declare const runRpcCommand: (options: RunCommandOptions) => Promise<RunCommandResult>;
248
- /** `lunora run &lt;functionPath>` handler (lazy-loaded via the command's `loader`). */
249
424
  interface DeployCommandOptions {
250
425
  /** Override the schema-drift gate — deploy even with breaking drift and no new migration. */
251
426
  allowSchemaDrift?: boolean;
@@ -255,82 +430,165 @@ interface DeployCommandOptions {
255
430
  /** Docker-availability probe injected in tests. Defaults to a real `docker info` check. */
256
431
  dockerAvailable?: DockerProbe;
257
432
  /**
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
- */
433
+ * Validate, bundle, and run all pre-deploy gates without publishing
434
+ * (`wrangler deploy --dry-run`). Post-deploy steps (data migrations, schema
435
+ * baseline re-bless) are skipped since nothing shipped.
436
+ */
262
437
  dryRun?: boolean;
263
438
  env?: string;
264
439
  /** Fetch implementation injected in tests for `--migrate` RPC calls. */
265
440
  fetchImpl?: FetchLike;
266
441
  /** Output format: `pretty` (default) or `json`. */
267
442
  format?: string;
443
+ /**
444
+ * After a successful live deploy, probe the new version's health route
445
+ * (`/_lunora/health/ready`, falling back to `/_lunora/health`) and fail the
446
+ * command when it never answers. Opt-in, not default-on: a worker whose
447
+ * health route is admin-gated or unreachable from CI must still be
448
+ * deployable, and a default network step would turn a successful deploy
449
+ * into a red build for an unrelated reason.
450
+ */
451
+ healthCheck?: boolean;
452
+ /** Injectable fetch for `--health-check`; defaults to the global `fetch`. */
453
+ healthFetch?: HealthFetch;
454
+ /** Injectable inter-attempt delay for `--health-check`; injected in tests to skip the real wait. */
455
+ healthSleep?: (ms: number) => Promise<void>;
268
456
  /** Set to `false` to disable interactive spinners (test injection). */
269
457
  interactive?: boolean;
270
458
  logger: Logger;
271
459
  /**
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
- */
460
+ * When true, after a successful `wrangler deploy`, discover and run all
461
+ * pending data migrations via the worker's `/_lunora/migrate` admin RPC.
462
+ * The worker must be live (exit 0) before migrations are attempted.
463
+ *
464
+ * Implementation note: the status RPC returns the full shard-level
465
+ * migration state, but there is no single authoritative "list of pending
466
+ * migration ids" that can be read client-side before running the worker.
467
+ * Instead, `--migrate` runs `migrate status` followed by `migrate up` for
468
+ * each migration id discovered locally via `discoverMigrations`. The
469
+ * worker's `MigrationRunner` is idempotent — running `up` on an already-
470
+ * applied migration is a no-op — so this approach is safe.
471
+ */
284
472
  migrate?: boolean;
285
473
  /** Admin bearer token for `--migrate` (falls back to `LUNORA_ADMIN_TOKEN`). */
286
474
  migrateToken?: string;
287
475
  /**
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
- */
476
+ * Worker URL for `--migrate`. REQUIRED when `--migrate` is set — the deploy
477
+ * handler never captures the URL `wrangler deploy` published to, so there is
478
+ * no safe default; omitting it would silently target `http://localhost:8787`
479
+ * (the dev worker), applying the migration to local state instead of prod.
480
+ */
293
481
  migrateUrl?: string;
294
482
  /**
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
- */
483
+ * Confirm a production data migration triggered via `--migrate` (the
484
+ * `migrate up --prod` confirmation the standalone command requires). Without
485
+ * it a `--migrate --migrate-url <prod>` deploy refuses to run the migration.
486
+ */
299
487
  migrateYes?: boolean;
300
488
  /**
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
- */
489
+ * Emit the bundled worker to this directory via `wrangler deploy --outdir`
490
+ * (paired with `dryRun` by `lunora build`). Also writes esbuild metadata to
491
+ * `<outDir>/bundle-meta.json`. When unset, no artifact is written.
492
+ */
305
493
  outDir?: string;
306
494
  /**
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
- */
495
+ * Upload a preview version (`wrangler versions upload`) instead of a live
496
+ * `wrangler deploy`. Codegen + the drift gate + validation still run, but
497
+ * the post-deploy finalize (migrations, baseline re-bless, auto-link, the
498
+ * production summary) is skipped — a preview never shifts live traffic.
499
+ */
312
500
  preview?: boolean;
313
501
  /** Railpack-availability probe injected in tests. Defaults to a real `railpack --version` + `BUILDKIT_HOST` check. */
314
502
  railpackAvailable?: DockerProbe;
503
+ /** Confirm prompt for the missing-secret offer; injected in tests. Defaults to the TTY prompt. */
504
+ secretConfirm?: (message: string) => Promise<boolean>;
505
+ /** Remote-secret lister for the missing-secret offer; injected in tests. Defaults to `wrangler secret list`. */
506
+ secretLister?: (inputs: ListRemoteSecretsInputs) => Promise<ListRemoteSecretsResult>;
315
507
  skipCodegen?: boolean;
316
508
  spawner?: Spawner;
317
509
  /**
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
- */
510
+ * Fail the deploy when codegen reports an ERROR-level advisory. Same
511
+ * option `lunora codegen` exposes as `--no-strict-advisories`; defaults to
512
+ * CI detection (on in CI, off locally) so a legitimately-partial target
513
+ * can still be shipped interactively. Does NOT gate platform diagnostics
514
+ * (`platform_unsupported_feature` / `platform_unknown_target`), which
515
+ * always block those mean the emitted `ctx.*` surface does not match
516
+ * what the target can serve, not merely a style nit.
517
+ */
518
+ strictAdvisories?: boolean;
519
+ /**
520
+ * Deploy target. Falls back to `"target"` in `lunora.json`, then
521
+ * `"cloudflare"`, which selects the wrangler
522
+ * toolchain — i.e. today's behavior for every project. An unregistered name
523
+ * throws rather than falling back, so a typo can never ship the app to the
524
+ * wrong provider.
525
+ */
526
+ target?: string;
527
+ /**
528
+ * Deploy to a temporary Cloudflare account (`wrangler deploy --temporary`).
529
+ * For unauthenticated use only: wrangler provisions a short-lived account +
530
+ * token, deploys, and prints a claim URL; the deployment stays live ~60
531
+ * minutes before the unclaimed account is deleted. Wrangler itself errors
532
+ * if credentials are already present (OAuth / `CLOUDFLARE_API_TOKEN` /
533
+ * global API key), so we pass the flag straight through without guarding.
534
+ */
325
535
  temporary?: boolean;
326
536
  /** Re-bless the committed schema baseline with the current shape (accepts breaking drift). */
327
537
  updateSchemaBaseline?: boolean;
328
538
  }
539
+ /**
540
+ * What this run put where — the identity of the thing that was just deployed.
541
+ *
542
+ * Present on every run that reached (and completed) the wrangler invocation,
543
+ * including `--dry-run` and `--preview`, so a consumer can tell "nothing went
544
+ * live" from "went live" without inferring it from a missing `url`. A dry run
545
+ * publishes nothing and therefore never carries a `url`.
546
+ *
547
+ * No `versionId`: the pinned wrangler (4.114.0) has no structured deploy output
548
+ * and no flag that returns the version id — it only prints it in prose, and
549
+ * scraping a second value out of prose is exactly what this shouldn't do. The
550
+ * id is available from `lunora deployments list` after the fact.
551
+ */
552
+ interface DeployedIdentity {
553
+ /** ISO-8601 stamp taken when the wrangler invocation returned. */
554
+ deployedAt: string;
555
+ /** True when `--dry-run` validated + bundled without publishing. */
556
+ dryRun: boolean;
557
+ /** The Cloudflare environment this run targeted, when `--env` named one. */
558
+ env?: string;
559
+ /** True when `--preview` uploaded a version instead of shifting live traffic. */
560
+ preview: boolean;
561
+ /** The URL wrangler reported publishing to; absent on a dry run, or when the output carried no URL. */
562
+ url?: string;
563
+ /** The Worker name from the project's wrangler config. */
564
+ workerName?: string;
565
+ }
329
566
  interface DeployCommandResult {
330
567
  code: number;
568
+ /** What was deployed and where — set once the wrangler invocation completed. */
569
+ deployment?: DeployedIdentity;
331
570
  descriptor: SpawnDescriptor | undefined;
332
571
  /** Set when the run aborted before reaching the wrangler invocation. */
333
572
  error?: string;
573
+ /**
574
+ * The `--health-check` probe's verdict, when the flag was set and the probe
575
+ * ran. A red probe fails the command (`code` is non-zero) — but the deploy
576
+ * itself still succeeded, which is why the reason is reported separately
577
+ * from `error`.
578
+ */
579
+ healthCheck?: {
580
+ error?: string;
581
+ ok: boolean;
582
+ url: string;
583
+ };
584
+ /**
585
+ * The `.dev.vars`-shaped filename (never a full path, never a value) a
586
+ * secret minted during this run was recorded into, when the missing-
587
+ * secret gate minted one — `.dev.vars` for the default environment, or a
588
+ * `.dev.vars.<env>` sibling for an explicit `--env`. `undefined` when
589
+ * nothing was minted this run.
590
+ */
591
+ mintedSecretsFile?: string;
334
592
  /** The schema-drift gate verdict, when it ran (skipped on `--skip-codegen`). */
335
593
  schemaDrift?: {
336
594
  blocked: boolean;
@@ -342,18 +600,17 @@ interface DeployCommandResult {
342
600
  };
343
601
  }
344
602
  /**
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
- */
603
+ * Run a deploy, then (in `--format json` mode) serialize the structured
604
+ * {@link DeployCommandResult} to stdout. Human/progress logging is routed to
605
+ * stderr for json output so stdout carries only the single JSON document.
606
+ */
349
607
  declare const runDeployCommand: (options: DeployCommandOptions) => Promise<DeployCommandResult>;
350
- /** `lunora deploy` handler (lazy-loaded via the command's `loader`). */
351
608
  /**
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
- */
609
+ * Start the codegen watch loop and return a handle to stop it. Regenerates on
610
+ * startup, then on debounced changes under `lunora/` (ignoring writes to the
611
+ * `_generated/` output to avoid a feedback loop). If the platform can't do a
612
+ * recursive watch, it logs once and falls back to startup-only codegen.
613
+ */
357
614
  declare const startCodegenWatch: (options: CodegenWatcherOptions) => CodegenWatcherHandle;
358
615
  interface CodegenWatcherOptions {
359
616
  /** Which API spec(s) to emit. Defaults to codegen's `"openapi"` when omitted. */
@@ -365,23 +622,25 @@ interface CodegenWatcherOptions {
365
622
  lunoraDirectory?: string;
366
623
  /** Project root containing the `lunora/` directory. */
367
624
  projectRoot: string;
625
+ /** Deploy target the emitted `ctx.*` surface is tailored to. Resolved by the caller; falls back to `"target"` in `lunora.json`, then `"cloudflare"`. */
626
+ target?: string;
368
627
  }
369
628
  interface CodegenWatcherHandle {
370
629
  /** Stop watching and cancel any pending regeneration. */
371
630
  close: () => void;
372
631
  /**
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
- */
632
+ * `true` when the platform supports recursive watch and the loop is active.
633
+ * `false` when `fs.watch({ recursive })` threw — startup-only codegen was run
634
+ * but schema edits will NOT auto-regenerate. Callers can surface this in the
635
+ * dev banner so the degraded state is visible beyond the single startup warning.
636
+ */
378
637
  watchAvailable: boolean;
379
638
  }
380
639
  /**
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
- */
640
+ * Start the studio server and resolve once it is listening. Loads the static
641
+ * bundle + renders the host HTML once up front; serves them and proxies
642
+ * `/_lunora/*` (HTTP + WS) to the worker.
643
+ */
385
644
  declare const startStudioServer: (options: StudioServerOptions) => Promise<StudioServerHandle>;
386
645
  interface StudioServerOptions {
387
646
  /** Project root — `.dev.vars` is read from here for the admin token. */
@@ -403,6 +662,24 @@ interface StudioServerHandle {
403
662
  /** The URL to open in a browser. */
404
663
  url: string;
405
664
  }
665
+ /**
666
+ * How the dev child runs. `wrangler` is the classic `lunora dev` stack (wrangler
667
+ * worker + embedded studio + codegen watch) for a standalone class-C project.
668
+ * `vite` is a project on `@lunora/vite`: the plugin already runs the worker,
669
+ * studio, and codegen inside the Vite dev server, so `lunora dev` runs the
670
+ * project's own dev script and gets out of the way — this also covers class-B
671
+ * frameworks whose own dev server runs the worker in `workerd` (Astro 6 +
672
+ * `@astrojs/cloudflare`, which embeds `@cloudflare/vite-plugin` in `astro dev`:
673
+ * SSR + `/_lunora/*` + `ShardDO` in one process, HMR intact). `framework-worker`
674
+ * is a class-B framework whose dev server CANNOT host the `ShardDO` Durable
675
+ * Object (SvelteKit / Nuxt: their adapters use wrangler's `getPlatformProxy()`,
676
+ * which runs an empty-script Miniflare and does not emulate internal DOs); there
677
+ * `lunora dev` runs the framework's own dev server (front door, HMR, and — via
678
+ * its `@lunora/vite` plugin — studio + codegen) AND a second `wrangler dev`
679
+ * sidecar that owns the real `ShardDO` in `workerd`, wired via the committed
680
+ * `wrangler.dev.jsonc`.
681
+ */
682
+ type DevFlavor = "framework-worker" | "vite" | "wrangler";
406
683
  /** A running worker child the orchestrator controls: send signals, await its exit. */
407
684
  interface WorkerProcess {
408
685
  /** Resolves with the worker's exit code (1 if it failed to start). */
@@ -423,6 +700,14 @@ interface DevCommandOptions {
423
700
  ensureEnv?: typeof ensureDevVariables;
424
701
  /** Injection seam for tests — defaults to the real `.dev.vars.example` package-aware scaffolder. */
425
702
  ensureExample?: typeof ensureDevVarsExample;
703
+ /** Injection seam for tests — defaults to the real empty-secret/admin-token filler. */
704
+ fillSecrets?: typeof fillDevSecrets;
705
+ /** Injection seam for tests — defaults to the real free-port probe ({@link findAvailablePort}). */
706
+ findFreePort?: (preferred: number) => Promise<number>;
707
+ /** Dev flavor override (tests / callers that already detected it) — defaults to {@link detectDevFlavor}. */
708
+ flavor?: DevFlavor;
709
+ /** Injection seam for tests — defaults to the real IPv6-loopback probe ({@link hasIpv6Loopback}). */
710
+ hasIpv6Loopback?: () => boolean;
426
711
  logger: Logger;
427
712
  /** Injection seam for tests — defaults to the real remote-config materializer. */
428
713
  materializeRemote?: typeof materializeRemoteWranglerConfig;
@@ -438,6 +723,10 @@ interface DevCommandOptions {
438
723
  startWorker?: WorkerSpawner;
439
724
  /** Disable the embedded studio server. */
440
725
  studio?: boolean;
726
+ /** Deploy target the emitted `ctx.*` surface is tailored to. Resolved by the caller; falls back to `"target"` in `lunora.json`, then `"cloudflare"`. */
727
+ target?: string;
728
+ /** Disable the `wrangler dev` spawn — an external task runner owns the worker. */
729
+ worker?: boolean;
441
730
  /** `wrangler dev` port. */
442
731
  workerPort?: number;
443
732
  }
@@ -445,10 +734,10 @@ interface DevRemotePlan {
445
734
  /** Short binding labels remoted (e.g. `"DB (D1)"`), for the banner. */
446
735
  bindings: string[];
447
736
  /**
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
- */
737
+ * Removes the generated temp wrangler config when dev exits. Always present
738
+ * and idempotent — a no-op when remote mode is off or nothing was
739
+ * materialized. The dev loop calls it on every shutdown path.
740
+ */
452
741
  cleanup: () => void;
453
742
  /** Whether remote mode was requested. */
454
743
  enabled: boolean;
@@ -456,183 +745,90 @@ interface DevRemotePlan {
456
745
  reason?: string;
457
746
  }
458
747
  interface DevCommandPlan {
459
- codegenEnabled: boolean;
748
+ /** Which stack the child runs — see {@link DevFlavor}. */
749
+ flavor: DevFlavor;
750
+ /**
751
+ * One-line redirect hint printed when a meta-framework is detected on the
752
+ * wrangler flavor: without `@lunora/vite` in the dependencies the worker
753
+ * still runs *inside* the framework's dev server, so the user should run
754
+ * their framework dev script for the full app. `undefined` for the vite
755
+ * flavor (`lunora dev` already runs the project's dev script there) and
756
+ * for a standalone project. Purely informational: the wrangler spawn runs
757
+ * regardless.
758
+ */
759
+ frameworkHint?: string;
760
+ /**
761
+ * True when `wrangler dev` was given `--ip 127.0.0.1` because the host has no
762
+ * IPv6 loopback (`::1`) — surfaced so the dev loop can note the rebind.
763
+ * Always `false` for the vite flavor (the plugin owns its own bind).
764
+ */
765
+ ipv4LoopbackForced: boolean;
460
766
  /** The remote-binding decision: which D1/KV/R2 bindings hit the deployed worker. */
461
767
  remote: DevRemotePlan;
768
+ runsCodegenWatch: boolean;
769
+ /**
770
+ * The `wrangler dev` sidecar for the `framework-worker` flavor (SvelteKit /
771
+ * Nuxt): a second child that owns the real `ShardDO` in `workerd`, wired via
772
+ * the committed `wrangler.dev.jsonc`. `undefined` for every other flavor —
773
+ * only the two-process class-B stack has a sidecar. When present, `wrangler`
774
+ * (above) is the framework's own dev server (the front door / HMR) and this
775
+ * is the Lunora realtime plane.
776
+ */
777
+ sidecar?: SpawnDescriptor & {
778
+ tag: string;
779
+ };
462
780
  studioEnabled: boolean;
463
781
  studioPort: number;
782
+ /**
783
+ * Whether this process spawns `wrangler dev`.
784
+ *
785
+ * `--no-worker` turns it off so an external task runner (Turbo, Nx, vis, a
786
+ * Procfile) can own worker supervision while `lunora dev` still provides
787
+ * codegen-watch and Studio. Without it, `lunora dev` insisted on being the
788
+ * process root, which is what blocked running the Lunora worker as one node
789
+ * in a larger dev graph.
790
+ */
791
+ workerEnabled: boolean;
464
792
  workerOrigin: string;
465
793
  workerPort: number;
466
- /** The single child process `lunora dev` spawns: `wrangler dev`. */
794
+ /** The primary child `lunora dev` spawns: `wrangler dev` (wrangler flavor) or the framework/`vite dev` server (vite / framework-worker). */
467
795
  wrangler: SpawnDescriptor & {
468
796
  tag: string;
469
797
  };
470
798
  }
471
799
  /**
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
- */
800
+ * Plan `lunora dev`. Wrangler flavor: the worker runs via `wrangler dev` and
801
+ * nothing else as a child process. Vite flavor (`@lunora/vite` declared): the
802
+ * plugin already runs the worker inside the Vite dev server, so the one child
803
+ * is the project's own dev script (`vite dev`, `astro dev`, …) and every CLI
804
+ * sibling is disabled. Pure + synchronous so it's unit-testable.
805
+ */
485
806
  declare const planDevCommand: (options: DevCommandOptions) => DevCommandPlan;
486
807
  /**
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
- */
808
+ * Start codegen watch + the studio server, spawn `wrangler dev`, print the
809
+ * banner, and resolve when the worker exits or the user interrupts — tearing
810
+ * down the sibling servers either way. The three side-effecting pieces (worker,
811
+ * studio, codegen) are injectable so this is testable without real I/O.
812
+ */
492
813
  declare const runDevCommand: (options: DevCommandOptions) => Promise<{
493
814
  code: number;
494
815
  plan: DevCommandPlan;
495
816
  }>;
496
- /** `lunora dev` handler (lazy-loaded via the command's `loader`). */
817
+ type PackageManager = "pnpm" | "npm" | "yarn" | "bun";
818
+ /** True when `manager` is on PATH — probed by running `<manager> --version`. Injectable for tests. */
819
+ type PackageManagerProbe = (manager: PackageManager) => boolean;
497
820
  /** Supported CI providers. */
498
821
  type CiProvider = "github" | "gitlab";
499
- /** A registry item a feature can install. */
500
- 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
822
  /**
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
- };
823
+ * The per-framework auth-UI registry items (`auth-ui` resolves to one of these).
824
+ *
825
+ * Solid has two because these are copy-in source files, not a compiled package:
826
+ * the 1.x and 2.0 spellings are mutually exclusive in the source itself, so the
827
+ * two majors get one item each and {@link detectAuthUiItem} picks.
828
+ */
829
+ type AuthUiItem = "auth-ui-angular" | "auth-ui-react" | "auth-ui-solid" | "auth-ui-solid-v2" | "auth-ui-svelte" | "auth-ui-vue";
830
+ /** A registry item a feature can install. */
831
+ type FeatureItem = "auth" | "auth-auth0" | "auth-clerk" | AuthUiItem | "mail";
636
832
  /** A single file the item scaffolds into the project. */
637
833
  interface RegistryFile {
638
834
  /** Source path inside the item dir (e.g. `schema.ts`). */
@@ -648,10 +844,10 @@ interface RegistryBinding {
648
844
  value: unknown;
649
845
  }
650
846
  /**
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
- */
847
+ * An environment variable an item needs. Scaffolded into `.dev.vars` (Workers'
848
+ * local-secrets file) on add — non-secrets get their `value`; secrets get an
849
+ * empty placeholder and a reminder to run `wrangler secret put` for production.
850
+ */
655
851
  interface RegistryEnvVariable {
656
852
  /** Human note on what the variable is for. */
657
853
  description?: string;
@@ -662,6 +858,13 @@ interface RegistryEnvVariable {
662
858
  /** A default/example value for non-secret vars. */
663
859
  value?: string;
664
860
  }
861
+ /** A re-export the item needs injected into the worker entry point (class-B/C only). */
862
+ interface EntrypointReexport {
863
+ /** Optional JS comment placed above the re-export line. */
864
+ comment?: string;
865
+ /** Module specifier (e.g. `"_generated/workflows"` → `export * from "./lunora/_generated/workflows"`). */
866
+ module: string;
867
+ }
665
868
  /** The `registry.json` manifest shape. */
666
869
  interface RegistryManifest {
667
870
  /** wrangler.jsonc additions (best-effort structural edits). */
@@ -673,6 +876,8 @@ interface RegistryManifest {
673
876
  devDependencies?: Readonly<Record<string, string>>;
674
877
  /** Post-install guidance printed after the item is added (per-item next steps). */
675
878
  docs?: string;
879
+ /** Worker-entry re-exports the item needs (class-B/C only). */
880
+ entrypointReexports?: ReadonlyArray<EntrypointReexport>;
676
881
  /** Environment variables the item needs; scaffolded into `.dev.vars`. */
677
882
  envVars?: ReadonlyArray<RegistryEnvVariable>;
678
883
  files: ReadonlyArray<RegistryFile>;
@@ -707,8 +912,17 @@ interface AddCommandOptions {
707
912
  out?: string;
708
913
  /** Force-overwrite existing files (take the incoming copy) instead of skipping/conflicting. */
709
914
  overwrite?: boolean;
915
+ /** 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. */
916
+ ref?: string;
710
917
  /** Override the remote registry source base (default gh:anolilab/lunora/registry). */
711
918
  source?: string;
919
+ /**
920
+ * Customize each resolved manifest after it is loaded but before the plan is
921
+ * printed / reconciled — used to inject user-chosen values into otherwise
922
+ * static manifests (e.g. the R2 `bucket_name` the init storage prompt asks
923
+ * for). Applied to every item; return the manifest unchanged to leave it as-is.
924
+ */
925
+ transformManifest?: (manifest: RegistryManifest) => RegistryManifest;
712
926
  /** Skip the package.json mutation confirmation prompt. */
713
927
  yes?: boolean;
714
928
  }
@@ -723,20 +937,254 @@ interface AddCommandResult {
723
937
  /** Files written (absolute paths). */
724
938
  written: ReadonlyArray<string>;
725
939
  }
726
- /** One resolved item: its parsed manifest plus the (possibly staged) directory it lives in. */
940
+ /**
941
+ * A feature offered in the post-scaffold multi-select. `auth`/`email` carry a
942
+ * sub-prompt or alias; every other value IS the registry item name applied
943
+ * directly (`storage` → the `storage` registry item, etc.).
944
+ */
945
+ type StackFeature = "ai" | "auth" | "auth-ui" | "backup" | "browser" | "cloudflare-access" | "crons" | "email" | "flags" | "hyperdrive" | "payment" | "presence" | "queue" | "storage" | "workflow";
946
+ /** Customize a resolved manifest before it is written (e.g. inject the chosen R2 bucket name). */
947
+ type OfferTransformManifest = (manifest: RegistryManifest) => RegistryManifest;
948
+ /**
949
+ * One feature ready to apply: the registry item name(s), an optional manifest
950
+ * transform, and a short `label` (the feature value) shown on the combined
951
+ * progress line. Built up-front by the collectors so every prompt is answered
952
+ * before any apply runs.
953
+ */
954
+ interface FeatureApply {
955
+ label: string;
956
+ names: ReadonlyArray<string>;
957
+ transformManifest?: OfferTransformManifest;
958
+ }
959
+ interface OfferDeps {
960
+ /**
961
+ * Apply the collected features into the new project in one batch — resolves
962
+ * `true` when every item succeeds. The CLI renders this as a single progress
963
+ * line whose label changes per feature; each plan's `transformManifest`
964
+ * customizes that item's manifest before it is written.
965
+ */
966
+ applyAll: (plans: ReadonlyArray<FeatureApply>) => Promise<boolean>;
967
+ /** When `false`, skip all prompts and print the later-setup hint. */
968
+ interactive: boolean;
969
+ logger: Logger;
970
+ /** Multi-select among the stack features to add (TTY-backed in production). */
971
+ multiSelect: (message: string, options: ReadonlyArray<{
972
+ description?: string;
973
+ label: string;
974
+ value: StackFeature;
975
+ }>, settings?: {
976
+ defaults?: ReadonlyArray<StackFeature>;
977
+ }) => Promise<StackFeature[]>;
978
+ /**
979
+ * Features chosen non-interactively (the `--add` flag). When set, the
980
+ * multi-select and every sub-prompt are skipped — each feature is applied with
981
+ * its shipped defaults (base registry item, placeholder bindings).
982
+ */
983
+ preselected?: ReadonlyArray<StackFeature>;
984
+ /** The new project's name — seeds smart defaults like the `project-uploads` bucket name. */
985
+ projectName: string;
986
+ /**
987
+ * Resolve which per-framework auth-UI item (`auth-ui-react|vue|…`) fits the
988
+ * scaffolded project. Injected by the CLI (detected from the template's deps);
989
+ * defaults to `auth-ui-react` when absent so this module stays pure/testable.
990
+ */
991
+ resolveAuthUiItem?: () => string;
992
+ /** Single-select among the auth providers (TTY-backed in production). */
993
+ select: (message: string, options: ReadonlyArray<{
994
+ description?: string;
995
+ label: string;
996
+ value: FeatureItem;
997
+ }>, settings?: {
998
+ default?: FeatureItem;
999
+ }) => Promise<FeatureItem | undefined>;
1000
+ /** Single-line text input (TTY-backed in production) — used for the storage bucket-name prompt. */
1001
+ text: (message: string, settings?: {
1002
+ default?: string;
1003
+ placeholder?: string;
1004
+ }) => Promise<string>;
1005
+ }
1006
+ /** One choice in the multi-select. */
1007
+ interface LintToolOption {
1008
+ description: string;
1009
+ label: string;
1010
+ value: LintTool;
1011
+ }
1012
+ interface LintToolOfferDeps {
1013
+ /** Write the ignores for the chosen tools — `applyLintIgnores` in production. */
1014
+ apply: (tools: ReadonlyArray<LintTool>) => LintIgnoreOutcome[];
1015
+ /** Tools already detectable in the scaffolded project — pre-selected in the prompt. */
1016
+ detected: ReadonlyArray<LintTool>;
1017
+ /** False in CI / `--yes` / off a TTY: skip the prompt and configure whatever was detected. */
1018
+ interactive: boolean;
1019
+ logger: Logger;
1020
+ multiSelect: (message: string, choices: ReadonlyArray<LintToolOption>, settings?: {
1021
+ defaults?: ReadonlyArray<LintTool>;
1022
+ }) => Promise<LintTool[]>;
1023
+ }
1024
+ type Template = "analog" | "astro" | "expo" | "next" | "nuxt" | "react-router" | "solid-v2" | "standalone" | "sveltekit" | "tanstack-start-react" | "tanstack-start-solid" | "vinext" | "vinext-pages";
1025
+ interface InitCommandOptions {
1026
+ /**
1027
+ * Add features non-interactively after scaffolding (the `--add` flag): a
1028
+ * comma-separated list of `ai | auth | backup | browser | cloudflare-access | crons | email | flags | hyperdrive | payment | presence | queue | storage | workflow`.
1029
+ * Bypasses the interactive multi-select and sub-prompts —
1030
+ * each named feature is applied with its shipped defaults.
1031
+ */
1032
+ add?: string;
1033
+ /**
1034
+ * When true, accept `--source` values that don't start with `gh:` /
1035
+ * `github:` / `https://` or that contain `..`. Defaults to false; the CLI
1036
+ * gate exists to stop arbitrary filesystem / scheme sources from being
1037
+ * pulled without the caller opting in.
1038
+ */
1039
+ allowUnsafeSource?: boolean;
1040
+ /** When set, also scaffold a CI deploy pipeline for the given provider. */
1041
+ ci?: CiProvider;
1042
+ cwd?: string;
1043
+ /**
1044
+ * Walk the whole flow — prompts, task list, next-steps, mascot — but make no
1045
+ * changes: skip the template fetch/copy, the feature applies, the dependency
1046
+ * install, and `git init`. Each skipped action logs a `would …` line instead.
1047
+ */
1048
+ dryRun?: boolean;
1049
+ /**
1050
+ * Local directory containing the template subdirs (e.g. `vite/`,
1051
+ * `standalone/`). When provided, skips the network fetch entirely.
1052
+ * Useful for offline runs, the clean-machine smoke test, and unit tests.
1053
+ */
1054
+ from?: string;
1055
+ /**
1056
+ * When true, configure Lunora into the CURRENT project (`cwd`) instead of
1057
+ * scaffolding a new directory. Finds an existing `vite.config.*` and
1058
+ * patches it via `patchViteConfig`, or creates a minimal one when absent.
1059
+ * All other scaffold options (`name`, `templateType`, `source`, `from`)
1060
+ * are ignored in this mode.
1061
+ */
1062
+ inPlace?: boolean;
1063
+ /**
1064
+ * Inject the post-scaffold install offer's prompts (tests). When set, the
1065
+ * offer runs regardless of TTY: `confirmInstall` drives the yes/no, and
1066
+ * `selectManager` picks among the detected managers.
1067
+ */
1068
+ installPrompt?: {
1069
+ confirmInstall: () => Promise<boolean>;
1070
+ selectManager: (managers: ReadonlyArray<PackageManager>) => Promise<PackageManager>;
1071
+ };
1072
+ /**
1073
+ * Force the post-scaffold "add auth / email?" offer on (the `--interactive`
1074
+ * flag). When omitted, the offer runs only when stdin is a TTY. `--yes`
1075
+ * suppresses it regardless. Has no effect once {@link prompt} is injected.
1076
+ */
1077
+ interactive?: boolean;
1078
+ /**
1079
+ * Test seam for the lint/formatter multi-select. Separate from {@link prompt}
1080
+ * because that one is pinned to the feature-offer's value union — reusing it
1081
+ * here would only typecheck through a cast.
1082
+ */
1083
+ lintPrompt?: LintToolOfferDeps["multiSelect"];
1084
+ logger: Logger;
1085
+ name?: string;
1086
+ /**
1087
+ * Local directory holding create-vite bases (one `template-<id>/` subdir per
1088
+ * framework). When set with `vite`, the overlay copies the base from disk
1089
+ * instead of fetching `create-vite` over the network — offline mode + tests.
1090
+ */
1091
+ overlayBaseFrom?: string;
1092
+ /** Probe for which package managers are installed (tests). Defaults to a real `<pm> --version` check. */
1093
+ packageManagerProbe?: PackageManagerProbe;
1094
+ /**
1095
+ * Inject the offer's prompts (tests). When set, the offer is treated as
1096
+ * interactive regardless of TTY, and these drive the feature multi-select,
1097
+ * the auth-provider sub-select, and the storage bucket-name text input.
1098
+ */
1099
+ prompt?: Pick<OfferDeps, "multiSelect" | "select" | "text">;
1100
+ /**
1101
+ * Override the git ref (branch, tag, or commit) the default template source
1102
+ * is fetched from. Takes precedence over the version-derived ref. Ignored
1103
+ * when `source` or `from` is set.
1104
+ */
1105
+ ref?: string;
1106
+ /** Local registry root for the offer's `runAddCommand` (offline / tests). Mirrors `from` but for registry items. */
1107
+ registryFrom?: string;
1108
+ /** Override the remote registry source base for the offer (default `gh:anolilab/lunora/registry`). */
1109
+ registrySource?: string;
1110
+ /**
1111
+ * Override the remote source giget downloads from. Default:
1112
+ * `gh:anolilab/lunora/templates/<templateType>#<ref>`, where `<ref>` is
1113
+ * the `ref` option when set, else derived from the CLI version (pre-release
1114
+ * channels → their branch, stable → `main`). Tests typically use `from`
1115
+ * instead to skip the network.
1116
+ */
1117
+ source?: string;
1118
+ /** Spawner for the post-scaffold dependency install (tests inject a recording stub). Defaults to a real subprocess. */
1119
+ spawner?: Spawner;
1120
+ templateType?: Template;
1121
+ /**
1122
+ * Scaffold via the **create-vite overlay** for this framework (`react`,
1123
+ * `vue`, `solid`, `svelte`, `vanilla`) instead of a bespoke template: fetch
1124
+ * the official create-vite base and apply the Lunora layer on top. Takes
1125
+ * precedence over `templateType`.
1126
+ */
1127
+ vite?: string;
1128
+ /** Suppress the offer entirely (the `--yes` flag): scaffold only, print the later-setup hint. */
1129
+ yes?: boolean;
1130
+ }
1131
+ interface InitCommandResult {
1132
+ code: number;
1133
+ files: ReadonlyArray<string>;
1134
+ target: string;
1135
+ }
1136
+ /**
1137
+ * `lunora init` entry: scaffold (in-place or a new directory), then — on success
1138
+ * — offer to add auth + email via the registry. The offer never affects the
1139
+ * scaffold's exit code.
1140
+ */
1141
+ declare const runInitCommand: (options: InitCommandOptions) => Promise<InitCommandResult>;
1142
+ interface MigrateGenerateCommandOptions {
1143
+ cwd?: string;
1144
+ logger: Logger;
1145
+ /** Migration name slug. Defaults to `auto`. */
1146
+ name?: string;
1147
+ /** Override the current time — used by tests for deterministic file names. */
1148
+ now?: () => Date;
1149
+ }
1150
+ interface MigrateGenerateCommandResult {
1151
+ code: number;
1152
+ /** Whether the diff was empty (no changes detected). */
1153
+ empty: boolean;
1154
+ /** Absolute path to the migration file (empty string when nothing was written). */
1155
+ migrationFile: string;
1156
+ }
1157
+ declare const runMigrateGenerateCommand: (options: MigrateGenerateCommandOptions) => MigrateGenerateCommandResult;
1158
+ /** One catalog entry as `lunora registry list` reports it. */
1159
+ interface CatalogItem {
1160
+ description?: string;
1161
+ name: string;
1162
+ }
1163
+ /** A built index entry (catalog item plus its short `title`). */
1164
+ interface IndexItem extends CatalogItem {
1165
+ title?: string;
1166
+ }
1167
+ /**
1168
+ * Build the catalog (`index.json` contents) from a local registry root by
1169
+ * reading every item's `registry.json`. Used by both `lunora registry build`
1170
+ * and the registry tests so the committed index can't drift from the item dirs.
1171
+ */
1172
+ declare const buildRegistryIndex: (root: string) => {
1173
+ items: IndexItem[];
1174
+ };
727
1175
  /** `lunora registry add` (one or more item names): scaffold items into the project. */
728
1176
  declare const runAddCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
729
1177
  /**
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
- */
1178
+ * `lunora registry view` — inspect a registry item without installing it:
1179
+ * print its plan (files / deps / env vars) followed by the full contents of each
1180
+ * file it would scaffold. Resolves only the named item — no `requires` expansion.
1181
+ */
734
1182
  declare const runRegistryViewCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
735
1183
  /**
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
- */
1184
+ * `lunora registry build` — regenerate `index.json` from the item directories
1185
+ * (the catalog `list` reads). With `--check`, verify the committed index matches
1186
+ * instead of rewriting it (exits non-zero on drift) — a CI guard.
1187
+ */
740
1188
  declare const runBuildIndexCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
741
1189
  /** Validate + narrow a parsed JSON value into a {@link RegistryManifest}. */
742
1190
  declare const parseManifest: (raw: unknown, itemName: string) => RegistryManifest;
@@ -754,23 +1202,6 @@ interface ResetCommandResult {
754
1202
  removed: ReadonlyArray<string>;
755
1203
  }
756
1204
  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
1205
  type InsertSchemaExtensionResult = {
775
1206
  ok: true;
776
1207
  text: string;
@@ -779,12 +1210,12 @@ type InsertSchemaExtensionResult = {
779
1210
  reason: "already-applied" | "invalid-identifier" | "no-define-schema" | "non-object-argument";
780
1211
  };
781
1212
  /**
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
- */
1213
+ * Append `.extend(<key>.extension)` and a managed import to an existing
1214
+ * `lunora/schema.ts`. Idempotent: a second call for the same `key` returns
1215
+ * `already-applied` and leaves the text unchanged.
1216
+ * @param source the current `lunora/schema.ts` contents
1217
+ * @param key the registry item key (e.g. `"ratelimit"`)
1218
+ */
788
1219
  declare const insertSchemaExtension: (source: string, key: string) => InsertSchemaExtensionResult;
789
1220
  /** Compact snapshot of a single global table — what we persist + diff. */
790
1221
  interface TableSnapshot {
@@ -827,26 +1258,34 @@ interface SchemaDiff {
827
1258
  unsupported: ReadonlyArray<UnsupportedEntry>;
828
1259
  }
829
1260
  /**
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
- */
1261
+ * Map a Lunora validator kind to a SQLite type affinity — the canonical
1262
+ * `@lunora/d1/dialect` mapping. Re-exported under this name because
1263
+ * `schema-snapshot.ts` builds the persisted snapshot from it.
1264
+ */
834
1265
  declare const validatorKindToSqlType: (kind: string) => ColumnSnapshot["sqlType"];
835
- /** Emit `CREATE TABLE` SQL for a new global table. */
1266
+ /**
1267
+ * Emit `CREATE TABLE` SQL for a new global table.
1268
+ *
1269
+ * Refuses a table past D1's column ceiling rather than writing SQL that
1270
+ * `lunora migrate up` will reject: the runtime auto-provisioner checks the same
1271
+ * number, and a migration file is the worse place to find out — the failure
1272
+ * lands later, against a database, with none of the schema context that names
1273
+ * which table and field to split.
1274
+ */
836
1275
  declare const renderCreateTable: (table: TableSnapshot) => string;
837
1276
  declare const renderDropTable: (tableName: string) => string;
838
1277
  declare const renderAddColumn: (tableName: string, columnName: string, column: ColumnSnapshot) => string;
839
1278
  declare const renderCreateIndex: (tableName: string, index: IndexSnapshot) => string;
840
1279
  declare const renderDropIndex: (tableName: string, indexName: string) => string;
841
1280
  /**
842
- * Compute a {@link SchemaDiff} from two snapshots. Pure function — no I/O.
843
- */
1281
+ * Compute a {@link SchemaDiff} from two snapshots. Pure function — no I/O.
1282
+ */
844
1283
  declare const diffSnapshots: (previous: SchemaSnapshot | undefined, next: SchemaSnapshot) => SchemaDiff;
845
1284
  /**
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
- */
1285
+ * Render a complete migration file body from a diff. Includes a header,
1286
+ * each SQL statement, and (if any) a trailing comment block describing the
1287
+ * manual SQL the user needs to fill in for unsupported deltas.
1288
+ */
850
1289
  declare const renderMigrationFile: (name: string, diff: SchemaDiff, generatedAt: string) => string;
851
1290
  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 };
1291
+ export { type AddCommandOptions, type AddCommandResult, COMMANDS, type ColumnSnapshot, type CommandName, DEFAULT_IMPORT_BATCH_SIZE, type DeployCommandOptions, type DeployCommandResult, type DeployedIdentity, 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 };