@zenovay/cli 0.1.67 → 0.1.68
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/{agency-BxYMejNb.js → agency-BRTQMQko.js} +1 -1
- package/dist/{ai-DbtIo6k2.js → ai-RVuD47iX.js} +1 -1
- package/dist/{alerts-DKQa_K77.js → alerts-B65b9jWl.js} +1 -1
- package/dist/{analytical-screen-B_wWUnT4.js → analytical-screen-DM7SBY5U.js} +1 -1
- package/dist/{analytics-BO22Zeas.js → analytics-CBP38R6T.js} +2 -2
- package/dist/{annotation-CL1q8mjr.js → annotation-CdqECkB6.js} +1 -1
- package/dist/api-hWp9s3Y8.js +1 -0
- package/dist/{api-keys-lfjOVUIe.js → api-keys-BmmNLpjG.js} +1 -1
- package/dist/api-v2-C6bvRBzw.js +1 -0
- package/dist/{api-v2-CPUUcP1i.js → api-v2-C82L-ZOL.js} +1 -1
- package/dist/{audit-DfKQdrug.js → audit-D_NXQFBa.js} +1 -1
- package/dist/bin.js +6 -6
- package/dist/{chat-panel-ZlKZ0W6J.js → chat-panel-DS-FxXoL.js} +1 -1
- package/dist/{commands-NsH5CS-H.js → commands-BJQxwCUl.js} +1 -1
- package/dist/{companies-CtZ2vGQs.js → companies-DNay1Xrh.js} +1 -1
- package/dist/{completions-Bem7-lcb.js → completions-D-Esx72b.js} +1 -1
- package/dist/{deploys-CUbSa8S5.js → deploys-BnByoalt.js} +1 -1
- package/dist/{devices-CrkIxfde.js → devices-Di7NUUmM.js} +1 -1
- package/dist/{doctor-D5HWdhgv.js → doctor-B_C_zJQh.js} +1 -1
- package/dist/{domains-V4sD09io.js → domains-xWz-syku.js} +1 -1
- package/dist/{emit-C9vAopcy.js → emit-NkY7PE3R.js} +1 -1
- package/dist/{error-codes-C5caZH9p.js → error-codes-D4XO4okw.js} +1 -1
- package/dist/{error-codes-fnm-9MRL.js → error-codes-DpKbL-uM.js} +1 -1
- package/dist/{errors-D3fS1kYu.js → errors-DhQE6fJQ.js} +1 -1
- package/dist/{events-tail-DGRZewwc.js → events-tail-CSHCH77I.js} +1 -1
- package/dist/{export-FjEyji8r.js → export-CmypMMjU.js} +1 -1
- package/dist/{funnel-C7DmrdUC.js → funnel-DwBZVMGB.js} +1 -1
- package/dist/{geo-C9OcRStg.js → geo-hKUpyWuw.js} +1 -1
- package/dist/globe-8qdyNUN-.js +2 -0
- package/dist/{goals-CVRryIri.js → goals-cNoELf2s.js} +1 -1
- package/dist/{health-DMiTjQ9Z.js → health-BJwKEdIp.js} +1 -1
- package/dist/{health-vxoiMF8G.js → health-CbaNXgdP.js} +1 -1
- package/dist/heatmaps-SCfq5M8H.js +1 -0
- package/dist/{home-CXwRtMge.js → home-DAEqaTOD.js} +1 -1
- package/dist/init-C7zAAhfS.js +79 -0
- package/dist/init-DOrkLxxe.js +1 -0
- package/dist/insights-Bshy_7Ln.js +1 -0
- package/dist/{integrations-CWPrMJfZ.js → integrations-m8rSzn3o.js} +1 -1
- package/dist/journeys-DZvlQiCz.js +1 -0
- package/dist/live-3YVbBo2f.js +1 -0
- package/dist/login-COMo5KUL.js +2 -0
- package/dist/login-W7wIGtyL.js +1 -0
- package/dist/logout-D89CET3S.js +2 -0
- package/dist/{notes-C8cba6QA.js → notes-IHtGD1hp.js} +1 -1
- package/dist/{pages-CKs5X38q.js → pages-BD1BmfgN.js} +1 -1
- package/dist/{plans-oxxMSOdB.js → plans-BjApr8oD.js} +1 -1
- package/dist/{profile-CD9QVZ2I.js → profile-u9G8Sxdv.js} +1 -1
- package/dist/{projects-hIQqeDYq.js → projects-DK9ZO7qd.js} +1 -1
- package/dist/{query-BLHvu1IF.js → query-BhtiMkwf.js} +1 -1
- package/dist/{resolve-site-DQVcWhjG.js → resolve-site-GDYx0__E.js} +1 -1
- package/dist/retention-BA59Mo79.js +1 -0
- package/dist/{revenue-BiViSloE.js → revenue-vHyW8Ypm.js} +1 -1
- package/dist/secrets-BBaEWu03.js +1 -0
- package/dist/{self-test-CSST_zHj.js → self-test-QdQWJ7tK.js} +2 -2
- package/dist/sessions-DN4j8OEV.js +1 -0
- package/dist/{settings-CFFiWmGO.js → settings-HSntEG-D.js} +1 -1
- package/dist/{share-Cx62AEP-.js → share-CQwuZtgh.js} +1 -1
- package/dist/{sources-D-KqX0Sg.js → sources-CSFQi-V7.js} +1 -1
- package/dist/{stats-BzTqFpJL.js → stats-DCzM0MeA.js} +1 -1
- package/dist/{status-agent-TIyEIKOj.js → status-agent-C2-h8fKK.js} +1 -1
- package/dist/{team-BRebgNMO.js → team-_SMC_yFx.js} +1 -1
- package/dist/{teams-DhrkUkt8.js → teams-C_eV1rXM.js} +1 -1
- package/dist/{telemetry-DRh10SvO.js → telemetry-BJbpxgIp.js} +1 -1
- package/dist/{telemetry-DC0Jw3JD.js → telemetry-BwXO7Z83.js} +1 -1
- package/dist/telemetry-CZhEbFqI.js +1 -0
- package/dist/{themes-gluHmb6E.js → themes-D5A3e_mg.js} +1 -1
- package/dist/update-DoOjZZNm.js +1 -0
- package/dist/uptime-Da9_QYPm.js +1 -0
- package/dist/{usage-BFCTeA8E.js → usage-beKJ1HbM.js} +1 -1
- package/dist/{use-baQFldqI.js → use-DbUqNyZk.js} +1 -1
- package/dist/{visitors-BtriXh9k.js → visitors-CJ2FfgSL.js} +1 -1
- package/dist/{vitals-BgAwONID.js → vitals-Cczahuhy.js} +1 -1
- package/dist/watch-6c4jbLbR.js +1 -0
- package/dist/{webhooks-PRWhMVgS.js → webhooks-CFtGBoJm.js} +1 -1
- package/dist/{webhooks-forward-BDxi2TcF.js → webhooks-forward-D-erVn8S.js} +1 -1
- package/dist/wizard-bin.js +1 -1
- package/package.json +1 -1
- package/dist/api-FCanTxsb.js +0 -1
- package/dist/api-v2-D9N_2hdW.js +0 -1
- package/dist/globe-PiPL3Bei.js +0 -2
- package/dist/heatmaps-G3Nf95tV.js +0 -1
- package/dist/init-BuyESMBj.js +0 -79
- package/dist/init-WmEUW4Em.js +0 -1
- package/dist/insights-J99-8Rcu.js +0 -1
- package/dist/journeys-BLxqoeFu.js +0 -1
- package/dist/live-CWSLgkC2.js +0 -1
- package/dist/login-CaDs2Peq.js +0 -2
- package/dist/login-wpGuU_Zm.js +0 -1
- package/dist/logout-BkeT6Hke.js +0 -2
- package/dist/retention-B8bgiVux.js +0 -1
- package/dist/secrets-M60NENIa.js +0 -1
- package/dist/sessions-lUUiiNYc.js +0 -1
- package/dist/telemetry-C1045t6Q.js +0 -1
- package/dist/update-BCgHj5O4.js +0 -1
- package/dist/uptime-CwG6bqir.js +0 -1
- package/dist/watch-Cv4FtwSJ.js +0 -1
- /package/dist/{client-Dm8uGVCy.js → client-I4GTcUcm.js} +0 -0
- /package/dist/{open-url-BxXbZzWS.js → open-url-CTfSApWl.js} +0 -0
- /package/dist/{prompt-B4s3o9G7.js → prompt-CJw_Mqo2.js} +0 -0
- /package/dist/{secrets-DPf_7SkN.js → secrets-DzueUVGL.js} +0 -0
package/dist/init-BuyESMBj.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import{readConfig as e,updateConfig as t}from"./config--JRu_jFq.js";import{ApiClient as n}from"./api-FCanTxsb.js";import{readToken as r}from"./token-store-BQuGH0z2.js";import{emit$1 as i,isHeadless as a}from"./emit-C9vAopcy.js";import{scrubSecrets as o}from"./secrets-DPf_7SkN.js";import{parseSseStream as s}from"./client-Dm8uGVCy.js";import{loginCommand as c,maybeInstallCompletions as l}from"./login-CaDs2Peq.js";import{Panel as u,useTheme as d}from"./panel-B-XxdP-N.js";import{Banner as f}from"./banner-DdgwXGzt.js";import{DiffView as p,ProgressRow as m}from"./progress-row-5ns2IsFh.js";import{Select as h}from"./prompt-B4s3o9G7.js";import{Keybar as g}from"./keybar-QgnmSion.js";import{spark as _}from"./sparkline-CpoBjjlc.js";import v from"node:path";import{promises as y}from"node:fs";import{z as b}from"zod";import x from"node:os";import S from"node:crypto";import{ulid as C}from"ulid";import{Box as w,Text as T,render as ee,useApp as te,useInput as E}from"ink";import D,{useEffect as O,useRef as k,useState as A}from"react";import{globby as j}from"globby";import M from"ink-spinner";import{applyPatch as N}from"diff";const P=[`@zenovay/tracker`,`@zenovay/next`,`@zenovay/nuxt`,`@zenovay/svelte`,`@zenovay/astro`,`@zenovay/remix`,`@zenovay/node`],F=[`zenovay.config.ts`,`zenovay.config.js`,`zenovay.config.mjs`,`zenovay.config.json`],ne=/<script[^>]*src\s*=\s*["']https:\/\/(?:api|cdn)\.zenovay\.com\/[^"']+["'][^>]*>\s*<\/script>/gi,re=/data-id\s*=\s*["'](ZV_[A-Za-z0-9]+)["']/i,I=/data-zenovay-site\s*=\s*["']([^"']+)["']/i,L=/\binit\s*\(\s*['"`](ZV_[A-Za-z0-9]+)['"`]/g,R=[{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 z(e,t){let n={zenovayInstalled:!1,correctTrackingCode:!1,foundTrackingCodes:[],zenovayFiles:[],competitors:[],summary:``,recommendation:`fresh-install`};try{let t=await y.readFile(v.join(e,`package.json`),`utf8`),r=JSON.parse(t),i={...r.dependencies,...r.devDependencies};for(let e of P)if(e in i){n.zenovayInstalled=!0,n.packageMarker=e;break}}catch{}for(let t of F)try{await y.access(v.join(e,t)),n.zenovayInstalled=!0,n.configFile=t;break}catch{}let r=await j([`**/*.{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 y.readFile(t,`utf8`)}catch{continue}let o=v.relative(e,t),s=r.match(ne);if(s&&s.length>0){n.zenovayInstalled=!0;let e=s[0].slice(0,200),t=e.match(re)??e.match(I),r=t?.[1]??null;r&&a.add(r),n.zenovayFiles.push({file:o,currentTrackingCode:r,scriptTagCount:s.length,matchSample:e})}if(!s&&/\.[jt]sx?$/.test(t)){L.lastIndex=0;let e;for(;(e=L.exec(r))!==null;){let t=e[1];a.add(t),n.zenovayInstalled=!0,n.zenovayFiles.push({file:o,currentTrackingCode:t,scriptTagCount:0,matchSample:e[0].slice(0,80)})}}for(let e of R)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=B(n,t),n}function B(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 ie(e){let t=await z(e,``);return{installed:t.zenovayInstalled,reasons:t.summary?[t.summary]:[],packageMarker:t.packageMarker,configFile:t.configFile,scriptFile:t.zenovayFiles[0]?.file}}const ae=[/^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)$/],oe=[/(^|\/)\.env($|\.(?!example$)[^/]+$)/,/(^|\/)\.git(\/|$)/,/(^|\/)node_modules\//,/(^|\/)\.ssh\//,/(^|\/)\.aws\//,/\.pem$/,/\.key$/,/(^|\/)id_rsa($|\.)/,/(^|\/)\.npmrc$/,/(^|\/)credentials(\.|$)/],V=256*1024,H=50,U=20,W=40;var G=class extends Error{constructor(e,t){super(t),this.code=e,this.name=`SandboxError`}};const K=/<script[^>]*src\s*=\s*["']https:\/\/(?:api|cdn)\.zenovay\.com\/[^"']+["'][^>]*>\s*<\/script>/i,se=[{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 q=class{sessionId;cwd;cwdReal;undoRoot;readCount=0;writeCount=0;roundCount=0;writtenPathsSet=new Set;constructor(e){this.sessionId=e.sessionId??C(),this.cwd=e.cwd,this.cwdReal=y.realpath(e.cwd),this.undoRoot=e.undoRoot??v.join(x.homedir(),`.zenovay`,`undo`)}incrementRound(){if(this.roundCount++,this.roundCount>W)throw new G(`round-cap`,`Tool-call recursion cap (${W}) 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 G(`escape`,`Path must be a non-empty string.`);if(e.includes(`\0`))throw new G(`escape`,`Null byte in path.`);if(/^\\\\[?.]\\/.test(e)||/^\\\\[A-Za-z0-9]/.test(e))throw new G(`escape`,`Windows special path prefix: ${e}`);if(/%/.test(e))try{let t=decodeURIComponent(e);if(/%[0-9A-Fa-f]{2}/.test(t))throw new G(`escape`,`Double-encoded path: ${e}`);e=t}catch(t){throw t instanceof G?t:new G(`escape`,`Malformed percent-encoding: ${e}`)}if(e.includes(`\0`))throw new G(`escape`,`Null byte in decoded path.`);if(e.includes(`\\`))throw new G(`escape`,`Backslash in path (Windows-style separator not accepted): ${e}`);let n=await this.cwdReal,r=v.isAbsolute(e)?e:v.join(n,e),i=v.normalize(r),a=i;try{a=await y.realpath(i)}catch(e){if(e.code!==`ENOENT`)throw new G(`escape`,`realpath failed: ${e.message}`);let t=v.dirname(i);try{let e=await y.realpath(t);a=v.join(e,v.basename(i))}catch{}}if(!this.isWithin(a,n))throw new G(`escape`,`Path escapes cwd: ${e}`);let o=v.relative(n,a);for(let e of oe)if(e.test(o)){if(t===`read`&&/(^|\/)node_modules\//.test(o))continue;throw new G(`blocklisted`,`Path is on the hard blocklist: ${o}`)}if(t===`write`){let e=ae.some(e=>e.test(o));if(!e&&!/^\.env(\.local)?$/.test(o)&&!/^\.claude\//.test(o)&&!/^\.cursor\//.test(o))throw new G(`not-allowlisted`,`Write path not on allowlist: ${o}`)}return a}isWithin(e,t){let n=v.relative(t,e);return!n.startsWith(`..`)&&!v.isAbsolute(n)}async safeRead(e){if(this.readCount>=H)throw new G(`read-cap`,`Read cap (${H}) reached.`);let t=await this.resolveForRead(e),n=await y.stat(t);if(n.size>V)throw new G(`too-large`,`File exceeds ${V}B: ${e} (${n.size}B)`);let r=await y.readFile(t),i=r.subarray(0,Math.min(r.length,8192));if(i.includes(0))throw new G(`binary-rejected`,`Binary content in ${e}.`);return this.readCount++,r.toString(`utf8`)}async safeWrite(e,t){if(this.writeCount>=U)throw new G(`write-cap`,`Write cap (${U}) reached.`);if(t.length>V)throw new G(`too-large`,`Write exceeds ${V}B: ${e}`);let n=await this.resolveForWrite(e),r=await y.readFile(n,`utf8`).catch(e=>{if(e.code===`ENOENT`)return null;throw e});if(r!==null){if(K.test(r)&&!K.test(t))throw new G(`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 se)if(i.test(r)&&!i.test(t))throw new G(`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 y.mkdir(v.dirname(n),{recursive:!0}),await y.writeFile(n,t,`utf8`),this.writeCount++;let a=await this.cwdReal;return this.writtenPathsSet.add(v.relative(a,n)),{backupPath:i}}async journalBackup(e){let t=await y.readFile(e).catch(e=>{if(e.code===`ENOENT`)return null;throw e}),n=v.join(this.undoRoot,this.sessionId);await y.mkdir(n,{recursive:!0,mode:448});let r=S.createHash(`sha256`).update(e).digest(`hex`).slice(0,16),i=v.join(n,`${r}.bak`),a=v.join(n,`manifest.jsonl`);t&&await y.writeFile(i,t,{mode:384});let o=JSON.stringify({abs:e,backupPath:t?i:null,ts:Date.now()});return await y.appendFile(a,o+`
|
|
2
|
-
`,{mode:384}),t?i:null}static wrapForModel(e,t){let n=S.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 o(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,t=`script`){let n=`app/layout.tsx`,r=e.trackingCode??e.siteId??``;return t===`npm`?ve(n,r):_e(n,r)}function _e(e,t){return[{targetPath:e,anchorKind:`after-imports`,code:`import Script from 'next/script';`,description:`Import next/script to inject the Zenovay tracker.`},{targetPath:e,anchorKind:`wrap-children`,code:`<Script
|
|
3
|
-
defer
|
|
4
|
-
data-id="${t}"
|
|
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.`}]}function ve(e,t){return[{targetPath:`components/zenovay-bootstrap.tsx`,anchorKind:`replace-file`,code:`'use client';
|
|
10
|
-
|
|
11
|
-
import { useEffect } from 'react';
|
|
12
|
-
import { init } from '@zenovay/tracker';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Mounts the Zenovay tracker exactly once on the client. Equivalent to the
|
|
16
|
-
* canonical <script src="https://api.zenovay.com/z.js"> tag — init() injects
|
|
17
|
-
* the same loader internally.
|
|
18
|
-
*/
|
|
19
|
-
export function ZenovayBootstrap() {
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
init('${t}', { allowLocalhost: true });
|
|
22
|
-
}, []);
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
`,description:`Create a client-component bootstrap that calls init() from @zenovay/tracker.`},{targetPath:e,anchorKind:`after-imports`,code:`import { ZenovayBootstrap } from '@/components/zenovay-bootstrap';`,description:`Import the Zenovay tracker bootstrap into the root layout.`},{targetPath:e,anchorKind:`wrap-children`,code:`<ZenovayBootstrap />
|
|
26
|
-
{children}`,description:`Render the Zenovay tracker bootstrap alongside children in the root layout.`}]}const ye={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`,packageDeps:[`@zenovay/tracker`],supportsNpmMode:!0,buildSnippets:ge},be=[`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 xe(e){for(let t of be)if(await e.exists(t))return t;return null}async function Se(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 Ce(e){let t=await Se(e);if(!t)return{matched:!1,confidence:0,reason:"package.json does not list `next` as a dependency."};let n=await xe(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 we(e){let t=`pages/_app.tsx`,n=e.trackingCode??e.siteId??``,r=`import type { AppProps } from 'next/app';
|
|
27
|
-
import Script from 'next/script';
|
|
28
|
-
|
|
29
|
-
export default function App({ Component, pageProps }: AppProps) {
|
|
30
|
-
return (
|
|
31
|
-
<>
|
|
32
|
-
<Script
|
|
33
|
-
defer
|
|
34
|
-
data-id="${n}"
|
|
35
|
-
data-allow-localhost="true"
|
|
36
|
-
src="https://api.zenovay.com/z.js"
|
|
37
|
-
strategy="afterInteractive"
|
|
38
|
-
/>
|
|
39
|
-
<Component {...pageProps} />
|
|
40
|
-
</>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
`;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 Te={id:`next-pages-router`,displayName:`Next.js (Pages Router)`,detect:Ce,files:[{path:`pages/_app.tsx`,kind:`mutate`,required:!0}],envVarName:`NEXT_PUBLIC_ZENOVAY_SITE`,buildSnippets:we},Ee=b.object({modules:b.array(b.string()).optional(),runtimeConfig:b.object({public:b.record(b.string(),b.unknown()).optional()}).optional()}).passthrough();async function De(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 Oe(e){let t=e.trackingCode??e.siteId??``,n=` app: {
|
|
44
|
-
head: {
|
|
45
|
-
script: [
|
|
46
|
-
{
|
|
47
|
-
defer: true,
|
|
48
|
-
src: 'https://api.zenovay.com/z.js',
|
|
49
|
-
'data-id': '${t}',
|
|
50
|
-
'data-allow-localhost': 'true',
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
},
|
|
54
|
-
},`;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 ke={id:`nuxt`,displayName:`Nuxt`,detect:De,files:[{path:`nuxt.config.ts`,kind:`mutate`,required:!0}],envVarName:`NUXT_PUBLIC_ZENOVAY_SITE`,buildSnippets:Oe},Ae=[`index.html`,`public/index.html`,`dist/index.html`];async function je(e){for(let t of Ae)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 Me(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 Ne={id:`plain-html`,displayName:`Plain HTML`,detect:je,files:[{path:`index.html`,kind:`mutate`,required:!0}],envVarName:`PUBLIC_ZENOVAY_SITE`,buildSnippets:Me};async function Pe(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 Fe(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 Ie={id:`remix`,displayName:`Remix`,detect:Pe,files:[{path:`app/root.tsx`,kind:`mutate`,required:!0}],envVarName:`PUBLIC_ZENOVAY_SITE`,buildSnippets:Fe};async function Le(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 Re(e){let t=e.trackingCode??e.siteId??``,n=`<svelte:head>
|
|
55
|
-
<script defer data-id="${t}" data-allow-localhost="true" src="https://api.zenovay.com/z.js"></script>
|
|
56
|
-
</svelte:head>
|
|
57
|
-
|
|
58
|
-
<slot />
|
|
59
|
-
`;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 ze={id:`sveltekit`,displayName:`SvelteKit`,detect:Le,files:[{path:`src/routes/+layout.svelte`,kind:`mutate`,required:!0}],envVarName:`PUBLIC_ZENOVAY_SITE`,buildSnippets:Re},Be=[ye,Te,ke,ze,de,Ie,Ne];async function Ve(e){let t=[];for(let n of Be){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 He(e){let t=t=>v.resolve(e,t);return{cwd:e,async readFile(e){try{return await y.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 y.access(t(e)),!0}catch{return!1}},async glob(t){return j(t,{cwd:e,dot:!1,gitignore:!0,onlyFiles:!0,followSymbolicLinks:!1})}}}async function Ue(e,t){let n=He(e),{adapter:r,ranked:i}=await Ve(n),a=i[0];return r&&a&&a.result.confidence>=.7?r:t?t.pickInteractively(i):r}function We(e,t){let n=/[\s"'#=]/.test(t)||t===``,r=n?`"${t.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`:t;return`${e}=${r}`}function Ge(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=v.resolve(e,r),a=``,o=!0;try{a=await y.readFile(i,`utf8`)}catch(e){if(e.code===`ENOENT`)o=!1;else throw e}let s=o?Ge(a):new Set,c=[],l=[],u=[];for(let[e,n]of Object.entries(t)){if(s.has(e)){l.push(e);continue}u.push(We(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(`
|
|
60
|
-
`);f=a+(e?`
|
|
61
|
-
`:``)+`
|
|
62
|
-
`+d+`
|
|
63
|
-
`+u.join(`
|
|
64
|
-
`)+`
|
|
65
|
-
`}else f=d+`
|
|
66
|
-
`+u.join(`
|
|
67
|
-
`)+`
|
|
68
|
-
`;if(o)await y.writeFile(i,f,`utf8`);else{let e=await y.open(i,`w`,384);try{await e.writeFile(f,`utf8`)}finally{await e.close()}}return{created:!o,existing:o,addedKeys:c,skippedKeys:l}}const Ke=`https://api.zenovay.com/mcp`,qe=b.object({url:b.string().url(),headers:b.record(b.string(),b.string()).optional()}),Je=b.object({mcpServers:b.record(b.string(),qe).optional()}).passthrough();function Ye(e){return e.HOME??e.USERPROFILE??x.homedir()}function Xe(e){return e.APPDATA??null}function Ze(e,t){let n=Ye(t),r=Xe(t),i=[];return i.push({id:`cursor`,displayName:`Cursor`,configPath:v.join(n,`.cursor`,`mcp.json`)}),e===`win32`&&r&&i.push({id:`cursor`,displayName:`Cursor (AppData)`,configPath:v.join(r,`Cursor`,`User`,`globalStorage`,`cursor.mcp`,`mcp.json`)}),e===`darwin`?i.push({id:`claude-desktop`,displayName:`Claude Desktop`,configPath:v.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`)}):e===`win32`&&r?i.push({id:`claude-desktop`,displayName:`Claude Desktop`,configPath:v.join(r,`Claude`,`claude_desktop_config.json`)}):i.push({id:`claude-desktop`,displayName:`Claude Desktop`,configPath:v.join(n,`.config`,`Claude`,`claude_desktop_config.json`)}),i.push({id:`vscode`,displayName:`VS Code`,configPath:v.join(n,`.vscode`,`mcp.json`)}),i}async function Qe(e){try{return await y.access(e),!0}catch{return!1}}async function $e(e){try{let t=await y.readFile(e,`utf8`);if(t.trim().length===0)return{};let n=JSON.parse(t),r=Je.safeParse(n);return r.success?r.data:n&&typeof n==`object`?n:{}}catch{return{}}}function et(e){return{url:Ke,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=et(e.accessToken);for(let e of Ze(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 $e(e.configPath),r=`${e.configPath}.bak`;await y.copyFile(e.configPath,r);let o={...n,mcpServers:{...n.mcpServers??{},zenovay:c}};await y.mkdir(v.dirname(e.configPath),{recursive:!0}),await y.writeFile(e.configPath,JSON.stringify(o,null,2)+`
|
|
69
|
-
`,`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 tt(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 nt=b.object({path:b.string().min(1)}),rt=b.object({path:b.string().min(1),content:b.string(),reason:b.string().min(1)}),it=b.object({path:b.string().min(1),patch:b.string().min(1),reason:b.string().min(1)}),at=b.object({}),ot=b.object({question:b.string().min(1),choices:b.array(b.string()).optional()});async function st(e,t){let n=nt.safeParse(t);if(!n.success)return{ok:!1,content:null,error:`invalid_args`};try{let t=await e.safeRead(n.data.path),r=q.scrubSecrets(t);return{ok:!0,content:q.wrapForModel(n.data.path,r)}}catch(e){return{ok:!1,content:null,error:e.message}}}async function ct(e,t,n){let r=rt.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 lt(e,t,n){let r=it.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=N(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.`}:ct(e,{path:i,content:c,reason:o},n)}async function ut(e){try{let t=He(e),{adapter:n,ranked:r}=await Ve(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 dt(e,t){let n=ot.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 ft(e){let{api:t,sandbox:n,approval:r,prompter:i,handlers:a}=e,o=[...e.initialMessages],c=``,l=0;for(;l<W;){n.incrementRound(),l++;let u=await t.openAiStream(`install`,{messages:o,cwd_fingerprint:n.sessionId,diagnosis:e.diagnosis,targetTrackingCode:e.targetTrackingCode}),d=[],f=``;for await(let e of s(u))switch(e.type){case`delta`:f+=e.content,a?.onDelta?.(e.content);break;case`tool_start`:a?.onToolStart?.({id:e.id,name:e.name});break;case`tool_call`:{let t=await pt(e.name,e.arguments,{sandbox:n,cwd:n.cwd,approval:r,prompter:i});d.push({id:e.id,name:e.name,arguments:e.arguments,result:t}),a?.onToolResult?.({id:e.id,name:e.name,result:t});break}case`usage`:a?.onUsage?.(e);break;case`error`:throw a?.onError?.(e),Error(`[${e.code}] ${e.message}`);case`done`:break}if(f&&(c+=f),d.length===0){f&&o.push({role:`assistant`,content:f});break}o.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)o.push({role:`tool`,toolCallId:e.id,toolName:e.name,content:JSON.stringify(e.result)})}return{finalText:c,rounds:l}}async function pt(e,t,n){try{switch(e){case`read_file`:return await st(n.sandbox,t);case`write_file`:return await ct(n.sandbox,t,n.approval);case`patch_file`:return await lt(n.sandbox,t,n.approval);case`detect_framework`:return await ut(n.cwd);case`ask_user`:return await dt(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 mt=e=>`<script defer\n data-id="${e}"\n data-allow-localhost="true"\n src="https://api.zenovay.com/z.js">\n</script>`;async function ht(e){let t={installed:[],skipped:[],errors:[]},n=await j([`**/*.html`,`!node_modules/**`,`!.git/**`,`!dist/**`,`!.next/**`,`!.nuxt/**`,`!build/**`,`!.output/**`],{cwd:e.cwd,gitignore:!0,absolute:!1});if(n.length===0)return t;let r=mt(e.trackingCode),i=RegExp(`data-id\\s*=\\s*["']${gt(e.trackingCode)}["']`);for(let a of n){let n=v.join(e.cwd,a),o;try{o=await y.readFile(n,`utf8`)}catch(e){t.errors.push({file:a,error:e.message});continue}if(K.test(o)&&i.test(o)){t.skipped.push({file:a,reason:`already installed with correct tracking code`});continue}let s;if(K.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??`
|
|
70
|
-
`,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 se)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 y.writeFile(n,s,`utf8`),t.installed.push(a)}catch(e){t.errors.push({file:a,error:e.message})}}return t}function gt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function _t(e){return e.yes||!process.stdout.isTTY?`auto`:`interactive`}function vt(e){let t=null,n=null,r=!1,i=!1,a=0,o=new Set,s=()=>{for(let e of o)e(t)};return{async approve(o){if(i)return`n`;if(e.mode===`auto`||r)return`y`;let c=String(++a);return new Promise(e=>{t={id:c,...o},n=t=>{t===`a`&&(r=!0),e(t)},s()})},subscribe(e){return o.add(e),()=>{o.delete(e)}},current(){return t},resolve(e,r){if(!t||t.id!==e||!n)return;let i=n;t=null,n=null,s(),i(r)},abort(){if(i=!0,n){let e=n;t=null,n=null,s(),e(`n`)}}}}function yt(){let e=[12,15,18,22,28,35,41,50,58,64,72,78],t=_(e,24);return[` ↑`,` ${t}`,` └────────────────────────`,` May Jun Jul Aug Sep`]}function bt(){return[` Landing page ████████████████████ 100%`,` ↓ -28%`,` Pricing ██████████████░░░░░░ 72%`,` ↓ -50%`,` Checkout ███████░░░░░░░░░░░░░ 36%`,` ↓ -64%`,` Purchased ███░░░░░░░░░░░░░░░░░ 13%`]}function xt(){return[` ▇▇▇▇▇▇▇▇▇▎ 89 Sarah K. /pricing 🇺🇸`,` ▇▇▇▇▇▇░░░░ 61 anon /docs 🇩🇪`,` ▇▇▇░░░░░░░ 34 anon /changelog 🇯🇵`]}function St(){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:yt},{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:bt},{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:xt},{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:St},{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.`]}],Ct=8e3,wt=({width:e,height:t})=>{let{theme:n}=d(),[r,i]=A(0);O(()=>{let e=setInterval(()=>{i(e=>(e+1)%X.length)},Ct);return()=>clearInterval(e)},[]);let a=X[r],o=a.visual?a.visual():[],s=X.map((e,t)=>t===r?`●`:`·`).join(` `);return D.createElement(w,{flexDirection:`column`,width:e,height:t,paddingX:2,paddingY:1},D.createElement(w,{marginBottom:1},D.createElement(T,{color:n.accent,bold:!0},`Learn`)),D.createElement(w,{marginBottom:1},D.createElement(T,{bold:!0,color:n.fg},a.title)),a.body.map((e,t)=>D.createElement(T,{key:t,color:n.muted},e||` `)),o.length>0&&D.createElement(w,{flexDirection:`column`,marginTop:1},o.map((e,t)=>D.createElement(T,{key:t,color:n.accent},e))),D.createElement(w,{flexGrow:1}),D.createElement(w,{marginTop:1},D.createElement(T,{color:n.dim,dimColor:!0},s,` · `,r+1,` / `,X.length)))},Tt={pending:`·`,active:`⠋`,done:`✓`,error:`✗`};function Et(e,t){switch(e){case`pending`:return t.dim;case`active`:return t.accent;case`done`:return t.success;case`error`:return t.error}}const Dt=({tasks:e,width:t,height:n,liveLine:r})=>{let{theme:i}=d(),a=e.filter(e=>e.status===`done`).length;return D.createElement(w,{flexDirection:`column`,width:t,height:n,paddingX:2,paddingY:1},D.createElement(w,{marginBottom:1},D.createElement(T,{color:i.accent,bold:!0},`Tasks`)),e.map(e=>D.createElement(w,{key:e.id,flexDirection:`column`},D.createElement(w,null,e.status===`active`?D.createElement(T,{color:i.accent},D.createElement(M,{type:`dots`})):D.createElement(T,{color:Et(e.status,i)},Tt[e.status]),D.createElement(T,null,` `),D.createElement(T,{color:e.status===`pending`?i.muted:i.fg},e.label)),e.detail&&D.createElement(w,{paddingLeft:2},D.createElement(T,{color:i.dim,dimColor:!0},e.detail)))),D.createElement(w,{flexGrow:1}),r&&D.createElement(w,{marginTop:1},D.createElement(T,{color:i.accent},`◆ `),D.createElement(T,{color:i.fg},r)),D.createElement(w,{marginTop:1},D.createElement(T,{color:i.dim,dimColor:!0},a,` / `,e.length)))};async function Ot(e){if(a(e))return kt(e);let t=`quit`,n=null,r=await new Promise(r=>{let{unmount:i,waitUntilExit:a}=ee(D.createElement(At,{opts:e,onExit:(e,a,o)=>{t=a??`quit`,n=o??null,i(),r(e)}}));a().catch(()=>r(1))});if(r===0&&await l().catch(()=>void 0),r!==0||t===`quit`||!n)return r;let i=n.id;if(t===`watch`){let{watchCommand:t}=await import(`./watch-Cv4FtwSJ.js`);return t({cliVersion:e.cliVersion,siteId:i})}if(t===`events`){let{eventsTailCommand:t}=await import(`./events-tail-DGRZewwc.js`);return t({cliVersion:e.cliVersion,siteId:i})}return 0}async function kt(t){let a=await import(`./telemetry-C1045t6Q.js`).catch(()=>null);a?.emit(`install.start`,{properties:{mode:`headless`}});try{let o=await e(),s=await Ue(t.cwd);if(!s)return i({type:`error`,code:`no_framework`,message:`Could not detect framework (headless mode has no picker).`}),a?.emit(`install.error`,{error_code:`no_framework`,properties:{mode:`headless`}}),2;i({type:`framework.detected`,framework:s.id,confidence:1}),a?.emit(`install.framework_detected`,{properties:{framework:s.id}});let c=await r({strict:!1});if(!c&&!process.env.ZENOVAY_API_TOKEN)return i({type:`error`,code:`not_logged_in`,message:"Run `zenovay login` first (or set ZENOVAY_API_TOKEN)."}),2;let l=new n({config:o,cliVersion:t.cliVersion,token:c}),[u,d]=await Promise.all([l.getSites(),z(t.cwd,``).catch(()=>null)]),f;if(t.siteId){if(f=u.find(e=>e.id===t.siteId),!f)return i({type:`error`,code:`site_not_found`,message:`Site ${t.siteId} not found.`}),2}else if(d?.foundTrackingCodes.length){for(let e of d.foundTrackingCodes){let t=u.find(t=>t.trackingCode===e);if(t){f=t;break}}f||=u[0]}else f=u[0];if(!f)return i({type:`error`,code:`no_site`,message:`No sites exist; create one at app.zenovay.com or re-run interactively.`}),2;let p=f.trackingCode??f.id;if(d&&(d.recommendation===`no-op`||d.foundTrackingCodes.includes(p)))return i({type:`info`,message:`Zenovay already installed correctly for ${f.name} (${p})`}),i({type:`done`,command:`init`,exitCode:0}),0;i({type:`info`,message:`Using site ${f.id} (${f.name}) trackingCode=${f.trackingCode??f.id}`});let m=await J(t.cwd,{[s.envVarName]:f.trackingCode??f.id});return i({type:`info`,message:`env vars added: ${m.addedKeys.join(`,`)}`}),i({type:`done`,command:`init`,exitCode:0}),a?.emit(`install.success`,{properties:{framework:s.id,mode:`headless`,env_keys_added:m.addedKeys.length}}),0}catch(e){return i({type:`error`,code:`init_failed`,message:e.message}),a?.emit(`install.error`,{error_code:`init_failed`,properties:{mode:`headless`,error:(e.message??`unknown`).slice(0,128)}}),1}}const At=({opts:t,onExit:i})=>{let{exit:a}=te(),{theme:o}=d(),[s,l]=A(`intro`),[p,m]=A(null),[h,_]=A([]),[v,y]=A(null),[b,x]=A(null),[S,C]=A(null),[ee,E]=A([]),[j,N]=A(void 0),[P,F]=A(null),[ne,re]=A(0),[I,L]=A(null),R=k(null),B=k(!1);return O(()=>(process.stdout.isTTY&&process.stdout.write(`\x1B[?1049h\x1B[H`),()=>{R.current?.abort(),process.stdout.isTTY&&process.stdout.write(`\x1B[?1049l`)}),[]),O(()=>{B.current||(B.current=!0,(async()=>{try{l(`detecting`);let i=await Ue(t.cwd);if(!i){C(`Could not detect your framework. Supported: Next.js, Nuxt, SvelteKit, Astro, Remix, plain HTML.`),l(`error`);return}m(i);let a=await r({strict:!1});!process.env.ZENOVAY_API_TOKEN&&!a&&(l(`login`),await c({cliVersion:t.cliVersion,offerCompletions:!1})),l(`loading-sites`);let o=await e(),s=await r({strict:!1}),u=new n({config:o,cliVersion:t.cliVersion,token:s}),[d,f]=await Promise.all([u.getSites(),z(t.cwd,``).catch(()=>null)]),p=await Gt(t.cwd);if(_(d),y(p),d.length===0){l(`create-site`);return}if(f?.foundTrackingCodes.length)for(let e of f.foundTrackingCodes){let t=d.find(t=>t.trackingCode===e);if(t){x(t),l(`already-installed`);return}}if(t.siteId){let e=d.find(e=>e.id===t.siteId);if(!e){C(`Site ${t.siteId} not found in your account.`),l(`error`);return}x(e),Z(e,i,t,{setPhase:l,setErrorMsg:C,setTasks:E,setLiveLine:N,setSandboxStats:F,setPendingApproval:L,registerBridge:e=>{R.current=e}});return}let h=Kt(d,p);if(t.yes&&h){x(h),Z(h,i,t,{setPhase:l,setErrorMsg:C,setTasks:E,setLiveLine:N,setSandboxStats:F,setPendingApproval:L,registerBridge:e=>{R.current=e}});return}l(`site-picker`)}catch(e){C(e.message),l(`error`)}})())},[]),O(()=>{s===`error`&&(R.current?.abort(),setTimeout(()=>{a(),i(1)},8e3))},[s]),D.createElement(w,{flexDirection:`column`},D.createElement(f,{version:t.cliVersion,subtitle:`AI install wizard`}),s===`intro`&&D.createElement(jt,null),s===`detecting`&&D.createElement(u,{title:`Scanning`,state:`busy`},D.createElement(w,null,D.createElement(T,{color:o.accent},D.createElement(M,{type:`dots`})),D.createElement(T,null,` Detecting framework…`))),s===`login`&&D.createElement(u,{title:`Authenticating`,state:`busy`},D.createElement(T,null,`Opening browser for login… (paste ZENOVAY_API_TOKEN env var to skip)`)),s===`loading-sites`&&D.createElement(u,{title:`Loading your sites`,state:`busy`},D.createElement(w,null,D.createElement(T,{color:o.accent},D.createElement(M,{type:`dots`})),D.createElement(T,null,` Fetching your Zenovay sites…`))),s===`already-installed`&&b&&D.createElement(Nt,{site:b,onContinue:()=>{l(`site-picker`)},onExit:()=>{a(),i(0,`quit`,b)}}),s===`site-picker`&&p&&D.createElement(Pt,{sites:h,preselectHint:v,onPick:e=>{if(e===`create-new`){l(`create-site`);return}x(e),Z(e,p,t,{setPhase:l,setErrorMsg:C,setTasks:E,setLiveLine:N,setSandboxStats:F,setPendingApproval:L,registerBridge:e=>{R.current=e}})}}),s===`create-site`&&D.createElement(u,{title:`Create a new site`,state:`warn`},D.createElement(T,{color:o.warn},"No site picked (or none exist yet). Visit https://app.zenovay.com/websites to create one, then re-run `zenovay init`."),D.createElement(T,{color:o.muted},`(Inline site creation from the CLI is scheduled for V1.1 — it requires a plan-limit check.)`)),s===`agent`&&p&&b&&D.createElement(Mt,{adapter:p,site:b,tasks:ee,liveLine:j,pendingApproval:I,onApprove:e=>{I&&R.current?.resolve(I.id,e)}}),s===`install-complete`&&p&&b&&D.createElement(Lt,{adapter:p,site:b,stats:P,onCommit:()=>l(`commit-prompt`),onSkipCommit:()=>l(`deploy-prompt`)}),s===`commit-prompt`&&b&&D.createElement(Rt,{cwd:t.cwd,onDone:e=>{e.committed&&N(`Pushed ${e.shortSha} to ${e.branch}`),l(`deploy-prompt`)},onError:e=>{C(e),l(`error`)}}),s===`deploy-prompt`&&b&&D.createElement(zt,{site:b,onDeployed:()=>l(`visit-prompt`),onSkip:()=>l(`verify`)}),s===`visit-prompt`&&b&&D.createElement(Bt,{site:b,onContinue:()=>l(`verify`)}),s===`verify`&&b&&D.createElement(Ht,{site:b,elapsed:ne,onTick:e=>re(e),onArrived:()=>l(`success`),onTimeout:()=>l(`success`)}),s===`success`&&p&&b&&D.createElement(It,{adapter:p,site:b,stats:P,onPick:e=>{a(),i(0,e,b)}}),s===`error`&&D.createElement(u,{title:`Install failed`,state:`err`},D.createElement(T,{color:o.error},S??`Unknown error`)),D.createElement(g,{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 q({cwd:o.cwd}),f=i.trackingCode??i.id;await t({defaultSiteId:i.id,defaultSiteName:i.name}).catch(()=>void 0);let p=await z(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 ht({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(`
|
|
71
|
-
`)+`
|
|
72
|
-
3. Insert the tracker using the snippet below.
|
|
73
|
-
4. Confirm the change with a diff before writing.
|
|
74
|
-
|
|
75
|
-
Snippet reference (anchored by anchorKind — adapt to the actual file):
|
|
76
|
-
`+h.map(e=>` ${e.anchorKind} @ ${e.targetPath}:\n ${e.code.replace(/\n/g,`
|
|
77
|
-
`)}`).join(`
|
|
78
|
-
|
|
79
|
-
`);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=vt({mode:_t(o)});s.registerBridge(v);let y=v.subscribe(e=>s.setPendingApproval(e)),b=null;try{await ft({api:u,sandbox:d,approval:v,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){b=e}finally{y(),s.setPendingApproval(null)}let x=d.stats();if(x.writes===0){let e=b?`Agent error: ${b.message}`:`Agent returned without writing any files (${x.reads} reads, ${x.rounds} rounds). The model may have refused or the AI Gateway may be misconfigured. Check api.zenovay.com logs.`;throw Error(e)}let S=a.files.map(e=>e.path),C=x.writtenPaths.some(e=>S.some(t=>e===t||e.endsWith(`/${t}`)));if(!C)throw Error(`Agent wrote to: [${x.writtenPaths.join(`, `)}] but never modified the framework's tracker target file(s): [${S.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 w=await J(o.cwd,{[a.envVarName]:f});if(_(`env`,`done`,`${w.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?.(x),s.setPhase(`install-complete`)}catch(e){s.setErrorMsg(e.message),s.setPhase(`error`)}}const jt=()=>{let{theme:e}=d();return D.createElement(u,{title:`Zenovay wants to set up your project`,state:`idle`},D.createElement(T,null,`We'll use AI to analyze your codebase and add the Zenovay tracker.`),D.createElement(T,{color:e.muted},`.env* contents stay on your machine. Only framework metadata reaches api.zenovay.com.`))},Mt=({adapter:e,site:t,tasks:n,liveLine:r,pendingApproval:i,onApprove:a})=>{let{theme:o}=d(),s=process.stdout.columns??100,c=(process.stdout.rows??30)-8,l=Math.floor(s/2)-1,u=Math.max(14,c);return D.createElement(w,{flexDirection:`column`},D.createElement(w,{flexDirection:`row`,minHeight:u,borderStyle:`round`,borderColor:o.border},D.createElement(w,{width:l,flexDirection:`column`},D.createElement(wt,{width:l,height:u})),D.createElement(w,{width:1,flexDirection:`column`},D.createElement(T,{color:o.border},`│`)),D.createElement(w,{width:l,flexDirection:`column`},i?D.createElement(w,{flexDirection:`column`,paddingX:2,paddingTop:1},D.createElement(T,{color:o.warn},`The agent wants to write `,i.path),i.reason?D.createElement(T,{color:o.muted},i.reason):null,D.createElement(p,{key:i.id,filePath:i.path,oldContent:i.oldContent,newContent:i.newContent,onApprove:a})):D.createElement(D.Fragment,null,D.createElement(w,{paddingX:2,paddingTop:1},D.createElement(m,{done:n.filter(e=>e.status===`done`).length,total:n.length,label:n.find(e=>e.status===`active`)?.label})),D.createElement(Dt,{tasks:n,liveLine:r,width:l,height:u})))),D.createElement(w,{marginTop:1},D.createElement(T,{color:o.muted},`Site: `,t.name,` · code: `,t.trackingCode??t.id,` · Framework: `,e.displayName)))},Nt=({site:e,onContinue:t,onExit:n})=>{let{theme:r}=d();E((e,r)=>{if(e===`q`||r.escape){n();return}if(e===`r`||e===`R`){t();return}});let i=e.url.replace(/^https?:\/\//,``).replace(/\/$/,``);return D.createElement(u,{title:`Already installed`,state:`ok`},D.createElement(w,{flexDirection:`column`,gap:1},D.createElement(w,{flexDirection:`row`,gap:1},D.createElement(T,{color:r.success},`✓`),D.createElement(T,{bold:!0},e.name),D.createElement(T,{color:r.muted},`(`,i,`)`)),D.createElement(T,{color:r.muted},`Zenovay is already tracking this project. No changes needed.`),e.trackingCode?D.createElement(T,{color:r.dim},`tracking code: `,e.trackingCode):null,D.createElement(w,{marginTop:1},D.createElement(T,{color:r.muted},`[`),D.createElement(T,{color:r.accent},`q`),D.createElement(T,{color:r.muted},` quit] [`),D.createElement(T,{color:r.accent},`r`),D.createElement(T,{color:r.muted},` re-run wizard anyway]`))))},Pt=({sites:e,preselectHint:t,onPick:n})=>{let r=Kt(e,t),i=e.filter(e=>e.id!==r?.id),a=r?[r,...i]:i,o=[...a.map(e=>({label:Wt(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 D.createElement(u,{title:t?`Pick a site (best match: ${t})`:`Pick a site`,state:`idle`},D.createElement(h,{items:o,onSelect:n}))};function Ft(){let e=process.argv[1]??``;return e.includes(`/_npx/`)||e.includes(`\\_npx\\`)||process.env.npm_execpath?.includes(`npx`)?`npx`:`global`}const It=({adapter:e,site:t,stats:n,onPick:r})=>{let{theme:i}=d(),a=Ft(),o=a===`npx`?`npx @zenovay/cli`:`zenovay`;return E((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}),D.createElement(u,{title:`You're live on Zenovay`,state:`ok`},D.createElement(T,{color:i.success,bold:!0},`✔ Installed successfully`),D.createElement(w,{marginTop:1,flexDirection:`column`},D.createElement(T,null,`Framework: `,D.createElement(T,{color:i.accent},e.displayName)),D.createElement(T,null,`Site: `,D.createElement(T,{color:i.accent},t.name),` (`,t.url,`)`),t.trackingCode?D.createElement(T,{color:i.muted},`Tracker: `,t.trackingCode):null,n&&n.rounds>0?D.createElement(T,{color:i.muted},`Modified: `,n.writes,` file(s) across `,n.rounds,` agent round(s)`):n&&n.writes>0?D.createElement(T,{color:i.muted},`Modified: `,n.writes,` file(s) (programmatic install — no AI calls)`):null),D.createElement(w,{marginTop:1,flexDirection:`column`},D.createElement(T,{bold:!0},`What's next?`),D.createElement(T,null,` `),D.createElement(w,null,D.createElement(T,{color:i.accent},` [W] `),D.createElement(T,null,`Open the live dashboard `),D.createElement(T,{color:i.muted},`— real-time visitors, top pages, sources, vitals`)),D.createElement(w,null,D.createElement(T,{color:i.accent},` [E] `),D.createElement(T,null,`Stream events as they fire `),D.createElement(T,{color:i.muted},`— page views, custom events, in real time`)),D.createElement(w,null,D.createElement(T,{color:i.accent},` [S] `),D.createElement(T,null,`Exit to shell`))),a===`npx`?D.createElement(w,{marginTop:1,flexDirection:`column`,borderStyle:`single`,borderColor:i.warn,paddingX:1},D.createElement(T,{color:i.warn,bold:!0},`Heads up — you ran via npx`),D.createElement(T,null,D.createElement(T,null,`The `),D.createElement(T,{color:i.accent},`zenovay`),D.createElement(T,null,` command isn't on your PATH yet. After you exit, run any of:`)),D.createElement(T,null,` `),D.createElement(T,{color:i.accent},` npm i -g @zenovay/cli `),D.createElement(T,{color:i.muted},"→ then `zenovay watch` works directly"),D.createElement(T,{color:i.accent},` npx @zenovay/cli watch `),D.createElement(T,{color:i.muted},`→ no install, slower start`)):D.createElement(w,{marginTop:1},D.createElement(T,{color:i.muted},`From your shell: `),D.createElement(T,{color:i.accent},o,` watch`),D.createElement(T,{color:i.muted},` · `),D.createElement(T,{color:i.accent},o,` --help`)),D.createElement(w,{marginTop:1},D.createElement(T,{color:i.muted},`Dashboard URL: https://app.zenovay.com/sites/`,t.id)))},Lt=({adapter:e,site:t,stats:n,onCommit:r,onSkipCommit:i})=>{let{theme:a}=d();return Q(e=>{e===`y`||e===`Y`||e===`\r`?r():(e===`n`||e===`N`||e===`s`||e===`S`)&&i()}),D.createElement(u,{title:`Tracker installed`,state:`ok`},D.createElement(T,null,D.createElement(T,{color:a.success},`✔ `),`The Zenovay tracker is in your project.`),D.createElement(w,{marginTop:1},D.createElement(T,{color:a.muted},`Framework: `),D.createElement(T,null,e.displayName)),D.createElement(w,null,D.createElement(T,{color:a.muted},`Site: `),D.createElement(T,null,t.name,` (`,t.url,`)`)),n&&D.createElement(w,null,D.createElement(T,{color:a.muted},`Modified: `),D.createElement(T,null,n.writes,` file(s)`)),D.createElement(w,{marginTop:1},D.createElement(T,null,`Commit + push these changes to git? `),D.createElement(T,{color:a.accent},`[Y/n]`)))},Rt=({cwd:e,onDone:t,onError:n})=>{let{theme:r}=d(),[i,a]=A(`committing`),[o,s]=A(`Staging changes…`);return O(()=>{(async()=>{try{let n=await Ut(e,e=>s(e),e=>a(e));n.committed?s(`Pushed ${n.shortSha} to origin/${n.branch}`):s(`No changes to commit (already up-to-date).`),setTimeout(()=>t(n),800)}catch(e){n(e.message)}})()},[]),D.createElement(u,{title:`Committing to git`,state:`busy`},D.createElement(w,null,D.createElement(T,{color:r.accent},D.createElement(M,{type:`dots`})),D.createElement(T,null,` `,i===`pushing`?`Pushing to origin`:`Committing`,`…`)),D.createElement(w,{marginTop:1},D.createElement(T,{color:r.muted},o)))},zt=({site:e,onDeployed:t,onSkip:n})=>{let{theme:r}=d();return Q(e=>{e===`y`||e===`Y`||e===`\r`||e===`d`||e===`D`?t():(e===`n`||e===`N`||e===`s`||e===`S`)&&n()}),D.createElement(u,{title:`Ready to deploy?`,state:`idle`},D.createElement(T,null,`The tracker is installed locally. To capture events you need it on the live site:`),D.createElement(T,null,` `),D.createElement(w,null,D.createElement(T,{color:r.accent},` → `),D.createElement(T,null,e.url)),D.createElement(T,null,` `),D.createElement(T,{color:r.muted},`Push the change through your normal deploy pipeline (Vercel auto-deploy, CI/CD, etc.).`),D.createElement(w,{marginTop:1},D.createElement(T,null,`Once it's deployed, press `),D.createElement(T,{color:r.accent},`[Y]`),D.createElement(T,null,` to verify the tracker is firing. `),D.createElement(T,{color:r.muted},`[s] skip verification`)))},Bt=({site:e,onContinue:t})=>{let{theme:n}=d();return Q(()=>t()),D.createElement(u,{title:`Visit your site`,state:`idle`},D.createElement(T,null,`To send a test event, open any page on your site:`),D.createElement(T,null,` `),D.createElement(w,null,D.createElement(T,{color:n.accent},` → `),D.createElement(T,null,e.url)),D.createElement(T,null,` `),D.createElement(T,{color:n.muted},`The tracker fires automatically on page load. We'll verify the next event arrives.`),D.createElement(w,{marginTop:1},D.createElement(T,null,`Press `),D.createElement(T,{color:n.accent},`[any key]`),D.createElement(T,null,` when you've visited the page.`)))};async function Vt(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 Ht=({site:t,elapsed:i,onTick:a,onArrived:o,onTimeout:s})=>{let{theme:c}=d(),[l,f]=A(`preflight`),[p,m]=A(``),[h,g]=A([]),_=k(!1),v=t.trackingCode??t.id,y=async()=>{f(`preflight`),m(`Fetching ${t.url}…`);let e=await Vt(t.url,v);if(!_.current){if(e.state===`tracker-correct`){f(`polling`),m(`Tracker detected on live site — waiting for first hit…`),b();return}if(e.state===`tracker-wrong-id`){f(`wrong-id-on-live`),g(e.foundCodes),m(`Live site has Zenovay but with id(s): ${e.foundCodes.join(`, `)}`);return}f(`awaiting-deploy`),m(e.networkError?`Couldn't reach ${t.url}: ${e.networkError}`:e.httpStatus?`${t.url} returned HTTP ${e.httpStatus}`:`No Zenovay tracker found on ${t.url}.`)}},b=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}),u=await tt(t.id,i,{api:l,timeoutMs:6e4,pollIntervalMs:2500,onTick:e=>{_.current||a(e)}});if(_.current)return;u.received?(f(`success`),o()):f(`timeout`)}catch{_.current||f(`timeout`)}};O(()=>(_.current=!1,y(),()=>{_.current=!0}),[]),E(e=>{(l===`awaiting-deploy`||l===`wrong-id-on-live`||l===`timeout`)&&(e===`r`||e===`R`?y():(e===`s`||e===`S`)&&s())},{isActive:!0});let x=Math.floor(i/1e3);return l===`preflight`?D.createElement(u,{title:`Verifying`,state:`busy`},D.createElement(w,null,D.createElement(T,{color:c.accent},D.createElement(M,{type:`dots`})),D.createElement(T,null,` Checking your live site for the tracker…`)),D.createElement(w,{marginTop:1},D.createElement(T,{color:c.muted},p))):l===`awaiting-deploy`?D.createElement(u,{title:`Tracker not yet on your live site`,state:`warn`},D.createElement(T,{color:c.warn},p),D.createElement(w,{marginTop:1,flexDirection:`column`},D.createElement(T,null,`The tracker is in your local repo but hasn't been deployed yet.`),D.createElement(T,{color:c.muted},`Push your changes and wait for your deploy to finish (Vercel / Cloudflare Pages / CI), then retry.`)),D.createElement(w,{marginTop:1},D.createElement(T,null,`Press `),D.createElement(T,{color:c.accent},`[r]`),D.createElement(T,null,` to re-check, `),D.createElement(T,{color:c.accent},`[s]`),D.createElement(T,null,` to skip verification.`))):l===`wrong-id-on-live`?D.createElement(u,{title:`Live site has a different tracking code`,state:`warn`},D.createElement(T,{color:c.warn},`Expected: `,D.createElement(T,{color:c.accent},v),` `,`Found on live: `,D.createElement(T,{color:c.accent},h.join(`, `))),D.createElement(w,{marginTop:1,flexDirection:`column`},D.createElement(T,null,`Your local install uses a different ID than what's on `,t.url,`.`),D.createElement(T,{color:c.muted},`Deploy the new local version, then retry — or skip if the existing ID is intentional.`)),D.createElement(w,{marginTop:1},D.createElement(T,null,`Press `),D.createElement(T,{color:c.accent},`[r]`),D.createElement(T,null,` to re-check, `),D.createElement(T,{color:c.accent},`[s]`),D.createElement(T,null,` to skip.`))):l===`timeout`?D.createElement(u,{title:`No event arrived in 3 minutes`,state:`warn`},D.createElement(T,{color:c.warn},`The tracker is on your live site but no hits reached api.zenovay.com.`),D.createElement(w,{marginTop:1},D.createElement(T,{color:c.muted},`Try opening `,t.url,` in a fresh browser tab (no ad-blocker), then retry.`)),D.createElement(w,{marginTop:1},D.createElement(T,null,`Press `),D.createElement(T,{color:c.accent},`[r]`),D.createElement(T,null,` to re-check, `),D.createElement(T,{color:c.accent},`[s]`),D.createElement(T,null,` to finish without verification.`))):D.createElement(u,{title:`Waiting for first event`,state:`busy`},D.createElement(w,null,D.createElement(T,{color:c.accent},D.createElement(M,{type:`dots`})),D.createElement(T,null,` Polling api.zenovay.com for the first hit on `),D.createElement(T,{color:c.accent},t.url),D.createElement(T,null,` (`,x,`s elapsed)`)),D.createElement(w,{marginTop:1},D.createElement(T,{color:c.muted},`Reload the page if nothing arrives within ~30 seconds.`)))};function Q(e){E((t,n)=>{e(t,{return:n.return,escape:n.escape})},{isActive:!0})}async function Ut(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 Wt(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 Gt(e){try{let t=await y.readFile(v.join(e,`package.json`),`utf8`),n=JSON.parse(t);if(n.name)return String(n.name).replace(/^@[^/]+\//,``)}catch{}try{let t=await y.readFile(v.join(e,`.git`,`config`),`utf8`),n=t.match(/url\s*=\s*.*[/:]([^/]+?)(?:\.git)?\s*$/m);if(n&&n[1])return n[1]}catch{}return v.basename(e)}function Kt(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=>{let t=$(e.name),r=$(e.url);return t.includes(n)||r.includes(n)||n.includes(t)||n.includes(r)});return a??e[0]??null}function $(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}export{ie as detectInstalled,Ot as initCommand};
|
package/dist/init-WmEUW4Em.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./config--JRu_jFq.js";import"./api-FCanTxsb.js";import"./token-store-BQuGH0z2.js";import{initCommand as e}from"./init-BuyESMBj.js";import"./formatter-DDG2TSOz.js";import"./emit-C9vAopcy.js";import"./secrets-DPf_7SkN.js";import"./client-Dm8uGVCy.js";import"./open-url-BxXbZzWS.js";import"./login-CaDs2Peq.js";import"./theme-BuGrQHax.js";import"./panel-B-XxdP-N.js";import"./banner-DdgwXGzt.js";import"./progress-row-5ns2IsFh.js";import"./prompt-B4s3o9G7.js";import"./keybar-QgnmSion.js";import"./sparkline-CpoBjjlc.js";export{e as initCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{readConfig as e}from"./config--JRu_jFq.js";import"./api-FCanTxsb.js";import{readToken as t}from"./token-store-BQuGH0z2.js";import{ApiV2Client as n}from"./api-v2-CPUUcP1i.js";import{requireTier as r}from"./tier-C4q8fJ8m.js";import"./formatter-DDG2TSOz.js";import{emit$1 as i,isHeadless as a}from"./emit-C9vAopcy.js";import{openInBrowser as o}from"./open-url-BxXbZzWS.js";import"./theme-BuGrQHax.js";import{Panel as s,useTheme as c}from"./panel-B-XxdP-N.js";import{Banner as l}from"./banner-DdgwXGzt.js";import"./prompt-B4s3o9G7.js";import{Keybar as u}from"./keybar-QgnmSion.js";import{resolveSiteId as d}from"./resolve-site-DQVcWhjG.js";import{EmptyState as f}from"./empty-state-DbToIL5T.js";import{deepLinkFor as p}from"./keybar-deep-link-DbmPjAEz.js";import{Box as m,Text as h,render as g,useApp as _,useInput as v}from"ink";import y,{useEffect as b,useState as x}from"react";import S from"ink-spinner";function C(e){return e===`critical`?`err`:e===`warning`?`warn`:`ok`}function w(e){return e===`anomaly`?`⚡ anomaly`:e===`recommendation`?`✦ recommendation`:`↗ trend`}async function T(o){let s=await e(),c=await t({strict:!1});if(!c)return process.stderr.write("Not logged in — run `zenovay login` first.\n"),2;let l=new n({config:s,cliVersion:o.cliVersion,token:c});try{await r(l,`pro`)}catch(e){return process.stderr.write(`${e.message}\n`),2}let u,f;try{({siteId:u,site:f}=await d(l,{explicit:o.siteId,headless:!!o.json,cliVersion:o.cliVersion}))}catch(e){return process.stderr.write(`${e.message}\n`),2}let p=f?.url?f.url.replace(/^https?:\/\//,``).replace(/\/$/,``):f?.name??u;if(a(o)){let e=await l.getInsights(u);return i({type:`insights.snapshot`,data:e}),0}return new Promise(e=>{let{unmount:t}=g(y.createElement(E,{api:l,siteId:u,siteLabel:p,cliVersion:o.cliVersion,onExit:n=>{t(),e(n)}}))})}const E=({api:e,siteId:t,siteLabel:n,cliVersion:r,onExit:i})=>{let{exit:a}=_(),{theme:d}=c(),[g,T]=x(null),[E,D]=x(!0),[O,k]=x(null);return v(e=>{if(e===`o`||e===`O`){o(p(`insights`,{siteId:t}));return}e===`q`&&(a(),i(0))}),b(()=>{let n=!1;return(async()=>{try{let r=await e.getInsights(t);n||(T(r),D(!1))}catch(e){n||(k(e.message),D(!1))}})(),()=>{n=!0}},[e,t]),E?y.createElement(m,{flexDirection:`column`},y.createElement(l,{version:r,subtitle:`insights · ${n}`}),y.createElement(s,{title:`Loading`,state:`busy`},y.createElement(m,null,y.createElement(h,{color:d.accent},y.createElement(S,{type:`dots`})),y.createElement(h,null,` Fetching insights…`)))):O?y.createElement(m,{flexDirection:`column`},y.createElement(l,{version:r,subtitle:`insights · ${n}`}),y.createElement(f,{reason:`error`,headline:`Failed to load`,hint:O})):!g||g.length===0?y.createElement(m,{flexDirection:`column`},y.createElement(l,{version:r,subtitle:`insights · ${n}`}),y.createElement(f,{reason:`no-data`,headline:`No insights yet`,hint:`Insights are generated nightly — check back tomorrow`})):y.createElement(m,{flexDirection:`column`},y.createElement(l,{version:r,subtitle:`insights · ${n}`}),g.map((e,t)=>y.createElement(s,{key:t,title:`${w(e.kind)} · ${e.severity}`,state:C(e.severity)},y.createElement(h,{bold:!0},e.title),e.body?y.createElement(h,{color:d.muted},e.body):null)),y.createElement(u,{items:[{key:`o`,label:`open in browser`},{key:`q`,label:`quit`}]}))};export{T as insightsCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{readConfig as e}from"./config--JRu_jFq.js";import"./api-FCanTxsb.js";import{readToken as t}from"./token-store-BQuGH0z2.js";import{ApiV2Client as n}from"./api-v2-CPUUcP1i.js";import{requireTier as r}from"./tier-C4q8fJ8m.js";import"./formatter-DDG2TSOz.js";import{emit$1 as i,isHeadless as a}from"./emit-C9vAopcy.js";import{openInBrowser as o}from"./open-url-BxXbZzWS.js";import"./theme-BuGrQHax.js";import{Panel as s,useTheme as c}from"./panel-B-XxdP-N.js";import{Banner as l}from"./banner-DdgwXGzt.js";import"./prompt-B4s3o9G7.js";import{Keybar as u}from"./keybar-QgnmSion.js";import{resolveSiteId as d}from"./resolve-site-DQVcWhjG.js";import{EmptyState as f}from"./empty-state-DbToIL5T.js";import{deepLinkFor as p}from"./keybar-deep-link-DbmPjAEz.js";import{Box as m,Text as h,render as g,useApp as _,useInput as v}from"ink";import y,{useEffect as b,useState as x}from"react";import S from"ink-spinner";async function C(o){let s=await e(),c=await t({strict:!1});if(!c)return process.stderr.write("Not logged in — run `zenovay login` first.\n"),2;let l=new n({config:s,cliVersion:o.cliVersion,token:c});try{await r(l,`pro`)}catch(e){return process.stderr.write(`${e.message}\n`),2}let u,f;try{({siteId:u,site:f}=await d(l,{explicit:o.siteId,headless:!!o.json,cliVersion:o.cliVersion}))}catch(e){return process.stderr.write(`${e.message}\n`),2}let p=f?.url?f.url.replace(/^https?:\/\//,``).replace(/\/$/,``):f?.name??u;if(a(o)){let e=await l.getJourneys(u);return i({type:`journeys.snapshot`,data:e}),0}return new Promise(e=>{let{unmount:t}=g(y.createElement(w,{api:l,siteId:u,siteLabel:p,cliVersion:o.cliVersion,onExit:n=>{t(),e(n)}}))})}const w=({api:e,siteId:t,siteLabel:n,cliVersion:r,onExit:i})=>{let{theme:a}=c(),{exit:d}=_(),[g,C]=x(null),[w,T]=x(!0),[E,D]=x(null);if(v(e=>{if(e===`o`||e===`O`){o(p(`journeys`,{siteId:t}));return}e===`q`&&(d(),i(0))}),b(()=>{let n=!1;return(async()=>{try{let r=await e.getJourneys(t);n||(C(r.flows),T(!1))}catch(e){n||(D(e.message),T(!1))}})(),()=>{n=!0}},[e,t]),w)return y.createElement(m,{flexDirection:`column`},y.createElement(l,{version:r,subtitle:`journeys · ${n}`}),y.createElement(s,{title:`Loading`,state:`busy`},y.createElement(m,null,y.createElement(h,{color:a.accent},y.createElement(S,{type:`dots`})),y.createElement(h,null,` Computing flows…`))));if(E)return y.createElement(m,{flexDirection:`column`},y.createElement(l,{version:r,subtitle:`journeys · ${n}`}),y.createElement(f,{reason:`error`,headline:`Failed to load`,hint:E}));if(!g||g.length===0)return y.createElement(m,{flexDirection:`column`},y.createElement(l,{version:r,subtitle:`journeys · ${n}`}),y.createElement(f,{reason:`no-data`,headline:`No journeys yet`,hint:`Need at least 2 page-views per session to compute flows`}));let O=Math.max(...g.map(e=>e.count),1),k=12;return y.createElement(m,{flexDirection:`column`},y.createElement(l,{version:r,subtitle:`journeys · ${n}`}),y.createElement(s,{title:`Top page transitions (${g.length})`},g.map((e,t)=>{let n=Math.max(1,Math.round(e.count/O*k));return y.createElement(m,{key:t,flexDirection:`row`},y.createElement(h,null,e.from.padEnd(22).slice(0,22)),y.createElement(h,{color:a.accent},` → `),y.createElement(h,null,e.to.padEnd(22).slice(0,22)),y.createElement(h,{color:a.accent},` `,`█`.repeat(n),`░`.repeat(k-n)),y.createElement(h,{color:a.muted},` ${e.count}`))})),y.createElement(u,{items:[{key:`o`,label:`open in browser`},{key:`q`,label:`quit`}]}))};export{C as journeysCommand};
|
package/dist/live-CWSLgkC2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{readConfig as e}from"./config--JRu_jFq.js";import"./api-FCanTxsb.js";import{readToken as t}from"./token-store-BQuGH0z2.js";import"./telemetry-DRh10SvO.js";import{ApiV2Client as n}from"./api-v2-CPUUcP1i.js";import"./formatter-DDG2TSOz.js";import{emit$1 as r,isHeadless as i}from"./emit-C9vAopcy.js";import"./client-Dm8uGVCy.js";import{openInBrowser as a}from"./open-url-BxXbZzWS.js";import"./theme-BuGrQHax.js";import{Panel as o,useTheme as s}from"./panel-B-XxdP-N.js";import{Banner as c}from"./banner-DdgwXGzt.js";import"./prompt-B4s3o9G7.js";import{Keybar as l}from"./keybar-QgnmSion.js";import"./sparkline-CpoBjjlc.js";import{ChatPanel as u}from"./chat-panel-ZlKZ0W6J.js";import{resolveSiteId as d}from"./resolve-site-DQVcWhjG.js";import{EmptyState as f}from"./empty-state-DbToIL5T.js";import{MetricCard as p}from"./metric-card-bQ-j_G6l.js";import{deepLinkFor as m}from"./keybar-deep-link-DbmPjAEz.js";import{Box as h,Text as g,render as _,useApp as v,useInput as y}from"ink";import b,{useEffect as x,useState as S}from"react";import C from"ink-spinner";async function w(a){let o=await e(),s=await t({strict:!1});if(!s)return process.stderr.write("Not logged in — run `zenovay login` first.\n"),2;let c=new n({config:o,cliVersion:a.cliVersion,token:s}),l,u;try{({siteId:l,site:u}=await d(c,{explicit:a.siteId,headless:!!a.json,cliVersion:a.cliVersion}))}catch(e){return process.stderr.write(`${e.message}\n`),2}let f=u?.url?u.url.replace(/^https?:\/\//,``).replace(/\/$/,``):u?.name??l;if(i(a)){let e=await c.getLive(l);return r({type:`live.snapshot`,data:e}),0}return new Promise(e=>{let{unmount:t}=_(b.createElement(T,{api:c,siteId:l,siteLabel:f,cliVersion:a.cliVersion,onExit:n=>{t(),e(n)}}))})}const T=({api:e,siteId:t,siteLabel:n,cliVersion:r,onExit:i})=>{let{exit:d}=v(),{theme:_}=s(),[w,T]=S(null),[E,D]=S(!0),[O,k]=S(null),[A,j]=S(!1);if(y(e=>{if(!A){if(e===`/`){j(!0);return}if(e===`o`||e===`O`){a(m(`live`,{siteId:t}));return}e===`q`&&(d(),i(0))}}),x(()=>{if(A)return;let n=!1,r=async()=>{try{let r=await e.getLive(t);n||(T(r),D(!1),k(null))}catch(e){n||(k(e.message),D(!1))}};r();let i=setInterval(r,2e3);return()=>{n=!0,clearInterval(i)}},[e,t,A]),A)return b.createElement(u,{cliVersion:r,api:e,dashboardContext:{commandName:`live`,siteId:t,siteLabel:n,metricsSnapshot:w},onClose:()=>j(!1)});if(E)return b.createElement(h,{flexDirection:`column`},b.createElement(c,{version:r,subtitle:`live · ${n}`}),b.createElement(o,{title:`Loading`,state:`busy`},b.createElement(h,null,b.createElement(g,{color:_.accent},b.createElement(C,{type:`dots`})),b.createElement(g,null,` Connecting…`))));if(O&&!w)return b.createElement(h,{flexDirection:`column`},b.createElement(c,{version:r,subtitle:`live · ${n}`}),b.createElement(f,{reason:`error`,headline:`Failed to load`,hint:O}));let M=process.stdout.columns??80,N=Math.max(20,Math.min(40,Math.floor(M/3)));return b.createElement(h,{flexDirection:`column`},b.createElement(c,{version:r,subtitle:`live · ${n}`}),b.createElement(p,{title:`Active now`,value:w?.activeVisitors??0,format:`number`,width:N}),b.createElement(o,{title:`Recent events`},!w||w.recentEvents.length===0?b.createElement(g,{color:_.dim},`— waiting for events —`):w.recentEvents.slice(0,15).map((e,t)=>b.createElement(h,{key:t},b.createElement(g,{color:_.accent},(e.type??`pageview`).padEnd(10)),b.createElement(g,null,e.path.padEnd(36).slice(0,36)),b.createElement(g,{color:_.muted},e.country??`—`)))),b.createElement(l,{items:[{key:`/`,label:`ask AI`},{key:`o`,label:`open in browser`},{key:`q`,label:`quit`}]}))};export{w as liveCommand};
|
package/dist/login-CaDs2Peq.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{readConfig as e}from"./config--JRu_jFq.js";import{ApiClient as t,pollDeviceToken as n,startDeviceAuthorization as r}from"./api-FCanTxsb.js";import{writeToken as i}from"./token-store-BQuGH0z2.js";import{emit$1 as a,isHeadless as o}from"./emit-C9vAopcy.js";import{openInBrowser as s}from"./open-url-BxXbZzWS.js";import c from"node:path";import{promises as l}from"node:fs";import u from"node:os";async function d(c){let l=await e(),u=o({json:c.json}),d=await r({apiBase:l.apiBase}),f=d.verification_uri_complete??d.verification_uri;u?a({type:`info`,message:`Open ${f} and enter code ${d.user_code}`}):c.onCode?c.onCode({userCode:d.user_code,verificationUri:d.verification_uri,verificationUriComplete:d.verification_uri_complete}):process.stdout.write(`\n Open this URL to authorize the CLI:\n ${f}\n Or enter code: ${d.user_code}\n\n`);let p=c.openBrowser??!u;if(p)try{await s(f)}catch{}let m=await n({apiBase:l.apiBase,deviceCode:d.device_code,interval:d.interval,expiresIn:d.expires_in});await i(m);let h=new t({config:l,cliVersion:c.cliVersion,token:m}),_=await h.me().catch(()=>null);if(_){let e={...m,userId:_.user.id,teamId:_.team?.id,email:_.user.email};await i(e)}return u?a({type:`done`,command:`login`,exitCode:0}):c.offerCompletions!==!1&&await g().catch(()=>void 0),{email:_?.user.email}}function f(){let e=process.env.SHELL??``,t=u.homedir();if(e.endsWith(`/zsh`)||e.endsWith(`zsh`))return{shell:`zsh`,rcPath:c.join(t,`.zshrc`)};if(e.endsWith(`/bash`)||e.endsWith(`bash`)){let e=process.platform===`darwin`?c.join(t,`.bash_profile`):c.join(t,`.bashrc`);return{shell:`bash`,rcPath:e}}return e.endsWith(`/fish`)||e.endsWith(`fish`)?{shell:`fish`,rcPath:c.join(t,`.config`,`fish`,`config.fish`)}:null}const p=/zenovay\s+completions/;async function m(e,t){try{let n=await l.readFile(e,`utf8`);return t.test(n)}catch{return!1}}function h(e){return process.stdin.isTTY?new Promise(t=>{process.stdout.write(e),process.stdin.setEncoding(`utf8`);let n=e=>{process.stdin.removeListener(`data`,n);try{process.stdin.pause()}catch{}let r=e.trim().toLowerCase();return t(r===``||r===`y`||r===`yes`)};process.stdin.resume(),process.stdin.on(`data`,n)}):Promise.resolve(!1)}async function g(){let e=f();if(!e||await m(e.rcPath,p))return;let t=await h(`Install shell completions for ${e.shell}? [Y/n] `);if(!t){process.stdout.write(`Skipped. You can install later with: zenovay completions ${e.shell} >> ${e.rcPath}\n`);return}let n=e.shell===`fish`?`zenovay completions fish | source
|
|
2
|
-
`:`eval "$(zenovay completions ${e.shell})"\n`;try{await l.mkdir(c.dirname(e.rcPath),{recursive:!0}),await l.appendFile(e.rcPath,`\n# Added by zenovay login\n${n}`,`utf8`),process.stdout.write(`✓ Completions installed. Restart your shell or source ${e.rcPath}.\n`)}catch(t){process.stdout.write(`Could not write ${e.rcPath} (${t.message}). Run manually: zenovay completions ${e.shell} >> ${e.rcPath}\n`)}}export{d as loginCommand,g as maybeInstallCompletions};
|
package/dist/login-wpGuU_Zm.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./config--JRu_jFq.js";import"./api-FCanTxsb.js";import"./token-store-BQuGH0z2.js";import"./formatter-DDG2TSOz.js";import"./emit-C9vAopcy.js";import"./open-url-BxXbZzWS.js";import{loginCommand as e,maybeInstallCompletions as t}from"./login-CaDs2Peq.js";export{e as loginCommand};
|
package/dist/logout-BkeT6Hke.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{readConfig as e}from"./config--JRu_jFq.js";import{ApiClient as t}from"./api-FCanTxsb.js";import{clearToken as n,readToken as r}from"./token-store-BQuGH0z2.js";import"./formatter-DDG2TSOz.js";import{emit$1 as i,isHeadless as a}from"./emit-C9vAopcy.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};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{readConfig as e}from"./config--JRu_jFq.js";import"./api-FCanTxsb.js";import{readToken as t}from"./token-store-BQuGH0z2.js";import{ApiV2Client as n}from"./api-v2-CPUUcP1i.js";import{requireTier as r}from"./tier-C4q8fJ8m.js";import"./formatter-DDG2TSOz.js";import{emit$1 as i,isHeadless as a}from"./emit-C9vAopcy.js";import{openInBrowser as o}from"./open-url-BxXbZzWS.js";import"./theme-BuGrQHax.js";import{Panel as s,useTheme as c}from"./panel-B-XxdP-N.js";import{Banner as l}from"./banner-DdgwXGzt.js";import"./prompt-B4s3o9G7.js";import{Keybar as u}from"./keybar-QgnmSion.js";import{resolveSiteId as d}from"./resolve-site-DQVcWhjG.js";import{EmptyState as f}from"./empty-state-DbToIL5T.js";import{deepLinkFor as p}from"./keybar-deep-link-DbmPjAEz.js";import{Box as m,Text as h,render as g,useApp as _,useInput as v}from"ink";import y,{useEffect as b,useState as x}from"react";import S from"ink-spinner";function C(e,t){return e>=.6?t.accent:e>=.4?t.muted:t.dim}function w(e){return!Number.isFinite(e)||e===0?` — `:` ${(e*100).toFixed(0).padStart(3)}% `}async function T(o){let s=await e(),c=await t({strict:!1});if(!c)return process.stderr.write("Not logged in — run `zenovay login` first.\n"),2;let l=new n({config:s,cliVersion:o.cliVersion,token:c});try{await r(l,`pro`)}catch(e){return process.stderr.write(`${e.message}\n`),2}let u,f;try{({siteId:u,site:f}=await d(l,{explicit:o.siteId,headless:!!o.json,cliVersion:o.cliVersion}))}catch(e){return process.stderr.write(`${e.message}\n`),2}let p=f?.url?f.url.replace(/^https?:\/\//,``).replace(/\/$/,``):f?.name??u;if(a(o)){let e=await l.getRetention(u);return i({type:`retention.snapshot`,data:e}),0}return new Promise(e=>{let{unmount:t}=g(y.createElement(E,{api:l,siteId:u,siteLabel:p,cliVersion:o.cliVersion,onExit:n=>{t(),e(n)}}))})}const E=({api:e,siteId:t,siteLabel:n,cliVersion:r,onExit:i})=>{let{exit:a}=_(),{theme:d}=c(),[g,T]=x(null),[E,D]=x(!0),[O,k]=x(null);return v(e=>{if(e===`o`||e===`O`){o(p(`retention`,{siteId:t}));return}e===`q`&&(a(),i(0))}),b(()=>{let n=!1;return(async()=>{try{let r=await e.getRetention(t);n||(T(r.cohorts),D(!1))}catch(e){n||(k(e.message),D(!1))}})(),()=>{n=!0}},[e,t]),E?y.createElement(m,{flexDirection:`column`},y.createElement(l,{version:r,subtitle:`retention · ${n}`}),y.createElement(s,{title:`Loading`,state:`busy`},y.createElement(m,null,y.createElement(h,{color:d.accent},y.createElement(S,{type:`dots`})),y.createElement(h,null,` Crunching cohorts…`)))):O?y.createElement(m,{flexDirection:`column`},y.createElement(l,{version:r,subtitle:`retention · ${n}`}),y.createElement(f,{reason:`error`,headline:`Failed to load`,hint:O})):!g||g.length===0?y.createElement(m,{flexDirection:`column`},y.createElement(l,{version:r,subtitle:`retention · ${n}`}),y.createElement(f,{reason:`no-data`,headline:`No retention data yet`,hint:`Retention needs at least 30 days of traffic`})):y.createElement(m,{flexDirection:`column`},y.createElement(l,{version:r,subtitle:`retention · ${n}`}),y.createElement(s,{title:`Cohort retention (D1 / D7 / D30)`},y.createElement(m,{flexDirection:`row`},y.createElement(h,{bold:!0},`cohort`.padEnd(12)),y.createElement(h,{bold:!0},` D1 `),y.createElement(h,{bold:!0},` D7 `),y.createElement(h,{bold:!0},` D30 `)),g.map(e=>y.createElement(m,{key:e.date,flexDirection:`row`},y.createElement(h,null,e.date.padEnd(12).slice(0,12)),y.createElement(h,{color:C(e.day1,d)},w(e.day1)),y.createElement(h,{color:C(e.day7,d)},w(e.day7)),y.createElement(h,{color:C(e.day30,d)},w(e.day30))))),y.createElement(u,{items:[{key:`o`,label:`open in browser`},{key:`q`,label:`quit`}]}))};export{T as retentionCommand};
|
package/dist/secrets-M60NENIa.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{SECRET_PATTERNS as e,scrubSecrets as t}from"./secrets-DPf_7SkN.js";export{e as SECRET_PATTERNS,t as scrubSecrets};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{readConfig as e}from"./config--JRu_jFq.js";import"./api-FCanTxsb.js";import{readToken as t}from"./token-store-BQuGH0z2.js";import{ApiV2Client as n}from"./api-v2-CPUUcP1i.js";import{requireTier as r}from"./tier-C4q8fJ8m.js";import"./formatter-DDG2TSOz.js";import{emit$1 as i,isHeadless as a}from"./emit-C9vAopcy.js";import{openInBrowser as o}from"./open-url-BxXbZzWS.js";import"./theme-BuGrQHax.js";import{Panel as s,useTheme as c}from"./panel-B-XxdP-N.js";import{Banner as l}from"./banner-DdgwXGzt.js";import"./prompt-B4s3o9G7.js";import{Keybar as u}from"./keybar-QgnmSion.js";import{resolveSiteId as d}from"./resolve-site-DQVcWhjG.js";import{DataTable as f}from"./data-table-DJzT7bAr.js";import{EmptyState as p}from"./empty-state-DbToIL5T.js";import{deepLinkFor as m}from"./keybar-deep-link-DbmPjAEz.js";import{Box as h,Text as g,render as _,useApp as v,useInput as y}from"ink";import b,{useEffect as x,useState as S}from"react";import C from"ink-spinner";function w(e){if(!e||e<=0)return`—`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return`${n}m ${(t%60).toString().padStart(2,`0`)}s`}function T(e){if(!e)return`—`;let t=Date.parse(e);if(Number.isNaN(t))return`—`;let n=Math.max(0,Math.floor((Date.now()-t)/1e3));return n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}d`}async function E(o){let s=await e(),c=await t({strict:!1});if(!c)return process.stderr.write("Not logged in — run `zenovay login` first.\n"),2;let l=new n({config:s,cliVersion:o.cliVersion,token:c});try{await r(l,`pro`)}catch(e){return process.stderr.write(`${e.message}\n`),2}let u,f;try{({siteId:u,site:f}=await d(l,{explicit:o.siteId,headless:!!o.json,cliVersion:o.cliVersion}))}catch(e){return process.stderr.write(`${e.message}\n`),2}let p=f?.url?f.url.replace(/^https?:\/\//,``).replace(/\/$/,``):f?.name??u;if(a(o)){let e=await l.getSessions(u);return i({type:`sessions.snapshot`,data:e}),0}return new Promise(e=>{let{unmount:t}=_(b.createElement(D,{api:l,siteId:u,siteLabel:p,cliVersion:o.cliVersion,onExit:n=>{t(),e(n)}}))})}const D=({api:e,siteId:t,siteLabel:n,cliVersion:r,onExit:i})=>{let{exit:a}=v(),{theme:d}=c(),[_,E]=S(null),[D,O]=S(!0),[k,A]=S(null);if(y(e=>{if(e===`o`||e===`O`){o(m(`sessions`,{siteId:t}));return}e===`q`&&(a(),i(0))}),x(()=>{let n=!1;return(async()=>{try{let r=await e.getSessions(t);n||(E(r),O(!1))}catch(e){n||(A(e.message),O(!1))}})(),()=>{n=!0}},[e,t]),D)return b.createElement(h,{flexDirection:`column`},b.createElement(l,{version:r,subtitle:`sessions · ${n}`}),b.createElement(s,{title:`Loading`,state:`busy`},b.createElement(h,null,b.createElement(g,{color:d.accent},b.createElement(C,{type:`dots`})),b.createElement(g,null,` Fetching sessions…`))));if(k)return b.createElement(h,{flexDirection:`column`},b.createElement(l,{version:r,subtitle:`sessions · ${n}`}),b.createElement(p,{reason:`error`,headline:`Failed to load`,hint:k}));if(!_||_.length===0)return b.createElement(h,{flexDirection:`column`},b.createElement(l,{version:r,subtitle:`sessions · ${n}`}),b.createElement(p,{reason:`no-data`,headline:`No replays yet`,hint:`Enable session replay in your site settings`}));let j=[{key:`id`,label:`session id`,width:24},{key:`visitor`,label:`visitor`,width:18},{key:`duration`,label:`duration`,align:`right`,width:9,format:e=>w(e)},{key:`startedAt`,label:`when`,align:`right`,width:6,format:e=>T(String(e))},{key:`pageCount`,label:`events`,align:`right`,width:7},{key:`deviceType`,label:`device`,width:8,format:e=>String(e??`—`)}];return b.createElement(h,{flexDirection:`column`},b.createElement(l,{version:r,subtitle:`sessions · ${n}`}),b.createElement(s,{title:`Recent sessions (${_.length})`},b.createElement(f,{columns:j,data:_,zebra:!0})),b.createElement(h,{marginTop:1},b.createElement(g,{color:d.muted},`Open any session for replay at https://app.zenovay.com/replay`)),b.createElement(u,{items:[{key:`o`,label:`open in browser`},{key:`q`,label:`quit`}]}))};export{E as sessionsCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./config--JRu_jFq.js";import{emit as e,flush as t,getProcessUptimeMs as n,getTelemetryStatus as r,initTelemetry as i,setTelemetry as a}from"./telemetry-DRh10SvO.js";export{e as emit,t as flush,n as getProcessUptimeMs,r as getTelemetryStatus,i as initTelemetry,a as setTelemetry};
|
package/dist/update-BCgHj5O4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{readConfig as e}from"./config--JRu_jFq.js";import{classifyBump as t,fetchManifest as n}from"./check-D9G0N7NB.js";import{applyUpdate as r}from"./apply-B19bFTz0.js";import"./formatter-DDG2TSOz.js";import{emit$1 as i,isHeadless as a}from"./emit-C9vAopcy.js";async function o(o){let s=await e(),c=await n({cliBase:s.cliBase}),l=t(o.cliVersion,c.latest);if(o.check)return a({json:o.json})?i({type:`info`,message:`latest=${c.latest} current=${o.cliVersion} bump=${l}`}):process.stdout.write(`Current: ${o.cliVersion}\nLatest: ${c.latest}\nBump: ${l}\n`),{updated:!1,from:o.cliVersion,to:c.latest};if(l===`none`)return a({json:o.json})||process.stdout.write(`Already on latest (${o.cliVersion}).\n`),{updated:!1,from:o.cliVersion,to:c.latest};if(l===`downgrade`&&!o.forceDowngrade)throw Error(`Refused to downgrade ${o.cliVersion} → ${c.latest}. Pass --force-downgrade if you really want this.`);let u=await r({currentVersion:o.cliVersion,cliBase:s.cliBase,binaryPath:o.binaryPath,forceDowngrade:o.forceDowngrade});return a({json:o.json})?u.updated&&i({type:`update.applied`,from:u.from,to:u.to}):u.updated?process.stdout.write(`Updated ${u.from} → ${u.to}\n`):process.stdout.write(`Not updated (${u.reason??`unknown`}).\n`),u}export{o as updateCommand};
|
package/dist/uptime-CwG6bqir.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{readConfig as e}from"./config--JRu_jFq.js";import"./api-FCanTxsb.js";import{readToken as t}from"./token-store-BQuGH0z2.js";import{ApiV2Client as n}from"./api-v2-CPUUcP1i.js";import{requireTier as r}from"./tier-C4q8fJ8m.js";import"./formatter-DDG2TSOz.js";import{emit$1 as i,isHeadless as a}from"./emit-C9vAopcy.js";import{openInBrowser as o}from"./open-url-BxXbZzWS.js";import"./theme-BuGrQHax.js";import{Panel as s,useTheme as c}from"./panel-B-XxdP-N.js";import{Banner as l}from"./banner-DdgwXGzt.js";import"./prompt-B4s3o9G7.js";import{Keybar as u}from"./keybar-QgnmSion.js";import{resolveSiteId as d}from"./resolve-site-DQVcWhjG.js";import{DataTable as f}from"./data-table-DJzT7bAr.js";import{EmptyState as p}from"./empty-state-DbToIL5T.js";import{deepLinkFor as m}from"./keybar-deep-link-DbmPjAEz.js";import{Box as h,Text as g,render as _,useApp as v,useInput as y}from"ink";import b,{useEffect as x,useState as S}from"react";import C from"ink-spinner";function w(e){return e===`up`?{glyph:`● up`,color:`green`}:e===`down`?{glyph:`● down`,color:`red`}:{glyph:`○ unknown`,color:`gray`}}function T(e){if(!e)return`—`;let t=Date.parse(e);if(Number.isNaN(t))return`—`;let n=Math.round((t-Date.now())/(1e3*60*60*24));return`${n}d`}async function E(o){let s=await e(),c=await t({strict:!1});if(!c)return process.stderr.write("Not logged in — run `zenovay login` first.\n"),2;let l=new n({config:s,cliVersion:o.cliVersion,token:c});try{await r(l,`pro`)}catch(e){return process.stderr.write(`${e.message}\n`),2}let u,f;try{({siteId:u,site:f}=await d(l,{explicit:o.siteId,headless:!!o.json,cliVersion:o.cliVersion}))}catch(e){return process.stderr.write(`${e.message}\n`),2}let p=f?.url?f.url.replace(/^https?:\/\//,``).replace(/\/$/,``):f?.name??u;if(a(o)){let e=await l.getUptime(u);return i({type:`uptime.snapshot`,data:e}),0}return new Promise(e=>{let{unmount:t}=_(b.createElement(D,{api:l,siteId:u,siteLabel:p,cliVersion:o.cliVersion,onExit:n=>{t(),e(n)}}))})}const D=({api:e,siteId:t,siteLabel:n,cliVersion:r,onExit:i})=>{let{exit:a}=v(),{theme:d}=c(),[_,E]=S(null),[D,O]=S(!0),[k,A]=S(null);if(y(e=>{if(e===`o`||e===`O`){o(m(`uptime`,{siteId:t}));return}e===`q`&&(a(),i(0))}),x(()=>{let n=!1;return(async()=>{try{let r=await e.getUptime(t);n||(E(r.monitors),O(!1))}catch(e){n||(A(e.message),O(!1))}})(),()=>{n=!0}},[e,t]),D)return b.createElement(h,{flexDirection:`column`},b.createElement(l,{version:r,subtitle:`uptime · ${n}`}),b.createElement(s,{title:`Loading`,state:`busy`},b.createElement(h,null,b.createElement(g,{color:d.accent},b.createElement(C,{type:`dots`})),b.createElement(g,null,` Fetching monitors…`))));if(k)return b.createElement(h,{flexDirection:`column`},b.createElement(l,{version:r,subtitle:`uptime · ${n}`}),b.createElement(p,{reason:`error`,headline:`Failed to load`,hint:k}));if(!_||_.length===0)return b.createElement(h,{flexDirection:`column`},b.createElement(l,{version:r,subtitle:`uptime · ${n}`}),b.createElement(p,{reason:`no-data`,headline:`No monitors configured`,hint:`Add one at app.zenovay.com/uptime`}));let j=[{key:`url`,label:`monitor`,width:36},{key:`status`,label:`status`,width:12,format:e=>w(String(e)).glyph},{key:`p95ms`,label:`p95 ms`,align:`right`,width:8,format:e=>typeof e==`number`?String(e):`—`},{key:`sslExpiry`,label:`ssl exp`,align:`right`,width:7,format:e=>T(e)}];return b.createElement(h,{flexDirection:`column`},b.createElement(l,{version:r,subtitle:`uptime · ${n}`}),b.createElement(s,{title:`Monitors (${_.length})`},b.createElement(f,{columns:j,data:_,zebra:!0})),b.createElement(u,{items:[{key:`o`,label:`open in browser`},{key:`q`,label:`quit`}]}))};export{E as uptimeCommand};
|
package/dist/watch-Cv4FtwSJ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{readConfig as e}from"./config--JRu_jFq.js";import"./api-FCanTxsb.js";import{readToken as t}from"./token-store-BQuGH0z2.js";import{ApiV2Client as n}from"./api-v2-CPUUcP1i.js";import"./formatter-DDG2TSOz.js";import{emit$1 as r,isHeadless as i}from"./emit-C9vAopcy.js";import{parseSseStream as a}from"./client-Dm8uGVCy.js";import{openInBrowser as o}from"./open-url-BxXbZzWS.js";import"./theme-BuGrQHax.js";import{Panel as s,useTheme as c}from"./panel-B-XxdP-N.js";import{Banner as l}from"./banner-DdgwXGzt.js";import"./prompt-B4s3o9G7.js";import{Keybar as u}from"./keybar-QgnmSion.js";import{spark as d}from"./sparkline-CpoBjjlc.js";import{resolveSiteId as f}from"./resolve-site-DQVcWhjG.js";import{EmptyState as p}from"./empty-state-DbToIL5T.js";import{deepLinkFor as m}from"./keybar-deep-link-DbmPjAEz.js";import{z as h}from"zod";import{Box as g,Text as _,render as v,useApp as y,useInput as b}from"ink";import x,{useEffect as S,useState as C}from"react";import w from"ink-spinner";import T from"ink-text-input";const E=Math.PI*2;function D(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 O(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=D(n),a=r*Math.cos(i)/Math.PI,o=Math.sin(i);return{x:a,y:o}}function k(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 A(e,t){let n=e*2,r=t*4;return{dw:n,dh:r,bits:new Uint8Array(n*r)}}function j(e,t,n){t<0||t>=e.dw||n<0||n>=e.dh||(e.bits[n*e.dw+t]=1)}function M(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*E,c=Math.round(t+r*Math.cos(s)),l=Math.round(n+i*Math.sin(s));j(e,c,l)}}function N(e){let t=Math.floor(e.dh/2);for(let n=0;n<e.dw;n+=4)j(e,n,t)}function P(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=O(o.lat,o.lng);if(!t)continue;let s=Math.round(n+t.x*i),c=Math.round(r-t.y*a);j(e,s,c),j(e,s+1,c),j(e,s,c+1),j(e,s+1,c+1)}}const F=[[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[0,3],[1,3]];function I(e,t,n){let r=0;for(let i=0;i<F.length;i++){let[a,o]=F[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 L(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 R({data:e,width:t=80,height:n=20,asciiOnly:r}){let{theme:i}=c(),a=k(r),o=A(t,n);M(o),N(o),P(o,e);let s=[];for(let e=0;e<n;e++){let n=``;for(let r=0;r<t;r++)n+=a?L(o,r,e):I(o,r,e);s.push(n)}return x.createElement(g,{flexDirection:`column`},s.map((e,t)=>x.createElement(_,{key:t,color:i.accent},e)),x.createElement(_,{color:i.muted},e.length,` live · `,a?`ascii mode`:`braille mode`))}const z=h.object({siteId:h.string().optional(),window:h.string().optional(),totalVisitors:h.number().optional(),visitors:h.object({count:h.number().optional(),series:h.array(h.number()).optional()}).optional(),topPages:h.array(h.object({path:h.string(),views:h.number().optional(),count:h.number().optional()})).optional(),sources:h.array(h.object({source:h.string(),visitors:h.number()})).optional()}).passthrough();async function B(a){let o=await e(),s=await t({strict:!1});if(!s)return process.stderr.write("Not logged in — run `zenovay login` first.\n"),2;let c=new n({config:o,cliVersion:a.cliVersion,token:s}),l;try{({siteId:l}=await f(c,{explicit:a.siteId,headless:!!a.json,cliVersion:a.cliVersion}))}catch(e){return process.stderr.write(`${e.message}\n`),2}if(i(a)){let e=await c.getDashboardSnapshot(l);return r({type:`watch.tick`,snapshot:e}),0}return new Promise(e=>{let{unmount:t}=v(x.createElement(V,{api:c,siteId:l,intervalMs:a.intervalMs??15e3,cliVersion:a.cliVersion,onExit:n=>{t(),e(n)}}))})}const V=({api:e,siteId:t,intervalMs:n,cliVersion:r,onExit:i})=>{let{theme:d}=c(),{exit:f}=y(),[h,v]=C(null),[T,E]=C(null),[D,O]=C(null),[k,A]=C([]),[j,M]=C(!0),[N,P]=C(null),[F,I]=C(1),[L,B]=C(!1),[V,Y]=C(!1);b((e,n)=>{if(e===`o`||e===`O`){o(m(`watch`,{siteId:t}));return}if(e===`q`){f(),i(0);return}if(e===`?`||e===`/`){Y(e=>!e);return}if(e===`g`){B(e=>!e);return}if(n.tab){I(e=>{let t=n.shift?(e+4)%6+1:e%6+1;return t});return}(e===`1`||e===`2`||e===`3`||e===`4`||e===`5`||e===`6`)&&I(Number(e))});let[X,Z]=C(!1);if(S(()=>{let r=!1,i=async()=>{try{let n=await e.getDashboardSnapshot(t);if(r)return;let i=z.safeParse(n);if(!i.success){Z(!0),M(!1);return}Z(!1);let a=i.data,o={visitors:a.visitors??(typeof a.totalVisitors==`number`?{count:a.totalVisitors}:void 0),topPages:a.topPages?.map(e=>({path:e.path,views:e.views??e.count??0})),sources:a.sources};v(o),e.getVitals(t).then(e=>{r||E(e)},()=>{}),e.getGoals(t).then(e=>{r||O(e)},()=>{}),M(!1),P(null)}catch(e){r||P(e.message)}};i();let a=setInterval(i,n);return()=>{r=!0,clearInterval(a)}},[e,t,n]),S(()=>{let n=new AbortController;return(async()=>{try{let r=await e.openEventsStream(t,n.signal);for await(let e of a(r))e.type===`error`&&A(t=>[...t,`[ERR ${e.code}] ${e.message}`].slice(-10))}catch{}})(),()=>n.abort()},[e,t]),j)return x.createElement(g,{flexDirection:`column`},x.createElement(l,{version:r,subtitle:`watch · ${t}`}),x.createElement(s,{title:`Loading`,state:`busy`},x.createElement(g,null,x.createElement(_,{color:d.accent},x.createElement(w,{type:`dots`})),x.createElement(_,null,` Fetching snapshot…`))));if(N&&!h)return x.createElement(g,{flexDirection:`column`},x.createElement(l,{version:r,subtitle:`watch · ${t}`}),x.createElement(s,{title:`Error`,state:`err`},x.createElement(_,{color:d.error},N)));if(X&&!h)return x.createElement(g,{flexDirection:`column`},x.createElement(l,{version:r,subtitle:`watch · ${t}`}),x.createElement(p,{reason:`error`,headline:`Couldn't load dashboard`,hint:"The server returned an unexpected shape. Try `zenovay update` to refresh the CLI."}));let Q=process.stdout.columns??80,$=Math.max(20,Math.floor(Q/3)-1),ee=[];return x.createElement(g,{flexDirection:`column`},x.createElement(l,{version:r,subtitle:`watch · ${t}${L?` · globe`:``}`}),x.createElement(g,{flexDirection:`row`},x.createElement(g,{flexDirection:`column`},L?x.createElement(s,{title:`Live globe`,focused:F===1,width:$},x.createElement(R,{data:ee,width:Math.max(40,$-4),height:12})):x.createElement(U,{snapshot:h,focused:F===1,width:$}),x.createElement(K,{events:k,focused:F===4,width:$})),x.createElement(g,{flexDirection:`column`},x.createElement(W,{snapshot:h,focused:F===2,width:$}),x.createElement(q,{vitals:T,focused:F===5,width:$})),x.createElement(g,{flexDirection:`column`},x.createElement(G,{snapshot:h,focused:F===3,width:$}),x.createElement(J,{goals:D,focused:F===6,width:$}))),V?x.createElement(H,{api:e,siteId:t,width:Q-2}):null,x.createElement(u,{items:[{key:`tab`,label:`next`},{key:`1-6`,label:`jump`},{key:`g`,label:L?`panels`:`globe`},{key:`?/`,label:V?`close chat`:`ai chat`},{key:`o`,label:`open in browser`},{key:`q`,label:`quit`}]}))},H=({api:e,siteId:t,width:n})=>{let{theme:r}=c(),[i,o]=C(``),[l,u]=C([]),[d,f]=C(!1),[p,m]=C(``),[h,v]=C(null),y=async n=>{let r=n.trim();if(!r||d)return;v(null),o(``);let i=[...l,{role:`user`,content:r}];u(i),f(!0),m(``);try{let n=i.map(e=>({role:e.role,content:e.content})),r=await e.openAiStream(`chat`,{messages:n,siteId:t},void 0),o=``;for await(let e of a(r))if(e.type===`delta`)o+=e.content,m(o);else if(e.type===`error`)v(`${e.code}: ${e.message}`);else if(e.type===`done`)break;u([...i,{role:`assistant`,content:o}]),m(``)}catch(e){v(e instanceof Error?e.message:`chat failed`)}finally{f(!1)}};return x.createElement(g,{marginTop:1},x.createElement(s,{title:`AI chat (esc / ?/ to close)`,focused:!0,width:n},x.createElement(g,{flexDirection:`column`},l.slice(-6).map((e,t)=>x.createElement(g,{key:t,flexDirection:`column`,marginBottom:1},x.createElement(_,{color:e.role===`user`?r.accent:r.info,bold:!0},e.role===`user`?`you`:`zenovay`),x.createElement(_,null,e.content))),d&&p?x.createElement(g,{flexDirection:`column`,marginBottom:1},x.createElement(_,{color:r.info,bold:!0},`zenovay`),x.createElement(_,null,p)):null,h?x.createElement(_,{color:r.error},`✗ `,h):null,x.createElement(g,null,x.createElement(_,{color:r.accent},d?`⠋ `:`▸ `),x.createElement(T,{value:i,onChange:o,onSubmit:y,placeholder:d?`streaming…`:`ask anything about your analytics`})))))},U=({snapshot:e,focused:t,width:n})=>{let{theme:r}=c(),i=e?.visitors?.count??0,a=e?.visitors?.series??[];return x.createElement(s,{title:`Visitors`,focused:t,width:n},x.createElement(_,{bold:!0},i.toString()),x.createElement(_,{color:r.muted},a.length>0?d(a,Math.max(8,n-6)):`— no data —`))},W=({snapshot:e,focused:t,width:n})=>{let{theme:r}=c(),i=e?.topPages?.slice(0,5)??[];return x.createElement(s,{title:`Top pages`,focused:t,width:n},i.length===0?x.createElement(_,{color:r.muted},`— no data —`):i.map(e=>x.createElement(g,{key:e.path},x.createElement(_,null,e.path.padEnd(n-10).slice(0,n-10)),x.createElement(_,{color:r.muted},` `,e.views))))},G=({snapshot:e,focused:t,width:n})=>{let{theme:r}=c(),i=e?.sources?.slice(0,5)??[];return x.createElement(s,{title:`Sources`,focused:t,width:n},i.length===0?x.createElement(_,{color:r.muted},`— no data —`):i.map(e=>x.createElement(g,{key:e.source},x.createElement(_,null,e.source.padEnd(n-10).slice(0,n-10)),x.createElement(_,{color:r.muted},` `,e.visitors))))},K=({events:e,focused:t,width:n})=>{let{theme:r}=c();return x.createElement(s,{title:`Events`,focused:t,width:n},e.length===0?x.createElement(_,{color:r.muted},`— waiting —`):e.slice(-10).map((e,t)=>x.createElement(_,{key:t},e.slice(0,n-4))))},q=({vitals:e,focused:t,width:n})=>{let{theme:r}=c(),i=(e,t,n)=>x.createElement(g,{key:e},x.createElement(_,{bold:!0},e.padEnd(6)),x.createElement(_,{color:r.muted},typeof t==`number`?`${t.toFixed(0)}${n}`:`—`));return x.createElement(s,{title:`Vitals`,focused:t,width:n},i(`LCP`,e?.lcpP75,`ms`),i(`INP`,e?.inpP75,`ms`),i(`CLS`,e?.clsP75?e.clsP75*1e3:void 0,`/1k`),i(`TTFB`,e?.ttfbP75,`ms`),i(`FCP`,e?.fcpP75,`ms`))},J=({goals:e,focused:t,width:n})=>{let{theme:r}=c(),i=e?.goals?.slice(0,5)??[];return x.createElement(s,{title:`Goals`,focused:t,width:n},i.length===0?x.createElement(_,{color:r.muted},`— no data —`):i.map(e=>x.createElement(g,{key:e.name},x.createElement(_,null,e.name.padEnd(n-10).slice(0,n-10)),x.createElement(_,{color:r.muted},` `,e.completions))))};export{B as watchCommand};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|