@lunora/cli 1.0.0-alpha.217 → 1.0.0-alpha.218

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 (67) hide show
  1. package/dist/bin.mjs +1 -1
  2. package/dist/index.d.mts +8 -0
  3. package/dist/index.d.ts +8 -0
  4. package/dist/index.mjs +1 -1
  5. package/dist/packem_chunks/handler.mjs +1 -1
  6. package/dist/packem_chunks/handler10.mjs +4 -1
  7. package/dist/packem_chunks/handler11.mjs +2 -4
  8. package/dist/packem_chunks/handler12.mjs +1 -2
  9. package/dist/packem_chunks/handler13.mjs +1 -1
  10. package/dist/packem_chunks/handler14.mjs +1 -1
  11. package/dist/packem_chunks/handler15.mjs +1 -1
  12. package/dist/packem_chunks/handler16.mjs +3 -1
  13. package/dist/packem_chunks/handler17.mjs +1 -3
  14. package/dist/packem_chunks/handler18.mjs +1 -1
  15. package/dist/packem_chunks/handler19.mjs +7 -1
  16. package/dist/packem_chunks/handler2.mjs +2 -1
  17. package/dist/packem_chunks/handler20.mjs +1 -7
  18. package/dist/packem_chunks/handler21.mjs +3 -1
  19. package/dist/packem_chunks/handler22.mjs +3 -2
  20. package/dist/packem_chunks/handler23.mjs +1 -3
  21. package/dist/packem_chunks/handler24.mjs +2 -3
  22. package/dist/packem_chunks/handler25.mjs +99 -1
  23. package/dist/packem_chunks/handler26.mjs +10 -99
  24. package/dist/packem_chunks/handler3.mjs +1 -2
  25. package/dist/packem_chunks/handler4.mjs +1 -1
  26. package/dist/packem_chunks/handler5.mjs +1 -1
  27. package/dist/packem_chunks/handler6.mjs +1 -1
  28. package/dist/packem_chunks/handler7.mjs +3 -1
  29. package/dist/packem_chunks/handler8.mjs +1 -3
  30. package/dist/packem_chunks/handler9.mjs +1 -1
  31. package/dist/packem_chunks/planDevCommand.mjs +6 -6
  32. package/dist/packem_chunks/runDeployCommand.mjs +1 -0
  33. package/dist/packem_chunks/runInitCommand.mjs +89 -63
  34. package/dist/packem_chunks/runMigrateGenerateCommand.mjs +3 -3
  35. package/dist/packem_shared/{COMMANDS-Cf45cyJN.mjs → COMMANDS-BbQ3-hLn.mjs} +1 -1
  36. package/dist/packem_shared/{DEFAULT_IMPORT_BATCH_SIZE-CYq3UJmD.mjs → DEFAULT_IMPORT_BATCH_SIZE-BPQYMEmV.mjs} +1 -1
  37. package/dist/packem_shared/{buildRegistryIndex-BcJgAx76.mjs → buildRegistryIndex-DVmy8fHE.mjs} +1 -1
  38. package/dist/packem_shared/catalog-Cbzph90w.mjs +1 -0
  39. package/dist/packem_shared/cli-DOBnG22n.mjs +3 -0
  40. package/dist/packem_shared/commands-CLLQuHqU.mjs +15 -0
  41. package/dist/packem_shared/{diffSnapshots-Cnoe8Ob4.mjs → diffSnapshots-DtC5Cs4Z.mjs} +3 -3
  42. package/dist/packem_shared/{import-8FCB0cUX.mjs → import-DuHtoh4_.mjs} +7 -7
  43. package/dist/packem_shared/resolve-BWFT7RvE.mjs +5 -0
  44. package/dist/packem_shared/runAddCommand-BABRWlOb.mjs +1 -0
  45. package/dist/packem_shared/schemaIrToSnapshot-VpPguG3W.mjs +1 -0
  46. package/dist/packem_shared/{storage-D5s4vbtJ.mjs → storage-DlUnv7uG.mjs} +1 -1
  47. package/dist/packem_shared/vectorize-metadata-Br1QnnS8.mjs +1 -0
  48. package/package.json +11 -11
  49. package/skills/lunora-deploy/SKILL.md +42 -11
  50. package/skills/lunora-functions/SKILL.md +42 -14
  51. package/skills/lunora-migration-helper/SKILL.md +4 -4
  52. package/skills/lunora-performance-audit/SKILL.md +8 -5
  53. package/skills/lunora-quickstart/SKILL.md +3 -3
  54. package/skills/lunora-setup-auth/SKILL.md +23 -6
  55. package/skills/lunora-setup-hyperdrive/SKILL.md +33 -13
  56. package/skills/lunora-setup-mail/SKILL.md +34 -28
  57. package/skills/lunora-setup-scheduler/SKILL.md +15 -10
  58. package/skills/lunora-setup-storage/SKILL.md +182 -25
  59. package/dist/packem_chunks/handler27.mjs +0 -10
  60. package/dist/packem_shared/catalog-CJaormx0.mjs +0 -1
  61. package/dist/packem_shared/cli-CqNvbTR1.mjs +0 -3
  62. package/dist/packem_shared/commands-YfMX-Mto.mjs +0 -19
  63. package/dist/packem_shared/resolve-DZAGzg67.mjs +0 -1
  64. package/dist/packem_shared/runAddCommand-vE21wRIK.mjs +0 -1
  65. package/dist/packem_shared/runDeployCommand-o64lz-UD.mjs +0 -1
  66. package/dist/packem_shared/schemaIrToSnapshot-ogkcpHjM.mjs +0 -1
  67. package/dist/packem_shared/vectorize-metadata-DbziRKpX.mjs +0 -1
@@ -1,3 +0,0 @@
1
- import{mkdirSync as O,readFileSync as w,lstatSync as A,writeFileSync as B}from"node:fs";import{join as u,dirname as f}from"node:path";import{fileURLToPath as D}from"node:url";import{resolveHint as E,isLunoraError as k,flattenHint as L,findSolutionByMessage as j}from"@lunora/errors";import{createCerebro as _}from"@visulima/cerebro";import I from"@visulima/cerebro/command/completion";import T from"@visulima/cerebro/command/version";import{A as p,T as s}from"./deploy-target-B0Xcb2jV.mjs";import{SDK_LANGUAGES as P}from"@lunora/codegen";import{createLogger as S}from"./createLogger-hGafwf-3.mjs";import{VisulimaError as U,renderError as M}from"@visulima/error";import{homedir as W}from"node:os";import{addArgsFor as J,detectPackageManager as K}from"@lunora/config";const F={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 auth-ui","Add copy-in auth screens for your framework (auto-detected)"],["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/handler2.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}]},y="lunora.advisor.map.json",H={description:"Score your app's advisor findings into a health map, and gate CI on it",examples:[["lunora advisor","Score the app and write lunora.advisor.map.json"],["lunora advisor --all","Show every procedure as a check matrix"],["lunora advisor --entry messages#sendMessage","Inspect one procedure"],["lunora advisor --min-score 80","Exit non-zero when the score drops below 80"],["lunora advisor --baseline","Fail on any regression against the committed map"]],group:"Develop",loader:()=>import("../packem_chunks/handler20.mjs").then(e=>({default:e.execute})),name:"advisor",options:[{description:"Show every procedure as a check matrix, not just the ones with findings",name:"all",type:Boolean},{description:`Compare against a committed map and fail on regression (default ${y})`,name:"baseline",type:String},{description:"Inspect a single procedure by `file#exportName`",name:"entry",type:String},{description:"Output format: pretty (default) or json",name:"format",type:String},{description:"Exit non-zero when the global score is below this value (0-100)",name:"min-score",type:String},{description:`Where to write the map (default ${y})`,name:"out",type:String},{description:"Write the map artifact to disk (the default)",name:"write",type:Boolean},{description:"Don't write the map artifact to disk — report only",name:"no-write",type:Boolean}]},$={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/handler3.mjs").then(e=>({default:e.execute})),name:"analyze",options:[{description:"Emit a JSON report instead of human text",name:"json",type:Boolean}]},V={argument:{description:"create | list | restore <id|file> | retention | prune | pitr",name:"subcommand",type:String},description:"Managed snapshot backups (create | list | restore) to a directory or an R2 bucket, 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 create --bucket default","Snapshot into an R2 bucket instead of a directory"],["lunora backup restore <id> --bucket default --verify","Restore from R2, checksum first"],["lunora backup retention","Show what the platform's retention would delete next"],["lunora backup prune","Delete the snapshots past the retention window (the only command that deletes backups)"],["lunora backup pitr --at 2026-06-01T00:00:00Z","Point-in-time recovery (≤30 days)"]],group:"Data",loader:()=>import("../packem_chunks/handler24.mjs").then(e=>({default:e.execute})),name:"backup",options:[{description:"Backup directory (default .lunora-backups)",name:"dir",type:String},{description:"Store snapshots in this R2 bucket instead of a directory (use `default` for the app's default bucket)",name:"bucket",type:String},{description:"Key prefix for bucket-backed snapshots (default backups/)",name:"prefix",type:String},{description:"restore: verify the snapshot's checksum before importing anything",name:"verify",type:Boolean},{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 destructive step without prompting: a production pitr --restore, or backup prune",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}]},G={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"],["lunora build --emit-bindings bindings.json","Also write what the bundle needs provisioned, for an external deployer"]],group:"Deploy",loader:()=>import("../packem_chunks/handler21.mjs").then(e=>({default:e.execute})),name:"build",options:[{description:"Override the schema-drift gate for this run (build even with breaking schema drift and no migration; the committed baseline is not advanced)",name:"allow-schema-drift",type:Boolean},{description:`Which API spec(s) to emit: ${p} (default openapi)`,name:"api-spec",type:String},{description:"Write a JSON manifest of the bindings + crons the bundle needs to this path, for an IaC program to consume",name:"emit-bindings",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},s]},q={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: ${p} (default openapi)`,name:"api-spec",type:String},{description:"Output format: pretty (default) or json",name:"format",type:String},{description:"Fail on ERROR-level advisories even locally (the gate already defaults to on in CI)",name:"strict-advisories",type:Boolean},{description:"Don't fail on ERROR-level advisories (the gate defaults to on in CI, off locally)",name:"no-strict-advisories",type:Boolean},s]},z={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/handler4.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}]},Y={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("./runDeployCommand-o64lz-UD.mjs").then(e=>({default:e.execute})),name:"deploy",options:[{description:"Override the schema-drift gate for this run (deploy even with breaking schema drift and no migration; the committed baseline is not advanced — use --update-schema-baseline to accept the new shape)",name:"allow-schema-drift",type:Boolean},{description:`Which API spec(s) to emit: ${p} (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 the deploy, probe the new version's health route (/_lunora/health/ready, falling back to /_lunora/health) and fail if it never answers",name:"health-check",type:Boolean},{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:"Fail the deploy on ERROR-level codegen advisories even locally (the gate already defaults to on in CI)",name:"strict-advisories",type:Boolean},{description:"Don't fail the deploy on ERROR-level codegen advisories (the gate defaults to on in CI, off locally). Never downgrades platform diagnostics.",name:"no-strict-advisories",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},s,{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}]},Q={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/handler5.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}]},X={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, ready/starting)"],["lunora dev status --json","Same as JSON — poll `.ready` to gate a dependent step in a task graph"],["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 --emit-bindings dev-manifest.json","Write what this worker needs + where it serves, for a task runner"],["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: ${p} (default openapi)`,name:"api-spec",type:String},{description:"Write the binding manifest (plus the dev origin) to <file>, for a supervisor that owns the rest of the graph",name:"emit-bindings",type:String},{description:"Studio server port (default 6173)",name:"port",type:Number},s,{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:"Serve the embedded studio at /__lunora (default)",name:"studio",type:Boolean},{description:"Don't start the embedded studio server",name:"no-studio",type:Boolean},{description:"Spawn wrangler dev for the worker (default)",name:"worker",type:Boolean},{description:"Don't spawn wrangler dev — an external task runner owns the worker; codegen watch + studio still run",name:"no-worker",type:Boolean},{description:"Run codegen on startup and watch for changes (default)",name:"codegen",type:Boolean},{description:"Don't run codegen — no watch, no startup generate (or set LUNORA_CODEGEN=0)",name:"no-codegen",type:Boolean},{description:"Proxy D1/KV/R2 bindings to the deployed worker (or set LUNORA_REMOTE=1)",name:"remote",type:Boolean}]},Z={argument:{description:"Optional path under the docs site (e.g. packages/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 packages/studio","Open a specific docs section"]],group:"Project",loader:()=>import("../packem_chunks/handler6.mjs").then(e=>({default:e.execute})),name:"docs"},ee={description:"Preflight the current Lunora project (wrangler bindings, placeholders, dev secrets)",examples:[["lunora doctor","Run the project preflight checks"],["lunora doctor --format json","Emit the findings as a machine-readable JSON document"]],group:"Project",loader:()=>import("../packem_chunks/handler7.mjs").then(e=>({default:e.execute})),name:"doctor",options:[{description:"Output format: pretty (default) or json",name:"format",type:String}]},te={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/handler8.mjs").then(e=>({default:e.execute})),name:"env",options:[{description:"Target this Cloudflare environment for `push`/`diff` (passes --env <name> to wrangler)",name:"env",type:String},{description:"Alias for --env production",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}]},re={description:"Run every *.eval.ts under evals/ via @lunora/testing's evaluate/agentHarness — no live worker needed",examples:[["lunora eval","Run every eval under evals/, print the aggregate table"],["lunora eval --threshold 0.8","Non-zero exit if any eval's average score falls below 0.8"],["lunora eval --dir evals/support --format json","Run a subset and emit a machine-readable result"]],group:"Develop",loader:()=>import("../packem_chunks/handler25.mjs").then(e=>({default:e.execute})),name:"eval",options:[{description:"Directory to discover *.eval.ts files under (default evals/)",name:"dir",type:String},{description:"Output format: pretty (default) or json",name:"format",type:String},{description:"Score gate every eval's average must meet ([0,1]); a per-eval `threshold` export wins over this for that eval",name:"threshold",type:Number}]},oe={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/handler9.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}]},ne={argument:{description:"Source NDJSON file, or a `npx convex export --path <dir>` directory",name:"file",type:String},description:"Bulk-insert rows from an NDJSON file — or a Convex export directory — via the worker's admin endpoint",examples:[["lunora import backup.ndjson","Bulk-insert rows from an NDJSON file"],["lunora import ./convex-export","Import a `npx convex export --path` directory (ids are preserved, so no remapping)"],["lunora import ./convex-export --with-storage","Also migrate blobs (verified sha256 upload) + `{ $storage }` refs"],["lunora import ./convex-export --scan","Write a candidate `lunora/import-convex.json` storage-column mapping (imports nothing)"],["lunora import ./snapshot.zip --with-storage --verify","Import a `npx convex export --path` zip snapshot with blob + row-parity checks"],["lunora import ./supabase-csv --from supabase","Import a directory of `COPY … TO STDOUT WITH CSV HEADER` dumps"],["lunora import ./firestore-json --from firebase --verify","Import Firestore documents (REST/Admin-SDK JSON) with row-parity checks"]],group:"Data",loader:()=>import("../packem_chunks/handler10.mjs").then(e=>({default:e.execute})),name:"import",options:[{description:"Source reader for a dump that cannot be detected: supabase | firebase (Convex and NDJSON are auto-detected)",name:"from",type:String},{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:"Also migrate file storage — Convex `_storage` blobs, or a Supabase/Firebase bucket (verified upload)",name:"with-storage",type:Boolean},{description:"Directory of storage objects to upload alongside the rows (Firebase: after `gcloud storage cp -r`)",name:"storage-dir",type:String},{description:"Write a candidate `lunora/import-convex.json` storage-column mapping and exit",name:"scan",type:Boolean},{description:"Verify row parity + dangling-storage after import (non-zero exit on mismatch)",name:"verify",type:Boolean},{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}]},ae={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"],["lunora info --bindings","List what this Worker needs provisioned: bindings, crons, vars"],["lunora info --bindings --json","Emit the manifest a deployer or task runner consumes"],["lunora info --bindings --out reqs.json","Write that manifest to a file"]],group:"Project",loader:()=>import("../packem_chunks/handler11.mjs").then(e=>({default:e.execute})),name:"info",options:[{description:"Report only what this Worker needs provisioned, as the binding manifest",name:"bindings",type:Boolean},{description:"Emit JSON instead of human text",name:"json",type:Boolean},{description:"With --bindings: write the manifest to <file> instead of stdout",name:"out",type:String}]},ie={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 -t solid-v2","Scaffold a Solid 2.0 SPA"],["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:"Template: analog | astro | expo | next | nuxt | react-router | solid-v2 | standalone | sveltekit | tanstack-start-react | tanstack-start-solid | vinext | vinext-pages. Also accepts an overlay framework (react | vue | solid | svelte), same as --vite.",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}]},se={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/handler12.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}]},le={description:"Scaffold lunora/schema.ts (and list/get procedures) from an existing Postgres or MySQL database",examples:[["lunora introspect --url postgres://localhost/shop","Scaffold a schema + procedures from every table"],["lunora introspect --tables users,orders","Introspect only these tables (DATABASE_URL is read by default)"],["lunora introspect --dry-run","Print what would be written without touching the filesystem"],["lunora introspect --no-procedures --force","Regenerate just the schema, overwriting the existing file"]],group:"Data",loader:()=>import("../packem_chunks/handler26.mjs").then(e=>({default:e.execute})),name:"introspect",options:[{description:"Database connection string (default: $DATABASE_URL)",name:"url",type:String},{description:"Postgres schema (default `public`) or MySQL database name",name:"schema",type:String},{description:"Comma-separated table allow-list (default: every base table)",name:"tables",type:String},{description:"Also emit list/get procedure modules per table (the default)",name:"procedures",type:Boolean},{description:"Emit only the schema — skip the per-table list/get procedure modules",name:"no-procedures",type:Boolean},{description:"Overwrite files that already exist",name:"force",type:Boolean},{description:"Print what would be written without writing it",name:"dry-run",type:Boolean}]},pe={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/handler13.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}]},de={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/handler22.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},s,{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 opaque cursor token printed by the previous page (bare epoch-millis also accepted for back-compat)",name:"cursor",type:String},{description:"durable: emit one JSON object per line instead of a table",name:"ndjson",type:Boolean}]},ce={argument:{description:"install [client…] | uninstall [client…] | serve",name:"args",type:String},description:"Connect your AI editor to Lunora over MCP (docs search + this project's dev server)",examples:[["lunora mcp install","Install into every MCP client already configured here"],["lunora mcp install claude-code cursor","Install into specific clients"],["lunora mcp install --list","List the supported clients and their config files"],["lunora mcp install --docs-only","Install only the hosted documentation server"],["lunora mcp install --print","Show the config that would be written, without writing it"],["lunora mcp install --global","Force every server into the machine-wide config"],["lunora mcp uninstall","Remove Lunora's MCP servers from every supported client"],["lunora mcp uninstall cursor","Remove them from one client"],["lunora mcp uninstall --print","Show what would be removed, without removing it"],["lunora mcp serve","Run the stdio MCP server (this is what your editor spawns)"],["lunora mcp serve --allow-writes","Also expose the mutation/action tools"],["lunora mcp serve --token $LUNORA_ADMIN_TOKEN","Expose the observability tools (logs, issues, advisories, insights, migrations) too"]],group:"Develop",loader:()=>import("../packem_chunks/handler27.mjs").then(e=>({default:e.execute})),name:"mcp",options:[{description:"install: replace entries that already exist",name:"force",type:Boolean},{description:"install: list the supported clients and their config files",name:"list",type:Boolean},{description:"install/uninstall: print what would change instead of writing it",name:"print",type:Boolean},{description:"install/uninstall: only the hosted documentation server",name:"docs-only",type:Boolean},{description:"install/uninstall: only this project's local server",name:"local-only",type:Boolean},{description:"install/uninstall: the machine-wide config (install default: docs server global, local server per-project)",name:"global",type:Boolean},{description:"install/uninstall: this project's config instead of the machine-wide one",name:"project",type:Boolean},{description:"serve: also expose the mutation/action tools (default: read-only)",name:"allow-writes",type:Boolean},{description:"serve: expose the documentation tools (default)",name:"docs",type:Boolean},{description:"serve: skip the documentation tools",name:"no-docs",type:Boolean},{description:"Docs site origin backing the documentation tools (default https://lunora.sh)",name:"docs-url",type:String},{description:"serve: deployment URL to expose (default: the running dev server)",name:"url",type:String},{description:"serve: bearer token (default: LUNORA_ADMIN_TOKEN from the environment or .dev.vars). Also gates the observability tools (logs, issues, advisories, query insights, migration status) — without a token they are not exposed at all",name:"token",type:String}]},ue={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}]},me={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/handler14.mjs").then(e=>({default:e.execute})),name:"prepare",options:[{description:"Override the schema-drift gate for this run (proceed even with breaking schema drift and no migration; the committed baseline is not advanced)",name:"allow-schema-drift",type:Boolean},{description:`Which API spec(s) to emit: ${p} (default openapi)`,name:"api-spec",type:String},s,{description:"Re-bless the committed schema baseline (lunora/.lunora-schema.json) with the current shape",name:"update-schema-baseline",type:Boolean}]},he={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/handler15.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}]},ge={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}]},fe={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)"],["lunora rules install --dir packages/app","Install into a specific root instead of the workspace root"]],group:"Project",loader:()=>import("../packem_chunks/handler16.mjs").then(e=>({default:e.execute})),name:"rules",options:[{description:"Install/check root (default: the detected workspace root, not the current directory)",name:"dir",type:String},{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}]},ye={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"],["lunora run messages:list --as user_123","Run as an authenticated user (needed when the app gates on identity)"]],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:"Run as this user id — dispatches through the admin-gated `runAs` op so identity-gated apps accept the call",name:"as",type:String},{description:`JSON-encoded extra identity claims to forge alongside --as (e.g. '{"org":"acme"}')`,name:"claims",type:String},{description:"Explicit shard key",name:"shard",type:String},{description:"Worker URL (defaults to the running dev server, else http://localhost:8787)",name:"url",type:String},{description:"Admin bearer for --as (prefer LUNORA_ADMIN_TOKEN or .dev.vars; --token is visible to other local processes via the process table)",name:"token",type:String}]},ve={argument:{description:"<generate>",name:"args",type:String},description:"Generate a self-contained typed client SDK for another language from the project's OpenRPC surface",examples:[["lunora sdk generate --lang python","Emit a Python SDK, transport included, into ./sdk/python"],["lunora sdk generate --lang go --out ./clients/go","Choose the language and output directory"],["lunora sdk generate --lang dart","A Flutter-ready Dart client — live queries arrive as a Stream"],["lunora sdk generate --lang kotlin","Any of the registered targets; --lang lists them"],["lunora sdk generate --lang rust --from ./sdks","Copy the transport from a local checkout instead of fetching it"]],group:"Project",loader:()=>import("../packem_chunks/handler23.mjs").then(e=>({default:e.execute})),name:"sdk",options:[{description:`Target language: ${P.join(" | ")}`,name:"lang",type:String},{description:"Output directory (default ./sdk/<lang>)",name:"out",type:String},{description:"Path to the OpenRPC document (default ./lunora/_generated/openrpc.json)",name:"spec",type:String},{description:"Copy the transport from a local directory of per-language transports (the repo's `sdks/`) instead of fetching it",name:"from",type:String},{description:"Git ref to fetch the transport from (default: this CLI's own release tag, so the transport matches the generated surface)",name:"ref",type:String},{description:"Override the remote transport source base (default gh:anolilab/lunora/sdks)",name:"source",type:String},{description:"Permit --source values outside gh:/github:/https://",name:"allow-unsafe-source",type:Boolean}]},be={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"],["lunora seed --seed 7 --now 1785000000000","Byte-identical rows across runs (pins the clock too)"]],group:"Data",loader:()=>import("../packem_chunks/handler17.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:"Epoch-ms reference for time columns (createdAt, expiresAt, …). Pin it with --seed for byte-identical rows across runs; defaults to now",name:"now",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}]},we={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/handler18.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: ${p} (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:"Run the TypeScript type-check step (default)",name:"typecheck",type:Boolean},{description:"Skip the TypeScript type-check step",name:"no-typecheck",type:Boolean},s]},ke={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/handler19.mjs").then(e=>({default:e.execute})),name:"view",options:[{description:"Open the deployed worker URL instead of localhost",name:"remote",type:Boolean}]},Se={filterStacktrace:()=>!1,hideErrorCodeView:!0},xe=(e,t={})=>{const r=e instanceof Error?e.message:String(e),o=E(k(e)?{code:e.code,hint:e.hint,message:r}:r),n=new U({hint:o===void 0?void 0:L(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="",M(n,Se)},Ce=(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,d=e[o-1]===t[a-1]?0:1;r[a]=Math.min((r[a-1]??0)+1,i+1,n+d),n=i}}return r[t.length]??0},Ne=(e,t)=>{let r,o=Number.POSITIVE_INFINITY;for(const a of t){const i=Ce(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},Re=e=>`https://registry.npmjs.org/@lunora/cli/${e}`,Oe=1440*60*1e3,Ae=1500,Be="0.0.0",De=/^v/u,Ee=new Set(["alpha","beta","next"]),m=e=>{const t=e.trim().replace(De,""),r=t.indexOf("-");return r===-1?{core:t,prerelease:""}:{core:t.slice(0,r),prerelease:t.slice(r+1)}},v=e=>{const[t,r,o]=m(e).core.split(".").map(n=>{const a=Number.parseInt(n,10);return Number.isFinite(a)?a:0});return[t??0,r??0,o??0]},Le=(e,t)=>{const r=Number.parseInt(e,10),o=Number.parseInt(t,10);return String(r)===e&&String(o)===t?r>o?1:-1:e>t?1:-1},je=(e,t)=>{if(e===t)return 0;if(e===""||t==="")return e===""?1:-1;const r=e.split("."),o=t.split(".");for(let n=0;n<Math.max(r.length,o.length);n+=1){const a=r[n],i=o[n];if(a===void 0||i===void 0)return a===void 0?-1:1;if(a!==i)return Le(a,i)}return 0},_e=(e,t)=>{const r=v(e),o=v(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 je(m(e).prerelease,m(t).prerelease)},Ie=e=>{const t=m(e).prerelease.split(".")[0]??"";return Ee.has(t)?t:"latest"},Te=(e,t)=>_e(t,e)>0,Pe=(e,t,r)=>t-e<r,Ue=(e,t,r="latest",o)=>{const n=`Update available for @lunora/cli: ${e} → ${t}`;if(o===void 0)return`${n} — add @lunora/cli@${r} as a dev dependency to update`;const{args:a,command:i}=J(o,[`@lunora/cli@${r}`],{dev:!0});return`${n} — run \`${i} ${a.join(" ")}\``},x=e=>u(e,"lunora-cli-update.json"),Me=e=>{const t=e.XDG_CACHE_HOME&&e.XDG_CACHE_HOME.length>0?e.XDG_CACHE_HOME:u(W(),".cache"),r=u(t,"lunora");try{O(r,{mode:448,recursive:!0})}catch{}return r},We=e=>{try{const t=JSON.parse(w(x(e),"utf8"));if(t!==null&&typeof t=="object"){const{checkedAt:r,latest:o}=t;if(typeof o=="string"&&typeof r=="number"){const{tag:n}=t;return{checkedAt:r,latest:o,...typeof n=="string"?{tag:n}:{}}}}}catch{}},b=(e,t)=>{try{const r=x(e);try{if(A(r).isSymbolicLink())return}catch{}B(r,`${JSON.stringify(t)}
3
- `,"utf8")}catch{}},Je=async(e,t)=>{try{const r=await e(Re(t),{signal:AbortSignal.timeout(Ae)});if(!r.ok)return;const o=await r.json(),n=o!==null&&typeof o=="object"?o.version:void 0;return typeof n=="string"?n:void 0}catch{return}},Ke=(e,t,r)=>e===Be||!r||t.CI!==void 0||t.LUNORA_NO_UPDATE_NOTIFIER!==void 0,Fe=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??Me(t),n=(e.now??Date.now)(),a=e.ttlMs??Oe,i=Ie(e.current),d=We(o),R=d?.tag??"latest",h=d!==void 0&&R===i?d:void 0;let c=h?.latest;if(h===void 0||!Pe(h.checkedAt,n,a)){const g=await Je(e.fetchImpl??globalThis.fetch,i);g===void 0?b(o,{checkedAt:n,latest:e.current,tag:i}):(c=g,b(o,{checkedAt:n,latest:g,tag:i}))}c!==void 0&&Te(e.current,c)&&e.logger.warn(Ue(e.current,c,i,e.manager))},He=["init","add","dev","codegen","build","deploy","containers","prepare","link","deployments","logs","run","insights","reset","migrate","export","import","seed","backup","eval","verify","info","doctor","env","analyze","view","docs","registry","rules","mcp"],$e=8,Ve=()=>{try{let e=f(D(import.meta.url));for(let t=0;t<$e;t+=1){try{const o=JSON.parse(w(u(e,"package.json"),"utf8")),n=o!==null&&typeof o=="object"?o:void 0;if(n?.name==="@lunora/cli"&&typeof n.version=="string"&&n.version.length>0)return n.version}catch{}const r=f(e);if(r===e)break;e=r}}catch{}return"0.0.0"},C=Ve(),Ge=[ie,F,X,q,H,G,Y,z,me,pe,Q,de,ye,se,ge,ue,oe,ne,be,le,V,re,we,ae,ee,te,$,ke,Z,he,fe,ce,ve],N=[...Ge,T,I],ut=N.map(e=>e.name),l=e=>e.replaceAll("{",String.raw`\{`).replaceAll("}",String.raw`\}`),qe=e=>e.every(t=>typeof t=="string")?e.map(t=>l(t)):e.map(t=>typeof t=="string"?[l(t)]:t.map(r=>l(r))),ze=e=>({...e,...e.argument===void 0?{}:{argument:{...e.argument,description:l(e.argument.description??"")}},...e.description===void 0?{}:{description:l(e.description)},...e.examples===void 0?{}:{examples:qe(e.examples)},...e.options===void 0?{}:{options:e.options.map(t=>({...t,description:l(t.description??"")}))}}),Ye=e=>{const t={value:0},r=_("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:C});for(const o of N)r.addCommand(ze(o));return{cli:r,exitCode:t}},Qe=/Command "(?<name>[^"]+)" not found/u,Xe=e=>{const t=S(),r=e instanceof Error?e.message:String(e),o=Qe.exec(r);if(!o?.groups){k(e)||j(r)!==void 0?t.error(xe(e)):t.error(r);return}const n=o.groups.name??"",a=Ne(n,He);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.")},mt=async(e={})=>{const{cli:t,exitCode:r}=Ye(e);try{await t.run({shouldExitProcess:!1})}catch(n){return Xe(n),1}let o;try{o=K(process.cwd())}catch{}return await Fe({current:C,logger:S(),manager:o}),r.value};export{He as C,y as D,ut as R,C as V,mt as r};
@@ -1,19 +0,0 @@
1
- import{existsSync as h,readFileSync as g,writeFileSync as v,mkdirSync as x,lstatSync as U}from"node:fs";import{join as p,relative as F,dirname as k}from"@visulima/path";import{DEV_VARS_FILE as G,parseDevVariableEntries as H,writeDevVariablesFileAtomically as Y,installArgsFor as z,detectPackageManager as X}from"@lunora/config";import{modify as T,applyEdits as C,parse as Q}from"jsonc-parser";import{d as Z,s as E,e as K,f as ee,c as ne,g as te}from"./resolve-DZAGzg67.mjs";import{b as re}from"./tui-prompts-Dd0pDuNr.mjs";import{s as u,c as se,b as ie}from"./catalog-CJaormx0.mjs";import{findWranglerFile as oe,readWranglerJsonc as ae}from"@lunora/config/cloudflare";import{LunoraError as j}from"@lunora/errors";import{insertSchemaExtension as ce}from"./insertSchemaExtension-DY4pA8wE.mjs";import{createHash as de}from"node:crypto";const B=e=>{if(!e.startsWith("workspace:"))return e;const n=e.slice(10);return n===""||n==="*"||n==="^"||n==="~"?Z():n},ue=new Set(["@lunora/client","@lunora/do","@lunora/ratelimit","@lunora/runtime","@lunora/server","@lunora/values"]),fe=/(['"])@lunora\/(client|do|ratelimit|runtime|server|values)(\/[^'"]*)?\1/gu,le=e=>{const n=p(e,"package.json");if(!h(n))return!1;try{const t=JSON.parse(g(n,"utf8"));return t.dependencies?.lunorash!==void 0||t.devDependencies?.lunorash!==void 0}catch{return!1}},pe=e=>e.replaceAll(fe,(n,t,i,r)=>`${t}lunorash/${i}${r??""}${t}`),O=(e,n,t,i="dependencies",r=!1)=>{const s=Object.entries(e);if(s.length===0)return[];const o=p(n,"package.json");if(!h(o))return t.warn(`package.json not found at ${o} — skipping dependency updates`),[];let a=g(o,"utf8");const c=JSON.parse(a),d=[];for(const[f,l]of s){if(r&&ue.has(f)){t.info(`dep provided by the lunorash umbrella, skipping: ${f}`);continue}if(c.dependencies?.[f]!==void 0||c.devDependencies?.[f]!==void 0){t.info(`dep already present: ${f}`);continue}const m=T(a,[i,f],B(l),{formattingOptions:{insertSpaces:!0,tabSize:4}});a=C(a,m),d.push(f)}return d.length>0&&(v(o,a,"utf8"),t.success(`added ${String(d.length)} ${i==="devDependencies"?"devDependency(ies)":"dependency(ies)"} to package.json: ${d.join(", ")}`)),d},me=(e,n,t)=>{if(e.length===0)return[];const i=p(n,G),r=h(i)?g(i,"utf8"):"",s=new Set(H(r).map(d=>d.key)),o=[],a=[],c=[];for(const d of e)d.secret&&a.push(d.name),!s.has(d.name)&&(d.description&&c.push(`# ${d.description}`),c.push(`${d.name}=${d.secret?"":d.value??""}`),o.push(d.name));if(o.length>0){const d=r===""||r.endsWith(`
2
- `)?r:`${r}
3
- `;Y(i,`${d}${c.join(`
4
- `)}
5
- `),t.success(`scaffolded ${String(o.length)} env var(s) into .dev.vars: ${o.join(", ")}`)}return a.length>0&&t.info(`set secret value(s) locally in .dev.vars, then for production: ${a.map(d=>`wrangler secret put ${d}`).join("; ")}`),o},D=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"]),he=["binding","name","queue","pattern"],N=e=>{if(!(typeof e!="object"||e===null))for(const n of he){const t=e[n];if(typeof t=="string"&&t.length>0)return`${n}:${t}`}},ge=(e,n,t,i)=>{const r=new Set(e.map(a=>JSON.stringify(a))),s=new Set(e.map(a=>N(a)).filter(a=>a!==void 0)),o=[];for(const a of n){if(r.has(JSON.stringify(a)))continue;const c=N(a);if(c!==void 0&&s.has(c)){i.warn(`${c.replace(":"," ")} already exists in ${t} — keeping the project's entry and skipping the registry item's. Reconcile by hand if the item needs different settings.`);continue}c!==void 0&&s.add(c),o.push(a)}return o},A=e=>Array.isArray(e),$e=(e,n)=>{let t=Q(e);for(const i of n){if(typeof t!="object"||t===null)return;t=t[i]}return t},ve=(e,n)=>{const t=e[0];return t!==void 0&&D.has(t)?!0:(n.warn(`skipping binding "${e.join(".")}" — only resource bindings (${[...D].join(", ")}) may be written, not exec/entrypoint keys`),!1)},V=Symbol("skip-binding"),ye=(e,n,t)=>{const{value:i}=n;if(!A(i))return i;const r=$e(e,n.path);if(!A(r))return i;const s=ge(r,i,n.path.join("."),t);return s.length===0?V:[...r,...s]},we=(e,n,t)=>{if(e.length===0)return[];const r=["wrangler.jsonc","wrangler.json"].map(a=>p(n,a)).find(a=>h(a));if(!r)return t.warn("wrangler.jsonc not found — skipping binding updates"),[];let s=g(r,"utf8");const o=[];for(const a of e){if(!ve(a.path,t))continue;const c=ye(s,a,t);if(c===V)continue;const d=T(s,[...a.path],c,{formattingOptions:{insertSpaces:!0,tabSize:4}});d.length!==0&&(s=C(s,d),o.push(a.path.join(".")))}return o.length>0&&(v(r,s,"utf8"),t.success(`applied ${String(o.length)} binding(s) to ${r}: ${o.join(", ")}`)),o},ke=(e,n,t,i=!1)=>{const r=[],s=[];return e.deps&&r.push(...O(e.deps,n,t,"dependencies",i)),e.devDependencies&&r.push(...O(e.devDependencies,n,t,"devDependencies",i)),e.bindings&&s.push(...we(e.bindings,n,t)),e.envVars&&me(e.envVars,n,t),{bindings:s,deps:r}},be=e=>e.source!==void 0&&e.source.length>0||e.from!==void 0&&e.from.length>0,Se=async(e,n)=>{const t=e.some(({manifest:d})=>Object.keys(d.deps??{}).length>0||Object.keys(d.devDependencies??{}).length>0),i=e.some(({manifest:d})=>(d.bindings??[]).length>0),r=be(n);if(!t&&!i&&!r||n.yes)return!0;const s=[];t&&s.push("add dependencies to package.json"),i&&s.push("write wrangler.jsonc bindings"),r&&s.push(`come from a custom registry source (${String(n.from??n.source)})`);const o=s.join(", ");if(!process.stdin.isTTY&&n.confirm===void 0)return n.logger.error(`add: stdin is not a TTY and the requested items ${o} — re-run with --yes to confirm`),!1;const c=await(n.confirm??re)(`The requested items ${o}. Continue?`);return c||n.logger.info("add: aborted"),c},S=1,xe=".lunora-registry.json",W=e=>p(e,"lunora",xe),je=e=>typeof e!="object"||e===null||!("items"in e)?!1:typeof e.items=="object"&&e.items!==null,w=e=>de("sha256").update(e).digest("hex"),Ee=e=>{const n=W(e);if(!h(n))return{items:{},version:S};try{const t=JSON.parse(g(n,"utf8"));if(je(t))return{items:t.items,version:S}}catch{}return{items:{},version:S}},Re=(e,n)=>{v(W(e),`${JSON.stringify(n,void 0,2)}
6
- `,"utf8")},_=(e,n,t,i)=>{const r=e.items[n]??{files:{}};e.items[n]=r,r.files[t]=w(i)},Oe=(e,n,t)=>e.items[n]?.files[t],L=3,P=e=>e===""?[]:e.split(`
7
- `),De=(e,n)=>{const t=P(e),i=P(n);let r=0;for(;r<t.length&&r<i.length&&t[r]===i[r];)r+=1;let s=t.length,o=i.length;for(;s>r&&o>r&&t[s-1]===i[o-1];)s-=1,o-=1;if(r===s&&r===o)return[];const a=[];for(let c=Math.max(0,r-L);c<r;c+=1)a.push(` ${t[c]??""}`);for(let c=r;c<s;c+=1)a.push(`- ${t[c]??""}`);for(let c=r;c<o;c+=1)a.push(`+ ${i[c]??""}`);for(let c=o;c<Math.min(i.length,o+L);c+=1)a.push(` ${i[c]??""}`);return a},Ne=/\.[cm]?[jt]sx?$/u,R=(e,n,t,i)=>{const r=p(e,n.from);if(U(r).isSymbolicLink())throw new j("INTERNAL",`registry item "${i}": refusing to read "${n.from}" — it is a symlink, not a regular file`);const s=g(r,"utf8");return t&&Ne.test(n.to)?pe(s):s},Ae=(e,n,t,i,r,s,o)=>{const a=p(i,"lunora","schema.ts");if(s)return r.info(`~ would merge .extend(${n}.extension) into lunora/schema.ts (and create ${e.to} if absent)`),{kind:"skipped",path:a};const c=p(i,e.to);h(c)||(x(k(c),{recursive:!0}),v(c,R(t,e,o,n),"utf8"));const d=o?"lunorash/server":"@lunora/server",f=h(a)?g(a,"utf8"):`import { defineSchema } from "${d}";
8
-
9
- export const schema = defineSchema({});
10
- `,l=ce(f,n);if(l.ok)return x(k(a),{recursive:!0}),v(a,l.text,"utf8"),r.success(`merged .extend(${n}.extension) into lunora/schema.ts`),{kind:"written",path:a};if(l.reason==="already-applied")return r.warn(`lunora/schema.ts already extends "${n}" — skipping`),{kind:"skipped",path:a};throw l.reason==="invalid-identifier"?new j("INTERNAL",`schema-extension item "${n}" is not a valid JS identifier — it is spliced into lunora/schema.ts as \`import { ${n} }\` / \`.extend(${n}.extension)\`. Rename the item to a valid identifier (no leading digit, no "-").`):new j("INTERNAL",`schema-extension merge failed for "${n}": ${l.reason}`)},_e=(e,n,t,i,r)=>{const s=De(n,t);if(s.length===0){r.info(`= ${e.to} (unchanged)`);return}r.info(`${i?"~":"+"} ${e.to}`);for(const o of s)r.info(` ${o}`)},Le=(e,n,t,i,r,s,o,a)=>{const c=p(i,e.to),d=R(t,e,a,n),f=h(c),l=f?g(c,"utf8"):"",m=q=>(x(k(c),{recursive:!0}),v(c,d,"utf8"),_(s,n,e.to,d),r.success(`${q}: ${e.to}`),{kind:"written",path:c});if(o.diff)return _e(e,l,d,f,r),{kind:"skipped",path:c};if(!f)return m("write");const $=w(l);if($===w(d))return _(s,n,e.to,d),r.warn(`skip (exists): ${e.to}`),{kind:"skipped",path:c};if(o.overwrite)return m("overwrite");const y=Oe(s,n,e.to);return y===void 0?(r.warn(`skip (exists, untracked): ${e.to} — refusing to overwrite a file lunora didn't add (use --overwrite to force)`),{kind:"skipped",path:c}):y===$?m("update"):y===w(d)?(r.warn(`skip (locally edited): ${e.to}`),{kind:"skipped",path:c}):(v(`${c}.new`,d,"utf8"),r.warn(`conflict: ${e.to} has local edits and an upstream update — wrote ${e.to}.new (use --overwrite to take theirs)`),{kind:"skipped",path:c})},Pe=(e,n,t,i,r,s,o={},a=!1)=>e.merge==="schema-extension"?Ae(e,n,t,i,r,o.diff===!0,a):Le(e,n,t,i,r,s,o,a),I=["src/server.ts","src/server/index.ts","src/server/index.tsx","src/index.ts","src/worker.ts"],Ie=e=>{const n=oe(e);if(n===void 0)return;const{parsed:t}=ae(n);return typeof t?.main=="string"?t.main:void 0},Je=e=>{const n=Ie(e),t=n===void 0?I:[n,...I];for(const i of t){const r=p(e,i);if(!h(r))continue;const s=g(r,"utf8");if(!s.includes("createShardDO(")){if(i===n)break;continue}return{entryPath:r,main:i,source:s}}},Fe=(e,n,t)=>{const i=F(k(e),p(n,"lunora",t)).replaceAll("\\","/");return i.startsWith(".")?i:`./${i}`},Te=(e,n)=>{for(const t of e){const r=`Add \`export * from "${`./lunora/${t.module}.js`}"\` to your worker entry`,s=t.comment?` (${t.comment})`:"";n.warn(`${r}${s}`)}return 0},Ce=(e,n,t,i)=>{const r=[];for(const s of e){const o=Fe(n,t,s.module),a=o.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);new RegExp(String.raw`export\s+\*\s+from\s+["']${a}\.js["']`,"u").test(i)||(s.comment&&r.push(`
11
- // ${s.comment}`),r.push(`export * from "${o}.js";`))}return r},Be=(e,n,t,i)=>{if(e.length===0)return 0;const r=Je(n);if(r===void 0)return Te(e,t);const s=Ce(e,r.entryPath,n,r.source);if(s.length===0)return 0;if(i){for(const a of s)a!==""&&t.info(`~ entrypoint: ${a}`);return s.length}const o=r.source.endsWith(`
12
- `)?"":`
13
- `;return v(r.entryPath,`${r.source}${o}${s.join(`
14
- `)}
15
- `,"utf8"),t.success(`wrote ${String(s.length)} entrypoint re-export(s) to ${F(n,r.entryPath)}`),s.length},J=(e,n,t,i={})=>{const r=[],s=[],o=[],a=[],c=Ee(n),d=le(n);try{for(const{directory:f,manifest:l}of e){for(const $ of l.files){const y=Pe($,l.name,f,n,t,c,i,d);(y.kind==="written"?r:s).push(y.path)}if(l.entrypointReexports!==void 0&&Be(l.entrypointReexports,n,t,i.diff===!0),i.diff)continue;const m=ke(l,n,t,d);o.push(...m.deps),a.push(...m.bindings)}}finally{!i.diff&&Object.keys(c.items).length>0&&Re(n,c)}return{bindings:a,deps:o,skipped:s,written:r}},b=()=>({bindings:[],code:0,deps:[],skipped:[],written:[]}),tn=(e,n,t,i,r)=>e.bindings?{...e,bindings:e.bindings.map(s=>{if(s.path[0]!==n||!Array.isArray(s.value))return s;const o=s.value;return{...s,value:o.map(a=>typeof a=="object"&&a!==null&&a[t.key]===t.value?{...a,[i]:r}:a)}})}:e,M=(e,n)=>{const t=n.title??n.description;e.info(`plan: ${u(n.name)}${t?` — ${u(t)}`:""}`);for(const s of n.files)e.info(` file ${u(s.to)} (${u(s.merge)})`);const i=new Map,r=s=>{const o=i.get(s);if(o!==void 0)return o;const a=B(s);return i.set(s,a),a};for(const[s,o]of Object.entries(n.deps??{}))e.info(` dep ${u(s)}@${u(r(o))}`);for(const[s,o]of Object.entries(n.devDependencies??{}))e.info(` dev ${u(s)}@${u(r(o))}`);for(const s of n.bindings??[])e.info(` bind ${u(s.path.join("."))} = ${u(JSON.stringify(s.value))}`);for(const s of n.envVars??[]){const o=s.secret?" (secret)":` = ${u(JSON.stringify(s.value??""))}`;e.info(` env ${u(s.name)}${o}`)}for(const s of n.entrypointReexports??[]){const o=`./lunora/${u(s.module)}`,a=s.comment?` // ${u(s.comment)}`:"";e.info(` entry ${o}${a}`)}},Ve=e=>{const n=e.map(({manifest:t})=>({bindings:(t.bindings??[]).map(i=>({path:i.path.join("."),value:i.value})),deps:Object.keys(t.deps??{}),devDependencies:Object.keys(t.devDependencies??{}),entrypointReexports:(t.entrypointReexports??[]).map(i=>({module:i.module,...i.comment?{comment:i.comment}:{}})),envVars:(t.envVars??[]).map(i=>({name:i.name,...i.secret?{secret:!0}:{value:i.value??""}})),files:t.files.map(i=>({merge:i.merge,to:i.to})),name:t.name,requires:t.requires??[],title:t.title}));process.stdout.write(`${JSON.stringify({items:n},void 0,2)}
16
- `)},We=e=>{try{const{args:n,command:t}=z(X(e));return`${t} ${n.join(" ")}`}catch{return"<your-package-manager> install"}},Me=(e,n,t,i,r,s)=>{r.success(`add complete: ${String(t)} written, ${String(i)} skipped`),r.info("next steps:"),r.info(" lunora codegen # regenerate _generated/ so the new tables/functions appear"),n.length>0&&r.info(` ${We(s)} # install newly-added dependencies`);for(const{manifest:o}of e)o.docs&&r.info(`${u(o.name)}: ${u(o.docs)}`)},qe=async e=>{const n=b(),t=E("list",e);if(t)return e.logger.error(t),{...n,code:1};let i=()=>{};try{const r=await ee(e);i=r.cleanup;const s=se(r.root);if(e.json)return process.stdout.write(`${JSON.stringify(s,void 0,2)}
17
- `),n;e.logger.info(`available registry items (${String(s.length)}):`);for(const o of s)e.logger.info(` ${o.name}${o.description?` — ${o.description}`:""}`);return n}catch(r){return e.logger.error(u(`list failed: ${r instanceof Error?r.message:String(r)}`)),{...n,code:1}}finally{i()}},rn=async e=>{const n=e.cwd??process.cwd(),t=b();if(e.list)return qe(e);if(e.names.length===0)return e.logger.error("add requires at least one item name. Usage: lunora registry add <name> [...names]"),{...t,code:1};const i=E("add",e);if(i)return e.logger.error(i),{...t,code:1};let r=[];try{const{cleanups:s,items:o}=await K(e.names,e);r=s;const{transformManifest:a}=e,c=a?o.map($=>({...$,manifest:a($.manifest)})):o;for(const{manifest:$}of c)M(e.logger,$);if(e.json&&Ve(c),e.dryRun)return e.logger.info("dry-run: stopping before any files are written"),t;if(e.diff)return J(c,n,e.logger,{diff:!0}),e.logger.info("diff: preview only — re-run without --diff to apply"),t;if(!await Se(c,e))return{...t,code:1};const{bindings:d,deps:f,skipped:l,written:m}=J(c,n,e.logger,{overwrite:e.overwrite});return Me(c,f,m.length,l.length,e.logger,n),{bindings:d,code:0,deps:f,skipped:l,written:m}}catch(s){return e.logger.error(u(`add failed: ${s instanceof Error?s.message:String(s)}`)),{...t,code:1}}finally{for(const s of r)s()}},sn=async e=>{const n=b();if(e.names.length===0)return e.logger.error("view requires an item name. Usage: lunora registry view <name>"),{...n,code:1};const t=E("view",e);if(t)return e.logger.error(t),{...n,code:1};const i=[];try{for(const r of e.names){const{cleanup:s,directory:o}=await ne(r,e);i.push(s);const a=te(o,r);M(e.logger,a);for(const c of a.files){e.logger.info(`--- ${u(c.to)} (${u(c.merge)}) ---`);const d=R(o,c,!1,r);for(const f of d.split(`
18
- `))e.logger.info(u(f))}}return n}catch(r){return e.logger.error(u(`view failed: ${r instanceof Error?r.message:String(r)}`)),{...n,code:1}}finally{for(const r of i)r()}},on=async e=>{const n=b(),t=e.from;if(t===void 0)return e.logger.error("registry build requires --from <registry root>"),{...n,code:1};if(!h(t))return e.logger.error(`registry root not found: ${t}`),{...n,code:1};const i=ie(t),r=e.out??p(t,"index.json");if(e.check){const s=h(r)?JSON.parse(g(r,"utf8")):{items:[]};return JSON.stringify(s.items??[])!==JSON.stringify(i.items)?(e.logger.error(`registry: ${r} is stale — run \`lunora registry build\` to regenerate it`),{...n,code:1}):(e.logger.success(`registry: ${r} is up to date (${String(i.items.length)} items)`),n)}return v(r,`${JSON.stringify({$schema:"./schema/registry.schema.json",...i},void 0,4)}
19
- `,"utf8"),e.logger.success(`registry: wrote ${r} (${String(i.items.length)} items)`),n};export{on as a,sn as b,be as i,rn as r,tn as s};
@@ -1 +0,0 @@
1
- import{existsSync as d,readFileSync as E,mkdtempSync as b,rmSync as w}from"node:fs";import{tmpdir as O}from"node:os";import{LunoraError as i}from"@lunora/errors";import{dirname as v,join as c}from"@visulima/path";import{downloadTemplate as B}from"giget";import{fileURLToPath as C}from"node:url";import U from"./parseManifest-CwPTKdtS.mjs";const D="alpha",S="main",k=new Set(["alpha","beta","next"]),G=/^[\w./@-]+$/,P=t=>!t.includes("..")&&G.test(t),f=()=>{try{let t=v(C(import.meta.url));for(let e=0;e<6;e+=1){const r=c(t,"package.json");if(d(r)){const s=JSON.parse(E(r,"utf8"));if(s.name==="@lunora/cli"&&typeof s.version=="string")return s.version}const n=v(t);if(n===t)break;t=n}}catch{}return"0.0.0"},R=t=>{if(t==="0.0.0")return D;const e=t.split("+")[0]??t,r=e.indexOf("-");if(r!==-1){const[n]=e.slice(r+1).split(".");if(n!==void 0&&k.has(n))return n}return S},$=t=>{if(t!==void 0&&t.length>0){if(!P(t))throw new i("INTERNAL",`invalid --ref "${t}" — a ref may contain letters, digits, ".", "_", "-", "/", "@" and must not contain "..".`);return t}return R(f())},l="anolilab/lunora",A=/^[0-9a-f]{40}$/iu,T=String.raw`\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)+)?(?:\+[0-9A-Za-z.-]+)?`,F=new RegExp(String.raw`^v?${T}$`,"u"),M=new RegExp(String.raw`^(?:@[\w.-]+\/)?[\w.-]+@${T}$`,"u"),V=t=>A.test(t)||F.test(t)||M.test(t),j=()=>{const t=process.env.GITHUB_TOKEN??process.env.GH_TOKEN;return t!==void 0&&t.length>0?{authorization:`Bearer ${t}`}:{}},x=async t=>{try{const e=await fetch(`https://api.github.com/repos/${l}/commits/${encodeURIComponent(t)}`,{headers:{accept:"application/vnd.github+json","user-agent":"lunora-cli",...j()},signal:AbortSignal.timeout(1e4)});if(!e.ok)return;const r=await e.json();return typeof r.sha=="string"&&A.test(r.sha)?r.sha:void 0}catch{return}},H=async(t,e)=>{const r=$(t);if(V(r))return r;const n=await x(r);return n===void 0?(e.warn(`could not pin ${l}#${r} to a commit — fetching the UNPINNED branch (set GITHUB_TOKEN if rate-limited).`),r):(e.info(`pinned ${l}#${r} → ${n}`),n)},ct=(t=f())=>`@lunora/cli@${t}`,z="latest",it=(t=f())=>{const e=R(t);return e===S?z:e},K="https://registry.npmjs.org",W=()=>{const t=process.env.npm_config_registry,e=t!==void 0&&t.length>0?t:K;return e.endsWith("/")?e.slice(0,-1):e},Z=async(t,e)=>{try{const r=await fetch(`${W()}/${t.replaceAll("/","%2F")}`,{headers:{accept:"application/vnd.npm.install-v1+json"},signal:AbortSignal.timeout(1e4)});return r.ok?(await r.json())["dist-tags"]?.[e]:void 0}catch{return}},ut=async(t,e)=>{const r=new Map;return await Promise.all([...new Set(t)].map(async n=>{const s=await Z(n,e);s!==void 0&&r.set(n,s)})),r},_="gh:anolilab/lunora/registry",y=/^[A-Za-z0-9][\w-]*$/u,q=t=>{if(!y.test(t))throw new i("INTERNAL",`invalid registry item name "${t}" — names must match ${y.source} (letters, digits, "-", "_"; no path separators or "..")`)},J=t=>t.includes("..")?!1:t.startsWith("gh:")||t.startsWith("github:")||t.startsWith("https://"),Y=t=>t.from===void 0&&t.source!==void 0&&t.source.length>0&&!t.allowUnsafeSource&&!J(t.source),lt=(t,e)=>Y(e)?`${t}: refusing --source ${String(e.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,N=async(t,e,r)=>{const n=b(c(O(),`lunora-${e}-fetch-`)),s=c(n,e);r.info(`fetching ${t}`);try{const a=await B(t,{cwd:n,dir:s,force:!0,install:!1,silent:!0});return r.info(a.commit?`resolved ${a.source} @ ${a.commit}`:`resolved ${a.source}`),{cleanup:()=>{w(n,{force:!0,recursive:!0})},directory:s}}catch(a){throw w(n,{force:!0,recursive:!0}),a}},p=new WeakMap,I=async t=>{const e=p.get(t);if(e!==void 0)return e;const r=t.source!==void 0&&t.source.length>0?Promise.resolve($(t.ref)):H(t.ref,t.logger);return p.set(t,r),r},Q=async(t,e,r=_)=>{if(q(t),e.from!==void 0){const s=c(e.from,t);if(!d(s))throw new i("INTERNAL",`registry item not found in local source: ${s}`);return{cleanup:()=>{},directory:s}}const n=e.source??r;return N(`${n}/${t}#${await I(e)}`,"item",e.logger)},dt=async t=>{if(t.from!==void 0){if(!d(t.from))throw new i("INTERNAL",`registry root not found: ${t.from}`);return{cleanup:()=>{},root:t.from}}const e=t.source??_,{cleanup:r,directory:n}=await N(`${e}#${await I(t)}`,"registry",t.logger);return{cleanup:r,root:n}},X=(t,e)=>{const r=JSON.parse(E(c(t,"registry.json"),"utf8"));return U(r,e)},ft=async(t,e)=>{const r=[],n=[],s=new Set,a=new Set,h=async o=>{if(s.has(o))return;if(a.has(o))throw new i("INTERNAL",`cyclic registry dependency detected at "${o}"`);a.add(o);const{cleanup:u,directory:g}=await Q(o,e);n.push(u);const m=X(g,o);for(const L of m.requires??[])await h(L);a.delete(o),s.add(o),r.push({directory:g,manifest:m})};try{for(const o of t)await h(o)}catch(o){for(const u of n)u();throw o}return{cleanups:n,items:r}};export{f as a,H as b,Q as c,it as d,ft as e,dt as f,X as g,ut as h,$ as i,ct as r,lt as s};
@@ -1 +0,0 @@
1
- import{r as n,a as o,b as i}from"./commands-YfMX-Mto.mjs";import"./catalog-CJaormx0.mjs";import"./resolve-DZAGzg67.mjs";export{n as runAddCommand,o as runBuildIndexCommand,i as runRegistryViewCommand};
@@ -1 +0,0 @@
1
- import"./vectorize-metadata-DbziRKpX.mjs";import"./advisory-gate-Cl8IEFIj.mjs";import"./deploy-target-B0Xcb2jV.mjs";import{e as c,r as d,a as f}from"../packem_chunks/handler.mjs";import"./command-DwC11Cwe.mjs";import"./docker-DpVxvYpL.mjs";import"./schema-drift-gate-BDCkQ1S6.mjs";import"./output-format-DfogXx0p.mjs";import"./platform-diagnostics-D0YzAdXm.mjs";import"./resolve-target-BRvw8Pf7.mjs";import"./createRecordingSpawner-DJlNacZ6.mjs";import"./tui-prompts-Dd0pDuNr.mjs";import"./wrangler-name-Dsk5K1f-.mjs";import"./wrangler-secrets-CCdt0mUl.mjs";import"../packem_chunks/runMigrateGenerateCommand.mjs";export{c as execute,d as runDeployCommand,f as runPreDeployPipeline};
@@ -1 +0,0 @@
1
- import{buildSchemaSnapshot as f}from"@lunora/codegen";import{validatorKindToSqlType as r}from"./diffSnapshots-Cnoe8Ob4.mjs";const c=e=>e.kind==="optional"&&e.inner?{nullable:!0,sqlType:r(e.inner.kind)}:{nullable:!1,sqlType:r(e.kind)},m=e=>e==="global",p=e=>{const s={},u=f(e,[]);for(const o of e.tables){if(!m(o.shardMode))continue;const t={};for(const[n,a]of Object.entries(o.shape)){const i=u.tables[o.name]?.fields[n];t[n]=i===void 0?c(a):{...c(a),field:i}}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:t,indexes:l,name:o.name}}return{tables:s,version:1}};export{p as default};
@@ -1 +0,0 @@
1
- const p=/(?:key|password|secret|token)$/iu,x=e=>p.test(e),g=e=>{switch(e){case"boolean":return"boolean";case"date":case"number":case"timestamp":return"number";case"id":case"literal":case"string":return"string";default:return}},l=/already (?:exists|indexed)|duplicate/iu,i=e=>["vectorize","create-metadata-index",e.index,`--property-name=${e.property}`,`--type=${e.type}`],m=async(e,n)=>{try{return await e(n)}catch(r){return{code:1,stderr:r instanceof Error?r.message:String(r)}}},y=async e=>{const{cwd:n,entries:r,exec:o,logger:d,spawner:u}=e,s=[];for(const t of r){const a=await m(u,{args:[...o.args,...i(t)],captureStderr:!0,command:o.command,cwd:n,stdoutToStderr:!0});if(a.code===0){s.push({entry:t,status:"created"});continue}const c=`${a.stderr??""}${a.stdout??""}`;if(l.test(c)){s.push({entry:t,status:"exists"});continue}s.push({entry:t,error:c.trim()||`exit code ${String(a.code)}`,status:"failed"}),d.warn(`could not create the Vectorize metadata index for "${t.property}" on "${t.index}" — filters on that property will match nothing until it exists. Run: wrangler ${i(t).join(" ")}`)}return s};export{i as c,y as e,x as i,g as m};