@zibby/cli 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/zibby.js +3 -3
- package/dist/commands/app-auth.js +17 -0
- package/dist/commands/app.js +1 -1
- package/dist/commands/init.js +125 -117
- package/dist/commands/mcp.js +3 -3
- package/dist/commands/workflows/generate.js +143 -135
- package/dist/commands/workflows/webhook.js +28 -0
- package/dist/package.json +2 -1
- package/package.json +2 -1
package/dist/commands/init.js
CHANGED
|
@@ -1,176 +1,176 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Oo=Object.defineProperty;var N=(e,o)=>()=>(e&&(o=e(e=0)),o);var L=(e,o)=>{for(var t in o)Oo(e,t,{get:o[t],enumerable:!0})};var Le={};L(Le,{resolveTemplate:()=>Be,templateAddCommand:()=>et,templateListCommand:()=>Qo,writeTemplateFiles:()=>Ne,writeTemplateFilesToDir:()=>Ke});import{mkdir as Oe,writeFile as Lo,readFile as Do}from"fs/promises";import{existsSync as se,readdirSync as jo,statSync as Uo,readFileSync as Yo}from"fs";import{join as F,dirname as Zo}from"path";import{fileURLToPath as Fo}from"url";import{spawn as Ho}from"child_process";import{createRequire as Go}from"module";import A from"chalk";import Wo from"ora";function Xo(e){return Jo.some(o=>o.test(e))}async function Me(e,o,t=null){let s=[];se(o)||await Oe(o,{recursive:!0});for(let r of jo(e)){if(Xo(r))continue;let a=F(e,r),c=F(o,r),m=Uo(a);if(m.isDirectory()){let p=await Me(a,c,t);for(let l of p)s.push(`${r}/${l}`)}else if(m.isFile()){let p=await Do(a,"utf-8");t&&(p=t(r,p)),await Lo(c,p),s.push(r)}}return s}async function Be(e){if(!e||typeof e!="string")throw new Error("Template name is required");if(/^(git\+|https?:)/.test(e))throw new Error(`Git/URL templates are not yet supported (got "${e}"). For now use a built-in template \u2014 see \`zibby template list\`.`);if(e.startsWith("@")||e.includes("/")||e.startsWith("zibby-template-"))throw new Error(`npm-package templates are not yet supported (got "${e}"). For now use a built-in template \u2014 see \`zibby template list\`.`);let{TemplateFactory:o}=await import("@zibby/workflow-templates");return o.getTemplateFiles(e)}async function Ke(e,o,t={}){let s=t.enableMemory!==!1,{template:r}=await Be(o);se(e)||await Oe(e,{recursive:!0});let a=await Me(r.path,e,(c,m)=>!s&&c==="execute-live.mjs"?m.replace("skills: [SKILLS.BROWSER, SKILLS.MEMORY],","skills: [SKILLS.BROWSER],"):m);return{template:r,copied:a}}async function Ne(e,o,t={}){return Ke(F(e,".zibby"),o,t)}async function Qo(){let{TemplateFactory:e}=await import("@zibby/workflow-templates"),o=e.listTemplates();console.log(""),console.log(A.bold.cyan(" Available templates")),console.log("");for(let t of o){if(console.log(` ${A.cyan(t.name)}`),console.log(` ${A.white(t.displayName)}`),t.description&&console.log(` ${A.gray(t.description)}`),t.features&&t.features.length)for(let r of t.features)console.log(A.gray(` \u2022 ${r}`));let s=t.defaultSlug||"your-workflow-name";console.log(""),console.log(` ${A.gray("Scaffold:")} ${A.cyan(`zibby workflow new ${s} -t ${t.name}`)}`),console.log("")}}async function et(e,o={}){e||(console.log(A.red(`
|
|
2
2
|
Missing template name.
|
|
3
|
-
`)),console.log(
|
|
4
|
-
`)),process.exit(1));let t=o.cwd||process.cwd(),
|
|
3
|
+
`)),console.log(A.gray(" Usage: zibby template add <name>")),console.log(A.gray(` See available templates: zibby template list
|
|
4
|
+
`)),process.exit(1));let t=o.cwd||process.cwd(),s=F(t,".zibby");se(s)||(console.log(A.yellow(`
|
|
5
5
|
No .zibby/ directory in ${t}.
|
|
6
|
-
`)),console.log(
|
|
7
|
-
${
|
|
8
|
-
`)),console.log(
|
|
9
|
-
`)),process.exit(1)}console.log(""),console.log(
|
|
10
|
-
`);return
|
|
6
|
+
`)),console.log(A.gray(" Run `zibby init` first to bootstrap the project.\n")),process.exit(1));let r;try{r=await Ne(t,e,{enableMemory:o.enableMemory!==!1})}catch(a){console.log(A.red(`
|
|
7
|
+
${a.message}
|
|
8
|
+
`)),console.log(A.gray(` See available templates: zibby template list
|
|
9
|
+
`)),process.exit(1)}console.log(""),console.log(A.green(` \u2713 Added template ${A.bold(r.template.name)}`)),console.log(A.gray(` ${r.copied.length} files written to ${s}/`));for(let a of r.copied)console.log(A.gray(` \u2022 ${a}`));if(!o.skipInstall&&se(F(t,"package.json"))){let a=!1;try{Go(F(t,"package.json")).resolve("@zibby/core/package.json"),a=!0}catch{}if(!a){let m=`@zibby/core@${JSON.parse(Yo(F(qo,"../../package.json"),"utf-8")).dependencies?.["@zibby/core"]||"latest"}`,p=Wo(` Installing ${m} (needed by .zibby/graph.mjs)...`).start();await new Promise(w=>{Ho("npm",["install","--save-dev",m],{cwd:t,stdio:"pipe"}).on("close",I=>w(I??1))})===0?p.succeed(` Installed ${m}`):(p.warn(` Could not auto-install ${m}`),console.log(A.gray(` Run manually: npm install --save-dev ${m}`)))}}console.log(""),console.log(A.gray(" Re-running `zibby template add <name>` overwrites existing files \u2014")),console.log(A.gray(" use this to refresh after `npm update @zibby/core`.")),console.log("")}var Vo,qo,Jo,De=N(()=>{Vo=Fo(import.meta.url),qo=Zo(Vo),Jo=[/^__tests__$/,/^__mocks__$/,/^node_modules$/,/\.test\.[mc]?js$/,/\.spec\.[mc]?js$/,/^\.DS_Store$/,/^chat\.mjs$/]});var je={};L(je,{BLOCK_REGEX:()=>me,upsertManagedBlock:()=>ot});function ot(e,o){if(typeof o!="string")throw new TypeError("blockContent must be a string");if(e==null)return{content:o,action:"created"};if(me.test(e)){let s=e.replace(me,o.trimEnd()+`
|
|
10
|
+
`);return s===e?{content:e,action:"skipped"}:{content:s,action:"updated"}}let t=e.endsWith(`
|
|
11
11
|
`)?`
|
|
12
12
|
`:`
|
|
13
13
|
|
|
14
|
-
`;return{content:e+t+o,action:"updated"}}var
|
|
14
|
+
`;return{content:e+t+o,action:"updated"}}var me,Ue=N(()=>{me=/<!--\s*BEGIN ZIBBY[^>]*-->[\s\S]*?<!--\s*END ZIBBY[^>]*-->\s*/i});var Fe={};L(Fe,{applyMemorySyncConfig:()=>rt,validateMemorySyncConfig:()=>Ze});function Ze(e){if(!e||typeof e!="object")return{ok:!0,kind:"noop"};let o=e.remote;return tt.includes(o)?{ok:!0,kind:"noop"}:typeof o!="string"?{ok:!1,error:`memorySync.remote must be null or a string, got ${typeof o}`}:o===nt?{ok:!0,kind:"hosted"}:Ye.some(t=>o.startsWith(t))?{ok:!0,kind:"byo",remote:o}:{ok:!1,error:`memorySync.remote = ${JSON.stringify(o)} is not recognized. Use null, 'hosted', or a URL beginning with one of: ${Ye.join(" / ")}.`}}async function rt({cwd:e,projectId:o,block:t,memoryApi:s,hostedSetup:r,getSessionToken:a,logger:c=console}){let m=Ze(t);if(!m.ok)return c.warn?.(`[memory-sync] config invalid: ${m.error}`),{action:"error",reason:m.error};if(m.kind==="noop")return{action:"skipped",reason:"memorySync.remote not set"};if(m.kind==="byo")return s?.memoryRemoteAdd?s.memoryRemoteAdd(e,m.remote)?{action:"byo",remote:m.remote}:{action:"error",reason:"memoryRemoteAdd returned false (memory DB not initialized?)"}:{action:"error",reason:"@zibby/ui-memory not loaded"};if(m.kind==="hosted"){if(typeof a=="function"&&!a())return{action:"pending-login",reason:'memorySync.remote = "hosted" but the user is not logged in. Run `zibby login` then `zibby memory remote use --hosted`.'};if(typeof r!="function")return{action:"error",reason:"hostedSetup function not provided"};try{return await r({cwd:e,projectId:o}),{action:"hosted"}}catch(p){return{action:"error",reason:`hosted setup failed: ${p.message}`}}}return{action:"error",reason:`unhandled kind: ${m.kind}`}}var tt,nt,Ye,He=N(()=>{tt=[null,void 0,"","none","off",!1],nt="hosted",Ye=["aws://","gs://","https://","http://","file://"]});var ge={};L(ge,{clearSession:()=>to,default:()=>dt,getMem0ProxyUrl:()=>so,getProjects:()=>ao,getProxyUrl:()=>no,getSessionToken:()=>pe,getUserInfo:()=>Qe,isLoggedIn:()=>oo,loadConfig:()=>E,saveConfig:()=>D,saveMem0ProxyUrl:()=>io,saveProjects:()=>lo,saveProxyUrl:()=>ro,saveSessionToken:()=>Xe,saveUserInfo:()=>eo});import{existsSync as Ge,mkdirSync as st,readFileSync as it,writeFileSync as at}from"fs";import{homedir as We}from"os";import{join as ie}from"path";function Ve(){return process.env.ZIBBY_CONFIG_DIR||ie(We(),".zibby")}function qe(){return ie(Ve(),"config.json")}function ct(){let e=Ve();Ge(e)||st(e,{recursive:!0})}function E(){try{let e=qe();if(Ge(e)){let o=it(e,"utf-8");return JSON.parse(o)}}catch{}return{}}function D(e){ct(),at(qe(),JSON.stringify(e,null,2))}function pe(){return E().sessionToken||null}function Xe(e){let o=E();o.sessionToken=e,D(o)}function Qe(){return E().user||null}function eo(e){let o=E();o.user=e,D(o)}function oo(){return pe()!==null}function to(){let e=E();delete e.sessionToken,delete e.user,delete e.mem0ProxyUrl,D(e)}function no(){return E().proxyUrl||null}function ro(e){let o=E();o.proxyUrl=e,D(o)}function so(){return E().mem0ProxyUrl||null}function io(e){let o=E();o.mem0ProxyUrl=e,D(o)}function ao(){return E().projects||[]}function lo(e){let o=E();o.projects=e,D(o)}var Je,lt,dt,fe=N(()=>{Je=ie(We(),".zibby"),lt=ie(Je,"config.json");dt={loadConfig:E,saveConfig:D,getSessionToken:pe,saveSessionToken:Xe,getUserInfo:Qe,saveUserInfo:eo,isLoggedIn:oo,clearSession:to,getProxyUrl:no,saveProxyUrl:ro,getMem0ProxyUrl:so,saveMem0ProxyUrl:io,getProjects:ao,saveProjects:lo,CONFIG_DIR:Je,CONFIG_FILE:lt}});var co={};L(co,{ENVIRONMENTS:()=>$,getAccountApiUrl:()=>mt,getApiUrl:()=>ut,getCurrentEnvironment:()=>pt,getFrontendUrl:()=>gt});function ut(){let e;if(process.env.ZIBBY_API_URL)e=process.env.ZIBBY_API_URL;else{let o=process.env.ZIBBY_ENV||"prod";$[o]?e=$[o].apiUrl:e=$.prod.apiUrl}try{let o=new URL(e);return o.protocol!=="http:"&&o.protocol!=="https:"?(console.error(`\u26A0\uFE0F Invalid API URL protocol: ${o.protocol} (only http/https allowed)`),$.prod.apiUrl):e}catch{return console.error(`\u26A0\uFE0F Invalid API URL: ${e}`),$.prod.apiUrl}}function mt(){if(process.env.ZIBBY_ACCOUNT_API_URL)return process.env.ZIBBY_ACCOUNT_API_URL;let e=process.env.ZIBBY_ENV||"prod";return($[e]||$.prod).accountApiUrl}function pt(){let e=process.env.ZIBBY_ENV||"prod";return $[e]||$.prod}function gt(){let e;if(process.env.ZIBBY_FRONTEND_URL)e=process.env.ZIBBY_FRONTEND_URL;else{let o=process.env.ZIBBY_ENV||"prod";$[o]?e=$[o].frontendUrl:e=$.prod.frontendUrl}try{let o=new URL(e);if(o.protocol!=="http:"&&o.protocol!=="https:")return console.error(`\u26A0\uFE0F Invalid frontend URL protocol: ${o.protocol} (only http/https allowed)`),$.local.frontendUrl;if(process.env.NODE_ENV==="production"||process.env.ZIBBY_ENV==="prod"){let s=["zibby.dev","studio.zibby.dev","studio-staging.zibby.dev","zibby.app","studio.zibby.app","studio-staging.zibby.app"],r=o.hostname;if(!s.some(c=>r===c||r.endsWith(`.${c}`))&&!r.includes("localhost")&&r!=="127.0.0.1")return console.error(`\u26A0\uFE0F Untrusted frontend URL in production: ${r}`),"https://studio.zibby.dev"}return e}catch{return console.error(`\u26A0\uFE0F Invalid frontend URL: ${e}`),$.local.frontendUrl}}var $,uo=N(()=>{$={local:{name:"Local Development",apiUrl:"http://localhost:3001",accountApiUrl:"http://localhost:3001",frontendUrl:"http://localhost:3000",description:"Local backend running on port 3001"},prod:{name:"Production",apiUrl:process.env.ZIBBY_PROD_API_URL||"https://api-prod.zibby.app",accountApiUrl:process.env.ZIBBY_PROD_ACCOUNT_API_URL||"https://api-prod.zibby.app",frontendUrl:process.env.ZIBBY_PROD_FRONTEND_URL||"https://studio.zibby.dev",description:"Production environment"}}});var ke={};L(ke,{__testing:()=>It,buildDoltEnv:()=>kt,clearConfig:()=>vt,getActiveCredentials:()=>bo,isHosted:()=>bt,readConfig:()=>we,refreshCredentials:()=>ho,writeConfig:()=>wt});import{readFileSync as mo,writeFileSync as he,existsSync as be,mkdirSync as po,chmodSync as ft}from"fs";import{join as ye}from"path";function V(e){let o=ye(e,".zibby");return{dir:o,config:ye(o,yt),creds:ye(o,ht)}}function we(e){let{config:o}=V(e);if(!be(o))return null;try{let t=JSON.parse(mo(o,"utf-8"));return t.mode!=="hosted"?null:t}catch{return null}}function bt(e){return!!we(e)}function wt(e,o){let{dir:t,config:s}=V(e);po(t,{recursive:!0}),he(s,JSON.stringify({mode:"hosted",projectId:o.projectId,bucket:o.bucket,prefix:o.prefix,doltUrl:o.doltUrl,configuredAt:new Date().toISOString()},null,2),"utf-8")}function vt(e){let{config:o,creds:t}=V(e);for(let s of[o,t])if(be(s))try{he(s,"")}catch{}}function ve(e){let{creds:o}=V(e);if(!be(o))return null;try{let t=JSON.parse(mo(o,"utf-8"));return!t?.accessKeyId||!t?.secretAccessKey||!t?.sessionToken?null:t}catch{return null}}function fo(e,o){let{dir:t,creds:s}=V(e);po(t,{recursive:!0}),he(s,JSON.stringify(o,null,2),"utf-8");try{ft(s,384)}catch{}}function yo(e){return e?.expiration?new Date(e.expiration).getTime()-Date.now()<go:!0}async function ho({cwd:e,projectId:o,apiUrl:t,sessionToken:s,fetch:r=globalThis.fetch}){if(!o)throw new Error("refreshCredentials: projectId required");if(!t)throw new Error("refreshCredentials: apiUrl required");if(!s)throw new Error("refreshCredentials: sessionToken required (run `zibby login`)");let a=`${String(t).replace(/\/+$/,"")}/memory/sync-credentials`,c=await r(a,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify({projectId:o})});if(!c.ok){let p=await c.text().catch(()=>"");throw new Error(`memory-sync credentials request failed (${c.status}): ${p||"no body"}`)}let m=await c.json();if(!m?.accessKeyId||!m?.secretAccessKey||!m?.sessionToken)throw new Error("memory-sync credentials response missing required fields");return fo(e,{accessKeyId:m.accessKeyId,secretAccessKey:m.secretAccessKey,sessionToken:m.sessionToken,expiration:m.expiration||null,refreshedAt:new Date().toISOString()}),ve(e)}async function bo({cwd:e,apiUrl:o,sessionToken:t,fetch:s}){let r=we(e);if(!r)return null;let a=ve(e);return(!a||yo(a))&&(a=await ho({cwd:e,projectId:r.projectId,apiUrl:o,sessionToken:t,fetch:s})),a}async function kt({cwd:e,apiUrl:o,sessionToken:t,fetch:s}){let r=await bo({cwd:e,apiUrl:o,sessionToken:t,fetch:s});return r?{AWS_ACCESS_KEY_ID:r.accessKeyId,AWS_SECRET_ACCESS_KEY:r.secretAccessKey,AWS_SESSION_TOKEN:r.sessionToken,AWS_REGION:process.env.AWS_REGION||"ap-southeast-2"}:null}var yt,ht,go,It,Ie=N(()=>{yt="memory-sync.json",ht="memory-sync-creds.json",go=120*1e3;It={paths:V,readCreds:ve,writeCreds:fo,isExpiringSoon:yo,REFRESH_HEADROOM_MS:go}});var wo={};L(wo,{memoryCompactCommand:()=>Ct,memoryCostCommand:()=>Pt,memoryInitCommand:()=>Ot,memoryPullCommand:()=>Rt,memoryPushCommand:()=>Tt,memoryRemoteAddCommand:()=>$t,memoryRemoteInfoCommand:()=>St,memoryRemoteRemoveCommand:()=>Et,memoryRemoteUseHostedCommand:()=>zt,memoryResetCommand:()=>xt,memoryStatsCommand:()=>_t});import n from"chalk";async function O(){try{return await import("@zibby/ui-memory")}catch{return console.log(n.yellow(`
|
|
15
15
|
@zibby/ui-memory is not installed.
|
|
16
|
-
`)),console.log(
|
|
16
|
+
`)),console.log(n.white(At)),null}}async function _t(){let e=await O();if(!e)return;let o=process.cwd(),t=e.getStats(o);if(!t.available){console.log(n.red(`
|
|
17
17
|
Dolt is not installed.
|
|
18
|
-
`)),console.log(
|
|
19
|
-
`));return}if(!t.initialized){console.log(
|
|
18
|
+
`)),console.log(n.white(" Install Dolt to enable test memory:")),console.log(n.gray(" brew install dolt # macOS")),console.log(n.gray(` curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash # Linux
|
|
19
|
+
`));return}if(!t.initialized){console.log(n.yellow(`
|
|
20
20
|
Memory database not initialized.
|
|
21
|
-
`)),console.log(
|
|
21
|
+
`)),console.log(n.white(" Run `zibby init` or `zibby memory init` to set it up.\n"));return}console.log(n.bold.cyan(`
|
|
22
22
|
Zibby Test Memory
|
|
23
|
-
`)),console.log(
|
|
24
|
-
${
|
|
25
|
-
${
|
|
26
|
-
${
|
|
27
|
-
`).filter(
|
|
23
|
+
`)),console.log(n.gray(` Dolt: ${t.doltVersion}`));let s=n.gray(` ${"\u2500".repeat(40)}`);console.log(s);let r=t.counts;if(console.log(n.white(` Test runs: ${n.cyan(r.runs)} (${n.green(`${r.passed} passed`)}, ${r.failed>0?n.red(`${r.failed} failed`):n.gray(`${r.failed} failed`)})`)),console.log(n.white(` Selectors: ${n.cyan(r.selectors)} tracked`)),console.log(n.white(` Pages: ${n.cyan(r.pages)} discovered`)),console.log(n.white(` Transitions: ${n.cyan(r.transitions)} mapped`)),console.log(n.white(` Insights: ${n.cyan(r.insights||0)} saved`)),t.recentRuns.length>0){console.log(`
|
|
24
|
+
${s}`),console.log(n.white(" Recent runs:"));for(let a of t.recentRuns){let c=a.passed?n.green("\u2713"):n.red("\u2717"),m=a.duration_ms?n.gray(`${(a.duration_ms/1e3).toFixed(1)}s`):"";console.log(` ${c} ${n.white(a.spec_path)} ${m}`)}}if(t.topSelectors.length>0){console.log(`
|
|
25
|
+
${s}`),console.log(n.white(" Top selectors:"));for(let a of t.topSelectors){let c=a.success_count+a.failure_count,m=Math.round(a.success_count/c*100);console.log(` ${n.cyan(a.stable_id||"?")} \u2192 ${a.element_desc} (${m}%, ${c} uses)`)}}if(t.log){console.log(`
|
|
26
|
+
${s}`),console.log(n.white(" Recent commits:"));let a=t.log.split(`
|
|
27
|
+
`).filter(c=>c.startsWith("commit")||c.trim().startsWith("run ")).slice(0,10);for(let c of a)console.log(n.gray(` ${c.trim()}`))}console.log("")}async function xt(e){let o=await O();if(!o)return;let t=process.cwd();if(!e.force){console.log(n.yellow(`
|
|
28
28
|
This will permanently delete the memory database.
|
|
29
|
-
`)),console.log(
|
|
30
|
-
`));return}let
|
|
29
|
+
`)),console.log(n.white(` Run with --force to confirm: zibby memory reset --force
|
|
30
|
+
`));return}let s=o.resetMemory(t);console.log(s?n.green(`
|
|
31
31
|
Memory database reset.
|
|
32
|
-
`):
|
|
32
|
+
`):n.gray(`
|
|
33
33
|
No memory database found.
|
|
34
|
-
`))}async function
|
|
34
|
+
`))}async function Ct(e){let o=await O();if(!o)return;let t=process.cwd(),s=o.getStats(t);if(!s.initialized){console.log(n.yellow(`
|
|
35
35
|
Memory database not initialized.
|
|
36
|
-
`));return}let
|
|
37
|
-
Compacting memory (keep last ${
|
|
38
|
-
`))}else console.log(
|
|
39
|
-
`))}async function
|
|
36
|
+
`));return}let r=e.maxRuns||50,a=e.maxAge||90;console.log(n.white(`
|
|
37
|
+
Compacting memory (keep last ${r} runs/spec, prune data older than ${a}d)...`));let c=s.counts;if(o.compactMemory(t,{maxRuns:r,maxAgeDays:a}).pruned){let p=o.getStats(t).counts,l=w=>c[w]-p[w];console.log(n.green(" Done.")),l("runs")>0&&console.log(n.gray(` Pruned ${l("runs")} old runs`)),l("selectors")>0&&console.log(n.gray(` Pruned ${l("selectors")} stale selectors`)),l("insights")>0&&console.log(n.gray(` Pruned ${l("insights")} old insights`)),l("transitions")>0&&console.log(n.gray(` Pruned ${l("transitions")} stale transitions`)),console.log(n.gray(` Dolt GC completed
|
|
38
|
+
`))}else console.log(n.gray(` Nothing to compact.
|
|
39
|
+
`))}async function Pt(){let e=await O();if(!e)return;let o=process.cwd(),t=e.getCostStats(o);if(!t){console.log(n.yellow(`
|
|
40
40
|
Memory database not initialized.
|
|
41
|
-
`)),console.log(
|
|
41
|
+
`)),console.log(n.white(" Run `zibby memory init` first.\n"));return}if(t.available===!1){console.log(n.yellow(`
|
|
42
42
|
No usage data yet${t.reason?` (${t.reason})`:""}.
|
|
43
|
-
`)),console.log(
|
|
44
|
-
`));return}console.log(
|
|
43
|
+
`)),console.log(n.gray(" Run `zibby test <spec>` once to populate. Token counts come from")),console.log(n.gray(` the LLM SDK and are written to .zibby/output/sessions/<id>/execute_live/usage.json.
|
|
44
|
+
`));return}console.log(n.bold.cyan(`
|
|
45
45
|
Zibby \u2014 LLM Cost Report
|
|
46
|
-
`));let
|
|
47
|
-
${
|
|
48
|
-
${
|
|
49
|
-
${
|
|
46
|
+
`));let s=n.gray(` ${"\u2500".repeat(60)}`),r=t.totals;if(console.log(s),console.log(n.white(` Runs with usage data: ${n.cyan(r.runs)}`)),console.log(n.white(` Total input tokens: ${n.cyan(j(r.input))}`)),console.log(n.white(` Total output tokens: ${n.cyan(j(r.output))}`)),console.log(n.white(` Total cache reads: ${n.cyan(j(r.cache_read))} ${n.gray("(billed at ~10% of normal input rate)")}`)),console.log(n.white(` Total cache creation: ${n.cyan(j(r.cache_creation))} ${n.gray("(billed at ~125% of normal input rate)")}`)),t.by_domain.length>0){console.log(`
|
|
47
|
+
${s}`),console.log(n.white(" By domain:"));for(let a of t.by_domain.slice(0,10)){let c=a.runs>0?Math.round((a.input+a.output)/a.runs):0;console.log(` ${n.cyan(a.domain.padEnd(30))} ${n.gray(`${a.runs} runs \xB7 ~${j(c)}/run avg`)}`)}}if(t.by_spec.length>0){console.log(`
|
|
48
|
+
${s}`),console.log(n.white(" By spec:"));for(let a of t.by_spec.slice(0,10)){let c=a.runs>0?Math.round((a.input+a.output)/a.runs):0;console.log(` ${n.cyan(String(a.spec_path).padEnd(40))} ${n.gray(`${a.runs} runs \xB7 ~${j(c)}/run avg`)}`)}}if(t.recent.length>0){console.log(`
|
|
49
|
+
${s}`),console.log(n.white(" Last 10 runs:"));for(let a of t.recent.slice(0,10)){let c=a.passed?n.green("\u2713"):n.red("\u2717"),m=(a.input_tokens||0)+(a.output_tokens||0),p=(a.cache_read_tokens||0)>0?n.gray(` \xB7 cache read ${j(a.cache_read_tokens)}`):"";console.log(` ${c} ${n.gray(a.run_at.slice(0,16))} ${n.cyan(j(m).padStart(8))} ${n.white(a.spec_path||"")}${p}`)}}console.log("")}function j(e){return e==null?"\u2014":e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}K`:`${(e/1e6).toFixed(2)}M`}async function $t(e,o={}){let t=await O();if(!t)return;e||(console.log(n.red(`
|
|
50
50
|
Usage: zibby memory remote add <url> [--name origin]
|
|
51
|
-
`)),console.log(
|
|
52
|
-
`)),console.log(
|
|
53
|
-
`));return}console.log(
|
|
54
|
-
Pulling team memory from remote...`));let o=e.memorySyncPull(process.cwd());o.pulled?console.log(
|
|
55
|
-
`)):(console.log(
|
|
51
|
+
`)),console.log(n.gray(" Supported: aws:// gs:// https:// file:///")),console.log(n.gray(" Example: zibby memory remote add aws://team-bucket/zibby/shop-prod")),console.log(""),process.exit(1));let s=process.cwd(),r=o.name||"origin";if(!t.memoryRemoteAdd(s,e,r)){console.log(n.red("\n Failed to add remote. Is the memory DB initialized? Run `zibby memory init` first.\n"));return}console.log(""),console.log(n.green(` \u2713 Added remote ${n.bold(r)} \u2192 ${e}`)),console.log(n.gray(" Next step: zibby memory pull (or just run any test \u2014 middleware auto-pulls/pushes)")),console.log("")}async function St(){let e=await O();if(!e)return;let o=e.memoryRemoteInfo(process.cwd());if(console.log(""),!o){console.log(n.yellow(` No memory remote configured.
|
|
52
|
+
`)),console.log(n.gray(" Set one with: zibby memory remote add <url>")),console.log(n.gray(` Without a remote, memory is local-only \u2014 team members won't see each other's learnings.
|
|
53
|
+
`));return}console.log(n.bold.cyan(" Memory remote")),console.log(` ${n.cyan(o.name||"origin")}: ${o.url||"(unknown)"}`),console.log("")}async function Et(e="origin"){let o=await O();if(!o)return;let t=o.memoryRemoteRemove(process.cwd(),e);console.log(""),t?(console.log(n.green(` \u2713 Removed remote ${e}.`)),console.log(n.gray(" Memory is now local-only."))):console.log(n.gray(` No remote named ${e} to remove.`)),console.log("")}async function Rt(){let e=await O();if(!e)return;console.log(n.cyan(`
|
|
54
|
+
Pulling team memory from remote...`));let o=e.memorySyncPull(process.cwd());o.pulled?console.log(n.green(` \u2713 Pulled latest. Local memory now reflects the team's shared knowledge.
|
|
55
|
+
`)):(console.log(n.yellow(` \u26A0 Pull skipped \u2014 ${o.error||"unknown reason"}.`)),console.log(n.gray(" Did you run `zibby memory remote add <url>` first?\n")))}async function zt(e={}){let o=await O();if(!o)return;let{join:t}=await import("path"),{existsSync:s}=await import("fs"),r=e.cwd||process.cwd(),a=e.projectId;if(!a){let k=t(r,".zibby.config.mjs");if(s(k))try{let T=(await import(`file://${k}?t=${Date.now()}`)).default;a=T?.projectId||T?.project?.id}catch{}}a||(console.log(n.red(`
|
|
56
56
|
Could not determine projectId.
|
|
57
|
-
`)),console.log(
|
|
58
|
-
`)),process.exit(1));let{getApiUrl:
|
|
59
|
-
`)),process.exit(1)),console.log(
|
|
60
|
-
Configuring hosted memory-sync...`));let
|
|
61
|
-
Failed: ${
|
|
62
|
-
`)),process.exit(1)}let{writeConfig:
|
|
63
|
-
Saved hosted-sync config, but failed to register Dolt remote.`)),console.log(
|
|
64
|
-
Config saved, but initial credential fetch failed: ${
|
|
65
|
-
`))}console.log(""),console.log(
|
|
66
|
-
Pushing local memory to team remote...`));let o=e.memorySyncPush(process.cwd());o.pushed?console.log(
|
|
67
|
-
`))}async function
|
|
57
|
+
`)),console.log(n.gray(" Either run this from a project dir with `.zibby.config.mjs`")),console.log(n.gray(` containing { projectId: "..." }, or pass --project-id <id>.
|
|
58
|
+
`)),process.exit(1));let{getApiUrl:c}=await Promise.resolve().then(()=>(uo(),co)),{getSessionToken:m}=await Promise.resolve().then(()=>(fe(),ge)),p=c(),l=m();l||(console.log(n.red("\n Not logged in. Run `zibby login` first.\n")),console.log(n.gray(" Hosted memory-sync is for signed-in users only \u2014")),console.log(n.gray(` the backend needs your identity to scope per-tenant credentials.
|
|
59
|
+
`)),process.exit(1)),console.log(n.cyan(`
|
|
60
|
+
Configuring hosted memory-sync...`));let w;try{let k=`${p.replace(/\/+$/,"")}/memory/sync-config?projectId=${encodeURIComponent(a)}`,z=await fetch(k,{headers:{Authorization:`Bearer ${l}`}});if(!z.ok){let T=await z.text().catch(()=>"");throw new Error(`backend returned ${z.status}: ${T||"no body"}`)}w=await z.json()}catch(k){console.log(n.red(`
|
|
61
|
+
Failed: ${k.message}
|
|
62
|
+
`)),process.exit(1)}let{writeConfig:_}=await Promise.resolve().then(()=>(Ie(),ke));_(r,{projectId:a,bucket:w.bucket,prefix:w.prefix,doltUrl:w.doltUrl}),o.memoryRemoteAdd(r,w.doltUrl)||(console.log(n.yellow(`
|
|
63
|
+
Saved hosted-sync config, but failed to register Dolt remote.`)),console.log(n.gray(" Try `zibby memory init` first (the local Dolt DB must exist).\n")),process.exit(1));let{refreshCredentials:I}=await Promise.resolve().then(()=>(Ie(),ke));try{await I({cwd:r,projectId:a,apiUrl:p,sessionToken:l})}catch(k){console.log(n.yellow(`
|
|
64
|
+
Config saved, but initial credential fetch failed: ${k.message}`)),console.log(n.gray(` Will retry on first push/pull.
|
|
65
|
+
`))}console.log(""),console.log(n.green(" \u2713 Hosted memory-sync configured.")),console.log(n.gray(` Bucket: ${w.bucket}`)),console.log(n.gray(` Prefix: ${w.prefix} \u2190 your tenant slot`)),console.log(n.gray(` Dolt: ${w.doltUrl}`)),console.log(""),console.log(n.gray(" Every test run will auto-pull/push. Creds refresh automatically.")),console.log(n.gray(" To revert to local-only: zibby memory remote remove origin")),console.log("")}async function Tt(){let e=await O();if(!e)return;console.log(n.cyan(`
|
|
66
|
+
Pushing local memory to team remote...`));let o=e.memorySyncPush(process.cwd());o.pushed?console.log(n.green(" \u2713 Pushed. Team can now `zibby memory pull` to see your run's learnings.\n")):console.log(n.yellow(` \u26A0 Push skipped \u2014 ${o.error||"unknown reason"}.
|
|
67
|
+
`))}async function Ot(){let e=await O();if(!e)return;let o=process.cwd();if(!e.DoltDB.isAvailable()){console.log(n.red(`
|
|
68
68
|
Dolt is not installed.
|
|
69
|
-
`)),console.log(
|
|
70
|
-
`));return}let{created:t,available:
|
|
69
|
+
`)),console.log(n.white(" Install Dolt:")),console.log(n.gray(" brew install dolt # macOS")),console.log(n.gray(` curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash # Linux
|
|
70
|
+
`));return}let{created:t,available:s}=e.initMemory(o);t?console.log(n.green(`
|
|
71
71
|
Memory database initialized at .zibby/memory/
|
|
72
|
-
`)):
|
|
72
|
+
`)):s&&console.log(n.gray(`
|
|
73
73
|
Memory database already initialized.
|
|
74
|
-
`))}var
|
|
74
|
+
`))}var At,vo=N(()=>{At=`
|
|
75
75
|
Install @zibby/ui-memory and Dolt to enable test memory:
|
|
76
76
|
|
|
77
77
|
npm install @zibby/ui-memory # add the package
|
|
78
78
|
brew install dolt # macOS
|
|
79
79
|
# or: curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash
|
|
80
|
-
`});var
|
|
81
|
-
`,"utf-8")}async function
|
|
82
|
-
`).find(
|
|
83
|
-
`,"utf-8"),
|
|
80
|
+
`});var Eo={};L(Eo,{setupCiCommand:()=>Ft,setupPlaywrightMcpCommand:()=>So,testWithVideoCommand:()=>Ht});import{spawn as _e,execSync as xe}from"child_process";import{join as H,dirname as Ce,resolve as Ao}from"path";import{readFileSync as _o,writeFileSync as xo,existsSync as q,mkdirSync as Co}from"fs";import{homedir as Po}from"os";import{createRequire as Mt}from"module";import C from"chalk";function Bt(){try{return Ce(Ae.resolve("@zibby/core/package.json"))}catch{return null}}function $o(e){try{return xe(`command -v ${e}`,{stdio:"pipe"}),!0}catch{return!1}}function Kt(){try{let e=Ae.resolve("@zibby/mcp-browser/dist/bin/mcp-browser-zibby.js");if(q(e))return e}catch{}try{let e=Ae.resolve("@playwright/mcp/package.json"),o=Ce(e),t=JSON.parse(_o(e,"utf-8")),s=typeof t.bin=="string"?t.bin:t.bin?.["playwright-mcp"];if(s){let a=H(o,s);if(q(a))return a}let r=H(o,"cli.js");if(q(r))return r}catch{}return null}function ko(e,o,t={}){return new Promise((s,r)=>{let a=_e(e,o,{stdio:"inherit",...t});a.on("close",c=>s(c??1)),a.on("error",r)})}async function Nt(e){return $o("playwright")?await ko("playwright",["install","ffmpeg"],{cwd:e})===0:await ko("npx",["--yes","playwright","install","ffmpeg"],{cwd:e})===0}function Lt({headed:e=!1,viewport:o=null}){let t=process.execPath,s=Ce(t),r=Kt(),a=Number(o?.width)||1280,c=Number(o?.height)||720,m=`${a}x${c}`,p=[];p.push(`--viewport-size=${m}`,"--output-dir=test-results"),e||p.push("--headless");let l;r?l={command:t,args:[r,...p],env:{PATH:`${s}:/usr/bin:/bin:/usr/sbin:/sbin`}}:l={command:"npx",args:["-y","@playwright/mcp",...p],env:{PATH:`${s}:/usr/bin:/bin:/usr/sbin:/sbin`}},l.description="Zibby MCP Browser - Playwright MCP with Zibby defaults";let w=H(Po(),".cursor"),_=H(w,"mcp.json");q(w)||Co(w,{recursive:!0});let I={mcpServers:{}};if(q(_))try{I=JSON.parse(_o(_,"utf-8")),(!I.mcpServers||typeof I.mcpServers!="object")&&(I.mcpServers={})}catch{I={mcpServers:{}}}I.mcpServers["playwright-official"]=l,xo(_,`${JSON.stringify(I,null,2)}
|
|
81
|
+
`,"utf-8")}async function Dt(){let e=Bt();if(!e)return;let o=H(e,"scripts","patch-cursor-mcp.js");if(q(o))try{await new Promise((t,s)=>{let r=_e(process.execPath,[o],{cwd:process.cwd(),stdio:"ignore"});r.on("close",a=>t(a??0)),r.on("error",s)})}catch{}}function jt(e){return Ao(e).replace(/^\/+/,"").replace(/\//g,"-")}function Ut(e){let o=String(e||""),t=o.split(`
|
|
82
|
+
`).find(a=>/playwright-official/i.test(a)&&/APPROVAL|🔑/i.test(a));if(t){let a=t.match(/=>\s*(\S+)/);if(a)return a[1]}let s=o.match(/playwright-official[^=]*=>\s*(\S+)/);if(s)return s[1];let r=o.match(/playwright-official-[a-f0-9]+/i);return r?r[0]:null}function Yt(e,o){let t=jt(e),s=H(Po(),".cursor","projects",t);Co(s,{recursive:!0});let r=H(s,"mcp-approvals.json");return xo(r,`${JSON.stringify([o],null,2)}
|
|
83
|
+
`,"utf-8"),r}function Io(e){try{return xe("cursor-agent mcp list",{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"],env:process.env,maxBuffer:2*1024*1024})}catch(o){let t=o.stdout!=null?String(o.stdout):"",s=o.stderr!=null?String(o.stderr):"";return t+s}}function Zt(e){try{return xe("cursor-agent mcp enable playwright-official",{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"],env:process.env,maxBuffer:1024*1024}),!0}catch{return!1}}async function So(e={}){let o=!!e.headed,t=e.viewport||{width:1280,height:720};if(!process.execPath)throw new Error("Node.js runtime not found");let s=await Nt(process.cwd());console.log(s?C.gray(" \u2713 ffmpeg installed for Playwright video"):C.yellow(" \u26A0 Could not install ffmpeg (video may be unavailable)")),Lt({headed:o,viewport:t}),await Dt();let r=Ao(process.cwd());if($o("cursor-agent")){Io(r);let a=Zt(r);a&&console.log(C.gray(" \u2713 cursor-agent: mcp enable playwright-official"));let c=Io(r),m=Ut(c);if(m)try{let p=Yt(r,m);console.log(C.gray(` \u2713 MCP auto-approval key saved (${p})`))}catch(p){console.log(C.yellow(` \u26A0 Could not write mcp-approvals.json: ${p.message}`))}else a||(console.log(C.yellow(" \u26A0 Could not auto-approve MCP (mcp enable failed and no approval key in cursor-agent output)")),console.log(C.gray(" Try: cursor-agent mcp enable playwright-official")))}else console.log(C.yellow(" \u26A0 cursor-agent not found; install it to use Cursor MCP tools"))}async function Ft(e){try{console.log(C.cyan(`
|
|
84
84
|
\u{1F680} Running CI setup...
|
|
85
|
-
`)),await
|
|
85
|
+
`)),await So({headed:!1,cloudSync:!0,viewport:{width:1280,height:720}}),console.log(C.green(`
|
|
86
86
|
\u2705 CI/CD setup complete!
|
|
87
|
-
`))}catch(o){console.log(
|
|
87
|
+
`))}catch(o){console.log(C.red(`
|
|
88
88
|
\u274C Error: ${o.message}
|
|
89
|
-
`)),process.exit(1)}}async function
|
|
89
|
+
`)),process.exit(1)}}async function Ht(e,o){try{let t=["playwright","test",e||"tests/","--project=chromium"];o.headed&&t.push("--headed"),console.log(C.cyan(`
|
|
90
90
|
\u{1F3A5} Running tests with video recording...
|
|
91
|
-
`)),console.log(
|
|
91
|
+
`)),console.log(C.gray("\u2501".repeat(50)));let s=_e("npx",t,{cwd:process.cwd(),stdio:"inherit"});s.on("close",r=>{r===0?console.log(C.green(`
|
|
92
92
|
\u2705 Tests complete!
|
|
93
|
-
`)):(console.log(
|
|
94
|
-
\u274C Tests failed with code ${
|
|
95
|
-
`)),process.exit(
|
|
96
|
-
\u274C Error: ${
|
|
97
|
-
`)),process.exit(1)})}catch(t){console.log(
|
|
93
|
+
`)):(console.log(C.red(`
|
|
94
|
+
\u274C Tests failed with code ${r}
|
|
95
|
+
`)),process.exit(r))}),s.on("error",r=>{console.log(C.red(`
|
|
96
|
+
\u274C Error: ${r.message}
|
|
97
|
+
`)),process.exit(1)})}catch(t){console.log(C.red(`
|
|
98
98
|
\u274C Error: ${t.message}
|
|
99
|
-
`)),process.exit(1)}}var Ae,
|
|
100
|
-
`,"utf-8")}async function
|
|
101
|
-
`));return}console.log(i.yellow("npm global bin not in PATH")),console.log(i.gray(` Location: ${
|
|
102
|
-
To add manually on Windows:`)),console.log(i.gray(' 1. Search "Environment Variables" in Start menu')),console.log(i.gray(' 2. Edit "Path" in User variables')),console.log(i.gray(` 3. Add: ${
|
|
99
|
+
`)),process.exit(1)}}var Ae,Ro=N(()=>{Ae=Mt(import.meta.url)});import{mkdir as M,writeFile as x,readFile as R}from"fs/promises";import{existsSync as b,readdirSync as ae}from"fs";import{join as g,resolve as Pe,dirname as Gt}from"path";import{homedir as Y}from"os";import G from"inquirer";import i from"chalk";import U from"ora";import{spawn as Q,execSync as le}from"child_process";import{fileURLToPath as Wt}from"url";import{createRequire as Vt}from"module";import{existsSync as Mo,readFileSync as Bo,writeFileSync as Ko,mkdirSync as No}from"fs";import{join as Ee}from"path";import{homedir as Re}from"os";var ne={cursor:{envVar:"CURSOR_API_KEY",label:"Cursor API Key",url:"https://cursor.com/settings"},claude:{envVar:"ANTHROPIC_API_KEY",label:"Anthropic API Key",url:"https://console.anthropic.com/settings/keys"},codex:{envVar:"OPENAI_API_KEY",label:"OpenAI API Key",url:"https://platform.openai.com/api-keys"},gemini:{envVar:"GEMINI_API_KEY",label:"Gemini API Key",url:"https://aistudio.google.com/app/apikey"}};function ze(){return Ee(Re(),".zibby","config.json")}function re(){try{let e=ze();return Mo(e)?JSON.parse(Bo(e,"utf-8")):{}}catch{return{}}}function Te(e,o){let t=o?ne[o]:null;t&&ue(t.envVar,e)}function ue(e,o){if(!e||typeof e!="string"||!o||typeof o!="string")return;let t=Ee(Re(),".zibby");No(t,{recursive:!0});let s=ze(),r=re();(!r.agentKeys||typeof r.agentKeys!="object")&&(r.agentKeys={}),r.agentKeys[e]=String(o).trim(),delete r.agentApiKey,Ko(s,`${JSON.stringify(r,null,2)}
|
|
100
|
+
`,"utf-8")}async function qt(){let e=re(),o=process.env.ANTHROPIC_API_KEY||e.agentKeys?.ANTHROPIC_API_KEY,t=e.agentKeys?.CLAUDE_CODE_OAUTH_TOKEN||null;console.log(""),console.log(i.cyan(" Claude credentials \u2014 pick the type you have:")),console.log("");let{kind:s}=await G.prompt([{type:"select",name:"kind",message:"Which Claude credential do you want to use?",choices:[{name:t?`OAuth ***${t.slice(-4)} \xB7 Pro/Max plan`:"OAuth \xB7 Pro/Max plan (long-lived token)",value:"oauth"},{name:o?`API key ***${o.slice(-4)} \xB7 pay-per-token`:"API key \xB7 pay-per-token",value:"api"}],default:t?"oauth":o?"api":"oauth"}]);if(s==="skip")return{kind:"skip"};if(s==="oauth"){t||(console.log(""),console.log(i.gray(" How to generate a long-lived OAuth token (cloud-compatible):")),console.log(i.gray(" 1. Install claude (skip if you already have it):")),console.log(i.gray(" npm install -g @anthropic-ai/claude-code")),console.log(i.gray(" 2. Run:")),console.log(i.gray(" claude setup-token")),console.log(i.gray(" \u2192 confirms in your browser \u2192 prints a token starting with sk-ant-oat01-\u2026")),console.log(i.gray(" 3. Paste that token below.")),console.log(""),console.log(i.yellow(" Note: do NOT paste the short-lived token from `claude` browser-login \u2014")),console.log(i.yellow(" it works locally but Anthropic rejects it from non-login IPs (cloud).")),console.log(""));let m=t?`Press Enter to reuse saved token (***${t.slice(-4)}), or paste a new one:`:"Paste OAuth token from `claude setup-token` (or press Enter to skip):",{token:p}=await G.prompt([{type:"password",name:"token",message:m,mask:"*"}]),l=(p||"").trim();return l?{kind:"oauth",token:l}:t?{kind:"oauth",token:t}:{kind:"skip"}}let r=o?`Press Enter to reuse saved API key (***${o.slice(-4)}), or paste a new one:`:"Paste Anthropic API key (from https://console.anthropic.com/settings/keys, or press Enter to skip):",{token:a}=await G.prompt([{type:"password",name:"token",message:r,mask:"*"}]),c=(a||"").trim();return c?{kind:"api",token:c}:o?{kind:"api",token:o}:{kind:"skip"}}var Jt=Wt(import.meta.url),zo=Gt(Jt),Xt=Vt(import.meta.url);async function Qt(){try{let e=process.platform==="win32",o=le("npm config get prefix",{encoding:"utf-8"}).trim(),t=e?o:`${o}/bin`,s=t.replace(/^~/,Y()),r=e?";":":";if(process.env.PATH.split(r).some(_=>{let I=_.replace(/^~/,Y());return I===s||I===t}))return;if(process.env.CI||process.env.ZIBBY_CI||!process.stdin.isTTY){console.log(i.yellow("npm global bin not in PATH")),console.log(i.gray(` Location: ${s}`)),console.log(i.gray(` Add it manually: export PATH="${s}:$PATH"
|
|
101
|
+
`));return}console.log(i.yellow("npm global bin not in PATH")),console.log(i.gray(` Location: ${s}`)),console.log();let{shouldAddPath:m}=await G.prompt([{type:"confirm",name:"shouldAddPath",message:"Add npm global bin to your shell PATH automatically?",default:!0}]);if(!m){e?(console.log(i.gray(`
|
|
102
|
+
To add manually on Windows:`)),console.log(i.gray(' 1. Search "Environment Variables" in Start menu')),console.log(i.gray(' 2. Edit "Path" in User variables')),console.log(i.gray(` 3. Add: ${s}
|
|
103
103
|
`))):(console.log(i.gray(`
|
|
104
|
-
To add manually, run:`)),console.log(i.gray(` echo 'export PATH="${
|
|
105
|
-
`)));return}if(e){console.log(i.yellow("Cannot auto-add PATH on Windows")),console.log(i.gray(" Please add manually:")),console.log(i.gray(' 1. Search "Environment Variables" in Start menu')),console.log(i.gray(' 2. Edit "Path" in User variables')),console.log(i.gray(` 3. Add: ${
|
|
106
|
-
`));return}let
|
|
107
|
-
`));return}}let
|
|
104
|
+
To add manually, run:`)),console.log(i.gray(` echo 'export PATH="${s}:$PATH"' >> ~/.zshrc`)),console.log(i.gray(` source ~/.zshrc
|
|
105
|
+
`)));return}if(e){console.log(i.yellow("Cannot auto-add PATH on Windows")),console.log(i.gray(" Please add manually:")),console.log(i.gray(' 1. Search "Environment Variables" in Start menu')),console.log(i.gray(' 2. Edit "Path" in User variables')),console.log(i.gray(` 3. Add: ${s}
|
|
106
|
+
`));return}let p=process.env.SHELL||"",l="";if(p.includes("zsh"))l=g(Y(),".zshrc");else if(p.includes("bash"))l=b(g(Y(),".bashrc"))?g(Y(),".bashrc"):g(Y(),".bash_profile");else{console.log(i.yellow(`Unknown shell: ${p}`)),console.log(i.gray(" Please add manually:")),console.log(i.gray(` export PATH="${s}:$PATH"`));return}if(b(l)){let _=await R(l,"utf-8");if(_.includes(s)||_.includes("npm")&&_.includes("global")&&_.includes("bin")){console.log(i.yellow(`PATH entry found in ${l} but not active`)),console.log(i.gray(` Run: source ${l}
|
|
107
|
+
`));return}}let w=`
|
|
108
108
|
# npm global bin (added by zibby)
|
|
109
|
-
export PATH="${
|
|
110
|
-
`;await
|
|
111
|
-
Run this to activate in current session:`)),console.log(i.gray(` source ${
|
|
112
|
-
`))}catch{}}async function
|
|
109
|
+
export PATH="${s}:$PATH"
|
|
110
|
+
`;await x(l,(b(l)?await R(l,"utf-8"):"")+w),console.log(i.green(`Added to ${l}`)),console.log(i.yellow(`
|
|
111
|
+
Run this to activate in current session:`)),console.log(i.gray(` source ${l}
|
|
112
|
+
`))}catch{}}async function Hn(e,o){let t=o.template==="browser-test-automation";console.log(t?`
|
|
113
113
|
Zibby Test Automation
|
|
114
114
|
`:`
|
|
115
115
|
Zibby Project Init
|
|
116
|
-
`);let
|
|
116
|
+
`);let s=!o.skipMemory,r=["dolt","mem0"].includes(String(o.memoryBackend||"").toLowerCase())?String(o.memoryBackend).toLowerCase():"dolt",a=o.infer===!0;await Qt();let c=e?Pe(process.cwd(),e):process.cwd(),m=e||"zibby-tests",p=!!e;p&&b(c)&&(console.log(i.red(`
|
|
117
117
|
Directory "${e}" already exists!
|
|
118
|
-
`)),process.exit(1)),!
|
|
118
|
+
`)),process.exit(1)),!p&&b(g(c,".zibby.config.mjs"))&&!o.force&&(console.log(i.yellow(`
|
|
119
119
|
Zibby is already initialized in this directory!
|
|
120
120
|
`)),console.log(i.white("Config file found: .zibby.config.mjs")),console.log(i.gray(`Use --force or -f to reinitialize
|
|
121
|
-
`)),process.exit(0)),o.force&&!
|
|
121
|
+
`)),process.exit(0)),o.force&&!p&&console.log(i.cyan(`
|
|
122
122
|
Reinitializing Zibby configuration...
|
|
123
123
|
`));let l;if(o.agent&&(o.headed||o.headless))console.log(i.cyan(`Setting up with provided options...
|
|
124
|
-
`)),l={agent:o.agent,browserMode:o.headless?"headless":"headed",apiKey:o.apiKey||null,cloudSync:!!(o.cloudSync||o.apiKey)};else{if(o.agent)l={agent:o.agent};else{let{agent:
|
|
124
|
+
`)),l={agent:o.agent,browserMode:o.headless?"headless":"headed",apiKey:o.apiKey||null,cloudSync:!!(o.cloudSync||o.apiKey)};else{if(o.agent)l={agent:o.agent};else{let{agent:P}=await G.prompt([{type:"select",name:"agent",message:"Which AI agent do you prefer?",choices:[{name:"Claude (Anthropic)",value:"claude"},{name:"Cursor",value:"cursor"},{name:"Codex (OpenAI)",value:"codex"},{name:"Gemini (Google)",value:"gemini"}],default:"claude"}]);l={agent:P}}let k=ne[l.agent],z=!(process.env.CI||process.env.ZIBBY_CI||!process.stdin.isTTY);if(l.agent==="claude"&&!o.agentKey&&z){let P=await qt();P?.kind==="oauth"&&P.token?(l.claudeOauthToken=P.token,l.agentAuth="oauth"):P?.kind==="api"&&P.token&&(l.agentKey=P.token,l.agentAuth="api")}else if(k&&!o.agentKey&&z){let P=re(),W=process.env[k.envVar]||P.agentKeys?.[k.envVar],Z=W?`***${W.slice(-4)}`:null,ee=Z?`${k.label} found (${Z}). Press Enter to keep, or paste a new key:`:`Enter ${k.label} (from ${k.url}, or press Enter to skip):`,{agentKey:K}=await G.prompt([{type:"password",name:"agentKey",message:ee,mask:"*"}]);K&&K.trim()&&(l.agentKey=K.trim(),l.agentAuth="api")}let T=[];if(t&&!o.headed&&!o.headless&&T.push({type:"select",name:"browserMode",message:"Browser mode during live AI execution?",choices:[{name:"Headed - Visible browser (recommended for development)",value:"headed"},{name:"Headless - Hidden browser (for CI/CD)",value:"headless"}],default:"headed"}),t&&!o.apiKey&&T.push({type:"input",name:"apiKey",message:"Project ZIBBY_API_KEY for test-result cloud sync (uploads runs to your team's zibby.dev dashboard) \u2014 paste or press Enter to skip:"}),T.length>0){let P=await G.prompt(T);Object.assign(l,P)}l.browserMode=o.headless?"headless":o.headed?"headed":l.browserMode,l.apiKey=o.apiKey||l.apiKey,l.cloudSync=!!(o.cloudSync||o.apiKey||l.apiKey&&l.apiKey.trim())}o.agentKey&&(l.agentKey=o.agentKey),o.agentOauthToken&&l.agent==="claude"&&(l.claudeOauthToken=o.agentOauthToken);let _=ne[l.agent];l.claudeOauthToken&&(ue("CLAUDE_CODE_OAUTH_TOKEN",l.claudeOauthToken),console.log(i.gray(" Claude OAuth subscription token saved to ~/.zibby/config.json")),console.log(i.gray(" Used by: zibby test / chat / workflow run / workflow start"))),l.agentKey&&(Te(l.agentKey,l.agent),console.log(i.gray(" Agent API key saved to ~/.zibby/config.json"))),l.mcp="playwright",l.setupMcp=l.agent==="cursor";let I=U("Setting up Zibby...").start();try{if(p&&await M(c,{recursive:!0}),t&&(await M(g(c,"test-specs/examples"),{recursive:!0}),await M(g(c,"tests"),{recursive:!0})),await M(g(c,".zibby/output"),{recursive:!0}),await M(g(c,".zibby/commands"),{recursive:!0}),s&&r==="dolt")try{let{initMemory:d,DoltDB:f}=await import("@zibby/ui-memory");if(f.isAvailable()){let{created:u}=d(c);u&&(I.text="Initialized test memory database (Dolt)...")}else I.text="Dolt not found \u2014 skipping memory database (brew install dolt)"}catch{}let k=o.template,z=k&&k!=="none"&&k!=="false";if(z){I.text=`Scaffolding workflow template: ${k}...`;try{let{writeTemplateFiles:d}=await Promise.resolve().then(()=>(De(),Le));await d(c,k,{enableMemory:s})}catch(d){throw I.fail(`Failed to scaffold template: ${d.message}`),d}}else await M(g(c,".zibby"),{recursive:!0});I.text="Generating configuration files...";let T=en(l,o,{memoryBackend:r,memoryInfer:a});if(await x(g(c,".zibby.config.mjs"),T),await x(g(c,".env.example"),on(l,r,a)),l.apiKey&&l.apiKey.trim()){let d=g(c,".env"),f=l.apiKey.trim();if(b(d)){let u=await R(d,"utf8");/^ZIBBY_API_KEY=/m.test(u)?u=u.replace(/^ZIBBY_API_KEY=.*/m,`ZIBBY_API_KEY=${f}`):/^#\s*ZIBBY_API_KEY=/m.test(u)?u=u.replace(/^#\s*ZIBBY_API_KEY=.*/m,`ZIBBY_API_KEY=${f}`):u=`${u.trimEnd()}
|
|
125
125
|
|
|
126
126
|
# Zibby Cloud Sync
|
|
127
|
-
ZIBBY_API_KEY=${
|
|
128
|
-
`,await
|
|
127
|
+
ZIBBY_API_KEY=${f}
|
|
128
|
+
`,await x(d,u)}else await x(d,tn(l,f,r,a))}if(l.agentKey&&_){let d=g(c,".env"),f=l.agentKey;if(b(d)){let u=await R(d,"utf8"),h=new RegExp(`^${_.envVar}=.*`,"m"),y=new RegExp(`^#\\s*${_.envVar}=.*`,"m");h.test(u)?u=u.replace(h,`${_.envVar}=${f}`):y.test(u)?u=u.replace(y,`${_.envVar}=${f}`):u=`${u.trimEnd()}
|
|
129
129
|
|
|
130
130
|
# AI Agent Key
|
|
131
|
-
${
|
|
132
|
-
`,await
|
|
131
|
+
${_.envVar}=${f}
|
|
132
|
+
`,await x(d,u)}}if(p){let d=nn(m,l,{memoryBackend:r});await x(g(c,"package.json"),d)}if(!b(g(c,".gitignore"))){let d=rn();await x(g(c,".gitignore"),d)}if(t){if(!b(g(c,"playwright.config.js"))){let d=sn("on");await x(g(c,"playwright.config.js"),d)}if(!b(g(c,"test-specs/examples/example-domain.txt"))){let d=an();await x(g(c,"test-specs/examples/example-domain.txt"),d)}}let P=Pe(zo,"../../../../examples/.zibby/commands");if(b(P)){let d=ae(P).filter(f=>f.toLowerCase().endsWith(".md"));for(let f of d){let u=g(c,".zibby/commands",f);if(o.force||!b(u)){let h=await R(g(P,f),"utf-8");await x(u,h)}}}if(!b(g(c,".zibby/commands/example.md"))){let d=ln();await x(g(c,".zibby/commands/example.md"),d)}let W=Pe(zo,"../../templates"),Z=g(W,".claude"),ee=!1,K=0,oe=0,te=0,ce=null;if(b(Z)){await M(g(c,".claude"),{recursive:!0}),await M(g(c,".claude","commands"),{recursive:!0}),await M(g(c,".claude","agents"),{recursive:!0});let d=g(Z,"CLAUDE.md"),f=g(c,".claude","CLAUDE.md");if(b(d)&&(o.force||!b(f))){let y=await R(d,"utf-8");await x(f,y),ee=!0}let u=g(Z,"commands");if(b(u)){let y=ae(u).filter(v=>v.toLowerCase().endsWith(".md"));for(let v of y){let B=g(c,".claude","commands",v);if(o.force||!b(B)){let S=await R(g(u,v),"utf-8");await x(B,S),K++}}}let h=g(Z,"agents");if(b(h)){let y=ae(h).filter(v=>v.toLowerCase().endsWith(".md"));for(let v of y){let B=g(c,".claude","agents",v);if(o.force||!b(B)){let S=await R(g(h,v),"utf-8");await x(B,S),oe++}}}}let de=g(W,".cursor","rules");if(b(de)){await M(g(c,".cursor","rules"),{recursive:!0});let d=ae(de).filter(f=>f.toLowerCase().endsWith(".mdc"));for(let f of d){let u=g(c,".cursor","rules",f);if(o.force||!b(u)){let h=await R(g(de,f),"utf-8");await x(u,h),te++}}}let $e=g(W,"AGENTS.md");if(b($e)){let{upsertManagedBlock:d}=await Promise.resolve().then(()=>(Ue(),je)),f=g(c,"AGENTS.md"),u=await R($e,"utf-8"),h=b(f)?await R(f,"utf-8"):null,{content:y,action:v}=d(h,u);v!=="skipped"&&await x(f,y),ce=v}if(ee&&console.log(i.green(" \u2713 Wrote .claude/CLAUDE.md (workflow + apps knowledge)")),K>0&&console.log(i.green(` \u2713 Wrote .claude/commands/ (${K} slash command${K===1?"":"s"})`)),oe>0&&console.log(i.green(` \u2713 Wrote .claude/agents/ (${oe} subagent definition${oe===1?"":"s"})`)),te>0&&console.log(i.green(` \u2713 Wrote .cursor/rules/ (${te} Cursor rule${te===1?"":"s"})`)),ce==="created"?console.log(i.green(" \u2713 Wrote AGENTS.md (Zibby section, managed block)")):ce==="updated"&&console.log(i.green(" \u2713 Updated AGENTS.md (Zibby section, your content preserved)")),p){let d=cn(m,l);await x(g(c,"README.md"),d)}try{let{validateMemorySyncConfig:d,applyMemorySyncConfig:f}=await Promise.resolve().then(()=>(He(),Fe)),u=g(c,".zibby.config.mjs"),h=null;if(b(u))try{h=(await import(`file://${u}?t=${Date.now()}`)).default?.memorySync}catch{}let y=d(h);if(y.ok&&y.kind!=="noop"){let v=await import("@zibby/ui-memory").catch(()=>null),{getSessionToken:B}=await Promise.resolve().then(()=>(fe(),ge)),S=await f({cwd:c,projectId:l.projectId,block:h,memoryApi:v,getSessionToken:B,hostedSetup:async({cwd:J,projectId:X})=>{let{memoryRemoteUseHostedCommand:Se}=await Promise.resolve().then(()=>(vo(),wo));await Se({cwd:J,projectId:X})},logger:{info:()=>{},warn:()=>{},error:()=>{}}});S.action==="hosted"?console.log(i.green(" \u2713 Hosted memory-sync configured from .zibby.config.mjs")):S.action==="byo"?console.log(i.green(` \u2713 Memory remote configured from .zibby.config.mjs \u2192 ${S.remote}`)):S.action==="pending-login"?(console.log(i.yellow(` \u26A0 memorySync.remote = "hosted" but you're not logged in.`)),console.log(i.gray(" Run `zibby login` then `zibby memory remote use --hosted` to finish."))):S.action==="error"&&console.log(i.yellow(` \u26A0 memorySync setup skipped: ${S.reason}`))}else y.ok||console.log(i.yellow(` \u26A0 memorySync config invalid: ${y.error}`))}catch(d){console.log(i.yellow(` \u26A0 memorySync auto-apply failed: ${d.message}`))}if(I.succeed(p?"Project created!":"Zibby initialized!"),z||(console.log(""),console.log(i.gray(" No workflow scaffolded. Add one when ready:")),console.log(i.gray(" zibby template list # see available")),console.log(i.gray(" zibby workflow new <slug> -t <template> # named, deployable copy")),console.log("")),p&&!o.skipInstall){let d=U("Installing dependencies...").start();await new Promise((f,u)=>{Q("npm",["install"],{cwd:c,stdio:"pipe"}).on("close",y=>{y===0?(d.succeed("Dependencies installed!"),f()):(d.fail("Failed to install dependencies"),u(new Error("npm install failed")))})})}if(!p&&s&&r==="mem0"&&(console.log(i.yellow(`
|
|
133
133
|
Using mem0 backend requires mem0ai in your project dependencies.`)),console.log(i.gray("Run this manually in your project when ready:")),console.log(i.white(` npm install mem0ai
|
|
134
|
-
`))),!o.skipInstall&&t){let
|
|
134
|
+
`))),!o.skipInstall&&t){let d=U("Installing Playwright browsers...").start();await new Promise(f=>{let u=Q("npx",["playwright","install","chromium"],{cwd:c,stdio:"pipe"}),h="";u.stdout.on("data",y=>{h+=y.toString()}),u.stderr.on("data",y=>{h+=y.toString()}),u.on("close",y=>{y===0?(h.includes("already installed")||h.includes("up to date")?d.succeed("Playwright browsers already installed"):d.succeed("Playwright browsers installed!"),f()):(d.warn("Could not verify Playwright browsers"),console.log(i.yellow(`
|
|
135
135
|
If tests fail, run: npx playwright install
|
|
136
|
-
`)),
|
|
137
|
-
`))}}}if(l.agent==="codex"&&!o.skipInstall){let
|
|
138
|
-
`))}}}if(l.agent==="gemini"&&!o.skipInstall){let
|
|
139
|
-
`))}}if(t){let
|
|
140
|
-
`,"utf-8");let
|
|
141
|
-
`))}}}if(l.agent==="cursor"&&l.setupMcp&&t){let
|
|
136
|
+
`)),f())})})}if(l.agent==="cursor"&&!o.skipInstall){let d=U("Checking cursor-agent CLI...").start();try{le("cursor-agent --version",{encoding:"utf-8",timeout:5e3,stdio:"pipe"}),d.succeed("cursor-agent CLI already installed")}catch{d.text="Installing cursor-agent CLI...";try{await new Promise((f,u)=>{Q("bash",["-c","curl https://cursor.com/install -fsS | bash"],{stdio:"pipe"}).on("close",y=>{if(y===0){let v=g(Y(),".local","bin");process.env.PATH.includes(v)||(process.env.PATH=`${v}:${process.env.PATH}`),d.succeed("cursor-agent CLI installed!"),f()}else u(new Error("cursor-agent install failed"))})})}catch{d.fail("Could not install cursor-agent CLI"),console.log(i.yellow(` Install manually: curl https://cursor.com/install -fsS | bash
|
|
137
|
+
`))}}}if(l.agent==="codex"&&!o.skipInstall){let d=U("Checking Codex CLI...").start();try{le("codex --version",{encoding:"utf-8",timeout:5e3,stdio:"pipe"}),d.succeed("Codex CLI already installed")}catch{d.text="Installing Codex CLI...";try{await new Promise((f,u)=>{Q("npm",["install","-g","@openai/codex"],{stdio:"pipe"}).on("close",y=>{y===0?(d.succeed("Codex CLI installed!"),f()):u(new Error("npm install -g @openai/codex failed"))})})}catch{d.fail("Could not install Codex CLI"),console.log(i.yellow(` Install manually: npm install -g @openai/codex
|
|
138
|
+
`))}}}if(l.agent==="gemini"&&!o.skipInstall){let d=U("Checking Gemini CLI...").start();try{le("gemini --version",{encoding:"utf-8",timeout:5e3,stdio:"pipe"}),d.succeed("Gemini CLI already installed")}catch{d.text="Installing Gemini CLI...";try{await new Promise((f,u)=>{Q("npm",["install","-g","@google/gemini-cli"],{stdio:"pipe"}).on("close",y=>{y===0?(d.succeed("Gemini CLI installed!"),f()):u(new Error("npm install -g @google/gemini-cli failed"))})})}catch{d.fail("Could not install Gemini CLI"),console.log(i.yellow(` Install manually: npm install -g @google/gemini-cli
|
|
139
|
+
`))}}if(t){let f=U("Configuring Gemini MCP servers...").start();try{let u=g(Y(),".gemini"),h=g(u,"settings.json");b(u)||await M(u,{recursive:!0});let y={mcpServers:{}};if(b(h))try{let X=await R(h,"utf-8");y=JSON.parse(X),y.mcpServers||(y.mcpServers={})}catch{}let v;try{let{createRequire:X}=await import("module");v=X(import.meta.url).resolve("@zibby/mcp-browser/bin/mcp-browser-zibby.js")}catch{v="@playwright/mcp"}let B=l.browserMode!=="headless",S=v==="@playwright/mcp"?["-y","@playwright/mcp","--isolated","--viewport-size=1280x720","--output-dir","test-results"]:[v,"--isolated","--viewport-size=1280x720","--output-dir=test-results"];B||S.push("--headless"),y.mcpServers["playwright-official"]={command:v==="@playwright/mcp"?"npx":"node",args:S},await x(h,`${JSON.stringify(y,null,2)}
|
|
140
|
+
`,"utf-8");let J="Gemini MCP configured";B?J+=" (headed mode - visible browser)":J+=" (headless mode - hidden browser)",f.succeed(J)}catch(u){f.fail("MCP setup failed"),console.log(i.yellow(" You may need to configure ~/.gemini/settings.json manually")),console.log(i.gray(` Error: ${u.message}
|
|
141
|
+
`))}}}if(l.agent==="cursor"&&l.setupMcp&&t){let d=U("Setting up Playwright MCP...").start();try{let{setupPlaywrightMcpCommand:f}=await Promise.resolve().then(()=>(Ro(),Eo)),u=l.cloudSync||!1,h=l.browserMode!=="headless";await f({headed:h,cloudSync:u,viewport:{width:1280,height:720}});let y="Playwright MCP configured";h?y+=" (headed mode - visible browser)":y+=" (headless mode - hidden browser)",u&&(y+=" + Zibby MCP (cloud sync)"),d.succeed(y),u&&!(l.apiKey&&l.apiKey.trim())&&console.log(i.gray(`
|
|
142
142
|
Copy .env.example to .env and set ZIBBY_API_KEY to enable uploads
|
|
143
|
-
`))}catch(
|
|
144
|
-
`)),console.log(i.gray(` Error: ${
|
|
143
|
+
`))}catch(f){d.fail("MCP setup script failed"),console.log(i.yellow(" Check if MCP is already configured:")),console.log(i.gray(' \u2022 Open Cursor settings \u2192 Check "playwright-official" MCP')),console.log(i.gray(" \u2022 Run: cursor-agent mcp list")),console.log(i.gray(` \u2022 Or run manually: zibby setup-playwright
|
|
144
|
+
`)),console.log(i.gray(` Error: ${f.message}
|
|
145
145
|
`))}}console.log(i.bold.green(`
|
|
146
146
|
All set!
|
|
147
|
-
`)),
|
|
147
|
+
`)),p&&(console.log(i.cyan("Get into the project:")),console.log(i.white(` cd ${e}
|
|
148
148
|
`))),t?(console.log(i.cyan("Run a test:")),console.log(i.white(` zibby test test-specs/examples/example-domain.txt
|
|
149
149
|
`)),console.log(i.cyan("Cloud features (optional):")),console.log(i.white(` zibby login ${i.gray("# unlock workflow deploy, hosted memory, etc.")}`)),console.log(""),console.log(i.cyan("Next steps:")),console.log(i.white(` 1. cp .env.example .env ${i.gray("# then add your API keys")}`)),console.log(i.white(` 2. Write test specs in ${i.bold("test-specs/")}`)),console.log(i.white(` 3. Run: ${i.bold("zibby test <spec-file>")}`)),console.log(i.white(` 4. Or chat: ${i.bold("zibby")}
|
|
150
150
|
`))):(console.log(i.cyan("Add a workflow when ready:")),console.log(i.white(` zibby template list ${i.gray("# see available")}`)),console.log(i.white(` zibby workflow new my-pipeline ${i.gray("# blank scaffold")}`)),console.log(i.white(` zibby workflow new my-pip -t <name> ${i.gray("# from a template")}
|
|
151
|
-
`)),console.log(i.cyan("Cloud features (optional):")),console.log(i.white(` zibby login ${i.gray("# unlock workflow deploy, hosted memory, etc.")}`)),console.log(""))}catch(
|
|
152
|
-
Error: ${
|
|
153
|
-
`)),process.exit(1)}}function
|
|
154
|
-
auth: '${e.agentAuth}', // 'oauth' (subscription) or 'api' (pay-per-token); cloud needs 'api'`:"",
|
|
151
|
+
`)),console.log(i.cyan("Cloud features (optional):")),console.log(i.white(` zibby login ${i.gray("# unlock workflow deploy, hosted memory, etc.")}`)),console.log(""))}catch(k){I.fail("Failed to create project"),console.error(i.red(`
|
|
152
|
+
Error: ${k.message}
|
|
153
|
+
`)),process.exit(1)}}function en(e,o={},t={}){let s=["dolt","mem0"].includes(String(t.memoryBackend||"").toLowerCase())?String(t.memoryBackend).toLowerCase():"dolt",r=t.memoryInfer===!0,a=e.agentAuth==="oauth"||e.agentAuth==="api"?`
|
|
154
|
+
auth: '${e.agentAuth}', // 'oauth' (subscription) or 'api' (pay-per-token); cloud needs 'api'`:"",c={claude:`
|
|
155
155
|
claude: {
|
|
156
156
|
model: 'auto', // Options: 'auto', 'sonnet-4.6', 'opus-4.6', 'sonnet-4.5', 'opus-4.5'
|
|
157
|
-
maxTokens: 4096,${e.agent==="claude"?
|
|
157
|
+
maxTokens: 4096,${e.agent==="claude"?a:""}
|
|
158
158
|
},`,cursor:`
|
|
159
159
|
cursor: {
|
|
160
|
-
model: 'auto', // Options: 'auto', 'opus-4.5', 'opus-4.5-thinking', 'sonnet-4.5', 'sonnet-4.5-thinking', 'composer-1', 'gpt-5.2-codex', 'gpt-5.2', 'gpt-5.3', 'gpt-5.4', 'gemini-3-pro', 'gemini-3-flash'${e.agent==="cursor"?
|
|
160
|
+
model: 'auto', // Options: 'auto', 'opus-4.5', 'opus-4.5-thinking', 'sonnet-4.5', 'sonnet-4.5-thinking', 'composer-1', 'gpt-5.2-codex', 'gpt-5.2', 'gpt-5.3', 'gpt-5.4', 'gemini-3-pro', 'gemini-3-flash'${e.agent==="cursor"?a:""}
|
|
161
161
|
},`,codex:`
|
|
162
162
|
codex: {
|
|
163
|
-
model: 'gpt-5.2-codex', // Options: 'auto', 'o4-mini', 'o3', 'codex-mini', 'gpt-4o', 'gpt-5.2-codex', 'gpt-5.2', 'gpt-5.3', 'gpt-5.4'${e.agent==="codex"?
|
|
163
|
+
model: 'gpt-5.2-codex', // Options: 'auto', 'o4-mini', 'o3', 'codex-mini', 'gpt-4o', 'gpt-5.2-codex', 'gpt-5.2', 'gpt-5.3', 'gpt-5.4'${e.agent==="codex"?a:""}
|
|
164
164
|
},`,gemini:`
|
|
165
165
|
gemini: {
|
|
166
|
-
model: 'gemini-2.5-pro', // Options: 'auto', 'gemini-2.5-pro', 'gemini-2.5-flash'${e.agent==="gemini"?
|
|
167
|
-
},`},
|
|
168
|
-
`).map(
|
|
166
|
+
model: 'gemini-2.5-pro', // Options: 'auto', 'gemini-2.5-pro', 'gemini-2.5-flash'${e.agent==="gemini"?a:""}
|
|
167
|
+
},`},m=e.agent,p=Object.entries(c).filter(([l])=>l!==m).map(([,l])=>l.split(`
|
|
168
|
+
`).map(w=>w.trim()?` // ${w.trimStart()}`:w).join(`
|
|
169
169
|
`)).join(`
|
|
170
170
|
`);return`export default {
|
|
171
171
|
// AI agent settings
|
|
172
|
-
agent: {${
|
|
173
|
-
${
|
|
172
|
+
agent: {${c[m]}
|
|
173
|
+
${p}
|
|
174
174
|
strictMode: false,
|
|
175
175
|
},
|
|
176
176
|
|
|
@@ -183,7 +183,11 @@ ${d}
|
|
|
183
183
|
|
|
184
184
|
// Chat memory backend adapter (dolt | mem0)
|
|
185
185
|
memory: {
|
|
186
|
-
backend: '${
|
|
186
|
+
backend: '${s}',
|
|
187
|
+
// Smart memory (mem0 only): true = LLM distills/dedupes facts on store
|
|
188
|
+
// (costs tokens); false = store raw, embed-only, free. Default false.
|
|
189
|
+
// Env override: ZIBBY_MEM0_INFER=true
|
|
190
|
+
infer: ${r},
|
|
187
191
|
},
|
|
188
192
|
|
|
189
193
|
// UI-test memory remote sync \u2014 declarative team configuration.
|
|
@@ -253,7 +257,11 @@ ${d}
|
|
|
253
257
|
// Cloud sync - auto-upload test results & videos (requires ZIBBY_API_KEY in .env)
|
|
254
258
|
cloudSync: ${e.cloudSync||!1}
|
|
255
259
|
};
|
|
256
|
-
`}function
|
|
260
|
+
`}function To(e){return e?`# Smart memory: LLM distills/dedupes facts on store (mem0; costs tokens). false = embed-only, free.
|
|
261
|
+
ZIBBY_MEM0_INFER=true
|
|
262
|
+
`:`# Smart memory: set true to let the LLM distill/dedupe facts on store (mem0; costs tokens). Default off = embed-only, free.
|
|
263
|
+
# ZIBBY_MEM0_INFER=false
|
|
264
|
+
`}function on(e,o="dolt",t=!1){return`# Zibby Test Automation - Environment Variables
|
|
257
265
|
|
|
258
266
|
# AI Provider Keys
|
|
259
267
|
${{claude:"ANTHROPIC_API_KEY=sk-ant-your_key_here",cursor:`# Cursor Agent uses cursor-agent CLI \u2014 no API key needed
|
|
@@ -270,7 +278,7 @@ ${{claude:"ANTHROPIC_API_KEY=sk-ant-your_key_here",cursor:`# Cursor Agent uses c
|
|
|
270
278
|
|
|
271
279
|
# Chat memory backend
|
|
272
280
|
ZIBBY_MEMORY_BACKEND=${o}
|
|
273
|
-
`}function
|
|
281
|
+
${To(t)}`}function tn(e,o,t="dolt",s=!1){return`# Zibby Test Automation - Environment Variables
|
|
274
282
|
|
|
275
283
|
# AI Provider Keys
|
|
276
284
|
${{claude:"ANTHROPIC_API_KEY=sk-ant-your_key_here",cursor:"# Cursor Agent uses cursor-agent CLI \u2014 no API key needed",codex:"OPENAI_API_KEY=sk-your_key_here",gemini:"GEMINI_API_KEY=your_key_here"}[e.agent]||""}
|
|
@@ -285,7 +293,7 @@ ZIBBY_API_KEY=${o}
|
|
|
285
293
|
|
|
286
294
|
# Chat memory backend
|
|
287
295
|
ZIBBY_MEMORY_BACKEND=${t}
|
|
288
|
-
`}function
|
|
296
|
+
${To(s)}`}function nn(e,o,t={}){let r={"@zibby/cli":"latest","@zibby/core":Xt("../../package.json").dependencies?.["@zibby/core"]||"latest"};return t.memoryBackend==="mem0"&&(r.mem0ai="^2.4.6"),JSON.stringify({name:e,version:"1.0.0",type:"module",private:!0,scripts:{"test:spec":"zibby run",test:"playwright test","test:headed":"playwright test --headed"},dependencies:r,devDependencies:{"@playwright/test":"^1.49.0",dotenv:"^17.2.3"}},null,2)}function rn(){return`# Dependencies
|
|
289
297
|
node_modules/
|
|
290
298
|
|
|
291
299
|
# Test artifacts
|
|
@@ -313,7 +321,7 @@ Thumbs.db
|
|
|
313
321
|
# Zibby memory (Dolt DB synced separately via dolt remote, not git)
|
|
314
322
|
.zibby/memory/
|
|
315
323
|
.zibby/memory-context.md
|
|
316
|
-
`}function
|
|
324
|
+
`}function sn(e="off",o=null){return`import { defineConfig} from '@playwright/test';
|
|
317
325
|
|
|
318
326
|
export default defineConfig({
|
|
319
327
|
testDir: './tests',
|
|
@@ -335,7 +343,7 @@ ${o?` outputDir: '${o}',
|
|
|
335
343
|
['list']
|
|
336
344
|
],
|
|
337
345
|
});
|
|
338
|
-
`}function
|
|
346
|
+
`}function an(){return`Test Specification: Example Domain Navigation
|
|
339
347
|
==============================================
|
|
340
348
|
|
|
341
349
|
Application: Example Domain
|
|
@@ -372,7 +380,7 @@ Notes:
|
|
|
372
380
|
- Uses a stable, public domain (example.com) maintained by IANA
|
|
373
381
|
- No authentication required
|
|
374
382
|
- Suitable for CI/CD smoke testing
|
|
375
|
-
`}function
|
|
383
|
+
`}function ln(){return`# Example command template
|
|
376
384
|
|
|
377
385
|
Use this command when the user asks for a concise testing task breakdown.
|
|
378
386
|
|
|
@@ -383,7 +391,7 @@ Required output format:
|
|
|
383
391
|
4. Expected result
|
|
384
392
|
|
|
385
393
|
Keep the response actionable and short.
|
|
386
|
-
`}function
|
|
394
|
+
`}function cn(e,o){return`# ${e}
|
|
387
395
|
|
|
388
396
|
AI-powered test automation with Zibby.
|
|
389
397
|
|
|
@@ -472,4 +480,4 @@ ${e}/
|
|
|
472
480
|
|
|
473
481
|
- Documentation: https://docs.zibby.dev
|
|
474
482
|
- Examples: https://github.com/zibby/examples
|
|
475
|
-
`}export{
|
|
483
|
+
`}export{en as generateConfig,Hn as initCommand};
|