@lunora/cli 1.0.0-alpha.324 → 1.0.0-alpha.326

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 (57) hide show
  1. package/dist/bin.mjs +1 -1
  2. package/dist/index.d.mts +21 -19
  3. package/dist/index.d.ts +21 -19
  4. package/dist/index.mjs +1 -1
  5. package/dist/packem_chunks/dispatch.mjs +1 -1
  6. package/dist/packem_chunks/handler.mjs +1 -1
  7. package/dist/packem_chunks/handler10.mjs +1 -1
  8. package/dist/packem_chunks/handler11.mjs +1 -1
  9. package/dist/packem_chunks/handler12.mjs +1 -1
  10. package/dist/packem_chunks/handler13.mjs +1 -1
  11. package/dist/packem_chunks/handler14.mjs +1 -1
  12. package/dist/packem_chunks/handler15.mjs +1 -1
  13. package/dist/packem_chunks/handler16.mjs +1 -1
  14. package/dist/packem_chunks/handler17.mjs +1 -1
  15. package/dist/packem_chunks/handler18.mjs +1 -1
  16. package/dist/packem_chunks/handler19.mjs +1 -1
  17. package/dist/packem_chunks/handler2.mjs +1 -1
  18. package/dist/packem_chunks/handler20.mjs +1 -1
  19. package/dist/packem_chunks/handler21.mjs +1 -1
  20. package/dist/packem_chunks/handler22.mjs +1 -1
  21. package/dist/packem_chunks/handler23.mjs +1 -1
  22. package/dist/packem_chunks/handler24.mjs +2 -2
  23. package/dist/packem_chunks/handler25.mjs +1 -1
  24. package/dist/packem_chunks/handler26.mjs +1 -1
  25. package/dist/packem_chunks/handler3.mjs +1 -1
  26. package/dist/packem_chunks/handler4.mjs +1 -1
  27. package/dist/packem_chunks/handler5.mjs +1 -1
  28. package/dist/packem_chunks/handler6.mjs +1 -1
  29. package/dist/packem_chunks/handler7.mjs +3 -3
  30. package/dist/packem_chunks/handler8.mjs +1 -1
  31. package/dist/packem_chunks/handler9.mjs +1 -1
  32. package/dist/packem_chunks/runCodegenCommand.mjs +1 -1
  33. package/dist/packem_chunks/runDeployCommand.mjs +3 -3
  34. package/dist/packem_chunks/runDevCommand.mjs +3 -0
  35. package/dist/packem_chunks/runInitCommand.mjs +17 -17
  36. package/dist/packem_chunks/runResetCommand.mjs +1 -1
  37. package/dist/packem_chunks/runRpcCommand.mjs +1 -1
  38. package/dist/packem_shared/COMMANDS-Cax5U9fX.mjs +1 -0
  39. package/dist/packem_shared/cli-D1ZleZMH.mjs +2 -0
  40. package/dist/packem_shared/command-B--jgXSc.mjs +1 -0
  41. package/dist/packem_shared/health-probe-Bw9JFfIy.mjs +1 -0
  42. package/dist/packem_shared/output-format-B4eQHi5y.mjs +2 -0
  43. package/dist/packem_shared/plan-B-KsxVne.mjs +5 -0
  44. package/dist/packem_shared/planDevCommand-BuJZzy-L.mjs +1 -0
  45. package/dist/packem_shared/render-lunora-error-DgaSmNLc.mjs +2 -0
  46. package/dist/packem_shared/secret-key-DsMeUoEg.mjs +1 -0
  47. package/dist/packem_shared/wrangler-secrets-CuUdFBaA.mjs +1 -0
  48. package/package.json +9 -9
  49. package/skills/lunora-quickstart/SKILL.md +15 -13
  50. package/dist/packem_chunks/planDevCommand.mjs +0 -7
  51. package/dist/packem_shared/COMMANDS-DdaAWPtr.mjs +0 -1
  52. package/dist/packem_shared/cli-DOpChqUe.mjs +0 -2
  53. package/dist/packem_shared/command-Mmxzxyr5.mjs +0 -1
  54. package/dist/packem_shared/render-lunora-error--4tmM6mt.mjs +0 -3
  55. package/dist/packem_shared/schema-drift-gate-BDCkQ1S6.mjs +0 -1
  56. package/dist/packem_shared/vectorize-metadata-dXpl2_Ar.mjs +0 -1
  57. package/dist/packem_shared/wrangler-secrets-C9lJnd5N.mjs +0 -1
package/dist/bin.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{r as e}from"./packem_shared/cli-DOpChqUe.mjs";try{const r=await e();process.exit(r)}catch(r){process.stderr.write(`${r instanceof Error?r.message:String(r)}
2
+ import{r as e}from"./packem_shared/cli-D1ZleZMH.mjs";try{const r=await e();process.exit(r)}catch(r){process.stderr.write(`${r instanceof Error?r.message:String(r)}
3
3
  `),process.exit(1)}
package/dist/index.d.mts CHANGED
@@ -364,11 +364,6 @@ interface ImportCommandResult extends CommandResult<ImportCommandData> {
364
364
  inserted: number;
365
365
  }
366
366
  declare const runImportCommand: (options: ImportCommandOptions) => Promise<ImportCommandResult>;
367
- /**
368
- * Injectable probe for a Docker-compatible container engine. Tests pass a
369
- * stub; production uses {@link isDockerAvailable}.
370
- */
371
- type DockerProbe = () => boolean;
372
367
  /**
373
368
  * Every exit code `lunora` can terminate with. Stable — a value never changes
374
369
  * meaning, and a new bucket takes the next free number.
@@ -413,6 +408,11 @@ declare const exitCodeForCode: (code: string) => ExitCode;
413
408
  * upstream-API codes do). Anything else is a general failure.
414
409
  */
415
410
  declare const exitCodeForError: (error: unknown) => ExitCode;
411
+ /**
412
+ * Injectable probe for a Docker-compatible container engine. Tests pass a
413
+ * stub; production uses {@link isDockerAvailable}.
414
+ */
415
+ type DockerProbe = () => boolean;
416
416
  /**
417
417
  * The shared `/_lunora/health` probe used by `lunora verify --health-url` and
418
418
  * `lunora deploy --health-check`.
@@ -738,6 +738,8 @@ interface DeployCommandResult {
738
738
  ok: boolean;
739
739
  url: string;
740
740
  };
741
+ /** Whether the target a successful deploy shipped to has a log tail for `lunora logs`. */
742
+ logsAvailable?: boolean;
741
743
  /**
742
744
  * The `.dev.vars`-shaped filename (never a full path, never a value) a
743
745
  * secret minted during this run was recorded into, when the missing-
@@ -914,7 +916,7 @@ interface DevCommandOptions {
914
916
  cwd?: string;
915
917
  /**
916
918
  * Override where the binding manifest is written. One is always produced at
917
- * {@link DEV_BINDINGS_FILE}; naming a path also makes a derivation failure
919
+ * `DEV_BINDINGS_FILE`; naming a path also makes a derivation failure
918
920
  * fatal, since a named path means something is waiting on it.
919
921
  */
920
922
  emitBindings?: string;
@@ -924,13 +926,13 @@ interface DevCommandOptions {
924
926
  ensureExample?: typeof ensureDevVarsExample;
925
927
  /** Injection seam for tests — defaults to the real empty-secret/admin-token filler. */
926
928
  fillSecrets?: typeof fillDevSecrets;
927
- /** Injection seam for tests — defaults to the real free-port probe ({@link findAvailablePort}). */
929
+ /** Injection seam for tests — defaults to the real free-port probe (`findAvailablePort`). */
928
930
  findFreePort?: (preferred: number) => Promise<number>;
929
- /** Dev flavor override (tests / callers that already detected it) — defaults to {@link detectDevFlavor}. */
931
+ /** Dev flavor override (tests / callers that already detected it) — defaults to `detectDevFlavor`. */
930
932
  flavor?: DevFlavor;
931
- /** Injection seam for tests — defaults to the real IPv6-loopback probe ({@link hasIpv6Loopback}). */
933
+ /** Injection seam for tests — defaults to the real IPv6-loopback probe (`hasIpv6Loopback`). */
932
934
  hasIpv6Loopback?: () => boolean;
933
- /** `wrangler dev` devtools inspector port (`--inspector-port`). Wrangler flavor only — see {@link resolveInspectorPort}. */
935
+ /** `wrangler dev` devtools inspector port (`--inspector-port`). Wrangler flavor only — see `resolveInspectorPort`. */
934
936
  inspectorPort?: number;
935
937
  /**
936
938
  * Logs are NDJSON on stdout (`--json`, or a detected AI agent). Forwarded to
@@ -1037,14 +1039,6 @@ interface DevCommandPlan {
1037
1039
  tag: string;
1038
1040
  };
1039
1041
  }
1040
- /**
1041
- * Plan `lunora dev`. Wrangler flavor: the worker runs via `wrangler dev` and
1042
- * nothing else as a child process. Vite flavor (`@lunora/vite` declared): the
1043
- * plugin already runs the worker inside the Vite dev server, so the one child
1044
- * is the project's own dev script (`vite dev`, `astro dev`, …) and every CLI
1045
- * sibling is disabled. Pure + synchronous so it's unit-testable.
1046
- */
1047
- declare const planDevCommand: (options: DevCommandOptions) => DevCommandPlan;
1048
1042
  /**
1049
1043
  * Start codegen watch + the studio server, spawn `wrangler dev`, print the
1050
1044
  * banner, and resolve when the worker exits or the user interrupts — tearing
@@ -1055,6 +1049,14 @@ declare const runDevCommand: (options: DevCommandOptions) => Promise<{
1055
1049
  code: number;
1056
1050
  plan: DevCommandPlan;
1057
1051
  }>;
1052
+ /**
1053
+ * Plan `lunora dev`. Wrangler flavor: the worker runs via `wrangler dev` and
1054
+ * nothing else as a child process. Vite flavor (`@lunora/vite` declared): the
1055
+ * plugin already runs the worker inside the Vite dev server, so the one child
1056
+ * is the project's own dev script (`vite dev`, `astro dev`, …) and every CLI
1057
+ * sibling is disabled. Pure + synchronous so it's unit-testable.
1058
+ */
1059
+ declare const planDevCommand: (options: DevCommandOptions) => DevCommandPlan;
1058
1060
  /** Supported CI providers. */
1059
1061
  type CiProvider = "github" | "gitlab";
1060
1062
  /**
@@ -1313,7 +1315,7 @@ interface LintToolOfferDeps {
1313
1315
  defaults?: ReadonlyArray<LintTool>;
1314
1316
  }) => Promise<LintTool[]>;
1315
1317
  }
1316
- type Template = "analog" | "astro" | "expo" | "next" | "nuxt" | "react-router" | "solid-v2" | "standalone" | "sveltekit" | "tanstack-start-react" | "tanstack-start-solid" | "vinext" | "vinext-pages";
1318
+ type Template = "analog" | "astro" | "expo" | "next" | "nuxt" | "react-router" | "rspack-react" | "solid-v2" | "standalone" | "sveltekit" | "tanstack-start-react" | "tanstack-start-react-rspack" | "tanstack-start-solid" | "vinext" | "vinext-pages";
1317
1319
  interface InitCommandOptions {
1318
1320
  /**
1319
1321
  * Add features non-interactively after scaffolding (the `--add` flag): a
package/dist/index.d.ts CHANGED
@@ -364,11 +364,6 @@ interface ImportCommandResult extends CommandResult<ImportCommandData> {
364
364
  inserted: number;
365
365
  }
366
366
  declare const runImportCommand: (options: ImportCommandOptions) => Promise<ImportCommandResult>;
367
- /**
368
- * Injectable probe for a Docker-compatible container engine. Tests pass a
369
- * stub; production uses {@link isDockerAvailable}.
370
- */
371
- type DockerProbe = () => boolean;
372
367
  /**
373
368
  * Every exit code `lunora` can terminate with. Stable — a value never changes
374
369
  * meaning, and a new bucket takes the next free number.
@@ -413,6 +408,11 @@ declare const exitCodeForCode: (code: string) => ExitCode;
413
408
  * upstream-API codes do). Anything else is a general failure.
414
409
  */
415
410
  declare const exitCodeForError: (error: unknown) => ExitCode;
411
+ /**
412
+ * Injectable probe for a Docker-compatible container engine. Tests pass a
413
+ * stub; production uses {@link isDockerAvailable}.
414
+ */
415
+ type DockerProbe = () => boolean;
416
416
  /**
417
417
  * The shared `/_lunora/health` probe used by `lunora verify --health-url` and
418
418
  * `lunora deploy --health-check`.
@@ -738,6 +738,8 @@ interface DeployCommandResult {
738
738
  ok: boolean;
739
739
  url: string;
740
740
  };
741
+ /** Whether the target a successful deploy shipped to has a log tail for `lunora logs`. */
742
+ logsAvailable?: boolean;
741
743
  /**
742
744
  * The `.dev.vars`-shaped filename (never a full path, never a value) a
743
745
  * secret minted during this run was recorded into, when the missing-
@@ -914,7 +916,7 @@ interface DevCommandOptions {
914
916
  cwd?: string;
915
917
  /**
916
918
  * Override where the binding manifest is written. One is always produced at
917
- * {@link DEV_BINDINGS_FILE}; naming a path also makes a derivation failure
919
+ * `DEV_BINDINGS_FILE`; naming a path also makes a derivation failure
918
920
  * fatal, since a named path means something is waiting on it.
919
921
  */
920
922
  emitBindings?: string;
@@ -924,13 +926,13 @@ interface DevCommandOptions {
924
926
  ensureExample?: typeof ensureDevVarsExample;
925
927
  /** Injection seam for tests — defaults to the real empty-secret/admin-token filler. */
926
928
  fillSecrets?: typeof fillDevSecrets;
927
- /** Injection seam for tests — defaults to the real free-port probe ({@link findAvailablePort}). */
929
+ /** Injection seam for tests — defaults to the real free-port probe (`findAvailablePort`). */
928
930
  findFreePort?: (preferred: number) => Promise<number>;
929
- /** Dev flavor override (tests / callers that already detected it) — defaults to {@link detectDevFlavor}. */
931
+ /** Dev flavor override (tests / callers that already detected it) — defaults to `detectDevFlavor`. */
930
932
  flavor?: DevFlavor;
931
- /** Injection seam for tests — defaults to the real IPv6-loopback probe ({@link hasIpv6Loopback}). */
933
+ /** Injection seam for tests — defaults to the real IPv6-loopback probe (`hasIpv6Loopback`). */
932
934
  hasIpv6Loopback?: () => boolean;
933
- /** `wrangler dev` devtools inspector port (`--inspector-port`). Wrangler flavor only — see {@link resolveInspectorPort}. */
935
+ /** `wrangler dev` devtools inspector port (`--inspector-port`). Wrangler flavor only — see `resolveInspectorPort`. */
934
936
  inspectorPort?: number;
935
937
  /**
936
938
  * Logs are NDJSON on stdout (`--json`, or a detected AI agent). Forwarded to
@@ -1037,14 +1039,6 @@ interface DevCommandPlan {
1037
1039
  tag: string;
1038
1040
  };
1039
1041
  }
1040
- /**
1041
- * Plan `lunora dev`. Wrangler flavor: the worker runs via `wrangler dev` and
1042
- * nothing else as a child process. Vite flavor (`@lunora/vite` declared): the
1043
- * plugin already runs the worker inside the Vite dev server, so the one child
1044
- * is the project's own dev script (`vite dev`, `astro dev`, …) and every CLI
1045
- * sibling is disabled. Pure + synchronous so it's unit-testable.
1046
- */
1047
- declare const planDevCommand: (options: DevCommandOptions) => DevCommandPlan;
1048
1042
  /**
1049
1043
  * Start codegen watch + the studio server, spawn `wrangler dev`, print the
1050
1044
  * banner, and resolve when the worker exits or the user interrupts — tearing
@@ -1055,6 +1049,14 @@ declare const runDevCommand: (options: DevCommandOptions) => Promise<{
1055
1049
  code: number;
1056
1050
  plan: DevCommandPlan;
1057
1051
  }>;
1052
+ /**
1053
+ * Plan `lunora dev`. Wrangler flavor: the worker runs via `wrangler dev` and
1054
+ * nothing else as a child process. Vite flavor (`@lunora/vite` declared): the
1055
+ * plugin already runs the worker inside the Vite dev server, so the one child
1056
+ * is the project's own dev script (`vite dev`, `astro dev`, …) and every CLI
1057
+ * sibling is disabled. Pure + synchronous so it's unit-testable.
1058
+ */
1059
+ declare const planDevCommand: (options: DevCommandOptions) => DevCommandPlan;
1058
1060
  /** Supported CI providers. */
1059
1061
  type CiProvider = "github" | "gitlab";
1060
1062
  /**
@@ -1313,7 +1315,7 @@ interface LintToolOfferDeps {
1313
1315
  defaults?: ReadonlyArray<LintTool>;
1314
1316
  }) => Promise<LintTool[]>;
1315
1317
  }
1316
- type Template = "analog" | "astro" | "expo" | "next" | "nuxt" | "react-router" | "solid-v2" | "standalone" | "sveltekit" | "tanstack-start-react" | "tanstack-start-solid" | "vinext" | "vinext-pages";
1318
+ type Template = "analog" | "astro" | "expo" | "next" | "nuxt" | "react-router" | "rspack-react" | "solid-v2" | "standalone" | "sveltekit" | "tanstack-start-react" | "tanstack-start-react-rspack" | "tanstack-start-solid" | "vinext" | "vinext-pages";
1317
1319
  interface InitCommandOptions {
1318
1320
  /**
1319
1321
  * Add features non-interactively after scaffolding (the `--add` flag): a
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{C as o,V as a,r as n}from"./packem_shared/cli-DOpChqUe.mjs";import{runCodegenCommand as m}from"./packem_chunks/runCodegenCommand.mjs";import{runDeployCommand as p}from"./packem_chunks/runDeployCommand.mjs";import{planDevCommand as C,runDevCommand as f}from"./packem_chunks/planDevCommand.mjs";import{runInitCommand as s}from"./packem_chunks/runInitCommand.mjs";import{runMigrateGenerateCommand as u}from"./packem_shared/runMigrateGenerateCommand-CDHswpMU.mjs";import{runResetCommand as E}from"./packem_chunks/runResetCommand.mjs";import{runRpcCommand as D}from"./packem_chunks/runRpcCommand.mjs";import{EXIT_CODE as R,exitCodeForCode as S,exitCodeForError as A,exitCodeForStatus as c}from"./packem_shared/EXIT_CODE-08cwt3MK.mjs";import{insertSchemaExtension as _}from"./packem_shared/insertSchemaExtension-DuiV6cba.mjs";import{createLogger as F,pail as b}from"./packem_shared/createLogger-Cl18I8AX.mjs";import{diffSnapshots as h,renderAddColumn as y,renderCreateIndex as L,renderCreateTable as w,renderDropIndex as B,renderDropTable as P,renderMigrationFile as U,validatorKindToSqlType as V}from"./packem_shared/diffSnapshots-WWwx-KvZ.mjs";import{default as G}from"./packem_shared/schemaIrToSnapshot-BjK-0IRo.mjs";import{createRecordingSpawner as Q,defaultSpawner as j}from"./packem_shared/createRecordingSpawner-sS7LEN7x.mjs";import{default as H}from"./packem_shared/parseManifest-CwPTKdtS.mjs";import{D as X,r as Y}from"./packem_shared/import-D7qdpSmJ.mjs";import{REQUIRED_COMPATIBILITY_DATE as k,REQUIRED_FLAG as z,validateWranglerProject as J,validateWranglerConfig as $}from"@lunora/config/cloudflare";import{b as er}from"./packem_shared/catalog-CahzmDLV.mjs";import{r as ar,a as nr,b as tr}from"./packem_shared/commands-CNqednoX.mjs";import{runExportCommand as dr}from"./packem_shared/runExportCommand-DxsJHYZt.mjs";export{o as COMMANDS,X as DEFAULT_IMPORT_BATCH_SIZE,R as EXIT_CODE,k as REQUIRED_COMPATIBILITY_DATE,z as REQUIRED_FLAG,a as VERSION,er as buildRegistryIndex,F as createLogger,Q as createRecordingSpawner,j as defaultSpawner,h as diffSnapshots,S as exitCodeForCode,A as exitCodeForError,c as exitCodeForStatus,_ as insertSchemaExtension,b as pail,H as parseManifest,C as planDevCommand,y as renderAddColumn,L as renderCreateIndex,w as renderCreateTable,B as renderDropIndex,P as renderDropTable,U as renderMigrationFile,ar as runAddCommand,nr as runBuildIndexCommand,n as runCli,m as runCodegenCommand,p as runDeployCommand,f as runDevCommand,dr as runExportCommand,Y as runImportCommand,s as runInitCommand,u as runMigrateGenerateCommand,tr as runRegistryViewCommand,E as runResetCommand,D as runRpcCommand,G as schemaIrToSnapshot,J as validateWrangler,$ as validateWranglerConfig,V as validatorKindToSqlType};
1
+ import{C as o,V as a,r as n}from"./packem_shared/cli-D1ZleZMH.mjs";import{runCodegenCommand as m}from"./packem_chunks/runCodegenCommand.mjs";import{runDeployCommand as p}from"./packem_chunks/runDeployCommand.mjs";import{runDevCommand as f}from"./packem_chunks/runDevCommand.mjs";import{p as i}from"./packem_shared/plan-B-KsxVne.mjs";import{runInitCommand as l}from"./packem_chunks/runInitCommand.mjs";import{runMigrateGenerateCommand as I}from"./packem_shared/runMigrateGenerateCommand-CDHswpMU.mjs";import{runResetCommand as g}from"./packem_chunks/runResetCommand.mjs";import{runRpcCommand as T}from"./packem_chunks/runRpcCommand.mjs";import{EXIT_CODE as S,exitCodeForCode as A,exitCodeForError as c,exitCodeForStatus as M}from"./packem_shared/EXIT_CODE-08cwt3MK.mjs";import{insertSchemaExtension as v}from"./packem_shared/insertSchemaExtension-DuiV6cba.mjs";import{createLogger as b,pail as O}from"./packem_shared/createLogger-Cl18I8AX.mjs";import{diffSnapshots as y,renderAddColumn as L,renderCreateIndex as w,renderCreateTable as B,renderDropIndex as P,renderDropTable as U,renderMigrationFile as V,validatorKindToSqlType as W}from"./packem_shared/diffSnapshots-WWwx-KvZ.mjs";import{default as N}from"./packem_shared/schemaIrToSnapshot-BjK-0IRo.mjs";import{createRecordingSpawner as j,defaultSpawner as q}from"./packem_shared/createRecordingSpawner-sS7LEN7x.mjs";import{default as K}from"./packem_shared/parseManifest-CwPTKdtS.mjs";import{D as Y,r as Z}from"./packem_shared/import-D7qdpSmJ.mjs";import{REQUIRED_COMPATIBILITY_DATE as z,REQUIRED_FLAG as J,validateWranglerProject as $,validateWranglerConfig as rr}from"@lunora/config/cloudflare";import{b as or}from"./packem_shared/catalog-CahzmDLV.mjs";import{r as nr,a as tr,b as mr}from"./packem_shared/commands-CNqednoX.mjs";import{runExportCommand as pr}from"./packem_shared/runExportCommand-DxsJHYZt.mjs";export{o as COMMANDS,Y as DEFAULT_IMPORT_BATCH_SIZE,S as EXIT_CODE,z as REQUIRED_COMPATIBILITY_DATE,J as REQUIRED_FLAG,a as VERSION,or as buildRegistryIndex,b as createLogger,j as createRecordingSpawner,q as defaultSpawner,y as diffSnapshots,A as exitCodeForCode,c as exitCodeForError,M as exitCodeForStatus,v as insertSchemaExtension,O as pail,K as parseManifest,i as planDevCommand,L as renderAddColumn,w as renderCreateIndex,B as renderCreateTable,P as renderDropIndex,U as renderDropTable,V as renderMigrationFile,nr as runAddCommand,tr as runBuildIndexCommand,n as runCli,m as runCodegenCommand,p as runDeployCommand,f as runDevCommand,pr as runExportCommand,Z as runImportCommand,l as runInitCommand,I as runMigrateGenerateCommand,mr as runRegistryViewCommand,g as runResetCommand,T as runRpcCommand,N as schemaIrToSnapshot,$ as validateWrangler,rr as validateWranglerConfig,W as validatorKindToSqlType};
@@ -1 +1 @@
1
- import{d as u}from"../packem_shared/command-Mmxzxyr5.mjs";import{EXIT_CODE as c}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{a as m}from"../packem_shared/resolve-target-C_ZloTvd.mjs";import{runMigrateGenerateCommand as l,runMigrateDataCommand as g,runMigrateToHyperdriveCommand as p,runMigrateCreateCommand as y}from"../packem_shared/runMigrateGenerateCommand-CDHswpMU.mjs";const b=n=>{const{argument:o,cwd:r,logger:t,options:a}=n,e=l({cwd:r,logger:t,name:o[1]??a.name});return{code:e.code,data:{empty:e.empty,migrationFile:e.migrationFile===""?void 0:e.migrationFile,subcommand:"generate"},...e.error===void 0?{}:{error:e.error}}},f=async n=>{const{logger:o,options:r}=n,t=await p({batchSize:r.batchSize,fromToken:r.fromToken??r.token,fromUrl:r.fromUrl??r.url,logger:o,out:r.out,prod:r.prod===!0,tables:r.tables,toToken:r.toToken??r.token,toUrl:r.toUrl??r.url,yes:r.yes===!0});return{code:t.code,data:{bytes:t.bytes,exported:t.exported,imported:t.imported,subcommand:"d1-to-hyperdrive"},...t.error===void 0?{}:{error:t.error}}},w=async n=>{const{argument:o,cwd:r,logger:t,options:a}=n,e=o[1]??a.name;if(!e){const i="migrate create requires a name. Usage: lunora migrate create <name> [--table <table>]";return t.error(i),{code:c.USAGE,error:i}}const s=await y({cwd:r,logger:t,name:e,table:a.table});return{code:s.code,data:{file:s.file===""?void 0:s.file,name:e,subcommand:"create"}}},h=async(n,o)=>{const{argument:r,cwd:t,logger:a,options:e}=n,s=r[1]??e.name;if(!s){const d=`migrate ${o} requires a migration id. Usage: lunora migrate ${o} <id>`;return a.error(d),{code:c.USAGE,error:d}}const i=await g({batchSize:e.batchSize,cwd:t,dryRun:e.dryRun===!0,id:s,logger:a,maxBatches:e.steps,prod:e.prod===!0,subcommand:o,token:e.token,url:m({cwd:t,prod:e.prod===!0,url:e.url}),yes:e.yes===!0});return{code:i.code,data:{id:s,result:i.body,subcommand:o}}},C=u(async({argument:n,cwd:o,logger:r,options:t})=>{const a=n[0],e={argument:n,cwd:o,logger:r,options:t};switch(a){case"create":return await w(e);case"d1-to-hyperdrive":return await f(e);case"down":case"status":case"up":return await h(e,a);case"generate":return b(e);default:{const s=`unknown migrate subcommand: "${a??""}" — expected generate | create | up | down | status`;return e.logger.error(s),{code:c.USAGE,error:s}}}});export{C as execute};
1
+ import{d as u}from"../packem_shared/command-B--jgXSc.mjs";import{EXIT_CODE as c}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{a as m}from"../packem_shared/resolve-target-C_ZloTvd.mjs";import{runMigrateGenerateCommand as l,runMigrateDataCommand as g,runMigrateToHyperdriveCommand as p,runMigrateCreateCommand as y}from"../packem_shared/runMigrateGenerateCommand-CDHswpMU.mjs";const b=n=>{const{argument:o,cwd:r,logger:t,options:a}=n,e=l({cwd:r,logger:t,name:o[1]??a.name});return{code:e.code,data:{empty:e.empty,migrationFile:e.migrationFile===""?void 0:e.migrationFile,subcommand:"generate"},...e.error===void 0?{}:{error:e.error}}},f=async n=>{const{logger:o,options:r}=n,t=await p({batchSize:r.batchSize,fromToken:r.fromToken??r.token,fromUrl:r.fromUrl??r.url,logger:o,out:r.out,prod:r.prod===!0,tables:r.tables,toToken:r.toToken??r.token,toUrl:r.toUrl??r.url,yes:r.yes===!0});return{code:t.code,data:{bytes:t.bytes,exported:t.exported,imported:t.imported,subcommand:"d1-to-hyperdrive"},...t.error===void 0?{}:{error:t.error}}},w=async n=>{const{argument:o,cwd:r,logger:t,options:a}=n,e=o[1]??a.name;if(!e){const i="migrate create requires a name. Usage: lunora migrate create <name> [--table <table>]";return t.error(i),{code:c.USAGE,error:i}}const s=await y({cwd:r,logger:t,name:e,table:a.table});return{code:s.code,data:{file:s.file===""?void 0:s.file,name:e,subcommand:"create"}}},h=async(n,o)=>{const{argument:r,cwd:t,logger:a,options:e}=n,s=r[1]??e.name;if(!s){const d=`migrate ${o} requires a migration id. Usage: lunora migrate ${o} <id>`;return a.error(d),{code:c.USAGE,error:d}}const i=await g({batchSize:e.batchSize,cwd:t,dryRun:e.dryRun===!0,id:s,logger:a,maxBatches:e.steps,prod:e.prod===!0,subcommand:o,token:e.token,url:m({cwd:t,prod:e.prod===!0,url:e.url}),yes:e.yes===!0});return{code:i.code,data:{id:s,result:i.body,subcommand:o}}},C=u(async({argument:n,cwd:o,logger:r,options:t})=>{const a=n[0],e={argument:n,cwd:o,logger:r,options:t};switch(a){case"create":return await w(e);case"d1-to-hyperdrive":return await f(e);case"down":case"status":case"up":return await h(e,a);case"generate":return b(e);default:{const s=`unknown migrate subcommand: "${a??""}" — expected generate | create | up | down | status`;return e.logger.error(s),{code:c.USAGE,error:s}}}});export{C as execute};
@@ -1 +1 @@
1
- import{existsSync as k,readFileSync as A}from"node:fs";import{applyLintIgnores as I,detectLintTools as N}from"@lunora/config";import{findWranglerFile as U}from"@lunora/config/cloudflare";import{join as w,basename as h}from"@visulima/path";import{d as S}from"../packem_shared/command-Mmxzxyr5.mjs";import{EXIT_CODE as o}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{r as D}from"../packem_shared/lint-ignore-report-DKZagpqk.mjs";import{t as y,a as E}from"../packem_shared/tui-prompts-B3YwUhGw.mjs";import{i as _}from"../packem_shared/resolve-DUCSc7jQ.mjs";import{r as L}from"../packem_shared/commands-CNqednoX.mjs";import{n as M,i as O,A as P,E as R,s as j,d as f,p as $,r as g,M as F,a as C,b as v,c as p,D as m,e as x,f as H,g as i,h as z,j as B,w as G,k as W,l as V}from"../packem_shared/storage-J4xhM4FU.mjs";const q=e=>{const r=e.trim().toLowerCase();return B.find(a=>a.value===r||a.label.toLowerCase()===r||r==="auth0"&&a.value==="auth-auth0"||r==="clerk"&&a.value==="auth-clerk")?.value},T=e=>{try{const r=JSON.parse(A(w(e,"package.json"),"utf8"));return{...r.dependencies,...r.devDependencies}}catch{return{}}},J=async e=>{const r=e.cwd??process.cwd(),t=H(T(r));return t!==void 0?t:e.yes===!0?(e.logger.warn(`add: couldn't detect your framework — using "${i}". Pass a specific item (e.g. \`lunora add auth-ui-vue\`) to override.`),i):await(e.promptSelect??((c,n,d)=>y(c,n,d)))("Which framework is your app?",z,{default:i})??i},X=async e=>{if(e.provider!==void 0&&e.provider!==""){const t=q(e.provider);return t===void 0?(e.logger.warn(`add: unknown --provider "${e.provider}" — using "${m}" (email & password).`),m):t}if(e.yes===!0)return m;const r=e.promptSelect??((t,a,c)=>y(t,a,c));return x(r)},l=e=>e.promptText??((r,t)=>E(r,t)),K=async e=>{const r=h(e.cwd??process.cwd());if(e.bucket!==void 0&&e.bucket!==""){const t=j(e.bucket);if(t!==void 0)return t;const a=f(r);return e.logger.warn(`add: "${e.bucket}" isn't a valid R2 bucket name (lowercase alphanumeric + hyphens, 3–63 chars) — using "${a}".`),a}return e.yes===!0?f(r):$(l(e),r)},Q=async e=>{const r=t=>{e.logger.warn(`add: ${t}`)};if(e.mailTo!==void 0&&e.mailTo!=="")return g(e.mailTo,r);if(e.yes!==!0)return g(await l(e)(F,{placeholder:"you@yourdomain.com"}),r)},Y=async e=>{const r=h(e.cwd??process.cwd());if(e.db!==void 0&&e.db!==""){const t=C(e.db);if(t!==void 0)return t;const a=v(r);return e.logger.warn(`add: "${e.db}" isn't a usable D1 database name — using "${a}".`),a}return e.yes===!0?v(r):p(l(e),r)},Z=async(e,r)=>e.kind==="auth"?[await X(r)]:e.kind==="auth-ui"?[await J(r)]:e.kind==="email"?[R]:[e.item],ee=(e,r)=>{D(I(e,N(e)),r)},re=e=>!_(e)||e.yes===!0,ae=async e=>{const r=e.cwd??process.cwd(),t=e.feature===void 0?void 0:M(e.feature);if(t===void 0)return e.logger.error("add requires a feature or registry item. Usage: lunora add <auth|email|storage|crons|presence|…>"),{code:o.USAGE,items:[]};if(!k(w(r,"lunora"))||U(r)===void 0)return e.logger.error("add: not a Lunora project here (need a lunora/ directory and a wrangler.jsonc). Run `lunora init` first."),{code:o.USAGE,items:[]};if(t.kind==="auth-ui"&&O(T(r)))return e.logger.error(`add: ${P}`),{code:o.USAGE,items:[]};const a=await Z(t,e),c=[];if(a.includes("storage")){const s=await K(e);c.push(u=>G(u,s))}if(a.includes("mail")){const s=await Q(e);s!==void 0&&c.push(u=>W(u,s))}if(a.some(s=>s==="auth"||s.startsWith("auth-"))){const s=await Y(e);c.push(u=>V(u,s))}const n=c.length>0?s=>{let u=s;for(const b of c)u=b(u);return u}:void 0,d=await L({allowUnsafeSource:e.allowUnsafeSource,confirm:e.confirm,cwd:r,from:e.from,logger:e.logger,names:[...a],ref:e.ref,source:e.source,transformManifest:n,yes:re(e)});return d.code===0&&ee(r,e.logger),{code:d.code,items:a}},ge=S(async({argument:e,cwd:r,logger:t,options:a})=>{const c=await ae({allowUnsafeSource:a.allowUnsafeSource===!0,bucket:a.bucket,cwd:r,db:a.db,feature:e[0],from:a.from,logger:t,mailTo:a.mailTo,provider:a.provider,ref:a.ref,source:a.source,yes:a.yes===!0});return{code:c.code,data:{items:c.items},...c.error===void 0?{}:{error:c.error}}});export{ge as execute,ae as runAddFeature};
1
+ import{existsSync as k,readFileSync as A}from"node:fs";import{applyLintIgnores as I,detectLintTools as N}from"@lunora/config";import{findWranglerFile as U}from"@lunora/config/cloudflare";import{join as w,basename as h}from"@visulima/path";import{d as S}from"../packem_shared/command-B--jgXSc.mjs";import{EXIT_CODE as o}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{r as D}from"../packem_shared/lint-ignore-report-DKZagpqk.mjs";import{t as y,a as E}from"../packem_shared/tui-prompts-B3YwUhGw.mjs";import{i as _}from"../packem_shared/resolve-DUCSc7jQ.mjs";import{r as L}from"../packem_shared/commands-CNqednoX.mjs";import{n as M,i as O,A as P,E as R,s as j,d as f,p as $,r as g,M as F,a as C,b as v,c as p,D as m,e as x,f as H,g as i,h as z,j as B,w as G,k as W,l as V}from"../packem_shared/storage-J4xhM4FU.mjs";const q=e=>{const r=e.trim().toLowerCase();return B.find(a=>a.value===r||a.label.toLowerCase()===r||r==="auth0"&&a.value==="auth-auth0"||r==="clerk"&&a.value==="auth-clerk")?.value},T=e=>{try{const r=JSON.parse(A(w(e,"package.json"),"utf8"));return{...r.dependencies,...r.devDependencies}}catch{return{}}},J=async e=>{const r=e.cwd??process.cwd(),t=H(T(r));return t!==void 0?t:e.yes===!0?(e.logger.warn(`add: couldn't detect your framework — using "${i}". Pass a specific item (e.g. \`lunora add auth-ui-vue\`) to override.`),i):await(e.promptSelect??((c,n,d)=>y(c,n,d)))("Which framework is your app?",z,{default:i})??i},X=async e=>{if(e.provider!==void 0&&e.provider!==""){const t=q(e.provider);return t===void 0?(e.logger.warn(`add: unknown --provider "${e.provider}" — using "${m}" (email & password).`),m):t}if(e.yes===!0)return m;const r=e.promptSelect??((t,a,c)=>y(t,a,c));return x(r)},l=e=>e.promptText??((r,t)=>E(r,t)),K=async e=>{const r=h(e.cwd??process.cwd());if(e.bucket!==void 0&&e.bucket!==""){const t=j(e.bucket);if(t!==void 0)return t;const a=f(r);return e.logger.warn(`add: "${e.bucket}" isn't a valid R2 bucket name (lowercase alphanumeric + hyphens, 3–63 chars) — using "${a}".`),a}return e.yes===!0?f(r):$(l(e),r)},Q=async e=>{const r=t=>{e.logger.warn(`add: ${t}`)};if(e.mailTo!==void 0&&e.mailTo!=="")return g(e.mailTo,r);if(e.yes!==!0)return g(await l(e)(F,{placeholder:"you@yourdomain.com"}),r)},Y=async e=>{const r=h(e.cwd??process.cwd());if(e.db!==void 0&&e.db!==""){const t=C(e.db);if(t!==void 0)return t;const a=v(r);return e.logger.warn(`add: "${e.db}" isn't a usable D1 database name — using "${a}".`),a}return e.yes===!0?v(r):p(l(e),r)},Z=async(e,r)=>e.kind==="auth"?[await X(r)]:e.kind==="auth-ui"?[await J(r)]:e.kind==="email"?[R]:[e.item],ee=(e,r)=>{D(I(e,N(e)),r)},re=e=>!_(e)||e.yes===!0,ae=async e=>{const r=e.cwd??process.cwd(),t=e.feature===void 0?void 0:M(e.feature);if(t===void 0)return e.logger.error("add requires a feature or registry item. Usage: lunora add <auth|email|storage|crons|presence|…>"),{code:o.USAGE,items:[]};if(!k(w(r,"lunora"))||U(r)===void 0)return e.logger.error("add: not a Lunora project here (need a lunora/ directory and a wrangler.jsonc). Run `lunora init` first."),{code:o.USAGE,items:[]};if(t.kind==="auth-ui"&&O(T(r)))return e.logger.error(`add: ${P}`),{code:o.USAGE,items:[]};const a=await Z(t,e),c=[];if(a.includes("storage")){const s=await K(e);c.push(u=>G(u,s))}if(a.includes("mail")){const s=await Q(e);s!==void 0&&c.push(u=>W(u,s))}if(a.some(s=>s==="auth"||s.startsWith("auth-"))){const s=await Y(e);c.push(u=>V(u,s))}const n=c.length>0?s=>{let u=s;for(const b of c)u=b(u);return u}:void 0,d=await L({allowUnsafeSource:e.allowUnsafeSource,confirm:e.confirm,cwd:r,from:e.from,logger:e.logger,names:[...a],ref:e.ref,source:e.source,transformManifest:n,yes:re(e)});return d.code===0&&ee(r,e.logger),{code:d.code,items:a}},ge=S(async({argument:e,cwd:r,logger:t,options:a})=>{const c=await ae({allowUnsafeSource:a.allowUnsafeSource===!0,bucket:a.bucket,cwd:r,db:a.db,feature:e[0],from:a.from,logger:t,mailTo:a.mailTo,provider:a.provider,ref:a.ref,source:a.source,yes:a.yes===!0});return{code:c.code,data:{items:c.items},...c.error===void 0?{}:{error:c.error}}});export{ge as execute,ae as runAddFeature};
@@ -1 +1 @@
1
- import{readFileSync as m,existsSync as u}from"node:fs";import{join as g}from"node:path";import{discoverSchema as h}from"@lunora/codegen";import{readLinkedProject as p}from"@lunora/config";import{findWranglerFile as $}from"@lunora/config/cloudflare";import{parse as v}from"jsonc-parser";import{Project as k}from"ts-morph";import{w,d as b}from"../packem_shared/binding-manifest-file-CQ1eQYy1.mjs";import{d as j}from"../packem_shared/command-Mmxzxyr5.mjs";import{EXIT_CODE as d}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";const f=(n,e)=>{if(n===null||typeof n!="object")return;const i=n[e];return typeof i=="string"&&i.length>0?i:void 0},S=(n,e)=>{if(n===null||typeof n!="object")return[];const i=n[e];return Array.isArray(i)?i:[]},x=(n,e)=>{const{manifest:i}=b(e);return{bindings:(i?.bindings??[]).map(r=>`${r.type}:${r.binding}`),compatibilityDate:f(n,"compatibility_date"),compatibilityFlags:S(n,"compatibility_flags").filter(r=>typeof r=="string"),main:f(n,"main"),name:f(n,"name")}},E=n=>({tables:n.tables.map(e=>{let i="root";return e.shardMode==="global"?i="global":typeof e.shardMode=="object"&&(i=`shardBy(${e.shardMode.field})`),{indexes:e.indexes.length,name:e.name,shard:i}}),vectorIndexes:n.vectorIndexes.length}),F=n=>{const e=g(n,"package.json");if(!u(e))return[];let i;try{i=JSON.parse(m(e,"utf8"))}catch{return[]}if(i===null||typeof i!="object")return[];const r=["dependencies","devDependencies","peerDependencies","optionalDependencies"],s=new Map;for(const a of r){const t=i[a];if(!(t===null||typeof t!="object"))for(const[o,c]of Object.entries(t))o.startsWith("@lunora/")&&typeof c=="string"&&!s.has(o)&&s.set(o,c)}return[...s.entries()].toSorted(([a],[t])=>a.localeCompare(t)).map(([a,t])=>({name:a,version:t}))},P=n=>{const e=F(n),i=$(n);let r;if(i)try{r=x(v(m(i,"utf8")),n)}catch{r=void 0}const s=g(n,"lunora","schema.ts");let a,t;if(u(s))try{const o=new k({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1});a=E(h(o,s))}catch(o){t=o instanceof Error?o.message:String(o)}return{link:p(n),lunoraPackages:e,projectRoot:n,schema:a,schemaError:t,wrangler:r,wranglerPath:i}},I=(n,e)=>{if(e.info(`project: ${n.projectRoot}`),e.info(""),e.info("@lunora/* packages:"),n.lunoraPackages.length===0)e.info(" (none found in package.json)");else for(const i of n.lunoraPackages)e.info(` ${i.name}@${i.version}`);if(e.info(""),n.wrangler?(e.info(`wrangler: ${n.wranglerPath??""}`),e.info(` name: ${n.wrangler.name??"<unset>"}`),e.info(` main: ${n.wrangler.main??"<unset>"}`),e.info(` compatibility_date: ${n.wrangler.compatibilityDate??"<unset>"}`),e.info(` compatibility_flags: ${n.wrangler.compatibilityFlags.join(", ")||"<none>"}`),e.info(` bindings: ${n.wrangler.bindings.join(", ")||"<none>"}`)):e.info("wrangler: (not found)"),e.info(""),n.link?(e.info(`link: ${n.link.workerName??"(unnamed)"} -> ${n.link.workerUrl??"<no url>"}`),n.link.env!==void 0&&e.info(` env: ${n.link.env}`)):e.info("link: (not linked — run `lunora link --url <https://your-worker>`)"),e.info(""),n.schemaError!==void 0)e.warn(`schema: parse error — ${n.schemaError}`);else if(n.schema){e.info(`schema: ${String(n.schema.tables.length)} table(s), ${String(n.schema.vectorIndexes)} vector index(es)`);for(const i of n.schema.tables)e.info(` ${i.name} [${i.shard}, ${String(i.indexes)} index(es)]`)}else e.info("schema: (no lunora/schema.ts)")},M=n=>{const{cwd:e,json:i,logger:r,out:s}=n;if(s!==void 0){const{error:o}=w({destination:s,logger:r,projectRoot:e});return o!==void 0?(r.error(o),{code:d.USAGE,error:o}):{code:0}}const{error:a,manifest:t}=b(e);if(t===void 0){const o=a??"could not derive the binding manifest";return r.error(o),{code:d.USAGE,error:o}}if(i)return{code:0,data:t};if(t.bindings.length===0)r.info("No bindings declared.");else{const o=Math.max(...t.bindings.map(c=>c.type.length));r.info(`${String(t.bindings.length)} binding(s):`);for(const c of t.bindings){const l=[c.resource,c.className,c.resourceId].filter(y=>y!==void 0).join(" ");r.info(` ${c.type.padEnd(o)} ${c.binding}${l===""?"":` ${l}`}`)}}return t.crons.length>0&&r.info(`${String(t.crons.length)} cron trigger(s): ${t.crons.join(", ")}`),t.vars.length>0&&r.info(`${String(t.vars.length)} var(s): ${t.vars.join(", ")}`),t.unknown.length>0&&r.warn(`not modelled by the manifest: ${t.unknown.join(", ")} — anything they bind must be provisioned by hand.`),{code:0,data:t}},A=n=>{const e=n.cwd??process.cwd(),i=n.format==="json",{logger:r}=n;if(n.bindings===!0)return M({cwd:e,json:i,logger:r,out:n.out});if(n.out!==void 0){const a="--out only applies with --bindings; the full info snapshot prints to stdout under --format json.";return r.error(a),{code:d.USAGE,error:a}}const s=P(e);return i||I(s,r),{code:0,data:s,snapshot:s}},L=j(({cwd:n,format:e,logger:i,options:r})=>A({bindings:r.bindings===!0,cwd:n,format:e,logger:i,out:r.out}));export{P as collectInfo,L as execute,A as runInfoCommand};
1
+ import{readFileSync as m,existsSync as u}from"node:fs";import{join as g}from"node:path";import{discoverSchema as h}from"@lunora/codegen";import{readLinkedProject as p}from"@lunora/config";import{findWranglerFile as $}from"@lunora/config/cloudflare";import{parse as v}from"jsonc-parser";import{Project as k}from"ts-morph";import{w,d as b}from"../packem_shared/binding-manifest-file-CQ1eQYy1.mjs";import{d as j}from"../packem_shared/command-B--jgXSc.mjs";import{EXIT_CODE as d}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";const f=(n,e)=>{if(n===null||typeof n!="object")return;const i=n[e];return typeof i=="string"&&i.length>0?i:void 0},S=(n,e)=>{if(n===null||typeof n!="object")return[];const i=n[e];return Array.isArray(i)?i:[]},x=(n,e)=>{const{manifest:i}=b(e);return{bindings:(i?.bindings??[]).map(r=>`${r.type}:${r.binding}`),compatibilityDate:f(n,"compatibility_date"),compatibilityFlags:S(n,"compatibility_flags").filter(r=>typeof r=="string"),main:f(n,"main"),name:f(n,"name")}},E=n=>({tables:n.tables.map(e=>{let i="root";return e.shardMode==="global"?i="global":typeof e.shardMode=="object"&&(i=`shardBy(${e.shardMode.field})`),{indexes:e.indexes.length,name:e.name,shard:i}}),vectorIndexes:n.vectorIndexes.length}),F=n=>{const e=g(n,"package.json");if(!u(e))return[];let i;try{i=JSON.parse(m(e,"utf8"))}catch{return[]}if(i===null||typeof i!="object")return[];const r=["dependencies","devDependencies","peerDependencies","optionalDependencies"],s=new Map;for(const a of r){const t=i[a];if(!(t===null||typeof t!="object"))for(const[o,c]of Object.entries(t))o.startsWith("@lunora/")&&typeof c=="string"&&!s.has(o)&&s.set(o,c)}return[...s.entries()].toSorted(([a],[t])=>a.localeCompare(t)).map(([a,t])=>({name:a,version:t}))},P=n=>{const e=F(n),i=$(n);let r;if(i)try{r=x(v(m(i,"utf8")),n)}catch{r=void 0}const s=g(n,"lunora","schema.ts");let a,t;if(u(s))try{const o=new k({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1});a=E(h(o,s))}catch(o){t=o instanceof Error?o.message:String(o)}return{link:p(n),lunoraPackages:e,projectRoot:n,schema:a,schemaError:t,wrangler:r,wranglerPath:i}},I=(n,e)=>{if(e.info(`project: ${n.projectRoot}`),e.info(""),e.info("@lunora/* packages:"),n.lunoraPackages.length===0)e.info(" (none found in package.json)");else for(const i of n.lunoraPackages)e.info(` ${i.name}@${i.version}`);if(e.info(""),n.wrangler?(e.info(`wrangler: ${n.wranglerPath??""}`),e.info(` name: ${n.wrangler.name??"<unset>"}`),e.info(` main: ${n.wrangler.main??"<unset>"}`),e.info(` compatibility_date: ${n.wrangler.compatibilityDate??"<unset>"}`),e.info(` compatibility_flags: ${n.wrangler.compatibilityFlags.join(", ")||"<none>"}`),e.info(` bindings: ${n.wrangler.bindings.join(", ")||"<none>"}`)):e.info("wrangler: (not found)"),e.info(""),n.link?(e.info(`link: ${n.link.workerName??"(unnamed)"} -> ${n.link.workerUrl??"<no url>"}`),n.link.env!==void 0&&e.info(` env: ${n.link.env}`)):e.info("link: (not linked — run `lunora link --url <https://your-worker>`)"),e.info(""),n.schemaError!==void 0)e.warn(`schema: parse error — ${n.schemaError}`);else if(n.schema){e.info(`schema: ${String(n.schema.tables.length)} table(s), ${String(n.schema.vectorIndexes)} vector index(es)`);for(const i of n.schema.tables)e.info(` ${i.name} [${i.shard}, ${String(i.indexes)} index(es)]`)}else e.info("schema: (no lunora/schema.ts)")},M=n=>{const{cwd:e,json:i,logger:r,out:s}=n;if(s!==void 0){const{error:o}=w({destination:s,logger:r,projectRoot:e});return o!==void 0?(r.error(o),{code:d.USAGE,error:o}):{code:0}}const{error:a,manifest:t}=b(e);if(t===void 0){const o=a??"could not derive the binding manifest";return r.error(o),{code:d.USAGE,error:o}}if(i)return{code:0,data:t};if(t.bindings.length===0)r.info("No bindings declared.");else{const o=Math.max(...t.bindings.map(c=>c.type.length));r.info(`${String(t.bindings.length)} binding(s):`);for(const c of t.bindings){const l=[c.resource,c.className,c.resourceId].filter(y=>y!==void 0).join(" ");r.info(` ${c.type.padEnd(o)} ${c.binding}${l===""?"":` ${l}`}`)}}return t.crons.length>0&&r.info(`${String(t.crons.length)} cron trigger(s): ${t.crons.join(", ")}`),t.vars.length>0&&r.info(`${String(t.vars.length)} var(s): ${t.vars.join(", ")}`),t.unknown.length>0&&r.warn(`not modelled by the manifest: ${t.unknown.join(", ")} — anything they bind must be provisioned by hand.`),{code:0,data:t}},A=n=>{const e=n.cwd??process.cwd(),i=n.format==="json",{logger:r}=n;if(n.bindings===!0)return M({cwd:e,json:i,logger:r,out:n.out});if(n.out!==void 0){const a="--out only applies with --bindings; the full info snapshot prints to stdout under --format json.";return r.error(a),{code:d.USAGE,error:a}}const s=P(e);return i||I(s,r),{code:0,data:s,snapshot:s}},L=j(({cwd:n,format:e,logger:i,options:r})=>A({bindings:r.bindings===!0,cwd:n,format:e,logger:i,out:r.out}));export{P as collectInfo,L as execute,A as runInfoCommand};
@@ -1,2 +1,2 @@
1
- import{r as v}from"../packem_shared/admin-token-VdUnvnKW.mjs";import{r as y}from"../packem_shared/admin-url-BhF5ufg1.mjs";import{d as M}from"../packem_shared/command-Mmxzxyr5.mjs";import{EXIT_CODE as d,exitCodeForStatus as T}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{a as x}from"../packem_shared/resolve-target-C_ZloTvd.mjs";const I="__lunora_admin__:getFunctionStats",E=10,f=(r,o)=>({calls:r.calls,conflicts:r.conflicts??0,errors:r.errors,lastErrorMessage:r.lastErrorMessage,maxDurationMs:r.maxDurationMs,meanDurationMs:r.calls===0?0:r.totalDurationMs/r.calls,path:r.path,rate:o}),O=(r,o)=>{const t=r.filter(e=>(e.conflicts??0)>0).map(e=>f(e,e.calls===0?0:(e.conflicts??0)/e.calls)).toSorted((e,s)=>s.rate-e.rate||s.conflicts-e.conflicts).slice(0,o),n=r.filter(e=>e.errors>0).map(e=>f(e,e.calls===0?0:e.errors/e.calls)).toSorted((e,s)=>s.rate-e.rate||s.errors-e.errors).slice(0,o),a=r.map(e=>f(e,0)).toSorted((e,s)=>s.maxDurationMs-e.maxDurationMs).slice(0,o);return{errorHotspots:n,latencyOutliers:a,totalFunctions:r.length,writeContention:t}},p=r=>`${(r*100).toFixed(1)}%`,$=r=>r<1e3?`${Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,m=(r,o,t,n)=>[r,...o.length===0?[` ${t}`]:o.map(a=>` ${n(a)}`)],_=r=>{const o=t=>t.lastErrorMessage?` — ${t.lastErrorMessage}`:"";return[`Insights over ${r.totalFunctions.toString()} function${r.totalFunctions===1?"":"s"}`,"",...m("Write-conflict hot-spots (OCC contention — candidates for sharding):",r.writeContention,"none — no write conflicts observed",t=>`${t.path} ${t.conflicts.toString()}/${t.calls.toString()} calls (${p(t.rate)})`),"",...m("Error hot-spots:",r.errorHotspots,"none — no errors observed",t=>`${t.path} ${t.errors.toString()}/${t.calls.toString()} calls (${p(t.rate)})${o(t)}`),"",...m("Latency outliers (slowest single call):",r.latencyOutliers,"none — no functions have run",t=>`${t.path} max ${$(t.maxDurationMs)}, mean ${$(t.meanDurationMs)} over ${t.calls.toString()} calls`)].join(`
1
+ import{r as v}from"../packem_shared/admin-token-VdUnvnKW.mjs";import{r as y}from"../packem_shared/admin-url-BhF5ufg1.mjs";import{d as M}from"../packem_shared/command-B--jgXSc.mjs";import{EXIT_CODE as d,exitCodeForStatus as T}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{a as x}from"../packem_shared/resolve-target-C_ZloTvd.mjs";const I="__lunora_admin__:getFunctionStats",E=10,f=(r,o)=>({calls:r.calls,conflicts:r.conflicts??0,errors:r.errors,lastErrorMessage:r.lastErrorMessage,maxDurationMs:r.maxDurationMs,meanDurationMs:r.calls===0?0:r.totalDurationMs/r.calls,path:r.path,rate:o}),O=(r,o)=>{const t=r.filter(e=>(e.conflicts??0)>0).map(e=>f(e,e.calls===0?0:(e.conflicts??0)/e.calls)).toSorted((e,s)=>s.rate-e.rate||s.conflicts-e.conflicts).slice(0,o),n=r.filter(e=>e.errors>0).map(e=>f(e,e.calls===0?0:e.errors/e.calls)).toSorted((e,s)=>s.rate-e.rate||s.errors-e.errors).slice(0,o),a=r.map(e=>f(e,0)).toSorted((e,s)=>s.maxDurationMs-e.maxDurationMs).slice(0,o);return{errorHotspots:n,latencyOutliers:a,totalFunctions:r.length,writeContention:t}},p=r=>`${(r*100).toFixed(1)}%`,$=r=>r<1e3?`${Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,m=(r,o,t,n)=>[r,...o.length===0?[` ${t}`]:o.map(a=>` ${n(a)}`)],_=r=>{const o=t=>t.lastErrorMessage?` — ${t.lastErrorMessage}`:"";return[`Insights over ${r.totalFunctions.toString()} function${r.totalFunctions===1?"":"s"}`,"",...m("Write-conflict hot-spots (OCC contention — candidates for sharding):",r.writeContention,"none — no write conflicts observed",t=>`${t.path} ${t.conflicts.toString()}/${t.calls.toString()} calls (${p(t.rate)})`),"",...m("Error hot-spots:",r.errorHotspots,"none — no errors observed",t=>`${t.path} ${t.errors.toString()}/${t.calls.toString()} calls (${p(t.rate)})${o(t)}`),"",...m("Latency outliers (slowest single call):",r.latencyOutliers,"none — no functions have run",t=>`${t.path} max ${$(t.maxDurationMs)}, mean ${$(t.meanDurationMs)} over ${t.calls.toString()} calls`)].join(`
2
2
  `)},i=(r,o,t)=>(r.error(o),{code:t,error:o}),k=r=>r===void 0||!Number.isFinite(r)||r<=0?E:Math.floor(r),A=async r=>{const{logger:o}=r;if(r.prod&&r.url===void 0)return i(o,"--prod requires an explicit --url (refusing to report from the implicit localhost worker)",d.USAGE);const t=y(r.url,o,r.cwd);if(t===void 0)return{code:d.USAGE,error:"could not resolve a usable worker URL"};const{token:n}=v({cwd:r.cwd??process.cwd(),token:r.token,url:t});if(!n)return i(o,"admin token required — pass --token, set LUNORA_ADMIN_TOKEN, or add it to .dev.vars (local targets only)",d.AUTH);const a=`${t}/_lunora/rpc`,e=globalThis.fetch;if(typeof e!="function")throw new TypeError("no fetch implementation available — pass fetchImpl or run on Node >= 18");const s={args:{},functionPath:I};r.shard!==void 0&&(s.shardKey=r.shard),o.info(`POST ${a} -> insights`);const l=await e(a,{body:JSON.stringify(s),headers:{authorization:`Bearer ${n}`,"content-type":"application/json"},method:"POST"}),c=await l.text();if(!l.ok)return i(o,`insights failed: HTTP ${String(l.status)}: ${c}`,T(l.status));let u;try{u=JSON.parse(c)}catch{return i(o,`insights failed: worker returned non-JSON: ${c}`,1)}const S=u.result??u,{functions:h}=S;if(!Array.isArray(h))return i(o,"insights failed: response carried no `functions` array",1);const g=O(h,k(r.limit));return r.format!=="json"&&o.info(_(g)),{code:0,report:g}},C=M(async({cwd:r,format:o,logger:t,options:n})=>{const a=n.limit===void 0?void 0:Number.parseInt(n.limit,10),e=await A({cwd:r,fetchImpl:void 0,format:o,limit:a,logger:t,prod:n.prod,shard:n.shard,token:n.token,url:x({cwd:r,prod:n.prod===!0,url:n.url})});return{code:e.code,data:e.report,error:e.error}});export{O as buildInsightsReport,C as execute,_ as formatInsightsReport,A as runInsightsCommand};
@@ -1 +1 @@
1
- import{existsSync as u,rmSync as a}from"node:fs";import{join as i}from"node:path";import{writeLinkedProject as d,LINKED_PROJECT_FILE as o}from"@lunora/config";import{d as k}from"../packem_shared/command-Mmxzxyr5.mjs";import{EXIT_CODE as c}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{r as s}from"../packem_shared/wrangler-name-Dsk5K1f-.mjs";const v=r=>{try{const{protocol:n}=new URL(r);return n==="http:"||n==="https:"}catch{return!1}},f=(r,n)=>{const e=i(r,o);return u(e)?(a(e),n.success(`link: removed ${o}`),{code:0}):(n.warn(`link: no ${o} to remove`),{code:0})},w=r=>{const n=r.cwd??process.cwd(),{logger:e}=r;if(r.remove)return f(n,e);if(r.url===void 0||r.url==="")return e.error("link requires a deployed Worker URL. Usage: lunora link --url <https://your-worker>"),{code:c.USAGE};if(!v(r.url))return e.error(`link: invalid --url "${r.url}" — expected an http(s) URL`),{code:c.USAGE};const l=r.now??(()=>new Date().toISOString()),t={env:r.env,linkedAt:l(),workerName:r.name??s(n),workerUrl:r.url},m=d(n,t);return e.success(`link: ${t.workerName??"(unnamed worker)"} -> ${r.url}`),e.info(`link: wrote ${m}`),t.env!==void 0&&e.info(`link: environment "${t.env}"`),{code:0,link:t}},y=k(({cwd:r,logger:n,options:e})=>w({cwd:r,env:e.env,logger:n,name:e.name,remove:e.remove===!0,url:e.url}));export{y as execute,w as runLinkCommand};
1
+ import{existsSync as u,rmSync as a}from"node:fs";import{join as i}from"node:path";import{writeLinkedProject as d,LINKED_PROJECT_FILE as o}from"@lunora/config";import{d as k}from"../packem_shared/command-B--jgXSc.mjs";import{EXIT_CODE as c}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{r as s}from"../packem_shared/wrangler-name-Dsk5K1f-.mjs";const v=r=>{try{const{protocol:n}=new URL(r);return n==="http:"||n==="https:"}catch{return!1}},f=(r,n)=>{const e=i(r,o);return u(e)?(a(e),n.success(`link: removed ${o}`),{code:0}):(n.warn(`link: no ${o} to remove`),{code:0})},w=r=>{const n=r.cwd??process.cwd(),{logger:e}=r;if(r.remove)return f(n,e);if(r.url===void 0||r.url==="")return e.error("link requires a deployed Worker URL. Usage: lunora link --url <https://your-worker>"),{code:c.USAGE};if(!v(r.url))return e.error(`link: invalid --url "${r.url}" — expected an http(s) URL`),{code:c.USAGE};const l=r.now??(()=>new Date().toISOString()),t={env:r.env,linkedAt:l(),workerName:r.name??s(n),workerUrl:r.url},m=d(n,t);return e.success(`link: ${t.workerName??"(unnamed worker)"} -> ${r.url}`),e.info(`link: wrote ${m}`),t.env!==void 0&&e.info(`link: environment "${t.env}"`),{code:0,link:t}},y=k(({cwd:r,logger:n,options:e})=>w({cwd:r,env:e.env,logger:n,name:e.name,remove:e.remove===!0,url:e.url}));export{y as execute,w as runLinkCommand};
@@ -1 +1 @@
1
- import{p as i}from"../packem_shared/deploy-target-DCWwiuAe.mjs";import{d as c}from"../packem_shared/command-Mmxzxyr5.mjs";import{EXIT_CODE as t}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{runPreDeployPipeline as d}from"./runDeployCommand.mjs";const l=async r=>{const a=r.cwd??process.cwd(),e=await d({allowSchemaDrift:r.allowSchemaDrift,apiSpec:r.apiSpec,cwd:a,logger:r.logger,spawner:r.spawner,strictAdvisories:r.strictAdvisories,target:r.target,updateSchemaBaseline:r.updateSchemaBaseline},"prepare");return e.error!==void 0?{code:e.code??t.USAGE,error:e.error,...e.schemaDrift===void 0?{}:{schemaDrift:e.schemaDrift},validation:e.validation}:(e.reblessSchemaBaseline?.(),r.logger.success("project is ready to deploy"),{code:0,validation:e.validation})},S=c(({cwd:r,logger:a,options:e})=>l({allowSchemaDrift:e.allowSchemaDrift===!0,apiSpec:i(e.apiSpec),cwd:r,logger:a,strictAdvisories:e.strictAdvisories,target:e.target,updateSchemaBaseline:e.updateSchemaBaseline===!0}));export{S as execute,l as runPrepareCommand};
1
+ import{p as i}from"../packem_shared/deploy-target-DCWwiuAe.mjs";import{d as c}from"../packem_shared/command-B--jgXSc.mjs";import{EXIT_CODE as t}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{runPreDeployPipeline as d}from"./runDeployCommand.mjs";const l=async r=>{const a=r.cwd??process.cwd(),e=await d({allowSchemaDrift:r.allowSchemaDrift,apiSpec:r.apiSpec,cwd:a,logger:r.logger,spawner:r.spawner,strictAdvisories:r.strictAdvisories,target:r.target,updateSchemaBaseline:r.updateSchemaBaseline},"prepare");return e.error!==void 0?{code:e.code??t.USAGE,error:e.error,...e.schemaDrift===void 0?{}:{schemaDrift:e.schemaDrift},validation:e.validation}:(e.reblessSchemaBaseline?.(),r.logger.success("project is ready to deploy"),{code:0,validation:e.validation})},S=c(({cwd:r,logger:a,options:e})=>l({allowSchemaDrift:e.allowSchemaDrift===!0,apiSpec:i(e.apiSpec),cwd:r,logger:a,strictAdvisories:e.strictAdvisories,target:e.target,updateSchemaBaseline:e.updateSchemaBaseline===!0}));export{S as execute,l as runPrepareCommand};
@@ -1 +1 @@
1
- import{d as l}from"../packem_shared/command-Mmxzxyr5.mjs";import{EXIT_CODE as n}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{r as s,b as t,a as o}from"../packem_shared/commands-CNqednoX.mjs";const y=l(({argument:a,cwd:u,format:m,logger:e,options:r})=>{const f=a[0],c=a.slice(1);if(f==="add")return s({allowUnsafeSource:r.allowUnsafeSource===!0,cwd:u,diff:r.diff===!0,dryRun:r.dryRun===!0,format:m,from:r.from,logger:e,names:c,overwrite:r.overwrite===!0,ref:r.ref,source:r.source,yes:r.yes===!0});if(f==="list")return s({allowUnsafeSource:r.allowUnsafeSource===!0,cwd:u,format:m,from:r.from,list:!0,logger:e,names:[],ref:r.ref,source:r.source});if(f==="view")return t({allowUnsafeSource:r.allowUnsafeSource===!0,cwd:u,from:r.from,logger:e,names:c,ref:r.ref,source:r.source});if(f==="build")return o({check:r.check===!0,cwd:u,from:r.from,logger:e,names:[],out:r.out});const d="registry: unknown subcommand. Usage: lunora registry <add|list|view|build> [names…]";return e.error(d),{code:n.USAGE,error:d}});export{y as execute};
1
+ import{d as l}from"../packem_shared/command-B--jgXSc.mjs";import{EXIT_CODE as n}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{r as s,b as t,a as o}from"../packem_shared/commands-CNqednoX.mjs";const y=l(({argument:a,cwd:u,format:m,logger:e,options:r})=>{const f=a[0],c=a.slice(1);if(f==="add")return s({allowUnsafeSource:r.allowUnsafeSource===!0,cwd:u,diff:r.diff===!0,dryRun:r.dryRun===!0,format:m,from:r.from,logger:e,names:c,overwrite:r.overwrite===!0,ref:r.ref,source:r.source,yes:r.yes===!0});if(f==="list")return s({allowUnsafeSource:r.allowUnsafeSource===!0,cwd:u,format:m,from:r.from,list:!0,logger:e,names:[],ref:r.ref,source:r.source});if(f==="view")return t({allowUnsafeSource:r.allowUnsafeSource===!0,cwd:u,from:r.from,logger:e,names:c,ref:r.ref,source:r.source});if(f==="build")return o({check:r.check===!0,cwd:u,from:r.from,logger:e,names:[],out:r.out});const d="registry: unknown subcommand. Usage: lunora registry <add|list|view|build> [names…]";return e.error(d),{code:n.USAGE,error:d}});export{y as execute};
@@ -1 +1 @@
1
- import{existsSync as c,readFileSync as g,readdirSync as f,statSync as k,mkdirSync as w,writeFileSync as y}from"node:fs";import{fileURLToPath as R}from"node:url";import{AGENT_RULES_DIR as u,detectAgentRules as v,LUNORA_SKILL_NAMES as L}from"@lunora/config";import{join as i,relative as A,resolve as E,dirname as d}from"@visulima/path";import{d as I}from"../packem_shared/command-Mmxzxyr5.mjs";import{EXIT_CODE as $}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";const b=(e=d(R(import.meta.url)))=>{let r=e;for(let n=0;n<6;n+=1){const t=i(r,"package.json");if(c(t))try{if(JSON.parse(g(t,"utf8")).name==="@lunora/cli"){const o=i(r,"skills");return c(o)?o:void 0}}catch{}const s=d(r);if(s===r)break;r=s}},_=e=>f(e).filter(r=>{const n=i(e,r);return k(n).isDirectory()&&c(i(n,"SKILL.md"))}),m=(e,r,n)=>{w(r,{recursive:!0});let t=!1;for(const s of f(e)){const l=i(e,s),o=i(r,s);if(k(l).isDirectory()){t=m(l,o,n)||t;continue}c(o)&&!n||(y(o,g(l)),t=!0)}return t},j=["pnpm-workspace.yaml","pnpm-lock.yaml","yarn.lock","package-lock.json","bun.lock","bun.lockb",".git"],O=e=>{let r=e;for(;;){if(j.some(t=>c(i(r,t))))return r;const n=d(r);if(n===r)return e;r=n}},p=(e,r)=>r===void 0?O(e):E(e,r),x=e=>{const r=e.cwd??process.cwd(),n=p(r,e.dir),t=e.overwrite===!0,s=b();if(s===void 0)return e.logger.error("rules: could not locate the bundled skills (is @lunora/cli installed correctly?)."),{code:1,installed:[],skipped:[]};const l=[],o=[];for(const a of _(s)){const h=i(n,u,a);m(i(s,a),h,t)?l.push(a):o.push(a)}const S=A(r,i(n,u))||u;return l.length>0&&e.logger.success(`Installed ${String(l.length)} Lunora skill(s) into ${S}/: ${l.join(", ")}.`),o.length>0&&e.logger.info(`Skipped ${String(o.length)} existing skill(s) (re-run with --overwrite to replace): ${o.join(", ")}.`),e.logger.info("Your AI coding agent will pick these up automatically. Start with the `lunora` skill."),{code:0,installed:l,skipped:o}},D=e=>{const r=e.cwd??process.cwd(),n=p(r,e.dir),t=v(n);return t.installed?(e.logger.success(`Lunora agent rules are installed (${String(t.present.length)}/${String(L.length)} skills).`),t.missing.length>0&&e.logger.info(`Missing: ${t.missing.join(", ")}. Run \`lunora rules install\` to add them.`),{code:0,installed:t.present,skipped:[]}):(e.logger.warn("Lunora agent rules are not installed. Run `lunora rules install` so your AI agent knows how to use Lunora."),{code:e.strict===!0?1:0,installed:t.present,skipped:[]})},B=I(({argument:e,cwd:r,logger:n,options:t})=>{const s=e[0]??"check";return s==="install"?x({cwd:r,dir:t.dir,logger:n,overwrite:t.overwrite===!0}):s==="check"?D({cwd:r,dir:t.dir,logger:n,strict:t.strict===!0}):(n.error("rules: unknown subcommand. Usage: lunora rules <install|check>"),{code:$.USAGE})});export{B as execute,_ as listBundledSkills,b as resolveBundledSkillsDirectory,D as runRulesCheck,x as runRulesInstall};
1
+ import{existsSync as c,readFileSync as g,readdirSync as f,statSync as k,mkdirSync as w,writeFileSync as y}from"node:fs";import{fileURLToPath as R}from"node:url";import{AGENT_RULES_DIR as u,detectAgentRules as v,LUNORA_SKILL_NAMES as L}from"@lunora/config";import{join as i,relative as A,resolve as E,dirname as d}from"@visulima/path";import{d as I}from"../packem_shared/command-B--jgXSc.mjs";import{EXIT_CODE as $}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";const b=(e=d(R(import.meta.url)))=>{let r=e;for(let n=0;n<6;n+=1){const t=i(r,"package.json");if(c(t))try{if(JSON.parse(g(t,"utf8")).name==="@lunora/cli"){const o=i(r,"skills");return c(o)?o:void 0}}catch{}const s=d(r);if(s===r)break;r=s}},_=e=>f(e).filter(r=>{const n=i(e,r);return k(n).isDirectory()&&c(i(n,"SKILL.md"))}),m=(e,r,n)=>{w(r,{recursive:!0});let t=!1;for(const s of f(e)){const l=i(e,s),o=i(r,s);if(k(l).isDirectory()){t=m(l,o,n)||t;continue}c(o)&&!n||(y(o,g(l)),t=!0)}return t},j=["pnpm-workspace.yaml","pnpm-lock.yaml","yarn.lock","package-lock.json","bun.lock","bun.lockb",".git"],O=e=>{let r=e;for(;;){if(j.some(t=>c(i(r,t))))return r;const n=d(r);if(n===r)return e;r=n}},p=(e,r)=>r===void 0?O(e):E(e,r),x=e=>{const r=e.cwd??process.cwd(),n=p(r,e.dir),t=e.overwrite===!0,s=b();if(s===void 0)return e.logger.error("rules: could not locate the bundled skills (is @lunora/cli installed correctly?)."),{code:1,installed:[],skipped:[]};const l=[],o=[];for(const a of _(s)){const h=i(n,u,a);m(i(s,a),h,t)?l.push(a):o.push(a)}const S=A(r,i(n,u))||u;return l.length>0&&e.logger.success(`Installed ${String(l.length)} Lunora skill(s) into ${S}/: ${l.join(", ")}.`),o.length>0&&e.logger.info(`Skipped ${String(o.length)} existing skill(s) (re-run with --overwrite to replace): ${o.join(", ")}.`),e.logger.info("Your AI coding agent will pick these up automatically. Start with the `lunora` skill."),{code:0,installed:l,skipped:o}},D=e=>{const r=e.cwd??process.cwd(),n=p(r,e.dir),t=v(n);return t.installed?(e.logger.success(`Lunora agent rules are installed (${String(t.present.length)}/${String(L.length)} skills).`),t.missing.length>0&&e.logger.info(`Missing: ${t.missing.join(", ")}. Run \`lunora rules install\` to add them.`),{code:0,installed:t.present,skipped:[]}):(e.logger.warn("Lunora agent rules are not installed. Run `lunora rules install` so your AI agent knows how to use Lunora."),{code:e.strict===!0?1:0,installed:t.present,skipped:[]})},B=I(({argument:e,cwd:r,logger:n,options:t})=>{const s=e[0]??"check";return s==="install"?x({cwd:r,dir:t.dir,logger:n,overwrite:t.overwrite===!0}):s==="check"?D({cwd:r,dir:t.dir,logger:n,strict:t.strict===!0}):(n.error("rules: unknown subcommand. Usage: lunora rules <install|check>"),{code:$.USAGE})});export{B as execute,_ as listBundledSkills,b as resolveBundledSkillsDirectory,D as runRulesCheck,x as runRulesInstall};
@@ -1,3 +1,3 @@
1
- import{existsSync as S}from"node:fs";import{mkdtemp as v,writeFile as k,rm as j}from"node:fs/promises";import{tmpdir as R}from"node:os";import{discoverSchema as C,schemaFromIr as T}from"@lunora/codegen";import{seedPlan as $}from"@lunora/seed";import{join as w}from"@visulima/path";import{Project as A}from"ts-morph";import{t as y}from"../packem_shared/admin-token-VdUnvnKW.mjs";import{d as E}from"../packem_shared/command-Mmxzxyr5.mjs";import{EXIT_CODE as u}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{a as F}from"../packem_shared/resolve-target-C_ZloTvd.mjs";import{b as N}from"../packem_shared/tui-prompts-B3YwUhGw.mjs";import{runResetCommand as U}from"./runResetCommand.mjs";import{r as I}from"../packem_shared/import-D7qdpSmJ.mjs";const O=(e,r)=>typeof r=="bigint"?Number(r):r instanceof ArrayBuffer?[...new Uint8Array(r)]:r,f=(e,r)=>({code:e,error:r,ndjson:""}),x=(e,r)=>{if(!S(r)){const o=`schema not found: ${r} — run \`vis generate lunora-table --name=<name>\` to create one`;return e.logger.error(o),f(u.NOT_FOUND,o)}if(e.reset===!0&&y({prod:e.prod,url:e.url})){const o="--reset only clears local .wrangler/state and cannot be combined with --prod or a remote --url";return e.logger.error(o),f(u.USAGE,o)}},z=async(e,r,o,t,n)=>{const s=await v(w(R(),"lunora-seed-")),d=w(s,"rows.ndjson");await k(d,e,"utf8");try{const a=await I({batchSize:n.batchSize,cwd:t,fetchImpl:n.fetchImpl,file:d,logger:n.logger,prod:n.prod,token:n.token,url:n.url,yes:!0}),i=a.body?.conflicts??0;return i>0&&n.logger.warn(`${String(i)} row(s) skipped — their _id already exists. Seeding is deterministic; re-run with --reset to wipe local state first, or a different --seed for fresh ids.`),{code:a.code,data:{conflicts:i,generated:r,inserted:a.inserted,tables:o},ndjson:e,...a.error===void 0?{}:{error:a.error}}}finally{await j(s,{force:!0,recursive:!0}).catch(()=>{})}},D=(e,r)=>{if(e.table===void 0||r.tables.some(n=>n.name===e.table))return;const o=r.tables.map(n=>n.name).join(", "),t=`unknown table "${e.table}" — schema defines: ${o||"(no tables)"}`;return e.logger.error(t),f(u.USAGE,t)},_=async(e,r)=>{if(!y({prod:e.prod,url:e.url})||e.yes===!0)return;if(!process.stdin.isTTY&&e.confirm===void 0){const s="seed: refusing to insert into a non-local target without confirmation — re-run with --yes";return e.logger.error(s),f(u.USAGE,s)}if(!await(e.confirm??N)(`This will insert ${String(r)} generated row(s) into ${e.url??"the production worker"}. Continue?`))return e.logger.info("seed: aborted"),f(u.CANCELLED,"seed: aborted at the confirmation prompt")},G=e=>{const r=[];for(const{rows:o,table:t}of e)for(const n of o)r.push(JSON.stringify({doc:n,table:t},O));return{lines:r,ndjson:r.length>0?`${r.join(`
1
+ import{existsSync as S}from"node:fs";import{mkdtemp as v,writeFile as k,rm as j}from"node:fs/promises";import{tmpdir as R}from"node:os";import{discoverSchema as C,schemaFromIr as T}from"@lunora/codegen";import{seedPlan as $}from"@lunora/seed";import{join as w}from"@visulima/path";import{Project as A}from"ts-morph";import{t as y}from"../packem_shared/admin-token-VdUnvnKW.mjs";import{d as E}from"../packem_shared/command-B--jgXSc.mjs";import{EXIT_CODE as u}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{a as F}from"../packem_shared/resolve-target-C_ZloTvd.mjs";import{b as N}from"../packem_shared/tui-prompts-B3YwUhGw.mjs";import{runResetCommand as U}from"./runResetCommand.mjs";import{r as I}from"../packem_shared/import-D7qdpSmJ.mjs";const O=(e,r)=>typeof r=="bigint"?Number(r):r instanceof ArrayBuffer?[...new Uint8Array(r)]:r,f=(e,r)=>({code:e,error:r,ndjson:""}),x=(e,r)=>{if(!S(r)){const o=`schema not found: ${r} — run \`vis generate lunora-table --name=<name>\` to create one`;return e.logger.error(o),f(u.NOT_FOUND,o)}if(e.reset===!0&&y({prod:e.prod,url:e.url})){const o="--reset only clears local .wrangler/state and cannot be combined with --prod or a remote --url";return e.logger.error(o),f(u.USAGE,o)}},z=async(e,r,o,t,n)=>{const s=await v(w(R(),"lunora-seed-")),d=w(s,"rows.ndjson");await k(d,e,"utf8");try{const a=await I({batchSize:n.batchSize,cwd:t,fetchImpl:n.fetchImpl,file:d,logger:n.logger,prod:n.prod,token:n.token,url:n.url,yes:!0}),i=a.body?.conflicts??0;return i>0&&n.logger.warn(`${String(i)} row(s) skipped — their _id already exists. Seeding is deterministic; re-run with --reset to wipe local state first, or a different --seed for fresh ids.`),{code:a.code,data:{conflicts:i,generated:r,inserted:a.inserted,tables:o},ndjson:e,...a.error===void 0?{}:{error:a.error}}}finally{await j(s,{force:!0,recursive:!0}).catch(()=>{})}},D=(e,r)=>{if(e.table===void 0||r.tables.some(n=>n.name===e.table))return;const o=r.tables.map(n=>n.name).join(", "),t=`unknown table "${e.table}" — schema defines: ${o||"(no tables)"}`;return e.logger.error(t),f(u.USAGE,t)},_=async(e,r)=>{if(!y({prod:e.prod,url:e.url})||e.yes===!0)return;if(!process.stdin.isTTY&&e.confirm===void 0){const s="seed: refusing to insert into a non-local target without confirmation — re-run with --yes";return e.logger.error(s),f(u.USAGE,s)}if(!await(e.confirm??N)(`This will insert ${String(r)} generated row(s) into ${e.url??"the production worker"}. Continue?`))return e.logger.info("seed: aborted"),f(u.CANCELLED,"seed: aborted at the confirmation prompt")},G=e=>{const r=[];for(const{rows:o,table:t}of e)for(const n of o)r.push(JSON.stringify({doc:n,table:t},O));return{lines:r,ndjson:r.length>0?`${r.join(`
2
2
  `)}
3
3
  `:""}},P=async e=>{const r=e.cwd??process.cwd(),o=e.format==="json",t=w(r,"lunora","schema.ts"),n=x(e,t);if(n!==void 0)return n;const s=new A({skipAddingFilesFromTsConfig:!0}),d=C(s,t),a=D(e,d);if(a!==void 0)return a;const i=T(d),l=$(i,{defaultCount:e.count??10,now:e.now,only:e.table===void 0?void 0:[e.table],seed:e.seed??0}),{lines:h,ndjson:c}=G(l),m=h.length;if(e.dryRun===!0)return!o&&c.length>0&&process.stdout.write(c),e.logger.info(`generated ${String(m)} row(s) across ${String(l.length)} table(s) — dry run, nothing inserted`),{code:0,data:{conflicts:0,generated:m,inserted:0,rows:o?h.map(g=>JSON.parse(g)):void 0,tables:l.length},ndjson:c};if(m===0)return e.logger.warn("no rows generated — nothing to insert"),{code:0,data:{conflicts:0,generated:0,inserted:0,tables:l.length},ndjson:c};if(e.reset===!0){const g=await U({confirm:e.confirm,cwd:r,logger:e.logger,yes:e.yes});if(g.code!==0)return{code:g.code,error:"seed: --reset could not clear local state",ndjson:c}}const b=await _(e,m);return b!==void 0?b:z(c,m,l.length,r,e)},ee=E(async({cwd:e,format:r,logger:o,options:t})=>{const n=await P({batchSize:t.batchSize,count:t.count,cwd:e,dryRun:t.dryRun===!0,format:r,logger:o,prod:t.prod===!0,reset:t.reset===!0,now:t.now,seed:t.seed,table:t.table,token:t.token,url:F({cwd:e,prod:t.prod===!0,url:t.url}),yes:t.yes===!0});return{code:n.code,data:n.data,error:n.error}});export{ee as execute,P as runSeedCommand};
@@ -1 +1 @@
1
- import{existsSync as m}from"node:fs";import{join as p}from"node:path";import{runCodegen as u}from"@lunora/codegen";import{a as v,e as g,r as y}from"../packem_shared/platform-diagnostics-Cn2g6Jh-.mjs";import{p as w,r as S}from"../packem_shared/deploy-target-DCWwiuAe.mjs";import{r as k}from"../packem_shared/codegen-error-AmH54ofi.mjs";import{d as j}from"../packem_shared/command-Mmxzxyr5.mjs";import{EXIT_CODE as E}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{r as A,p as D}from"../packem_shared/schema-drift-gate-BDCkQ1S6.mjs";import{defaultSpawner as R}from"../packem_shared/createRecordingSpawner-sS7LEN7x.mjs";import{validateWranglerProject as $}from"@lunora/config/cloudflare";import{execArgsFor as b,detectPackageManager as U}from"@lunora/config";const x=async(r,a,t)=>{if(!m(p(r,"tsconfig.json")))return{warning:"no tsconfig.json found — skipping TypeScript type-check"};const o=b(U(r),"tsc",["--noEmit","-p","tsconfig.json"]),e=await a({args:o.args,command:o.command,cwd:r,stdoutToStderr:t==="json"});return e.code===0?{}:{error:`type errors: tsc --noEmit exited ${String(e.code)}`}},P=async(r,a)=>{if(r.healthUrl===void 0||r.healthUrl==="")return;const t=await D({baseUrl:r.healthUrl,fetchImpl:r.healthFetch});if(t.error===void 0){a.success(`verify: health probe ok (${t.url})`);return}return t.error},T=(r,a)=>{const{errorAdvisories:t,names:o,shouldBlock:e}=g(r,y(a));if(e)return`${t.length.toString()} ERROR-level ${t.length===1?"advisory":"advisories"} (${o.join(", ")}). Pass --no-strict-advisories to downgrade this to a warning and continue.`},C=(r,a,t,o)=>{if(a.length===0&&t.length===0)return r.success("verify: project is valid"),{code:0,errors:[],warnings:[],wranglerPath:o};if(t.length>0){r.warn("verify: warnings:");for(const e of t)r.warn(` - ${e}`)}if(a.length>0){r.error("verify: errors:");for(const e of a){r.error(` - ${e}`);const n=k(e);n!==void 0&&r.error(n)}return{code:1,error:a[0],errors:a,warnings:t,wranglerPath:o}}return r.success("verify: project is valid (with warnings)"),{code:0,errors:[],warnings:t,wranglerPath:o}},H=async r=>{const a=r.cwd??process.cwd(),{logger:t}=r,o=$({environment:r.env,projectRoot:a}),e=[...o.report.errors],n=[...o.report.warnings];try{const s=S(a,r.target);if(s.target===void 0){const c=s.error??"unknown deploy target";return t.error(c),{code:E.USAGE,error:c,errors:[c],warnings:[],wranglerPath:void 0}}const i=u({apiSpec:r.apiSpec,dryRun:!0,projectRoot:a,target:s.target}),f=v(i.platformDiagnostics,t);e.push(...f.errors),n.push(...f.warnings);const l=T(i.advisories,r);l!==void 0&&e.push(l);const h=A({allowDrift:r.allowSchemaDrift===!0,codegen:i,command:"verify",logger:t,readOnly:!0});h.blocked&&e.push(h.reason)}catch(s){const i=s instanceof Error?s.message:String(s);e.push(`codegen failed: ${i}`)}if(r.typecheck!==!1){const s=await x(a,r.spawner??R,r.format??"pretty");s.error!==void 0&&e.push(s.error),s.warning!==void 0&&n.push(s.warning)}const d=await P(r,t);return d!==void 0&&e.push(d),C(t,e,n,o.wranglerPath)},J=j(async({cwd:r,format:a,logger:t,options:o})=>{const e=await H({allowSchemaDrift:o.allowSchemaDrift===!0,apiSpec:w(o.apiSpec),cwd:r,env:o.env,format:a,healthUrl:o.healthUrl,logger:t,strictAdvisories:o.strictAdvisories,target:o.target,typecheck:o.typecheck===!1?!1:void 0});return{code:e.code,data:{errors:e.errors,warnings:e.warnings,wranglerPath:e.wranglerPath},error:e.error}});export{J as execute,H as runVerifyCommand};
1
+ import{existsSync as m}from"node:fs";import{join as p}from"node:path";import{runCodegen as u}from"@lunora/codegen";import{a as v,e as g,r as y}from"../packem_shared/platform-diagnostics-Cn2g6Jh-.mjs";import{p as w,r as S}from"../packem_shared/deploy-target-DCWwiuAe.mjs";import{r as k}from"../packem_shared/codegen-error-AmH54ofi.mjs";import{d as j}from"../packem_shared/command-B--jgXSc.mjs";import{EXIT_CODE as E}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{r as A,p as D}from"../packem_shared/health-probe-Bw9JFfIy.mjs";import{defaultSpawner as R}from"../packem_shared/createRecordingSpawner-sS7LEN7x.mjs";import{validateWranglerProject as $}from"@lunora/config/cloudflare";import{execArgsFor as b,detectPackageManager as U}from"@lunora/config";const x=async(r,a,t)=>{if(!m(p(r,"tsconfig.json")))return{warning:"no tsconfig.json found — skipping TypeScript type-check"};const o=b(U(r),"tsc",["--noEmit","-p","tsconfig.json"]),e=await a({args:o.args,command:o.command,cwd:r,stdoutToStderr:t==="json"});return e.code===0?{}:{error:`type errors: tsc --noEmit exited ${String(e.code)}`}},P=async(r,a)=>{if(r.healthUrl===void 0||r.healthUrl==="")return;const t=await D({baseUrl:r.healthUrl,fetchImpl:r.healthFetch});if(t.error===void 0){a.success(`verify: health probe ok (${t.url})`);return}return t.error},T=(r,a)=>{const{errorAdvisories:t,names:o,shouldBlock:e}=g(r,y(a));if(e)return`${t.length.toString()} ERROR-level ${t.length===1?"advisory":"advisories"} (${o.join(", ")}). Pass --no-strict-advisories to downgrade this to a warning and continue.`},C=(r,a,t,o)=>{if(a.length===0&&t.length===0)return r.success("verify: project is valid"),{code:0,errors:[],warnings:[],wranglerPath:o};if(t.length>0){r.warn("verify: warnings:");for(const e of t)r.warn(` - ${e}`)}if(a.length>0){r.error("verify: errors:");for(const e of a){r.error(` - ${e}`);const n=k(e);n!==void 0&&r.error(n)}return{code:1,error:a[0],errors:a,warnings:t,wranglerPath:o}}return r.success("verify: project is valid (with warnings)"),{code:0,errors:[],warnings:t,wranglerPath:o}},H=async r=>{const a=r.cwd??process.cwd(),{logger:t}=r,o=$({environment:r.env,projectRoot:a}),e=[...o.report.errors],n=[...o.report.warnings];try{const s=S(a,r.target);if(s.target===void 0){const c=s.error??"unknown deploy target";return t.error(c),{code:E.USAGE,error:c,errors:[c],warnings:[],wranglerPath:void 0}}const i=u({apiSpec:r.apiSpec,dryRun:!0,projectRoot:a,target:s.target}),f=v(i.platformDiagnostics,t);e.push(...f.errors),n.push(...f.warnings);const l=T(i.advisories,r);l!==void 0&&e.push(l);const h=A({allowDrift:r.allowSchemaDrift===!0,codegen:i,command:"verify",logger:t,readOnly:!0});h.blocked&&e.push(h.reason)}catch(s){const i=s instanceof Error?s.message:String(s);e.push(`codegen failed: ${i}`)}if(r.typecheck!==!1){const s=await x(a,r.spawner??R,r.format??"pretty");s.error!==void 0&&e.push(s.error),s.warning!==void 0&&n.push(s.warning)}const d=await P(r,t);return d!==void 0&&e.push(d),C(t,e,n,o.wranglerPath)},J=j(async({cwd:r,format:a,logger:t,options:o})=>{const e=await H({allowSchemaDrift:o.allowSchemaDrift===!0,apiSpec:w(o.apiSpec),cwd:r,env:o.env,format:a,healthUrl:o.healthUrl,logger:t,strictAdvisories:o.strictAdvisories,target:o.target,typecheck:o.typecheck===!1?!1:void 0});return{code:e.code,data:{errors:e.errors,warnings:e.warnings,wranglerPath:e.wranglerPath},error:e.error}});export{J as execute,H as runVerifyCommand};
@@ -1 +1 @@
1
- import{readLiveDevServerState as c}from"@lunora/config";import{d as i}from"../packem_shared/command-Mmxzxyr5.mjs";import{o as a}from"../packem_shared/open-url-EnKy--w-.mjs";const n="http://127.0.0.1:6173",d="/__lunora",u=/\/$/u,l=r=>{const e=c(r);return e===void 0?n:e.studioUrl!==void 0?e.studioUrl:e.mode==="vite"?`${e.url.replace(u,"")}${d}`:n},m=async r=>{const e=l(r.cwd??process.cwd()),{logger:t}=r;t.info(`opening ${e}`);try{await a(e,{opener:r.opener})}catch(o){const s=o instanceof Error?o.message:String(o);return t.error(`view: failed to open URL: ${s}`),{code:1,url:e}}return{code:0,url:e}},v=i(({cwd:r,logger:e})=>m({cwd:r,logger:e}));export{v as execute,m as runViewCommand};
1
+ import{readLiveDevServerState as c}from"@lunora/config";import{d as i}from"../packem_shared/command-B--jgXSc.mjs";import{o as a}from"../packem_shared/open-url-EnKy--w-.mjs";const n="http://127.0.0.1:6173",d="/__lunora",u=/\/$/u,l=r=>{const e=c(r);return e===void 0?n:e.studioUrl!==void 0?e.studioUrl:e.mode==="vite"?`${e.url.replace(u,"")}${d}`:n},m=async r=>{const e=l(r.cwd??process.cwd()),{logger:t}=r;t.info(`opening ${e}`);try{await a(e,{opener:r.opener})}catch(o){const s=o instanceof Error?o.message:String(o);return t.error(`view: failed to open URL: ${s}`),{code:1,url:e}}return{code:0,url:e}},v=i(({cwd:r,logger:e})=>m({cwd:r,logger:e}));export{v as execute,m as runViewCommand};
@@ -1,4 +1,4 @@
1
- import{writeFileSync as h,existsSync as S,readFileSync as p}from"node:fs";import{isAbsolute as v,join as w}from"node:path";import{byCodepoint as b,scoreAdvisor as y,parseAdvisorMap as x,compareToBaseline as j}from"@lunora/advisor";import{runCodegen as A}from"@lunora/codegen";import{d as M}from"../packem_shared/command-Mmxzxyr5.mjs";import{EXIT_CODE as D}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{D as u}from"../packem_shared/cli-DOpChqUe.mjs";const l={clean:"·",exempt:"–",failing:"✗",warned:"!"},d=(e,r)=>e.length>=r?e:e+" ".repeat(r-e.length),E=e=>`${e.id} (${e.visibility} ${e.kind})`,f=e=>{let r=0;for(const n of e)r=Math.max(r,n.id.length);return r},g=(e,r)=>` ${d(String(e.score),3)} ${l[e.coverage]} ${d(e.id,r)} ${e.visibility} ${e.kind}`,R=e=>{if(!e.comparable)return[` baseline not comparable (${e.reason}) — regenerate it; this run cannot verify anything`];if(!e.regressed)return[` no regression against baseline (score ${e.scoreDelta>=0?"+":""}${String(e.scoreDelta)})`];const r=[` REGRESSED against baseline (score ${e.scoreDelta>=0?"+":""}${String(e.scoreDelta)})`];for(const n of e.dropped)r.push(` ${n.id}: ${String(n.before)} → ${String(n.after)}`);for(const n of e.newFailing)r.push(` ${n}: now failing`);for(const n of e.worsened)r.push(` ${n}: more findings than the baseline`);return e.projectRegressed&&r.push(" project: new schema/config rules fired"),r},F=(e,r)=>{const n=e.procedures.filter(i=>i.coverage!=="clean"&&i.coverage!=="exempt"),t=f(n),o=[`advisor health ${String(e.score)}/100 — ${e.grade}`,` ${String(e.summary.clean)} clean · ${String(e.summary.warned)} warned · ${String(e.summary.failing)} failing · ${String(e.summary.exempt)} exempt (${String(e.summary.procedures)} procedures, ${String(e.summary.rulesFired)} rules fired)`];return e.project.checks.length>0&&o.push("",` project ${String(e.project.score)}/100 — ${e.project.checks.map(i=>i.name).join(", ")}`),n.length>0&&o.push("",...n.map(i=>g(i,t)),""," run with --all for every procedure, or --entry <file#export> for one"),r!==void 0&&o.push("",...R(r)),o.join(`
1
+ import{writeFileSync as h,existsSync as S,readFileSync as p}from"node:fs";import{isAbsolute as v,join as w}from"node:path";import{byCodepoint as b,scoreAdvisor as y,parseAdvisorMap as x,compareToBaseline as j}from"@lunora/advisor";import{runCodegen as A}from"@lunora/codegen";import{d as M}from"../packem_shared/command-B--jgXSc.mjs";import{EXIT_CODE as D}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{D as u}from"../packem_shared/cli-D1ZleZMH.mjs";const l={clean:"·",exempt:"–",failing:"✗",warned:"!"},d=(e,r)=>e.length>=r?e:e+" ".repeat(r-e.length),E=e=>`${e.id} (${e.visibility} ${e.kind})`,f=e=>{let r=0;for(const n of e)r=Math.max(r,n.id.length);return r},g=(e,r)=>` ${d(String(e.score),3)} ${l[e.coverage]} ${d(e.id,r)} ${e.visibility} ${e.kind}`,R=e=>{if(!e.comparable)return[` baseline not comparable (${e.reason}) — regenerate it; this run cannot verify anything`];if(!e.regressed)return[` no regression against baseline (score ${e.scoreDelta>=0?"+":""}${String(e.scoreDelta)})`];const r=[` REGRESSED against baseline (score ${e.scoreDelta>=0?"+":""}${String(e.scoreDelta)})`];for(const n of e.dropped)r.push(` ${n.id}: ${String(n.before)} → ${String(n.after)}`);for(const n of e.newFailing)r.push(` ${n}: now failing`);for(const n of e.worsened)r.push(` ${n}: more findings than the baseline`);return e.projectRegressed&&r.push(" project: new schema/config rules fired"),r},F=(e,r)=>{const n=e.procedures.filter(i=>i.coverage!=="clean"&&i.coverage!=="exempt"),t=f(n),o=[`advisor health ${String(e.score)}/100 — ${e.grade}`,` ${String(e.summary.clean)} clean · ${String(e.summary.warned)} warned · ${String(e.summary.failing)} failing · ${String(e.summary.exempt)} exempt (${String(e.summary.procedures)} procedures, ${String(e.summary.rulesFired)} rules fired)`];return e.project.checks.length>0&&o.push("",` project ${String(e.project.score)}/100 — ${e.project.checks.map(i=>i.name).join(", ")}`),n.length>0&&o.push("",...n.map(i=>g(i,t)),""," run with --all for every procedure, or --entry <file#export> for one"),r!==void 0&&o.push("",...R(r)),o.join(`
2
2
  `)},k=e=>e.coverage==="exempt"?[` exempt: ${e.exemptReason===void 0||e.exemptReason===""?"no reason given":e.exemptReason}`]:e.checks.map(r=>{const n=r.occurrences>1?`, ×${String(r.occurrences)}`:"";return` ${r.name} (−${String(r.weight)}${n})`}),T=e=>{const r=new Map;for(const n of e){const t=r.get(n.file);t===void 0?r.set(n.file,[n]):t.push(n)}return[...r].toSorted(([n],[t])=>b(n,t))},B=e=>{const r=f(e.procedures),n=[`advisor health ${String(e.score)}/100 — ${e.grade}`,"",` legend: ${l.clean} clean ${l.warned} warned ${l.failing} failing ${l.exempt} exempt`];for(const[t,o]of T(e.procedures)){n.push("",` ${t}`);for(const i of o)n.push(g(i,r),...k(i))}return n.join(`
3
3
  `)},C=(e,r)=>{const n=e.procedures.find(o=>o.id===r);if(n===void 0){const o=e.procedures.slice(0,10).map(i=>` ${i.id}`);return[`no procedure ${r} in the map. Known ids:`,...o,e.procedures.length>10?" …":""].filter(Boolean).join(`
4
4
  `)}const t=[`${E(n)} — ${String(n.score)}/100, ${n.coverage}`,` weight in the global mean: ${String(n.weight)}`];if(n.checks.length===0)return t.push(""," no rule fired"),t.join(`
@@ -1 +1 @@
1
- import{mkdtempSync as p,rmSync as u,existsSync as m,readdirSync as $,statSync as g}from"node:fs";import{tmpdir as S}from"node:os";import{join as y,relative as w}from"node:path";import{d as z}from"../packem_shared/command-Mmxzxyr5.mjs";import{EXIT_CODE as B}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{defaultSpawner as F}from"../packem_shared/createRecordingSpawner-sS7LEN7x.mjs";import{execArgsFor as h,detectPackageManager as x}from"@lunora/config";const v=e=>{const t=[],n=o=>{for(const s of $(o)){const r=y(o,s),i=g(r);i.isDirectory()?n(r):i.isFile()&&t.push({path:w(e,r),sizeBytes:i.size})}};return n(e),t},l=e=>e<1024?`${String(e)} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(2)} MiB`,M=e=>{const t=v(e),n=t.toSorted((r,i)=>i.sizeBytes-r.sizeBytes),o=t.reduce((r,i)=>r+i.sizeBytes,0);return{generatedFiles:t.filter(r=>r.path.includes("_generated")),outdir:e,topModules:n.slice(0,10),totalBytes:o,totalFiles:t.length}},O=(e,t)=>{if(t.info(`outdir: ${e.outdir}`),t.info(`total: ${String(e.totalFiles)} files, ${l(e.totalBytes)}`),e.topModules.length>0){t.info(""),t.info("top modules by size:");for(const n of e.topModules)t.info(` ${l(n.sizeBytes).padStart(10," ")} ${n.path}`)}if(e.generatedFiles.length>0){t.info(""),t.info(`_generated/ files: ${String(e.generatedFiles.length)}`);for(const n of e.generatedFiles)t.info(` ${l(n.sizeBytes).padStart(10," ")} ${n.path}`)}},j=async e=>{const t=e.cwd??process.cwd(),n=e.format==="json",{logger:o}=e;let s,r,i=!1;if(e.inspectOnly)s=e.inspectOnly;else{s=p(y(S(),"lunora-analyze-")),i=!0;const a=h(x(t),"wrangler",["deploy","--dry-run","--outdir",s]);r={args:a.args,command:a.command,cwd:t,stdoutToStderr:n},o.info(`analyze: building via ${r.command} ${r.args.join(" ")}`);const d=await(e.spawner??F)(r);if(d.code!==0){const f=`analyze: wrangler dry-run failed (exit ${String(d.code)})`;return o.error(f),u(s,{force:!0,recursive:!0}),{code:d.code,descriptor:r,error:f,report:void 0}}}try{if(!m(s)){const c=`analyze: outdir not found at ${s}`;return o.error(c),{code:B.NOT_FOUND,descriptor:r,error:c,report:void 0}}const a=M(s);return n||O(a,o),{code:0,descriptor:r,report:a}}finally{if(i&&m(s))try{u(s,{force:!0,recursive:!0})}catch{}}},N=z(async({cwd:e,format:t,logger:n})=>{const o=await j({cwd:e,format:t,logger:n});return{code:o.code,data:o.report,error:o.error}});export{N as execute,j as runAnalyzeCommand};
1
+ import{mkdtempSync as p,rmSync as u,existsSync as m,readdirSync as $,statSync as g}from"node:fs";import{tmpdir as S}from"node:os";import{join as y,relative as w}from"node:path";import{d as z}from"../packem_shared/command-B--jgXSc.mjs";import{EXIT_CODE as B}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{defaultSpawner as F}from"../packem_shared/createRecordingSpawner-sS7LEN7x.mjs";import{execArgsFor as h,detectPackageManager as x}from"@lunora/config";const v=e=>{const t=[],n=o=>{for(const s of $(o)){const r=y(o,s),i=g(r);i.isDirectory()?n(r):i.isFile()&&t.push({path:w(e,r),sizeBytes:i.size})}};return n(e),t},l=e=>e<1024?`${String(e)} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(2)} MiB`,M=e=>{const t=v(e),n=t.toSorted((r,i)=>i.sizeBytes-r.sizeBytes),o=t.reduce((r,i)=>r+i.sizeBytes,0);return{generatedFiles:t.filter(r=>r.path.includes("_generated")),outdir:e,topModules:n.slice(0,10),totalBytes:o,totalFiles:t.length}},O=(e,t)=>{if(t.info(`outdir: ${e.outdir}`),t.info(`total: ${String(e.totalFiles)} files, ${l(e.totalBytes)}`),e.topModules.length>0){t.info(""),t.info("top modules by size:");for(const n of e.topModules)t.info(` ${l(n.sizeBytes).padStart(10," ")} ${n.path}`)}if(e.generatedFiles.length>0){t.info(""),t.info(`_generated/ files: ${String(e.generatedFiles.length)}`);for(const n of e.generatedFiles)t.info(` ${l(n.sizeBytes).padStart(10," ")} ${n.path}`)}},j=async e=>{const t=e.cwd??process.cwd(),n=e.format==="json",{logger:o}=e;let s,r,i=!1;if(e.inspectOnly)s=e.inspectOnly;else{s=p(y(S(),"lunora-analyze-")),i=!0;const a=h(x(t),"wrangler",["deploy","--dry-run","--outdir",s]);r={args:a.args,command:a.command,cwd:t,stdoutToStderr:n},o.info(`analyze: building via ${r.command} ${r.args.join(" ")}`);const d=await(e.spawner??F)(r);if(d.code!==0){const f=`analyze: wrangler dry-run failed (exit ${String(d.code)})`;return o.error(f),u(s,{force:!0,recursive:!0}),{code:d.code,descriptor:r,error:f,report:void 0}}}try{if(!m(s)){const c=`analyze: outdir not found at ${s}`;return o.error(c),{code:B.NOT_FOUND,descriptor:r,error:c,report:void 0}}const a=M(s);return n||O(a,o),{code:0,descriptor:r,report:a}}finally{if(i&&m(s))try{u(s,{force:!0,recursive:!0})}catch{}}},N=z(async({cwd:e,format:t,logger:n})=>{const o=await j({cwd:e,format:t,logger:n});return{code:o.code,data:o.report,error:o.error}});export{N as execute,j as runAnalyzeCommand};
@@ -1 +1 @@
1
- import{join as c,resolve as l}from"node:path";import{p as u}from"../packem_shared/deploy-target-DCWwiuAe.mjs";import{d as m}from"../packem_shared/command-Mmxzxyr5.mjs";import{defaultSpawner as f}from"../packem_shared/createRecordingSpawner-sS7LEN7x.mjs";import{runDeployCommand as p}from"./runDeployCommand.mjs";import{readdirSync as w,readFileSync as y}from"node:fs";import{gzipSync as g}from"node:zlib";const b=e=>!e.endsWith(".map")&&e!=="bundle-meta.json"&&e!=="README.md",S=e=>{let a;try{a=w(e,{recursive:!0,withFileTypes:!0})}catch{return}let n=0,r=0,t=0;for(const i of a){if(!i.isFile()||!b(i.name))continue;const d=y(c(i.parentPath,i.name));n+=1,t+=d.byteLength,r+=g(d).byteLength}return n===0?void 0:{files:n,gzipBytes:r,rawBytes:t}},s=".lunora/build",v=async e=>f({...e,stdoutToStderr:!0}),o=e=>`${(e/1024).toFixed(1)} KiB`,D=async e=>{const a=e.outDir??s,n=e.format==="json",{logger:r}=e,t=await p({allowSchemaDrift:e.allowSchemaDrift,apiSpec:e.apiSpec,commandName:"build",cwd:e.cwd,dryRun:!0,emitBindings:e.emitBindings,format:void 0,interactive:n?!1:void 0,logger:r,outDir:a,spawner:e.spawner??(n?v:void 0),strictAdvisories:e.strictAdvisories,target:e.target});if(t.code!==0)return t;r.success(`build complete — bundle written to ${a}`);const i=S(l(e.cwd??process.cwd(),a));return i===void 0?r.warn(`could not weigh the bundle — nothing uploadable was found in ${a}`):r.info(`bundle: ${o(i.rawBytes)} raw, ${o(i.gzipBytes)} gzipped across ${String(i.files)} file(s) — Cloudflare's Worker size limit (3 MB Free, 10 MB Paid) applies to the gzipped number`),{...t,bundle:i}},M=m(async({cwd:e,format:a,logger:n,options:r})=>{const t=await D({allowSchemaDrift:r.allowSchemaDrift===!0,apiSpec:u(r.apiSpec),cwd:e,emitBindings:r.emitBindings,format:a,logger:n,outDir:r.outDir,strictAdvisories:r.strictAdvisories,target:r.target});return{code:t.code,data:{bundle:t.bundle,deployment:t.deployment,outDir:r.outDir??s,validation:t.validation},error:t.error}});export{M as execute,D as runBuildCommand};
1
+ import{join as c,resolve as l}from"node:path";import{p as u}from"../packem_shared/deploy-target-DCWwiuAe.mjs";import{d as m}from"../packem_shared/command-B--jgXSc.mjs";import{defaultSpawner as f}from"../packem_shared/createRecordingSpawner-sS7LEN7x.mjs";import{runDeployCommand as p}from"./runDeployCommand.mjs";import{readdirSync as w,readFileSync as y}from"node:fs";import{gzipSync as g}from"node:zlib";const b=e=>!e.endsWith(".map")&&e!=="bundle-meta.json"&&e!=="README.md",S=e=>{let a;try{a=w(e,{recursive:!0,withFileTypes:!0})}catch{return}let n=0,r=0,t=0;for(const i of a){if(!i.isFile()||!b(i.name))continue;const d=y(c(i.parentPath,i.name));n+=1,t+=d.byteLength,r+=g(d).byteLength}return n===0?void 0:{files:n,gzipBytes:r,rawBytes:t}},s=".lunora/build",v=async e=>f({...e,stdoutToStderr:!0}),o=e=>`${(e/1024).toFixed(1)} KiB`,D=async e=>{const a=e.outDir??s,n=e.format==="json",{logger:r}=e,t=await p({allowSchemaDrift:e.allowSchemaDrift,apiSpec:e.apiSpec,commandName:"build",cwd:e.cwd,dryRun:!0,emitBindings:e.emitBindings,format:void 0,interactive:n?!1:void 0,logger:r,outDir:a,spawner:e.spawner??(n?v:void 0),strictAdvisories:e.strictAdvisories,target:e.target});if(t.code!==0)return t;r.success(`build complete — bundle written to ${a}`);const i=S(l(e.cwd??process.cwd(),a));return i===void 0?r.warn(`could not weigh the bundle — nothing uploadable was found in ${a}`):r.info(`bundle: ${o(i.rawBytes)} raw, ${o(i.gzipBytes)} gzipped across ${String(i.files)} file(s) — Cloudflare's Worker size limit (3 MB Free, 10 MB Paid) applies to the gzipped number`),{...t,bundle:i}},M=m(async({cwd:e,format:a,logger:n,options:r})=>{const t=await D({allowSchemaDrift:r.allowSchemaDrift===!0,apiSpec:u(r.apiSpec),cwd:e,emitBindings:r.emitBindings,format:a,logger:n,outDir:r.outDir,strictAdvisories:r.strictAdvisories,target:r.target});return{code:t.code,data:{bundle:t.bundle,deployment:t.deployment,outDir:r.outDir??s,validation:t.validation},error:t.error}});export{M as execute,D as runBuildCommand};
@@ -1,3 +1,3 @@
1
- import{writeFileSync as E,existsSync as w,cpSync as j,statSync as b,lstatSync as I,readdirSync as N,mkdirSync as D,readFileSync as M}from"node:fs";import{join as u,sep as x,relative as B,resolve as O,dirname as K}from"node:path";import{SDK_TARGETS as V,SDK_LANGUAGES as G,generateSdk as P,isTypedSchema as Q}from"@lunora/codegen";import{LunoraError as d}from"@lunora/errors";import{d as J}from"../packem_shared/command-Mmxzxyr5.mjs";import{r as _,a as U,b as q,c as H,s as W}from"../packem_shared/resolve-DUCSc7jQ.mjs";const $="gh:anolilab/lunora/sdks",v="lunora-transport.json",X=/_test\.|Tests?\./u,k=t=>t.startsWith("test_")||X.test(t),A=(t,n="")=>N(t).toSorted((e,r)=>e.localeCompare(r)).flatMap(e=>{const r=u(t,e),a=n.length>0?`${n}/${e}`:e;return b(r).isDirectory()?A(r,a):[a]}),C=(t,n)=>{const e=I(n);if(e.isSymbolicLink())throw new d("INTERNAL",`refusing to vendor "${B(t,n)}" — it is a symlink, not a regular file`);if(e.isDirectory())for(const r of N(n))k(r)||C(t,u(n,r))},F=(t,n,e,r)=>{const a=u(t,e);if(!w(a))throw new d("NOT_FOUND",`transport is missing ${e}`);C(t,a);const s=u(n,r);return j(a,s,{filter:o=>!k(o.slice(o.lastIndexOf(x)+1)),force:!0,recursive:!0}),b(s).isDirectory()?A(s).map(o=>`${r}/${o}`):[r]},R=(t,n)=>n.vendor.every(e=>w(u(t,e.from))),z=async(t,n)=>{const{language:e,logger:r,outputDirectory:a,registryOptions:s,target:o}=n,{cleanup:f,directory:h}=await H(e,{...s,ref:t},$);try{if(!R(h,o)){r.warn(`${$}/${e} does not exist at ${t}.`);return}return{files:o.vendor.flatMap(c=>F(h,a,c.from,c.to)).toSorted((c,l)=>c.localeCompare(l)),ref:t,source:`${$}/${e}`,versionMatched:t===_()}}finally{f()}},Y=(t,n)=>{const{language:e,outputDirectory:r,target:a}=n,s=u(t,e);if(!w(s))throw new d("NOT_FOUND",`no transport at ${s} — --from must point at a directory of per-language transports (the repo's \`sdks/\`)`);if(!R(s,a)){const o=a.vendor.map(f=>f.from).join(", ");throw new d("NOT_FOUND",`${s} is not a ${e} transport — expected it to contain ${o}`)}return{files:a.vendor.flatMap(o=>F(s,r,o.from,o.to)).toSorted((o,f)=>o.localeCompare(f)),ref:"local",source:s,versionMatched:!1}},Z=async t=>{const{allowUnsafeSource:n,from:e,language:r,logger:a,outputDirectory:s,ref:o,source:f,target:h}=t;if(e!==void 0)return Y(e,{language:r,outputDirectory:s,target:h});const c={allowUnsafeSource:n,logger:a,names:[],source:f},l=async i=>z(await q(i,a),{language:r,logger:a,outputDirectory:s,registryOptions:c,target:h});if(o!==void 0&&o.length>0){const i=await l(o);if(i===void 0)throw new d("NOT_FOUND",`--ref ${o} carries no ${r} transport — pick a ref that does, or pass --from <dir> to copy a local one`);return i}const m=_(),g=await l(m).catch(i=>{const y=i instanceof Error?i.message.split(`
1
+ import{writeFileSync as E,existsSync as w,cpSync as j,statSync as b,lstatSync as I,readdirSync as N,mkdirSync as D,readFileSync as M}from"node:fs";import{join as u,sep as x,relative as B,resolve as O,dirname as K}from"node:path";import{SDK_TARGETS as V,SDK_LANGUAGES as G,generateSdk as P,isTypedSchema as Q}from"@lunora/codegen";import{LunoraError as d}from"@lunora/errors";import{d as J}from"../packem_shared/command-B--jgXSc.mjs";import{r as _,a as U,b as q,c as H,s as W}from"../packem_shared/resolve-DUCSc7jQ.mjs";const $="gh:anolilab/lunora/sdks",v="lunora-transport.json",X=/_test\.|Tests?\./u,k=t=>t.startsWith("test_")||X.test(t),A=(t,n="")=>N(t).toSorted((e,r)=>e.localeCompare(r)).flatMap(e=>{const r=u(t,e),a=n.length>0?`${n}/${e}`:e;return b(r).isDirectory()?A(r,a):[a]}),C=(t,n)=>{const e=I(n);if(e.isSymbolicLink())throw new d("INTERNAL",`refusing to vendor "${B(t,n)}" — it is a symlink, not a regular file`);if(e.isDirectory())for(const r of N(n))k(r)||C(t,u(n,r))},F=(t,n,e,r)=>{const a=u(t,e);if(!w(a))throw new d("NOT_FOUND",`transport is missing ${e}`);C(t,a);const s=u(n,r);return j(a,s,{filter:o=>!k(o.slice(o.lastIndexOf(x)+1)),force:!0,recursive:!0}),b(s).isDirectory()?A(s).map(o=>`${r}/${o}`):[r]},R=(t,n)=>n.vendor.every(e=>w(u(t,e.from))),z=async(t,n)=>{const{language:e,logger:r,outputDirectory:a,registryOptions:s,target:o}=n,{cleanup:f,directory:h}=await H(e,{...s,ref:t},$);try{if(!R(h,o)){r.warn(`${$}/${e} does not exist at ${t}.`);return}return{files:o.vendor.flatMap(c=>F(h,a,c.from,c.to)).toSorted((c,l)=>c.localeCompare(l)),ref:t,source:`${$}/${e}`,versionMatched:t===_()}}finally{f()}},Y=(t,n)=>{const{language:e,outputDirectory:r,target:a}=n,s=u(t,e);if(!w(s))throw new d("NOT_FOUND",`no transport at ${s} — --from must point at a directory of per-language transports (the repo's \`sdks/\`)`);if(!R(s,a)){const o=a.vendor.map(f=>f.from).join(", ");throw new d("NOT_FOUND",`${s} is not a ${e} transport — expected it to contain ${o}`)}return{files:a.vendor.flatMap(o=>F(s,r,o.from,o.to)).toSorted((o,f)=>o.localeCompare(f)),ref:"local",source:s,versionMatched:!1}},Z=async t=>{const{allowUnsafeSource:n,from:e,language:r,logger:a,outputDirectory:s,ref:o,source:f,target:h}=t;if(e!==void 0)return Y(e,{language:r,outputDirectory:s,target:h});const c={allowUnsafeSource:n,logger:a,names:[],source:f},l=async i=>z(await q(i,a),{language:r,logger:a,outputDirectory:s,registryOptions:c,target:h});if(o!==void 0&&o.length>0){const i=await l(o);if(i===void 0)throw new d("NOT_FOUND",`--ref ${o} carries no ${r} transport — pick a ref that does, or pass --from <dir> to copy a local one`);return i}const m=_(),g=await l(m).catch(i=>{const y=i instanceof Error?i.message.split(`
2
2
  `)[0]??i.message:String(i);a.warn(`could not fetch the transport at ${m} (${y}).`)});if(g!==void 0)return g;const p=await l(void 0);if(p===void 0)throw new d("NOT_FOUND",`no ${r} transport at ${m} or on the release branch. This language may not be released yet — pass --from <dir> to copy one from a checkout, or --ref <tag> to name a ref that has it.`);return a.warn(`FALLBACK: the transport is NOT version-matched to this CLI (${U()}). Wanted ${m}, used ${p.ref}. The vendored wire protocol may not be the one this surface was generated against; ${v} records what was actually copied.`),p},ee=(t,n,e)=>{const r={cliVersion:U(),files:e.files,language:n,note:e.versionMatched?"Vendored by `lunora sdk generate` at the ref matching the CLI that generated the surface beside it. Regenerate with a newer CLI to upgrade.":"Vendored by `lunora sdk generate` from a ref that is NOT this CLI's release tag, so the transport and the generated surface may be different protocol vintages.",ref:e.ref,source:e.source,versionMatched:e.versionMatched};E(u(t,v),`${JSON.stringify(r,void 0,4)}
3
3
  `,"utf8")},te=u("lunora","_generated","openrpc.json"),re=t=>{if(!w(t))throw new d("NOT_FOUND",`no OpenRPC document at ${t} — run \`lunora codegen --api-spec openrpc\` (or \`--api-spec both\`) first, or pass --spec`);let n;try{n=JSON.parse(M(t,"utf8"))}catch(e){throw new d("BAD_REQUEST",`${t} is not valid JSON: ${e instanceof Error?e.message:String(e)}`)}if(n===null||typeof n!="object"||!Array.isArray(n.methods))throw new d("BAD_REQUEST",`${t} is not an OpenRPC document (no \`methods\` array)`);return n},de=J(async({argument:t,cwd:n,logger:e,options:r})=>{const a=t[0]??"generate";if(a!=="generate")throw new d("BAD_REQUEST",`unknown subcommand "${a}" — the only one is \`lunora sdk generate\``);const s=r.lang??"python",o=V[s];if(o===void 0)throw new d("BAD_REQUEST",`unsupported --lang "${s}" — expected one of: ${G.join(" | ")}`);const f=W("sdk generate",{allowUnsafeSource:r.allowUnsafeSource,logger:e,names:[],source:r.source});if(f!==void 0)throw new d("BAD_REQUEST",f);const h=O(n,r.spec??te),c=O(n,r.out??u("sdk",s)),l=re(h);l.methods.length===0&&e.warn(`${h} declares no methods — writing an empty SDK.`);const{files:m,undeclared:g,unrepresentable:p}=await P(l,o);D(c,{recursive:!0});const i=await Z({allowUnsafeSource:r.allowUnsafeSource,from:r.from,language:s,logger:e,outputDirectory:c,ref:r.ref,source:r.source,target:o});ee(c,s,i);for(const[S,L]of Object.entries(m)){const T=u(c,S);D(K(T),{recursive:!0}),E(T,L,"utf8")}const y=l.methods.filter(S=>!Q(S.result?.schema)).length;return e.success(`Generated ${s} SDK for ${String(l.methods.length)} function(s) → ${c}`),e.info(`Vendored the ${s} transport (${String(i.files.length)} file(s)) from ${i.source} @ ${i.ref}${i.versionMatched?" — version-matched to this CLI":""}; see ${v}.`),e.info(o.requires.length>0?`Install in the consuming project: ${o.requires.join(", ")}.`:"Nothing to install — the transport is vendored and needs only the standard library."),g.length>0&&e.warn(`${String(g.length)} schema(s) are not expressible as a named ${s} model, so those arguments or returns stay untyped: ${g.join(", ")}`),p.length>0&&e.warn(`${String(p.length)} function(s) take or return a \`v.bigint()\`/\`v.bytes()\`, which no generated model can carry — their parameters stay untyped, so pass wire values directly: ${p.join(", ")}`),y>0&&e.warn(`${String(y)} of ${String(l.methods.length)} function(s) return an untyped result — declare \`.output()\` on them for typed returns.`),{code:0}});export{de as execute};
@@ -1,3 +1,3 @@
1
- import H,{join as m,resolve as N}from"node:path";import{isInteractive as z,promptYesNo as J}from"@lunora/config";import{backupObjectKey as v,isBackupManifestEntry as B,normalizeBackupPrefix as W,BACKUP_KEY_PREFIX as Y,backupManifestKey as X,isBackupManifestKey as Q,backupObjectKeyOfManifest as D}from"@lunora/runtime";import{r as E,t as V}from"../packem_shared/admin-token-VdUnvnKW.mjs";import{r as T}from"../packem_shared/admin-url-BhF5ufg1.mjs";import{d as Z}from"../packem_shared/command-Mmxzxyr5.mjs";import{EXIT_CODE as u,isRefusal as p,exitCodeForStatus as k}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{a as ee}from"../packem_shared/resolve-target-C_ZloTvd.mjs";import{runExportCommand as re}from"../packem_shared/runExportCommand-DxsJHYZt.mjs";import{b as te,l as ae,M as I,u as oe,r as ne}from"../packem_shared/import-D7qdpSmJ.mjs";import{readAndLogBody as y}from"./runRpcCommand.mjs";import{randomUUID as G,createHash as ie}from"node:crypto";import{existsSync as A,createReadStream as se,createWriteStream as ce}from"node:fs";import{mkdir as de,rm as b,rename as j,readFile as C,writeFile as ue,realpath as U,mkdtemp as _}from"node:fs/promises";import{LunoraError as w}from"@lunora/errors";import{i as x}from"../packem_shared/path-containment-CgxYZggb.mjs";import{tmpdir as R}from"node:os";import{Readable as le}from"node:stream";import{pipeline as fe}from"node:stream/promises";const S="manifest.json",q=async e=>{const t=ie("sha256");let r=0;for await(const a of se(e)){const o=a;r+=o.byteLength,t.update(o)}return{bytes:r,sha256:t.digest("hex")}},O=async e=>{const t=m(e,S);if(!A(t))return[];let r;try{r=JSON.parse(await C(t,"utf8"))}catch(a){const o=a instanceof Error?a.message:String(a);throw new w("INTERNAL",`backup: ${t} exists but is not valid JSON (${o}) — refusing to overwrite it; fix or remove it manually`,{cause:a})}if(!Array.isArray(r))throw new TypeError(`backup: ${t} exists but is not a JSON array — refusing to overwrite it; fix or remove it manually`);return r.filter(a=>B(a))},me=async(e,t)=>{const r=m(e,`${S}.${G()}.tmp`);try{await ue(r,`${JSON.stringify(t,void 0,2)}
1
+ import H,{join as m,resolve as N}from"node:path";import{isInteractive as z,promptYesNo as J}from"@lunora/config";import{backupObjectKey as v,isBackupManifestEntry as B,normalizeBackupPrefix as W,BACKUP_KEY_PREFIX as Y,backupManifestKey as X,isBackupManifestKey as Q,backupObjectKeyOfManifest as D}from"@lunora/runtime";import{r as E,t as V}from"../packem_shared/admin-token-VdUnvnKW.mjs";import{r as T}from"../packem_shared/admin-url-BhF5ufg1.mjs";import{d as Z}from"../packem_shared/command-B--jgXSc.mjs";import{EXIT_CODE as u,isRefusal as p,exitCodeForStatus as k}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{a as ee}from"../packem_shared/resolve-target-C_ZloTvd.mjs";import{runExportCommand as re}from"../packem_shared/runExportCommand-DxsJHYZt.mjs";import{b as te,l as ae,M as I,u as oe,r as ne}from"../packem_shared/import-D7qdpSmJ.mjs";import{readAndLogBody as y}from"./runRpcCommand.mjs";import{randomUUID as G,createHash as ie}from"node:crypto";import{existsSync as A,createReadStream as se,createWriteStream as ce}from"node:fs";import{mkdir as de,rm as b,rename as j,readFile as C,writeFile as ue,realpath as U,mkdtemp as _}from"node:fs/promises";import{LunoraError as w}from"@lunora/errors";import{i as x}from"../packem_shared/path-containment-CgxYZggb.mjs";import{tmpdir as R}from"node:os";import{Readable as le}from"node:stream";import{pipeline as fe}from"node:stream/promises";const S="manifest.json",q=async e=>{const t=ie("sha256");let r=0;for await(const a of se(e)){const o=a;r+=o.byteLength,t.update(o)}return{bytes:r,sha256:t.digest("hex")}},O=async e=>{const t=m(e,S);if(!A(t))return[];let r;try{r=JSON.parse(await C(t,"utf8"))}catch(a){const o=a instanceof Error?a.message:String(a);throw new w("INTERNAL",`backup: ${t} exists but is not valid JSON (${o}) — refusing to overwrite it; fix or remove it manually`,{cause:a})}if(!Array.isArray(r))throw new TypeError(`backup: ${t} exists but is not a JSON array — refusing to overwrite it; fix or remove it manually`);return r.filter(a=>B(a))},me=async(e,t)=>{const r=m(e,`${S}.${G()}.tmp`);try{await ue(r,`${JSON.stringify(t,void 0,2)}
2
2
  `,"utf8"),await j(r,m(e,S))}catch(a){throw await b(r,{force:!0}),a}},ge=async(e,t)=>{const r=N(e),a=N(r,t.file),o=()=>{throw new w("INTERNAL",`backup: entry ${t.id} points outside ${r} (${t.file}) — refusing to read it`)};if(x(r,a)||o(),!!A(a))return x(await U(r),await U(a))||o(),a},he=e=>{const t=r=>v("",r);return{commit:async(r,a)=>{await j(a,m(e,r))},label:e,list:async()=>O(e),locate:t,materialize:async(r,a)=>{const o=i=>i===void 0?void 0:{path:i,release:()=>Promise.resolve()};return o(r===void 0?A(a)?a:void 0:await ge(e,r))},record:async r=>{const a=await O(e);a.push(r),await me(e,a)},stage:async r=>{await de(e,{recursive:!0});const a=m(e,`${t(r)}.${G()}.partial`);return{path:a,release:()=>b(a,{force:!0})}}}},we="/_lunora/admin/storage/object",be="/_lunora/admin/storage",P=8,ke=(e,t=H)=>{const r=t.basename(e);return r===""||r==="."||r===".."?"snapshot.ndjson":r},ye=e=>{const{context:t,logger:r}=e,a=W(e.prefix??Y),o=`bucket ${t.bucket??"(default)"} under ${a}`,i=te(t),n=c=>`${t.baseUrl}${we}?key=${encodeURIComponent(c)}${i}`,f=async c=>{const s=await t.fetchImpl(n(c),{headers:{authorization:`Bearer ${t.token}`},method:"GET"});if(!s.ok){const l=await s.text().catch(()=>"<no body>");throw new w("INTERNAL",`backup: could not read ${c} (HTTP ${String(s.status)}): ${l}`)}return s.text()},K=async c=>{try{const s=JSON.parse(await f(c));if(B(s))return s;r.warn(`backup: ignoring ${c} — not a backup manifest`)}catch(s){r.warn(`backup: ignoring ${c} — ${s instanceof Error?s.message:String(s)}`)}};return{commit:async(c,s,l)=>{if(l.bytes>I)throw new w("INTERNAL",`backup: the snapshot is ${String(l.bytes)} bytes, above the ${String(I)}-byte limit for a checksum-verified upload — nothing was written. Narrow it with \`--tables\`, or write it to a directory with \`--dir\` and move the file yourself (\`wrangler r2 object put\`).`);const d=await C(s);await oe(t,c,d,{contentType:"application/x-ndjson",id:c,sha256:l.sha256,size:l.bytes},r)},label:o,list:async()=>{const s=(await ae(t,a)).map(d=>d.key).filter(d=>Q(d)),l=[];for(let d=0;d<s.length;d+=P){const g=await Promise.all(s.slice(d,d+P).map(async h=>K(h)));l.push(...g.filter(h=>h!==void 0))}return l.toSorted((d,g)=>d.id.localeCompare(g.id))},locate:c=>v(a,c),materialize:async(c,s)=>{const l=c?.file??s,d=await t.fetchImpl(n(l),{headers:{authorization:`Bearer ${t.token}`},method:"GET"});if(d.status===404)return;if(!d.ok||d.body===null){const $=await d.text().catch(()=>"<no body>");throw new w("INTERNAL",`backup: could not download ${l} (HTTP ${String(d.status)}): ${$}`)}const g=await _(m(R(),"lunora-backup-")),h=m(g,ke(l));try{await fe(le.from(d.body),ce(h))}catch($){throw await b(g,{force:!0,recursive:!0}),$}return{path:h,release:async()=>b(g,{force:!0,recursive:!0})}},record:async c=>{const s=X(c.file),l=await t.fetchImpl(`${t.baseUrl}${be}?key=${encodeURIComponent(s)}${i}`,{body:`${JSON.stringify(c,void 0,2)}
3
3
  `,headers:{authorization:`Bearer ${t.token}`,"content-type":"application/json"},method:"PUT"});if(!l.ok){const d=await l.text().catch(()=>"<no body>");throw new w("INTERNAL",`backup: snapshot ${c.file} was written but its manifest was not (HTTP ${String(l.status)}): ${d}`)}},stage:async c=>{const s=await _(m(R(),"lunora-backup-"));return{path:m(s,v("",c)),release:async()=>b(s,{force:!0,recursive:!0})}}}},pe=".lunora-backups",F="/_lunora/admin/backup/retention",$e="/_lunora/admin/backup/prune",ve="/_lunora/admin/pitr",Se="__lunora_admin__:getPitrBookmark",Ee="__lunora_admin__:pitrRestore",Te=async(e,t)=>{const r=(e.now??(()=>new Date))().toISOString(),a=await t.stage(r);try{const o=await re({cwd:e.cwd,fetchImpl:e.fetchImpl,logger:e.logger,out:a.path,prod:e.prod,tables:e.tables,token:e.token,url:e.url});if(o.code!==0)return{code:o.code};const i=t.locate(r),n=await q(a.path);await t.commit(i,a.path,n);const f={bytes:n.bytes,createdAt:r,file:i,id:r,rows:o.rows,sha256:n.sha256,tables:e.tables};return await t.record(f),e.logger.success(`backup created: ${i} (${o.rows.toString()} rows, ${n.bytes.toString()} bytes)`),{code:0,entry:f}}finally{await a.release().catch(o=>{e.logger.warn(`backup: could not clean up staging (${o instanceof Error?o.message:String(o)})`)})}},Ae=async(e,t,r)=>{if(t?.sha256===void 0)return r.error(t===void 0?"--verify needs a recorded checksum, and a snapshot restored by path/key has no manifest entry — restore it by its backup id instead":`--verify: backup ${t.id} carries no recorded checksum — it was taken by a release before checksums existed`),{code:u.USAGE};const a=await q(e);if(a.sha256!==t.sha256)return r.error(`--verify: ${t.file} does not match its recorded checksum (expected ${t.sha256}, got ${a.sha256}) — nothing was imported`),{code:1};r.success(`verified ${t.file} against its recorded sha256`)},Ne=async(e,t)=>{const r=await t.list();if(r.length===0)return e.logger.info(`no backups found in ${t.label}`),{code:0,entries:[]};for(const a of r)e.logger.info(`${a.id} ${a.rows.toString()} rows ${a.bytes.toString()} bytes ${a.file}`);return{code:0,entries:r}},Ie=async(e,t)=>{const{target:r}=e;if(r===void 0||r.length===0)return e.logger.error("restore requires a backup id or file path. Usage: lunora backup restore <id|file>"),{code:u.USAGE};const o=(await t.list()).find(n=>n.id===r),i=await t.materialize(o,r);if(i===void 0)return e.logger.error(`backup not found: ${r}`),{code:u.NOT_FOUND};try{if(e.verify===!0){const f=await Ae(i.path,o,e.logger);if(f!==void 0)return f}const n=await ne({cwd:e.cwd,fetchImpl:e.fetchImpl,file:i.path,logger:e.logger,prod:e.prod,token:e.token,url:e.url,yes:e.yes});return{code:n.code,entry:o,restored:n.inserted}}finally{await i.release().catch(n=>{e.logger.warn(`backup: could not clean up the downloaded snapshot (${n instanceof Error?n.message:String(n)})`)})}},Ue=e=>{if(e.prod&&e.url===void 0)return e.logger.error("--prod requires an explicit --url (refusing to target the implicit localhost worker)"),{refused:u.USAGE};if(e.restore===!0&&e.at===void 0&&e.bookmark===void 0)return e.logger.error("pitr --restore requires --at <time> or --bookmark <bookmark>"),{refused:u.USAGE};const t=T(e.url,e.logger,e.cwd);if(t===void 0)return{refused:u.USAGE};if(e.restore===!0&&V({prod:e.prod,url:t})&&e.yes!==!0)return e.logger.error(`pitr --restore restores data in place at ${t}, which is not local. Re-run with --yes to confirm.`),{refused:u.USAGE};const{token:r}=E({cwd:e.cwd??process.cwd(),token:e.token,url:t});if(!r)return e.logger.error("admin token required — pass --token, set LUNORA_ADMIN_TOKEN, or add it to .dev.vars (local targets only)"),{refused:u.AUTH};const a=e.adminFetch??globalThis.fetch;if(typeof a!="function")throw new TypeError("no fetch implementation available — pass pitrFetch or run on Node >= 18");return{fetchImpl:a,requestUrl:`${t}${ve}`,token:r}},_e=(e,t)=>{const r={};return e.at!==void 0&&(r.time=e.at),t&&e.bookmark!==void 0&&(r.bookmark=e.bookmark),t&&e.restart===!0&&(r.restart=!0),r},xe=async e=>{const t=Ue(e);if(p(t))return{code:t.refused};const r=e.restore===!0,a=r?Ee:Se,o=_e(e,r),i=r?"restore":"bookmark";e.logger.info(`POST ${t.requestUrl} -> pitr ${i}${e.shard===void 0?"":` (shard "${e.shard}")`}`);const n=await t.fetchImpl(t.requestUrl,{body:JSON.stringify({args:o,functionPath:a,shardKey:e.shard}),headers:{authorization:`Bearer ${t.token}`,"content-type":"application/json"},method:"POST"});return{body:await y(n,e.logger),code:n.ok?0:k(n.status)}},Re=(e,t)=>{if(e.bucket===void 0)return e.prefix!==void 0?(e.logger.error("--prefix applies only to an R2 destination — pass --bucket alongside it, or use --dir to point at a local directory."),{refused:u.USAGE}):he(m(t,e.dir??pe));if(e.dir!==void 0)return e.logger.error("--dir applies only to a local destination and does not apply alongside --bucket — drop one."),{refused:u.USAGE};if(e.prod===!0&&e.url===void 0)return e.logger.error("--prod requires an explicit --url (refusing to target the implicit localhost worker)"),{refused:u.USAGE};const r=T(e.url,e.logger,e.cwd);if(r===void 0)return{refused:u.USAGE};const{token:a}=E({cwd:t,token:e.token,url:r});if(!a)return e.logger.error("admin token required — pass --token, set LUNORA_ADMIN_TOKEN, or add it to .dev.vars (local targets only)"),{refused:u.AUTH};const o=e.fetchImpl??globalThis.fetch;if(typeof o!="function")throw new TypeError("no fetch implementation available — pass fetchImpl or run on Node >= 18");return ye({context:{baseUrl:r,bucket:e.bucket==="default"?void 0:e.bucket,fetchImpl:o,token:a},logger:e.logger,prefix:e.prefix})},L=e=>{const t=[e.bucket===void 0?void 0:"--bucket",e.prefix===void 0?void 0:"--prefix",e.dir===void 0?void 0:"--dir"].filter(i=>i!==void 0);if(t.length>0)return e.logger.error(`${t.join(" / ")} ${t.length===1?"does":"do"} not apply here — retention and prune act on the store the worker itself is configured with (\`backupStore\`), not a destination you name.`),{refused:u.USAGE};if(e.prod===!0&&e.url===void 0)return e.logger.error("--prod requires an explicit --url (refusing to target the implicit localhost worker)"),{refused:u.USAGE};const r=T(e.url,e.logger,e.cwd);if(r===void 0)return{refused:u.USAGE};const{token:a}=E({cwd:e.cwd??process.cwd(),token:e.token,url:r});if(!a)return e.logger.error("admin token required — pass --token, set LUNORA_ADMIN_TOKEN, or add it to .dev.vars (local targets only)"),{refused:u.AUTH};const o=e.adminFetch??globalThis.fetch;if(typeof o!="function")throw new TypeError("no fetch implementation available — pass pitrFetch or run on Node >= 18");return{baseUrl:r,fetchImpl:o,token:a}},M=(e,t)=>{e.logger.info(`backup retention would keep the newest ${t.keep.toString()} of ${t.eligible.toString()} under ${t.prefix} and delete ${t.wouldDelete.length.toString()}`);for(const r of t.wouldDelete)e.logger.info(` ${D(r)}`)},Oe=async e=>{const t=L(e);if(p(t))return{code:t.refused};const r=await t.fetchImpl(`${t.baseUrl}${F}`,{headers:{authorization:`Bearer ${t.token}`},method:"GET"});if(!r.ok)return await y(r,e.logger),{code:k(r.status)};const a=await r.json();return a.cron===void 0?(e.logger.info("no scheduled backup is configured (`backupCron`), so retention would delete nothing"),{code:0,preview:a}):a.keep<=0?(e.logger.info(`retention is off for cron "${a.cron}" (\`backupRetain\` unset) — every snapshot under ${a.prefix} is kept`),{code:0,preview:a}):(M(e,a),a.eligible===0&&e.logger.info(`no snapshot under ${a.prefix} was written by this cron, so retention has nothing of its own to remove`),{code:0,preview:a})},Pe=(e,t)=>{e.logger.success(`deleted ${t.deleted.length.toString()} backup(s)`);for(const r of t.deleted)e.logger.info(` ${D(r)}`);t.failed.length>0&&e.logger.warn(`${t.failed.length.toString()} could not be removed — the snapshot may be gone with its manifest left behind; run again to retry`),t.ignored>0&&e.logger.info(`${t.ignored.toString()} were already gone by the time the delete ran`),t.remaining>0&&e.logger.info(`${t.remaining.toString()} more are past the window — run \`lunora backup prune\` again`)},Be=async e=>{const t=L(e);if(p(t))return{code:t.refused};const r=await t.fetchImpl(`${t.baseUrl}${F}`,{headers:{authorization:`Bearer ${t.token}`},method:"GET"});if(!r.ok)return await y(r,e.logger),{code:k(r.status)};const a=await r.json();if(a.keep<=0||a.cron===void 0)return e.logger.error("backup prune needs a retention window: set `backupRetain` (and `backupCron`) on the worker. Without one there is nothing past the window to remove."),{code:u.USAGE,preview:a};if(a.wouldDelete.length===0)return e.logger.info(`nothing to prune — ${a.eligible.toString()} snapshot(s) under ${a.prefix} and retention keeps the newest ${a.keep.toString()}`),{code:0,preview:a};if(M(e,a),e.yes!==!0){const n=e.confirm??(z()?J:void 0);if(n===void 0)return e.logger.error("refusing to delete backups without confirmation — re-run with --yes (there is no undo for an object-store delete)"),{code:u.USAGE,preview:a};if(!await n(`delete ${a.wouldDelete.length.toString()} backup(s)? This cannot be undone. [y/N] `))return e.logger.info("nothing was deleted"),{code:0,preview:a}}const o=await t.fetchImpl(`${t.baseUrl}${$e}`,{body:JSON.stringify({confirm:a.wouldDelete}),headers:{authorization:`Bearer ${t.token}`,"content-type":"application/json"},method:"POST"});if(!o.ok)return await y(o,e.logger),{code:k(o.status),preview:a};const i=await o.json();return Pe(e,i),{code:i.failed.length>0?1:0,deleted:i.deleted,preview:a}},De=async(e,t)=>{try{if(e.subcommand==="pitr")return await xe(e);if(e.subcommand==="retention")return await Oe(e);if(e.subcommand==="prune")return await Be(e);const r=Re(e,t);return p(r)?{code:r.refused}:e.subcommand==="create"?await Te(e,r):e.subcommand==="list"?await Ne(e,r):await Ie(e,r)}catch(r){return e.logger.error(r instanceof Error?r.message:String(r)),{code:1}}},Ge=async e=>{const t=e.cwd??process.cwd(),r=await De(e,t);return{...r,data:{subcommand:e.subcommand,...r.entries===void 0?{}:{entries:r.entries},...r.entry===void 0?{}:{entry:r.entry},...r.restored===void 0?{}:{restored:r.restored},...r.preview===void 0?{}:{preview:r.preview},...r.deleted===void 0?{}:{deleted:r.deleted},...r.body===void 0?{}:{result:r.body}}}},je=e=>e==="create"||e==="list"||e==="pitr"||e==="prune"||e==="restore"||e==="retention",or=Z(async({argument:e,cwd:t,format:r,logger:a,options:o})=>{const i=e[0];if(!je(i)){const f=`backup: unknown subcommand "${i??""}" — expected create | list | restore | retention | prune | pitr`;return a.error(f),{code:u.USAGE,error:f}}const n=await Ge({at:o.at,bookmark:o.bookmark,bucket:o.bucket,cwd:t,dir:o.dir,format:r,logger:a,prefix:o.prefix,prod:o.prod===!0,restart:o.restart===!0,restore:o.restore===!0,shard:o.shard,subcommand:i,tables:o.tables,target:e[1],token:o.token,url:ee({cwd:t,prod:o.prod===!0,url:o.url}),verify:o.verify===!0,yes:o.yes===!0});return{code:n.code,data:n.data,error:n.error}});export{or as execute,Ge as runBackupCommand};
@@ -1 +1 @@
1
- import{readdirSync as g,lstatSync as S,existsSync as y}from"node:fs";import{join as E,basename as T}from"node:path";import{pathToFileURL as w}from"node:url";import{d as R}from"../packem_shared/command-Mmxzxyr5.mjs";import{EXIT_CODE as u}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";const l=".eval.ts",$=new Set([".git","_generated","dist","node_modules"]),v=(e,s=[])=>{let r;try{r=g(e)}catch{return s}for(const t of r){const o=E(e,t);let n;try{n=S(o)}catch{continue}if(n.isDirectory()){if($.has(t))continue;v(o,s)}else n.isFile()&&t.endsWith(l)&&s.push(o)}return s.toSorted((t,o)=>t.localeCompare(o))},_=e=>typeof e=="object"&&e!==null&&typeof e.run=="function",m=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1,F="evals",O='"lunora eval" needs native TypeScript execution — run Node ≥23.6, or a TS loader/transform (tracked in plans/245-eval-runner-design.md §8.3)',N=/unknown file extension ".ts"/i,p=e=>e instanceof Error?e.code==="ERR_UNKNOWN_FILE_EXTENSION"?!0:N.test(e.message):!1,f=e=>T(e,l),x=e=>({average:e.result?.average,error:e.error,items:e.result?.items,name:e.name,passed:e.passed,path:e.path,threshold:e.threshold}),b=e=>({evals:e.evals.map(s=>x(s))}),i=(e,s,r)=>(e.error(s),{code:r,error:s,evals:[]}),A=(e,s,r)=>{if(!y(e))return r.info(`eval: no "${s}" directory — nothing to run`),[];const t=v(e);return t.length===0&&r.info(`eval: no ${l} files found under "${s}"`),t},I=async e=>{const r=(await import(w(e).href)).default;if(!_(r))throw new Error("does not default-export an eval module (expected `{ run(): Promise<EvalResult>, name?, threshold? }`)");return r},L=async(e,s)=>{let r;try{r=await I(e)}catch(n){if(p(n))throw n;return{error:n instanceof Error?n.message:String(n),name:f(e),passed:!1,path:e}}const t=r.name??f(e);if(r.threshold!==void 0&&!m(r.threshold))return{error:`invalid \`threshold\` export: must be a number in [0, 1] — received ${JSON.stringify(r.threshold)}`,name:t,passed:!1,path:e};const o=r.threshold??s;try{const n=await r.run(),a=o===void 0||n.average>=o;return{name:t,passed:a,path:e,result:n,threshold:o}}catch(n){return{error:n instanceof Error?n.message:String(n),name:t,passed:!1,path:e,threshold:o}}},U=async(e,s)=>{const r=[];for(const t of e)r.push(await L(t,s));return r},D=e=>{if(e.error!==void 0)return`ERROR: ${e.error}`;const s=e.passed?"pass":"FAIL",r=e.result?.items.length??0;return`${s} (${String(r)} cases)`},C=e=>{if(e.length===0)return[];const s=Math.max(4,...e.map(t=>t.name.length)),r=[`${"NAME".padEnd(s)} SCORE THRESHOLD STATUS`];for(const t of e){const o=t.result===void 0?"—":t.result.average.toFixed(3),n=t.threshold===void 0?"—":t.threshold.toFixed(3);r.push(`${t.name.padEnd(s)} ${o.padEnd(6)} ${n.padEnd(9)} ${D(t)}`)}return r},M=async e=>{const s=e.cwd??process.cwd(),{logger:r}=e;if(e.threshold!==void 0&&!m(e.threshold))return i(r,`eval: --threshold must be a number in [0, 1] — received "${String(e.threshold)}"`,u.USAGE);const t=e.dir??F,o=E(s,t),n=A(o,t,r);let a;try{a=await U(n,e.threshold)}catch(d){if(!p(d))throw d;return i(r,O,1)}if(e.threshold!==void 0&&a.length===0){const d=`eval: --threshold ${String(e.threshold)} was set but 0 eval files were discovered under "${t}" — nothing was gated`;return i(r,d,u.USAGE)}for(const d of C(a))r.info(d);const c=a.filter(d=>!d.passed),h=c.length>0?1:0;return h===0?r.success(`eval: ${String(a.length)} eval(s) passed`):r.error(`eval: ${String(c.length)}/${String(a.length)} eval(s) failed`),{code:h,evals:a}},V=R(async({cwd:e,format:s,logger:r,options:t})=>{const o=await M({cwd:e,dir:t.dir,format:s,logger:r,threshold:t.threshold});return{code:o.code,data:b(o),error:o.error}});export{V as execute,M as runEvalCommand};
1
+ import{readdirSync as g,lstatSync as S,existsSync as y}from"node:fs";import{join as E,basename as T}from"node:path";import{pathToFileURL as w}from"node:url";import{d as R}from"../packem_shared/command-B--jgXSc.mjs";import{EXIT_CODE as u}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";const l=".eval.ts",$=new Set([".git","_generated","dist","node_modules"]),v=(e,s=[])=>{let r;try{r=g(e)}catch{return s}for(const t of r){const o=E(e,t);let n;try{n=S(o)}catch{continue}if(n.isDirectory()){if($.has(t))continue;v(o,s)}else n.isFile()&&t.endsWith(l)&&s.push(o)}return s.toSorted((t,o)=>t.localeCompare(o))},_=e=>typeof e=="object"&&e!==null&&typeof e.run=="function",m=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1,F="evals",O='"lunora eval" needs native TypeScript execution — run Node ≥23.6, or a TS loader/transform (tracked in plans/245-eval-runner-design.md §8.3)',N=/unknown file extension ".ts"/i,p=e=>e instanceof Error?e.code==="ERR_UNKNOWN_FILE_EXTENSION"?!0:N.test(e.message):!1,f=e=>T(e,l),x=e=>({average:e.result?.average,error:e.error,items:e.result?.items,name:e.name,passed:e.passed,path:e.path,threshold:e.threshold}),b=e=>({evals:e.evals.map(s=>x(s))}),i=(e,s,r)=>(e.error(s),{code:r,error:s,evals:[]}),A=(e,s,r)=>{if(!y(e))return r.info(`eval: no "${s}" directory — nothing to run`),[];const t=v(e);return t.length===0&&r.info(`eval: no ${l} files found under "${s}"`),t},I=async e=>{const r=(await import(w(e).href)).default;if(!_(r))throw new Error("does not default-export an eval module (expected `{ run(): Promise<EvalResult>, name?, threshold? }`)");return r},L=async(e,s)=>{let r;try{r=await I(e)}catch(n){if(p(n))throw n;return{error:n instanceof Error?n.message:String(n),name:f(e),passed:!1,path:e}}const t=r.name??f(e);if(r.threshold!==void 0&&!m(r.threshold))return{error:`invalid \`threshold\` export: must be a number in [0, 1] — received ${JSON.stringify(r.threshold)}`,name:t,passed:!1,path:e};const o=r.threshold??s;try{const n=await r.run(),a=o===void 0||n.average>=o;return{name:t,passed:a,path:e,result:n,threshold:o}}catch(n){return{error:n instanceof Error?n.message:String(n),name:t,passed:!1,path:e,threshold:o}}},U=async(e,s)=>{const r=[];for(const t of e)r.push(await L(t,s));return r},D=e=>{if(e.error!==void 0)return`ERROR: ${e.error}`;const s=e.passed?"pass":"FAIL",r=e.result?.items.length??0;return`${s} (${String(r)} cases)`},C=e=>{if(e.length===0)return[];const s=Math.max(4,...e.map(t=>t.name.length)),r=[`${"NAME".padEnd(s)} SCORE THRESHOLD STATUS`];for(const t of e){const o=t.result===void 0?"—":t.result.average.toFixed(3),n=t.threshold===void 0?"—":t.threshold.toFixed(3);r.push(`${t.name.padEnd(s)} ${o.padEnd(6)} ${n.padEnd(9)} ${D(t)}`)}return r},M=async e=>{const s=e.cwd??process.cwd(),{logger:r}=e;if(e.threshold!==void 0&&!m(e.threshold))return i(r,`eval: --threshold must be a number in [0, 1] — received "${String(e.threshold)}"`,u.USAGE);const t=e.dir??F,o=E(s,t),n=A(o,t,r);let a;try{a=await U(n,e.threshold)}catch(d){if(!p(d))throw d;return i(r,O,1)}if(e.threshold!==void 0&&a.length===0){const d=`eval: --threshold ${String(e.threshold)} was set but 0 eval files were discovered under "${t}" — nothing was gated`;return i(r,d,u.USAGE)}for(const d of C(a))r.info(d);const c=a.filter(d=>!d.passed),h=c.length>0?1:0;return h===0?r.success(`eval: ${String(a.length)} eval(s) passed`):r.error(`eval: ${String(c.length)}/${String(a.length)} eval(s) failed`),{code:h,evals:a}},V=R(async({cwd:e,format:s,logger:r,options:t})=>{const o=await M({cwd:e,dir:t.dir,format:s,logger:r,threshold:t.threshold});return{code:o.code,data:b(o),error:o.error}});export{V as execute,M as runEvalCommand};
@@ -1,2 +1,2 @@
1
- import{readLinkedProject as v,resolveDeployDriver as h,execArgsFor as b,detectPackageManager as y}from"@lunora/config";import{d as w}from"../packem_shared/command-Mmxzxyr5.mjs";import{EXIT_CODE as l}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{defaultSpawner as L}from"../packem_shared/createRecordingSpawner-sS7LEN7x.mjs";import{createR2Sql as S}from"@lunora/bindings/r2sql";import{createPipelineLogReader as _}from"@lunora/runtime";const E=["trace","debug","log","info","warn","error","fatal"],T=new Set(E),f=/^\d+$/,u=(e,t)=>{if(e===void 0)return;const n=e.trim();if(f.test(n))return Number(n);const a=Date.parse(n);if(Number.isNaN(a))throw new TypeError(`logs: invalid ${t} "${e}" — pass epoch-millis or an ISO 8601 date`);return a},C=e=>Buffer.from(JSON.stringify(e),"utf8").toString("base64url"),I=e=>{const t=e.trim();if(f.test(t))return{ts:Number(t)};let n;try{n=JSON.parse(Buffer.from(t,"base64url").toString("utf8"))}catch{throw new TypeError(`logs: invalid --cursor "${e}" — expected the token printed by the previous page (or a bare epoch-millis ts)`)}if(typeof n!="object"||n===null||typeof n.ts!="number"||!Number.isFinite(n.ts))throw new TypeError(`logs: invalid --cursor "${e}" — expected the token printed by the previous page (or a bare epoch-millis ts)`);const{ts:a}=n,r=n.seen,s=Array.isArray(r)?r.filter(i=>typeof i=="string"):void 0;return s!==void 0&&s.length>0?{seen:s,ts:a}:{ts:a}},m=(e,t)=>{if(e!==void 0){if(!T.has(e))throw new TypeError(`logs: invalid ${t} "${e}" — expected one of trace, debug, log, info, warn, error, fatal`);return e}},p=e=>{const t={},n=u(e.since,"--since");n!==void 0&&(t.sinceTs=n);const a=u(e.until,"--until");a!==void 0&&(t.untilTs=a);const r=m(e.level,"--level");r!==void 0&&(t.level=r);const s=m(e.minLevel,"--min-level");if(s!==void 0&&(t.minLevel=s),e.functionPrefix!==void 0&&(t.functionPathPrefix=e.functionPrefix),e.traceId!==void 0&&(t.traceId=e.traceId),e.shardKey!==void 0&&(t.shardKey=e.shardKey),e.userId!==void 0&&(t.userId=e.userId),e.limit!==void 0){const i=Number(e.limit);if(!Number.isFinite(i))throw new TypeError(`logs: invalid --limit "${e.limit}" — expected a number`);t.limit=i}return e.cursor!==void 0&&(t.cursor=I(e.cursor)),t},R=e=>{const t=new Date(e.ts).toISOString(),n=e.level.toUpperCase().padEnd(5);return`${t} ${n} ${e.functionPath} ${e.message}`},$=async e=>{const t=e.environment??process.env,n=t.R2_SQL_ACCOUNT_ID,a=t.R2_SQL_TOKEN,r=t.R2_SQL_BUCKET,s=[];if((n===void 0||n.length===0)&&s.push("R2_SQL_ACCOUNT_ID"),(a===void 0||a.length===0)&&s.push("R2_SQL_TOKEN"),(r===void 0||r.length===0)&&s.push("R2_SQL_BUCKET"),(e.table===void 0||e.table.length===0)&&s.push("--table"),s.length>0)return e.logger.error(`logs --durable: R2 SQL not configured (missing ${s.join(", ")}). The Pipeline must write to an R2 Data Catalog (Iceberg) table, and you must supply R2_SQL_ACCOUNT_ID / R2_SQL_TOKEN / R2_SQL_BUCKET plus --table — see the observability docs.`),{code:l.USAGE,error:"not configured"};let i;try{i=p(e)}catch(o){return e.logger.error(o instanceof Error?o.message:String(o)),{code:l.USAGE,error:"invalid option"}}const d=S({accountId:n,apiToken:a,bucket:r,fetch:e.fetch}),c=await _(d,{namespace:e.namespace,table:e.table}).query(i);for(const o of c.rows)process.stdout.write(`${e.ndjson===!0?JSON.stringify(o):R(o)}
2
- `);return c.rows.length===0?e.logger.info("logs --durable: no matching log records"):c.nextCursor!==void 0&&e.logger.info(`logs --durable: more rows available — pass --cursor ${C(c.nextCursor)} for the next page`),{code:0,rows:c.rows}},N=async e=>{const t=e.cwd??process.cwd(),n=e.env??v(t)?.env,a=h(e.target);if(a.toolchain===void 0){const c=`logs: deploy target "${a.id}" has no command-line toolchain`;return e.logger.error(c),{code:l.USAGE,descriptor:void 0,error:c}}const r=a.toolchain.tail({environment:n,format:e.format,search:e.search,status:e.status,temporary:e.temporary,worker:e.worker}),s=b(y(t),r.tool,r.args),i={args:s.args,command:s.command,cwd:t};return e.logger.info(`tailing logs via ${i.command} ${i.args.join(" ")}`),{code:(await(e.spawner??L)(i)).code,delegated:!0,descriptor:i}},U=w(async({argument:e,cwd:t,format:n,logger:a,options:r})=>{if(r.durable===!0){const s=await $({cursor:r.cursor,functionPrefix:r.functionPrefix,level:r.level,limit:r.limit,logger:a,minLevel:r.minLevel,namespace:r.namespace,ndjson:r.ndjson===!0,shardKey:r.shardKey,since:r.since,table:r.table,traceId:r.traceId,until:r.until,userId:r.userId});return{...s,...s.rows===void 0?{}:{delegated:!0}}}return N({cwd:t,env:r.env,format:n,logger:a,search:r.search,status:r.status,target:r.target,temporary:r.temporary===!0,worker:e[0]})});export{U as execute,N as runLogsCommand};
1
+ import{readLinkedProject as v,resolveDeployDriver as h,toolchainExecArgs as b,detectPackageManager as y}from"@lunora/config";import{d as w}from"../packem_shared/command-B--jgXSc.mjs";import{EXIT_CODE as d}from"../packem_shared/EXIT_CODE-08cwt3MK.mjs";import{defaultSpawner as L}from"../packem_shared/createRecordingSpawner-sS7LEN7x.mjs";import{createR2Sql as S}from"@lunora/bindings/r2sql";import{createPipelineLogReader as _}from"@lunora/runtime";const E=["trace","debug","log","info","warn","error","fatal"],T=new Set(E),f=/^\d+$/,u=(e,t)=>{if(e===void 0)return;const a=e.trim();if(f.test(a))return Number(a);const n=Date.parse(a);if(Number.isNaN(n))throw new TypeError(`logs: invalid ${t} "${e}" — pass epoch-millis or an ISO 8601 date`);return n},C=e=>Buffer.from(JSON.stringify(e),"utf8").toString("base64url"),I=e=>{const t=e.trim();if(f.test(t))return{ts:Number(t)};let a;try{a=JSON.parse(Buffer.from(t,"base64url").toString("utf8"))}catch{throw new TypeError(`logs: invalid --cursor "${e}" — expected the token printed by the previous page (or a bare epoch-millis ts)`)}if(typeof a!="object"||a===null||typeof a.ts!="number"||!Number.isFinite(a.ts))throw new TypeError(`logs: invalid --cursor "${e}" — expected the token printed by the previous page (or a bare epoch-millis ts)`);const{ts:n}=a,r=a.seen,s=Array.isArray(r)?r.filter(i=>typeof i=="string"):void 0;return s!==void 0&&s.length>0?{seen:s,ts:n}:{ts:n}},m=(e,t)=>{if(e!==void 0){if(!T.has(e))throw new TypeError(`logs: invalid ${t} "${e}" — expected one of trace, debug, log, info, warn, error, fatal`);return e}},p=e=>{const t={},a=u(e.since,"--since");a!==void 0&&(t.sinceTs=a);const n=u(e.until,"--until");n!==void 0&&(t.untilTs=n);const r=m(e.level,"--level");r!==void 0&&(t.level=r);const s=m(e.minLevel,"--min-level");if(s!==void 0&&(t.minLevel=s),e.functionPrefix!==void 0&&(t.functionPathPrefix=e.functionPrefix),e.traceId!==void 0&&(t.traceId=e.traceId),e.shardKey!==void 0&&(t.shardKey=e.shardKey),e.userId!==void 0&&(t.userId=e.userId),e.limit!==void 0){const i=Number(e.limit);if(!Number.isFinite(i))throw new TypeError(`logs: invalid --limit "${e.limit}" — expected a number`);t.limit=i}return e.cursor!==void 0&&(t.cursor=I(e.cursor)),t},R=e=>{const t=new Date(e.ts).toISOString(),a=e.level.toUpperCase().padEnd(5);return`${t} ${a} ${e.functionPath} ${e.message}`},$=async e=>{const t=e.environment??process.env,a=t.R2_SQL_ACCOUNT_ID,n=t.R2_SQL_TOKEN,r=t.R2_SQL_BUCKET,s=[];if((a===void 0||a.length===0)&&s.push("R2_SQL_ACCOUNT_ID"),(n===void 0||n.length===0)&&s.push("R2_SQL_TOKEN"),(r===void 0||r.length===0)&&s.push("R2_SQL_BUCKET"),(e.table===void 0||e.table.length===0)&&s.push("--table"),s.length>0)return e.logger.error(`logs --durable: R2 SQL not configured (missing ${s.join(", ")}). The Pipeline must write to an R2 Data Catalog (Iceberg) table, and you must supply R2_SQL_ACCOUNT_ID / R2_SQL_TOKEN / R2_SQL_BUCKET plus --table — see the observability docs.`),{code:d.USAGE,error:"not configured"};let i;try{i=p(e)}catch(c){return e.logger.error(c instanceof Error?c.message:String(c)),{code:d.USAGE,error:"invalid option"}}const o=S({accountId:a,apiToken:n,bucket:r,fetch:e.fetch}),l=await _(o,{namespace:e.namespace,table:e.table}).query(i);for(const c of l.rows)process.stdout.write(`${e.ndjson===!0?JSON.stringify(c):R(c)}
2
+ `);return l.rows.length===0?e.logger.info("logs --durable: no matching log records"):l.nextCursor!==void 0&&e.logger.info(`logs --durable: more rows available — pass --cursor ${C(l.nextCursor)} for the next page`),{code:0,rows:l.rows}},N=async e=>{const t=e.cwd??process.cwd(),a=e.env??v(t)?.env,n=h(e.target),r=n.toolchain?.tail;if(r===void 0){const c=`logs: deploy target "${n.id}" has no log tail`;return e.logger.error(c),{code:d.USAGE,descriptor:void 0,error:c}}const s=r({environment:a,format:e.format,search:e.search,status:e.status,temporary:e.temporary,worker:e.worker}),i=b(y(t),s),o={args:i.args,command:i.command,cwd:t};return e.logger.info(`tailing logs via ${o.command} ${o.args.join(" ")}`),{code:(await(e.spawner??L)(o)).code,delegated:!0,descriptor:o}},U=w(async({argument:e,cwd:t,format:a,logger:n,options:r})=>{if(r.durable===!0){const s=await $({cursor:r.cursor,functionPrefix:r.functionPrefix,level:r.level,limit:r.limit,logger:n,minLevel:r.minLevel,namespace:r.namespace,ndjson:r.ndjson===!0,shardKey:r.shardKey,since:r.since,table:r.table,traceId:r.traceId,until:r.until,userId:r.userId});return{...s,...s.rows===void 0?{}:{delegated:!0}}}return N({cwd:t,env:r.env,format:a,logger:n,search:r.search,status:r.status,target:r.target,temporary:r.temporary===!0,worker:e[0]})});export{U as execute,N as runLogsCommand};