@checksum-ai/runtime 4.4.2 → 4.5.0
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/.env +1 -1
- package/checksum-root/eslint.config.js +10 -1
- package/cli.js +1 -1
- package/package.json +1 -1
package/.env
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
CHECKSUM_RUNTIME_BUILD_TIME=2026-06-
|
|
1
|
+
CHECKSUM_RUNTIME_BUILD_TIME=2026-06-18T11:56:27.052Z
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
// ESLint 9+ flat config for Checksum Playwright tests
|
|
3
3
|
// Minimal and modern per typescript-eslint Quickstart + Playwright recommended
|
|
4
4
|
// Dev dependencies to add:
|
|
5
|
-
// npm i -D eslint @eslint/js typescript typescript-eslint @typescript-eslint/eslint-plugin eslint-plugin-playwright
|
|
5
|
+
// npm i -D eslint @eslint/js typescript typescript-eslint @typescript-eslint/eslint-plugin eslint-plugin-playwright @stylistic/eslint-plugin
|
|
6
6
|
|
|
7
7
|
import tseslint from "typescript-eslint";
|
|
8
|
+
import stylistic from "@stylistic/eslint-plugin";
|
|
8
9
|
|
|
9
10
|
export default tseslint.config(
|
|
10
11
|
// Project-specific options for typed linting
|
|
@@ -19,6 +20,7 @@ export default tseslint.config(
|
|
|
19
20
|
},
|
|
20
21
|
plugins: {
|
|
21
22
|
"@typescript-eslint": tseslint.plugin,
|
|
23
|
+
"@stylistic": stylistic,
|
|
22
24
|
},
|
|
23
25
|
rules: {
|
|
24
26
|
"@typescript-eslint/no-floating-promises": "error",
|
|
@@ -28,6 +30,13 @@ export default tseslint.config(
|
|
|
28
30
|
// lint if it (or any `eval` / `require`) is left in a committed test.
|
|
29
31
|
"no-eval": "error",
|
|
30
32
|
"@typescript-eslint/no-require-imports": "error",
|
|
33
|
+
// Formatting — kept intentionally minimal: only the two rules that caused
|
|
34
|
+
// real heal churn (single↔double quote flips, missing/extra semicolons).
|
|
35
|
+
// Auto-fixed by `eslint --fix`, so an agent's edit is normalized to this
|
|
36
|
+
// style instead of reflowing the file. `avoidEscape` keeps single quotes
|
|
37
|
+
// when the string contains a double quote (no ugly escaping).
|
|
38
|
+
"@stylistic/quotes": ["error", "double", { avoidEscape: true }],
|
|
39
|
+
"@stylistic/semi": ["error", "always"],
|
|
31
40
|
},
|
|
32
41
|
},
|
|
33
42
|
// Ignores
|
package/cli.js
CHANGED
|
@@ -860,7 +860,7 @@ Example:
|
|
|
860
860
|
`,s+="\x1B[G",s+=Rlr,this.write(s),this.rl.close()}};t(Smt,"ScreenManager");var Qme=Smt;var Imt=class Imt extends Promise{static withResolver(){let n,s;return{promise:new Promise((l,d)=>{n=l,s=d}),resolve:n,reject:s}}};t(Imt,"PromisePolyfill");var yBe=Imt;var Qlr=Na(require("path"),1);var JSn=globalThis.setImmediate;function zSn(){let i=Error.prepareStackTrace,n=[];try{Error.prepareStackTrace=(s,c)=>{let l=c.slice(1);return n=l,l},new Error().stack}catch{return n}return Error.prepareStackTrace=i,n}t(zSn,"getCallSites");function Tmt(i){let n=zSn();return t((c,l={})=>{let{input:d=process.stdin,signal:h}=l,b=new Set,T=new Llr.default;T.pipe(l.output??process.stdout);let k=Olr.createInterface({terminal:!0,input:d,output:T});T.mute();let F=new Qme(k),{promise:H,resolve:j,reject:X}=yBe.withResolver(),se=t(()=>X(new cBe),"cancel");if(h){let Ke=t(()=>X(new aBe({cause:h.reason})),"abort");if(h.aborted)return Ke(),Object.assign(H,{cancel:se});h.addEventListener("abort",Ke),b.add(()=>h.removeEventListener("abort",Ke))}b.add(Dlr((Ke,qe)=>{X(new Fme(`User force closed the prompt with ${Ke} ${qe}`))}));let pe=t(()=>X(new Fme("User force closed the prompt with SIGINT")),"sigint");return k.on("SIGINT",pe),b.add(()=>k.removeListener("SIGINT",pe)),elr(k,Ke=>{let qe=Mlr.AsyncResource.bind(()=>HJ.clearAll());k.on("close",qe),b.add(()=>k.removeListener("close",qe));let lt=t(()=>{let Ue=t(()=>F.checkCursorPos(),"checkCursorPos");k.input.on("keypress",Ue),b.add(()=>k.input.removeListener("keypress",Ue));let gt=null;Ke(()=>{var Jt;let Ot=!1;try{let Dt=i(c,Di=>{Ot?j(Di):gt={value:Di}});if(Dt===void 0){let Di=(Jt=n[1])==null?void 0:Jt.getFileName();throw Di&&!Di.startsWith("file://")&&(Di=Qlr.default.resolve(Di)),new Error(`Prompt functions must return a string.
|
|
861
861
|
at ${Di}`)}let[fn,$r]=typeof Dt=="string"?[Dt]:Dt;F.render(fn,$r),HJ.run()}catch(Dt){X(Dt)}if(Ot=!0,gt!==null){let{value:Dt}=gt;gt=null,j(Dt)}})},"startCycle");return"readableFlowing"in d?JSn(lt):lt(),Object.assign(H.then(Ue=>(HJ.clearAll(),Ue),Ue=>{throw HJ.clearAll(),Ue}).finally(()=>{b.forEach(Ue=>Ue()),F.done({clearContent:!!l.clearPromptOnDone}),T.end()}).then(()=>H),{cancel:se})})},"prompt")}t(Tmt,"createPrompt");var Ulr=require("util");var xmt=class xmt{separator=(0,Ulr.styleText)("dim",Array.from({length:15}).join($te.line));type="separator";constructor(n){n&&(this.separator=n)}static isSeparator(n){return!!(n&&typeof n=="object"&&"type"in n&&n.type==="separator")}};t(xmt,"Separator");var RD=xmt;var Vte=require("util");var WSn={icon:{cursor:$te.pointer},style:{disabled:t(i=>(0,Vte.styleText)("dim",i),"disabled"),description:t(i=>(0,Vte.styleText)("cyan",i),"description"),keysHelpTip:t(i=>i.map(([n,s])=>`${(0,Vte.styleText)("bold",n)} ${(0,Vte.styleText)("dim",s)}`).join((0,Vte.styleText)("dim"," \u2022 ")),"keysHelpTip")},i18n:{disabledError:"This option is disabled and cannot be selected."},indexMode:"hidden"};function wmt(i){return!RD.isSeparator(i)&&!i.disabled}t(wmt,"isSelectable");function kmt(i){return!RD.isSeparator(i)}t(kmt,"isNavigable");function HSn(i){return i.map(n=>{if(RD.isSeparator(n))return n;if(typeof n!="object"||n===null||!("value"in n)){let l=String(n);return{value:n,name:l,short:l,disabled:!1}}let s=n.name??String(n.value),c={value:n.value,name:s,short:n.short??s,disabled:n.disabled??!1};return n.description&&(c.description=n.description),c})}t(HSn,"normalizeChoices");var Dmt=Tmt((i,n)=>{let{loop:s=!0,pageSize:c=7}=i,l=Ome(WSn,i.theme),{keybindings:d}=l,[h,b]=mB("idle"),T=rmt({status:h,theme:l}),k=qJ(),F=!d.includes("vim"),H=Mme(()=>HSn(i.choices),[i.choices]),j=Mme(()=>{let $r=H.findIndex(kmt),Di=H.findLastIndex(kmt);if($r===-1)throw new Ute("[select prompt] No selectable choices. All choices are disabled.");return{first:$r,last:Di}},[H]),X=Mme(()=>"default"in i?H.findIndex($r=>wmt($r)&&$r.value===i.default):-1,[i.default,H]),[se,pe]=mB(X===-1?j.first:X),Ke=H[se];if(Ke==null||RD.isSeparator(Ke))throw new Error("Active index does not point to a choice");let[qe,lt]=mB();nmt(($r,Di)=>{if(clearTimeout(k.current),qe&<(void 0),q_t($r))Ke.disabled?lt(l.i18n.disabledError):(b("done"),n(Ke.value));else if(Bme($r,d)||oBe($r,d)){if(Di.clearLine(0),s||Bme($r,d)&&se!==j.first||oBe($r,d)&&se!==j.last){let Zr=Bme($r,d)?-1:1,qo=se;do qo=(qo+Zr+H.length)%H.length;while(!kmt(H[qo]));pe(qo)}}else if(V_t($r)&&!Number.isNaN(Number(Di.line))){let Zr=Number(Di.line)-1,qo=-1,Ro=H.findIndex(Cd=>RD.isSeparator(Cd)?!1:(qo++,qo===Zr)),bn=H[Ro];bn!=null&&wmt(bn)&&pe(Ro),k.current=setTimeout(()=>{Di.clearLine(0)},700)}else if(H_t($r))Di.clearLine(0);else if(F){let Zr=Di.line.toLowerCase(),qo=H.findIndex(Ro=>RD.isSeparator(Ro)||!wmt(Ro)?!1:Ro.name.toLowerCase().startsWith(Zr));qo!==-1&&pe(qo),k.current=setTimeout(()=>{Di.clearLine(0)},700)}}),VJ(()=>()=>{clearTimeout(k.current)},[]);let Ue=l.style.message(i.message,h),gt=l.style.keysHelpTip([["\u2191\u2193","navigate"],["\u23CE","select"]]),Ot=0,Jt=amt({items:H,active:se,renderItem({item:$r,isActive:Di,index:Zr}){if(RD.isSeparator($r))return Ot++,` ${$r.separator}`;let qo=Di?l.icon.cursor:" ",Ro=l.indexMode==="number"?`${Zr+1-Ot}. `:"";if($r.disabled){let Cd=typeof $r.disabled=="string"?$r.disabled:"(disabled)",yc=Di?l.icon.cursor:"-";return l.style.disabled(`${yc} ${Ro}${$r.name} ${Cd}`)}return(Di?l.style.highlight:Cd=>Cd)(`${qo} ${Ro}${$r.name}`)},pageSize:c,loop:s});if(h==="done")return[T,Ue,l.style.answer(Ke.short)].filter(Boolean).join(" ");let{description:Dt}=Ke;return`${[[T,Ue].filter(Boolean).join(" "),Jt," ",Dt?l.style.description(Dt):"",qe?l.style.error(qe):"",gt].filter(Boolean).join(`
|
|
862
862
|
`).trimEnd()}${Plr}`});var VSn={"example.checksum.spec.ts":["67f42a75415305bb0b9a4ebf4c48852fff93683352daf99b437253115eba93a4","cb20838ab7a1e68b6d31c7a2227023e89a99a8ba4f6ea1dc8b1537636f64004e"],"github-actions.example.yml":["7716cd5467c47d8ac991167cf9c40b0f7aafa9288776bd76c7603951872ad612"]},qSn=t(i=>i.replace(/\r\n/g,`
|
|
863
|
-
`).replace(/\n$/,""),"normalizeFileContents"),GSn=t(i=>(0,jlr.createHash)("sha256").update(qSn(i)).digest("hex"),"getFileContentsHash"),Nmt=class Nmt extends $0{constructor(n,s=!1){super(n,s,{skipChecksumDataLoad:!0})}init({requireChecksumFolder:n=!0}={}){try{this.findProjectRoot()}catch(s){console.log(s.message),process.exit(1)}if(this.checksumRoot=(0,PE.join)(process.cwd(),hIe),!(0,oh.existsSync)(this.checksumRoot)){if(n)throw new Error("Could not find checksum folder in your project, you should run the init command first to setup your Checksum.ai project.");(0,oh.mkdirSync)(this.checksumRoot)}if(!(0,oh.existsSync)(this.getChecksumRootOrigin()))throw new Error("Could not find checksum node module, please install @checksum-ai/runtime package and try again.")}removeLegacyStarterFileIfUnchanged(n){let s=(0,PE.join)(this.checksumRoot,n);if(!(0,oh.existsSync)(s))return!1;let c=GSn((0,oh.readFileSync)(s,"utf8")),l=VSn[n];return!l||!l.includes(c)?!1:((0,oh.unlinkSync)(s),!0)}install(){console.log("Creating checksum directory and necessary files to run your tests..."),this.init({requireChecksumFolder:!1}),lOt({isInit:!0}).forEach(l=>{let d=(0,PE.join)(this.checksumRoot,l);(0,oh.existsSync)(d)||((0,oh.mkdirSync)((0,PE.dirname)(d),{recursive:!0}),(0,oh.copyFileSync)((0,PE.join)(this.getChecksumRootOrigin(),l),d))}),[this.removeLegacyStarterFileIfUnchanged("example.checksum.spec.ts"),this.removeLegacyStarterFileIfUnchanged("github-actions.example.yml")].some(Boolean)&&console.log("Removed untouched legacy starter files that were replaced by the refreshed checksum/tests/examples scaffold.");let s=(0,PE.join)(this.checksumRoot,".gitignore.example"),c=(0,PE.join)(this.checksumRoot,".gitignore");(0,oh.existsSync)(s)&&!(0,oh.existsSync)(c)&&((0,oh.copyFileSync)(s,c),(0,oh.unlinkSync)(s)),this.validateAuthExists(),(0,oh.mkdirSync)((0,PE.join)(this.checksumRoot,"tests"),{recursive:!0})}addTsConfig(){console.log("Adding tsconfig.json to your checksum directory..."),this.init();let n=(0,PE.join)(this.checksumRoot,"tsconfig.json");(0,oh.existsSync)(n)||(0,oh.copyFileSync)((0,PE.join)(this.getChecksumRootOrigin(),"tsconfig.json"),n)}async addEslintConfig(){console.log("Adding ESLint config to your checksum directory..."),this.init();let n=(0,PE.join)(this.checksumRoot,"eslint.config.js");(0,oh.existsSync)(n)?console.log("eslint.config.js already exists."):((0,oh.copyFileSync)((0,PE.join)(this.getChecksumRootOrigin(),"eslint.config.js"),n),console.log("Added eslint.config.js."));let s=["eslint","@eslint/js","typescript","typescript-eslint"],c=this.getChecksumArg("yes"),l=!!c;if(!c)try{l=await Dmt({message:`Install required devDependencies now? (${s.join(", ")})`,choices:[{name:"Yes",value:"yes"},{name:"No",value:"no"}],default:"yes"})==="yes"}catch{l=!1}if(l){let h=(0,oh.existsSync)((0,PE.join)(this.projectRootDirectory,"yarn.lock"))?`yarn add -D ${s.join(" ")}`:`npm i -D ${s.join(" ")}`;try{console.log("Installing devDependencies...",h),await this.execCmd(`cd "${this.projectRootDirectory}" && ${h}`),console.log("DevDependencies installed successfully.")}catch(b){console.log("Failed installing devDependencies:",b.message)}}else console.log(`Skipped installing devDependencies. You can install them manually with:
|
|
863
|
+
`).replace(/\n$/,""),"normalizeFileContents"),GSn=t(i=>(0,jlr.createHash)("sha256").update(qSn(i)).digest("hex"),"getFileContentsHash"),Nmt=class Nmt extends $0{constructor(n,s=!1){super(n,s,{skipChecksumDataLoad:!0})}init({requireChecksumFolder:n=!0}={}){try{this.findProjectRoot()}catch(s){console.log(s.message),process.exit(1)}if(this.checksumRoot=(0,PE.join)(process.cwd(),hIe),!(0,oh.existsSync)(this.checksumRoot)){if(n)throw new Error("Could not find checksum folder in your project, you should run the init command first to setup your Checksum.ai project.");(0,oh.mkdirSync)(this.checksumRoot)}if(!(0,oh.existsSync)(this.getChecksumRootOrigin()))throw new Error("Could not find checksum node module, please install @checksum-ai/runtime package and try again.")}removeLegacyStarterFileIfUnchanged(n){let s=(0,PE.join)(this.checksumRoot,n);if(!(0,oh.existsSync)(s))return!1;let c=GSn((0,oh.readFileSync)(s,"utf8")),l=VSn[n];return!l||!l.includes(c)?!1:((0,oh.unlinkSync)(s),!0)}install(){console.log("Creating checksum directory and necessary files to run your tests..."),this.init({requireChecksumFolder:!1}),lOt({isInit:!0}).forEach(l=>{let d=(0,PE.join)(this.checksumRoot,l);(0,oh.existsSync)(d)||((0,oh.mkdirSync)((0,PE.dirname)(d),{recursive:!0}),(0,oh.copyFileSync)((0,PE.join)(this.getChecksumRootOrigin(),l),d))}),[this.removeLegacyStarterFileIfUnchanged("example.checksum.spec.ts"),this.removeLegacyStarterFileIfUnchanged("github-actions.example.yml")].some(Boolean)&&console.log("Removed untouched legacy starter files that were replaced by the refreshed checksum/tests/examples scaffold.");let s=(0,PE.join)(this.checksumRoot,".gitignore.example"),c=(0,PE.join)(this.checksumRoot,".gitignore");(0,oh.existsSync)(s)&&!(0,oh.existsSync)(c)&&((0,oh.copyFileSync)(s,c),(0,oh.unlinkSync)(s)),this.validateAuthExists(),(0,oh.mkdirSync)((0,PE.join)(this.checksumRoot,"tests"),{recursive:!0})}addTsConfig(){console.log("Adding tsconfig.json to your checksum directory..."),this.init();let n=(0,PE.join)(this.checksumRoot,"tsconfig.json");(0,oh.existsSync)(n)||(0,oh.copyFileSync)((0,PE.join)(this.getChecksumRootOrigin(),"tsconfig.json"),n)}async addEslintConfig(){console.log("Adding ESLint config to your checksum directory..."),this.init();let n=(0,PE.join)(this.checksumRoot,"eslint.config.js");(0,oh.existsSync)(n)?console.log("eslint.config.js already exists."):((0,oh.copyFileSync)((0,PE.join)(this.getChecksumRootOrigin(),"eslint.config.js"),n),console.log("Added eslint.config.js."));let s=["eslint","@eslint/js","typescript","typescript-eslint","@stylistic/eslint-plugin"],c=this.getChecksumArg("yes"),l=!!c;if(!c)try{l=await Dmt({message:`Install required devDependencies now? (${s.join(", ")})`,choices:[{name:"Yes",value:"yes"},{name:"No",value:"no"}],default:"yes"})==="yes"}catch{l=!1}if(l){let h=(0,oh.existsSync)((0,PE.join)(this.projectRootDirectory,"yarn.lock"))?`yarn add -D ${s.join(" ")}`:`npm i -D ${s.join(" ")}`;try{console.log("Installing devDependencies...",h),await this.execCmd(`cd "${this.projectRootDirectory}" && ${h}`),console.log("DevDependencies installed successfully.")}catch(b){console.log("Failed installing devDependencies:",b.message)}}else console.log(`Skipped installing devDependencies. You can install them manually with:
|
|
864
864
|
npm i -D `+s.join(" ")+`
|
|
865
865
|
or
|
|
866
866
|
yarn add -D `+s.join(" "))}};t(Nmt,"CLIInstall");var qte=Nmt;var $lr=require("fs"),Jlr=Na(require("path"));var Pmt=class Pmt{constructor(n,s){this.config=n;this.baseURL=n.apiURL+s}getBaseURL(){return this.baseURL}get(n){let s=`${this.baseURL}/${n}`;return fetch(s,{method:"GET",headers:{ChecksumAppCode:this.config.apiKey}})}put(n,s){return fetch(`${this.baseURL}/${n}`,{method:"PUT",headers:{"Content-Type":"application/json",ChecksumAppCode:this.config.apiKey},...s?{body:JSON.stringify(s)}:{}})}post(n,s){return fetch(`${this.baseURL}/${n}`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:this.config.apiKey},...s?{body:JSON.stringify(s)}:{}})}delete(n){return fetch(`${this.baseURL}/${n}`,{method:"DELETE",headers:{ChecksumAppCode:this.config.apiKey}})}};t(Pmt,"RuntimeAPIService");var ABe=Pmt;var Rmt=class Rmt extends ABe{constructor(s){super(s,"/client-api/runtime");this.config=s}};t(Rmt,"CliAPIService");var vBe=Rmt;var Bmt=class Bmt extends $0{constructor(n,s=!1){super(n,s,{muteChecksumConfigMissingError:!0}),this.config&&!this.config.apiURL&&(this.config.apiURL=HRe({}).apiURL)}initApiService(){if(!this.config){this.handleError("No checksum configuration found.");return}let n=this.config,s=n.apiKey,c=this.getArg("--api-key");c&&c!==""?n.apiKey=c:!!s?n.apiKey=s:this.handleError("No API key provided. Please provide an API key using --api-key=<apiKey>"),this.apiService=new vBe(n)}async downloadDotenv(){if(!this.apiService){this.handleError("API service is not initialized.");return}try{let n=await this.apiService.get("dotenv");if(!n.ok){let{status:l,statusText:d}=n;l===403&&this.handleError('The API key you provided is not valid. Please check your API key and try again, running: "npx checksumai dotenv --download --api-key=<apiKey>"'),this.handleError(`Error occured when trying to download the .env file. ${l} ${d}`)}let s=await n.text();s=this.removeAuthorizeReports(s);let c=Jlr.default.join(this.checksumRoot,".env");(0,$lr.writeFileSync)(c,s),console.log(`The .env file has been downloaded to ${c}`)}catch{this.handleError("Error occured when trying to download the .env file.")}}async run(){this.initApiService(),this.getArg("--download")?await this.downloadDotenv():this.handleError("Invalid command. Use --download to download the .env file and run the command again.")}handleError(n){console.error(n),process.exit(1)}removeAuthorizeReports(n){return n.split(`
|
package/package.json
CHANGED