@lunora/cli 1.0.0-alpha.145 → 1.0.0-alpha.147
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.mjs +1 -1
- package/dist/index.d.mts +29 -12
- package/dist/index.d.ts +29 -12
- package/dist/index.mjs +1 -1
- package/dist/packem_chunks/handler.mjs +1 -1
- package/dist/packem_chunks/handler10.mjs +1 -1
- package/dist/packem_chunks/handler11.mjs +1 -1
- package/dist/packem_chunks/handler12.mjs +2 -2
- package/dist/packem_chunks/handler13.mjs +2 -2
- package/dist/packem_chunks/handler14.mjs +1 -1
- package/dist/packem_chunks/handler15.mjs +1 -1
- package/dist/packem_chunks/handler16.mjs +1 -1
- package/dist/packem_chunks/handler17.mjs +1 -1
- package/dist/packem_chunks/handler18.mjs +2 -2
- package/dist/packem_chunks/handler19.mjs +1 -1
- package/dist/packem_chunks/handler2.mjs +1 -1
- package/dist/packem_chunks/handler20.mjs +1 -1
- package/dist/packem_chunks/handler21.mjs +2 -2
- package/dist/packem_chunks/handler22.mjs +1 -1
- package/dist/packem_chunks/handler23.mjs +1 -1
- package/dist/packem_chunks/handler24.mjs +1 -1
- package/dist/packem_chunks/handler25.mjs +8 -9
- package/dist/packem_chunks/handler3.mjs +2 -2
- package/dist/packem_chunks/handler4.mjs +1 -1
- package/dist/packem_chunks/handler5.mjs +1 -1
- package/dist/packem_chunks/handler6.mjs +1 -1
- package/dist/packem_chunks/handler7.mjs +1 -1
- package/dist/packem_chunks/handler8.mjs +1 -1
- package/dist/packem_chunks/handler9.mjs +3 -3
- package/dist/packem_chunks/planDevCommand.mjs +6 -6
- package/dist/packem_chunks/runCodegenCommand.mjs +1 -1
- package/dist/packem_chunks/runDeployCommand.mjs +1 -1
- package/dist/packem_chunks/runInitCommand.mjs +52 -52
- package/dist/packem_chunks/runMigrateGenerateCommand.mjs +4 -4
- package/dist/packem_chunks/runResetCommand.mjs +1 -1
- package/dist/packem_chunks/runRpcCommand.mjs +1 -1
- package/dist/packem_shared/{COMMANDS-C7e5qiYV.mjs → COMMANDS-DNQLU6rs.mjs} +1 -1
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-C4qrFAn_.mjs +8 -0
- package/dist/packem_shared/{admin-token-DV5A9T5b.mjs → admin-token-BKmc3AUm.mjs} +1 -1
- package/dist/packem_shared/cli-C-iz79JI.mjs +3 -0
- package/dist/packem_shared/{command-Bjv4VmYA.mjs → command-0l-ZPhIX.mjs} +1 -1
- package/dist/packem_shared/{commands-BvfzxKAa.mjs → commands-CG9qEtqR.mjs} +5 -5
- package/dist/packem_shared/createLogger-BoSxdb2T.mjs +2 -0
- package/dist/packem_shared/detect-package-manager-DXDstphE.mjs +1 -0
- package/dist/packem_shared/{diffSnapshots-9bDd9nOK.mjs → diffSnapshots-BbwCuhoN.mjs} +2 -2
- package/dist/packem_shared/{lint-ignore-report-CSeEIMkV.mjs → lint-ignore-report-CKDXv9MQ.mjs} +1 -1
- package/dist/packem_shared/open-url-zbbAo_D7.mjs +1 -0
- package/dist/packem_shared/output-format-Cv3aLqhP.mjs +2 -0
- package/dist/packem_shared/{post-codegen-hook-reEtIN59.mjs → post-codegen-hook-DhL1RH5u.mjs} +1 -1
- package/dist/packem_shared/runAddCommand-a_rW768_.mjs +1 -0
- package/dist/packem_shared/runExportCommand-DFpdjDoT.mjs +5 -0
- package/dist/packem_shared/{schemaIrToSnapshot-Clwd2A8e.mjs → schemaIrToSnapshot-Dahp39qH.mjs} +1 -1
- package/dist/packem_shared/shared-BF5QIWFD.mjs +1 -0
- package/dist/packem_shared/tui-prompts-BU3irGxV.mjs +4 -0
- package/dist/packem_shared/{wrangler-secrets-DzYgUxU-.mjs → wrangler-secrets-D0Tv5GWn.mjs} +1 -1
- package/package.json +12 -11
- package/skills/lunora-realtime/SKILL.md +15 -0
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-xn-frBqK.mjs +0 -12
- package/dist/packem_shared/cli-DdEKv4ng.mjs +0 -3
- package/dist/packem_shared/createLogger--C3x1FNE.mjs +0 -2
- package/dist/packem_shared/detect-package-manager-D9r2z_X6.mjs +0 -1
- package/dist/packem_shared/open-url-CTU_g9gr.mjs +0 -1
- package/dist/packem_shared/output-format-D7cKB-O5.mjs +0 -2
- package/dist/packem_shared/runAddCommand-oQMYPkp6.mjs +0 -1
- package/dist/packem_shared/tui-prompts-CCt3jm1k.mjs +0 -4
package/dist/bin.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{f as s}from"./packem_shared/cli-
|
|
2
|
+
import{f as s}from"./packem_shared/cli-C-iz79JI.mjs";try{const r=await s();process.exit(r)}catch(r){process.stderr.write(`${r instanceof Error?r.message:String(r)}
|
|
3
3
|
`),process.exit(1)}
|
package/dist/index.d.mts
CHANGED
|
@@ -89,15 +89,14 @@ interface CodegenCommandResult {
|
|
|
89
89
|
outputDirectory: string;
|
|
90
90
|
}
|
|
91
91
|
declare const runCodegenCommand: (options: CodegenCommandOptions) => CodegenCommandResult;
|
|
92
|
-
/** Rows per HTTP request when importing. Convex uses ~500; same here. */
|
|
93
|
-
declare const DEFAULT_IMPORT_BATCH_SIZE = 500;
|
|
94
92
|
/**
|
|
95
|
-
* Minimal projection of `globalThis.fetch` for the
|
|
96
|
-
*
|
|
97
|
-
*
|
|
93
|
+
* Minimal projection of `globalThis.fetch` for the transfer commands: `body` is
|
|
94
|
+
* exposed as a stream-iterable (the export path pipes it) and accepts bytes (the
|
|
95
|
+
* blob path uploads them). The JSON-only commands use the narrower `FetchLike`
|
|
96
|
+
* in `../run/handler` instead.
|
|
98
97
|
*/
|
|
99
98
|
type StreamingFetchLike = (input: string, init?: {
|
|
100
|
-
body?: string;
|
|
99
|
+
body?: string | Uint8Array;
|
|
101
100
|
headers?: Record<string, string>;
|
|
102
101
|
method?: string;
|
|
103
102
|
}) => Promise<{
|
|
@@ -134,6 +133,8 @@ interface ExportCommandResult {
|
|
|
134
133
|
* the body in memory.
|
|
135
134
|
*/
|
|
136
135
|
declare const runExportCommand: (options: ExportCommandOptions) => Promise<ExportCommandResult>;
|
|
136
|
+
/** Rows per HTTP request when importing. Convex uses ~500; same here. */
|
|
137
|
+
declare const DEFAULT_IMPORT_BATCH_SIZE = 500;
|
|
137
138
|
interface ImportCommandOptions {
|
|
138
139
|
/** Rows per HTTP request. Defaults to {@link DEFAULT_IMPORT_BATCH_SIZE}. */
|
|
139
140
|
batchSize?: number;
|
|
@@ -143,6 +144,11 @@ interface ImportCommandOptions {
|
|
|
143
144
|
file: string;
|
|
144
145
|
logger: Logger;
|
|
145
146
|
prod?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Scan the export for columns holding `_storage` ids and write a candidate
|
|
149
|
+
* `lunora/import-convex.json`. Scan-only: nothing is imported.
|
|
150
|
+
*/
|
|
151
|
+
scan?: boolean;
|
|
146
152
|
/**
|
|
147
153
|
* Wrap each line as `{table:<name>,doc:<line>}`. Use when the source NDJSON
|
|
148
154
|
* is bare docs from a single table — Convex's `convex import --table users`
|
|
@@ -151,6 +157,18 @@ interface ImportCommandOptions {
|
|
|
151
157
|
table?: string;
|
|
152
158
|
token?: string;
|
|
153
159
|
url?: string;
|
|
160
|
+
/**
|
|
161
|
+
* Verify per-table row parity + dangling-storage after import. Exits non-zero
|
|
162
|
+
* when a table's inserted count differs from its source line count, or when a
|
|
163
|
+
* document references a storage id that was not migrated.
|
|
164
|
+
*/
|
|
165
|
+
verify?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Also migrate Convex `_storage` blobs: read `_storage/documents.jsonl`, upload
|
|
168
|
+
* each blob with sha256+size verification, and build the `storageId → key` map.
|
|
169
|
+
* Off by default so the plain-document import path is unchanged.
|
|
170
|
+
*/
|
|
171
|
+
withStorage?: boolean;
|
|
154
172
|
/** Confirm bulk-writing production. Required alongside `--prod`. */
|
|
155
173
|
yes?: boolean;
|
|
156
174
|
}
|
|
@@ -160,12 +178,6 @@ interface ImportCommandResult {
|
|
|
160
178
|
/** Total inserted rows across batches. */
|
|
161
179
|
inserted: number;
|
|
162
180
|
}
|
|
163
|
-
/**
|
|
164
|
-
* Stream an NDJSON file — or a `npx convex export --path <dir>` directory — in
|
|
165
|
-
* chunks, POSTing each batch to `/_lunora/admin/import`. The line buffer stays
|
|
166
|
-
* bounded by `batchSize`, so a multi-GiB source imports without buffering
|
|
167
|
-
* everything in memory.
|
|
168
|
-
*/
|
|
169
181
|
declare const runImportCommand: (options: ImportCommandOptions) => Promise<ImportCommandResult>;
|
|
170
182
|
/**
|
|
171
183
|
* Injectable probe for a Docker-compatible container engine. Tests pass a
|
|
@@ -950,6 +962,11 @@ interface InitCommandResult {
|
|
|
950
962
|
files: ReadonlyArray<string>;
|
|
951
963
|
target: string;
|
|
952
964
|
}
|
|
965
|
+
/**
|
|
966
|
+
* `lunora init` entry: scaffold (in-place or a new directory), then — on success
|
|
967
|
+
* — offer to add auth + email via the registry. The offer never affects the
|
|
968
|
+
* scaffold's exit code.
|
|
969
|
+
*/
|
|
953
970
|
declare const runInitCommand: (options: InitCommandOptions) => Promise<InitCommandResult>;
|
|
954
971
|
interface MigrateGenerateCommandOptions {
|
|
955
972
|
cwd?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -89,15 +89,14 @@ interface CodegenCommandResult {
|
|
|
89
89
|
outputDirectory: string;
|
|
90
90
|
}
|
|
91
91
|
declare const runCodegenCommand: (options: CodegenCommandOptions) => CodegenCommandResult;
|
|
92
|
-
/** Rows per HTTP request when importing. Convex uses ~500; same here. */
|
|
93
|
-
declare const DEFAULT_IMPORT_BATCH_SIZE = 500;
|
|
94
92
|
/**
|
|
95
|
-
* Minimal projection of `globalThis.fetch` for the
|
|
96
|
-
*
|
|
97
|
-
*
|
|
93
|
+
* Minimal projection of `globalThis.fetch` for the transfer commands: `body` is
|
|
94
|
+
* exposed as a stream-iterable (the export path pipes it) and accepts bytes (the
|
|
95
|
+
* blob path uploads them). The JSON-only commands use the narrower `FetchLike`
|
|
96
|
+
* in `../run/handler` instead.
|
|
98
97
|
*/
|
|
99
98
|
type StreamingFetchLike = (input: string, init?: {
|
|
100
|
-
body?: string;
|
|
99
|
+
body?: string | Uint8Array;
|
|
101
100
|
headers?: Record<string, string>;
|
|
102
101
|
method?: string;
|
|
103
102
|
}) => Promise<{
|
|
@@ -134,6 +133,8 @@ interface ExportCommandResult {
|
|
|
134
133
|
* the body in memory.
|
|
135
134
|
*/
|
|
136
135
|
declare const runExportCommand: (options: ExportCommandOptions) => Promise<ExportCommandResult>;
|
|
136
|
+
/** Rows per HTTP request when importing. Convex uses ~500; same here. */
|
|
137
|
+
declare const DEFAULT_IMPORT_BATCH_SIZE = 500;
|
|
137
138
|
interface ImportCommandOptions {
|
|
138
139
|
/** Rows per HTTP request. Defaults to {@link DEFAULT_IMPORT_BATCH_SIZE}. */
|
|
139
140
|
batchSize?: number;
|
|
@@ -143,6 +144,11 @@ interface ImportCommandOptions {
|
|
|
143
144
|
file: string;
|
|
144
145
|
logger: Logger;
|
|
145
146
|
prod?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Scan the export for columns holding `_storage` ids and write a candidate
|
|
149
|
+
* `lunora/import-convex.json`. Scan-only: nothing is imported.
|
|
150
|
+
*/
|
|
151
|
+
scan?: boolean;
|
|
146
152
|
/**
|
|
147
153
|
* Wrap each line as `{table:<name>,doc:<line>}`. Use when the source NDJSON
|
|
148
154
|
* is bare docs from a single table — Convex's `convex import --table users`
|
|
@@ -151,6 +157,18 @@ interface ImportCommandOptions {
|
|
|
151
157
|
table?: string;
|
|
152
158
|
token?: string;
|
|
153
159
|
url?: string;
|
|
160
|
+
/**
|
|
161
|
+
* Verify per-table row parity + dangling-storage after import. Exits non-zero
|
|
162
|
+
* when a table's inserted count differs from its source line count, or when a
|
|
163
|
+
* document references a storage id that was not migrated.
|
|
164
|
+
*/
|
|
165
|
+
verify?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Also migrate Convex `_storage` blobs: read `_storage/documents.jsonl`, upload
|
|
168
|
+
* each blob with sha256+size verification, and build the `storageId → key` map.
|
|
169
|
+
* Off by default so the plain-document import path is unchanged.
|
|
170
|
+
*/
|
|
171
|
+
withStorage?: boolean;
|
|
154
172
|
/** Confirm bulk-writing production. Required alongside `--prod`. */
|
|
155
173
|
yes?: boolean;
|
|
156
174
|
}
|
|
@@ -160,12 +178,6 @@ interface ImportCommandResult {
|
|
|
160
178
|
/** Total inserted rows across batches. */
|
|
161
179
|
inserted: number;
|
|
162
180
|
}
|
|
163
|
-
/**
|
|
164
|
-
* Stream an NDJSON file — or a `npx convex export --path <dir>` directory — in
|
|
165
|
-
* chunks, POSTing each batch to `/_lunora/admin/import`. The line buffer stays
|
|
166
|
-
* bounded by `batchSize`, so a multi-GiB source imports without buffering
|
|
167
|
-
* everything in memory.
|
|
168
|
-
*/
|
|
169
181
|
declare const runImportCommand: (options: ImportCommandOptions) => Promise<ImportCommandResult>;
|
|
170
182
|
/**
|
|
171
183
|
* Injectable probe for a Docker-compatible container engine. Tests pass a
|
|
@@ -950,6 +962,11 @@ interface InitCommandResult {
|
|
|
950
962
|
files: ReadonlyArray<string>;
|
|
951
963
|
target: string;
|
|
952
964
|
}
|
|
965
|
+
/**
|
|
966
|
+
* `lunora init` entry: scaffold (in-place or a new directory), then — on success
|
|
967
|
+
* — offer to add auth + email via the registry. The offer never affects the
|
|
968
|
+
* scaffold's exit code.
|
|
969
|
+
*/
|
|
953
970
|
declare const runInitCommand: (options: InitCommandOptions) => Promise<InitCommandResult>;
|
|
954
971
|
interface MigrateGenerateCommandOptions {
|
|
955
972
|
cwd?: string;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as o,i as n,f as a}from"./packem_shared/cli-C-iz79JI.mjs";import{runCodegenCommand as t}from"./packem_chunks/runCodegenCommand.mjs";import{runDeployCommand as p}from"./packem_chunks/runDeployCommand.mjs";import{planDevCommand as x,runDevCommand as i}from"./packem_chunks/planDevCommand.mjs";import{runInitCommand as l}from"./packem_chunks/runInitCommand.mjs";import{runMigrateGenerateCommand as u}from"./packem_chunks/runMigrateGenerateCommand.mjs";import{runResetCommand as g}from"./packem_chunks/runResetCommand.mjs";import{runRpcCommand as R}from"./packem_chunks/runRpcCommand.mjs";import{insertSchemaExtension as D}from"./packem_shared/insertSchemaExtension-DZReBZ4_.mjs";import{createLogger as A,pail as c}from"./packem_shared/createLogger-BoSxdb2T.mjs";import{diffSnapshots as v,renderAddColumn as _,renderCreateIndex as h,renderCreateTable as y,renderDropIndex as F,renderDropTable as L,renderMigrationFile as O,validatorKindToSqlType as b}from"./packem_shared/diffSnapshots-BbwCuhoN.mjs";import{default as B}from"./packem_shared/schemaIrToSnapshot-Dahp39qH.mjs";import{createRecordingSpawner as U,defaultSpawner as W}from"./packem_shared/createRecordingSpawner-SKs4R1fc.mjs";import{default as N}from"./packem_shared/parseManifest-x3WsxKHz.mjs";import{DEFAULT_IMPORT_BATCH_SIZE as V,runImportCommand as j}from"./packem_shared/DEFAULT_IMPORT_BATCH_SIZE-C4qrFAn_.mjs";import{REQUIRED_COMPATIBILITY_DATE as H,REQUIRED_FLAG as K,validateWranglerProject as Y,validateWranglerConfig as Z}from"@lunora/config/cloudflare";import{buildRegistryIndex as z}from"./packem_shared/buildRegistryIndex-DwySASBu.mjs";import{I as X,F as $,E as rr}from"./packem_shared/commands-CG9qEtqR.mjs";import{runExportCommand as or}from"./packem_shared/runExportCommand-DFpdjDoT.mjs";export{o as COMMANDS,V as DEFAULT_IMPORT_BATCH_SIZE,H as REQUIRED_COMPATIBILITY_DATE,K as REQUIRED_FLAG,n as VERSION,z as buildRegistryIndex,A as createLogger,U as createRecordingSpawner,W as defaultSpawner,v as diffSnapshots,D as insertSchemaExtension,c as pail,N as parseManifest,x as planDevCommand,_ as renderAddColumn,h as renderCreateIndex,y as renderCreateTable,F as renderDropIndex,L as renderDropTable,O as renderMigrationFile,X as runAddCommand,$ as runBuildIndexCommand,a as runCli,t as runCodegenCommand,p as runDeployCommand,i as runDevCommand,or as runExportCommand,j as runImportCommand,l as runInitCommand,u as runMigrateGenerateCommand,rr as runRegistryViewCommand,g as runResetCommand,R as runRpcCommand,B as schemaIrToSnapshot,Y as validateWrangler,Z as validateWranglerConfig,b as validatorKindToSqlType};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{existsSync as b,readFileSync as k}from"node:fs";import{applyLintIgnores as $,detectLintTools as S}from"@lunora/config";import{findWranglerFile as T}from"@lunora/config/cloudflare";import{join as g,basename as h}from"@visulima/path";import{i as j}from"../packem_shared/command-0l-ZPhIX.mjs";import{d as L,r as U,l as x,i as R,o as m,u as B,a as f,b as D,c as F,e as p,f as M,n as N,g as c,h as W,j as q,s as u,k as A,m as C,p as I,q as O,t as J}from"../packem_shared/lint-ignore-report-CKDXv9MQ.mjs";import{i as K,t as P,d as Q,s as X}from"../packem_shared/output-format-Cv3aLqhP.mjs";import{v as w,B as Y}from"../packem_shared/tui-prompts-BU3irGxV.mjs";import{I as Z}from"../packem_shared/commands-CG9qEtqR.mjs";const z=r=>{const e=r.trim().toLowerCase();return C.find(a=>a.value===e||a.label.toLowerCase()===e||e==="auth0"&&a.value==="auth-auth0"||e==="clerk"&&a.value==="auth-clerk")?.value},v=r=>{try{const e=JSON.parse(k(g(r,"package.json"),"utf8"));return{...e.dependencies,...e.devDependencies}}catch{return{}}},E=async r=>{const e=r.cwd??process.cwd(),a=q(v(e));return a!==void 0?a:r.yes===!0?(r.logger.warn(`add: couldn't detect your framework — using "${u}". Pass a specific item (e.g. \`lunora add auth-ui-vue\`) to override.`),u):await(r.promptSelect??((o,t,d)=>w(o,t,d)))("Which framework is your app?",A,{default:u})??u},G=async r=>{if(r.provider!==void 0&&r.provider!==""){const a=z(r.provider);return a===void 0?(r.logger.warn(`add: unknown --provider "${r.provider}" — using "${c}" (email & password).`),c):a}if(r.yes===!0)return c;const e=r.promptSelect??((a,o,t)=>w(a,o,t));return W(e)},l=r=>r.promptText??((e,a)=>Y(e,a)),H=async r=>{const e=h(r.cwd??process.cwd());if(r.bucket!==void 0&&r.bucket!==""){const a=R(r.bucket);if(a!==void 0)return a;const o=m(e);return r.logger.warn(`add: "${r.bucket}" isn't a valid R2 bucket name (lowercase alphanumeric + hyphens, 3–63 chars) — using "${o}".`),o}return r.yes===!0?m(e):B(l(r),e)},V=async r=>{const e=a=>{r.logger.warn(`add: ${a}`)};if(r.mailTo!==void 0&&r.mailTo!=="")return f(r.mailTo,e);if(r.yes!==!0)return f(await l(r)(D,{placeholder:"you@yourdomain.com"}),e)},_=async r=>{const e=h(r.cwd??process.cwd());if(r.db!==void 0&&r.db!==""){const a=F(r.db);if(a!==void 0)return a;const o=p(e);return r.logger.warn(`add: "${r.db}" isn't a usable D1 database name — using "${o}".`),o}return r.yes===!0?p(e):M(l(r),e)},rr=async(r,e)=>r.kind==="auth"?[await G(e)]:r.kind==="auth-ui"?[await E(e)]:r.kind==="email"?[x]:[r.item],er=(r,e)=>{N($(r,S(r)),e)},ar=async r=>{const e=r.cwd??process.cwd(),a=r.feature===void 0?void 0:L(r.feature);if(a===void 0)return r.logger.error("add requires a feature or registry item. Usage: lunora add <auth|email|storage|crons|presence|…>"),{code:1,items:[]};if(!b(g(e,"lunora"))||T(e)===void 0)return r.logger.error("add: not a Lunora project here (need a lunora/ directory and a wrangler.jsonc). Run `lunora init` first."),{code:1,items:[]};if(a.kind==="auth-ui"&&U(v(e)))return r.logger.error("add: auth-ui has no React Native port — the screens render DOM elements and a stylesheet, which Metro has nothing to mount. Build the screens with React Native primitives against the same better-auth client (`@lunora/react-native/auth`); `lunora add auth` still installs the server half."),{code:1,items:[]};const o=await rr(a,r),t=[];if(o.includes("storage")){const s=await H(r);t.push(i=>I(i,s))}if(o.includes("mail")){const s=await V(r);s!==void 0&&t.push(i=>O(i,s))}if(o.some(s=>s==="auth"||s.startsWith("auth-"))){const s=await _(r);t.push(i=>J(i,s))}const d=t.length>0?s=>{let i=s;for(const y of t)i=y(i);return i}:void 0,n=await Z({allowUnsafeSource:r.allowUnsafeSource,cwd:e,from:r.from,logger:r.logger,names:[...o],ref:r.ref,source:r.source,transformManifest:d,yes:!0});return n.code===0&&er(e,r.logger),{code:n.code,items:o}},mr=j(async({argument:r,cwd:e,logger:a,options:o})=>{const t=K("add",o.format);if(t!==void 0)return a.error(t),{code:1};const d=X(o.format,a),n=await ar({allowUnsafeSource:o.allowUnsafeSource===!0,bucket:o.bucket,cwd:e,db:o.db,feature:r[0],from:o.from,logger:d,mailTo:o.mailTo,provider:o.provider,ref:o.ref,source:o.source,yes:o.yes===!0});return P(o.format)&&Q({code:n.code,items:n.items}),{code:n.code}});export{mr as execute,ar as runAddFeature};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as p}from"../packem_shared/command-
|
|
1
|
+
import{i as p}from"../packem_shared/command-0l-ZPhIX.mjs";import{d as u}from"../packem_shared/resolve-target-CeiNrCAx.mjs";import{runExportCommand as d}from"../packem_shared/runExportCommand-DFpdjDoT.mjs";const a=p(({argument:r,cwd:t,logger:e,options:o})=>d({cwd:t,logger:e,out:r[0]??o.out,prod:o.prod===!0,tables:o.tables,token:o.token,url:u({cwd:t,prod:o.prod===!0,url:o.url})}));export{a as execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i
|
|
1
|
+
import{i}from"../packem_shared/command-0l-ZPhIX.mjs";import{d as n}from"../packem_shared/resolve-target-CeiNrCAx.mjs";import{runImportCommand as u}from"../packem_shared/DEFAULT_IMPORT_BATCH_SIZE-C4qrFAn_.mjs";const s=i(({argument:a,cwd:r,logger:o,options:e})=>{const t=a[0];return t?u({batchSize:e.batchSize,cwd:r,file:t,logger:o,prod:e.prod===!0,scan:e.scan===!0,table:e.table,token:e.token,url:n({cwd:r,prod:e.prod===!0,url:e.url}),verify:e.verify===!0,withStorage:e.withStorage===!0,yes:e.yes===!0}):(o.error("import requires a path. Usage: lunora import <file.ndjson | convex-export-dir> [--table <name>]"),{code:1})});export{s as execute};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{readFileSync as
|
|
2
|
-
`):x(r,e.logger),{code:0,snapshot:r}},
|
|
1
|
+
import{readFileSync as f,existsSync as m}from"node:fs";import{join as g}from"node:path";import{discoverSchema as p}from"@lunora/codegen";import{readLinkedProject as u}from"@lunora/config";import{findWranglerFile as b}from"@lunora/config/cloudflare";import{parse as h}from"jsonc-parser";import{Project as y}from"ts-morph";import{i as j}from"../packem_shared/command-0l-ZPhIX.mjs";const l=(e,o)=>{if(e===null||typeof e!="object")return;const r=e[o];return typeof r=="string"&&r.length>0?r:void 0},c=(e,o)=>{if(e===null||typeof e!="object")return[];const r=e[o];return Array.isArray(r)?r:[]},w=e=>{const o=c(e.durable_objects??{},"bindings"),r=c(e,"d1_databases"),s=c(e,"vectorize");return{bindings:{d1:r.map(n=>l(n,"binding")??"<unnamed>"),durableObjects:o.map(n=>l(n,"name")??"<unnamed>"),vectorize:s.map(n=>l(n,"binding")??"<unnamed>")},compatibilityDate:l(e,"compatibility_date"),compatibilityFlags:c(e,"compatibility_flags").filter(n=>typeof n=="string"),main:l(e,"main"),name:l(e,"name")}},$=e=>({tables:e.tables.map(o=>{let r="root";return o.shardMode==="global"?r="global":typeof o.shardMode=="object"&&(r=`shardBy(${o.shardMode.field})`),{indexes:o.indexes.length,name:o.name,shard:r}}),vectorIndexes:e.vectorIndexes.length}),k=e=>{const o=g(e,"package.json");if(!m(o))return[];let r;try{r=JSON.parse(f(o,"utf8"))}catch{return[]}if(r===null||typeof r!="object")return[];const s=["dependencies","devDependencies","peerDependencies","optionalDependencies"],n=new Map;for(const a of s){const t=r[a];if(!(t===null||typeof t!="object"))for(const[i,d]of Object.entries(t))i.startsWith("@lunora/")&&typeof d=="string"&&!n.has(i)&&n.set(i,d)}return[...n.entries()].toSorted(([a],[t])=>a.localeCompare(t)).map(([a,t])=>({name:a,version:t}))},v=e=>{const o=k(e),r=b(e);let s;if(r)try{s=w(h(f(r,"utf8")))}catch{s=void 0}const n=g(e,"lunora","schema.ts");let a,t;if(m(n))try{const i=new y({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1});a=$(p(i,n))}catch(i){t=i instanceof Error?i.message:String(i)}return{link:u(e),lunoraPackages:o,projectRoot:e,schema:a,schemaError:t,wrangler:s,wranglerPath:r}},x=(e,o)=>{if(o.info(`project: ${e.projectRoot}`),o.info(""),o.info("@lunora/* packages:"),e.lunoraPackages.length===0)o.info(" (none found in package.json)");else for(const r of e.lunoraPackages)o.info(` ${r.name}@${r.version}`);if(o.info(""),e.wrangler?(o.info(`wrangler: ${e.wranglerPath??""}`),o.info(` name: ${e.wrangler.name??"<unset>"}`),o.info(` main: ${e.wrangler.main??"<unset>"}`),o.info(` compatibility_date: ${e.wrangler.compatibilityDate??"<unset>"}`),o.info(` compatibility_flags: ${e.wrangler.compatibilityFlags.join(", ")||"<none>"}`),o.info(` durable objects: ${e.wrangler.bindings.durableObjects.join(", ")||"<none>"}`),o.info(` d1 databases: ${e.wrangler.bindings.d1.join(", ")||"<none>"}`),o.info(` vectorize indexes: ${e.wrangler.bindings.vectorize.join(", ")||"<none>"}`)):o.info("wrangler: (not found)"),o.info(""),e.link?(o.info(`link: ${e.link.workerName??"(unnamed)"} -> ${e.link.workerUrl??"<no url>"}`),e.link.env!==void 0&&o.info(` env: ${e.link.env}`)):o.info("link: (not linked — run `lunora link --url <https://your-worker>`)"),o.info(""),e.schemaError!==void 0)o.warn(`schema: parse error — ${e.schemaError}`);else if(e.schema){o.info(`schema: ${String(e.schema.tables.length)} table(s), ${String(e.schema.vectorIndexes)} vector index(es)`);for(const r of e.schema.tables)o.info(` ${r.name} [${r.shard}, ${String(r.indexes)} index(es)]`)}else o.info("schema: (no lunora/schema.ts)")},S=e=>{const o=e.cwd??process.cwd(),r=v(o);return e.json?process.stdout.write(`${JSON.stringify(r,void 0,2)}
|
|
2
|
+
`):x(r,e.logger),{code:0,snapshot:r}},E=j(({cwd:e,logger:o,options:r})=>S({cwd:e,json:r.json===!0,logger:o}));export{v as collectInfo,E as execute,S as runInfoCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{u as m}from"../packem_shared/admin-url-Ca-KI3d_.mjs";import{i as $}from"../packem_shared/command-
|
|
2
|
-
`)},
|
|
1
|
+
import{u as m}from"../packem_shared/admin-url-Ca-KI3d_.mjs";import{i as $}from"../packem_shared/command-0l-ZPhIX.mjs";import{d as S}from"../packem_shared/resolve-target-CeiNrCAx.mjs";const M="__lunora_admin__:getFunctionStats",y=10,u=(o,e)=>({calls:o.calls,conflicts:o.conflicts??0,errors:o.errors,lastErrorMessage:o.lastErrorMessage,maxDurationMs:o.maxDurationMs,meanDurationMs:o.calls===0?0:o.totalDurationMs/o.calls,path:o.path,rate:e}),v=(o,e)=>{const t=o.filter(r=>(r.conflicts??0)>0).map(r=>u(r,r.calls===0?0:(r.conflicts??0)/r.calls)).toSorted((r,s)=>s.rate-r.rate||s.conflicts-r.conflicts).slice(0,e),n=o.filter(r=>r.errors>0).map(r=>u(r,r.calls===0?0:r.errors/r.calls)).toSorted((r,s)=>s.rate-r.rate||s.errors-r.errors).slice(0,e),i=o.map(r=>u(r,0)).toSorted((r,s)=>s.maxDurationMs-r.maxDurationMs).slice(0,e);return{errorHotspots:n,latencyOutliers:i,totalFunctions:o.length,writeContention:t}},p=o=>`${(o*100).toFixed(1)}%`,f=o=>o<1e3?`${Math.round(o).toString()}ms`:`${(o/1e3).toFixed(2)}s`,d=(o,e,t,n)=>[o,...e.length===0?[` ${t}`]:e.map(i=>` ${n(i)}`)],w=o=>{const e=t=>t.lastErrorMessage?` — ${t.lastErrorMessage}`:"";return[`Insights over ${o.totalFunctions.toString()} function${o.totalFunctions===1?"":"s"}`,"",...d("Write-conflict hot-spots (OCC contention — candidates for sharding):",o.writeContention,"none — no write conflicts observed",t=>`${t.path} ${t.conflicts.toString()}/${t.calls.toString()} calls (${p(t.rate)})`),"",...d("Error hot-spots:",o.errorHotspots,"none — no errors observed",t=>`${t.path} ${t.errors.toString()}/${t.calls.toString()} calls (${p(t.rate)})${e(t)}`),"",...d("Latency outliers (slowest single call):",o.latencyOutliers,"none — no functions have run",t=>`${t.path} max ${f(t.maxDurationMs)}, mean ${f(t.meanDurationMs)} over ${t.calls.toString()} calls`)].join(`
|
|
2
|
+
`)},O=o=>o===void 0||!Number.isFinite(o)||o<=0?y:Math.floor(o),N=async o=>{if(o.prod&&o.url===void 0)return o.logger.error("--prod requires an explicit --url (refusing to report from the implicit localhost worker)"),{code:1};const e=o.token??process.env.LUNORA_ADMIN_TOKEN;if(!e)return o.logger.error("admin token required — pass --token or set LUNORA_ADMIN_TOKEN"),{code:1};const t=m(o.url,o.logger,o.cwd);if(t===void 0)return{code:1};const n=`${t}/_lunora/rpc`,i=globalThis.fetch;if(typeof i!="function")throw new TypeError("no fetch implementation available — pass fetchImpl or run on Node >= 18");const r={args:{},functionPath:M};o.shard!==void 0&&(r.shardKey=o.shard),o.logger.info(`POST ${n} -> insights`);const s=await i(n,{body:JSON.stringify(r),headers:{authorization:`Bearer ${e}`,"content-type":"application/json"},method:"POST"}),a=await s.text();if(!s.ok)return o.logger.error(`insights failed: HTTP ${String(s.status)}: ${a}`),{code:1};let l;try{l=JSON.parse(a)}catch{return o.logger.error(`insights failed: worker returned non-JSON: ${a}`),{code:1}}const h=l.result??l,{functions:g}=h;if(!Array.isArray(g))return o.logger.error("insights failed: response carried no `functions` array"),{code:1};const c=v(g,O(o.limit));return o.logger.info(o.json?JSON.stringify(c,void 0,2):w(c)),{code:0,report:c}},b=$(({cwd:o,logger:e,options:t})=>{const n=t.limit===void 0?void 0:Number.parseInt(t.limit,10);return N({cwd:o,json:t.json,limit:n,logger:e,prod:t.prod,shard:t.shard,token:t.token,url:S({cwd:o,prod:t.prod===!0,url:t.url})})});export{v as buildInsightsReport,b as execute,w as formatInsightsReport,N as runInsightsCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as c,rmSync as m}from"node:fs";import{join as u}from"node:path";import{writeLinkedProject as s,LINKED_PROJECT_FILE as t}from"@lunora/config";import{i as d}from"../packem_shared/command-
|
|
1
|
+
import{existsSync as c,rmSync as m}from"node:fs";import{join as u}from"node:path";import{writeLinkedProject as s,LINKED_PROJECT_FILE as t}from"@lunora/config";import{i as d}from"../packem_shared/command-0l-ZPhIX.mjs";import{d as a}from"../packem_shared/wrangler-name-CHDf3rMP.mjs";const k=r=>{try{const{protocol:o}=new URL(r);return o==="http:"||o==="https:"}catch{return!1}},p=(r,o)=>{const e=u(r,t);return c(e)?(m(e),o.success(`link: removed ${t}`),{code:0}):(o.warn(`link: no ${t} to remove`),{code:0})},v=r=>{const o=r.cwd??process.cwd(),{logger:e}=r;if(r.remove)return p(o,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:1};if(!k(r.url))return e.error(`link: invalid --url "${r.url}" — expected an http(s) URL`),{code:1};const i=r.now??(()=>new Date().toISOString()),n={env:r.env,linkedAt:i(),workerName:r.name??a(o),workerUrl:r.url},l=s(o,n);return e.success(`link: ${n.workerName??"(unnamed worker)"} -> ${r.url}`),e.info(`link: wrote ${l}`),n.env!==void 0&&e.info(`link: environment "${n.env}"`),{code:0,link:n}},h=d(({cwd:r,logger:o,options:e})=>v({cwd:r,env:e.env,logger:o,name:e.name,remove:e.remove===!0,url:e.url}));export{h as execute,v as runLinkCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{runCodegen as g}from"@lunora/codegen";import{resolveTargetOrThrow as d,resolveDeployDriver as p}from"@lunora/config";import{r as m}from"../packem_shared/api-spec-BENwiyUa.mjs";import{l as f}from"../packem_shared/codegen-error-DJN6pTH5.mjs";import{i as u}from"../packem_shared/command-
|
|
1
|
+
import{runCodegen as g}from"@lunora/codegen";import{resolveTargetOrThrow as d,resolveDeployDriver as p}from"@lunora/config";import{r as m}from"../packem_shared/api-spec-BENwiyUa.mjs";import{l as f}from"../packem_shared/codegen-error-DJN6pTH5.mjs";import{i as u}from"../packem_shared/command-0l-ZPhIX.mjs";import{a as w}from"../packem_shared/platform-diagnostics-C4TFj5Pu.mjs";import{m as h}from"../packem_shared/post-codegen-hook-DhL1RH5u.mjs";import{R as v}from"../packem_shared/schema-drift-gate-d12lMICD.mjs";import{validateWranglerProject as S}from"@lunora/config/cloudflare";const b=async(r,o,a=[],i)=>{const l={crons:a,projectRoot:r},n=p(i);try{const e=await n.infer(l),s=[e.shardNamespaces.length>0?`${String(e.shardNamespaces.length)} shard namespace(s)`:void 0,e.queues.length>0?`${String(e.queues.length)} queue(s)`:void 0,e.workflows.length>0?`${String(e.workflows.length)} workflow(s)`:void 0,e.containers.length>0?`${String(e.containers.length)} container(s)`:void 0,e.globalDatabase?"global database":void 0,e.objectStorage?"object storage":void 0,e.keyValueStore?"key-value store":void 0].filter(c=>c!==void 0);s.length>0&&o.info(`${n.name} target requires: ${s.join(", ")}`)}catch{}const t=await n.provision(l);t.changed&&o.success(`provisioned: ${t.added.join(", ")} → ${t.configPath??"wrangler.jsonc"}`);for(const e of t.warnings)o.warn(e)},$=async r=>{const o=r.cwd??process.cwd(),a=d(o,r.target);r.logger.info("running codegen");let i;try{i=g({apiSpec:r.apiSpec,projectRoot:o,target:a}),r.logger.success("codegen complete"),w(i.platformDiagnostics,r.logger)}catch(e){const s=e instanceof Error?e.message:String(e);return r.logger.error(f(e)),{code:1,error:`codegen failed: ${s}`,validation:{problems:[],wranglerPath:void 0}}}const l=await h({cwd:o,logger:r.logger,spawner:r.spawner});if(l.error!==void 0)return r.logger.error(l.error),{code:1,error:l.error,validation:{problems:[],wranglerPath:void 0}};const n=v({allowDrift:r.allowSchemaDrift===!0,codegen:i,command:"prepare",logger:r.logger,updateBaseline:r.updateSchemaBaseline===!0});if(n.blocked)return{code:1,error:"schema drift gate blocked prepare",schemaDrift:{blocked:!0,reason:n.reason},validation:{problems:[],wranglerPath:void 0}};await b(o,r.logger,i.cronTriggers,a);const t=S({projectRoot:o});if(t.problems.length>0){r.logger.error("wrangler.jsonc validation failed:");for(const e of t.problems)r.logger.error(` - ${e}`);return{code:1,error:"wrangler validation failed",validation:t}}return n.rebless?.(),r.logger.success("project is ready to deploy"),{code:0,validation:t}},x=u(({cwd:r,logger:o,options:a})=>$({allowSchemaDrift:a.allowSchemaDrift===!0,apiSpec:m(a.apiSpec),cwd:r,logger:o,target:a.target,updateSchemaBaseline:a.updateSchemaBaseline===!0}));export{x as execute,$ as runPrepareCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as n}from"../packem_shared/command-
|
|
1
|
+
import{i as n}from"../packem_shared/command-0l-ZPhIX.mjs";import{I as c,E as f,F as a}from"../packem_shared/commands-CG9qEtqR.mjs";const i=n(({argument:u,cwd:s,logger:o,options:e})=>{const r=u[0],t=u.slice(1);return r==="add"?c({allowUnsafeSource:e.allowUnsafeSource===!0,cwd:s,diff:e.diff===!0,dryRun:e.dryRun===!0,from:e.from,json:e.json===!0,logger:o,names:t,overwrite:e.overwrite===!0,ref:e.ref,source:e.source,yes:e.yes===!0}):r==="list"?c({cwd:s,from:e.from,json:e.json===!0,list:!0,logger:o,names:[],ref:e.ref,source:e.source}):r==="view"?f({allowUnsafeSource:e.allowUnsafeSource===!0,cwd:s,from:e.from,logger:o,names:t,ref:e.ref,source:e.source}):r==="build"?a({check:e.check===!0,from:e.from,logger:o,out:e.out}):(o.error("registry: unknown subcommand. Usage: lunora registry <add|list|view|build> [names…]"),{code:1})});export{i as execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as c,readFileSync as g,readdirSync as p,statSync as k,mkdirSync as S,writeFileSync as y}from"node:fs";import{fileURLToPath as v}from"node:url";import{AGENT_RULES_DIR as u,detectAgentRules as L,LUNORA_SKILL_NAMES as R}from"@lunora/config";import{join as l,relative as $,resolve as j,dirname as d}from"@visulima/path";import{i as I}from"../packem_shared/command-
|
|
1
|
+
import{existsSync as c,readFileSync as g,readdirSync as p,statSync as k,mkdirSync as S,writeFileSync as y}from"node:fs";import{fileURLToPath as v}from"node:url";import{AGENT_RULES_DIR as u,detectAgentRules as L,LUNORA_SKILL_NAMES as R}from"@lunora/config";import{join as l,relative as $,resolve as j,dirname as d}from"@visulima/path";import{i as I}from"../packem_shared/command-0l-ZPhIX.mjs";const b=(r=d(v(import.meta.url)))=>{let e=r;for(let n=0;n<6;n+=1){const t=l(e,"package.json");if(c(t))try{if(JSON.parse(g(t,"utf8")).name==="@lunora/cli"){const s=l(e,"skills");return c(s)?s:void 0}}catch{}const o=d(e);if(o===e)break;e=o}},A=r=>p(r).filter(e=>{const n=l(r,e);return k(n).isDirectory()&&c(l(n,"SKILL.md"))}),m=(r,e,n)=>{S(e,{recursive:!0});let t=!1;for(const o of p(r)){const s=l(r,o),i=l(e,o);if(k(s).isDirectory()){t=m(s,i,n)||t;continue}c(i)&&!n||(y(i,g(s)),t=!0)}return t},_=["pnpm-workspace.yaml","pnpm-lock.yaml","yarn.lock","package-lock.json","bun.lock","bun.lockb",".git"],x=r=>{let e=r;for(;;){if(_.some(t=>c(l(e,t))))return e;const n=d(e);if(n===e)return r;e=n}},f=(r,e)=>e===void 0?x(r):j(r,e),D=r=>{const e=r.cwd??process.cwd(),n=f(e,r.dir),t=r.overwrite===!0,o=b();if(o===void 0)return r.logger.error("rules: could not locate the bundled skills (is @lunora/cli installed correctly?)."),{code:1,installed:[],skipped:[]};const s=[],i=[];for(const a of A(o)){const w=l(n,u,a);m(l(o,a),w,t)?s.push(a):i.push(a)}const h=$(e,l(n,u))||u;return s.length>0&&r.logger.success(`Installed ${String(s.length)} Lunora skill(s) into ${h}/: ${s.join(", ")}.`),i.length>0&&r.logger.info(`Skipped ${String(i.length)} existing skill(s) (re-run with --overwrite to replace): ${i.join(", ")}.`),r.logger.info("Your AI coding agent will pick these up automatically. Start with the `lunora` skill."),{code:0,installed:s,skipped:i}},E=r=>{const e=r.cwd??process.cwd(),n=f(e,r.dir),t=L(n);return t.installed?(r.logger.success(`Lunora agent rules are installed (${String(t.present.length)}/${String(R.length)} skills).`),t.missing.length>0&&r.logger.info(`Missing: ${t.missing.join(", ")}. Run \`lunora rules install\` to add them.`),{code:0,installed:t.present,skipped:[]}):(r.logger.warn("Lunora agent rules are not installed. Run `lunora rules install` so your AI agent knows how to use Lunora."),{code:r.strict===!0?1:0,installed:t.present,skipped:[]})},M=I(({argument:r,cwd:e,logger:n,options:t})=>{const o=r[0]??"check";return o==="install"?D({cwd:e,dir:t.dir,logger:n,overwrite:t.overwrite===!0}):o==="check"?E({cwd:e,dir:t.dir,logger:n,strict:t.strict===!0}):(n.error("rules: unknown subcommand. Usage: lunora rules <install|check>"),{code:1})});export{M as execute,b as resolveBundledSkillsDirectory,E as runRulesCheck,D as runRulesInstall};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{existsSync as y}from"node:fs";import{mkdtemp as S,writeFile as v,rm as
|
|
1
|
+
import{existsSync as y}from"node:fs";import{mkdtemp as S,writeFile as v,rm as $}from"node:fs/promises";import{tmpdir as j}from"node:os";import{discoverSchema as k,schemaFromIr as C}from"@lunora/codegen";import{seedPlan as x}from"@lunora/seed";import{join as m}from"@visulima/path";import{Project as z}from"ts-morph";import{d as F}from"../packem_shared/admin-token-BKmc3AUm.mjs";import{i as I}from"../packem_shared/command-0l-ZPhIX.mjs";import{d as R}from"../packem_shared/resolve-target-CeiNrCAx.mjs";import{o as T}from"../packem_shared/tui-prompts-BU3irGxV.mjs";import{runResetCommand as A}from"./runResetCommand.mjs";import{runImportCommand as N}from"../packem_shared/DEFAULT_IMPORT_BATCH_SIZE-C4qrFAn_.mjs";const p=r=>r===""?!1:F(r),B=(r,e)=>typeof e=="bigint"?Number(e):e instanceof ArrayBuffer?[...new Uint8Array(e)]:e,c=r=>({code:r,conflicts:0,generated:0,inserted:0,ndjson:""}),P=(r,e)=>{if(!y(e))return r.logger.error(`schema not found: ${e} — run \`vis generate lunora-table --name=<name>\` to create one`),c(1);if(r.reset===!0&&(r.prod===!0||!p(r.url)))return r.logger.error("--reset only clears local .wrangler/state and cannot be combined with --prod or a remote --url"),c(1)},U=async(r,e,o,t)=>{const l=await S(m(j(),"lunora-seed-")),a=m(l,"rows.ndjson");await v(a,r,"utf8");try{const n=await N({batchSize:t.batchSize,cwd:o,fetchImpl:t.fetchImpl,file:a,logger:t.logger,prod:t.prod,token:t.token,url:t.url}),d=n.body?.conflicts??0;return d>0&&t.logger.warn(`${String(d)} 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:n.code,conflicts:d,generated:e,inserted:n.inserted,ndjson:r}}finally{await $(l,{force:!0,recursive:!0}).catch(()=>{})}},_=(r,e)=>{if(r.table===void 0||e.tables.some(t=>t.name===r.table))return;const o=e.tables.map(t=>t.name).join(", ");return r.logger.error(`unknown table "${r.table}" — schema defines: ${o||"(no tables)"}`),c(1)},H=async(r,e)=>{if(!(!(r.prod===!0||!p(r.url))||r.yes===!0)){if(!process.stdin.isTTY&&r.confirm===void 0)return r.logger.error("seed: refusing to insert into a non-local target without confirmation — re-run with --yes"),c(1);if(!await(r.confirm??T)(`This will insert ${String(e)} generated row(s) into ${r.url??"the production worker"}. Continue?`))return r.logger.info("seed: aborted"),c(1)}},J=async r=>{const e=r.cwd??process.cwd(),o=m(e,"lunora","schema.ts"),t=P(r,o);if(t!==void 0)return t;const l=new z({skipAddingFilesFromTsConfig:!0}),a=k(l,o),n=_(r,a);if(n!==void 0)return n;const d=C(a),g=x(d,{defaultCount:r.count??10,now:r.now,only:r.table===void 0?void 0:[r.table],seed:r.seed??0}),u=[];for(const{rows:f,table:h}of g)for(const b of f)u.push(JSON.stringify({doc:b,table:h},B));const i=u.length>0?`${u.join(`
|
|
2
2
|
`)}
|
|
3
|
-
`:"",s=u.length;if(r.dryRun===!0)return i.length>0&&process.stdout.write(i),r.logger.info(`generated ${String(s)} row(s) across ${String(g.length)} table(s) — dry run, nothing inserted`),{code:0,conflicts:0,generated:s,inserted:0,ndjson:i};if(r.reset===!0){const f=await
|
|
3
|
+
`:"",s=u.length;if(r.dryRun===!0)return i.length>0&&process.stdout.write(i),r.logger.info(`generated ${String(s)} row(s) across ${String(g.length)} table(s) — dry run, nothing inserted`),{code:0,conflicts:0,generated:s,inserted:0,ndjson:i};if(r.reset===!0){const f=await A({cwd:e,logger:r.logger,yes:!0});if(f.code!==0)return{code:f.code,conflicts:0,generated:s,inserted:0,ndjson:i}}if(s===0)return r.logger.warn("no rows generated — nothing to insert"),{code:0,conflicts:0,generated:0,inserted:0,ndjson:i};const w=await H(r,s);return w!==void 0?w:U(i,s,e,r)},Z=I(async({cwd:r,logger:e,options:o})=>({code:(await J({batchSize:o.batchSize,count:o.count,cwd:r,dryRun:o.dryRun===!0,logger:e,prod:o.prod===!0,reset:o.reset===!0,now:o.now,seed:o.seed,table:o.table,token:o.token,url:R({cwd:r,prod:o.prod===!0,url:o.url}),yes:o.yes===!0})).code}));export{Z as execute,J as runSeedCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as p}from"node:fs";import{join as m}from"node:path";import{runCodegen as w}from"@lunora/codegen";import{r as u}from"../packem_shared/api-spec-BENwiyUa.mjs";import{c as y}from"../packem_shared/codegen-error-DJN6pTH5.mjs";import{i as v}from"../packem_shared/command-
|
|
1
|
+
import{existsSync as p}from"node:fs";import{join as m}from"node:path";import{runCodegen as w}from"@lunora/codegen";import{r as u}from"../packem_shared/api-spec-BENwiyUa.mjs";import{c as y}from"../packem_shared/codegen-error-DJN6pTH5.mjs";import{i as v}from"../packem_shared/command-0l-ZPhIX.mjs";import{i as S}from"../packem_shared/deploy-target-Dvr9vxpR.mjs";import{M as $,l as j}from"../packem_shared/detect-package-manager-DXDstphE.mjs";import{i as k,t as P,d as U,s as x}from"../packem_shared/output-format-Cv3aLqhP.mjs";import{R as E}from"../packem_shared/schema-drift-gate-d12lMICD.mjs";import{defaultSpawner as b}from"../packem_shared/createRecordingSpawner-SKs4R1fc.mjs";import{validateWranglerProject as D}from"@lunora/config/cloudflare";const R=async(r,o)=>{if(!p(m(r,"tsconfig.json")))return{warning:"no tsconfig.json found — skipping TypeScript type-check"};const e=$(j(r),"tsc",["--noEmit","-p","tsconfig.json"]),t=await o({args:e.args,command:e.command,cwd:r});return t.code===0?{}:{error:`type errors: tsc --noEmit exited ${String(t.code)}`}},T="/_lunora/health",d=r=>(r.endsWith("/")?r.slice(0,-1):r)+T,C=async(r,o)=>{const e=d(r);let t;try{t=await o(e)}catch(a){const i=a instanceof Error?a.message:String(a);return{error:`health probe failed: could not reach ${e} (${i})`}}return t.ok?{}:{error:`health probe failed: ${e} returned HTTP ${String(t.status)}`}},W=async(r,o)=>{if(r.healthUrl===void 0||r.healthUrl==="")return;const e=await C(r.healthUrl,r.healthFetch??(t=>fetch(t)));if(e.error===void 0){o.success(`verify: health probe ok (${d(r.healthUrl)})`);return}return e.error},A=(r,o,e,t)=>{if(o.length===0&&e.length===0)return r.success("verify: project is valid"),{code:0,errors:[],warnings:[],wranglerPath:t};if(e.length>0){r.warn("verify: warnings:");for(const a of e)r.warn(` - ${a}`)}if(o.length>0){r.error("verify: errors:");for(const a of o){r.error(` - ${a}`);const i=y(a);i!==void 0&&r.error(i)}return{code:1,errors:o,warnings:e,wranglerPath:t}}return r.success("verify: project is valid (with warnings)"),{code:0,errors:[],warnings:e,wranglerPath:t}},F=async r=>{const o=r.cwd??process.cwd(),e=x(r.format,r.logger),t=k("verify",r.format);if(t!==void 0)return r.logger.error(t),{code:1,error:t,errors:[],warnings:[],wranglerPath:void 0};const a=D({projectRoot:o}),i=[...a.report.errors],l=[...a.report.warnings];try{const n=S(o,r.target);if(n.target===void 0){const c=n.error??"unknown deploy target";return e.error(c),{code:1,error:c,errors:[c],warnings:[],wranglerPath:void 0}}const s=w({apiSpec:r.apiSpec,dryRun:!0,projectRoot:o,target:n.target}),h=E({allowDrift:r.allowSchemaDrift===!0,codegen:s,command:"verify",logger:e,readOnly:!0});h.blocked&&i.push(h.reason)}catch(n){const s=n instanceof Error?n.message:String(n);i.push(`codegen failed: ${s}`)}if(r.typecheck!==!1){const n=await R(o,r.spawner??b);n.error!==void 0&&i.push(n.error),n.warning!==void 0&&l.push(n.warning)}const f=await W(r,e);f!==void 0&&i.push(f);const g=A(e,i,l,a.wranglerPath);return P(r.format)&&U(g),g},L=v(async({cwd:r,logger:o,options:e})=>({code:(await F({allowSchemaDrift:e.allowSchemaDrift===!0,apiSpec:u(e.apiSpec),cwd:r,format:e.format,healthUrl:e.healthUrl,logger:o,target:e.target,typecheck:e.typecheck===!1?!1:void 0})).code}));export{L as execute,F as runVerifyCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{mkdtempSync as p,rmSync as l,existsSync as c,readdirSync as u,statSync as y}from"node:fs";import{tmpdir as g}from"node:os";import{join as f,relative as m}from"node:path";import{i as $}from"../packem_shared/command-
|
|
1
|
+
import{mkdtempSync as p,rmSync as l,existsSync as c,readdirSync as u,statSync as y}from"node:fs";import{tmpdir as g}from"node:os";import{join as f,relative as m}from"node:path";import{i as $}from"../packem_shared/command-0l-ZPhIX.mjs";import{M as S,l as z}from"../packem_shared/detect-package-manager-DXDstphE.mjs";import{defaultSpawner as B}from"../packem_shared/createRecordingSpawner-SKs4R1fc.mjs";const w=t=>{const r=[],e=i=>{for(const o of u(i)){const s=f(i,o),n=y(s);n.isDirectory()?e(s):n.isFile()&&r.push({path:m(t,s),sizeBytes:n.size})}};return e(t),r},d=t=>t<1024?`${String(t)} B`:t<1024*1024?`${(t/1024).toFixed(1)} KiB`:`${(t/(1024*1024)).toFixed(2)} MiB`,h=t=>{const r=w(t),e=r.toSorted((o,s)=>s.sizeBytes-o.sizeBytes),i=r.reduce((o,s)=>o+s.sizeBytes,0);return{generatedFiles:r.filter(o=>o.path.includes("_generated")),outdir:t,topModules:e.slice(0,10),totalBytes:i,totalFiles:r.length}},F=(t,r)=>{if(r.info(`outdir: ${t.outdir}`),r.info(`total: ${String(t.totalFiles)} files, ${d(t.totalBytes)}`),t.topModules.length>0){r.info(""),r.info("top modules by size:");for(const e of t.topModules)r.info(` ${d(e.sizeBytes).padStart(10," ")} ${e.path}`)}if(t.generatedFiles.length>0){r.info(""),r.info(`_generated/ files: ${String(t.generatedFiles.length)}`);for(const e of t.generatedFiles)r.info(` ${d(e.sizeBytes).padStart(10," ")} ${e.path}`)}},v=async t=>{const r=t.cwd??process.cwd(),{logger:e}=t;let i,o,s=!1;if(t.inspectOnly)i=t.inspectOnly;else{i=p(f(g(),"lunora-analyze-")),s=!0;const n=S(z(r),"wrangler",["deploy","--dry-run","--outdir",i]);o={args:n.args,command:n.command,cwd:r},e.info(`analyze: building via ${o.command} ${o.args.join(" ")}`);const a=await(t.spawner??B)(o);if(a.code!==0)return e.error(`analyze: wrangler dry-run failed (exit ${String(a.code)})`),l(i,{force:!0,recursive:!0}),{code:a.code,descriptor:o,report:void 0}}try{if(!c(i))return e.error(`analyze: outdir not found at ${i}`),{code:1,descriptor:o,report:void 0};const n=h(i);return t.json?process.stdout.write(`${JSON.stringify(n,void 0,2)}
|
|
2
2
|
`):F(n,e),{code:0,descriptor:o,report:n}}finally{if(s&&c(i))try{l(i,{force:!0,recursive:!0})}catch{}}},k=$(({cwd:t,logger:r,options:e})=>v({cwd:t,json:e.json===!0,logger:r}));export{k as execute,v as runAnalyzeCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFileSync as u,existsSync as l}from"node:fs";import{join as p}from"node:path";import{parse as a}from"jsonc-parser";import{i as m}from"../packem_shared/command-
|
|
1
|
+
import{readFileSync as u,existsSync as l}from"node:fs";import{join as p}from"node:path";import{parse as a}from"jsonc-parser";import{i as m}from"../packem_shared/command-0l-ZPhIX.mjs";import{f as g}from"../packem_shared/open-url-zbbAo_D7.mjs";const c=8787,i="/_lunora/studio",d=e=>{for(const t of["wrangler.jsonc","wrangler.json"]){const r=p(e,t);if(l(r))return r}},y=e=>{const t=d(e);if(t)try{const r=a(u(t,"utf8"));return r!==null&&typeof r=="object"?r:void 0}catch{return}},w=e=>{if(!e)return c;const{dev:t}=e;if(t!==null&&typeof t=="object"){const{port:r}=t;if(typeof r=="number"&&Number.isFinite(r))return r}return c},h=e=>{if(!e)return;const{routes:t}=e;if(Array.isArray(t)&&t.length>0){const n=t[0];if(typeof n=="string")return`https://${n.split("/")[0]??n}${i}`;if(n!==null&&typeof n=="object"){const{pattern:o}=n;if(typeof o=="string"&&o.length>0)return`https://${o.split("/")[0]??o}${i}`}}const{name:r}=e;if(typeof r=="string"&&r.length>0)return`https://${r}.workers.dev${i}`},$=async e=>{const t=e.cwd??process.cwd(),r=y(t),{logger:n}=e;let o;if(e.remote){if(o=h(r),!o)return n.error("view --remote: could not determine the remote URL from wrangler config (set `routes` or `name`)."),{code:1,url:void 0}}else o=`http://localhost:${String(w(r))}${i}`;n.info(`opening ${o}`);try{await g(o,{opener:e.opener})}catch(s){const f=s instanceof Error?s.message:String(s);return n.error(`view: failed to open URL: ${f}`),{code:1,url:o}}return{code:0,url:o}},R=m(({cwd:e,logger:t,options:r})=>$({cwd:e,logger:t,remote:r.remote===!0}));export{R as execute,$ as runViewCommand};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{writeFileSync as
|
|
1
|
+
import{writeFileSync as h,existsSync as v,readFileSync as S}from"node:fs";import{isAbsolute as w,join as b}from"node:path";import{byCodepoint as y,scoreAdvisor as x,parseAdvisorMap as j,compareToBaseline as R}from"@lunora/advisor";import{runCodegen as k}from"@lunora/codegen";import{i as A}from"../packem_shared/command-0l-ZPhIX.mjs";import{i as D,d as M,s as F,t as N}from"../packem_shared/output-format-Cv3aLqhP.mjs";import{o as g}from"../packem_shared/cli-C-iz79JI.mjs";const l={clean:"·",exempt:"–",failing:"✗",warned:"!"},u=(r,e)=>r.length>=e?r:r+" ".repeat(e-r.length),C=r=>`${r.id} (${r.visibility} ${r.kind})`,m=r=>{let e=0;for(const o of r)e=Math.max(e,o.id.length);return e},p=(r,e)=>` ${u(String(r.score),3)} ${l[r.coverage]} ${u(r.id,e)} ${r.visibility} ${r.kind}`,E=r=>{if(!r.comparable)return[` baseline not comparable (${r.reason}) — regenerate it; this run cannot verify anything`];if(!r.regressed)return[` no regression against baseline (score ${r.scoreDelta>=0?"+":""}${String(r.scoreDelta)})`];const e=[` REGRESSED against baseline (score ${r.scoreDelta>=0?"+":""}${String(r.scoreDelta)})`];for(const o of r.dropped)e.push(` ${o.id}: ${String(o.before)} → ${String(o.after)}`);for(const o of r.newFailing)e.push(` ${o}: now failing`);for(const o of r.worsened)e.push(` ${o}: more findings than the baseline`);return r.projectRegressed&&e.push(" project: new schema/config rules fired"),e},J=(r,e)=>{const o=r.procedures.filter(i=>i.coverage!=="clean"&&i.coverage!=="exempt"),n=m(o),t=[`advisor health ${String(r.score)}/100 — ${r.grade}`,` ${String(r.summary.clean)} clean · ${String(r.summary.warned)} warned · ${String(r.summary.failing)} failing · ${String(r.summary.exempt)} exempt (${String(r.summary.procedures)} procedures, ${String(r.summary.rulesFired)} rules fired)`];return r.project.checks.length>0&&t.push("",` project ${String(r.project.score)}/100 — ${r.project.checks.map(i=>i.name).join(", ")}`),o.length>0&&t.push("",...o.map(i=>p(i,n)),""," run with --all for every procedure, or --entry <file#export> for one"),e!==void 0&&t.push("",...E(e)),t.join(`
|
|
2
2
|
`)},O=r=>r.coverage==="exempt"?[` exempt: ${r.exemptReason===void 0||r.exemptReason===""?"no reason given":r.exemptReason}`]:r.checks.map(e=>{const o=e.occurrences>1?`, ×${String(e.occurrences)}`:"";return` ${e.name} (−${String(e.weight)}${o})`}),B=r=>{const e=new Map;for(const o of r){const n=e.get(o.file);n===void 0?e.set(o.file,[o]):n.push(o)}return[...e].toSorted(([o],[n])=>y(o,n))},P=r=>{const e=m(r.procedures),o=[`advisor health ${String(r.score)}/100 — ${r.grade}`,"",` legend: ${l.clean} clean ${l.warned} warned ${l.failing} failing ${l.exempt} exempt`];for(const[n,t]of B(r.procedures)){o.push("",` ${n}`);for(const i of t)o.push(p(i,e),...O(i))}return o.join(`
|
|
3
3
|
`)},T=(r,e)=>{const o=r.procedures.find(t=>t.id===e);if(o===void 0){const t=r.procedures.slice(0,10).map(i=>` ${i.id}`);return[`no procedure ${e} in the map. Known ids:`,...t,r.procedures.length>10?" …":""].filter(Boolean).join(`
|
|
4
4
|
`)}const n=[`${C(o)} — ${String(o.score)}/100, ${o.coverage}`,` weight in the global mean: ${String(o.weight)}`];if(o.checks.length===0)return n.push(""," no rule fired"),n.join(`
|
|
5
5
|
`);n.push(""," rules fired:");for(const t of o.checks)n.push(` [${t.level}] ${t.name} −${String(t.weight)}${t.occurrences>1?` (×${String(t.occurrences)})`:""}`);return n.join(`
|
|
6
|
-
`)},q=new Date(0).toISOString(),f=(r,e)=>w(e)?e:b(r,e),G=r=>{if(r===void 0)return{value:void 0};if(r===null||r==="")return{error:"--min-score needs a value between 0 and 100"};const e=Number(r);return Number.isFinite(e)&&e>=0&&e<=100?{value:e}:{error:"--min-score must be a number between 0 and 100"}},H=(r,e,o)=>{const n=f(e,o===null||o===""?g:o);if(!v(n))return{error:`baseline not found at ${n} — generate one with \`lunora advisor\` and commit it`};const t=j(JSON.parse(S(n,"utf8")));return t===void 0?{error:`baseline at ${n} is malformed — regenerate it with \`lunora advisor\``}:{comparison:R(r,t)}},I=r=>`baseline is not comparable (${r}) — regenerate it; this run verified nothing`,K=(r,e,o)=>e.entry!==void 0?T(r,e.entry):e.all===!0?P(r):J(r,o),L=r=>{const e=r.cwd??process.cwd(),o=N(r.format),n=F(r.format,r.logger),t=D("advisor",r.format);if(t!==void 0)return r.logger.error(t),{error:t};const i=G(r.minScore);if("error"in i)return r.logger.error(i.error),{error:i.error};const{advisorContext:d,advisories
|
|
6
|
+
`)},q=new Date(0).toISOString(),f=(r,e)=>w(e)?e:b(r,e),G=r=>{if(r===void 0)return{value:void 0};if(r===null||r==="")return{error:"--min-score needs a value between 0 and 100"};const e=Number(r);return Number.isFinite(e)&&e>=0&&e<=100?{value:e}:{error:"--min-score must be a number between 0 and 100"}},H=(r,e,o)=>{const n=f(e,o===null||o===""?g:o);if(!v(n))return{error:`baseline not found at ${n} — generate one with \`lunora advisor\` and commit it`};const t=j(JSON.parse(S(n,"utf8")));return t===void 0?{error:`baseline at ${n} is malformed — regenerate it with \`lunora advisor\``}:{comparison:R(r,t)}},I=r=>`baseline is not comparable (${r}) — regenerate it; this run verified nothing`,K=(r,e,o)=>e.entry!==void 0?T(r,e.entry):e.all===!0?P(r):J(r,o),L=r=>{const e=r.cwd??process.cwd(),o=N(r.format),n=F(r.format,r.logger),t=D("advisor",r.format);if(t!==void 0)return r.logger.error(t),{error:t};const i=G(r.minScore);if("error"in i)return r.logger.error(i.error),{error:i.error};const{advisorContext:d,advisories:$}=k({dryRun:!0,projectRoot:e});if(d===void 0){const s="advisor evidence unavailable — codegen ran with linting disabled";return r.logger.error(s),{error:s}}const c=x(d.procedureProtections??[],$,{generatedAt:r.generatedAt??q}),a={map:c};if(r.baseline!==void 0){const s=H(c,e,r.baseline);if("error"in s)return r.logger.error(s.error),{...a,error:s.error};a.comparison=s.comparison,s.comparison.comparable||r.logger.error(I(s.comparison.reason))}if(r.write!==!1){const s=f(e,r.out??g);h(s,`${JSON.stringify(c,void 0,4)}
|
|
7
7
|
`,"utf8"),a.written=s}return a.belowMinScore=i.value!==void 0&&c.score<i.value,a.belowMinScore&&n.error(`advisor score ${String(c.score)} is below the required ${String(i.value)}`),o?(M(a),a):(n.info(K(c,r,a.comparison)),a.written!==void 0&&n.success(`wrote ${a.written}`),a)},z=r=>r.error!==void 0||r.belowMinScore===!0?!0:r.comparison!==void 0&&(!r.comparison.comparable||r.comparison.regressed),_=A(({cwd:r,logger:e,options:o})=>{const n=L({all:o.all,baseline:o.baseline,cwd:r,entry:o.entry,format:o.format,logger:e,minScore:o.minScore,out:o.out,write:o.write});return{code:z(n)?1:0}});export{_ as execute,L as runAdvisorCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{readLinkedProject as g,resolveDeployDriver as p}from"@lunora/config";import{i as f}from"../packem_shared/command-
|
|
1
|
+
import{readLinkedProject as g,resolveDeployDriver as p}from"@lunora/config";import{i as f}from"../packem_shared/command-0l-ZPhIX.mjs";import{M as v,l as h}from"../packem_shared/detect-package-manager-DXDstphE.mjs";import{defaultSpawner as b}from"../packem_shared/createRecordingSpawner-SKs4R1fc.mjs";import{createR2Sql as w}from"@lunora/bindings/r2sql";import{createPipelineLogReader as y}from"@lunora/runtime";const S=new Set(["debug","error","fatal","info","log","trace","warn"]),u=/^\d+$/,c=(r,o)=>{if(r===void 0)return;const t=r.trim();if(u.test(t))return Number(t);const e=Date.parse(t);if(Number.isNaN(e))throw new TypeError(`logs: invalid ${o} "${r}" — pass epoch-millis or an ISO 8601 date`);return e},_=r=>Buffer.from(JSON.stringify(r),"utf8").toString("base64url"),$=r=>{const o=r.trim();if(u.test(o))return{ts:Number(o)};let t;try{t=JSON.parse(Buffer.from(o,"base64url").toString("utf8"))}catch{throw new TypeError(`logs: invalid --cursor "${r}" — expected the token printed by the previous page (or a bare epoch-millis ts)`)}if(typeof t!="object"||t===null||typeof t.ts!="number"||!Number.isFinite(t.ts))throw new TypeError(`logs: invalid --cursor "${r}" — expected the token printed by the previous page (or a bare epoch-millis ts)`);const{ts:e}=t,i=t.seen,n=Array.isArray(i)?i.filter(s=>typeof s=="string"):void 0;return n!==void 0&&n.length>0?{seen:n,ts:e}:{ts:e}},d=(r,o)=>{if(r!==void 0){if(!S.has(r))throw new TypeError(`logs: invalid ${o} "${r}" — expected one of trace, debug, log, info, warn, error, fatal`);return r}},L=r=>{const o={},t=c(r.since,"--since");t!==void 0&&(o.sinceTs=t);const e=c(r.until,"--until");e!==void 0&&(o.untilTs=e);const i=d(r.level,"--level");i!==void 0&&(o.level=i);const n=d(r.minLevel,"--min-level");if(n!==void 0&&(o.minLevel=n),r.functionPrefix!==void 0&&(o.functionPathPrefix=r.functionPrefix),r.traceId!==void 0&&(o.traceId=r.traceId),r.shardKey!==void 0&&(o.shardKey=r.shardKey),r.userId!==void 0&&(o.userId=r.userId),r.limit!==void 0){const s=Number(r.limit);if(!Number.isFinite(s))throw new TypeError(`logs: invalid --limit "${r.limit}" — expected a number`);o.limit=s}return r.cursor!==void 0&&(o.cursor=$(r.cursor)),o},T=r=>{const o=new Date(r.ts).toISOString(),t=r.level.toUpperCase().padEnd(5);return`${o} ${t} ${r.functionPath} ${r.message}`},I=async r=>{const o=r.environment??process.env,t=o.R2_SQL_ACCOUNT_ID,e=o.R2_SQL_TOKEN,i=o.R2_SQL_BUCKET,n=[];if((t===void 0||t.length===0)&&n.push("R2_SQL_ACCOUNT_ID"),(e===void 0||e.length===0)&&n.push("R2_SQL_TOKEN"),(i===void 0||i.length===0)&&n.push("R2_SQL_BUCKET"),(r.table===void 0||r.table.length===0)&&n.push("--table"),n.length>0)return r.logger.error(`logs --durable: R2 SQL not configured (missing ${n.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:1,error:"not configured"};let s;try{s=L(r)}catch(a){return r.logger.error(a instanceof Error?a.message:String(a)),{code:1,error:"invalid option"}}const m=w({accountId:t,apiToken:e,bucket:i,fetch:r.fetch}),l=await y(m,{namespace:r.namespace,table:r.table}).query(s);for(const a of l.rows)process.stdout.write(`${r.ndjson===!0?JSON.stringify(a):T(a)}
|
|
2
2
|
`);return l.rows.length===0?r.logger.info("logs --durable: no matching log records"):l.nextCursor!==void 0&&r.logger.info(`logs --durable: more rows available — pass --cursor ${_(l.nextCursor)} for the next page`),{code:0,rows:l.rows}},N=new Set(["json","pretty"]),x=async r=>{const o=r.cwd??process.cwd();if(r.format!==void 0&&!N.has(r.format))return r.logger.error(`logs: unknown --format "${r.format}" — expected pretty | json`),{code:1,descriptor:void 0,error:"invalid format"};const t=r.env??g(o)?.env,e=p(r.target);if(e.toolchain===void 0)return r.logger.error(`logs: deploy target "${e.id}" has no command-line toolchain`),{code:1,descriptor:void 0,error:"no toolchain"};const i=e.toolchain.tail({environment:t,format:r.format,search:r.search,status:r.status,temporary:r.temporary,worker:r.worker}),n=v(h(o),i.tool,i.args),s={args:n.args,command:n.command,cwd:o};return r.logger.info(`tailing logs via ${s.command} ${s.args.join(" ")}`),{code:(await(r.spawner??b)(s)).code,descriptor:s}},Q=f(({argument:r,cwd:o,logger:t,options:e})=>e.durable===!0?I({cursor:e.cursor,functionPrefix:e.functionPrefix,level:e.level,limit:e.limit,logger:t,minLevel:e.minLevel,namespace:e.namespace,ndjson:e.ndjson===!0,shardKey:e.shardKey,since:e.since,table:e.table,traceId:e.traceId,until:e.until,userId:e.userId}):x({cwd:o,env:e.env,format:e.format,logger:t,search:e.search,status:e.status,target:e.target,temporary:e.temporary===!0,worker:r[0]}));export{Q as execute,x as runLogsCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readdirSync as E,lstatSync as x,existsSync as N}from"node:fs";import{join as p,basename as R}from"node:path";import{pathToFileURL as b}from"node:url";import{i as F}from"../packem_shared/command-
|
|
1
|
+
import{readdirSync as E,lstatSync as x,existsSync as N}from"node:fs";import{join as p,basename as R}from"node:path";import{pathToFileURL as b}from"node:url";import{i as F}from"../packem_shared/command-0l-ZPhIX.mjs";import{i as O,t as g,d as v,s as T}from"../packem_shared/output-format-Cv3aLqhP.mjs";const h=".eval.ts",_=new Set([".git","_generated","dist","node_modules"]),$=(r,o=[])=>{let e;try{e=E(r)}catch{return o}for(const t of e){const n=p(r,t);let s;try{s=x(n)}catch{continue}if(s.isDirectory()){if(_.has(t))continue;$(n,o)}else s.isFile()&&t.endsWith(h)&&o.push(n)}return o.toSorted((t,n)=>t.localeCompare(n))},A=r=>typeof r=="object"&&r!==null&&typeof r.run=="function",S=r=>typeof r=="number"&&Number.isFinite(r)&&r>=0&&r<=1,C="evals",I='"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)',L=/unknown file extension ".ts"/i,y=r=>r instanceof Error?r.code==="ERR_UNKNOWN_FILE_EXTENSION"?!0:L.test(r.message):!1,m=r=>R(r,h),U=r=>({average:r.result?.average,error:r.error,items:r.result?.items,name:r.name,passed:r.passed,path:r.path,threshold:r.threshold}),w=r=>({code:r.code,error:r.error,evals:r.evals.map(o=>U(o))}),l=(r,o,e)=>{r.error(e);const t={code:1,error:e,evals:[]};return g(o)&&v(w(t)),t},k=(r,o,e)=>{if(!N(r))return e.info(`eval: no "${o}" directory — nothing to run`),[];const t=$(r);return t.length===0&&e.info(`eval: no ${h} files found under "${o}"`),t},D=async r=>{const o=(await import(b(r).href)).default;if(!A(o))throw new Error("does not default-export an eval module (expected `{ run(): Promise<EvalResult>, name?, threshold? }`)");return o},H=async(r,o)=>{let e;try{e=await D(r)}catch(s){if(y(s))throw s;return{error:s instanceof Error?s.message:String(s),name:m(r),passed:!1,path:r}}const t=e.name??m(r);if(e.threshold!==void 0&&!S(e.threshold))return{error:`invalid \`threshold\` export: must be a number in [0, 1] — received ${JSON.stringify(e.threshold)}`,name:t,passed:!1,path:r};const n=e.threshold??o;try{const s=await e.run(),d=n===void 0||s.average>=n;return{name:t,passed:d,path:r,result:s,threshold:n}}catch(s){return{error:s instanceof Error?s.message:String(s),name:t,passed:!1,path:r,threshold:n}}},M=async(r,o)=>{const e=[];for(const t of r)e.push(await H(t,o));return e},j=r=>{if(r.error!==void 0)return`ERROR: ${r.error}`;const o=r.passed?"pass":"FAIL",e=r.result?.items.length??0;return`${o} (${String(e)} cases)`},J=r=>{if(r.length===0)return[];const o=Math.max(4,...r.map(t=>t.name.length)),e=[`${"NAME".padEnd(o)} SCORE THRESHOLD STATUS`];for(const t of r){const n=t.result===void 0?"—":t.result.average.toFixed(3),s=t.threshold===void 0?"—":t.threshold.toFixed(3);e.push(`${t.name.padEnd(o)} ${n.padEnd(6)} ${s.padEnd(9)} ${j(t)}`)}return e},W=async r=>{const o=r.cwd??process.cwd(),e=T(r.format,r.logger),t=O("eval",r.format);if(t!==void 0)return r.logger.error(t),{code:1,error:t,evals:[]};if(r.threshold!==void 0&&!S(r.threshold))return l(e,r.format,`eval: --threshold must be a number in [0, 1] — received "${String(r.threshold)}"`);const n=r.dir??C,s=p(o,n),d=k(s,n,e);let i;try{i=await M(d,r.threshold)}catch(a){if(!y(a))throw a;return l(e,r.format,I)}if(r.threshold!==void 0&&i.length===0){const a=`eval: --threshold ${String(r.threshold)} was set but 0 eval files were discovered under "${n}" — nothing was gated`;return l(e,r.format,a)}for(const a of J(i))e.info(a);const c=i.filter(a=>!a.passed),u=c.length>0?1:0;u===0?e.success(`eval: ${String(i.length)} eval(s) passed`):e.error(`eval: ${String(c.length)}/${String(i.length)} eval(s) failed`);const f={code:u,evals:i};return g(r.format)&&v(w(f)),f},B=F(async({cwd:r,logger:o,options:e})=>({code:(await W({cwd:r,dir:e.dir,format:e.format,logger:o,threshold:e.threshold})).code}));export{B as execute,W as runEvalCommand};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as T,readFileSync as O}from"node:fs";import{writeFile as x,mkdir as D}from"node:fs/promises";import{join as v}from"@visulima/path";import{i as B}from"../packem_shared/command-
|
|
1
|
+
import{existsSync as T,readFileSync as O}from"node:fs";import{writeFile as x,mkdir as D}from"node:fs/promises";import{join as v}from"@visulima/path";import{i as B}from"../packem_shared/command-0l-ZPhIX.mjs";import{createRequire as q}from"node:module";import{LunoraError as w}from"@lunora/errors";import{P as U,l as F}from"../packem_shared/detect-package-manager-DXDstphE.mjs";import{parseSchema as Y,applyAdditiveEdit as j}from"@lunora/config";const H=/^\//,J=(e,n)=>{try{const{args:t,command:a}=U(F(e),[n],{dev:!0});return`${a} ${t.join(" ")}`}catch{return`<your-package-manager> add -D ${n}`}},R=(e,n,t)=>{const a=q(v(t,"noop.cjs"));try{a.resolve(e)}catch{throw new w("INTERNAL",`\`lunora introspect\` needs the \`${n}\` driver to read this database, and it isn't installed.
|
|
2
2
|
|
|
3
3
|
Install it in your project:
|
|
4
4
|
|