@lunora/cli 1.0.0-alpha.2 → 1.0.0-alpha.200

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/LICENSE.md +33 -0
  2. package/README.md +1 -1
  3. package/__assets__/package-og.svg +1 -1
  4. package/dist/bin.mjs +2 -10
  5. package/dist/index.d.mts +797 -358
  6. package/dist/index.d.ts +797 -358
  7. package/dist/index.mjs +1 -19
  8. package/dist/packem_chunks/handler.mjs +1 -76
  9. package/dist/packem_chunks/handler10.mjs +2 -22
  10. package/dist/packem_chunks/handler11.mjs +2 -192
  11. package/dist/packem_chunks/handler12.mjs +1 -131
  12. package/dist/packem_chunks/handler13.mjs +1 -65
  13. package/dist/packem_chunks/handler14.mjs +1 -58
  14. package/dist/packem_chunks/handler15.mjs +1 -79
  15. package/dist/packem_chunks/handler16.mjs +3 -41
  16. package/dist/packem_chunks/handler17.mjs +1 -105
  17. package/dist/packem_chunks/handler18.mjs +1 -172
  18. package/dist/packem_chunks/handler19.mjs +7 -89
  19. package/dist/packem_chunks/handler2.mjs +2 -114
  20. package/dist/packem_chunks/handler20.mjs +2 -94
  21. package/dist/packem_chunks/handler21.mjs +2 -311
  22. package/dist/packem_chunks/handler22.mjs +3 -0
  23. package/dist/packem_chunks/handler23.mjs +3 -0
  24. package/dist/packem_chunks/handler24.mjs +1 -0
  25. package/dist/packem_chunks/handler25.mjs +99 -0
  26. package/dist/packem_chunks/handler26.mjs +10 -0
  27. package/dist/packem_chunks/handler3.mjs +1 -204
  28. package/dist/packem_chunks/handler4.mjs +1 -33
  29. package/dist/packem_chunks/handler5.mjs +1 -49
  30. package/dist/packem_chunks/handler6.mjs +1 -91
  31. package/dist/packem_chunks/handler7.mjs +3 -42
  32. package/dist/packem_chunks/handler8.mjs +1 -174
  33. package/dist/packem_chunks/handler9.mjs +1 -16
  34. package/dist/packem_chunks/planDevCommand.mjs +7 -543
  35. package/dist/packem_chunks/runCodegenCommand.mjs +4 -52
  36. package/dist/packem_chunks/runDeployCommand.mjs +1 -504
  37. package/dist/packem_chunks/runInitCommand.mjs +1141 -565
  38. package/dist/packem_chunks/runMigrateGenerateCommand.mjs +9 -395
  39. package/dist/packem_chunks/runResetCommand.mjs +1 -41
  40. package/dist/packem_chunks/runRpcCommand.mjs +1 -68
  41. package/dist/packem_shared/COMMANDS-su5nmqYP.mjs +1 -0
  42. package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Nf7GsE6v.mjs +1 -0
  43. package/dist/packem_shared/admin-token-rxXZbVMZ.mjs +1 -0
  44. package/dist/packem_shared/admin-url-Cil3Or6N.mjs +1 -0
  45. package/dist/packem_shared/advisory-gate-Cl8IEFIj.mjs +1 -0
  46. package/dist/packem_shared/api-spec-lYyq4vL6.mjs +1 -0
  47. package/dist/packem_shared/buildRegistryIndex-Zi3bBqpc.mjs +1 -0
  48. package/dist/packem_shared/cli-RB-BoDnW.mjs +3 -0
  49. package/dist/packem_shared/codegen-error-C04fGQjf.mjs +3 -0
  50. package/dist/packem_shared/command-DwC11Cwe.mjs +1 -0
  51. package/dist/packem_shared/commands-BOgN2nF7.mjs +19 -0
  52. package/dist/packem_shared/createLogger-hGafwf-3.mjs +2 -0
  53. package/dist/packem_shared/createRecordingSpawner-DJlNacZ6.mjs +1 -0
  54. package/dist/packem_shared/deploy-target-D9GPy_tq.mjs +1 -0
  55. package/dist/packem_shared/detect-package-manager-DSaAqRof.mjs +1 -0
  56. package/dist/packem_shared/diffSnapshots-CIOFQN_a.mjs +5 -0
  57. package/dist/packem_shared/docker-DpVxvYpL.mjs +1 -0
  58. package/dist/packem_shared/health-probe-QEPfFdgJ.mjs +1 -0
  59. package/dist/packem_shared/import-CrVGrOt3.mjs +12 -0
  60. package/dist/packem_shared/insertSchemaExtension-DY4pA8wE.mjs +8 -0
  61. package/dist/packem_shared/lint-ignore-report-CDbcbtv7.mjs +2 -0
  62. package/dist/packem_shared/open-url-EnKy--w-.mjs +1 -0
  63. package/dist/packem_shared/output-format-DfogXx0p.mjs +2 -0
  64. package/dist/packem_shared/parseManifest-CwPTKdtS.mjs +1 -0
  65. package/dist/packem_shared/path-containment-CgxYZggb.mjs +1 -0
  66. package/dist/packem_shared/platform-diagnostics-uOXqysk3.mjs +4 -0
  67. package/dist/packem_shared/post-codegen-hook-DRdEoTsQ.mjs +1 -0
  68. package/dist/packem_shared/prompt-cancelled-C8Sj7OqI.mjs +1 -0
  69. package/dist/packem_shared/resolve-DZAGzg67.mjs +1 -0
  70. package/dist/packem_shared/resolve-target-C_ZloTvd.mjs +1 -0
  71. package/dist/packem_shared/runAddCommand-BXz-PXbb.mjs +1 -0
  72. package/dist/packem_shared/runExportCommand-DmXKEWSq.mjs +5 -0
  73. package/dist/packem_shared/schema-drift-gate-AscQpYH5.mjs +1 -0
  74. package/dist/packem_shared/schemaIrToSnapshot-qpRoV7HY.mjs +1 -0
  75. package/dist/packem_shared/shared-D-zCOmgY.mjs +1 -0
  76. package/dist/packem_shared/tui-prompts-Dd0pDuNr.mjs +4 -0
  77. package/dist/packem_shared/vectorize-metadata-DbziRKpX.mjs +1 -0
  78. package/dist/packem_shared/wrangler-name-Dsk5K1f-.mjs +1 -0
  79. package/dist/packem_shared/wrangler-secrets-CE7jcf8E.mjs +1 -0
  80. package/package.json +43 -19
  81. package/skills/README.md +35 -17
  82. package/skills/lunora/SKILL.md +65 -9
  83. package/skills/lunora-functions/SKILL.md +38 -3
  84. package/skills/lunora-migration-helper/SKILL.md +70 -17
  85. package/skills/lunora-performance-audit/SKILL.md +36 -6
  86. package/skills/lunora-quickstart/SKILL.md +90 -24
  87. package/skills/lunora-realtime/SKILL.md +58 -30
  88. package/skills/lunora-setup-storage/SKILL.md +7 -3
  89. package/dist/packem_shared/COMMANDS-1V_KEx35.mjs +0 -905
  90. package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs +0 -244
  91. package/dist/packem_shared/admin-url-4UzT-CI4.mjs +0 -19
  92. package/dist/packem_shared/api-spec-CtA6ilu4.mjs +0 -13
  93. package/dist/packem_shared/buildRegistryIndex-BcYe607_.mjs +0 -38
  94. package/dist/packem_shared/command-BDXcJCCJ.mjs +0 -14
  95. package/dist/packem_shared/createLogger-CHPNjFw2.mjs +0 -73
  96. package/dist/packem_shared/defaultSpawner-DxI3mebw.mjs +0 -43
  97. package/dist/packem_shared/diffSnapshots-RR2ZE8Ya.mjs +0 -161
  98. package/dist/packem_shared/docker-hMQ97KSQ.mjs +0 -21
  99. package/dist/packem_shared/features-ocSSpZtS.mjs +0 -24
  100. package/dist/packem_shared/insertSchemaExtension-BuzF6-t2.mjs +0 -59
  101. package/dist/packem_shared/open-url-Dfq6fAyT.mjs +0 -41
  102. package/dist/packem_shared/output-format-7gyGR3h8.mjs +0 -17
  103. package/dist/packem_shared/parseArgs-YXFuKdEk.mjs +0 -56
  104. package/dist/packem_shared/parseManifest--vZf2FY1.mjs +0 -94
  105. package/dist/packem_shared/resolve-target-qbsJ_5sF.mjs +0 -16
  106. package/dist/packem_shared/runAddCommand-BZGkRnBs.mjs +0 -693
  107. package/dist/packem_shared/schema-drift-gate-BtBt0as0.mjs +0 -79
  108. package/dist/packem_shared/schemaIrToSnapshot-aBTo7TM5.mjs +0 -43
  109. package/dist/packem_shared/wrangler-name-cy4yhm9j.mjs +0 -12
@@ -1,18 +1,11 @@
1
- import { existsSync, mkdirSync, writeFileSync, readdirSync, mkdtempSync, rmSync, readFileSync } from 'node:fs';
2
- import { tmpdir } from 'node:os';
3
- import { fileURLToPath } from 'node:url';
4
- import { detectFramework as detectFramework$1, isInteractive, promptSelect, promptMultiSelect } from '@lunora/config';
5
- import { walkSync } from '@visulima/fs';
6
- import { resolve, join as join$1, relative, dirname as dirname$1 } from '@visulima/path';
7
- import { downloadTemplate } from 'giget';
8
- import { join, dirname } from 'node:path';
9
- import { d as defineHandler } from '../packem_shared/command-BDXcJCCJ.mjs';
10
- import MagicString from 'magic-string';
11
- import { Project, SyntaxKind } from 'ts-morph';
12
- import { p as promptAuthProvider, E as EMAIL_ITEM } from '../packem_shared/features-ocSSpZtS.mjs';
13
- import { runAddCommand } from '../packem_shared/runAddCommand-BZGkRnBs.mjs';
14
-
15
- const GITHUB_CONTENT = `name: Deploy
1
+ import{existsSync as m,mkdirSync as M,writeFileSync as v,readFileSync as b,readdirSync as re,rmSync as $,mkdtempSync as oe,cpSync as G,renameSync as Re,lstatSync as Oe}from"node:fs";import{tmpdir as se}from"node:os";import{detectFramework as Te,isInteractive as g,LUNA_ART as Pe,LUNA_NAME as De,LUNA_SIGNOFF as Be,BADGES as f,paintAnswer as je,detectLintTools as Ve,applyLintIgnores as Ue}from"@lunora/config";import{walkSync as Fe}from"@visulima/fs";import{join as u,dirname as A,basename as E,resolve as ne,relative as He}from"@visulima/path";import{downloadTemplate as ie}from"giget";import{modify as We,applyEdits as ze}from"jsonc-parser";import{join as V,dirname as qe}from"node:path";import{i as le,e as Ke,d as U,c as Ge,b as Je,a as Ye}from"../packem_shared/detect-package-manager-DSaAqRof.mjs";import{d as Xe}from"../packem_shared/command-DwC11Cwe.mjs";import Qe from"magic-string";import{Project as Ze,SyntaxKind as w}from"ts-morph";import{P as F}from"../packem_shared/prompt-cancelled-C8Sj7OqI.mjs";import{h as ce,d as de,i as ue,b as et}from"../packem_shared/resolve-DZAGzg67.mjs";import{defaultSpawner as pe}from"../packem_shared/createRecordingSpawner-DJlNacZ6.mjs";import{d as tt,e as at,f as rt,a as he,t as H,g as me,h as ot,b as fe,i as ve,w as st,j as nt,k as ge,l as it}from"../packem_shared/tui-prompts-Dd0pDuNr.mjs";import{E as we,p as lt,w as ct,M as dt,r as ut,k as pt,f as ht,c as ye,l as be,e as mt,g as ft}from"../packem_shared/lint-ignore-report-CDbcbtv7.mjs";import{logStep as J}from"../packem_shared/createLogger-hGafwf-3.mjs";import vt from"node:dns/promises";import{r as gt}from"../packem_shared/commands-BOgN2nF7.mjs";const W={bun:{githubCacheKey:void 0,githubSetupStep:` - uses: oven-sh/setup-bun@v2
2
+ `,gitlabImage:"oven/bun:1",gitlabProvisionScript:[],installCmd:"bun install --frozen-lockfile",lockfile:"bun.lockb"},npm:{githubCacheKey:"npm",githubSetupStep:"",gitlabImage:"node:22",gitlabProvisionScript:[],installCmd:"npm ci",lockfile:"package-lock.json"},pnpm:{githubCacheKey:"pnpm",githubSetupStep:` - uses: pnpm/action-setup@v4
3
+ `,gitlabImage:"node:22",gitlabProvisionScript:["corepack enable"],installCmd:"pnpm install --frozen-lockfile",lockfile:"pnpm-lock.yaml"},yarn:{githubCacheKey:"yarn",githubSetupStep:"",gitlabImage:"node:22",gitlabProvisionScript:["corepack enable"],installCmd:"yarn install --frozen-lockfile",lockfile:"yarn.lock"}},C=(e,t)=>{const a=Ke(e,"lunora",t);return[a.command,...a.args].join(" ")},Y=e=>` - uses: actions/checkout@v4
4
+ ${e.githubSetupStep} - uses: actions/setup-node@v4
5
+ with:
6
+ node-version: 22
7
+ ${e.githubCacheKey===void 0?"":` cache: ${e.githubCacheKey}
8
+ `} - run: ${e.installCmd}`,wt=e=>{const t=W[e],a=t.githubCacheKey===void 0?`# (below) requires it — run \`${e} install\` locally and`:`# (below) and the ${e} cache both require it — run \`${e} install\` locally and`;return`name: Deploy
16
9
 
17
10
  on:
18
11
  push:
@@ -20,6 +13,10 @@ on:
20
13
  pull_request:
21
14
  workflow_dispatch:
22
15
 
16
+ # Prerequisite: commit your ${t.lockfile}. \`${t.installCmd}\`
17
+ ${a}
18
+ # commit the lockfile before pushing, or the first CI run fails.
19
+ #
23
20
  # Set these repository secrets (Settings → Secrets and variables → Actions):
24
21
  # CLOUDFLARE_API_TOKEN — a Workers-scoped API token
25
22
  # CLOUDFLARE_ACCOUNT_ID — your Cloudflare account id
@@ -35,16 +32,10 @@ jobs:
35
32
  permissions:
36
33
  contents: read
37
34
  steps:
38
- - uses: actions/checkout@v4
39
- - uses: pnpm/action-setup@v4
40
- - uses: actions/setup-node@v4
41
- with:
42
- node-version: 22
43
- cache: pnpm
44
- - run: pnpm install --frozen-lockfile
35
+ ${Y(t)}
45
36
  # Codegen + wrangler validation gate (no deploy) — fails fast on drift.
46
- - run: pnpm exec lunora prepare
47
- - run: pnpm exec lunora deploy
37
+ - run: ${C(e,["prepare"])}
38
+ - run: ${C(e,["deploy"])}
48
39
 
49
40
  # Preview version on every pull request — uploads a versioned preview URL;
50
41
  # production traffic is untouched.
@@ -54,27 +45,24 @@ jobs:
54
45
  permissions:
55
46
  contents: read
56
47
  steps:
57
- - uses: actions/checkout@v4
58
- - uses: pnpm/action-setup@v4
59
- - uses: actions/setup-node@v4
60
- with:
61
- node-version: 22
62
- cache: pnpm
63
- - run: pnpm install --frozen-lockfile
64
- - run: pnpm exec lunora deploy --preview
65
- `;
66
- const GITLAB_CONTENT = `stages:
48
+ ${Y(t)}
49
+ - run: ${C(e,["deploy","--preview"])}
50
+ `},yt=e=>{const t=W[e],a=[...t.gitlabProvisionScript,t.installCmd].map(r=>` - ${r}`).join(`
51
+ `);return`stages:
67
52
  - deploy
68
53
 
54
+ # Prerequisite: commit your ${t.lockfile}. \`${t.installCmd}\`
55
+ # (below) requires it — run \`${e} install\` locally and commit the lockfile
56
+ # before pushing, or the first pipeline fails.
57
+ #
69
58
  # Set these as masked CI/CD variables (Settings → CI/CD → Variables):
70
59
  # CLOUDFLARE_API_TOKEN — a Workers-scoped API token
71
60
  # CLOUDFLARE_ACCOUNT_ID — your Cloudflare account id
72
61
  .lunora_base:
73
- image: node:22
62
+ image: ${t.gitlabImage}
74
63
  stage: deploy
75
64
  before_script:
76
- - corepack enable
77
- - pnpm install --frozen-lockfile
65
+ ${a}
78
66
 
79
67
  # Production deploy on the default branch.
80
68
  deploy:
@@ -83,8 +71,8 @@ deploy:
83
71
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
84
72
  script:
85
73
  # Codegen + wrangler validation gate (no deploy) — fails fast on drift.
86
- - pnpm exec lunora prepare
87
- - pnpm exec lunora deploy
74
+ - ${C(e,["prepare"])}
75
+ - ${C(e,["deploy"])}
88
76
 
89
77
  # Preview version on every merge request (versioned preview URL; production
90
78
  # traffic is untouched).
@@ -93,212 +81,1124 @@ preview:
93
81
  rules:
94
82
  - if: $CI_PIPELINE_SOURCE == "merge_request_event"
95
83
  script:
96
- - pnpm exec lunora deploy --preview
97
- `;
98
- const WORKFLOWS = {
99
- github: {
100
- content: GITHUB_CONTENT,
101
- file: join(".github", "workflows", "deploy.yml"),
102
- secretsHint: "repository secrets (Settings → Secrets and variables → Actions)"
103
- },
104
- gitlab: {
105
- content: GITLAB_CONTENT,
106
- file: ".gitlab-ci.yml",
107
- secretsHint: "masked CI/CD variables (Settings CI/CD Variables)"
108
- }
109
- };
110
- const isCiProvider = (value) => value === "github" || value === "gitlab";
111
- const writeCiWorkflow = (projectRoot, provider, options = {}) => {
112
- const spec = WORKFLOWS[provider];
113
- const path = join(projectRoot, spec.file);
114
- if (existsSync(path) && options.overwrite !== true) {
115
- return { path, skipped: true, written: false };
116
- }
117
- mkdirSync(dirname(path), { recursive: true });
118
- writeFileSync(path, spec.content, "utf8");
119
- return { path, skipped: false, written: true };
120
- };
121
- const scaffoldCiWorkflow = (projectRoot, provider, logger, options = {}) => {
122
- const spec = WORKFLOWS[provider];
123
- try {
124
- const result = writeCiWorkflow(projectRoot, provider, options);
125
- if (result.skipped) {
126
- logger.info(`--ci ${provider}: ${spec.file} already exists — left unchanged (re-run with overwrite to replace).`);
127
- } else {
128
- logger.success(`--ci ${provider}: wrote ${spec.file}`);
129
- logger.info(`--ci ${provider}: set CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID as ${spec.secretsHint} to enable deploys.`);
130
- }
131
- return result;
132
- } catch (error) {
133
- const message = error instanceof Error ? error.message : String(error);
134
- logger.warn(`--ci ${provider}: could not write ${spec.file} (${message})`);
135
- return { path: join(projectRoot, spec.file), skipped: false, written: false };
136
- }
137
- };
84
+ - ${C(e,["deploy","--preview"])}
85
+ `},xe={github:{file:V(".github","workflows","deploy.yml"),secretsHint:"repository secrets (Settings → Secrets and variables → Actions)"},gitlab:{file:".gitlab-ci.yml",secretsHint:"masked CI/CD variables (Settings → CI/CD → Variables)"}},bt=(e,t)=>e==="github"?wt(t):yt(t),xt=e=>e==="github"||e==="gitlab",kt=(e,t,a,r={})=>{const o=V(e,xe[t].file);return m(o)&&r.overwrite!==!0?{path:o,skipped:!0,written:!1}:(M(qe(o),{recursive:!0}),v(o,bt(t,a),"utf8"),{path:o,skipped:!1,written:!0})},Ct=(e,t,a,r,o={})=>{const s=xe[t];try{const n=kt(e,t,a,o);if(n.skipped)r.info(`--ci ${t}: ${s.file} already exists — left unchanged (re-run with overwrite to replace).`);else{const i=le(a),l=[i.command,...i.args].join(" "),{installCmd:d,lockfile:c}=W[a];r.success(`--ci ${t}: wrote ${s.file}`),r.info(`--ci ${t}: set CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID as ${s.secretsHint} to enable deploys.`),r.info(`--ci ${t}: run \`${l}\` and commit ${c} before pushing — the pipeline runs \`${d}\`.`)}return n}catch(n){const i=n instanceof Error?n.message:String(n);return r.warn(`--ci ${t}: could not write ${s.file} (${i})`),{path:V(e,s.file),skipped:!1,written:!1}}},St={astro:"@lunora/react",none:"@lunora/react",nuxt:"@lunora/vue","react-router":"@lunora/react","solid-start":"@lunora/solid",sveltekit:"@lunora/svelte","tanstack-start":"@lunora/react","tanstack-start-solid":"@lunora/solid",vinext:"@lunora/react"},Lt=e=>{const t=Te(e);return{...t,adapter:St[t.framework]}},_="lunora()",X='import { lunora } from "@lunora/vite";',Mt=/\blunora\s*\(/u,At='"@lunora/vite"',Et="'@lunora/vite'",Nt=e=>{for(const t of e.getStatements()){if(t.getKind()!==w.ExportAssignment)continue;const a=t.asKindOrThrow(w.ExportAssignment).getExpression();if(a.getKind()!==w.CallExpression)continue;const r=a.asKindOrThrow(w.CallExpression);if(r.getExpression().getText()!=="defineConfig")continue;const o=r.getArguments()[0];if(o?.getKind()===w.ObjectLiteralExpression)return o.asKindOrThrow(w.ObjectLiteralExpression)}},It=e=>{for(const t of e.getStatements()){if(t.getKind()!==w.ExportAssignment)continue;const a=t.asKindOrThrow(w.ExportAssignment).getExpression();if(a.getKind()===w.ObjectLiteralExpression)return a.asKindOrThrow(w.ObjectLiteralExpression)}},_t=e=>new Ze({compilerOptions:{allowJs:!0},useInMemoryFileSystem:!0}).createSourceFile("vite.config.ts",e,{overwrite:!0}),$t=(e,t)=>{const a=t.getImportDeclarations().at(-1)?.getEnd()??0;a===0?e.prepend(`${X}
86
+ `):e.appendLeft(a,`
87
+ ${X}`)},Rt=(e,t)=>{const a=t.getProperty("plugins");if(a===void 0){const s=t.getProperties(),n=t.getStart()+1;if(s.length===0)e.appendLeft(n,` plugins: [${_}] `);else{const i=s[0];i!==void 0&&e.appendLeft(i.getStart(),`plugins: [${_}],
88
+ `)}return}const r=a.getDescendantsOfKind(w.ArrayLiteralExpression)[0];if(r===void 0)return;const o=r.getElements();if(o.length===0)e.appendLeft(r.getStart()+1,_);else{const s=o[0];s!==void 0&&e.appendLeft(s.getStart(),`${_}, `)}},ke=e=>{if(Mt.test(e))return{changed:!1,code:e,reason:"lunora plugin already present"};const t=_t(e),a=Nt(t)??It(t);if(a===void 0)return{changed:!1,code:e,reason:"could not locate a Vite config plugins array to patch"};const r=new Qe(e);return!e.includes(At)&&!e.includes(Et)&&$t(r,t),Rt(r,a),{changed:!0,code:r.toString()}},Ot=/enotfound|eai_again|econnrefused|etimedout|network|fetch failed|getaddrinfo/u,Tt=/404|not found|could not find|no such/u,Pt=(e,t)=>{const a=e instanceof Error?e.message:String(e),r=a.toLowerCase(),o=`failed to download template "${t.templateType}" from ${t.remote}: ${a}`;return Tt.test(r)?{hints:[`Check the template name "${t.templateType}" and the ref "${t.ref}".`,"List/inspect available templates, or target a branch/tag with `--ref <branch>`."],message:`template "${t.templateType}" not found at ${t.remote}: ${a}`}:Ot.test(r)?{hints:["You appear to be offline or unable to reach GitHub.","To scaffold without a network, point at a local template root: `lunora init --from <dir>`."],message:o}:{hints:["If this is a network/offline issue, scaffold from a local root with `lunora init --from <dir>`."],message:o}},R=async(e,t,a)=>{if(g()){await at(f[e],t,a);return}if(process.stdout.write(`
89
+ `),a===void 0||a===""){J(e,t);return}const r=a.split(`
90
+ `).map(o=>je(o)).join(`
91
+ `);J(e,`${t}
92
+ ${r}`)},Dt=async e=>{if(g()){await tt();return}e.info(`
93
+ ${Pe}
94
+ ${De}: ${Be}`)},Ce=[{description:"LLMs via Workers AI (summarize, generate, stream)",label:"AI",value:"ai"},{description:"Sign-up / sign-in (asks which provider)",label:"Authentication",value:"auth"},{description:"Copy-in auth screens for your framework (sign in/up, reset, 2FA)",label:"Auth UI",value:"auth-ui"},{description:"Snapshot + restore your Durable Object data",label:"Backups",value:"backup"},{description:"Headless browser screenshots + PDFs",label:"Browser rendering",value:"browser"},{description:"Zero Trust identity via Cloudflare Access",label:"Cloudflare Access",value:"cloudflare-access"},{description:"Scheduled jobs via Cron Triggers (@lunora/scheduler)",label:"Cron jobs",value:"crons"},{description:"Cloudflare Email Workers + a dev mail catcher",label:"Transactional email",value:"email"},{description:"OpenFeature feature flags (ctx.flags)",label:"Feature flags",value:"flags"},{description:"External Postgres/MySQL via Hyperdrive",label:"Hyperdrive",value:"hyperdrive"},{description:"Stripe-first payments (checkout, subscription, webhooks)",label:"Payments",value:"payment"},{description:"Live presence / who's-online over hibernated WebSockets",label:"Presence",value:"presence"},{description:"Async message queues (push/pull consumers)",label:"Queues",value:"queue"},{description:"Typed R2 buckets + signed URLs (@lunora/storage)",label:"File storage",value:"storage"},{description:"Durable long-running workflows (step.do, sleep, branch)",label:"Workflows",value:"workflow"}],Q=Ce.map(e=>e.value),Bt=e=>e==="email"?we:e,jt=(e,t)=>{const a=[];for(const r of e.split(",").map(o=>o.trim()).filter(Boolean))Q.includes(r)?a.includes(r)||a.push(r):t(`init: unknown --add feature "${r}" — expected ${Q.join(" | ")}; skipping.`);return a},Vt=async e=>{const t=await ht(e.select),a=await ye(e.text,e.projectName);return{label:"auth",names:[t],transformManifest:r=>be(r,a)}},Ut=async e=>{const t=await e.text(dt,{placeholder:"you@yourdomain.com"}),a=ut(t,r=>{e.logger.warn(r)});return{label:"email",names:[we],transformManifest:a===void 0?void 0:r=>pt(r,a)}},Ft=async(e,t)=>{const a=e.resolveAuthUiItem?.()??"auth-ui-react";if(t)return{label:"auth-ui",names:[a]};const r=await ye(e.text,e.projectName);return{label:"auth-ui",names:[a],transformManifest:o=>be(o,r)}},Ht=async e=>{const t=await lt(e.text,e.projectName);return{label:"storage",names:["storage"],transformManifest:a=>ct(a,t)}},Wt={auth:Vt,"auth-ui":async(e,t)=>Ft(e,t.includes("auth")),email:Ut,storage:Ht},Z=async e=>{if(e.preselected!==void 0&&e.preselected.length>0){await e.applyAll(e.preselected.map(r=>{const o=r==="auth-ui"?e.resolveAuthUiItem?.()??"auth-ui-react":Bt(r);return{label:r,names:[o]}}));return}if(!e.interactive){e.logger.info("tip: add features later with `lunora add <ai|auth|backup|browser|cloudflare-access|crons|email|flags|hyperdrive|payment|presence|queue|storage|workflow>`.");return}const t=await e.multiSelect("Which features do you want to add?",Ce,{defaults:[]});if(t.length===0)return;const a=[];for(const r of t){const o=Wt[r];a.push(o?await o(e,t):{label:r,names:[r]})}await e.applyAll(a)},zt=[{description:"Adds an ignores entry to eslint.config.js",label:"ESLint",value:"eslint"},{description:"Writes .prettierignore",label:"Prettier",value:"prettier"},{description:"Adds negated patterns to biome.json",label:"Biome",value:"biome"},{description:"Writes ignorePatterns to .oxlintrc.json",label:"oxlint (oxc)",value:"oxlint"}],qt="Which linter/formatter do you use? We'll tell it to skip Lunora's generated files.",Kt=async e=>{const t=e.interactive?await e.multiSelect(qt,zt,{defaults:e.detected}):[...e.detected];if(t.length===0)return[];const a=e.apply(t);return mt(a,e.logger),a},N="M 259.500 10.552 C 220.080 15.859, 182.424 32.566, 152.500 58.025 C 110.179 94.031, 85.380 137.183, 77.518 188.500 C 75.410 202.255, 74.569 225.677, 75.796 236.466 C 76.757 244.917, 76.683 245.692, 74.518 249.966 C 63.118 272.466, 53.141 303.876, 51.382 322.799 L 50.718 329.943 71.960 320.471 C 83.643 315.262, 93.326 311, 93.478 311 C 93.630 311, 96.547 316.063, 99.959 322.250 C 103.371 328.438, 107.249 334.850, 108.577 336.500 L 110.990 339.500 110.981 336 C 110.977 334.075, 111.499 324.991, 112.143 315.813 L 113.312 299.127 121.406 293.336 C 132.495 285.403, 149.593 271.554, 161 261.268 C 171.556 251.748, 189.116 235, 188.540 235 C 188.337 235, 183.069 238.648, 176.835 243.106 C 142.318 267.789, 68.537 314, 63.646 314 C 61.843 314, 72.791 281.179, 80.905 262.259 C 92.233 235.845, 107.473 212.389, 132.106 183.453 L 138.451 176 148.268 176 C 176.192 176, 197.512 187.154, 212.868 209.797 C 216.470 215.108, 217.035 216.595, 216.477 219.297 C 211.386 243.968, 202.359 274.496, 193.797 296 C 183.898 320.861, 167.147 352.101, 152.395 373.215 L 147.004 380.930 152.891 385.830 C 161.400 392.911, 165.563 396, 166.594 395.998 C 167.092 395.998, 168.772 391.641, 170.327 386.317 C 176.279 365.934, 188.422 338.749, 200.942 317.778 C 223.060 280.731, 256.432 244.369, 294.500 215.836 C 309.956 204.252, 313.937 201.603, 314.719 202.385 C 315.116 202.783, 315.449 213.096, 315.460 225.304 C 315.474 241.855, 315.021 250.405, 313.680 258.924 C 307.009 301.272, 291.175 336.677, 263.112 372 C 255.259 381.883, 227.182 410.673, 218.516 417.727 L 213.532 421.783 223.439 424.880 C 281.705 443.093, 349.165 436.018, 398.616 406.508 C 446.728 377.797, 483.322 331.466, 497.366 281.481 C 503.381 260.075, 504.480 250.741, 504.491 221 C 504.501 191.997, 503.598 184.047, 497.987 163.732 C 484.768 115.871, 452.505 72.708, 407.718 42.964 C 381.051 25.254, 352.818 14.828, 319.695 10.460 C 305.932 8.645, 273.298 8.695, 259.500 10.552",L=`/* The welcome page is a full-bleed starter — reset the browser's default
95
+ body margin/padding so it sits flush; everything else is scoped under
96
+ .lunora-welcome (collision-safe). */
97
+ body {
98
+ margin: 0;
99
+ padding: 0;
100
+ }
138
101
 
139
- const ADAPTER_BY_FRAMEWORK = {
140
- astro: "@lunora/react",
141
- none: "@lunora/react",
142
- nuxt: "@lunora/vue",
143
- "react-router": "@lunora/react",
144
- "solid-start": "@lunora/solid",
145
- sveltekit: "@lunora/svelte",
146
- "tanstack-start": "@lunora/react",
147
- "tanstack-start-solid": "@lunora/solid"
148
- };
149
- const detectFramework = (root) => {
150
- const base = detectFramework$1(root);
151
- return { ...base, adapter: ADAPTER_BY_FRAMEWORK[base.framework] };
152
- };
102
+ .lunora-welcome {
103
+ --cyan: hsl(186 84% 56%); --violet: hsl(256 72% 68%); --rose: hsl(330 80% 64%);
104
+ --ribbon: linear-gradient(115deg, var(--cyan), var(--violet) 52%, var(--rose));
105
+ --sans: "Geist Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
106
+ --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
107
+ /* NIGHT (default) */
108
+ --bg: #0e0e11; --surface: hsl(240 12% 8% / 0.72); --surface-2: hsl(240 11% 11% / 0.82);
109
+ --line: hsl(0 0% 100% / 0.08); --line-2: hsl(0 0% 100% / 0.14);
110
+ --t-display: hsl(228 30% 97%); --t-primary: hsl(228 26% 90%); --t-secondary: hsl(228 12% 62%); --t-faint: hsl(228 10% 44%);
111
+ --logo: hsl(228 30% 97%); --accent: var(--violet); --shot-bg: hsl(240 12% 6%);
112
+ --glow-1: hsl(256 80% 52% / 0.30); --glow-2: hsl(196 84% 52% / 0.13); --arc: hsl(256 60% 70% / 0.11);
153
113
 
154
- const LUNORA_CALL = "lunora()";
155
- const LUNORA_IMPORT = 'import { lunora } from "@lunora/vite";';
156
- const LUNORA_CALL_RE = /\blunora\s*\(/u;
157
- const LUNORA_VITE_DOUBLE = '"@lunora/vite"';
158
- const LUNORA_VITE_SINGLE = "'@lunora/vite'";
159
- const findDefineConfigObject = (sf) => {
160
- for (const statement of sf.getStatements()) {
161
- if (statement.getKind() !== SyntaxKind.ExportAssignment) {
162
- continue;
163
- }
164
- const expr = statement.asKindOrThrow(SyntaxKind.ExportAssignment).getExpression();
165
- if (expr.getKind() !== SyntaxKind.CallExpression) {
166
- continue;
167
- }
168
- const call = expr.asKindOrThrow(SyntaxKind.CallExpression);
169
- if (call.getExpression().getText() !== "defineConfig") {
170
- continue;
171
- }
172
- const argument = call.getArguments()[0];
173
- if (argument?.getKind() === SyntaxKind.ObjectLiteralExpression) {
174
- return argument.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);
175
- }
176
- }
177
- return void 0;
178
- };
179
- const findPlainExportObject = (sf) => {
180
- for (const statement of sf.getStatements()) {
181
- if (statement.getKind() !== SyntaxKind.ExportAssignment) {
182
- continue;
183
- }
184
- const expr = statement.asKindOrThrow(SyntaxKind.ExportAssignment).getExpression();
185
- if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {
186
- return expr.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);
187
- }
188
- }
189
- return void 0;
190
- };
191
- const findConfigObject = (sourceText) => {
192
- const project = new Project({
193
- compilerOptions: { allowJs: true },
194
- useInMemoryFileSystem: true
195
- });
196
- const sf = project.createSourceFile("vite.config.ts", sourceText, { overwrite: true });
197
- return findDefineConfigObject(sf) ?? findPlainExportObject(sf);
198
- };
199
- const importInsertPosition = (sourceText) => {
200
- const project = new Project({
201
- compilerOptions: { allowJs: true },
202
- useInMemoryFileSystem: true
203
- });
204
- const sf = project.createSourceFile("vite.config.ts", sourceText, { overwrite: true });
205
- const imports = sf.getImportDeclarations();
206
- if (imports.length === 0) {
207
- return 0;
208
- }
209
- const last = imports[imports.length - 1];
210
- if (last === void 0) {
211
- return 0;
212
- }
213
- return last.getEnd();
214
- };
215
- const addImport = (ms, source) => {
216
- const insertAt = importInsertPosition(source);
217
- if (insertAt === 0) {
218
- ms.prepend(`${LUNORA_IMPORT}
219
- `);
220
- } else {
221
- ms.appendLeft(insertAt, `
222
- ${LUNORA_IMPORT}`);
223
- }
224
- };
225
- const patchPluginsArray = (ms, configObject) => {
226
- const pluginsProp = configObject.getProperty("plugins");
227
- if (pluginsProp === void 0) {
228
- const properties = configObject.getProperties();
229
- const openBrace = configObject.getStart() + 1;
230
- if (properties.length === 0) {
231
- ms.appendLeft(openBrace, ` plugins: [${LUNORA_CALL}] `);
232
- } else {
233
- const firstProp = properties[0];
234
- if (firstProp !== void 0) {
235
- ms.appendLeft(firstProp.getStart(), `plugins: [${LUNORA_CALL}],
236
- `);
237
- }
238
- }
239
- return;
240
- }
241
- const arrayLit = pluginsProp.getDescendantsOfKind(SyntaxKind.ArrayLiteralExpression)[0];
242
- if (arrayLit === void 0) {
243
- return;
244
- }
245
- const elements = arrayLit.getElements();
246
- if (elements.length === 0) {
247
- ms.appendLeft(arrayLit.getStart() + 1, LUNORA_CALL);
248
- } else {
249
- const firstElement = elements[0];
250
- if (firstElement !== void 0) {
251
- ms.appendLeft(firstElement.getStart(), `${LUNORA_CALL}, `);
114
+ position: relative; min-height: 100vh; background: var(--bg); color: var(--t-primary);
115
+ font-family: var(--sans); line-height: 1.55; -webkit-font-smoothing: antialiased; overflow-x: hidden;
116
+ transition: background .3s, color .3s;
117
+ }
118
+ .lunora-welcome[data-theme="light"] {
119
+ --bg: hsl(228 32% 97%); --surface: hsl(0 0% 100% / 0.82); --surface-2: hsl(0 0% 100% / 0.95);
120
+ --line: hsl(228 16% 88%); --line-2: hsl(228 14% 80%);
121
+ --t-display: hsl(240 14% 10%); --t-primary: hsl(240 12% 18%); --t-secondary: hsl(235 9% 42%); --t-faint: hsl(235 8% 58%);
122
+ --logo: hsl(240 16% 9%); --accent: hsl(256 58% 56%); --shot-bg: hsl(228 26% 99%);
123
+ --glow-1: hsl(256 80% 60% / 0.14); --glow-2: hsl(196 84% 58% / 0.08); --arc: hsl(256 40% 55% / 0.12);
124
+ }
125
+ .lunora-welcome *, .lunora-welcome *::before, .lunora-welcome *::after { box-sizing: border-box; }
126
+ .lunora-welcome a { color: inherit; text-decoration: none; }
127
+ .lunora-welcome button { font-family: inherit; cursor: pointer; }
128
+ .lunora-welcome ::selection { background: hsl(256 72% 68% / 0.3); }
129
+ .lunora-welcome code { font-family: var(--mono); }
130
+
131
+ /* glow background */
132
+ .lunora-welcome .lw-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
133
+ .lunora-welcome .lw-bg .glow { position: absolute; left: 50%; top: -4%; width: 860px; height: 720px; transform: translateX(-50%);
134
+ border-radius: 50%; background: radial-gradient(circle at 50% 50%, var(--glow-1), var(--glow-2) 40%, transparent 66%); }
135
+ .lunora-welcome .lw-bg .arc { position: absolute; left: 50%; border-radius: 50%; border: 1px solid var(--arc); transform: translateX(-50%); }
136
+ .lunora-welcome .lw-bg .arc.a1 { top: -340px; width: 980px; height: 980px; }
137
+ .lunora-welcome .lw-bg .arc.a2 { top: -240px; width: 720px; height: 720px; opacity: .7; }
138
+
139
+ /* theme toggle */
140
+ .lunora-welcome .lw-toggle { position: fixed; z-index: 5; top: 20px; right: clamp(16px,4vw,36px); display: inline-flex; align-items: center;
141
+ gap: 7px; border: 1px solid var(--line-2); background: var(--surface); backdrop-filter: blur(12px); color: var(--t-secondary);
142
+ font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; padding: 7px 11px; transition: .15s; }
143
+ .lunora-welcome .lw-toggle:hover { color: var(--t-display); border-color: var(--accent); }
144
+ .lunora-welcome .lw-toggle svg { width: 13px; height: 13px; }
145
+
146
+ .lunora-welcome .lw-wrap { position: relative; z-index: 2; width: 100%; max-width: 1080px; margin: 0 auto;
147
+ padding: clamp(44px,8vh,92px) clamp(20px,5vw,48px); display: flex; flex-direction: column; min-height: 100vh; }
148
+ .lunora-welcome .brand { display: flex; align-items: center; justify-content: center; gap: 15px; margin-bottom: clamp(38px,6vh,68px); color: var(--logo); }
149
+ .lunora-welcome .brand svg { width: 54px; height: auto; display: block; }
150
+ .lunora-welcome .brand .word { font-size: 34px; font-weight: 600; letter-spacing: -0.03em; color: var(--t-display); }
151
+
152
+ .lunora-welcome .grid { display: grid; grid-template-columns: 1.06fr 0.94fr; gap: 16px; align-items: stretch; flex: 1; max-height: 580px; }
153
+ @media (max-width: 820px) { .lunora-welcome .grid { grid-template-columns: 1fr; max-height: none; } }
154
+
155
+ .lunora-welcome .card { border: 1px solid var(--line); background: var(--surface); backdrop-filter: blur(10px); transition: border-color .2s, background .2s; }
156
+ .lunora-welcome .card:hover { border-color: var(--line-2); background: var(--surface-2); }
157
+ .lunora-welcome .card:hover .arrow { color: var(--accent); transform: translateX(3px); }
158
+ .lunora-welcome .arrow { color: var(--t-faint); transition: color .2s, transform .2s; }
159
+ .lunora-welcome .arrow svg { width: 20px; height: 20px; display: block; }
160
+ .lunora-welcome .ic { display: grid; place-items: center; color: var(--accent);
161
+ border: 1px solid color-mix(in oklab, var(--accent) 36%, transparent); background: color-mix(in oklab, var(--accent) 12%, transparent); }
162
+ .lunora-welcome .ic svg { display: block; }
163
+
164
+ /* left feature card stretches to fill the box height */
165
+ .lunora-welcome .feature { padding: clamp(18px,2vw,24px); display: flex; flex-direction: column; }
166
+ .lunora-welcome .shot { border: 1px solid var(--line); overflow: hidden; background: var(--shot-bg);
167
+ -webkit-mask-image: linear-gradient(to bottom, #000 56%, transparent 100%); mask-image: linear-gradient(to bottom, #000 56%, transparent 100%); }
168
+ .lunora-welcome .shot .top { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
169
+ .lunora-welcome .shot .wm { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--t-primary); }
170
+ .lunora-welcome .shot .wm i { width: 11px; height: 11px; background: var(--ribbon); -webkit-mask: radial-gradient(circle,#000 60%,transparent 62%); mask: radial-gradient(circle,#000 60%,transparent 62%); }
171
+ .lunora-welcome .shot .search { flex: 1; height: 22px; border: 1px solid var(--line); border-radius: 4px; }
172
+ .lunora-welcome .shot .ver { font-family: var(--mono); font-size: 8px; letter-spacing: .08em; color: var(--t-faint); }
173
+ .lunora-welcome .shot .body { display: grid; grid-template-columns: 92px 1fr; min-height: 224px; }
174
+ .lunora-welcome .shot .nav { border-right: 1px solid var(--line); padding: 14px 12px; display: flex; flex-direction: column; gap: 11px; }
175
+ .lunora-welcome .shot .nav i, .lunora-welcome .shot .doc i { height: 5px; border-radius: 2px; background: var(--line); }
176
+ .lunora-welcome .shot .doc { padding: 16px 18px; display: flex; flex-direction: column; gap: 9px; }
177
+ .lunora-welcome .shot .doc .h { height: 8px; width: 46%; border-radius: 2px; background: var(--line-2); margin-bottom: 5px; }
178
+ .lunora-welcome .shot .doc .accent { height: 5px; width: 26%; border-radius: 2px; background: var(--accent); }
179
+ .lunora-welcome .feature .info { margin-top: auto; padding-top: clamp(18px,2.4vh,28px); }
180
+ .lunora-welcome .feature .ic { width: 40px; height: 40px; margin-bottom: 15px; }
181
+ .lunora-welcome .feature .ic svg { width: 19px; height: 19px; }
182
+ .lunora-welcome .feature h2 { margin: 0 0 10px; font-size: 19px; font-weight: 600; letter-spacing: -0.015em; color: var(--t-display); }
183
+ .lunora-welcome .feature .row { display: flex; align-items: flex-end; gap: 16px; }
184
+ .lunora-welcome .feature p { margin: 0; color: var(--t-secondary); font-size: 14px; max-width: 50ch; }
185
+ .lunora-welcome .feature .row .arrow { margin-left: auto; }
186
+
187
+ /* right stack smaller cards, spread to align bottoms with the feature */
188
+ .lunora-welcome .stack { display: flex; flex-direction: column; gap: 16px; height: 100%; }
189
+ .lunora-welcome .mini { flex: 1; padding: 15px 17px; display: flex; align-items: center; gap: 16px; min-height: 0; }
190
+ .lunora-welcome .mini .mc { flex: 1; }
191
+ .lunora-welcome .mini .ic { width: 32px; height: 32px; margin-bottom: 10px; }
192
+ .lunora-welcome .mini .ic svg { width: 16px; height: 16px; }
193
+ .lunora-welcome .mini h3 { margin: 0 0 5px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--t-display); }
194
+ .lunora-welcome .mini p { margin: 0; color: var(--t-secondary); font-size: 12.5px; line-height: 1.45; }
195
+
196
+ .lunora-welcome .lw-foot { text-align: center; padding-top: 26px; font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--t-faint); }
197
+
198
+ @media (prefers-reduced-motion: reduce) { .lunora-welcome * { transition: none !important; } }
199
+ `,Gt=`import { useEffect, useState } from "react";
200
+
201
+ type Theme = "dark" | "light";
202
+
203
+ export default function App() {
204
+ // Default to "dark" for a stable first paint, then reconcile to the OS
205
+ // preference; the toggle takes over after that.
206
+ const [theme, setTheme] = useState<Theme>("dark");
207
+
208
+ useEffect(() => {
209
+ if (typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: light)").matches) {
210
+ setTheme("light");
211
+ }
212
+ }, []);
213
+
214
+ const isLight = theme === "light";
215
+
216
+ return (
217
+ <div className="lunora-welcome" data-theme={theme}>
218
+ <div className="lw-bg">
219
+ <div className="arc a1" />
220
+ <div className="arc a2" />
221
+ <div className="glow" />
222
+ </div>
223
+
224
+ <button className="lw-toggle" type="button" aria-label="Toggle color theme" onClick={() => setTheme(isLight ? "dark" : "light")}>
225
+ {isLight ? (
226
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8">
227
+ <path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z" />
228
+ </svg>
229
+ ) : (
230
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8">
231
+ <circle cx="12" cy="12" r="4" />
232
+ <path d="M12 2v2M12 20v2M4 12H2M22 12h-2M5 5l1.5 1.5M17.5 17.5 19 19M19 5l-1.5 1.5M6.5 17.5 5 19" />
233
+ </svg>
234
+ )}
235
+ <span>{isLight ? "Ivory" : "Night"}</span>
236
+ </button>
237
+
238
+ <div className="lw-wrap">
239
+ <div className="brand">
240
+ <svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
241
+ <path d="${N}" fill="currentColor" fillRule="evenodd" />
242
+ </svg>
243
+ <span className="word">Lunora</span>
244
+ </div>
245
+
246
+ <div className="grid">
247
+ <a className="card feature" href="https://lunora.sh/docs">
248
+ <div className="shot" aria-hidden="true">
249
+ <div className="top">
250
+ <span className="wm">
251
+ <i /> Lunora
252
+ </span>
253
+ <span className="search" />
254
+ <span className="ver">v0.1</span>
255
+ </div>
256
+ <div className="body">
257
+ <div className="nav">
258
+ <i style={{ width: "80%" }} />
259
+ <i style={{ width: "60%" }} />
260
+ <i style={{ width: "72%" }} />
261
+ <i style={{ width: "50%" }} />
262
+ <i style={{ width: "66%" }} />
263
+ <i style={{ width: "44%" }} />
264
+ <i style={{ width: "58%" }} />
265
+ </div>
266
+ <div className="doc">
267
+ <span className="h" />
268
+ <i style={{ width: "92%" }} />
269
+ <i style={{ width: "88%" }} />
270
+ <span className="accent" />
271
+ <i style={{ width: "80%" }} />
272
+ <i style={{ width: "90%" }} />
273
+ <i style={{ width: "72%" }} />
274
+ <i style={{ width: "84%" }} />
275
+ <i style={{ width: "78%" }} />
276
+ </div>
277
+ </div>
278
+ </div>
279
+ <div className="info">
280
+ <span className="ic">
281
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7">
282
+ <path d="M4 5a2 2 0 0 1 2-2h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z" />
283
+ <path d="M14 3v5h5" />
284
+ </svg>
285
+ </span>
286
+ <h2>Documentation</h2>
287
+ <div className="row">
288
+ <p>
289
+ Schemas, queries, live subscriptions, sharding, and edge deploy — start to finish. New here or coming from Convex or tRPC,
290
+ you'll have a live app fast.
291
+ </p>
292
+ <span className="arrow">
293
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
294
+ <path d="M5 12h14M13 6l6 6-6 6" />
295
+ </svg>
296
+ </span>
297
+ </div>
298
+ </div>
299
+ </a>
300
+
301
+ <div className="stack">
302
+ <a className="card mini" href="https://lunora.sh/blog">
303
+ <div className="mc">
304
+ <span className="ic">
305
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7">
306
+ <path d="M5 4h11a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H6a2 2 0 0 1-2-2V5a1 1 0 0 1 1-1zM8 8h7M8 12h7M8 16h4" />
307
+ </svg>
308
+ </span>
309
+ <h3>Blog</h3>
310
+ <p>Product updates, deep dives, and what's new in Lunora.</p>
311
+ </div>
312
+ <span className="arrow">
313
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
314
+ <path d="M5 12h14M13 6l6 6-6 6" />
315
+ </svg>
316
+ </span>
317
+ </a>
318
+ <a className="card mini" href="/_lunora">
319
+ <div className="mc">
320
+ <span className="ic">
321
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7">
322
+ <rect x="3" y="3" width="18" height="18" rx="1" />
323
+ <path d="M3 9h18M9 21V9" />
324
+ </svg>
325
+ </span>
326
+ <h3>Lunora Studio</h3>
327
+ <p>Local admin for schema, data, logs, and advisors.</p>
328
+ </div>
329
+ <span className="arrow">
330
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
331
+ <path d="M5 12h14M13 6l6 6-6 6" />
332
+ </svg>
333
+ </span>
334
+ </a>
335
+ <a className="card mini" href="https://lunora.sh/packages">
336
+ <div className="mc">
337
+ <span className="ic">
338
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7">
339
+ <path d="M12 2 3 7v10l9 5 9-5V7z" />
340
+ <path d="M3 7l9 5 9-5M12 12v10" />
341
+ </svg>
342
+ </span>
343
+ <h3>Cloudflare ecosystem</h3>
344
+ <p>Auth, mail, storage, AI, payments — one deploy.</p>
345
+ </div>
346
+ <span className="arrow">
347
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
348
+ <path d="M5 12h14M13 6l6 6-6 6" />
349
+ </svg>
350
+ </span>
351
+ </a>
352
+ </div>
353
+ </div>
354
+
355
+ <div className="lw-foot">Running on Lunora · Vite + React</div>
356
+ </div>
357
+ </div>
358
+ );
359
+ }
360
+ `,Jt=`<script setup lang="ts">
361
+ import { onMounted, ref } from "vue";
362
+
363
+ // Default to "dark" for a stable first paint, then reconcile to the OS
364
+ // preference; the toggle takes over after that.
365
+ const theme = ref<"dark" | "light">("dark");
366
+
367
+ onMounted(() => {
368
+ if (window.matchMedia("(prefers-color-scheme: light)").matches) {
369
+ theme.value = "light";
252
370
  }
253
- }
254
- };
255
- const patchViteConfig = (source) => {
256
- if (LUNORA_CALL_RE.test(source)) {
257
- return { changed: false, code: source, reason: "lunora plugin already present" };
258
- }
259
- const configObject = findConfigObject(source);
260
- if (configObject === void 0) {
261
- return { changed: false, code: source, reason: "could not locate a Vite config plugins array to patch" };
262
- }
263
- const ms = new MagicString(source);
264
- const alreadyImported = source.includes(LUNORA_VITE_DOUBLE) || source.includes(LUNORA_VITE_SINGLE);
265
- if (alreadyImported) {
266
- patchPluginsArray(ms, configObject);
267
- } else {
268
- addImport(ms, source);
269
- patchPluginsArray(ms, configObject);
270
- }
271
- return { changed: true, code: ms.toString() };
371
+ });
372
+
373
+ const toggle = (): void => {
374
+ theme.value = theme.value === "light" ? "dark" : "light";
272
375
  };
376
+ <\/script>
273
377
 
274
- const STACK_FEATURE_OPTIONS = [
275
- { description: "Sign-up / sign-in (asks which provider)", label: "Authentication", value: "auth" },
276
- { description: "Cloudflare Email Workers + a dev mail catcher", label: "Transactional email", value: "email" }
277
- ];
278
- const offerRegistryExtras = async (deps) => {
279
- if (!deps.interactive) {
280
- deps.logger.info("tip: add authentication or email later with `lunora add auth` / `lunora add email`.");
281
- return;
282
- }
283
- const picked = await deps.multiSelect("Which features do you want to add?", STACK_FEATURE_OPTIONS, { defaults: [] });
284
- for (const feature of picked) {
285
- if (feature === "auth") {
286
- const provider = await promptAuthProvider(deps.select);
287
- await deps.apply([provider]);
288
- } else {
289
- await deps.apply([EMAIL_ITEM]);
290
- }
291
- }
378
+ <template>
379
+ <div class="lunora-welcome" :data-theme="theme">
380
+ <div class="lw-bg">
381
+ <div class="arc a1" />
382
+ <div class="arc a2" />
383
+ <div class="glow" />
384
+ </div>
385
+
386
+ <button class="lw-toggle" type="button" aria-label="Toggle color theme" @click="toggle">
387
+ <svg v-if="theme === 'light'" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
388
+ <path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z" />
389
+ </svg>
390
+ <svg v-else viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
391
+ <circle cx="12" cy="12" r="4" />
392
+ <path d="M12 2v2M12 20v2M4 12H2M22 12h-2M5 5l1.5 1.5M17.5 17.5 19 19M19 5l-1.5 1.5M6.5 17.5 5 19" />
393
+ </svg>
394
+ <span>{{ theme === "light" ? "Ivory" : "Night" }}</span>
395
+ </button>
396
+
397
+ <div class="lw-wrap">
398
+ <div class="brand">
399
+ <svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
400
+ <path d="${N}" fill="currentColor" fill-rule="evenodd" />
401
+ </svg>
402
+ <span class="word">Lunora</span>
403
+ </div>
404
+
405
+ <div class="grid">
406
+ <a class="card feature" href="https://lunora.sh/docs">
407
+ <div class="shot" aria-hidden="true">
408
+ <div class="top">
409
+ <span class="wm"><i /> Lunora</span>
410
+ <span class="search" />
411
+ <span class="ver">v0.1</span>
412
+ </div>
413
+ <div class="body">
414
+ <div class="nav">
415
+ <i style="width: 80%" />
416
+ <i style="width: 60%" />
417
+ <i style="width: 72%" />
418
+ <i style="width: 50%" />
419
+ <i style="width: 66%" />
420
+ <i style="width: 44%" />
421
+ <i style="width: 58%" />
422
+ </div>
423
+ <div class="doc">
424
+ <span class="h" />
425
+ <i style="width: 92%" />
426
+ <i style="width: 88%" />
427
+ <span class="accent" />
428
+ <i style="width: 80%" />
429
+ <i style="width: 90%" />
430
+ <i style="width: 72%" />
431
+ <i style="width: 84%" />
432
+ <i style="width: 78%" />
433
+ </div>
434
+ </div>
435
+ </div>
436
+ <div class="info">
437
+ <span class="ic">
438
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
439
+ <path d="M4 5a2 2 0 0 1 2-2h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z" />
440
+ <path d="M14 3v5h5" />
441
+ </svg>
442
+ </span>
443
+ <h2>Documentation</h2>
444
+ <div class="row">
445
+ <p>
446
+ Schemas, queries, live subscriptions, sharding, and edge deploy — start to finish. New here or coming from Convex or tRPC,
447
+ you'll have a live app fast.
448
+ </p>
449
+ <span class="arrow">
450
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
451
+ <path d="M5 12h14M13 6l6 6-6 6" />
452
+ </svg>
453
+ </span>
454
+ </div>
455
+ </div>
456
+ </a>
457
+
458
+ <div class="stack">
459
+ <a class="card mini" href="https://lunora.sh/blog">
460
+ <div class="mc">
461
+ <span class="ic">
462
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
463
+ <path d="M5 4h11a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H6a2 2 0 0 1-2-2V5a1 1 0 0 1 1-1zM8 8h7M8 12h7M8 16h4" />
464
+ </svg>
465
+ </span>
466
+ <h3>Blog</h3>
467
+ <p>Product updates, deep dives, and what's new in Lunora.</p>
468
+ </div>
469
+ <span class="arrow">
470
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
471
+ <path d="M5 12h14M13 6l6 6-6 6" />
472
+ </svg>
473
+ </span>
474
+ </a>
475
+ <a class="card mini" href="/_lunora">
476
+ <div class="mc">
477
+ <span class="ic">
478
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
479
+ <rect x="3" y="3" width="18" height="18" rx="1" />
480
+ <path d="M3 9h18M9 21V9" />
481
+ </svg>
482
+ </span>
483
+ <h3>Lunora Studio</h3>
484
+ <p>Local admin for schema, data, logs, and advisors.</p>
485
+ </div>
486
+ <span class="arrow">
487
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
488
+ <path d="M5 12h14M13 6l6 6-6 6" />
489
+ </svg>
490
+ </span>
491
+ </a>
492
+ <a class="card mini" href="https://lunora.sh/packages">
493
+ <div class="mc">
494
+ <span class="ic">
495
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
496
+ <path d="M12 2 3 7v10l9 5 9-5V7z" />
497
+ <path d="M3 7l9 5 9-5M12 12v10" />
498
+ </svg>
499
+ </span>
500
+ <h3>Cloudflare ecosystem</h3>
501
+ <p>Auth, mail, storage, AI, payments — one deploy.</p>
502
+ </div>
503
+ <span class="arrow">
504
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
505
+ <path d="M5 12h14M13 6l6 6-6 6" />
506
+ </svg>
507
+ </span>
508
+ </a>
509
+ </div>
510
+ </div>
511
+
512
+ <div class="lw-foot">Running on Lunora · Vite + Vue</div>
513
+ </div>
514
+ </div>
515
+ </template>
516
+ `,Yt=`import { createSignal, onMount } from "solid-js";
517
+
518
+ export default function App() {
519
+ // Default to "dark" for a stable first paint, then reconcile to the OS
520
+ // preference; the toggle takes over after that.
521
+ const [theme, setTheme] = createSignal<"dark" | "light">("dark");
522
+
523
+ onMount(() => {
524
+ if (window.matchMedia("(prefers-color-scheme: light)").matches) {
525
+ setTheme("light");
526
+ }
527
+ });
528
+
529
+ const isLight = () => theme() === "light";
530
+
531
+ return (
532
+ <div class="lunora-welcome" data-theme={theme()}>
533
+ <div class="lw-bg">
534
+ <div class="arc a1" />
535
+ <div class="arc a2" />
536
+ <div class="glow" />
537
+ </div>
538
+
539
+ <button class="lw-toggle" type="button" aria-label="Toggle color theme" onClick={() => setTheme(isLight() ? "dark" : "light")}>
540
+ {isLight() ? (
541
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
542
+ <path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z" />
543
+ </svg>
544
+ ) : (
545
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
546
+ <circle cx="12" cy="12" r="4" />
547
+ <path d="M12 2v2M12 20v2M4 12H2M22 12h-2M5 5l1.5 1.5M17.5 17.5 19 19M19 5l-1.5 1.5M6.5 17.5 5 19" />
548
+ </svg>
549
+ )}
550
+ <span>{isLight() ? "Ivory" : "Night"}</span>
551
+ </button>
552
+
553
+ <div class="lw-wrap">
554
+ <div class="brand">
555
+ <svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
556
+ <path d="${N}" fill="currentColor" fill-rule="evenodd" />
557
+ </svg>
558
+ <span class="word">Lunora</span>
559
+ </div>
560
+
561
+ <div class="grid">
562
+ <a class="card feature" href="https://lunora.sh/docs">
563
+ <div class="shot" aria-hidden="true">
564
+ <div class="top">
565
+ <span class="wm">
566
+ <i /> Lunora
567
+ </span>
568
+ <span class="search" />
569
+ <span class="ver">v0.1</span>
570
+ </div>
571
+ <div class="body">
572
+ <div class="nav">
573
+ <i style={{ width: "80%" }} />
574
+ <i style={{ width: "60%" }} />
575
+ <i style={{ width: "72%" }} />
576
+ <i style={{ width: "50%" }} />
577
+ <i style={{ width: "66%" }} />
578
+ <i style={{ width: "44%" }} />
579
+ <i style={{ width: "58%" }} />
580
+ </div>
581
+ <div class="doc">
582
+ <span class="h" />
583
+ <i style={{ width: "92%" }} />
584
+ <i style={{ width: "88%" }} />
585
+ <span class="accent" />
586
+ <i style={{ width: "80%" }} />
587
+ <i style={{ width: "90%" }} />
588
+ <i style={{ width: "72%" }} />
589
+ <i style={{ width: "84%" }} />
590
+ <i style={{ width: "78%" }} />
591
+ </div>
592
+ </div>
593
+ </div>
594
+ <div class="info">
595
+ <span class="ic">
596
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
597
+ <path d="M4 5a2 2 0 0 1 2-2h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z" />
598
+ <path d="M14 3v5h5" />
599
+ </svg>
600
+ </span>
601
+ <h2>Documentation</h2>
602
+ <div class="row">
603
+ <p>
604
+ Schemas, queries, live subscriptions, sharding, and edge deploy — start to finish. New here or coming from Convex or tRPC,
605
+ you'll have a live app fast.
606
+ </p>
607
+ <span class="arrow">
608
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
609
+ <path d="M5 12h14M13 6l6 6-6 6" />
610
+ </svg>
611
+ </span>
612
+ </div>
613
+ </div>
614
+ </a>
615
+
616
+ <div class="stack">
617
+ <a class="card mini" href="https://lunora.sh/blog">
618
+ <div class="mc">
619
+ <span class="ic">
620
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
621
+ <path d="M5 4h11a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H6a2 2 0 0 1-2-2V5a1 1 0 0 1 1-1zM8 8h7M8 12h7M8 16h4" />
622
+ </svg>
623
+ </span>
624
+ <h3>Blog</h3>
625
+ <p>Product updates, deep dives, and what's new in Lunora.</p>
626
+ </div>
627
+ <span class="arrow">
628
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
629
+ <path d="M5 12h14M13 6l6 6-6 6" />
630
+ </svg>
631
+ </span>
632
+ </a>
633
+ <a class="card mini" href="/_lunora">
634
+ <div class="mc">
635
+ <span class="ic">
636
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
637
+ <rect x="3" y="3" width="18" height="18" rx="1" />
638
+ <path d="M3 9h18M9 21V9" />
639
+ </svg>
640
+ </span>
641
+ <h3>Lunora Studio</h3>
642
+ <p>Local admin for schema, data, logs, and advisors.</p>
643
+ </div>
644
+ <span class="arrow">
645
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
646
+ <path d="M5 12h14M13 6l6 6-6 6" />
647
+ </svg>
648
+ </span>
649
+ </a>
650
+ <a class="card mini" href="https://lunora.sh/packages">
651
+ <div class="mc">
652
+ <span class="ic">
653
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
654
+ <path d="M12 2 3 7v10l9 5 9-5V7z" />
655
+ <path d="M3 7l9 5 9-5M12 12v10" />
656
+ </svg>
657
+ </span>
658
+ <h3>Cloudflare ecosystem</h3>
659
+ <p>Auth, mail, storage, AI, payments — one deploy.</p>
660
+ </div>
661
+ <span class="arrow">
662
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
663
+ <path d="M5 12h14M13 6l6 6-6 6" />
664
+ </svg>
665
+ </span>
666
+ </a>
667
+ </div>
668
+ </div>
669
+
670
+ <div class="lw-foot">Running on Lunora · Vite + Solid</div>
671
+ </div>
672
+ </div>
673
+ );
674
+ }
675
+ `,Xt=`<script lang="ts">
676
+ import { onMount } from "svelte";
677
+
678
+ // Default to "dark" for a stable first paint, then reconcile to the OS
679
+ // preference; the toggle takes over after that.
680
+ let theme = $state<"dark" | "light">("dark");
681
+ const isLight = $derived(theme === "light");
682
+
683
+ onMount(() => {
684
+ if (window.matchMedia("(prefers-color-scheme: light)").matches) {
685
+ theme = "light";
686
+ }
687
+ });
688
+
689
+ const toggle = (): void => {
690
+ theme = theme === "light" ? "dark" : "light";
691
+ };
692
+ <\/script>
693
+
694
+ <div class="lunora-welcome" data-theme={theme}>
695
+ <div class="lw-bg">
696
+ <div class="arc a1"></div>
697
+ <div class="arc a2"></div>
698
+ <div class="glow"></div>
699
+ </div>
700
+
701
+ <button class="lw-toggle" type="button" aria-label="Toggle color theme" onclick={toggle}>
702
+ {#if isLight}
703
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
704
+ <path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z" />
705
+ </svg>
706
+ {:else}
707
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
708
+ <circle cx="12" cy="12" r="4" />
709
+ <path d="M12 2v2M12 20v2M4 12H2M22 12h-2M5 5l1.5 1.5M17.5 17.5 19 19M19 5l-1.5 1.5M6.5 17.5 5 19" />
710
+ </svg>
711
+ {/if}
712
+ <span>{isLight ? "Ivory" : "Night"}</span>
713
+ </button>
714
+
715
+ <div class="lw-wrap">
716
+ <div class="brand">
717
+ <svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
718
+ <path d="${N}" fill="currentColor" fill-rule="evenodd" />
719
+ </svg>
720
+ <span class="word">Lunora</span>
721
+ </div>
722
+
723
+ <div class="grid">
724
+ <a class="card feature" href="https://lunora.sh/docs">
725
+ <div class="shot" aria-hidden="true">
726
+ <div class="top">
727
+ <span class="wm"><i></i> Lunora</span>
728
+ <span class="search"></span>
729
+ <span class="ver">v0.1</span>
730
+ </div>
731
+ <div class="body">
732
+ <div class="nav">
733
+ <i style="width: 80%"></i>
734
+ <i style="width: 60%"></i>
735
+ <i style="width: 72%"></i>
736
+ <i style="width: 50%"></i>
737
+ <i style="width: 66%"></i>
738
+ <i style="width: 44%"></i>
739
+ <i style="width: 58%"></i>
740
+ </div>
741
+ <div class="doc">
742
+ <span class="h"></span>
743
+ <i style="width: 92%"></i>
744
+ <i style="width: 88%"></i>
745
+ <span class="accent"></span>
746
+ <i style="width: 80%"></i>
747
+ <i style="width: 90%"></i>
748
+ <i style="width: 72%"></i>
749
+ <i style="width: 84%"></i>
750
+ <i style="width: 78%"></i>
751
+ </div>
752
+ </div>
753
+ </div>
754
+ <div class="info">
755
+ <span class="ic">
756
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
757
+ <path d="M4 5a2 2 0 0 1 2-2h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z" />
758
+ <path d="M14 3v5h5" />
759
+ </svg>
760
+ </span>
761
+ <h2>Documentation</h2>
762
+ <div class="row">
763
+ <p>
764
+ Schemas, queries, live subscriptions, sharding, and edge deploy — start to finish. New here or coming from Convex or tRPC,
765
+ you'll have a live app fast.
766
+ </p>
767
+ <span class="arrow">
768
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
769
+ <path d="M5 12h14M13 6l6 6-6 6" />
770
+ </svg>
771
+ </span>
772
+ </div>
773
+ </div>
774
+ </a>
775
+
776
+ <div class="stack">
777
+ <a class="card mini" href="https://lunora.sh/blog">
778
+ <div class="mc">
779
+ <span class="ic">
780
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
781
+ <path d="M5 4h11a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H6a2 2 0 0 1-2-2V5a1 1 0 0 1 1-1zM8 8h7M8 12h7M8 16h4" />
782
+ </svg>
783
+ </span>
784
+ <h3>Blog</h3>
785
+ <p>Product updates, deep dives, and what's new in Lunora.</p>
786
+ </div>
787
+ <span class="arrow">
788
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
789
+ <path d="M5 12h14M13 6l6 6-6 6" />
790
+ </svg>
791
+ </span>
792
+ </a>
793
+ <a class="card mini" href="/_lunora">
794
+ <div class="mc">
795
+ <span class="ic">
796
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
797
+ <rect x="3" y="3" width="18" height="18" rx="1" />
798
+ <path d="M3 9h18M9 21V9" />
799
+ </svg>
800
+ </span>
801
+ <h3>Lunora Studio</h3>
802
+ <p>Local admin for schema, data, logs, and advisors.</p>
803
+ </div>
804
+ <span class="arrow">
805
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
806
+ <path d="M5 12h14M13 6l6 6-6 6" />
807
+ </svg>
808
+ </span>
809
+ </a>
810
+ <a class="card mini" href="https://lunora.sh/packages">
811
+ <div class="mc">
812
+ <span class="ic">
813
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
814
+ <path d="M12 2 3 7v10l9 5 9-5V7z" />
815
+ <path d="M3 7l9 5 9-5M12 12v10" />
816
+ </svg>
817
+ </span>
818
+ <h3>Cloudflare ecosystem</h3>
819
+ <p>Auth, mail, storage, AI, payments — one deploy.</p>
820
+ </div>
821
+ <span class="arrow">
822
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
823
+ <path d="M5 12h14M13 6l6 6-6 6" />
824
+ </svg>
825
+ </span>
826
+ </a>
827
+ </div>
828
+ </div>
829
+
830
+ <div class="lw-foot">Running on Lunora · Vite + Svelte</div>
831
+ </div>
832
+ </div>
833
+ `,Qt=`import "./style.css";
834
+
835
+ import { LunoraClient } from "lunorash/client";
836
+
837
+ import { api } from "#lunora/_generated/api.js";
838
+
839
+ // \`@lunora/vite\` runs the Worker on the same origin as Vite, so default to
840
+ // \`location.origin\`. Point \`VITE_LUNORA_URL\` at a deployed Worker to develop
841
+ // the client against production data.
842
+ const url = (import.meta.env.VITE_LUNORA_URL as string | undefined) ?? globalThis.location.origin;
843
+ const client = new LunoraClient({ url });
844
+
845
+ const MOON_ICON = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z" /></svg>';
846
+ const SUN_ICON =
847
+ '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><circle cx="12" cy="12" r="4" /><path d="M12 2v2M12 20v2M4 12H2M22 12h-2M5 5l1.5 1.5M17.5 17.5 19 19M19 5l-1.5 1.5M6.5 17.5 5 19" /></svg>';
848
+
849
+ const welcomeHtml = \`
850
+ <div class="lw-bg">
851
+ <div class="arc a1"></div>
852
+ <div class="arc a2"></div>
853
+ <div class="glow"></div>
854
+ </div>
855
+
856
+ <button class="lw-toggle" type="button" aria-label="Toggle color theme"></button>
857
+
858
+ <div class="lw-wrap">
859
+ <div class="brand">
860
+ <svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
861
+ <path d="${N}" fill="currentColor" fill-rule="evenodd" />
862
+ </svg>
863
+ <span class="word">Lunora</span>
864
+ </div>
865
+
866
+ <div class="grid">
867
+ <a class="card feature" href="https://lunora.sh/docs">
868
+ <div class="shot" aria-hidden="true">
869
+ <div class="top">
870
+ <span class="wm"><i></i> Lunora</span>
871
+ <span class="search"></span>
872
+ <span class="ver">v0.1</span>
873
+ </div>
874
+ <div class="body">
875
+ <div class="nav">
876
+ <i style="width: 80%"></i>
877
+ <i style="width: 60%"></i>
878
+ <i style="width: 72%"></i>
879
+ <i style="width: 50%"></i>
880
+ <i style="width: 66%"></i>
881
+ <i style="width: 44%"></i>
882
+ <i style="width: 58%"></i>
883
+ </div>
884
+ <div class="doc">
885
+ <span class="h"></span>
886
+ <i style="width: 92%"></i>
887
+ <i style="width: 88%"></i>
888
+ <span class="accent"></span>
889
+ <i style="width: 80%"></i>
890
+ <i style="width: 90%"></i>
891
+ <i style="width: 72%"></i>
892
+ <i style="width: 84%"></i>
893
+ <i style="width: 78%"></i>
894
+ </div>
895
+ </div>
896
+ </div>
897
+ <div class="info">
898
+ <span class="ic">
899
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
900
+ <path d="M4 5a2 2 0 0 1 2-2h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z" />
901
+ <path d="M14 3v5h5" />
902
+ </svg>
903
+ </span>
904
+ <h2>Documentation</h2>
905
+ <div class="row">
906
+ <p>
907
+ Schemas, queries, live subscriptions, sharding, and edge deploy — start to finish. New here or coming from Convex or tRPC,
908
+ you'll have a live app fast.
909
+ </p>
910
+ <span class="arrow">
911
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
912
+ <path d="M5 12h14M13 6l6 6-6 6" />
913
+ </svg>
914
+ </span>
915
+ </div>
916
+ </div>
917
+ </a>
918
+
919
+ <div class="stack">
920
+ <a class="card mini" href="https://lunora.sh/blog">
921
+ <div class="mc">
922
+ <span class="ic">
923
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
924
+ <path d="M5 4h11a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H6a2 2 0 0 1-2-2V5a1 1 0 0 1 1-1zM8 8h7M8 12h7M8 16h4" />
925
+ </svg>
926
+ </span>
927
+ <h3>Blog</h3>
928
+ <p>Product updates, deep dives, and what's new in Lunora.</p>
929
+ </div>
930
+ <span class="arrow">
931
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
932
+ <path d="M5 12h14M13 6l6 6-6 6" />
933
+ </svg>
934
+ </span>
935
+ </a>
936
+ <a class="card mini" href="/_lunora">
937
+ <div class="mc">
938
+ <span class="ic">
939
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
940
+ <rect x="3" y="3" width="18" height="18" rx="1" />
941
+ <path d="M3 9h18M9 21V9" />
942
+ </svg>
943
+ </span>
944
+ <h3>Lunora Studio</h3>
945
+ <p>Local admin for schema, data, logs, and advisors.</p>
946
+ </div>
947
+ <span class="arrow">
948
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
949
+ <path d="M5 12h14M13 6l6 6-6 6" />
950
+ </svg>
951
+ </span>
952
+ </a>
953
+ <a class="card mini" href="https://lunora.sh/packages">
954
+ <div class="mc">
955
+ <span class="ic">
956
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
957
+ <path d="M12 2 3 7v10l9 5 9-5V7z" />
958
+ <path d="M3 7l9 5 9-5M12 12v10" />
959
+ </svg>
960
+ </span>
961
+ <h3>Cloudflare ecosystem</h3>
962
+ <p>Auth, mail, storage, AI, payments — one deploy.</p>
963
+ </div>
964
+ <span class="arrow">
965
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
966
+ <path d="M5 12h14M13 6l6 6-6 6" />
967
+ </svg>
968
+ </span>
969
+ </a>
970
+ </div>
971
+ </div>
972
+
973
+ <div class="lw-foot">Running on Lunora · Vite + Vanilla · <span id="lw-count">0</span> messages</div>
974
+ </div>
975
+ \`;
976
+
977
+ const root = document.querySelector<HTMLDivElement>("#app")!;
978
+ root.classList.add("lunora-welcome");
979
+ root.innerHTML = welcomeHtml;
980
+
981
+ // Theme toggle: flip the root's data-theme + swap the button's icon/label.
982
+ const toggleButton = root.querySelector<HTMLButtonElement>(".lw-toggle")!;
983
+
984
+ const paintToggle = (theme: "dark" | "light"): void => {
985
+ root.dataset.theme = theme;
986
+ toggleButton.innerHTML = \`\${theme === "light" ? MOON_ICON : SUN_ICON}<span>\${theme === "light" ? "Ivory" : "Night"}</span>\`;
292
987
  };
293
988
 
294
- const TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".gitignore", ".html", ".js", ".json", ".jsonc", ".md", ".mjs", ".ts", ".tsx"]);
295
- const VITE_CONFIG_CANDIDATES = ["vite.config.ts", "vite.config.mts", "vite.config.js", "vite.config.mjs"];
296
- const MINIMAL_VITE_CONFIG = `import { defineConfig } from "vite";
989
+ paintToggle(window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark");
990
+ toggleButton.addEventListener("click", () => {
991
+ paintToggle(root.dataset.theme === "light" ? "dark" : "light");
992
+ });
993
+
994
+ // Live demo: the message count of a demo channel re-renders on every delta.
995
+ const count = document.querySelector<HTMLSpanElement>("#lw-count")!;
996
+
997
+ client.onUpdate(api.messages.list, { channelId: "channel:demo" }, (result) => {
998
+ count.textContent = String(result.messages.length);
999
+ });
1000
+ `,O="const url = (import.meta.env.VITE_LUNORA_URL as string | undefined) ?? globalThis.location.origin;",Zt=`import "./index.css";
1001
+
1002
+ import { LunoraProvider } from "@lunora/react";
1003
+ import { LunoraClient } from "lunorash/client";
1004
+ import { StrictMode } from "react";
1005
+ import { createRoot } from "react-dom/client";
1006
+
1007
+ import App from "./App.tsx";
1008
+
1009
+ // \`@lunora/vite\` runs the Worker on the same origin as Vite, so default to
1010
+ // \`location.origin\`. Point \`VITE_LUNORA_URL\` at a deployed Worker to develop
1011
+ // the client against production data.
1012
+ ${O}
1013
+ const client = new LunoraClient({ url });
1014
+
1015
+ const root = document.getElementById("root");
1016
+
1017
+ if (!root) {
1018
+ throw new Error("missing #root mount node");
1019
+ }
1020
+
1021
+ createRoot(root).render(
1022
+ <StrictMode>
1023
+ <LunoraProvider client={client}>
1024
+ <App />
1025
+ </LunoraProvider>
1026
+ </StrictMode>,
1027
+ );
1028
+ `,ea=`import "./style.css";
1029
+
1030
+ import { createLunora } from "@lunora/vue";
1031
+ import { LunoraClient } from "lunorash/client";
1032
+ import { createApp } from "vue";
1033
+
1034
+ import App from "./App.vue";
1035
+
1036
+ // Provide one LunoraClient at the app root via the Vue plugin form.
1037
+ ${O}
1038
+ createApp(App).use(createLunora(new LunoraClient({ url }))).mount("#app");
1039
+ `,ta=`import "./index.css";
1040
+
1041
+ import { LunoraProvider } from "@lunora/solid";
1042
+ import { LunoraClient } from "lunorash/client";
1043
+ import { render } from "solid-js/web";
1044
+
1045
+ import App from "./App";
1046
+
1047
+ ${O}
1048
+ const client = new LunoraClient({ url });
1049
+ const root = document.getElementById("root");
1050
+
1051
+ render(
1052
+ () => (
1053
+ <LunoraProvider client={client}>
1054
+ <App />
1055
+ </LunoraProvider>
1056
+ ),
1057
+ root!,
1058
+ );
1059
+ `,aa=`<script lang="ts">
1060
+ import { setLunoraClient } from "@lunora/svelte";
1061
+ import { LunoraClient } from "lunorash/client";
1062
+
1063
+ import App from "./App.svelte";
1064
+
1065
+ ${O}
1066
+ setLunoraClient(new LunoraClient({ url }));
1067
+ <\/script>
1068
+
1069
+ <App />
1070
+ `,ra=`import "./app.css";
1071
+
1072
+ import { mount } from "svelte";
1073
+
1074
+ import Root from "./Root.svelte";
1075
+
1076
+ // Mount \`Root\` (it sets the ambient LunoraClient) rather than \`App\` directly.
1077
+ const app = mount(Root, { target: document.getElementById("app")! });
1078
+
1079
+ export default app;
1080
+ `,T={react:{adapter:"@lunora/react",createViteTemplate:"react-ts",files:[{contents:Zt,path:"src/main.tsx"},{contents:Gt,path:"src/App.tsx"},{contents:L,path:"src/index.css"}],label:"React"},solid:{adapter:"@lunora/solid",createViteTemplate:"solid-ts",files:[{contents:ta,path:"src/index.tsx"},{contents:Yt,path:"src/App.tsx"},{contents:L,path:"src/index.css"}],label:"Solid"},svelte:{adapter:"@lunora/svelte",createViteTemplate:"svelte-ts",files:[{contents:aa,path:"src/Root.svelte"},{contents:ra,path:"src/main.ts"},{contents:Xt,path:"src/App.svelte"},{contents:L,path:"src/app.css"}],label:"Svelte"},vanilla:{adapter:"lunorash/client",createViteTemplate:"vanilla-ts",files:[{contents:Qt,path:"src/main.ts"},{contents:L,path:"src/style.css"}],label:"Vanilla"},vue:{adapter:"@lunora/vue",createViteTemplate:"vue-ts",files:[{contents:ea,path:"src/main.ts"},{contents:Jt,path:"src/App.vue"},{contents:L,path:"src/style.css"}],label:"Vue"}},z=e=>Object.hasOwn(T,e),oa=`import type { Middleware } from "lunorash/server";
1081
+ import { defineSchemaExtension, defineTable, definePlugin, v } from "lunorash/server";
1082
+ import { createDbStore, RateLimiter } from "lunorash/ratelimit";
1083
+ import type { RateLimitConfigMap } from "lunorash/ratelimit";
1084
+
1085
+ export const limits = {
1086
+ default: { kind: "token bucket", period: 60_000, rate: 10 },
1087
+ } as const satisfies RateLimitConfigMap;
1088
+
1089
+ export type LimitName = keyof typeof limits;
1090
+
1091
+ export const makeRateLimiter = (ctx: { db: unknown }): RateLimiter<LimitName> =>
1092
+ new RateLimiter<LimitName>({
1093
+ config: limits,
1094
+ store: createDbStore({ db: ctx.db as never, table: "ratelimit_buckets" }),
1095
+ });
1096
+
1097
+ const middleware: Middleware<{ api?: Record<string, unknown>; db: unknown }, { api: Record<string, unknown>; db: unknown }> = ({ ctx, next }) =>
1098
+ next({
1099
+ ctx: {
1100
+ ...ctx,
1101
+ api: { ...ctx.api, ratelimit: makeRateLimiter(ctx) },
1102
+ },
1103
+ });
1104
+
1105
+ export const ratelimit = definePlugin("ratelimit", {
1106
+ extension: defineSchemaExtension("ratelimit", {
1107
+ tables: {
1108
+ buckets: defineTable({
1109
+ key: v.string(),
1110
+ value: v.number(),
1111
+ ts: v.number(),
1112
+ prev: v.optional(v.number()),
1113
+ })
1114
+ .index("by_key", ["key"])
1115
+ .externallyManaged(),
1116
+ },
1117
+ }),
1118
+ middleware,
1119
+ });
1120
+ `,sa=`import { ratelimit } from "./ratelimit/schema.js";
1121
+ import { defineSchema, defineTable, v } from "lunorash/server";
1122
+
1123
+ export default defineSchema({
1124
+ messages: defineTable({
1125
+ channelId: v.string(),
1126
+ text: v.string(),
1127
+ })
1128
+ .shardBy("channelId")
1129
+ .index("by_channel", ["channelId"]),
1130
+ }).extend(ratelimit.extension);
1131
+ `,na=`import { RateLimiter, rateLimit, createDbStore } from "lunorash/ratelimit";
1132
+
1133
+ import { mutation, query, v } from "#lunora/_generated/server.js";
1134
+
1135
+ const limiter = (ctx: { db: unknown }) => new RateLimiter({
1136
+ config: {
1137
+ send: { kind: "token bucket", period: 60_000, rate: 30 },
1138
+ },
1139
+ store: createDbStore({ db: ctx.db as never, table: "ratelimit_buckets" }),
1140
+ });
1141
+
1142
+ export const list = query.input({ channelId: v.string().meta({ schema: { maxLength: 256 } }), limit: v.optional(v.number()) }).query(async ({ args, ctx }) => {
1143
+ const messages = await ctx.db
1144
+ .query("messages")
1145
+ .withIndex("by_channel", (q) => q.eq("channelId", args.channelId))
1146
+ .take(args.limit ?? 50);
1147
+
1148
+ return { channelId: args.channelId, messages };
1149
+ });
1150
+
1151
+ export const send = mutation
1152
+ .input({ channelId: v.string().meta({ schema: { maxLength: 256 } }), text: v.string().meta({ schema: { maxLength: 4096 } }) })
1153
+ .use(rateLimit(limiter, "send", { key: (ctx) => ctx.auth.userId ?? "anon" }))
1154
+ .mutation(async ({ args, ctx }) => {
1155
+ const id = await ctx.db.insert("messages", { channelId: args.channelId, text: args.text });
1156
+
1157
+ return { channelId: args.channelId, id, text: args.text };
1158
+ });
1159
+ `,ia=`import type { ShardNamespaceLike } from "lunorash/runtime";
1160
+
1161
+ import { defineApp } from "../lunora/_generated/app.js";
1162
+
1163
+ interface Env extends Record<string, unknown> {
1164
+ SHARD: ShardNamespaceLike;
1165
+ }
1166
+
1167
+ const app = defineApp<Env>()
1168
+ .shard((env) => env.SHARD)
1169
+ .build();
1170
+
1171
+ export const ShardDO = app.ShardDO;
1172
+ export default app;
1173
+ `,la=`{
1174
+ "$schema": "node_modules/wrangler/config-schema.json",
1175
+ "name": "__NAME__",
1176
+ "main": "src/server.ts",
1177
+ "compatibility_date": "2026-06-10",
1178
+ "compatibility_flags": ["nodejs_compat"],
1179
+ "durable_objects": {
1180
+ "bindings": [{ "name": "SHARD", "class_name": "ShardDO" }],
1181
+ },
1182
+ "migrations": [{ "tag": "v1", "new_sqlite_classes": ["ShardDO"] }],
1183
+ "observability": { "enabled": true, "head_sampling_rate": 1 },
1184
+ }
1185
+ `,ca=[".wrangler",".env",".env.*","!.env.example",".dev.vars",".dev.vars.*","!.dev.vars.example",".lunora/",".lunora-cache","lunora/_generated"],da=`# Lunora endpoint for the browser client.
1186
+ # Vite statically replaces \`import.meta.env.VITE_LUNORA_URL\` at \`vite dev\` / build.
1187
+ # Leave it unset to use the page origin; set it to point at a deployed Worker:
1188
+ #
1189
+ # VITE_LUNORA_URL=https://my-app.example.workers.dev
1190
+ `,ua={"@cloudflare/workers-types":"^4.20260611.1",wrangler:"^4.100.0"},x=(e,t,a,r)=>{const o=u(e,t);M(A(o),{recursive:!0}),v(o,a,"utf8"),r.push(o)},pa=/\r?\n/,ha=e=>{const t=u(e,".gitignore"),a=m(t)?b(t,"utf8"):"",r=new Set(a.split(pa)),o=ca.filter(n=>!r.has(n));if(o.length===0)return;const s=a.length>0&&!a.endsWith(`
1191
+ `)?`
1192
+ `:"";v(t,`${a}${s}
1193
+ # Lunora
1194
+ ${o.join(`
1195
+ `)}
1196
+ `,"utf8")},P=e=>e==="lunorash"||e.startsWith("@lunora/"),ma=(e,t,a,r)=>P(e)?r.get(e)??a:t,k=(e,t,a)=>({...e,[t]:a}),ee=(e,t,a)=>Object.fromEntries(Object.entries(e).map(([r,o])=>[r,ma(r,o,t,a)])),fa=async(e,t,a,r)=>{const o=u(e,"package.json"),s=JSON.parse(b(o,"utf8"));let n=k(s.dependencies??{},"lunorash",r);n=k(n,"@lunora/ratelimit",r),a.adapter.startsWith("@lunora/")&&(n=k(n,a.adapter,r));for(const[c,p]of Object.entries(a.extraDependencies??{}))n=k(n,c,p);let i=k(s.devDependencies??{},"@lunora/vite",r);i=k(i,"@lunora/studio",r);for(const[c,p]of Object.entries(ua))i=k(i,c,p);const l=[...Object.keys(n),...Object.keys(i)].filter(c=>P(c)),d=await ce(l,r);s.name=t,s.imports={...s.imports,"#lunora/*":"./lunora/*"},s.dependencies=ee(n,r,d),s.devDependencies=ee(i,r,d),s.scripts={...s.scripts,codegen:"lunora codegen",deploy:"vite build && lunora deploy"},v(o,`${JSON.stringify(s,void 0,4)}
1197
+ `,"utf8")},va=["vite.config.ts","vite.config.mts","vite.config.js","vite.config.mjs"],Se=e=>va.map(t=>u(e,t)).find(t=>m(t)),ga=(e,t)=>{const a=Se(e);if(a===void 0){t.warn("overlay: no vite.config found in the create-vite base — add `lunora()` to your Vite plugins manually.");return}const r=ke(b(a,"utf8"));r.changed&&v(a,r.code,"utf8")},wa=async e=>{const{adapter:t,distTag:a,logger:r,name:o,target:s}=e,n=[];x(s,u("lunora","ratelimit","schema.ts"),oa,n),x(s,u("lunora","schema.ts"),sa,n),x(s,u("lunora","messages.ts"),na,n),x(s,u("src","server.ts"),ia,n),x(s,"wrangler.jsonc",la.replaceAll("__NAME__",o),n),x(s,".env.example",da,n);for(const i of t.files)x(s,i.path,i.contents,n);return ga(s,r),await fa(s,o,t,a),ha(s),n},ya=["lunar","silver","silent","waning","waxing","crescent","cosmic","stellar","orbital","gibbous","twilight","midnight","shimmering","drifting","weightless"],ba=["moon","tide","crater","comet","eclipse","halo","orbit","nebula","voyager","lander","rover","beacon","harbor","meadow","fox"],te=e=>e[Math.floor(Math.random()*e.length)],xa=()=>`${te(ya)}-${te(ba)}`,ka=async()=>vt.lookup("github.com").then(()=>!0,()=>!1),Ca=/^(?:gh|github):([^/]+)\/([^#/]+)(?:\/[^#]*)?(?:#(.+))?$/,Le=e=>{const t=Ca.exec(e);if(t===null)return;const[,a,r,o]=t;if(!(a===void 0||r===void 0))return{owner:a,ref:o??"HEAD",repo:r}},Sa=async e=>{const t=Le(e);if(t===void 0)return;const a=`https://codeload.github.com/${t.owner}/${t.repo}/tar.gz/${t.ref}`;try{const r=await fetch(a,{method:"HEAD"});return r.status===404?!1:r.ok?!0:void 0}catch{return}},Me=async e=>e.isLocal||!(e.source===void 0||Le(e.source)!==void 0)?!0:await ka()?e.source!==void 0&&await Sa(e.source)===!1?(e.logger.error(`template source not found: ${e.source} — double-check --ref / --source, or browse the templates at https://lunora.sh/docs.`),!1):!0:(e.logger.error("you appear to be offline — connect to the internet and try again, or scaffold from a local template with `--from <dir>`."),!1),y={extras:"Let's finish setting up your app.",framework:"Which framework should we launch?",git:"Initialize a new git repository? (optional)",install:"Install dependencies now?",name:"Where should we land your project?",nextHeader:"Liftoff confirmed — explore your project!",packageManager:"Which package manager?"},La=new Set([".gitignore",".html",".js",".json",".jsonc",".md",".mjs",".ts",".tsx"]),Ma=`import { defineConfig } from "vite";
297
1198
  import { lunora } from "@lunora/vite";
298
1199
 
299
1200
  export default defineConfig({ plugins: [lunora()] });
300
- `;
301
- const SAMPLE_SCHEMA = `import { defineSchema, defineTable, v } from "@lunora/server";
1201
+ `,Aa=`import { defineSchema, defineTable, v } from "@lunora/server";
302
1202
 
303
1203
  export default defineSchema({
304
1204
  messages: defineTable({
@@ -308,8 +1208,7 @@ export default defineSchema({
308
1208
  .shardBy("channelId")
309
1209
  .index("by_channel", ["channelId"]),
310
1210
  });
311
- `;
312
- const SAMPLE_FUNCTION = `import { mutation, query, v } from "./_generated/server";
1211
+ `,Ea=`import { mutation, query, v } from "./_generated/server";
313
1212
 
314
1213
  export const list = query
315
1214
  .input({ channelId: v.id("channels"), limit: v.optional(v.number()) })
@@ -322,331 +1221,8 @@ export const send = mutation
322
1221
  .mutation(async ({ args }) => {
323
1222
  return { channelId: args.channelId, text: args.text };
324
1223
  });
325
- `;
326
- const DEFAULT_SOURCE_BASE = "gh:anolilab/lunora/templates";
327
- const DEFAULT_SOURCE_REF_FALLBACK = "alpha";
328
- const resolveCliVersion = () => {
329
- try {
330
- let directory = dirname$1(fileURLToPath(import.meta.url));
331
- for (let index = 0; index < 5; index += 1) {
332
- const candidate = join$1(directory, "package.json");
333
- if (existsSync(candidate)) {
334
- const parsed = JSON.parse(readFileSync(candidate, "utf8"));
335
- if (parsed.name === "@lunora/cli" && typeof parsed.version === "string") {
336
- return parsed.version;
337
- }
338
- }
339
- const parent = dirname$1(directory);
340
- if (parent === directory) {
341
- break;
342
- }
343
- directory = parent;
344
- }
345
- } catch {
346
- }
347
- return "0.0.0";
348
- };
349
- const resolveDefaultSourceRef = () => {
350
- const version = resolveCliVersion();
351
- return version === "0.0.0" ? DEFAULT_SOURCE_REF_FALLBACK : `v${version}`;
352
- };
353
- const isTextFile = (filePath) => {
354
- const lastDot = filePath.lastIndexOf(".");
355
- if (lastDot === -1) {
356
- return false;
357
- }
358
- return TEXT_EXTENSIONS.has(filePath.slice(lastDot));
359
- };
360
- const substitute = (content, name) => content.replaceAll("{{name}}", name);
361
- const collectFiles = (directory) => {
362
- const out = [];
363
- for (const entry of walkSync(directory, { includeDirs: false, includeFiles: true })) {
364
- out.push(entry.path);
365
- }
366
- return out;
367
- };
368
- const copyTemplate = (sourceDirectory, target, name) => {
369
- const files = collectFiles(sourceDirectory);
370
- const written = [];
371
- for (const source of files) {
372
- const relativePath = relative(sourceDirectory, source);
373
- const destination = join$1(target, relativePath);
374
- mkdirSync(dirname$1(destination), { recursive: true });
375
- const raw = readFileSync(source);
376
- const text = isTextFile(source) ? substitute(raw.toString("utf8"), name) : void 0;
377
- if (text === void 0) {
378
- writeFileSync(destination, raw);
379
- } else {
380
- writeFileSync(destination, text, "utf8");
381
- }
382
- written.push(destination);
383
- }
384
- return written;
385
- };
386
- const resolveTemplateSource = (templateType, source) => {
387
- if (source !== void 0 && source.length > 0) {
388
- return source;
389
- }
390
- return `${DEFAULT_SOURCE_BASE}/${templateType}#${resolveDefaultSourceRef()}`;
391
- };
392
- const isSafeSource = (source) => {
393
- if (source.includes("..")) {
394
- return false;
395
- }
396
- return source.startsWith("gh:") || source.startsWith("github:") || source.startsWith("https://");
397
- };
398
- const logScaffoldSuccess = (logger, written, target, name) => {
399
- logger.success(`scaffolded ${String(written.length)} files into ${target}`);
400
- logger.info("next steps:");
401
- logger.info(` cd ${name}`);
402
- logger.info(" pnpm install");
403
- logger.info(" pnpm dev");
404
- };
405
- const scaffoldFromLocal = (fromRoot, templateType, target, name, logger) => {
406
- const templateDirectory = join$1(fromRoot, templateType);
407
- if (!existsSync(templateDirectory)) {
408
- logger.error(`template not found in local source: ${templateDirectory}`);
409
- return { code: 1, files: [], target };
410
- }
411
- const written = copyTemplate(templateDirectory, target, name);
412
- logScaffoldSuccess(logger, written, target, name);
413
- return { code: 0, files: written, target };
414
- };
415
- const scaffoldFromRemote = async (source, templateType, target, name, logger) => {
416
- const stagingRoot = mkdtempSync(join$1(tmpdir(), "lunora-init-fetch-"));
417
- const stagingDirectory = join$1(stagingRoot, "template");
418
- try {
419
- const remote = resolveTemplateSource(templateType, source);
420
- logger.info(`fetching template from ${remote}`);
421
- const downloaded = await downloadTemplate(remote, {
422
- cwd: stagingRoot,
423
- dir: stagingDirectory,
424
- force: true,
425
- install: false,
426
- silent: true
427
- });
428
- const staged = collectFiles(stagingDirectory);
429
- if (downloaded.commit) {
430
- logger.info(`resolved ${downloaded.source} @ ${downloaded.commit} (${String(staged.length)} file(s))`);
431
- } else {
432
- logger.info(`resolved ${downloaded.source} (${String(staged.length)} file(s))`);
433
- }
434
- const written = copyTemplate(stagingDirectory, target, name);
435
- logScaffoldSuccess(logger, written, target, name);
436
- return { code: 0, files: written, target };
437
- } catch (error) {
438
- const message = error instanceof Error ? error.message : String(error);
439
- logger.error(`failed to download template: ${message}`);
440
- return { code: 1, files: [], target };
441
- } finally {
442
- rmSync(stagingRoot, { force: true, recursive: true });
443
- }
444
- };
445
- const createMinimalViteConfig = (cwd, logger) => {
446
- const target = join$1(cwd, "vite.config.ts");
447
- try {
448
- writeFileSync(target, MINIMAL_VITE_CONFIG, "utf8");
449
- } catch (error) {
450
- const message = error instanceof Error ? error.message : String(error);
451
- logger.error(`init --in-place: could not write ${target}: ${message}`);
452
- return { code: 1, files: [], target: cwd };
453
- }
454
- logger.success(`created ${target} with lunora() plugin`);
455
- return { code: 0, files: [target], target: cwd };
456
- };
457
- const patchExistingViteConfig = (viteConfigPath, cwd, logger) => {
458
- let source;
459
- try {
460
- source = readFileSync(viteConfigPath, "utf8");
461
- } catch (error) {
462
- const message = error instanceof Error ? error.message : String(error);
463
- logger.error(`init --in-place: could not read ${viteConfigPath}: ${message}`);
464
- return { code: 1, files: [], target: cwd };
465
- }
466
- const result = patchViteConfig(source);
467
- if (!result.changed) {
468
- logger.info(`${viteConfigPath}: ${result.reason ?? "no changes needed"}`);
469
- return { code: 0, files: [], target: cwd };
470
- }
471
- try {
472
- writeFileSync(viteConfigPath, result.code, "utf8");
473
- } catch (error) {
474
- const message = error instanceof Error ? error.message : String(error);
475
- logger.error(`init --in-place: could not write ${viteConfigPath}: ${message}`);
476
- return { code: 1, files: [], target: cwd };
477
- }
478
- logger.success(`patched ${viteConfigPath} — added lunora() plugin`);
479
- return { code: 0, files: [viteConfigPath], target: cwd };
480
- };
481
- const scaffoldLunoraDirectory = (cwd, logger) => {
482
- const lunoraDirectory = join$1(cwd, "lunora");
483
- const schemaPath = join$1(lunoraDirectory, "schema.ts");
484
- if (existsSync(schemaPath)) {
485
- logger.info(`lunora/ already present — left ${schemaPath} untouched`);
486
- return [];
487
- }
488
- const written = [];
489
- try {
490
- mkdirSync(lunoraDirectory, { recursive: true });
491
- writeFileSync(schemaPath, SAMPLE_SCHEMA, "utf8");
492
- written.push(schemaPath);
493
- const functionPath = join$1(lunoraDirectory, "messages.ts");
494
- if (!existsSync(functionPath)) {
495
- writeFileSync(functionPath, SAMPLE_FUNCTION, "utf8");
496
- written.push(functionPath);
497
- }
498
- logger.success(`scaffolded lunora/ (${String(written.length)} file(s))`);
499
- } catch (error) {
500
- const message = error instanceof Error ? error.message : String(error);
501
- logger.error(`init --here: could not scaffold lunora/: ${message}`);
502
- }
503
- return written;
504
- };
505
- const printFrameworkNextSteps = (detection, logger) => {
506
- const { adapter, class: frameworkClass, framework } = detection;
507
- logger.info("");
508
- logger.info(`detected framework: ${framework} (class ${frameworkClass})`);
509
- logger.info("next steps:");
510
- logger.info(` 1. install the adapter: pnpm add ${adapter} @lunora/client @lunora/runtime @lunora/server`);
511
- logger.info(" 2. run codegen: lunora codegen");
512
- if (frameworkClass === "A") {
513
- logger.info(" 3. compose one worker: wrap your worker entry with");
514
- logger.info(" createWorker({ httpRouter: <your framework SSR handler>, shardDO: ShardDO, ... })");
515
- logger.info(` 4. add the provider: mount the ${adapter} provider in your root layout/route`);
516
- logger.info(" 5. make a loader live: preloadQuery() in a loader, usePreloadedQuery() in the component");
517
- logger.info(" see https://lunora.sh/docs/frameworks/reactive-loaders");
518
- } else if (frameworkClass === "B") {
519
- logger.info(" 3. inject Lunora: mount Lunora realtime under /_lunora/* in your server hook");
520
- logger.info(` (${framework} owns its Cloudflare adapter — Lunora composes into its server entry)`);
521
- logger.info(` 4. add the provider: mount the ${adapter} provider in your root layout`);
522
- logger.info(" 5. read the guide: https://lunora.sh/docs/frameworks/deploy");
523
- } else {
524
- logger.info(" 3. add the provider: wrap your app with the LunoraProvider from @lunora/react");
525
- logger.info(" 4. read the guide: https://lunora.sh/docs/frameworks/bring-your-framework");
526
- }
527
- logger.info("");
528
- };
529
- const findExistingViteConfig = (cwd) => {
530
- for (const candidate of VITE_CONFIG_CANDIDATES) {
531
- const full = join$1(cwd, candidate);
532
- if (existsSync(full)) {
533
- return full;
534
- }
535
- }
536
- return void 0;
537
- };
538
- const patchOrCreateViteConfig = (cwd, framework, logger) => {
539
- const viteConfigPath = findExistingViteConfig(cwd);
540
- if (viteConfigPath === void 0) {
541
- if (framework === "sveltekit" || framework === "nuxt" || framework === "astro") {
542
- logger.info(`no Vite config found — ${framework} wires Lunora through its server entry (see next steps)`);
543
- return { code: 0, files: [], target: cwd };
544
- }
545
- return createMinimalViteConfig(cwd, logger);
546
- }
547
- return patchExistingViteConfig(viteConfigPath, cwd, logger);
548
- };
549
- const runInPlaceInit = (cwd, logger) => {
550
- const detection = detectFramework(cwd);
551
- const viteResult = patchOrCreateViteConfig(cwd, detection.framework, logger);
552
- if (viteResult.code !== 0) {
553
- return viteResult;
554
- }
555
- const scaffolded = scaffoldLunoraDirectory(cwd, logger);
556
- printFrameworkNextSteps(detection, logger);
557
- return { code: 0, files: [...viteResult.files, ...scaffolded], target: cwd };
558
- };
559
- const offerIsInteractive = (options) => options.yes !== true && (options.prompt !== void 0 || (options.interactive ?? isInteractive()));
560
- const maybeOfferExtras = async (options, projectDirectory) => {
561
- const interactive = offerIsInteractive(options);
562
- const apply = async (names) => {
563
- const result = await runAddCommand({
564
- allowUnsafeSource: options.allowUnsafeSource,
565
- cwd: projectDirectory,
566
- from: options.registryFrom,
567
- logger: options.logger,
568
- names: [...names],
569
- source: options.registrySource,
570
- yes: true
571
- });
572
- return result.code === 0;
573
- };
574
- await offerRegistryExtras({
575
- apply,
576
- interactive,
577
- logger: options.logger,
578
- multiSelect: options.prompt?.multiSelect ?? ((message, choices, settings) => promptMultiSelect(message, choices, settings)),
579
- select: options.prompt?.select ?? ((message, choices, settings) => promptSelect(message, choices, settings))
580
- });
581
- };
582
- const scaffoldNewProject = async (options, cwd) => {
583
- const name = options.name ?? "lunora-app";
584
- const templateType = options.templateType ?? "vite";
585
- if (templateType === "next") {
586
- options.logger.warn('template "next" is not yet available — re-run with `-t vite` or `-t standalone`.');
587
- return { code: 1, files: [], target: "" };
588
- }
589
- if (name.includes("/") || name.includes("\\") || name === ".." || name === ".") {
590
- options.logger.error(`init: refusing project name "${name}" — must not contain path separators or be "." / "..".`);
591
- return { code: 1, files: [], target: "" };
592
- }
593
- const target = resolve(cwd, name);
594
- if (existsSync(target)) {
595
- const entries = readdirSync(target);
596
- if (entries.length > 0) {
597
- options.logger.error(`target directory not empty: ${target}`);
598
- return { code: 1, files: [], target };
599
- }
600
- }
601
- if (options.from !== void 0) {
602
- return scaffoldFromLocal(options.from, templateType, target, name, options.logger);
603
- }
604
- if (options.source !== void 0 && options.source.length > 0 && !options.allowUnsafeSource && !isSafeSource(options.source)) {
605
- options.logger.error(
606
- `init: refusing --source ${options.source} — only gh:, github:, or https:// sources are allowed (and may not contain ".."). Re-run with --allow-unsafe-source if you really want this.`
607
- );
608
- return { code: 1, files: [], target };
609
- }
610
- return scaffoldFromRemote(options.source, templateType, target, name, options.logger);
611
- };
612
- const runInitCommand = async (options) => {
613
- const cwd = options.cwd ?? process.cwd();
614
- const result = options.inPlace === true ? runInPlaceInit(cwd, options.logger) : await scaffoldNewProject(options, cwd);
615
- if (result.code === 0 && result.target !== "") {
616
- await maybeOfferExtras(options, result.target);
617
- }
618
- if (result.code === 0 && options.ci !== void 0) {
619
- scaffoldCiWorkflow(options.inPlace === true ? cwd : result.target, options.ci, options.logger);
620
- }
621
- return result;
622
- };
623
- const isTemplate = (value) => value === "astro" || value === "next" || value === "nuxt" || value === "standalone" || value === "sveltekit" || value === "tanstack-start-react" || value === "tanstack-start-solid" || value === "vite";
624
- const resolveCiProvider = (raw, logger) => {
625
- if (raw === void 0) {
626
- return void 0;
627
- }
628
- if (isCiProvider(raw)) {
629
- return raw;
630
- }
631
- logger.warn(`init: unknown --ci "${raw}" — expected github | gitlab; skipping CI scaffold.`);
632
- return void 0;
633
- };
634
- const execute = defineHandler(({ argument, cwd, logger, options }) => {
635
- const templateRaw = options.template ?? "vite";
636
- const template = isTemplate(templateRaw) ? templateRaw : "vite";
637
- return runInitCommand({
638
- allowUnsafeSource: options.allowUnsafeSource === true,
639
- cwd,
640
- ci: resolveCiProvider(options.ci, logger),
641
- from: options.from,
642
- inPlace: options.here === true,
643
- interactive: options.interactive === true ? true : void 0,
644
- logger,
645
- name: argument[0],
646
- source: options.source,
647
- templateType: template,
648
- yes: options.yes === true
649
- });
650
- });
651
-
652
- export { execute, isTemplate, runInitCommand };
1224
+ `,Na="gh:anolilab/lunora/templates",Ia=e=>{const t=e.lastIndexOf(".");return t===-1?!1:La.has(e.slice(t))},_a=(e,t)=>e.replaceAll("{{name}}",t),$a=async(e,t)=>{const a=new Set;for(const r of e)if(E(r)==="package.json")try{const o=JSON.parse(b(r,"utf8"));for(const s of["dependencies","devDependencies"])for(const n of Object.keys(o[s]??{}))P(n)&&a.add(n)}catch{}return ce(a,t)},Ra=(e,t,a)=>{let r;try{r=JSON.parse(e)}catch{return e}let o=e;for(const s of["dependencies","devDependencies"])for(const n of Object.keys(r[s]??{})){if(!P(n))continue;const i=a.get(n)??t,l=We(o,[s,n],i,{formattingOptions:{insertSpaces:!0,tabSize:4}});o=ze(o,l)}return o},Oa=["@parcel/watcher","esbuild","lmdb","msgpackr-extract","rs-module-lexer","sharp","unrs-resolver","vue-demi","workerd"],Ta=["cpu-features","protobufjs","ssh2"],Ae="pnpm-workspace.yaml",Pa=()=>["# pnpm reads its settings from here (the package.json `pnpm` field is no longer read).","# Pre-approve the toolchain's native build scripts so `pnpm install` runs them","# without the interactive `pnpm approve-builds` step; deny the optional native","# builds a scaffold doesn't need (so no C/C++ toolchain is required).","allowBuilds:",...Oa.map(e=>` '${e}': true`),...Ta.map(e=>` '${e}': false`),""].join(`
1225
+ `),q=e=>{const t=[];for(const a of Fe(e,{includeDirs:!1,includeFiles:!0}))Oe(a.path).isSymbolicLink()||t.push(a.path);return t},Ee=async(e,t,a)=>{const r=q(e),o=[],s=de(),n=await $a(r,s);for(const i of r){const l=He(e,i),d=u(t,l);M(A(d),{recursive:!0});const c=b(i);let p=Ia(i)?_a(c.toString("utf8"),a):void 0;p!==void 0&&E(i)==="package.json"&&(p=Ra(p,s,n)),p===void 0?v(d,c):v(d,p,"utf8"),o.push(d)}return o},B=(e,t,a)=>t!==void 0&&t.length>0?t:`${Na}/${e}#${ue(a)}`,Da=e=>e.includes("..")?!1:e.startsWith("gh:")||e.startsWith("github:")||e.startsWith("https://"),S=(e,t)=>{e.info(`[dry-run] would ${t}`)},K=(e,t,a)=>{g()&&process.stdout.write(`
1226
+ `),e.success(`scaffolded ${String(t.length)} files into ${a}`)},Ba=(e,t)=>{const{args:a,command:r}=Je(e,t);return`${r} ${a.join(" ")}`},Ne=(e,t)=>{let a=ne(e);for(;;){if(t(a))return!0;const r=A(a);if(r===a)return!1;a=r}},ja=e=>{if(m(u(e,Ae)))return!0;const t=u(e,"package.json");if(!m(t))return!1;try{return JSON.parse(b(t,"utf8")).workspaces!==void 0}catch{return!1}},Ie=e=>Ne(e,ja),Va=e=>Ne(e,t=>m(u(t,".git"))),Ua=async(e,t)=>{if(e.yes===!0||!g()||Va(A(t)))return;if(!await fe(y.git,{badge:f.git,defaultYes:!1})){await ve("Sounds good! You can always run git init manually.");return}if(e.dryRun===!0){S(e.logger,"initialize a git repository");return}const a=e.spawner??pe;(await st("Initializing a git repository…",()=>a({args:["init"],command:"git",cwd:t}))).code===0?await R("git","Initialized an empty git repository."):e.logger.warn("`git init` failed — initialize it yourself later with `git init`.")},Fa=async(e,t,a,r)=>{const o=[{code:`cd ./${e}`,lead:"Enter your project directory using"}];t===void 0&&o.push({code:`${a} install`,lead:"Install dependencies with",tail:r?" from the workspace root":void 0}),o.push({code:Ye(a,"dev"),lead:"Run",tail:" to start the dev server."},{code:"lunora add",lead:"Add features like auth or storage using"});const s=[{code:"https://lunora.sh/docs",lead:"Read the docs at"},{code:"https://lunora.sh/chat",lead:"Stuck? Join the chat at"}];if(g()){await nt(f.next,y.nextHeader,o,s);return}const n=o.map(i=>`${i.lead} ${i.code}${i.tail??""}`);n.push("",...s.map(i=>`${i.lead} ${i.code}${i.tail??""}`)),await R("next",y.nextHeader,n.join(`
1227
+ `))},Ha=e=>e.yes!==!0&&(e.installPrompt!==void 0||g()),Wa=async(e,t)=>{if(!Ha(e)||Ie(A(t)))return;const a=Ge(e.packageManagerProbe),[r]=a;if(r===void 0)return;if(!await(e.installPrompt?.confirmInstall??(async()=>fe(y.install,{badge:f.deps,defaultYes:!0})))()){await ve("No problem! Remember to install dependencies after setup.");return}let s=r;if(a.length>1&&(s=e.installPrompt?await e.installPrompt.selectManager(a):await H(y.packageManager,a.map(c=>({label:c,value:c})),{badge:f.deps,default:r})??r),e.dryRun===!0){S(e.logger,`install dependencies with ${s}`);return}if(s==="pnpm"){const c=u(t,Ae);m(c)||v(c,Pa(),"utf8")}const n=e.spawner??pe,{args:i,command:l}=le(s);await R("deps",`Installing dependencies with ${s}…`);const d=await n({args:i,command:l,cwd:t});if(d.code!==0){e.logger.warn(`\`${l} install\` exited with code ${String(d.code)} — run it yourself in ${E(t)}/.`);return}return await R("deps",`Dependencies installed with ${s}.`),s},za=async(e,t,a,r,o)=>{const s=u(e,t);if(!m(s))return o.error(`template not found in local source: ${s}`),{code:1,files:[],target:a};const n=await Ee(s,a,r);return K(o,n,a),{code:0,files:n,target:a}},qa=async e=>{const{logger:t,name:a,ref:r,source:o,target:s,templateType:n}=e,i=oe(u(se(),"lunora-init-fetch-")),l=u(i,"template");try{const d=o!==void 0&&o.length>0?r:await et(r,t),c=B(n,o,d);let p,h=[];await ge([{label:`${n} template fetched`,run:async()=>{p=await ie(c,{cwd:i,dir:l,force:!0,install:!1,silent:!0})}},{label:`files copied into ${a}/`,run:async()=>{h=await Ee(l,s,a)}}],{end:"Project initialized!",start:"Project initializing…"});const I=q(l);return g()&&process.stdout.write(`
1228
+ `),t.info(p?.commit?`template: ${p.source} @ ${p.commit} (${String(I.length)} files)`:`template: ${p?.source??c} (${String(I.length)} files)`),K(t,h,s),{code:0,files:h,target:s}}catch(d){if(d instanceof F)throw d;const{hints:c,message:p}=Pt(d,{ref:ue(r),remote:B(n,o,r),templateType:n});t.error(p);for(const h of c)t.warn(h);return{code:1,files:[],target:s}}finally{$(i,{force:!0,recursive:!0})}},Ka=e=>{for(const t of["_gitignore","_npmrc","_gitattributes"]){const a=u(e,t);m(a)&&Re(a,u(e,`.${t.slice(1)}`))}},Ga=async e=>{const{framework:t,logger:a,name:r,overlayBaseFrom:o,target:s}=e,n=T[t],i=oe(u(se(),"lunora-vite-base-"));try{let l;if(o!==void 0&&(l=u(o,`template-${n.createViteTemplate}`),!m(l)))return a.error(`create-vite base not found on disk: ${l}`),{code:1,files:[],target:s};const d=async()=>{if(l!==void 0){G(l,s,{recursive:!0});return}const p=u(i,"base"),h=`github:vitejs/vite/packages/create-vite/template-${n.createViteTemplate}#main`;await ie(h,{cwd:i,dir:p,force:!0,install:!1,silent:!0}),Ka(p),G(p,s,{recursive:!0})};let c=[];return await ge([{label:`create-vite (${n.label}) base ready`,run:d},{label:`Lunora overlay applied (${n.label})`,run:async()=>{c=await wa({adapter:n,distTag:de(),logger:a,name:r,target:s})}}],{end:"Project initialized!",start:"Project initializing…"}),K(a,c,s),{code:0,files:[...q(s)],target:s}}catch(l){if(l instanceof F)throw l;const d=l instanceof Error?l.message:String(l);return a.error(`failed to scaffold the ${n.label} base: ${d}`),{code:1,files:[],target:s}}finally{$(i,{force:!0,recursive:!0})}},j=(e,t,a,r,o)=>(o.error(`init --in-place: could not ${e} ${t}: ${a instanceof Error?a.message:String(a)}`),{code:1,files:[],target:r}),Ja=(e,t)=>{const a=u(e,"vite.config.ts");try{v(a,Ma,"utf8")}catch(r){return j("write",a,r,e,t)}return t.success(`created ${a} with lunora() plugin`),{code:0,files:[a],target:e}},Ya=(e,t,a)=>{let r;try{r=b(e,"utf8")}catch(s){return j("read",e,s,t,a)}const o=ke(r);if(!o.changed)return a.info(`${e}: ${o.reason??"no changes needed"}`),{code:0,files:[],target:t};try{v(e,o.code,"utf8")}catch(s){return j("write",e,s,t,a)}return a.success(`patched ${e} — added lunora() plugin`),{code:0,files:[e],target:t}},Xa=(e,t)=>{const a=u(e,"lunora"),r=u(a,"schema.ts");if(m(r))return t.info(`lunora/ already present — left ${r} untouched`),[];const o=[];try{M(a,{recursive:!0}),v(r,Aa,"utf8"),o.push(r);const s=u(a,"messages.ts");m(s)||(v(s,Ea,"utf8"),o.push(s)),t.success(`scaffolded lunora/ (${String(o.length)} file(s))`)}catch(s){const n=s instanceof Error?s.message:String(s);t.error(`init --here: could not scaffold lunora/: ${n}`)}return o},Qa=(e,t,a)=>{const{adapter:r,class:o,framework:s}=e;a.info(""),a.info(`detected framework: ${s} (class ${o})`),a.info("next steps:"),a.info(` 1. install the adapter: ${Ba(t,[r,"@lunora/client","@lunora/runtime","@lunora/server"])}`),a.info(" 2. run codegen: lunora codegen"),o==="A"?(a.info(" 3. compose one worker: wrap your worker entry with"),a.info(" createWorker({ httpRouter: <your framework SSR handler>, shardDO: ShardDO, ... })"),a.info(` 4. add the provider: mount the ${r} provider in your root layout/route`),a.info(" 5. make a loader live: preloadQuery() in a loader, usePreloadedQuery() in the component"),a.info(" see https://lunora.sh/docs/frameworks/reactive-loaders")):o==="B"?(a.info(" 3. inject Lunora: mount Lunora realtime under /_lunora/* in your server hook"),a.info(` (${s} owns its Cloudflare adapter — Lunora composes into its server entry)`),a.info(` 4. add the provider: mount the ${r} provider in your root layout`),a.info(" 5. read the guide: https://lunora.sh/docs/frameworks/deploy")):(a.info(" 3. add the provider: wrap your app with the LunoraProvider from @lunora/react"),a.info(" 4. read the guide: https://lunora.sh/docs/frameworks/bring-your-framework")),a.info("")},Za=(e,t,a)=>{const r=Se(e);return r===void 0?t==="sveltekit"||t==="nuxt"||t==="astro"?(a.info(`no Vite config found — ${t} wires Lunora through its server entry (see next steps)`),{code:0,files:[],target:e}):Ja(e,a):Ya(r,e,a)},er=(e,t)=>{const a=Lt(e),r=Za(e,a.framework,t);if(r.code!==0)return r;const o=Xa(e,t);return Qa(a,U(e),t),{code:0,files:[...r.files,...o],target:e}},tr=e=>e.yes!==!0&&(e.prompt!==void 0||(e.interactive??g())),ae=async(e,t,a)=>{a.dryRun!==!0&&await Kt({apply:r=>Ue(e,r),detected:Ve(e),interactive:t,logger:a.logger,multiSelect:a.lintPrompt??((r,o,s)=>me(r,o,{...s,badge:f.add}))})},ar=async(e,t)=>{const a=tr(e),r=e.add===void 0?[]:jt(e.add,n=>{e.logger.warn(n)}),s={applyAll:async n=>{if(n.length===0)return!0;if(e.dryRun===!0)return S(e.logger,`add ${n.map(h=>h.label).join(", ")}`),!0;const i=[],l=g()?{error:h=>{i.push({level:"error",message:h})},info:()=>{},success:()=>{},warn:h=>{i.push({level:"warn",message:h})}}:e.logger,d=n.map(h=>({running:`adding ${h.label}…`,task:()=>gt({allowUnsafeSource:e.allowUnsafeSource,cwd:t,from:e.registryFrom,logger:l,names:[...h.names],ref:e.ref,source:e.registrySource,transformManifest:h.transformManifest,yes:!0})})),c=`added ${n.map(h=>h.label).join(", ")}`,p=await it(f.add,d,c);for(const{level:h,message:I}of i)e.logger[h](I);return p.every(h=>h.code===0)},interactive:a,logger:e.logger,multiSelect:e.prompt?.multiSelect??((n,i,l)=>me(n,i,{...l,badge:f.add})),preselected:r.length>0?r:void 0,projectName:E(t),resolveAuthUiItem:()=>{try{const n=JSON.parse(b(u(t,"package.json"),"utf8"));return ft({...n.dependencies,...n.devDependencies})??"auth-ui-react"}catch{return"auth-ui-react"}},select:e.prompt?.select??((n,i,l)=>H(n,i,{...l,badge:f.add})),text:e.prompt?.text??((n,i)=>he(n,{...i,badge:f.add}))};if(r.length>0){await Z(s),await ae(t,a,e);return}g()&&await ot(y.extras),await Z(s),await ae(t,a,e)},D="react",_e=[{description:"React SPA — official create-vite base + the Lunora layer (the default)",label:"React",value:"react"},{description:"Vue SPA — create-vite base + Lunora",label:"Vue",value:"vue"},{description:"Solid SPA — create-vite base + Lunora",label:"Solid",value:"solid"},{description:"Solid 2.0 SPA — the Solid 2 line (@solidjs/web, vite-plugin-solid 3)",label:"Solid 2",value:"solid-v2"},{description:"Svelte SPA — create-vite base + Lunora",label:"Svelte",value:"svelte"},{description:"Next.js (App Router) — OpenNext on Cloudflare + a standalone Lunora worker",label:"Next.js",value:"next"},{description:"TanStack Start (React) — SSR with live-loader routes",label:"TanStack Start · React",value:"tanstack-start-react"},{description:"TanStack Start (Solid)",label:"TanStack Start · Solid",value:"tanstack-start-solid"},{description:"Next.js App Router on Vite (vinext) — composed into the Lunora worker (experimental)",label:"vinext · App Router",value:"vinext"},{description:"Next.js Pages Router on Vite (vinext) — composed into one worker (experimental)",label:"vinext · Pages Router",value:"vinext-pages"},{description:"React Router (v7, framework mode) — SSR composed into the Lunora worker",label:"React Router",value:"react-router"},{description:"Astro + a standalone Lunora worker",label:"Astro",value:"astro"},{description:"AnalogJS (Angular) — single-worker, Lunora mounted in Nitro",label:"Analog",value:"analog"},{description:"Nuxt (Vue) — single-worker, Lunora mounted in Nitro",label:"Nuxt",value:"nuxt"},{description:"SvelteKit + a standalone Lunora worker",label:"SvelteKit",value:"sveltekit"},{description:"React Native (Expo) — an iOS/Android/web app + a Lunora worker backend",label:"React Native · Expo",value:"expo"},{description:"Worker only — no frontend",label:"Standalone",value:"standalone"}],rr=Object.keys(T).join("|"),$e=_e.filter(e=>!z(e.value)).map(e=>e.value),or=$e.join("|"),sr=e=>z(e)?{framework:e,kind:"overlay"}:{kind:"template",templateType:e},nr=async e=>e.vite!==void 0?{framework:e.vite,kind:"overlay"}:e.templateType!==void 0?{kind:"template",templateType:e.templateType}:!g()||e.yes===!0?{framework:D,kind:"overlay"}:sr(await H(y.framework,_e,{badge:f.tmpl,default:D})??D),ir=e=>{if(g()||e.yes===!0)return;const t=[];if(e.name===void 0&&t.push("a project name (`lunora init <name>`)"),e.templateType===void 0&&e.vite===void 0&&t.push(`a framework — \`--vite <${rr}>\` for an SPA, or \`-t <${or}>\` for a bespoke template`),t.length!==0)return`lunora init can't prompt in a non-interactive terminal — provide ${t.join(" and ")}, or pass --yes to accept the defaults.`},lr=async(e,t,a,r)=>z(t)?await Me({isLocal:e.overlayBaseFrom!==void 0,logger:e.logger})?(M(r,{recursive:!0}),Ga({framework:t,logger:e.logger,name:a,overlayBaseFrom:e.overlayBaseFrom,target:r})):{code:1,files:[],target:r}:(e.logger.error(`init: unknown framework "${t}". Supported overlays: ${Object.keys(T).join(", ")}.`),{code:1,files:[],target:r}),cr=async(e,t,a,r)=>e.from!==void 0?await za(e.from,t,r,a,e.logger):e.source!==void 0&&e.source.length>0&&!e.allowUnsafeSource&&!Da(e.source)?(e.logger.error(`init: refusing --source ${e.source} — only gh:, github:, or https:// sources are allowed (and may not contain ".."). Re-run with --allow-unsafe-source if you really want this.`),{code:1,files:[],target:r}):await Me({isLocal:!1,logger:e.logger,source:B(t,e.source,e.ref)})?qa({logger:e.logger,name:a,ref:e.ref,source:e.source,target:r,templateType:t}):{code:1,files:[],target:r},dr=async(e,t,a)=>{await rt("realtime backend on Cloudflare Workers + Durable Objects");const r=ir(e);if(r!==void 0)return e.logger.error(r),{code:1,files:[],target:""};const o=xa(),s=e.name??await he(y.name,{badge:f.dir,default:o,placeholder:o}),n=await nr(e),i=s.trim();if(i.length===0)return e.logger.error("init: refusing an empty project name — pass a directory name (e.g. `lunora init my-app`)."),{code:1,files:[],target:""};if(i.includes("/")||i.includes("\\")||i===".."||i===".")return e.logger.error(`init: refusing project name "${i}" — must not contain path separators or be "." / "..".`),{code:1,files:[],target:""};const l=ne(t,i),d=m(l);if(d&&re(l).length>0)return e.logger.error(`target directory not empty: ${l}`),{code:1,files:[],target:l};if(e.dryRun===!0){const c=n.kind==="overlay"?`the ${n.framework} create-vite overlay`:`the ${n.templateType} template`;return S(e.logger,`scaffold ${c} into ${l}`),{code:0,files:[],target:l}}return a(l,d),n.kind==="overlay"?lr(e,n.framework,i,l):cr(e,n.templateType,i,l)},ur=(e,t)=>{const{target:a,targetPreExisted:r}=e;if(!(a===void 0||!m(a))){if(r===!0)for(const o of re(a))$(u(a,o),{force:!0,recursive:!0});else $(a,{force:!0,recursive:!0});t.info(`removed the partially-created project at ${a}`)}},pr=async(e,t,a)=>e.inPlace!==!0?dr(e,t,a):e.dryRun===!0?(S(e.logger,`configure Lunora into ${t}`),{code:0,files:[],target:t}):er(t,e.logger),hr=async(e,t,a)=>{await ar(e,t.target);const r=e.inPlace===!0?void 0:await Wa(e,t.target);if(e.inPlace!==!0){await Ua(e,t.target);const o=r??U(t.target);await Fa(E(t.target),r,o,Ie(a)),await Dt(e.logger)}},mr=(e,t,a)=>{if(t.code!==0||e.ci===void 0)return;if(e.dryRun===!0){S(e.logger,`scaffold a ${e.ci} CI deploy pipeline`);return}const r=e.inPlace===!0?a:t.target;try{const o=U(r);Ct(r,e.ci,o,e.logger)}catch{e.logger.warn(`--ci ${e.ci}: could not detect a package manager for this project — skipped the CI pipeline.`)}},fr=async e=>{const t=e.cwd??process.cwd(),a={};let r;try{r=await pr(e,t,(o,s)=>{a.target=o,a.targetPreExisted=s}),r.code===0&&r.target!==""&&(a.target=void 0,await hr(e,r,t))}catch(o){if(o instanceof F)return ur(a,e.logger),process.stdout.write("\n ✖ Setup cancelled — run `lunora init` again whenever you're ready. 🌙\n"),{code:130,files:[],target:""};throw o}return mr(e,r,t),r},vr=e=>typeof e=="string"&&$e.includes(e),gr=(e,t)=>{if(e!==void 0){if(xt(e))return e;t.warn(`init: unknown --ci "${e}" — expected github | gitlab; skipping CI scaffold.`)}},Br=Xe(({argument:e,cwd:t,logger:a,options:r})=>{const o=r.template!==void 0&&vr(r.template)?r.template:void 0;return fr({add:r.add,allowUnsafeSource:r.allowUnsafeSource===!0,cwd:t,ci:gr(r.ci,a),dryRun:r.dryRun===!0,from:r.from,inPlace:r.here===!0,interactive:r.interactive===!0?!0:void 0,logger:a,name:e[0],ref:r.ref,source:r.source,templateType:o,vite:r.vite,yes:r.yes===!0})});export{Br as execute,vr as isTemplate,B as resolveTemplateSource,fr as runInitCommand};