@zenovay/cli 1.0.16 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{readConfig as e}from"./config-JVhBplSX.js";import"./api-ytLQekr6.js";import{readToken as t}from"./token-store-RBywEspd.js";import{emit as n}from"./telemetry-DXc0eIRy.js";import{ApiV2Client as r}from"./api-v2-uFQkimu_.js";import{detectInstalled as i,initCommand as a}from"./init-
|
|
1
|
+
import{readConfig as e}from"./config-JVhBplSX.js";import"./api-ytLQekr6.js";import{readToken as t}from"./token-store-RBywEspd.js";import{emit as n}from"./telemetry-DXc0eIRy.js";import{ApiV2Client as r}from"./api-v2-uFQkimu_.js";import{detectInstalled as i,initCommand as a}from"./init-C0CeKPzO.js";import"./formatter-DutfcQAc.js";import{emit$1 as o,isHeadless as s}from"./emit-DBYk96TD.js";import"./open-url-DHEOtfXN.js";import"./secrets-BGNbID-c.js";import{parseSseStream as c}from"./client-DkVqZ_Bu.js";import"./login-DghPaa-z.js";import"./theme-DOR-SSzW.js";import{Banner as l,Panel as u,useTheme as d}from"./panel-B9_Bd2So.js";import"./progress-row-Cz2F_drl.js";import{Select as f}from"./prompt-CPA77m_S.js";import"./keybar-BWZ9d4xa.js";import"./sparkline-8ucKVUV7.js";import{ChatPanel as p}from"./chat-panel-uZc6n7uu.js";import{resolveSiteId as m}from"./resolve-site-DxrmRbGU.js";import{Box as h,Static as g,Text as _,render as v,useApp as y,useInput as ee}from"ink";import b,{useEffect as x,useRef as S,useState as C}from"react";import w from"ink-spinner";import T from"ink-text-input";const E=30,D=9e4;function O(e){return e.replace(/_/g,` `)}function k(e){if(!e)return``;let t=Object.entries(e).map(([e,t])=>`${e}: ${JSON.stringify(t)}`).join(`, `);return t.length>80?t.slice(0,77)+`…`:t}function A(e,t,n){if(t<=0)return{body:``,clipped:0};let r=e.split(`
|
|
2
2
|
`),i=[];for(let e of r)if(e.length<=n||n<=0)i.push(e);else for(let t=0;t<e.length;t+=n)i.push(e.slice(t,t+n));if(i.length<=t)return{body:e,clipped:0};let a=i.slice(i.length-t);return{body:a.join(`
|
|
3
3
|
`),clipped:i.length-t}}const j=({cliVersion:e,api:t,siteId:r,siteLabel:i,initialAllowAll:a=!1,onClose:o})=>{let{theme:s}=d(),{exit:f}=y(),[p,m]=C([]),[v,j]=C(``),[M,N]=C(!1),[P,F]=C(``),[I,L]=C([]),[R,z]=C(null),[B,V]=C(a),[H,U]=C(!1),[W,G]=C(0),K=S(``),q=S(null),J=S(Date.now());x(()=>{if(!M)return;let e=setInterval(()=>{K.current!==P&&F(K.current)},Math.floor(1e3/E));return()=>clearInterval(e)},[M,P]),x(()=>(n(`mcp.open`,{properties:{has_site:!!r}}),()=>{n(`mcp.close`,{duration_ms:Date.now()-J.current})}),[r]),ee((e,t)=>{if(t.escape||t.ctrl&&e===`c`){q.current?.abort(),o();return}if(e===`a`||e===`A`){V(!0),H&&U(!1);return}if(e===`x`||e===`X`){q.current?.abort(),z(`Cancelled.`),U(!1),N(!1);return}if((t.return||e===`y`||e===`Y`)&&H){U(!1);return}if((e===`n`||e===`N`)&&H){q.current?.abort(),z(`Cancelled by user.`),U(!1),N(!1);return}});let Y=async e=>{let i=e.trim();if(!i||M||H)return;j(``),z(null),m(e=>[...e,{role:`user`,content:i}]),K.current=``,F(``),L([]),G(0),N(!0),q.current=new AbortController;let a=setTimeout(()=>{q.current?.abort(),z(`Request timed out after ${D/1e3}s`)},D);try{let e=p.map(e=>({role:e.role,content:e.content}));e.push({role:`user`,content:i});let a=await t.openAiStream(`mcp`,{messages:e,siteId:r},q.current.signal);if(!a.ok){z(`MCP request failed (${a.status})`);return}let o=0,s=new Map;for await(let e of c(a))if(e.type===`delta`)K.current+=e.content;else if(e.type===`tool_call`)s.set(e.id,e.arguments),o+=1,G(o),n(`mcp.tool_call`,{properties:{tool_name:e.name}}),L(t=>[...t,{id:e.id,name:e.name,argsPreview:k(e.arguments),status:`running`}]);else if(e.type===`tool_start`){let t=s.get(e.id);L(r=>r.some(t=>t.id===e.id)?r:(o+=1,G(o),n(`mcp.tool_call`,{properties:{tool_name:e.name}}),[...r,{id:e.id,name:e.name,argsPreview:k(t),status:`running`}]))}else if(e.type===`tool_result`)L(t=>t.map(t=>t.id===e.id?{...t,status:e.error?`error`:`done`,result:e.summary,error:e.error,name:e.name??t.name}:t));else if(e.type===`done`){let e=K.current;m(t=>[...t,{role:`assistant`,content:e||``}]),o>0&&!B&&U(!0);break}else if(e.type===`error`){z(e.message);break}}catch(e){e.name!==`AbortError`&&z(e.message??`unknown error`)}finally{clearTimeout(a),K.current=``,F(``),N(!1),q.current=null}},X=[`mcp`,i].filter(Boolean).join(` · `),Z=process.stdout.rows??40,Q=Math.max(4,Z-16),te=Math.max(20,(process.stdout.columns??80)-4),$=A(P,Q,te);return b.createElement(h,{flexDirection:`column`},b.createElement(l,{version:e,subtitle:X}),p.length===0&&!M?b.createElement(h,{marginTop:1,marginLeft:2,flexDirection:`column`},b.createElement(_,{color:s.muted},`Describe what you want to create or change. Examples:`),b.createElement(h,{marginTop:0,flexDirection:`column`},b.createElement(_,{color:s.dim},` · "Create a goal for newsletter signups"`),b.createElement(_,{color:s.dim},` · "Add a funnel: landing page → signup → dashboard"`),b.createElement(_,{color:s.dim},` · "Annotate today with our product launch"`),b.createElement(_,{color:s.dim},` · "Set up uptime monitoring for /api/health"`)),b.createElement(h,{marginTop:1},b.createElement(_,{color:s.dim},`MCP actions execute server-side. `),b.createElement(_,{color:s.warn},`Review each turn before continuing.`)),b.createElement(h,{marginTop:0,flexDirection:`row`},b.createElement(_,{color:s.accent},`[a]`),b.createElement(_,{color:s.dim},` allow-all · `),b.createElement(_,{color:s.accent},`[Esc]`),b.createElement(_,{color:s.dim},` close`))):null,b.createElement(g,{items:p},(e,t)=>b.createElement(h,{key:t,marginTop:1},b.createElement(u,{title:e.role===`user`?`you`:`Zenovay MCP`,pillColor:e.role===`user`?s.accent:s.info,state:`idle`},b.createElement(_,{color:s.fg,wrap:`wrap`},e.content)))),M?b.createElement(h,{flexDirection:`column`},I.length>0?b.createElement(h,{marginTop:1},b.createElement(u,{title:`Actions${B?` (allow-all)`:``}`,state:I.some(e=>e.status===`running`)?`busy`:`ok`},I.map(e=>b.createElement(h,{key:e.id,flexDirection:`column`,marginBottom:0},b.createElement(h,{flexDirection:`row`},b.createElement(_,{color:e.status===`error`?s.error:e.status===`done`?s.success:s.accent},e.status===`done`?`✓ `:e.status===`error`?`✗ `:`⋯ `),b.createElement(_,{color:s.fg,bold:!0},O(e.name))),e.argsPreview?b.createElement(h,{marginLeft:2},b.createElement(_,{color:s.dim},e.argsPreview)):null,e.status===`done`&&e.result?b.createElement(h,{marginLeft:2},b.createElement(_,{color:s.dim},`→ `,e.result.slice(0,80))):null,e.status===`error`&&e.error?b.createElement(h,{marginLeft:2},b.createElement(_,{color:s.error},`✗ `,e.error.slice(0,80))):null)))):null,P.length>0?b.createElement(h,{marginTop:1},b.createElement(u,{title:`Zenovay MCP`,pillColor:s.info,state:`busy`},$.clipped>0?b.createElement(_,{color:s.dim},` …${$.clipped} earlier line${$.clipped===1?``:`s`} above`):null,b.createElement(_,{color:s.fg,wrap:`wrap`},$.body))):I.every(e=>e.status!==`running`)||I.length===0?b.createElement(h,{marginTop:1,marginLeft:2,flexDirection:`row`},b.createElement(_,{color:s.accent},b.createElement(w,{type:`dots`})),b.createElement(_,{color:s.muted},` Planning actions…`)):null):null,H&&!M?b.createElement(h,{marginTop:1},b.createElement(u,{title:`Continue?`,state:`warn`,pillColor:s.warn},b.createElement(_,{color:s.muted},W,` action`,W===1?``:`s`,` executed this turn. Send another message?`),b.createElement(h,{marginTop:1,flexDirection:`row`},b.createElement(_,{color:s.success},`[Enter / y] `),b.createElement(_,{color:s.dim},`continue `),b.createElement(_,{color:s.error},`[n] `),b.createElement(_,{color:s.dim},`cancel `),b.createElement(_,{color:s.accent},`[a] `),b.createElement(_,{color:s.dim},`allow-all this session `),b.createElement(_,{color:s.warn},`[x] `),b.createElement(_,{color:s.dim},`abort`)))):null,R?b.createElement(h,{marginTop:1,marginLeft:2},b.createElement(_,{color:s.error},`✗ `,R)):null,b.createElement(h,{marginTop:1,marginLeft:2,flexDirection:`column`},b.createElement(h,{flexDirection:`row`},b.createElement(_,{color:M||H?s.dim:s.accent},M?`⋯ `:H?`? `:`> `),b.createElement(T,{value:v,onChange:j,onSubmit:e=>void Y(e),placeholder:M?`executing…`:H?`press Enter to continue, n to cancel…`:`describe what to create or change…`})),b.createElement(h,{marginTop:1,flexDirection:`row`},b.createElement(_,{color:s.dim},`[Enter] send [a] allow-all [x] abort [Esc] close`),B?b.createElement(_,{color:s.success},` ● allow-all`):null)))};async function M(e){if((s(e)||!process.stdin.isTTY)&&e.mode!==`install`)return o({type:`error`,code:`interactive_only`,message:`zenovay ai is interactive; run without --json in a TTY`}),2;let t=await i(e.cwd),n;if(e.mode)n=e.mode;else if(!t.installed)n=`install`;else if(s(e))return o({type:`error`,code:`no_mode`,message:`Headless mode requires --mode chat|mcp|install`}),2;else n=await N(t,e.cliVersion);return n===`install`?a({cliVersion:e.cliVersion,cwd:e.cwd,json:e.json}):n===`chat`?P(e):F(e)}async function N(e,t){return new Promise(n=>{let r=[{label:`Chat with your analytics`,value:`chat`,description:`Ask natural-language questions about your data`},{label:`Manage via MCP`,value:`mcp`,description:`Create goals, funnels, sites, etc. in plain English`},{label:`Re-run install / repair`,value:`install`,description:`Run the install wizard again`}],i=e.packageMarker?`detected · ${e.packageMarker}`:`detected`,{unmount:a}=v(b.createElement(h,{flexDirection:`column`},b.createElement(l,{version:t,subtitle:`ai · ${i}`,live:!1}),b.createElement(h,{marginTop:1},b.createElement(u,{title:`Zenovay AI assistant`,state:`idle`},b.createElement(_,null,`What do you want to do?`))),b.createElement(h,{marginTop:1},b.createElement(f,{items:r,onSelect:e=>{a(),n(e)}}))))})}async function P(n){let i=await e(),a=await t({strict:!1});if(!a)return process.stderr.write("Not logged in — run `zenovay login` first.\n"),2;let o=i.defaultSiteId,s=i.defaultSiteName,c=new r({config:i,cliVersion:n.cliVersion,token:a});return new Promise(e=>{let{unmount:t}=v(b.createElement(p,{cliVersion:n.cliVersion,api:c,dashboardContext:{commandName:`ai chat`,siteId:o,siteLabel:s,metricsSnapshot:null},onClose:()=>{t(),e(0)}}))})}async function F(n){let i=await e(),a=await t({strict:!1});if(!a)return process.stderr.write("Not logged in — run `zenovay login` first.\n"),2;let o=new r({config:i,cliVersion:n.cliVersion,token:a}),s,c;try{let e=await m(o,{explicit:void 0,headless:!1,cliVersion:n.cliVersion});s=e.siteId,c=e.site?.url?e.site.url.replace(/^https?:\/\//,``).replace(/\/$/,``):e.site?.name??s}catch{}return new Promise(e=>{let{unmount:t}=v(b.createElement(j,{cliVersion:n.cliVersion,api:o,siteId:s,siteLabel:c,onClose:()=>{t(),e(0)}}))})}export{M as aiCommand};
|
package/dist/bin.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{configDir as e}from"./config-JVhBplSX.js";import"./check-D9G0N7NB.js";import{ensureLatest as t}from"./ensure-latest-wK7bjiER.js";import"./api-ytLQekr6.js";import"./token-store-RBywEspd.js";import{normalizeError as n}from"./error-codes-DkVjjA_L.js";import{emit as r,flush as i,initTelemetry as a}from"./telemetry-DXc0eIRy.js";import{cac as o}from"cac";import{fork as s}from"node:child_process";import c from"node:path";import{fileURLToPath as l}from"node:url";import{readFileSync as u}from"node:fs";var d=`@zenovay/cli`,f=`1.0.
|
|
2
|
+
import{configDir as e}from"./config-JVhBplSX.js";import"./check-D9G0N7NB.js";import{ensureLatest as t}from"./ensure-latest-wK7bjiER.js";import"./api-ytLQekr6.js";import"./token-store-RBywEspd.js";import{normalizeError as n}from"./error-codes-DkVjjA_L.js";import{emit as r,flush as i,initTelemetry as a}from"./telemetry-DXc0eIRy.js";import{cac as o}from"cac";import{fork as s}from"node:child_process";import c from"node:path";import{fileURLToPath as l}from"node:url";import{readFileSync as u}from"node:fs";var d=`@zenovay/cli`,f=`1.0.17`,p=`Zenovay CLI — AI install wizard + full terminal analytics dashboard`,m=`module`,h={zenovay:`dist/bin.js`,zv:`dist/bin.js`},g=[`dist/**/*.js`,`dist/**/*.cjs`,`dist/**/*.mjs`,`dist/**/*.d.ts`,`README.md`,`LICENSE`],_={dev:`tsx src/bin.ts`,build:`tsdown`,"build:binaries":`tsx scripts/build-binaries.ts`,typecheck:`tsc --noEmit`,lint:`eslint 'src/**/*.{ts,tsx}'`,test:`vitest run`,"test:watch":`vitest`,"test:all":`vitest run tests/unit tests/integration tests/security`,"test:release":`vitest run tests/e2e tests/update --testTimeout=600000`,"test:smoke":`vitest run tests/smoke --testTimeout=60000`,"test:update-golden":`UPDATE_GOLDEN=1 vitest run tests/e2e`,"render:globe":`tsx scripts/render-globe.ts`,smoke:`bash scripts/smoke-test.sh`},v={cac:`^6.7.14`,chalk:`^5.4.1`,diff:`^8.0.3`,globby:`^14.1.0`,ink:`^5.1.0`,"ink-gradient":`^3.0.0`,"ink-select-input":`^6.0.0`,"ink-spinner":`^5.0.0`,"ink-text-input":`^6.0.0`,open:`^10.1.0`,react:`^18.3.1`,semver:`^7.6.3`,"string-width":`^7.2.0`,ulid:`^2.3.0`,zod:`^3.23.8`},y={"@aws-sdk/client-s3":`^3.1036.0`,"@types/node":`^22.10.0`,"@types/react":`^18.3.12`,"@types/semver":`^7.5.8`,"@typescript-eslint/parser":`^8.61.0`,"@vitest/coverage-v8":`^2.1.8`,"csv-parse":`^6.2.1`,eslint:`^9.16.0`,"ink-testing-library":`^4.0.0`,"react-devtools-core":`^4.19.1`,tsdown:`^0.9.0`,tsx:`^4.19.2`,typescript:`^5.7.2`,vitest:`^2.1.8`},b={node:`>=20.0.0`},x=`pnpm@9.15.9`,S={overrides:{"ws@>=8.0.0 <8.21.0":`>=8.21.0`}},C=`Zenovay <cli@zenovay.com>`,w=`SEE LICENSE IN LICENSE`,T=`https://cli.zenovay.com`,E={type:`git`,url:`https://github.com/zenovay/cli-zenovay.git`},D={url:`https://cli.zenovay.com/feedback`},O=[`zenovay`,`analytics`,`cli`,`tui`,`ai-agent`,`install-wizard`],k={name:d,version:f,description:p,type:m,bin:h,files:g,scripts:_,dependencies:v,devDependencies:y,engines:b,packageManager:x,pnpm:S,author:C,license:w,homepage:T,repository:E,bugs:D,keywords:O};const A=c.dirname(l(import.meta.url)),j=k.version,M=process.argv[0]??`zenovay`;function N(){if(process.env.ZENOVAY_BACKGROUND_UPDATE===`1`&&!(process.env.ZENOVAY_NO_UPDATE_CHECK===`1`||process.env.CI===`true`))try{let e=c.join(A,`lib`,`update`,`worker.js`),t=s(e,[],{detached:!0,stdio:`ignore`,env:{...process.env,ZENOVAY_UPDATE_WORKER_FORK:`1`}});t.unref()}catch{}}const P=o(`zenovay`);P.version(j),P.help(e=>{let t=e.filter(e=>{let t=e.title??``;return!/for more info/i.test(t)});return t.push({body:"Run `zenovay <command> --help` for command-specific options and examples."}),t}),P.option(`-q, --quiet`,`Suppress spinners + interactive UI; implies --json`),P.option(`--team <name-or-id>`,"Team override for this command (alternative to `zenovay teams switch`)"),(process.argv.includes(`-q`)||process.argv.includes(`--quiet`))&&(process.env.ZENOVAY_FORMAT=`json`,process.argv.includes(`--json`)||process.argv.push(`--json`));const F=process.argv.findIndex(e=>e===`--team`);if(F!==-1&&process.argv[F+1]&&(process.env.ZENOVAY_TEAM_ID=process.argv[F+1]),!process.env.ZENOVAY_TEAM_ID)try{let t=c.join(e(),`config.json`),n=u(t,`utf8`),r=JSON.parse(n);r.currentTeamId&&(process.env.ZENOVAY_TEAM_ID=r.currentTeamId)}catch{}P.command(`init`,`AI install wizard — add Zenovay tracking to your codebase`).option(`--json`,`Emit NDJSON events to stdout`).option(`--yes`,`Auto-approve all diffs (for CI)`).option(`--review`,`Review each file write before it is applied`).option(`--skip-mcp`,`Skip MCP client install`).option(`--skip-verify`,`Skip first-event verification`).option(`--no-first-party`,`Skip the same-origin /api/_z/* proxy setup (first-party tracking)`).option(`--host <host>`,`Deploy host for first-party tracking when it can't be auto-detected: cloudflare-pages | vercel | netlify | nextjs`).option(`--site-id <id>`,`Install for a specific site id (skips the picker)`).action(async e=>{let{initCommand:t}=await import(`./init-BijYETQa.js`),n=await t({cliVersion:j,cwd:process.cwd(),json:e.json,yes:e.yes,review:e.review,skipMcp:e.skipMcp,skipVerify:e.skipVerify,firstParty:e.firstParty,host:e.host,siteId:e.siteId});process.exitCode=n}),P.command(`login`,`Authenticate via OAuth device flow`).option(`--json`,`Emit NDJSON events`).option(`--no-browser`,`Skip opening the browser automatically`).action(async e=>{let{loginCommand:t}=await import(`./login-CjWgzSQ9.js`),n=await t({cliVersion:j,json:e.json,openBrowser:e.browser!==!1,onCode:e=>{process.stdout.write(`\n Open this URL to authorize the CLI:\n ${e.verificationUriComplete??e.verificationUri}\n Or enter code: ${e.userCode}\n\n`)}});!e.json&&n.email?process.stdout.write(`\n ✔ Logged in as ${n.email}\n Try \`zenovay overview\` to see your dashboard, or \`zenovay --help\` for the full command list.\n\n`):e.json||process.stdout.write(`
|
|
3
3
|
✔ Logged in.
|
|
4
4
|
|
|
5
|
-
`)}),P.command(`logout`,`Revoke current session and delete local auth`).option(`--json`,``).action(async e=>{let{logoutCommand:t}=await import(`./logout-k6auX20A.js`);await t({cliVersion:j,json:e.json})}),P.command(`ai`,`3-mode AI assistant (install / chat / mcp)`).option(`--mode <mode>`,`install | chat | mcp`).option(`--json`,``).action(async e=>{let{aiCommand:t}=await import(`./ai-
|
|
5
|
+
`)}),P.command(`logout`,`Revoke current session and delete local auth`).option(`--json`,``).action(async e=>{let{logoutCommand:t}=await import(`./logout-k6auX20A.js`);await t({cliVersion:j,json:e.json})}),P.command(`ai`,`3-mode AI assistant (install / chat / mcp)`).option(`--mode <mode>`,`install | chat | mcp`).option(`--json`,``).action(async e=>{let{aiCommand:t}=await import(`./ai-BaosO-Bv.js`),n=await t({cliVersion:j,cwd:process.cwd(),mode:e.mode,json:e.json});process.exitCode=n}),P.command(`watch`,"[ANALYTICS] Alias for `analytics` (dashboard summary)").option(`--site-id <id>`,`Site ID`).option(`--interval <ms>`,`Poll interval ms (legacy; ignored by analytics)`,{default:15e3}).option(`--json`,``).option(`--csv`,`Emit top-pages as CSV`).option(`--tsv`,`Emit top-pages as TSV`).option(`--ndjson`,`Emit top-pages as NDJSON (one row per line)`).action(async e=>{let{analyticsCommand:t}=await import(`./analytics-C4BEogU8.js`),n=await t({cliVersion:j,siteId:e.siteId,json:e.json,csv:e.csv,tsv:e.tsv,ndjson:e.ndjson});process.exitCode=n}),P.command(`analytics [sub]`,`[ANALYTICS] Landing dashboard — visitors, pageviews, bounce, top pages. Subs: live | funnels | goals | insights | profiles | companies`).option(`--site-id <id>`,`Site ID`).option(`--json`,``).option(`--csv`,`Emit top-pages as CSV`).option(`--tsv`,`Emit top-pages as TSV`).option(`--ndjson`,`Emit top-pages as NDJSON (one row per line)`).action(async(e,t)=>{switch(e){case void 0:{let{analyticsCommand:e}=await import(`./analytics-C4BEogU8.js`);process.exitCode=await e({cliVersion:j,siteId:t.siteId,json:t.json,csv:t.csv,tsv:t.tsv,ndjson:t.ndjson});return}case`live`:{let{liveCommand:e}=await import(`./live-CfBEtKWj.js`);process.exitCode=await e({cliVersion:j,siteId:t.siteId,json:t.json});return}case`funnels`:{let{funnelCommand:e}=await import(`./funnel-CnreY4vM.js`);process.exitCode=await e({cliVersion:j,siteId:t.siteId,json:t.json,csv:t.csv,tsv:t.tsv,ndjson:t.ndjson});return}case`goals`:{let{goalsCommand:e}=await import(`./goals-CgekksXZ.js`);process.exitCode=await e({cliVersion:j,action:`list`,json:t.json});return}case`insights`:{let{insightsCommand:e}=await import(`./insights-GOTk-oX2.js`);process.exitCode=await e({cliVersion:j,siteId:t.siteId,json:t.json});return}case`profiles`:{let{visitorsCommand:e}=await import(`./visitors-Dx8QDDRc.js`);process.exitCode=await e({cliVersion:j,siteId:t.siteId,json:t.json});return}case`companies`:{let{companiesCommand:e}=await import(`./companies-Ce2RcrmL.js`);process.exitCode=await e({cliVersion:j,siteId:t.siteId,json:t.json});return}default:process.stderr.write(t.json?JSON.stringify({type:`error`,code:`validation_failed`,message:`Unknown analytics sub-command: ${e}`,hint:`Valid: live | funnels | goals | insights | profiles | companies`})+`
|
|
6
6
|
`:`\n✗ Unknown analytics sub-command: '${e}'\n Valid: live | funnels | goals | insights | profiles | companies. Run \`zenovay analytics --help\`\n`),process.exit(2)}}),P.command(`overview`,"[ANALYTICS] Alias for `analytics`").option(`--site-id <id>`,`Site ID`).option(`--json`,``).option(`--csv`,`Emit top-pages as CSV`).option(`--tsv`,`Emit top-pages as TSV`).option(`--ndjson`,`Emit top-pages as NDJSON (one row per line)`).action(async e=>{let{analyticsCommand:t}=await import(`./analytics-C4BEogU8.js`),n=await t({cliVersion:j,siteId:e.siteId,json:e.json,csv:e.csv,tsv:e.tsv,ndjson:e.ndjson});process.exitCode=n}),P.command(`home`,`[ACCOUNT] Top-level summary — sites + this-week deltas`).option(`--json`,``).action(async e=>{let{homeCommand:t}=await import(`./home-BCy1u3Yf.js`);process.exitCode=await t({cliVersion:j,json:e.json})}),P.command(`live`,`[ANALYTICS] Real-time visitors + globe + recent events (2s polling)`).option(`--site-id <id>`,`Site ID`).option(`--json`,``).action(async e=>{let{liveCommand:t}=await import(`./live-CfBEtKWj.js`),n=await t({cliVersion:j,siteId:e.siteId,json:e.json});process.exitCode=n}),P.command(`pages`,`[ANALYTICS] Top pages by views — last 24h`).option(`--site-id <id>`,`Site ID`).option(`--json`,``).option(`--csv`,`Emit pages as CSV`).option(`--tsv`,`Emit pages as TSV`).option(`--ndjson`,`Emit pages as NDJSON (one row per line)`).action(async e=>{let{pagesCommand:t}=await import(`./pages-BC_lNSC0.js`),n=await t({cliVersion:j,siteId:e.siteId,json:e.json,csv:e.csv,tsv:e.tsv,ndjson:e.ndjson});process.exitCode=n}),P.command(`devices`,`[ANALYTICS] Device / browser / OS breakdown — last 24h`).option(`--site-id <id>`,`Site ID`).option(`--json`,``).option(`--csv`,`Emit devices as CSV`).option(`--tsv`,`Emit devices as TSV`).option(`--ndjson`,`Emit devices as NDJSON (one row per line)`).action(async e=>{let{devicesCommand:t}=await import(`./devices-Ur3mbfL2.js`),n=await t({cliVersion:j,siteId:e.siteId,json:e.json,csv:e.csv,tsv:e.tsv,ndjson:e.ndjson});process.exitCode=n}),P.command(`geo`,`[ANALYTICS] Countries + cities + globe — last 24h`).option(`--site-id <id>`,`Site ID`).option(`--json`,``).option(`--csv`,`Emit countries as CSV`).option(`--tsv`,`Emit countries as TSV`).option(`--ndjson`,`Emit countries as NDJSON (one row per line)`).action(async e=>{let{geoCommand:t}=await import(`./geo-BqaJUbYR.js`),n=await t({cliVersion:j,siteId:e.siteId,json:e.json,csv:e.csv,tsv:e.tsv,ndjson:e.ndjson});process.exitCode=n}),P.command(`retention`,`[BEHAVIOR] Cohort retention heatmap — D1 / D7 / D30 (Pro+)`).option(`--site-id <id>`,`Site ID`).option(`--json`,``).action(async e=>{let{retentionCommand:t}=await import(`./retention-B0LYJbJF.js`),n=await t({cliVersion:j,siteId:e.siteId,json:e.json});process.exitCode=n}),P.command(`uptime`,`[BEHAVIOR] Uptime monitors with status + p95 (Pro+)`).option(`--site-id <id>`,`Site ID`).option(`--json`,``).action(async e=>{let{uptimeCommand:t}=await import(`./uptime-CHSTY_hM.js`),n=await t({cliVersion:j,siteId:e.siteId,json:e.json});process.exitCode=n}),P.command(`sessions`,`[BEHAVIOR] Recent session-replay list (Pro+)`).option(`--site-id <id>`,`Site ID`).option(`--json`,``).action(async e=>{let{sessionsCommand:t}=await import(`./sessions-DrHESZA8.js`),n=await t({cliVersion:j,siteId:e.siteId,json:e.json});process.exitCode=n}),P.command(`heatmaps`,`[BEHAVIOR] Recent heatmap captures (Pro+)`).option(`--site-id <id>`,`Site ID`).option(`--json`,``).action(async e=>{let{heatmapsCommand:t}=await import(`./heatmaps-CuIKLE_4.js`),n=await t({cliVersion:j,siteId:e.siteId,json:e.json});process.exitCode=n}),P.command(`journeys`,`[BEHAVIOR] Page-to-page transition flow (Pro+)`).option(`--site-id <id>`,`Site ID`).option(`--json`,``).action(async e=>{let{journeysCommand:t}=await import(`./journeys-CYsnja_v.js`),n=await t({cliVersion:j,siteId:e.siteId,json:e.json});process.exitCode=n}),P.command(`insights`,`[INTELLIGENCE] AI-generated anomaly / trend / recommendation cards (Pro+)`).option(`--site-id <id>`,`Site ID`).option(`--json`,``).action(async e=>{let{insightsCommand:t}=await import(`./insights-GOTk-oX2.js`),n=await t({cliVersion:j,siteId:e.siteId,json:e.json});process.exitCode=n}),P.command(`events [action]`,`[OPERATIONS] events tail [--filter --forward-to --replay-24h] — stream live events`).option(`--site-id <id>`,`Site ID`,{default:``}).option(`--filter <expr>`,`Filter expression (e.g. 'type=pageview AND country=US')`).option(`--forward-to <url>`,`POST each event to a webhook with HMAC-SHA256 signature`).option(`--replay-24h`,`Replay the last 24h before going live`).option(`--set-forward-secret <hex>`,`Persist the HMAC secret used by --forward-to`).option(`--json`,``).action(async(e,t)=>{e!==`tail`&&(process.stderr.write(t.json?JSON.stringify({type:`error`,code:`validation_failed`,message:`Unknown events action: ${e??`(none)`}`,hint:`Usage: zenovay events tail`})+`
|
|
7
7
|
`:`\n✗ Unknown events action: '${e??`(none)`}'\n Usage: zenovay events tail. Run \`zenovay events tail --help\`\n`),process.exit(2));let{eventsTailCommand:n}=await import(`./events-tail-9y4WPcly.js`),r=await n({cliVersion:j,siteId:t.siteId,json:t.json,filter:t.filter,forwardTo:t.forwardTo,replay24h:t.replay24h,setForwardSecret:t.setForwardSecret});process.exitCode=r}),P.command(`health`,`Run self-diagnostic checks`).option(`--json`,``).action(async e=>{let{healthCommand:t}=await import(`./health-BEHoAay2.js`),n=await t({cliVersion:j,binaryPath:M,json:e.json});process.exitCode=n}),P.command(`annotation [action]`,`[OPERATIONS] annotation create [--type --message --occurred-at] (deploy / release / campaign / incident / custom)`).option(`--type <type>`,`One of: deploy, release, campaign, incident, custom`,{default:`custom`}).option(`--message <message>`,`Short description (1–500 chars)`,{default:``}).option(`--occurred-at <iso>`,`ISO 8601 timestamp (default: now)`).option(`--site-id <id>`,`Site ID`).option(`--json`,``).action(async(e,t)=>{let n=e??`create`;if(n!==`create`){process.stderr.write(`Unknown annotation action: ${n}. Try: zenovay annotation create --type=deploy --message="..."\n`),process.exitCode=2;return}let{annotationCreateCommand:r}=await import(`./annotation-YmTGoEJj.js`),i=await r({cliVersion:j,type:t.type,message:t.message,occurredAt:t.occurredAt,siteId:t.siteId,json:t.json});process.exitCode=i}),P.command(`doctor`,`AI-assisted self-healing`).option(`--json`,``).action(async e=>{let{doctorCommand:t}=await import(`./doctor-Ryf9p_Zm.js`),n=await t({cliVersion:j,binaryPath:M,json:e.json});process.exitCode=n}),P.command(`stats`,`One-shot dashboard summary (scriptable by default)`).option(`--site-id <id>`,`Site ID`).option(`--range <range>`,`Time range: 24h | 7d | 30d`,{default:`24h`}).option(`--watch`,`Auto-refresh every 60s`).option(`--json`,``).option(`--csv`,``).option(`--tsv`,``).option(`--ndjson`,``).action(async e=>{let{statsCommand:t}=await import(`./stats-CItbeDaf.js`),n=await t({cliVersion:j,siteId:e.siteId,range:e.range,watch:e.watch,json:e.json,csv:e.csv,tsv:e.tsv,ndjson:e.ndjson});process.exitCode=n}),P.command(`sources`,`Traffic source breakdown with delta arrows`).option(`--site-id <id>`,`Site ID`).option(`--period <p>`,`Period: 7d | 30d | 90d | 1y`,{default:`30d`}).option(`--compare <c>`,`Comparison window (use "prev" for period-over-period)`).option(`--json`,``).option(`--csv`,``).option(`--tsv`,``).option(`--ndjson`,``).action(async e=>{let{sourcesCommand:t}=await import(`./sources-D05rpOAC.js`),n=await t({cliVersion:j,siteId:e.siteId,period:e.period,compare:e.compare,json:e.json,csv:e.csv,tsv:e.tsv,ndjson:e.ndjson});process.exitCode=n}),P.command(`vitals`,`Core Web Vitals dashboard (LCP / INP / CLS / TTFB / FCP)`).option(`--site-id <id>`,`Site ID`).option(`--url <path>`,`Filter to a single URL`).option(`--device <type>`,`Filter by device: mobile | desktop`).option(`--window <w>`,`Time window: 24h | 7d | 30d | 90d`,{default:`7d`}).option(`--watch`,`Auto-refresh every 5 minutes`).option(`--json`,``).option(`--csv`,``).option(`--tsv`,``).option(`--ndjson`,``).action(async e=>{let{vitalsCommand:t}=await import(`./vitals-D33j5JvU.js`),n=await t({cliVersion:j,siteId:e.siteId,url:e.url,device:e.device,window:e.window,watch:e.watch,json:e.json,csv:e.csv,tsv:e.tsv,ndjson:e.ndjson});process.exitCode=n}),P.command(`revenue`,`MRR / ARR / transaction series`).option(`--site-id <id>`,`Site ID`).option(`--range <r>`,`Time range: 24h | 7d | 30d | 1y`,{default:`30d`}).option(`--watch`,`Auto-refresh every 5 minutes`).option(`--json`,``).option(`--csv`,``).option(`--tsv`,``).option(`--ndjson`,``).action(async e=>{let{revenueCommand:t}=await import(`./revenue-urjZpz6Y.js`),n=await t({cliVersion:j,siteId:e.siteId,range:e.range,watch:e.watch,json:e.json,csv:e.csv,tsv:e.tsv,ndjson:e.ndjson});process.exitCode=n}),P.command(`funnels`,`List available funnels`).option(`--site-id <id>`,`Site ID`).option(`--json`,``).option(`--csv`,``).option(`--tsv`,``).option(`--ndjson`,``).action(async e=>{let{funnelCommand:t}=await import(`./funnel-CnreY4vM.js`),n=await t({cliVersion:j,siteId:e.siteId,json:e.json,csv:e.csv,tsv:e.tsv,ndjson:e.ndjson});process.exitCode=n}),P.command(`themes`,`List available themes with colored swatches`).option(`--validate <path>`,`Validate a custom theme JSON file`).option(`--json`,`Emit themes JSON to stdout`).action(async e=>{let{themesCommand:t}=await import(`./themes-BpLMRqpK.js`),n=await t({cliVersion:j,validate:e.validate,json:e.json});process.exitCode=n}),P.command(`completions [shell] [valuesType]`,`Emit shell-completion script (bash | zsh | fish | nushell | pwsh)`).option(`--list`,`List supported shells`).action(async(e,t,n)=>{let{completionsCommand:r}=await import(`./completions-h5DWl_bT.js`),i=await r({shell:e,valuesType:t,list:n.list});process.exitCode=i}),P.command(`query [sql]`,`Restricted SQL REPL over the analytics schema (Scale+)`).option(`--site-id <id>`,`Site ID`).option(`--max-rows <n>`,`Cap result row count`,{default:1e3}).option(`--json`,``).option(`--csv`,``).option(`--tsv`,``).option(`--ndjson`,``).action(async(e,t)=>{let{queryCommand:n}=await import(`./query-D65FguzL.js`),r=await n({cliVersion:j,siteId:t.siteId,sql:e,maxRows:typeof t.maxRows==`string`?Number(t.maxRows):t.maxRows,json:t.json,csv:t.csv,tsv:t.tsv,ndjson:t.ndjson});process.exitCode=r}),P.command(`companies`,`B2B identification feed (Scale+)`).option(`--site-id <id>`,`Site ID`).option(`--window <w>`,`Time window: 24h | 7d | 30d | 90d`,{default:`24h`}).option(`--limit <n>`,`Max rows`,{default:100}).option(`--new-only`,`Show only newly identified companies (first-seen in last hour)`).option(`--watch`,`Auto-refresh every 30s`).option(`--json`,``).option(`--csv`,``).option(`--tsv`,``).option(`--ndjson`,``).action(async e=>{let{companiesCommand:t}=await import(`./companies-Ce2RcrmL.js`),n=await t({cliVersion:j,siteId:e.siteId,window:e.window,limit:typeof e.limit==`string`?Number(e.limit):e.limit,newOnly:e.newOnly,watch:e.watch,json:e.json,csv:e.csv,tsv:e.tsv,ndjson:e.ndjson});process.exitCode=n}),P.command(`projects`,`List your tracked projects`).option(`--site-id <id>`,`Site ID`).option(`--json`,``).option(`--csv`,``).option(`--tsv`,``).option(`--ndjson`,``).action(async e=>{let{projectsCommand:t}=await import(`./projects-D-P9b7nc.js`),n=await t({cliVersion:j,siteId:e.siteId,json:e.json,csv:e.csv,tsv:e.tsv,ndjson:e.ndjson});process.exitCode=n}),P.command(`deploys`,`[OPERATIONS] Recent deploy markers overlaid on charts`).option(`--site-id <id>`,`Site ID`).option(`--branch <name>`,`Filter to a single branch (e.g. main, develop)`).option(`--since <iso>`,`Only commits after this ISO timestamp`).option(`--limit <n>`,`Max rows`,{default:50}).option(`--connect`,`Print the GitHub-integration deep link in app.zenovay.com`).option(`--json`,``).option(`--csv`,``).option(`--tsv`,``).option(`--ndjson`,``).action(async e=>{let{deploysCommand:t}=await import(`./deploys-CdPkHNoR.js`),n=await t({cliVersion:j,siteId:e.siteId,branch:e.branch,since:e.since,limit:typeof e.limit==`string`?Number(e.limit):e.limit,connect:e.connect,json:e.json,csv:e.csv,tsv:e.tsv,ndjson:e.ndjson});process.exitCode=n}),P.command(`errors`,`[BEHAVIOR] Recent JS / HTTP error snapshot`).alias(`error`).option(`--site-id <id>`,`Site ID`).option(`--window <w>`,`Time window: 24h | 7d | 30d | 90d`,{default:`24h`}).option(`--limit <n>`,`Max errors to fetch`,{default:100}).option(`--search <q>`,`Filter by class or message substring`).option(`--watch`,`Auto-refresh every 30s`).option(`--json`,``).option(`--csv`,``).option(`--tsv`,``).option(`--ndjson`,``).action(async e=>{let{errorsCommand:t}=await import(`./errors-CZlfihYR.js`),n=await t({cliVersion:j,siteId:e.siteId,window:e.window,limit:typeof e.limit==`string`?Number(e.limit):e.limit,search:e.search,watch:e.watch,json:e.json,csv:e.csv,tsv:e.tsv,ndjson:e.ndjson});process.exitCode=n}),P.command(`funnel <id>`,`Funnel drop-off chart for a specific funnel`).option(`--site-id <id>`,`Site ID`).option(`--window <w>`,`Time window: 7d | 30d`,{default:`30d`}).option(`--json`,``).option(`--csv`,``).option(`--tsv`,``).option(`--ndjson`,``).action(async(e,t)=>{let{funnelCommand:n}=await import(`./funnel-CnreY4vM.js`),r=await n({cliVersion:j,siteId:t.siteId,funnelId:e,window:t.window,json:t.json,csv:t.csv,tsv:t.tsv,ndjson:t.ndjson});process.exitCode=r}),P.command(`api-keys [action] [id]`,`[MANAGE] api-keys list | create [--name --scope] | delete <id>`).option(`--name <n>`,`Human-readable label (create)`).option(`--scope <scope>`,`read | write (create)`,{default:`read`}).option(`--yes`,`Skip confirmation (delete)`).option(`--json`,``).action(async(e,t,n)=>{let{apiKeysCommand:r}=await import(`./api-keys-fkRYlRR5.js`),i=e??`list`;process.exitCode=await r({cliVersion:j,action:i,id:t,name:n.name,scope:n.scope===`write`?`write`:`read`,yes:n.yes,json:n.json})}),P.command(`domains [action] [arg]`,`[MANAGE] domains list | add <url> [--name] | delete <id>`).option(`--name <n>`,`Friendly project name (add; default: domain itself)`).option(`--yes`,`Skip confirmation (delete)`).option(`--json`,``).action(async(e,t,n)=>{let{domainsCommand:r}=await import(`./domains-BxOad5mT.js`),i=e??`list`;process.exitCode=await r({cliVersion:j,action:i,url:i===`add`?t:void 0,id:i===`delete`?t:void 0,name:n.name,yes:n.yes,json:n.json})}),P.command(`team [action] [arg] [arg2]`,`[MANAGE] team list | invite <email> [--role] | remove <userId> | role <userId> <admin|member> (Pro+)`).option(`--role <role>`,`admin | member (invite)`,{default:`member`}).option(`--yes`,`Skip confirmation (remove)`).option(`--json`,``).action(async(e,t,n,r)=>{let{teamCommand:i}=await import(`./team-C-4HALGr.js`),a=e??`list`,o;a===`role`?o=n===`admin`?`admin`:`member`:a===`invite`&&(o=r.role===`admin`?`admin`:`member`),process.exitCode=await i({cliVersion:j,action:a,email:a===`invite`?t:void 0,userId:a===`remove`||a===`role`?t:void 0,role:o,yes:r.yes,json:r.json})}),P.command(`profile [action]`,`[ACCOUNT] profile show | edit [--name --notifications]`).option(`--name <n>`,`New display name (edit)`).option(`--notifications <pref>`,`email | none (edit)`).option(`--json`,``).action(async(e,t)=>{let n=e??`show`,r=t.notifications===`email`||t.notifications===`none`?t.notifications:void 0,{profileCommand:i}=await import(`./profile-5_2FhUf2.js`);process.exitCode=await i({cliVersion:j,action:n,name:t.name,notifications:r,json:t.json})}),P.command(`plans [action] [arg] [arg2]`,`[ACCOUNT] plans info | upgrade <pro|scale> | cancel --yes | payment update`).option(`--yes`,"Required for `cancel`").option(`--json`,``).action(async(e,t,n,r)=>{let i=e??`info`,{plansCommand:a}=await import(`./plans-CYnC6qA9.js`),o;if(i===`upgrade`&&t){let e=String(t).toLowerCase();(e===`pro`||e===`scale`||e===`enterprise`)&&(o=e)}let s=i===`payment`&&t===`update`||i===`payment`?`update`:void 0;process.exitCode=await a({cliVersion:j,action:i,targetPlan:o,paymentAction:s,yes:r.yes,json:r.json})}),P.command(`billing [action]`,"[ACCOUNT] Alias for `plans info`").option(`--json`,``).action(async(e,t)=>{let{plansCommand:n}=await import(`./plans-CYnC6qA9.js`);process.exitCode=await n({cliVersion:j,action:`info`,json:t.json})}),P.command(`settings [action] [key] [value]`,`[ACCOUNT] settings get [key] | set <key> <value>`).option(`--json`,``).action(async(e,t,n,r)=>{let i=e??`get`,{settingsCommand:a}=await import(`./settings-CdeO73MK.js`);process.exitCode=await a({cliVersion:j,action:i,key:t||void 0,value:n||void 0,json:r.json})}),P.command(`integrations [action] [name]`,`[ACCOUNT] integrations list | connect <gsc|github> | disconnect <gsc|github>`).option(`--yes`,`Skip confirmation (disconnect)`).option(`--json`,``).action(async(e,t,n)=>{let r=e??`list`,i=t===`gsc`||t===`github`?t:void 0,{integrationsCommand:a}=await import(`./integrations-AQRYDaZ8.js`);process.exitCode=await a({cliVersion:j,action:r,name:i,yes:n.yes,json:n.json})}),P.command(`goals [action] [id]`,`[ACCOUNT] goals list | create [--name --type --target] | delete <id> (Pro+)`).option(`--name <n>`,`Goal name (create)`).option(`--type <t>`,`pageview | event (create)`).option(`--target <v>`,`URL pattern or event name (create)`).option(`--yes`,`Skip confirmation (delete)`).option(`--json`,``).action(async(e,t,n)=>{let r=e??`list`,i=n.type===`event`||n.type===`pageview`?n.type:void 0,{goalsCommand:a}=await import(`./goals-CgekksXZ.js`);process.exitCode=await a({cliVersion:j,action:r,id:t,name:n.name,type:i,target:n.target,yes:n.yes,json:n.json})}),P.command(`notes [action] [id]`,`[ACCOUNT] notes list | create [--content --site-id] | delete <id>`).option(`--content <text>`,`Note body (create)`).option(`--site-id <id>`,`Attach to a specific site (create; defaults to current)`).option(`--yes`,`Skip confirmation (delete)`).option(`--json`,``).action(async(e,t,n)=>{let r=e??`list`,{notesCommand:i}=await import(`./notes-BxnYyEy2.js`);process.exitCode=await i({cliVersion:j,action:r,id:t,content:n.content,siteId:n.siteId,yes:n.yes,json:n.json})}),P.command(`agency [action] [arg] [arg2]`,`[ACCOUNT] agency clients list | clients add [--email --name] | clients remove <id> | report send <clientId> (Scale+)`).option(`--email <e>`,`Client contact email (clients add)`).option(`--name <n>`,`Client name (clients add)`).option(`--yes`,`Skip confirmation (clients remove)`).option(`--json`,``).action(async(e,t,n,r)=>{let{agencyCommand:i}=await import(`./agency-BbnHbz-V.js`),a=`clients-list`,o;e===`clients`?t===`add`?a=`clients-add`:t===`remove`?(a=`clients-remove`,o=n):a=`clients-list`:e===`report`&&t===`send`&&(a=`report-send`,o=n),process.exitCode=await i({cliVersion:j,action:a,id:o,email:r.email,name:r.name,yes:r.yes,json:r.json})}),P.command(`use [site]`,`Set / show / reset your default site (used when --site-id is omitted)`).option(`--reset`,`Clear the stored default site`).option(`--show`,`Print the current default and exit`).option(`--json`,`Emit JSON`).action(async(e,t)=>{let{useCommand:n}=await import(`./use-B5cyJIdz.js`),r=await n({cliVersion:j,match:e,reset:t.reset,show:t.show,json:t.json});process.exitCode=r}),P.command(`update`,`Manually install the latest version`).option(`--check`,`Don't install — just print latest`).option(`--force-downgrade`,`Allow downgrading to an older version`).option(`--no-update-check`,`Disable auto-update for this invocation`).option(`--json`,``).action(async e=>{let{updateCommand:t}=await import(`./update-BAq0JgwD.js`);await t({cliVersion:j,binaryPath:M,check:e.check,forceDowngrade:e.forceDowngrade,json:e.json})}),P.command(`usage`,`[ACCOUNT] Current month events vs plan limits + headcounts`).option(`--json`,``).action(async e=>{let{usageCommand:t}=await import(`./usage-fE-ViGrc.js`);process.exitCode=await t({cliVersion:j,json:e.json})}),P.command(`globe`,`[ANALYTICS] Live 3D globe — visitors plotted on a Braille sphere`).option(`--site-id <id>`,`Site ID`).option(`--browser`,`Open the dashboard's Mapbox globe in your browser instead of the terminal version`).option(`--json`,``).action(async e=>{let{globeCommand:t}=await import(`./globe-BKJc9jE7.js`);process.exitCode=await t({cliVersion:j,siteId:e.siteId,browser:e.browser,json:e.json})}),P.command(`webhooks [action] [arg]`,`[MANAGE] webhooks list | add <url> [--events] | delete <id> | rotate <id> | test <id> | forward [--to]`).option(`--events <list>`,`Comma-separated event types (add)`).option(`--yes`,`Skip confirmation (delete/rotate)`).option(`--to <url>`,`forward: local URL to POST events to (e.g. localhost:3000/webhook)`).option(`--site-id <id>`,`forward: Site ID`).option(`--sign`,`forward: HMAC-sign each forwarded request with X-Zenovay-Signature`).option(`--secret <hex>`,`forward: HMAC secret (auto-derived from tunnel key if --sign without --secret)`).option(`--max-retries <n>`,`forward: per-request retry count`,{default:3}).option(`--json`,``).action(async(e,t,n)=>{let r=e??`list`;if(r===`forward`){let{webhooksForwardCommand:e}=await import(`./webhooks-forward-DCVO9f_K.js`);process.exitCode=await e({cliVersion:j,to:n.to,siteId:n.siteId,sign:n.sign,secret:n.secret,maxRetries:typeof n.maxRetries==`string`?Number(n.maxRetries):n.maxRetries});return}let{webhooksCommand:i}=await import(`./webhooks-vH9WTb9j.js`);process.exitCode=await i({cliVersion:j,action:r,url:r===`add`?t:void 0,id:r===`delete`||r===`rotate`||r===`test`?t:void 0,events:n.events,yes:n.yes,json:n.json})}),P.command(`audit [action]`,`[ACCOUNT] audit list [--since --action --actor] | export [--format --out] (Pro+)`).option(`--since <window>`,`Window like 24h, 7d, 30d (list)`,{default:`7d`}).option(`--action <pattern>`,`Filter by action string (list)`).option(`--actor <userId>`,`Filter by actor user ID (list)`).option(`--format <fmt>`,`ndjson | csv | json (export)`,{default:`ndjson`}).option(`--out <file>`,`Output file path (export). Defaults to stdout`).option(`--json`,``).action(async(e,t)=>{let n=e??`list`,r=t.format??`ndjson`,{auditCommand:i}=await import(`./audit-DCRvk4rA.js`);process.exitCode=await i({cliVersion:j,action:n,since:t.since,filterAction:t.action,actor:t.actor,format:r,out:t.out,json:t.json})}),P.command(`share [action]`,`[ACCOUNT] share enable | disable | url — public dashboard share for the current site`).option(`--site-id <id>`,`Site ID (defaults to your current default site)`).option(`--yes`,`Skip confirmation (disable)`).option(`--json`,``).action(async(e,t)=>{let n=e??`url`,{shareCommand:r}=await import(`./share-lgJFoyb3.js`);process.exitCode=await r({cliVersion:j,action:n,siteId:t.siteId,yes:t.yes,json:t.json})}),P.command(`commands`,`Emit the machine-readable command tree (for AI agents and shell-completion regen)`).option(`--json`,``).action(async e=>{let{commandsCommand:t}=await import(`./commands-DSICboQu.js`);process.exitCode=await t({cliVersion:j,json:e.json})}),P.command(`teams [action] [arg]`,`[ACCOUNT] teams list | switch <name-or-id> | current | reset`).option(`--json`,``).action(async(e,t,n)=>{let r=e??`list`,{teamsCommand:i}=await import(`./teams-DDBH4Osf.js`);process.exitCode=await i({cliVersion:j,action:r,match:r===`switch`?t:void 0,json:n.json})}),P.command(`self-test`,`[OPERATIONS] Functional smoke check across every read endpoint and your local install`).option(`--quick`,`Run a 10-test subset (faster)`).option(`--full`,`Include active security probes + CLI meta-tests (dev/CI use)`).option(`--verbose`,`Include full stdout/stderr per test`).option(`--parallel <n>`,`Concurrent subprocesses (default 4)`,{default:4}).option(`--json`,`Emit NDJSON one line per test result + final summary`).action(async e=>{let{selfTestCommand:t}=await import(`./self-test-UekpcsNv.js`);process.exitCode=await t({cliVersion:j,full:!!e.full,quick:!!e.quick,verbose:!!e.verbose,parallel:Number(e.parallel)||4,json:!!e.json})}),P.command(`tour`,`[OPERATIONS] Interactive 8-step walkthrough of the CLI`).option(`--non-interactive`,`Print all 8 steps as a flat document (no prompts)`).action(async e=>{let{tourCommand:t}=await import(`./tour-Diao22fI.js`);process.exitCode=await t({cliVersion:j,nonInteractive:!!(e[`non-interactive`]||e.nonInteractive)})}),P.command(`alerts [action] [id]`,`[MANAGE] alerts list | create [--metric --op --threshold --window] | delete <id> (Pro+)`).option(`--site-id <id>`,`Site ID (defaults to your current default site)`).option(`--metric <name>`,`Metric to watch (visitors|pageviews|bounce_rate|errors|lcp|inp|cls|uptime|revenue)`).option(`--op <gt|lt>`,`Comparison operator`).option(`--threshold <num>`,`Numeric threshold`).option(`--window <e.g. 1h>`,`Rolling window (5m|1h|24h|7d)`).option(`--name <label>`,`Optional friendly label for the alert`).option(`--channel <chan>`,`Notification channel: in_app | email | webhook (default in_app)`).option(`--email <addr>`,`Notification email (required when --channel email)`).option(`--yes`,`Skip confirmation prompt on delete`).option(`--json`,``).action(async(e,t,n)=>{let r=e??`list`,i=new Set([`list`,`create`,`delete`]);i.has(r)||(process.stderr.write(n.json?JSON.stringify({type:`error`,code:`validation_failed`,message:`Unknown alerts action: ${e}`,hint:`Run zenovay alerts --help`})+`
|
|
8
8
|
`:`\n✗ Unknown action: '${e}'\n Valid: list | create | delete. Run \`zenovay alerts --help\`\n`),process.exit(2));let{alertsCommand:a}=await import(`./alerts-BjSU9WXH.js`);process.exitCode=await a({cliVersion:j,action:r,siteId:n[`site-id`]??n.siteId,metric:n.metric,op:n.op,threshold:n.threshold,window:n.window,name:n.name,channel:n.channel,email:n.email,id:t,yes:!!n.yes,json:!!n.json})}),P.command(`export <type>`,`[OPERATIONS] Export data: analytics | sessions (Pro+) | heatmaps (Pro+)`).option(`--site-id <id>`,`Site ID (defaults to your current default site)`).option(`--range <range>`,`Time range: 7d | 30d | 90d`,{default:`30d`}).option(`--format <fmt>`,`Output format: csv | json`,{default:`csv`}).option(`--out <file>`,`Write to file instead of stdout`).option(`--json`,``).action(async(e,t)=>{let n=new Set([`analytics`,`sessions`,`heatmaps`]);n.has(e)||(process.stderr.write(t.json?JSON.stringify({type:`error`,code:`validation_failed`,message:`Unknown export type: ${e}`,hint:`Valid: analytics | sessions | heatmaps`})+`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./config-JVhBplSX.js";import"./api-ytLQekr6.js";import"./token-store-RBywEspd.js";import{HostChoicePanel as e,initCommand as t}from"./init-
|
|
1
|
+
import"./config-JVhBplSX.js";import"./api-ytLQekr6.js";import"./token-store-RBywEspd.js";import{HostChoicePanel as e,initCommand as t}from"./init-C0CeKPzO.js";import"./formatter-DutfcQAc.js";import"./emit-DBYk96TD.js";import"./open-url-DHEOtfXN.js";import"./secrets-BGNbID-c.js";import"./client-DkVqZ_Bu.js";import"./login-DghPaa-z.js";import"./theme-DOR-SSzW.js";import"./panel-B9_Bd2So.js";import"./progress-row-Cz2F_drl.js";import"./prompt-CPA77m_S.js";import"./keybar-BWZ9d4xa.js";import"./sparkline-8ucKVUV7.js";export{t as initCommand};
|
|
@@ -332,4 +332,4 @@ Snippet reference (anchored by anchorKind — adapt to the actual file):
|
|
|
332
332
|
`+h.map(e=>` ${e.anchorKind} @ ${e.targetPath}:\n ${e.code.replace(/\n/g,`
|
|
333
333
|
`)}`).join(`
|
|
334
334
|
|
|
335
|
-
`);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 (Claude Code/Cursor/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=Vn({mode:Bn(o)});s.registerBridge(v);let y=v.subscribe(e=>s.setPendingApproval(e)),b=null,x=``,S=0;try{await Kt({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&&(_(`read`,`done`),_(`write`,`done`,`wrote ${r.path}`),s.setLiveLine(`Wrote ${r.path}`))},onDelta:e=>{x=(x+e).slice(-600);let t=Date.now();if(t-S<280)return;S=t;let n=x.replace(/\s+/g,` `).trim().slice(-80);n.length>4&&s.setLiveLine(n)}},initialMessages:[{role:`user`,content:g}],diagnosis:p,targetTrackingCode:f})}catch(e){b=e}finally{y(),s.setPendingApproval(null)}let C=d.stats(),ee=C.writes>0?await z(o.cwd,f).catch(()=>null):null,w=Yt(C,ee?.foundTrackingCodes??[],f,b);if(!w.ok)throw Error(w.error);_(`write`,`done`),_(`env`,`active`),s.setLiveLine(`Adding env var to .env.local`);let T=await G(o.cwd,{[a.envVarName]:f});if(_(`env`,`done`,`${T.addedKeys.length} key(s) added`),!o.skipMcp&&l){_(`mcp`,`active`),s.setLiveLine(`Detecting Cursor / Claude Desktop / VS Code…`);let e=await K({accessToken:l.accessToken}).catch(e=>({installed:[],skipped:[],errors:[{client:`mcp`,message:e.message}]}));_(`mcp`,`done`,rr(e))}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)),await ir(o.cwd,f,s),s.setSandboxStats?.(C),await Q(o,f,s),s.setPhase(`install-complete`)}catch(e){s.setErrorMsg(e.message),s.setPhase(`error`)}}const or=()=>{let{theme:e}=m();return k.createElement(p,{title:`Zenovay wants to set up your project`,state:`idle`},k.createElement(E,null,`We'll use AI to analyze your codebase and add the Zenovay tracker.`),k.createElement(E,{color:e.muted},`.env* contents stay on your machine. Only framework metadata reaches api.zenovay.com.`))},sr=({siteName:e,note:t,onChoose:n})=>{let{theme:r}=m(),i=[{label:`Cloudflare Pages`,value:`cloudflare-pages`,description:`writes functions/api/_z/[[path]].ts`},{label:`Vercel`,value:`vercel`,description:`adds a vercel.json rewrite`},{label:`Netlify`,value:`netlify`,description:`adds a _redirects rule`},{label:`Next.js (self-hosted)`,value:`nextjs-server`,description:`adds a next.config rewrite`},{label:`Skip — standard tracking only`,value:`skip`,description:`already works in Chrome, Firefox and most browsers`}];return k.createElement(T,{flexDirection:`column`,paddingX:2,paddingTop:1},k.createElement(E,{bold:!0},`Count visitors in every browser?`),t?k.createElement(E,{color:r.warn},t):null,k.createElement(E,{color:r.muted},`Your tracker already works. Safari, Edge and Brave block analytics loaded from another domain — serving Zenovay from your own domain fixes that. Where is `,e,` deployed?`),k.createElement(T,{marginTop:1},k.createElement(_,{items:i,onSelect:e=>n(e===`skip`?null:e)})))},cr=({adapter:e,site:t,tasks:n,liveLine:r,pendingApproval:i,onApprove:a,pendingHostChoice:o,hostChoiceNote:s,onHostChoice:c})=>{let{theme:l}=m(),u=process.stdout.columns??100,d=(process.stdout.rows??30)-8,f=Math.floor(u/2)-1,p=Math.max(14,d);return k.createElement(T,{flexDirection:`column`},k.createElement(T,{flexDirection:`row`,minHeight:p,borderStyle:`round`,borderColor:l.border},k.createElement(T,{width:f,flexDirection:`column`},k.createElement(Yn,{width:f,height:p})),k.createElement(T,{width:1,flexDirection:`column`},k.createElement(E,{color:l.border},`│`)),k.createElement(T,{width:f,flexDirection:`column`},i?k.createElement(T,{flexDirection:`column`,paddingX:2,paddingTop:1},k.createElement(E,{color:l.warn},`The agent wants to write `,i.path),i.reason?k.createElement(E,{color:l.muted},i.reason):null,k.createElement(h,{key:i.id,filePath:i.path,oldContent:i.oldContent,newContent:i.newContent,onApprove:a})):o&&c?k.createElement(sr,{siteName:t.name,note:s,onChoose:c}):k.createElement(k.Fragment,null,k.createElement(T,{paddingX:2,paddingTop:1},k.createElement(g,{done:n.filter(e=>e.status===`done`).length,total:n.length,label:n.find(e=>e.status===`active`)?.label})),k.createElement(Qn,{tasks:n,liveLine:r,width:f,height:p})))),k.createElement(T,{marginTop:1},k.createElement(E,{color:l.muted},`Site: `,t.name,` · code: `,t.trackingCode??t.id,` · Framework: `,e.displayName)))},lr=({site:e,onContinue:t,onExit:n})=>{let{theme:r}=m();D((e,r)=>{if(e===`q`||r.escape){n();return}if(e===`r`||e===`R`){t();return}});let i=e.url.replace(/^https?:\/\//,``).replace(/\/$/,``);return k.createElement(p,{title:`Already installed`,state:`ok`},k.createElement(T,{flexDirection:`column`,gap:1},k.createElement(T,{flexDirection:`row`,gap:1},k.createElement(E,{color:r.success},`✓`),k.createElement(E,{bold:!0},e.name),k.createElement(E,{color:r.muted},`(`,i,`)`)),k.createElement(E,{color:r.muted},`Zenovay is already tracking this project. No changes needed.`),e.trackingCode?k.createElement(E,{color:r.dim},`tracking code: `,e.trackingCode):null))},ur=({sites:e,preselectHint:t,onPick:n})=>{let r=Tr(e,t),i=e.filter(e=>e.id!==r?.id),a=r?[r,...i]:i,o=[...a.map(e=>({label:Cr(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 k.createElement(p,{title:t?`Pick a site (best match: ${t})`:`Pick a site`,state:`idle`},k.createElement(_,{items:o,onSelect:n}))};function dr(){let e=process.argv[1]??``;return e.includes(`/_npx/`)||e.includes(`\\_npx\\`)||process.env.npm_execpath?.includes(`npx`)?`npx`:`global`}const fr=({k:e,primary:t})=>{let{theme:n}=m();return k.createElement(E,null,k.createElement(E,{color:n.muted},`[`),k.createElement(E,{bold:!0,color:t?n.accent:n.fg},e),k.createElement(E,{color:n.muted},`] `))},pr=({adapter:e,site:t,stats:n,arrived:i,firstParty:a,onPick:o})=>{let{theme:c}=m(),l=dr(),u=l===`npx`?`npx @zenovay/cli`:`zenovay`,d=r(t),f=n&&n.rounds>0?`${n.writes} file(s) · ${n.rounds} agent round(s)`:n&&n.writes>0?`${n.writes} file(s) · programmatic (no AI calls)`:null;return D((e,t)=>{let n=e.toLowerCase();n===`w`||t.return?o(`watch`):n===`o`?s(d).catch(()=>void 0):n===`e`?o(`events`):(n===`s`||n===`q`||t.escape)&&o(`quit`)},{isActive:!0}),k.createElement(p,{title:`You're live on Zenovay`,state:`ok`},k.createElement(E,{bold:!0,color:c.success},i?`✓ First event received from ${t.name}`:`✓ Installed successfully`),k.createElement(E,{color:c.accent},`─`.repeat(18)),k.createElement(T,{marginTop:1,flexDirection:`column`},k.createElement(Z,{label:`Framework`,value:e.displayName}),k.createElement(Z,{label:`Site`,value:k.createElement(zn,{url:t.url,label:t.name})}),t.trackingCode?k.createElement(Z,{label:`Tracker`,value:k.createElement(E,{color:c.muted},t.trackingCode)}):k.createElement(Z,{label:`Tracker`,value:k.createElement(E,{color:c.warn},t.id,` (using site ID — verify in dashboard)`)}),f?k.createElement(Z,{label:`Changes`,value:k.createElement(E,{color:c.muted},f)}):null,k.createElement(Z,{label:`Dashboard`,value:k.createElement(zn,{url:d})})),a&&a.proxyFile&&a.proxyAction!==`manual`&&a.proxyAction!==`skipped`?k.createElement(T,{marginTop:1},k.createElement(E,{color:c.success},`✓ `),k.createElement(E,{color:c.muted},`Analytics now load from your own domain — after you deploy, Safari, Edge and Brave visitors are counted too.`)):a?.manual?k.createElement(T,{marginTop:1,flexDirection:`column`},k.createElement(E,{color:c.muted},`Counting visitors in every browser (optional):`),k.createElement(E,{color:c.muted},` `,a.manual)):null,k.createElement(T,{marginTop:1,flexDirection:`column`},k.createElement(E,{color:c.dim},`WHAT'S NEXT`),k.createElement(T,{marginTop:1},k.createElement(E,null,` `),k.createElement(fr,{k:`W`,primary:!0}),k.createElement(E,null,`Watch live in this terminal `),k.createElement(E,{color:c.muted},`— visitors, pages, sources, vitals`)),k.createElement(T,null,k.createElement(E,null,` `),k.createElement(fr,{k:`O`}),k.createElement(E,null,`Open the dashboard in your browser`)),k.createElement(T,null,k.createElement(E,null,` `),k.createElement(fr,{k:`E`}),k.createElement(E,null,`Stream events as they fire `),k.createElement(E,{color:c.muted},`— page views, custom events, live`)),k.createElement(T,null,k.createElement(E,null,` `),k.createElement(fr,{k:`S`}),k.createElement(E,null,`Exit to shell`))),l===`npx`?k.createElement(T,{marginTop:1,flexDirection:`column`,borderStyle:`single`,borderColor:c.warn,paddingX:1},k.createElement(E,{color:c.warn,bold:!0},`Heads up — you ran via npx`),k.createElement(E,{color:c.muted},"The `zenovay` command isn't on your PATH yet. After you exit, run:"),k.createElement(T,{marginTop:1},k.createElement(E,{color:c.fg},` npm i -g @zenovay/cli `),k.createElement(E,{color:c.muted},"→ then `zenovay overview` works directly"))):k.createElement(T,{marginTop:1},k.createElement(E,{color:c.muted},`From your shell: `),k.createElement(E,{color:c.fg},u,` overview`),k.createElement(E,{color:c.muted},` · `),k.createElement(E,{color:c.fg},u,` --help`)))},mr=({adapter:e,site:t,stats:n,verify:r,firstParty:i,onCommit:a,onSkipCommit:o})=>{let{theme:s}=m();return xr(e=>{e===`y`||e===`Y`||e===`\r`?a():(e===`n`||e===`N`||e===`s`||e===`S`)&&o()}),k.createElement(p,{title:`Tracker installed`,state:r&&!r.ok?`warn`:`ok`},r?k.createElement(E,null,k.createElement(E,{color:r.ok?s.success:s.warn},r.ok?`✔ Verified — `:`⚠ `),r.detail):k.createElement(E,null,k.createElement(E,{color:s.success},`✔ `),`The Zenovay tracker is in your project.`),k.createElement(T,{marginTop:1},k.createElement(E,{color:s.muted},`Framework: `),k.createElement(E,null,e.displayName)),k.createElement(T,null,k.createElement(E,{color:s.muted},`Site: `),k.createElement(E,null,t.name,` (`,t.url,`)`)),n&&k.createElement(T,null,k.createElement(E,{color:s.muted},`Modified: `),k.createElement(E,null,n.writes,` file(s)`)),k.createElement(hr,{firstParty:i}),k.createElement(T,{marginTop:1},k.createElement(E,null,`Commit + push these changes to git? `),k.createElement(E,{color:s.accent},`[Y/n]`)))},hr=({firstParty:e})=>{let{theme:t}=m();if(!e)return null;let n=e.proxyFile&&e.proxyAction!==`manual`&&e.proxyAction!==`skipped`;return n?k.createElement(T,{marginTop:1,flexDirection:`column`},k.createElement(T,null,k.createElement(E,{color:t.success},`✔ `),k.createElement(E,null,`Analytics now load from your own domain `),k.createElement(E,{color:t.muted},`(`,e.proxyFile,`)`)),k.createElement(E,{color:t.muted},`After you deploy, Safari, Edge and Brave visitors are counted too.`)):e.manual?k.createElement(T,{marginTop:1,flexDirection:`column`},k.createElement(T,null,k.createElement(E,{color:t.muted},`Counting visitors in every browser (optional):`)),k.createElement(E,{color:t.muted},e.manual)):null},gr=({cwd:e,onDone:t,onError:n})=>{let{theme:r}=m(),[i,a]=j(`committing`),[o,s]=j(`Staging changes…`);return A(()=>{(async()=>{try{let n=await Sr(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)}})()},[]),k.createElement(p,{title:`Committing to git`,state:`busy`},k.createElement(T,null,k.createElement(E,{color:r.accent},k.createElement(N,{type:`dots`})),k.createElement(E,null,` `,i===`pushing`?`Pushing to origin`:`Committing`,`…`)),k.createElement(T,{marginTop:1},k.createElement(E,{color:r.muted},o)))},_r=({site:e,onDeployed:t,onSkip:n})=>{let{theme:r}=m();return xr(e=>{e===`y`||e===`Y`||e===`\r`||e===`d`||e===`D`?t():(e===`n`||e===`N`||e===`s`||e===`S`)&&n()}),k.createElement(p,{title:`Ready to deploy?`,state:`idle`},k.createElement(E,null,`The tracker is installed locally. To capture events you need it on the live site:`),k.createElement(E,null,` `),k.createElement(T,null,k.createElement(E,{color:r.muted},` → `),k.createElement(zn,{url:e.url})),k.createElement(E,null,` `),k.createElement(E,{color:r.muted},`Push the change through your normal deploy pipeline (Vercel auto-deploy, CI/CD, etc.).`),k.createElement(T,{marginTop:1},k.createElement(E,null,`Once it's deployed, press `),k.createElement(E,{color:r.accent},`[Y]`),k.createElement(E,null,` to verify the tracker is firing. `),k.createElement(E,{color:r.muted},`[s] skip verification`)))},vr=({site:e,onContinue:t})=>{let{theme:n}=m();return xr(()=>t()),k.createElement(p,{title:`Visit your site`,state:`idle`},k.createElement(E,null,`To send a test event, open any page on your site:`),k.createElement(E,null,` `),k.createElement(T,null,k.createElement(E,{color:n.muted},` → `),k.createElement(zn,{url:e.url})),k.createElement(E,null,` `),k.createElement(E,{color:n.muted},`The tracker fires automatically on page load. We'll verify the next event arrives.`),k.createElement(T,{marginTop:1},k.createElement(E,null,`Press `),k.createElement(E,{color:n.accent},`[any key]`),k.createElement(E,null,` when you've visited the page.`)))};async function yr(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 br=({site:t,elapsed:r,onTick:a,onArrived:o,onTimeout:s})=>{let{theme:c}=m(),[l,u]=j(`preflight`),[d,f]=j(``),[h,g]=j([]),_=re(!1),v=t.trackingCode??t.id,y=async()=>{u(`preflight`),f(`Fetching ${t.url}…`);let e=await yr(t.url,v);if(_.current)return;if(e.state===`tracker-correct`){u(`polling`),f(`Tracker detected on live site — waiting for first hit…`),b();return}if(e.state===`tracker-wrong-id`){u(`wrong-id-on-live`),g(e.foundCodes),f(`Live site has Zenovay but with id(s): ${e.foundCodes.join(`, `)}`);return}u(`awaiting-deploy`);let n=e.networkError?/enotfound|getaddrinfo|dns/i.test(e.networkError)?` (DNS lookup failed — check the site URL is correct + deployed)`:/timeout|etimedout|abort|econnrefused|network/i.test(e.networkError)?` (check your internet connection, then retry with [r])`:``:``;f(e.networkError?`Couldn't reach ${t.url}: ${e.networkError}${n}`:e.httpStatus?`${t.url} returned HTTP ${e.httpStatus}`:`No Zenovay tracker found on ${t.url}.`)},b=async()=>{let r=Date.now()-10*60*1e3;try{let s=await e(),c=await i({strict:!1}),l=new n({config:s,cliVersion:`0`,token:c}),d=await Nt(t.id,r,{api:l,timeoutMs:6e4,pollIntervalMs:2500,onTick:e=>{_.current||a(e)}});if(_.current)return;d.received?(u(`success`),o()):u(`timeout`)}catch{_.current||u(`timeout`)}};A(()=>(_.current=!1,y(),()=>{_.current=!0}),[]),D(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(r/1e3);return l===`preflight`?k.createElement(p,{title:`Verifying`,state:`busy`},k.createElement(T,null,k.createElement(E,{color:c.accent},k.createElement(N,{type:`dots`})),k.createElement(E,null,` Checking your live site for the tracker…`)),k.createElement(T,{marginTop:1},k.createElement(E,{color:c.muted},d))):l===`awaiting-deploy`?k.createElement(p,{title:`Tracker not yet on your live site`,state:`warn`},k.createElement(E,{color:c.warn},d),k.createElement(T,{marginTop:1,flexDirection:`column`},k.createElement(E,null,`The tracker is in your local repo but hasn't been deployed yet.`),k.createElement(E,{color:c.muted},`Push your changes and wait for your deploy to finish (Vercel / Cloudflare Pages / CI), then retry.`)),k.createElement(T,{marginTop:1},k.createElement(E,null,`Press `),k.createElement(E,{color:c.accent},`[r]`),k.createElement(E,null,` to re-check, `),k.createElement(E,{color:c.accent},`[s]`),k.createElement(E,null,` to skip verification.`))):l===`wrong-id-on-live`?k.createElement(p,{title:`Live site has a different tracking code`,state:`warn`},k.createElement(E,{color:c.warn},`Expected: `,k.createElement(E,{color:c.accent},v),` `,`Found on live: `,k.createElement(E,{color:c.accent},h.join(`, `))),k.createElement(T,{marginTop:1,flexDirection:`column`},k.createElement(E,null,`Your local install uses a different ID than what's on `,t.url,`.`),k.createElement(E,{color:c.muted},`Deploy the new local version, then retry — or skip if the existing ID is intentional.`)),k.createElement(T,{marginTop:1},k.createElement(E,null,`Press `),k.createElement(E,{color:c.accent},`[r]`),k.createElement(E,null,` to re-check, `),k.createElement(E,{color:c.accent},`[s]`),k.createElement(E,null,` to skip.`))):l===`timeout`?k.createElement(p,{title:`No event arrived in 3 minutes`,state:`warn`},k.createElement(E,{color:c.warn},`The tracker is on your live site but no hits reached api.zenovay.com.`),k.createElement(T,{marginTop:1},k.createElement(E,{color:c.muted},`Try opening `,t.url,` in a fresh browser tab (no ad-blocker), then retry.`)),k.createElement(T,{marginTop:1},k.createElement(E,null,`Press `),k.createElement(E,{color:c.accent},`[r]`),k.createElement(E,null,` to re-check, `),k.createElement(E,{color:c.accent},`[s]`),k.createElement(E,null,` to finish without verification.`))):k.createElement(p,{title:`Waiting for first event`,state:`busy`},k.createElement(T,null,k.createElement(E,{color:c.accent},k.createElement(N,{type:`dots`})),k.createElement(E,null,` Polling api.zenovay.com for the first hit on `),k.createElement(E,{color:c.accent},t.url),k.createElement(E,null,` (`,x,`s elapsed)`)),k.createElement(T,{marginTop:1},k.createElement(E,{color:c.muted},`Reload the page if nothing arrives within ~30 seconds.`)))};function xr(e){D((t,n)=>{e(t,{return:n.return,escape:n.escape})},{isActive:!0})}async function Sr(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.trim()}\nPush manually with: git push origin ${l}`),{committed:!0,shortSha:c,branch:l}}return n(`done`),{committed:!0,shortSha:c,branch:l}}function Cr(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 wr(e){try{let t=await x.readFile(b.join(e,`package.json`),`utf8`),n=JSON.parse(t);if(n.name)return String(n.name).replace(/^@[^/]+\//,``)}catch{}try{let t=await x.readFile(b.join(e,`.git`,`config`),`utf8`),n=t.match(/url\s*=\s*.*[/:]([^/]+?)(?:\.git)?\s*$/m);if(n&&n[1])return n[1]}catch{}return b.basename(e)}function Tr(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{sr as HostChoicePanel,ue as detectInstalled,$n as initCommand};
|
|
335
|
+
`);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 (Claude Code/Cursor/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=Vn({mode:Bn(o)});s.registerBridge(v);let y=v.subscribe(e=>s.setPendingApproval(e)),b=null,x=``,S=0;try{await Kt({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&&(_(`read`,`done`),_(`write`,`done`,`wrote ${r.path}`),s.setLiveLine(`Wrote ${r.path}`))},onDelta:e=>{x=(x+e).slice(-600);let t=Date.now();if(t-S<280)return;S=t;let n=x.replace(/\s+/g,` `).trim().slice(-80);n.length>4&&s.setLiveLine(n)}},initialMessages:[{role:`user`,content:g}],diagnosis:p,targetTrackingCode:f})}catch(e){b=e}finally{y(),s.setPendingApproval(null)}let C=d.stats(),ee=C.writes>0?await z(o.cwd,f).catch(()=>null):null,w=Yt(C,ee?.foundTrackingCodes??[],f,b);if(!w.ok)throw Error(w.error);_(`write`,`done`),_(`env`,`active`),s.setLiveLine(`Adding env var to .env.local`);let T=await G(o.cwd,{[a.envVarName]:f});if(_(`env`,`done`,`${T.addedKeys.length} key(s) added`),!o.skipMcp&&l){_(`mcp`,`active`),s.setLiveLine(`Detecting Cursor / Claude Desktop / VS Code…`);let e=await K({accessToken:l.accessToken}).catch(e=>({installed:[],skipped:[],errors:[{client:`mcp`,message:e.message}]}));_(`mcp`,`done`,rr(e))}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)),await ir(o.cwd,f,s),s.setSandboxStats?.(C),await Q(o,f,s),s.setPhase(`install-complete`)}catch(e){s.setErrorMsg(e.message),s.setPhase(`error`)}}const or=()=>{let{theme:e}=m();return k.createElement(p,{title:`Zenovay wants to set up your project`,state:`idle`},k.createElement(E,null,`We'll use AI to analyze your codebase and add the Zenovay tracker.`),k.createElement(E,{color:e.muted},`.env* contents stay on your machine. Only framework metadata reaches api.zenovay.com.`))},sr=({siteName:e,note:t,onChoose:n})=>{let{theme:r}=m(),i=[{label:`Cloudflare Pages`,value:`cloudflare-pages`,description:`writes functions/api/_z/[[path]].ts`},{label:`Vercel`,value:`vercel`,description:`adds a vercel.json rewrite`},{label:`Netlify`,value:`netlify`,description:`adds a _redirects rule`},{label:`Next.js (self-hosted)`,value:`nextjs-server`,description:`adds a next.config rewrite`},{label:`Skip — standard tracking only`,value:`skip`,description:`already works in Chrome, Firefox and most browsers`}];return k.createElement(T,{flexDirection:`column`,paddingX:2,paddingTop:1},k.createElement(E,{bold:!0},`Count visitors in every browser?`),t?k.createElement(E,{color:r.warn},t):null,k.createElement(E,{color:r.muted},`Your tracker already works. Safari, Edge and Brave block analytics loaded from another domain — serving Zenovay from your own domain fixes that. Where is `,e,` deployed?`),k.createElement(T,{marginTop:1},k.createElement(_,{items:i,onSelect:e=>n(e===`skip`?null:e)})))},cr=({adapter:e,site:t,tasks:n,liveLine:r,pendingApproval:i,onApprove:a,pendingHostChoice:o,hostChoiceNote:s,onHostChoice:c})=>{let{theme:l}=m(),u=process.stdout.columns??100,d=(process.stdout.rows??30)-8,f=Math.floor(u/2)-1,p=Math.max(14,d);return k.createElement(T,{flexDirection:`column`},k.createElement(T,{flexDirection:`row`,minHeight:p,borderStyle:`round`,borderColor:l.border},k.createElement(T,{width:f,flexDirection:`column`},k.createElement(Yn,{width:f,height:p})),k.createElement(T,{width:1,flexDirection:`column`},k.createElement(E,{color:l.border},`│`)),k.createElement(T,{width:f,flexDirection:`column`},i?k.createElement(T,{flexDirection:`column`,paddingX:2,paddingTop:1},k.createElement(E,{color:l.warn},`The agent wants to write `,i.path),i.reason?k.createElement(E,{color:l.muted},i.reason):null,k.createElement(h,{key:i.id,filePath:i.path,oldContent:i.oldContent,newContent:i.newContent,onApprove:a})):o&&c?k.createElement(sr,{siteName:t.name,note:s,onChoose:c}):k.createElement(k.Fragment,null,k.createElement(T,{paddingX:2,paddingTop:1},k.createElement(g,{done:n.filter(e=>e.status===`done`).length,total:n.length,label:n.find(e=>e.status===`active`)?.label})),k.createElement(Qn,{tasks:n,liveLine:r,width:f,height:p})))),k.createElement(T,{marginTop:1},k.createElement(E,{color:l.muted},`Site: `,t.name,` · code: `,t.trackingCode??t.id,` · Framework: `,e.displayName)))},lr=({site:e,onContinue:t,onExit:n})=>{let{theme:r}=m();D((e,r)=>{if(e===`q`||r.escape){n();return}if(e===`r`||e===`R`){t();return}});let i=e.url.replace(/^https?:\/\//,``).replace(/\/$/,``);return k.createElement(p,{title:`Already installed`,state:`ok`},k.createElement(T,{flexDirection:`column`,gap:1},k.createElement(T,{flexDirection:`row`,gap:1},k.createElement(E,{color:r.success},`✓`),k.createElement(E,{bold:!0},e.name),k.createElement(E,{color:r.muted},`(`,i,`)`)),k.createElement(E,{color:r.muted},`Zenovay is already tracking this project. No changes needed.`),e.trackingCode?k.createElement(E,{color:r.dim},`tracking code: `,e.trackingCode):null))},ur=({sites:e,preselectHint:t,onPick:n})=>{let r=Tr(e,t),i=e.filter(e=>e.id!==r?.id),a=r?[r,...i]:i,o=[...a.map(e=>({label:Cr(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 k.createElement(p,{title:t?`Pick a site (best match: ${t})`:`Pick a site`,state:`idle`},k.createElement(_,{items:o,onSelect:n}))};function dr(){let e=process.argv[1]??``;return e.includes(`/_npx/`)||e.includes(`\\_npx\\`)||process.env.npm_execpath?.includes(`npx`)?`npx`:`global`}const fr=({k:e,primary:t})=>{let{theme:n}=m();return k.createElement(E,null,k.createElement(E,{color:n.muted},`[`),k.createElement(E,{bold:!0,color:t?n.accent:n.fg},e),k.createElement(E,{color:n.muted},`] `))},pr=({adapter:e,site:t,stats:n,arrived:i,firstParty:a,onPick:o})=>{let{theme:c}=m(),l=dr(),u=l===`npx`?`npx @zenovay/cli`:`zenovay`,d=r(t),f=n&&n.rounds>0?`${n.writes} file(s) · ${n.rounds} agent round(s)`:n&&n.writes>0?`${n.writes} file(s) · programmatic (no AI calls)`:null;return D((e,t)=>{let n=e.toLowerCase();n===`w`||t.return?o(`watch`):n===`o`?s(d).catch(()=>void 0):n===`e`?o(`events`):(n===`s`||n===`q`||t.escape)&&o(`quit`)},{isActive:!0}),k.createElement(p,{title:`You're live on Zenovay`,state:`ok`},k.createElement(E,{bold:!0,color:c.success},i?`✓ First event received from ${t.name}`:`✓ Installed successfully`),k.createElement(E,{color:c.accent},`─`.repeat(18)),k.createElement(T,{marginTop:1,flexDirection:`column`},k.createElement(Z,{label:`Framework`,value:e.displayName}),k.createElement(Z,{label:`Site`,value:k.createElement(zn,{url:t.url,label:t.name})}),t.trackingCode?k.createElement(Z,{label:`Tracker`,value:k.createElement(E,{color:c.muted},t.trackingCode)}):k.createElement(Z,{label:`Tracker`,value:k.createElement(E,{color:c.warn},t.id,` (using site ID — verify in dashboard)`)}),f?k.createElement(Z,{label:`Changes`,value:k.createElement(E,{color:c.muted},f)}):null,k.createElement(Z,{label:`Dashboard`,value:k.createElement(zn,{url:d})})),a&&a.proxyFile&&a.proxyAction!==`manual`&&a.proxyAction!==`skipped`?k.createElement(T,{marginTop:1},k.createElement(E,{color:c.success},`✓ `),k.createElement(E,{color:c.muted},`Analytics now load from your own domain — after you deploy, Safari, Edge and Brave visitors are counted too.`)):a?.manual?k.createElement(T,{marginTop:1,flexDirection:`column`},k.createElement(E,{color:c.muted},`Counting visitors in every browser (optional):`),k.createElement(E,{color:c.muted},` `,a.manual)):null,k.createElement(T,{marginTop:1,flexDirection:`column`},k.createElement(E,{color:c.dim},`WHAT'S NEXT`),k.createElement(T,{marginTop:1},k.createElement(E,null,` `),k.createElement(fr,{k:`W`,primary:!0}),k.createElement(E,null,`Watch live in this terminal `),k.createElement(E,{color:c.muted},`— visitors, pages, sources, vitals`)),k.createElement(T,null,k.createElement(E,null,` `),k.createElement(fr,{k:`O`}),k.createElement(E,null,`Open the dashboard in your browser`)),k.createElement(T,null,k.createElement(E,null,` `),k.createElement(fr,{k:`E`}),k.createElement(E,null,`Stream events as they fire `),k.createElement(E,{color:c.muted},`— page views, custom events, live`)),k.createElement(T,null,k.createElement(E,null,` `),k.createElement(fr,{k:`S`}),k.createElement(E,null,`Exit to shell`))),l===`npx`?k.createElement(T,{marginTop:1,flexDirection:`column`,borderStyle:`single`,borderColor:c.warn,paddingX:1},k.createElement(E,{color:c.warn,bold:!0},`Heads up — you ran via npx`),k.createElement(E,{color:c.muted},"The `zenovay` command isn't on your PATH yet. After you exit, run:"),k.createElement(T,{marginTop:1},k.createElement(E,{color:c.fg},` npm i -g @zenovay/cli `),k.createElement(E,{color:c.muted},"→ then `zenovay overview` works directly"))):k.createElement(T,{marginTop:1},k.createElement(E,{color:c.muted},`From your shell: `),k.createElement(E,{color:c.fg},u,` overview`),k.createElement(E,{color:c.muted},` · `),k.createElement(E,{color:c.fg},u,` --help`)))},mr=({adapter:e,site:t,stats:n,verify:r,firstParty:i,onCommit:a,onSkipCommit:o})=>{let{theme:s}=m();return xr(e=>{e===`y`||e===`Y`||e===`\r`?a():(e===`n`||e===`N`||e===`s`||e===`S`)&&o()}),k.createElement(p,{title:`Tracker installed`,state:r&&!r.ok?`warn`:`ok`},r?k.createElement(E,null,k.createElement(E,{color:r.ok?s.success:s.warn},r.ok?`✔ Verified — `:`⚠ `),r.detail):k.createElement(E,null,k.createElement(E,{color:s.success},`✔ `),`The Zenovay tracker is in your project.`),k.createElement(T,{marginTop:1},k.createElement(E,{color:s.muted},`Framework: `),k.createElement(E,null,e.displayName)),k.createElement(T,null,k.createElement(E,{color:s.muted},`Site: `),k.createElement(E,null,t.name,` (`,t.url,`)`)),n&&k.createElement(T,null,k.createElement(E,{color:s.muted},`Modified: `),k.createElement(E,null,n.writes,` file(s)`)),k.createElement(hr,{firstParty:i}),k.createElement(T,{marginTop:1},k.createElement(E,null,`Commit + push these changes to git? `),k.createElement(E,{color:s.accent},`[Y/n]`)))},hr=({firstParty:e})=>{let{theme:t}=m();if(!e)return null;let n=e.proxyFile&&e.proxyAction!==`manual`&&e.proxyAction!==`skipped`;return n?k.createElement(T,{marginTop:1,flexDirection:`column`},k.createElement(T,null,k.createElement(E,{color:t.success},`✔ `),k.createElement(E,null,`Analytics now load from your own domain `),k.createElement(E,{color:t.muted},`(`,e.proxyFile,`)`)),k.createElement(E,{color:t.muted},`After you deploy, Safari, Edge and Brave visitors are counted too.`)):e.manual?k.createElement(T,{marginTop:1,flexDirection:`column`},k.createElement(T,null,k.createElement(E,{color:t.muted},`Counting visitors in every browser (optional):`)),k.createElement(E,{color:t.muted},e.manual)):null},gr=({cwd:e,onDone:t,onError:n})=>{let{theme:r}=m(),[i,a]=j(`committing`),[o,s]=j(`Staging changes…`);return A(()=>{(async()=>{try{let n=await Sr(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)}})()},[]),k.createElement(p,{title:`Committing to git`,state:`busy`},k.createElement(T,null,k.createElement(E,{color:r.accent},k.createElement(N,{type:`dots`})),k.createElement(E,null,` `,i===`pushing`?`Pushing to origin`:`Committing`,`…`)),k.createElement(T,{marginTop:1},k.createElement(E,{color:r.muted},o)))},_r=({site:e,onDeployed:t,onSkip:n})=>{let{theme:r}=m();return xr(e=>{e===`y`||e===`Y`||e===`\r`||e===`d`||e===`D`?t():(e===`n`||e===`N`||e===`s`||e===`S`)&&n()}),k.createElement(p,{title:`Ready to deploy?`,state:`idle`},k.createElement(E,null,`The tracker is installed locally. To capture events you need it on the live site:`),k.createElement(E,null,` `),k.createElement(T,null,k.createElement(E,{color:r.muted},` → `),k.createElement(zn,{url:e.url})),k.createElement(E,null,` `),k.createElement(E,{color:r.muted},`Push the change through your normal deploy pipeline (Vercel auto-deploy, CI/CD, etc.).`),k.createElement(T,{marginTop:1},k.createElement(E,null,`Once it's deployed, press `),k.createElement(E,{color:r.accent},`[Y]`),k.createElement(E,null,` to verify the tracker is firing. `),k.createElement(E,{color:r.muted},`[s] skip verification`)))},vr=({site:e,onContinue:t})=>{let{theme:n}=m();return xr(()=>t()),k.createElement(p,{title:`Visit your site`,state:`idle`},k.createElement(E,null,`To send a test event, open any page on your site:`),k.createElement(E,null,` `),k.createElement(T,null,k.createElement(E,{color:n.muted},` → `),k.createElement(zn,{url:e.url})),k.createElement(E,null,` `),k.createElement(E,{color:n.muted},`The tracker fires automatically on page load. We'll verify the next event arrives.`),k.createElement(T,{marginTop:1},k.createElement(E,null,`Press `),k.createElement(E,{color:n.accent},`[any key]`),k.createElement(E,null,` when you've visited the page.`)))};async function yr(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\b[^>]*\bsrc\s*=\s*["'][^"']*(?:(?:api|cdn)\.zenovay\.com\/|\/(?:api\/)?_z\/script\.js)[^"']*["'][^>]*>/gi,a=/data-id\s*=\s*["'](ZV_[A-Za-z0-9]+)["']/i,o=/[?&]id=(ZV_[A-Za-z0-9]+)/i,s=r.match(i)??[];if(s.length===0)return{state:`tracker-missing`};let c=Array.from(new Set(s.map(e=>e.match(a)?.[1]??e.match(o)?.[1]).filter(e=>!!e)));return c.includes(t)?{state:`tracker-correct`}:{state:`tracker-wrong-id`,foundCodes:c}}catch(e){return{state:`tracker-missing`,networkError:e.message}}}const br=({site:t,elapsed:r,onTick:a,onArrived:o,onTimeout:s})=>{let{theme:c}=m(),[l,u]=j(`preflight`),[d,f]=j(``),[h,g]=j([]),_=re(!1),v=t.trackingCode??t.id,y=async()=>{u(`preflight`),f(`Fetching ${t.url}…`);let e=await yr(t.url,v);if(_.current)return;if(e.state===`tracker-correct`){u(`polling`),f(`Tracker detected on live site — waiting for first hit…`),b();return}if(e.state===`tracker-wrong-id`){u(`wrong-id-on-live`),g(e.foundCodes),f(`Live site has Zenovay but with id(s): ${e.foundCodes.join(`, `)}`);return}u(`awaiting-deploy`);let n=e.networkError?/enotfound|getaddrinfo|dns/i.test(e.networkError)?` (DNS lookup failed — check the site URL is correct + deployed)`:/timeout|etimedout|abort|econnrefused|network/i.test(e.networkError)?` (check your internet connection, then retry with [r])`:``:``;f(e.networkError?`Couldn't reach ${t.url}: ${e.networkError}${n}`:e.httpStatus?`${t.url} returned HTTP ${e.httpStatus}`:`No Zenovay tracker found on ${t.url}.`)},b=async()=>{let r=Date.now()-10*60*1e3;try{let s=await e(),c=await i({strict:!1}),l=new n({config:s,cliVersion:`0`,token:c}),d=await Nt(t.id,r,{api:l,timeoutMs:6e4,pollIntervalMs:2500,onTick:e=>{_.current||a(e)}});if(_.current)return;d.received?(u(`success`),o()):u(`timeout`)}catch{_.current||u(`timeout`)}};A(()=>(_.current=!1,y(),()=>{_.current=!0}),[]),D(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(r/1e3);return l===`preflight`?k.createElement(p,{title:`Verifying`,state:`busy`},k.createElement(T,null,k.createElement(E,{color:c.accent},k.createElement(N,{type:`dots`})),k.createElement(E,null,` Checking your live site for the tracker…`)),k.createElement(T,{marginTop:1},k.createElement(E,{color:c.muted},d))):l===`awaiting-deploy`?k.createElement(p,{title:`Tracker not yet on your live site`,state:`warn`},k.createElement(E,{color:c.warn},d),k.createElement(T,{marginTop:1,flexDirection:`column`},k.createElement(E,null,`The tracker is in your local repo but hasn't been deployed yet.`),k.createElement(E,{color:c.muted},`Push your changes and wait for your deploy to finish (Vercel / Cloudflare Pages / CI), then retry.`)),k.createElement(T,{marginTop:1},k.createElement(E,null,`Press `),k.createElement(E,{color:c.accent},`[r]`),k.createElement(E,null,` to re-check, `),k.createElement(E,{color:c.accent},`[s]`),k.createElement(E,null,` to skip verification.`))):l===`wrong-id-on-live`?k.createElement(p,{title:`Live site has a different tracking code`,state:`warn`},k.createElement(E,{color:c.warn},`Expected: `,k.createElement(E,{color:c.accent},v),` `,`Found on live: `,k.createElement(E,{color:c.accent},h.join(`, `))),k.createElement(T,{marginTop:1,flexDirection:`column`},k.createElement(E,null,`Your local install uses a different ID than what's on `,t.url,`.`),k.createElement(E,{color:c.muted},`Deploy the new local version, then retry — or skip if the existing ID is intentional.`)),k.createElement(T,{marginTop:1},k.createElement(E,null,`Press `),k.createElement(E,{color:c.accent},`[r]`),k.createElement(E,null,` to re-check, `),k.createElement(E,{color:c.accent},`[s]`),k.createElement(E,null,` to skip.`))):l===`timeout`?k.createElement(p,{title:`No event arrived in 3 minutes`,state:`warn`},k.createElement(E,{color:c.warn},`The tracker is on your live site but no hits reached api.zenovay.com.`),k.createElement(T,{marginTop:1},k.createElement(E,{color:c.muted},`Try opening `,t.url,` in a fresh browser tab (no ad-blocker), then retry.`)),k.createElement(T,{marginTop:1},k.createElement(E,null,`Press `),k.createElement(E,{color:c.accent},`[r]`),k.createElement(E,null,` to re-check, `),k.createElement(E,{color:c.accent},`[s]`),k.createElement(E,null,` to finish without verification.`))):k.createElement(p,{title:`Waiting for first event`,state:`busy`},k.createElement(T,null,k.createElement(E,{color:c.accent},k.createElement(N,{type:`dots`})),k.createElement(E,null,` Polling api.zenovay.com for the first hit on `),k.createElement(E,{color:c.accent},t.url),k.createElement(E,null,` (`,x,`s elapsed)`)),k.createElement(T,{marginTop:1},k.createElement(E,{color:c.muted},`Reload the page if nothing arrives within ~30 seconds.`)))};function xr(e){D((t,n)=>{e(t,{return:n.return,escape:n.escape})},{isActive:!0})}async function Sr(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.trim()}\nPush manually with: git push origin ${l}`),{committed:!0,shortSha:c,branch:l}}return n(`done`),{committed:!0,shortSha:c,branch:l}}function Cr(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 wr(e){try{let t=await x.readFile(b.join(e,`package.json`),`utf8`),n=JSON.parse(t);if(n.name)return String(n.name).replace(/^@[^/]+\//,``)}catch{}try{let t=await x.readFile(b.join(e,`.git`,`config`),`utf8`),n=t.match(/url\s*=\s*.*[/:]([^/]+?)(?:\.git)?\s*$/m);if(n&&n[1])return n[1]}catch{}return b.basename(e)}function Tr(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{sr as HostChoicePanel,ue as detectInstalled,$n as initCommand};
|
package/dist/wizard-bin.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import(`./init-
|
|
2
|
+
import(`./init-BijYETQa.js`).then(async({initCommand:e})=>{let{readFileSync:t}=await import(`node:fs`),n=await import(`node:path`),{fileURLToPath:r}=await import(`node:url`),i=n.dirname(r(import.meta.url)),a=JSON.parse(t(n.join(i,`..`,`package.json`),`utf8`)),o=process.argv.slice(2),s=o.includes(`--json`),c=o.includes(`--yes`),l=o.includes(`--skip-mcp`),u=o.includes(`--skip-verify`),d=await e({cliVersion:a.version,cwd:process.cwd(),json:s,yes:c,skipMcp:l,skipVerify:u});process.exit(d)});
|