@zenovay/cli 0.1.16 → 0.1.18
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/{ai-QwPVHbiS.js → ai-B8PRo9Ja.js} +1 -1
- package/dist/{analytical-screen-DQwA5IZ1.js → analytical-screen-DI8ahq4z.js} +1 -1
- package/dist/{api-0Qf43hhF.js → api-DXmhz2DM.js} +1 -1
- package/dist/{api-v2-DnMJJmhi.js → api-v2-FrwTv9zH.js} +1 -1
- package/dist/apply-D2xZJdvQ.js +1 -0
- package/dist/bin.js +3 -1
- package/dist/check-Comj8AkL.js +1 -0
- package/dist/{companies-BPwvvD2o.js → companies-Xu9p4GXI.js} +1 -1
- package/dist/config-CZ9IzjIH.js +1 -0
- package/dist/data-table-lMY6gJTI.js +1 -0
- package/dist/{deploys-BUnVkaEg.js → deploys-Bf_wSsLz.js} +1 -1
- package/dist/devices-BaWxrRjY.js +1 -0
- package/dist/{doctor-DyNONZGx.js → doctor-CnWr28VY.js} +1 -1
- package/dist/{emit-0WJ_OGeT.js → emit-BmfLGjqr.js} +1 -1
- package/dist/empty-state-CsRSB1cb.js +1 -0
- package/dist/{errors-DND9r91m.js → errors-BaS_oMYP.js} +1 -1
- package/dist/{events-tail-D6UfbRj7.js → events-tail-BpAhoXVM.js} +3 -3
- package/dist/{funnel-BpMHOOaE.js → funnel-DaoYO2g_.js} +1 -1
- package/dist/geo-DG_ETC0h.js +1 -0
- package/dist/globe-UnGLnca5.js +1 -0
- package/dist/health-BaXEAzM7.js +1 -0
- package/dist/{health-B7BBVo2z.js → health-Bz-S_pGQ.js} +1 -1
- package/dist/heatmaps-B56aCdpr.js +1 -0
- package/dist/init-DZfTNHF4.js +62 -0
- package/dist/init-Vrznsq24.js +1 -0
- package/dist/insights-Cx67JytT.js +1 -0
- package/dist/journeys-DqtbkbRQ.js +1 -0
- package/dist/{keybar-CWo5rhK_.js → keybar-DUC7w1HQ.js} +1 -1
- package/dist/live-DB5w__ih.js +1 -0
- package/dist/login-Bb_At1Ov.js +1 -0
- package/dist/{login-CpJeUOCR.js → login-DvMRHd3J.js} +1 -1
- package/dist/logout-B_-6rZdK.js +2 -0
- package/dist/metric-card-W4GayhPO.js +1 -0
- package/dist/overview-ChOU9GHP.js +1 -0
- package/dist/pages-BGODfLio.js +1 -0
- package/dist/panel-DZqvtaao.js +1 -0
- package/dist/{projects-CYmKX2WM.js → projects-DYxHeEYi.js} +1 -1
- package/dist/{prompt-B1QrBhyZ.js → prompt-DEng-me1.js} +1 -1
- package/dist/{query-DD6ZGKsY.js → query-ClP0vb33.js} +1 -1
- package/dist/{resolve-site-CPY8XSeq.js → resolve-site-D4W9yMVw.js} +1 -1
- package/dist/retention-BSmE8p6T.js +1 -0
- package/dist/{revenue-C6YPnOvr.js → revenue-CMeu1Pv6.js} +1 -1
- package/dist/sessions-4yj1VVsv.js +1 -0
- package/dist/{sources-BYSCTIBA.js → sources-EJuXDR0z.js} +1 -1
- package/dist/sparkline-B6ueqPAB.js +1 -0
- package/dist/{stats-C0AJtjVS.js → stats-Cl-2pqTC.js} +1 -1
- package/dist/{themes-Bhj-4q-r.js → themes-Ty85UcjT.js} +1 -1
- package/dist/tier-CSgWXnOt.js +1 -0
- package/dist/{ui-CVGR9Ffn.js → ui-BtZp4Eh8.js} +1 -1
- package/dist/update-5mypMXp6.js +1 -0
- package/dist/uptime-pvxntalC.js +1 -0
- package/dist/{use-jF2EdP8H.js → use-BxzYOpQl.js} +1 -1
- package/dist/{vitals-rttZVRnn.js → vitals-B87wKDAN.js} +1 -1
- package/dist/watch-SfQIks0Y.js +1 -0
- package/dist/{webhooks-forward-DQaXTq3w.js → webhooks-forward-DLMxW-Kg.js} +1 -1
- package/dist/wizard-bin.js +1 -1
- package/dist/{ws-client-DsIRZ_TX.js → ws-client-3QuvHd5K.js} +1 -1
- package/package.json +1 -1
- package/dist/check-CmOnrU4W.js +0 -1
- package/dist/config-Ddkbfelp.js +0 -1
- package/dist/health-B4NtoJtP.js +0 -1
- package/dist/init-B9fjLwAP.js +0 -62
- package/dist/init-QiTMBqJb.js +0 -1
- package/dist/login-2h7PjSlW.js +0 -1
- package/dist/logout-DBIL_bPH.js +0 -2
- package/dist/panel-DglZ755S.js +0 -1
- package/dist/sparkline-CR_bzxwB.js +0 -1
- package/dist/update-CgGLjHBM.js +0 -1
- package/dist/watch-Bgjke7jm.js +0 -1
- /package/dist/{client-DZ4Awt8u.js → client-vixcHdv-.js} +0 -0
- /package/dist/{completions-Bqs_uGx6.js → completions-DHOrzR_j.js} +0 -0
- /package/dist/{formatter-45-fT1Hv.js → formatter-BNYzdX5c.js} +0 -0
- /package/dist/{wrapper-U9nLhCpo.js → wrapper-D7FQ-LtK.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=[500,1e3,2e3,4e3,8e3,16e3,32e3,6e4];let t=null;async function n(){if(t)return t;let e=globalThis.WebSocket;if(typeof e==`function`)return t=e,e;try{let e=await import(`./wrapper-
|
|
1
|
+
const e=[500,1e3,2e3,4e3,8e3,16e3,32e3,6e4];let t=null;async function n(){if(t)return t;let e=globalThis.WebSocket;if(typeof e==`function`)return t=e,e;try{let e=await import(`./wrapper-D7FQ-LtK.js`),n=e.default??e.WebSocket;if(!n)throw Error(`ws package missing default export`);return t=n,n}catch(e){throw Error(`WebSocket unavailable: install Node 22+ or add the 'ws' dependency (${e.message})`)}}function r(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason??Error(`aborted`));return}let i=setTimeout(()=>{t?.removeEventListener(`abort`,a),n()},e),a=()=>{clearTimeout(i),r(t?.reason??Error(`aborted`))};t?.addEventListener(`abort`,a,{once:!0})})}function i(t){return e[Math.min(t-1,e.length-1)]??6e4}function a(e,t){if(!t)return e;let n=e.includes(`?`)?`&`:`?`;return`${e}${n}access_token=${encodeURIComponent(t)}`}async function o(e,t,n,r){let i=a(e,n),o;try{o=n?new t(i,{headers:{Authorization:`Bearer ${n}`}}):new t(i)}catch(e){throw Error(`ws connect failed: ${e.message}`)}return await new Promise((e,t)=>{let n=!1,i=()=>{n||(n=!0,c(),e({socket:o,open:!0}))},a=e=>{if(n)return;n=!0,c();let r=e?.message??(typeof e==`string`?e:`ws connection error`);t(Error(r))},s=()=>{if(!n){n=!0,c();try{o.close()}catch{}t(r?.reason??Error(`aborted`))}},c=()=>{o.onopen=null,o.onerror=null,r?.removeEventListener(`abort`,s)};o.onopen=i,o.onerror=a,r?.addEventListener(`abort`,s,{once:!0})})}async function*s(e){let t=e.webSocketImpl??await n(),a=e.pingIntervalMs??3e4,s=e.maxReconnectAttempts??10,c=0;for(;;){if(e.signal?.aborted)return;let n;try{n=await o(e.url,t,e.bearer,e.signal)}catch(t){if(e.signal?.aborted)return;if(c++,c>s)throw t;let n=i(c);e.onReconnect?.(c,n);try{await r(n,e.signal)}catch{return}continue}yield{type:`open`};let l=[],u=[],d=!1,f=Date.now(),p=!1,m=e=>{f=Date.now();let t=u.shift();t?t(e):l.push(e)},h=()=>{if(!d)for(d=!0;u.length;)u.shift()(null)};n.socket.onmessage=e=>{m({type:`message`,data:e.data})},n.socket.onclose=()=>{m({type:`close`}),h()},n.socket.onerror=e=>{let t=e?.message??`ws error`;m({type:`error`,data:t})};let g=()=>{try{n.socket.close()}catch{}h()};e.signal?.addEventListener(`abort`,g,{once:!0});let _=null;a>0&&(_=setInterval(()=>{if(Date.now()-f>a*1.5){try{n.socket.close()}catch{}h()}},Math.max(1e3,Math.floor(a/2))));try{for(;;){if(e.signal?.aborted)return;let t;if(t=l.length>0?l.shift():d?null:await new Promise(e=>u.push(e)),t===null||(t.type===`message`&&(p=!0),yield t,t.type===`close`))break}}finally{_&&clearInterval(_),e.signal?.removeEventListener(`abort`,g);try{n.socket.close()}catch{}}if(e.signal?.aborted)return;if(p&&(c=0),c++,c>s)throw Error(`ws connection exceeded reconnect cap`);let v=i(c);e.onReconnect?.(c,v);try{await r(v,e.signal)}catch{return}}}var c=class{opts;ac=null;socket=null;running=!1;constructor(e){this.opts=e}async start(e){this.running=!0,this.ac=new AbortController;let t=l(this.ac.signal,this.opts.signal),a=this.opts.webSocketImpl??await n(),s=this.opts.maxReconnectAttempts??10,c=0;for(;this.running;){if(t.aborted)return;let n;try{n=await o(this.opts.url,a,this.opts.bearer,t)}catch(e){if(t.aborted)return;if(c++,c>s)throw e;let n=i(c);this.opts.onReconnect?.(c,n);try{await r(n,t)}catch{return}continue}this.socket=n.socket;let l=!1;if(await new Promise(r=>{n.socket.onmessage=t=>{l=!0;let r=typeof t.data==`string`?t.data:String(t.data),i=null;try{i=JSON.parse(r)}catch{return}!i||typeof i.correlationId!=`string`||e(i).then(e=>{let t={correlationId:i.correlationId,status:e.status,headers:e.headers,body:e.body};try{n.socket.send(JSON.stringify(t))}catch{}}).catch(e=>{let t={correlationId:i.correlationId,status:502,body:JSON.stringify({error:e.message})};try{n.socket.send(JSON.stringify(t))}catch{}})},n.socket.onclose=()=>r(),n.socket.onerror=()=>r(),t.addEventListener(`abort`,()=>{try{n.socket.close()}catch{}r()},{once:!0})}),this.socket=null,t.aborted||!this.running)return;if(l&&(c=0),c++,c>s)throw Error(`ws tunnel exceeded reconnect cap`);let u=i(c);this.opts.onReconnect?.(c,u);try{await r(u,t)}catch{return}}}async stop(){this.running=!1,this.ac?.abort();try{this.socket?.close()}catch{}this.socket=null}};function l(e,t){if(!t)return e;let n=new AbortController,r=()=>n.abort(e.reason),i=()=>n.abort(t.reason);return e.aborted?n.abort(e.reason):e.addEventListener(`abort`,r,{once:!0}),t.aborted?n.abort(t.reason):t.addEventListener(`abort`,i,{once:!0}),n.signal}export{c as WsTunnelClient,s as connectWs};
|
package/package.json
CHANGED
package/dist/check-CmOnrU4W.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{z as e}from"zod";import t from"semver";const n=e.object({url:e.string().url(),sha256:e.string().regex(/^[0-9a-f]{64}$/i),sig:e.string()}),r=e.object({latest:e.string(),minSupported:e.string().optional(),platforms:e.record(e.string(),n),changelog:e.string().url().optional(),releasedAt:e.string().datetime().optional()});function i(e,n){if(!t.valid(e)||!t.valid(n)||t.eq(e,n))return`none`;if(t.lt(n,e))return`downgrade`;let r=t.diff(e,n);return r===`patch`||r===`prepatch`?`patch`:r===`minor`||r===`preminor`?`minor`:`major`}function a(e=process.platform,t=process.arch){let n=e===`darwin`?`darwin`:e===`linux`?`linux`:e===`win32`?`win32`:e,r=t===`x64`?`x64`:t===`arm64`?`arm64`:t;return`${n}-${r}`}async function o(e){let t=e.fetchImpl??fetch,n=await t(`${e.cliBase}/version`,{signal:e.signal});if(!n.ok)throw Error(`Manifest fetch failed: ${n.status}`);let i=await n.json();return r.parse(i)}export{i as classifyBump,o as fetchManifest,a as platformKey};
|
package/dist/config-Ddkbfelp.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"node:path";import{promises as t}from"node:fs";import n from"node:os";import{z as r}from"zod";const i=r.object({theme:r.string().optional(),apiBase:r.string().url().default(`https://api.zenovay.com`),cliBase:r.string().url().default(`https://cli.zenovay.com`),region:r.enum([`us`,`eu`,`auto`]).default(`auto`),telemetry:r.boolean().default(!1),noUpdateCheck:r.boolean().default(!1),lastUpdateNotice:r.number().optional(),forwardSecret:r.string().optional(),defaultSiteId:r.string().optional(),defaultSiteName:r.string().optional()}),a={apiBase:`https://api.zenovay.com`,cliBase:`https://cli.zenovay.com`,region:`auto`,telemetry:!1,noUpdateCheck:!1};function o(){if(process.platform===`win32`){let t=process.env.APPDATA??e.join(n.homedir(),`AppData`,`Roaming`);return e.join(t,`zenovay`)}let t=process.env.XDG_CONFIG_HOME??e.join(n.homedir(),`.config`);return e.join(t,`zenovay`)}function s(){return e.join(o(),`config.json`)}async function c(){let e=s();try{let n=await t.readFile(e,`utf8`),r=i.safeParse(JSON.parse(n));return r.success?r.data:a}catch(e){if(e.code===`ENOENT`)return a;throw e}}async function l(e){let n=o();await t.mkdir(n,{recursive:!0,mode:448});let r=s();await t.writeFile(r,JSON.stringify(e,null,2),{mode:384}),process.platform!==`win32`&&await t.chmod(r,384)}async function u(e){let t=await c(),n=i.parse({...t,...e});return await l(n),n}export{o as configDir,s as configPath,c as readConfig,u as updateConfig};
|
package/dist/health-B4NtoJtP.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./config-Ddkbfelp.js";import"./api-0Qf43hhF.js";import"./formatter-45-fT1Hv.js";import"./emit-0WJ_OGeT.js";import"./panel-DglZ755S.js";import"./check-CmOnrU4W.js";import{HealthReport as e,exitCodeFor as t,healthCommand as n,runHealthChecks as r}from"./health-B7BBVo2z.js";export{n as healthCommand};
|
package/dist/init-B9fjLwAP.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import{readConfig as e,updateConfig as t}from"./config-Ddkbfelp.js";import{ApiClient as n,readToken as r}from"./api-0Qf43hhF.js";import{parseSseStream as i}from"./client-DZ4Awt8u.js";import{emit as a,isHeadless as o}from"./emit-0WJ_OGeT.js";import{loginCommand as s}from"./login-CpJeUOCR.js";import{Panel as c}from"./panel-DglZ755S.js";import{Banner as l,BrandGradient as u,Select as d}from"./prompt-B1QrBhyZ.js";import{Keybar as f}from"./keybar-CWo5rhK_.js";import{spark as p}from"./sparkline-CR_bzxwB.js";import m from"node:path";import{promises as h}from"node:fs";import{Box as g,Text as _,render as v,useApp as y,useInput as b}from"ink";import x,{useEffect as S,useRef as C,useState as w}from"react";import T from"node:os";import{z as E}from"zod";import{globby as D}from"globby";import O from"ink-spinner";import k from"node:crypto";import{ulid as ee}from"ulid";import{applyPatch as A}from"diff";const te=[`@zenovay/tracker`,`@zenovay/next`,`@zenovay/nuxt`,`@zenovay/svelte`,`@zenovay/astro`,`@zenovay/remix`,`@zenovay/node`],j=[`zenovay.config.ts`,`zenovay.config.js`,`zenovay.config.mjs`,`zenovay.config.json`],M=/<script[^>]*src\s*=\s*["']https:\/\/(?:api|cdn)\.zenovay\.com\/[^"']+["'][^>]*>\s*<\/script>/gi,N=/data-id\s*=\s*["'](ZV_[A-Za-z0-9]+)["']/i,P=/data-zenovay-site\s*=\s*["']([^"']+)["']/i,F=[{name:`PostHog`,patterns:[/posthog\.com\b/i,/posthog-js/,/window\.posthog/]},{name:`Plausible`,patterns:[/plausible\.io\/js/i,/window\.plausible/]},{name:`Google Analytics`,patterns:[/googletagmanager\.com\/gtag\/js/i,/www\.google-analytics\.com\/analytics\.js/i,/window\.gtag\b/]},{name:`Mixpanel`,patterns:[/cdn\.mxpnl\.com/i,/mixpanel-browser/]},{name:`Segment`,patterns:[/cdn\.segment\.com\/analytics\.js/i,/window\.analytics\b/]},{name:`Hotjar`,patterns:[/static\.hotjar\.com/i,/\(h,o,t,j,a,r\)/i]},{name:`Amplitude`,patterns:[/cdn\.amplitude\.com/i,/amplitude\.getInstance/]},{name:`Heap`,patterns:[/cdn\.heapanalytics\.com/i]},{name:`FullStory`,patterns:[/fullstory\.com\/s\/fs\.js/i,/window\.FS\.identify/]}];async function I(e,t){let n={zenovayInstalled:!1,correctTrackingCode:!1,foundTrackingCodes:[],zenovayFiles:[],competitors:[],summary:``,recommendation:`fresh-install`};try{let t=await h.readFile(m.join(e,`package.json`),`utf8`),r=JSON.parse(t),i={...r.dependencies,...r.devDependencies};for(let e of te)if(e in i){n.zenovayInstalled=!0,n.packageMarker=e;break}}catch{}for(let t of j)try{await h.access(m.join(e,t)),n.zenovayInstalled=!0,n.configFile=t;break}catch{}let r=await D([`**/*.{html,htm,tsx,jsx,vue,svelte,astro,ts,js,mjs}`,`!node_modules/**`,`!.git/**`,`!dist/**`,`!.next/**`,`!.nuxt/**`,`!build/**`,`!.output/**`],{cwd:e,gitignore:!0,deep:4,absolute:!0}).catch(()=>[]),i=new Map,a=new Set;for(let t of r.slice(0,300)){let r;try{r=await h.readFile(t,`utf8`)}catch{continue}let o=m.relative(e,t),s=r.match(M);if(s&&s.length>0){n.zenovayInstalled=!0;let e=s[0].slice(0,200),t=e.match(N)??e.match(P),r=t?.[1]??null;r&&a.add(r),n.zenovayFiles.push({file:o,currentTrackingCode:r,scriptTagCount:s.length,matchSample:e})}for(let e of F)if(e.patterns.some(e=>e.test(r))){let t=i.get(e.name)??new Set;t.add(o),i.set(e.name,t)}}if(n.foundTrackingCodes=Array.from(a),n.competitors=Array.from(i.entries()).map(([e,t])=>({name:e,files:Array.from(t).slice(0,5)})),n.zenovayInstalled)if(n.foundTrackingCodes.length>0){let e=n.foundTrackingCodes.every(e=>e===t);n.correctTrackingCode=e,n.recommendation=e?`no-op`:`update-tracking-code`}else n.correctTrackingCode=!1,n.recommendation=`no-op`;else n.competitors.length>0?n.recommendation=`fresh-install-alongside-competitor`:n.recommendation=`fresh-install`;return n.summary=ne(n,t),n}function ne(e,t){let n=[];return e.zenovayInstalled?e.foundTrackingCodes.length===0?n.push(`Zenovay package or config detected but no <script> tag found.`):e.correctTrackingCode?n.push(`Zenovay tracker present in ${e.zenovayFiles.length} file(s) with correct ID ${t}.`):n.push(`Zenovay tracker present in ${e.zenovayFiles.length} file(s), but with mismatching ID(s): ${e.foundTrackingCodes.join(`, `)} (target: ${t}).`):n.push(`No Zenovay tracker found.`),e.competitors.length>0&&n.push(`Competitor tracker(s) present (DO NOT modify): ${e.competitors.map(e=>e.name).join(`, `)}.`),n.join(` `)}async function re(e){let t=await I(e,``);return{installed:t.zenovayInstalled,reasons:t.summary?[t.summary]:[],packageMarker:t.packageMarker,configFile:t.configFile,scriptFile:t.zenovayFiles[0]?.file}}const ie=[{name:`openai-proj`,regex:/\bsk-proj-[A-Za-z0-9_-]{20,}\b/g},{name:`anthropic`,regex:/\bsk-ant-[A-Za-z0-9_-]{20,}\b/g},{name:`openai-sk`,regex:/\bsk-[A-Za-z0-9]{20,}\b/g},{name:`github-pat-new`,regex:/\bgithub_pat_[A-Za-z0-9_]{82}\b/g},{name:`github-pat`,regex:/\bghp_[A-Za-z0-9]{36}\b/g},{name:`github-oauth`,regex:/\bgho_[A-Za-z0-9]{36}\b/g},{name:`aws-access-key`,regex:/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/g},{name:`stripe-live`,regex:/\b(?:sk|pk)_live_[A-Za-z0-9]{24,}\b/g},{name:`stripe-test`,regex:/\b(?:sk|pk)_test_[A-Za-z0-9]{24,}\b/g},{name:`stripe-restricted`,regex:/\brk_(?:live|test)_[A-Za-z0-9]{24,}\b/g},{name:`stripe-webhook`,regex:/\bwhsec_[A-Za-z0-9]{24,}\b/g},{name:`slack-bot`,regex:/\bxox[bpoa]-[A-Za-z0-9-]{10,}\b/g},{name:`google-api`,regex:/\bAIza[0-9A-Za-z_-]{35}\b/g},{name:`jwt`,regex:/\beyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g},{name:`private-key-rsa`,regex:/-----BEGIN (?:RSA|EC|OPENSSH|DSA|PGP) PRIVATE KEY(?: BLOCK)?-----/g},{name:`private-key-pkcs8`,regex:/-----BEGIN PRIVATE KEY-----/g}];function ae(e){let t=e;for(let e of ie){let n=new RegExp(e.regex.source,e.regex.flags);t=t.replace(n,`[REDACTED:${e.name}]`)}return t}const oe=[/^package\.json$/,/^package-lock\.json$/,/^pnpm-lock\.yaml$/,/^yarn\.lock$/,/^bun\.lock$/,/^tsconfig.*\.json$/,/^(next|nuxt|vite|astro|remix|svelte|tailwind|postcss)\.config\.(ts|mts|cts|js|mjs|cjs)$/,/^app\/.*\.(tsx|ts|jsx|js|svelte|astro|vue)$/,/^pages\/.*\.(tsx|ts|jsx|js)$/,/^public\/index\.html$/,/^index\.html$/,/^src\/main\.(tsx|ts|jsx|js)$/,/^src\/App\.(tsx|ts|jsx|js|svelte|vue)$/,/^src\/routes\/\+layout\.(svelte|ts|js)$/,/^src\/routes\/root\..*$/,/^src\/layouts\/.*\.(astro|svelte|vue)$/,/^\.env\.example$/,/^README\.md$/,/^\.gitignore$/,/^nuxt\.config\.(ts|js|mjs)$/,/^plugins\/.*\.(ts|js)$/],se=[/(^|\/)\.env($|\.(?!example$)[^/]+$)/,/(^|\/)\.git(\/|$)/,/(^|\/)node_modules\//,/(^|\/)\.ssh\//,/(^|\/)\.aws\//,/\.pem$/,/\.key$/,/(^|\/)id_rsa($|\.)/,/(^|\/)\.npmrc$/,/(^|\/)credentials(\.|$)/],L=256*1024,R=50,z=20,B=40;var V=class extends Error{constructor(e,t){super(t),this.code=e,this.name=`SandboxError`}};const H=/<script[^>]*src\s*=\s*["']https:\/\/(?:api|cdn)\.zenovay\.com\/[^"']+["'][^>]*>\s*<\/script>/i,U=[{name:`PostHog`,re:/posthog\.com\b|posthog-js|window\.posthog/i},{name:`Plausible`,re:/plausible\.io\/js|window\.plausible/i},{name:`Google Analytics`,re:/googletagmanager\.com\/gtag\/js|google-analytics\.com\/analytics\.js|window\.gtag\b/i},{name:`Mixpanel`,re:/cdn\.mxpnl\.com|mixpanel-browser/i},{name:`Segment`,re:/cdn\.segment\.com\/analytics\.js|window\.analytics\b/i},{name:`Hotjar`,re:/static\.hotjar\.com|\(h,o,t,j,a,r\)/i},{name:`Amplitude`,re:/cdn\.amplitude\.com|amplitude\.getInstance/i},{name:`Heap`,re:/cdn\.heapanalytics\.com/i},{name:`FullStory`,re:/fullstory\.com\/s\/fs\.js|window\.FS\.identify/i}];var W=class{sessionId;cwd;cwdReal;undoRoot;readCount=0;writeCount=0;roundCount=0;writtenPathsSet=new Set;constructor(e){this.sessionId=e.sessionId??ee(),this.cwd=e.cwd,this.cwdReal=h.realpath(e.cwd),this.undoRoot=e.undoRoot??m.join(T.homedir(),`.zenovay`,`undo`)}incrementRound(){if(this.roundCount++,this.roundCount>B)throw new V(`round-cap`,`Tool-call recursion cap (${B}) exceeded.`)}stats(){return{sessionId:this.sessionId,reads:this.readCount,writes:this.writeCount,rounds:this.roundCount,writtenPaths:[...this.writtenPathsSet]}}async resolveForRead(e){return this.resolveSafe(e,`read`)}async resolveForWrite(e){return this.resolveSafe(e,`write`)}async resolveSafe(e,t){if(typeof e!=`string`||e.length===0)throw new V(`escape`,`Path must be a non-empty string.`);if(e.includes(`\0`))throw new V(`escape`,`Null byte in path.`);if(/^\\\\[?.]\\/.test(e)||/^\\\\[A-Za-z0-9]/.test(e))throw new V(`escape`,`Windows special path prefix: ${e}`);if(/%/.test(e))try{let t=decodeURIComponent(e);if(/%[0-9A-Fa-f]{2}/.test(t))throw new V(`escape`,`Double-encoded path: ${e}`);e=t}catch(t){throw t instanceof V?t:new V(`escape`,`Malformed percent-encoding: ${e}`)}if(e.includes(`\0`))throw new V(`escape`,`Null byte in decoded path.`);if(e.includes(`\\`))throw new V(`escape`,`Backslash in path (Windows-style separator not accepted): ${e}`);let n=await this.cwdReal,r=m.isAbsolute(e)?e:m.join(n,e),i=m.normalize(r),a=i;try{a=await h.realpath(i)}catch(e){if(e.code!==`ENOENT`)throw new V(`escape`,`realpath failed: ${e.message}`);let t=m.dirname(i);try{let e=await h.realpath(t);a=m.join(e,m.basename(i))}catch{}}if(!this.isWithin(a,n))throw new V(`escape`,`Path escapes cwd: ${e}`);let o=m.relative(n,a);for(let e of se)if(e.test(o)){if(t===`read`&&/(^|\/)node_modules\//.test(o))continue;throw new V(`blocklisted`,`Path is on the hard blocklist: ${o}`)}if(t===`write`){let e=oe.some(e=>e.test(o));if(!e&&!/^\.env(\.local)?$/.test(o)&&!/^\.claude\//.test(o)&&!/^\.cursor\//.test(o))throw new V(`not-allowlisted`,`Write path not on allowlist: ${o}`)}return a}isWithin(e,t){let n=m.relative(t,e);return!n.startsWith(`..`)&&!m.isAbsolute(n)}async safeRead(e){if(this.readCount>=R)throw new V(`read-cap`,`Read cap (${R}) reached.`);let t=await this.resolveForRead(e),n=await h.stat(t);if(n.size>L)throw new V(`too-large`,`File exceeds ${L}B: ${e} (${n.size}B)`);let r=await h.readFile(t),i=r.subarray(0,Math.min(r.length,8192));if(i.includes(0))throw new V(`binary-rejected`,`Binary content in ${e}.`);return this.readCount++,r.toString(`utf8`)}async safeWrite(e,t){if(this.writeCount>=z)throw new V(`write-cap`,`Write cap (${z}) reached.`);if(t.length>L)throw new V(`too-large`,`Write exceeds ${L}B: ${e}`);let n=await this.resolveForWrite(e),r=await h.readFile(n,`utf8`).catch(e=>{if(e.code===`ENOENT`)return null;throw e});if(r!==null){if(H.test(r)&&!H.test(t))throw new V(`destructive-tracker-removal`,`Refusing to write ${e}: existing Zenovay tracker tag would be removed. If you want to change the data-id, use patch_file to swap the attribute value instead of overwriting the file.`);for(let{name:n,re:i}of U)if(i.test(r)&&!i.test(t))throw new V(`destructive-competitor-removal`,`Refusing to write ${e}: existing ${n} tracker would be removed. Zenovay installs alongside competitors — never replace them.`)}let i=await this.journalBackup(n);await h.mkdir(m.dirname(n),{recursive:!0}),await h.writeFile(n,t,`utf8`),this.writeCount++;let a=await this.cwdReal;return this.writtenPathsSet.add(m.relative(a,n)),{backupPath:i}}async journalBackup(e){let t=await h.readFile(e).catch(e=>{if(e.code===`ENOENT`)return null;throw e}),n=m.join(this.undoRoot,this.sessionId);await h.mkdir(n,{recursive:!0,mode:448});let r=k.createHash(`sha256`).update(e).digest(`hex`).slice(0,16),i=m.join(n,`${r}.bak`),a=m.join(n,`manifest.jsonl`);t&&await h.writeFile(i,t,{mode:384});let o=JSON.stringify({abs:e,backupPath:t?i:null,ts:Date.now()});return await h.appendFile(a,o+`
|
|
2
|
-
`,{mode:384}),t?i:null}static wrapForModel(e,t){let n=k.createHash(`sha256`).update(t).digest(`hex`).slice(0,16),r=t.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`);return`<FILE path="${e}" sha256="${n}">\n${r}\n</FILE>`}static scrubSecrets(e){return ae(e)}};const ce=[`astro.config.ts`,`astro.config.mjs`,`astro.config.js`];async function le(e){for(let t of ce)if(await e.exists(t))return{matched:!0,confidence:.95,reason:`Detected Astro via \`${t}\`.`};let t=await e.readFile(`package.json`);if(t)try{let e=JSON.parse(t);if(e.dependencies?.astro??e.devDependencies?.astro)return{matched:!0,confidence:.8,reason:"Detected Astro via `astro` dependency."}}catch{}return{matched:!1,confidence:0,reason:"No astro.config.* or `astro` dependency found."}}function ue(e){let t=e.trackingCode??e.siteId??``,n=`<script defer data-id="${t}" data-allow-localhost="true" src="https://api.zenovay.com/z.js" is:inline></script>`;return[{targetPath:`src/layouts/Layout.astro`,anchorKind:`head-tag`,code:n,description:`Inject the Zenovay tracker inside <head> of the primary layout.`},{targetPath:`src/layouts/BaseHead.astro`,anchorKind:`head-tag`,code:n,description:"Fallback target when the project uses a dedicated `BaseHead.astro`."}]}const de={id:`astro`,displayName:`Astro`,detect:le,files:[{path:`src/layouts/Layout.astro`,kind:`mutate`,required:!1},{path:`src/layouts/BaseHead.astro`,kind:`mutate`,required:!1},{path:`.env`,kind:`create`,required:!0}],envVarName:`PUBLIC_ZENOVAY_SITE`,buildSnippets:ue},fe=[`app/layout.tsx`,`app/layout.ts`,`app/layout.jsx`,`app/layout.js`];async function pe(e){for(let t of fe)if(await e.exists(t))return t;return null}async function me(e){let t=await e.readFile(`package.json`);if(!t)return!1;try{let e=JSON.parse(t);return!!(e.dependencies?.next??e.devDependencies?.next)}catch{return!1}}async function he(e){let t=await me(e),n=await e.exists(`app`),r=await pe(e);return t?n?r?{matched:!0,confidence:.95,reason:`Detected Next.js App Router via \`next\` dep + \`${r}\`.`}:{matched:!1,confidence:.4,reason:"Found `app/` but no root layout file (layout.tsx/ts/jsx/js)."}:{matched:!1,confidence:0,reason:"No `app/` directory found — not an App Router project."}:{matched:!1,confidence:0,reason:"package.json does not list `next` as a dependency."}}function ge(e){let t=`app/layout.tsx`,n=e.trackingCode??e.siteId??``;return[{targetPath:t,anchorKind:`after-imports`,code:`import Script from 'next/script';`,description:`Import next/script to inject the Zenovay tracker.`},{targetPath:t,anchorKind:`wrap-children`,code:`<Script
|
|
3
|
-
defer
|
|
4
|
-
data-id="${n}"
|
|
5
|
-
data-allow-localhost="true"
|
|
6
|
-
src="https://api.zenovay.com/z.js"
|
|
7
|
-
strategy="afterInteractive"
|
|
8
|
-
/>
|
|
9
|
-
{children}`,description:`Add the Zenovay tracker <Script> next to children in the root layout.`}]}const _e={id:`next-app-router`,displayName:`Next.js (App Router)`,detect:he,files:[{path:`app/layout.tsx`,kind:`mutate`,required:!0}],envVarName:`NEXT_PUBLIC_ZENOVAY_SITE`,buildSnippets:ge},ve=[`pages/_app.tsx`,`pages/_app.ts`,`pages/_app.jsx`,`pages/_app.js`,`src/pages/_app.tsx`,`src/pages/_app.ts`,`src/pages/_app.jsx`,`src/pages/_app.js`];async function ye(e){for(let t of ve)if(await e.exists(t))return t;return null}async function be(e){let t=await e.readFile(`package.json`);if(!t)return!1;try{let e=JSON.parse(t);return!!(e.dependencies?.next??e.devDependencies?.next)}catch{return!1}}async function xe(e){let t=await be(e);if(!t)return{matched:!1,confidence:0,reason:"package.json does not list `next` as a dependency."};let n=await ye(e);if(n)return{matched:!0,confidence:.9,reason:`Detected Next.js Pages Router via \`${n}\`.`};let r=await e.exists(`app`),i=await e.glob(`pages/**/*.{tsx,ts,jsx,js}`);return i.length>0&&!r?{matched:!0,confidence:.7,reason:"Found `pages/` directory with route files but no `_app` — will create one."}:{matched:!1,confidence:.2,reason:`Next.js detected, but no pages-router entry point found.`}}function Se(e){let t=`pages/_app.tsx`,n=e.trackingCode??e.siteId??``,r=`import type { AppProps } from 'next/app';
|
|
10
|
-
import Script from 'next/script';
|
|
11
|
-
|
|
12
|
-
export default function App({ Component, pageProps }: AppProps) {
|
|
13
|
-
return (
|
|
14
|
-
<>
|
|
15
|
-
<Script
|
|
16
|
-
defer
|
|
17
|
-
data-id="${n}"
|
|
18
|
-
data-allow-localhost="true"
|
|
19
|
-
src="https://api.zenovay.com/z.js"
|
|
20
|
-
strategy="afterInteractive"
|
|
21
|
-
/>
|
|
22
|
-
<Component {...pageProps} />
|
|
23
|
-
</>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
`;return[{targetPath:t,anchorKind:`after-imports`,code:`import Script from 'next/script';`,description:"Import next/script in `_app`."},{targetPath:t,anchorKind:`wrap-children`,code:`<><Script defer data-id="${n}" data-allow-localhost="true" src="https://api.zenovay.com/z.js" strategy="afterInteractive" /><Component {...pageProps} /></>`,description:`Render the Zenovay tracker alongside the page component.`},{targetPath:t,anchorKind:`replace-file`,code:r,description:"Full replacement when `_app` does not exist yet."}]}const Ce={id:`next-pages-router`,displayName:`Next.js (Pages Router)`,detect:xe,files:[{path:`pages/_app.tsx`,kind:`mutate`,required:!0}],envVarName:`NEXT_PUBLIC_ZENOVAY_SITE`,buildSnippets:Se},we=E.object({modules:E.array(E.string()).optional(),runtimeConfig:E.object({public:E.record(E.string(),E.unknown()).optional()}).optional()}).passthrough();async function Te(e){let t=await e.readFile(`package.json`);if(!t)return{matched:!1,confidence:0,reason:`No package.json found.`};try{let e=JSON.parse(t),n=!!(e.dependencies?.nuxt??e.devDependencies?.nuxt??e.dependencies?.nuxt3??e.devDependencies?.nuxt3);if(n)return{matched:!0,confidence:.95,reason:"Detected Nuxt via `nuxt` / `nuxt3` dependency."}}catch{}let n=await e.exists(`nuxt.config.ts`)||await e.exists(`nuxt.config.js`)||await e.exists(`nuxt.config.mjs`);return n?{matched:!0,confidence:.6,reason:"Found `nuxt.config.*` but no explicit dependency listing."}:{matched:!1,confidence:0,reason:`No Nuxt dependency or config detected.`}}function Ee(e){let t=e.trackingCode??e.siteId??``,n=` app: {
|
|
27
|
-
head: {
|
|
28
|
-
script: [
|
|
29
|
-
{
|
|
30
|
-
defer: true,
|
|
31
|
-
src: 'https://api.zenovay.com/z.js',
|
|
32
|
-
'data-id': '${t}',
|
|
33
|
-
'data-allow-localhost': 'true',
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
},`;return[{targetPath:`nuxt.config.ts`,anchorKind:`head-tag`,code:n,description:"Add the Zenovay tracker to Nuxt's `app.head.script` so every page loads it."}]}const De={id:`nuxt`,displayName:`Nuxt`,detect:Te,files:[{path:`nuxt.config.ts`,kind:`mutate`,required:!0}],envVarName:`NUXT_PUBLIC_ZENOVAY_SITE`,buildSnippets:Ee},Oe=[`index.html`,`public/index.html`,`dist/index.html`];async function ke(e){for(let t of Oe)if(await e.exists(t))return{matched:!0,confidence:.5,reason:`Detected plain HTML project via \`${t}\`.`};let t=await e.glob(`**/*.html`);return t.length>0?{matched:!0,confidence:.3,reason:`Found ${t.length} HTML file(s); plain-HTML adapter is usable as fallback.`}:{matched:!1,confidence:0,reason:`No HTML files found in the project.`}}function Ae(e){let t=e.siteId??``,n=`<script defer\n data-id="${t}"\n data-allow-localhost="true"\n src="https://api.zenovay.com/z.js">\n</script>`;return[{targetPath:`index.html`,anchorKind:`head-tag`,code:n,description:`Inject the Zenovay tracker inside <head>. Repeat for every HTML file that contains a <head>.`}]}const je={id:`plain-html`,displayName:`Plain HTML`,detect:ke,files:[{path:`index.html`,kind:`mutate`,required:!0}],envVarName:`PUBLIC_ZENOVAY_SITE`,buildSnippets:Ae};async function Me(e){let t=await e.readFile(`package.json`);if(t)try{let e=JSON.parse(t),n={...e.dependencies??{},...e.devDependencies??{}},r=Object.keys(n).some(e=>e.startsWith(`@remix-run/`));if(r)return{matched:!0,confidence:.95,reason:"Detected Remix via `@remix-run/*` dependencies."}}catch{}return await e.exists(`remix.config.js`)||await e.exists(`remix.config.ts`)?{matched:!0,confidence:.8,reason:"Detected Remix via `remix.config.*`."}:{matched:!1,confidence:0,reason:`No Remix dependency or config detected.`}}function Ne(e){let t=e.trackingCode??e.siteId??``;return[{targetPath:`app/root.tsx`,anchorKind:`head-tag`,code:`<script defer data-id="${t}" data-allow-localhost="true" src="https://api.zenovay.com/z.js"></script>`,description:`Inline the Zenovay tracker <script> inside the document <head>.`}]}const Pe={id:`remix`,displayName:`Remix`,detect:Me,files:[{path:`app/root.tsx`,kind:`mutate`,required:!0}],envVarName:`PUBLIC_ZENOVAY_SITE`,buildSnippets:Ne};async function Fe(e){let t=await e.readFile(`package.json`);if(!t)return{matched:!1,confidence:0,reason:`No package.json found.`};try{let e=JSON.parse(t),n=!!(e.dependencies?.[`@sveltejs/kit`]??e.devDependencies?.[`@sveltejs/kit`]);return n?{matched:!0,confidence:.95,reason:"Detected SvelteKit via `@sveltejs/kit` dependency."}:{matched:!1,confidence:0,reason:"`@sveltejs/kit` not in dependencies."}}catch{return{matched:!1,confidence:0,reason:`package.json is not valid JSON.`}}}function Ie(e){let t=e.trackingCode??e.siteId??``,n=`<svelte:head>
|
|
38
|
-
<script defer data-id="${t}" data-allow-localhost="true" src="https://api.zenovay.com/z.js"></script>
|
|
39
|
-
</svelte:head>
|
|
40
|
-
|
|
41
|
-
<slot />
|
|
42
|
-
`;return[{targetPath:`src/routes/+layout.svelte`,anchorKind:`replace-file`,code:n,description:`Root layout that loads the Zenovay tracker in every route via <svelte:head>.`}]}const Le={id:`sveltekit`,displayName:`SvelteKit`,detect:Fe,files:[{path:`src/routes/+layout.svelte`,kind:`mutate`,required:!0}],envVarName:`PUBLIC_ZENOVAY_SITE`,buildSnippets:Ie},Re=[_e,Ce,De,Le,de,Pe,je];async function G(e){let t=[];for(let n of Re){let r=await n.detect(e);t.push({adapter:n,result:r})}let n=[...t].sort((e,t)=>t.result.confidence-e.result.confidence),r=n[0],i=r&&r.result.matched?r.adapter:null;return{adapter:i,ranked:n}}function K(e){let t=t=>m.resolve(e,t);return{cwd:e,async readFile(e){try{return await h.readFile(t(e),`utf8`)}catch(e){let t=e.code;if(t===`ENOENT`||t===`EISDIR`)return null;throw e}},async exists(e){try{return await h.access(t(e)),!0}catch{return!1}},async glob(t){return D(t,{cwd:e,dot:!1,gitignore:!0,onlyFiles:!0,followSymbolicLinks:!1})}}}async function q(e,t){let n=K(e),{adapter:r,ranked:i}=await G(n),a=i[0];return r&&a&&a.result.confidence>=.7?r:t?t.pickInteractively(i):r}function ze(e,t){let n=/[\s"'#=]/.test(t)||t===``,r=n?`"${t.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`:t;return`${e}=${r}`}function Be(e){let t=new Set;for(let n of e.split(/\r?\n/)){let e=n.trim();if(!e||e.startsWith(`#`))continue;let r=e.indexOf(`=`);if(r<=0)continue;let i=e.slice(0,r).trim();/^[A-Za-z_][A-Za-z0-9_]*$/.test(i)&&t.add(i)}return t}async function J(e,t,n={}){let r=n.filename??`.env.local`,i=m.resolve(e,r),a=``,o=!0;try{a=await h.readFile(i,`utf8`)}catch(e){if(e.code===`ENOENT`)o=!1;else throw e}let s=o?Be(a):new Set,c=[],l=[],u=[];for(let[e,n]of Object.entries(t)){if(s.has(e)){l.push(e);continue}u.push(ze(e,n)),c.push(e)}if(c.length===0)return{created:!1,existing:o,addedKeys:c,skippedKeys:l};let d=`# Added by Zenovay CLI`,f;if(o){let e=a.length>0&&!a.endsWith(`
|
|
43
|
-
`);f=a+(e?`
|
|
44
|
-
`:``)+`
|
|
45
|
-
`+d+`
|
|
46
|
-
`+u.join(`
|
|
47
|
-
`)+`
|
|
48
|
-
`}else f=d+`
|
|
49
|
-
`+u.join(`
|
|
50
|
-
`)+`
|
|
51
|
-
`;if(o)await h.writeFile(i,f,`utf8`);else{let e=await h.open(i,`w`,384);try{await e.writeFile(f,`utf8`)}finally{await e.close()}}return{created:!o,existing:o,addedKeys:c,skippedKeys:l}}const Ve=`https://api.zenovay.com/mcp`,He=E.object({url:E.string().url(),headers:E.record(E.string(),E.string()).optional()}),Ue=E.object({mcpServers:E.record(E.string(),He).optional()}).passthrough();function We(e){return e.HOME??e.USERPROFILE??T.homedir()}function Ge(e){return e.APPDATA??null}function Ke(e,t){let n=We(t),r=Ge(t),i=[];return i.push({id:`cursor`,displayName:`Cursor`,configPath:m.join(n,`.cursor`,`mcp.json`)}),e===`win32`&&r&&i.push({id:`cursor`,displayName:`Cursor (AppData)`,configPath:m.join(r,`Cursor`,`User`,`globalStorage`,`cursor.mcp`,`mcp.json`)}),e===`darwin`?i.push({id:`claude-desktop`,displayName:`Claude Desktop`,configPath:m.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`)}):e===`win32`&&r?i.push({id:`claude-desktop`,displayName:`Claude Desktop`,configPath:m.join(r,`Claude`,`claude_desktop_config.json`)}):i.push({id:`claude-desktop`,displayName:`Claude Desktop`,configPath:m.join(n,`.config`,`Claude`,`claude_desktop_config.json`)}),i.push({id:`vscode`,displayName:`VS Code`,configPath:m.join(n,`.vscode`,`mcp.json`)}),i}async function qe(e){try{return await h.access(e),!0}catch{return!1}}async function Je(e){try{let t=await h.readFile(e,`utf8`);if(t.trim().length===0)return{};let n=JSON.parse(t),r=Ue.safeParse(n);return r.success?r.data:n&&typeof n==`object`?n:{}}catch{return{}}}function Ye(e){return{url:Ve,headers:{Authorization:`Bearer ${e}`}}}async function Y(e){let t=e.env??process.env,n=e.platform??process.platform,r=new Set(e.skip??[]),i=[],a=[],o=[],s=new Set,c=Ye(e.accessToken);for(let e of Ke(n,t)){if(r.has(e.id)){a.push(e.displayName);continue}if(s.has(e.configPath))continue;s.add(e.configPath);try{let t=await qe(e.configPath);if(!t){a.push(e.displayName);continue}let n=await Je(e.configPath),r=`${e.configPath}.bak`;await h.copyFile(e.configPath,r);let o={...n,mcpServers:{...n.mcpServers??{},zenovay:c}};await h.mkdir(m.dirname(e.configPath),{recursive:!0}),await h.writeFile(e.configPath,JSON.stringify(o,null,2)+`
|
|
52
|
-
`,`utf8`),i.push(e.displayName)}catch(t){o.push({client:e.displayName,message:t instanceof Error?t.message:String(t)})}}return{installed:i,skipped:a,errors:o}}async function Xe(e,t,n){let r=n.timeoutMs??18e4,i=n.pollIntervalMs??2e3,a=n.now??(()=>Date.now()),o=n.sleep??(e=>new Promise(t=>setTimeout(t,e))),s=a(),c=s+r;for(n.onTick?.(0);;){let l=await n.api.getFirstEvent({siteId:e,since:t});if(l.received)return{received:!0,event:l.event};let u=a()-s;if(u>=r)return{received:!1};let d=c-a(),f=Math.min(i,Math.max(0,d));if(f<=0)return{received:!1};await o(f),n.onTick?.(a()-s)}}const Ze=E.object({path:E.string().min(1)}),Qe=E.object({path:E.string().min(1),content:E.string(),reason:E.string().min(1)}),$e=E.object({path:E.string().min(1),patch:E.string().min(1),reason:E.string().min(1)}),et=E.object({}),tt=E.object({question:E.string().min(1),choices:E.array(E.string()).optional()});async function nt(e,t){let n=Ze.safeParse(t);if(!n.success)return{ok:!1,content:null,error:`invalid_args`};try{let t=await e.safeRead(n.data.path),r=W.scrubSecrets(t);return{ok:!0,content:W.wrapForModel(n.data.path,r)}}catch(e){return{ok:!1,content:null,error:e.message}}}async function rt(e,t,n){let r=Qe.safeParse(t);if(!r.success)return{ok:!1,content:null,error:`invalid_args`};let{path:i,content:a,reason:o}=r.data,s=``;try{s=await e.safeRead(i)}catch{s=``}let c=await n.approve({path:i,oldContent:s,newContent:a,reason:o});if(c===`n`)return{ok:!1,content:null,error:`skipped_by_user`};if(c===`e`)return{ok:!1,content:null,error:`deferred_to_user_edit`};try{let{backupPath:t}=await e.safeWrite(i,a);return{ok:!0,content:{path:i,backupPath:t}}}catch(e){return{ok:!1,content:null,error:e.message}}}async function it(e,t,n){let r=$e.safeParse(t);if(!r.success)return{ok:!1,content:null,error:`invalid_args`};let{path:i,patch:a,reason:o}=r.data;if(/^\*\*\*\s+Begin Patch/m.test(a)||/^\*\*\*\s+Update File:/m.test(a))return{ok:!1,content:null,error:'unsupported_patch_format: This tool only accepts STANDARD unified diff with `--- a/...`, `+++ b/...`, and `@@ -N,M +N,M @@` headers. The "*** Begin Patch / *** Update File:" V4A format is NOT supported. Please call write_file with the full new file content instead.'};let s;try{s=await e.safeRead(i)}catch(e){return{ok:!1,content:null,error:e.message}}let c;try{c=A(s,a)}catch(e){return{ok:!1,content:null,error:`patch_failed: ${e.message}. Please call write_file with the full new file content instead — write_file is more reliable than patch_file for this use case.`}}return c===!1||typeof c!=`string`?{ok:!1,content:null,error:`patch_did_not_apply_cleanly. The patch context may not match the file. Please call write_file with the full new file content instead.`}:rt(e,{path:i,content:c,reason:o},n)}async function at(e){try{let t=K(e),{adapter:n,ranked:r}=await G(t);return{ok:!0,content:{matched:n!==null,adapter:n?.id,displayName:n?.displayName,ranked:r.map(e=>({id:e.adapter.id,confidence:e.result.confidence,reason:e.result.reason}))}}}catch(e){return{ok:!1,content:null,error:e.message}}}async function ot(e,t){let n=tt.safeParse(t);if(!n.success)return{ok:!1,content:null,error:`invalid_args`};try{let t=await e.ask(n.data);return{ok:!0,content:{answer:t}}}catch(e){return{ok:!1,content:null,error:e.message}}}async function st(e){let{api:t,sandbox:n,approval:r,prompter:a,handlers:o}=e,s=[...e.initialMessages],c=``,l=0;for(;l<B;){n.incrementRound(),l++;let u=await t.openAiStream(`install`,{messages:s,cwd_fingerprint:n.sessionId,diagnosis:e.diagnosis,targetTrackingCode:e.targetTrackingCode}),d=[],f=``;for await(let e of i(u))switch(e.type){case`delta`:f+=e.content,o?.onDelta?.(e.content);break;case`tool_start`:o?.onToolStart?.({id:e.id,name:e.name});break;case`tool_call`:{let t=await ct(e.name,e.arguments,{sandbox:n,cwd:n.cwd,approval:r,prompter:a});d.push({id:e.id,name:e.name,arguments:e.arguments,result:t}),o?.onToolResult?.({id:e.id,name:e.name,result:t});break}case`usage`:o?.onUsage?.(e);break;case`error`:throw o?.onError?.(e),Error(`[${e.code}] ${e.message}`);case`done`:break}if(f&&(c+=f),d.length===0){f&&s.push({role:`assistant`,content:f});break}s.push({role:`assistant`,content:f,toolCalls:d.map(e=>({id:e.id,type:`function`,function:{name:e.name,arguments:JSON.stringify(e.arguments)}}))});for(let e of d)s.push({role:`tool`,toolCallId:e.id,toolName:e.name,content:JSON.stringify(e.result)})}return{finalText:c,rounds:l}}async function ct(e,t,n){try{switch(e){case`read_file`:return await nt(n.sandbox,t);case`write_file`:return await rt(n.sandbox,t,n.approval);case`patch_file`:return await it(n.sandbox,t,n.approval);case`detect_framework`:return await at(n.cwd);case`ask_user`:return await ot(n.prompter,t);default:return{ok:!1,content:null,error:`unknown_tool:${e}`}}}catch(e){return{ok:!1,content:null,error:`tool_threw: ${e.message}`}}}const lt=e=>`<script defer\n data-id="${e}"\n data-allow-localhost="true"\n src="https://api.zenovay.com/z.js">\n</script>`;async function ut(e){let t={installed:[],skipped:[],errors:[]},n=await D([`**/*.html`,`!node_modules/**`,`!.git/**`,`!dist/**`,`!.next/**`,`!.nuxt/**`,`!build/**`,`!.output/**`],{cwd:e.cwd,gitignore:!0,absolute:!1});if(n.length===0)return t;let r=lt(e.trackingCode),i=RegExp(`data-id\\s*=\\s*["']${dt(e.trackingCode)}["']`);for(let a of n){let n=m.join(e.cwd,a),o;try{o=await h.readFile(n,`utf8`)}catch(e){t.errors.push({file:a,error:e.message});continue}if(H.test(o)&&i.test(o)){t.skipped.push({file:a,reason:`already installed with correct tracking code`});continue}let s;if(H.test(o))s=o.replace(/(<script[^>]*src\s*=\s*["']https:\/\/(?:api|cdn)\.zenovay\.com\/[^"']+["'][^>]*>)/i,t=>t.replace(/data-id\s*=\s*["']ZV_\w+["']/i,`data-id="${e.trackingCode}"`)),s===o&&(s=o.replace(/<script(\s)/i,`<script$1data-id="${e.trackingCode}"$1`));else if(e.updateOnly){t.skipped.push({file:a,reason:`updateOnly=true and no Zenovay tag present`});continue}else if(/<\/head>/i.test(o)){if(s=o.replace(/(\n[\t ]*)?<\/head>/i,(e,t)=>{let n=t??`
|
|
53
|
-
`,i=r.replace(/\n/g,`${n}`);return`${n}${i}${n}</head>`}),s===o){t.skipped.push({file:a,reason:`</head> regex did not match unexpectedly`});continue}}else{t.skipped.push({file:a,reason:`no <head>...</head> in file (fragment or non-page)`});continue}let c=null;for(let{name:e,re:t}of U)if(t.test(o)&&!t.test(s)){c=e;break}if(c){t.errors.push({file:a,error:`would remove ${c} tracker — refusing to write`});continue}try{await h.writeFile(n,s,`utf8`),t.installed.push(a)}catch(e){t.errors.push({file:a,error:e.message})}}return t}function dt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ft(){let e=[12,15,18,22,28,35,41,50,58,64,72,78],t=p(e,24);return[` ↑`,` ${t}`,` └────────────────────────`,` May Jun Jul Aug Sep`]}function pt(){return[` Landing page ████████████████████ 100%`,` ↓ -28%`,` Pricing ██████████████░░░░░░ 72%`,` ↓ -50%`,` Checkout ███████░░░░░░░░░░░░░ 36%`,` ↓ -64%`,` Purchased ███░░░░░░░░░░░░░░░░░ 13%`]}function mt(){return[` ▇▇▇▇▇▇▇▇▇▎ 89 Sarah K. /pricing 🇺🇸`,` ▇▇▇▇▇▇░░░░ 61 anon /docs 🇩🇪`,` ▇▇▇░░░░░░░ 34 anon /changelog 🇯🇵`]}function ht(){return[` LCP ● 2.1s good ████████████░░░░░░`,` INP ● 89ms good ██████████████████`,` CLS ⚠ 0.14 needs ████████████░░░░░░`,` TTFB ● 380ms good ███████████████░░░`]}const X=[{title:`Welcome`,body:[`The wizard is an agent — it handles the entire`,`Zenovay setup process on your behalf.`,``,`Reading your project, deciding where the tracker`,`belongs, and writing the snippet for you.`]},{title:`Events`,body:[`Events are the foundation of Zenovay analytics.`,``,`Every pageview, click, and custom action is an`,`event. Group them into Goals to track conversions.`]},{title:`Trends`,body:[`Use trends to measure growth.`,``,`See how visitors, signups, and revenue have`,`changed over the last week, month, or quarter.`],visual:ft},{title:`Funnels`,body:[`Funnels reveal where users drop off.`,``,`Define the steps you care about — landing,`,`pricing, checkout, purchase — and Zenovay shows`,`the per-step conversion rate.`],visual:pt},{title:`Live visitors`,body:[`Watch every visitor in real time, ranked by an`,`AI score that highlights high-intent traffic.`,``,"Use `zenovay visitors --live` after install."],visual:mt},{title:`Core Web Vitals`,body:[`LCP, INP, CLS — Google's page-experience metrics,`,`collected automatically once the tracker is in.`,``,"Use `zenovay vitals` to see them per page + device."],visual:ht},{title:`MCP integration`,body:[`Your CLI session can install Zenovay's MCP server`,`into Cursor / Claude Desktop / VS Code.`,``,`Then ask your AI: "what were my top pages today?"`,`and it queries Zenovay directly.`]},{title:`AI insights`,body:[`Zenovay watches your data and surfaces anomalies`,`automatically — traffic spikes, error bursts,`,`revenue drops — without you needing to ask.`,``,"Run `zenovay ai` after install to chat with them."]},{title:`Privacy-first`,body:[`No cookies required. No third-party trackers.`,`Cookieless mode is one toggle in your dashboard.`,``,`GDPR, CCPA, and PECR-compliant out of the box.`]}],gt=8e3,_t=({width:e,height:t})=>{let[n,r]=w(0);S(()=>{let e=setInterval(()=>{r(e=>(e+1)%X.length)},gt);return()=>clearInterval(e)},[]);let i=X[n],a=i.visual?i.visual():[],o=X.map((e,t)=>t===n?`●`:`·`).join(` `);return x.createElement(g,{flexDirection:`column`,width:e,height:t,paddingX:2,paddingY:1},x.createElement(g,{marginBottom:1},x.createElement(_,{color:`magentaBright`,bold:!0},`Learn`)),x.createElement(g,{marginBottom:1},x.createElement(_,{bold:!0,color:`white`},i.title)),i.body.map((e,t)=>x.createElement(_,{key:t,color:`gray`},e||` `)),a.length>0&&x.createElement(g,{flexDirection:`column`,marginTop:1},a.map((e,t)=>x.createElement(_,{key:t,color:`cyan`},e))),x.createElement(g,{flexGrow:1}),x.createElement(g,{marginTop:1},x.createElement(_,{color:`gray`,dimColor:!0},o,` · `,n+1,` / `,X.length)))},vt={pending:`·`,active:`⠋`,done:`✓`,error:`✗`},yt={pending:`gray`,active:`magenta`,done:`green`,error:`red`},bt=({tasks:e,width:t,height:n,liveLine:r})=>{let i=e.filter(e=>e.status===`done`).length;return x.createElement(g,{flexDirection:`column`,width:t,height:n,paddingX:2,paddingY:1},x.createElement(g,{marginBottom:1},x.createElement(_,{color:`magentaBright`,bold:!0},`Tasks`)),e.map(e=>x.createElement(g,{key:e.id,flexDirection:`column`},x.createElement(g,null,e.status===`active`?x.createElement(_,{color:`magenta`},x.createElement(O,{type:`dots`})):x.createElement(_,{color:yt[e.status]},vt[e.status]),x.createElement(_,null,` `),x.createElement(_,{color:e.status===`pending`?`gray`:`white`},e.label)),e.detail&&x.createElement(g,{paddingLeft:2},x.createElement(_,{color:`gray`,dimColor:!0},e.detail)))),x.createElement(g,{flexGrow:1}),r&&x.createElement(g,{marginTop:1},x.createElement(_,{color:`cyan`},`◆ `),x.createElement(_,{color:`white`},r)),x.createElement(g,{marginTop:1},x.createElement(_,{color:`gray`,dimColor:!0},i,` / `,e.length)))};async function xt(e){if(o(e))return St(e);let t=`quit`,n=null,r=await new Promise(r=>{let{unmount:i,waitUntilExit:a}=v(x.createElement(Ct,{opts:e,onExit:(e,a,o)=>{t=a??`quit`,n=o??null,i(),r(e)}}));a().catch(()=>r(1))});if(r!==0||t===`quit`||!n)return r;let i=n.id;if(t===`watch`){let{watchCommand:t}=await import(`./watch-Bgjke7jm.js`);return t({cliVersion:e.cliVersion,siteId:i})}if(t===`events`){let{eventsTailCommand:t}=await import(`./events-tail-D6UfbRj7.js`);return t({cliVersion:e.cliVersion,siteId:i})}return 0}async function St(t){try{let i=await e(),o=await q(t.cwd);if(!o)return a({type:`error`,code:`no_framework`,message:`Could not detect framework (headless mode has no picker).`}),2;a({type:`framework.detected`,framework:o.id,confidence:1});let s=await r({strict:!1});if(!s&&!process.env.ZENOVAY_API_TOKEN)return a({type:`error`,code:`not_logged_in`,message:"Run `zenovay login` first (or set ZENOVAY_API_TOKEN)."}),2;let c=new n({config:i,cliVersion:t.cliVersion,token:s}),l=await c.getSites(),u=t.siteId?l.find(e=>e.id===t.siteId):l[0];if(!u&&t.siteId)return a({type:`error`,code:`site_not_found`,message:`Site ${t.siteId} not found.`}),2;if(!u)return a({type:`error`,code:`no_site`,message:`No sites exist; create one at app.zenovay.com or re-run interactively.`}),2;a({type:`info`,message:`Using site ${u.id} (${u.name}) trackingCode=${u.trackingCode??u.id}`});let d=await J(t.cwd,{[o.envVarName]:u.trackingCode??u.id});return a({type:`info`,message:`env vars added: ${d.addedKeys.join(`,`)}`}),a({type:`done`,command:`init`,exitCode:0}),0}catch(e){return a({type:`error`,code:`init_failed`,message:e.message}),1}}const Ct=({opts:t,onExit:i})=>{let{exit:a}=y(),[o,u]=w(`intro`),[d,p]=w(null),[m,h]=w([]),[v,b]=w(null),[T,E]=w(null),[D,k]=w(null),[ee,A]=w([]),[te,j]=w(void 0),[M,N]=w(null),[P,F]=w(0),I=C(!1);return S(()=>(process.stdout.isTTY&&process.stdout.write(`\x1B[?1049h\x1B[H`),()=>{process.stdout.isTTY&&process.stdout.write(`\x1B[?1049l`)}),[]),S(()=>{I.current||(I.current=!0,(async()=>{try{u(`detecting`);let i=await q(t.cwd);if(!i){k(`Could not detect your framework. Supported: Next.js, Nuxt, SvelteKit, Astro, Remix, plain HTML.`),u(`error`);return}p(i);let a=await r({strict:!1});!process.env.ZENOVAY_API_TOKEN&&!a&&(u(`login`),await s({cliVersion:t.cliVersion})),u(`loading-sites`);let o=await e(),c=await r({strict:!1}),l=new n({config:o,cliVersion:t.cliVersion,token:c}),d=await l.getSites(),f=await Lt(t.cwd),m=Rt(d,f);if(h(d),b(f),d.length===0){u(`create-site`);return}if(t.siteId){let e=d.find(e=>e.id===t.siteId);if(!e){k(`Site ${t.siteId} not found in your account.`),u(`error`);return}E(e),Z(e,i,t,{setPhase:u,setErrorMsg:k,setTasks:A,setLiveLine:j,setSandboxStats:N});return}if(t.yes&&m){E(m),Z(m,i,t,{setPhase:u,setErrorMsg:k,setTasks:A,setLiveLine:j,setSandboxStats:N});return}u(`site-picker`)}catch(e){k(e.message),u(`error`)}})())},[]),S(()=>{o===`error`&&setTimeout(()=>{a(),i(1)},8e3)},[o]),x.createElement(g,{flexDirection:`column`},x.createElement(l,{version:t.cliVersion,subtitle:`AI install wizard`}),o===`intro`&&x.createElement(wt,null),o===`detecting`&&x.createElement(c,{title:`Scanning`,state:`busy`},x.createElement(g,null,x.createElement(_,{color:`magenta`},x.createElement(O,{type:`dots`})),x.createElement(_,null,` Detecting framework…`))),o===`login`&&x.createElement(c,{title:`Authenticating`,state:`busy`},x.createElement(_,null,`Opening browser for login… (paste ZENOVAY_API_TOKEN env var to skip)`)),o===`loading-sites`&&x.createElement(c,{title:`Loading your sites`,state:`busy`},x.createElement(g,null,x.createElement(_,{color:`magenta`},x.createElement(O,{type:`dots`})),x.createElement(_,null,` Fetching your Zenovay sites…`))),o===`site-picker`&&d&&x.createElement(Et,{sites:m,preselectHint:v,onPick:e=>{if(e===`create-new`){u(`create-site`);return}E(e),Z(e,d,t,{setPhase:u,setErrorMsg:k,setTasks:A,setLiveLine:j,setSandboxStats:N})}}),o===`create-site`&&x.createElement(c,{title:`Create a new site`,state:`warn`},x.createElement(_,{color:`yellow`},"No site picked (or none exist yet). Visit https://app.zenovay.com/websites to create one, then re-run `zenovay init`."),x.createElement(_,{color:`gray`},`(Inline site creation from the CLI is scheduled for V1.1 — it requires a plan-limit check.)`)),o===`agent`&&d&&T&&x.createElement(Tt,{adapter:d,site:T,tasks:ee,liveLine:te}),o===`install-complete`&&d&&T&&x.createElement(kt,{adapter:d,site:T,stats:M,onCommit:()=>u(`commit-prompt`),onSkipCommit:()=>u(`deploy-prompt`)}),o===`commit-prompt`&&T&&x.createElement(At,{cwd:t.cwd,onDone:e=>{e.committed&&j(`Pushed ${e.shortSha} to ${e.branch}`),u(`deploy-prompt`)},onError:e=>{k(e),u(`error`)}}),o===`deploy-prompt`&&T&&x.createElement(jt,{site:T,onDeployed:()=>u(`visit-prompt`),onSkip:()=>u(`verify`)}),o===`visit-prompt`&&T&&x.createElement(Mt,{site:T,onContinue:()=>u(`verify`)}),o===`verify`&&T&&x.createElement(Pt,{site:T,elapsed:P,onTick:e=>F(e),onArrived:()=>u(`success`),onTimeout:()=>u(`success`)}),o===`success`&&d&&T&&x.createElement(Ot,{adapter:d,site:T,stats:M,onPick:e=>{a(),i(0,e,T)}}),o===`error`&&x.createElement(c,{title:`Install failed`,state:`err`},x.createElement(_,{color:`red`},D??`Unknown error`)),x.createElement(f,{items:[{key:`q`,label:`quit`},{key:`ctrl-c`,label:`abort`}]}))};async function Z(i,a,o,s){try{s.setPhase(`agent`);let c=await e(),l=await r({strict:!1}),u=new n({config:c,cliVersion:o.cliVersion,token:l}),d=new W({cwd:o.cwd}),f=i.trackingCode??i.id;await t({defaultSiteId:i.id,defaultSiteName:i.name}).catch(()=>void 0);let p=await I(o.cwd,f);if(p.recommendation===`no-op`){s.setTasks(e=>e.map(e=>e.id===`detect`||e.id===`read`||e.id===`write`?{...e,status:`done`,detail:`already installed correctly`}:e)),s.setLiveLine(p.summary),s.setSandboxStats?.({reads:0,writes:0,rounds:0}),!o.skipMcp&&l&&await Y({accessToken:l.accessToken}).catch(()=>void 0),s.setPhase(`install-complete`);return}p.competitors.length>0&&s.setLiveLine(`Detected ${p.competitors.map(e=>e.name).join(`, `)} — will install Zenovay alongside (won't touch their tags).`);let m=a.id===`plain-html`&&(p.recommendation===`fresh-install`||p.recommendation===`fresh-install-alongside-competitor`||p.recommendation===`update-tracking-code`);if(m){s.setTasks(e=>e.map(e=>e.id===`detect`?{...e,status:`done`,detail:`Plain HTML`}:e)),s.setLiveLine(`Plain HTML — using fast install path (no AI needed)…`);let e=await ut({cwd:o.cwd,trackingCode:f,updateOnly:p.recommendation===`update-tracking-code`});if(e.installed.length===0&&e.errors.length===0)throw Error(`No HTML files were modified. Either no .html files contain a <head>...</head> block, or every file already has the correct tracker.`);if(e.installed.length===0&&e.errors.length>0)throw Error(`Programmatic install failed for all ${e.errors.length} file(s). First error: ${e.errors[0].file}: ${e.errors[0].error}`);s.setTasks(t=>t.map(t=>t.id===`read`||t.id===`write`?{...t,status:`done`,detail:`${e.installed.length} file(s)`}:t)),s.setLiveLine(`Tracker added to ${e.installed.length} file(s). Skipped ${e.skipped.length}, errored ${e.errors.length}.`);let t=await J(o.cwd,{[a.envVarName]:f});if(s.setTasks(e=>e.map(e=>e.id===`env`?{...e,status:`done`,detail:`${t.addedKeys.length} key(s) added`}:e)),!o.skipMcp&&l){let e=await Y({accessToken:l.accessToken}).catch(()=>null);s.setTasks(t=>t.map(t=>t.id===`mcp`?{...t,status:`done`,detail:e&&e.installed.length>0?e.installed.join(`, `):`none detected`}:t))}else s.setTasks(e=>e.map(e=>e.id===`mcp`?{...e,status:`done`,detail:`skipped`}:e));s.setLiveLine(void 0),s.setSandboxStats?.({reads:e.installed.length,writes:e.installed.length,rounds:0}),s.setPhase(`install-complete`);return}let h=a.buildSnippets({trackingCode:f,siteId:i.id}),g=`Install Zenovay tracking into this ${a.displayName} project.\nSite: ${i.name} (trackingCode: ${f}).\n1. Call detect_framework to confirm the framework.\n2. Read the entry file(s) for this framework:\n`+a.files.map(e=>` - ${e.path}`).join(`
|
|
54
|
-
`)+`
|
|
55
|
-
3. Insert the tracker using the snippet below.
|
|
56
|
-
4. Confirm the change with a diff before writing.
|
|
57
|
-
|
|
58
|
-
Snippet reference (anchored by anchorKind — adapt to the actual file):
|
|
59
|
-
`+h.map(e=>` ${e.anchorKind} @ ${e.targetPath}:\n ${e.code.replace(/\n/g,`
|
|
60
|
-
`)}`).join(`
|
|
61
|
-
|
|
62
|
-
`);s.setTasks([{id:`detect`,label:`Detect framework`,status:`active`},{id:`read`,label:`Read project entry files`,status:`pending`},{id:`write`,label:`Insert tracker snippet`,status:`pending`},{id:`env`,label:`Write env vars (.env.local)`,status:`pending`},{id:`mcp`,label:`Install MCP clients (Cursor/Claude/VS Code)`,status:`pending`},{id:`verify`,label:`Wait for first event`,status:`pending`}]);let _=(e,t,n)=>{s.setTasks(r=>r.map(r=>r.id===e?{...r,status:t,detail:n??r.detail}:r))},v=null;try{await st({api:u,sandbox:d,approval:{async approve(){return`y`}},prompter:{async ask({question:e}){return e}},handlers:{onToolStart:({name:e})=>{e===`detect_framework`?(_(`detect`,`active`),s.setLiveLine(`Inspecting package.json + config files…`)):e===`read_file`?(_(`detect`,`done`),_(`read`,`active`)):(e===`write_file`||e===`patch_file`)&&(_(`read`,`done`),_(`write`,`active`))},onToolResult:({name:e,result:t})=>{let n=t?.ok!==!1,r=t?.content??{};e===`detect_framework`&&n&&(_(`detect`,`done`,a.displayName),s.setLiveLine(`Detected ${a.displayName}`)),e===`read_file`&&n&&r.path&&s.setLiveLine(`Read ${r.path}`),(e===`write_file`||e===`patch_file`)&&n&&r.path&&s.setLiveLine(`Wrote ${r.path}`)},onDelta:e=>{let t=e.replace(/\s+/g,` `).trim();t.length>4&&s.setLiveLine(t.slice(0,80))}},initialMessages:[{role:`user`,content:g}],diagnosis:p,targetTrackingCode:f})}catch(e){v=e}let y=d.stats();if(y.writes===0){let e=v?`Agent error: ${v.message}`:`Agent returned without writing any files (${y.reads} reads, ${y.rounds} rounds). The model may have refused or the AI Gateway may be misconfigured. Check api.zenovay.com logs.`;throw Error(e)}let b=a.files.map(e=>e.path),x=y.writtenPaths.some(e=>b.some(t=>e===t||e.endsWith(`/${t}`)));if(!x)throw Error(`Agent wrote to: [${y.writtenPaths.join(`, `)}] but never modified the framework's tracker target file(s): [${b.join(`, `)}]. The tracker is NOT installed. The model likely put the trackingCode into .env.local instead of into the HTML/JSX entry file.`);_(`write`,`done`),_(`env`,`active`),s.setLiveLine(`Adding env var to .env.local`);let S=await J(o.cwd,{[a.envVarName]:f});if(_(`env`,`done`,`${S.addedKeys.length} key(s) added`),!o.skipMcp&&l){_(`mcp`,`active`),s.setLiveLine(`Detecting Cursor / Claude Desktop / VS Code…`);let e=await Y({accessToken:l.accessToken}).catch(()=>null);e&&e.installed.length>0?_(`mcp`,`done`,e.installed.join(`, `)):_(`mcp`,`done`,`none detected`)}else _(`mcp`,`done`,`skipped`);s.setTasks(e=>e.map(e=>e.id===`detect`||e.id===`read`||e.id===`write`?{...e,status:e.status===`pending`?`done`:e.status}:e)),s.setLiveLine(void 0),s.setSandboxStats?.(y),s.setPhase(`install-complete`)}catch(e){s.setErrorMsg(e.message),s.setPhase(`error`)}}const wt=()=>x.createElement(c,{title:`Zenovay wants to set up your project`,state:`idle`},x.createElement(_,null,`We'll use AI to analyze your codebase and add the Zenovay tracker.`),x.createElement(_,{color:`gray`},`.env* contents stay on your machine. Only framework metadata reaches api.zenovay.com.`)),Tt=({adapter:e,site:t,tasks:n,liveLine:r})=>{let i=process.stdout.columns??100,a=(process.stdout.rows??30)-8,o=Math.floor(i/2)-1,s=Math.max(14,a);return x.createElement(g,{flexDirection:`column`},x.createElement(g,{flexDirection:`row`,minHeight:s,borderStyle:`round`,borderColor:`gray`},x.createElement(g,{width:o,flexDirection:`column`},x.createElement(_t,{width:o,height:s})),x.createElement(g,{width:1,flexDirection:`column`},x.createElement(_,{color:`gray`},`│`)),x.createElement(g,{width:o,flexDirection:`column`},x.createElement(bt,{tasks:n,liveLine:r,width:o,height:s}))),x.createElement(g,{marginTop:1},x.createElement(_,{color:`gray`},`Site: `,t.name,` · code: `,t.trackingCode??t.id,` · Framework: `,e.displayName)))},Et=({sites:e,preselectHint:t,onPick:n})=>{let r=Rt(e,t),i=e.filter(e=>e.id!==r?.id),a=r?[r,...i]:i,o=[...a.map(e=>({label:It(e,e.id===r?.id),value:e,description:e.trackingCode?`trackingCode: ${e.trackingCode}`:void 0})),{label:`+ Create new site on app.zenovay.com`,value:`create-new`,description:`Open the dashboard to add a new website`}];return x.createElement(c,{title:t?`Pick a site (best match: ${t})`:`Pick a site`,state:`idle`},x.createElement(d,{items:o,onSelect:n}))};function Dt(){let e=process.argv[1]??``;return e.includes(`/_npx/`)||e.includes(`\\_npx\\`)||process.env.npm_execpath?.includes(`npx`)?`npx`:`global`}const Ot=({adapter:e,site:t,stats:n,onPick:r})=>{let i=Dt(),a=i===`npx`?`npx @zenovay/cli`:`zenovay`;return b((e,t)=>{let n=e.toLowerCase();n===`w`||t.return?r(`watch`):n===`e`?r(`events`):(n===`s`||n===`q`||t.escape)&&r(`quit`)},{isActive:!0}),x.createElement(c,{title:`You're live on Zenovay`,state:`ok`},x.createElement(_,null,x.createElement(u,null,`✔ Installed successfully`)),x.createElement(g,{marginTop:1,flexDirection:`column`},x.createElement(_,null,`Framework: `,x.createElement(_,{color:`cyan`},e.displayName)),x.createElement(_,null,`Site: `,x.createElement(_,{color:`cyan`},t.name),` (`,t.url,`)`),t.trackingCode?x.createElement(_,{color:`gray`},`Tracker: `,t.trackingCode):null,n&&n.rounds>0?x.createElement(_,{color:`gray`},`Modified: `,n.writes,` file(s) across `,n.rounds,` agent round(s)`):n&&n.writes>0?x.createElement(_,{color:`gray`},`Modified: `,n.writes,` file(s) (programmatic install — no AI calls)`):null),x.createElement(g,{marginTop:1,flexDirection:`column`},x.createElement(_,{bold:!0},`What's next?`),x.createElement(_,null,` `),x.createElement(g,null,x.createElement(_,{color:`cyan`},` [W] `),x.createElement(_,null,`Open the live dashboard `),x.createElement(_,{color:`gray`},`— real-time visitors, top pages, sources, vitals`)),x.createElement(g,null,x.createElement(_,{color:`cyan`},` [E] `),x.createElement(_,null,`Stream events as they fire `),x.createElement(_,{color:`gray`},`— page views, custom events, in real time`)),x.createElement(g,null,x.createElement(_,{color:`cyan`},` [S] `),x.createElement(_,null,`Exit to shell`))),i===`npx`?x.createElement(g,{marginTop:1,flexDirection:`column`,borderStyle:`single`,borderColor:`yellow`,paddingX:1},x.createElement(_,{color:`yellow`,bold:!0},`Heads up — you ran via npx`),x.createElement(_,null,x.createElement(_,null,`The `),x.createElement(_,{color:`cyan`},`zenovay`),x.createElement(_,null,` command isn't on your PATH yet. After you exit, run any of:`)),x.createElement(_,null,` `),x.createElement(_,{color:`cyan`},` npm i -g @zenovay/cli `),x.createElement(_,{color:`gray`},"→ then `zenovay watch` works directly"),x.createElement(_,{color:`cyan`},` npx @zenovay/cli watch `),x.createElement(_,{color:`gray`},`→ no install, slower start`)):x.createElement(g,{marginTop:1},x.createElement(_,{color:`gray`},`From your shell: `),x.createElement(_,{color:`cyan`},a,` watch`),x.createElement(_,{color:`gray`},` · `),x.createElement(_,{color:`cyan`},a,` --help`)),x.createElement(g,{marginTop:1},x.createElement(_,{color:`gray`},`Dashboard URL: https://app.zenovay.com/sites/`,t.id)))},kt=({adapter:e,site:t,stats:n,onCommit:r,onSkipCommit:i})=>(Q(e=>{e===`y`||e===`Y`||e===`\r`?r():(e===`n`||e===`N`||e===`s`||e===`S`)&&i()}),x.createElement(c,{title:`Tracker installed`,state:`ok`},x.createElement(_,null,x.createElement(u,null,`✔ `),`The Zenovay tracker is in your project.`),x.createElement(g,{marginTop:1},x.createElement(_,{color:`gray`},`Framework: `),x.createElement(_,null,e.displayName)),x.createElement(g,null,x.createElement(_,{color:`gray`},`Site: `),x.createElement(_,null,t.name,` (`,t.url,`)`)),n&&x.createElement(g,null,x.createElement(_,{color:`gray`},`Modified: `),x.createElement(_,null,n.writes,` file(s)`)),x.createElement(g,{marginTop:1},x.createElement(_,null,`Commit + push these changes to git? `),x.createElement(_,{color:`cyan`},`[Y/n]`)))),At=({cwd:e,onDone:t,onError:n})=>{let[r,i]=w(`committing`),[a,o]=w(`Staging changes…`);return S(()=>{(async()=>{try{let n=await Ft(e,e=>o(e),e=>i(e));n.committed?o(`Pushed ${n.shortSha} to origin/${n.branch}`):o(`No changes to commit (already up-to-date).`),setTimeout(()=>t(n),800)}catch(e){n(e.message)}})()},[]),x.createElement(c,{title:`Committing to git`,state:`busy`},x.createElement(g,null,x.createElement(_,{color:`magenta`},x.createElement(O,{type:`dots`})),x.createElement(_,null,` `,r===`pushing`?`Pushing to origin`:`Committing`,`…`)),x.createElement(g,{marginTop:1},x.createElement(_,{color:`gray`},a)))},jt=({site:e,onDeployed:t,onSkip:n})=>(Q(e=>{e===`y`||e===`Y`||e===`\r`||e===`d`||e===`D`?t():(e===`n`||e===`N`||e===`s`||e===`S`)&&n()}),x.createElement(c,{title:`Ready to deploy?`,state:`idle`},x.createElement(_,null,`The tracker is installed locally. To capture events you need it on the live site:`),x.createElement(_,null,` `),x.createElement(g,null,x.createElement(_,{color:`cyan`},` → `),x.createElement(_,null,e.url)),x.createElement(_,null,` `),x.createElement(_,{color:`gray`},`Push the change through your normal deploy pipeline (Vercel auto-deploy, CI/CD, etc.).`),x.createElement(g,{marginTop:1},x.createElement(_,null,`Once it's deployed, press `),x.createElement(_,{color:`cyan`},`[Y]`),x.createElement(_,null,` to verify the tracker is firing. `),x.createElement(_,{color:`gray`},`[s] skip verification`)))),Mt=({site:e,onContinue:t})=>(Q(()=>t()),x.createElement(c,{title:`Visit your site`,state:`idle`},x.createElement(_,null,`To send a test event, open any page on your site:`),x.createElement(_,null,` `),x.createElement(g,null,x.createElement(_,{color:`cyan`},` → `),x.createElement(_,null,e.url)),x.createElement(_,null,` `),x.createElement(_,{color:`gray`},`The tracker fires automatically on page load. We'll verify the next event arrives.`),x.createElement(g,{marginTop:1},x.createElement(_,null,`Press `),x.createElement(_,{color:`cyan`},`[any key]`),x.createElement(_,null,` when you've visited the page.`))));async function Nt(e,t){try{let n=await fetch(e,{headers:{"User-Agent":`zenovay-cli/preflight`},signal:AbortSignal.timeout(8e3),redirect:`follow`});if(!n.ok)return{state:`tracker-missing`,httpStatus:n.status};let r=await n.text(),i=/<script[^>]*src\s*=\s*["']https:\/\/(?:api|cdn)\.zenovay\.com\/[^"']+["'][^>]*>\s*<\/script>/gi,a=/data-id\s*=\s*["'](ZV_[A-Za-z0-9]+)["']/i,o=r.match(i)??[];if(o.length===0)return{state:`tracker-missing`};let s=Array.from(new Set(o.map(e=>e.match(a)?.[1]).filter(e=>!!e)));return s.includes(t)?{state:`tracker-correct`}:{state:`tracker-wrong-id`,foundCodes:s}}catch(e){return{state:`tracker-missing`,networkError:e.message}}}const Pt=({site:t,elapsed:i,onTick:a,onArrived:o,onTimeout:s})=>{let[l,u]=w(`preflight`),[d,f]=w(``),[p,m]=w([]),h=C(!1),v=t.trackingCode??t.id,y=async()=>{u(`preflight`),f(`Fetching ${t.url}…`);let e=await Nt(t.url,v);if(!h.current){if(e.state===`tracker-correct`){u(`polling`),f(`Tracker detected on live site — waiting for first hit…`),T();return}if(e.state===`tracker-wrong-id`){u(`wrong-id-on-live`),m(e.foundCodes),f(`Live site has Zenovay but with id(s): ${e.foundCodes.join(`, `)}`);return}u(`awaiting-deploy`),f(e.networkError?`Couldn't reach ${t.url}: ${e.networkError}`:e.httpStatus?`${t.url} returned HTTP ${e.httpStatus}`:`No Zenovay tracker found on ${t.url}.`)}},T=async()=>{let i=Date.now()-10*60*1e3;try{let s=await e(),c=await r({strict:!1}),l=new n({config:s,cliVersion:`0`,token:c}),d=await Xe(t.id,i,{api:l,timeoutMs:6e4,pollIntervalMs:2500,onTick:e=>{h.current||a(e)}});if(h.current)return;d.received?(u(`success`),o()):u(`timeout`)}catch{h.current||u(`timeout`)}};S(()=>(h.current=!1,y(),()=>{h.current=!0}),[]),b(e=>{(l===`awaiting-deploy`||l===`wrong-id-on-live`||l===`timeout`)&&(e===`r`||e===`R`?y():(e===`s`||e===`S`)&&s())},{isActive:!0});let E=Math.floor(i/1e3);return l===`preflight`?x.createElement(c,{title:`Verifying`,state:`busy`},x.createElement(g,null,x.createElement(_,{color:`magenta`},x.createElement(O,{type:`dots`})),x.createElement(_,null,` Checking your live site for the tracker…`)),x.createElement(g,{marginTop:1},x.createElement(_,{color:`gray`},d))):l===`awaiting-deploy`?x.createElement(c,{title:`Tracker not yet on your live site`,state:`warn`},x.createElement(_,{color:`yellow`},d),x.createElement(g,{marginTop:1,flexDirection:`column`},x.createElement(_,null,`The tracker is in your local repo but hasn't been deployed yet.`),x.createElement(_,{color:`gray`},`Push your changes and wait for your deploy to finish (Vercel / Cloudflare Pages / CI), then retry.`)),x.createElement(g,{marginTop:1},x.createElement(_,null,`Press `),x.createElement(_,{color:`cyan`},`[r]`),x.createElement(_,null,` to re-check, `),x.createElement(_,{color:`cyan`},`[s]`),x.createElement(_,null,` to skip verification.`))):l===`wrong-id-on-live`?x.createElement(c,{title:`Live site has a different tracking code`,state:`warn`},x.createElement(_,{color:`yellow`},`Expected: `,x.createElement(_,{color:`cyan`},v),` `,`Found on live: `,x.createElement(_,{color:`cyan`},p.join(`, `))),x.createElement(g,{marginTop:1,flexDirection:`column`},x.createElement(_,null,`Your local install uses a different ID than what's on `,t.url,`.`),x.createElement(_,{color:`gray`},`Deploy the new local version, then retry — or skip if the existing ID is intentional.`)),x.createElement(g,{marginTop:1},x.createElement(_,null,`Press `),x.createElement(_,{color:`cyan`},`[r]`),x.createElement(_,null,` to re-check, `),x.createElement(_,{color:`cyan`},`[s]`),x.createElement(_,null,` to skip.`))):l===`timeout`?x.createElement(c,{title:`No event arrived in 3 minutes`,state:`warn`},x.createElement(_,{color:`yellow`},`The tracker is on your live site but no hits reached api.zenovay.com.`),x.createElement(g,{marginTop:1},x.createElement(_,{color:`gray`},`Try opening `,t.url,` in a fresh browser tab (no ad-blocker), then retry.`)),x.createElement(g,{marginTop:1},x.createElement(_,null,`Press `),x.createElement(_,{color:`cyan`},`[r]`),x.createElement(_,null,` to re-check, `),x.createElement(_,{color:`cyan`},`[s]`),x.createElement(_,null,` to finish without verification.`))):x.createElement(c,{title:`Waiting for first event`,state:`busy`},x.createElement(g,null,x.createElement(_,{color:`magenta`},x.createElement(O,{type:`dots`})),x.createElement(_,null,` Polling api.zenovay.com for the first hit on `),x.createElement(_,{color:`cyan`},t.url),x.createElement(_,null,` (`,E,`s elapsed)`)),x.createElement(g,{marginTop:1},x.createElement(_,{color:`gray`},`Reload the page if nothing arrives within ~30 seconds.`)))};function Q(e){b((t,n)=>{e(t,{return:n.return,escape:n.escape})},{isActive:!0})}async function Ft(e,t,n){let{execFile:r}=await import(`node:child_process`),{promisify:i}=await import(`node:util`),a=i(r),o=async(t,n)=>{let{stdout:r}=await a(t,n,{cwd:e,maxBuffer:4e6});return r.trim()};try{await o(`git`,[`rev-parse`,`--is-inside-work-tree`])}catch{return t(`Not a git repository — skipped.`),{committed:!1}}let s=await o(`git`,[`status`,`--porcelain`]);if(!s)return{committed:!1};t(`Staging tracker changes…`),await o(`git`,[`add`,`-A`]),t(`Creating commit…`),await o(`git`,[`commit`,`-m`,`chore(zenovay): install tracking script via @zenovay/cli`]);let c=await o(`git`,[`rev-parse`,`--short`,`HEAD`]),l=await o(`git`,[`rev-parse`,`--abbrev-ref`,`HEAD`]);n(`pushing`),t(`Pushing to origin/${l}…`);try{await o(`git`,[`push`,`origin`,l])}catch(e){return t(`Commit ${c} created locally; push failed (${e.message.slice(0,80)}). Push manually with: git push origin ${l}`),{committed:!0,shortSha:c,branch:l}}return n(`done`),{committed:!0,shortSha:c,branch:l}}function It(e,t){let n=`${e.name}`.padEnd(30,` `).slice(0,30),r=e.url.replace(/^https?:\/\//,``).padEnd(28,` `).slice(0,28),i=t?` ← best match`:``;return`${n} ${r}${i}`}async function Lt(e){try{let t=await h.readFile(m.join(e,`package.json`),`utf8`),n=JSON.parse(t);if(n.name)return String(n.name).replace(/^@[^/]+\//,``)}catch{}try{let t=await h.readFile(m.join(e,`.git`,`config`),`utf8`),n=t.match(/url\s*=\s*.*[/:]([^/]+?)(?:\.git)?\s*$/m);if(n&&n[1])return n[1]}catch{}return m.basename(e)}function Rt(e,t){if(!t||e.length===0)return e[0]??null;let n=$(t),r=e.find(e=>$(e.name)===n);if(r)return r;let i=e.find(e=>{let t=e.url.replace(/^https?:\/\//,``).replace(/\/.*$/,``),[r]=t.split(`.`);return $(r??``)===n});if(i)return i;let a=e.find(e=>$(e.name).includes(n)||$(e.url).includes(n));return a??e[0]??null}function $(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}export{re as detectInstalled,xt as initCommand};
|
package/dist/init-QiTMBqJb.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./config-Ddkbfelp.js";import"./api-0Qf43hhF.js";import{initCommand as e}from"./init-B9fjLwAP.js";import"./client-DZ4Awt8u.js";import"./formatter-45-fT1Hv.js";import"./emit-0WJ_OGeT.js";import"./login-CpJeUOCR.js";import"./panel-DglZ755S.js";import"./prompt-B1QrBhyZ.js";import"./keybar-CWo5rhK_.js";import"./sparkline-CR_bzxwB.js";export{e as initCommand};
|
package/dist/login-2h7PjSlW.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./config-Ddkbfelp.js";import"./api-0Qf43hhF.js";import"./formatter-45-fT1Hv.js";import"./emit-0WJ_OGeT.js";import{loginCommand as e}from"./login-CpJeUOCR.js";export{e as loginCommand};
|
package/dist/logout-DBIL_bPH.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{readConfig as e}from"./config-Ddkbfelp.js";import{ApiClient as t,clearToken as n,readToken as r}from"./api-0Qf43hhF.js";import"./formatter-45-fT1Hv.js";import{emit as i,isHeadless as a}from"./emit-0WJ_OGeT.js";async function o(o){let s=await e(),c=await r({strict:!1}).catch(()=>null);if(c)try{let e=new t({config:s,cliVersion:o.cliVersion,token:c});await e.revokeCurrentToken()}catch{}await n(),a({json:o.json})?i({type:`done`,command:`logout`,exitCode:0}):process.stdout.write(`Logged out.
|
|
2
|
-
`)}export{o as logoutCommand};
|
package/dist/panel-DglZ755S.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Box as e,Text as t}from"ink";import n,{createContext as r,useContext as i,useEffect as a,useState as o}from"react";const s={name:`mocha`,bg:`#1E1E2E`,fg:`#CDD6F4`,muted:`#6C7086`,accent:`#B4BEFE`,accent2:`#F5C2E7`,success:`#A6E3A1`,warn:`#F9E2AF`,error:`#F38BA8`,border:`#45475A`,dim:`#585B70`},c={name:`latte`,bg:`#EFF1F5`,fg:`#4C4F69`,muted:`#8C8FA1`,accent:`#7287FD`,accent2:`#EA76CB`,success:`#40A02B`,warn:`#DF8E1D`,error:`#D20F39`,border:`#BCC0CC`,dim:`#ACB0BE`},l={name:`dracula`,bg:`#282A36`,fg:`#F8F8F2`,muted:`#6272A4`,accent:`#BD93F9`,accent2:`#FF79C6`,success:`#50FA7B`,warn:`#F1FA8C`,error:`#FF5555`,border:`#44475A`,dim:`#6272A4`},u={name:`tokyoNight`,bg:`#1A1B26`,fg:`#C0CAF5`,muted:`#565F89`,accent:`#7AA2F7`,accent2:`#BB9AF7`,success:`#9ECE6A`,warn:`#E0AF68`,error:`#F7768E`,border:`#3B4261`,dim:`#414868`},d={name:`nord`,bg:`#2E3440`,fg:`#D8DEE9`,muted:`#4C566A`,accent:`#88C0D0`,accent2:`#81A1C1`,success:`#A3BE8C`,warn:`#EBCB8B`,error:`#BF616A`,border:`#3B4252`,dim:`#434C5E`},f={from:`#7D56F4`,to:`#FF5FD1`},p=r({theme:s});function m(){return i(p)}function h(e,t,n){if(n)return e.accent;switch(t){case`busy`:return e.accent;case`ok`:return e.success;case`warn`:return e.warn;case`err`:return e.error;case`idle`:default:return e.border}}function g(){let e=process.stdout.columns;return typeof e==`number`&&e>0?e:80}function _({title:r,state:i=`idle`,pillColor:a,width:o,focused:s=!1,children:c}){let{theme:l}=m(),u=h(l,i,s),d=o??g(),f=a??u,p=`╭─ `,_=` ─╮`,v=r??``,y=r?v.length:0,b=r?p.length+y+_.length:4,x=Math.max(2,d-b),S=r?n.createElement(e,{flexDirection:`row`},n.createElement(t,{color:u},p),n.createElement(t,{color:f,bold:!0},v),n.createElement(t,{color:u},_,`─`.repeat(x))):n.createElement(e,{flexDirection:`row`},n.createElement(t,{color:u},`╭`,`─`.repeat(Math.max(2,d-2)),`╮`)),C=n.createElement(e,{flexDirection:`row`},n.createElement(t,{color:u},`╰`,`─`.repeat(Math.max(2,d-2)),`╯`));return n.createElement(e,{flexDirection:`column`},S,n.createElement(e,{flexDirection:`row`},n.createElement(t,{color:u},`│ `),n.createElement(e,{flexDirection:`column`,flexGrow:1},c),n.createElement(t,{color:u},` │`)),C)}export{f as BRAND_GRADIENT,_ as Panel,l as dracula,c as latte,s as mocha,d as nord,u as tokyoNight,m as useTheme};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=[`▁`,`▂`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`];function t(e,t){if(e.length<=t)return e.slice();let n=e.length/t,r=[];for(let i=0;i<t;i+=1){let t=Math.floor(i*n),a=Math.min(e.length,Math.floor((i+1)*n)),o=0,s=0;for(let n=t;n<a;n+=1){let t=e[n];typeof t==`number`&&(o+=t,s+=1)}r.push(s===0?0:o/s)}return r}function n(n,r){if(n.length===0)return``;let i=typeof r==`number`&&r>0?r:n.length,a=t(n,i),o=0;for(let e of a)typeof e==`number`&&e>o&&(o=e);if(o===0)return e[0].repeat(a.length);let s=e.length-1,c=``;for(let t of a){let n=Math.max(0,Math.min(1,t/o)),r=Math.min(s,Math.round(n*s));c+=e[r]}return c}const r=[1,2,4,64],i=[8,16,32,128],a=[0,r[3],r[3]|r[2],r[3]|r[2]|r[1],r[3]|r[2]|r[1]|r[0]],o=[0,i[3],i[3]|i[2],i[3]|i[2]|i[1],i[3]|i[2]|i[1]|i[0]];export{n as spark};
|
package/dist/update-CgGLjHBM.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{readConfig as e}from"./config-Ddkbfelp.js";import"./formatter-45-fT1Hv.js";import{emit as t,isHeadless as n}from"./emit-0WJ_OGeT.js";import{classifyBump as r,fetchManifest as i,platformKey as a}from"./check-CmOnrU4W.js";import o from"node:path";import{promises as s}from"node:fs";import c from"node:os";import l from"node:crypto";import u from"semver";const d=`AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=`;async function f(e){let t=await i({cliBase:e.cliBase,fetchImpl:e.fetchImpl});return p({...e,manifest:t})}async function p(e){let{manifest:t,currentVersion:n,forceDowngrade:i}=e,o=r(n,t.latest);if(o===`none`)return{updated:!1,from:n,to:t.latest,reason:`already-latest`};if(o===`downgrade`&&!i)return{updated:!1,from:n,to:t.latest,reason:`downgrade-blocked`};t.minSupported&&u.lt(n,t.minSupported);let c=a(),l=t.platforms[c];if(!l)throw Error(`No release binary for platform ${c}`);let d=await m(l,e.fetchImpl);try{return await h(d,l.sha256),await g(l,t.latest,c),await _(d,e.binaryPath),{updated:!0,from:n,to:t.latest}}catch(e){throw await s.unlink(d).catch(()=>void 0),e}}async function m(e,t=fetch){let n=await t(e.url);if(!n.ok)throw Error(`Download failed: ${n.status}`);let r=Buffer.from(await n.arrayBuffer()),i=await s.mkdtemp(o.join(c.tmpdir(),`zenovay-update-`)),a=o.join(i,`zenovay.new`);return await s.writeFile(a,r,{mode:493}),a}async function h(e,t){let n=await s.readFile(e),r=l.createHash(`sha256`).update(n).digest(`hex`);if(r.toLowerCase()!==t.toLowerCase())throw Error(`Checksum mismatch: expected ${t}, got ${r}. Update REFUSED.`)}async function g(e,t,n){let r=Buffer.from(d,`base64`);if(r.length!==32)throw Error(`Invalid release public key — update REFUSED.`);let i=Buffer.from(`${e.sha256}|${t}|${n}`),a=Buffer.from(e.sig,`base64`),o=l.createPublicKey({key:Buffer.concat([Buffer.from(`302a300506032b6570032100`,`hex`),r]),format:`der`,type:`spki`}),s=l.verify(null,i,o,a);if(!s)throw Error(`Signature verification FAILED. Update REFUSED.`)}async function _(e,t){let n=`${t}.old-${Date.now()}`;try{await s.rename(t,n)}catch(e){if(e.code!==`ENOENT`)throw e}try{await s.rename(e,t),process.platform!==`win32`&&await s.chmod(t,493),await s.unlink(n).catch(()=>void 0)}catch(e){try{await s.rename(n,t)}catch{}throw e}}async function v(a){let o=await e(),s=await i({cliBase:o.cliBase}),c=r(a.cliVersion,s.latest);if(a.check)return n({json:a.json})?t({type:`info`,message:`latest=${s.latest} current=${a.cliVersion} bump=${c}`}):process.stdout.write(`Current: ${a.cliVersion}\nLatest: ${s.latest}\nBump: ${c}\n`),{updated:!1,from:a.cliVersion,to:s.latest};if(c===`none`)return n({json:a.json})||process.stdout.write(`Already on latest (${a.cliVersion}).\n`),{updated:!1,from:a.cliVersion,to:s.latest};if(c===`downgrade`&&!a.forceDowngrade)throw Error(`Refused to downgrade ${a.cliVersion} → ${s.latest}. Pass --force-downgrade if you really want this.`);let l=await f({currentVersion:a.cliVersion,cliBase:o.cliBase,binaryPath:a.binaryPath,forceDowngrade:a.forceDowngrade});return n({json:a.json})?l.updated&&t({type:`update.applied`,from:l.from,to:l.to}):l.updated?process.stdout.write(`Updated ${l.from} → ${l.to}\n`):process.stdout.write(`Not updated (${l.reason??`unknown`}).\n`),l}export{v as updateCommand};
|
package/dist/watch-Bgjke7jm.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{readConfig as e}from"./config-Ddkbfelp.js";import{ApiClient as t,readToken as n}from"./api-0Qf43hhF.js";import{parseSseStream as r}from"./client-DZ4Awt8u.js";import"./formatter-45-fT1Hv.js";import{emit as i,isHeadless as a}from"./emit-0WJ_OGeT.js";import{Panel as o}from"./panel-DglZ755S.js";import{Banner as s}from"./prompt-B1QrBhyZ.js";import{Keybar as c}from"./keybar-CWo5rhK_.js";import{spark as l}from"./sparkline-CR_bzxwB.js";import{resolveSiteId as u}from"./resolve-site-CPY8XSeq.js";import{Box as d,Text as f,render as p,useApp as m,useInput as h}from"ink";import g,{useEffect as _,useState as v}from"react";import y from"ink-spinner";import b from"ink-text-input";const x=Math.PI*2;function S(e){let t=e,n=Math.PI*Math.sin(e);for(let e=0;e<6;e++){let e=2*t+Math.sin(2*t)-n,r=2+2*Math.cos(2*t);if(r===0)break;t-=e/r}return t}function C(e,t){if(e<-90||e>90||t<-180||t>180)return null;let n=e*Math.PI/180,r=t*Math.PI/180,i=S(n),a=r*Math.cos(i)/Math.PI,o=Math.sin(i);return{x:a,y:o}}function w(e){if(e)return!0;let t=process.env;if(t.NO_COLOR||t.ZENOVAY_GLOBE===`ascii`)return!0;let n=(t.LANG||t.LC_ALL||t.LC_CTYPE||``).toLowerCase();return!!(n&&!n.includes(`utf`))}function T(e,t){let n=e*2,r=t*4;return{dw:n,dh:r,bits:new Uint8Array(n*r)}}function E(e,t,n){t<0||t>=e.dw||n<0||n>=e.dh||(e.bits[n*e.dw+t]=1)}function D(e){let t=e.dw/2,n=e.dh/2,r=e.dw/2-1,i=e.dh/2-1,a=Math.max(e.dw,e.dh)*2;for(let o=0;o<a;o++){let s=o/a*x,c=Math.round(t+r*Math.cos(s)),l=Math.round(n+i*Math.sin(s));E(e,c,l)}}function O(e){let t=Math.floor(e.dh/2);for(let n=0;n<e.dw;n+=4)E(e,n,t)}function k(e,t){let n=e.dw/2,r=e.dh/2,i=e.dw/2-1,a=e.dh/2-1;for(let o of t){let t=C(o.lat,o.lng);if(!t)continue;let s=Math.round(n+t.x*i),c=Math.round(r-t.y*a);E(e,s,c),E(e,s+1,c),E(e,s,c+1),E(e,s+1,c+1)}}const A=[[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[0,3],[1,3]];function j(e,t,n){let r=0;for(let i=0;i<A.length;i++){let[a,o]=A[i],s=t*2+a,c=n*4+o;e.bits[c*e.dw+s]&&(r|=1<<i)}return r===0?` `:String.fromCodePoint(10240+r)}function M(e,t,n){let r=0;for(let i=0;i<4;i++)for(let a=0;a<2;a++){let o=t*2+a,s=n*4+i;e.bits[s*e.dw+o]&&r++}return r===0?` `:r<=2?`.`:r<=4?`:`:r<=6?`*`:`#`}function N({data:e,width:t=80,height:n=20,asciiOnly:r}){let i=w(r),a=T(t,n);D(a),O(a),k(a,e);let o=[];for(let e=0;e<n;e++){let n=``;for(let r=0;r<t;r++)n+=i?M(a,r,e):j(a,r,e);o.push(n)}return g.createElement(d,{flexDirection:`column`},o.map((e,t)=>g.createElement(f,{key:t,color:`magenta`},e)),g.createElement(f,{color:`gray`},e.length,` live · `,i?`ascii mode`:`braille mode`))}async function P(r){let o=await e(),s=await n({strict:!1});if(!s)return process.stderr.write("Not logged in — run `zenovay login` first.\n"),2;let c=new t({config:o,cliVersion:r.cliVersion,token:s}),l;try{({siteId:l}=await u(c,{explicit:r.siteId,headless:!!r.json,cliVersion:r.cliVersion}))}catch(e){return process.stderr.write(`${e.message}\n`),2}if(a(r)){let e=await c.getDashboardSnapshot(l);return i({type:`watch.tick`,snapshot:e}),0}return new Promise(e=>{let{unmount:t}=p(g.createElement(F,{api:c,siteId:l,intervalMs:r.intervalMs??15e3,cliVersion:r.cliVersion,onExit:n=>{t(),e(n)}}))})}const F=({api:e,siteId:t,intervalMs:n,cliVersion:i,onExit:a})=>{let{exit:l}=m(),[u,p]=v(null),[b,x]=v(null),[S,C]=v(null),[w,T]=v([]),[E,D]=v(!0),[O,k]=v(null),[A,j]=v(1),[M,P]=v(!1),[F,U]=v(!1);if(h((e,t)=>{if(e===`q`){l(),a(0);return}if(e===`?`||e===`/`){U(e=>!e);return}if(e===`g`){P(e=>!e);return}if(t.tab){j(e=>{let n=t.shift?(e+4)%6+1:e%6+1;return n});return}(e===`1`||e===`2`||e===`3`||e===`4`||e===`5`||e===`6`)&&j(Number(e))}),_(()=>{let r=!1,i=async()=>{try{let n=await e.getDashboardSnapshot(t);if(r)return;p(n);let i=e.getVitals;typeof i==`function`&&i.call(e,t).then(e=>{r||x(e)},()=>{});let a=e.getGoals;typeof a==`function`&&a.call(e,t).then(e=>{r||C(e)},()=>{}),D(!1),k(null)}catch(e){r||k(e.message)}};i();let a=setInterval(i,n);return()=>{r=!0,clearInterval(a)}},[e,t,n]),_(()=>{let n=new AbortController;return(async()=>{try{let i=await e.openEventsStream(t,n.signal);for await(let e of r(i))e.type===`error`&&T(t=>[...t,`[ERR ${e.code}] ${e.message}`].slice(-10))}catch{}})(),()=>n.abort()},[e,t]),E)return g.createElement(d,{flexDirection:`column`},g.createElement(s,{version:i,subtitle:`watch · ${t}`}),g.createElement(o,{title:`Loading`,state:`busy`},g.createElement(d,null,g.createElement(f,{color:`magenta`},g.createElement(y,{type:`dots`})),g.createElement(f,null,` Fetching snapshot…`))));if(O&&!u)return g.createElement(d,{flexDirection:`column`},g.createElement(s,{version:i,subtitle:`watch · ${t}`}),g.createElement(o,{title:`Error`,state:`err`},g.createElement(f,{color:`red`},O)));let W=process.stdout.columns??80,G=Math.max(20,Math.floor(W/3)-1),K=[];return g.createElement(d,{flexDirection:`column`},g.createElement(s,{version:i,subtitle:`watch · ${t}${M?` · globe`:``}`}),g.createElement(d,{flexDirection:`row`},g.createElement(d,{flexDirection:`column`},M?g.createElement(o,{title:`Live globe`,focused:A===1,width:G},g.createElement(N,{data:K,width:Math.max(40,G-4),height:12})):g.createElement(L,{snapshot:u,focused:A===1,width:G}),g.createElement(B,{events:w,focused:A===4,width:G})),g.createElement(d,{flexDirection:`column`},g.createElement(R,{snapshot:u,focused:A===2,width:G}),g.createElement(V,{vitals:b,focused:A===5,width:G})),g.createElement(d,{flexDirection:`column`},g.createElement(z,{snapshot:u,focused:A===3,width:G}),g.createElement(H,{goals:S,focused:A===6,width:G}))),F?g.createElement(I,{api:e,siteId:t,width:W-2}):null,g.createElement(c,{items:[{key:`tab`,label:`next`},{key:`1-6`,label:`jump`},{key:`g`,label:M?`panels`:`globe`},{key:`?/`,label:F?`close chat`:`ai chat`},{key:`q`,label:`quit`}]}))},I=({api:e,siteId:t,width:n})=>{let[i,a]=v(``),[s,c]=v([]),[l,u]=v(!1),[p,m]=v(``),[h,_]=v(null),y=async n=>{let i=n.trim();if(!i||l)return;_(null),a(``);let o=[...s,{role:`user`,content:i}];c(o),u(!0),m(``);try{let n=o.map(e=>({role:e.role,content:e.content})),i=await e.openAiStream(`chat`,{messages:n,siteId:t},void 0),a=``;for await(let e of r(i))if(e.type===`delta`)a+=e.content,m(a);else if(e.type===`error`)_(`${e.code}: ${e.message}`);else if(e.type===`done`)break;c([...o,{role:`assistant`,content:a}]),m(``)}catch(e){_(e instanceof Error?e.message:`chat failed`)}finally{u(!1)}};return g.createElement(d,{marginTop:1},g.createElement(o,{title:`AI chat (esc / ?/ to close)`,focused:!0,width:n},g.createElement(d,{flexDirection:`column`},s.slice(-6).map((e,t)=>g.createElement(d,{key:t,flexDirection:`column`,marginBottom:1},g.createElement(f,{color:e.role===`user`?`cyan`:`magenta`,bold:!0},e.role===`user`?`you`:`zenovay`),g.createElement(f,null,e.content))),l&&p?g.createElement(d,{flexDirection:`column`,marginBottom:1},g.createElement(f,{color:`magenta`,bold:!0},`zenovay`),g.createElement(f,null,p)):null,h?g.createElement(f,{color:`red`},`✗ `,h):null,g.createElement(d,null,g.createElement(f,{color:`cyan`},l?`⠋ `:`▸ `),g.createElement(b,{value:i,onChange:a,onSubmit:y,placeholder:l?`streaming…`:`ask anything about your analytics`})))))},L=({snapshot:e,focused:t,width:n})=>{let r=e?.visitors?.count??0,i=e?.visitors?.series??[];return g.createElement(o,{title:`Visitors`,focused:t,width:n},g.createElement(f,{bold:!0},r.toString()),g.createElement(f,{color:`gray`},i.length>0?l(i,Math.max(8,n-6)):`— no data —`))},R=({snapshot:e,focused:t,width:n})=>{let r=e?.topPages?.slice(0,5)??[];return g.createElement(o,{title:`Top pages`,focused:t,width:n},r.length===0?g.createElement(f,{color:`gray`},`— no data —`):r.map(e=>g.createElement(d,{key:e.path},g.createElement(f,null,e.path.padEnd(n-10).slice(0,n-10)),g.createElement(f,{color:`gray`},` `,e.views))))},z=({snapshot:e,focused:t,width:n})=>{let r=e?.sources?.slice(0,5)??[];return g.createElement(o,{title:`Sources`,focused:t,width:n},r.length===0?g.createElement(f,{color:`gray`},`— no data —`):r.map(e=>g.createElement(d,{key:e.source},g.createElement(f,null,e.source.padEnd(n-10).slice(0,n-10)),g.createElement(f,{color:`gray`},` `,e.visitors))))},B=({events:e,focused:t,width:n})=>g.createElement(o,{title:`Events`,focused:t,width:n},e.length===0?g.createElement(f,{color:`gray`},`— waiting —`):e.slice(-10).map((e,t)=>g.createElement(f,{key:t},e.slice(0,n-4)))),V=({vitals:e,focused:t,width:n})=>{let r=(e,t,n)=>g.createElement(d,{key:e},g.createElement(f,{bold:!0},e.padEnd(6)),g.createElement(f,{color:`gray`},typeof t==`number`?`${t.toFixed(0)}${n}`:`—`));return g.createElement(o,{title:`Vitals`,focused:t,width:n},r(`LCP`,e?.lcpP75,`ms`),r(`INP`,e?.inpP75,`ms`),r(`CLS`,e?.clsP75?e.clsP75*1e3:void 0,`/1k`),r(`TTFB`,e?.ttfbP75,`ms`),r(`FCP`,e?.fcpP75,`ms`))},H=({goals:e,focused:t,width:n})=>{let r=e?.goals?.slice(0,5)??[];return g.createElement(o,{title:`Goals`,focused:t,width:n},r.length===0?g.createElement(f,{color:`gray`},`— no data —`):r.map(e=>g.createElement(d,{key:e.name},g.createElement(f,null,e.name.padEnd(n-10).slice(0,n-10)),g.createElement(f,{color:`gray`},` `,e.completions))))};export{P as watchCommand};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|