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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/LICENSE.md +6 -0
  2. package/__assets__/package-og.svg +1 -1
  3. package/dist/bin.mjs +1 -1
  4. package/dist/index.d.mts +293 -134
  5. package/dist/index.d.ts +293 -134
  6. package/dist/index.mjs +8 -9
  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 +20 -189
  10. package/dist/packem_chunks/handler12.mjs +176 -115
  11. package/dist/packem_chunks/handler13.mjs +118 -52
  12. package/dist/packem_chunks/handler14.mjs +50 -43
  13. package/dist/packem_chunks/handler15.mjs +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 +8 -4
  22. package/dist/packem_chunks/handler4.mjs +2 -2
  23. package/dist/packem_chunks/handler5.mjs +7 -4
  24. package/dist/packem_chunks/handler6.mjs +10 -7
  25. package/dist/packem_chunks/handler7.mjs +2 -2
  26. package/dist/packem_chunks/handler8.mjs +1 -1
  27. package/dist/packem_chunks/handler9.mjs +323 -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 +47 -41
  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-D0tmnAwr.mjs} +106 -27
  36. package/dist/packem_shared/{DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs → DEFAULT_IMPORT_BATCH_SIZE-D0VOTerB.mjs} +7 -2
  37. package/dist/packem_shared/{api-spec-CtA6ilu4.mjs → api-spec-Bx0iKbxA.mjs} +3 -1
  38. package/dist/packem_shared/{buildRegistryIndex-BcYe607_.mjs → buildRegistryIndex-BS5ig822.mjs} +1 -1
  39. package/dist/packem_shared/codegen-error-DJG-ghs_.mjs +31 -0
  40. package/dist/packem_shared/{command-BDXcJCCJ.mjs → command-lYnl4QyF.mjs} +6 -1
  41. package/dist/packem_shared/{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-WuSn20kb.mjs} +23 -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/parseArgs-YXFuKdEk.mjs +0 -56
  59. package/dist/packem_shared/runAddCommand-G544_v6e.mjs +0 -4
  60. 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;
@@ -148,6 +163,8 @@ interface ImportCommandOptions {
148
163
  table?: string;
149
164
  token?: string;
150
165
  url?: string;
166
+ /** Confirm bulk-writing production. Required alongside `--prod`. */
167
+ yes?: boolean;
151
168
  }
152
169
  interface ImportCommandResult {
153
170
  body: unknown;
@@ -220,6 +237,35 @@ declare const createRecordingSpawner: (exitCode?: number) => {
220
237
  calls: RecordedSpawn[];
221
238
  spawner: Spawner;
222
239
  };
240
+ interface SecretListRunnerResult {
241
+ code: number;
242
+ stderr: string;
243
+ stdout: string;
244
+ }
245
+ /** Runs an argv and resolves its captured output. Injected in tests. */
246
+ type SecretListRunner = (command: string, args: ReadonlyArray<string>, cwd: string) => Promise<SecretListRunnerResult>;
247
+ interface ListRemoteSecretsInputs {
248
+ cwd: string;
249
+ /** Cloudflare environment name (`--env`). */
250
+ env?: string;
251
+ /** Injected command runner; defaults to a real `wrangler secret list`. */
252
+ runner?: SecretListRunner;
253
+ /** Target a temporary-account deployment (`--temporary`). */
254
+ temporary?: boolean;
255
+ }
256
+ interface ListRemoteSecretsResult {
257
+ /** Diagnostic message when `ok` is false. */
258
+ error?: string;
259
+ /** Remote secret names (sorted), empty when none or on failure. */
260
+ names: ReadonlyArray<string>;
261
+ /** False when wrangler failed or its output could not be parsed. */
262
+ ok: boolean;
263
+ }
264
+ /**
265
+ * Parse `wrangler secret list --format json` output into a sorted name list.
266
+ * The payload is an array of `{ name, type }`; anything else yields `undefined`
267
+ * so the caller can report a parse failure rather than silently returning [].
268
+ */
223
269
  type FetchLike = (input: string, init?: {
224
270
  body?: string;
225
271
  headers?: Record<string, string>;
@@ -312,6 +358,10 @@ interface DeployCommandOptions {
312
358
  preview?: boolean;
313
359
  /** Railpack-availability probe injected in tests. Defaults to a real `railpack --version` + `BUILDKIT_HOST` check. */
314
360
  railpackAvailable?: DockerProbe;
361
+ /** Confirm prompt for the missing-secret offer; injected in tests. Defaults to the TTY prompt. */
362
+ secretConfirm?: (message: string) => Promise<boolean>;
363
+ /** Remote-secret lister for the missing-secret offer; injected in tests. Defaults to `wrangler secret list`. */
364
+ secretLister?: (inputs: ListRemoteSecretsInputs) => Promise<ListRemoteSecretsResult>;
315
365
  skipCodegen?: boolean;
316
366
  spawner?: Spawner;
317
367
  /**
@@ -403,6 +453,34 @@ interface StudioServerHandle {
403
453
  /** The URL to open in a browser. */
404
454
  url: string;
405
455
  }
456
+ /**
457
+ * How the dev child runs. `wrangler` is the classic `lunora dev` stack (wrangler
458
+ * worker + embedded studio + codegen watch) for a standalone class-C project.
459
+ * `vite` is a project on `@lunora/vite`: the plugin already runs the worker,
460
+ * studio, and codegen inside the Vite dev server, so `lunora dev` runs the
461
+ * project's own dev script and gets out of the way — this also covers class-B
462
+ * frameworks whose own dev server runs the worker in `workerd` (Astro 6 +
463
+ * `@astrojs/cloudflare`, which embeds `@cloudflare/vite-plugin` in `astro dev`:
464
+ * SSR + `/_lunora/*` + `ShardDO` in one process, HMR intact). `framework-worker`
465
+ * is a class-B framework whose dev server CANNOT host the `ShardDO` Durable
466
+ * Object (SvelteKit / Nuxt: their adapters use wrangler's `getPlatformProxy()`,
467
+ * which runs an empty-script Miniflare and does not emulate internal DOs); there
468
+ * `lunora dev` runs the framework's own dev server (front door, HMR, and — via
469
+ * its `@lunora/vite` plugin — studio + codegen) AND a second `wrangler dev`
470
+ * sidecar that owns the real `ShardDO` in `workerd`, wired via the committed
471
+ * `wrangler.dev.jsonc`.
472
+ */
473
+ type DevFlavor = "framework-worker" | "vite" | "wrangler";
474
+ /**
475
+ * Detect the dev flavor.
476
+ *
477
+ * A SvelteKit / Nuxt project needs the two-process `framework-worker` stack even
478
+ * though it also declares `@lunora/vite` (which its framework dev server uses for
479
+ * codegen/studio) — so the framework check comes FIRST. Everything else on
480
+ * `@lunora/vite` (class-A frameworks + Astro + standalone Vite) delegates to the
481
+ * project's own dev server (`vite`); a project without `@lunora/vite` is the
482
+ * classic standalone `wrangler` stack.
483
+ */
406
484
  /** A running worker child the orchestrator controls: send signals, await its exit. */
407
485
  interface WorkerProcess {
408
486
  /** Resolves with the worker's exit code (1 if it failed to start). */
@@ -423,6 +501,14 @@ interface DevCommandOptions {
423
501
  ensureEnv?: typeof ensureDevVariables;
424
502
  /** Injection seam for tests — defaults to the real `.dev.vars.example` package-aware scaffolder. */
425
503
  ensureExample?: typeof ensureDevVarsExample;
504
+ /** Injection seam for tests — defaults to the real empty-secret/admin-token filler. */
505
+ fillSecrets?: typeof fillDevSecrets;
506
+ /** Injection seam for tests — defaults to the real free-port probe ({@link findAvailablePort}). */
507
+ findFreePort?: (preferred: number) => Promise<number>;
508
+ /** Dev flavor override (tests / callers that already detected it) — defaults to {@link detectDevFlavor}. */
509
+ flavor?: DevFlavor;
510
+ /** Injection seam for tests — defaults to the real IPv6-loopback probe ({@link hasIpv6Loopback}). */
511
+ hasIpv6Loopback?: () => boolean;
426
512
  logger: Logger;
427
513
  /** Injection seam for tests — defaults to the real remote-config materializer. */
428
514
  materializeRemote?: typeof materializeRemoteWranglerConfig;
@@ -457,13 +543,42 @@ interface DevRemotePlan {
457
543
  }
458
544
  interface DevCommandPlan {
459
545
  codegenEnabled: boolean;
546
+ /** Which stack the child runs — see {@link DevFlavor}. */
547
+ flavor: DevFlavor;
548
+ /**
549
+ * One-line redirect hint printed when a meta-framework is detected on the
550
+ * wrangler flavor: without `@lunora/vite` in the dependencies the worker
551
+ * still runs *inside* the framework's dev server, so the user should run
552
+ * their framework dev script for the full app. `undefined` for the vite
553
+ * flavor (`lunora dev` already runs the project's dev script there) and
554
+ * for a standalone project. Purely informational: the wrangler spawn runs
555
+ * regardless.
556
+ */
557
+ frameworkHint?: string;
558
+ /**
559
+ * True when `wrangler dev` was given `--ip 127.0.0.1` because the host has no
560
+ * IPv6 loopback (`::1`) — surfaced so the dev loop can note the rebind.
561
+ * Always `false` for the vite flavor (the plugin owns its own bind).
562
+ */
563
+ ipv4LoopbackForced: boolean;
460
564
  /** The remote-binding decision: which D1/KV/R2 bindings hit the deployed worker. */
461
565
  remote: DevRemotePlan;
566
+ /**
567
+ * The `wrangler dev` sidecar for the `framework-worker` flavor (SvelteKit /
568
+ * Nuxt): a second child that owns the real `ShardDO` in `workerd`, wired via
569
+ * the committed `wrangler.dev.jsonc`. `undefined` for every other flavor —
570
+ * only the two-process class-B stack has a sidecar. When present, `wrangler`
571
+ * (above) is the framework's own dev server (the front door / HMR) and this
572
+ * is the Lunora realtime plane.
573
+ */
574
+ sidecar?: SpawnDescriptor & {
575
+ tag: string;
576
+ };
462
577
  studioEnabled: boolean;
463
578
  studioPort: number;
464
579
  workerOrigin: string;
465
580
  workerPort: number;
466
- /** The single child process `lunora dev` spawns: `wrangler dev`. */
581
+ /** The primary child `lunora dev` spawns: `wrangler dev` (wrangler flavor) or the framework/`vite dev` server (vite / framework-worker). */
467
582
  wrangler: SpawnDescriptor & {
468
583
  tag: string;
469
584
  };
@@ -477,10 +592,11 @@ interface DevCommandPlan {
477
592
  * to remote, the args stay empty and dev runs fully local.
478
593
  */
479
594
  /**
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.
595
+ * Plan `lunora dev`. Wrangler flavor: the worker runs via `wrangler dev` and
596
+ * nothing else as a child process. Vite flavor (`@lunora/vite` declared): the
597
+ * plugin already runs the worker inside the Vite dev server, so the one child
598
+ * is the project's own dev script (`vite dev`, `astro dev`, …) and every CLI
599
+ * sibling is disabled. Pure + synchronous so it's unit-testable.
484
600
  */
485
601
  declare const planDevCommand: (options: DevCommandOptions) => DevCommandPlan;
486
602
  /**
@@ -508,16 +624,142 @@ type PackageManagerProbe = (manager: PackageManager) => boolean;
508
624
  /** A registry item a feature can install. */
509
625
  type FeatureItem = "auth" | "auth-auth0" | "auth-clerk" | "mail";
510
626
  /** The auth-provider choices offered for `add auth` / the init auth prompt. Each value is a registry item name. */
511
-
627
+ /** A single file the item scaffolds into the project. */
628
+ interface RegistryFile {
629
+ /** Source path inside the item dir (e.g. `schema.ts`). */
630
+ from: string;
631
+ /** Merge strategy. `create-or-skip` writes whole files; `schema-extension` AST-merges schema.ts. */
632
+ merge: "create-or-skip" | "schema-extension";
633
+ /** Destination relative to the project root (e.g. `lunora/ratelimit/index.ts`). */
634
+ to: string;
635
+ }
636
+ /** A wrangler.jsonc binding addition. `path` is the jsonc key path; `value` the value to set. */
637
+ interface RegistryBinding {
638
+ path: ReadonlyArray<string>;
639
+ value: unknown;
640
+ }
641
+ /**
642
+ * An environment variable an item needs. Scaffolded into `.dev.vars` (Workers'
643
+ * local-secrets file) on add — non-secrets get their `value`; secrets get an
644
+ * empty placeholder and a reminder to run `wrangler secret put` for production.
645
+ */
646
+ interface RegistryEnvVariable {
647
+ /** Human note on what the variable is for. */
648
+ description?: string;
649
+ /** The variable name (e.g. `RESEND_API_KEY`). */
650
+ name: string;
651
+ /** Mark as a secret: never write a value, only a placeholder, and remind about prod. Defaults to `true` when no `value` is given. */
652
+ secret?: boolean;
653
+ /** A default/example value for non-secret vars. */
654
+ value?: string;
655
+ }
656
+ /** A re-export the item needs injected into the worker entry point (class-B/C only). */
657
+ interface EntrypointReexport {
658
+ /** Optional JS comment placed above the re-export line. */
659
+ comment?: string;
660
+ /** Module specifier (e.g. `"_generated/workflows"` → `export * from "./lunora/_generated/workflows"`). */
661
+ module: string;
662
+ }
663
+ /** The `registry.json` manifest shape. */
664
+ interface RegistryManifest {
665
+ /** wrangler.jsonc additions (best-effort structural edits). */
666
+ bindings?: ReadonlyArray<RegistryBinding>;
667
+ /** npm deps to add to the project package.json (name → version range). */
668
+ deps?: Readonly<Record<string, string>>;
669
+ description?: string;
670
+ /** npm devDependencies to add to the project package.json. */
671
+ devDependencies?: Readonly<Record<string, string>>;
672
+ /** Post-install guidance printed after the item is added (per-item next steps). */
673
+ docs?: string;
674
+ /** Worker-entry re-exports the item needs (class-B/C only). */
675
+ entrypointReexports?: ReadonlyArray<EntrypointReexport>;
676
+ /** Environment variables the item needs; scaffolded into `.dev.vars`. */
677
+ envVars?: ReadonlyArray<RegistryEnvVariable>;
678
+ files: ReadonlyArray<RegistryFile>;
679
+ name: string;
680
+ /** Other registry items this one depends on (resolved transitively, deps first). */
681
+ requires?: ReadonlyArray<string>;
682
+ /** Short human-readable label (distinct from the longer `description`). */
683
+ title?: string;
684
+ }
685
+ interface AddCommandOptions {
686
+ /** Bypass the `--source` safety gate (matches init). */
687
+ allowUnsafeSource?: boolean;
688
+ /** `registry build --check`: verify the index is current instead of rewriting it. */
689
+ check?: boolean;
690
+ /** Inject a confirmer for non-interactive callers / tests. */
691
+ confirm?: (prompt: string) => Promise<boolean>;
692
+ cwd?: string;
693
+ /** Preview the file-level changes (a content diff) and write nothing. */
694
+ diff?: boolean;
695
+ /** Print the plan and stop without writing anything. */
696
+ dryRun?: boolean;
697
+ /** Local registry root (offline / tests). Expects per-item subdirs, each with a `registry.json`. */
698
+ from?: string;
699
+ /** Emit a JSON snapshot of the plan/result. */
700
+ json?: boolean;
701
+ /** `--list`: enumerate available items instead of adding. */
702
+ list?: boolean;
703
+ logger: Logger;
704
+ /** Item names to add (positional args). */
705
+ names: ReadonlyArray<string>;
706
+ /** `registry build` output path for the generated catalog (defaults to the root's `index.json`). */
707
+ out?: string;
708
+ /** Force-overwrite existing files (take the incoming copy) instead of skipping/conflicting. */
709
+ overwrite?: boolean;
710
+ /** 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. */
711
+ ref?: string;
712
+ /** Override the remote registry source base (default gh:anolilab/lunora/registry). */
713
+ source?: string;
714
+ /**
715
+ * Customize each resolved manifest after it is loaded but before the plan is
716
+ * printed / reconciled — used to inject user-chosen values into otherwise
717
+ * static manifests (e.g. the R2 `bucket_name` the init storage prompt asks
718
+ * for). Applied to every item; return the manifest unchanged to leave it as-is.
719
+ */
720
+ transformManifest?: (manifest: RegistryManifest) => RegistryManifest;
721
+ /** Skip the package.json mutation confirmation prompt. */
722
+ yes?: boolean;
723
+ }
724
+ interface AddCommandResult {
725
+ /** Bindings written to wrangler.jsonc. */
726
+ bindings: ReadonlyArray<string>;
727
+ code: number;
728
+ /** Deps added to package.json. */
729
+ deps: ReadonlyArray<string>;
730
+ /** Files skipped because they already existed. */
731
+ skipped: ReadonlyArray<string>;
732
+ /** Files written (absolute paths). */
733
+ written: ReadonlyArray<string>;
734
+ }
735
+ /** One resolved item: its parsed manifest plus the (possibly staged) directory it lives in. */
512
736
  /**
513
737
  * A feature offered in the post-scaffold multi-select. `auth`/`email` carry a
514
738
  * sub-prompt or alias; every other value IS the registry item name applied
515
739
  * directly (`storage` → the `storage` registry item, etc.).
516
740
  */
517
- type StackFeature = "auth" | "backup" | "crons" | "email" | "presence" | "ratelimit" | "storage";
741
+ type StackFeature = "ai" | "auth" | "backup" | "browser" | "cloudflare-access" | "crons" | "email" | "flags" | "hyperdrive" | "payment" | "presence" | "queue" | "storage" | "workflow";
742
+ /** Customize a resolved manifest before it is written (e.g. inject the chosen R2 bucket name). */
743
+ type OfferTransformManifest = (manifest: RegistryManifest) => RegistryManifest;
744
+ /**
745
+ * One feature ready to apply: the registry item name(s), an optional manifest
746
+ * transform, and a short `label` (the feature value) shown on the combined
747
+ * progress line. Built up-front by the collectors so every prompt is answered
748
+ * before any apply runs.
749
+ */
750
+ interface FeatureApply {
751
+ label: string;
752
+ names: ReadonlyArray<string>;
753
+ transformManifest?: OfferTransformManifest;
754
+ }
518
755
  interface OfferDeps {
519
- /** Apply one or more registry items into the new project; resolves `true` on success. */
520
- apply: (names: ReadonlyArray<string>) => Promise<boolean>;
756
+ /**
757
+ * Apply the collected features into the new project in one batch — resolves
758
+ * `true` when every item succeeds. The CLI renders this as a single progress
759
+ * line whose label changes per feature; each plan's `transformManifest`
760
+ * customizes that item's manifest before it is written.
761
+ */
762
+ applyAll: (plans: ReadonlyArray<FeatureApply>) => Promise<boolean>;
521
763
  /** When `false`, skip all prompts and print the later-setup hint. */
522
764
  interactive: boolean;
523
765
  logger: Logger;
@@ -529,6 +771,14 @@ interface OfferDeps {
529
771
  }>, settings?: {
530
772
  defaults?: ReadonlyArray<StackFeature>;
531
773
  }) => Promise<StackFeature[]>;
774
+ /**
775
+ * Features chosen non-interactively (the `--add` flag). When set, the
776
+ * multi-select and every sub-prompt are skipped — each feature is applied with
777
+ * its shipped defaults (base registry item, placeholder bindings).
778
+ */
779
+ preselected?: ReadonlyArray<StackFeature>;
780
+ /** The new project's name — seeds smart defaults like the `project-uploads` bucket name. */
781
+ projectName: string;
532
782
  /** Single-select among the auth providers (TTY-backed in production). */
533
783
  select: (message: string, options: ReadonlyArray<{
534
784
  description?: string;
@@ -537,17 +787,34 @@ interface OfferDeps {
537
787
  }>, settings?: {
538
788
  default?: FeatureItem;
539
789
  }) => Promise<FeatureItem | undefined>;
790
+ /** Single-line text input (TTY-backed in production) — used for the storage bucket-name prompt. */
791
+ text: (message: string, settings?: {
792
+ default?: string;
793
+ placeholder?: string;
794
+ }) => Promise<string>;
540
795
  }
541
796
  /**
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.
797
+ * Offer the stack features (ai, auth, backup, browser, cloudflare-access,
798
+ * crons, email, flags, hyperdrive, payment, presence, queue, storage,
799
+ * workflow) in ONE multi-select after a successful scaffold. Auth,
800
+ * presence, backups) in ONE multi-select after a successful scaffold. Auth,
801
+ * email, and storage run a follow-up prompt (provider / destination / bucket
802
+ * name); every other feature value is applied as its registry item directly.
803
+ *
804
+ * Every question is asked FIRST (in selection order), then the picked features
805
+ * are applied together via {@link OfferDeps.applyAll} — the CLI renders that as a
806
+ * single progress line whose label changes per feature, instead of one spinner
807
+ * per item. Non-interactive: prints how to add them later and changes nothing.
548
808
  */
549
809
  type Template = "analog" | "astro" | "next" | "nuxt" | "react-router" | "standalone" | "sveltekit" | "tanstack-start-react" | "tanstack-start-solid";
550
810
  interface InitCommandOptions {
811
+ /**
812
+ * Add features non-interactively after scaffolding (the `--add` flag): a
813
+ * comma-separated list of `ai | auth | backup | browser | cloudflare-access | crons | email | flags | hyperdrive | payment | presence | queue | storage | workflow`.
814
+ * Bypasses the interactive multi-select and sub-prompts —
815
+ * each named feature is applied with its shipped defaults.
816
+ */
817
+ add?: string;
551
818
  /**
552
819
  * When true, accept `--source` values that don't start with `gh:` /
553
820
  * `github:` / `https://` or that contain `..`. Defaults to false; the CLI
@@ -559,6 +826,12 @@ interface InitCommandOptions {
559
826
  ci?: CiProvider;
560
827
  cwd?: string;
561
828
  /**
829
+ * Walk the whole flow — prompts, task list, next-steps, mascot — but make no
830
+ * changes: skip the template fetch/copy, the feature applies, the dependency
831
+ * install, and `git init`. Each skipped action logs a `would …` line instead.
832
+ */
833
+ dryRun?: boolean;
834
+ /**
562
835
  * Local directory containing the template subdirs (e.g. `vite/`,
563
836
  * `standalone/`). When provided, skips the network fetch entirely.
564
837
  * Useful for offline runs, the clean-machine smoke test, and unit tests.
@@ -599,10 +872,10 @@ interface InitCommandOptions {
599
872
  packageManagerProbe?: PackageManagerProbe;
600
873
  /**
601
874
  * 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.
875
+ * interactive regardless of TTY, and these drive the feature multi-select,
876
+ * the auth-provider sub-select, and the storage bucket-name text input.
604
877
  */
605
- prompt?: Pick<OfferDeps, "multiSelect" | "select">;
878
+ prompt?: Pick<OfferDeps, "multiSelect" | "select" | "text">;
606
879
  /**
607
880
  * Override the git ref (branch, tag, or commit) the default template source
608
881
  * is fetched from. Takes precedence over the version-derived ref. Ignored
@@ -639,11 +912,6 @@ interface InitCommandResult {
639
912
  files: ReadonlyArray<string>;
640
913
  target: string;
641
914
  }
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
915
  declare const runInitCommand: (options: InitCommandOptions) => Promise<InitCommandResult>;
648
916
  /** Narrow a raw `--template` value to a known {@link Template}. */
649
917
  interface MigrateGenerateCommandOptions {
@@ -681,99 +949,6 @@ interface IndexItem extends CatalogItem {
681
949
  declare const buildRegistryIndex: (root: string) => {
682
950
  items: IndexItem[];
683
951
  };
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
952
  /** `lunora registry add` (one or more item names): scaffold items into the project. */
778
953
  declare const runAddCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
779
954
  /**
@@ -805,22 +980,6 @@ interface ResetCommandResult {
805
980
  }
806
981
  declare const runResetCommand: (options: ResetCommandOptions) => Promise<ResetCommandResult>;
807
982
  /** `lunora reset` handler (lazy-loaded via the command's `loader`). */
808
- /**
809
- * Tiny argv parser.
810
- *
811
- * Supports long options (`--name value`, `--name=value`, `--flag`), short
812
- * options (`-x value`, `-xvalue`), positional arguments (everything else, in
813
- * order), and a `--` terminator after which everything is positional.
814
- *
815
- * Intentionally small — replaces a full CLI library for the handful of
816
- * subcommands we need.
817
- */
818
- interface ParsedArgs {
819
- flags: Record<string, boolean>;
820
- options: Record<string, string>;
821
- positional: ReadonlyArray<string>;
822
- }
823
- declare const parseArgs: (argv: ReadonlyArray<string>, booleanFlags?: ReadonlySet<string>) => ParsedArgs;
824
983
  type InsertSchemaExtensionResult = {
825
984
  ok: true;
826
985
  text: string;
@@ -899,4 +1058,4 @@ declare const diffSnapshots: (previous: SchemaSnapshot | undefined, next: Schema
899
1058
  */
900
1059
  declare const renderMigrationFile: (name: string, diff: SchemaDiff, generatedAt: string) => string;
901
1060
  declare const schemaIrToSnapshot: (ir: SchemaIR) => SchemaSnapshot;
902
- 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 };
1061
+ export { type AddCommandOptions, type AddCommandResult, COMMANDS, type ColumnSnapshot, type CommandName, DEFAULT_IMPORT_BATCH_SIZE, type DeployCommandOptions, type DeployCommandResult, type DevCommandOptions, type DevCommandPlan, type DiffEntry, type ExportCommandOptions, type ExportCommandResult, type FetchLike, type ImportCommandOptions, type ImportCommandResult, type IndexSnapshot, type InitCommandOptions, type InitCommandResult, type InsertSchemaExtensionResult, type Logger, type MigrateGenerateCommandOptions, type MigrateGenerateCommandResult, type RecordedSpawn, type RegistryBinding, type RegistryFile, type RegistryManifest, type ResetCommandOptions, type ResetCommandResult, type RunCliOptions, type RunCommandOptions, type RunCommandResult, type SchemaDiff, type SchemaSnapshot, type SpawnDescriptor, type SpawnResult, type Spawner, type StreamingFetchLike, type TableSnapshot, type Template, type UnsupportedEntry, VERSION, buildRegistryIndex, createLogger, createRecordingSpawner, defaultSpawner, diffSnapshots, insertSchemaExtension, pail, parseManifest, planDevCommand, renderAddColumn, renderCreateIndex, renderCreateTable, renderDropIndex, renderDropTable, renderMigrationFile, runAddCommand, runBuildIndexCommand, runCli, runCodegenCommand, runDeployCommand, runDevCommand, runExportCommand, runImportCommand, runInitCommand, runMigrateGenerateCommand, runRegistryViewCommand, runResetCommand, runRpcCommand, schemaIrToSnapshot, validatorKindToSqlType };
package/dist/index.mjs CHANGED
@@ -1,19 +1,18 @@
1
- export { COMMANDS, VERSION, runCli } from './packem_shared/COMMANDS-Bn8luojF.mjs';
1
+ export { COMMANDS, VERSION, runCli } from './packem_shared/COMMANDS-D0tmnAwr.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-D0VOTerB.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';
7
7
  export { runMigrateGenerateCommand } from './packem_chunks/runMigrateGenerateCommand.mjs';
8
8
  export { runResetCommand } from './packem_chunks/runResetCommand.mjs';
9
9
  export { runRpcCommand } from './packem_chunks/runRpcCommand.mjs';
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';
10
+ export { insertSchemaExtension } from './packem_shared/insertSchemaExtension-DAqbfr9Z.mjs';
11
+ export { createLogger, pail } from './packem_shared/createLogger-CIWSHrTL.mjs';
13
12
  export { diffSnapshots, renderAddColumn, renderCreateIndex, renderCreateTable, renderDropIndex, renderDropTable, renderMigrationFile, validatorKindToSqlType } from './packem_shared/diffSnapshots-BeDvvNiF.mjs';
14
13
  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';
14
+ export { createRecordingSpawner, defaultSpawner } from './packem_shared/createRecordingSpawner-WuSn20kb.mjs';
15
+ export { default as parseManifest } from './packem_shared/parseManifest-Dbp-Q2q3.mjs';
17
16
  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';
17
+ export { buildRegistryIndex } from './packem_shared/buildRegistryIndex-BS5ig822.mjs';
18
+ export { r as runAddCommand, a as runBuildIndexCommand, b as runRegistryViewCommand } from './packem_shared/commands-ClEvcz3V.mjs';