@lunora/cli 1.0.0-alpha.32 → 1.0.0-alpha.321
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/LICENSE.md +33 -0
- package/README.md +1 -1
- package/dist/bin.mjs +2 -10
- package/dist/index.d.mts +960 -370
- package/dist/index.d.ts +960 -370
- package/dist/index.mjs +1 -19
- package/dist/packem_chunks/dispatch.mjs +1 -0
- package/dist/packem_chunks/handler.mjs +1 -160
- package/dist/packem_chunks/handler10.mjs +1 -16
- package/dist/packem_chunks/handler11.mjs +2 -22
- package/dist/packem_chunks/handler12.mjs +1 -192
- package/dist/packem_chunks/handler13.mjs +1 -131
- package/dist/packem_chunks/handler14.mjs +1 -65
- package/dist/packem_chunks/handler15.mjs +1 -58
- package/dist/packem_chunks/handler16.mjs +3 -80
- package/dist/packem_chunks/handler17.mjs +1 -43
- package/dist/packem_chunks/handler18.mjs +1 -105
- package/dist/packem_chunks/handler19.mjs +7 -170
- package/dist/packem_chunks/handler2.mjs +1 -114
- package/dist/packem_chunks/handler20.mjs +1 -94
- package/dist/packem_chunks/handler21.mjs +3 -94
- package/dist/packem_chunks/handler22.mjs +3 -0
- package/dist/packem_chunks/handler23.mjs +1 -0
- package/dist/packem_chunks/handler24.mjs +2 -0
- package/dist/packem_chunks/handler25.mjs +99 -0
- package/dist/packem_chunks/handler26.mjs +10 -0
- package/dist/packem_chunks/handler3.mjs +1 -204
- package/dist/packem_chunks/handler4.mjs +1 -33
- package/dist/packem_chunks/handler5.mjs +1 -49
- package/dist/packem_chunks/handler6.mjs +1 -91
- package/dist/packem_chunks/handler7.mjs +3 -42
- package/dist/packem_chunks/handler8.mjs +1 -174
- package/dist/packem_chunks/handler9.mjs +1 -315
- package/dist/packem_chunks/planDevCommand.mjs +7 -541
- package/dist/packem_chunks/runCodegenCommand.mjs +4 -52
- package/dist/packem_chunks/runDeployCommand.mjs +7 -594
- package/dist/packem_chunks/runInitCommand.mjs +162 -1430
- package/dist/packem_chunks/runResetCommand.mjs +1 -41
- package/dist/packem_chunks/runRpcCommand.mjs +1 -68
- package/dist/packem_shared/COMMANDS-DdaAWPtr.mjs +1 -0
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-BgMPHEoe.mjs +1 -0
- package/dist/packem_shared/EXIT_CODE-08cwt3MK.mjs +1 -0
- package/dist/packem_shared/admin-token-VdUnvnKW.mjs +1 -0
- package/dist/packem_shared/admin-url-BhF5ufg1.mjs +1 -0
- package/dist/packem_shared/binding-manifest-file-CQ1eQYy1.mjs +2 -0
- package/dist/packem_shared/buildRegistryIndex-Dc8D8AR6.mjs +1 -0
- package/dist/packem_shared/catalog-CahzmDLV.mjs +1 -0
- package/dist/packem_shared/cli-DOpChqUe.mjs +2 -0
- package/dist/packem_shared/codegen-error-AmH54ofi.mjs +3 -0
- package/dist/packem_shared/command-Mmxzxyr5.mjs +1 -0
- package/dist/packem_shared/commands-CNqednoX.mjs +13 -0
- package/dist/packem_shared/createLogger-Cl18I8AX.mjs +2 -0
- package/dist/packem_shared/createRecordingSpawner-sS7LEN7x.mjs +1 -0
- package/dist/packem_shared/deploy-target-DCWwiuAe.mjs +1 -0
- package/dist/packem_shared/diffSnapshots-WWwx-KvZ.mjs +5 -0
- package/dist/packem_shared/docker-DpVxvYpL.mjs +1 -0
- package/dist/packem_shared/import-D7qdpSmJ.mjs +12 -0
- package/dist/packem_shared/insertSchemaExtension-DuiV6cba.mjs +8 -0
- package/dist/packem_shared/lint-ignore-report-DKZagpqk.mjs +2 -0
- package/dist/packem_shared/open-url-EnKy--w-.mjs +1 -0
- package/dist/packem_shared/parseManifest-CwPTKdtS.mjs +1 -0
- package/dist/packem_shared/path-containment-CgxYZggb.mjs +1 -0
- package/dist/packem_shared/platform-diagnostics-Cn2g6Jh-.mjs +4 -0
- package/dist/packem_shared/prompt-cancelled-BvsNxg_Q.mjs +1 -0
- package/dist/packem_shared/render-lunora-error--4tmM6mt.mjs +3 -0
- package/dist/packem_shared/resolve-DUCSc7jQ.mjs +5 -0
- package/dist/packem_shared/resolve-target-C_ZloTvd.mjs +1 -0
- package/dist/packem_shared/runAddCommand-Cf2q2y27.mjs +1 -0
- package/dist/packem_shared/runExportCommand-DxsJHYZt.mjs +5 -0
- package/dist/packem_shared/runMigrateGenerateCommand-CDHswpMU.mjs +11 -0
- package/dist/packem_shared/schema-drift-gate-BDCkQ1S6.mjs +1 -0
- package/dist/packem_shared/schemaIrToSnapshot-BjK-0IRo.mjs +1 -0
- package/dist/packem_shared/shared-D-zCOmgY.mjs +1 -0
- package/dist/packem_shared/storage-J4xhM4FU.mjs +1 -0
- package/dist/packem_shared/tui-prompts-B3YwUhGw.mjs +4 -0
- package/dist/packem_shared/vectorize-metadata-dXpl2_Ar.mjs +1 -0
- package/dist/packem_shared/wrangler-name-Dsk5K1f-.mjs +1 -0
- package/dist/packem_shared/wrangler-secrets-C9lJnd5N.mjs +1 -0
- package/package.json +39 -19
- package/skills/README.md +35 -17
- package/skills/lunora/SKILL.md +123 -9
- package/skills/lunora-create-package/SKILL.md +4 -3
- package/skills/lunora-deploy/SKILL.md +42 -11
- package/skills/lunora-functions/SKILL.md +120 -15
- package/skills/lunora-migration-helper/SKILL.md +74 -21
- package/skills/lunora-performance-audit/SKILL.md +78 -9
- package/skills/lunora-quickstart/SKILL.md +93 -27
- package/skills/lunora-realtime/SKILL.md +73 -39
- package/skills/lunora-setup-auth/SKILL.md +33 -6
- package/skills/lunora-setup-hyperdrive/SKILL.md +33 -13
- package/skills/lunora-setup-hyperdrive-global/SKILL.md +5 -0
- package/skills/lunora-setup-mail/SKILL.md +34 -28
- package/skills/lunora-setup-scheduler/SKILL.md +18 -14
- package/skills/lunora-setup-storage/SKILL.md +187 -27
- package/dist/packem_chunks/runMigrateGenerateCommand.mjs +0 -397
- package/dist/packem_shared/COMMANDS-B0ftFD_3.mjs +0 -948
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs +0 -244
- package/dist/packem_shared/admin-url-4UzT-CI4.mjs +0 -19
- package/dist/packem_shared/api-spec-CtA6ilu4.mjs +0 -13
- package/dist/packem_shared/buildRegistryIndex-BcYe607_.mjs +0 -38
- package/dist/packem_shared/codegen-error-DJG-ghs_.mjs +0 -31
- package/dist/packem_shared/command-D3lB_4Az.mjs +0 -19
- package/dist/packem_shared/commands-B-gR09Z_.mjs +0 -845
- package/dist/packem_shared/createLogger-B40gPzQo.mjs +0 -78
- package/dist/packem_shared/createRecordingSpawner-DxI3mebw.mjs +0 -43
- package/dist/packem_shared/detect-package-manager-DYp7n3mJ.mjs +0 -61
- package/dist/packem_shared/diffSnapshots-BeDvvNiF.mjs +0 -161
- package/dist/packem_shared/docker-hMQ97KSQ.mjs +0 -21
- package/dist/packem_shared/insertSchemaExtension-DAqbfr9Z.mjs +0 -64
- package/dist/packem_shared/open-url-Dfq6fAyT.mjs +0 -41
- package/dist/packem_shared/output-format-wUvAN6AL.mjs +0 -17
- package/dist/packem_shared/parseArgs-YXFuKdEk.mjs +0 -56
- package/dist/packem_shared/parseManifest--vZf2FY1.mjs +0 -94
- package/dist/packem_shared/prompt-cancelled-APzX1Im-.mjs +0 -9
- package/dist/packem_shared/resolve-target-qbsJ_5sF.mjs +0 -16
- package/dist/packem_shared/runAddCommand-bnY6-HKb.mjs +0 -4
- package/dist/packem_shared/schema-drift-gate-BtBt0as0.mjs +0 -79
- package/dist/packem_shared/schemaIrToSnapshot-DdsljJT-.mjs +0 -43
- package/dist/packem_shared/storage-BIsph-Vk.mjs +0 -84
- package/dist/packem_shared/tui-prompts-BjEN8XgP.mjs +0 -658
- package/dist/packem_shared/wrangler-name-cy4yhm9j.mjs +0 -12
- package/dist/packem_shared/wrangler-secrets-P2_ZUR-k.mjs +0 -47
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{errorAdvisoryNames as a}from"@lunora/codegen";const i=e=>e.strictAdvisories??(process.env.CI!==void 0&&process.env.CI!==""),v=(e,s)=>{const o=e.filter(t=>t.level==="ERROR");return{errorAdvisories:o,names:a(e),shouldBlock:o.length>0&&s}},p=(e,s)=>{if(e.length===0)return{errors:[],warnings:[]};const o=e.map(r=>` [${r.level.toUpperCase()}] ${r.name} — ${r.message}
|
|
2
|
+
↳ ${r.remediation}`),t=e.filter(r=>r.level==="error").map(r=>r.message),n=e.filter(r=>r.level!=="error").map(r=>r.message),l=`${String(e.length)} platform ${e.length===1?"diagnostic":"diagnostics"}:
|
|
3
|
+
${o.join(`
|
|
4
|
+
`)}`;return t.length===0?(s.warn(l),{errors:[],warnings:n}):(s.error(l),{errors:t,warnings:n})};export{p as a,v as e,i as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class e extends Error{constructor(){super("cancelled"),this.name="PromptCancelledError"}}export{e as P};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{isProcessStreamLogger as a,createStderrLogger as c}from"./createLogger-Cl18I8AX.mjs";import{resolveHint as m,isLunoraError as i,flattenHint as d}from"@lunora/errors";import{VisulimaError as f,renderError as p}from"@visulima/error";import{exitCodeForError as u}from"./EXIT_CODE-08cwt3MK.mjs";const S={description:"Output format: pretty (default) or json",name:"format",type:String},$=(t,e)=>e===void 0?{format:"pretty"}:e==="json"||e==="pretty"?{format:e}:{error:`${t}: unknown --format "${e}" — expected pretty | json`},v=(t,e)=>t==="json"&&a(e)?c():e,x=t=>{process.stdout.write(`${JSON.stringify(t,void 0,2)}
|
|
2
|
+
`)},g={filterStacktrace:()=>!1,hideErrorCodeView:!0},y=(t,e={})=>{const n=t instanceof Error?t.message:String(t),r=m(i(t)?{code:t.code,hint:t.hint,message:n}:n),o=r===void 0?[]:d(r).split(`
|
|
3
|
+
`);i(t)&&(o.length>0&&o.push(""),o.push(`\`${t.code}\` — exits ${String(u(t))}. Run \`lunora docs exit-codes\` for the table.`));const s=new f({hint:o.length===0?void 0:o,message:e.reason===void 0?n:`${e.reason}: ${n}`,name:t instanceof Error&&t.name.length>0?t.name:"Error"});return s.stack="",p(s,g)};export{S as O,x as a,v as l,$ as p,y as r};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{existsSync as p,readFileSync as h,writeFileSync as j,mkdtempSync as G,rmSync as w}from"node:fs";import{tmpdir as W}from"node:os";import{LunoraError as g}from"@lunora/errors";import{dirname as S,join as f}from"@visulima/path";import{downloadTemplate as J}from"giget";import{fileURLToPath as z}from"node:url";import{DEV_VARS_FILE as H,parseDevVariableEntries as K,writeDevVariablesFileAtomically as q}from"@lunora/config";import{modify as N,applyEdits as O,parse as Y}from"jsonc-parser";import{b as Z}from"./tui-prompts-B3YwUhGw.mjs";import X from"./parseManifest-CwPTKdtS.mjs";const Q="alpha",T="main",ee=new Set(["alpha","beta","next"]),te=/^[\w./@-]+$/,ne=e=>!e.includes("..")&&te.test(e),v=()=>{try{let e=S(z(import.meta.url));for(let t=0;t<6;t+=1){const n=f(e,"package.json");if(p(n)){const r=JSON.parse(h(n,"utf8"));if(r.name==="@lunora/cli"&&typeof r.version=="string")return r.version}const s=S(e);if(s===e)break;e=s}}catch{}return"0.0.0"},D=e=>{if(e==="0.0.0")return Q;const t=e.split("+")[0]??e,n=t.indexOf("-");if(n!==-1){const[s]=t.slice(n+1).split(".");if(s!==void 0&&ee.has(s))return s}return T},I=e=>{if(e!==void 0&&e.length>0){if(!ne(e))throw new g("INTERNAL",`invalid --ref "${e}" — a ref may contain letters, digits, ".", "_", "-", "/", "@" and must not contain "..".`);return e}return D(v())},L="anolilab/lunora",B=/^[0-9a-f]{40}$/iu,P=String.raw`\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)+)?(?:\+[0-9A-Za-z.-]+)?`,se=new RegExp(String.raw`^v?${P}$`,"u"),re=new RegExp(String.raw`^(?:@[\w.-]+\/)?[\w.-]+@${P}$`,"u"),oe=e=>B.test(e)||se.test(e)||re.test(e),ie=()=>{const e=process.env.GITHUB_TOKEN??process.env.GH_TOKEN;return e!==void 0&&e.length>0?{authorization:`Bearer ${e}`}:{}},ae=async(e,t=L)=>{try{const n=await fetch(`https://api.github.com/repos/${t}/commits/${encodeURIComponent(e)}`,{headers:{accept:"application/vnd.github+json","user-agent":"lunora-cli",...ie()},signal:AbortSignal.timeout(1e4)});if(!n.ok)return;const s=await n.json();return typeof s.sha=="string"&&B.test(s.sha)?s.sha:void 0}catch{return}},ce=async(e,t,n)=>{if(oe(t))return t;const s=await ae(t,e);return s===void 0?(n.warn(`could not pin ${e}#${t} to a commit — fetching the UNPINNED branch (set GITHUB_TOKEN if rate-limited).`),t):(n.info(`pinned ${e}#${t} → ${s}`),s)},de=async(e,t)=>ce(L,I(e),t),Fe=(e=v())=>`@lunora/cli@${e}`,ue="latest",V=(e=v())=>{const t=D(e);return t===T?ue:t},fe="https://registry.npmjs.org",le=()=>{const e=process.env.npm_config_registry,t=e!==void 0&&e.length>0?e:fe;return t.endsWith("/")?t.slice(0,-1):t},pe=async(e,t)=>{try{const n=await fetch(`${le()}/${e.replaceAll("/","%2F")}`,{headers:{accept:"application/vnd.npm.install-v1+json"},signal:AbortSignal.timeout(1e4)});return n.ok?(await n.json())["dist-tags"]?.[t]:void 0}catch{return}},he=async(e,t)=>{const n=new Map;return await Promise.all([...new Set(e)].map(async s=>{const r=await pe(s,t);r!==void 0&&n.set(s,r)})),n},ge=e=>{if(!e.startsWith("workspace:"))return!1;const t=e.slice(10);return t===""||t==="*"||t==="^"||t==="~"},me=(e,t,n)=>{if(!e.startsWith("workspace:"))return e;const s=e.slice(10);return s===""||s==="*"||s==="^"||s==="~"?(n===void 0?void 0:t?.get(n))??V():s},Ge=async e=>{const t=new Set;for(const n of e)for(const s of[n.deps,n.devDependencies])for(const[r,o]of Object.entries(s??{}))ge(o)&&t.add(r);return t.size===0?new Map:he([...t],V())},ve=new Set(["@lunora/client","@lunora/do","@lunora/ratelimit","@lunora/runtime","@lunora/server","@lunora/values"]),ye=/(['"])@lunora\/(client|do|ratelimit|runtime|server|values)(\/[^'"]*)?\1/gu,We=e=>{const t=f(e,"package.json");if(!p(t))return!1;try{const n=JSON.parse(h(t,"utf8"));return n.dependencies?.lunorash!==void 0||n.devDependencies?.lunorash!==void 0}catch{return!1}},Je=e=>e.replaceAll(ye,(t,n,s,r)=>`${n}lunorash/${s}${r??""}${n}`),$=(e,t,n,s="dependencies",r=!1,o)=>{const a=Object.entries(e);if(a.length===0)return[];const i=f(t,"package.json");if(!p(i))return n.warn(`package.json not found at ${i} — skipping dependency updates`),[];let d=h(i,"utf8");const c=JSON.parse(d),l=[];for(const[u,M]of a){if(r&&ve.has(u)){n.info(`dep provided by the lunorash umbrella, skipping: ${u}`);continue}if(c.dependencies?.[u]!==void 0||c.devDependencies?.[u]!==void 0){n.info(`dep already present: ${u}`);continue}const F=N(d,[s,u],me(M,o,u),{formattingOptions:{insertSpaces:!0,tabSize:4}});d=O(d,F),l.push(u)}return l.length>0&&(j(i,d,"utf8"),n.success(`added ${String(l.length)} ${s==="devDependencies"?"devDependency(ies)":"dependency(ies)"} to package.json: ${l.join(", ")}`)),l},we=(e,t,n)=>{if(e.length===0)return[];const s=f(t,H),r=p(s)?h(s,"utf8"):"",o=new Set(K(r).map(c=>c.key)),a=[],i=[],d=[];for(const c of e)c.secret&&i.push(c.name),!o.has(c.name)&&(c.description&&d.push(`# ${c.description}`),d.push(`${c.name}=${c.secret?"":c.value??""}`),a.push(c.name));if(a.length>0){const c=r===""||r.endsWith(`
|
|
2
|
+
`)?r:`${r}
|
|
3
|
+
`;q(s,`${c}${d.join(`
|
|
4
|
+
`)}
|
|
5
|
+
`),n.success(`scaffolded ${String(a.length)} env var(s) into .dev.vars: ${a.join(", ")}`)}return i.length>0&&n.info(`set secret value(s) locally in .dev.vars, then for production: ${i.map(c=>`wrangler secret put ${c}`).join("; ")}`),a},E=new Set(["ai","analytics_engine_datasets","browser","d1_databases","durable_objects","hyperdrive","kv_namespaces","mtls_certificates","queues","r2_buckets","send_email","services","vars","vectorize","version_metadata","workflows"]),Se=["binding","name","queue","pattern"],b=e=>{if(!(typeof e!="object"||e===null))for(const t of Se){const n=e[t];if(typeof n=="string"&&n.length>0)return`${t}:${n}`}},$e=(e,t,n,s)=>{const r=new Set(e.map(i=>JSON.stringify(i))),o=new Set(e.map(i=>b(i)).filter(i=>i!==void 0)),a=[];for(const i of t){if(r.has(JSON.stringify(i)))continue;const d=b(i);if(d!==void 0&&o.has(d)){s.warn(`${d.replace(":"," ")} already exists in ${n} — keeping the project's entry and skipping the registry item's. Reconcile by hand if the item needs different settings.`);continue}d!==void 0&&o.add(d),a.push(i)}return a},R=e=>Array.isArray(e),_=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Ee=(e,t,n,s)=>{const r={};for(const[o,a]of Object.entries(t)){if(!Object.hasOwn(e,o)){r[o]=a;continue}JSON.stringify(e[o])!==JSON.stringify(a)&&s.warn(`${o} already exists in ${n} — keeping the project's value and skipping the registry item's. Reconcile by hand if the item needs different settings.`)}return r},be=(e,t)=>{let n=Y(e);for(const s of t){if(typeof n!="object"||n===null)return;n=n[s]}return n},Re=(e,t)=>{const n=e[0];return n!==void 0&&E.has(n)?!0:(t.warn(`skipping binding "${e.join(".")}" — only resource bindings (${[...E].join(", ")}) may be written, not exec/entrypoint keys`),!1)},m=Symbol("skip-binding"),_e=(e,t,n)=>{const{value:s}=t,r=t.path.join("."),o=be(e,t.path);if(R(s)){if(!R(o))return s;const a=$e(o,s,r,n);return a.length===0?m:[...o,...a]}if(_(s)){if(!_(o))return s;const a=Ee(o,s,r,n);return Object.keys(a).length===0?m:{...o,...a}}return s},Ae=(e,t,n)=>{if(e.length===0)return[];const r=["wrangler.jsonc","wrangler.json"].map(i=>f(t,i)).find(i=>p(i));if(!r)return n.warn("wrangler.jsonc not found — skipping binding updates"),[];let o=h(r,"utf8");const a=[];for(const i of e){if(!Re(i.path,n))continue;const d=_e(o,i,n);if(d===m)continue;const c=N(o,[...i.path],d,{formattingOptions:{insertSpaces:!0,tabSize:4}});c.length!==0&&(o=O(o,c),a.push(i.path.join(".")))}return a.length>0&&(j(r,o,"utf8"),n.success(`applied ${String(a.length)} binding(s) to ${r}: ${a.join(", ")}`)),a},ze=(e,t,n,s=!1,r)=>{const o=[],a=[];return e.deps&&o.push(...$(e.deps,t,n,"dependencies",s,r)),e.devDependencies&&o.push(...$(e.devDependencies,t,n,"devDependencies",s,r)),e.bindings&&a.push(...Ae(e.bindings,t,n)),e.envVars&&we(e.envVars,t,n),{bindings:a,deps:o}},y=e=>e.source!==void 0&&e.source.length>0||e.from!==void 0&&e.from.length>0,He=async(e,t)=>{const n=e.some(({manifest:c})=>Object.keys(c.deps??{}).length>0||Object.keys(c.devDependencies??{}).length>0),s=e.some(({manifest:c})=>(c.bindings??[]).length>0),r=y(t);if(!n&&!s&&!r||t.yes)return{ok:!0};const o=[];n&&o.push("add dependencies to package.json"),s&&o.push("write wrangler.jsonc bindings"),r&&o.push(`come from a custom registry source (${String(t.from??t.source)})`);const a=o.join(", ");return!process.stdin.isTTY&&t.confirm===void 0?(t.logger.error(`add: stdin is not a TTY and the requested items ${a} — re-run with --yes to confirm`),{ok:!1,reason:"non-interactive"}):await(t.confirm??Z)(`The requested items ${a}. Continue?`)?{ok:!0}:(t.logger.info("add: aborted"),{ok:!1,reason:"declined"})},U="gh:anolilab/lunora/registry",A=/^[A-Za-z0-9][\w-]*$/u,ke=e=>{if(!A.test(e))throw new g("INTERNAL",`invalid registry item name "${e}" — names must match ${A.source} (letters, digits, "-", "_"; no path separators or "..")`)},je=e=>e.includes("..")?!1:e.startsWith("gh:")||e.startsWith("github:")||e.startsWith("https://"),Ne=e=>y(e)&&e.from===void 0&&!e.allowUnsafeSource&&!je(e.source??""),Ke=(e,t)=>Ne(t)?`${e}: refusing --source ${String(t.source)} — only gh:, github:, or https:// sources are allowed (and may not contain ".."). Re-run with --allow-unsafe-source if you really want this.`:void 0,C=async(e,t,n)=>{const s=G(f(W(),`lunora-${t}-fetch-`)),r=f(s,t);n.info(`fetching ${e}`);try{const o=await J(e,{cwd:s,dir:r,force:!0,install:!1,silent:!0});return n.info(o.commit?`resolved ${o.source} @ ${o.commit}`:`resolved ${o.source}`),{cleanup:()=>{w(s,{force:!0,recursive:!0})},directory:r}}catch(o){throw w(s,{force:!0,recursive:!0}),o}},k=new WeakMap,x=async e=>{const t=k.get(e);if(t!==void 0)return t;const n=y(e)?Promise.resolve(I(e.ref)):de(e.ref,e.logger);return k.set(e,n),n},Oe=async(e,t,n=U)=>{if(ke(e),t.from!==void 0){const r=f(t.from,e);if(!p(r))throw new g("INTERNAL",`registry item not found in local source: ${r}`);return{cleanup:()=>{},directory:r}}const s=t.source??n;return C(`${s}/${e}#${await x(t)}`,"item",t.logger)},qe=async e=>{if(e.from!==void 0){if(!p(e.from))throw new g("INTERNAL",`registry root not found: ${e.from}`);return{cleanup:()=>{},root:e.from}}const t=e.source??U,{cleanup:n,directory:s}=await C(`${t}#${await x(e)}`,"registry",e.logger);return{cleanup:n,root:s}},Te=(e,t)=>{const n=JSON.parse(h(f(e,"registry.json"),"utf8"));return X(n,t)},Ye=async(e,t)=>{const n=[],s=[],r=new Set,o=new Set,a=async i=>{if(r.has(i))return;if(o.has(i))throw new g("INTERNAL",`cyclic registry dependency detected at "${i}"`);o.add(i);const{cleanup:d,directory:c}=await Oe(i,t);s.push(d);const l=Te(c,i);for(const u of l.requires??[])await a(u);o.delete(i),r.add(i),n.push({directory:c,manifest:l})};try{for(const i of e)await a(i)}catch(i){for(const d of s)d();throw i}return{cleanups:s,items:n}};export{v as a,de as b,Oe as c,ze as d,Je as e,Ye as f,Ge as g,He as h,y as i,qe as j,me as k,Te as l,he as m,ce as n,V as o,We as p,I as q,Fe as r,Ke as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readLinkedProject as n}from"@lunora/config";const v=({cwd:e,env:i,url:o})=>{if(o!==void 0&&o!=="")return o;const r=n(e);if(!(r===void 0||r.env!==i))return r.workerUrl},d=({cwd:e,prod:i,url:o})=>{if(o!==void 0&&o!=="")return o;if(!i)return;const r=n(e);if(!(r===void 0||r.env!==void 0&&r.env!=="production"))return r.workerUrl};export{d as a,v as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./EXIT_CODE-08cwt3MK.mjs";import"./resolve-DUCSc7jQ.mjs";import"./catalog-CahzmDLV.mjs";import{r as n,a as i,b as t}from"./commands-CNqednoX.mjs";export{n as runAddCommand,i as runBuildIndexCommand,t as runRegistryViewCommand};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{randomUUID as b}from"node:crypto";import{createWriteStream as x}from"node:fs";import{unlink as E,rename as S}from"node:fs/promises";import{r as T}from"./admin-token-VdUnvnKW.mjs";import{r as O}from"./admin-url-BhF5ufg1.mjs";import{EXIT_CODE as w,isRefusal as $,exitCodeForStatus as N}from"./EXIT_CODE-08cwt3MK.mjs";import{E as U}from"./shared-D-zCOmgY.mjs";const k=e=>{if(e===void 0)return;const r=e.split(",").map(t=>t.trim()).filter(t=>t.length>0);return r.length>0?r:void 0},p=async(e,r)=>{e.write(r)||await new Promise((t,a)=>{let d=o=>{};const n=()=>{e.removeListener("error",d),t()};d=o=>{e.removeListener("drain",n),a(o)},e.once("drain",n),e.once("error",d)})},I=async(e,r)=>{const t=e.getReader(),a=new TextDecoder;let d=0,n=0,o="",c=!1;try{for(;!c;){const i=await t.read();if(c=i.done,i.value===void 0)continue;d+=i.value.length,o+=a.decode(i.value,{stream:!0});let s=o.indexOf(`
|
|
2
|
+
`);for(;s!==-1;){n+=1;const l=`${o.slice(0,s)}
|
|
3
|
+
`;await p(r,l),o=o.slice(s+1),s=o.indexOf(`
|
|
4
|
+
`)}}return o.length>0&&(n+=1,await p(r,`${o}
|
|
5
|
+
`)),{bytes:d,rows:n}}finally{t.releaseLock()}},v=async(e,r)=>{if(r===void 0)return;const t=e;await new Promise(a=>{if(t.closed){a();return}t.once("close",()=>{a()}),t.destroy()});try{await E(r)}catch{}},P=async(e,r,t)=>{await new Promise((d,n)=>{e.end(o=>{const c=o??t();c===void 0?d():n(c)})});const a=t();if(a!==void 0)throw await v(e,r),a},A=async(e,r,t)=>{await P(e,r.stage,t);try{await S(r.stage,r.path)}catch(a){throw await v(e,r.stage),a}},y="export --format json needs a file destination (--out <file>) — with --out - the NDJSON stream already owns stdout.",_=e=>{const r=e.out===void 0||e.out==="-"?void 0:e.out;if(e.format==="json"&&r===void 0){e.logger.error(y);return}return{destination:r}},D=e=>{if(e.prod&&e.url===void 0)return e.logger.error("--prod requires an explicit --url (refusing to export from the implicit localhost worker)"),{refused:w.USAGE};const r=O(e.url,e.logger,e.cwd);if(r===void 0)return{refused:w.USAGE};const{token:t}=T({cwd:e.cwd??process.cwd(),token:e.token,url:r});if(!t)return e.logger.error("admin token required — pass --token, set LUNORA_ADMIN_TOKEN, or add it to .dev.vars (local targets only)"),{refused:w.AUTH};const a=e.fetchImpl??globalThis.fetch;if(typeof a!="function")throw new TypeError("no fetch implementation available — pass fetchImpl or run on Node >= 18");return{fetchImpl:a,requestUrl:`${r}${U}`,tables:k(e.tables),token:t}},G=async e=>{const r=_(e);if(r===void 0)return{bytes:0,code:w.USAGE,error:y,rows:0};const{destination:t}=r,a=D(e);if($(a))return{bytes:0,code:a.refused,error:"export: could not resolve the worker URL and admin token",rows:0};const{fetchImpl:d,requestUrl:n,tables:o,token:c}=a;e.logger.info(`POST ${n} -> export${o?` (tables: ${o.join(",")})`:""}`);const i=await d(n,{body:JSON.stringify(o?{tables:o}:{}),headers:{authorization:`Bearer ${c}`,"content-type":"application/json"},method:"POST"});if(!i.ok){const u=await i.text(),h=`export failed: HTTP ${String(i.status)}: ${u}`;return e.logger.error(h),{bytes:0,code:N(i.status),error:h,rows:0}}if(!i.body)return e.logger.error("export response carried no body"),{bytes:0,code:1,error:"export response carried no body",rows:0};const s=t===void 0?void 0:{path:t,stage:`${t}.${b()}.partial`},l=s===void 0?process.stdout:x(s.stage,{encoding:"utf8",mode:384});let g;s!==void 0&&l.on("error",u=>{g??=u});let f,m;try{({bytes:f,rows:m}=await I(i.body,l))}catch(u){throw await v(l,s?.stage),u}return s!==void 0&&(await A(l,s,()=>g),e.logger.success(`wrote ${String(m)} rows to ${s.path} (${String(f)} bytes)`)),{bytes:f,code:0,data:t===void 0?void 0:{bytes:f,out:t,rows:m,tables:o},rows:m}};export{G as runExportCommand};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{existsSync as p,mkdirSync as _,writeFileSync as v,mkdtempSync as x,rmSync as F,readFileSync as U}from"node:fs";import{tmpdir as O}from"node:os";import{discoverMigrations as k,discoverSchema as N,readPackageDependencies as D}from"@lunora/codegen";import{isInteractive as P,promptSelect as G,promptText as j}from"@lunora/config";import{LunoraError as T}from"@lunora/errors";import{join as l}from"@visulima/path";import{Project as w}from"ts-morph";import{r as z,t as L}from"./admin-token-VdUnvnKW.mjs";import{r as q,n as H}from"./admin-url-BhF5ufg1.mjs";import{isRefusal as B,exitCodeForStatus as W,EXIT_CODE as c}from"./EXIT_CODE-08cwt3MK.mjs";import{diffSnapshots as J,renderMigrationFile as V}from"./diffSnapshots-WWwx-KvZ.mjs";import X from"./schemaIrToSnapshot-BjK-0IRo.mjs";import{runExportCommand as Z}from"./runExportCommand-DxsJHYZt.mjs";import{r as K}from"./import-D7qdpSmJ.mjs";import{readAndLogBody as Q}from"../packem_chunks/runRpcCommand.mjs";const h="__lunora_reproject__",Y=e=>{if(!e.startsWith(h))return;const r=e.slice(h.length);return r===""?void 0:r},ee=".snapshot.json",R=/[^\da-z]+/gu,M=(e,r)=>{let t=0,o=e.length;for(;t<o&&e[t]===r;)t+=1;for(;o>t&&e[o-1]===r;)o-=1;return e.slice(t,o)},re=e=>{const r=M(e.toLowerCase().replaceAll(R,"_"),"_");return r===""?"auto":r},te=e=>{const r=(t,o=2)=>t.toString().padStart(o,"0");return`${String(e.getUTCFullYear())}${r(e.getUTCMonth()+1)}${r(e.getUTCDate())}${r(e.getUTCHours())}${r(e.getUTCMinutes())}${r(e.getUTCSeconds())}`},oe=e=>{if(p(e))try{const r=U(e,"utf8"),t=JSON.parse(r);if(t.version!==1)throw new T("INTERNAL",`unsupported snapshot version: ${t.version}`);return t}catch(r){const t=r instanceof Error?r.message:String(r);throw new T("INTERNAL",`failed to read ${e}: ${t}`,{cause:r})}},ke=e=>{const r=e.cwd??process.cwd(),t=l(r,"lunora","schema.ts");if(!p(t)){const m=`schema not found: ${t} — run \`vis generate lunora-table --name=<name>\` to create one`;return e.logger.error(m),{code:c.NOT_FOUND,empty:!0,error:m,migrationFile:""}}const o=new w({skipAddingFilesFromTsConfig:!0}),a=N(o,t),s=X(a),n=l(r,"lunora","migrations"),i=l(n,ee);let d;try{d=oe(i)}catch(m){const S=m instanceof Error?m.message:String(m);return e.logger.error(S),{code:c.USAGE,empty:!0,error:S,migrationFile:""}}const u=J(d,s);if(u.empty)return e.logger.info("no schema changes detected — snapshot is already up to date"),{code:0,empty:!0,migrationFile:""};const f=(e.now??(()=>new Date))(),y=re(e.name??"auto"),$=`${te(f)}_${y}.sql`,b=l(n,$);_(n,{recursive:!0});const C=V(y,u,f.toISOString());return v(b,C,"utf8"),v(i,`${JSON.stringify(s,void 0,4)}
|
|
2
|
+
`,"utf8"),e.logger.success(`wrote ${b}`),u.unsupported.length>0&&e.logger.warn(`${String(u.unsupported.length)} unsupported diff(s) — see the comment block in ${$} and write the SQL manually`),{code:0,empty:!1,migrationFile:b}},ne="migrations.ts",I=/^[A-Za-z_]\w*$/u,ae=new Set(["await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","implements","import","in","instanceof","interface","let","new","null","package","private","protected","public","return","static","super","switch","this","throw","true","try","typeof","var","void","while","with","yield"]),A=/^import\s*\{\s*defineMigration\s*\}\s*from\s*["'](?:@lunora\/server|lunorash\/server)["'][^\n]*$/mu,ie=e=>`import { defineMigration } from "${D(e)?.has("lunorash")??!1?"lunorash/server":"@lunora/server"}";`,se="__lunora_admin__:runMigration",ce="__lunora_admin__:migrationStatus",de="/_lunora/migrate",le=e=>M(e.trim().toLowerCase().replaceAll(R,"-"),"-"),ue=e=>e.split("-").filter(r=>r.length>0).map((r,t)=>t===0?r:r.charAt(0).toUpperCase()+r.slice(1)).join(""),me=e=>{const r=l(e,"lunora","schema.ts");if(!p(r))return[];try{const t=new w({skipAddingFilesFromTsConfig:!0});return N(t,r).tables.map(o=>o.name)}catch{return[]}},ge=async e=>e.length>0?G("Which table does this migration iterate?",e.map(r=>({label:r,value:r}))):j("Target table for the migration: "),fe=async(e,r)=>{if(r.table!==void 0)return r.table;const t=r.promptTable??(P()?ge:void 0);if(t===void 0){r.logger.error("migrate create requires a target table when not running interactively — re-run with --table <table>");return}const a=(await t(me(e)))?.trim();if(a===void 0||a===""){r.logger.error("no table selected — re-run with --table <table>");return}return a},De=async e=>{const r=e.cwd??process.cwd(),t=le(e.name);if(t==="")return e.logger.error(`invalid migration name: "${e.name}" — must contain at least one alphanumeric character`),{code:c.USAGE,file:""};const o=ue(t);if(!I.test(o)||ae.has(o))return e.logger.error(`invalid migration name: "${e.name}" derives the export \`${o}\`, which is not a valid identifier — pick a name that starts with a letter and isn't a reserved word`),{code:c.USAGE,file:""};const a=await fe(r,e);if(a===void 0)return{code:c.USAGE,file:""};if(!I.test(a))return e.logger.error(`invalid table: "${a}" — must be a valid identifier ([A-Za-z_][A-Za-z0-9_]*)`),{code:c.USAGE,file:""};const s=l(r,"lunora"),n=l(s,ne);let i=p(n)?U(n,"utf8"):"";if(i.includes(`id: "${t}"`)||new RegExp(String.raw`\bexport const ${o}\b`,"u").test(i))return e.logger.error(`a migration with id "${t}" (export \`${o}\`) already exists in ${n}`),{code:c.CONFLICT,file:""};const d=ie(r);i.trim()===""?i=`${d}
|
|
3
|
+
`:A.test(i)?i=i.replace(A,d):i=`${d}
|
|
4
|
+
${i}`;const u=`export const ${o} = defineMigration({
|
|
5
|
+
id: "${t}",
|
|
6
|
+
table: "${a}",
|
|
7
|
+
up: (document) => document,
|
|
8
|
+
});`;return _(s,{recursive:!0}),v(n,`${i.trimEnd()}
|
|
9
|
+
|
|
10
|
+
${u}
|
|
11
|
+
`,"utf8"),e.logger.success(`scaffolded migration "${t}" in ${n}`),{code:0,file:n}},he=(e,r)=>{const t=new w({skipAddingFilesFromTsConfig:!0});return k(t,l(e,"lunora")).find(a=>a.id===r)?.table},pe=(e,r)=>{const t=Y(r.id);if(t!==void 0)return t;if(r.id.startsWith(h)){r.logger.error(`"${r.id}" names no table — use ${h}<table>`);return}let o;try{o=he(e,r.id)}catch(a){r.logger.error(a instanceof Error?a.message:String(a));return}if(o===void 0){r.logger.error(`migration "${r.id}" not found under lunora/ — declare it with defineMigration({ id: "${r.id}", ... })`);return}if(o===""){r.logger.error(`migration "${r.id}" must declare \`table\` as a static string literal`);return}return o},be=e=>{const r=e.cwd??process.cwd();if(e.prod&&e.url===void 0)return e.logger.error("--prod requires an explicit --url (refusing to migrate the implicit localhost worker)"),{refused:c.USAGE};const t=pe(r,e);if(t===void 0)return{refused:c.USAGE};const o=q(e.url,e.logger,e.cwd);if(o===void 0)return{refused:c.USAGE};const{token:a}=z({cwd:r,token:e.token,url:o});if(!a)return e.logger.error("admin token required — pass --token, set LUNORA_ADMIN_TOKEN, or add it to .dev.vars (local targets only)"),{refused:c.AUTH};if((e.subcommand==="up"||e.subcommand==="down")&&L({prod:e.prod,url:o})&&!e.yes)return e.logger.error(`migrate ${e.subcommand} runs the migration against ${o}, which is not local. Re-run with --yes to confirm.`),{refused:c.USAGE};const s=e.fetchImpl??globalThis.fetch;if(typeof s!="function")throw new TypeError("no fetch implementation available — pass fetchImpl or run on Node >= 18");return{fetchImpl:s,requestUrl:`${o}${de}`,table:t,token:a}},ve=e=>{if(e===null||typeof e!="object")return;const r=e,t=typeof r.failed=="number"&&r.failed>0?r.failed:0;if(t>0)return`${String(t)} shard(s) could not be reached — their rows were NOT migrated (see the per-shard errors above)`;if(r.status==="failed")return"the migration reported `failed` on at least one shard — see the per-shard results above"},we=e=>{const r={id:e.id};return e.subcommand==="status"||(r.direction=e.subcommand,e.dryRun&&(r.dryRun=!0),e.batchSize!==void 0&&(r.batchSize=e.batchSize),e.maxBatches!==void 0&&(r.maxBatches=e.maxBatches)),r},Pe=async e=>{const r=be(e);if(B(r))return{body:void 0,code:r.refused,requestUrl:""};const{fetchImpl:t,requestUrl:o,table:a,token:s}=r,n=e.subcommand==="status"?ce:se,i=we(e);e.logger.info(`POST ${o} -> ${e.subcommand} ${e.id} (table "${a}")`);const d=await t(o,{body:JSON.stringify({args:i,functionPath:n,table:a}),headers:{authorization:`Bearer ${s}`,"content-type":"application/json"},method:"POST"}),u=await Q(d,e.logger),g=ve(u);g!==void 0&&e.logger.error(`migrate ${e.subcommand} "${e.id}": ${g}`);const f=g===void 0?0:1;return{body:u,code:d.ok?f:W(d.status),requestUrl:o}},E=e=>e===void 0?void 0:H(e),Ge=async e=>{const{logger:r}=e,t=E(e.fromUrl??e.toUrl),o=E(e.toUrl??e.fromUrl);if(t===o){const n="source and target are the same deployment — pass distinct --from-url and --to-url so the D1 export and Hyperdrive import don't run against one database";return r.error(n),{bytes:0,code:c.USAGE,error:n,exported:0,imported:0}}const a=e.out===void 0?x(l(O(),"lunora-d1ps-")):void 0,s=e.out??l(a,"dump.ndjson");try{r.info(`Exporting .global() data from the D1 source (${t??"http://localhost:8787"}) …`);const n=await Z({fetchImpl:e.fetchImpl,logger:r,out:s,prod:e.prod,tables:e.tables,token:e.fromToken,url:t});if(n.code!==0)return{bytes:n.bytes,code:n.code,exported:n.rows,imported:0,...n.error===void 0?{}:{error:n.error}};r.info(`Exported ${String(n.rows)} row(s) (${String(n.bytes)} bytes).`),r.info(`Importing into the Hyperdrive target (${o??"http://localhost:8787"}) …`);const i=await K({batchSize:e.batchSize,fetchImpl:e.fetchImpl,file:s,logger:r,prod:e.prod,token:e.toToken,url:o,yes:e.yes});return i.code!==0?{bytes:n.bytes,code:i.code,exported:n.rows,imported:i.inserted,...i.error===void 0?{}:{error:i.error}}:(i.inserted===n.rows?r.info(`✓ Migrated ${String(n.rows)} row(s) — counts match. Verify your app reads from Hyperdrive, then decommission the D1 binding.`):r.warn(`Imported ${String(i.inserted)} of ${String(n.rows)} exported row(s) — the remainder likely already existed in the target (see conflicts above). Re-run after resolving, or inspect the dump with --out.`),{bytes:n.bytes,code:0,exported:n.rows,imported:i.inserted})}finally{a!==void 0&&F(a,{force:!0,recursive:!0})}};export{De as runMigrateCreateCommand,Pe as runMigrateDataCommand,ke as runMigrateGenerateCommand,Ge as runMigrateToHyperdriveCommand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as p,readFileSync as b,writeFileSync as S}from"node:fs";import{parseSchemaSnapshot as w,SchemaSnapshotParseError as y,evaluateSchemaDrift as k,serializeSchemaSnapshot as H}from"@lunora/codegen";const f="/_lunora/health",E="/_lunora/health/ready",P=(e,r=f)=>(e.endsWith("/")?e.slice(0,-1):e)+r,d=async(e,r,a)=>{let h={error:`health probe failed: no health path configured for ${e}`,url:e};for(const[c,i]of r.entries()){const t=P(e,i);let s;try{s=await a(t)}catch(o){const l=o instanceof Error?o.message:String(o);return{error:`health probe failed: could not reach ${t} (${l})`,url:t}}if(s.ok)return{url:t};if(h={error:`health probe failed: ${t} returned HTTP ${String(s.status)}`,url:t},s.status!==404||c===r.length-1)return h}return h},v=async e=>new Promise(r=>{setTimeout(r,e)}),_=async({attempts:e=1,baseUrl:r,delayMs:a=2e3,fetchImpl:h,paths:c=[f],sleep:i=v,timeoutMs:t=1e4})=>{const s=h??(u=>fetch(u,{signal:AbortSignal.timeout(t)})),o=Math.max(1,e);let l=await d(r,c,s);for(let u=1;u<o&&l.error!==void 0;u+=1)await i(a),l=await d(r,c,s);return l},$=e=>{if(!p(e))return{status:"absent"};let r;try{r=b(e,"utf8")}catch{return{status:"corrupt"}}try{const a=w(r);return a===void 0?{status:"corrupt"}:{snapshot:a,status:"ok"}}catch(a){if(a instanceof y)return{status:"corrupt"};throw a}},O=(e,r)=>{S(e,H(r),"utf8")},T=e=>{const r=`schema-drift gate: the committed baseline ${e.snapshotPath} is unreadable or malformed, so schema drift cannot be checked. Fix it (e.g. resolve a merge conflict in lunora/.lunora-schema.json), or pass --update-schema-baseline to regenerate it from the current schema.`;return e.updateBaseline&&!e.readOnly?(e.logger.warn(`schema baseline was unreadable; regenerating from the current schema on success (--update-schema-baseline): ${e.snapshotPath}`),{blocked:!1,changes:[],reason:r,rebless:e.rebless}):(e.readOnly||e.logger.error(r),{blocked:!0,changes:[],reason:r})},A=(e,r)=>(r.readOnly||r.logger.error(e.reason),r.updateBaseline&&!r.readOnly?(r.logger.warn(`schema baseline will be re-blessed despite breaking drift on success (--update-schema-baseline): ${r.snapshotPath}`),{blocked:!1,changes:e.changes,reason:e.reason,rebless:r.rebless}):{blocked:!0,changes:e.changes,reason:e.reason}),F=e=>{const{allowDrift:r,codegen:a,command:h,logger:c,readOnly:i=!1,updateBaseline:t=!1}=e,s=a.schemaSnapshotPath,o=$(s),l={logger:c,readOnly:i,rebless:()=>{O(s,a.schemaSnapshot)},snapshotPath:s,updateBaseline:t};if(o.status==="corrupt")return T(l);const u=m=>k({allowDrift:m,baseline:o.status==="ok"?o.snapshot:void 0,command:h,current:a.schemaSnapshot,migrations:a.migrations}),n=u(r);if(n.blocked)return A(n,l);const g=r&&n.changes.length>0&&u(!1).blocked;return n.changes.length>0?(i||c.info(n.reason),g&&!t?(i||c.warn(`schema baseline left at its committed shape — --allow-schema-drift overrides this run only. Pass --update-schema-baseline to accept the new shape: ${s}`),{blocked:!1,changes:n.changes,reason:n.reason}):{blocked:!1,changes:n.changes,reason:n.reason,rebless:i?void 0:l.rebless}):{blocked:!1,changes:n.changes,reason:n.reason}};export{E as H,f as a,_ as p,F as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{buildSchemaSnapshot as b,isD1GlobalTable as d}from"@lunora/codegen";import{validatorKindToSqlType as p}from"./diffSnapshots-WWwx-KvZ.mjs";const k=new Set(["any","null"]),f=(n,e)=>{const t=e.kindOf(n);return t!==void 0&&k.has(t)||e.nullableOf(n)?!0:t==="union"&&(e.membersOf(n)??[]).some(l=>f(l,e))},m=n=>n.kind==="optional"&&n.inner?m(n.inner):n.kind==="literal"&&n.literalValue==="null"?"null":n.kind,i=n=>n.kind==="optional"&&n.inner?i(n.inner):n,O=n=>f(n,{kindOf:m,membersOf:e=>i(e).members,nullableOf:e=>i(e).column?.notNull===!1}),N=n=>p(n.kind==="optional"&&n.inner?n.inner.kind:n.kind),T=(n,e)=>n.kind==="optional"||O(n)?!0:e===void 0?!1:e.nullable===!0,h=d,y=n=>{const e={},t=b(n,[]);for(const l of n.tables){if(!h(l))continue;const a={};for(const[o,c]of Object.entries(l.shape)){const s=t.tables[l.name]?.fields[o],r={nullable:T(c,s),sqlType:N(c)};a[o]=s===void 0?r:{...r,field:s}}const u={};for(const o of l.indexes)u[o.name]={fields:[...o.fields],name:o.name,unique:o.unique??!1};e[l.name]={columns:a,indexes:u,name:l.name}}return{tables:e,version:1}};export{y as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a="/_lunora/admin/export",o="/_lunora/admin/import",_="/_lunora/admin/storage",n="/_lunora/admin/storage/url";export{a as E,o as I,_ as S,n as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as Ye}from"./commands-CNqednoX.mjs";var B={exports:{}},se,rr;function X(){if(rr)return se;rr=1;const r="2.0.0",i=256,t=Number.MAX_SAFE_INTEGER||9007199254740991,s=16,a=i-6;return se={MAX_LENGTH:i,MAX_SAFE_COMPONENT_LENGTH:s,MAX_SAFE_BUILD_LENGTH:a,MAX_SAFE_INTEGER:t,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:r,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},se}var ne,tr;function H(){return tr||(tr=1,ne=process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...i)=>console.error("SEMVER",...i):()=>{}),ne}var sr;function M(){return sr||(sr=1,(function(r,i){const{MAX_SAFE_COMPONENT_LENGTH:t,MAX_SAFE_BUILD_LENGTH:s,MAX_LENGTH:a}=X(),h=H();i=r.exports={};const u=i.re=[],f=i.safeRe=[],n=i.src=[],R=i.safeSrc=[],e=i.t={};let o=0;const c="[a-zA-Z0-9-]",m=[["\\s",1],["\\d",a],[c,s]],L=O=>{for(const[P,D]of m)O=O.split(`${P}*`).join(`${P}{0,${D}}`).split(`${P}+`).join(`${P}{1,${D}}`);return O},E=(O,P,D)=>{const G=L(P),y=o++;h(O,y,P),e[O]=y,n[y]=P,R[y]=G,u[y]=new RegExp(P,D?"g":void 0),f[y]=new RegExp(G,D?"g":void 0)};E("NUMERICIDENTIFIER","0|[1-9]\\d*"),E("NUMERICIDENTIFIERLOOSE","\\d+"),E("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${c}*`),E("MAINVERSION",`(${n[e.NUMERICIDENTIFIER]})\\.(${n[e.NUMERICIDENTIFIER]})\\.(${n[e.NUMERICIDENTIFIER]})`),E("MAINVERSIONLOOSE",`(${n[e.NUMERICIDENTIFIERLOOSE]})\\.(${n[e.NUMERICIDENTIFIERLOOSE]})\\.(${n[e.NUMERICIDENTIFIERLOOSE]})`),E("PRERELEASEIDENTIFIER",`(?:${n[e.NONNUMERICIDENTIFIER]}|${n[e.NUMERICIDENTIFIER]})`),E("PRERELEASEIDENTIFIERLOOSE",`(?:${n[e.NONNUMERICIDENTIFIER]}|${n[e.NUMERICIDENTIFIERLOOSE]})`),E("PRERELEASE",`(?:-(${n[e.PRERELEASEIDENTIFIER]}(?:\\.${n[e.PRERELEASEIDENTIFIER]})*))`),E("PRERELEASELOOSE",`(?:-?(${n[e.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${n[e.PRERELEASEIDENTIFIERLOOSE]})*))`),E("BUILDIDENTIFIER",`${c}+`),E("BUILD",`(?:\\+(${n[e.BUILDIDENTIFIER]}(?:\\.${n[e.BUILDIDENTIFIER]})*))`),E("FULLPLAIN",`v?${n[e.MAINVERSION]}${n[e.PRERELEASE]}?${n[e.BUILD]}?`),E("FULL",`^${n[e.FULLPLAIN]}$`),E("LOOSEPLAIN",`[v=\\s]*${n[e.MAINVERSIONLOOSE]}${n[e.PRERELEASELOOSE]}?${n[e.BUILD]}?`),E("LOOSE",`^${n[e.LOOSEPLAIN]}$`),E("GTLT","((?:<|>)?=?)"),E("XRANGEIDENTIFIERLOOSE",`${n[e.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),E("XRANGEIDENTIFIER",`${n[e.NUMERICIDENTIFIER]}|x|X|\\*`),E("XRANGEPLAIN",`[v=\\s]*(${n[e.XRANGEIDENTIFIER]})(?:\\.(${n[e.XRANGEIDENTIFIER]})(?:\\.(${n[e.XRANGEIDENTIFIER]})(?:${n[e.PRERELEASE]})?${n[e.BUILD]}?)?)?`),E("XRANGEPLAINLOOSE",`[v=\\s]*(${n[e.XRANGEIDENTIFIERLOOSE]})(?:\\.(${n[e.XRANGEIDENTIFIERLOOSE]})(?:\\.(${n[e.XRANGEIDENTIFIERLOOSE]})(?:${n[e.PRERELEASELOOSE]})?${n[e.BUILD]}?)?)?`),E("XRANGE",`^${n[e.GTLT]}\\s*${n[e.XRANGEPLAIN]}$`),E("XRANGELOOSE",`^${n[e.GTLT]}\\s*${n[e.XRANGEPLAINLOOSE]}$`),E("COERCEPLAIN",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?`),E("COERCE",`${n[e.COERCEPLAIN]}(?:$|[^\\d])`),E("COERCEFULL",n[e.COERCEPLAIN]+`(?:${n[e.PRERELEASE]})?(?:${n[e.BUILD]})?(?:$|[^\\d])`),E("COERCERTL",n[e.COERCE],!0),E("COERCERTLFULL",n[e.COERCEFULL],!0),E("LONETILDE","(?:~>?)"),E("TILDETRIM",`(\\s*)${n[e.LONETILDE]}\\s+`,!0),i.tildeTrimReplace="$1~",E("TILDE",`^${n[e.LONETILDE]}${n[e.XRANGEPLAIN]}$`),E("TILDELOOSE",`^${n[e.LONETILDE]}${n[e.XRANGEPLAINLOOSE]}$`),E("LONECARET","(?:\\^)"),E("CARETTRIM",`(\\s*)${n[e.LONECARET]}\\s+`,!0),i.caretTrimReplace="$1^",E("CARET",`^${n[e.LONECARET]}${n[e.XRANGEPLAIN]}$`),E("CARETLOOSE",`^${n[e.LONECARET]}${n[e.XRANGEPLAINLOOSE]}$`),E("COMPARATORLOOSE",`^${n[e.GTLT]}\\s*(${n[e.LOOSEPLAIN]})$|^$`),E("COMPARATOR",`^${n[e.GTLT]}\\s*(${n[e.FULLPLAIN]})$|^$`),E("COMPARATORTRIM",`(\\s*)${n[e.GTLT]}\\s*(${n[e.LOOSEPLAIN]}|${n[e.XRANGEPLAIN]})`,!0),i.comparatorTrimReplace="$1$2$3",E("HYPHENRANGE",`^\\s*(${n[e.XRANGEPLAIN]})\\s+-\\s+(${n[e.XRANGEPLAIN]})\\s*$`),E("HYPHENRANGELOOSE",`^\\s*(${n[e.XRANGEPLAINLOOSE]})\\s+-\\s+(${n[e.XRANGEPLAINLOOSE]})\\s*$`),E("STAR","(<|>)?=?\\s*\\*"),E("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),E("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(B,B.exports)),B.exports}var ie,nr;function ze(){if(nr)return ie;nr=1;const r=Object.freeze({loose:!0}),i=Object.freeze({});return ie=s=>s?typeof s!="object"?r:s:i,ie}var ae,ir;function zr(){if(ir)return ae;ir=1;const r=/^[0-9]+$/,i=(s,a)=>{if(typeof s=="number"&&typeof a=="number")return s===a?0:s<a?-1:1;const h=r.test(s),u=r.test(a);return h&&u&&(s=+s,a=+a),s===a?0:h&&!u?-1:u&&!h?1:s<a?-1:1};return ae={compareIdentifiers:i,rcompareIdentifiers:(s,a)=>i(a,s)},ae}var oe,ar;function j(){if(ar)return oe;ar=1;const r=H(),{MAX_LENGTH:i,MAX_SAFE_INTEGER:t}=X(),{safeRe:s,t:a}=M(),h=ze(),{compareIdentifiers:u}=zr(),f=(R,e)=>{const o=e.split(".");if(o.length>R.length)return!1;for(let c=0;c<o.length;c++)if(u(R[c],o[c])!==0)return!1;return!0};class n{constructor(e,o){if(o=h(o),e instanceof n){if(e.loose===!!o.loose&&e.includePrerelease===!!o.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>i)throw new TypeError(`version is longer than ${i} characters`);r("SemVer",e,o),this.options=o,this.loose=!!o.loose,this.includePrerelease=!!o.includePrerelease;const c=e.trim().match(o.loose?s[a.LOOSE]:s[a.FULL]);if(!c)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+c[1],this.minor=+c[2],this.patch=+c[3],this.major>t||this.major<0)throw new TypeError("Invalid major version");if(this.minor>t||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>t||this.patch<0)throw new TypeError("Invalid patch version");c[4]?this.prerelease=c[4].split(".").map(m=>{if(/^[0-9]+$/.test(m)){const L=+m;if(L>=0&&L<t)return L}return m}):this.prerelease=[],this.build=c[5]?c[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(r("SemVer.compare",this.version,this.options,e),!(e instanceof n)){if(typeof e=="string"&&e===this.version)return 0;e=new n(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof n||(e=new n(e,this.options)),this.major<e.major?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:this.patch>e.patch?1:0}comparePre(e){if(e instanceof n||(e=new n(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let o=0;do{const c=this.prerelease[o],m=e.prerelease[o];if(r("prerelease compare",o,c,m),c===void 0&&m===void 0)return 0;if(m===void 0)return 1;if(c===void 0)return-1;if(c===m)continue;return u(c,m)}while(++o)}compareBuild(e){e instanceof n||(e=new n(e,this.options));let o=0;do{const c=this.build[o],m=e.build[o];if(r("build compare",o,c,m),c===void 0&&m===void 0)return 0;if(m===void 0)return 1;if(c===void 0)return-1;if(c===m)continue;return u(c,m)}while(++o)}inc(e,o,c){if(e.startsWith("pre")){if(!o&&c===!1)throw new Error("invalid increment argument: identifier is empty");if(o){const m=`-${o}`.match(this.options.loose?s[a.PRERELEASELOOSE]:s[a.PRERELEASE]);if(!m||m[1]!==o)throw new Error(`invalid identifier: ${o}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",o,c);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",o,c);break;case"prepatch":this.prerelease.length=0,this.inc("patch",o,c),this.inc("pre",o,c);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",o,c),this.inc("pre",o,c);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const m=Number(c)?1:0;if(this.prerelease.length===0)this.prerelease=[m];else{let L=this.prerelease.length;for(;--L>=0;)typeof this.prerelease[L]=="number"&&(this.prerelease[L]++,L=-2);if(L===-1){if(o===this.prerelease.join(".")&&c===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(m)}}if(o){let L=[o,m];if(c===!1&&(L=[o]),f(this.prerelease,o)){const E=this.prerelease[o.split(".").length];isNaN(E)&&(this.prerelease=L)}else this.prerelease=L}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return oe=n,oe}var ue,or;function V(){if(or)return ue;or=1;const r=j();return ue=(t,s,a=!1)=>{if(t instanceof r)return t;try{return new r(t,s)}catch(h){if(!a)return null;throw h}},ue}var ce,ur;function tt(){if(ur)return ce;ur=1;const r=V();return ce=(t,s)=>{const a=r(t,s);return a?a.version:null},ce}var le,cr;function st(){if(cr)return le;cr=1;const r=V();return le=(t,s)=>{const a=r(t.trim().replace(/^[=v]+/,""),s);return a?a.version:null},le}var fe,lr;function nt(){if(lr)return fe;lr=1;const r=j();return fe=(t,s,a,h,u)=>{typeof a=="string"&&(u=h,h=a,a=void 0);try{return new r(t instanceof r?t.version:t,a).inc(s,h,u).version}catch{return null}},fe}var he,fr;function it(){if(fr)return he;fr=1;const r=V();return he=(t,s)=>{const a=r(t,null,!0),h=r(s,null,!0),u=a.compare(h);if(u===0)return null;const f=u>0,n=f?a:h,R=f?h:a,e=!!n.prerelease.length;if(!!R.prerelease.length&&!e){if(!R.patch&&!R.minor)return"major";if(R.compareMain(n)===0)return R.minor&&!R.patch?"minor":"patch"}const c=e?"pre":"";return a.major!==h.major?c+"major":a.minor!==h.minor?c+"minor":a.patch!==h.patch?c+"patch":"prerelease"},he}var Ee,hr;function at(){if(hr)return Ee;hr=1;const r=j();return Ee=(t,s)=>new r(t,s).major,Ee}var pe,Er;function ot(){if(Er)return pe;Er=1;const r=j();return pe=(t,s)=>new r(t,s).minor,pe}var me,pr;function ut(){if(pr)return me;pr=1;const r=j();return me=(t,s)=>new r(t,s).patch,me}var Re,mr;function ct(){if(mr)return Re;mr=1;const r=V();return Re=(t,s)=>{const a=r(t,s);return a&&a.prerelease.length?a.prerelease:null},Re}var de,Rr;function U(){if(Rr)return de;Rr=1;const r=j();return de=(t,s,a)=>new r(t,a).compare(new r(s,a)),de}var ve,dr;function lt(){if(dr)return ve;dr=1;const r=U();return ve=(t,s,a)=>r(s,t,a),ve}var Ie,vr;function ft(){if(vr)return Ie;vr=1;const r=U();return Ie=(t,s)=>r(t,s,!0),Ie}var $e,Ir;function Ke(){if(Ir)return $e;Ir=1;const r=j();return $e=(t,s,a)=>{const h=new r(t,a),u=new r(s,a);return h.compare(u)||h.compareBuild(u)},$e}var Le,$r;function ht(){if($r)return Le;$r=1;const r=Ke();return Le=(t,s)=>t.sort((a,h)=>r(a,h,s)),Le}var Ne,Lr;function Et(){if(Lr)return Ne;Lr=1;const r=Ke();return Ne=(t,s)=>t.sort((a,h)=>r(h,a,s)),Ne}var Se,Nr;function W(){if(Nr)return Se;Nr=1;const r=U();return Se=(t,s,a)=>r(t,s,a)>0,Se}var Oe,Sr;function Ze(){if(Sr)return Oe;Sr=1;const r=U();return Oe=(t,s,a)=>r(t,s,a)<0,Oe}var Ae,Or;function Kr(){if(Or)return Ae;Or=1;const r=U();return Ae=(t,s,a)=>r(t,s,a)===0,Ae}var Te,Ar;function Zr(){if(Ar)return Te;Ar=1;const r=U();return Te=(t,s,a)=>r(t,s,a)!==0,Te}var ge,Tr;function Je(){if(Tr)return ge;Tr=1;const r=U();return ge=(t,s,a)=>r(t,s,a)>=0,ge}var we,gr;function Qe(){if(gr)return we;gr=1;const r=U();return we=(t,s,a)=>r(t,s,a)<=0,we}var Pe,wr;function Jr(){if(wr)return Pe;wr=1;const r=Kr(),i=Zr(),t=W(),s=Je(),a=Ze(),h=Qe();return Pe=(f,n,R,e)=>{switch(n){case"===":return typeof f=="object"&&(f=f.version),typeof R=="object"&&(R=R.version),f===R;case"!==":return typeof f=="object"&&(f=f.version),typeof R=="object"&&(R=R.version),f!==R;case"":case"=":case"==":return r(f,R,e);case"!=":return i(f,R,e);case">":return t(f,R,e);case">=":return s(f,R,e);case"<":return a(f,R,e);case"<=":return h(f,R,e);default:throw new TypeError(`Invalid operator: ${n}`)}},Pe}var Ce,Pr;function pt(){if(Pr)return Ce;Pr=1;const r=j(),i=V(),{safeRe:t,t:s}=M();return Ce=(h,u)=>{if(h instanceof r)return h;if(typeof h=="number"&&(h=String(h)),typeof h!="string")return null;u=u||{};let f=null;if(!u.rtl)f=h.match(u.includePrerelease?t[s.COERCEFULL]:t[s.COERCE]);else{const m=u.includePrerelease?t[s.COERCERTLFULL]:t[s.COERCERTL];let L;for(;(L=m.exec(h))&&(!f||f.index+f[0].length!==h.length);)(!f||L.index+L[0].length!==f.index+f[0].length)&&(f=L),m.lastIndex=L.index+L[1].length+L[2].length;m.lastIndex=-1}if(f===null)return null;const n=f[2],R=f[3]||"0",e=f[4]||"0",o=u.includePrerelease&&f[5]?`-${f[5]}`:"",c=u.includePrerelease&&f[6]?`+${f[6]}`:"";return i(`${n}.${R}.${e}${o}${c}`,u)},Ce}var qe,Cr;function mt(){if(Cr)return qe;Cr=1;const r=V(),i=X(),t=j(),s=(f,n,R)=>{if(!i.RELEASE_TYPES.includes(n))return null;const e=a(f,R);return e&&h(e,n)},a=(f,n)=>{const R=f instanceof t?f.version:f;return r(R,n)},h=(f,n)=>{if(u(n))return f.version;switch(f.prerelease=[],n){case"major":f.minor=0,f.patch=0;break;case"minor":f.patch=0;break}return f.format()},u=f=>f.startsWith("pre");return qe=s,qe}var _e,qr;function Rt(){if(qr)return _e;qr=1;class r{constructor(){this.max=1e3,this.map=new Map}get(t){const s=this.map.get(t);if(s!==void 0)return this.map.delete(t),this.map.set(t,s),s}delete(t){return this.map.delete(t)}set(t,s){if(!this.delete(t)&&s!==void 0){if(this.map.size>=this.max){const h=this.map.keys().next().value;this.delete(h)}this.map.set(t,s)}return this}}return _e=r,_e}var De,_r;function F(){if(_r)return De;_r=1;const r=/\s+/g;class i{constructor(l,I){if(I=a(I),l instanceof i)return l.loose===!!I.loose&&l.includePrerelease===!!I.includePrerelease?l:new i(l.raw,I);if(l instanceof h)return this.raw=l.value,this.set=[[l]],this.formatted=void 0,this;if(this.options=I,this.loose=!!I.loose,this.includePrerelease=!!I.includePrerelease,this.raw=l.trim().replace(r," "),this.set=this.raw.split("||").map(v=>this.parseRange(v.trim())).filter(v=>v.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const v=this.set[0];if(this.set=this.set.filter(S=>!P(S[0])),this.set.length===0)this.set=[v];else if(this.set.length>1){for(const S of this.set)if(S.length===1&&D(S[0])){this.set=[S];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let l=0;l<this.set.length;l++){l>0&&(this.formatted+="||");const I=this.set[l];for(let v=0;v<I.length;v++)v>0&&(this.formatted+=" "),this.formatted+=I[v].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(l){l=l.replace(O,"");const v=((this.options.includePrerelease&&L)|(this.options.loose&&E))+":"+l,S=s.get(v);if(S)return S;const d=this.options.loose,$=d?n[e.HYPHENRANGELOOSE]:n[e.HYPHENRANGE];l=l.replace($,re(this.options.includePrerelease)),u("hyphen replace",l),l=l.replace(n[e.COMPARATORTRIM],o),u("comparator trim",l),l=l.replace(n[e.TILDETRIM],c),u("tilde trim",l),l=l.replace(n[e.CARETTRIM],m),u("caret trim",l);let g=l.split(" ").map(q=>y(q,this.options)).join(" ").split(/\s+/).map(q=>ee(q,this.options));d&&(g=g.filter(q=>(u("loose invalid filter",q,this.options),!!q.match(n[e.COMPARATORLOOSE])))),u("range list",g);const A=new Map,w=g.map(q=>new h(q,this.options));for(const q of w){if(P(q))return[q];A.set(q.value,q)}A.size>1&&A.has("")&&A.delete("");const b=[...A.values()];return s.set(v,b),b}intersects(l,I){if(!(l instanceof i))throw new TypeError("a Range is required");return this.set.some(v=>G(v,I)&&l.set.some(S=>G(S,I)&&v.every(d=>S.every($=>d.intersects($,I)))))}test(l){if(!l)return!1;if(typeof l=="string")try{l=new f(l,this.options)}catch{return!1}for(let I=0;I<this.set.length;I++)if(te(this.set[I],l,this.options))return!0;return!1}}De=i;const t=Rt(),s=new t,a=ze(),h=Y(),u=H(),f=j(),{safeRe:n,src:R,t:e,comparatorTrimReplace:o,tildeTrimReplace:c,caretTrimReplace:m}=M(),{FLAG_INCLUDE_PRERELEASE:L,FLAG_LOOSE:E}=X(),O=new RegExp(R[e.BUILD],"g"),P=p=>p.value==="<0.0.0-0",D=p=>p.value==="",G=(p,l)=>{let I=!0;const v=p.slice();let S=v.pop();for(;I&&v.length;)I=v.every(d=>S.intersects(d,l)),S=v.pop();return I},y=(p,l)=>(p=p.replace(n[e.BUILD],""),u("comp",p,l),p=x(p,l),u("caret",p),p=_(p,l),u("tildes",p),p=Z(p,l),u("xrange",p),p=Q(p,l),u("stars",p),p),T=p=>!p||p.toLowerCase()==="x"||p==="*",C=(p,l,I)=>T(p)&&!T(l)||T(l)&&I&&!T(I),_=(p,l)=>p.trim().split(/\s+/).map(I=>N(I,l)).join(" "),N=(p,l)=>{const I=l.loose?n[e.TILDELOOSE]:n[e.TILDE],v=l.includePrerelease?"-0":"";return p.replace(I,(S,d,$,g,A)=>{u("tilde",p,S,d,$,g,A);let w;return T(d)?w="":T($)?w=`>=${d}.0.0${v} <${+d+1}.0.0-0`:T(g)?w=`>=${d}.${$}.0${v} <${d}.${+$+1}.0-0`:A?(u("replaceTilde pr",A),w=`>=${d}.${$}.${g}-${A} <${d}.${+$+1}.0-0`):w=`>=${d}.${$}.${g} <${d}.${+$+1}.0-0`,u("tilde return",w),w})},x=(p,l)=>p.trim().split(/\s+/).map(I=>K(I,l)).join(" "),K=(p,l)=>{u("caret",p,l);const I=l.loose?n[e.CARETLOOSE]:n[e.CARET],v=l.includePrerelease?"-0":"";return p.replace(I,(S,d,$,g,A)=>{u("caret",p,S,d,$,g,A);let w;return T(d)?w="":T($)?w=`>=${d}.0.0${v} <${+d+1}.0.0-0`:T(g)?d==="0"?w=`>=${d}.${$}.0${v} <${d}.${+$+1}.0-0`:w=`>=${d}.${$}.0${v} <${+d+1}.0.0-0`:A?(u("replaceCaret pr",A),d==="0"?$==="0"?w=`>=${d}.${$}.${g}-${A} <${d}.${$}.${+g+1}-0`:w=`>=${d}.${$}.${g}-${A} <${d}.${+$+1}.0-0`:w=`>=${d}.${$}.${g}-${A} <${+d+1}.0.0-0`):(u("no pr"),d==="0"?$==="0"?w=`>=${d}.${$}.${g} <${d}.${$}.${+g+1}-0`:w=`>=${d}.${$}.${g} <${d}.${+$+1}.0-0`:w=`>=${d}.${$}.${g} <${+d+1}.0.0-0`),u("caret return",w),w})},Z=(p,l)=>(u("replaceXRanges",p,l),p.split(/\s+/).map(I=>J(I,l)).join(" ")),J=(p,l)=>{p=p.trim();const I=l.loose?n[e.XRANGELOOSE]:n[e.XRANGE];return p.replace(I,(v,S,d,$,g,A)=>{if(u("xRange",p,v,S,d,$,g,A),C(d,$,g))return p;const w=T(d),b=w||T($),q=b||T(g),k=q;return S==="="&&k&&(S=""),A=l.includePrerelease?"-0":"",w?S===">"||S==="<"?v="<0.0.0-0":v="*":S&&k?(b&&($=0),g=0,S===">"?(S=">=",b?(d=+d+1,$=0,g=0):($=+$+1,g=0)):S==="<="&&(S="<",b?d=+d+1:$=+$+1),S==="<"&&(A="-0"),v=`${S+d}.${$}.${g}${A}`):b?v=`>=${d}.0.0${A} <${+d+1}.0.0-0`:q&&(v=`>=${d}.${$}.0${A} <${d}.${+$+1}.0-0`),u("xRange return",v),v})},Q=(p,l)=>(u("replaceStars",p,l),p.trim().replace(n[e.STAR],"")),ee=(p,l)=>(u("replaceGTE0",p,l),p.trim().replace(n[l.includePrerelease?e.GTE0PRE:e.GTE0],"")),re=p=>(l,I,v,S,d,$,g,A,w,b,q,k)=>(T(v)?I="":T(S)?I=`>=${v}.0.0${p?"-0":""}`:T(d)?I=`>=${v}.${S}.0${p?"-0":""}`:$?I=`>=${I}`:I=`>=${I}${p?"-0":""}`,T(w)?A="":T(b)?A=`<${+w+1}.0.0-0`:T(q)?A=`<${w}.${+b+1}.0-0`:k?A=`<=${w}.${b}.${q}-${k}`:p?A=`<${w}.${b}.${+q+1}-0`:A=`<=${A}`,`${I} ${A}`.trim()),te=(p,l,I)=>{for(let v=0;v<p.length;v++)if(!p[v].test(l))return!1;if(l.prerelease.length&&!I.includePrerelease){for(let v=0;v<p.length;v++)if(u(p[v].semver),p[v].semver!==h.ANY&&p[v].semver.prerelease.length>0){const S=p[v].semver;if(S.major===l.major&&S.minor===l.minor&&S.patch===l.patch)return!0}return!1}return!0};return De}var ye,Dr;function Y(){if(Dr)return ye;Dr=1;const r=Symbol("SemVer ANY");class i{static get ANY(){return r}constructor(e,o){if(o=t(o),e instanceof i){if(e.loose===!!o.loose)return e;e=e.value}e=e.trim().split(/\s+/).join(" "),u("comparator",e,o),this.options=o,this.loose=!!o.loose,this.parse(e),this.semver===r?this.value="":this.value=this.operator+this.semver.version,u("comp",this)}parse(e){const o=this.options.loose?s[a.COMPARATORLOOSE]:s[a.COMPARATOR],c=e.match(o);if(!c)throw new TypeError(`Invalid comparator: ${e}`);this.operator=c[1]!==void 0?c[1]:"",this.operator==="="&&(this.operator=""),c[2]?this.semver=new f(c[2],this.options.loose):this.semver=r}toString(){return this.value}test(e){if(u("Comparator.test",e,this.options.loose),this.semver===r||e===r)return!0;if(typeof e=="string")try{e=new f(e,this.options)}catch{return!1}return h(e,this.operator,this.semver,this.options)}intersects(e,o){if(!(e instanceof i))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new n(e.value,o).test(this.value):e.operator===""?e.value===""?!0:new n(this.value,o).test(e.semver):(o=t(o),o.includePrerelease&&(this.value==="<0.0.0-0"||e.value==="<0.0.0-0")||!o.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&e.operator.startsWith(">")||this.operator.startsWith("<")&&e.operator.startsWith("<")||this.semver.version===e.semver.version&&this.operator.includes("=")&&e.operator.includes("=")||h(this.semver,"<",e.semver,o)&&this.operator.startsWith(">")&&e.operator.startsWith("<")||h(this.semver,">",e.semver,o)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))}}ye=i;const t=ze(),{safeRe:s,t:a}=M(),h=Jr(),u=H(),f=j(),n=F();return ye}var je,yr;function z(){if(yr)return je;yr=1;const r=F();return je=(t,s,a)=>{try{s=new r(s,a)}catch{return!1}return s.test(t)},je}var Ge,jr;function dt(){if(jr)return Ge;jr=1;const r=F();return Ge=(t,s)=>new r(t,s).set.map(a=>a.map(h=>h.value).join(" ").trim().split(" ")),Ge}var be,Gr;function vt(){if(Gr)return be;Gr=1;const r=j(),i=F();return be=(s,a,h)=>{let u=null,f=null,n=null;try{n=new i(a,h)}catch{return null}return s.forEach(R=>{n.test(R)&&(!u||f.compare(R)===-1)&&(u=R,f=new r(u,h))}),u},be}var Ue,br;function It(){if(br)return Ue;br=1;const r=j(),i=F();return Ue=(s,a,h)=>{let u=null,f=null,n=null;try{n=new i(a,h)}catch{return null}return s.forEach(R=>{n.test(R)&&(!u||f.compare(R)===1)&&(u=R,f=new r(u,h))}),u},Ue}var Fe,Ur;function $t(){if(Ur)return Fe;Ur=1;const r=j(),i=F(),t=W();return Fe=(a,h)=>{a=new i(a,h);let u=new r("0.0.0");if(a.test(u)||(u=new r("0.0.0-0"),a.test(u)))return u;u=null;for(let f=0;f<a.set.length;++f){const n=a.set[f];let R=null;n.forEach(e=>{const o=new r(e.semver.version);switch(e.operator){case">":o.prerelease.length===0?o.patch++:o.prerelease.push(0),o.raw=o.format();case"":case">=":(!R||t(o,R))&&(R=o);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${e.operator}`)}}),R&&(!u||t(u,R))&&(u=R)}return u&&a.test(u)?u:null},Fe}var Ve,Fr;function Lt(){if(Fr)return Ve;Fr=1;const r=F();return Ve=(t,s)=>{try{return new r(t,s).range||"*"}catch{return null}},Ve}var xe,Vr;function er(){if(Vr)return xe;Vr=1;const r=j(),i=Y(),{ANY:t}=i,s=F(),a=z(),h=W(),u=Ze(),f=Qe(),n=Je();return xe=(e,o,c,m)=>{e=new r(e,m),o=new s(o,m);let L,E,O,P,D;switch(c){case">":L=h,E=f,O=u,P=">",D=">=";break;case"<":L=u,E=n,O=h,P="<",D="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(a(e,o,m))return!1;for(let G=0;G<o.set.length;++G){const y=o.set[G];let T=null,C=null;if(y.forEach(_=>{_.semver===t&&(_=new i(">=0.0.0")),T=T||_,C=C||_,L(_.semver,T.semver,m)?T=_:O(_.semver,C.semver,m)&&(C=_)}),T.operator===P||T.operator===D||(!C.operator||C.operator===P)&&E(e,C.semver))return!1;if(C.operator===D&&O(e,C.semver))return!1}return!0},xe}var ke,xr;function Nt(){if(xr)return ke;xr=1;const r=er();return ke=(t,s,a)=>r(t,s,">",a),ke}var Xe,kr;function St(){if(kr)return Xe;kr=1;const r=er();return Xe=(t,s,a)=>r(t,s,"<",a),Xe}var Me,Xr;function Ot(){if(Xr)return Me;Xr=1;const r=F();return Me=(t,s,a)=>(t=new r(t,a),s=new r(s,a),t.intersects(s,a)),Me}var Be,Mr;function At(){if(Mr)return Be;Mr=1;const r=z(),i=U();return Be=(t,s,a)=>{const h=[];let u=null,f=null;const n=t.sort((c,m)=>i(c,m,a));for(const c of n)r(c,s,a)?(f=c,u||(u=c)):(f&&h.push([u,f]),f=null,u=null);u&&h.push([u,null]);const R=[];for(const[c,m]of h)c===m?R.push(c):!m&&c===n[0]?R.push("*"):m?c===n[0]?R.push(`<=${m}`):R.push(`${c} - ${m}`):R.push(`>=${c}`);const e=R.join(" || "),o=typeof s.raw=="string"?s.raw:String(s);return e.length<o.length?e:s},Be}var He,Br;function Tt(){if(Br)return He;Br=1;const r=F(),i=Y(),{ANY:t}=i,s=z(),a=U(),h=(o,c,m={})=>{if(o===c)return!0;o=new r(o,m),c=new r(c,m);let L=!1;e:for(const E of o.set){for(const O of c.set){const P=n(E,O,m);if(L=L||P!==null,P)continue e}if(L)return!1}return!0},u=[new i(">=0.0.0-0")],f=[new i(">=0.0.0")],n=(o,c,m)=>{if(o===c)return!0;if(o.length===1&&o[0].semver===t){if(c.length===1&&c[0].semver===t)return!0;m.includePrerelease?o=u:o=f}if(c.length===1&&c[0].semver===t){if(m.includePrerelease)return!0;c=f}const L=new Set;let E,O;for(const N of o)N.operator===">"||N.operator===">="?E=R(E,N,m):N.operator==="<"||N.operator==="<="?O=e(O,N,m):L.add(N.semver);if(L.size>1)return null;let P;if(E&&O){if(P=a(E.semver,O.semver,m),P>0)return null;if(P===0&&(E.operator!==">="||O.operator!=="<="))return null}for(const N of L){if(E&&!s(N,String(E),m)||O&&!s(N,String(O),m))return null;for(const x of c)if(!s(N,String(x),m))return!1;return!0}let D,G,y,T,C=O&&!m.includePrerelease&&O.semver.prerelease.length?O.semver:!1,_=E&&!m.includePrerelease&&E.semver.prerelease.length?E.semver:!1;C&&C.prerelease.length===1&&O.operator==="<"&&C.prerelease[0]===0&&(C=!1);for(const N of c){if(T=T||N.operator===">"||N.operator===">=",y=y||N.operator==="<"||N.operator==="<=",E){if(_&&N.semver.prerelease&&N.semver.prerelease.length&&N.semver.major===_.major&&N.semver.minor===_.minor&&N.semver.patch===_.patch&&(_=!1),N.operator===">"||N.operator===">="){if(D=R(E,N,m),D===N&&D!==E)return!1}else if(E.operator===">="&&!N.test(E.semver))return!1}if(O){if(C&&N.semver.prerelease&&N.semver.prerelease.length&&N.semver.major===C.major&&N.semver.minor===C.minor&&N.semver.patch===C.patch&&(C=!1),N.operator==="<"||N.operator==="<="){if(G=e(O,N,m),G===N&&G!==O)return!1}else if(O.operator==="<="&&!N.test(O.semver))return!1}if(!N.operator&&(O||E)&&P!==0)return!1}return!(E&&y&&!O&&P!==0||O&&T&&!E&&P!==0||_||C)},R=(o,c,m)=>{if(!o)return c;const L=a(o.semver,c.semver,m);return L>0?o:L<0||c.operator===">"&&o.operator===">="?c:o},e=(o,c,m)=>{if(!o)return c;const L=a(o.semver,c.semver,m);return L<0?o:L>0||c.operator==="<"&&o.operator==="<="?c:o};return He=h,He}var We,Hr;function gt(){if(Hr)return We;Hr=1;const r=M(),i=X(),t=j(),s=zr(),a=V(),h=tt(),u=st(),f=nt(),n=it(),R=at(),e=ot(),o=ut(),c=ct(),m=U(),L=lt(),E=ft(),O=Ke(),P=ht(),D=Et(),G=W(),y=Ze(),T=Kr(),C=Zr(),_=Je(),N=Qe(),x=Jr(),K=pt(),Z=mt(),J=Y(),Q=F(),ee=z(),re=dt(),te=vt(),p=It(),l=$t(),I=Lt(),v=er(),S=Nt(),d=St(),$=Ot(),g=At(),A=Tt();return We={parse:a,valid:h,clean:u,inc:f,diff:n,major:R,minor:e,patch:o,prerelease:c,compare:m,rcompare:L,compareLoose:E,compareBuild:O,sort:P,rsort:D,gt:G,lt:y,eq:T,neq:C,gte:_,lte:N,cmp:x,coerce:K,truncate:Z,Comparator:J,Range:Q,satisfies:ee,toComparators:re,maxSatisfying:te,minSatisfying:p,minVersion:l,validRange:I,outside:v,gtr:S,ltr:d,intersects:$,simplifyRange:g,subset:A,SemVer:t,re:r.re,src:r.src,tokens:r.t,SEMVER_SPEC_VERSION:i.SEMVER_SPEC_VERSION,RELEASE_TYPES:i.RELEASE_TYPES,compareIdentifiers:s.compareIdentifiers,rcompareIdentifiers:s.rcompareIdentifiers},We}var Wr=gt();const wt=[{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"}],Yr="auth",Mt=async r=>await r("Which auth provider?",wt,{default:Yr})??Yr,Bt="mail",Ht=[{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 1.x + Vite",label:"Solid",value:"auth-ui-solid"},{description:"Solid 2.0 + Vite (@solidjs/web)",label:"Solid 2",value:"auth-ui-solid-v2"},{description:"Analog",label:"Angular",value:"auth-ui-angular"}],Wt="auth-ui-react",Pt=r=>Object.hasOwn(r,"react-native")||Object.hasOwn(r,"@lunora/react-native")||Object.hasOwn(r,"expo"),Yt="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.",Ct=r=>{if(!(r===void 0||Wr.validRange(r)===null))return Wr.minVersion(r)?.major},qt=r=>Object.hasOwn(r,"@solidjs/web")||(Ct(r["solid-js"])??0)>=2,zt=r=>{const i=t=>Object.hasOwn(r,t);if(!Pt(r)){if(qt(r))return"auth-ui-solid-v2";if(i("@lunora/react"))return"auth-ui-react";if(i("@lunora/vue"))return"auth-ui-vue";if(i("@lunora/svelte"))return"auth-ui-svelte";if(i("@lunora/solid"))return"auth-ui-solid";if(i("@lunora/angular"))return"auth-ui-angular";if(i("react")||i("next"))return"auth-ui-react";if(i("vue")||i("nuxt"))return"auth-ui-vue";if(i("svelte")||i("@sveltejs/kit"))return"auth-ui-svelte";if(i("solid-js"))return"auth-ui-solid";if(i("@angular/core"))return"auth-ui-angular"}},Kt=r=>{const i=r.trim();if(i==="")return;const t=i.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"}},_t=/[^a-z0-9]+/u,Qr=(r,i,t)=>{let s=r.toLowerCase().split(_t).filter(Boolean).join("-").slice(0,t);return s.endsWith("-")&&(s=s.slice(0,-1)),s.length>=i?s:void 0},Dt="DB",yt="Name your D1 database (run `wrangler d1 create` to get its id, then put it in wrangler.jsonc)",et=r=>Qr(r,1,64),jt="lunora-db",Gt=r=>et(`${r}-db`)??jt,Zt=async(r,i)=>{const t=Gt(i);return et(await r(yt,{default:t,placeholder:t}))??t},Jt=(r,i)=>Ye(r,"d1_databases",{key:"binding",value:Dt},"database_name",i),bt="SEND_EMAIL",Qt="Verified destination email for production delivery (blank = set it later in wrangler.jsonc)",Ut=r=>{const i=r.trim();if(i.length===0||i.includes(" "))return!1;const t=i.indexOf("@");if(t<=0||t!==i.lastIndexOf("@"))return!1;const s=i.slice(t+1);return s.length>=3&&s.includes(".")&&!s.startsWith(".")&&!s.endsWith(".")},es=(r,i)=>{const t=r.trim();if(t!==""){if(!Ut(t)){i(`"${t}" doesn't look like an email — leaving the placeholder; set destination_address in wrangler.jsonc.`);return}return t}},rs=(r,i)=>Ye(r,"send_email",{key:"name",value:bt},"destination_address",i),Ft="UPLOADS",Vt="Name your R2 bucket (you can rename it in wrangler.jsonc later)",rt=r=>Qr(r,3,63),xt="lunora-uploads",kt=r=>rt(`${r}-uploads`)??xt,ts=async(r,i)=>{const t=kt(i);return rt(await r(Vt,{default:t,placeholder:t}))??t},ss=(r,i)=>Ye(r,"r2_buckets",{key:"binding",value:Ft},"bucket_name",i);export{Yt as A,Yr as D,Bt as E,Qt as M,et as a,Gt as b,Zt as c,kt as d,Mt as e,zt as f,Wt as g,Ht as h,Pt as i,wt as j,rs as k,Jt as l,Kt as n,ts as p,es as r,rt as s,ss as w};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{jsx as n,jsxs as u}from"react/jsx-runtime";import{isInteractive as p,ACCENT as x,LUNA_ART as ce,LUNA_NAME as le,LUNA_SIGNOFF as ae,BADGE_COLUMN_WIDTH as z,badgeWidth as J,badgeLead as se,padBadge as ue}from"@lunora/config";import{render as H}from"@visulima/tui";import{Box as d}from"@visulima/tui/components/box";import{Text as l}from"@visulima/tui/components/text";import{useApp as I}from"@visulima/tui/hooks/use-app";import{useInput as B}from"@visulima/tui/hooks/use-input";import{useInterval as de}from"@visulima/tui/hooks/use-interval";import{CommandPalette as fe}from"@visulima/tui-kit/command-palette";import{ConfirmInput as he}from"@visulima/tui-kit/confirm-input";import{SelectInput as me}from"@visulima/tui-kit/select-input";import{Spinner as pe}from"@visulima/tui-kit/spinner";import{TextInput as ve}from"@visulima/tui-kit/text-input";import{useState as S,useEffect as A}from"react";import{P as K}from"./prompt-cancelled-BvsNxg_Q.mjs";let j=!1;const V=()=>{j||(j=!0,process.getMaxListeners()<64&&process.setMaxListeners(64))},we=({children:e,onCancel:r})=>{const{exit:t}=I();return B((i,o)=>{o.ctrl&&i==="c"&&(r(),t())}),e},Q=e=>e instanceof Error?e:new Error(typeof e=="string"?e:"task failed"),Z=10,xe=8,ee=({spec:e})=>u(l,{children:[n(l,{children:se(e.text)}),n(l,{backgroundColor:e.bg,bold:!0,color:e.fg,children:ue(e.text)})]}),$=({badge:e,message:r})=>e===void 0?n(l,{bold:!0,children:r}):u(d,{children:[n(ee,{spec:e}),n(l,{bold:!0,children:` ${r}`})]}),re=2,T=" ".repeat(z-1),te=e=>" ".repeat(J(e)+1),Ce=e=>e===void 0?re:J(e)+1,D=({badge:e,children:r,message:t})=>u(d,{flexDirection:"column",children:[n($,{badge:e,message:t}),n(d,{flexDirection:"column",marginLeft:Ce(e),children:r})]}),g=({answer:e,badge:r,message:t})=>u(d,{flexDirection:"column",children:[n($,{badge:r,message:t}),e===""?null:n(l,{dimColor:!0,children:`${r===void 0?" ".repeat(re):te(r)}${e}`})]}),R=e=>{const{exit:r}=I(),[t,i]=S(void 0);return A(()=>{t!==void 0&&r()},[t,r]),{answer:t,submit:(o,c)=>{e(o),i(c)}}},Se=({children:e})=>{const{exit:r}=I();return A(()=>{r()},[r]),e},y=async e=>{V(),process.stdout.write(`
|
|
2
|
+
`);const r=H(n(Se,{children:e}));try{await r.waitUntilExit()}catch{}finally{r.unmount()}},Ze=async(e,r,t)=>{if(!p())return;const i=t===void 0||t===""?[]:t.split(`
|
|
3
|
+
`);await y(u(d,{flexDirection:"column",children:[n($,{badge:e,message:r}),i.map(o=>n(l,{dimColor:!0,children:`${te(e)}${o}`},o))]}))},G=async e=>{V(),process.stdout.write(`
|
|
4
|
+
`);const r={value:!1},t=H(n(we,{onCancel:()=>{r.value=!0},children:e}),{exitOnCtrlC:!1});try{await t.waitUntilExit()}finally{t.unmount()}if(r.value)throw new K},E=async(e,r)=>{let t=r;return await G(e(i=>{t=i})),t},ne=e=>e.description===void 0?e.label:`${e.label} — ${e.description}`,U=()=>{const{exit:e}=I();B((r,t)=>{t.escape&&e()})},Ie=({badge:e,finish:r,initialIndex:t,message:i,options:o})=>{const{answer:c,submit:s}=R(r);return U(),c!==void 0?n(g,{answer:c,badge:e,message:i}):n(D,{badge:e,message:i,children:n(me,{accentColor:x,initialIndex:t,items:o.map(a=>({key:a.value,label:ne(a),value:a.value})),limit:Z,onSelect:a=>{s(a.value,o.find(h=>h.value===a.value)?.label??a.value)}})})},be=({badge:e,finish:r,message:t,options:i})=>{const{exit:o}=I(),{answer:c,submit:s}=R(r);return c!==void 0?n(g,{answer:c,badge:e,message:t}):n(D,{badge:e,message:t,children:n(fe,{accentColor:x,autoFocus:!0,commands:i.map(a=>({description:a.description,id:a.value,label:a.label})),limit:Z,onCancel:()=>{o()},onSelect:a=>{s(a,i.find(h=>h.value===a)?.label??a)},placeholder:"Type to filter…"})})},er=async(e,r,t)=>{if(!p()||r.length===0)return t?.default;const{badge:i}=t??{};if(r.length>xe)return E(c=>n(be,{badge:i,finish:c,message:e,options:r}),t?.default);const o=t?.default===void 0?-1:r.findIndex(c=>c.value===t.default);return E(c=>n(Ie,{badge:i,finish:c,initialIndex:o>=0?o:void 0,message:e,options:r}),t?.default)},Te=({badge:e,defaultValue:r,finish:t,message:i,placeholder:o})=>{const{answer:c,submit:s}=R(t);return U(),c!==void 0?n(g,{answer:c,badge:e,message:i}):n(D,{badge:e,message:i,children:n(ve,{defaultValue:r,onSubmit:a=>{const h=a.trim()===""?r:a.trim();s(h,h)},placeholder:o})})},rr=async(e,r)=>{const t=r?.default??"";if(!p())return t;const{badge:i}=r??{};return E(o=>n(Te,{badge:i,defaultValue:t,finish:o,message:e,placeholder:r?.placeholder}),t)},ye=({badge:e,defaults:r,finish:t,message:i,options:o})=>{const{answer:c,submit:s}=R(t),[a,h]=S(0),[m,w]=S(()=>new Set(r));return U(),B((b,v)=>{if(!(c!==void 0||o.length===0)){if(v.upArrow)h(f=>(f-1+o.length)%o.length);else if(v.downArrow)h(f=>(f+1)%o.length);else if(b===" "){const f=o[a];f!==void 0&&w(C=>{const _=new Set(C);return _.has(f.value)?_.delete(f.value):_.add(f.value),_})}else if(v.return){const f=o.filter(C=>m.has(C.value));s(f.map(C=>C.value),f.length>0?f.map(C=>C.label).join(", "):"none")}}}),c!==void 0?n(g,{answer:c,badge:e,message:i}):n(D,{badge:e,message:i,children:u(d,{flexDirection:"column",children:[n(l,{dimColor:!0,children:"space toggles · enter confirms · esc cancels"}),o.map((b,v)=>{const f=v===a;return n(l,{color:f?x:void 0,children:`${f?"▸ ":" "}${m.has(b.value)?"◼":"◻"} ${ne(b)}`},b.value)})]})})},tr=async(e,r,t)=>{const i=t?.defaults??[];if(!p()||r.length===0)return[...i];const{badge:o}=t??{};return E(c=>n(ye,{badge:o,defaults:i,finish:c,message:e,options:r}),[...i])},Ne=({badge:e,defaultYes:r,finish:t,message:i})=>{const{answer:o,submit:c}=R(t);return o!==void 0?n(g,{answer:o,badge:e,message:i}):u(d,{children:[e===void 0?null:n(ee,{spec:e}),n(l,{bold:!0,children:e===void 0?`${i} `:` ${i} `}),n(he,{defaultChoice:r?"confirm":"cancel",onCancel:()=>{c(!1,"No")},onConfirm:()=>{c(!0,"Yes")}})]})},Ee=async(e,r)=>{const t=r?.defaultYes===!0;if(!p())return t;const{badge:i}=r??{};return E(o=>n(Ne,{badge:i,defaultYes:t,finish:o,message:e}),!1)},nr=()=>p()?e=>Ee(e,{defaultYes:!0}):()=>Promise.resolve(!1),W="#c8a8ff",L="#d9c8ff",$e="#6b5b9a",P=({moon:e,prefix:r,suffix:t})=>u(d,{children:[n(l,{color:W,dimColor:!0,children:r}),typeof e=="string"?n(l,{color:L,children:e}):e,t===void 0?null:n(l,{color:W,children:t})]}),X=({left:e,right:r})=>u(l,{color:L,children:[e,n(l,{color:$e,children:"●●"}),r]}),ge=()=>u(d,{flexDirection:"column",paddingX:1,children:[n(P,{moon:".-‐-.",prefix:"· ✦ · ",suffix:" ✦"}),n(P,{moon:n(X,{left:"/",right:"\\"}),prefix:" ✦ · ",suffix:" ·"}),n(P,{moon:n(X,{left:"\\",right:"/"}),prefix:" . ✦ · "}),u(d,{children:[n(l,{bold:!0,color:x,children:" lunora init "}),n(l,{dimColor:!0,children:"· moonrise sequence"}),n(l,{color:L})]})]}),or=async e=>{p()&&await y(u(d,{flexDirection:"column",children:[n(ge,{}),n(d,{paddingX:1,children:n(l,{dimColor:!0,children:e})})]}))},Re=({label:e})=>u(d,{children:[n(l,{color:x,children:n(pe,{type:"dots"})}),u(l,{children:[" ",e]})]}),ir=async(e,r)=>{if(!p())return r();V();const t=H(n(Re,{label:e}));try{return await r()}finally{t.unmount()}},cr=async()=>{p()&&await y(u(d,{paddingX:1,children:[n(l,{color:L,children:ce}),u(d,{flexDirection:"column",marginLeft:2,children:[n(l,{bold:!0,color:x,children:le}),n(l,{children:ae})]})]}))},_e="#06b6d4",M=" ".repeat(9),lr=async e=>{p()&&await y(n(l,{bold:!0,children:`${M}${e}`}))},ar=async e=>{p()&&await y(u(d,{children:[n(l,{color:_e,children:`${T}◼`}),n(l,{children:` ${e}`})]}))},sr=async(e,r,t,i)=>{p()&&await y(u(d,{flexDirection:"column",children:[n($,{badge:e,message:r}),n(d,{flexDirection:"column",marginTop:1,children:t.map(o=>u(l,{children:[`${M}${o.lead} `,n(l,{color:x,children:o.code}),o.tail??""]},o.lead))}),n(d,{flexDirection:"column",marginTop:1,children:i.map(o=>u(l,{children:[`${M}${o.lead} `,n(l,{color:x,children:o.code}),o.tail??""]},o.lead))})]}))},Y="#a855f7",oe="#06b6d4",N=[Y,"#9b51f6","#8a5cf6","#6f86f6","#4aa6ef","#2bb6dd","#12bcd0",oe],O=N.length-2,F=(e,r)=>Array.from({length:Math.max(0,e)},()=>r),q=[...F(N.length-1,Y),...N,...F(N.length-1,oe),...N.toReversed()],k=q.map((e,r)=>{const t=q.slice(r,r+O);return[...t,...F(O-t.length,Y)]}),Ae=" ".repeat(Math.max(0,z-O)),ie=({label:e})=>{const[r,t]=S(0);de(()=>{t(o=>(o+1)%k.length)},90);const i=k[r%k.length]??[];return u(l,{children:[Ae,i.map((o,c)=>n(l,{color:o,children:"█"},c)),` ${e}`]})},De=({label:e,status:r})=>r==="running"?n(l,{color:x,children:`${T}▶ ${e}`}):r==="failed"?n(l,{color:"red",children:`${T}✖ ${e}`}):r==="done"?n(l,{dimColor:!0,children:`${T}■ ${e}`}):n(l,{dimColor:!0,children:`${T}□ ${e}`}),Le=async(e,r,t)=>{const i=[];let o;for(const[c,s]of e.entries()){if(t())break;r(c,"running");try{i.push(await s.run()),r(c,"done")}catch(a){r(c,"failed"),o=a;break}}return{failure:o,results:i}},Pe=(e,r,t,i)=>{let o=!0;return Le(e,(s,a)=>{o&&r(h=>h.map((m,w)=>w===s?a:m))},()=>!o).then(({failure:s,results:a})=>{t(a,s),setTimeout(()=>{o&&i()},400)}).catch(s=>{t([],s)}),()=>{o=!1}},ke=({end:e,onSettle:r,onStart:t,start:i,tasks:o})=>{const{exit:c}=I(),[s,a]=S(()=>o.map(()=>"pending"));A(()=>(t(),Pe(o,a,r,c)),[c,r,t,o]);const h=s.length>0&&s.every(m=>m==="done");return u(d,{flexDirection:"column",children:[h?u(d,{children:[n(l,{bold:!0,color:"green",children:`${T}✔`}),n(l,{bold:!0,color:"green",children:` ${e}`})]}):n(ie,{label:i}),o.map((m,w)=>n(De,{label:m.label,status:s[w]??"pending"},m.label))]})},ur=async(e,r)=>{if(!p()){const s=[];for(const a of e)s.push(await a.run());return s}let t=[],i,o=()=>{},c;try{await G(n(ke,{end:r.end,onSettle:(s,a)=>{t=s,i=a,o()},onStart:()=>{c=new Promise(s=>{o=s})},start:r.start,tasks:e}))}catch(s){throw await c,s}if(i!==void 0)throw Q(i);return t},Me=async(e,r)=>{const t=[];let i;for(const[o,c]of e.entries()){r(o);try{t.push(await c.task())}catch(s){i=s;break}}return{failure:i,values:t}},Oe=({badge:e,done:r,onSettle:t,steps:i})=>{const{exit:o}=I(),[c,s]=S(0),[a,h]=S(!1);return A(()=>{let m=!0,w;return Me(i,v=>{m&&s(v)}).then(({failure:v,values:f})=>{if(m){if(v!==void 0){t({error:v,ok:!1}),o();return}h(!0),w=setTimeout(()=>{m&&(t({ok:!0,values:f}),o())},400)}}).catch(()=>{}),()=>{m=!1,w!==void 0&&clearTimeout(w)}},[o,t,i]),a?n($,{badge:e,message:r}):n(ie,{label:i[c]?.running??""})},dr=async(e,r,t)=>{if(!p()){const o=[];for(const c of r)o.push(await c.task());return o}let i;if(await G(n(Oe,{badge:e,done:t,onSettle:o=>{i=o},steps:r})),i===void 0)throw new K;if(!i.ok)throw Q(i.error);return i.values};export{rr as a,Ee as b,nr as c,cr as d,Ze as e,or as f,tr as g,lr as h,ar as i,sr as j,ur as k,dr as l,er as t,ir as w};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const i=e=>e.endsWith("S")?e.slice(0,-1):e,d=e=>e.replaceAll(/([a-z\d])([A-Z])/gu,"$1_$2").toUpperCase().split(/[_-]+/u).filter(t=>t.length>0),l=new Set(["CREDENTIAL","DSN","PASSPHRASE","PASSWD","PASSWORD","SECRET","TOKEN"]),S=["ACCESS_KEY","API_KEY","ENCRYPTION_KEY","PRIVATE_KEY","SIGNING_KEY"],m=new RegExp(`(?:${[...l,...S.map(e=>e.replaceAll("_",""))].join("|")})S?$`,"iu"),g=e=>d(e).some(t=>t==="PUBLIC"||t==="PUBLISHABLE"),h=e=>{if(g(e))return!1;const t=d(e);if(t.some(s=>l.has(i(s))))return!0;const r=i(t.join("_"));return S.some(s=>r===s||r.endsWith(`_${s}`))||m.test(e)},x=e=>{switch(e){case"boolean":return"boolean";case"date":case"number":case"timestamp":return"number";case"id":case"literal":case"string":return"string";default:return}},A=/already (?:exists|indexed)|duplicate/iu,u=e=>["vectorize","create-metadata-index",e.index,`--property-name=${e.property}`,`--type=${e.type}`],_=async(e,t)=>{try{return await e(t)}catch(r){return{code:1,stderr:r instanceof Error?r.message:String(r)}}},I=async e=>{const{cwd:t,entries:r,exec:s,logger:E,spawner:p}=e,a=[];for(const n of r){const o=await _(p,{args:[...s.args,...u(n)],captureStderr:!0,command:s.command,cwd:t,stdoutToStderr:!0});if(o.code===0){a.push({entry:n,status:"created"});continue}const c=`${o.stderr??""}${o.stdout??""}`;if(A.test(c)){a.push({entry:n,status:"exists"});continue}a.push({entry:n,error:c.trim()||`exit code ${String(o.code)}`,status:"failed"}),E.warn(`could not create the Vectorize metadata index for "${n.property}" on "${n.index}" — filters on that property will match nothing until it exists. Run: wrangler ${u(n).join(" ")}`)}return a};export{u as c,I as e,h as i,x as m};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{findWranglerFile as a,readWranglerJsonc as t}from"@lunora/config/cloudflare";const i=n=>{const e=a(n);if(!e)return;const{parsed:r}=t(e);return typeof r?.name=="string"&&r.name.length>0?r.name:void 0};export{i as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolveDeployDriver as c,resolveProjectTarget as d,execArgsFor as l,detectPackageManager as i}from"@lunora/config";import{defaultSpawner as m}from"./createRecordingSpawner-sS7LEN7x.mjs";const u=async(e,t,o)=>{try{const r=await m({args:t,captureStderr:!0,captureStdoutSilently:!0,command:e,cwd:o});return{code:r.code,stderr:r.stderr??"",stdout:r.stdout??""}}catch(r){return{code:1,stderr:r instanceof Error?r.message:String(r),stdout:""}}},f=e=>{let t;try{t=JSON.parse(e)}catch{return}return Array.isArray(t)?[...t.map(r=>r!==null&&typeof r=="object"?r.name:void 0).filter(r=>typeof r=="string"&&r.length>0)].toSorted((r,n)=>r.localeCompare(n)):void 0},y=async e=>{const t=c(d(e.cwd)).toolchain?.secretList({environment:e.env,temporary:e.temporary});if(t===void 0)return{error:"deploy target has no command-line toolchain",names:[],ok:!1};const{args:o,command:r}=l(i(e.cwd),t.tool,t.args),a=await(e.runner??u)(r,o,e.cwd);if(a.code!==0)return{error:a.stderr.trim()||`wrangler secret list exited ${String(a.code)}`,names:[],ok:!1};const s=f(a.stdout);return s===void 0?{error:"could not parse `wrangler secret list --format json` output",names:[],ok:!1}:{names:s,ok:!0}};export{y as l};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/cli",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
4
|
-
"description": "The Lunora CLI: init, dev, deploy, codegen,
|
|
3
|
+
"version": "1.0.0-alpha.321",
|
|
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",
|
|
7
7
|
"cli",
|
|
@@ -51,27 +51,47 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@bomb.sh/tab": "0.0.
|
|
55
|
-
"@lunora/
|
|
56
|
-
"@lunora/
|
|
57
|
-
"@lunora/
|
|
58
|
-
"@lunora/
|
|
59
|
-
"@lunora/
|
|
60
|
-
"@
|
|
61
|
-
"@
|
|
62
|
-
"@
|
|
63
|
-
"@
|
|
64
|
-
"@
|
|
65
|
-
"@visulima/
|
|
66
|
-
"@visulima/
|
|
67
|
-
"
|
|
68
|
-
"
|
|
54
|
+
"@bomb.sh/tab": "0.0.22",
|
|
55
|
+
"@lunora/advisor": "1.0.0-alpha.169",
|
|
56
|
+
"@lunora/bindings": "1.0.0-alpha.82",
|
|
57
|
+
"@lunora/codegen": "1.0.0-alpha.235",
|
|
58
|
+
"@lunora/config": "1.0.0-alpha.279",
|
|
59
|
+
"@lunora/container": "1.0.0-alpha.63",
|
|
60
|
+
"@lunora/d1": "1.0.0-alpha.149",
|
|
61
|
+
"@lunora/errors": "1.0.0-alpha.47",
|
|
62
|
+
"@lunora/mcp": "1.0.0-alpha.195",
|
|
63
|
+
"@lunora/runtime": "1.0.0-alpha.161",
|
|
64
|
+
"@lunora/seed": "1.0.0-alpha.167",
|
|
65
|
+
"@visulima/cerebro": "3.1.1",
|
|
66
|
+
"@visulima/error": "6.1.0",
|
|
67
|
+
"@visulima/fs": "6.0.7",
|
|
68
|
+
"@visulima/pail": "5.0.0",
|
|
69
|
+
"@visulima/path": "4.0.0",
|
|
70
|
+
"@visulima/spinner": "1.0.1",
|
|
71
|
+
"@visulima/tui": "4.0.7",
|
|
72
|
+
"@visulima/tui-kit": "1.0.10",
|
|
73
|
+
"adm-zip": "0.6.1",
|
|
74
|
+
"csv-parse": "7.0.2",
|
|
75
|
+
"giget": "3.3.1",
|
|
69
76
|
"jsonc-parser": "^3.3.1",
|
|
70
|
-
"magic-string": "^
|
|
71
|
-
"react": "^19.2.
|
|
77
|
+
"magic-string": "^1.2.3",
|
|
78
|
+
"react": "^19.2.8",
|
|
72
79
|
"react-reconciler": "^0.33.0",
|
|
80
|
+
"smol-toml": "1.8.0",
|
|
73
81
|
"ts-morph": "^28.0.0"
|
|
74
82
|
},
|
|
83
|
+
"peerDependencies": {
|
|
84
|
+
"mysql2": "*",
|
|
85
|
+
"pg": "*"
|
|
86
|
+
},
|
|
87
|
+
"peerDependenciesMeta": {
|
|
88
|
+
"mysql2": {
|
|
89
|
+
"optional": true
|
|
90
|
+
},
|
|
91
|
+
"pg": {
|
|
92
|
+
"optional": true
|
|
93
|
+
}
|
|
94
|
+
},
|
|
75
95
|
"engines": {
|
|
76
96
|
"node": "^22.15.0 || >=24.11.0"
|
|
77
97
|
}
|
package/skills/README.md
CHANGED
|
@@ -9,21 +9,39 @@ framework correctly. They ship inside `@lunora/cli` and are discovered by the
|
|
|
9
9
|
Each skill is a `SKILL.md` with YAML frontmatter (`name`, `description`) in its
|
|
10
10
|
own directory:
|
|
11
11
|
|
|
12
|
-
| Skill
|
|
13
|
-
|
|
|
14
|
-
| `lunora`
|
|
15
|
-
| `lunora-quickstart`
|
|
16
|
-
| `lunora-functions`
|
|
17
|
-
| `lunora-realtime`
|
|
18
|
-
| `lunora-setup-auth`
|
|
19
|
-
| `lunora-setup-mail`
|
|
20
|
-
| `lunora-setup-storage`
|
|
21
|
-
| `lunora-setup-scheduler`
|
|
22
|
-
| `lunora-
|
|
23
|
-
| `lunora-
|
|
24
|
-
| `lunora-
|
|
25
|
-
| `lunora-
|
|
12
|
+
| Skill | Use for |
|
|
13
|
+
| -------------------------------- | ---------------------------------------------------------------------------- |
|
|
14
|
+
| `lunora` | Router — start here, then switch to the matching skill below. |
|
|
15
|
+
| `lunora-quickstart` | `lunora init` / adding Lunora to an app + first round-trip. |
|
|
16
|
+
| `lunora-functions` | Core authoring rules — schema, validators, query/mutation/action, `ctx.db`. |
|
|
17
|
+
| `lunora-realtime` | Client reactivity — live hooks, optimistic updates, `@lunora/db`. |
|
|
18
|
+
| `lunora-setup-auth` | Authentication via `lunora registry add auth` (+ providers). |
|
|
19
|
+
| `lunora-setup-mail` | Transactional email via `lunora registry add mail` — `sendEmail` actions. |
|
|
20
|
+
| `lunora-setup-storage` | R2 file storage via `lunora registry add storage` — signed upload/download. |
|
|
21
|
+
| `lunora-setup-scheduler` | Deferred (`ctx.scheduler`) + cron jobs (`lunora registry add crons`). |
|
|
22
|
+
| `lunora-setup-hyperdrive` | Existing Postgres/MySQL from an action — `ctx.sql`, non-reactive. |
|
|
23
|
+
| `lunora-setup-hyperdrive-global` | Postgres/MySQL as a reactive `.global()` backend; D1 → Hyperdrive migration. |
|
|
24
|
+
| `lunora-create-package` | Building a reusable registry item or `@lunora/*` package. |
|
|
25
|
+
| `lunora-migration-helper` | Schema/data migrations, `.global()` DDL flow, the drift gate. |
|
|
26
|
+
| `lunora-deploy` | Deploying to Cloudflare — wrangler bindings, secrets, the gate. |
|
|
27
|
+
| `lunora-performance-audit` | `lunora insights`, scans, indexes, OCC conflicts, sharding/`.global()`. |
|
|
26
28
|
|
|
27
|
-
These are mirrored into `.agents/skills/` and `.claude/skills
|
|
28
|
-
so agents working inside this repo pick them up directly
|
|
29
|
-
|
|
29
|
+
These are mirrored (via symlinks) into `.agents/skills/` and `.claude/skills/`,
|
|
30
|
+
so agents working inside this repo pick them up directly, and into
|
|
31
|
+
`plugins/lunora/skills/`, the payload of the Claude Code / Codex plugin. The
|
|
32
|
+
source of truth lives here so the published `@lunora/cli` tarball carries them —
|
|
33
|
+
`lunora rules install` copies this directory into a consumer project.
|
|
34
|
+
|
|
35
|
+
**Adding a skill?** Create it here, then mirror it through all three hops:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
ln -s ../../packages/cli/skills/<name> .agents/skills/<name>
|
|
39
|
+
ln -s ../../.agents/skills/<name> .claude/skills/<name>
|
|
40
|
+
ln -s ../../../packages/cli/skills/<name> plugins/lunora/skills/<name>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`scripts/check-skill-mirrors.js` (run on every `pnpm install`) fails if a mirror
|
|
44
|
+
is missing, dangling, or has become a real directory — a copied directory keeps
|
|
45
|
+
resolving while it silently drifts from the source, so it is treated as an
|
|
46
|
+
error rather than a warning. Forget a hop and it prints the exact `ln -s` for
|
|
47
|
+
the one you missed, so `pnpm install` is the shortest path to the right command.
|
package/skills/lunora/SKILL.md
CHANGED
|
@@ -14,8 +14,9 @@ Lunora exposes a Convex-style functional API (`defineSchema`, `query`,
|
|
|
14
14
|
`mutation`, `action`) on top of Cloudflare Workers and Durable Objects. State
|
|
15
15
|
lives in a per-app `ShardDO` (SQLite, OCC, hibernated WebSocket subscriptions)
|
|
16
16
|
by default; `.shardBy(key)` partitions it across many DOs and `.global()`
|
|
17
|
-
replicates a table to D1
|
|
18
|
-
drives codegen and end-to-end
|
|
17
|
+
replicates a table to D1 — or to Postgres/MySQL over Hyperdrive — for
|
|
18
|
+
low-latency cross-region reads. A Vite plugin drives codegen and end-to-end
|
|
19
|
+
type sync.
|
|
19
20
|
|
|
20
21
|
If a more specific Lunora skill clearly matches the request, use that instead.
|
|
21
22
|
|
|
@@ -47,12 +48,13 @@ After codegen is green, use the most specific Lunora skill for the task:
|
|
|
47
48
|
- Wiring live data into a client (hooks, optimistic updates): `lunora-realtime`
|
|
48
49
|
- Authentication setup (email/password, OAuth, magic link, OTP):
|
|
49
50
|
`lunora-setup-auth`
|
|
50
|
-
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
- Transactional email: `lunora-setup-mail`
|
|
52
|
+
- R2 file storage (signed upload/download): `lunora-setup-storage`
|
|
53
|
+
- Deferred work (`ctx.scheduler`) and cron jobs: `lunora-setup-scheduler`
|
|
54
|
+
- Querying an **existing** Postgres/MySQL database from an action (`ctx.sql`,
|
|
55
|
+
non-reactive): `lunora-setup-hyperdrive`
|
|
56
|
+
- Using Postgres/MySQL as a **reactive `.global()` backend**, or migrating a D1
|
|
57
|
+
`.global()` dataset onto it: `lunora-setup-hyperdrive-global`
|
|
56
58
|
- Building a reusable capability — a registry item or an `@lunora/*` package:
|
|
57
59
|
`lunora-create-package`
|
|
58
60
|
- Planning or running a schema/data migration: `lunora-migration-helper`
|
|
@@ -61,9 +63,119 @@ After codegen is green, use the most specific Lunora skill for the task:
|
|
|
61
63
|
- Investigating performance, scan, or write-conflict issues:
|
|
62
64
|
`lunora-performance-audit`
|
|
63
65
|
|
|
66
|
+
**Reviewing or auditing existing `lunora/` code** has no skill of its own,
|
|
67
|
+
because two commands do the work mechanically — run them before reading
|
|
68
|
+
anything:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
lunora verify # wrangler config + codegen dry-run + tsc --noEmit
|
|
72
|
+
lunora advisor # the static + runtime lint set, scored per procedure
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`lunora advisor` is the security/quality review: RLS coverage, ownership and
|
|
76
|
+
identity checks, fail-open guards, input validators, unindexed reads,
|
|
77
|
+
non-deterministic calls in queries, SQL interpolation, and leaked secrets. It
|
|
78
|
+
prints each finding's own lint id and category, so read its output rather than
|
|
79
|
+
grepping for rule names. Use `--entry <file>#<export>` to inspect one procedure
|
|
80
|
+
and `--min-score` / `--baseline` to gate CI. Only after it is clean is a by-hand
|
|
81
|
+
pass over `lunora-functions` worth the tokens.
|
|
82
|
+
|
|
64
83
|
If one of those clearly matches the user's goal, switch to it instead of staying
|
|
65
84
|
in this skill.
|
|
66
85
|
|
|
86
|
+
## Capabilities Without a Dedicated Skill
|
|
87
|
+
|
|
88
|
+
Most other capabilities install as a **registry item** — `lunora registry add
|
|
89
|
+
<item>` scaffolds the `lunora/` glue, wrangler bindings, and env vars, then
|
|
90
|
+
prints post-install steps. Browse with `lunora registry list`; preview with
|
|
91
|
+
`lunora registry view <item>`. Read the installed item's README, and the
|
|
92
|
+
package's `docs/` for the API.
|
|
93
|
+
|
|
94
|
+
| Goal | Install / package |
|
|
95
|
+
| --------------------------------------------- | ------------------------------------------------------------ |
|
|
96
|
+
| Background jobs on Cloudflare Queues | `registry add queue` → `@lunora/queue` (`ctx.queues`) |
|
|
97
|
+
| Durable multi-step workflows | `registry add workflow` → `@lunora/workflow` (`ctx.runStep`) |
|
|
98
|
+
| Durable AI agents (tool loops, HITL, memory) | `@lunora/agent` (`defineAgent`) |
|
|
99
|
+
| Workers AI / RAG | `registry add ai` → `@lunora/ai` (`ctx.ai`, `defineRag`) |
|
|
100
|
+
| Feature flags (OpenFeature) | `registry add flags` → `@lunora/flags` (`ctx.flags`) |
|
|
101
|
+
| Payments (Stripe / Polar) | `registry add payment` → `@lunora/payment` |
|
|
102
|
+
| Rate limiting | `registry add ratelimit` → `@lunora/ratelimit` |
|
|
103
|
+
| Headless browser (action-only) | `registry add browser` → `@lunora/browser` (`ctx.browser`) |
|
|
104
|
+
| Cloudflare Containers | `@lunora/container` (`defineContainer`, `ctx.containers`) |
|
|
105
|
+
| Presence / who's-here | `registry add presence` |
|
|
106
|
+
| Cloudflare Access (Zero Trust) identity | `registry add cloudflare-access` |
|
|
107
|
+
| Backup / restore | `registry add backup` |
|
|
108
|
+
| Testing (in-memory harness, agent doubles) | `@lunora/testing` (`lunoraTest`) |
|
|
109
|
+
| Deterministic seed data | `@lunora/seed` + `lunora seed` |
|
|
110
|
+
| Local-first replica / offline mirror | `@lunora/replica` |
|
|
111
|
+
| Exposing the deployment to AI agents over MCP | `@lunora/mcp` |
|
|
112
|
+
|
|
113
|
+
Scaffolding inside this repo uses `vis generate lunora-<kind>` — `query`,
|
|
114
|
+
`mutation`, `action`, `http-route`, `table`, `cron`, `container`, `workflow`,
|
|
115
|
+
`queue`, `step`, `agent`, `flags`, `collections`, `package` (`vis generate
|
|
116
|
+
--list` for the full set). Most take a name: **always** pass it as
|
|
117
|
+
`--name=value`, since vis parses a space-separated `--name foo` as `--name=true`
|
|
118
|
+
plus a stray positional. `lunora-flags` and `lunora-collections` are singletons
|
|
119
|
+
and take no name.
|
|
120
|
+
|
|
121
|
+
## Exposing a Deployment Over MCP
|
|
122
|
+
|
|
123
|
+
`@lunora/mcp` puts a **running deployment** behind an MCP server (`lunora-mcp`),
|
|
124
|
+
so an agent can introspect and call it. It needs `LUNORA_URL` and
|
|
125
|
+
`LUNORA_ADMIN_TOKEN` — the admin bearer, which cannot be scoped down, because
|
|
126
|
+
every tool reads admin-gated routes. The safety story is therefore the gates
|
|
127
|
+
below, never the credential.
|
|
128
|
+
|
|
129
|
+
Always advertised, no gate:
|
|
130
|
+
|
|
131
|
+
| Tool | What it does |
|
|
132
|
+
| ---------------------------- | ---------------------------------------------------------------------- |
|
|
133
|
+
| `lunora_list_functions` | The deployment's public functions and their kinds. |
|
|
134
|
+
| `lunora_list_tables` | `.global()` tables with row counts. |
|
|
135
|
+
| `lunora_get_function_schema` | One function's argument descriptors, so a caller can build valid args. |
|
|
136
|
+
| `lunora_run_query` | Runs a query. Read-only. |
|
|
137
|
+
| `lunora_explain_error` | Explains an error `code` or raw `message` from the static catalog. |
|
|
138
|
+
|
|
139
|
+
`lunora_explain_error` touches no deployment and needs no token — the catalog is
|
|
140
|
+
compiled into `@lunora/errors`. Reach for it before guessing at what a Lunora
|
|
141
|
+
error means.
|
|
142
|
+
|
|
143
|
+
**Three env gates hold back everything else.** Each one both omits the tool from
|
|
144
|
+
the advertised list _and_ refuses it at dispatch, so the guarantee does not
|
|
145
|
+
depend on the client behaving:
|
|
146
|
+
|
|
147
|
+
- `LUNORA_MCP_ALLOW_WRITES` → `lunora_run_mutation`, `lunora_run_action`.
|
|
148
|
+
- `LUNORA_MCP_ALLOW_OBSERVABILITY` → the five `lunora_get_*` tools (logs,
|
|
149
|
+
issues, advisories, query insights, migration status). Read-only, but they
|
|
150
|
+
return production log lines and error messages — user data that lands at the
|
|
151
|
+
model provider.
|
|
152
|
+
- `LUNORA_MCP_ALLOW_DATA_READS` → `lunora_find_related`. **It returns raw table
|
|
153
|
+
rows read through the deployment's admin writer, with RLS policies and column
|
|
154
|
+
masks bypassed**, plus everything reachable within `depth` hops. It is
|
|
155
|
+
deliberately not folded into the observability gate: enabling log reading for
|
|
156
|
+
debugging must not silently also hand over every row.
|
|
157
|
+
|
|
158
|
+
All three default to **off**. Set one only when the answer to "may a model see
|
|
159
|
+
this?" is yes.
|
|
160
|
+
|
|
161
|
+
### Writes are a two-step handshake
|
|
162
|
+
|
|
163
|
+
Past `LUNORA_MCP_ALLOW_WRITES`, each individual write still needs its own
|
|
164
|
+
confirmation. The first `lunora_run_mutation` / `lunora_run_action` call does
|
|
165
|
+
**not** execute — it returns `status: "action_required"` carrying
|
|
166
|
+
`proposedAction`, an `actionDigest`, and the `expiresAt` it is valid until (ten
|
|
167
|
+
minutes). The client shows that to a human, then calls the same tool again with
|
|
168
|
+
the identical `functionPath`, `args` and `shardKey`, plus `confirmed: true` and
|
|
169
|
+
that digest.
|
|
170
|
+
|
|
171
|
+
Editing anything produces a different digest and needs a fresh proposal; an
|
|
172
|
+
expired digest is refused rather than quietly re-proposed. Be precise about what
|
|
173
|
+
this buys: the digest binds the **call**, proving the write that runs is exactly
|
|
174
|
+
the one proposed on this deployment inside the window. It does **not** prove a
|
|
175
|
+
human ever saw it — an MCP server has no channel to a person, and a client that
|
|
176
|
+
asks nobody can echo the digest straight back. Enabling writes is the operator
|
|
177
|
+
asserting that the client on the other end does the asking.
|
|
178
|
+
|
|
67
179
|
## Core Mental Model
|
|
68
180
|
|
|
69
181
|
- **Functions** live in `lunora/*.ts` and are one of `query` (reactive read),
|
|
@@ -75,7 +187,9 @@ in this skill.
|
|
|
75
187
|
- **Reads go through indexes.** Prefer `ctx.db.query("t").withIndex(...)` over
|
|
76
188
|
`.filter(...)`; declare the index with `.index("by_x", ["x"])`.
|
|
77
189
|
- **Clients** subscribe over WebSocket. `useQuery`/`useMutation` (React, Vue,
|
|
78
|
-
Solid, Svelte) re-render the moment a
|
|
190
|
+
Solid, Svelte, React Native; signals in Angular) re-render the moment a
|
|
191
|
+
mutation changes the queried rows. Subscriptions run under the socket's
|
|
192
|
+
verified identity, so `rls()` / `ctx.auth` apply to live updates too.
|
|
79
193
|
|
|
80
194
|
## When Not to Use
|
|
81
195
|
|
|
@@ -73,8 +73,8 @@ A registry item is a directory under `registry/<name>/` with three files:
|
|
|
73
73
|
Add an entry to `registry/index.json`, then rebuild and check the index:
|
|
74
74
|
|
|
75
75
|
```bash
|
|
76
|
-
lunora registry build
|
|
77
|
-
lunora registry build --check
|
|
76
|
+
lunora registry build --from ./registry # regenerate registry/index.json
|
|
77
|
+
lunora registry build --from ./registry --check # verify the index is up to date (CI)
|
|
78
78
|
lunora registry view <name> # preview what `add` would do
|
|
79
79
|
lunora registry add <name> # install into the current project
|
|
80
80
|
```
|
|
@@ -122,7 +122,8 @@ declaration the user must add so codegen wires the typed surface.
|
|
|
122
122
|
- [ ] Chose the right shape (registry item, workspace package, or both).
|
|
123
123
|
- [ ] Registry item: `registry.json` + `index.ts` + `README.md` authored;
|
|
124
124
|
`bindings`/`envVars`/`requires`/`files` correct.
|
|
125
|
-
- [ ] `lunora registry build` run;
|
|
125
|
+
- [ ] `lunora registry build --from ./registry` run; the same command with
|
|
126
|
+
`--check` passes.
|
|
126
127
|
- [ ] Workspace package: scaffolded via `vis generate lunora-package`; no `.js`
|
|
127
128
|
extensions, no mixed default+named exports, catalog versions used.
|
|
128
129
|
- [ ] `lint:types` and `test` pass for the new package.
|