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

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 (83) hide show
  1. package/dist/bin.mjs +2 -10
  2. package/dist/index.mjs +1 -18
  3. package/dist/packem_chunks/handler.mjs +1 -160
  4. package/dist/packem_chunks/handler10.mjs +1 -16
  5. package/dist/packem_chunks/handler11.mjs +1 -23
  6. package/dist/packem_chunks/handler12.mjs +2 -192
  7. package/dist/packem_chunks/handler13.mjs +2 -131
  8. package/dist/packem_chunks/handler14.mjs +1 -65
  9. package/dist/packem_chunks/handler15.mjs +1 -100
  10. package/dist/packem_chunks/handler16.mjs +1 -44
  11. package/dist/packem_chunks/handler17.mjs +1 -105
  12. package/dist/packem_chunks/handler18.mjs +3 -170
  13. package/dist/packem_chunks/handler19.mjs +1 -128
  14. package/dist/packem_chunks/handler2.mjs +2 -116
  15. package/dist/packem_chunks/handler20.mjs +1 -94
  16. package/dist/packem_chunks/handler21.mjs +2 -202
  17. package/dist/packem_chunks/handler3.mjs +2 -208
  18. package/dist/packem_chunks/handler4.mjs +1 -33
  19. package/dist/packem_chunks/handler5.mjs +1 -52
  20. package/dist/packem_chunks/handler6.mjs +1 -94
  21. package/dist/packem_chunks/handler7.mjs +1 -42
  22. package/dist/packem_chunks/handler8.mjs +1 -174
  23. package/dist/packem_chunks/handler9.mjs +8 -334
  24. package/dist/packem_chunks/planDevCommand.mjs +7 -1181
  25. package/dist/packem_chunks/runCodegenCommand.mjs +4 -53
  26. package/dist/packem_chunks/runDeployCommand.mjs +1 -619
  27. package/dist/packem_chunks/runInitCommand.mjs +51 -1411
  28. package/dist/packem_chunks/runMigrateGenerateCommand.mjs +9 -442
  29. package/dist/packem_chunks/runResetCommand.mjs +1 -41
  30. package/dist/packem_chunks/runRpcCommand.mjs +1 -69
  31. package/dist/packem_shared/COMMANDS-DRqlsGT2.mjs +3 -0
  32. package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-DL87PIEl.mjs +8 -0
  33. package/dist/packem_shared/admin-url-DfVehV3e.mjs +1 -0
  34. package/dist/packem_shared/api-spec-BENwiyUa.mjs +1 -0
  35. package/dist/packem_shared/buildRegistryIndex-DwySASBu.mjs +1 -0
  36. package/dist/packem_shared/codegen-error-DJN6pTH5.mjs +3 -0
  37. package/dist/packem_shared/command-Bjv4VmYA.mjs +1 -0
  38. package/dist/packem_shared/commands-BhX2Bo9B.mjs +19 -0
  39. package/dist/packem_shared/createLogger--C3x1FNE.mjs +2 -0
  40. package/dist/packem_shared/createRecordingSpawner-C8_7nffs.mjs +1 -0
  41. package/dist/packem_shared/detect-package-manager-B2eIuAiP.mjs +1 -0
  42. package/dist/packem_shared/diffSnapshots-9bDd9nOK.mjs +5 -0
  43. package/dist/packem_shared/docker-CKvYE9YF.mjs +1 -0
  44. package/dist/packem_shared/insertSchemaExtension-DZReBZ4_.mjs +8 -0
  45. package/dist/packem_shared/open-url-CTU_g9gr.mjs +1 -0
  46. package/dist/packem_shared/output-format-D7cKB-O5.mjs +2 -0
  47. package/dist/packem_shared/parseManifest-x3WsxKHz.mjs +1 -0
  48. package/dist/packem_shared/prompt-cancelled-C8Sj7OqI.mjs +1 -0
  49. package/dist/packem_shared/resolve-target-vxaXHmvg.mjs +1 -0
  50. package/dist/packem_shared/runAddCommand--TBYJQYi.mjs +1 -0
  51. package/dist/packem_shared/schema-drift-gate-CpqG-xP4.mjs +1 -0
  52. package/dist/packem_shared/schemaIrToSnapshot-Clwd2A8e.mjs +1 -0
  53. package/dist/packem_shared/storage-DOvAKGi4.mjs +1 -0
  54. package/dist/packem_shared/tui-prompts-CCt3jm1k.mjs +4 -0
  55. package/dist/packem_shared/wrangler-name-HIl0Z6yx.mjs +1 -0
  56. package/dist/packem_shared/wrangler-secrets-BMRJwKQU.mjs +1 -0
  57. package/package.json +6 -6
  58. package/dist/packem_shared/COMMANDS-BOJIDoVY.mjs +0 -1031
  59. package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-D0VOTerB.mjs +0 -249
  60. package/dist/packem_shared/admin-url-4UzT-CI4.mjs +0 -19
  61. package/dist/packem_shared/api-spec-Bx0iKbxA.mjs +0 -15
  62. package/dist/packem_shared/buildRegistryIndex-BS5ig822.mjs +0 -38
  63. package/dist/packem_shared/codegen-error-DJG-ghs_.mjs +0 -31
  64. package/dist/packem_shared/command-lYnl4QyF.mjs +0 -19
  65. package/dist/packem_shared/commands-D5Yxt9VY.mjs +0 -991
  66. package/dist/packem_shared/createLogger-CIWSHrTL.mjs +0 -105
  67. package/dist/packem_shared/createRecordingSpawner-WuSn20kb.mjs +0 -64
  68. package/dist/packem_shared/detect-package-manager-v4hHpQd0.mjs +0 -62
  69. package/dist/packem_shared/diffSnapshots-BeDvvNiF.mjs +0 -161
  70. package/dist/packem_shared/docker-hMQ97KSQ.mjs +0 -21
  71. package/dist/packem_shared/insertSchemaExtension-DAqbfr9Z.mjs +0 -64
  72. package/dist/packem_shared/open-url-4PBLY9X0.mjs +0 -42
  73. package/dist/packem_shared/output-format-B4642rjE.mjs +0 -17
  74. package/dist/packem_shared/parseManifest-Dbp-Q2q3.mjs +0 -121
  75. package/dist/packem_shared/prompt-cancelled-APzX1Im-.mjs +0 -9
  76. package/dist/packem_shared/resolve-target-qbsJ_5sF.mjs +0 -16
  77. package/dist/packem_shared/runAddCommand-D1hgfqFQ.mjs +0 -4
  78. package/dist/packem_shared/schema-drift-gate-BtBt0as0.mjs +0 -79
  79. package/dist/packem_shared/schemaIrToSnapshot-DdsljJT-.mjs +0 -43
  80. package/dist/packem_shared/storage-BXU4ax4O.mjs +0 -84
  81. package/dist/packem_shared/tui-prompts-BjEN8XgP.mjs +0 -658
  82. package/dist/packem_shared/wrangler-name-cy4yhm9j.mjs +0 -12
  83. package/dist/packem_shared/wrangler-secrets-Coni-mER.mjs +0 -49
@@ -0,0 +1,3 @@
1
+ import{mkdirSync as f,readFileSync as u,lstatSync as v,writeFileSync as b}from"node:fs";import{resolveHint as k,isLunoraError as m,flattenHint as S,findSolutionByMessage as w}from"@lunora/errors";import{createCerebro as x}from"@visulima/cerebro";import O from"@visulima/cerebro/command/completion";import N from"@visulima/cerebro/command/version";import{p as l}from"./api-spec-BENwiyUa.mjs";import{createLogger as g}from"./createLogger--C3x1FNE.mjs";import{VisulimaError as R,renderError as A}from"@visulima/error";import{homedir as B}from"node:os";import{join as d}from"node:path";const D={argument:{description:"Feature or registry item: ai | auth | email | storage | crons | presence | queue | workflow | flags | backup | …",name:"feature",type:String},description:"Add a feature or registry item (ai, auth, email, storage, crons, …) to the current Lunora project",examples:[["lunora add auth","Add authentication (asks which provider)"],["lunora add auth --provider clerk","Add Clerk auth without prompting"],["lunora add email","Add transactional email (Cloudflare Email Workers + dev mail catcher)"],["lunora add storage","Add the R2 storage registry item (asks for the bucket name)"],["lunora add storage --bucket my-app-uploads","Add storage with a bucket name, no prompt"],["lunora add crons","Add the scheduled-jobs registry item"],["lunora add storage --ref alpha","Add an item from the alpha branch's registry"]],group:"Project",loader:()=>import("../packem_chunks/handler.mjs").then(e=>({default:e.execute})),name:"add",options:[{description:"auth: provider to use without prompting (auth | clerk | auth0)",name:"provider",type:String},{description:"auth: D1 database name to use without prompting (lowercase alphanumeric + hyphens)",name:"db",type:String},{description:"storage: R2 bucket name to use without prompting (lowercase alphanumeric + hyphens)",name:"bucket",type:String},{description:"email: verified destination address to use without prompting",name:"mail-to",type:String},{description:"Skip prompts (auth provider, DB name, bucket name, mail destination) and use the defaults",name:"yes",type:Boolean},{description:"Local registry root (offline; expects <name>/ subdirs)",name:"from",type:String},{description:"Override the remote registry source base (e.g. gh:owner/repo/registry)",name:"source",type:String},{description:"Fetch items from a git ref (branch, tag, or commit), e.g. --ref alpha. Overrides the version-derived default",name:"ref",type:String},{description:"Permit --source values outside gh:/github:/https://",name:"allow-unsafe-source",type:Boolean},{description:"Output format: pretty (default) or json",name:"format",type:String}]},L={description:"Run wrangler dry-run and report bundle size, top modules, and _generated files",examples:[["lunora analyze","Report the worker bundle size + heaviest modules"]],group:"Deploy",loader:()=>import("../packem_chunks/handler2.mjs").then(e=>({default:e.execute})),name:"analyze",options:[{description:"Emit a JSON report instead of human text",name:"json",type:Boolean}]},E={argument:{description:"create | list | restore <id|file> | pitr",name:"subcommand",type:String},description:"Managed snapshot backups (create | list | restore) plus native point-in-time recovery (pitr)",examples:[["lunora backup create","Snapshot every table to a backup file"],["lunora backup list","List recorded snapshots"],["lunora backup restore <id>","Restore a snapshot by id"],["lunora backup pitr --at 2026-06-01T00:00:00Z","Point-in-time recovery (≤30 days)"]],group:"Data",loader:()=>import("../packem_chunks/handler3.mjs").then(e=>({default:e.execute})),name:"backup",options:[{description:"Backup directory (default .lunora-backups)",name:"dir",type:String},{description:"Comma-separated table allowlist (create)",name:"tables",type:String},{description:"pitr: time to read/restore to (ISO or epoch-ms, ≤30 days)",name:"at",type:String},{description:"pitr --restore: explicit bookmark to restore to (wins over --at)",name:"bookmark",type:String},{description:"pitr: perform a restore instead of just reading the bookmark",name:"restore",type:Boolean},{description:"pitr --restore: restart the shard now so recovery applies immediately",name:"restart",type:Boolean},{description:"pitr: target shard key (default: root shard)",name:"shard",type:String},{description:"Target production — requires an explicit --url",name:"prod",type:Boolean},{description:"Confirm a production pitr --restore (required with --prod)",name:"yes",type:Boolean},{description:"Worker URL (default http://localhost:8787)",name:"url",type:String},{description:"Admin bearer token (prefer LUNORA_ADMIN_TOKEN; --token is visible to other local processes via the process table)",name:"token",type:String}]},C={description:"Codegen + validate + bundle the Worker to disk without deploying",examples:[["lunora build","Bundle to .lunora/build without deploying"],["lunora build --out-dir dist-worker","Bundle to a custom directory"]],group:"Deploy",loader:()=>import("../packem_chunks/handler4.mjs").then(e=>({default:e.execute})),name:"build",options:[{description:`Which API spec(s) to emit: ${l} (default openapi)`,name:"api-spec",type:String},{description:"Output format: pretty (default) or json",name:"format",type:String},{description:"Directory to write the bundled Worker to (default .lunora/build)",name:"out-dir",type:String}]},j={description:"Run codegen for lunora/ functions and schema",examples:[["lunora codegen","Generate lunora/_generated/ from your schema + functions"]],group:"Develop",loader:()=>import("../packem_chunks/runCodegenCommand.mjs").then(e=>({default:e.execute})),name:"codegen",options:[{description:`Which API spec(s) to emit: ${l} (default openapi)`,name:"api-spec",type:String},{description:"Output format: pretty (default) or json",name:"format",type:String}]},T={argument:{description:"<build|push|images|list|info|delete> [args…]",name:"args",type:String},description:"Build/push container images and manage container instances (wraps wrangler containers)",examples:[["lunora containers build ./containers/transcoder --tag transcoder:v1","Build a container image with the local Docker engine"],["lunora containers build ./containers/transcoder --tag transcoder:v1 --push","Build and push to the Cloudflare Registry in one step"],["lunora containers push transcoder:v1","Push a locally-tagged image to the Cloudflare Registry"],["lunora containers images list","List images in your Cloudflare Registry"],["lunora containers images delete transcoder:v1","Delete an image to free registry storage"]],group:"Deploy",loader:()=>import("../packem_chunks/handler5.mjs").then(e=>({default:e.execute})),name:"containers",options:[{description:"build: push the image to the Cloudflare Registry after building",name:"push",type:Boolean},{description:"build: name:tag for the image (forwarded to wrangler --tag)",name:"tag",type:String},{description:"Cloudflare environment name",name:"env",type:String}]},_={description:"Codegen, validate wrangler, then wrangler deploy",examples:[["lunora deploy","Deploy to Cloudflare"],["lunora deploy --env production","Deploy to a named environment"],["lunora deploy --dry-run","Validate + bundle without publishing"],["lunora deploy --migrate","Deploy, then run pending data migrations"]],group:"Deploy",loader:()=>import("../packem_chunks/runDeployCommand.mjs").then(e=>({default:e.execute})),name:"deploy",options:[{description:"Override the schema-drift gate (deploy even with breaking schema drift and no migration)",name:"allow-schema-drift",type:Boolean},{description:`Which API spec(s) to emit: ${l} (default openapi)`,name:"api-spec",type:String},{description:"Validate, bundle, and run pre-deploy gates without publishing (wrangler deploy --dry-run)",name:"dry-run",type:Boolean},{description:"Cloudflare environment name",name:"env",type:String},{description:"Output format: pretty (default) or json",name:"format",type:String},{description:"After a successful deploy, run pending data migrations against the live worker",name:"migrate",type:Boolean},{description:"Skip codegen + the schema-drift gate (assumes `lunora build`/`prepare` already ran in this CI run). Wrangler still bundles the worker.",name:"prebuilt",type:Boolean},{description:"Admin bearer token for --migrate (falls back to LUNORA_ADMIN_TOKEN)",name:"migrate-token",type:String},{description:"Worker URL for --migrate (REQUIRED with --migrate; the deploy target URL is not captured automatically)",name:"migrate-url",type:String},{description:"Confirm running the production data migration triggered by --migrate (required with --migrate)",name:"migrate-yes",type:Boolean},{description:"Upload a preview version (wrangler versions upload) instead of going live — prints a preview URL; doesn't shift production traffic",name:"preview",type:Boolean},{description:"Deploy to a temporary Cloudflare account when unauthenticated (wrangler deploy --temporary; live ~60min, then claim or it's deleted). Wrangler errors if you're already authenticated.",name:"temporary",type:Boolean},{description:"Re-bless the committed schema baseline (lunora/.lunora-schema.json) with the current shape",name:"update-schema-baseline",type:Boolean}]},I={argument:{description:"list | inspect <version-id> | rollback [version-id] | promote <version-id>",name:"subcommand",type:String},description:"List deployments and roll back / promote / inspect Worker versions",examples:[["lunora deployments list","Show the 10 most recent deployments"],["lunora deployments inspect <version-id>","View a specific Worker version"],["lunora deployments rollback --yes","Roll back to the previous version"],["lunora deployments promote <version-id> --yes","Send 100% of traffic to a version"]],group:"Deploy",loader:()=>import("../packem_chunks/handler6.mjs").then(e=>({default:e.execute})),name:"deployments",options:[{description:"Cloudflare environment name",name:"env",type:String},{description:"Display `list` output as JSON",name:"json",type:Boolean},{description:"Reason/description recorded with a rollback or promote",name:"message",type:String},{description:"Confirm a rollback or promote (required — these change live traffic)",name:"yes",type:Boolean}]},$={argument:{description:"Optional subcommand: stop (shut the running dev server down) | status (report it) | logs (print its captured output)",name:"args",type:String},description:"Run the dev stack: wrangler worker + studio + codegen watch",examples:[["lunora dev","Run the worker + studio + codegen watch"],["lunora dev --background","Run detached: blocks until ready, prints URL + PID, then returns"],["lunora dev stop","Stop the background/tracked dev server (idempotent)"],["lunora dev status","Report the running dev server (URL, PID, uptime)"],["lunora dev logs","Print the captured dev-server log (background runs)"],["lunora dev --json","Machine-readable JSON log lines (also LUNORA_LOG_JSON=1)"],["lunora dev --no-studio","Skip the embedded studio server"],["lunora dev --worker-port 8080","Use a custom wrangler dev port"],["lunora dev --remote","Proxy D1/KV/R2 to the deployed worker (also LUNORA_REMOTE=1)"]],group:"Develop",loader:()=>import("../packem_chunks/planDevCommand.mjs").then(e=>({default:e.execute})),name:"dev",options:[{description:`Which API spec(s) codegen emits: ${l} (default openapi)`,name:"api-spec",type:String},{description:"Studio server port (default 6173)",name:"port",type:Number},{description:"wrangler dev port (default 8787)",name:"worker-port",type:Number},{description:"Run the dev server as a managed background process (auto-enabled when an AI agent is detected; LUNORA_AGENT_MODE=0 disables)",name:"background",type:Boolean},{description:"Emit machine-readable JSON log lines (also LUNORA_LOG_JSON=1; auto-enabled for AI agents)",name:"json",type:Boolean},{description:"How many trailing lines `lunora dev logs` prints (default 100, 0 = all)",name:"lines",type:Number},{description:"Don't start the embedded studio server",name:"no-studio",type:Boolean},{description:"Don't watch + regenerate codegen",name:"no-codegen",type:Boolean},{description:"Proxy D1/KV/R2 bindings to the deployed worker (or set LUNORA_REMOTE=1)",name:"remote",type:Boolean}]},U={argument:{description:"Optional path under the docs site (e.g. addons/studio)",name:"section",type:String},description:"Open the Lunora docs in your browser (optional [section] path)",examples:[["lunora docs","Open the Lunora docs"],["lunora docs addons/studio","Open a specific docs section"]],group:"Project",loader:()=>import("../packem_chunks/handler7.mjs").then(e=>({default:e.execute})),name:"docs"},P={description:"Preflight the current Lunora project (wrangler bindings, placeholders, dev secrets)",examples:[["lunora doctor","Run the project preflight checks"]],group:"Project",loader:()=>import("../packem_chunks/handler8.mjs").then(e=>({default:e.execute})),name:"doctor",options:[]},W={argument:{description:"list | get <KEY> | set <KEY> <VALUE> | unset <KEY> | generate [KEY] | push | diff | doctor",name:"subcommand",type:String},description:"Manage .dev.vars and sync secrets via wrangler (list | get | set | unset | generate | push | diff | doctor)",examples:[["lunora env list","List .dev.vars keys"],["lunora env set API_KEY secret","Set a local variable"],["lunora env generate","Generate strong values for the project's secrets (print KEY=value)"],["lunora env generate AUTH_SECRET --set","Generate one secret and write it to .dev.vars"],["lunora env push --yes","Upload secrets to Cloudflare"],["lunora env diff","Compare local .dev.vars keys against Cloudflare"]],group:"Data",loader:()=>import("../packem_chunks/handler9.mjs").then(e=>({default:e.execute})),name:"env",options:[{description:"Target production for `push` (passes --env production to wrangler)",name:"prod",type:Boolean},{description:"For `generate` — write the generated secrets into .dev.vars instead of printing them",name:"set",type:Boolean},{description:"Push secrets to a temporary-account deployment when unauthenticated (wrangler secret put --temporary). Errors if you're already authenticated.",name:"temporary",type:Boolean},{description:"Required for `push` — confirms uploading secrets to Cloudflare",name:"yes",type:Boolean}]},M={argument:{description:"Optional path (alias for --out)",name:"path",type:String},description:"Stream NDJSON of every shard-local + global table from the worker",examples:[["lunora export --out backup.ndjson","Dump every table to an NDJSON file"],["lunora export --tables messages,users","Export only specific tables"]],group:"Data",loader:()=>import("../packem_chunks/handler10.mjs").then(e=>({default:e.execute})),name:"export",options:[{description:"Output file path (`-` for stdout, default)",name:"out",type:String},{description:"Comma-separated table allowlist",name:"tables",type:String},{description:"Target production — requires an explicit --url",name:"prod",type:Boolean},{description:"Worker URL (default http://localhost:8787)",name:"url",type:String},{description:"Admin bearer token (prefer LUNORA_ADMIN_TOKEN; --token is visible to other local processes via the process table)",name:"token",type:String}]},J={argument:{description:"Source NDJSON file",name:"file",type:String},description:"Bulk-insert rows from an NDJSON file via the worker's admin endpoint",examples:[["lunora import backup.ndjson","Bulk-insert rows from an NDJSON file"]],group:"Data",loader:()=>import("../packem_chunks/handler11.mjs").then(e=>({default:e.execute})),name:"import",options:[{description:"Wrap each bare doc as `{table:<name>,doc:...}`",name:"table",type:String},{description:"Rows per HTTP request (default 500)",name:"batch-size",type:Number},{description:"Target production — requires an explicit --url",name:"prod",type:Boolean},{description:"Confirm bulk-writing production (required with --prod)",name:"yes",type:Boolean},{description:"Worker URL (default http://localhost:8787)",name:"url",type:String},{description:"Admin bearer token (prefer LUNORA_ADMIN_TOKEN; --token is visible to other local processes via the process table)",name:"token",type:String}]},K={description:"Print resolved project config: @lunora/* versions, wrangler summary, schema overview",examples:[["lunora info","Print resolved project config"],["lunora info --json","Emit a JSON snapshot"]],group:"Project",loader:()=>import("../packem_chunks/handler12.mjs").then(e=>({default:e.execute})),name:"info",options:[{description:"Emit a JSON snapshot instead of human text",name:"json",type:Boolean}]},q={argument:{description:"Project name",name:"name",type:String},description:"Scaffold a new Lunora project",examples:[["lunora init my-app","Scaffold with the default (vite) template"],["lunora init my-app -t next","Scaffold a Next.js app"],["lunora init my-app -t tanstack-start-react","Scaffold a TanStack Start (React) app"],["lunora init my-app -t tanstack-start-solid","Scaffold a TanStack Start (Solid) app"],["lunora init my-app --ref alpha","Scaffold from the alpha branch's templates"],["lunora init --here","Add Lunora to the current project"],["lunora init my-app --ci github","Scaffold + add a GitHub Actions deploy pipeline"],["lunora init my-app --ci gitlab","Scaffold + add a GitLab CI deploy pipeline"]],group:"Project",loader:()=>import("../packem_chunks/runInitCommand.mjs").then(e=>({default:e.execute})),name:"init",options:[{alias:"t",description:"Bespoke template (standalone | astro | next | nuxt | sveltekit | tanstack-start-react | tanstack-start-solid). For an SPA use --vite react|vue|solid|svelte.",name:"template",type:String},{description:"Scaffold via the create-vite overlay for a framework (react | vue | solid | svelte | vanilla) — official create-vite base + Lunora layer",name:"vite",type:String},{description:"Local templates root to copy from (offline-friendly; expects <type>/ subdirs)",name:"from",type:String},{description:"Override the remote template source (e.g. gh:owner/repo/sub#ref)",name:"source",type:String},{description:"Fetch templates from a git ref (branch, tag, or commit), e.g. --ref alpha. Overrides the version-derived default",name:"ref",type:String},{description:"Permit --source values outside gh:/github:/https:// (e.g. local file://)",name:"allow-unsafe-source",type:Boolean},{description:"Add Lunora to the current project: detect the framework, patch the config, scaffold lunora/, print per-framework wiring steps",name:"here",type:Boolean},{alias:"i",description:"After scaffolding, offer to add auth + email (defaults on when stdin is a TTY)",name:"interactive",type:Boolean},{alias:"y",description:"Skip the auth/email offer; scaffold only",name:"yes",type:Boolean},{description:"Also scaffold a CI deploy pipeline: github (.github/workflows/deploy.yml) or gitlab (.gitlab-ci.yml)",name:"ci",type:String},{description:"Add features non-interactively after scaffolding (comma-separated): ai | auth | backup | browser | cloudflare-access | crons | email | flags | hyperdrive | payment | presence | queue | storage | workflow",name:"add",type:String},{description:"Walk through every step (prompts + output) without writing files, installing, or running git",name:"dry-run",type:Boolean}]},H={description:"Report write-conflict hot-spots, error rates, and latency outliers from a running Worker",examples:[["lunora insights","Report against the local dev worker"],["lunora insights --shard channel:demo","Scope the report to one shard"],["lunora insights --json","Emit the raw report as JSON"],["lunora insights --prod --url https://app.example.com --token $LUNORA_ADMIN_TOKEN","Report against production"]],group:"Develop",loader:()=>import("../packem_chunks/handler13.mjs").then(e=>({default:e.execute})),name:"insights",options:[{description:"Explicit shard key (defaults to the root shard)",name:"shard",type:String},{description:"Max rows per section (default 10)",name:"limit",type:String},{description:"Emit a JSON report instead of human text",name:"json",type:Boolean},{description:"Target production — requires an explicit --url",name:"prod",type:Boolean},{description:"Worker URL (default http://localhost:8787)",name:"url",type:String},{description:"Admin bearer token (or LUNORA_ADMIN_TOKEN)",name:"token",type:String}]},F={description:"Link this checkout to its deployed Worker (writes .lunora/project.json)",examples:[["lunora link --url https://app.acme.workers.dev","Link to a deployed Worker URL"],["lunora link --url https://app.acme.workers.dev --env production","Link a named environment"],["lunora link --remove","Remove the link"]],group:"Deploy",loader:()=>import("../packem_chunks/handler14.mjs").then(e=>({default:e.execute})),name:"link",options:[{description:"Cloudflare environment name to record alongside the link",name:"env",type:String},{description:"Worker name (defaults to the `name` in wrangler config)",name:"name",type:String},{description:"Remove the existing link (.lunora/project.json)",name:"remove",type:Boolean},{description:"Deployed Worker URL to link (e.g. https://app.acme.workers.dev)",name:"url",type:String}]},V={argument:{description:"Worker name (defaults to the name in wrangler config)",name:"worker",type:String},description:"Stream live logs from a deployed Worker, or read the durable log archive with --durable",group:"Deploy",loader:()=>import("../packem_chunks/handler21.mjs").then(e=>({default:e.execute})),name:"logs",options:[{description:"Cloudflare environment name",name:"env",type:String},{description:"Output format: pretty (default) or json",name:"format",type:String},{description:"Substring filter on log messages",name:"search",type:String},{description:"Filter by invocation status: ok, error, or canceled",name:"status",type:String},{description:"Tail a temporary-account deployment when unauthenticated (wrangler tail --temporary). Errors if you're already authenticated.",name:"temporary",type:Boolean},{description:"Read the durable log archive (pipelineLogSink → R2) via R2 SQL instead of tailing live",name:"durable",type:Boolean},{description:"durable: Iceberg table the Pipeline writes to (required with --durable)",name:"table",type:String},{description:"durable: Iceberg namespace (R2 Data Catalog database) the table lives in",name:"namespace",type:String},{description:"durable: lower time bound (epoch-millis or ISO 8601), inclusive",name:"since",type:String},{description:"durable: upper time bound (epoch-millis or ISO 8601), inclusive",name:"until",type:String},{description:"durable: exact severity filter (trace|debug|log|info|warn|error|fatal)",name:"level",type:String},{description:"durable: severity floor — this level and every more-severe one",name:"min-level",type:String},{description:"durable: keep function paths starting with this prefix (LIKE 'prefix%')",name:"function-prefix",type:String},{description:"durable: trace-id filter",name:"trace-id",type:String},{description:"durable: shard-key filter",name:"shard-key",type:String},{description:"durable: user-id filter",name:"user-id",type:String},{description:"durable: max rows (clamped to 1–10000; default 500)",name:"limit",type:String},{description:"durable: resume after a prior page — the ts from its nextCursor",name:"cursor",type:String},{description:"durable: emit one JSON object per line instead of a table",name:"ndjson",type:Boolean}]},G={argument:{description:"generate | create | up | down | status | d1-to-hyperdrive [name|id]",name:"subcommand",type:String},description:"Schema (generate), online data (create | up | down | status), and backend (d1-to-hyperdrive) migrations",examples:[["lunora migrate generate","Diff lunora/schema.ts and emit a SQL migration"],["lunora migrate create add_users_email","Scaffold a data migration"],["lunora migrate up backfill-names","Run a data migration across shards"],["lunora migrate status backfill-names","Report a migration's per-shard status"],["lunora migrate d1-to-hyperdrive --from-url https://old --to-url https://new","Copy .global() data from D1 to Hyperdrive"]],group:"Data",loader:()=>import("../packem_chunks/runMigrateGenerateCommand.mjs").then(e=>({default:e.execute})),name:"migrate",options:[{description:"Migration name slug (e.g. add_users_email)",name:"name",type:String},{description:"Target table for `create` (prompted for interactively when omitted)",name:"table",type:String},{description:"Preview a data migration without rewriting rows",name:"dry-run",type:Boolean},{description:"Rows per batch for a data migration",name:"batch-size",type:Number},{description:"Cap batches processed this run (maps to the runner's maxBatches)",name:"steps",type:Number},{description:"Target production — requires an explicit --url",name:"prod",type:Boolean},{description:"Worker URL (default http://localhost:8787)",name:"url",type:String},{description:"Admin bearer token (prefer LUNORA_ADMIN_TOKEN; --token is visible to other local processes via the process table)",name:"token",type:String},{description:"Required with --prod for up/down — confirms running against production",name:"yes",type:Boolean},{description:"d1-to-hyperdrive: source (D1) worker URL (defaults to --url)",name:"from-url",type:String},{description:"d1-to-hyperdrive: source admin token (defaults to --token / LUNORA_ADMIN_TOKEN)",name:"from-token",type:String},{description:"d1-to-hyperdrive: target (Hyperdrive) worker URL (defaults to --url)",name:"to-url",type:String},{description:"d1-to-hyperdrive: target admin token (defaults to --token / LUNORA_ADMIN_TOKEN)",name:"to-token",type:String},{description:"d1-to-hyperdrive: comma-separated .global() tables to move (default: all global tables)",name:"tables",type:String},{description:"d1-to-hyperdrive: keep the intermediate NDJSON dump at this path",name:"out",type:String}]},Y={description:"Run codegen + binding reconcile + wrangler validation (no Vite) — for CI",examples:[["lunora prepare","Codegen + binding reconcile + validate (CI, before deploy)"]],group:"Deploy",loader:()=>import("../packem_chunks/handler15.mjs").then(e=>({default:e.execute})),name:"prepare",options:[{description:"Override the schema-drift gate (proceed even with breaking schema drift and no migration)",name:"allow-schema-drift",type:Boolean},{description:`Which API spec(s) to emit: ${l} (default openapi)`,name:"api-spec",type:String},{description:"Re-bless the committed schema baseline (lunora/.lunora-schema.json) with the current shape",name:"update-schema-baseline",type:Boolean}]},z={argument:{description:"<add|list|view|build> [item names…]",name:"args",type:String},description:"Component registry: add/list/view items, or build the catalog",examples:[["lunora registry list","List available registry items"],["lunora registry add presence","Scaffold a registry item into lunora/"],["lunora registry build --check","Verify the committed catalog is current"]],group:"Project",loader:()=>import("../packem_chunks/handler16.mjs").then(e=>({default:e.execute})),name:"registry",options:[{description:"add: print the plan and stop without writing",name:"dry-run",type:Boolean},{description:"add: preview the file changes (content diff) and write nothing",name:"diff",type:Boolean},{description:"add: force-overwrite existing files (take the incoming copy)",name:"overwrite",type:Boolean},{description:"add: skip the package.json mutation confirmation prompt",name:"yes",type:Boolean},{description:"Local registry root (offline; expects <name>/ subdirs)",name:"from",type:String},{description:"Override the remote registry source base (e.g. gh:owner/repo/registry)",name:"source",type:String},{description:"Fetch items from a git ref (branch, tag, or commit), e.g. --ref alpha. Overrides the version-derived default",name:"ref",type:String},{description:"Permit --source values outside gh:/github:/https://",name:"allow-unsafe-source",type:Boolean},{description:"Emit JSON output (add plan / list)",name:"json",type:Boolean},{description:"build: output path for the catalog (default <root>/index.json)",name:"out",type:String},{description:"build: verify the index is current instead of rewriting it",name:"check",type:Boolean}]},Q={description:"Clear local Miniflare state (and .lunora-cache with --all)",examples:[["lunora reset","Clear local Miniflare state"],["lunora reset --all","Also remove .lunora-cache"]],group:"Develop",loader:()=>import("../packem_chunks/runResetCommand.mjs").then(e=>({default:e.execute})),name:"reset",options:[{description:"Also remove .lunora-cache",name:"all",type:Boolean},{description:"Skip the confirmation prompt (required when stdin is not a TTY)",name:"yes",type:Boolean}]},X={argument:{description:"install | check",name:"subcommand",type:String},description:"Install the Lunora agent skills (AI rules) into .agents/skills/, or check they're present",examples:[["lunora rules install","Copy the Lunora agent skills into .agents/skills/"],["lunora rules install --overwrite","Reinstall, replacing edited skill files"],["lunora rules check","Report which Lunora skills are installed"],["lunora rules check --strict","Exit non-zero when rules are missing (CI gate)"]],group:"Project",loader:()=>import("../packem_chunks/handler17.mjs").then(e=>({default:e.execute})),name:"rules",options:[{description:"install: overwrite skill files that already exist (default: skip them)",name:"overwrite",type:Boolean},{description:"check: exit non-zero when the rules are missing (for CI gating)",name:"strict",type:Boolean}]},Z={argument:{description:"Function path (e.g. messages:send)",name:"functionPath",type:String},description:"Send a single RPC to a running Lunora Worker",examples:[[`lunora run messages:send --args '{"text":"hi"}'`,"Call a function with JSON args"],["lunora run messages:list --shard channel:demo","Target a specific shard"]],group:"Develop",loader:()=>import("../packem_chunks/runRpcCommand.mjs").then(e=>({default:e.execute})),name:"run",options:[{description:"JSON-encoded args object",name:"args",type:String},{description:"Explicit shard key",name:"shard",type:String},{description:"Worker URL (default http://localhost:8787)",name:"url",type:String}]},ee={description:"Generate deterministic fake data from lunora/schema.ts and bulk-insert it via the worker's admin endpoint",examples:[["lunora seed","Seed every table with the default row count"],["lunora seed --table posts --count 50","Seed 50 posts; FK-parent tables are seeded automatically"],["lunora seed --reset","Wipe local .wrangler/state, then seed from scratch"],["lunora seed --seed 7 --dry-run","Print the NDJSON for seed 7 without inserting"]],group:"Data",loader:()=>import("../packem_chunks/handler18.mjs").then(e=>({default:e.execute})),name:"seed",options:[{description:"Rows per table (default 10)",name:"count",type:Number},{description:"Seed only this table; its FK-parent tables are seeded automatically",name:"table",type:String},{description:"Deterministic seed — same value yields identical rows (default 0)",name:"seed",type:Number},{description:"Print the generated NDJSON instead of inserting",name:"dry-run",type:Boolean},{description:"Wipe local .wrangler/state before seeding (local dev only)",name:"reset",type:Boolean},{description:"Rows per HTTP request (default 500)",name:"batch-size",type:Number},{description:"Target production — requires an explicit --url",name:"prod",type:Boolean},{description:"Worker URL (default http://localhost:8787)",name:"url",type:String},{description:"Admin bearer token (prefer LUNORA_ADMIN_TOKEN; --token is visible to other local processes via the process table)",name:"token",type:String},{description:"Skip the confirmation prompt when seeding a non-local/production target",name:"yes",type:Boolean}]},te={description:"Validate wrangler.jsonc + codegen dry-run + tsc --noEmit (no files written)",examples:[["lunora verify","Validate wrangler + codegen + tsc"],["lunora verify --no-typecheck","Skip the TypeScript type-check"],["lunora verify --health-url https://my-app.workers.dev","Also probe the deployment's /_lunora/health"]],group:"Deploy",loader:()=>import("../packem_chunks/handler19.mjs").then(e=>({default:e.execute})),name:"verify",options:[{description:"Treat breaking schema drift as a warning instead of a failure",name:"allow-schema-drift",type:Boolean},{description:`Which API spec(s) to emit: ${l} (default openapi)`,name:"api-spec",type:String},{description:"Output format: pretty (default) or json",name:"format",type:String},{description:"Probe this deployment's /_lunora/health endpoint (off by default; keeps verify offline-safe)",name:"health-url",type:String},{description:"Skip the TypeScript type-check step",name:"no-typecheck",type:Boolean}]},re={description:"Open the Lunora studio in your browser (local dev by default, --remote for production)",examples:[["lunora view","Open the studio for local dev"],["lunora view --remote","Open the deployed studio"]],group:"Project",loader:()=>import("../packem_chunks/handler20.mjs").then(e=>({default:e.execute})),name:"view",options:[{description:"Open the deployed worker URL instead of localhost",name:"remote",type:Boolean}]},oe={filterStacktrace:()=>!1,hideErrorCodeView:!0},ne=(e,t={})=>{const r=e instanceof Error?e.message:String(e),o=k(m(e)?{code:e.code,hint:e.hint,message:r}:r),n=new R({hint:o===void 0?void 0:S(o).split(`
2
+ `),message:t.reason===void 0?r:`${t.reason}: ${r}`,name:e instanceof Error&&e.name.length>0?e.name:"Error"});return n.stack="",A(n,oe)},ae=(e,t)=>{const r=Array.from({length:t.length+1},(o,n)=>n);for(let o=1;o<=e.length;o+=1){let n=r[0]??0;r[0]=o;for(let a=1;a<=t.length;a+=1){const i=r[a]??0,s=e[o-1]===t[a-1]?0:1;r[a]=Math.min((r[a-1]??0)+1,i+1,n+s),n=i}}return r[t.length]??0},ie=(e,t)=>{let r,o=Number.POSITIVE_INFINITY;for(const a of t){const i=ae(e,a);i<o&&(o=i,r=a)}const n=Math.max(2,Math.ceil(e.length/3));return r!==void 0&&o<=n?r:void 0},se="https://registry.npmjs.org/@lunora/cli/latest",le=1440*60*1e3,pe=1500,de="0.0.0",ce=/^v/u,c=e=>{const t=e.trim().replace(ce,"").split("-")[0]??"",[r,o,n]=t.split(".").map(a=>{const i=Number.parseInt(a,10);return Number.isFinite(i)?i:0});return[r??0,o??0,n??0]},ue=(e,t)=>{const r=c(e),o=c(t);for(let n=0;n<3;n+=1)if((r[n]??0)!==(o[n]??0))return(r[n]??0)>(o[n]??0)?1:-1;return 0},me=(e,t)=>ue(t,e)>0,ge=(e,t,r)=>t-e<r,he=(e,t)=>`Update available for @lunora/cli: ${e} → ${t} — run \`pnpm add -D @lunora/cli@latest\``,h=e=>d(e,"lunora-cli-update.json"),ye=e=>{const t=e.XDG_CACHE_HOME&&e.XDG_CACHE_HOME.length>0?e.XDG_CACHE_HOME:d(B(),".cache"),r=d(t,"lunora");try{f(r,{mode:448,recursive:!0})}catch{}return r},fe=e=>{try{const t=JSON.parse(u(h(e),"utf8"));if(t!==null&&typeof t=="object"){const{checkedAt:r,latest:o}=t;if(typeof o=="string"&&typeof r=="number")return{checkedAt:r,latest:o}}}catch{}},ve=(e,t)=>{try{const r=h(e);try{if(v(r).isSymbolicLink())return}catch{}b(r,`${JSON.stringify(t)}
3
+ `,"utf8")}catch{}},be=async e=>{try{const t=await e(se,{signal:AbortSignal.timeout(pe)});if(!t.ok)return;const r=await t.json(),o=r!==null&&typeof r=="object"?r.version:void 0;return typeof o=="string"?o:void 0}catch{return}},ke=(e,t,r)=>e===de||!r||t.CI!==void 0||t.LUNORA_NO_UPDATE_NOTIFIER!==void 0,Se=async e=>{const t=e.env??process.env,r=e.isTTY??process.stdout.isTTY;if(ke(e.current,t,r))return;const o=e.cacheDir??ye(t),n=(e.now??Date.now)(),a=e.ttlMs??le,i=fe(o);let s=i?.latest;if(i===void 0||!ge(i.checkedAt,n,a)){const p=await be(e.fetchImpl??globalThis.fetch);p!==void 0&&(s=p,ve(o,{checkedAt:n,latest:p}))}s!==void 0&&me(e.current,s)&&e.logger.warn(he(e.current,s))},we=["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"],xe=()=>{try{const e=JSON.parse(u(new URL("../package.json",import.meta.url),"utf8")),t=e!==null&&typeof e=="object"?e.version:void 0;return typeof t=="string"&&t.length>0?t:"0.0.0"}catch{return"0.0.0"}},y=xe(),Oe=[q,D,$,j,C,_,T,Y,F,I,V,Z,H,Q,G,M,J,ee,E,te,K,P,W,L,re,U,z,X],Ne=e=>{const t={value:0},r=x("lunora",{argv:e.argv===void 0?void 0:[...e.argv],cwd:e.cwd,exit:o=>{t.value=typeof o=="number"?o:0},logger:e.logger,packageName:"@lunora/cli",packageVersion:y});for(const o of Oe)r.addCommand(o);return r.addCommand(N),r.addCommand(O),{cli:r,exitCode:t}},Re=/Command "(?<name>[^"]+)" not found/u,Ae=e=>{const t=g(),r=e instanceof Error?e.message:String(e),o=Re.exec(r);if(!o?.groups){m(e)||w(r)!==void 0?t.error(ne(e)):t.error(r);return}const n=o.groups.name??"",a=ie(n,we);t.error(`Unknown command "${n}".${a===void 0?"":` Did you mean "${a}"?`}`),t.info("Run `lunora --help` to list commands, or `lunora docs` to open the documentation.")},Ue=async(e={})=>{const{cli:t,exitCode:r}=Ne(e);try{await t.run({shouldExitProcess:!1})}catch(o){return Ae(o),1}return await Se({current:y,logger:g()}),r.value};export{we as COMMANDS,y as VERSION,Ue as runCli};
@@ -0,0 +1,8 @@
1
+ import{createWriteStream as T,createReadStream as x}from"node:fs";import{unlink as k,stat as I}from"node:fs/promises";import{LunoraError as S}from"@lunora/errors";import{a as O}from"./admin-url-DfVehV3e.mjs";const A="/_lunora/admin/export",E="/_lunora/admin/import",_=500,L=r=>{if(r===void 0)return;const t=r.split(",").map(o=>o.trim()).filter(o=>o.length>0);return t.length>0?t:void 0},N=async(r,t)=>{r.write(t)||await new Promise(o=>{r.once("drain",o)})},R=async(r,t)=>{const o=r.getReader(),u=new TextDecoder;let s=0,g=0,e="",a=!1;try{for(;!a;){const c=await o.read();if(a=c.done,c.value===void 0)continue;s+=c.value.length,e+=u.decode(c.value,{stream:!0});let l=e.indexOf(`
2
+ `);for(;l!==-1;){g+=1;const n=`${e.slice(0,l)}
3
+ `;await N(t,n),e=e.slice(l+1),l=e.indexOf(`
4
+ `)}}return e.length>0&&(g+=1,await N(t,`${e}
5
+ `)),{bytes:s,rows:g}}finally{o.releaseLock()}},P=async(r,t)=>{if(t!==void 0){r.destroy();try{await k(t)}catch{}}},M=async r=>{if(r.prod&&r.url===void 0)return r.logger.error("--prod requires an explicit --url (refusing to export from the implicit localhost worker)"),{bytes:0,code:1,rows:0};const t=r.token??process.env.LUNORA_ADMIN_TOKEN;if(!t)return r.logger.error("admin token required — pass --token or set LUNORA_ADMIN_TOKEN"),{bytes:0,code:1,rows:0};const o=O(r.url,r.logger);if(o===void 0)return{bytes:0,code:1,rows:0};const u=`${o}${A}`,s=L(r.tables),g=r.fetchImpl??globalThis.fetch;if(typeof g!="function")throw new TypeError("no fetch implementation available — pass fetchImpl or run on Node >= 18");r.logger.info(`POST ${u} -> export${s?` (tables: ${s.join(",")})`:""}`);const e=await g(u,{body:JSON.stringify(s?{tables:s}:{}),headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},method:"POST"});if(!e.ok){const d=await e.text();return r.logger.error(`export failed: HTTP ${String(e.status)}: ${d}`),{bytes:0,code:1,rows:0}}if(!e.body)return r.logger.error("export response carried no body"),{bytes:0,code:1,rows:0};const a=r.out===void 0||r.out==="-"?void 0:r.out,c=a===void 0?process.stdout:T(a,{encoding:"utf8"});let l,n;try{({bytes:l,rows:n}=await R(e.body,c))}catch(d){throw await P(c,a),d}return a!==void 0&&(await new Promise((d,w)=>{c.end(h=>{h?w(h):d()})}),r.logger.success(`wrote ${String(n)} rows to ${a} (${String(l)} bytes)`)),{bytes:l,code:0,rows:n}},U=async r=>{if(r.prod&&r.url===void 0){r.logger.error("--prod requires an explicit --url (refusing to import to the implicit localhost worker)");return}if(r.prod&&r.yes!==!0){r.logger.error("import --prod bulk-writes production. Re-run with --yes to confirm.");return}const t=r.token??process.env.LUNORA_ADMIN_TOKEN;if(!t){r.logger.error("admin token required — pass --token or set LUNORA_ADMIN_TOKEN");return}try{if(!(await I(r.file)).isFile()){r.logger.error(`not a file: ${r.file}`);return}}catch(s){const g=s instanceof Error?s.message:String(s);r.logger.error(`failed to stat ${r.file}: ${g}`);return}const o=O(r.url,r.logger);if(o===void 0)return;const u=r.fetchImpl??globalThis.fetch;if(typeof u!="function")throw new TypeError("no fetch implementation available — pass fetchImpl or run on Node >= 18");return{fetchImpl:u,requestUrl:`${o}${E}`,token:t}},C=async r=>{const t=await U(r);if(t===void 0)return{body:void 0,code:1,inserted:0};const{fetchImpl:o,requestUrl:u,token:s}=t,g=r.batchSize??_;r.logger.info(`POST ${u} -> import ${r.file}`);const e=x(r.file,{encoding:"utf8"}),a={},c=[];let l=0,n="",d=[],w=0;const h=async()=>{if(d.length===0)return;const p=d.join(`
6
+ `);d=[];const f=await o(u,{body:p,headers:{authorization:`Bearer ${s}`,"content-type":"application/x-ndjson"},method:"POST"});if(!f.ok){const m=await f.text().catch(()=>"<no body>");throw new S("INTERNAL",`import batch failed (HTTP ${String(f.status)}): ${m}`)}const i=await f.json();if(i.inserted)for(const[m,y]of Object.entries(i.inserted))a[m]=(a[m]??0)+y;Array.isArray(i.errors)&&c.push(...i.errors),typeof i.conflicts=="number"&&(l+=i.conflicts)},b=p=>{const f=p.trim();if(f.length===0)return;if(w+=1,r.table===void 0){d.push(f);return}let i;try{i=JSON.parse(f)}catch(m){const y=m instanceof Error?m.message:String(m);throw new S("INTERNAL",`invalid JSON on line ${String(w)}: ${y}`,{cause:m})}d.push(JSON.stringify({doc:i,table:r.table}))};for await(const p of e){const f=typeof p=="string"?p:p.toString("utf8");n+=f;let i=n.indexOf(`
7
+ `);for(;i!==-1;)b(n.slice(0,i)),n=n.slice(i+1),i=n.indexOf(`
8
+ `),d.length>=g&&await h()}n.length>0&&b(n),await h();const $=Object.values(a).reduce((p,f)=>p+f,0),v={conflicts:l,errors:c,inserted:a};return r.logger.info(JSON.stringify(v,void 0,2)),r.logger.success(`imported ${String($)} rows (${String(l)} conflicts, ${String(c.length)} errors)`),{body:v,code:c.length>0?1:0,inserted:$}};export{_ as DEFAULT_IMPORT_BATCH_SIZE,M as runExportCommand,C as runImportCommand};
@@ -0,0 +1 @@
1
+ const n=new Set(["127.0.0.1","::1","[::1]","localhost"]),s=/\/$/u,a=(r,e)=>{const o=r??"http://localhost:8787";let t;try{t=new URL(o)}catch{e.error(`invalid --url: ${o}`);return}if(!n.has(t.hostname)&&t.protocol!=="https:"){e.error(`refusing to send the admin bearer over ${t.protocol}// to ${t.hostname} — use https for non-localhost targets`);return}return o.replace(s,"")};export{a};
@@ -0,0 +1 @@
1
+ import{LunoraError as r}from"@lunora/errors";const o=["both","none","openapi","openrpc"],p=o.join(" | "),i=n=>{if(!(typeof n!="string"||n.length===0)){if(o.includes(n))return n;throw new r("INTERNAL",`invalid --api-spec "${n}" — expected one of: ${p}`)}};export{p,i as r};
@@ -0,0 +1 @@
1
+ import{existsSync as a,readFileSync as n,readdirSync as m,statSync as p}from"node:fs";import{join as o}from"@visulima/path";import l from"./parseManifest-x3WsxKHz.mjs";const d=/[\u0000-\u001F\u007F-\u009F]/gu,s=t=>t===void 0?void 0:t.replaceAll(d,""),c=t=>m(t).filter(r=>{const e=o(t,r);return p(e).isDirectory()&&a(o(e,"registry.json"))}),S=t=>{const r=o(t,"index.json");if(a(r)){const e=JSON.parse(n(r,"utf8"));if(Array.isArray(e.items))return e.items.filter(i=>typeof i=="object"&&i!==null&&typeof i.name=="string").map(i=>({description:s(i.description),name:s(i.name)??i.name}))}return c(t).map(e=>{const i=JSON.parse(n(o(t,e,"registry.json"),"utf8"));return{description:s(i.description),name:e}})},g=t=>({items:c(t).map(r=>{const e=l(JSON.parse(n(o(t,r,"registry.json"),"utf8")),r);return{...e.description===void 0?{}:{description:e.description},name:e.name,...e.title===void 0?{}:{title:e.title}}}).toSorted((r,e)=>r.name.localeCompare(e.name))});export{g as buildRegistryIndex,S as collectCatalog,c as listItemDirectories};
@@ -0,0 +1,3 @@
1
+ import{findLunoraSolution as n}from"@lunora/codegen";import{VisulimaError as a,renderError as s}from"@visulima/error";const d=r=>r.body.split(`
2
+ `).filter(e=>!e.startsWith("```")).join(`
3
+ `).replaceAll(/\*\*(.+?)\*\*/gu,"$1").replaceAll(/`([^`]+)`/gu,"$1"),l={filterStacktrace:()=>!1,hideErrorCodeView:!0},m=(r,e)=>{const o=r instanceof Error?r.message:String(r),t=n(o),i=new a({hint:t?[t.header,"",d(t)]:void 0,message:e===void 0?`codegen failed: ${o}`:`codegen failed (${e}): ${o}`,name:"CodegenError"});return i.stack="",s(i,l)},u=r=>{const e=n(r);if(e===void 0)return;const o=new a({hint:[d(e)],message:e.header,name:"Hint"});return o.stack="",s(o,l)};export{u as c,m as l};
@@ -0,0 +1 @@
1
+ import{createLogger as s}from"./createLogger--C3x1FNE.mjs";import{P as c,a}from"./prompt-cancelled-C8Sj7OqI.mjs";const p=t=>async r=>{const e=s();try{const{code:o}=await t({argument:r.argument,cwd:r.process.cwd,logger:e,options:r.options});r.process.exit(o)}catch(o){if(o instanceof c){r.process.exit(a);return}e.error(o instanceof Error?o.message:String(o)),r.process.exit(1)}};export{p as i};
@@ -0,0 +1,19 @@
1
+ import{existsSync as g,readFileSync as m,writeFileSync as h,mkdirSync as k,mkdtempSync as ee,rmSync as O}from"node:fs";import{dirname as w,join as l,relative as P}from"@visulima/path";import{DEV_VARS_FILE as te,parseDevVariableEntries as re,findWranglerFile as ne,readWranglerJsonc as oe}from"@lunora/config";import{modify as q,applyEdits as L,parse as se}from"jsonc-parser";import{fileURLToPath as ie}from"node:url";import{LunoraError as v}from"@lunora/errors";import{i as ae}from"./tui-prompts-CCt3jm1k.mjs";import{collectCatalog as ce,buildRegistryIndex as ue}from"./buildRegistryIndex-DwySASBu.mjs";import{insertSchemaExtension as fe}from"./insertSchemaExtension-DZReBZ4_.mjs";import{createHash as de}from"node:crypto";import{tmpdir as le}from"node:os";import{downloadTemplate as pe}from"giget";import ge from"./parseManifest-x3WsxKHz.mjs";const me="alpha",W="main",$e=new Set(["alpha","beta","next"]),he=/^[\w./@-]+$/,ye=e=>!e.includes("..")&&he.test(e),z=()=>{try{let e=w(ie(import.meta.url));for(let t=0;t<6;t+=1){const r=l(e,"package.json");if(g(r)){const o=JSON.parse(m(r,"utf8"));if(o.name==="@lunora/cli"&&typeof o.version=="string")return o.version}const n=w(e);if(n===e)break;e=n}}catch{}return"0.0.0"},M=e=>{if(e==="0.0.0")return me;const t=e.split("+")[0]??e,r=t.indexOf("-");if(r!==-1){const[n]=t.slice(r+1).split(".");if(n!==void 0&&$e.has(n))return n}return W},U=e=>{if(e!==void 0&&e.length>0){if(!ye(e))throw new v("INTERNAL",`invalid --ref "${e}" — a ref may contain letters, digits, ".", "_", "-", "/", "@" and must not contain "..".`);return e}return M(z())},j="anolilab/lunora",V=/^[0-9a-f]{40}$/iu,B=String.raw`\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)+)?(?:\+[0-9A-Za-z.-]+)?`,ve=new RegExp(String.raw`^v?${B}$`,"u"),we=new RegExp(String.raw`^(?:@[\w.-]+\/)?[\w.-]+@${B}$`,"u"),be=e=>V.test(e)||ve.test(e)||we.test(e),Se=()=>{const e=process.env.GITHUB_TOKEN??process.env.GH_TOKEN;return e!==void 0&&e.length>0?{authorization:`Bearer ${e}`}:{}},ke=async e=>{try{const t=await fetch(`https://api.github.com/repos/${j}/commits/${encodeURIComponent(e)}`,{headers:{accept:"application/vnd.github+json","user-agent":"lunora-cli",...Se()},signal:AbortSignal.timeout(1e4)});if(!t.ok)return;const r=await t.json();return typeof r.sha=="string"&&V.test(r.sha)?r.sha:void 0}catch{return}},je=async(e,t)=>{const r=U(e);if(be(r))return r;const n=await ke(r);return n===void 0?(t.warn(`could not pin ${j}#${r} to a commit — fetching the UNPINNED branch (set GITHUB_TOKEN if rate-limited).`),r):(t.info(`pinned ${j}#${r} → ${n}`),n)},xe="latest",Ne=(e=z())=>{const t=M(e);return t===W?xe:t},Oe="https://registry.npmjs.org",Re=()=>{const e=process.env.npm_config_registry,t=e!==void 0&&e.length>0?e:Oe;return t.endsWith("/")?t.slice(0,-1):t},Ae=async(e,t)=>{try{const r=await fetch(`${Re()}/${e.replaceAll("/","%2F")}`,{headers:{accept:"application/vnd.npm.install-v1+json"},signal:AbortSignal.timeout(1e4)});return r.ok?(await r.json())["dist-tags"]?.[t]:void 0}catch{return}},kt=async(e,t)=>{const r=new Map;return await Promise.all([...new Set(e)].map(async n=>{const o=await Ae(n,t);o!==void 0&&r.set(n,o)})),r},Ee=e=>{if(!e.startsWith("workspace:"))return e;const t=e.slice(10);return t===""||t==="*"||t==="^"||t==="~"?Ne():t},Te=new Set(["@lunora/client","@lunora/do","@lunora/ratelimit","@lunora/runtime","@lunora/server","@lunora/values"]),_e=/(['"])@lunora\/(client|do|ratelimit|runtime|server|values)(\/[^'"]*)?\1/gu,Je=e=>{const t=l(e,"package.json");if(!g(t))return!1;try{const r=JSON.parse(m(t,"utf8"));return r.dependencies?.lunorash!==void 0||r.devDependencies?.lunorash!==void 0}catch{return!1}},De=e=>e.replaceAll(_e,(t,r,n,o)=>`${r}lunorash/${n}${o??""}${r}`),R=(e,t,r,n="dependencies",o=!1)=>{const s=Object.entries(e);if(s.length===0)return[];const c=l(t,"package.json");if(!g(c))return r.warn(`package.json not found at ${c} — skipping dependency updates`),[];let a=m(c,"utf8");const i=JSON.parse(a),u=[];for(const[f,d]of s){if(o&&Te.has(f)){r.info(`dep provided by the lunorash umbrella, skipping: ${f}`);continue}if(i.dependencies?.[f]!==void 0||i.devDependencies?.[f]!==void 0){r.info(`dep already present: ${f}`);continue}const p=q(a,[n,f],Ee(d),{formattingOptions:{insertSpaces:!0,tabSize:4}});a=L(a,p),u.push(f)}return u.length>0&&(h(c,a,"utf8"),r.success(`added ${String(u.length)} ${n==="devDependencies"?"devDependency(ies)":"dependency(ies)"} to package.json: ${u.join(", ")}`)),u},Ie=(e,t,r)=>{if(e.length===0)return[];const n=l(t,te),o=g(n)?m(n,"utf8"):"",s=new Set(re(o).map(u=>u.key)),c=[],a=[],i=[];for(const u of e)u.secret&&a.push(u.name),!s.has(u.name)&&(u.description&&i.push(`# ${u.description}`),i.push(`${u.name}=${u.secret?"":u.value??""}`),c.push(u.name));if(c.length>0){const u=o===""||o.endsWith(`
2
+ `)?o:`${o}
3
+ `;h(n,`${u}${i.join(`
4
+ `)}
5
+ `,"utf8"),r.success(`scaffolded ${String(c.length)} env var(s) into .dev.vars: ${c.join(", ")}`)}return a.length>0&&r.info(`set secret value(s) locally in .dev.vars, then for production: ${a.map(u=>`wrangler secret put ${u}`).join("; ")}`),c},A=new Set(["ai","analytics_engine_datasets","browser","d1_databases","durable_objects","hyperdrive","kv_namespaces","mtls_certificates","queues","r2_buckets","send_email","services","vars","vectorize","version_metadata","workflows"]),Pe=(e,t,r)=>{if(e.length===0)return[];const n=["wrangler.jsonc","wrangler.json"].map(i=>l(t,i)).find(i=>g(i));if(!n)return r.warn("wrangler.jsonc not found — skipping binding updates"),[];let o=m(n,"utf8");const s=[],c=i=>Array.isArray(i),a=i=>{let u=se(o);for(const f of i){if(typeof u!="object"||u===null)return;u=u[f]}return u};for(const i of e){const u=i.path[0];if(u===void 0||!A.has(u)){r.warn(`skipping binding "${i.path.join(".")}" — only resource bindings (${[...A].join(", ")}) may be written, not exec/entrypoint keys`);continue}let{value:f}=i;if(c(f)){const p=a(i.path);if(c(p)){const $=new Set(p.map(y=>JSON.stringify(y)));f=[...p,...f.filter(y=>!$.has(JSON.stringify(y)))]}}const d=q(o,[...i.path],f,{formattingOptions:{insertSpaces:!0,tabSize:4}});d.length!==0&&(o=L(o,d),s.push(i.path.join(".")))}return s.length>0&&(h(n,o,"utf8"),r.success(`applied ${String(s.length)} binding(s) to ${n}: ${s.join(", ")}`)),s},qe=(e,t,r,n=!1)=>{const o=[],s=[];return e.deps&&o.push(...R(e.deps,t,r,"dependencies",n)),e.devDependencies&&o.push(...R(e.devDependencies,t,r,"devDependencies",n)),e.bindings&&s.push(...Pe(e.bindings,t,r)),e.envVars&&Ie(e.envVars,t,r),{bindings:s,deps:o}},Le=async(e,t)=>{const r=e.some(({manifest:i})=>Object.keys(i.deps??{}).length>0||Object.keys(i.devDependencies??{}).length>0),n=e.some(({manifest:i})=>(i.bindings??[]).length>0),o=t.source!==void 0&&t.source.length>0;if(!r&&!n&&!o||t.yes)return!0;const s=[];r&&s.push("add dependencies to package.json"),n&&s.push("write wrangler.jsonc bindings"),o&&s.push(`come from a non-default source (${String(t.source)})`);const c=s.join(", ");if(!process.stdin.isTTY&&t.confirm===void 0)return t.logger.error(`add: stdin is not a TTY and the requested items ${c} — re-run with --yes to confirm`),!1;const a=await(t.confirm??ae)(`The requested items ${c}. Continue?`);return a||t.logger.info("add: aborted"),a},S=1,We=".lunora-registry.json",F=e=>l(e,"lunora",We),ze=e=>typeof e!="object"||e===null||!("items"in e)?!1:typeof e.items=="object"&&e.items!==null,x=e=>de("sha256").update(e).digest("hex"),Me=e=>{const t=F(e);if(!g(t))return{items:{},version:S};try{const r=JSON.parse(m(t,"utf8"));if(ze(r))return{items:r.items,version:S}}catch{}return{items:{},version:S}},Ue=(e,t)=>{h(F(e),`${JSON.stringify(t,void 0,2)}
6
+ `,"utf8")},E=(e,t,r,n)=>{const o=e.items[t],s=o??{files:{}};o===void 0&&(e.items[t]=s),s.files[r]=x(n)},Ve=(e,t,r)=>e.items[t]?.files[r],T=e=>e===""?[]:e.split(`
7
+ `),Be=(e,t)=>{const r=T(e),n=T(t);let o=0;for(;o<r.length&&o<n.length&&r[o]===n[o];)o+=1;let s=r.length,c=n.length;for(;s>o&&c>o&&r[s-1]===n[c-1];)s-=1,c-=1;if(o===s&&o===c)return[];const a=[];for(let i=Math.max(0,o-3);i<o;i+=1)a.push(` ${r[i]??""}`);for(let i=o;i<s;i+=1)a.push(`- ${r[i]??""}`);for(let i=o;i<c;i+=1)a.push(`+ ${n[i]??""}`);for(let i=c;i<Math.min(n.length,c+3);i+=1)a.push(` ${n[i]??""}`);return a},Fe=/\.[cm]?[jt]sx?$/u,H=(e,t,r)=>{const n=m(l(e,t.from),"utf8");return r&&Fe.test(t.to)?De(n):n},He=(e,t,r,n,o,s,c)=>{const a=l(n,"lunora","schema.ts");if(s)return o.info(`~ would merge .extend(${t}.extension) into lunora/schema.ts (and create ${e.to} if absent)`),{kind:"skipped",path:a};const i=l(n,e.to);g(i)||(k(w(i),{recursive:!0}),h(i,H(r,e,c),"utf8"));const u=c?"lunorash/server":"@lunora/server",f=g(a)?m(a,"utf8"):`import { defineSchema } from "${u}";
8
+
9
+ export const schema = defineSchema({});
10
+ `,d=fe(f,t);if(d.ok)return k(w(a),{recursive:!0}),h(a,d.text,"utf8"),o.success(`merged .extend(${t}.extension) into lunora/schema.ts`),{kind:"written",path:a};if(d.reason==="already-applied")return o.warn(`lunora/schema.ts already extends "${t}" — skipping`),{kind:"skipped",path:a};throw d.reason==="invalid-identifier"?new v("INTERNAL",`schema-extension item "${t}" is not a valid JS identifier — it is spliced into lunora/schema.ts as \`import { ${t} }\` / \`.extend(${t}.extension)\`. Rename the item to a valid identifier (no leading digit, no "-").`):new v("INTERNAL",`schema-extension merge failed for "${t}": ${d.reason}`)},Ge=(e,t,r,n,o)=>{const s=Be(t,r);if(s.length===0){o.info(`= ${e.to} (unchanged)`);return}o.info(`${n?"~":"+"} ${e.to}`);for(const c of s)o.info(` ${c}`)},Ze=(e,t,r,n,o,s,c,a)=>{const i=l(n,e.to),u=H(r,e,a),f=g(i),d=f?m(i,"utf8"):"",p=X=>(k(w(i),{recursive:!0}),h(i,u,"utf8"),E(s,t,e.to,u),o.success(`${X}: ${e.to}`),{kind:"written",path:i});if(c.diff)return Ge(e,d,u,f,o),{kind:"skipped",path:i};if(!f)return p("write");const $=x(d);if($===x(u))return E(s,t,e.to,u),o.warn(`skip (exists): ${e.to}`),{kind:"skipped",path:i};if(c.overwrite)return p("overwrite");const y=Ve(s,t,e.to);return y===void 0?(o.warn(`skip (exists, untracked): ${e.to} — refusing to overwrite a file lunora didn't add (use --overwrite to force)`),{kind:"skipped",path:i}):y===$?p("update"):(h(`${i}.new`,u,"utf8"),o.warn(`conflict: ${e.to} has local edits and an upstream update — wrote ${e.to}.new (use --overwrite to take theirs)`),{kind:"skipped",path:i})},Ce=(e,t,r,n,o,s,c={},a=!1)=>e.merge==="schema-extension"?He(e,t,r,n,o,c.diff===!0,a):Ze(e,t,r,n,o,s,c,a),_=["src/server.ts","src/server/index.ts","src/server/index.tsx","src/index.ts","src/worker.ts"],Ke=e=>{const t=ne(e);if(t===void 0)return;const{parsed:r}=oe(t);return typeof r?.main=="string"?r.main:void 0},Ye=e=>{const t=Ke(e),r=t===void 0?_:[t,..._];for(const n of r){const o=l(e,n);if(!g(o))continue;const s=m(o,"utf8");if(!s.includes("createShardDO(")){if(n===t)break;continue}return{entryPath:o,main:n,source:s}}},Qe=(e,t,r)=>{const n=P(w(e),l(t,"lunora",r)).replaceAll("\\","/");return n.startsWith(".")?n:`./${n}`},Xe=(e,t)=>{for(const r of e){const n=`Add \`export * from "${`./lunora/${r.module}.js`}"\` to your worker entry`,o=r.comment?` (${r.comment})`:"";t.warn(`${n}${o}`)}return 0},et=(e,t,r,n)=>{const o=[];for(const s of e){const c=Qe(t,r,s.module),a=c.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);new RegExp(String.raw`export\s+\*\s+from\s+["']${a}\.js["']`,"u").test(n)||(s.comment&&o.push(`
11
+ // ${s.comment}`),o.push(`export * from "${c}.js";`))}return o},tt=(e,t,r,n)=>{if(e.length===0)return 0;const o=Ye(t);if(o===void 0)return Xe(e,r);const s=et(e,o.entryPath,t,o.source);if(s.length===0)return 0;if(n){for(const a of s)a!==""&&r.info(`~ entrypoint: ${a}`);return s.length}const c=o.source.endsWith(`
12
+ `)?"":`
13
+ `;return h(o.entryPath,`${o.source}${c}${s.join(`
14
+ `)}
15
+ `,"utf8"),r.success(`wrote ${String(s.length)} entrypoint re-export(s) to ${P(t,o.entryPath)}`),s.length},J=(e,t,r,n={})=>{const o=[],s=[],c=[],a=[],i=Me(t),u=Je(t);for(const{directory:f,manifest:d}of e){for(const $ of d.files){const y=Ce($,d.name,f,t,r,i,n,u);(y.kind==="written"?o:s).push(y.path)}if(d.entrypointReexports!==void 0&&tt(d.entrypointReexports,t,r,n.diff===!0),n.diff)continue;const p=qe(d,t,r,u);c.push(...p.deps),a.push(...p.bindings)}return!n.diff&&Object.keys(i.items).length>0&&Ue(t,i),{bindings:a,deps:c,skipped:s,written:o}},G="gh:anolilab/lunora/registry",D=/^[A-Za-z0-9][\w-]*$/u,rt=e=>{if(!D.test(e))throw new v("INTERNAL",`invalid registry item name "${e}" — names must match ${D.source} (letters, digits, "-", "_"; no path separators or "..")`)},nt=e=>e.includes("..")?!1:e.startsWith("gh:")||e.startsWith("github:")||e.startsWith("https://"),ot=e=>e.from===void 0&&e.source!==void 0&&e.source.length>0&&!e.allowUnsafeSource&&!nt(e.source),N=(e,t)=>ot(t)?`${e}: refusing --source ${String(t.source)} — only gh:, github:, or https:// sources are allowed (and may not contain ".."). Re-run with --allow-unsafe-source if you really want this.`:void 0,Z=async(e,t,r)=>{const n=ee(l(le(),`lunora-${t}-fetch-`)),o=l(n,t);r.info(`fetching ${e}`);try{const s=await pe(e,{cwd:n,dir:o,force:!0,install:!1,silent:!0});return r.info(s.commit?`resolved ${s.source} @ ${s.commit}`:`resolved ${s.source}`),{cleanup:()=>{O(n,{force:!0,recursive:!0})},directory:o}}catch(s){throw O(n,{force:!0,recursive:!0}),s}},I=new WeakMap,C=async e=>{const t=I.get(e);if(t!==void 0)return t;const r=e.source!==void 0&&e.source.length>0?Promise.resolve(U(e.ref)):je(e.ref,e.logger);return I.set(e,r),r},K=async(e,t)=>{if(rt(e),t.from!==void 0){const n=l(t.from,e);if(!g(n))throw new v("INTERNAL",`registry item not found in local source: ${n}`);return{cleanup:()=>{},directory:n}}const r=t.source??G;return Z(`${r}/${e}#${await C(t)}`,"item",t.logger)},st=async e=>{if(e.from!==void 0){if(!g(e.from))throw new v("INTERNAL",`registry root not found: ${e.from}`);return{cleanup:()=>{},root:e.from}}const t=e.source??G,{cleanup:r,directory:n}=await Z(`${t}#${await C(e)}`,"registry",e.logger);return{cleanup:r,root:n}},Y=(e,t)=>{const r=JSON.parse(m(l(e,"registry.json"),"utf8"));return ge(r,t)},it=async(e,t)=>{const r=[],n=[],o=new Set,s=new Set,c=async a=>{if(o.has(a))return;if(s.has(a))throw new v("INTERNAL",`cyclic registry dependency detected at "${a}"`);s.add(a);const{cleanup:i,directory:u}=await K(a,t);n.push(i);const f=Y(u,a);for(const d of f.requires??[])await c(d);s.delete(a),o.add(a),r.push({directory:u,manifest:f})};try{for(const a of e)await c(a)}catch(a){for(const i of n)i();throw a}return{cleanups:n,items:r}},b=()=>({bindings:[],code:0,deps:[],skipped:[],written:[]}),jt=(e,t,r,n,o)=>e.bindings?{...e,bindings:e.bindings.map(s=>{if(s.path[0]!==t||!Array.isArray(s.value))return s;const c=s.value;return{...s,value:c.map(a=>typeof a=="object"&&a!==null&&a[r.key]===r.value?{...a,[n]:o}:a)}})}:e,Q=(e,t)=>{const r=t.title??t.description;e.info(`plan: ${t.name}${r?` — ${r}`:""}`);for(const n of t.files)e.info(` file ${n.to} (${n.merge})`);for(const[n,o]of Object.entries(t.deps??{}))e.info(` dep ${n}@${o}`);for(const[n,o]of Object.entries(t.devDependencies??{}))e.info(` dev ${n}@${o}`);for(const n of t.bindings??[])e.info(` bind ${n.path.join(".")} = ${JSON.stringify(n.value)}`);for(const n of t.envVars??[]){const o=n.secret?" (secret)":` = ${JSON.stringify(n.value??"")}`;e.info(` env ${n.name}${o}`)}for(const n of t.entrypointReexports??[]){const o=`./lunora/${n.module}`,s=n.comment?` // ${n.comment}`:"";e.info(` entry ${o}${s}`)}},at=e=>{const t=e.map(({manifest:r})=>({bindings:(r.bindings??[]).map(n=>({path:n.path.join("."),value:n.value})),deps:Object.keys(r.deps??{}),devDependencies:Object.keys(r.devDependencies??{}),entrypointReexports:(r.entrypointReexports??[]).map(n=>({module:n.module,...n.comment?{comment:n.comment}:{}})),envVars:(r.envVars??[]).map(n=>({name:n.name,...n.secret?{secret:!0}:{value:n.value??""}})),files:r.files.map(n=>({merge:n.merge,to:n.to})),name:r.name,requires:r.requires??[],title:r.title}));process.stdout.write(`${JSON.stringify({items:t},void 0,2)}
16
+ `)},ct=(e,t,r,n,o)=>{o.success(`add complete: ${String(r)} written, ${String(n)} skipped`),o.info("next steps:"),o.info(" lunora codegen # regenerate _generated/ so the new tables/functions appear"),t.length>0&&o.info(" pnpm install # install newly-added dependencies");for(const{manifest:s}of e)s.docs&&o.info(`${s.name}: ${s.docs}`)},ut=async e=>{const t=b(),r=N("list",e);if(r)return e.logger.error(r),{...t,code:1};let n=()=>{};try{const o=await st(e);n=o.cleanup;const s=ce(o.root);if(e.json)return process.stdout.write(`${JSON.stringify(s,void 0,2)}
17
+ `),t;e.logger.info(`available registry items (${String(s.length)}):`);for(const c of s)e.logger.info(` ${c.name}${c.description?` — ${c.description}`:""}`);return t}catch(o){return e.logger.error(`list failed: ${o instanceof Error?o.message:String(o)}`),{...t,code:1}}finally{n()}},xt=async e=>{const t=e.cwd??process.cwd(),r=b();if(e.list)return ut(e);if(e.names.length===0)return e.logger.error("add requires at least one item name. Usage: lunora registry add <name> [...names]"),{...r,code:1};const n=N("add",e);if(n)return e.logger.error(n),{...r,code:1};let o=[];try{const{cleanups:s,items:c}=await it(e.names,e);o=s;const{transformManifest:a}=e,i=a?c.map($=>({...$,manifest:a($.manifest)})):c;for(const{manifest:$}of i)Q(e.logger,$);if(e.json&&at(i),e.dryRun)return e.logger.info("dry-run: stopping before any files are written"),r;if(e.diff)return J(i,t,e.logger,{diff:!0}),e.logger.info("diff: preview only — re-run without --diff to apply"),r;if(!await Le(i,e))return{...r,code:1};const{bindings:u,deps:f,skipped:d,written:p}=J(i,t,e.logger,{overwrite:e.overwrite});return ct(i,f,p.length,d.length,e.logger),{bindings:u,code:0,deps:f,skipped:d,written:p}}catch(s){return e.logger.error(`add failed: ${s instanceof Error?s.message:String(s)}`),{...r,code:1}}finally{for(const s of o)s()}},Nt=async e=>{const t=b();if(e.names.length===0)return e.logger.error("view requires an item name. Usage: lunora registry view <name>"),{...t,code:1};const r=N("view",e);if(r)return e.logger.error(r),{...t,code:1};const n=[];try{for(const o of e.names){const{cleanup:s,directory:c}=await K(o,e);n.push(s);const a=Y(c,o);Q(e.logger,a);for(const i of a.files){e.logger.info(`--- ${i.to} (${i.merge}) ---`);const u=m(l(c,i.from),"utf8");for(const f of u.split(`
18
+ `))e.logger.info(f)}}return t}catch(o){return e.logger.error(`view failed: ${o instanceof Error?o.message:String(o)}`),{...t,code:1}}finally{for(const o of n)o()}},Ot=async e=>{const t=b(),r=e.from;if(r===void 0)return e.logger.error("registry build requires --from <registry root>"),{...t,code:1};if(!g(r))return e.logger.error(`registry root not found: ${r}`),{...t,code:1};const n=ue(r),o=e.out??l(r,"index.json");if(e.check){const s=g(o)?JSON.parse(m(o,"utf8")):{items:[]};return JSON.stringify(s.items??[])!==JSON.stringify(n.items)?(e.logger.error(`registry: ${o} is stale — run \`lunora registry build\` to regenerate it`),{...t,code:1}):(e.logger.success(`registry: ${o} is up to date (${String(n.items.length)} items)`),t)}return h(o,`${JSON.stringify({$schema:"./schema/registry.schema.json",...n},void 0,4)}
19
+ `,"utf8"),e.logger.success(`registry: wrote ${o} (${String(n.items.length)} items)`),t};export{Ne as L,xt as M,kt as P,ut as R,je as b,jt as d,U as g,Nt as k,Ot as q};
@@ -0,0 +1,2 @@
1
+ import{STEP_BADGE_NAMES as p,LunoraReporter as u}from"@lunora/config";import{JsonReporter as g}from"@visulima/pail/reporter/json";import{createPail as l}from"@visulima/pail/server";let n,a=!1,t;const d=()=>{if(a)return!0;const r=process.env.LUNORA_LOG_JSON;return r==="1"||r==="true"},c=r=>new r,f=()=>a?[c(g)]:t!==void 0&&t.length>0?t:[c(d()?g:u)],v=()=>{a||(a=!0,n=void 0)},S={compose:(...r)=>r,console:()=>c(u),json:()=>c(g)},y=r=>{t=Array.isArray(r)?r:[r],n=void 0},m=Object.fromEntries(p.map(r=>[r,{label:r,logLevel:"informational"}])),o=()=>(n??=l({reporters:f(),scope:["lunora"],stderr:process.stderr,stdout:process.stdout,types:m}),n),A=()=>({debug:r=>{o().debug(r)},error:r=>{o().error(r)},info:r=>{o().info(r)},success:r=>{o().success(r)},warn:r=>{o().warn(r)}}),P=()=>{const r=(e,s)=>{process.stderr.write(`${e} ${s}
2
+ `)};return{debug:e=>{r("debug",e)},error:e=>{r("error",e)},info:e=>{r("info ",e)},success:e=>{r("ok ",e)},warn:e=>{r("warn ",e)}}},E=new Proxy({},{get(r,e){const s=o(),i=s[e];return typeof i=="function"?i.bind(s):i}}),O=(r,e)=>{o()[r](e)};export{y as configureLogHandlers,A as createLogger,P as createStderrLogger,v as forceJsonLogging,o as getPail,S as logHandlers,O as logStep,E as pail};
@@ -0,0 +1 @@
1
+ import{spawn as l}from"node:child_process";const u=/[\s"%&<>^|]/u,m=/(\\*)"/gu,w=/(\\+)$/u,h=(t,e,n=process.platform)=>{if(n!=="win32"||t===process.execPath)return{args:[...e],command:t,shell:!1};const c=r=>r===""?'""':u.test(r)?`"${r.replaceAll(m,String.raw`$1$1\"`).replace(w,"$1$1")}"`:r;return{args:e.map(r=>c(r)),command:c(t),shell:!0}},S=t=>new Promise((e,n)=>{const c=typeof t.input=="string",r=t.captureStdout===!0;let p="inherit";r?p="pipe":t.stdoutToStderr&&(p=2);const a=h(t.command,t.args),s=l(a.command,a.args,{cwd:t.cwd??process.cwd(),env:t.env?{...process.env,...t.env}:process.env,shell:a.shell,stdio:[c?"pipe":"inherit",p,"inherit"]});let i="";r&&s.stdout&&s.stdout.on("data",o=>{i+=o.toString("utf8"),process.stdout.write(o)}),s.on("error",o=>{n(o)}),s.on("exit",(o,d)=>{e({code:o??(d?1:0),stdout:r?i:void 0})}),c&&s.stdin&&s.stdin.end(t.input)}),f=(t=0)=>{const e=[];return{calls:e,spawner:n=>(e.push({descriptor:n}),Promise.resolve({code:t}))}};export{f as createRecordingSpawner,S as defaultSpawner,h as spawnShellCompat};
@@ -0,0 +1 @@
1
+ import{spawnSync as t}from"node:child_process";import{LunoraError as m}from"@lunora/errors";import{findPackageManagerSync as o,identifyInitiatingPackageManager as p}from"@visulima/package/package-manager";const c=["pnpm","bun","yarn","npm"],i=new Set(["bun","npm","pnpm","yarn"]),s=n=>i.has(n),u=n=>{try{return t(n,["--version"],{stdio:"ignore",timeout:5e3}).status===0}catch{return!1}},d=(n=u)=>c.filter(a=>n(a)),y=n=>({args:["install"],command:n}),b=n=>{try{return o(n).packageManager}catch{}const a=p();if(a!==void 0){const e=a.name==="cnpm"?"npm":a.name;if(s(e))return e}const[r]=d();if(r!==void 0)return r;throw new m("INTERNAL","Could not detect a package manager: no lock file or `packageManager` field was found, and none (pnpm, bun, yarn, npm) is installed on PATH.")},k=(n,a,r)=>n==="yarn"?{args:[a,...r],command:"yarn"}:n==="bun"?{args:["x",a,...r],command:"bun"}:n==="npm"?{args:["--",a,...r],command:"npx"}:{args:["exec",a,...r],command:"pnpm"},w=(n,a)=>n==="npm"?`npm run ${a}`:n==="bun"?`bun run ${a}`:`${n} ${a}`;export{k as M,b as P,y as d,w as k,d as t};
@@ -0,0 +1,5 @@
1
+ import{quoteIdentifier as l,sqlAffinityForKind as f,frameworkColumnDdl as $,columnRef as y,physicalIndexName as u}from"@lunora/d1/dialect";const q=e=>f(e),d=(e,n)=>{const s=[l(e),n.sqlType];return n.nullable||s.push("NOT NULL"),s.join(" ")},T=e=>{const n=Object.entries(e.columns).map(([r,a])=>` ${d(r,a)}`),s=[...$().map(r=>` ${r}`),...n].join(`,
2
+ `);return`CREATE TABLE IF NOT EXISTS ${l(e.name)} (
3
+ ${s}
4
+ );`},h=e=>`DROP TABLE IF EXISTS ${l(e)};`,b=(e,n,s)=>`ALTER TABLE ${l(e)} ADD COLUMN ${d(n,s)};`,m=(e,n)=>{const s=n.fields.map(r=>y(r)).join(", ");return`CREATE ${n.unique?"UNIQUE ":""}INDEX IF NOT EXISTS ${u(e,n.name)} ON ${l(e)} (${s});`},E=(e,n)=>`DROP INDEX IF EXISTS ${u(e,n)};`,L=(e,n,s,r,a)=>{s.sqlType!==r.sqlType&&a.push({kind:"columnTypeChange",summary:`column type change on ${e}.${n}: ${s.sqlType} → ${r.sqlType} (write SQL manually)`}),s.nullable!==r.nullable&&a.push({kind:"columnTypeChange",summary:`nullability change on ${e}.${n}: ${s.nullable?"NULL":"NOT NULL"} → ${r.nullable?"NULL":"NOT NULL"} (write SQL manually)`})},N=(e,n,s,r,a)=>{for(const[o,i]of Object.entries(s)){const t=n[o];if(t===void 0){r.push({kind:"addColumn",sql:b(e,o,i),summary:`ADD COLUMN ${e}.${o}`});continue}L(e,o,t,i,a)}for(const o of Object.keys(n))s[o]===void 0&&a.push({kind:"dropColumn",summary:`DROP COLUMN ${e}.${o} (SQLite drop-column requires careful migration — write SQL manually)`})},O=(e,n,s,r,a)=>{for(const[o,i]of Object.entries(s)){const t=n[o];if(t===void 0){r.push({kind:"createIndex",sql:m(e,i),summary:`CREATE INDEX ${o} ON ${e}`});continue}(!(t.fields.length===i.fields.length&&t.fields.every((p,c)=>p===i.fields[c]))||t.unique!==i.unique)&&a.push({kind:"indexRename",summary:`index ${o} changed on ${e} — drop+create manually if intentional`})}for(const o of Object.keys(n))s[o]===void 0&&r.push({kind:"dropIndex",sql:E(e,o),summary:`DROP INDEX ${o}`})},g=(e,n,s)=>{s.push({kind:"createTable",sql:T(n),summary:`CREATE TABLE ${e}`});for(const r of Object.values(n.indexes))s.push({kind:"createIndex",sql:m(e,r),summary:`CREATE INDEX ${r.name} ON ${e}`})},D=(e,n)=>{const s=e?.tables??{},r=[],a=[];for(const[o,i]of Object.entries(n.tables)){const t=s[o];if(t===void 0){g(o,i,r);continue}N(o,t.columns,i.columns,r,a),O(o,t.indexes,i.indexes,r,a)}for(const[o]of Object.entries(s))n.tables[o]===void 0&&r.push({kind:"dropTable",sql:h(o),summary:`DROP TABLE ${o}`});return{empty:r.length===0&&a.length===0,entries:r,unsupported:a}},C=(e,n,s)=>{const r=[`-- Lunora migration: ${e}`,`-- Generated at ${s}`,"-- This file was produced by `lunora migrate generate`. Review carefully before applying.",""];for(const a of n.entries)r.push(`-- ${a.summary}`,a.sql,"");if(n.unsupported.length>0){r.push("-- ---------------------------------------------------------------","-- The following deltas are NOT auto-generated in v0.1.","-- Write the appropriate SQL below by hand:","--");for(const a of n.unsupported)r.push(`-- * ${a.summary}`);r.push("-- ---------------------------------------------------------------","")}return n.empty&&r.push("-- No changes detected. Re-running `lunora migrate generate` will overwrite this file.",""),r.join(`
5
+ `)};export{D as diffSnapshots,b as renderAddColumn,m as renderCreateIndex,T as renderCreateTable,E as renderDropIndex,h as renderDropTable,C as renderMigrationFile,q as validatorKindToSqlType};
@@ -0,0 +1 @@
1
+ import{spawnSync as r}from"node:child_process";const e=()=>{try{return r("docker",["info"],{stdio:"ignore"}).status===0}catch{return!1}},s=()=>{if(typeof process.env.BUILDKIT_HOST!="string"||process.env.BUILDKIT_HOST.length===0)return!1;try{return r("railpack",["--version"],{stdio:"ignore"}).status===0}catch{return!1}};export{s as o,e as r};
@@ -0,0 +1,8 @@
1
+ import{Project as f,SyntaxKind as o,Node as i}from"ts-morph";const x=/^[A-Za-z_$][\w$]*$/u,s=r=>`// lunora:add:${r}:start`,a=r=>`// lunora:add:${r}:end`,p=r=>`./${r}/schema`,m=r=>{for(const e of r)if(e.getExpression().getText()==="defineSchema")return e},g=r=>{let e=r;for(let t=e.getParent();t!==void 0;t=e.getParent())if(i.isPropertyAccessExpression(t)&&t.getExpression()===e)e=t;else if(i.isCallExpression(t)&&t.getExpression()===e)e=t;else break;return e},E=(r,e)=>{if(!x.test(e))return{ok:!1,reason:"invalid-identifier"};if(r.includes(s(e)))return{ok:!1,reason:"already-applied"};const t=new f({compilerOptions:{allowJs:!0},useInMemoryFileSystem:!0}).createSourceFile("schema.ts",r,{overwrite:!0}),l=t.getDescendantsOfKind(o.CallExpression),n=m(l);if(!n)return{ok:!1,reason:"no-define-schema"};if(n.getArguments()[0]?.getKind()!==o.ObjectLiteralExpression)return{ok:!1,reason:"non-object-argument"};const c=g(n).getEnd(),d=`
2
+ ${s(e)}
3
+ .extend(${e}.extension)
4
+ ${a(e)}
5
+ `;t.insertText(c,d);const u=`${s(e)}
6
+ import { ${e} } from "${p(e)}";
7
+ ${a(e)}
8
+ `;return t.insertText(0,u),{ok:!0,text:t.getFullText()}};export{E as insertSchemaExtension};
@@ -0,0 +1 @@
1
+ import{spawn as s}from"node:child_process";import{platform as a}from"node:os";import{LunoraError as n}from"@lunora/errors";const i=()=>{const e=a();return e==="darwin"?{args:[],command:"open"}:e==="win32"?{args:["/c","start",""],command:"cmd"}:{args:[],command:"xdg-open"}},d=e=>e.replaceAll("%","%25").replaceAll("&","%26").replaceAll("|","%7C").replaceAll("^","%5E").replaceAll("<","%3C").replaceAll(">","%3E").replaceAll("(","%28").replaceAll(")","%29").replaceAll('"',"%22").replaceAll("!","%21"),w=e=>new Promise((o,r)=>{const{args:t,command:c}=i(),p=a()==="win32"?d(e):e,l=s(c,[...t,p],{detached:!0,stdio:"ignore"});l.once("error",m=>{r(m)}),l.once("spawn",()=>{l.unref(),o()})}),h=async(e,o={})=>{let r;try{r=new URL(e)}catch{throw new n("INTERNAL",`Invalid URL: ${e}`)}if(r.protocol!=="http:"&&r.protocol!=="https:")throw new n("INTERNAL",`Refusing to open non-http(s) URL: ${e}`);await(o.opener??w)(e)};export{h as f};
@@ -0,0 +1,2 @@
1
+ import{createStderrLogger as o}from"./createLogger--C3x1FNE.mjs";const e=new Set(["json","pretty"]),i=(t,r)=>{if(r!==void 0&&!e.has(r))return`${t}: unknown --format "${r}" — expected pretty | json`},s=t=>t==="json",d=(t,r)=>s(t)?o():r,p=t=>{process.stdout.write(`${JSON.stringify(t,void 0,2)}
2
+ `)};export{p as d,i,s as r,d as s};
@@ -0,0 +1 @@
1
+ import{LunoraError as i}from"@lunora/errors";const l=/[\r\n]/u,d=/^[A-Za-z_]\w*$/u,g=/^[A-Za-z0-9][\w-]*$/u,b=/^[\w.-]+(?:\/[\w.-]+)*$/u,L=(a,o)=>{if(typeof a!="object"||a===null)throw new i("INTERNAL",`registry.json for "${o}" is not an object`);const t=a,{name:s}=t;if(typeof s!="string"||s.length===0)throw new i("INTERNAL",`registry.json for "${o}" is missing a string "name"`);if(!g.test(s))throw new i("INTERNAL",`registry.json for "${o}": name "${s}" must match ${g.source} (letters, digits, "-", "_"; no path separators, "..", or code)`);const y=t.files;if(!Array.isArray(y))throw new TypeError(`registry.json for "${o}" is missing a "files" array`);const w=y.map((e,r)=>{if(typeof e!="object"||e===null)throw new i("INTERNAL",`registry.json "${o}": files[${String(r)}] is not an object`);const n=e,{from:f}=n,{to:p}=n,{merge:m}=n;if(typeof f!="string"||typeof p!="string")throw new TypeError(`registry.json "${o}": files[${String(r)}] needs string "from" and "to"`);if(m!=="create-or-skip"&&m!=="schema-extension")throw new i("INTERNAL",`registry.json "${o}": files[${String(r)}].merge must be "create-or-skip" or "schema-extension"`);for(const[R,c]of[["from",f],["to",p]])if(c.includes("..")||c.startsWith("/"))throw new i("INTERNAL",`registry.json "${o}": files[${String(r)}].${R} "${c}" must be a relative path without ".."`);return{from:f,merge:m,to:p}}),u=e=>typeof e=="object"&&e!==null?e:void 0,h=u(t.deps),$=u(t.devDependencies),A=Array.isArray(t.requires)?t.requires.filter(e=>typeof e=="string"):void 0,v=Array.isArray(t.bindings)?t.bindings.filter(e=>{if(typeof e!="object"||e===null)return!1;const r=e;return Array.isArray(r.path)&&r.path.every(n=>typeof n=="string")}):void 0,j=Array.isArray(t.entrypointReexports)?t.entrypointReexports.filter(e=>typeof e=="object"&&e!==null&&typeof e.module=="string").map(e=>{if(e.module.includes("..")||e.module.startsWith("/")||!b.test(e.module))throw new i("INTERNAL",`registry.json "${o}": entrypointReexports[].module "${e.module}" must be a safe relative module path without path traversal or unsafe characters`);const r={module:e.module};if(typeof e.comment=="string"){if(l.test(e.comment))throw new i("INTERNAL",`registry.json "${o}": entrypointReexports[].comment must not contain a newline`);r.comment=e.comment}return r}):void 0,N=Array.isArray(t.envVars)?t.envVars.filter(e=>typeof e=="object"&&e!==null&&typeof e.name=="string").map(e=>{const r=typeof e.value=="string";if(!d.test(e.name))throw new i("INTERNAL",`registry.json "${o}": envVars["${e.name}"].name must match ${d.source} (letters, digits, underscore; no "=" or newline)`);if(r&&l.test(e.value))throw new i("INTERNAL",`registry.json "${o}": envVars["${e.name}"].value must not contain a newline`);if(typeof e.description=="string"&&l.test(e.description))throw new i("INTERNAL",`registry.json "${o}": envVars["${e.name}"].description must not contain a newline`);return{...typeof e.description=="string"?{description:e.description}:{},name:e.name,secret:typeof e.secret=="boolean"?e.secret:!r,...r?{value:e.value}:{}}}):void 0;return{bindings:v,deps:h,description:typeof t.description=="string"?t.description:void 0,devDependencies:$,docs:typeof t.docs=="string"?t.docs:void 0,entrypointReexports:j,envVars:N,files:w,name:s,requires:A,title:typeof t.title=="string"?t.title:void 0}};export{L as default};
@@ -0,0 +1 @@
1
+ class e extends Error{constructor(){super("cancelled"),this.name="PromptCancelledError"}}const o=130;export{e as P,o as a};
@@ -0,0 +1 @@
1
+ import{readLinkedProject as e}from"@lunora/config";const t=({cwd:o,url:r})=>r!==void 0&&r!==""?r:e(o)?.workerUrl,c=({cwd:o,prod:r,url:d})=>d!==void 0&&d!==""?d:r?e(o)?.workerUrl:void 0;export{c as s,t};
@@ -0,0 +1 @@
1
+ import"node:fs";import"@visulima/path";import{M as d,q as i,R as s,k as t}from"./commands-BhX2Bo9B.mjs";import"./buildRegistryIndex-DwySASBu.mjs";export{d as runAddCommand,i as runBuildIndexCommand,s as runListCommand,t as runRegistryViewCommand};
@@ -0,0 +1 @@
1
+ import{existsSync as i,readFileSync as u,writeFileSync as d}from"node:fs";import{evaluateSchemaDrift as g,parseSchemaSnapshot as b,SchemaSnapshotParseError as p,serializeSchemaSnapshot as m}from"@lunora/codegen";const f=e=>{if(!i(e))return{status:"absent"};let s;try{s=u(e,"utf8")}catch{return{status:"corrupt"}}try{const a=b(s);return a===void 0?{status:"corrupt"}:{snapshot:a,status:"ok"}}catch(a){if(a instanceof p)return{status:"corrupt"};throw a}},S=(e,s)=>{d(e,m(s),"utf8")},k=e=>{const s=`schema-drift gate: the committed baseline ${e.snapshotPath} is unreadable or malformed, so schema drift cannot be checked. Fix it (e.g. resolve a merge conflict in lunora/.lunora-schema.json), or pass --update-schema-baseline to regenerate it from the current schema.`;return e.updateBaseline&&!e.readOnly?(e.logger.warn(`schema baseline was unreadable; regenerating from the current schema on success (--update-schema-baseline): ${e.snapshotPath}`),{blocked:!1,changes:[],reason:s,rebless:e.rebless}):(e.readOnly||e.logger.error(s),{blocked:!0,changes:[],reason:s})},y=(e,s)=>(s.readOnly||s.logger.error(e.reason),s.updateBaseline&&!s.readOnly?(s.logger.warn(`schema baseline will be re-blessed despite breaking drift on success (--update-schema-baseline): ${s.snapshotPath}`),{blocked:!1,changes:e.changes,reason:e.reason,rebless:s.rebless}):{blocked:!0,changes:e.changes,reason:e.reason}),P=e=>{const{allowDrift:s,codegen:a,logger:l,readOnly:t=!1,updateBaseline:h=!1}=e,n=a.schemaSnapshotPath,o=f(n),c={logger:l,readOnly:t,rebless:()=>{S(n,a.schemaSnapshot)},snapshotPath:n,updateBaseline:h};if(o.status==="corrupt")return k(c);const r=g({allowDrift:s,baseline:o.status==="ok"?o.snapshot:void 0,current:a.schemaSnapshot});return r.blocked?y(r,c):r.changes.length>0?(t||l.info(r.reason),{blocked:!1,changes:r.changes,reason:r.reason,rebless:t?void 0:c.rebless}):{blocked:!1,changes:r.changes,reason:r.reason}};export{P as k};
@@ -0,0 +1 @@
1
+ import{validatorKindToSqlType as i}from"./diffSnapshots-9bDd9nOK.mjs";const r=e=>e.kind==="optional"&&e.inner?{nullable:!0,sqlType:i(e.inner.kind)}:{nullable:!1,sqlType:i(e.kind)},f=e=>e==="global",c=e=>{const s={};for(const o of e.tables){if(!f(o.shardMode))continue;const a={};for(const[n,t]of Object.entries(o.shape))a[n]=r(t);const l={};for(const n of o.indexes)l[n.name]={fields:[...n.fields],name:n.name,unique:n.unique??!1};s[o.name]={columns:a,indexes:l,name:o.name}}return{tables:s,version:1}};export{c as default};
@@ -0,0 +1 @@
1
+ import{d as s}from"./commands-BhX2Bo9B.mjs";const d=/[^a-z0-9]+/u,r=(e,t,a)=>{let n=e.toLowerCase().split(d).filter(Boolean).join("-").slice(0,a);return n.endsWith("-")&&(n=n.slice(0,-1)),n.length>=t?n:void 0},u="DB",c="Name your D1 database (run `wrangler d1 create` to get its id, then put it in wrangler.jsonc)",l=e=>r(e,1,64),h="lunora-db",m=e=>l(`${e}-db`)??h,y=async(e,t)=>{const a=m(t);return l(await e(c,{default:a,placeholder:a}))??a},_=(e,t)=>s(e,"d1_databases",{key:"binding",value:u},"database_name",t),f=[{description:"Email + password on better-auth (default)",label:"Email & password",value:"auth"},{description:"Clerk-hosted auth",label:"Clerk",value:"auth-clerk"},{description:"Auth0 (OIDC)",label:"Auth0",value:"auth-auth0"}],i="auth",j=async e=>await e("Which auth provider?",f,{default:i})??i,C="mail",D=e=>{const t=e.trim();if(t==="")return;const a=t.toLowerCase();return a==="auth"?{kind:"auth"}:a==="email"||a==="mail"?{kind:"email"}:{item:a,kind:"item"}},p="SEND_EMAIL",A="Verified destination email for production delivery (blank = set it later in wrangler.jsonc)",$=e=>{const t=e.trim();if(t.length===0||t.includes(" "))return!1;const a=t.indexOf("@");if(a<=0||a!==t.lastIndexOf("@"))return!1;const n=t.slice(a+1);return n.length>=3&&n.includes(".")&&!n.startsWith(".")&&!n.endsWith(".")},E=(e,t)=>{const a=e.trim();if(a!==""){if(!$(a)){t(`"${a}" doesn't look like an email — leaving the placeholder; set destination_address in wrangler.jsonc.`);return}return a}},L=(e,t)=>s(e,"send_email",{key:"name",value:p},"destination_address",t),b="UPLOADS",k="Name your R2 bucket (you can rename it in wrangler.jsonc later)",o=e=>r(e,3,63),g="lunora-uploads",w=e=>o(`${e}-uploads`)??g,O=async(e,t)=>{const a=w(t);return o(await e(k,{default:a,placeholder:a}))??a},W=(e,t)=>s(e,"r2_buckets",{key:"binding",value:b},"bucket_name",t);export{w as a,A as b,m as c,E as d,y as e,i as f,j as g,f as h,o as i,_ as j,L as l,C as n,D as o,W as p,l as r,O as u};
@@ -0,0 +1,4 @@
1
+ import{jsx as t,jsxs as c}from"react/jsx-runtime";import{isInteractive as m,ACCENT as b,LUNA_ART as oe,LUNA_NAME as se,LUNA_SIGNOFF as ce,BADGE_COLUMN_WIDTH as j,badgeLead as de,padBadge as ue,badgeWidth as K}from"@lunora/config";import{render as V}from"@visulima/tui";import"@visulima/tui/components/big-text";import{Box as d}from"@visulima/tui/components/box";import{CommandPalette as fe}from"@visulima/tui/components/command-palette";import{ConfirmInput as he}from"@visulima/tui/components/confirm-input";import{SelectInput as me}from"@visulima/tui/components/select-input";import{Spinner as ge}from"@visulima/tui/components/spinner";import{Text as o}from"@visulima/tui/components/text";import{TextInput as pe}from"@visulima/tui/components/text-input";import{useApp as $}from"@visulima/tui/hooks/use-app";import{useInput as W}from"@visulima/tui/hooks/use-input";import{useInterval as be}from"@visulima/tui/hooks/use-interval";import{useEffect as L,useState as x}from"react";import{P as Z}from"./prompt-cancelled-C8Sj7OqI.mjs";let H=!1;const F=()=>{H||(H=!0,process.getMaxListeners()<64&&process.setMaxListeners(64))},ve=({children:e,onCancel:r})=>{const{exit:n}=$();return W((a,l)=>{l.ctrl&&a==="c"&&(r(),n())}),e},z=e=>e instanceof Error?e:new Error(typeof e=="string"?e:"task failed"),J=10,we=8,I=({spec:e})=>c(o,{children:[t(o,{children:de(e.text)}),t(o,{backgroundColor:e.bg,bold:!0,color:e.fg,children:ue(e.text)})]}),ee=({badge:e,message:r})=>e===void 0?t(o,{bold:!0,children:r}):c(d,{children:[t(I,{spec:e}),t(o,{bold:!0,children:` ${r}`})]}),re=2,ne=" ".repeat(j-1),te=e=>" ".repeat(K(e)+1),xe=e=>e===void 0?re:K(e)+1,N=({badge:e,children:r,message:n})=>c(d,{flexDirection:"column",children:[t(ee,{badge:e,message:n}),t(d,{flexDirection:"column",marginLeft:xe(e),children:r})]}),S=({answer:e,badge:r,message:n})=>c(d,{flexDirection:"column",children:[t(ee,{badge:r,message:n}),e===""?null:t(o,{dimColor:!0,children:`${r===void 0?" ".repeat(re):te(r)}${e}`})]}),A=e=>{const{exit:r}=$(),[n,a]=x(void 0);return L(()=>{n!==void 0&&r()},[n,r]),{answer:n,submit:(l,i)=>{e(l),a(i)}}},$e=({children:e})=>{const{exit:r}=$();return L(()=>{r()},[r]),e},y=async e=>{F(),process.stdout.write(`
2
+ `);const r=V(t($e,{children:e}));try{await r.waitUntilExit()}catch{}finally{r.unmount()}},rr=async(e,r,n)=>{if(!m())return;const a=n===void 0||n===""?[]:n.split(`
3
+ `);await y(c(d,{flexDirection:"column",children:[c(d,{children:[t(I,{spec:e}),t(o,{bold:!0,children:` ${r}`})]}),a.map(l=>t(o,{dimColor:!0,children:`${te(e)}${l}`},l))]}))},G=async e=>{F(),process.stdout.write(`
4
+ `);const r={value:!1},n=V(t(ve,{onCancel:()=>{r.value=!0},children:e}),{exitOnCtrlC:!1});try{await n.waitUntilExit()}finally{n.unmount()}if(r.value)throw new Z},k=async(e,r)=>{let n=r;return await G(e(a=>{n=a})),n},le=e=>e.description===void 0?e.label:`${e.label} — ${e.description}`,O=()=>{const{exit:e}=$();W((r,n)=>{n.escape&&e()})},ye=({badge:e,finish:r,initialIndex:n,message:a,options:l})=>{const{answer:i,submit:u}=A(r);return O(),i!==void 0?t(S,{answer:i,badge:e,message:a}):t(N,{badge:e,message:a,children:t(me,{accentColor:b,initialIndex:n,items:l.map(s=>({key:s.value,label:le(s),value:s.value})),limit:J,onSelect:s=>{u(s.value,l.find(f=>f.value===s.value)?.label??s.value)}})})},Ce=({badge:e,finish:r,message:n,options:a})=>{const{exit:l}=$(),{answer:i,submit:u}=A(r);return i!==void 0?t(S,{answer:i,badge:e,message:n}):t(N,{badge:e,message:n,children:t(fe,{accentColor:b,autoFocus:!0,commands:a.map(s=>({description:s.description,id:s.value,label:s.label})),limit:J,onCancel:()=>{l()},onSelect:s=>{u(s,a.find(f=>f.value===s)?.label??s)},placeholder:"Type to filter…"})})},nr=async(e,r,n)=>{if(!m()||r.length===0)return n?.default;const{badge:a}=n??{};if(r.length>we)return k(i=>t(Ce,{badge:a,finish:i,message:e,options:r}),n?.default);const l=n?.default===void 0?-1:r.findIndex(i=>i.value===n.default);return k(i=>t(ye,{badge:a,finish:i,initialIndex:l>=0?l:void 0,message:e,options:r}),n?.default)},De=({badge:e,defaultValue:r,finish:n,message:a,placeholder:l})=>{const{answer:i,submit:u}=A(n);return O(),i!==void 0?t(S,{answer:i,badge:e,message:a}):t(N,{badge:e,message:a,children:t(pe,{defaultValue:r,onSubmit:s=>{const f=s.trim()===""?r:s.trim();u(f,f)},placeholder:l})})},tr=async(e,r)=>{const n=r?.default??"";if(!m())return n;const{badge:a}=r??{};return k(l=>t(De,{badge:a,defaultValue:n,finish:l,message:e,placeholder:r?.placeholder}),n)},ke=({badge:e,defaults:r,finish:n,message:a,options:l})=>{const{answer:i,submit:u}=A(n),[s,f]=x(0),[g,C]=x(()=>new Set(r));return O(),W((p,v)=>{if(!(i!==void 0||l.length===0)){if(v.upArrow)f(h=>(h-1+l.length)%l.length);else if(v.downArrow)f(h=>(h+1)%l.length);else if(p===" "){const h=l[s];h!==void 0&&C(w=>{const E=new Set(w);return E.has(h.value)?E.delete(h.value):E.add(h.value),E})}else if(v.return){const h=l.filter(w=>g.has(w.value));u(h.map(w=>w.value),h.length>0?h.map(w=>w.label).join(", "):"none")}}}),i!==void 0?t(S,{answer:i,badge:e,message:a}):t(N,{badge:e,message:a,children:c(d,{flexDirection:"column",children:[t(o,{dimColor:!0,children:"space toggles · enter confirms · esc cancels"}),l.map((p,v)=>{const h=v===s;return t(o,{color:h?b:void 0,children:`${h?"▸ ":" "}${g.has(p.value)?"◼":"◻"} ${le(p)}`},p.value)})]})})},lr=async(e,r,n)=>{const a=n?.defaults??[];if(!m()||r.length===0)return[...a];const{badge:l}=n??{};return k(i=>t(ke,{badge:l,defaults:a,finish:i,message:e,options:r}),[...a])},Ie=({badge:e,defaultYes:r,finish:n,message:a})=>{const{answer:l,submit:i}=A(n);return l!==void 0?t(S,{answer:l,badge:e,message:a}):c(d,{children:[e===void 0?null:t(I,{spec:e}),t(o,{bold:!0,children:e===void 0?`${a} `:` ${a} `}),t(he,{defaultChoice:r?"confirm":"cancel",onCancel:()=>{i(!1,"No")},onConfirm:()=>{i(!0,"Yes")}})]})},Se=async(e,r)=>{const n=r?.defaultYes===!0;if(!m())return n;const{badge:a}=r??{};return k(l=>t(Ie,{badge:a,defaultYes:n,finish:l,message:e}),!1)},ar=()=>m()?e=>Se(e,{defaultYes:!0}):()=>Promise.resolve(!1),P="#c8a8ff",U="#d9c8ff",Ae="#6b5b9a",M=({moon:e,prefix:r,suffix:n})=>c(d,{children:[t(o,{color:P,dimColor:!0,children:r}),typeof e=="string"?t(o,{color:U,children:e}):e,n===void 0?null:t(o,{color:P,children:n})]}),Q=({left:e,right:r})=>c(o,{color:U,children:[e,t(o,{color:Ae,children:"●●"}),r]}),Ee=()=>c(d,{flexDirection:"column",paddingX:1,children:[t(M,{moon:".-‐-.",prefix:"· ✦ · ",suffix:" ✦"}),t(M,{moon:t(Q,{left:"/",right:"\\"}),prefix:" ✦ · ",suffix:" ·"}),t(M,{moon:t(Q,{left:"\\",right:"/"}),prefix:" . ✦ · "}),c(d,{children:[t(o,{bold:!0,color:b,children:" lunora init "}),t(o,{dimColor:!0,children:"· moonrise sequence"}),t(o,{color:U})]})]}),ir=async e=>{m()&&await y(c(d,{flexDirection:"column",children:[t(Ee,{}),t(d,{paddingX:1,children:t(o,{dimColor:!0,children:e})})]}))},Te=({label:e})=>c(d,{children:[t(o,{color:b,children:t(ge,{type:"dots"})}),c(o,{children:[" ",e]})]}),or=async(e,r)=>{if(!m())return r();F();const n=V(t(Te,{label:e}));try{return await r()}finally{n.unmount()}},sr=async()=>{m()&&await y(c(d,{paddingX:1,children:[t(o,{color:U,children:oe}),c(d,{flexDirection:"column",marginLeft:2,children:[t(o,{bold:!0,color:b,children:se}),t(o,{children:ce})]})]}))},Le="#06b6d4",_=" ".repeat(9),cr=async e=>{m()&&await y(t(o,{bold:!0,children:`${_}${e}`}))},dr=async e=>{m()&&await y(c(d,{children:[t(o,{color:Le,children:`${ne}◼`}),t(o,{children:` ${e}`})]}))},ur=async(e,r,n,a)=>{m()&&await y(c(d,{flexDirection:"column",children:[c(d,{children:[t(I,{spec:e}),t(o,{bold:!0,children:` ${r}`})]}),t(d,{flexDirection:"column",marginTop:1,children:n.map(l=>c(o,{children:[`${_}${l.lead} `,t(o,{color:b,children:l.code}),l.tail??""]},l.lead))}),t(d,{flexDirection:"column",marginTop:1,children:a.map(l=>c(o,{children:[`${_}${l.lead} `,t(o,{color:b,children:l.code}),l.tail??""]},l.lead))})]}))},T=" ".repeat(j-1),q="#a855f7",ae="#06b6d4",D=[q,"#9b51f6","#8a5cf6","#6f86f6","#4aa6ef","#2bb6dd","#12bcd0",ae],B=D.length-2,X=(e,r)=>Array.from({length:Math.max(0,e)},()=>r),R=[...X(D.length-1,q),...D,...X(D.length-1,ae),...D.toReversed()],Y=R.map((e,r)=>{const n=R.slice(r,r+B);return[...n,...X(B-n.length,q)]}),Ne=" ".repeat(Math.max(0,j-B)),ie=({label:e})=>{const[r,n]=x(0);be(()=>{n(l=>(l+1)%Y.length)},90);const a=Y[r%Y.length]??[];return c(o,{children:[Ne,a.map((l,i)=>t(o,{color:l,children:"█"},i)),` ${e}`]})},Ue=({label:e,status:r})=>r==="running"?t(o,{color:b,children:`${T}▶ ${e}`}):r==="failed"?t(o,{color:"red",children:`${T}✖ ${e}`}):r==="done"?t(o,{dimColor:!0,children:`${T}■ ${e}`}):t(o,{dimColor:!0,children:`${T}□ ${e}`}),Me=async(e,r)=>{const n=[];let a;for(const[l,i]of e.entries()){r(l,"running");try{n.push(await i.run()),r(l,"done")}catch(u){r(l,"failed"),a=u;break}}return{failure:a,results:n}},Ye=(e,r,n,a)=>{let l=!0;return Me(e,(i,u)=>{l&&r(s=>s.map((f,g)=>g===i?u:f))}).then(({failure:i,results:u})=>{setTimeout(()=>{l&&(n(u,i),a())},400)}).catch(()=>{}),()=>{l=!1}},_e=({end:e,onSettle:r,start:n,tasks:a})=>{const{exit:l}=$(),[i,u]=x(()=>a.map(()=>"pending"));L(()=>Ye(a,u,r,l),[l,r,a]);const s=i.length>0&&i.every(f=>f==="done");return c(d,{flexDirection:"column",children:[s?c(d,{children:[t(o,{bold:!0,color:"green",children:`${ne}✔`}),t(o,{bold:!0,color:"green",children:` ${e}`})]}):t(ie,{label:n}),a.map((f,g)=>t(Ue,{label:f.label,status:i[g]??"pending"},f.label))]})},fr=async(e,r)=>{if(!m()){const l=[];for(const i of e)l.push(await i.run());return l}let n=[],a;if(await G(t(_e,{end:r.end,onSettle:(l,i)=>{n=l,a=i},start:r.start,tasks:e})),a!==void 0)throw z(a);return n},Be=async(e,r)=>{const n=[];let a;for(const[l,i]of e.entries()){r(l);try{n.push(await i.task())}catch(u){a=u;break}}return{failure:a,values:n}},Xe=({badge:e,done:r,onSettle:n,steps:a})=>{const{exit:l}=$(),[i,u]=x(0),[s,f]=x(!1);return L(()=>{let g=!0,C;return Be(a,p=>{g&&u(p)}).then(({failure:p,values:v})=>{if(g){if(p!==void 0){n({error:p,ok:!1}),l();return}f(!0),C=setTimeout(()=>{g&&(n({ok:!0,values:v}),l())},400)}}).catch(()=>{}),()=>{g=!1,C!==void 0&&clearTimeout(C)}},[l,n,a]),s?c(d,{children:[t(I,{spec:e}),t(o,{bold:!0,children:` ${r}`})]}):t(ie,{label:a[i]?.running??""})},hr=async(e,r,n)=>{if(!m()){const l=[];for(const i of r)l.push(await i.task());return l}let a;if(await G(t(Xe,{badge:e,done:n,onSettle:l=>{a=l},steps:r})),a===void 0)throw new Z;if(!a.ok)throw z(a.error);return a.values};export{ar as $,nr as B,tr as C,or as H,lr as I,ir as M,fr as Q,cr as U,ur as W,dr as X,sr as Y,rr as h,Se as i,hr as t};
@@ -0,0 +1 @@
1
+ import{findWranglerFile as t,readWranglerJsonc as o}from"@lunora/config";const i=r=>{const e=t(r);if(!e)return;const{parsed:n}=o(e);return typeof n?.name=="string"&&n.name.length>0?n.name:void 0};export{i as d};
@@ -0,0 +1 @@
1
+ import{execFile as c}from"node:child_process";import{M as d,P as i}from"./detect-package-manager-B2eIuAiP.mjs";const m=r=>r?typeof r.code=="number"?r.code:1:0,l=(r,t,e)=>new Promise(n=>{c(r,[...t],{cwd:e},(o,s,a)=>{n({code:m(o),stderr:a,stdout:s})})}),p=r=>{let t;try{t=JSON.parse(r)}catch{return}return Array.isArray(t)?[...t.map(e=>e!==null&&typeof e=="object"?e.name:void 0).filter(e=>typeof e=="string"&&e.length>0)].toSorted((e,n)=>e.localeCompare(n)):void 0},y=async r=>{const t=["secret","list","--format","json"];r.env!==void 0&&t.push("--env",r.env),r.temporary&&t.push("--temporary");const{args:e,command:n}=d(i(r.cwd),"wrangler",t),o=await(r.runner??l)(n,e,r.cwd);if(o.code!==0)return{error:o.stderr.trim()||`wrangler secret list exited ${String(o.code)}`,names:[],ok:!1};const s=p(o.stdout);return s===void 0?{error:"could not parse `wrangler secret list --format json` output",names:[],ok:!1}:{names:s,ok:!0}};export{y as f};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/cli",
3
- "version": "1.0.0-alpha.100",
3
+ "version": "1.0.0-alpha.102",
4
4
  "description": "The Lunora CLI: init, dev, deploy, codegen, run, reset, and migrate commands",
5
5
  "keywords": [
6
6
  "agent-skills",
@@ -53,13 +53,13 @@
53
53
  "dependencies": {
54
54
  "@bomb.sh/tab": "0.0.19",
55
55
  "@lunora/bindings": "1.0.0-alpha.11",
56
- "@lunora/codegen": "1.0.0-alpha.54",
57
- "@lunora/config": "1.0.0-alpha.80",
56
+ "@lunora/codegen": "1.0.0-alpha.56",
57
+ "@lunora/config": "1.0.0-alpha.82",
58
58
  "@lunora/container": "1.0.0-alpha.16",
59
- "@lunora/d1": "1.0.0-alpha.40",
59
+ "@lunora/d1": "1.0.0-alpha.41",
60
60
  "@lunora/errors": "1.0.0-alpha.8",
61
- "@lunora/runtime": "1.0.0-alpha.37",
62
- "@lunora/seed": "1.0.0-alpha.30",
61
+ "@lunora/runtime": "1.0.0-alpha.38",
62
+ "@lunora/seed": "1.0.0-alpha.31",
63
63
  "@visulima/cerebro": "3.0.0",
64
64
  "@visulima/error": "6.0.0",
65
65
  "@visulima/fs": "5.0.4",