@lunora/cli 1.0.0-alpha.457 → 1.0.0-alpha.458

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.
@@ -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-B6vu47iR.mjs";import{EXIT_CODE as u}from"../packem_shared/EXIT_CODE-DVjUgIaG.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 E,lstatSync as S,existsSync as y}from"node:fs";import{join as m,basename as $}from"node:path";import{d as w}from"../packem_shared/command-B6vu47iR.mjs";import{EXIT_CODE as h}from"../packem_shared/EXIT_CODE-DVjUgIaG.mjs";const l=".eval.ts",F=new Set([".git","_generated","dist","node_modules"]),p=(e,s=[])=>{let r;try{r=E(e)}catch{return s}for(const t of r){const n=m(e,t);let o;try{o=S(n)}catch{continue}if(o.isDirectory()){if(F.has(t))continue;p(n,s)}else o.isFile()&&t.endsWith(l)&&s.push(n)}return s.toSorted((t,n)=>t.localeCompare(n))},b=e=>typeof e=="object"&&e!==null&&typeof e.run=="function",g=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1,R="evals";let u;const T=async()=>(u??=import("jiti").then(({createJiti:e})=>e(import.meta.url,{interopDefault:!1})),u),f=e=>$(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}),A=e=>({evals:e.evals.map(s=>x(s))}),v=(e,s,r)=>(e.error(s),{code:r,error:s,evals:[]}),L=(e,s,r)=>{if(!y(e))return r.info(`eval: no "${s}" directory — nothing to run`),[];const t=p(e);return t.length===0&&r.info(`eval: no ${l} files found under "${s}"`),t},I=async e=>{const t=(await(await T()).import(e)).default;if(!b(t))throw new Error("does not default-export an eval module (expected `{ run(): Promise<EvalResult>, name?, threshold? }`)");return t},O=async(e,s)=>{let r;try{r=await I(e)}catch(o){return{error:o instanceof Error?o.message:String(o),name:f(e),passed:!1,path:e}}const t=r.name??f(e);if(r.threshold!==void 0&&!g(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 n=r.threshold??s;try{const o=await r.run(),a=n===void 0||o.average>=n;return{name:t,passed:a,path:e,result:o,threshold:n}}catch(o){return{error:o instanceof Error?o.message:String(o),name:t,passed:!1,path:e,threshold:n}}},_=async(e,s)=>{const r=[];for(const t of e)r.push(await O(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 n=t.result===void 0?"—":t.result.average.toFixed(3),o=t.threshold===void 0?"—":t.threshold.toFixed(3);r.push(`${t.name.padEnd(s)} ${n.padEnd(6)} ${o.padEnd(9)} ${D(t)}`)}return r},M=async e=>{const s=e.cwd??process.cwd(),{logger:r}=e;if(e.threshold!==void 0&&!g(e.threshold))return v(r,`eval: --threshold must be a number in [0, 1] — received "${String(e.threshold)}"`,h.USAGE);const t=e.dir??R,n=m(s,t),o=L(n,t,r),a=await _(o,e.threshold);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 v(r,d,h.USAGE)}for(const d of C(a))r.info(d);const i=a.filter(d=>!d.passed),c=i.length>0?1:0;return c===0?r.success(`eval: ${String(a.length)} eval(s) passed`):r.error(`eval: ${String(i.length)}/${String(a.length)} eval(s) failed`),{code:c,evals:a}},N=w(async({cwd:e,format:s,logger:r,options:t})=>{const n=await M({cwd:e,dir:t.dir,format:s,logger:r,threshold:t.threshold});return{code:n.code,data:A(n),error:n.error}});export{N as execute,M as runEvalCommand};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/cli",
3
- "version": "1.0.0-alpha.457",
3
+ "version": "1.0.0-alpha.458",
4
4
  "description": "The Lunora CLI: init, dev, deploy, codegen, migrate, seed, doctor, insights, logs, registry, and the rest of the project commands",
5
5
  "keywords": [
6
6
  "agent-skills",
@@ -56,16 +56,16 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "@bomb.sh/tab": "0.0.22",
59
- "@lunora/advisor": "1.0.0-alpha.275",
60
- "@lunora/bindings": "1.0.0-alpha.142",
61
- "@lunora/codegen": "1.0.0-alpha.377",
62
- "@lunora/config": "1.0.0-alpha.432",
63
- "@lunora/container": "1.0.0-alpha.100",
64
- "@lunora/d1": "1.0.0-alpha.223",
59
+ "@lunora/advisor": "1.0.0-alpha.277",
60
+ "@lunora/bindings": "1.0.0-alpha.144",
61
+ "@lunora/codegen": "1.0.0-alpha.378",
62
+ "@lunora/config": "1.0.0-alpha.433",
63
+ "@lunora/container": "1.0.0-alpha.102",
64
+ "@lunora/d1": "1.0.0-alpha.224",
65
65
  "@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
66
66
  "@lunora/mcp": "1.0.0-alpha.278",
67
- "@lunora/runtime": "1.0.0-alpha.259",
68
- "@lunora/seed": "1.0.0-alpha.271",
67
+ "@lunora/runtime": "1.0.0-alpha.261",
68
+ "@lunora/seed": "1.0.0-alpha.272",
69
69
  "@visulima/cerebro": "4.0.1",
70
70
  "@visulima/error": "6.1.0",
71
71
  "@visulima/fs": "7.0.0",
@@ -77,6 +77,7 @@
77
77
  "adm-zip": "0.6.1",
78
78
  "csv-parse": "7.0.3",
79
79
  "giget": "3.3.1",
80
+ "jiti": "2.7.0",
80
81
  "jsonc-parser": "^3.3.1",
81
82
  "magic-string": "^1.4.2",
82
83
  "react": "^19.3.0",