@lunora/cli 1.0.0-alpha.8 → 1.0.0-alpha.80

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 (59) hide show
  1. package/LICENSE.md +6 -0
  2. package/__assets__/package-og.svg +1 -1
  3. package/dist/bin.mjs +1 -1
  4. package/dist/index.d.mts +290 -117
  5. package/dist/index.d.ts +290 -117
  6. package/dist/index.mjs +8 -8
  7. package/dist/packem_chunks/handler.mjs +87 -6
  8. package/dist/packem_chunks/handler10.mjs +8 -14
  9. package/dist/packem_chunks/handler11.mjs +19 -189
  10. package/dist/packem_chunks/handler12.mjs +176 -115
  11. package/dist/packem_chunks/handler13.mjs +118 -52
  12. package/dist/packem_chunks/handler14.mjs +50 -43
  13. package/dist/packem_chunks/handler15.mjs +48 -67
  14. package/dist/packem_chunks/handler16.mjs +85 -37
  15. package/dist/packem_chunks/handler17.mjs +39 -100
  16. package/dist/packem_chunks/handler18.mjs +87 -152
  17. package/dist/packem_chunks/handler19.mjs +148 -67
  18. package/dist/packem_chunks/handler2.mjs +6 -4
  19. package/dist/packem_chunks/handler20.mjs +77 -75
  20. package/dist/packem_chunks/handler21.mjs +71 -288
  21. package/dist/packem_chunks/handler3.mjs +6 -3
  22. package/dist/packem_chunks/handler4.mjs +2 -2
  23. package/dist/packem_chunks/handler5.mjs +7 -4
  24. package/dist/packem_chunks/handler6.mjs +10 -7
  25. package/dist/packem_chunks/handler7.mjs +2 -2
  26. package/dist/packem_chunks/handler8.mjs +1 -1
  27. package/dist/packem_chunks/handler9.mjs +315 -12
  28. package/dist/packem_chunks/planDevCommand.mjs +758 -81
  29. package/dist/packem_chunks/runCodegenCommand.mjs +5 -4
  30. package/dist/packem_chunks/runDeployCommand.mjs +126 -20
  31. package/dist/packem_chunks/runInitCommand.mjs +1661 -179
  32. package/dist/packem_chunks/runMigrateGenerateCommand.mjs +5 -4
  33. package/dist/packem_chunks/runResetCommand.mjs +2 -2
  34. package/dist/packem_chunks/runRpcCommand.mjs +3 -2
  35. package/dist/packem_shared/{COMMANDS-Bn8luojF.mjs → COMMANDS-DW8lQmuW.mjs} +85 -23
  36. package/dist/packem_shared/{DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs → DEFAULT_IMPORT_BATCH_SIZE-CRQmmBZM.mjs} +3 -2
  37. package/dist/packem_shared/{api-spec-CtA6ilu4.mjs → api-spec-Bx0iKbxA.mjs} +3 -1
  38. package/dist/packem_shared/{buildRegistryIndex-BcYe607_.mjs → buildRegistryIndex-BS5ig822.mjs} +1 -1
  39. package/dist/packem_shared/codegen-error-DJG-ghs_.mjs +31 -0
  40. package/dist/packem_shared/{command-BDXcJCCJ.mjs → command-lYnl4QyF.mjs} +6 -1
  41. package/dist/packem_shared/{commands-DqsEzojt.mjs → commands-ClEvcz3V.mjs} +224 -18
  42. package/dist/packem_shared/{createLogger-CHPNjFw2.mjs → createLogger-CIWSHrTL.mjs} +40 -8
  43. package/dist/packem_shared/{createRecordingSpawner-DxI3mebw.mjs → createRecordingSpawner-Cw5Iu73G.mjs} +12 -2
  44. package/dist/packem_shared/{detect-package-manager-DYp7n3mJ.mjs → detect-package-manager-DvEthdCw.mjs} +26 -30
  45. package/dist/packem_shared/{insertSchemaExtension-BuzF6-t2.mjs → insertSchemaExtension-DAqbfr9Z.mjs} +15 -10
  46. package/dist/packem_shared/{open-url-Dfq6fAyT.mjs → open-url-4PBLY9X0.mjs} +3 -2
  47. package/dist/packem_shared/{output-format-7gyGR3h8.mjs → output-format-B4642rjE.mjs} +1 -1
  48. package/dist/packem_shared/{parseManifest--vZf2FY1.mjs → parseManifest-Dbp-Q2q3.mjs} +36 -9
  49. package/dist/packem_shared/prompt-cancelled-APzX1Im-.mjs +9 -0
  50. package/dist/packem_shared/runAddCommand-DGjFXGqa.mjs +4 -0
  51. package/dist/packem_shared/storage-DEXpJkXh.mjs +84 -0
  52. package/dist/packem_shared/tui-prompts-BjEN8XgP.mjs +658 -0
  53. package/dist/packem_shared/wrangler-secrets-Dq_Fkbm-.mjs +49 -0
  54. package/package.json +16 -13
  55. package/skills/lunora-quickstart/SKILL.md +25 -5
  56. package/skills/lunora-setup-storage/SKILL.md +7 -3
  57. package/dist/packem_shared/features-ocSSpZtS.mjs +0 -24
  58. package/dist/packem_shared/runAddCommand-G544_v6e.mjs +0 -4
  59. package/dist/packem_shared/tui-prompts-XHFxlOg5.mjs +0 -269
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CodegenOptions, SchemaIR } from '@lunora/codegen';
2
2
  import '@visulima/cerebro';
3
- import { ensureDevVariables, ensureDevVarsExample, materializeRemoteWranglerConfig } from '@lunora/config';
3
+ import { ensureDevVariables, ensureDevVarsExample, fillDevSecrets, materializeRemoteWranglerConfig } from '@lunora/config';
4
4
  export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, type WranglerProjectValidationOptions as WranglerValidationOptions, type WranglerValidationReport, type WranglerProjectValidationResult as WranglerValidationResult, validateWranglerProject as validateWrangler, validateWranglerConfig } from '@lunora/config';
5
5
  /** Every command name the CLI registers (drives the `CommandName` type + tests). */
6
6
  declare const COMMANDS: readonly ["init", "add", "dev", "codegen", "build", "deploy", "containers", "prepare", "link", "deployments", "logs", "run", "insights", "reset", "migrate", "export", "import", "seed", "backup", "verify", "info", "doctor", "env", "analyze", "view", "docs", "registry", "rules"];
@@ -49,6 +49,15 @@ interface PailLogger {
49
49
  success: (message: string) => void;
50
50
  warn: (message: string) => void;
51
51
  }
52
+ /**
53
+ * Minimal reporter shape consumed by `createPail`. We re-declare it locally
54
+ * because `@visulima/pail`'s `reporter/*` entrypoints ship a packaging bug:
55
+ * their `index.d.ts` re-exports `./json-reporter.d.ts` / `./pretty-reporter.d.ts`,
56
+ * but the real declaration files are suffixed (`*.server.d.ts`). `tsc` tolerates
57
+ * the dangling re-export, but the type-aware linter resolves `JsonReporter` /
58
+ * `PrettyReporter` to an unresolved type. Constructing them through this typed
59
+ * factory keeps every call site safe.
60
+ */
52
61
  declare const createLogger: () => Logger;
53
62
  /**
54
63
  * Logger whose every channel writes to `process.stderr`. Used by commands in
@@ -64,6 +73,12 @@ declare const createLogger: () => Logger;
64
73
  * the package barrel) stays side-effect-free.
65
74
  */
66
75
  declare const pail: PailLogger;
76
+ /**
77
+ * Emit a badged step line through the shared pail (the `init` flow's off-TTY
78
+ * fallback for the create-astro-style transcript). The `message` may contain
79
+ * newlines — `LunoraReporter` indents continuation lines under the badge so a
80
+ * dimmed answer sits below its question.
81
+ */
67
82
  interface CodegenCommandOptions {
68
83
  /** Which API spec(s) to emit. Defaults to codegen's `"openapi"` when omitted. */
69
84
  apiSpec?: ApiSpec;
@@ -220,6 +235,35 @@ declare const createRecordingSpawner: (exitCode?: number) => {
220
235
  calls: RecordedSpawn[];
221
236
  spawner: Spawner;
222
237
  };
238
+ interface SecretListRunnerResult {
239
+ code: number;
240
+ stderr: string;
241
+ stdout: string;
242
+ }
243
+ /** Runs an argv and resolves its captured output. Injected in tests. */
244
+ type SecretListRunner = (command: string, args: ReadonlyArray<string>, cwd: string) => Promise<SecretListRunnerResult>;
245
+ interface ListRemoteSecretsInputs {
246
+ cwd: string;
247
+ /** Cloudflare environment name (`--env`). */
248
+ env?: string;
249
+ /** Injected command runner; defaults to a real `wrangler secret list`. */
250
+ runner?: SecretListRunner;
251
+ /** Target a temporary-account deployment (`--temporary`). */
252
+ temporary?: boolean;
253
+ }
254
+ interface ListRemoteSecretsResult {
255
+ /** Diagnostic message when `ok` is false. */
256
+ error?: string;
257
+ /** Remote secret names (sorted), empty when none or on failure. */
258
+ names: ReadonlyArray<string>;
259
+ /** False when wrangler failed or its output could not be parsed. */
260
+ ok: boolean;
261
+ }
262
+ /**
263
+ * Parse `wrangler secret list --format json` output into a sorted name list.
264
+ * The payload is an array of `{ name, type }`; anything else yields `undefined`
265
+ * so the caller can report a parse failure rather than silently returning [].
266
+ */
223
267
  type FetchLike = (input: string, init?: {
224
268
  body?: string;
225
269
  headers?: Record<string, string>;
@@ -312,6 +356,10 @@ interface DeployCommandOptions {
312
356
  preview?: boolean;
313
357
  /** Railpack-availability probe injected in tests. Defaults to a real `railpack --version` + `BUILDKIT_HOST` check. */
314
358
  railpackAvailable?: DockerProbe;
359
+ /** Confirm prompt for the missing-secret offer; injected in tests. Defaults to the TTY prompt. */
360
+ secretConfirm?: (message: string) => Promise<boolean>;
361
+ /** Remote-secret lister for the missing-secret offer; injected in tests. Defaults to `wrangler secret list`. */
362
+ secretLister?: (inputs: ListRemoteSecretsInputs) => Promise<ListRemoteSecretsResult>;
315
363
  skipCodegen?: boolean;
316
364
  spawner?: Spawner;
317
365
  /**
@@ -403,6 +451,34 @@ interface StudioServerHandle {
403
451
  /** The URL to open in a browser. */
404
452
  url: string;
405
453
  }
454
+ /**
455
+ * How the dev child runs. `wrangler` is the classic `lunora dev` stack (wrangler
456
+ * worker + embedded studio + codegen watch) for a standalone class-C project.
457
+ * `vite` is a project on `@lunora/vite`: the plugin already runs the worker,
458
+ * studio, and codegen inside the Vite dev server, so `lunora dev` runs the
459
+ * project's own dev script and gets out of the way — this also covers class-B
460
+ * frameworks whose own dev server runs the worker in `workerd` (Astro 6 +
461
+ * `@astrojs/cloudflare`, which embeds `@cloudflare/vite-plugin` in `astro dev`:
462
+ * SSR + `/_lunora/*` + `ShardDO` in one process, HMR intact). `framework-worker`
463
+ * is a class-B framework whose dev server CANNOT host the `ShardDO` Durable
464
+ * Object (SvelteKit / Nuxt: their adapters use wrangler's `getPlatformProxy()`,
465
+ * which runs an empty-script Miniflare and does not emulate internal DOs); there
466
+ * `lunora dev` runs the framework's own dev server (front door, HMR, and — via
467
+ * its `@lunora/vite` plugin — studio + codegen) AND a second `wrangler dev`
468
+ * sidecar that owns the real `ShardDO` in `workerd`, wired via the committed
469
+ * `wrangler.dev.jsonc`.
470
+ */
471
+ type DevFlavor = "framework-worker" | "vite" | "wrangler";
472
+ /**
473
+ * Detect the dev flavor.
474
+ *
475
+ * A SvelteKit / Nuxt project needs the two-process `framework-worker` stack even
476
+ * though it also declares `@lunora/vite` (which its framework dev server uses for
477
+ * codegen/studio) — so the framework check comes FIRST. Everything else on
478
+ * `@lunora/vite` (class-A frameworks + Astro + standalone Vite) delegates to the
479
+ * project's own dev server (`vite`); a project without `@lunora/vite` is the
480
+ * classic standalone `wrangler` stack.
481
+ */
406
482
  /** A running worker child the orchestrator controls: send signals, await its exit. */
407
483
  interface WorkerProcess {
408
484
  /** Resolves with the worker's exit code (1 if it failed to start). */
@@ -423,6 +499,14 @@ interface DevCommandOptions {
423
499
  ensureEnv?: typeof ensureDevVariables;
424
500
  /** Injection seam for tests — defaults to the real `.dev.vars.example` package-aware scaffolder. */
425
501
  ensureExample?: typeof ensureDevVarsExample;
502
+ /** Injection seam for tests — defaults to the real empty-secret/admin-token filler. */
503
+ fillSecrets?: typeof fillDevSecrets;
504
+ /** Injection seam for tests — defaults to the real free-port probe ({@link findAvailablePort}). */
505
+ findFreePort?: (preferred: number) => Promise<number>;
506
+ /** Dev flavor override (tests / callers that already detected it) — defaults to {@link detectDevFlavor}. */
507
+ flavor?: DevFlavor;
508
+ /** Injection seam for tests — defaults to the real IPv6-loopback probe ({@link hasIpv6Loopback}). */
509
+ hasIpv6Loopback?: () => boolean;
426
510
  logger: Logger;
427
511
  /** Injection seam for tests — defaults to the real remote-config materializer. */
428
512
  materializeRemote?: typeof materializeRemoteWranglerConfig;
@@ -457,13 +541,42 @@ interface DevRemotePlan {
457
541
  }
458
542
  interface DevCommandPlan {
459
543
  codegenEnabled: boolean;
544
+ /** Which stack the child runs — see {@link DevFlavor}. */
545
+ flavor: DevFlavor;
546
+ /**
547
+ * One-line redirect hint printed when a meta-framework is detected on the
548
+ * wrangler flavor: without `@lunora/vite` in the dependencies the worker
549
+ * still runs *inside* the framework's dev server, so the user should run
550
+ * their framework dev script for the full app. `undefined` for the vite
551
+ * flavor (`lunora dev` already runs the project's dev script there) and
552
+ * for a standalone project. Purely informational: the wrangler spawn runs
553
+ * regardless.
554
+ */
555
+ frameworkHint?: string;
556
+ /**
557
+ * True when `wrangler dev` was given `--ip 127.0.0.1` because the host has no
558
+ * IPv6 loopback (`::1`) — surfaced so the dev loop can note the rebind.
559
+ * Always `false` for the vite flavor (the plugin owns its own bind).
560
+ */
561
+ ipv4LoopbackForced: boolean;
460
562
  /** The remote-binding decision: which D1/KV/R2 bindings hit the deployed worker. */
461
563
  remote: DevRemotePlan;
564
+ /**
565
+ * The `wrangler dev` sidecar for the `framework-worker` flavor (SvelteKit /
566
+ * Nuxt): a second child that owns the real `ShardDO` in `workerd`, wired via
567
+ * the committed `wrangler.dev.jsonc`. `undefined` for every other flavor —
568
+ * only the two-process class-B stack has a sidecar. When present, `wrangler`
569
+ * (above) is the framework's own dev server (the front door / HMR) and this
570
+ * is the Lunora realtime plane.
571
+ */
572
+ sidecar?: SpawnDescriptor & {
573
+ tag: string;
574
+ };
462
575
  studioEnabled: boolean;
463
576
  studioPort: number;
464
577
  workerOrigin: string;
465
578
  workerPort: number;
466
- /** The single child process `lunora dev` spawns: `wrangler dev`. */
579
+ /** The primary child `lunora dev` spawns: `wrangler dev` (wrangler flavor) or the framework/`vite dev` server (vite / framework-worker). */
467
580
  wrangler: SpawnDescriptor & {
468
581
  tag: string;
469
582
  };
@@ -477,10 +590,11 @@ interface DevCommandPlan {
477
590
  * to remote, the args stay empty and dev runs fully local.
478
591
  */
479
592
  /**
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.
593
+ * Plan `lunora dev`. Wrangler flavor: the worker runs via `wrangler dev` and
594
+ * nothing else as a child process. Vite flavor (`@lunora/vite` declared): the
595
+ * plugin already runs the worker inside the Vite dev server, so the one child
596
+ * is the project's own dev script (`vite dev`, `astro dev`, …) and every CLI
597
+ * sibling is disabled. Pure + synchronous so it's unit-testable.
484
598
  */
485
599
  declare const planDevCommand: (options: DevCommandOptions) => DevCommandPlan;
486
600
  /**
@@ -508,16 +622,142 @@ type PackageManagerProbe = (manager: PackageManager) => boolean;
508
622
  /** A registry item a feature can install. */
509
623
  type FeatureItem = "auth" | "auth-auth0" | "auth-clerk" | "mail";
510
624
  /** The auth-provider choices offered for `add auth` / the init auth prompt. Each value is a registry item name. */
511
-
625
+ /** A single file the item scaffolds into the project. */
626
+ interface RegistryFile {
627
+ /** Source path inside the item dir (e.g. `schema.ts`). */
628
+ from: string;
629
+ /** Merge strategy. `create-or-skip` writes whole files; `schema-extension` AST-merges schema.ts. */
630
+ merge: "create-or-skip" | "schema-extension";
631
+ /** Destination relative to the project root (e.g. `lunora/ratelimit/index.ts`). */
632
+ to: string;
633
+ }
634
+ /** A wrangler.jsonc binding addition. `path` is the jsonc key path; `value` the value to set. */
635
+ interface RegistryBinding {
636
+ path: ReadonlyArray<string>;
637
+ value: unknown;
638
+ }
639
+ /**
640
+ * An environment variable an item needs. Scaffolded into `.dev.vars` (Workers'
641
+ * local-secrets file) on add — non-secrets get their `value`; secrets get an
642
+ * empty placeholder and a reminder to run `wrangler secret put` for production.
643
+ */
644
+ interface RegistryEnvVariable {
645
+ /** Human note on what the variable is for. */
646
+ description?: string;
647
+ /** The variable name (e.g. `RESEND_API_KEY`). */
648
+ name: string;
649
+ /** Mark as a secret: never write a value, only a placeholder, and remind about prod. Defaults to `true` when no `value` is given. */
650
+ secret?: boolean;
651
+ /** A default/example value for non-secret vars. */
652
+ value?: string;
653
+ }
654
+ /** A re-export the item needs injected into the worker entry point (class-B/C only). */
655
+ interface EntrypointReexport {
656
+ /** Optional JS comment placed above the re-export line. */
657
+ comment?: string;
658
+ /** Module specifier (e.g. `"_generated/workflows"` → `export * from "./lunora/_generated/workflows"`). */
659
+ module: string;
660
+ }
661
+ /** The `registry.json` manifest shape. */
662
+ interface RegistryManifest {
663
+ /** wrangler.jsonc additions (best-effort structural edits). */
664
+ bindings?: ReadonlyArray<RegistryBinding>;
665
+ /** npm deps to add to the project package.json (name → version range). */
666
+ deps?: Readonly<Record<string, string>>;
667
+ description?: string;
668
+ /** npm devDependencies to add to the project package.json. */
669
+ devDependencies?: Readonly<Record<string, string>>;
670
+ /** Post-install guidance printed after the item is added (per-item next steps). */
671
+ docs?: string;
672
+ /** Worker-entry re-exports the item needs (class-B/C only). */
673
+ entrypointReexports?: ReadonlyArray<EntrypointReexport>;
674
+ /** Environment variables the item needs; scaffolded into `.dev.vars`. */
675
+ envVars?: ReadonlyArray<RegistryEnvVariable>;
676
+ files: ReadonlyArray<RegistryFile>;
677
+ name: string;
678
+ /** Other registry items this one depends on (resolved transitively, deps first). */
679
+ requires?: ReadonlyArray<string>;
680
+ /** Short human-readable label (distinct from the longer `description`). */
681
+ title?: string;
682
+ }
683
+ interface AddCommandOptions {
684
+ /** Bypass the `--source` safety gate (matches init). */
685
+ allowUnsafeSource?: boolean;
686
+ /** `registry build --check`: verify the index is current instead of rewriting it. */
687
+ check?: boolean;
688
+ /** Inject a confirmer for non-interactive callers / tests. */
689
+ confirm?: (prompt: string) => Promise<boolean>;
690
+ cwd?: string;
691
+ /** Preview the file-level changes (a content diff) and write nothing. */
692
+ diff?: boolean;
693
+ /** Print the plan and stop without writing anything. */
694
+ dryRun?: boolean;
695
+ /** Local registry root (offline / tests). Expects per-item subdirs, each with a `registry.json`. */
696
+ from?: string;
697
+ /** Emit a JSON snapshot of the plan/result. */
698
+ json?: boolean;
699
+ /** `--list`: enumerate available items instead of adding. */
700
+ list?: boolean;
701
+ logger: Logger;
702
+ /** Item names to add (positional args). */
703
+ names: ReadonlyArray<string>;
704
+ /** `registry build` output path for the generated catalog (defaults to the root's `index.json`). */
705
+ out?: string;
706
+ /** Force-overwrite existing files (take the incoming copy) instead of skipping/conflicting. */
707
+ overwrite?: boolean;
708
+ /** 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. */
709
+ ref?: string;
710
+ /** Override the remote registry source base (default gh:anolilab/lunora/registry). */
711
+ source?: string;
712
+ /**
713
+ * Customize each resolved manifest after it is loaded but before the plan is
714
+ * printed / reconciled — used to inject user-chosen values into otherwise
715
+ * static manifests (e.g. the R2 `bucket_name` the init storage prompt asks
716
+ * for). Applied to every item; return the manifest unchanged to leave it as-is.
717
+ */
718
+ transformManifest?: (manifest: RegistryManifest) => RegistryManifest;
719
+ /** Skip the package.json mutation confirmation prompt. */
720
+ yes?: boolean;
721
+ }
722
+ interface AddCommandResult {
723
+ /** Bindings written to wrangler.jsonc. */
724
+ bindings: ReadonlyArray<string>;
725
+ code: number;
726
+ /** Deps added to package.json. */
727
+ deps: ReadonlyArray<string>;
728
+ /** Files skipped because they already existed. */
729
+ skipped: ReadonlyArray<string>;
730
+ /** Files written (absolute paths). */
731
+ written: ReadonlyArray<string>;
732
+ }
733
+ /** One resolved item: its parsed manifest plus the (possibly staged) directory it lives in. */
512
734
  /**
513
735
  * A feature offered in the post-scaffold multi-select. `auth`/`email` carry a
514
736
  * sub-prompt or alias; every other value IS the registry item name applied
515
737
  * directly (`storage` → the `storage` registry item, etc.).
516
738
  */
517
- type StackFeature = "auth" | "backup" | "crons" | "email" | "presence" | "ratelimit" | "storage";
739
+ type StackFeature = "ai" | "auth" | "backup" | "browser" | "cloudflare-access" | "crons" | "email" | "flags" | "hyperdrive" | "payment" | "presence" | "queue" | "storage" | "workflow";
740
+ /** Customize a resolved manifest before it is written (e.g. inject the chosen R2 bucket name). */
741
+ type OfferTransformManifest = (manifest: RegistryManifest) => RegistryManifest;
742
+ /**
743
+ * One feature ready to apply: the registry item name(s), an optional manifest
744
+ * transform, and a short `label` (the feature value) shown on the combined
745
+ * progress line. Built up-front by the collectors so every prompt is answered
746
+ * before any apply runs.
747
+ */
748
+ interface FeatureApply {
749
+ label: string;
750
+ names: ReadonlyArray<string>;
751
+ transformManifest?: OfferTransformManifest;
752
+ }
518
753
  interface OfferDeps {
519
- /** Apply one or more registry items into the new project; resolves `true` on success. */
520
- apply: (names: ReadonlyArray<string>) => Promise<boolean>;
754
+ /**
755
+ * Apply the collected features into the new project in one batch — resolves
756
+ * `true` when every item succeeds. The CLI renders this as a single progress
757
+ * line whose label changes per feature; each plan's `transformManifest`
758
+ * customizes that item's manifest before it is written.
759
+ */
760
+ applyAll: (plans: ReadonlyArray<FeatureApply>) => Promise<boolean>;
521
761
  /** When `false`, skip all prompts and print the later-setup hint. */
522
762
  interactive: boolean;
523
763
  logger: Logger;
@@ -529,6 +769,14 @@ interface OfferDeps {
529
769
  }>, settings?: {
530
770
  defaults?: ReadonlyArray<StackFeature>;
531
771
  }) => Promise<StackFeature[]>;
772
+ /**
773
+ * Features chosen non-interactively (the `--add` flag). When set, the
774
+ * multi-select and every sub-prompt are skipped — each feature is applied with
775
+ * its shipped defaults (base registry item, placeholder bindings).
776
+ */
777
+ preselected?: ReadonlyArray<StackFeature>;
778
+ /** The new project's name — seeds smart defaults like the `project-uploads` bucket name. */
779
+ projectName: string;
532
780
  /** Single-select among the auth providers (TTY-backed in production). */
533
781
  select: (message: string, options: ReadonlyArray<{
534
782
  description?: string;
@@ -537,17 +785,34 @@ interface OfferDeps {
537
785
  }>, settings?: {
538
786
  default?: FeatureItem;
539
787
  }) => Promise<FeatureItem | undefined>;
788
+ /** Single-line text input (TTY-backed in production) — used for the storage bucket-name prompt. */
789
+ text: (message: string, settings?: {
790
+ default?: string;
791
+ placeholder?: string;
792
+ }) => Promise<string>;
540
793
  }
541
794
  /**
542
- * Offer the stack features (auth, email, storage, rate limiting, crons,
543
- * presence, backups) in ONE multi-select after a successful scaffold. When auth
544
- * is picked, a follow-up single-select chooses the provider (email+password /
545
- * Clerk / Auth0); email maps to the `mail` item; every other feature value is
546
- * applied as its registry item directly. Picked items are applied in selection
547
- * order. Non-interactive: prints how to add them later and changes nothing.
795
+ * Offer the stack features (ai, auth, backup, browser, cloudflare-access,
796
+ * crons, email, flags, hyperdrive, payment, presence, queue, storage,
797
+ * workflow) in ONE multi-select after a successful scaffold. Auth,
798
+ * presence, backups) in ONE multi-select after a successful scaffold. Auth,
799
+ * email, and storage run a follow-up prompt (provider / destination / bucket
800
+ * name); every other feature value is applied as its registry item directly.
801
+ *
802
+ * Every question is asked FIRST (in selection order), then the picked features
803
+ * are applied together via {@link OfferDeps.applyAll} — the CLI renders that as a
804
+ * single progress line whose label changes per feature, instead of one spinner
805
+ * per item. Non-interactive: prints how to add them later and changes nothing.
548
806
  */
549
807
  type Template = "analog" | "astro" | "next" | "nuxt" | "react-router" | "standalone" | "sveltekit" | "tanstack-start-react" | "tanstack-start-solid";
550
808
  interface InitCommandOptions {
809
+ /**
810
+ * Add features non-interactively after scaffolding (the `--add` flag): a
811
+ * comma-separated list of `ai | auth | backup | browser | cloudflare-access | crons | email | flags | hyperdrive | payment | presence | queue | storage | workflow`.
812
+ * Bypasses the interactive multi-select and sub-prompts —
813
+ * each named feature is applied with its shipped defaults.
814
+ */
815
+ add?: string;
551
816
  /**
552
817
  * When true, accept `--source` values that don't start with `gh:` /
553
818
  * `github:` / `https://` or that contain `..`. Defaults to false; the CLI
@@ -559,6 +824,12 @@ interface InitCommandOptions {
559
824
  ci?: CiProvider;
560
825
  cwd?: string;
561
826
  /**
827
+ * Walk the whole flow — prompts, task list, next-steps, mascot — but make no
828
+ * changes: skip the template fetch/copy, the feature applies, the dependency
829
+ * install, and `git init`. Each skipped action logs a `would …` line instead.
830
+ */
831
+ dryRun?: boolean;
832
+ /**
562
833
  * Local directory containing the template subdirs (e.g. `vite/`,
563
834
  * `standalone/`). When provided, skips the network fetch entirely.
564
835
  * Useful for offline runs, the clean-machine smoke test, and unit tests.
@@ -599,10 +870,10 @@ interface InitCommandOptions {
599
870
  packageManagerProbe?: PackageManagerProbe;
600
871
  /**
601
872
  * Inject the offer's prompts (tests). When set, the offer is treated as
602
- * interactive regardless of TTY, and these drive the feature multi-select
603
- * and the auth-provider sub-select.
873
+ * interactive regardless of TTY, and these drive the feature multi-select,
874
+ * the auth-provider sub-select, and the storage bucket-name text input.
604
875
  */
605
- prompt?: Pick<OfferDeps, "multiSelect" | "select">;
876
+ prompt?: Pick<OfferDeps, "multiSelect" | "select" | "text">;
606
877
  /**
607
878
  * Override the git ref (branch, tag, or commit) the default template source
608
879
  * is fetched from. Takes precedence over the version-derived ref. Ignored
@@ -639,11 +910,6 @@ interface InitCommandResult {
639
910
  files: ReadonlyArray<string>;
640
911
  target: string;
641
912
  }
642
- /**
643
- * `lunora init` entry: scaffold (in-place or a new directory), then — on success
644
- * — offer to add auth + email via the registry. The offer never affects the
645
- * scaffold's exit code.
646
- */
647
913
  declare const runInitCommand: (options: InitCommandOptions) => Promise<InitCommandResult>;
648
914
  /** Narrow a raw `--template` value to a known {@link Template}. */
649
915
  interface MigrateGenerateCommandOptions {
@@ -681,99 +947,6 @@ interface IndexItem extends CatalogItem {
681
947
  declare const buildRegistryIndex: (root: string) => {
682
948
  items: IndexItem[];
683
949
  };
684
- /** A single file the item scaffolds into the project. */
685
- interface RegistryFile {
686
- /** Source path inside the item dir (e.g. `schema.ts`). */
687
- from: string;
688
- /** Merge strategy. `create-or-skip` writes whole files; `schema-extension` AST-merges schema.ts. */
689
- merge: "create-or-skip" | "schema-extension";
690
- /** Destination relative to the project root (e.g. `lunora/ratelimit/index.ts`). */
691
- to: string;
692
- }
693
- /** A wrangler.jsonc binding addition. `path` is the jsonc key path; `value` the value to set. */
694
- interface RegistryBinding {
695
- path: ReadonlyArray<string>;
696
- value: unknown;
697
- }
698
- /**
699
- * An environment variable an item needs. Scaffolded into `.dev.vars` (Workers'
700
- * local-secrets file) on add — non-secrets get their `value`; secrets get an
701
- * empty placeholder and a reminder to run `wrangler secret put` for production.
702
- */
703
- interface RegistryEnvVariable {
704
- /** Human note on what the variable is for. */
705
- description?: string;
706
- /** The variable name (e.g. `RESEND_API_KEY`). */
707
- name: string;
708
- /** Mark as a secret: never write a value, only a placeholder, and remind about prod. Defaults to `true` when no `value` is given. */
709
- secret?: boolean;
710
- /** A default/example value for non-secret vars. */
711
- value?: string;
712
- }
713
- /** The `registry.json` manifest shape. */
714
- interface RegistryManifest {
715
- /** wrangler.jsonc additions (best-effort structural edits). */
716
- bindings?: ReadonlyArray<RegistryBinding>;
717
- /** npm deps to add to the project package.json (name → version range). */
718
- deps?: Readonly<Record<string, string>>;
719
- description?: string;
720
- /** npm devDependencies to add to the project package.json. */
721
- devDependencies?: Readonly<Record<string, string>>;
722
- /** Post-install guidance printed after the item is added (per-item next steps). */
723
- docs?: string;
724
- /** Environment variables the item needs; scaffolded into `.dev.vars`. */
725
- envVars?: ReadonlyArray<RegistryEnvVariable>;
726
- files: ReadonlyArray<RegistryFile>;
727
- name: string;
728
- /** Other registry items this one depends on (resolved transitively, deps first). */
729
- requires?: ReadonlyArray<string>;
730
- /** Short human-readable label (distinct from the longer `description`). */
731
- title?: string;
732
- }
733
- interface AddCommandOptions {
734
- /** Bypass the `--source` safety gate (matches init). */
735
- allowUnsafeSource?: boolean;
736
- /** `registry build --check`: verify the index is current instead of rewriting it. */
737
- check?: boolean;
738
- /** Inject a confirmer for non-interactive callers / tests. */
739
- confirm?: (prompt: string) => Promise<boolean>;
740
- cwd?: string;
741
- /** Preview the file-level changes (a content diff) and write nothing. */
742
- diff?: boolean;
743
- /** Print the plan and stop without writing anything. */
744
- dryRun?: boolean;
745
- /** Local registry root (offline / tests). Expects per-item subdirs, each with a `registry.json`. */
746
- from?: string;
747
- /** Emit a JSON snapshot of the plan/result. */
748
- json?: boolean;
749
- /** `--list`: enumerate available items instead of adding. */
750
- list?: boolean;
751
- logger: Logger;
752
- /** Item names to add (positional args). */
753
- names: ReadonlyArray<string>;
754
- /** `registry build` output path for the generated catalog (defaults to the root's `index.json`). */
755
- out?: string;
756
- /** Force-overwrite existing files (take the incoming copy) instead of skipping/conflicting. */
757
- overwrite?: boolean;
758
- /** 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. */
759
- ref?: string;
760
- /** Override the remote registry source base (default gh:anolilab/lunora/registry). */
761
- source?: string;
762
- /** Skip the package.json mutation confirmation prompt. */
763
- yes?: boolean;
764
- }
765
- interface AddCommandResult {
766
- /** Bindings written to wrangler.jsonc. */
767
- bindings: ReadonlyArray<string>;
768
- code: number;
769
- /** Deps added to package.json. */
770
- deps: ReadonlyArray<string>;
771
- /** Files skipped because they already existed. */
772
- skipped: ReadonlyArray<string>;
773
- /** Files written (absolute paths). */
774
- written: ReadonlyArray<string>;
775
- }
776
- /** One resolved item: its parsed manifest plus the (possibly staged) directory it lives in. */
777
950
  /** `lunora registry add` (one or more item names): scaffold items into the project. */
778
951
  declare const runAddCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
779
952
  /**
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- export { COMMANDS, VERSION, runCli } from './packem_shared/COMMANDS-Bn8luojF.mjs';
1
+ export { COMMANDS, VERSION, runCli } from './packem_shared/COMMANDS-DW8lQmuW.mjs';
2
2
  export { runCodegenCommand } from './packem_chunks/runCodegenCommand.mjs';
3
- export { DEFAULT_IMPORT_BATCH_SIZE, runExportCommand, runImportCommand } from './packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs';
3
+ export { DEFAULT_IMPORT_BATCH_SIZE, runExportCommand, runImportCommand } from './packem_shared/DEFAULT_IMPORT_BATCH_SIZE-CRQmmBZM.mjs';
4
4
  export { runDeployCommand } from './packem_chunks/runDeployCommand.mjs';
5
5
  export { planDevCommand, runDevCommand } from './packem_chunks/planDevCommand.mjs';
6
6
  export { runInitCommand } from './packem_chunks/runInitCommand.mjs';
@@ -8,12 +8,12 @@ export { runMigrateGenerateCommand } from './packem_chunks/runMigrateGenerateCom
8
8
  export { runResetCommand } from './packem_chunks/runResetCommand.mjs';
9
9
  export { runRpcCommand } from './packem_chunks/runRpcCommand.mjs';
10
10
  export { default as parseArgs } from './packem_shared/parseArgs-YXFuKdEk.mjs';
11
- export { insertSchemaExtension } from './packem_shared/insertSchemaExtension-BuzF6-t2.mjs';
12
- export { createLogger, pail } from './packem_shared/createLogger-CHPNjFw2.mjs';
11
+ export { insertSchemaExtension } from './packem_shared/insertSchemaExtension-DAqbfr9Z.mjs';
12
+ export { createLogger, pail } from './packem_shared/createLogger-CIWSHrTL.mjs';
13
13
  export { diffSnapshots, renderAddColumn, renderCreateIndex, renderCreateTable, renderDropIndex, renderDropTable, renderMigrationFile, validatorKindToSqlType } from './packem_shared/diffSnapshots-BeDvvNiF.mjs';
14
14
  export { default as schemaIrToSnapshot } from './packem_shared/schemaIrToSnapshot-DdsljJT-.mjs';
15
- export { createRecordingSpawner, defaultSpawner } from './packem_shared/createRecordingSpawner-DxI3mebw.mjs';
16
- export { default as parseManifest } from './packem_shared/parseManifest--vZf2FY1.mjs';
15
+ export { createRecordingSpawner, defaultSpawner } from './packem_shared/createRecordingSpawner-Cw5Iu73G.mjs';
16
+ export { default as parseManifest } from './packem_shared/parseManifest-Dbp-Q2q3.mjs';
17
17
  export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, validateWranglerProject as validateWrangler, validateWranglerConfig } from '@lunora/config';
18
- export { buildRegistryIndex } from './packem_shared/buildRegistryIndex-BcYe607_.mjs';
19
- export { r as runAddCommand, a as runBuildIndexCommand, b as runRegistryViewCommand } from './packem_shared/commands-DqsEzojt.mjs';
18
+ export { buildRegistryIndex } from './packem_shared/buildRegistryIndex-BS5ig822.mjs';
19
+ export { r as runAddCommand, a as runBuildIndexCommand, b as runRegistryViewCommand } from './packem_shared/commands-ClEvcz3V.mjs';