@lunora/cli 1.0.0-alpha.134 → 1.0.0-alpha.136

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.
package/dist/bin.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{f as s}from"./packem_shared/cli-Cmbw5lEB.mjs";try{const r=await s();process.exit(r)}catch(r){process.stderr.write(`${r instanceof Error?r.message:String(r)}
2
+ import{f as s}from"./packem_shared/cli-DdEKv4ng.mjs";try{const r=await s();process.exit(r)}catch(r){process.stderr.write(`${r instanceof Error?r.message:String(r)}
3
3
  `),process.exit(1)}
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CodegenOptions, Finding, SchemaIR } from '@lunora/codegen';
2
2
  import '@visulima/cerebro';
3
- import { ensureDevVariables, ensureDevVarsExample, fillDevSecrets } from '@lunora/config';
3
+ import { ensureDevVariables, ensureDevVarsExample, fillDevSecrets, LintTool, LintIgnoreOutcome } from '@lunora/config';
4
4
  import { materializeRemoteWranglerConfig } from '@lunora/config/cloudflare';
5
5
  export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, type WranglerProjectValidationOptions as WranglerValidationOptions, type WranglerValidationReport, type WranglerProjectValidationResult as WranglerValidationResult, validateWranglerProject as validateWrangler, validateWranglerConfig } from '@lunora/config/cloudflare';
6
6
  /** Every command name the CLI registers (drives the `CommandName` type + tests). */
@@ -820,6 +820,24 @@ interface OfferDeps {
820
820
  placeholder?: string;
821
821
  }) => Promise<string>;
822
822
  }
823
+ /** One choice in the multi-select. */
824
+ interface LintToolOption {
825
+ description: string;
826
+ label: string;
827
+ value: LintTool;
828
+ }
829
+ interface LintToolOfferDeps {
830
+ /** Write the ignores for the chosen tools — `applyLintIgnores` in production. */
831
+ apply: (tools: ReadonlyArray<LintTool>) => LintIgnoreOutcome[];
832
+ /** Tools already detectable in the scaffolded project — pre-selected in the prompt. */
833
+ detected: ReadonlyArray<LintTool>;
834
+ /** False in CI / `--yes` / off a TTY: skip the prompt and configure whatever was detected. */
835
+ interactive: boolean;
836
+ logger: Logger;
837
+ multiSelect: (message: string, choices: ReadonlyArray<LintToolOption>, settings?: {
838
+ defaults?: ReadonlyArray<LintTool>;
839
+ }) => Promise<LintTool[]>;
840
+ }
823
841
  type Template = "analog" | "astro" | "expo" | "next" | "nuxt" | "react-router" | "standalone" | "sveltekit" | "tanstack-start-react" | "tanstack-start-solid";
824
842
  interface InitCommandOptions {
825
843
  /**
@@ -874,6 +892,12 @@ interface InitCommandOptions {
874
892
  * suppresses it regardless. Has no effect once {@link prompt} is injected.
875
893
  */
876
894
  interactive?: boolean;
895
+ /**
896
+ * Test seam for the lint/formatter multi-select. Separate from {@link prompt}
897
+ * because that one is pinned to the feature-offer's value union — reusing it
898
+ * here would only typecheck through a cast.
899
+ */
900
+ lintPrompt?: LintToolOfferDeps["multiSelect"];
877
901
  logger: Logger;
878
902
  name?: string;
879
903
  /**
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CodegenOptions, Finding, SchemaIR } from '@lunora/codegen';
2
2
  import '@visulima/cerebro';
3
- import { ensureDevVariables, ensureDevVarsExample, fillDevSecrets } from '@lunora/config';
3
+ import { ensureDevVariables, ensureDevVarsExample, fillDevSecrets, LintTool, LintIgnoreOutcome } from '@lunora/config';
4
4
  import { materializeRemoteWranglerConfig } from '@lunora/config/cloudflare';
5
5
  export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, type WranglerProjectValidationOptions as WranglerValidationOptions, type WranglerValidationReport, type WranglerProjectValidationResult as WranglerValidationResult, validateWranglerProject as validateWrangler, validateWranglerConfig } from '@lunora/config/cloudflare';
6
6
  /** Every command name the CLI registers (drives the `CommandName` type + tests). */
@@ -820,6 +820,24 @@ interface OfferDeps {
820
820
  placeholder?: string;
821
821
  }) => Promise<string>;
822
822
  }
823
+ /** One choice in the multi-select. */
824
+ interface LintToolOption {
825
+ description: string;
826
+ label: string;
827
+ value: LintTool;
828
+ }
829
+ interface LintToolOfferDeps {
830
+ /** Write the ignores for the chosen tools — `applyLintIgnores` in production. */
831
+ apply: (tools: ReadonlyArray<LintTool>) => LintIgnoreOutcome[];
832
+ /** Tools already detectable in the scaffolded project — pre-selected in the prompt. */
833
+ detected: ReadonlyArray<LintTool>;
834
+ /** False in CI / `--yes` / off a TTY: skip the prompt and configure whatever was detected. */
835
+ interactive: boolean;
836
+ logger: Logger;
837
+ multiSelect: (message: string, choices: ReadonlyArray<LintToolOption>, settings?: {
838
+ defaults?: ReadonlyArray<LintTool>;
839
+ }) => Promise<LintTool[]>;
840
+ }
823
841
  type Template = "analog" | "astro" | "expo" | "next" | "nuxt" | "react-router" | "standalone" | "sveltekit" | "tanstack-start-react" | "tanstack-start-solid";
824
842
  interface InitCommandOptions {
825
843
  /**
@@ -874,6 +892,12 @@ interface InitCommandOptions {
874
892
  * suppresses it regardless. Has no effect once {@link prompt} is injected.
875
893
  */
876
894
  interactive?: boolean;
895
+ /**
896
+ * Test seam for the lint/formatter multi-select. Separate from {@link prompt}
897
+ * because that one is pinned to the feature-offer's value union — reusing it
898
+ * here would only typecheck through a cast.
899
+ */
900
+ lintPrompt?: LintToolOfferDeps["multiSelect"];
877
901
  logger: Logger;
878
902
  name?: string;
879
903
  /**
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{p as o,i as n,f as a}from"./packem_shared/cli-Cmbw5lEB.mjs";import{runCodegenCommand as t}from"./packem_chunks/runCodegenCommand.mjs";import{DEFAULT_IMPORT_BATCH_SIZE as p,runExportCommand as f,runImportCommand as i}from"./packem_shared/DEFAULT_IMPORT_BATCH_SIZE-xn-frBqK.mjs";import{runDeployCommand as C}from"./packem_chunks/runDeployCommand.mjs";import{planDevCommand as s,runDevCommand as u}from"./packem_chunks/planDevCommand.mjs";import{runInitCommand as g}from"./packem_chunks/runInitCommand.mjs";import{runMigrateGenerateCommand as R}from"./packem_chunks/runMigrateGenerateCommand.mjs";import{runResetCommand as D}from"./packem_chunks/runResetCommand.mjs";import{runRpcCommand as A}from"./packem_chunks/runRpcCommand.mjs";import{insertSchemaExtension as M}from"./packem_shared/insertSchemaExtension-DZReBZ4_.mjs";import{createLogger as _,pail as h}from"./packem_shared/createLogger--C3x1FNE.mjs";import{diffSnapshots as F,renderAddColumn as L,renderCreateIndex as O,renderCreateTable as b,renderDropIndex as w,renderDropTable as B,renderMigrationFile as P,validatorKindToSqlType as U}from"./packem_shared/diffSnapshots-9bDd9nOK.mjs";import{default as G}from"./packem_shared/schemaIrToSnapshot-Clwd2A8e.mjs";import{createRecordingSpawner as Q,defaultSpawner as V}from"./packem_shared/createRecordingSpawner-SKs4R1fc.mjs";import{default as q}from"./packem_shared/parseManifest-x3WsxKHz.mjs";import{REQUIRED_COMPATIBILITY_DATE as K,REQUIRED_FLAG as Y,validateWranglerProject as Z,validateWranglerConfig as k}from"@lunora/config/cloudflare";import{buildRegistryIndex as J}from"./packem_shared/buildRegistryIndex-DwySASBu.mjs";import{I as $,F as rr,E as er}from"./packem_shared/commands-BvfzxKAa.mjs";export{o as COMMANDS,p as DEFAULT_IMPORT_BATCH_SIZE,K as REQUIRED_COMPATIBILITY_DATE,Y as REQUIRED_FLAG,n as VERSION,J as buildRegistryIndex,_ as createLogger,Q as createRecordingSpawner,V as defaultSpawner,F as diffSnapshots,M as insertSchemaExtension,h as pail,q as parseManifest,s as planDevCommand,L as renderAddColumn,O as renderCreateIndex,b as renderCreateTable,w as renderDropIndex,B as renderDropTable,P as renderMigrationFile,$ as runAddCommand,rr as runBuildIndexCommand,a as runCli,t as runCodegenCommand,C as runDeployCommand,u as runDevCommand,f as runExportCommand,i as runImportCommand,g as runInitCommand,R as runMigrateGenerateCommand,er as runRegistryViewCommand,D as runResetCommand,A as runRpcCommand,G as schemaIrToSnapshot,Z as validateWrangler,k as validateWranglerConfig,U as validatorKindToSqlType};
1
+ import{p as o,i as n,f as a}from"./packem_shared/cli-DdEKv4ng.mjs";import{runCodegenCommand as t}from"./packem_chunks/runCodegenCommand.mjs";import{DEFAULT_IMPORT_BATCH_SIZE as p,runExportCommand as f,runImportCommand as i}from"./packem_shared/DEFAULT_IMPORT_BATCH_SIZE-xn-frBqK.mjs";import{runDeployCommand as C}from"./packem_chunks/runDeployCommand.mjs";import{planDevCommand as s,runDevCommand as u}from"./packem_chunks/planDevCommand.mjs";import{runInitCommand as g}from"./packem_chunks/runInitCommand.mjs";import{runMigrateGenerateCommand as R}from"./packem_chunks/runMigrateGenerateCommand.mjs";import{runResetCommand as D}from"./packem_chunks/runResetCommand.mjs";import{runRpcCommand as A}from"./packem_chunks/runRpcCommand.mjs";import{insertSchemaExtension as M}from"./packem_shared/insertSchemaExtension-DZReBZ4_.mjs";import{createLogger as _,pail as h}from"./packem_shared/createLogger--C3x1FNE.mjs";import{diffSnapshots as F,renderAddColumn as L,renderCreateIndex as O,renderCreateTable as b,renderDropIndex as w,renderDropTable as B,renderMigrationFile as P,validatorKindToSqlType as U}from"./packem_shared/diffSnapshots-9bDd9nOK.mjs";import{default as G}from"./packem_shared/schemaIrToSnapshot-Clwd2A8e.mjs";import{createRecordingSpawner as Q,defaultSpawner as V}from"./packem_shared/createRecordingSpawner-SKs4R1fc.mjs";import{default as q}from"./packem_shared/parseManifest-x3WsxKHz.mjs";import{REQUIRED_COMPATIBILITY_DATE as K,REQUIRED_FLAG as Y,validateWranglerProject as Z,validateWranglerConfig as k}from"@lunora/config/cloudflare";import{buildRegistryIndex as J}from"./packem_shared/buildRegistryIndex-DwySASBu.mjs";import{I as $,F as rr,E as er}from"./packem_shared/commands-BvfzxKAa.mjs";export{o as COMMANDS,p as DEFAULT_IMPORT_BATCH_SIZE,K as REQUIRED_COMPATIBILITY_DATE,Y as REQUIRED_FLAG,n as VERSION,J as buildRegistryIndex,_ as createLogger,Q as createRecordingSpawner,V as defaultSpawner,F as diffSnapshots,M as insertSchemaExtension,h as pail,q as parseManifest,s as planDevCommand,L as renderAddColumn,O as renderCreateIndex,b as renderCreateTable,w as renderDropIndex,B as renderDropTable,P as renderMigrationFile,$ as runAddCommand,rr as runBuildIndexCommand,a as runCli,t as runCodegenCommand,C as runDeployCommand,u as runDevCommand,f as runExportCommand,i as runImportCommand,g as runInitCommand,R as runMigrateGenerateCommand,er as runRegistryViewCommand,D as runResetCommand,A as runRpcCommand,G as schemaIrToSnapshot,Z as validateWrangler,k as validateWranglerConfig,U as validatorKindToSqlType};
@@ -1 +1 @@
1
- import{existsSync as y,readFileSync as $}from"node:fs";import{findWranglerFile as b}from"@lunora/config/cloudflare";import{join as p,basename as h}from"@visulima/path";import{i as k}from"../packem_shared/command-Bjv4VmYA.mjs";import{i as S,r as T,d as j,s as U}from"../packem_shared/output-format-D7cKB-O5.mjs";import{B as g,C as x}from"../packem_shared/tui-prompts-CCt3jm1k.mjs";import{d as C,r as R,l as q,i as B,o as l,u as D,a as m,b as F,c as L,e as f,f as M,g as d,n as N,h as W,s as u,j as A,k as O,p as G,m as I,q as J}from"../packem_shared/storage-CSzKwh4L.mjs";import{I as K}from"../packem_shared/commands-BvfzxKAa.mjs";const P=r=>{const e=r.trim().toLowerCase();return O.find(a=>a.value===e||a.label.toLowerCase()===e||e==="auth0"&&a.value==="auth-auth0"||e==="clerk"&&a.value==="auth-clerk")?.value},w=r=>{try{const e=JSON.parse($(p(r,"package.json"),"utf8"));return{...e.dependencies,...e.devDependencies}}catch{return{}}},Q=async r=>{const e=r.cwd??process.cwd(),a=W(w(e));return a!==void 0?a:r.yes===!0?(r.logger.warn(`add: couldn't detect your framework — using "${u}". Pass a specific item (e.g. \`lunora add auth-ui-vue\`) to override.`),u):await(r.promptSelect??((o,s,n)=>g(o,s,n)))("Which framework is your app?",A,{default:u})??u},V=async r=>{if(r.provider!==void 0&&r.provider!==""){const a=P(r.provider);return a===void 0?(r.logger.warn(`add: unknown --provider "${r.provider}" — using "${d}" (email & password).`),d):a}if(r.yes===!0)return d;const e=r.promptSelect??((a,o,s)=>g(a,o,s));return N(e)},c=r=>r.promptText??((e,a)=>x(e,a)),X=async r=>{const e=h(r.cwd??process.cwd());if(r.bucket!==void 0&&r.bucket!==""){const a=B(r.bucket);if(a!==void 0)return a;const o=l(e);return r.logger.warn(`add: "${r.bucket}" isn't a valid R2 bucket name (lowercase alphanumeric + hyphens, 3–63 chars) — using "${o}".`),o}return r.yes===!0?l(e):D(c(r),e)},Y=async r=>{const e=a=>{r.logger.warn(`add: ${a}`)};if(r.mailTo!==void 0&&r.mailTo!=="")return m(r.mailTo,e);if(r.yes!==!0)return m(await c(r)(F,{placeholder:"you@yourdomain.com"}),e)},Z=async r=>{const e=h(r.cwd??process.cwd());if(r.db!==void 0&&r.db!==""){const a=L(r.db);if(a!==void 0)return a;const o=f(e);return r.logger.warn(`add: "${r.db}" isn't a usable D1 database name — using "${o}".`),o}return r.yes===!0?f(e):M(c(r),e)},z=async(r,e)=>r.kind==="auth"?[await V(e)]:r.kind==="auth-ui"?[await Q(e)]:r.kind==="email"?[q]:[r.item],E=async r=>{const e=r.cwd??process.cwd(),a=r.feature===void 0?void 0:C(r.feature);if(a===void 0)return r.logger.error("add requires a feature or registry item. Usage: lunora add <auth|email|storage|crons|presence|…>"),{code:1,items:[]};if(!y(p(e,"lunora"))||b(e)===void 0)return r.logger.error("add: not a Lunora project here (need a lunora/ directory and a wrangler.jsonc). Run `lunora init` first."),{code:1,items:[]};if(a.kind==="auth-ui"&&R(w(e)))return r.logger.error("add: auth-ui has no React Native port — the screens render DOM elements and a stylesheet, which Metro has nothing to mount. Build the screens with React Native primitives against the same better-auth client (`@lunora/react-native/auth`); `lunora add auth` still installs the server half."),{code:1,items:[]};const o=await z(a,r),s=[];if(o.includes("storage")){const t=await X(r);s.push(i=>G(i,t))}if(o.includes("mail")){const t=await Y(r);t!==void 0&&s.push(i=>I(i,t))}if(o.some(t=>t==="auth"||t.startsWith("auth-"))){const t=await Z(r);s.push(i=>J(i,t))}const n=s.length>0?t=>{let i=t;for(const v of s)i=v(i);return i}:void 0;return{code:(await K({allowUnsafeSource:r.allowUnsafeSource,cwd:e,from:r.from,logger:r.logger,names:[...o],ref:r.ref,source:r.source,transformManifest:n,yes:!0})).code,items:o}},ir=k(async({argument:r,cwd:e,logger:a,options:o})=>{const s=S("add",o.format);if(s!==void 0)return a.error(s),{code:1};const n=U(o.format,a),t=await E({allowUnsafeSource:o.allowUnsafeSource===!0,bucket:o.bucket,cwd:e,db:o.db,feature:r[0],from:o.from,logger:n,mailTo:o.mailTo,provider:o.provider,ref:o.ref,source:o.source,yes:o.yes===!0});return T(o.format)&&j({code:t.code,items:t.items}),{code:t.code}});export{ir as execute,E as runAddFeature};
1
+ import{existsSync as $,readFileSync as b}from"node:fs";import{applyLintIgnores as k,detectLintTools as S}from"@lunora/config";import{findWranglerFile as T}from"@lunora/config/cloudflare";import{join as g,basename as h}from"@visulima/path";import{i as j}from"../packem_shared/command-Bjv4VmYA.mjs";import{d as L,r as U,l as x,i as C,o as m,u as R,a as f,b as B,c as D,e as p,f as F,n as M,g as c,h as N,j as W,s as u,k as q,m as A,p as I,q as O,t as J}from"../packem_shared/lint-ignore-report-CSeEIMkV.mjs";import{i as K,r as P,d as Q,s as X}from"../packem_shared/output-format-D7cKB-O5.mjs";import{B as w,C as Y}from"../packem_shared/tui-prompts-CCt3jm1k.mjs";import{I as Z}from"../packem_shared/commands-BvfzxKAa.mjs";const z=r=>{const e=r.trim().toLowerCase();return A.find(a=>a.value===e||a.label.toLowerCase()===e||e==="auth0"&&a.value==="auth-auth0"||e==="clerk"&&a.value==="auth-clerk")?.value},v=r=>{try{const e=JSON.parse(b(g(r,"package.json"),"utf8"));return{...e.dependencies,...e.devDependencies}}catch{return{}}},E=async r=>{const e=r.cwd??process.cwd(),a=W(v(e));return a!==void 0?a:r.yes===!0?(r.logger.warn(`add: couldn't detect your framework — using "${u}". Pass a specific item (e.g. \`lunora add auth-ui-vue\`) to override.`),u):await(r.promptSelect??((o,t,d)=>w(o,t,d)))("Which framework is your app?",q,{default:u})??u},G=async r=>{if(r.provider!==void 0&&r.provider!==""){const a=z(r.provider);return a===void 0?(r.logger.warn(`add: unknown --provider "${r.provider}" — using "${c}" (email & password).`),c):a}if(r.yes===!0)return c;const e=r.promptSelect??((a,o,t)=>w(a,o,t));return N(e)},l=r=>r.promptText??((e,a)=>Y(e,a)),H=async r=>{const e=h(r.cwd??process.cwd());if(r.bucket!==void 0&&r.bucket!==""){const a=C(r.bucket);if(a!==void 0)return a;const o=m(e);return r.logger.warn(`add: "${r.bucket}" isn't a valid R2 bucket name (lowercase alphanumeric + hyphens, 3–63 chars) — using "${o}".`),o}return r.yes===!0?m(e):R(l(r),e)},V=async r=>{const e=a=>{r.logger.warn(`add: ${a}`)};if(r.mailTo!==void 0&&r.mailTo!=="")return f(r.mailTo,e);if(r.yes!==!0)return f(await l(r)(B,{placeholder:"you@yourdomain.com"}),e)},_=async r=>{const e=h(r.cwd??process.cwd());if(r.db!==void 0&&r.db!==""){const a=D(r.db);if(a!==void 0)return a;const o=p(e);return r.logger.warn(`add: "${r.db}" isn't a usable D1 database name — using "${o}".`),o}return r.yes===!0?p(e):F(l(r),e)},rr=async(r,e)=>r.kind==="auth"?[await G(e)]:r.kind==="auth-ui"?[await E(e)]:r.kind==="email"?[x]:[r.item],er=(r,e)=>{M(k(r,S(r)),e)},ar=async r=>{const e=r.cwd??process.cwd(),a=r.feature===void 0?void 0:L(r.feature);if(a===void 0)return r.logger.error("add requires a feature or registry item. Usage: lunora add <auth|email|storage|crons|presence|…>"),{code:1,items:[]};if(!$(g(e,"lunora"))||T(e)===void 0)return r.logger.error("add: not a Lunora project here (need a lunora/ directory and a wrangler.jsonc). Run `lunora init` first."),{code:1,items:[]};if(a.kind==="auth-ui"&&U(v(e)))return r.logger.error("add: auth-ui has no React Native port — the screens render DOM elements and a stylesheet, which Metro has nothing to mount. Build the screens with React Native primitives against the same better-auth client (`@lunora/react-native/auth`); `lunora add auth` still installs the server half."),{code:1,items:[]};const o=await rr(a,r),t=[];if(o.includes("storage")){const s=await H(r);t.push(i=>I(i,s))}if(o.includes("mail")){const s=await V(r);s!==void 0&&t.push(i=>O(i,s))}if(o.some(s=>s==="auth"||s.startsWith("auth-"))){const s=await _(r);t.push(i=>J(i,s))}const d=t.length>0?s=>{let i=s;for(const y of t)i=y(i);return i}:void 0,n=await Z({allowUnsafeSource:r.allowUnsafeSource,cwd:e,from:r.from,logger:r.logger,names:[...o],ref:r.ref,source:r.source,transformManifest:d,yes:!0});return n.code===0&&er(e,r.logger),{code:n.code,items:o}},mr=j(async({argument:r,cwd:e,logger:a,options:o})=>{const t=K("add",o.format);if(t!==void 0)return a.error(t),{code:1};const d=X(o.format,a),n=await ar({allowUnsafeSource:o.allowUnsafeSource===!0,bucket:o.bucket,cwd:e,db:o.db,feature:r[0],from:o.from,logger:d,mailTo:o.mailTo,provider:o.provider,ref:o.ref,source:o.source,yes:o.yes===!0});return P(o.format)&&Q({code:n.code,items:n.items}),{code:n.code}});export{mr as execute,ar as runAddFeature};
@@ -1,4 +1,4 @@
1
- import{writeFileSync as $,existsSync as v,readFileSync as S}from"node:fs";import{isAbsolute as w,join as b}from"node:path";import{byCodepoint as y,scoreAdvisor as x,parseAdvisorMap as j,compareToBaseline as R}from"@lunora/advisor";import{runCodegen as k}from"@lunora/codegen";import{i as A}from"../packem_shared/command-Bjv4VmYA.mjs";import{i as D,d as M,s as F,r as N}from"../packem_shared/output-format-D7cKB-O5.mjs";import{o as g}from"../packem_shared/cli-Cmbw5lEB.mjs";const l={clean:"·",exempt:"–",failing:"✗",warned:"!"},u=(r,e)=>r.length>=e?r:r+" ".repeat(e-r.length),C=r=>`${r.id} (${r.visibility} ${r.kind})`,m=r=>{let e=0;for(const o of r)e=Math.max(e,o.id.length);return e},p=(r,e)=>` ${u(String(r.score),3)} ${l[r.coverage]} ${u(r.id,e)} ${r.visibility} ${r.kind}`,E=r=>{if(!r.comparable)return[` baseline not comparable (${r.reason}) — regenerate it; this run cannot verify anything`];if(!r.regressed)return[` no regression against baseline (score ${r.scoreDelta>=0?"+":""}${String(r.scoreDelta)})`];const e=[` REGRESSED against baseline (score ${r.scoreDelta>=0?"+":""}${String(r.scoreDelta)})`];for(const o of r.dropped)e.push(` ${o.id}: ${String(o.before)} → ${String(o.after)}`);for(const o of r.newFailing)e.push(` ${o}: now failing`);for(const o of r.worsened)e.push(` ${o}: more findings than the baseline`);return r.projectRegressed&&e.push(" project: new schema/config rules fired"),e},J=(r,e)=>{const o=r.procedures.filter(i=>i.coverage!=="clean"&&i.coverage!=="exempt"),n=m(o),t=[`advisor health ${String(r.score)}/100 — ${r.grade}`,` ${String(r.summary.clean)} clean · ${String(r.summary.warned)} warned · ${String(r.summary.failing)} failing · ${String(r.summary.exempt)} exempt (${String(r.summary.procedures)} procedures, ${String(r.summary.rulesFired)} rules fired)`];return r.project.checks.length>0&&t.push("",` project ${String(r.project.score)}/100 — ${r.project.checks.map(i=>i.name).join(", ")}`),o.length>0&&t.push("",...o.map(i=>p(i,n)),""," run with --all for every procedure, or --entry <file#export> for one"),e!==void 0&&t.push("",...E(e)),t.join(`
1
+ import{writeFileSync as $,existsSync as v,readFileSync as S}from"node:fs";import{isAbsolute as w,join as b}from"node:path";import{byCodepoint as y,scoreAdvisor as x,parseAdvisorMap as j,compareToBaseline as R}from"@lunora/advisor";import{runCodegen as k}from"@lunora/codegen";import{i as A}from"../packem_shared/command-Bjv4VmYA.mjs";import{i as D,d as M,s as F,r as N}from"../packem_shared/output-format-D7cKB-O5.mjs";import{o as g}from"../packem_shared/cli-DdEKv4ng.mjs";const l={clean:"·",exempt:"–",failing:"✗",warned:"!"},u=(r,e)=>r.length>=e?r:r+" ".repeat(e-r.length),C=r=>`${r.id} (${r.visibility} ${r.kind})`,m=r=>{let e=0;for(const o of r)e=Math.max(e,o.id.length);return e},p=(r,e)=>` ${u(String(r.score),3)} ${l[r.coverage]} ${u(r.id,e)} ${r.visibility} ${r.kind}`,E=r=>{if(!r.comparable)return[` baseline not comparable (${r.reason}) — regenerate it; this run cannot verify anything`];if(!r.regressed)return[` no regression against baseline (score ${r.scoreDelta>=0?"+":""}${String(r.scoreDelta)})`];const e=[` REGRESSED against baseline (score ${r.scoreDelta>=0?"+":""}${String(r.scoreDelta)})`];for(const o of r.dropped)e.push(` ${o.id}: ${String(o.before)} → ${String(o.after)}`);for(const o of r.newFailing)e.push(` ${o}: now failing`);for(const o of r.worsened)e.push(` ${o}: more findings than the baseline`);return r.projectRegressed&&e.push(" project: new schema/config rules fired"),e},J=(r,e)=>{const o=r.procedures.filter(i=>i.coverage!=="clean"&&i.coverage!=="exempt"),n=m(o),t=[`advisor health ${String(r.score)}/100 — ${r.grade}`,` ${String(r.summary.clean)} clean · ${String(r.summary.warned)} warned · ${String(r.summary.failing)} failing · ${String(r.summary.exempt)} exempt (${String(r.summary.procedures)} procedures, ${String(r.summary.rulesFired)} rules fired)`];return r.project.checks.length>0&&t.push("",` project ${String(r.project.score)}/100 — ${r.project.checks.map(i=>i.name).join(", ")}`),o.length>0&&t.push("",...o.map(i=>p(i,n)),""," run with --all for every procedure, or --entry <file#export> for one"),e!==void 0&&t.push("",...E(e)),t.join(`
2
2
  `)},O=r=>r.coverage==="exempt"?[` exempt: ${r.exemptReason===void 0||r.exemptReason===""?"no reason given":r.exemptReason}`]:r.checks.map(e=>{const o=e.occurrences>1?`, ×${String(e.occurrences)}`:"";return` ${e.name} (−${String(e.weight)}${o})`}),B=r=>{const e=new Map;for(const o of r){const n=e.get(o.file);n===void 0?e.set(o.file,[o]):n.push(o)}return[...e].toSorted(([o],[n])=>y(o,n))},P=r=>{const e=m(r.procedures),o=[`advisor health ${String(r.score)}/100 — ${r.grade}`,"",` legend: ${l.clean} clean ${l.warned} warned ${l.failing} failing ${l.exempt} exempt`];for(const[n,t]of B(r.procedures)){o.push("",` ${n}`);for(const i of t)o.push(p(i,e),...O(i))}return o.join(`
3
3
  `)},T=(r,e)=>{const o=r.procedures.find(t=>t.id===e);if(o===void 0){const t=r.procedures.slice(0,10).map(i=>` ${i.id}`);return[`no procedure ${e} in the map. Known ids:`,...t,r.procedures.length>10?" …":""].filter(Boolean).join(`
4
4
  `)}const n=[`${C(o)} — ${String(o.score)}/100, ${o.coverage}`,` weight in the global mean: ${String(o.weight)}`];if(o.checks.length===0)return n.push(""," no rule fired"),n.join(`
@@ -1,4 +1,4 @@
1
- import{i as P}from"../packem_shared/cli-Cmbw5lEB.mjs";import{i as W}from"../packem_shared/command-Bjv4VmYA.mjs";import{existsSync as u,readFileSync as y,realpathSync as D,statSync as T,writeFileSync as z,chmodSync as H,renameSync as I,unlinkSync as K,mkdirSync as q}from"node:fs";import{homedir as w}from"node:os";import{findWranglerFile as G}from"@lunora/config/cloudflare";import{join as s,dirname as V,relative as Z}from"@visulima/path";import{l as B,M as Q}from"../packem_shared/detect-package-manager-D9r2z_X6.mjs";import{stringify as X}from"smol-toml";import{modify as x,applyEdits as C,parse as Y}from"jsonc-parser";import{readLiveDevServerState as b}from"@lunora/config";import{resolveAdminToken as oo}from"@lunora/config/studio-host";import{connectLocalStdio as to}from"@lunora/mcp";const m=o=>({args:[...o.args],command:o.command,...o.env===void 0?{}:{env:o.env}}),$=o=>o.transport==="http"?{type:"http",url:o.url}:m(o),eo=o=>o.transport==="http"?{httpUrl:o.url}:m(o),ro=o=>o.transport==="http"?{serverUrl:o.url}:m(o),no=o=>({args:["-y","mcp-remote",o],command:"npx"}),ao=o=>o.transport==="http"?no(o.url):m(o),io=o=>o.transport==="http"?{url:o.url}:m(o),lo=o=>o.transport==="http"?{enabled:!0,type:"remote",url:o.url}:{command:[o.command,...o.args],enabled:!0,type:"local",...o.env===void 0?{}:{environment:o.env}},so=o=>o.transport==="http"?{disabled:!1,type:"streamableHttp",url:o.url}:{disabled:!1,...m(o)},co=({home:o,platform:t})=>{if(t==="darwin")return{global:s(o,"Library","Application Support","Claude","claude_desktop_config.json")};if(t==="win32"){const e=process.env.APPDATA;return e===void 0||e===""?{}:{global:s(e,"Claude","claude_desktop_config.json")}}return t==="linux"?{global:s(o,".config","Claude","claude_desktop_config.json")}:{}},po=(o,t)=>X({mcp_servers:{[o]:t.transport==="http"?{url:t.url}:{args:[...t.args],command:t.command,...t.env===void 0?{}:{env:t.env}}}}),h=[{buildEntry:$,paths:({projectRoot:o})=>({project:s(o,".mcp.json")}),format:"json",id:"claude-code",key:"mcpServers",label:"Claude Code"},{buildEntry:$,paths:({home:o,projectRoot:t})=>({global:s(o,".cursor","mcp.json"),project:s(t,".cursor","mcp.json")}),format:"json",id:"cursor",key:"mcpServers",label:"Cursor"},{buildEntry:$,paths:({projectRoot:o})=>({project:s(o,".vscode","mcp.json")}),format:"json",id:"vscode",key:"servers",label:"VS Code (GitHub Copilot)"},{buildEntry:eo,paths:({home:o,projectRoot:t})=>({global:s(o,".gemini","settings.json"),project:s(t,".gemini","settings.json")}),format:"json",id:"gemini",key:"mcpServers",label:"Gemini CLI"},{buildEntry:ao,paths:co,format:"json",id:"claude-desktop",key:"mcpServers",label:"Claude Desktop"},{buildEntry:ro,paths:({home:o})=>({global:s(o,".codeium","windsurf","mcp_config.json")}),format:"json",id:"windsurf",key:"mcpServers",label:"Windsurf"},{buildEntry:lo,paths:({home:o,projectRoot:t})=>({global:s(o,".config","opencode","opencode.json"),project:s(t,"opencode.json")}),format:"json",id:"opencode",key:"mcp",label:"OpenCode"},{buildEntry:so,paths:({home:o})=>({global:s(o,".cline","mcp.json")}),format:"json",id:"cline",key:"mcpServers",label:"Cline"},{buildEntry:io,paths:({home:o})=>({global:s(o,".config","zed","settings.json")}),format:"json",id:"zed",key:"context_servers",label:"Zed"},{paths:({home:o,projectRoot:t})=>({global:s(o,".codex","config.toml"),project:s(t,".codex","config.toml")}),format:"manual",id:"codex",label:"Codex CLI",renderSnippet:po}],E=h.map(o=>o.id),uo=o=>h.find(t=>t.id===o.toLowerCase()),v=(o,t)=>{let e=o,r;try{e=D(o),r=T(e).mode}catch{}const n=`${e}.lunora-${Math.random().toString(36).slice(2,10)}.tmp`;try{z(n,t,"utf8"),r!==void 0&&H(n,r),I(n,e)}catch(a){try{K(n)}catch{}throw a}},R={formattingOptions:{insertSpaces:!0,tabSize:4}},k=o=>{const t=[],e=Y(o,t,{allowTrailingComma:!0});return{errors:t,value:e}},g=o=>typeof o=="object"&&o!==null&&!Array.isArray(o),j=(o,t,e)=>{if(!g(o))return;const r=o[t];return g(r)?r[e]:void 0},U=o=>{if(!u(o.path))return"absent";let t;try{t=y(o.path,"utf8")}catch{return"invalid"}if(t.trim().length===0)return"absent";const{errors:e,value:r}=k(t);return e.length>0||!g(r)?"invalid":j(r,o.key,o.name)===void 0?"absent":"present"},mo=o=>U(o)==="present",fo=o=>{const{entry:t,force:e=!1,key:r,name:n,path:a}=o;if(!u(a))return q(V(a),{recursive:!0}),v(a,`${JSON.stringify({[r]:{[n]:t}},void 0,4)}
1
+ import{i as P}from"../packem_shared/cli-DdEKv4ng.mjs";import{i as W}from"../packem_shared/command-Bjv4VmYA.mjs";import{existsSync as u,readFileSync as y,realpathSync as D,statSync as T,writeFileSync as z,chmodSync as H,renameSync as I,unlinkSync as K,mkdirSync as q}from"node:fs";import{homedir as w}from"node:os";import{findWranglerFile as G}from"@lunora/config/cloudflare";import{join as s,dirname as V,relative as Z}from"@visulima/path";import{l as B,M as Q}from"../packem_shared/detect-package-manager-D9r2z_X6.mjs";import{stringify as X}from"smol-toml";import{modify as x,applyEdits as C,parse as Y}from"jsonc-parser";import{readLiveDevServerState as b}from"@lunora/config";import{resolveAdminToken as oo}from"@lunora/config/studio-host";import{connectLocalStdio as to}from"@lunora/mcp";const m=o=>({args:[...o.args],command:o.command,...o.env===void 0?{}:{env:o.env}}),$=o=>o.transport==="http"?{type:"http",url:o.url}:m(o),eo=o=>o.transport==="http"?{httpUrl:o.url}:m(o),ro=o=>o.transport==="http"?{serverUrl:o.url}:m(o),no=o=>({args:["-y","mcp-remote",o],command:"npx"}),ao=o=>o.transport==="http"?no(o.url):m(o),io=o=>o.transport==="http"?{url:o.url}:m(o),lo=o=>o.transport==="http"?{enabled:!0,type:"remote",url:o.url}:{command:[o.command,...o.args],enabled:!0,type:"local",...o.env===void 0?{}:{environment:o.env}},so=o=>o.transport==="http"?{disabled:!1,type:"streamableHttp",url:o.url}:{disabled:!1,...m(o)},co=({home:o,platform:t})=>{if(t==="darwin")return{global:s(o,"Library","Application Support","Claude","claude_desktop_config.json")};if(t==="win32"){const e=process.env.APPDATA;return e===void 0||e===""?{}:{global:s(e,"Claude","claude_desktop_config.json")}}return t==="linux"?{global:s(o,".config","Claude","claude_desktop_config.json")}:{}},po=(o,t)=>X({mcp_servers:{[o]:t.transport==="http"?{url:t.url}:{args:[...t.args],command:t.command,...t.env===void 0?{}:{env:t.env}}}}),h=[{buildEntry:$,paths:({projectRoot:o})=>({project:s(o,".mcp.json")}),format:"json",id:"claude-code",key:"mcpServers",label:"Claude Code"},{buildEntry:$,paths:({home:o,projectRoot:t})=>({global:s(o,".cursor","mcp.json"),project:s(t,".cursor","mcp.json")}),format:"json",id:"cursor",key:"mcpServers",label:"Cursor"},{buildEntry:$,paths:({projectRoot:o})=>({project:s(o,".vscode","mcp.json")}),format:"json",id:"vscode",key:"servers",label:"VS Code (GitHub Copilot)"},{buildEntry:eo,paths:({home:o,projectRoot:t})=>({global:s(o,".gemini","settings.json"),project:s(t,".gemini","settings.json")}),format:"json",id:"gemini",key:"mcpServers",label:"Gemini CLI"},{buildEntry:ao,paths:co,format:"json",id:"claude-desktop",key:"mcpServers",label:"Claude Desktop"},{buildEntry:ro,paths:({home:o})=>({global:s(o,".codeium","windsurf","mcp_config.json")}),format:"json",id:"windsurf",key:"mcpServers",label:"Windsurf"},{buildEntry:lo,paths:({home:o,projectRoot:t})=>({global:s(o,".config","opencode","opencode.json"),project:s(t,"opencode.json")}),format:"json",id:"opencode",key:"mcp",label:"OpenCode"},{buildEntry:so,paths:({home:o})=>({global:s(o,".cline","mcp.json")}),format:"json",id:"cline",key:"mcpServers",label:"Cline"},{buildEntry:io,paths:({home:o})=>({global:s(o,".config","zed","settings.json")}),format:"json",id:"zed",key:"context_servers",label:"Zed"},{paths:({home:o,projectRoot:t})=>({global:s(o,".codex","config.toml"),project:s(t,".codex","config.toml")}),format:"manual",id:"codex",label:"Codex CLI",renderSnippet:po}],E=h.map(o=>o.id),uo=o=>h.find(t=>t.id===o.toLowerCase()),v=(o,t)=>{let e=o,r;try{e=D(o),r=T(e).mode}catch{}const n=`${e}.lunora-${Math.random().toString(36).slice(2,10)}.tmp`;try{z(n,t,"utf8"),r!==void 0&&H(n,r),I(n,e)}catch(a){try{K(n)}catch{}throw a}},R={formattingOptions:{insertSpaces:!0,tabSize:4}},k=o=>{const t=[],e=Y(o,t,{allowTrailingComma:!0});return{errors:t,value:e}},g=o=>typeof o=="object"&&o!==null&&!Array.isArray(o),j=(o,t,e)=>{if(!g(o))return;const r=o[t];return g(r)?r[e]:void 0},U=o=>{if(!u(o.path))return"absent";let t;try{t=y(o.path,"utf8")}catch{return"invalid"}if(t.trim().length===0)return"absent";const{errors:e,value:r}=k(t);return e.length>0||!g(r)?"invalid":j(r,o.key,o.name)===void 0?"absent":"present"},mo=o=>U(o)==="present",fo=o=>{const{entry:t,force:e=!1,key:r,name:n,path:a}=o;if(!u(a))return q(V(a),{recursive:!0}),v(a,`${JSON.stringify({[r]:{[n]:t}},void 0,4)}
2
2
  `),{action:"created",path:a};const i=y(a,"utf8");if(i.trim().length===0)return v(a,`${JSON.stringify({[r]:{[n]:t}},void 0,4)}
3
3
  `),{action:"created",path:a};const{errors:l,value:c}=k(i);if(l.length>0)return{action:"invalid",error:`parse error at offset ${String(l[0]?.offset??0)}`,path:a};if(!g(c))return{action:"invalid",error:"the file's root is not a JSON object",path:a};const f=c[r];if(f!==void 0&&!g(f))return{action:"invalid",error:`"${r}" is not an object`,path:a};if(j(c,r,n)!==void 0&&!e)return{action:"skipped",path:a};try{const d=x(i,[r,n],t,R);d.length>0&&v(a,C(i,d))}catch(d){return{action:"invalid",error:d instanceof Error?d.message:String(d),path:a}}return{action:"updated",path:a}},go=o=>{const{key:t,name:e,path:r}=o;if(!u(r))return{action:"absent",path:r};let n;try{n=y(r,"utf8")}catch(l){return{action:"invalid",error:l instanceof Error?l.message:String(l),path:r}}const{errors:a,value:i}=k(n);if(a.length>0)return{action:"invalid",error:`parse error at offset ${String(a[0]?.offset??0)}`,path:r};if(j(i,t,e)===void 0)return{action:"absent",path:r};try{const l=x(n,[t,e],void 0,R);l.length>0&&v(r,C(n,l))}catch(l){return{action:"invalid",error:l instanceof Error?l.message:String(l),path:r}}return{action:"removed",path:r}},ho=["global","project"],p=(o,t)=>{const e=Z(t,o);return e.length>0&&!e.startsWith("..")?e:o},vo=(o,t)=>{const e=o.paths(t);return ho.flatMap(r=>{const n=e[r];return n===void 0?[]:[{client:o,path:n,scope:r}]})},yo=(o,t,e,r)=>{const n=o.paths(t),a=e==="global"?"project":"global",i=n[e]??(r?void 0:n[a]);if(i!==void 0)return{client:o,path:i,scope:n[e]===void 0?a:e}},$o=o=>h.filter(t=>Object.values(t.paths(o)).some(e=>u(e))),N=(o,t,e,r)=>{if(o.length===0)return t();const n=[];for(const a of o){const i=uo(a);if(i===void 0){e.error(`mcp ${r}: unknown client "${a}". Known clients: ${E.join(", ")}.`);return}n.push(i)}return n},bo=o=>o.client.format==="json",wo="https://lunora.sh/mcp",_="lunora-docs",M="lunora",ko=o=>u(s(o,"lunora"))&&G(o)!==void 0,jo=o=>{const{args:t,command:e}=Q(o,"lunora",["mcp","serve"]);return{args:t,command:e,transport:"stdio"}},So=o=>({transport:"http",url:o}),Oo=o=>({home:o.home,platform:o.platform,projectRoot:o.cwd}),A=(o,t,e)=>yo(o,Oo(e),e.scope??t.preferredScope,e.scope!==void 0||!t.allowScopeFallback),xo=(o,t,e)=>{const r=A(o,t,e);if(r===void 0){e.logger.warn(`${o.label}: has no ${e.scope??t.preferredScope}-scoped config — skipped "${t.name}".`);return}const{path:n}=r,a=o.buildEntry(t.spec);if(e.print===!0){const c=p(n,e.cwd);return e.force!==!0&&mo({key:o.key,name:t.name,path:n})?(e.logger.info(`${o.label}: "${t.name}" already configured in ${c} — a real install would skip it (re-run with --force to replace).`),{action:"printed",path:n}):(e.logger.info(`${o.label} → ${c}
4
4
  ${JSON.stringify({[o.key]:{[t.name]:a}},void 0,4)}`),{action:"printed",path:n})}const i=fo({entry:a,force:e.force===!0,key:o.key,name:t.name,path:n}),l=p(n,e.cwd);return i.action==="invalid"?e.logger.error(`${o.label}: ${l} is not valid JSON (${i.error??"unknown error"}) — left untouched.`):i.action==="skipped"?e.logger.info(`${o.label}: "${t.name}" already configured in ${l} — re-run with --force to replace it.`):e.logger.success(`${o.label}: ${i.action==="created"?"created":"updated"} ${l} with "${t.name}".`),{action:i.action,path:n}},Co=(o,t,e)=>{const r=A(o,t,e)?.path;if(r===void 0){e.logger.warn(`${o.label}: no known config location on ${e.platform} — skipped.`);return}return e.logger.info(`${o.label}: add this to ${p(r,e.cwd)}
@@ -1 +1,2 @@
1
- import{r}from"../packem_shared/api-spec-BENwiyUa.mjs";import{i as a}from"../packem_shared/command-Bjv4VmYA.mjs";import{runDeployCommand as c}from"./runDeployCommand.mjs";const i=".lunora/build",p=async o=>{const e=o.outDir??i,t=await c({apiSpec:o.apiSpec,cwd:o.cwd,dryRun:!0,format:o.format,logger:o.logger,outDir:e,spawner:o.spawner,target:o.target});return t.code===0&&o.logger.success(`build complete bundle written to ${e}`),t},d=a(async({cwd:o,logger:e,options:t})=>({code:(await p({apiSpec:r(t.apiSpec),cwd:o,format:t.format,logger:e,outDir:t.outDir,target:t.target})).code}));export{d as execute,p as runBuildCommand};
1
+ import{mkdirSync as s,writeFileSync as a}from"node:fs";import{isAbsolute as g,resolve as c,dirname as m}from"node:path";import{findWranglerFile as l,readWranglerJsonc as u,buildBindingManifest as p}from"@lunora/config/cloudflare";import{r as f}from"../packem_shared/api-spec-BENwiyUa.mjs";import{i as w}from"../packem_shared/command-Bjv4VmYA.mjs";import{runDeployCommand as b}from"./runDeployCommand.mjs";const h=".lunora/build",y=(i,r,n)=>{const e=l(i),d=e===void 0?void 0:u(e).parsed;if(d===void 0)return{error:`--emit-bindings found no readable wrangler config in ${i}. The manifest is derived from it, and an empty one would tell a deployer this Worker needs nothing.`};const o=p(d),t=g(r)?r:c(i,r);return s(m(t),{recursive:!0}),a(t,`${JSON.stringify(o,void 0,2)}
2
+ `,"utf8"),n.success(`binding manifest written to ${t} (${o.bindings.length.toString()} bindings, ${o.crons.length.toString()} crons)`),o.unknown.length>0&&n.warn(`binding manifest does not model these wrangler sections: ${o.unknown.join(", ")}. Anything they bind must be provisioned by hand — please report them so the manifest can cover them.`),{}},v=async i=>{const r=i.outDir??h,n=await b({apiSpec:i.apiSpec,cwd:i.cwd,dryRun:!0,format:i.format,logger:i.logger,outDir:r,spawner:i.spawner,target:i.target});if(n.code!==0)return n;if(i.logger.success(`build complete — bundle written to ${r}`),i.emitBindings!==void 0){const{error:e}=y(i.cwd??process.cwd(),i.emitBindings,i.logger);if(e!==void 0)return i.logger.error(e),{...n,code:1}}return n},x=w(async({cwd:i,logger:r,options:n})=>({code:(await v({apiSpec:f(n.apiSpec),cwd:i,emitBindings:n.emitBindings,format:n.format,logger:r,outDir:n.outDir,target:n.target})).code}));export{x as execute,v as runBuildCommand};
@@ -1,11 +1,11 @@
1
- import{existsSync as h,mkdirSync as S,writeFileSync as m,readFileSync as b,readdirSync as te,rmSync as _,mkdtempSync as ae,lstatSync as Ne,cpSync as K,renameSync as Ie}from"node:fs";import{tmpdir as re}from"node:os";import{detectFramework as _e,isInteractive as g,LUNA_ART as Re,LUNA_NAME as Te,LUNA_SIGNOFF as je,paintAnswer as Oe,BADGES as f}from"@lunora/config";import{walkSync as Be}from"@visulima/fs";import{join as p,dirname as C,basename as A,resolve as E,relative as Ee}from"@visulima/path";import{downloadTemplate as oe}from"giget";import{modify as Pe,applyEdits as De}from"jsonc-parser";import{join as P,dirname as Ue}from"node:path";import{p as se,M as Ve,l as D,t as ze,f as He}from"../packem_shared/detect-package-manager-D9r2z_X6.mjs";import{i as We}from"../packem_shared/command-Bjv4VmYA.mjs";import qe from"magic-string";import{Project as ie,SyntaxKind as v}from"ts-morph";import{P as U}from"../packem_shared/prompt-cancelled-C8Sj7OqI.mjs";import{P as ne,g as le,b as Fe,L as ce,I as Ke}from"../packem_shared/commands-BvfzxKAa.mjs";import{defaultSpawner as de}from"../packem_shared/createRecordingSpawner-SKs4R1fc.mjs";import{Y as Je,h as Qe,M as Ge,C as pe,U as Xe,i as ue,X as he,B as V,H as Ye,W as Ze,Q as me,I as et,t as tt}from"../packem_shared/tui-prompts-CCt3jm1k.mjs";import{l as ge,u as at,p as rt,b as ot,a as st,m as it,n as nt,f as ve,q as fe,h as lt}from"../packem_shared/storage-CSzKwh4L.mjs";import{logStep as J}from"../packem_shared/createLogger--C3x1FNE.mjs";import ct from"node:dns/promises";const z={bun:{githubCacheKey:void 0,githubSetupStep:` - uses: oven-sh/setup-bun@v2
1
+ import{existsSync as h,mkdirSync as S,writeFileSync as g,readFileSync as b,readdirSync as ae,rmSync as _,mkdtempSync as re,lstatSync as _e,cpSync as K,renameSync as Re}from"node:fs";import{tmpdir as oe}from"node:os";import{detectFramework as je,isInteractive as v,LUNA_ART as Te,LUNA_NAME as Oe,LUNA_SIGNOFF as Be,paintAnswer as Ee,BADGES as m,detectLintTools as Pe,applyLintIgnores as De}from"@lunora/config";import{walkSync as Ue}from"@visulima/fs";import{join as p,dirname as C,basename as A,resolve as E,relative as Ve}from"@visulima/path";import{downloadTemplate as ie}from"giget";import{modify as ze,applyEdits as He}from"jsonc-parser";import{join as P,dirname as We}from"node:path";import{p as se,M as qe,l as D,t as Fe,f as Ke}from"../packem_shared/detect-package-manager-D9r2z_X6.mjs";import{i as Je}from"../packem_shared/command-Bjv4VmYA.mjs";import Ge from"magic-string";import{Project as ne,SyntaxKind as f}from"ts-morph";import{P as U}from"../packem_shared/prompt-cancelled-C8Sj7OqI.mjs";import{P as le,g as ce,b as Qe,L as de,I as Ye}from"../packem_shared/commands-BvfzxKAa.mjs";import{defaultSpawner as pe}from"../packem_shared/createRecordingSpawner-SKs4R1fc.mjs";import{Y as Xe,h as Ze,M as et,C as ue,U as tt,i as he,X as me,B as V,H as at,W as rt,Q as ge,I as ve,t as ot}from"../packem_shared/tui-prompts-CCt3jm1k.mjs";import{l as fe,u as it,p as st,b as nt,a as lt,q as ct,h as dt,f as we,t as ye,n as pt,j as ut}from"../packem_shared/lint-ignore-report-CSeEIMkV.mjs";import{logStep as J}from"../packem_shared/createLogger--C3x1FNE.mjs";import ht from"node:dns/promises";const z={bun:{githubCacheKey:void 0,githubSetupStep:` - uses: oven-sh/setup-bun@v2
2
2
  `,gitlabImage:"oven/bun:1",gitlabProvisionScript:[],installCmd:"bun install --frozen-lockfile",lockfile:"bun.lockb"},npm:{githubCacheKey:"npm",githubSetupStep:"",gitlabImage:"node:22",gitlabProvisionScript:[],installCmd:"npm ci",lockfile:"package-lock.json"},pnpm:{githubCacheKey:"pnpm",githubSetupStep:` - uses: pnpm/action-setup@v4
3
- `,gitlabImage:"node:22",gitlabProvisionScript:["corepack enable"],installCmd:"pnpm install --frozen-lockfile",lockfile:"pnpm-lock.yaml"},yarn:{githubCacheKey:"yarn",githubSetupStep:"",gitlabImage:"node:22",gitlabProvisionScript:["corepack enable"],installCmd:"yarn install --frozen-lockfile",lockfile:"yarn.lock"}},$=(e,t)=>{const a=Ve(e,"lunora",t);return[a.command,...a.args].join(" ")},Q=e=>` - uses: actions/checkout@v4
3
+ `,gitlabImage:"node:22",gitlabProvisionScript:["corepack enable"],installCmd:"pnpm install --frozen-lockfile",lockfile:"pnpm-lock.yaml"},yarn:{githubCacheKey:"yarn",githubSetupStep:"",gitlabImage:"node:22",gitlabProvisionScript:["corepack enable"],installCmd:"yarn install --frozen-lockfile",lockfile:"yarn.lock"}},$=(e,t)=>{const a=qe(e,"lunora",t);return[a.command,...a.args].join(" ")},G=e=>` - uses: actions/checkout@v4
4
4
  ${e.githubSetupStep} - uses: actions/setup-node@v4
5
5
  with:
6
6
  node-version: 22
7
7
  ${e.githubCacheKey===void 0?"":` cache: ${e.githubCacheKey}
8
- `} - run: ${e.installCmd}`,dt=e=>{const t=z[e],a=t.githubCacheKey===void 0?`# (below) requires it — run \`${e} install\` locally and`:`# (below) and the ${e} cache both require it — run \`${e} install\` locally and`;return`name: Deploy
8
+ `} - run: ${e.installCmd}`,mt=e=>{const t=z[e],a=t.githubCacheKey===void 0?`# (below) requires it — run \`${e} install\` locally and`:`# (below) and the ${e} cache both require it — run \`${e} install\` locally and`;return`name: Deploy
9
9
 
10
10
  on:
11
11
  push:
@@ -32,7 +32,7 @@ jobs:
32
32
  permissions:
33
33
  contents: read
34
34
  steps:
35
- ${Q(t)}
35
+ ${G(t)}
36
36
  # Codegen + wrangler validation gate (no deploy) — fails fast on drift.
37
37
  - run: ${$(e,["prepare"])}
38
38
  - run: ${$(e,["deploy"])}
@@ -45,9 +45,9 @@ ${Q(t)}
45
45
  permissions:
46
46
  contents: read
47
47
  steps:
48
- ${Q(t)}
48
+ ${G(t)}
49
49
  - run: ${$(e,["deploy","--preview"])}
50
- `},pt=e=>{const t=z[e],a=[...t.gitlabProvisionScript,t.installCmd].map(r=>` - ${r}`).join(`
50
+ `},gt=e=>{const t=z[e],a=[...t.gitlabProvisionScript,t.installCmd].map(r=>` - ${r}`).join(`
51
51
  `);return`stages:
52
52
  - deploy
53
53
 
@@ -82,16 +82,16 @@ preview:
82
82
  - if: $CI_PIPELINE_SOURCE == "merge_request_event"
83
83
  script:
84
84
  - ${$(e,["deploy","--preview"])}
85
- `},we={github:{file:P(".github","workflows","deploy.yml"),secretsHint:"repository secrets (Settings → Secrets and variables → Actions)"},gitlab:{file:".gitlab-ci.yml",secretsHint:"masked CI/CD variables (Settings → CI/CD → Variables)"}},ut=(e,t)=>e==="github"?dt(t):pt(t),ht=e=>e==="github"||e==="gitlab",mt=(e,t,a,r={})=>{const o=P(e,we[t].file);return h(o)&&r.overwrite!==!0?{path:o,skipped:!0,written:!1}:(S(Ue(o),{recursive:!0}),m(o,ut(t,a),"utf8"),{path:o,skipped:!1,written:!0})},gt=(e,t,a,r,o={})=>{const s=we[t];try{const i=mt(e,t,a,o);if(i.skipped)r.info(`--ci ${t}: ${s.file} already exists — left unchanged (re-run with overwrite to replace).`);else{const n=se(a),l=[n.command,...n.args].join(" "),{installCmd:d,lockfile:u}=z[a];r.success(`--ci ${t}: wrote ${s.file}`),r.info(`--ci ${t}: set CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID as ${s.secretsHint} to enable deploys.`),r.info(`--ci ${t}: run \`${l}\` and commit ${u} before pushing — the pipeline runs \`${d}\`.`)}return i}catch(i){const n=i instanceof Error?i.message:String(i);return r.warn(`--ci ${t}: could not write ${s.file} (${n})`),{path:P(e,s.file),skipped:!1,written:!1}}},vt={astro:"@lunora/react",none:"@lunora/react",nuxt:"@lunora/vue","react-router":"@lunora/react","solid-start":"@lunora/solid",sveltekit:"@lunora/svelte","tanstack-start":"@lunora/react","tanstack-start-solid":"@lunora/solid"},ft=e=>{const t=_e(e);return{...t,adapter:vt[t.framework]}},I="lunora()",G='import { lunora } from "@lunora/vite";',wt=/\blunora\s*\(/u,yt='"@lunora/vite"',bt="'@lunora/vite'",kt=e=>{for(const t of e.getStatements()){if(t.getKind()!==v.ExportAssignment)continue;const a=t.asKindOrThrow(v.ExportAssignment).getExpression();if(a.getKind()!==v.CallExpression)continue;const r=a.asKindOrThrow(v.CallExpression);if(r.getExpression().getText()!=="defineConfig")continue;const o=r.getArguments()[0];if(o?.getKind()===v.ObjectLiteralExpression)return o.asKindOrThrow(v.ObjectLiteralExpression)}},xt=e=>{for(const t of e.getStatements()){if(t.getKind()!==v.ExportAssignment)continue;const a=t.asKindOrThrow(v.ExportAssignment).getExpression();if(a.getKind()===v.ObjectLiteralExpression)return a.asKindOrThrow(v.ObjectLiteralExpression)}},$t=e=>{const t=new ie({compilerOptions:{allowJs:!0},useInMemoryFileSystem:!0}).createSourceFile("vite.config.ts",e,{overwrite:!0});return kt(t)??xt(t)},Ct=e=>{const t=new ie({compilerOptions:{allowJs:!0},useInMemoryFileSystem:!0}).createSourceFile("vite.config.ts",e,{overwrite:!0}).getImportDeclarations();if(t.length===0)return 0;const a=t[t.length-1];return a===void 0?0:a.getEnd()},Mt=(e,t)=>{const a=Ct(t);a===0?e.prepend(`${G}
85
+ `},be={github:{file:P(".github","workflows","deploy.yml"),secretsHint:"repository secrets (Settings → Secrets and variables → Actions)"},gitlab:{file:".gitlab-ci.yml",secretsHint:"masked CI/CD variables (Settings → CI/CD → Variables)"}},vt=(e,t)=>e==="github"?mt(t):gt(t),ft=e=>e==="github"||e==="gitlab",wt=(e,t,a,r={})=>{const o=P(e,be[t].file);return h(o)&&r.overwrite!==!0?{path:o,skipped:!0,written:!1}:(S(We(o),{recursive:!0}),g(o,vt(t,a),"utf8"),{path:o,skipped:!1,written:!0})},yt=(e,t,a,r,o={})=>{const i=be[t];try{const s=wt(e,t,a,o);if(s.skipped)r.info(`--ci ${t}: ${i.file} already exists — left unchanged (re-run with overwrite to replace).`);else{const n=se(a),l=[n.command,...n.args].join(" "),{installCmd:d,lockfile:u}=z[a];r.success(`--ci ${t}: wrote ${i.file}`),r.info(`--ci ${t}: set CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID as ${i.secretsHint} to enable deploys.`),r.info(`--ci ${t}: run \`${l}\` and commit ${u} before pushing — the pipeline runs \`${d}\`.`)}return s}catch(s){const n=s instanceof Error?s.message:String(s);return r.warn(`--ci ${t}: could not write ${i.file} (${n})`),{path:P(e,i.file),skipped:!1,written:!1}}},bt={astro:"@lunora/react",none:"@lunora/react",nuxt:"@lunora/vue","react-router":"@lunora/react","solid-start":"@lunora/solid",sveltekit:"@lunora/svelte","tanstack-start":"@lunora/react","tanstack-start-solid":"@lunora/solid"},xt=e=>{const t=je(e);return{...t,adapter:bt[t.framework]}},N="lunora()",Q='import { lunora } from "@lunora/vite";',kt=/\blunora\s*\(/u,$t='"@lunora/vite"',Ct="'@lunora/vite'",Mt=e=>{for(const t of e.getStatements()){if(t.getKind()!==f.ExportAssignment)continue;const a=t.asKindOrThrow(f.ExportAssignment).getExpression();if(a.getKind()!==f.CallExpression)continue;const r=a.asKindOrThrow(f.CallExpression);if(r.getExpression().getText()!=="defineConfig")continue;const o=r.getArguments()[0];if(o?.getKind()===f.ObjectLiteralExpression)return o.asKindOrThrow(f.ObjectLiteralExpression)}},Lt=e=>{for(const t of e.getStatements()){if(t.getKind()!==f.ExportAssignment)continue;const a=t.asKindOrThrow(f.ExportAssignment).getExpression();if(a.getKind()===f.ObjectLiteralExpression)return a.asKindOrThrow(f.ObjectLiteralExpression)}},St=e=>{const t=new ne({compilerOptions:{allowJs:!0},useInMemoryFileSystem:!0}).createSourceFile("vite.config.ts",e,{overwrite:!0});return Mt(t)??Lt(t)},At=e=>{const t=new ne({compilerOptions:{allowJs:!0},useInMemoryFileSystem:!0}).createSourceFile("vite.config.ts",e,{overwrite:!0}).getImportDeclarations();if(t.length===0)return 0;const a=t[t.length-1];return a===void 0?0:a.getEnd()},It=(e,t)=>{const a=At(t);a===0?e.prepend(`${Q}
86
86
  `):e.appendLeft(a,`
87
- ${G}`)},Lt=(e,t)=>{const a=t.getProperty("plugins");if(a===void 0){const s=t.getProperties(),i=t.getStart()+1;if(s.length===0)e.appendLeft(i,` plugins: [${I}] `);else{const n=s[0];n!==void 0&&e.appendLeft(n.getStart(),`plugins: [${I}],
88
- `)}return}const r=a.getDescendantsOfKind(v.ArrayLiteralExpression)[0];if(r===void 0)return;const o=r.getElements();if(o.length===0)e.appendLeft(r.getStart()+1,I);else{const s=o[0];s!==void 0&&e.appendLeft(s.getStart(),`${I}, `)}},ye=e=>{if(wt.test(e))return{changed:!1,code:e,reason:"lunora plugin already present"};const t=$t(e);if(t===void 0)return{changed:!1,code:e,reason:"could not locate a Vite config plugins array to patch"};const a=new qe(e);return e.includes(yt)||e.includes(bt)||Mt(a,e),Lt(a,t),{changed:!0,code:a.toString()}},St=/enotfound|eai_again|econnrefused|etimedout|network|fetch failed|getaddrinfo/u,At=/404|not found|could not find|no such/u,Nt=(e,t)=>{const a=e instanceof Error?e.message:String(e),r=a.toLowerCase(),o=`failed to download template "${t.templateType}" from ${t.remote}: ${a}`;return At.test(r)?{hints:[`Check the template name "${t.templateType}" and the ref "${t.ref}".`,"List/inspect available templates, or target a branch/tag with `--ref <branch>`."],message:`template "${t.templateType}" not found at ${t.remote}: ${a}`}:St.test(r)?{hints:["You appear to be offline or unable to reach GitHub.","To scaffold without a network, point at a local template root: `lunora init --from <dir>`."],message:o}:{hints:["If this is a network/offline issue, scaffold from a local root with `lunora init --from <dir>`."],message:o}},R=async(e,t,a)=>{if(g()){await Qe(f[e],t,a);return}if(process.stdout.write(`
87
+ ${Q}`)},Nt=(e,t)=>{const a=t.getProperty("plugins");if(a===void 0){const i=t.getProperties(),s=t.getStart()+1;if(i.length===0)e.appendLeft(s,` plugins: [${N}] `);else{const n=i[0];n!==void 0&&e.appendLeft(n.getStart(),`plugins: [${N}],
88
+ `)}return}const r=a.getDescendantsOfKind(f.ArrayLiteralExpression)[0];if(r===void 0)return;const o=r.getElements();if(o.length===0)e.appendLeft(r.getStart()+1,N);else{const i=o[0];i!==void 0&&e.appendLeft(i.getStart(),`${N}, `)}},xe=e=>{if(kt.test(e))return{changed:!1,code:e,reason:"lunora plugin already present"};const t=St(e);if(t===void 0)return{changed:!1,code:e,reason:"could not locate a Vite config plugins array to patch"};const a=new Ge(e);return e.includes($t)||e.includes(Ct)||It(a,e),Nt(a,t),{changed:!0,code:a.toString()}},_t=/enotfound|eai_again|econnrefused|etimedout|network|fetch failed|getaddrinfo/u,Rt=/404|not found|could not find|no such/u,jt=(e,t)=>{const a=e instanceof Error?e.message:String(e),r=a.toLowerCase(),o=`failed to download template "${t.templateType}" from ${t.remote}: ${a}`;return Rt.test(r)?{hints:[`Check the template name "${t.templateType}" and the ref "${t.ref}".`,"List/inspect available templates, or target a branch/tag with `--ref <branch>`."],message:`template "${t.templateType}" not found at ${t.remote}: ${a}`}:_t.test(r)?{hints:["You appear to be offline or unable to reach GitHub.","To scaffold without a network, point at a local template root: `lunora init --from <dir>`."],message:o}:{hints:["If this is a network/offline issue, scaffold from a local root with `lunora init --from <dir>`."],message:o}},R=async(e,t,a)=>{if(v()){await Ze(m[e],t,a);return}if(process.stdout.write(`
89
89
  `),a===void 0||a===""){J(e,t);return}const r=a.split(`
90
- `).map(o=>Oe(o)).join(`
90
+ `).map(o=>Ee(o)).join(`
91
91
  `);J(e,`${t}
92
- ${r}`)},It=async e=>{if(g()){await Je();return}e.info(`
93
- ${Re}
94
- ${Te}: ${je}`)},be=[{description:"LLMs via Workers AI (summarize, generate, stream)",label:"AI",value:"ai"},{description:"Sign-up / sign-in (asks which provider)",label:"Authentication",value:"auth"},{description:"Copy-in auth screens for your framework (sign in/up, reset, 2FA)",label:"Auth UI",value:"auth-ui"},{description:"Snapshot + restore your Durable Object data",label:"Backups",value:"backup"},{description:"Headless browser screenshots + PDFs",label:"Browser rendering",value:"browser"},{description:"Zero Trust identity via Cloudflare Access",label:"Cloudflare Access",value:"cloudflare-access"},{description:"Scheduled jobs via Cron Triggers (@lunora/scheduler)",label:"Cron jobs",value:"crons"},{description:"Cloudflare Email Workers + a dev mail catcher",label:"Transactional email",value:"email"},{description:"OpenFeature feature flags (ctx.flags)",label:"Feature flags",value:"flags"},{description:"External Postgres/MySQL via Hyperdrive",label:"Hyperdrive",value:"hyperdrive"},{description:"Stripe-first payments (checkout, subscription, webhooks)",label:"Payments",value:"payment"},{description:"Live presence / who's-online over hibernated WebSockets",label:"Presence",value:"presence"},{description:"Async message queues (push/pull consumers)",label:"Queues",value:"queue"},{description:"Typed R2 buckets + signed URLs (@lunora/storage)",label:"File storage",value:"storage"},{description:"Durable long-running workflows (step.do, sleep, branch)",label:"Workflows",value:"workflow"}],X=be.map(e=>e.value),_t=e=>e==="email"?ge:e,Rt=(e,t)=>{const a=[];for(const r of e.split(",").map(o=>o.trim()).filter(Boolean))X.includes(r)?a.includes(r)||a.push(r):t(`init: unknown --add feature "${r}" — expected ${X.join(" | ")}; skipping.`);return a},Tt=async e=>{const t=await nt(e.select),a=await ve(e.text,e.projectName);return{label:"auth",names:[t],transformManifest:r=>fe(r,a)}},jt=async e=>{const t=await e.text(ot,{placeholder:"you@yourdomain.com"}),a=st(t,r=>{e.logger.warn(r)});return{label:"email",names:[ge],transformManifest:a===void 0?void 0:r=>it(r,a)}},Ot=async(e,t)=>{const a=e.resolveAuthUiItem?.()??"auth-ui-react";if(t)return{label:"auth-ui",names:[a]};const r=await ve(e.text,e.projectName);return{label:"auth-ui",names:[a],transformManifest:o=>fe(o,r)}},Bt=async e=>{const t=await at(e.text,e.projectName);return{label:"storage",names:["storage"],transformManifest:a=>rt(a,t)}},Et={auth:Tt,"auth-ui":async(e,t)=>Ot(e,t.includes("auth")),email:jt,storage:Bt},Y=async e=>{if(e.preselected!==void 0&&e.preselected.length>0){await e.applyAll(e.preselected.map(r=>{const o=r==="auth-ui"?e.resolveAuthUiItem?.()??"auth-ui-react":_t(r);return{label:r,names:[o]}}));return}if(!e.interactive){e.logger.info("tip: add features later with `lunora add <ai|auth|backup|browser|cloudflare-access|crons|email|flags|hyperdrive|payment|presence|queue|storage|workflow>`.");return}const t=await e.multiSelect("Which features do you want to add?",be,{defaults:[]});if(t.length===0)return;const a=[];for(const r of t){const o=Et[r];a.push(o?await o(e,t):{label:r,names:[r]})}await e.applyAll(a)},N="M 259.500 10.552 C 220.080 15.859, 182.424 32.566, 152.500 58.025 C 110.179 94.031, 85.380 137.183, 77.518 188.500 C 75.410 202.255, 74.569 225.677, 75.796 236.466 C 76.757 244.917, 76.683 245.692, 74.518 249.966 C 63.118 272.466, 53.141 303.876, 51.382 322.799 L 50.718 329.943 71.960 320.471 C 83.643 315.262, 93.326 311, 93.478 311 C 93.630 311, 96.547 316.063, 99.959 322.250 C 103.371 328.438, 107.249 334.850, 108.577 336.500 L 110.990 339.500 110.981 336 C 110.977 334.075, 111.499 324.991, 112.143 315.813 L 113.312 299.127 121.406 293.336 C 132.495 285.403, 149.593 271.554, 161 261.268 C 171.556 251.748, 189.116 235, 188.540 235 C 188.337 235, 183.069 238.648, 176.835 243.106 C 142.318 267.789, 68.537 314, 63.646 314 C 61.843 314, 72.791 281.179, 80.905 262.259 C 92.233 235.845, 107.473 212.389, 132.106 183.453 L 138.451 176 148.268 176 C 176.192 176, 197.512 187.154, 212.868 209.797 C 216.470 215.108, 217.035 216.595, 216.477 219.297 C 211.386 243.968, 202.359 274.496, 193.797 296 C 183.898 320.861, 167.147 352.101, 152.395 373.215 L 147.004 380.930 152.891 385.830 C 161.400 392.911, 165.563 396, 166.594 395.998 C 167.092 395.998, 168.772 391.641, 170.327 386.317 C 176.279 365.934, 188.422 338.749, 200.942 317.778 C 223.060 280.731, 256.432 244.369, 294.500 215.836 C 309.956 204.252, 313.937 201.603, 314.719 202.385 C 315.116 202.783, 315.449 213.096, 315.460 225.304 C 315.474 241.855, 315.021 250.405, 313.680 258.924 C 307.009 301.272, 291.175 336.677, 263.112 372 C 255.259 381.883, 227.182 410.673, 218.516 417.727 L 213.532 421.783 223.439 424.880 C 281.705 443.093, 349.165 436.018, 398.616 406.508 C 446.728 377.797, 483.322 331.466, 497.366 281.481 C 503.381 260.075, 504.480 250.741, 504.491 221 C 504.501 191.997, 503.598 184.047, 497.987 163.732 C 484.768 115.871, 452.505 72.708, 407.718 42.964 C 381.051 25.254, 352.818 14.828, 319.695 10.460 C 305.932 8.645, 273.298 8.695, 259.500 10.552",L=`/* The welcome page is a full-bleed starter — reset the browser's default
92
+ ${r}`)},Tt=async e=>{if(v()){await Xe();return}e.info(`
93
+ ${Te}
94
+ ${Oe}: ${Be}`)},ke=[{description:"LLMs via Workers AI (summarize, generate, stream)",label:"AI",value:"ai"},{description:"Sign-up / sign-in (asks which provider)",label:"Authentication",value:"auth"},{description:"Copy-in auth screens for your framework (sign in/up, reset, 2FA)",label:"Auth UI",value:"auth-ui"},{description:"Snapshot + restore your Durable Object data",label:"Backups",value:"backup"},{description:"Headless browser screenshots + PDFs",label:"Browser rendering",value:"browser"},{description:"Zero Trust identity via Cloudflare Access",label:"Cloudflare Access",value:"cloudflare-access"},{description:"Scheduled jobs via Cron Triggers (@lunora/scheduler)",label:"Cron jobs",value:"crons"},{description:"Cloudflare Email Workers + a dev mail catcher",label:"Transactional email",value:"email"},{description:"OpenFeature feature flags (ctx.flags)",label:"Feature flags",value:"flags"},{description:"External Postgres/MySQL via Hyperdrive",label:"Hyperdrive",value:"hyperdrive"},{description:"Stripe-first payments (checkout, subscription, webhooks)",label:"Payments",value:"payment"},{description:"Live presence / who's-online over hibernated WebSockets",label:"Presence",value:"presence"},{description:"Async message queues (push/pull consumers)",label:"Queues",value:"queue"},{description:"Typed R2 buckets + signed URLs (@lunora/storage)",label:"File storage",value:"storage"},{description:"Durable long-running workflows (step.do, sleep, branch)",label:"Workflows",value:"workflow"}],Y=ke.map(e=>e.value),Ot=e=>e==="email"?fe:e,Bt=(e,t)=>{const a=[];for(const r of e.split(",").map(o=>o.trim()).filter(Boolean))Y.includes(r)?a.includes(r)||a.push(r):t(`init: unknown --add feature "${r}" — expected ${Y.join(" | ")}; skipping.`);return a},Et=async e=>{const t=await dt(e.select),a=await we(e.text,e.projectName);return{label:"auth",names:[t],transformManifest:r=>ye(r,a)}},Pt=async e=>{const t=await e.text(nt,{placeholder:"you@yourdomain.com"}),a=lt(t,r=>{e.logger.warn(r)});return{label:"email",names:[fe],transformManifest:a===void 0?void 0:r=>ct(r,a)}},Dt=async(e,t)=>{const a=e.resolveAuthUiItem?.()??"auth-ui-react";if(t)return{label:"auth-ui",names:[a]};const r=await we(e.text,e.projectName);return{label:"auth-ui",names:[a],transformManifest:o=>ye(o,r)}},Ut=async e=>{const t=await it(e.text,e.projectName);return{label:"storage",names:["storage"],transformManifest:a=>st(a,t)}},Vt={auth:Et,"auth-ui":async(e,t)=>Dt(e,t.includes("auth")),email:Pt,storage:Ut},X=async e=>{if(e.preselected!==void 0&&e.preselected.length>0){await e.applyAll(e.preselected.map(r=>{const o=r==="auth-ui"?e.resolveAuthUiItem?.()??"auth-ui-react":Ot(r);return{label:r,names:[o]}}));return}if(!e.interactive){e.logger.info("tip: add features later with `lunora add <ai|auth|backup|browser|cloudflare-access|crons|email|flags|hyperdrive|payment|presence|queue|storage|workflow>`.");return}const t=await e.multiSelect("Which features do you want to add?",ke,{defaults:[]});if(t.length===0)return;const a=[];for(const r of t){const o=Vt[r];a.push(o?await o(e,t):{label:r,names:[r]})}await e.applyAll(a)},zt=[{description:"Adds an ignores entry to eslint.config.js",label:"ESLint",value:"eslint"},{description:"Writes .prettierignore",label:"Prettier",value:"prettier"},{description:"Adds negated patterns to biome.json",label:"Biome",value:"biome"},{description:"Writes ignorePatterns to .oxlintrc.json",label:"oxlint (oxc)",value:"oxlint"}],Ht="Which linter/formatter do you use? We'll tell it to skip Lunora's generated files.",Wt=async e=>{const t=e.interactive?await e.multiSelect(Ht,zt,{defaults:e.detected}):[...e.detected];if(t.length===0)return[];const a=e.apply(t);return pt(a,e.logger),a},I="M 259.500 10.552 C 220.080 15.859, 182.424 32.566, 152.500 58.025 C 110.179 94.031, 85.380 137.183, 77.518 188.500 C 75.410 202.255, 74.569 225.677, 75.796 236.466 C 76.757 244.917, 76.683 245.692, 74.518 249.966 C 63.118 272.466, 53.141 303.876, 51.382 322.799 L 50.718 329.943 71.960 320.471 C 83.643 315.262, 93.326 311, 93.478 311 C 93.630 311, 96.547 316.063, 99.959 322.250 C 103.371 328.438, 107.249 334.850, 108.577 336.500 L 110.990 339.500 110.981 336 C 110.977 334.075, 111.499 324.991, 112.143 315.813 L 113.312 299.127 121.406 293.336 C 132.495 285.403, 149.593 271.554, 161 261.268 C 171.556 251.748, 189.116 235, 188.540 235 C 188.337 235, 183.069 238.648, 176.835 243.106 C 142.318 267.789, 68.537 314, 63.646 314 C 61.843 314, 72.791 281.179, 80.905 262.259 C 92.233 235.845, 107.473 212.389, 132.106 183.453 L 138.451 176 148.268 176 C 176.192 176, 197.512 187.154, 212.868 209.797 C 216.470 215.108, 217.035 216.595, 216.477 219.297 C 211.386 243.968, 202.359 274.496, 193.797 296 C 183.898 320.861, 167.147 352.101, 152.395 373.215 L 147.004 380.930 152.891 385.830 C 161.400 392.911, 165.563 396, 166.594 395.998 C 167.092 395.998, 168.772 391.641, 170.327 386.317 C 176.279 365.934, 188.422 338.749, 200.942 317.778 C 223.060 280.731, 256.432 244.369, 294.500 215.836 C 309.956 204.252, 313.937 201.603, 314.719 202.385 C 315.116 202.783, 315.449 213.096, 315.460 225.304 C 315.474 241.855, 315.021 250.405, 313.680 258.924 C 307.009 301.272, 291.175 336.677, 263.112 372 C 255.259 381.883, 227.182 410.673, 218.516 417.727 L 213.532 421.783 223.439 424.880 C 281.705 443.093, 349.165 436.018, 398.616 406.508 C 446.728 377.797, 483.322 331.466, 497.366 281.481 C 503.381 260.075, 504.480 250.741, 504.491 221 C 504.501 191.997, 503.598 184.047, 497.987 163.732 C 484.768 115.871, 452.505 72.708, 407.718 42.964 C 381.051 25.254, 352.818 14.828, 319.695 10.460 C 305.932 8.645, 273.298 8.695, 259.500 10.552",L=`/* The welcome page is a full-bleed starter — reset the browser's default
95
95
  body margin/padding so it sits flush; everything else is scoped under
96
96
  .lunora-welcome (collision-safe). */
97
97
  body {
@@ -196,7 +196,7 @@ body {
196
196
  .lunora-welcome .lw-foot { text-align: center; padding-top: 26px; font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--t-faint); }
197
197
 
198
198
  @media (prefers-reduced-motion: reduce) { .lunora-welcome * { transition: none !important; } }
199
- `,Pt=`import { useEffect, useState } from "react";
199
+ `,qt=`import { useEffect, useState } from "react";
200
200
 
201
201
  type Theme = "dark" | "light";
202
202
 
@@ -238,7 +238,7 @@ export default function App() {
238
238
  <div className="lw-wrap">
239
239
  <div className="brand">
240
240
  <svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
241
- <path d="${N}" fill="currentColor" fillRule="evenodd" />
241
+ <path d="${I}" fill="currentColor" fillRule="evenodd" />
242
242
  </svg>
243
243
  <span className="word">Lunora</span>
244
244
  </div>
@@ -357,7 +357,7 @@ export default function App() {
357
357
  </div>
358
358
  );
359
359
  }
360
- `,Dt=`<script setup lang="ts">
360
+ `,Ft=`<script setup lang="ts">
361
361
  import { onMounted, ref } from "vue";
362
362
 
363
363
  // Default to "dark" for a stable first paint, then reconcile to the OS
@@ -397,7 +397,7 @@ const toggle = (): void => {
397
397
  <div class="lw-wrap">
398
398
  <div class="brand">
399
399
  <svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
400
- <path d="${N}" fill="currentColor" fill-rule="evenodd" />
400
+ <path d="${I}" fill="currentColor" fill-rule="evenodd" />
401
401
  </svg>
402
402
  <span class="word">Lunora</span>
403
403
  </div>
@@ -513,7 +513,7 @@ const toggle = (): void => {
513
513
  </div>
514
514
  </div>
515
515
  </template>
516
- `,Ut=`import { createSignal, onMount } from "solid-js";
516
+ `,Kt=`import { createSignal, onMount } from "solid-js";
517
517
 
518
518
  export default function App() {
519
519
  // Default to "dark" for a stable first paint, then reconcile to the OS
@@ -553,7 +553,7 @@ export default function App() {
553
553
  <div class="lw-wrap">
554
554
  <div class="brand">
555
555
  <svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
556
- <path d="${N}" fill="currentColor" fill-rule="evenodd" />
556
+ <path d="${I}" fill="currentColor" fill-rule="evenodd" />
557
557
  </svg>
558
558
  <span class="word">Lunora</span>
559
559
  </div>
@@ -672,7 +672,7 @@ export default function App() {
672
672
  </div>
673
673
  );
674
674
  }
675
- `,Vt=`<script lang="ts">
675
+ `,Jt=`<script lang="ts">
676
676
  import { onMount } from "svelte";
677
677
 
678
678
  // Default to "dark" for a stable first paint, then reconcile to the OS
@@ -715,7 +715,7 @@ export default function App() {
715
715
  <div class="lw-wrap">
716
716
  <div class="brand">
717
717
  <svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
718
- <path d="${N}" fill="currentColor" fill-rule="evenodd" />
718
+ <path d="${I}" fill="currentColor" fill-rule="evenodd" />
719
719
  </svg>
720
720
  <span class="word">Lunora</span>
721
721
  </div>
@@ -830,7 +830,7 @@ export default function App() {
830
830
  <div class="lw-foot">Running on Lunora · Vite + Svelte</div>
831
831
  </div>
832
832
  </div>
833
- `,zt=`import "./style.css";
833
+ `,Gt=`import "./style.css";
834
834
 
835
835
  import { LunoraClient } from "lunorash/client";
836
836
 
@@ -858,7 +858,7 @@ const welcomeHtml = \`
858
858
  <div class="lw-wrap">
859
859
  <div class="brand">
860
860
  <svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
861
- <path d="${N}" fill="currentColor" fill-rule="evenodd" />
861
+ <path d="${I}" fill="currentColor" fill-rule="evenodd" />
862
862
  </svg>
863
863
  <span class="word">Lunora</span>
864
864
  </div>
@@ -997,7 +997,7 @@ const count = document.querySelector<HTMLSpanElement>("#lw-count")!;
997
997
  client.onUpdate(api.messages.list, { channelId: "channel:demo" }, (result) => {
998
998
  count.textContent = String(result.messages.length);
999
999
  });
1000
- `,T="const url = (import.meta.env.VITE_LUNORA_URL as string | undefined) ?? globalThis.location.origin;",Ht=`import "./index.css";
1000
+ `,j="const url = (import.meta.env.VITE_LUNORA_URL as string | undefined) ?? globalThis.location.origin;",Qt=`import "./index.css";
1001
1001
 
1002
1002
  import { LunoraProvider } from "@lunora/react";
1003
1003
  import { LunoraClient } from "lunorash/client";
@@ -1009,7 +1009,7 @@ import App from "./App.tsx";
1009
1009
  // \`@lunora/vite\` runs the Worker on the same origin as Vite, so default to
1010
1010
  // \`location.origin\`. Point \`VITE_LUNORA_URL\` at a deployed Worker to develop
1011
1011
  // the client against production data.
1012
- ${T}
1012
+ ${j}
1013
1013
  const client = new LunoraClient({ url });
1014
1014
 
1015
1015
  const root = document.getElementById("root");
@@ -1025,7 +1025,7 @@ createRoot(root).render(
1025
1025
  </LunoraProvider>
1026
1026
  </StrictMode>,
1027
1027
  );
1028
- `,Wt=`import "./style.css";
1028
+ `,Yt=`import "./style.css";
1029
1029
 
1030
1030
  import { createLunora } from "@lunora/vue";
1031
1031
  import { LunoraClient } from "lunorash/client";
@@ -1034,9 +1034,9 @@ import { createApp } from "vue";
1034
1034
  import App from "./App.vue";
1035
1035
 
1036
1036
  // Provide one LunoraClient at the app root via the Vue plugin form.
1037
- ${T}
1037
+ ${j}
1038
1038
  createApp(App).use(createLunora(new LunoraClient({ url }))).mount("#app");
1039
- `,qt=`import "./index.css";
1039
+ `,Xt=`import "./index.css";
1040
1040
 
1041
1041
  import { LunoraContext } from "@lunora/solid";
1042
1042
  import { LunoraClient } from "lunorash/client";
@@ -1044,7 +1044,7 @@ import { render } from "solid-js/web";
1044
1044
 
1045
1045
  import App from "./App";
1046
1046
 
1047
- ${T}
1047
+ ${j}
1048
1048
  const client = new LunoraClient({ url });
1049
1049
  const root = document.getElementById("root");
1050
1050
 
@@ -1056,18 +1056,18 @@ render(
1056
1056
  ),
1057
1057
  root!,
1058
1058
  );
1059
- `,Ft=`<script lang="ts">
1059
+ `,Zt=`<script lang="ts">
1060
1060
  import { setLunoraClient } from "@lunora/svelte";
1061
1061
  import { LunoraClient } from "lunorash/client";
1062
1062
 
1063
1063
  import App from "./App.svelte";
1064
1064
 
1065
- ${T}
1065
+ ${j}
1066
1066
  setLunoraClient(new LunoraClient({ url }));
1067
1067
  <\/script>
1068
1068
 
1069
1069
  <App />
1070
- `,Kt=`import "./app.css";
1070
+ `,ea=`import "./app.css";
1071
1071
 
1072
1072
  import { mount } from "svelte";
1073
1073
 
@@ -1077,7 +1077,7 @@ import Root from "./Root.svelte";
1077
1077
  const app = mount(Root, { target: document.getElementById("app")! });
1078
1078
 
1079
1079
  export default app;
1080
- `,j={react:{adapter:"@lunora/react",createViteTemplate:"react-ts",files:[{contents:Ht,path:"src/main.tsx"},{contents:Pt,path:"src/App.tsx"},{contents:L,path:"src/index.css"}],label:"React"},solid:{adapter:"@lunora/solid",createViteTemplate:"solid-ts",files:[{contents:qt,path:"src/index.tsx"},{contents:Ut,path:"src/App.tsx"},{contents:L,path:"src/index.css"}],label:"Solid"},svelte:{adapter:"@lunora/svelte",createViteTemplate:"svelte-ts",files:[{contents:Ft,path:"src/Root.svelte"},{contents:Kt,path:"src/main.ts"},{contents:Vt,path:"src/App.svelte"},{contents:L,path:"src/app.css"}],label:"Svelte"},vanilla:{adapter:"lunorash/client",createViteTemplate:"vanilla-ts",files:[{contents:zt,path:"src/main.ts"},{contents:L,path:"src/style.css"}],label:"Vanilla"},vue:{adapter:"@lunora/vue",createViteTemplate:"vue-ts",files:[{contents:Wt,path:"src/main.ts"},{contents:Dt,path:"src/App.vue"},{contents:L,path:"src/style.css"}],label:"Vue"}},H=e=>Object.hasOwn(j,e),Jt=`import type { Middleware } from "lunorash/server";
1080
+ `,T={react:{adapter:"@lunora/react",createViteTemplate:"react-ts",files:[{contents:Qt,path:"src/main.tsx"},{contents:qt,path:"src/App.tsx"},{contents:L,path:"src/index.css"}],label:"React"},solid:{adapter:"@lunora/solid",createViteTemplate:"solid-ts",files:[{contents:Xt,path:"src/index.tsx"},{contents:Kt,path:"src/App.tsx"},{contents:L,path:"src/index.css"}],label:"Solid"},svelte:{adapter:"@lunora/svelte",createViteTemplate:"svelte-ts",files:[{contents:Zt,path:"src/Root.svelte"},{contents:ea,path:"src/main.ts"},{contents:Jt,path:"src/App.svelte"},{contents:L,path:"src/app.css"}],label:"Svelte"},vanilla:{adapter:"lunorash/client",createViteTemplate:"vanilla-ts",files:[{contents:Gt,path:"src/main.ts"},{contents:L,path:"src/style.css"}],label:"Vanilla"},vue:{adapter:"@lunora/vue",createViteTemplate:"vue-ts",files:[{contents:Yt,path:"src/main.ts"},{contents:Ft,path:"src/App.vue"},{contents:L,path:"src/style.css"}],label:"Vue"}},H=e=>Object.hasOwn(T,e),ta=`import type { Middleware } from "lunorash/server";
1081
1081
  import { defineSchemaExtension, defineTable, definePlugin, v } from "lunorash/server";
1082
1082
  import { createDbStore, RateLimiter } from "lunorash/ratelimit";
1083
1083
  import type { RateLimitConfigMap } from "lunorash/ratelimit";
@@ -1117,7 +1117,7 @@ export const ratelimit = definePlugin("ratelimit", {
1117
1117
  }),
1118
1118
  middleware,
1119
1119
  });
1120
- `,Qt=`import { ratelimit } from "./ratelimit/schema.js";
1120
+ `,aa=`import { ratelimit } from "./ratelimit/schema.js";
1121
1121
  import { defineSchema, defineTable, v } from "lunorash/server";
1122
1122
 
1123
1123
  export default defineSchema({
@@ -1128,7 +1128,7 @@ export default defineSchema({
1128
1128
  .shardBy("channelId")
1129
1129
  .index("by_channel", ["channelId"]),
1130
1130
  }).extend(ratelimit.extension);
1131
- `,Gt=`import { RateLimiter, rateLimit, createDbStore } from "lunorash/ratelimit";
1131
+ `,ra=`import { RateLimiter, rateLimit, createDbStore } from "lunorash/ratelimit";
1132
1132
 
1133
1133
  import { mutation, query, v } from "#lunora/_generated/server.js";
1134
1134
 
@@ -1156,7 +1156,7 @@ export const send = mutation
1156
1156
 
1157
1157
  return { channelId: args.channelId, id, text: args.text };
1158
1158
  });
1159
- `,Xt=`import type { ShardNamespaceLike } from "lunorash/runtime";
1159
+ `,oa=`import type { ShardNamespaceLike } from "lunorash/runtime";
1160
1160
 
1161
1161
  import { defineApp } from "../lunora/_generated/app.js";
1162
1162
 
@@ -1170,7 +1170,7 @@ const app = defineApp<Env>()
1170
1170
 
1171
1171
  export const ShardDO = app.ShardDO;
1172
1172
  export default app;
1173
- `,Yt=`{
1173
+ `,ia=`{
1174
1174
  "$schema": "node_modules/wrangler/config-schema.json",
1175
1175
  "name": "__NAME__",
1176
1176
  "main": "src/server.ts",
@@ -1182,23 +1182,23 @@ export default app;
1182
1182
  "migrations": [{ "tag": "v1", "new_sqlite_classes": ["ShardDO"] }],
1183
1183
  "observability": { "enabled": true, "head_sampling_rate": 1 },
1184
1184
  }
1185
- `,Zt=[".wrangler",".env",".env.*","!.env.example",".dev.vars",".dev.vars.*","!.dev.vars.example",".lunora/",".lunora-cache","lunora/_generated"],ea=`# Lunora endpoint for the browser client.
1185
+ `,sa=[".wrangler",".env",".env.*","!.env.example",".dev.vars",".dev.vars.*","!.dev.vars.example",".lunora/",".lunora-cache","lunora/_generated"],na=`# Lunora endpoint for the browser client.
1186
1186
  # Vite statically replaces \`import.meta.env.VITE_LUNORA_URL\` at \`vite dev\` / build.
1187
1187
  # Leave it unset to use the page origin; set it to point at a deployed Worker:
1188
1188
  #
1189
1189
  # VITE_LUNORA_URL=https://my-app.example.workers.dev
1190
- `,ta={"@cloudflare/workers-types":"^4.20260611.1",wrangler:"^4.100.0"},k=(e,t,a,r)=>{const o=p(e,t);S(C(o),{recursive:!0}),m(o,a,"utf8"),r.push(o)},aa=/\r?\n/,ra=e=>{const t=p(e,".gitignore"),a=h(t)?b(t,"utf8"):"",r=Zt.filter(s=>!a.split(aa).includes(s));if(r.length===0)return;const o=a.length>0&&!a.endsWith(`
1190
+ `,la={"@cloudflare/workers-types":"^4.20260611.1",wrangler:"^4.100.0"},x=(e,t,a,r)=>{const o=p(e,t);S(C(o),{recursive:!0}),g(o,a,"utf8"),r.push(o)},ca=/\r?\n/,da=e=>{const t=p(e,".gitignore"),a=h(t)?b(t,"utf8"):"",r=sa.filter(i=>!a.split(ca).includes(i));if(r.length===0)return;const o=a.length>0&&!a.endsWith(`
1191
1191
  `)?`
1192
- `:"";m(t,`${a}${o}
1192
+ `:"";g(t,`${a}${o}
1193
1193
  # Lunora
1194
1194
  ${r.join(`
1195
1195
  `)}
1196
- `,"utf8")},ke=e=>e==="lunorash"||e.startsWith("@lunora/"),xe=(e,t,a,r)=>ke(e)?r?.get(e)??a:t,x=(e,t,a,r)=>({...e,[t]:xe(t,a,r)}),Z=(e,t,a)=>Object.fromEntries(Object.entries(e).map(([r,o])=>[r,xe(r,o,t,a)])),oa=async(e,t,a,r)=>{const o=p(e,"package.json"),s=JSON.parse(b(o,"utf8"));let i=x(s.dependencies??{},"lunorash",r,r);i=x(i,"@lunora/ratelimit",r,r),a.adapter.startsWith("@lunora/")&&(i=x(i,a.adapter,r,r));for(const[u,c]of Object.entries(a.extraDependencies??{}))i=x(i,u,c,r);let n=x(s.devDependencies??{},"@lunora/vite",r,r);n=x(n,"@lunora/studio",r,r);for(const[u,c]of Object.entries(ta))n=x(n,u,c,r);const l=[...Object.keys(i),...Object.keys(n)].filter(u=>ke(u)),d=await ne(l,r);s.name=t,s.imports={...s.imports,"#lunora/*":"./lunora/*"},s.dependencies=Z(i,r,d),s.devDependencies=Z(n,r,d),s.scripts={...s.scripts,codegen:"lunora codegen",deploy:"vite build && lunora deploy"},m(o,`${JSON.stringify(s,void 0,4)}
1197
- `,"utf8")},sa=(e,t)=>{const a=["vite.config.ts","vite.config.mts","vite.config.js","vite.config.mjs"].map(o=>p(e,o)).find(o=>h(o));if(a===void 0){t.warn("overlay: no vite.config found in the create-vite base — add `lunora()` to your Vite plugins manually.");return}const r=ye(b(a,"utf8"));r.changed&&m(a,r.code,"utf8")},ia=async e=>{const{adapter:t,distTag:a,logger:r,name:o,target:s}=e,i=[];k(s,p("lunora","ratelimit","schema.ts"),Jt,i),k(s,p("lunora","schema.ts"),Qt,i),k(s,p("lunora","messages.ts"),Gt,i),k(s,p("src","server.ts"),Xt,i),k(s,"wrangler.jsonc",Yt.replaceAll("__NAME__",o),i),k(s,".env.example",ea,i);for(const n of t.files)k(s,n.path,n.contents,i);return sa(s,r),await oa(s,o,t,a),ra(s),i},na=["lunar","silver","silent","waning","waxing","crescent","cosmic","stellar","orbital","gibbous","twilight","midnight","shimmering","drifting","weightless"],la=["moon","tide","crater","comet","eclipse","halo","orbit","nebula","voyager","lander","rover","beacon","harbor","meadow","fox"],ee=e=>e[Math.floor(Math.random()*e.length)],ca=()=>`${ee(na)}-${ee(la)}`,da=async()=>ct.lookup("github.com").then(()=>!0,()=>!1),pa=/^(?:gh|github):([^/]+)\/([^#/]+)(?:\/[^#]*)?(?:#(.+))?$/,$e=e=>{const t=pa.exec(e);if(t===null)return;const[,a,r,o]=t;if(!(a===void 0||r===void 0))return{owner:a,ref:o??"HEAD",repo:r}},ua=async e=>{const t=$e(e);if(t===void 0)return;const a=`https://codeload.github.com/${t.owner}/${t.repo}/tar.gz/${t.ref}`;try{const r=await fetch(a,{method:"HEAD"});return r.status===404?!1:r.ok?!0:void 0}catch{return}},Ce=async e=>e.isLocal||!(e.source===void 0||$e(e.source)!==void 0)?!0:await da()?e.source!==void 0&&await ua(e.source)===!1?(e.logger.error(`template source not found: ${e.source} — double-check --ref / --source, or browse the templates at https://lunora.sh/docs.`),!1):!0:(e.logger.error("you appear to be offline — connect to the internet and try again, or scaffold from a local template with `--from <dir>`."),!1),y={extras:"Let's finish setting up your app.",framework:"Which framework should we launch?",git:"Initialize a new git repository? (optional)",install:"Install dependencies now?",name:"Where should we land your project?",nextHeader:"Liftoff confirmed — explore your project!",packageManager:"Which package manager?"},ha=new Set([".gitignore",".html",".js",".json",".jsonc",".md",".mjs",".ts",".tsx"]),ma=["vite.config.ts","vite.config.mts","vite.config.js","vite.config.mjs"],ga=`import { defineConfig } from "vite";
1196
+ `,"utf8")},$e=e=>e==="lunorash"||e.startsWith("@lunora/"),Ce=(e,t,a,r)=>$e(e)?r?.get(e)??a:t,k=(e,t,a,r)=>({...e,[t]:Ce(t,a,r)}),Z=(e,t,a)=>Object.fromEntries(Object.entries(e).map(([r,o])=>[r,Ce(r,o,t,a)])),pa=async(e,t,a,r)=>{const o=p(e,"package.json"),i=JSON.parse(b(o,"utf8"));let s=k(i.dependencies??{},"lunorash",r,r);s=k(s,"@lunora/ratelimit",r,r),a.adapter.startsWith("@lunora/")&&(s=k(s,a.adapter,r,r));for(const[u,c]of Object.entries(a.extraDependencies??{}))s=k(s,u,c,r);let n=k(i.devDependencies??{},"@lunora/vite",r,r);n=k(n,"@lunora/studio",r,r);for(const[u,c]of Object.entries(la))n=k(n,u,c,r);const l=[...Object.keys(s),...Object.keys(n)].filter(u=>$e(u)),d=await le(l,r);i.name=t,i.imports={...i.imports,"#lunora/*":"./lunora/*"},i.dependencies=Z(s,r,d),i.devDependencies=Z(n,r,d),i.scripts={...i.scripts,codegen:"lunora codegen",deploy:"vite build && lunora deploy"},g(o,`${JSON.stringify(i,void 0,4)}
1197
+ `,"utf8")},ua=(e,t)=>{const a=["vite.config.ts","vite.config.mts","vite.config.js","vite.config.mjs"].map(o=>p(e,o)).find(o=>h(o));if(a===void 0){t.warn("overlay: no vite.config found in the create-vite base — add `lunora()` to your Vite plugins manually.");return}const r=xe(b(a,"utf8"));r.changed&&g(a,r.code,"utf8")},ha=async e=>{const{adapter:t,distTag:a,logger:r,name:o,target:i}=e,s=[];x(i,p("lunora","ratelimit","schema.ts"),ta,s),x(i,p("lunora","schema.ts"),aa,s),x(i,p("lunora","messages.ts"),ra,s),x(i,p("src","server.ts"),oa,s),x(i,"wrangler.jsonc",ia.replaceAll("__NAME__",o),s),x(i,".env.example",na,s);for(const n of t.files)x(i,n.path,n.contents,s);return ua(i,r),await pa(i,o,t,a),da(i),s},ma=["lunar","silver","silent","waning","waxing","crescent","cosmic","stellar","orbital","gibbous","twilight","midnight","shimmering","drifting","weightless"],ga=["moon","tide","crater","comet","eclipse","halo","orbit","nebula","voyager","lander","rover","beacon","harbor","meadow","fox"],ee=e=>e[Math.floor(Math.random()*e.length)],va=()=>`${ee(ma)}-${ee(ga)}`,fa=async()=>ht.lookup("github.com").then(()=>!0,()=>!1),wa=/^(?:gh|github):([^/]+)\/([^#/]+)(?:\/[^#]*)?(?:#(.+))?$/,Me=e=>{const t=wa.exec(e);if(t===null)return;const[,a,r,o]=t;if(!(a===void 0||r===void 0))return{owner:a,ref:o??"HEAD",repo:r}},ya=async e=>{const t=Me(e);if(t===void 0)return;const a=`https://codeload.github.com/${t.owner}/${t.repo}/tar.gz/${t.ref}`;try{const r=await fetch(a,{method:"HEAD"});return r.status===404?!1:r.ok?!0:void 0}catch{return}},Le=async e=>e.isLocal||!(e.source===void 0||Me(e.source)!==void 0)?!0:await fa()?e.source!==void 0&&await ya(e.source)===!1?(e.logger.error(`template source not found: ${e.source} — double-check --ref / --source, or browse the templates at https://lunora.sh/docs.`),!1):!0:(e.logger.error("you appear to be offline — connect to the internet and try again, or scaffold from a local template with `--from <dir>`."),!1),y={extras:"Let's finish setting up your app.",framework:"Which framework should we launch?",git:"Initialize a new git repository? (optional)",install:"Install dependencies now?",name:"Where should we land your project?",nextHeader:"Liftoff confirmed — explore your project!",packageManager:"Which package manager?"},ba=new Set([".gitignore",".html",".js",".json",".jsonc",".md",".mjs",".ts",".tsx"]),xa=["vite.config.ts","vite.config.mts","vite.config.js","vite.config.mjs"],ka=`import { defineConfig } from "vite";
1198
1198
  import { lunora } from "@lunora/vite";
1199
1199
 
1200
1200
  export default defineConfig({ plugins: [lunora()] });
1201
- `,va=`import { defineSchema, defineTable, v } from "@lunora/server";
1201
+ `,$a=`import { defineSchema, defineTable, v } from "@lunora/server";
1202
1202
 
1203
1203
  export default defineSchema({
1204
1204
  messages: defineTable({
@@ -1208,7 +1208,7 @@ export default defineSchema({
1208
1208
  .shardBy("channelId")
1209
1209
  .index("by_channel", ["channelId"]),
1210
1210
  });
1211
- `,fa=`import { mutation, query, v } from "./_generated/server";
1211
+ `,Ca=`import { mutation, query, v } from "./_generated/server";
1212
1212
 
1213
1213
  export const list = query
1214
1214
  .input({ channelId: v.id("channels"), limit: v.optional(v.number()) })
@@ -1221,8 +1221,8 @@ export const send = mutation
1221
1221
  .mutation(async ({ args }) => {
1222
1222
  return { channelId: args.channelId, text: args.text };
1223
1223
  });
1224
- `,wa="gh:anolilab/lunora/templates",ya=e=>{const t=e.lastIndexOf(".");return t===-1?!1:ha.has(e.slice(t))},ba=(e,t)=>e.replaceAll("{{name}}",t),Me=e=>e==="lunorash"||e.startsWith("@lunora/"),ka=async(e,t)=>{const a=new Set;for(const r of e)if(A(r)==="package.json")try{const o=JSON.parse(b(r,"utf8"));for(const s of["dependencies","devDependencies"])for(const i of Object.keys(o[s]??{}))Me(i)&&a.add(i)}catch{}return ne(a,t)},xa=(e,t,a)=>{let r;try{r=JSON.parse(e)}catch{return e}let o=e;for(const s of["dependencies","devDependencies"])for(const i of Object.keys(r[s]??{})){if(!Me(i))continue;const n=a.get(i)??t,l=Pe(o,[s,i],n,{formattingOptions:{insertSpaces:!0,tabSize:4}});o=De(o,l)}return o},$a=["@parcel/watcher","esbuild","lmdb","msgpackr-extract","rs-module-lexer","sharp","unrs-resolver","vue-demi","workerd"],Ca=["cpu-features","protobufjs","ssh2"],Ma="pnpm-workspace.yaml",La=()=>["# pnpm reads its settings from here (the package.json `pnpm` field is no longer read).","# Pre-approve the toolchain's native build scripts so `pnpm install` runs them","# without the interactive `pnpm approve-builds` step; deny the optional native","# builds a scaffold doesn't need (so no C/C++ toolchain is required).","allowBuilds:",...$a.map(e=>` '${e}': true`),...Ca.map(e=>` '${e}': false`),""].join(`
1225
- `),W=e=>{const t=[];for(const a of Be(e,{includeDirs:!1,includeFiles:!0}))Ne(a.path).isSymbolicLink()||t.push(a.path);return t},Le=async(e,t,a)=>{const r=W(e),o=[],s=ce(),i=await ka(r,s);for(const n of r){const l=Ee(e,n),d=p(t,l);S(C(d),{recursive:!0});const u=b(n);let c=ya(n)?ba(u.toString("utf8"),a):void 0;c!==void 0&&A(n)==="package.json"&&(c=xa(c,s,i)),c===void 0?m(d,u):m(d,c,"utf8"),o.push(d)}return o},B=(e,t,a)=>t!==void 0&&t.length>0?t:`${wa}/${e}#${le(a)}`,Sa=e=>e.includes("..")?!1:e.startsWith("gh:")||e.startsWith("github:")||e.startsWith("https://"),M=(e,t)=>{e.info(`[dry-run] would ${t}`)},q=(e,t,a)=>{g()&&process.stdout.write(`
1226
- `),e.success(`scaffolded ${String(t.length)} files into ${a}`)},Aa=(e,t)=>`${e} ${e==="npm"?"install":"add"} ${t.join(" ")}`,Se=e=>{let t=E(e);for(;;){if(h(p(t,"pnpm-workspace.yaml")))return!0;const a=p(t,"package.json");if(h(a))try{if(JSON.parse(b(a,"utf8")).workspaces!==void 0)return!0}catch{}const r=C(t);if(r===t)return!1;t=r}},Na=e=>{let t=E(e);for(;;){if(h(p(t,".git")))return!0;const a=C(t);if(a===t)return!1;t=a}},Ia=async(e,t)=>{if(e.yes===!0||!g()||Na(C(t)))return;if(!await ue(y.git,{badge:f.git,defaultYes:!1})){await he("Sounds good! You can always run git init manually.");return}if(e.dryRun===!0){M(e.logger,"initialize a git repository");return}const a=e.spawner??de;(await Ye("Initializing a git repository…",()=>a({args:["init"],command:"git",cwd:t}))).code===0?await R("git","Initialized an empty git repository."):e.logger.warn("`git init` failed — initialize it yourself later with `git init`.")},_a=async(e,t,a,r)=>{const o=[{code:`cd ./${e}`,lead:"Enter your project directory using"}];t===void 0&&o.push({code:`${a} install`,lead:"Install dependencies with",tail:r?" from the workspace root":void 0}),o.push({code:He(a,"dev"),lead:"Run",tail:" to start the dev server."},{code:"lunora add",lead:"Add features like auth or storage using"});const s=[{code:"https://lunora.sh/docs",lead:"Read the docs at"},{code:"https://lunora.sh/chat",lead:"Stuck? Join the chat at"}];if(g()){await Ze(f.next,y.nextHeader,o,s);return}const i=o.map(n=>`${n.lead} ${n.code}${n.tail??""}`);i.push("",...s.map(n=>`${n.lead} ${n.code}${n.tail??""}`)),await R("next",y.nextHeader,i.join(`
1227
- `))},Ra=e=>e.yes!==!0&&(e.installPrompt!==void 0||g()),Ta=async(e,t)=>{if(!Ra(e)||Se(C(t)))return;const a=ze(e.packageManagerProbe),[r]=a;if(r===void 0)return;if(!await(e.installPrompt?.confirmInstall??(async()=>ue(y.install,{badge:f.deps,defaultYes:!0})))()){await he("No problem! Remember to install dependencies after setup.");return}let o=r;if(a.length>1&&(o=e.installPrompt?await e.installPrompt.selectManager(a):await V(y.packageManager,a.map(d=>({label:d,value:d})),{badge:f.deps,default:r})??r),e.dryRun===!0){M(e.logger,`install dependencies with ${o}`);return}if(o==="pnpm"){const d=p(t,Ma);h(d)||m(d,La(),"utf8")}const s=e.spawner??de,{args:i,command:n}=se(o);await R("deps",`Installing dependencies with ${o}…`);const l=await s({args:i,command:n,cwd:t});if(l.code!==0){e.logger.warn(`\`${n} install\` exited with code ${String(l.code)} — run it yourself in ${A(t)}/.`);return}return await R("deps",`Dependencies installed with ${o}.`),o},ja=async(e,t,a,r,o)=>{const s=p(e,t);if(!h(s))return o.error(`template not found in local source: ${s}`),{code:1,files:[],target:a};const i=await Le(s,a,r);return q(o,i,a),{code:0,files:i,target:a}},Oa=async e=>{const{logger:t,name:a,ref:r,source:o,target:s,templateType:i}=e,n=ae(p(re(),"lunora-init-fetch-")),l=p(n,"template");try{const d=o!==void 0&&o.length>0?r:await Fe(r,t),u=B(i,o,d);let c,w=[];await me([{label:`${i} template fetched`,run:async()=>{c=await oe(u,{cwd:n,dir:l,force:!0,install:!1,silent:!0})}},{label:`files copied into ${a}/`,run:async()=>{w=await Le(l,s,a)}}],{end:"Project initialized!",start:"Project initializing…"});const F=W(l);return g()&&process.stdout.write(`
1228
- `),t.info(c?.commit?`template: ${c.source} @ ${c.commit} (${String(F.length)} files)`:`template: ${c?.source??u} (${String(F.length)} files)`),q(t,w,s),{code:0,files:w,target:s}}catch(d){if(d instanceof U)throw d;const{hints:u,message:c}=Nt(d,{ref:le(r),remote:B(i,o,r),templateType:i});t.error(c);for(const w of u)t.warn(w);return{code:1,files:[],target:s}}finally{_(n,{force:!0,recursive:!0})}},Ba=e=>{for(const t of["_gitignore","_npmrc","_gitattributes"]){const a=p(e,t);h(a)&&Ie(a,p(e,`.${t.slice(1)}`))}},Ea=async e=>{const{framework:t,logger:a,name:r,overlayBaseFrom:o,target:s}=e,i=j[t],n=ae(p(re(),"lunora-vite-base-"));try{let l;if(o!==void 0&&(l=p(o,`template-${i.createViteTemplate}`),!h(l)))return a.error(`create-vite base not found on disk: ${l}`),{code:1,files:[],target:s};const d=async()=>{if(l!==void 0){K(l,s,{recursive:!0});return}const c=p(n,"base"),w=`github:vitejs/vite/packages/create-vite/template-${i.createViteTemplate}#main`;await oe(w,{cwd:n,dir:c,force:!0,install:!1,silent:!0}),Ba(c),K(c,s,{recursive:!0})};let u=[];return await me([{label:`create-vite (${i.label}) base ready`,run:d},{label:`Lunora overlay applied (${i.label})`,run:async()=>{u=await ia({adapter:i,distTag:ce(),logger:a,name:r,target:s})}}],{end:"Project initialized!",start:"Project initializing…"}),q(a,u,s),{code:0,files:[...W(s)],target:s}}catch(l){if(l instanceof U)throw l;const d=l instanceof Error?l.message:String(l);return a.error(`failed to scaffold the ${i.label} base: ${d}`),{code:1,files:[],target:s}}finally{_(n,{force:!0,recursive:!0})}},Pa=(e,t)=>{const a=p(e,"vite.config.ts");try{m(a,ga,"utf8")}catch(r){const o=r instanceof Error?r.message:String(r);return t.error(`init --in-place: could not write ${a}: ${o}`),{code:1,files:[],target:e}}return t.success(`created ${a} with lunora() plugin`),{code:0,files:[a],target:e}},Da=(e,t,a)=>{let r;try{r=b(e,"utf8")}catch(s){const i=s instanceof Error?s.message:String(s);return a.error(`init --in-place: could not read ${e}: ${i}`),{code:1,files:[],target:t}}const o=ye(r);if(!o.changed)return a.info(`${e}: ${o.reason??"no changes needed"}`),{code:0,files:[],target:t};try{m(e,o.code,"utf8")}catch(s){const i=s instanceof Error?s.message:String(s);return a.error(`init --in-place: could not write ${e}: ${i}`),{code:1,files:[],target:t}}return a.success(`patched ${e} — added lunora() plugin`),{code:0,files:[e],target:t}},Ua=(e,t)=>{const a=p(e,"lunora"),r=p(a,"schema.ts");if(h(r))return t.info(`lunora/ already present — left ${r} untouched`),[];const o=[];try{S(a,{recursive:!0}),m(r,va,"utf8"),o.push(r);const s=p(a,"messages.ts");h(s)||(m(s,fa,"utf8"),o.push(s)),t.success(`scaffolded lunora/ (${String(o.length)} file(s))`)}catch(s){const i=s instanceof Error?s.message:String(s);t.error(`init --here: could not scaffold lunora/: ${i}`)}return o},Va=(e,t,a)=>{const{adapter:r,class:o,framework:s}=e;a.info(""),a.info(`detected framework: ${s} (class ${o})`),a.info("next steps:"),a.info(` 1. install the adapter: ${Aa(t,[r,"@lunora/client","@lunora/runtime","@lunora/server"])}`),a.info(" 2. run codegen: lunora codegen"),o==="A"?(a.info(" 3. compose one worker: wrap your worker entry with"),a.info(" createWorker({ httpRouter: <your framework SSR handler>, shardDO: ShardDO, ... })"),a.info(` 4. add the provider: mount the ${r} provider in your root layout/route`),a.info(" 5. make a loader live: preloadQuery() in a loader, usePreloadedQuery() in the component"),a.info(" see https://lunora.sh/docs/frameworks/reactive-loaders")):o==="B"?(a.info(" 3. inject Lunora: mount Lunora realtime under /_lunora/* in your server hook"),a.info(` (${s} owns its Cloudflare adapter — Lunora composes into its server entry)`),a.info(` 4. add the provider: mount the ${r} provider in your root layout`),a.info(" 5. read the guide: https://lunora.sh/docs/frameworks/deploy")):(a.info(" 3. add the provider: wrap your app with the LunoraProvider from @lunora/react"),a.info(" 4. read the guide: https://lunora.sh/docs/frameworks/bring-your-framework")),a.info("")},za=e=>{for(const t of ma){const a=p(e,t);if(h(a))return a}},Ha=(e,t,a)=>{const r=za(e);return r===void 0?t==="sveltekit"||t==="nuxt"||t==="astro"?(a.info(`no Vite config found — ${t} wires Lunora through its server entry (see next steps)`),{code:0,files:[],target:e}):Pa(e,a):Da(r,e,a)},Wa=(e,t)=>{const a=ft(e),r=Ha(e,a.framework,t);if(r.code!==0)return r;const o=Ua(e,t);return Va(a,D(e),t),{code:0,files:[...r.files,...o],target:e}},qa=e=>e.yes!==!0&&(e.prompt!==void 0||(e.interactive??g())),Fa=async(e,t)=>{const a=qa(e),r=e.add===void 0?[]:Rt(e.add,s=>{e.logger.warn(s)}),o={applyAll:async s=>{if(s.length===0)return!0;if(e.dryRun===!0)return M(e.logger,`add ${s.map(c=>c.label).join(", ")}`),!0;const i=[],n=g()?{error:c=>{i.push({level:"error",message:c})},info:()=>{},success:()=>{},warn:c=>{i.push({level:"warn",message:c})}}:e.logger,l=s.map(c=>({running:`adding ${c.label}…`,task:()=>Ke({allowUnsafeSource:e.allowUnsafeSource,cwd:t,from:e.registryFrom,logger:n,names:[...c.names],ref:e.ref,source:e.registrySource,transformManifest:c.transformManifest,yes:!0})})),d=`added ${s.map(c=>c.label).join(", ")}`,u=await tt(f.add,l,d);for(const{level:c,message:w}of i)e.logger[c](w);return u.every(c=>c.code===0)},interactive:a,logger:e.logger,multiSelect:e.prompt?.multiSelect??((s,i,n)=>et(s,i,{...n,badge:f.add})),preselected:r.length>0?r:void 0,projectName:A(t),resolveAuthUiItem:()=>{try{const s=JSON.parse(b(p(t,"package.json"),"utf8"));return lt({...s.dependencies,...s.devDependencies})??"auth-ui-react"}catch{return"auth-ui-react"}},select:e.prompt?.select??((s,i,n)=>V(s,i,{...n,badge:f.add})),text:e.prompt?.text??((s,i)=>pe(s,{...i,badge:f.add}))};if(r.length>0){await Y(o);return}g()&&await Xe(y.extras),await Y(o)},O="react",Ae=[{description:"React SPA — official create-vite base + the Lunora layer (the default)",label:"React",value:"react"},{description:"Vue SPA — create-vite base + Lunora",label:"Vue",value:"vue"},{description:"Solid SPA — create-vite base + Lunora",label:"Solid",value:"solid"},{description:"Svelte SPA — create-vite base + Lunora",label:"Svelte",value:"svelte"},{description:"Next.js (App Router) — OpenNext on Cloudflare + a standalone Lunora worker",label:"Next.js",value:"next"},{description:"TanStack Start (React) — SSR with live-loader routes",label:"TanStack Start · React",value:"tanstack-start-react"},{description:"TanStack Start (Solid)",label:"TanStack Start · Solid",value:"tanstack-start-solid"},{description:"React Router (v7, framework mode) — SSR composed into the Lunora worker",label:"React Router",value:"react-router"},{description:"Astro + a standalone Lunora worker",label:"Astro",value:"astro"},{description:"AnalogJS (Angular) — single-worker, Lunora mounted in Nitro",label:"Analog",value:"analog"},{description:"Nuxt (Vue) — single-worker, Lunora mounted in Nitro",label:"Nuxt",value:"nuxt"},{description:"SvelteKit + a standalone Lunora worker",label:"SvelteKit",value:"sveltekit"},{description:"React Native (Expo) — an iOS/Android/web app + a Lunora worker backend",label:"React Native · Expo",value:"expo"},{description:"Worker only — no frontend",label:"Standalone",value:"standalone"}],Ka=Object.keys(j).join("|"),Ja=Ae.filter(e=>!H(e.value)).map(e=>e.value).join("|"),Qa=e=>H(e)?{framework:e,kind:"overlay"}:{kind:"template",templateType:e},Ga=async e=>e.vite!==void 0?{framework:e.vite,kind:"overlay"}:e.templateType!==void 0?{kind:"template",templateType:e.templateType}:!g()||e.yes===!0?{framework:O,kind:"overlay"}:Qa(await V(y.framework,Ae,{badge:f.tmpl,default:O})??O),Xa=e=>{if(g()||e.yes===!0)return;const t=[];if(e.name===void 0&&t.push("a project name (`lunora init <name>`)"),e.templateType===void 0&&e.vite===void 0&&t.push(`a framework — \`--vite <${Ka}>\` for an SPA, or \`-t <${Ja}>\` for a bespoke template`),t.length!==0)return`lunora init can't prompt in a non-interactive terminal — provide ${t.join(" and ")}, or pass --yes to accept the defaults.`},Ya=async(e,t,a,r)=>H(t)?await Ce({isLocal:e.overlayBaseFrom!==void 0,logger:e.logger})?(S(r,{recursive:!0}),Ea({framework:t,logger:e.logger,name:a,overlayBaseFrom:e.overlayBaseFrom,target:r})):{code:1,files:[],target:r}:(e.logger.error(`init: unknown framework "${t}". Supported overlays: ${Object.keys(j).join(", ")}.`),{code:1,files:[],target:r}),Za=async(e,t,a,r)=>e.from!==void 0?await ja(e.from,t,r,a,e.logger):e.source!==void 0&&e.source.length>0&&!e.allowUnsafeSource&&!Sa(e.source)?(e.logger.error(`init: refusing --source ${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.`),{code:1,files:[],target:r}):await Ce({isLocal:!1,logger:e.logger,source:B(t,e.source,e.ref)})?Oa({logger:e.logger,name:a,ref:e.ref,source:e.source,target:r,templateType:t}):{code:1,files:[],target:r},er=async(e,t,a)=>{await Ge("realtime backend on Cloudflare Workers + Durable Objects");const r=Xa(e);if(r!==void 0)return e.logger.error(r),{code:1,files:[],target:""};const o=ca(),s=e.name??await pe(y.name,{badge:f.dir,default:o,placeholder:o}),i=await Ga(e),n=s.trim();if(n.length===0)return e.logger.error("init: refusing an empty project name — pass a directory name (e.g. `lunora init my-app`)."),{code:1,files:[],target:""};if(n.includes("/")||n.includes("\\")||n===".."||n===".")return e.logger.error(`init: refusing project name "${n}" — must not contain path separators or be "." / "..".`),{code:1,files:[],target:""};const l=E(t,n),d=h(l);if(d&&te(l).length>0)return e.logger.error(`target directory not empty: ${l}`),{code:1,files:[],target:l};if(e.dryRun===!0){const u=i.kind==="overlay"?`the ${i.framework} create-vite overlay`:`the ${i.templateType} template`;return M(e.logger,`scaffold ${u} into ${l}`),{code:0,files:[],target:l}}return a(l,d),i.kind==="overlay"?Ya(e,i.framework,n,l):Za(e,i.templateType,n,l)},tr=(e,t)=>{const{target:a,targetPreExisted:r}=e;if(!(a===void 0||!h(a))){if(r===!0)for(const o of te(a))_(p(a,o),{force:!0,recursive:!0});else _(a,{force:!0,recursive:!0});t.info(`removed the partially-created project at ${a}`)}},ar=async(e,t,a)=>e.inPlace!==!0?er(e,t,a):e.dryRun===!0?(M(e.logger,`configure Lunora into ${t}`),{code:0,files:[],target:t}):Wa(t,e.logger),rr=async(e,t,a)=>{await Fa(e,t.target);const r=e.inPlace===!0?void 0:await Ta(e,t.target);if(e.inPlace!==!0){await Ia(e,t.target);const o=r??D(t.target);await _a(A(t.target),r,o,Se(a)),await It(e.logger)}},or=(e,t,a)=>{if(t.code!==0||e.ci===void 0)return;if(e.dryRun===!0){M(e.logger,`scaffold a ${e.ci} CI deploy pipeline`);return}const r=e.inPlace===!0?a:t.target;try{const o=D(r);gt(r,e.ci,o,e.logger)}catch{e.logger.warn(`--ci ${e.ci}: could not detect a package manager for this project — skipped the CI pipeline.`)}},sr=async e=>{const t=e.cwd??process.cwd(),a={};let r;try{r=await ar(e,t,(o,s)=>{a.target=o,a.targetPreExisted=s}),r.code===0&&r.target!==""&&(a.target=void 0,await rr(e,r,t))}catch(o){if(o instanceof U)return tr(a,e.logger),process.stdout.write("\n ✖ Setup cancelled — run `lunora init` again whenever you're ready. 🌙\n"),{code:130,files:[],target:""};throw o}return or(e,r,t),r},ir=e=>e==="analog"||e==="astro"||e==="expo"||e==="next"||e==="nuxt"||e==="react-router"||e==="standalone"||e==="sveltekit"||e==="tanstack-start-react"||e==="tanstack-start-solid",nr=(e,t)=>{if(e!==void 0){if(ht(e))return e;t.warn(`init: unknown --ci "${e}" — expected github | gitlab; skipping CI scaffold.`)}},Sr=We(({argument:e,cwd:t,logger:a,options:r})=>{const o=r.template!==void 0&&ir(r.template)?r.template:void 0;return sr({add:r.add,allowUnsafeSource:r.allowUnsafeSource===!0,cwd:t,ci:nr(r.ci,a),dryRun:r.dryRun===!0,from:r.from,inPlace:r.here===!0,interactive:r.interactive===!0?!0:void 0,logger:a,name:e[0],ref:r.ref,source:r.source,templateType:o,vite:r.vite,yes:r.yes===!0})});export{Sr as execute,ir as isTemplate,B as resolveTemplateSource,sr as runInitCommand};
1224
+ `,Ma="gh:anolilab/lunora/templates",La=e=>{const t=e.lastIndexOf(".");return t===-1?!1:ba.has(e.slice(t))},Sa=(e,t)=>e.replaceAll("{{name}}",t),Se=e=>e==="lunorash"||e.startsWith("@lunora/"),Aa=async(e,t)=>{const a=new Set;for(const r of e)if(A(r)==="package.json")try{const o=JSON.parse(b(r,"utf8"));for(const i of["dependencies","devDependencies"])for(const s of Object.keys(o[i]??{}))Se(s)&&a.add(s)}catch{}return le(a,t)},Ia=(e,t,a)=>{let r;try{r=JSON.parse(e)}catch{return e}let o=e;for(const i of["dependencies","devDependencies"])for(const s of Object.keys(r[i]??{})){if(!Se(s))continue;const n=a.get(s)??t,l=ze(o,[i,s],n,{formattingOptions:{insertSpaces:!0,tabSize:4}});o=He(o,l)}return o},Na=["@parcel/watcher","esbuild","lmdb","msgpackr-extract","rs-module-lexer","sharp","unrs-resolver","vue-demi","workerd"],_a=["cpu-features","protobufjs","ssh2"],Ra="pnpm-workspace.yaml",ja=()=>["# pnpm reads its settings from here (the package.json `pnpm` field is no longer read).","# Pre-approve the toolchain's native build scripts so `pnpm install` runs them","# without the interactive `pnpm approve-builds` step; deny the optional native","# builds a scaffold doesn't need (so no C/C++ toolchain is required).","allowBuilds:",...Na.map(e=>` '${e}': true`),..._a.map(e=>` '${e}': false`),""].join(`
1225
+ `),W=e=>{const t=[];for(const a of Ue(e,{includeDirs:!1,includeFiles:!0}))_e(a.path).isSymbolicLink()||t.push(a.path);return t},Ae=async(e,t,a)=>{const r=W(e),o=[],i=de(),s=await Aa(r,i);for(const n of r){const l=Ve(e,n),d=p(t,l);S(C(d),{recursive:!0});const u=b(n);let c=La(n)?Sa(u.toString("utf8"),a):void 0;c!==void 0&&A(n)==="package.json"&&(c=Ia(c,i,s)),c===void 0?g(d,u):g(d,c,"utf8"),o.push(d)}return o},B=(e,t,a)=>t!==void 0&&t.length>0?t:`${Ma}/${e}#${ce(a)}`,Ta=e=>e.includes("..")?!1:e.startsWith("gh:")||e.startsWith("github:")||e.startsWith("https://"),M=(e,t)=>{e.info(`[dry-run] would ${t}`)},q=(e,t,a)=>{v()&&process.stdout.write(`
1226
+ `),e.success(`scaffolded ${String(t.length)} files into ${a}`)},Oa=(e,t)=>`${e} ${e==="npm"?"install":"add"} ${t.join(" ")}`,Ie=e=>{let t=E(e);for(;;){if(h(p(t,"pnpm-workspace.yaml")))return!0;const a=p(t,"package.json");if(h(a))try{if(JSON.parse(b(a,"utf8")).workspaces!==void 0)return!0}catch{}const r=C(t);if(r===t)return!1;t=r}},Ba=e=>{let t=E(e);for(;;){if(h(p(t,".git")))return!0;const a=C(t);if(a===t)return!1;t=a}},Ea=async(e,t)=>{if(e.yes===!0||!v()||Ba(C(t)))return;if(!await he(y.git,{badge:m.git,defaultYes:!1})){await me("Sounds good! You can always run git init manually.");return}if(e.dryRun===!0){M(e.logger,"initialize a git repository");return}const a=e.spawner??pe;(await at("Initializing a git repository…",()=>a({args:["init"],command:"git",cwd:t}))).code===0?await R("git","Initialized an empty git repository."):e.logger.warn("`git init` failed — initialize it yourself later with `git init`.")},Pa=async(e,t,a,r)=>{const o=[{code:`cd ./${e}`,lead:"Enter your project directory using"}];t===void 0&&o.push({code:`${a} install`,lead:"Install dependencies with",tail:r?" from the workspace root":void 0}),o.push({code:Ke(a,"dev"),lead:"Run",tail:" to start the dev server."},{code:"lunora add",lead:"Add features like auth or storage using"});const i=[{code:"https://lunora.sh/docs",lead:"Read the docs at"},{code:"https://lunora.sh/chat",lead:"Stuck? Join the chat at"}];if(v()){await rt(m.next,y.nextHeader,o,i);return}const s=o.map(n=>`${n.lead} ${n.code}${n.tail??""}`);s.push("",...i.map(n=>`${n.lead} ${n.code}${n.tail??""}`)),await R("next",y.nextHeader,s.join(`
1227
+ `))},Da=e=>e.yes!==!0&&(e.installPrompt!==void 0||v()),Ua=async(e,t)=>{if(!Da(e)||Ie(C(t)))return;const a=Fe(e.packageManagerProbe),[r]=a;if(r===void 0)return;if(!await(e.installPrompt?.confirmInstall??(async()=>he(y.install,{badge:m.deps,defaultYes:!0})))()){await me("No problem! Remember to install dependencies after setup.");return}let o=r;if(a.length>1&&(o=e.installPrompt?await e.installPrompt.selectManager(a):await V(y.packageManager,a.map(d=>({label:d,value:d})),{badge:m.deps,default:r})??r),e.dryRun===!0){M(e.logger,`install dependencies with ${o}`);return}if(o==="pnpm"){const d=p(t,Ra);h(d)||g(d,ja(),"utf8")}const i=e.spawner??pe,{args:s,command:n}=se(o);await R("deps",`Installing dependencies with ${o}…`);const l=await i({args:s,command:n,cwd:t});if(l.code!==0){e.logger.warn(`\`${n} install\` exited with code ${String(l.code)} — run it yourself in ${A(t)}/.`);return}return await R("deps",`Dependencies installed with ${o}.`),o},Va=async(e,t,a,r,o)=>{const i=p(e,t);if(!h(i))return o.error(`template not found in local source: ${i}`),{code:1,files:[],target:a};const s=await Ae(i,a,r);return q(o,s,a),{code:0,files:s,target:a}},za=async e=>{const{logger:t,name:a,ref:r,source:o,target:i,templateType:s}=e,n=re(p(oe(),"lunora-init-fetch-")),l=p(n,"template");try{const d=o!==void 0&&o.length>0?r:await Qe(r,t),u=B(s,o,d);let c,w=[];await ge([{label:`${s} template fetched`,run:async()=>{c=await ie(u,{cwd:n,dir:l,force:!0,install:!1,silent:!0})}},{label:`files copied into ${a}/`,run:async()=>{w=await Ae(l,i,a)}}],{end:"Project initialized!",start:"Project initializing…"});const F=W(l);return v()&&process.stdout.write(`
1228
+ `),t.info(c?.commit?`template: ${c.source} @ ${c.commit} (${String(F.length)} files)`:`template: ${c?.source??u} (${String(F.length)} files)`),q(t,w,i),{code:0,files:w,target:i}}catch(d){if(d instanceof U)throw d;const{hints:u,message:c}=jt(d,{ref:ce(r),remote:B(s,o,r),templateType:s});t.error(c);for(const w of u)t.warn(w);return{code:1,files:[],target:i}}finally{_(n,{force:!0,recursive:!0})}},Ha=e=>{for(const t of["_gitignore","_npmrc","_gitattributes"]){const a=p(e,t);h(a)&&Re(a,p(e,`.${t.slice(1)}`))}},Wa=async e=>{const{framework:t,logger:a,name:r,overlayBaseFrom:o,target:i}=e,s=T[t],n=re(p(oe(),"lunora-vite-base-"));try{let l;if(o!==void 0&&(l=p(o,`template-${s.createViteTemplate}`),!h(l)))return a.error(`create-vite base not found on disk: ${l}`),{code:1,files:[],target:i};const d=async()=>{if(l!==void 0){K(l,i,{recursive:!0});return}const c=p(n,"base"),w=`github:vitejs/vite/packages/create-vite/template-${s.createViteTemplate}#main`;await ie(w,{cwd:n,dir:c,force:!0,install:!1,silent:!0}),Ha(c),K(c,i,{recursive:!0})};let u=[];return await ge([{label:`create-vite (${s.label}) base ready`,run:d},{label:`Lunora overlay applied (${s.label})`,run:async()=>{u=await ha({adapter:s,distTag:de(),logger:a,name:r,target:i})}}],{end:"Project initialized!",start:"Project initializing…"}),q(a,u,i),{code:0,files:[...W(i)],target:i}}catch(l){if(l instanceof U)throw l;const d=l instanceof Error?l.message:String(l);return a.error(`failed to scaffold the ${s.label} base: ${d}`),{code:1,files:[],target:i}}finally{_(n,{force:!0,recursive:!0})}},qa=(e,t)=>{const a=p(e,"vite.config.ts");try{g(a,ka,"utf8")}catch(r){const o=r instanceof Error?r.message:String(r);return t.error(`init --in-place: could not write ${a}: ${o}`),{code:1,files:[],target:e}}return t.success(`created ${a} with lunora() plugin`),{code:0,files:[a],target:e}},Fa=(e,t,a)=>{let r;try{r=b(e,"utf8")}catch(i){const s=i instanceof Error?i.message:String(i);return a.error(`init --in-place: could not read ${e}: ${s}`),{code:1,files:[],target:t}}const o=xe(r);if(!o.changed)return a.info(`${e}: ${o.reason??"no changes needed"}`),{code:0,files:[],target:t};try{g(e,o.code,"utf8")}catch(i){const s=i instanceof Error?i.message:String(i);return a.error(`init --in-place: could not write ${e}: ${s}`),{code:1,files:[],target:t}}return a.success(`patched ${e} — added lunora() plugin`),{code:0,files:[e],target:t}},Ka=(e,t)=>{const a=p(e,"lunora"),r=p(a,"schema.ts");if(h(r))return t.info(`lunora/ already present — left ${r} untouched`),[];const o=[];try{S(a,{recursive:!0}),g(r,$a,"utf8"),o.push(r);const i=p(a,"messages.ts");h(i)||(g(i,Ca,"utf8"),o.push(i)),t.success(`scaffolded lunora/ (${String(o.length)} file(s))`)}catch(i){const s=i instanceof Error?i.message:String(i);t.error(`init --here: could not scaffold lunora/: ${s}`)}return o},Ja=(e,t,a)=>{const{adapter:r,class:o,framework:i}=e;a.info(""),a.info(`detected framework: ${i} (class ${o})`),a.info("next steps:"),a.info(` 1. install the adapter: ${Oa(t,[r,"@lunora/client","@lunora/runtime","@lunora/server"])}`),a.info(" 2. run codegen: lunora codegen"),o==="A"?(a.info(" 3. compose one worker: wrap your worker entry with"),a.info(" createWorker({ httpRouter: <your framework SSR handler>, shardDO: ShardDO, ... })"),a.info(` 4. add the provider: mount the ${r} provider in your root layout/route`),a.info(" 5. make a loader live: preloadQuery() in a loader, usePreloadedQuery() in the component"),a.info(" see https://lunora.sh/docs/frameworks/reactive-loaders")):o==="B"?(a.info(" 3. inject Lunora: mount Lunora realtime under /_lunora/* in your server hook"),a.info(` (${i} owns its Cloudflare adapter — Lunora composes into its server entry)`),a.info(` 4. add the provider: mount the ${r} provider in your root layout`),a.info(" 5. read the guide: https://lunora.sh/docs/frameworks/deploy")):(a.info(" 3. add the provider: wrap your app with the LunoraProvider from @lunora/react"),a.info(" 4. read the guide: https://lunora.sh/docs/frameworks/bring-your-framework")),a.info("")},Ga=e=>{for(const t of xa){const a=p(e,t);if(h(a))return a}},Qa=(e,t,a)=>{const r=Ga(e);return r===void 0?t==="sveltekit"||t==="nuxt"||t==="astro"?(a.info(`no Vite config found — ${t} wires Lunora through its server entry (see next steps)`),{code:0,files:[],target:e}):qa(e,a):Fa(r,e,a)},Ya=(e,t)=>{const a=xt(e),r=Qa(e,a.framework,t);if(r.code!==0)return r;const o=Ka(e,t);return Ja(a,D(e),t),{code:0,files:[...r.files,...o],target:e}},Xa=e=>e.yes!==!0&&(e.prompt!==void 0||(e.interactive??v())),te=async(e,t,a)=>{a.dryRun!==!0&&await Wt({apply:r=>De(e,r),detected:Pe(e),interactive:t,logger:a.logger,multiSelect:a.lintPrompt??((r,o,i)=>ve(r,o,{...i,badge:m.add}))})},Za=async(e,t)=>{const a=Xa(e),r=e.add===void 0?[]:Bt(e.add,i=>{e.logger.warn(i)}),o={applyAll:async i=>{if(i.length===0)return!0;if(e.dryRun===!0)return M(e.logger,`add ${i.map(c=>c.label).join(", ")}`),!0;const s=[],n=v()?{error:c=>{s.push({level:"error",message:c})},info:()=>{},success:()=>{},warn:c=>{s.push({level:"warn",message:c})}}:e.logger,l=i.map(c=>({running:`adding ${c.label}…`,task:()=>Ye({allowUnsafeSource:e.allowUnsafeSource,cwd:t,from:e.registryFrom,logger:n,names:[...c.names],ref:e.ref,source:e.registrySource,transformManifest:c.transformManifest,yes:!0})})),d=`added ${i.map(c=>c.label).join(", ")}`,u=await ot(m.add,l,d);for(const{level:c,message:w}of s)e.logger[c](w);return u.every(c=>c.code===0)},interactive:a,logger:e.logger,multiSelect:e.prompt?.multiSelect??((i,s,n)=>ve(i,s,{...n,badge:m.add})),preselected:r.length>0?r:void 0,projectName:A(t),resolveAuthUiItem:()=>{try{const i=JSON.parse(b(p(t,"package.json"),"utf8"));return ut({...i.dependencies,...i.devDependencies})??"auth-ui-react"}catch{return"auth-ui-react"}},select:e.prompt?.select??((i,s,n)=>V(i,s,{...n,badge:m.add})),text:e.prompt?.text??((i,s)=>ue(i,{...s,badge:m.add}))};if(r.length>0){await X(o),await te(t,a,e);return}v()&&await tt(y.extras),await X(o),await te(t,a,e)},O="react",Ne=[{description:"React SPA — official create-vite base + the Lunora layer (the default)",label:"React",value:"react"},{description:"Vue SPA — create-vite base + Lunora",label:"Vue",value:"vue"},{description:"Solid SPA — create-vite base + Lunora",label:"Solid",value:"solid"},{description:"Svelte SPA — create-vite base + Lunora",label:"Svelte",value:"svelte"},{description:"Next.js (App Router) — OpenNext on Cloudflare + a standalone Lunora worker",label:"Next.js",value:"next"},{description:"TanStack Start (React) — SSR with live-loader routes",label:"TanStack Start · React",value:"tanstack-start-react"},{description:"TanStack Start (Solid)",label:"TanStack Start · Solid",value:"tanstack-start-solid"},{description:"React Router (v7, framework mode) — SSR composed into the Lunora worker",label:"React Router",value:"react-router"},{description:"Astro + a standalone Lunora worker",label:"Astro",value:"astro"},{description:"AnalogJS (Angular) — single-worker, Lunora mounted in Nitro",label:"Analog",value:"analog"},{description:"Nuxt (Vue) — single-worker, Lunora mounted in Nitro",label:"Nuxt",value:"nuxt"},{description:"SvelteKit + a standalone Lunora worker",label:"SvelteKit",value:"sveltekit"},{description:"React Native (Expo) — an iOS/Android/web app + a Lunora worker backend",label:"React Native · Expo",value:"expo"},{description:"Worker only — no frontend",label:"Standalone",value:"standalone"}],er=Object.keys(T).join("|"),tr=Ne.filter(e=>!H(e.value)).map(e=>e.value).join("|"),ar=e=>H(e)?{framework:e,kind:"overlay"}:{kind:"template",templateType:e},rr=async e=>e.vite!==void 0?{framework:e.vite,kind:"overlay"}:e.templateType!==void 0?{kind:"template",templateType:e.templateType}:!v()||e.yes===!0?{framework:O,kind:"overlay"}:ar(await V(y.framework,Ne,{badge:m.tmpl,default:O})??O),or=e=>{if(v()||e.yes===!0)return;const t=[];if(e.name===void 0&&t.push("a project name (`lunora init <name>`)"),e.templateType===void 0&&e.vite===void 0&&t.push(`a framework — \`--vite <${er}>\` for an SPA, or \`-t <${tr}>\` for a bespoke template`),t.length!==0)return`lunora init can't prompt in a non-interactive terminal — provide ${t.join(" and ")}, or pass --yes to accept the defaults.`},ir=async(e,t,a,r)=>H(t)?await Le({isLocal:e.overlayBaseFrom!==void 0,logger:e.logger})?(S(r,{recursive:!0}),Wa({framework:t,logger:e.logger,name:a,overlayBaseFrom:e.overlayBaseFrom,target:r})):{code:1,files:[],target:r}:(e.logger.error(`init: unknown framework "${t}". Supported overlays: ${Object.keys(T).join(", ")}.`),{code:1,files:[],target:r}),sr=async(e,t,a,r)=>e.from!==void 0?await Va(e.from,t,r,a,e.logger):e.source!==void 0&&e.source.length>0&&!e.allowUnsafeSource&&!Ta(e.source)?(e.logger.error(`init: refusing --source ${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.`),{code:1,files:[],target:r}):await Le({isLocal:!1,logger:e.logger,source:B(t,e.source,e.ref)})?za({logger:e.logger,name:a,ref:e.ref,source:e.source,target:r,templateType:t}):{code:1,files:[],target:r},nr=async(e,t,a)=>{await et("realtime backend on Cloudflare Workers + Durable Objects");const r=or(e);if(r!==void 0)return e.logger.error(r),{code:1,files:[],target:""};const o=va(),i=e.name??await ue(y.name,{badge:m.dir,default:o,placeholder:o}),s=await rr(e),n=i.trim();if(n.length===0)return e.logger.error("init: refusing an empty project name — pass a directory name (e.g. `lunora init my-app`)."),{code:1,files:[],target:""};if(n.includes("/")||n.includes("\\")||n===".."||n===".")return e.logger.error(`init: refusing project name "${n}" — must not contain path separators or be "." / "..".`),{code:1,files:[],target:""};const l=E(t,n),d=h(l);if(d&&ae(l).length>0)return e.logger.error(`target directory not empty: ${l}`),{code:1,files:[],target:l};if(e.dryRun===!0){const u=s.kind==="overlay"?`the ${s.framework} create-vite overlay`:`the ${s.templateType} template`;return M(e.logger,`scaffold ${u} into ${l}`),{code:0,files:[],target:l}}return a(l,d),s.kind==="overlay"?ir(e,s.framework,n,l):sr(e,s.templateType,n,l)},lr=(e,t)=>{const{target:a,targetPreExisted:r}=e;if(!(a===void 0||!h(a))){if(r===!0)for(const o of ae(a))_(p(a,o),{force:!0,recursive:!0});else _(a,{force:!0,recursive:!0});t.info(`removed the partially-created project at ${a}`)}},cr=async(e,t,a)=>e.inPlace!==!0?nr(e,t,a):e.dryRun===!0?(M(e.logger,`configure Lunora into ${t}`),{code:0,files:[],target:t}):Ya(t,e.logger),dr=async(e,t,a)=>{await Za(e,t.target);const r=e.inPlace===!0?void 0:await Ua(e,t.target);if(e.inPlace!==!0){await Ea(e,t.target);const o=r??D(t.target);await Pa(A(t.target),r,o,Ie(a)),await Tt(e.logger)}},pr=(e,t,a)=>{if(t.code!==0||e.ci===void 0)return;if(e.dryRun===!0){M(e.logger,`scaffold a ${e.ci} CI deploy pipeline`);return}const r=e.inPlace===!0?a:t.target;try{const o=D(r);yt(r,e.ci,o,e.logger)}catch{e.logger.warn(`--ci ${e.ci}: could not detect a package manager for this project — skipped the CI pipeline.`)}},ur=async e=>{const t=e.cwd??process.cwd(),a={};let r;try{r=await cr(e,t,(o,i)=>{a.target=o,a.targetPreExisted=i}),r.code===0&&r.target!==""&&(a.target=void 0,await dr(e,r,t))}catch(o){if(o instanceof U)return lr(a,e.logger),process.stdout.write("\n ✖ Setup cancelled — run `lunora init` again whenever you're ready. 🌙\n"),{code:130,files:[],target:""};throw o}return pr(e,r,t),r},hr=e=>e==="analog"||e==="astro"||e==="expo"||e==="next"||e==="nuxt"||e==="react-router"||e==="standalone"||e==="sveltekit"||e==="tanstack-start-react"||e==="tanstack-start-solid",mr=(e,t)=>{if(e!==void 0){if(ft(e))return e;t.warn(`init: unknown --ci "${e}" — expected github | gitlab; skipping CI scaffold.`)}},Tr=Je(({argument:e,cwd:t,logger:a,options:r})=>{const o=r.template!==void 0&&hr(r.template)?r.template:void 0;return ur({add:r.add,allowUnsafeSource:r.allowUnsafeSource===!0,cwd:t,ci:mr(r.ci,a),dryRun:r.dryRun===!0,from:r.from,inPlace:r.here===!0,interactive:r.interactive===!0?!0:void 0,logger:a,name:e[0],ref:r.ref,source:r.source,templateType:o,vite:r.vite,yes:r.yes===!0})});export{Tr as execute,hr as isTemplate,B as resolveTemplateSource,ur as runInitCommand};
@@ -1 +1 @@
1
- import"node:fs";import"node:path";import"node:url";import"@lunora/errors";import"@visulima/cerebro";import"@visulima/cerebro/command/completion";import"@visulima/cerebro/command/version";import{p as S,t as A,i as C,f as D}from"./cli-Cmbw5lEB.mjs";import"./detect-package-manager-D9r2z_X6.mjs";import"./createLogger--C3x1FNE.mjs";export{S as COMMANDS,A as REGISTERED_COMMAND_NAMES,C as VERSION,D as runCli};
1
+ import"node:fs";import"node:path";import"node:url";import"@lunora/errors";import"@visulima/cerebro";import"@visulima/cerebro/command/completion";import"@visulima/cerebro/command/version";import{p as S,t as A,i as C,f as D}from"./cli-DdEKv4ng.mjs";import"./detect-package-manager-D9r2z_X6.mjs";import"./createLogger--C3x1FNE.mjs";export{S as COMMANDS,A as REGISTERED_COMMAND_NAMES,C as VERSION,D as runCli};
@@ -0,0 +1,3 @@
1
+ import{mkdirSync as B,readFileSync as w,lstatSync as A,writeFileSync as D}from"node:fs";import{join as u,dirname as y}from"node:path";import{fileURLToPath as L}from"node:url";import{resolveHint as j,isLunoraError as k,flattenHint as E,findSolutionByMessage as C}from"@lunora/errors";import{createCerebro as I}from"@visulima/cerebro";import $ from"@visulima/cerebro/command/completion";import P from"@visulima/cerebro/command/version";import{p}from"./api-spec-BENwiyUa.mjs";import{g as s}from"./deploy-target-Dvr9vxpR.mjs";import{P as _,l as T}from"./detect-package-manager-D9r2z_X6.mjs";import{createLogger as S}from"./createLogger--C3x1FNE.mjs";import{VisulimaError as U,renderError as M}from"@visulima/error";import{homedir as W}from"node:os";const J={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/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}]},f="lunora.advisor.map.json",K={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/handler21.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 ${f})`,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 ${f})`,name:"out",type:String},{description:"Write the map artifact to disk (default true; use --no-write to skip)",name:"no-write",type:Boolean}]},F={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}]},q={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}]},H={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/handler4.mjs").then(e=>({default:e.execute})),name:"build",options:[{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]},V={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/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}]},G={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: ${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 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}]},Y={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}]},Q={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: ${p} (default openapi)`,name:"api-spec",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:"Don't start the embedded studio server",name:"no-studio",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:"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}]},X={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"},Z={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:[]},ee={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 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}]},te={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/handler23.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}]},re={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}]},oe={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)"]],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}]},ne={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}]},ae={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}]},ie={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}]},se={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/handler24.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 (default true; --no-procedures to skip)",name:"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}]},le={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}]},pe={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}]},de={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"]],group:"Develop",loader:()=>import("../packem_chunks/handler25.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: 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)",name:"token",type:String}]},ce={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}]},ue={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: ${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}]},me={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}]},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}]},he={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/handler17.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}]},fe={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/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:"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}]},ve={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: ${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:"Skip the TypeScript type-check step",name:"no-typecheck",type:Boolean},s]},be={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}]},we={filterStacktrace:()=>!1,hideErrorCodeView:!0},ke=(e,t={})=>{const r=e instanceof Error?e.message:String(e),o=j(k(e)?{code:e.code,hint:e.hint,message:r}:r),n=new U({hint:o===void 0?void 0:E(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,we)},Se=(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},xe=(e,t)=>{let r,o=Number.POSITIVE_INFINITY;for(const a of t){const i=Se(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,Ne=1500,Be="0.0.0",Ae=/^v/u,De=new Set(["alpha","beta","next"]),m=e=>{const t=e.trim().replace(Ae,""),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},Ee=(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)},Ce=e=>{const t=m(e).prerelease.split(".")[0]??"";return De.has(t)?t:"latest"},Ie=(e,t)=>Ee(t,e)>0,$e=(e,t,r)=>t-e<r,Pe=(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}=_(o,[`@lunora/cli@${r}`],{dev:!0});return`${n} — run \`${i} ${a.join(" ")}\``},x=e=>u(e,"lunora-cli-update.json"),_e=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{B(r,{mode:448,recursive:!0})}catch{}return r},Te=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{}D(r,`${JSON.stringify(t)}
3
+ `,"utf8")}catch{}},Ue=async(e,t)=>{try{const r=await e(Re(t),{signal:AbortSignal.timeout(Ne)});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}},Me=(e,t,r)=>e===Be||!r||t.CI!==void 0||t.LUNORA_NO_UPDATE_NOTIFIER!==void 0,We=async e=>{const t=e.env??process.env,r=e.isTTY??process.stdout.isTTY;if(Me(e.current,t,r))return;const o=e.cacheDir??_e(t),n=(e.now??Date.now)(),a=e.ttlMs??Oe,i=Ce(e.current),d=Te(o),N=d?.tag??"latest",g=d!==void 0&&N===i?d:void 0;let c=g?.latest;if(g===void 0||!$e(g.checkedAt,n,a)){const h=await Ue(e.fetchImpl??globalThis.fetch,i);h===void 0?b(o,{checkedAt:n,latest:e.current,tag:i}):(c=h,b(o,{checkedAt:n,latest:h,tag:i}))}c!==void 0&&Ie(e.current,c)&&e.logger.warn(Pe(e.current,c,i,e.manager))},Je=["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"],Ke=8,Fe=()=>{try{let e=y(L(import.meta.url));for(let t=0;t<Ke;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=y(e);if(r===e)break;e=r}}catch{}return"0.0.0"},R=Fe(),qe=[ae,J,Q,V,K,H,G,z,ue,le,Y,pe,ye,ie,ge,ce,re,oe,fe,se,q,te,ve,ne,Z,ee,F,be,X,me,he,de],O=[...qe,P,$],dt=O.map(e=>e.name),l=e=>e.replaceAll("{",String.raw`\{`).replaceAll("}",String.raw`\}`),He=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))),Ve=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:He(e.examples)},...e.options===void 0?{}:{options:e.options.map(t=>({...t,description:l(t.description??"")}))}}),ze=e=>{const t={value:0},r=I("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:R});for(const o of O)r.addCommand(Ve(o));return{cli:r,exitCode:t}},Ge=/Command "(?<name>[^"]+)" not found/u,Ye=e=>{const t=S(),r=e instanceof Error?e.message:String(e),o=Ge.exec(r);if(!o?.groups){k(e)||C(r)!==void 0?t.error(ke(e)):t.error(r);return}const n=o.groups.name??"",a=xe(n,Je);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.")},ct=async(e={})=>{const{cli:t,exitCode:r}=ze(e);try{await t.run({shouldExitProcess:!1})}catch(n){return Ye(n),1}let o;try{o=T(process.cwd())}catch{o=void 0}return await We({current:R,logger:S(),manager:o}),r.value};export{ct as f,R as i,f as o,Je as p,dt as t};
@@ -0,0 +1,2 @@
1
+ import{d as i}from"./commands-BvfzxKAa.mjs";const o=[{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"}],r="auth",y=async a=>await a("Which auth provider?",o,{default:r})??r,O="mail",S=[{description:"Next, react-router, TanStack Start, Astro islands",label:"React",value:"auth-ui-react"},{description:"Nuxt, Vue + Vite",label:"Vue",value:"auth-ui-vue"},{description:"SvelteKit, Svelte + Vite",label:"Svelte",value:"auth-ui-svelte"},{description:"TanStack Start Solid, Solid + Vite",label:"Solid",value:"auth-ui-solid"},{description:"Analog",label:"Angular",value:"auth-ui-angular"}],x="auth-ui-react",d=a=>Object.hasOwn(a,"react-native")||Object.hasOwn(a,"@lunora/react-native")||Object.hasOwn(a,"expo"),A=a=>{const t=e=>Object.hasOwn(a,e);if(!d(a)){if(t("@lunora/react"))return"auth-ui-react";if(t("@lunora/vue"))return"auth-ui-vue";if(t("@lunora/svelte"))return"auth-ui-svelte";if(t("@lunora/solid"))return"auth-ui-solid";if(t("@lunora/angular"))return"auth-ui-angular";if(t("react")||t("next"))return"auth-ui-react";if(t("vue")||t("nuxt"))return"auth-ui-vue";if(t("svelte")||t("@sveltejs/kit"))return"auth-ui-svelte";if(t("solid-js"))return"auth-ui-solid";if(t("@angular/core"))return"auth-ui-angular"}},_=a=>{const t=a.trim();if(t==="")return;const e=t.toLowerCase();return e==="auth-ui"||e==="auth-ui-"?{kind:"auth-ui"}:e==="auth"?{kind:"auth"}:e==="email"||e==="mail"?{kind:"email"}:{item:e,kind:"item"}},c=/[^a-z0-9]+/u,s=(a,t,e)=>{let n=a.toLowerCase().split(c).filter(Boolean).join("-").slice(0,e);return n.endsWith("-")&&(n=n.slice(0,-1)),n.length>=t?n:void 0},h="DB",f="Name your D1 database (run `wrangler d1 create` to get its id, then put it in wrangler.jsonc)",u=a=>s(a,1,64),p="lunora-db",v=a=>u(`${a}-db`)??p,L=async(a,t)=>{const e=v(t);return u(await a(f,{default:e,placeholder:e}))??e},V=(a,t)=>i(a,"d1_databases",{key:"binding",value:h},"database_name",t),$="SEND_EMAIL",C="Verified destination email for production delivery (blank = set it later in wrangler.jsonc)",b=a=>{const t=a.trim();if(t.length===0||t.includes(" "))return!1;const e=t.indexOf("@");if(e<=0||e!==t.lastIndexOf("@"))return!1;const n=t.slice(e+1);return n.length>=3&&n.includes(".")&&!n.startsWith(".")&&!n.endsWith(".")},D=(a,t)=>{const e=a.trim();if(e!==""){if(!b(e)){t(`"${e}" doesn't look like an email — leaving the placeholder; set destination_address in wrangler.jsonc.`);return}return e}},N=(a,t)=>i(a,"send_email",{key:"name",value:$},"destination_address",t),m="UPLOADS",g="Name your R2 bucket (you can rename it in wrangler.jsonc later)",l=a=>s(a,3,63),k="lunora-uploads",w=a=>l(`${a}-uploads`)??k,E=async(a,t)=>{const e=w(t);return l(await a(g,{default:e,placeholder:e}))??e},W=(a,t)=>i(a,"r2_buckets",{key:"binding",value:m},"bucket_name",t),I=(a,t)=>{for(const e of a)(e.status==="created"||e.status==="updated")&&t.success(`${e.status} ${e.path} — ${e.tool} now skips Lunora's generated files`),e.status==="failed"&&t.warn(`could not configure ${e.tool} to skip Lunora's generated files: ${e.message??"unknown error"}. Add the entries by hand, or re-run once the path is writable.`),e.status==="manual"&&e.snippet!==void 0&&t.warn(`${e.path} needs an entry so ${e.tool} skips Lunora's generated files — add:
2
+ ${e.snippet}`)};export{D as a,C as b,u as c,_ as d,v as e,L as f,r as g,y as h,l as i,A as j,S as k,O as l,o as m,I as n,w as o,W as p,N as q,d as r,x as s,V as t,E as u};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/cli",
3
- "version": "1.0.0-alpha.134",
3
+ "version": "1.0.0-alpha.136",
4
4
  "description": "The Lunora CLI: init, dev, deploy, codegen, migrate, seed, doctor, insights, logs, registry, and the rest of the project commands",
5
5
  "keywords": [
6
6
  "agent-skills",
@@ -52,16 +52,16 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@bomb.sh/tab": "0.0.21",
55
- "@lunora/advisor": "1.0.0-alpha.62",
55
+ "@lunora/advisor": "1.0.0-alpha.63",
56
56
  "@lunora/bindings": "1.0.0-alpha.18",
57
- "@lunora/codegen": "1.0.0-alpha.85",
58
- "@lunora/config": "1.0.0-alpha.110",
57
+ "@lunora/codegen": "1.0.0-alpha.86",
58
+ "@lunora/config": "1.0.0-alpha.112",
59
59
  "@lunora/container": "1.0.0-alpha.20",
60
- "@lunora/d1": "1.0.0-alpha.58",
60
+ "@lunora/d1": "1.0.0-alpha.59",
61
61
  "@lunora/errors": "1.0.0-alpha.12",
62
- "@lunora/mcp": "1.0.0-alpha.53",
62
+ "@lunora/mcp": "1.0.0-alpha.54",
63
63
  "@lunora/runtime": "1.0.0-alpha.51",
64
- "@lunora/seed": "1.0.0-alpha.58",
64
+ "@lunora/seed": "1.0.0-alpha.59",
65
65
  "@visulima/cerebro": "3.0.0",
66
66
  "@visulima/error": "6.0.0",
67
67
  "@visulima/fs": "5.0.5",
@@ -1,3 +0,0 @@
1
- import{mkdirSync as B,readFileSync as w,lstatSync as A,writeFileSync as D}from"node:fs";import{join as u,dirname as y}from"node:path";import{fileURLToPath as L}from"node:url";import{resolveHint as E,isLunoraError as k,flattenHint as j,findSolutionByMessage as C}from"@lunora/errors";import{createCerebro as I}from"@visulima/cerebro";import $ from"@visulima/cerebro/command/completion";import P from"@visulima/cerebro/command/version";import{p}from"./api-spec-BENwiyUa.mjs";import{g as s}from"./deploy-target-Dvr9vxpR.mjs";import{P as _,l as T}from"./detect-package-manager-D9r2z_X6.mjs";import{createLogger as S}from"./createLogger--C3x1FNE.mjs";import{VisulimaError as U,renderError as M}from"@visulima/error";import{homedir as W}from"node:os";const J={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/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}]},f="lunora.advisor.map.json",K={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/handler21.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 ${f})`,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 ${f})`,name:"out",type:String},{description:"Write the map artifact to disk (default true; use --no-write to skip)",name:"no-write",type:Boolean}]},F={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}]},q={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}]},H={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: ${p} (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},s]},V={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/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}]},G={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: ${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 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}]},Y={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}]},Q={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: ${p} (default openapi)`,name:"api-spec",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:"Don't start the embedded studio server",name:"no-studio",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:"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}]},X={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"},Z={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:[]},ee={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 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}]},te={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/handler23.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}]},re={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}]},oe={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)"]],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}]},ne={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}]},ae={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}]},ie={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}]},se={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/handler24.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 (default true; --no-procedures to skip)",name:"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}]},le={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}]},pe={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}]},de={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"]],group:"Develop",loader:()=>import("../packem_chunks/handler25.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: 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)",name:"token",type:String}]},ce={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}]},ue={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: ${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}]},me={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}]},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}]},he={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/handler17.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}]},fe={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/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:"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}]},ve={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: ${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:"Skip the TypeScript type-check step",name:"no-typecheck",type:Boolean},s]},be={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}]},we={filterStacktrace:()=>!1,hideErrorCodeView:!0},ke=(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:j(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,we)},Se=(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},xe=(e,t)=>{let r,o=Number.POSITIVE_INFINITY;for(const a of t){const i=Se(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,Ne=1500,Be="0.0.0",Ae=/^v/u,De=new Set(["alpha","beta","next"]),m=e=>{const t=e.trim().replace(Ae,""),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},Ee=(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},je=(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 Ee(m(e).prerelease,m(t).prerelease)},Ce=e=>{const t=m(e).prerelease.split(".")[0]??"";return De.has(t)?t:"latest"},Ie=(e,t)=>je(t,e)>0,$e=(e,t,r)=>t-e<r,Pe=(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}=_(o,[`@lunora/cli@${r}`],{dev:!0});return`${n} — run \`${i} ${a.join(" ")}\``},x=e=>u(e,"lunora-cli-update.json"),_e=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{B(r,{mode:448,recursive:!0})}catch{}return r},Te=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{}D(r,`${JSON.stringify(t)}
3
- `,"utf8")}catch{}},Ue=async(e,t)=>{try{const r=await e(Re(t),{signal:AbortSignal.timeout(Ne)});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}},Me=(e,t,r)=>e===Be||!r||t.CI!==void 0||t.LUNORA_NO_UPDATE_NOTIFIER!==void 0,We=async e=>{const t=e.env??process.env,r=e.isTTY??process.stdout.isTTY;if(Me(e.current,t,r))return;const o=e.cacheDir??_e(t),n=(e.now??Date.now)(),a=e.ttlMs??Oe,i=Ce(e.current),d=Te(o),N=d?.tag??"latest",g=d!==void 0&&N===i?d:void 0;let c=g?.latest;if(g===void 0||!$e(g.checkedAt,n,a)){const h=await Ue(e.fetchImpl??globalThis.fetch,i);h===void 0?b(o,{checkedAt:n,latest:e.current,tag:i}):(c=h,b(o,{checkedAt:n,latest:h,tag:i}))}c!==void 0&&Ie(e.current,c)&&e.logger.warn(Pe(e.current,c,i,e.manager))},Je=["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"],Ke=8,Fe=()=>{try{let e=y(L(import.meta.url));for(let t=0;t<Ke;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=y(e);if(r===e)break;e=r}}catch{}return"0.0.0"},R=Fe(),qe=[ae,J,Q,V,K,H,G,z,ue,le,Y,pe,ye,ie,ge,ce,re,oe,fe,se,q,te,ve,ne,Z,ee,F,be,X,me,he,de],O=[...qe,P,$],dt=O.map(e=>e.name),l=e=>e.replaceAll("{",String.raw`\{`).replaceAll("}",String.raw`\}`),He=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))),Ve=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:He(e.examples)},...e.options===void 0?{}:{options:e.options.map(t=>({...t,description:l(t.description??"")}))}}),ze=e=>{const t={value:0},r=I("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:R});for(const o of O)r.addCommand(Ve(o));return{cli:r,exitCode:t}},Ge=/Command "(?<name>[^"]+)" not found/u,Ye=e=>{const t=S(),r=e instanceof Error?e.message:String(e),o=Ge.exec(r);if(!o?.groups){k(e)||C(r)!==void 0?t.error(ke(e)):t.error(r);return}const n=o.groups.name??"",a=xe(n,Je);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.")},ct=async(e={})=>{const{cli:t,exitCode:r}=ze(e);try{await t.run({shouldExitProcess:!1})}catch(n){return Ye(n),1}let o;try{o=T(process.cwd())}catch{o=void 0}return await We({current:R,logger:S(),manager:o}),r.value};export{ct as f,R as i,f as o,Je as p,dt as t};
@@ -1 +0,0 @@
1
- import{d as r}from"./commands-BvfzxKAa.mjs";const o=[{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"}],n="auth",O=async a=>await a("Which auth provider?",o,{default:n})??n,S="mail",y=[{description:"Next, react-router, TanStack Start, Astro islands",label:"React",value:"auth-ui-react"},{description:"Nuxt, Vue + Vite",label:"Vue",value:"auth-ui-vue"},{description:"SvelteKit, Svelte + Vite",label:"Svelte",value:"auth-ui-svelte"},{description:"TanStack Start Solid, Solid + Vite",label:"Solid",value:"auth-ui-solid"},{description:"Analog",label:"Angular",value:"auth-ui-angular"}],x="auth-ui-react",d=a=>Object.hasOwn(a,"react-native")||Object.hasOwn(a,"@lunora/react-native")||Object.hasOwn(a,"expo"),_=a=>{const e=t=>Object.hasOwn(a,t);if(!d(a)){if(e("@lunora/react"))return"auth-ui-react";if(e("@lunora/vue"))return"auth-ui-vue";if(e("@lunora/svelte"))return"auth-ui-svelte";if(e("@lunora/solid"))return"auth-ui-solid";if(e("@lunora/angular"))return"auth-ui-angular";if(e("react")||e("next"))return"auth-ui-react";if(e("vue")||e("nuxt"))return"auth-ui-vue";if(e("svelte")||e("@sveltejs/kit"))return"auth-ui-svelte";if(e("solid-js"))return"auth-ui-solid";if(e("@angular/core"))return"auth-ui-angular"}},A=a=>{const e=a.trim();if(e==="")return;const t=e.toLowerCase();return t==="auth-ui"||t==="auth-ui-"?{kind:"auth-ui"}:t==="auth"?{kind:"auth"}:t==="email"||t==="mail"?{kind:"email"}:{item:t,kind:"item"}},c=/[^a-z0-9]+/u,u=(a,e,t)=>{let i=a.toLowerCase().split(c).filter(Boolean).join("-").slice(0,t);return i.endsWith("-")&&(i=i.slice(0,-1)),i.length>=e?i:void 0},h="DB",v="Name your D1 database (run `wrangler d1 create` to get its id, then put it in wrangler.jsonc)",l=a=>u(a,1,64),f="lunora-db",b=a=>l(`${a}-db`)??f,V=async(a,e)=>{const t=b(e);return l(await a(v,{default:t,placeholder:t}))??t},C=(a,e)=>r(a,"d1_databases",{key:"binding",value:h},"database_name",e),m="SEND_EMAIL",D="Verified destination email for production delivery (blank = set it later in wrangler.jsonc)",p=a=>{const e=a.trim();if(e.length===0||e.includes(" "))return!1;const t=e.indexOf("@");if(t<=0||t!==e.lastIndexOf("@"))return!1;const i=e.slice(t+1);return i.length>=3&&i.includes(".")&&!i.startsWith(".")&&!i.endsWith(".")},N=(a,e)=>{const t=a.trim();if(t!==""){if(!p(t)){e(`"${t}" doesn't look like an email — leaving the placeholder; set destination_address in wrangler.jsonc.`);return}return t}},E=(a,e)=>r(a,"send_email",{key:"name",value:m},"destination_address",e),$="UPLOADS",g="Name your R2 bucket (you can rename it in wrangler.jsonc later)",s=a=>u(a,3,63),k="lunora-uploads",w=a=>s(`${a}-uploads`)??k,L=async(a,e)=>{const t=w(e);return s(await a(g,{default:t,placeholder:t}))??t},W=(a,e)=>r(a,"r2_buckets",{key:"binding",value:$},"bucket_name",e);export{N as a,D as b,l as c,A as d,b as e,V as f,n as g,_ as h,s as i,y as j,o as k,S as l,E as m,O as n,w as o,W as p,C as q,d as r,x as s,L as u};