@zibby/cli 0.2.1 → 0.4.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.
Files changed (44) hide show
  1. package/README.md +117 -16
  2. package/dist/bin/zibby.js +3 -3
  3. package/dist/commands/chat-agents.js +1 -1
  4. package/dist/commands/chat.js +62 -62
  5. package/dist/commands/credentials-api.js +1 -1
  6. package/dist/commands/credentials-file.js +1 -1
  7. package/dist/commands/creds.js +1 -1
  8. package/dist/commands/init.js +180 -82
  9. package/dist/commands/memory.js +48 -20
  10. package/dist/commands/run.js +52 -55
  11. package/dist/commands/template.js +9 -0
  12. package/dist/commands/uninstall.js +15 -14
  13. package/dist/commands/workflows/agent-helpers.js +7 -7
  14. package/dist/commands/workflows/generate.js +54 -32
  15. package/dist/commands/workflows/run-local.js +19 -19
  16. package/dist/commands/workflows/run.js +5 -5
  17. package/dist/commands/workflows/start.js +12 -12
  18. package/dist/package.json +2 -2
  19. package/dist/templates/zibby-workflow-claude/agents-md-block.md +65 -5
  20. package/dist/templates/zibby-workflow-claude/claude/agents/zibby-test-author.md +16 -1
  21. package/dist/templates/zibby-workflow-claude/claude/agents/zibby-workflow-builder.md +22 -2
  22. package/dist/templates/zibby-workflow-claude/claude/commands/zibby-add-node.md +1 -1
  23. package/dist/templates/zibby-workflow-claude/claude/commands/zibby-debug.md +1 -1
  24. package/dist/templates/zibby-workflow-claude/claude/commands/zibby-delete.md +1 -1
  25. package/dist/templates/zibby-workflow-claude/claude/commands/zibby-deploy.md +24 -14
  26. package/dist/templates/zibby-workflow-claude/claude/commands/zibby-list.md +2 -2
  27. package/dist/templates/zibby-workflow-claude/claude/commands/zibby-memory-cost.md +39 -0
  28. package/dist/templates/zibby-workflow-claude/claude/commands/zibby-memory-pull.md +47 -0
  29. package/dist/templates/zibby-workflow-claude/claude/commands/zibby-memory-remote-use-hosted.md +61 -0
  30. package/dist/templates/zibby-workflow-claude/claude/commands/zibby-memory-stats.md +38 -0
  31. package/dist/templates/zibby-workflow-claude/claude/commands/zibby-static-ip.md +8 -6
  32. package/dist/templates/zibby-workflow-claude/claude/commands/zibby-tail.md +1 -1
  33. package/dist/templates/zibby-workflow-claude/claude/commands/zibby-test-debug.md +2 -2
  34. package/dist/templates/zibby-workflow-claude/claude/commands/zibby-test-generate.md +1 -1
  35. package/dist/templates/zibby-workflow-claude/claude/commands/zibby-test-run.md +3 -2
  36. package/dist/templates/zibby-workflow-claude/claude/commands/zibby-test-write.md +1 -1
  37. package/dist/templates/zibby-workflow-claude/claude/commands/zibby-trigger.md +10 -6
  38. package/dist/templates/zibby-workflow-claude/cursor/rules/zibby-workflows.mdc +76 -13
  39. package/dist/templates/zibby-workflow-claude/manifest.json +5 -1
  40. package/dist/utils/agent-credentials.js +4 -3
  41. package/dist/utils/apply-memory-sync-config.js +1 -0
  42. package/dist/utils/credentials-loader.js +1 -1
  43. package/dist/utils/hosted-memory-sync.js +1 -0
  44. package/package.json +2 -2
@@ -1,77 +1,156 @@
1
- var me=Object.defineProperty;var ge=(t,e)=>()=>(t&&(e=t(t=0)),e);var fe=(t,e)=>{for(var a in e)me(t,a,{get:e[a],enumerable:!0})};var le={};fe(le,{setupCiCommand:()=>$e,setupPlaywrightMcpCommand:()=>ae,testWithVideoCommand:()=>Ke});import{spawn as H,execSync as F}from"child_process";import{join as K,dirname as W,resolve as te}from"path";import{readFileSync as ne,writeFileSync as oe,existsSync as T,mkdirSync as se}from"fs";import{homedir as ie}from"os";import{createRequire as ve}from"module";import x from"chalk";function xe(){try{return W(G.resolve("@zibby/core/package.json"))}catch{return null}}function re(t){try{return F(`command -v ${t}`,{stdio:"pipe"}),!0}catch{return!1}}function Pe(){try{let t=G.resolve("@zibby/mcp-browser/bin/mcp-browser-zibby.js");if(T(t))return t}catch{}try{let t=G.resolve("@playwright/mcp/package.json"),e=W(t),a=JSON.parse(ne(t,"utf-8")),l=typeof a.bin=="string"?a.bin:a.bin?.["playwright-mcp"];if(l){let m=K(e,l);if(T(m))return m}let n=K(e,"cli.js");if(T(n))return n}catch{}return null}function Q(t,e,a={}){return new Promise((l,n)=>{let m=H(t,e,{stdio:"inherit",...a});m.on("close",y=>l(y??1)),m.on("error",n)})}async function Ce(t){return re("playwright")?await Q("playwright",["install","ffmpeg"],{cwd:t})===0:await Q("npx",["--yes","playwright","install","ffmpeg"],{cwd:t})===0}function Ae({headed:t=!1,viewport:e=null}){let a=process.execPath,l=W(a),n=Pe(),m=Number(e?.width)||1280,y=Number(e?.height)||720,r=`${m}x${y}`,w=[];w.push(`--viewport-size=${r}`,"--output-dir=test-results"),t||w.push("--headless");let g;n?g={command:a,args:[n,...w],env:{PATH:`${l}:/usr/bin:/bin:/usr/sbin:/sbin`}}:g={command:"npx",args:["-y","@playwright/mcp",...w],env:{PATH:`${l}:/usr/bin:/bin:/usr/sbin:/sbin`}},g.description="Zibby MCP Browser - Playwright MCP with Zibby defaults";let C=K(ie(),".cursor"),f=K(C,"mcp.json");T(C)||se(C,{recursive:!0});let v={mcpServers:{}};if(T(f))try{v=JSON.parse(ne(f,"utf-8")),(!v.mcpServers||typeof v.mcpServers!="object")&&(v.mcpServers={})}catch{v={mcpServers:{}}}v.mcpServers["playwright-official"]=g,oe(f,`${JSON.stringify(v,null,2)}
2
- `,"utf-8")}async function Ie(){let t=xe();if(!t)return;let e=K(t,"scripts","patch-cursor-mcp.js");if(T(e))try{await new Promise((a,l)=>{let n=H(process.execPath,[e],{cwd:process.cwd(),stdio:"ignore"});n.on("close",m=>a(m??0)),n.on("error",l)})}catch{}}function Ee(t){return te(t).replace(/^\/+/,"").replace(/\//g,"-")}function ke(t){let e=String(t||""),a=e.split(`
3
- `).find(m=>/playwright-official/i.test(m)&&/APPROVAL|🔑/i.test(m));if(a){let m=a.match(/=>\s*(\S+)/);if(m)return m[1]}let l=e.match(/playwright-official[^=]*=>\s*(\S+)/);if(l)return l[1];let n=e.match(/playwright-official-[a-f0-9]+/i);return n?n[0]:null}function Se(t,e){let a=Ee(t),l=K(ie(),".cursor","projects",a);se(l,{recursive:!0});let n=K(l,"mcp-approvals.json");return oe(n,`${JSON.stringify([e],null,2)}
4
- `,"utf-8"),n}function ee(t){try{return F("cursor-agent mcp list",{cwd:t,encoding:"utf-8",stdio:["ignore","pipe","pipe"],env:process.env,maxBuffer:2*1024*1024})}catch(e){let a=e.stdout!=null?String(e.stdout):"",l=e.stderr!=null?String(e.stderr):"";return a+l}}function _e(t){try{return F("cursor-agent mcp enable playwright-official",{cwd:t,encoding:"utf-8",stdio:["ignore","pipe","pipe"],env:process.env,maxBuffer:1024*1024}),!0}catch{return!1}}async function ae(t={}){let e=!!t.headed,a=t.viewport||{width:1280,height:720};if(!process.execPath)throw new Error("Node.js runtime not found");let l=await Ce(process.cwd());console.log(l?x.gray(" \u2713 ffmpeg installed for Playwright video"):x.yellow(" \u26A0 Could not install ffmpeg (video may be unavailable)")),Ae({headed:e,viewport:a}),await Ie();let n=te(process.cwd());if(re("cursor-agent")){ee(n);let m=_e(n);m&&console.log(x.gray(" \u2713 cursor-agent: mcp enable playwright-official"));let y=ee(n),r=ke(y);if(r)try{let w=Se(n,r);console.log(x.gray(` \u2713 MCP auto-approval key saved (${w})`))}catch(w){console.log(x.yellow(` \u26A0 Could not write mcp-approvals.json: ${w.message}`))}else m||(console.log(x.yellow(" \u26A0 Could not auto-approve MCP (mcp enable failed and no approval key in cursor-agent output)")),console.log(x.gray(" Try: cursor-agent mcp enable playwright-official")))}else console.log(x.yellow(" \u26A0 cursor-agent not found; install it to use Cursor MCP tools"))}async function $e(t){try{console.log(x.cyan(`
1
+ var wo=Object.defineProperty;var N=(o,e)=>()=>(o&&(e=o(o=0)),e);var D=(o,e)=>{for(var t in e)wo(o,t,{get:e[t],enumerable:!0})};var Ce={};D(Ce,{templateAddCommand:()=>Po,templateListCommand:()=>Co,writeTemplateFiles:()=>Ae});import{mkdir as Ie,writeFile as q,readFile as J}from"fs/promises";import{existsSync as ne,readdirSync as Ao}from"fs";import{join as O}from"path";import k from"chalk";async function Ae(o,e,t={}){let a=t.enableMemory!==!1,{TemplateFactory:i}=await import("@zibby/core/templates"),{graphPath:s,nodesPath:p,readmePath:u,resultHandlerPath:l,template:f}=i.getTemplateFiles(e),h=O(o,".zibby");ne(h)||await Ie(h,{recursive:!0});let v=[];await q(O(h,"graph.mjs"),await J(s,"utf-8")),v.push("graph.mjs"),l&&(await q(O(h,"result-handler.mjs"),await J(l,"utf-8")),v.push("result-handler.mjs")),await q(O(h,"README.md"),await J(u,"utf-8")),v.push("README.md");let w=O(h,"nodes");await Ie(w,{recursive:!0});for(let A of Ao(p)){let x=await J(O(p,A),"utf-8");!a&&A==="execute-live.mjs"&&(x=x.replace("skills: [SKILLS.BROWSER, SKILLS.MEMORY],","skills: [SKILLS.BROWSER],")),await q(O(w,A),x),v.push(`nodes/${A}`)}let I=O(f.path,"chat.mjs");return ne(I)&&(await q(O(h,"chat.mjs"),await J(I,"utf-8")),v.push("chat.mjs")),{template:f,copied:v}}async function Co(){let{TemplateFactory:o}=await import("@zibby/core/templates"),e=o.listTemplates();console.log(""),console.log(k.bold.cyan(" Available templates")),console.log("");for(let t of e){if(console.log(` ${k.cyan(t.name)}`),console.log(` ${k.white(t.displayName)}`),t.description&&console.log(` ${k.gray(t.description)}`),t.features&&t.features.length)for(let a of t.features)console.log(k.gray(` \u2022 ${a}`));console.log("")}console.log(k.gray(" Use: zibby template add <name> (or pass -t <name> to zibby init)")),console.log("")}async function Po(o,e={}){o||(console.log(k.red(`
2
+ Missing template name.
3
+ `)),console.log(k.gray(" Usage: zibby template add <name>")),console.log(k.gray(` See available templates: zibby template list
4
+ `)),process.exit(1));let t=e.cwd||process.cwd(),a=O(t,".zibby");ne(a)||(console.log(k.yellow(`
5
+ No .zibby/ directory in ${t}.
6
+ `)),console.log(k.gray(" Run `zibby init` first to bootstrap the project.\n")),process.exit(1));let i;try{i=await Ae(t,o,{enableMemory:e.enableMemory!==!1})}catch(s){console.log(k.red(`
7
+ ${s.message}
8
+ `)),console.log(k.gray(` See available templates: zibby template list
9
+ `)),process.exit(1)}console.log(""),console.log(k.green(` \u2713 Added template ${k.bold(i.template.name)}`)),console.log(k.gray(` ${i.copied.length} files written to ${a}/`));for(let s of i.copied)console.log(k.gray(` \u2022 ${s}`));console.log(""),console.log(k.gray(" Re-running `zibby template add <name>` overwrites existing files \u2014")),console.log(k.gray(" use this to refresh after `npm update @zibby/core`.")),console.log("")}var Pe=N(()=>{});var $e={};D($e,{applyMemorySyncConfig:()=>$o,validateMemorySyncConfig:()=>Se});function Se(o){if(!o||typeof o!="object")return{ok:!0,kind:"noop"};let e=o.remote;return _o.includes(e)?{ok:!0,kind:"noop"}:typeof e!="string"?{ok:!1,error:`memorySync.remote must be null or a string, got ${typeof e}`}:e===So?{ok:!0,kind:"hosted"}:_e.some(t=>e.startsWith(t))?{ok:!0,kind:"byo",remote:e}:{ok:!1,error:`memorySync.remote = ${JSON.stringify(e)} is not recognized. Use null, 'hosted', or a URL beginning with one of: ${_e.join(" / ")}.`}}async function $o({cwd:o,projectId:e,block:t,memoryApi:a,hostedSetup:i,getSessionToken:s,logger:p=console}){let u=Se(t);if(!u.ok)return p.warn?.(`[memory-sync] config invalid: ${u.error}`),{action:"error",reason:u.error};if(u.kind==="noop")return{action:"skipped",reason:"memorySync.remote not set"};if(u.kind==="byo")return a?.memoryRemoteAdd?a.memoryRemoteAdd(o,u.remote)?{action:"byo",remote:u.remote}:{action:"error",reason:"memoryRemoteAdd returned false (memory DB not initialized?)"}:{action:"error",reason:"@zibby/ui-memory not loaded"};if(u.kind==="hosted"){if(typeof s=="function"&&!s())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 i!="function")return{action:"error",reason:"hostedSetup function not provided"};try{return await i({cwd:o,projectId:e}),{action:"hosted"}}catch(l){return{action:"error",reason:`hosted setup failed: ${l.message}`}}}return{action:"error",reason:`unhandled kind: ${u.kind}`}}var _o,So,_e,Ee=N(()=>{_o=[null,void 0,"","none","off",!1],So="hosted",_e=["aws://","gs://","https://","http://","file://"]});var re={};D(re,{clearSession:()=>De,default:()=>Ko,getMem0ProxyUrl:()=>Ye,getProjects:()=>He,getProxyUrl:()=>Le,getSessionToken:()=>se,getUserInfo:()=>Be,isLoggedIn:()=>Ne,loadConfig:()=>$,saveConfig:()=>M,saveMem0ProxyUrl:()=>Ze,saveProjects:()=>Fe,saveProxyUrl:()=>Ue,saveSessionToken:()=>Me,saveUserInfo:()=>je});import{existsSync as ze,mkdirSync as Eo,readFileSync as zo,writeFileSync as Ro}from"fs";import{homedir as Re}from"os";import{join as oe}from"path";function Oe(){return process.env.ZIBBY_CONFIG_DIR||oe(Re(),".zibby")}function Te(){return oe(Oe(),"config.json")}function To(){let o=Oe();ze(o)||Eo(o,{recursive:!0})}function $(){try{let o=Te();if(ze(o)){let e=zo(o,"utf-8");return JSON.parse(e)}}catch{}return{}}function M(o){To(),Ro(Te(),JSON.stringify(o,null,2))}function se(){return $().sessionToken||null}function Me(o){let e=$();e.sessionToken=o,M(e)}function Be(){return $().user||null}function je(o){let e=$();e.user=o,M(e)}function Ne(){return se()!==null}function De(){let o=$();delete o.sessionToken,delete o.user,delete o.mem0ProxyUrl,M(o)}function Le(){return $().proxyUrl||null}function Ue(o){let e=$();e.proxyUrl=o,M(e)}function Ye(){return $().mem0ProxyUrl||null}function Ze(o){let e=$();e.mem0ProxyUrl=o,M(e)}function He(){return $().projects||[]}function Fe(o){let e=$();e.projects=o,M(e)}var Ke,Oo,Ko,ie=N(()=>{Ke=oe(Re(),".zibby"),Oo=oe(Ke,"config.json");Ko={loadConfig:$,saveConfig:M,getSessionToken:se,saveSessionToken:Me,getUserInfo:Be,saveUserInfo:je,isLoggedIn:Ne,clearSession:De,getProxyUrl:Le,saveProxyUrl:Ue,getMem0ProxyUrl:Ye,saveMem0ProxyUrl:Ze,getProjects:He,saveProjects:Fe,CONFIG_DIR:Ke,CONFIG_FILE:Oo}});var Ge={};D(Ge,{ENVIRONMENTS:()=>_,getAccountApiUrl:()=>Bo,getApiUrl:()=>Mo,getCurrentEnvironment:()=>jo,getFrontendUrl:()=>No});function Mo(){let o;if(process.env.ZIBBY_API_URL)o=process.env.ZIBBY_API_URL;else{let e=process.env.ZIBBY_ENV||"prod";_[e]?o=_[e].apiUrl:o=_.prod.apiUrl}try{let e=new URL(o);return e.protocol!=="http:"&&e.protocol!=="https:"?(console.error(`\u26A0\uFE0F Invalid API URL protocol: ${e.protocol} (only http/https allowed)`),_.prod.apiUrl):o}catch{return console.error(`\u26A0\uFE0F Invalid API URL: ${o}`),_.prod.apiUrl}}function Bo(){if(process.env.ZIBBY_ACCOUNT_API_URL)return process.env.ZIBBY_ACCOUNT_API_URL;let o=process.env.ZIBBY_ENV||"prod";return(_[o]||_.prod).accountApiUrl}function jo(){let o=process.env.ZIBBY_ENV||"prod";return _[o]||_.prod}function No(){let o;if(process.env.ZIBBY_FRONTEND_URL)o=process.env.ZIBBY_FRONTEND_URL;else{let e=process.env.ZIBBY_ENV||"prod";_[e]?o=_[e].frontendUrl:o=_.prod.frontendUrl}try{let e=new URL(o);if(e.protocol!=="http:"&&e.protocol!=="https:")return console.error(`\u26A0\uFE0F Invalid frontend URL protocol: ${e.protocol} (only http/https allowed)`),_.local.frontendUrl;if(process.env.NODE_ENV==="production"||process.env.ZIBBY_ENV==="prod"){let a=["zibby.dev","studio.zibby.dev","studio-staging.zibby.dev","zibby.app","studio.zibby.app","studio-staging.zibby.app"],i=e.hostname;if(!a.some(p=>i===p||i.endsWith(`.${p}`))&&!i.includes("localhost")&&i!=="127.0.0.1")return console.error(`\u26A0\uFE0F Untrusted frontend URL in production: ${i}`),"https://studio.zibby.dev"}return o}catch{return console.error(`\u26A0\uFE0F Invalid frontend URL: ${o}`),_.local.frontendUrl}}var _,Ve=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://account-api-prod.zibby.app",frontendUrl:process.env.ZIBBY_PROD_FRONTEND_URL||"https://studio.zibby.dev",description:"Production environment"}}});var pe={};D(pe,{__testing:()=>Go,buildDoltEnv:()=>Fo,clearConfig:()=>Ho,getActiveCredentials:()=>oo,isHosted:()=>Yo,readConfig:()=>de,refreshCredentials:()=>eo,writeConfig:()=>Zo});import{readFileSync as We,writeFileSync as le,existsSync as ce,mkdirSync as qe,chmodSync as Do}from"fs";import{join as ae}from"path";function H(o){let e=ae(o,".zibby");return{dir:e,config:ae(e,Lo),creds:ae(e,Uo)}}function de(o){let{config:e}=H(o);if(!ce(e))return null;try{let t=JSON.parse(We(e,"utf-8"));return t.mode!=="hosted"?null:t}catch{return null}}function Yo(o){return!!de(o)}function Zo(o,e){let{dir:t,config:a}=H(o);qe(t,{recursive:!0}),le(a,JSON.stringify({mode:"hosted",projectId:e.projectId,bucket:e.bucket,prefix:e.prefix,doltUrl:e.doltUrl,configuredAt:new Date().toISOString()},null,2),"utf-8")}function Ho(o){let{config:e,creds:t}=H(o);for(let a of[e,t])if(ce(a))try{le(a,"")}catch{}}function ue(o){let{creds:e}=H(o);if(!ce(e))return null;try{let t=JSON.parse(We(e,"utf-8"));return!t?.accessKeyId||!t?.secretAccessKey||!t?.sessionToken?null:t}catch{return null}}function Xe(o,e){let{dir:t,creds:a}=H(o);qe(t,{recursive:!0}),le(a,JSON.stringify(e,null,2),"utf-8");try{Do(a,384)}catch{}}function Qe(o){return o?.expiration?new Date(o.expiration).getTime()-Date.now()<Je:!0}async function eo({cwd:o,projectId:e,apiUrl:t,sessionToken:a,fetch:i=globalThis.fetch}){if(!e)throw new Error("refreshCredentials: projectId required");if(!t)throw new Error("refreshCredentials: apiUrl required");if(!a)throw new Error("refreshCredentials: sessionToken required (run `zibby login`)");let s=`${String(t).replace(/\/+$/,"")}/memory/sync-credentials`,p=await i(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({projectId:e})});if(!p.ok){let l=await p.text().catch(()=>"");throw new Error(`memory-sync credentials request failed (${p.status}): ${l||"no body"}`)}let u=await p.json();if(!u?.accessKeyId||!u?.secretAccessKey||!u?.sessionToken)throw new Error("memory-sync credentials response missing required fields");return Xe(o,{accessKeyId:u.accessKeyId,secretAccessKey:u.secretAccessKey,sessionToken:u.sessionToken,expiration:u.expiration||null,refreshedAt:new Date().toISOString()}),ue(o)}async function oo({cwd:o,apiUrl:e,sessionToken:t,fetch:a}){let i=de(o);if(!i)return null;let s=ue(o);return(!s||Qe(s))&&(s=await eo({cwd:o,projectId:i.projectId,apiUrl:e,sessionToken:t,fetch:a})),s}async function Fo({cwd:o,apiUrl:e,sessionToken:t,fetch:a}){let i=await oo({cwd:o,apiUrl:e,sessionToken:t,fetch:a});return i?{AWS_ACCESS_KEY_ID:i.accessKeyId,AWS_SECRET_ACCESS_KEY:i.secretAccessKey,AWS_SESSION_TOKEN:i.sessionToken,AWS_REGION:process.env.AWS_REGION||"ap-southeast-2"}:null}var Lo,Uo,Je,Go,me=N(()=>{Lo="memory-sync.json",Uo="memory-sync-creds.json",Je=120*1e3;Go={paths:H,readCreds:ue,writeCreds:Xe,isExpiringSoon:Qe,REFRESH_HEADROOM_MS:Je}});var to={};D(to,{memoryCompactCommand:()=>Jo,memoryCostCommand:()=>Xo,memoryInitCommand:()=>rt,memoryPullCommand:()=>tt,memoryPushCommand:()=>st,memoryRemoteAddCommand:()=>Qo,memoryRemoteInfoCommand:()=>et,memoryRemoteRemoveCommand:()=>ot,memoryRemoteUseHostedCommand:()=>nt,memoryResetCommand:()=>qo,memoryStatsCommand:()=>Wo});import n from"chalk";async function z(){try{return await import("@zibby/ui-memory")}catch{return console.log(n.yellow(`
10
+ @zibby/ui-memory is not installed.
11
+ `)),console.log(n.white(Vo)),null}}async function Wo(){let o=await z();if(!o)return;let e=process.cwd(),t=o.getStats(e);if(!t.available){console.log(n.red(`
12
+ Dolt is not installed.
13
+ `)),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
14
+ `));return}if(!t.initialized){console.log(n.yellow(`
15
+ Memory database not initialized.
16
+ `)),console.log(n.white(" Run `zibby init` or `zibby memory init` to set it up.\n"));return}console.log(n.bold.cyan(`
17
+ Zibby Test Memory
18
+ `)),console.log(n.gray(` Dolt: ${t.doltVersion}`));let a=n.gray(` ${"\u2500".repeat(40)}`);console.log(a);let i=t.counts;if(console.log(n.white(` Test runs: ${n.cyan(i.runs)} (${n.green(`${i.passed} passed`)}, ${i.failed>0?n.red(`${i.failed} failed`):n.gray(`${i.failed} failed`)})`)),console.log(n.white(` Selectors: ${n.cyan(i.selectors)} tracked`)),console.log(n.white(` Pages: ${n.cyan(i.pages)} discovered`)),console.log(n.white(` Transitions: ${n.cyan(i.transitions)} mapped`)),console.log(n.white(` Insights: ${n.cyan(i.insights||0)} saved`)),t.recentRuns.length>0){console.log(`
19
+ ${a}`),console.log(n.white(" Recent runs:"));for(let s of t.recentRuns){let p=s.passed?n.green("\u2713"):n.red("\u2717"),u=s.duration_ms?n.gray(`${(s.duration_ms/1e3).toFixed(1)}s`):"";console.log(` ${p} ${n.white(s.spec_path)} ${u}`)}}if(t.topSelectors.length>0){console.log(`
20
+ ${a}`),console.log(n.white(" Top selectors:"));for(let s of t.topSelectors){let p=s.success_count+s.failure_count,u=Math.round(s.success_count/p*100);console.log(` ${n.cyan(s.stable_id||"?")} \u2192 ${s.element_desc} (${u}%, ${p} uses)`)}}if(t.log){console.log(`
21
+ ${a}`),console.log(n.white(" Recent commits:"));let s=t.log.split(`
22
+ `).filter(p=>p.startsWith("commit")||p.trim().startsWith("run ")).slice(0,10);for(let p of s)console.log(n.gray(` ${p.trim()}`))}console.log("")}async function qo(o){let e=await z();if(!e)return;let t=process.cwd();if(!o.force){console.log(n.yellow(`
23
+ This will permanently delete the memory database.
24
+ `)),console.log(n.white(` Run with --force to confirm: zibby memory reset --force
25
+ `));return}let a=e.resetMemory(t);console.log(a?n.green(`
26
+ Memory database reset.
27
+ `):n.gray(`
28
+ No memory database found.
29
+ `))}async function Jo(o){let e=await z();if(!e)return;let t=process.cwd(),a=e.getStats(t);if(!a.initialized){console.log(n.yellow(`
30
+ Memory database not initialized.
31
+ `));return}let i=o.maxRuns||50,s=o.maxAge||90;console.log(n.white(`
32
+ Compacting memory (keep last ${i} runs/spec, prune data older than ${s}d)...`));let p=a.counts;if(e.compactMemory(t,{maxRuns:i,maxAgeDays:s}).pruned){let l=e.getStats(t).counts,f=h=>p[h]-l[h];console.log(n.green(" Done.")),f("runs")>0&&console.log(n.gray(` Pruned ${f("runs")} old runs`)),f("selectors")>0&&console.log(n.gray(` Pruned ${f("selectors")} stale selectors`)),f("insights")>0&&console.log(n.gray(` Pruned ${f("insights")} old insights`)),f("transitions")>0&&console.log(n.gray(` Pruned ${f("transitions")} stale transitions`)),console.log(n.gray(` Dolt GC completed
33
+ `))}else console.log(n.gray(` Nothing to compact.
34
+ `))}async function Xo(){let o=await z();if(!o)return;let e=process.cwd(),t=o.getCostStats(e);if(!t){console.log(n.yellow(`
35
+ Memory database not initialized.
36
+ `)),console.log(n.white(" Run `zibby memory init` first.\n"));return}if(t.available===!1){console.log(n.yellow(`
37
+ No usage data yet${t.reason?` (${t.reason})`:""}.
38
+ `)),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.
39
+ `));return}console.log(n.bold.cyan(`
40
+ Zibby \u2014 LLM Cost Report
41
+ `));let a=n.gray(` ${"\u2500".repeat(60)}`),i=t.totals;if(console.log(a),console.log(n.white(` Runs with usage data: ${n.cyan(i.runs)}`)),console.log(n.white(` Total input tokens: ${n.cyan(B(i.input))}`)),console.log(n.white(` Total output tokens: ${n.cyan(B(i.output))}`)),console.log(n.white(` Total cache reads: ${n.cyan(B(i.cache_read))} ${n.gray("(billed at ~10% of normal input rate)")}`)),console.log(n.white(` Total cache creation: ${n.cyan(B(i.cache_creation))} ${n.gray("(billed at ~125% of normal input rate)")}`)),t.by_domain.length>0){console.log(`
42
+ ${a}`),console.log(n.white(" By domain:"));for(let s of t.by_domain.slice(0,10)){let p=s.runs>0?Math.round((s.input+s.output)/s.runs):0;console.log(` ${n.cyan(s.domain.padEnd(30))} ${n.gray(`${s.runs} runs \xB7 ~${B(p)}/run avg`)}`)}}if(t.by_spec.length>0){console.log(`
43
+ ${a}`),console.log(n.white(" By spec:"));for(let s of t.by_spec.slice(0,10)){let p=s.runs>0?Math.round((s.input+s.output)/s.runs):0;console.log(` ${n.cyan(String(s.spec_path).padEnd(40))} ${n.gray(`${s.runs} runs \xB7 ~${B(p)}/run avg`)}`)}}if(t.recent.length>0){console.log(`
44
+ ${a}`),console.log(n.white(" Last 10 runs:"));for(let s of t.recent.slice(0,10)){let p=s.passed?n.green("\u2713"):n.red("\u2717"),u=(s.input_tokens||0)+(s.output_tokens||0),l=(s.cache_read_tokens||0)>0?n.gray(` \xB7 cache read ${B(s.cache_read_tokens)}`):"";console.log(` ${p} ${n.gray(s.run_at.slice(0,16))} ${n.cyan(B(u).padStart(8))} ${n.white(s.spec_path||"")}${l}`)}}console.log("")}function B(o){return o==null?"\u2014":o<1e3?String(o):o<1e6?`${(o/1e3).toFixed(1)}K`:`${(o/1e6).toFixed(2)}M`}async function Qo(o,e={}){let t=await z();if(!t)return;o||(console.log(n.red(`
45
+ Usage: zibby memory remote add <url> [--name origin]
46
+ `)),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 a=process.cwd(),i=e.name||"origin";if(!t.memoryRemoteAdd(a,o,i)){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(i)} \u2192 ${o}`)),console.log(n.gray(" Next step: zibby memory pull (or just run any test \u2014 middleware auto-pulls/pushes)")),console.log("")}async function et(){let o=await z();if(!o)return;let e=o.memoryRemoteInfo(process.cwd());if(console.log(""),!e){console.log(n.yellow(` No memory remote configured.
47
+ `)),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.
48
+ `));return}console.log(n.bold.cyan(" Memory remote")),console.log(` ${n.cyan(e.name||"origin")}: ${e.url||"(unknown)"}`),console.log("")}async function ot(o="origin"){let e=await z();if(!e)return;let t=e.memoryRemoteRemove(process.cwd(),o);console.log(""),t?(console.log(n.green(` \u2713 Removed remote ${o}.`)),console.log(n.gray(" Memory is now local-only."))):console.log(n.gray(` No remote named ${o} to remove.`)),console.log("")}async function tt(){let o=await z();if(!o)return;console.log(n.cyan(`
49
+ Pulling team memory from remote...`));let e=o.memorySyncPull(process.cwd());e.pulled?console.log(n.green(` \u2713 Pulled latest. Local memory now reflects the team's shared knowledge.
50
+ `)):(console.log(n.yellow(` \u26A0 Pull skipped \u2014 ${e.error||"unknown reason"}.`)),console.log(n.gray(" Did you run `zibby memory remote add <url>` first?\n")))}async function nt(o={}){let e=await z();if(!e)return;let{join:t}=await import("path"),{existsSync:a}=await import("fs"),i=o.cwd||process.cwd(),s=o.projectId;if(!s){let I=t(i,".zibby.config.mjs");if(a(I))try{let x=(await import(`file://${I}?t=${Date.now()}`)).default;s=x?.projectId||x?.project?.id}catch{}}s||(console.log(n.red(`
51
+ Could not determine projectId.
52
+ `)),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>.
53
+ `)),process.exit(1));let{getApiUrl:p}=await Promise.resolve().then(()=>(Ve(),Ge)),{getSessionToken:u}=await Promise.resolve().then(()=>(ie(),re)),l=p(),f=u();f||(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.
54
+ `)),process.exit(1)),console.log(n.cyan(`
55
+ Configuring hosted memory-sync...`));let h;try{let I=`${l.replace(/\/+$/,"")}/memory/sync-config?projectId=${encodeURIComponent(s)}`,A=await fetch(I,{headers:{Authorization:`Bearer ${f}`}});if(!A.ok){let x=await A.text().catch(()=>"");throw new Error(`backend returned ${A.status}: ${x||"no body"}`)}h=await A.json()}catch(I){console.log(n.red(`
56
+ Failed: ${I.message}
57
+ `)),process.exit(1)}let{writeConfig:v}=await Promise.resolve().then(()=>(me(),pe));v(i,{projectId:s,bucket:h.bucket,prefix:h.prefix,doltUrl:h.doltUrl}),e.memoryRemoteAdd(i,h.doltUrl)||(console.log(n.yellow(`
58
+ 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:w}=await Promise.resolve().then(()=>(me(),pe));try{await w({cwd:i,projectId:s,apiUrl:l,sessionToken:f})}catch(I){console.log(n.yellow(`
59
+ Config saved, but initial credential fetch failed: ${I.message}`)),console.log(n.gray(` Will retry on first push/pull.
60
+ `))}console.log(""),console.log(n.green(" \u2713 Hosted memory-sync configured.")),console.log(n.gray(` Bucket: ${h.bucket}`)),console.log(n.gray(` Prefix: ${h.prefix} \u2190 your tenant slot`)),console.log(n.gray(` Dolt: ${h.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 st(){let o=await z();if(!o)return;console.log(n.cyan(`
61
+ Pushing local memory to team remote...`));let e=o.memorySyncPush(process.cwd());e.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 ${e.error||"unknown reason"}.
62
+ `))}async function rt(){let o=await z();if(!o)return;let e=process.cwd();if(!o.DoltDB.isAvailable()){console.log(n.red(`
63
+ Dolt is not installed.
64
+ `)),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
65
+ `));return}let{created:t,available:a}=o.initMemory(e);t?console.log(n.green(`
66
+ Memory database initialized at .zibby/memory/
67
+ `)):a&&console.log(n.gray(`
68
+ Memory database already initialized.
69
+ `))}var Vo,no=N(()=>{Vo=`
70
+ Install @zibby/ui-memory and Dolt to enable test memory:
71
+
72
+ npm install @zibby/ui-memory # add the package
73
+ brew install dolt # macOS
74
+ # or: curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash
75
+ `});var go={};D(go,{setupCiCommand:()=>ft,setupPlaywrightMcpCommand:()=>mo,testWithVideoCommand:()=>ht});import{spawn as ye,execSync as fe}from"child_process";import{join as L,dirname as he,resolve as io}from"path";import{readFileSync as ao,writeFileSync as lo,existsSync as F,mkdirSync as co}from"fs";import{homedir as uo}from"os";import{createRequire as it}from"module";import C from"chalk";function at(){try{return he(ge.resolve("@zibby/core/package.json"))}catch{return null}}function po(o){try{return fe(`command -v ${o}`,{stdio:"pipe"}),!0}catch{return!1}}function lt(){try{let o=ge.resolve("@zibby/mcp-browser/bin/mcp-browser-zibby.js");if(F(o))return o}catch{}try{let o=ge.resolve("@playwright/mcp/package.json"),e=he(o),t=JSON.parse(ao(o,"utf-8")),a=typeof t.bin=="string"?t.bin:t.bin?.["playwright-mcp"];if(a){let s=L(e,a);if(F(s))return s}let i=L(e,"cli.js");if(F(i))return i}catch{}return null}function so(o,e,t={}){return new Promise((a,i)=>{let s=ye(o,e,{stdio:"inherit",...t});s.on("close",p=>a(p??1)),s.on("error",i)})}async function ct(o){return po("playwright")?await so("playwright",["install","ffmpeg"],{cwd:o})===0:await so("npx",["--yes","playwright","install","ffmpeg"],{cwd:o})===0}function dt({headed:o=!1,viewport:e=null}){let t=process.execPath,a=he(t),i=lt(),s=Number(e?.width)||1280,p=Number(e?.height)||720,u=`${s}x${p}`,l=[];l.push(`--viewport-size=${u}`,"--output-dir=test-results"),o||l.push("--headless");let f;i?f={command:t,args:[i,...l],env:{PATH:`${a}:/usr/bin:/bin:/usr/sbin:/sbin`}}:f={command:"npx",args:["-y","@playwright/mcp",...l],env:{PATH:`${a}:/usr/bin:/bin:/usr/sbin:/sbin`}},f.description="Zibby MCP Browser - Playwright MCP with Zibby defaults";let h=L(uo(),".cursor"),v=L(h,"mcp.json");F(h)||co(h,{recursive:!0});let w={mcpServers:{}};if(F(v))try{w=JSON.parse(ao(v,"utf-8")),(!w.mcpServers||typeof w.mcpServers!="object")&&(w.mcpServers={})}catch{w={mcpServers:{}}}w.mcpServers["playwright-official"]=f,lo(v,`${JSON.stringify(w,null,2)}
76
+ `,"utf-8")}async function ut(){let o=at();if(!o)return;let e=L(o,"scripts","patch-cursor-mcp.js");if(F(e))try{await new Promise((t,a)=>{let i=ye(process.execPath,[e],{cwd:process.cwd(),stdio:"ignore"});i.on("close",s=>t(s??0)),i.on("error",a)})}catch{}}function pt(o){return io(o).replace(/^\/+/,"").replace(/\//g,"-")}function mt(o){let e=String(o||""),t=e.split(`
77
+ `).find(s=>/playwright-official/i.test(s)&&/APPROVAL|🔑/i.test(s));if(t){let s=t.match(/=>\s*(\S+)/);if(s)return s[1]}let a=e.match(/playwright-official[^=]*=>\s*(\S+)/);if(a)return a[1];let i=e.match(/playwright-official-[a-f0-9]+/i);return i?i[0]:null}function gt(o,e){let t=pt(o),a=L(uo(),".cursor","projects",t);co(a,{recursive:!0});let i=L(a,"mcp-approvals.json");return lo(i,`${JSON.stringify([e],null,2)}
78
+ `,"utf-8"),i}function ro(o){try{return fe("cursor-agent mcp list",{cwd:o,encoding:"utf-8",stdio:["ignore","pipe","pipe"],env:process.env,maxBuffer:2*1024*1024})}catch(e){let t=e.stdout!=null?String(e.stdout):"",a=e.stderr!=null?String(e.stderr):"";return t+a}}function yt(o){try{return fe("cursor-agent mcp enable playwright-official",{cwd:o,encoding:"utf-8",stdio:["ignore","pipe","pipe"],env:process.env,maxBuffer:1024*1024}),!0}catch{return!1}}async function mo(o={}){let e=!!o.headed,t=o.viewport||{width:1280,height:720};if(!process.execPath)throw new Error("Node.js runtime not found");let a=await ct(process.cwd());console.log(a?C.gray(" \u2713 ffmpeg installed for Playwright video"):C.yellow(" \u26A0 Could not install ffmpeg (video may be unavailable)")),dt({headed:e,viewport:t}),await ut();let i=io(process.cwd());if(po("cursor-agent")){ro(i);let s=yt(i);s&&console.log(C.gray(" \u2713 cursor-agent: mcp enable playwright-official"));let p=ro(i),u=mt(p);if(u)try{let l=gt(i,u);console.log(C.gray(` \u2713 MCP auto-approval key saved (${l})`))}catch(l){console.log(C.yellow(` \u26A0 Could not write mcp-approvals.json: ${l.message}`))}else s||(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(o){try{console.log(C.cyan(`
5
79
  \u{1F680} Running CI setup...
6
- `)),await ae({headed:!1,cloudSync:!0,viewport:{width:1280,height:720}}),console.log(x.green(`
80
+ `)),await mo({headed:!1,cloudSync:!0,viewport:{width:1280,height:720}}),console.log(C.green(`
7
81
  \u2705 CI/CD setup complete!
8
- `))}catch(e){console.log(x.red(`
82
+ `))}catch(e){console.log(C.red(`
9
83
  \u274C Error: ${e.message}
10
- `)),process.exit(1)}}async function Ke(t,e){try{let a=["playwright","test",t||"tests/","--project=chromium"];e.headed&&a.push("--headed"),console.log(x.cyan(`
84
+ `)),process.exit(1)}}async function ht(o,e){try{let t=["playwright","test",o||"tests/","--project=chromium"];e.headed&&t.push("--headed"),console.log(C.cyan(`
11
85
  \u{1F3A5} Running tests with video recording...
12
- `)),console.log(x.gray("\u2501".repeat(50)));let l=H("npx",a,{cwd:process.cwd(),stdio:"inherit"});l.on("close",n=>{n===0?console.log(x.green(`
86
+ `)),console.log(C.gray("\u2501".repeat(50)));let a=ye("npx",t,{cwd:process.cwd(),stdio:"inherit"});a.on("close",i=>{i===0?console.log(C.green(`
13
87
  \u2705 Tests complete!
14
- `)):(console.log(x.red(`
15
- \u274C Tests failed with code ${n}
16
- `)),process.exit(n))}),l.on("error",n=>{console.log(x.red(`
17
- \u274C Error: ${n.message}
18
- `)),process.exit(1)})}catch(a){console.log(x.red(`
19
- \u274C Error: ${a.message}
20
- `)),process.exit(1)}}var G,ce=ge(()=>{G=ve(import.meta.url)});import{mkdir as M,writeFile as h,readFile as A}from"fs/promises";import{existsSync as P,readdirSync as Me}from"fs";import{join as p,resolve as pe,dirname as Be}from"path";import{homedir as k}from"os";import D from"inquirer";import o from"chalk";import I from"ora";import{spawn as R,execSync as L}from"child_process";import{fileURLToPath as ze}from"url";import{createRequire as de}from"module";import{existsSync as ye,readFileSync as he,writeFileSync as be,mkdirSync as we}from"fs";import{join as q}from"path";import{homedir as U}from"os";var O={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 J(){return q(U(),".zibby","config.json")}function V(){try{let t=J();return ye(t)?JSON.parse(he(t,"utf-8")):{}}catch{return{}}}function X(t,e){let a=q(U(),".zibby");we(a,{recursive:!0});let l=J(),n=V(),m=e?O[e]:null;m&&((!n.agentKeys||typeof n.agentKeys!="object")&&(n.agentKeys={}),n.agentKeys[m.envVar]=String(t).trim()),delete n.agentApiKey,be(l,`${JSON.stringify(n,null,2)}
21
- `,"utf-8")}var Te=ze(import.meta.url),Re=Be(Te),ue=de(import.meta.url);async function Ye(){try{let t=process.platform==="win32",e=L("npm config get prefix",{encoding:"utf-8"}).trim(),a=t?e:`${e}/bin`,l=a.replace(/^~/,k()),n=t?";":":";if(process.env.PATH.split(n).some(f=>{let v=f.replace(/^~/,k());return v===l||v===a}))return;if(process.env.CI||process.env.ZIBBY_CI||!process.stdin.isTTY){console.log(o.yellow("\u26A0\uFE0F npm global bin not in PATH")),console.log(o.gray(` Location: ${l}`)),console.log(o.gray(` Add it manually: export PATH="${l}:$PATH"
22
- `));return}console.log(o.yellow("\u26A0\uFE0F npm global bin not in PATH")),console.log(o.gray(` Location: ${l}`)),console.log();let{shouldAddPath:r}=await D.prompt([{type:"confirm",name:"shouldAddPath",message:"Add npm global bin to your shell PATH automatically?",default:!0}]);if(!r){t?(console.log(o.gray(`
23
- \u{1F4A1} To add manually on Windows:`)),console.log(o.gray(' 1. Search "Environment Variables" in Start menu')),console.log(o.gray(' 2. Edit "Path" in User variables')),console.log(o.gray(` 3. Add: ${l}
24
- `))):(console.log(o.gray(`
25
- \u{1F4A1} To add manually, run:`)),console.log(o.gray(` echo 'export PATH="${l}:$PATH"' >> ~/.zshrc`)),console.log(o.gray(` source ~/.zshrc
26
- `)));return}if(t){console.log(o.yellow("\u26A0\uFE0F Cannot auto-add PATH on Windows")),console.log(o.gray(" Please add manually:")),console.log(o.gray(' 1. Search "Environment Variables" in Start menu')),console.log(o.gray(' 2. Edit "Path" in User variables')),console.log(o.gray(` 3. Add: ${l}
27
- `));return}let w=process.env.SHELL||"",g="";if(w.includes("zsh"))g=p(k(),".zshrc");else if(w.includes("bash"))g=P(p(k(),".bashrc"))?p(k(),".bashrc"):p(k(),".bash_profile");else{console.log(o.yellow(`\u26A0\uFE0F Unknown shell: ${w}`)),console.log(o.gray(" Please add manually:")),console.log(o.gray(` export PATH="${l}:$PATH"`));return}if(P(g)){let f=await A(g,"utf-8");if(f.includes(l)||f.includes("npm")&&f.includes("global")&&f.includes("bin")){console.log(o.yellow(`\u26A0\uFE0F PATH entry found in ${g} but not active`)),console.log(o.gray(` Run: source ${g}
28
- `));return}}let C=`
88
+ `)):(console.log(C.red(`
89
+ \u274C Tests failed with code ${i}
90
+ `)),process.exit(i))}),a.on("error",i=>{console.log(C.red(`
91
+ \u274C Error: ${i.message}
92
+ `)),process.exit(1)})}catch(t){console.log(C.red(`
93
+ \u274C Error: ${t.message}
94
+ `)),process.exit(1)}}var ge,yo=N(()=>{ge=it(import.meta.url)});import{mkdir as U,writeFile as S,readFile as V}from"fs/promises";import{existsSync as P,readdirSync as bt,readFileSync as wt}from"fs";import{join as b,resolve as fo,dirname as vt}from"path";import{homedir as K}from"os";import Y from"inquirer";import r from"chalk";import T from"ora";import{spawn as G,execSync as X}from"child_process";import{fileURLToPath as xt}from"url";import{createRequire as ho}from"module";import{existsSync as vo,readFileSync as xo,writeFileSync as ko,mkdirSync as Io}from"fs";import{join as we}from"path";import{homedir as ve}from"os";var Q={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 xe(){return we(ve(),".zibby","config.json")}function ee(){try{let o=xe();return vo(o)?JSON.parse(xo(o,"utf-8")):{}}catch{return{}}}function ke(o,e){let t=e?Q[e]:null;t&&te(t.envVar,o)}function te(o,e){if(!o||typeof o!="string"||!e||typeof e!="string")return;let t=we(ve(),".zibby");Io(t,{recursive:!0});let a=xe(),i=ee();(!i.agentKeys||typeof i.agentKeys!="object")&&(i.agentKeys={}),i.agentKeys[o]=String(e).trim(),delete i.agentApiKey,ko(a,`${JSON.stringify(i,null,2)}
95
+ `,"utf-8")}function kt(){if(process.platform==="darwin")try{let o=X('security find-generic-password -s "Claude Code-credentials" -w',{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim();if(o){let e=JSON.parse(o);if(e?.claudeAiOauth?.accessToken)return e.claudeAiOauth}}catch{}try{let o=b(K(),".claude",".credentials.json");return P(o)&&JSON.parse(wt(o,"utf-8"))?.claudeAiOauth||null}catch{return null}}async function It(){let o=kt(),e=o?.accessToken||null,t=o?.subscriptionType?o.subscriptionType.charAt(0).toUpperCase()+o.subscriptionType.slice(1):null,a=process.platform==="darwin"?"macOS Keychain":"~/.claude/.credentials.json",i=process.env.ANTHROPIC_API_KEY||ee().agentKeys?.ANTHROPIC_API_KEY;console.log(""),console.log(r.cyan(" Claude has two billing modes \u2014 choose which you have:")),console.log("");let s=e?t?`Subscription (OAuth) \u2014 Claude ${t} plan detected (${a}, ***${e.slice(-4)})`:`Subscription (OAuth) \u2014 auto-detected (${a}, ***${e.slice(-4)})`:"Subscription (OAuth) \u2014 Claude Pro / Max plan billing",{kind:p}=await Y.prompt([{type:"select",name:"kind",message:"Which Claude credential do you want to use?",choices:[{name:s,value:"oauth"},{name:i?`API key \u2014 found one (***${i.slice(-4)}), pay-per-token billing`:"API key \u2014 pay-per-token billing via console.anthropic.com",value:"api"}],default:e?"oauth":i?"api":"oauth"}]);if(p==="skip")return{kind:"skip"};if(p==="oauth"){if(e)return{kind:"oauth",token:e,subscriptionType:o?.subscriptionType};console.log(""),console.log(r.gray(" How to get an OAuth subscription token:")),console.log(r.gray(" 1. Install claude: npm install -g @anthropic-ai/claude-code")),console.log(r.gray(" 2. Run: claude")),console.log(r.gray(" \u2192 log in via browser \u2192 quit when shell appears")),console.log(r.gray(" 3. Read your token:")),process.platform==="darwin"?(console.log(r.gray(' (macOS) security find-generic-password -s "Claude Code-credentials" -w')),console.log(r.gray(" | jq -r .claudeAiOauth.accessToken"))):console.log(r.gray(" cat ~/.claude/.credentials.json | jq -r .claudeAiOauth.accessToken")),console.log("");let{token:l}=await Y.prompt([{type:"password",name:"token",message:"Paste OAuth token (or press Enter to skip):",mask:"*"}]);return l&&l.trim()?{kind:"oauth",token:l.trim()}:{kind:"skip"}}if(i)return{kind:"api",token:i};let{token:u}=await Y.prompt([{type:"password",name:"token",message:"Paste Anthropic API key (from https://console.anthropic.com/settings/keys, or press Enter to skip):",mask:"*"}]);return u&&u.trim()?{kind:"api",token:u.trim()}:{kind:"skip"}}var At=xt(import.meta.url),Ct=vt(At),bo=ho(import.meta.url);async function Pt(){try{let o=process.platform==="win32",e=X("npm config get prefix",{encoding:"utf-8"}).trim(),t=o?e:`${e}/bin`,a=t.replace(/^~/,K()),i=o?";":":";if(process.env.PATH.split(i).some(v=>{let w=v.replace(/^~/,K());return w===a||w===t}))return;if(process.env.CI||process.env.ZIBBY_CI||!process.stdin.isTTY){console.log(r.yellow("npm global bin not in PATH")),console.log(r.gray(` Location: ${a}`)),console.log(r.gray(` Add it manually: export PATH="${a}:$PATH"
96
+ `));return}console.log(r.yellow("npm global bin not in PATH")),console.log(r.gray(` Location: ${a}`)),console.log();let{shouldAddPath:u}=await Y.prompt([{type:"confirm",name:"shouldAddPath",message:"Add npm global bin to your shell PATH automatically?",default:!0}]);if(!u){o?(console.log(r.gray(`
97
+ To add manually on Windows:`)),console.log(r.gray(' 1. Search "Environment Variables" in Start menu')),console.log(r.gray(' 2. Edit "Path" in User variables')),console.log(r.gray(` 3. Add: ${a}
98
+ `))):(console.log(r.gray(`
99
+ To add manually, run:`)),console.log(r.gray(` echo 'export PATH="${a}:$PATH"' >> ~/.zshrc`)),console.log(r.gray(` source ~/.zshrc
100
+ `)));return}if(o){console.log(r.yellow("Cannot auto-add PATH on Windows")),console.log(r.gray(" Please add manually:")),console.log(r.gray(' 1. Search "Environment Variables" in Start menu')),console.log(r.gray(' 2. Edit "Path" in User variables')),console.log(r.gray(` 3. Add: ${a}
101
+ `));return}let l=process.env.SHELL||"",f="";if(l.includes("zsh"))f=b(K(),".zshrc");else if(l.includes("bash"))f=P(b(K(),".bashrc"))?b(K(),".bashrc"):b(K(),".bash_profile");else{console.log(r.yellow(`Unknown shell: ${l}`)),console.log(r.gray(" Please add manually:")),console.log(r.gray(` export PATH="${a}:$PATH"`));return}if(P(f)){let v=await V(f,"utf-8");if(v.includes(a)||v.includes("npm")&&v.includes("global")&&v.includes("bin")){console.log(r.yellow(`PATH entry found in ${f} but not active`)),console.log(r.gray(` Run: source ${f}
102
+ `));return}}let h=`
29
103
  # npm global bin (added by zibby)
30
- export PATH="${l}:$PATH"
31
- `;await h(g,(P(g)?await A(g,"utf-8"):"")+C),console.log(o.green(`\u2705 Added to ${g}`)),console.log(o.yellow(`
32
- \u{1F4A1} Run this to activate in current session:`)),console.log(o.gray(` source ${g}
33
- `))}catch{}}async function ft(t,e){console.log(o.bold.cyan(`
34
- \u{1F3AD} Welcome to Zibby Test Automation!
35
- `));let a=!e.skipMemory,l=["dolt","mem0"].includes(String(e.memoryBackend||"").toLowerCase())?String(e.memoryBackend).toLowerCase():"dolt";await Ye();let n=t?pe(process.cwd(),t):process.cwd(),m=t||"zibby-tests",y=!!t;y&&P(n)&&(console.log(o.red(`
36
- \u274C Directory "${t}" already exists!
37
- `)),process.exit(1)),!y&&P(p(n,".zibby.config.mjs"))&&!e.force&&(console.log(o.yellow(`
38
- \u26A0\uFE0F Zibby is already initialized in this directory!
39
- `)),console.log(o.white("Config file found: .zibby.config.mjs")),console.log(o.gray(`Use --force or -f to reinitialize
40
- `)),process.exit(0)),e.force&&!y&&console.log(o.cyan(`
104
+ export PATH="${a}:$PATH"
105
+ `;await S(f,(P(f)?await V(f,"utf-8"):"")+h),console.log(r.green(`Added to ${f}`)),console.log(r.yellow(`
106
+ Run this to activate in current session:`)),console.log(r.gray(` source ${f}
107
+ `))}catch{}}async function yn(o,e){let t=e.template==="browser-test-automation";console.log(t?`
108
+ Zibby Test Automation
109
+ `:`
110
+ Zibby Project Init
111
+ `);let a=!e.skipMemory,i=["dolt","mem0"].includes(String(e.memoryBackend||"").toLowerCase())?String(e.memoryBackend).toLowerCase():"dolt";await Pt();let s=o?fo(process.cwd(),o):process.cwd(),p=o||"zibby-tests",u=!!o;u&&P(s)&&(console.log(r.red(`
112
+ Directory "${o}" already exists!
113
+ `)),process.exit(1)),!u&&P(b(s,".zibby.config.mjs"))&&!e.force&&(console.log(r.yellow(`
114
+ Zibby is already initialized in this directory!
115
+ `)),console.log(r.white("Config file found: .zibby.config.mjs")),console.log(r.gray(`Use --force or -f to reinitialize
116
+ `)),process.exit(0)),e.force&&!u&&console.log(r.cyan(`
41
117
  Reinitializing Zibby configuration...
42
- `));let r;if(e.agent&&(e.headed||e.headless))console.log(o.cyan(`Setting up with provided options...
43
- `)),r={agent:e.agent,browserMode:e.headless?"headless":"headed",apiKey:e.apiKey||null,cloudSync:!!(e.cloudSync||e.apiKey)};else{if(e.agent)r={agent:e.agent};else{let{agent:S}=await D.prompt([{type:"select",name:"agent",message:"Which AI agent do you prefer?",choices:[{name:"Cursor",value:"cursor"},{name:"Claude (Anthropic)",value:"claude"},{name:"Codex (OpenAI)",value:"codex"},{name:"Gemini (Google)",value:"gemini"}],default:"cursor"}]);r={agent:S}}let f=O[r.agent];if(f&&!e.agentKey&&!(process.env.CI||process.env.ZIBBY_CI||!process.stdin.isTTY)){let S=V(),B=process.env[f.envVar]||S.agentKeys?.[f.envVar],E=B?`***${B.slice(-4)}`:null,s=E?`${f.label} found (${E}). Press Enter to keep, or paste a new key:`:`Enter ${f.label} (from ${f.url}, or press Enter to skip):`,{agentKey:c}=await D.prompt([{type:"password",name:"agentKey",message:s,mask:"*"}]);c&&c.trim()&&(r.agentKey=c.trim())}let v=[];if(!e.headed&&!e.headless&&v.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"}),e.apiKey||v.push({type:"input",name:"apiKey",message:"Enable cloud sync? Enter project ZIBBY_API_KEY (or press Enter to skip):"}),v.length>0){let S=await D.prompt(v);Object.assign(r,S)}r.browserMode=e.headless?"headless":e.headed?"headed":r.browserMode,r.apiKey=e.apiKey||r.apiKey,r.cloudSync=!!(e.cloudSync||e.apiKey||r.apiKey&&r.apiKey.trim())}e.agentKey&&(r.agentKey=e.agentKey);let g=O[r.agent];r.agentKey&&(X(r.agentKey,r.agent),console.log(o.gray(" \u2713 Agent API key saved to ~/.zibby/config.json"))),r.mcp="playwright",r.setupMcp=r.agent==="cursor";let C=I("Setting up Zibby...").start();try{if(y&&await M(n,{recursive:!0}),await M(p(n,"test-specs/examples"),{recursive:!0}),await M(p(n,"tests"),{recursive:!0}),await M(p(n,".zibby/output"),{recursive:!0}),await M(p(n,".zibby/commands"),{recursive:!0}),a&&l==="dolt")try{let{initMemory:s,DoltDB:c}=await import("@zibby/memory");if(c.isAvailable()){let{created:i}=s(n);i&&(C.text="Initialized test memory database (Dolt)...")}else C.text="Dolt not found \u2014 skipping memory database (brew install dolt)"}catch{}C.text="Scaffolding workflow graph...";let{TemplateFactory:f}=await import("@zibby/core/templates"),v=e.template||"browser-test-automation";try{let{graphPath:s,nodesPath:c,readmePath:i,resultHandlerPath:u,template:d}=f.getTemplateFiles(v),b=p(n,".zibby"),z=await A(s,"utf-8");if(await h(p(b,"graph.mjs"),z),u){let $=await A(u,"utf-8");await h(p(b,"result-handler.mjs"),$)}let Y=await A(i,"utf-8");await h(p(b,"README.md"),Y),await M(p(b,"nodes"),{recursive:!0});let{readdirSync:_}=await import("fs"),j=_(c);for(let $ of j){let Z=await A(p(c,$),"utf-8");!a&&$==="execute-live.mjs"&&(Z=Z.replace("skills: [SKILLS.BROWSER, SKILLS.MEMORY],","skills: [SKILLS.BROWSER],")),await h(p(b,"nodes",$),Z)}let N=p(d.path,"chat.mjs");if(P(N)){let $=await A(N,"utf-8");await h(p(b,"chat.mjs"),$)}}catch(s){throw C.fail(`Failed to scaffold template: ${s.message}`),s}C.text="Generating configuration files...";let S=je(r,e,{memoryBackend:l});if(await h(p(n,".zibby.config.mjs"),S),await h(p(n,".env.example"),Oe(r,l)),r.apiKey&&r.apiKey.trim()){let s=p(n,".env"),c=r.apiKey.trim();if(P(s)){let i=await A(s,"utf8");/^ZIBBY_API_KEY=/m.test(i)?i=i.replace(/^ZIBBY_API_KEY=.*/m,`ZIBBY_API_KEY=${c}`):/^#\s*ZIBBY_API_KEY=/m.test(i)?i=i.replace(/^#\s*ZIBBY_API_KEY=.*/m,`ZIBBY_API_KEY=${c}`):i=`${i.trimEnd()}
118
+ `));let l;if(e.agent&&(e.headed||e.headless))console.log(r.cyan(`Setting up with provided options...
119
+ `)),l={agent:e.agent,browserMode:e.headless?"headless":"headed",apiKey:e.apiKey||null,cloudSync:!!(e.cloudSync||e.apiKey)};else{if(e.agent)l={agent:e.agent};else{let{agent:x}=await Y.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:x}}let w=Q[l.agent],I=!(process.env.CI||process.env.ZIBBY_CI||!process.stdin.isTTY);if(l.agent==="claude"&&!e.agentKey&&I){let x=await It();x?.kind==="oauth"&&x.token?l.claudeOauthToken=x.token:x?.kind==="api"&&x.token&&(l.agentKey=x.token)}else if(w&&!e.agentKey&&I){let x=ee(),c=process.env[w.envVar]||x.agentKeys?.[w.envVar],m=c?`***${c.slice(-4)}`:null,d=m?`${w.label} found (${m}). Press Enter to keep, or paste a new key:`:`Enter ${w.label} (from ${w.url}, or press Enter to skip):`,{agentKey:y}=await Y.prompt([{type:"password",name:"agentKey",message:d,mask:"*"}]);y&&y.trim()&&(l.agentKey=y.trim())}let A=[];if(t&&!e.headed&&!e.headless&&A.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&&!e.apiKey&&A.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:"}),A.length>0){let x=await Y.prompt(A);Object.assign(l,x)}l.browserMode=e.headless?"headless":e.headed?"headed":l.browserMode,l.apiKey=e.apiKey||l.apiKey,l.cloudSync=!!(e.cloudSync||e.apiKey||l.apiKey&&l.apiKey.trim())}e.agentKey&&(l.agentKey=e.agentKey),e.agentOauthToken&&l.agent==="claude"&&(l.claudeOauthToken=e.agentOauthToken);let h=Q[l.agent];l.claudeOauthToken&&(te("CLAUDE_CODE_OAUTH_TOKEN",l.claudeOauthToken),console.log(r.gray(" Claude OAuth subscription token saved to ~/.zibby/config.json")),console.log(r.gray(" Used by: zibby test / chat / workflow run / workflow start"))),l.agentKey&&(ke(l.agentKey,l.agent),console.log(r.gray(" Agent API key saved to ~/.zibby/config.json"))),l.mcp="playwright",l.setupMcp=l.agent==="cursor";let v=T("Setting up Zibby...").start();try{if(u&&await U(s,{recursive:!0}),t&&(await U(b(s,"test-specs/examples"),{recursive:!0}),await U(b(s,"tests"),{recursive:!0})),await U(b(s,".zibby/output"),{recursive:!0}),await U(b(s,".zibby/commands"),{recursive:!0}),a&&i==="dolt")try{let{initMemory:c,DoltDB:m}=await import("@zibby/ui-memory");if(m.isAvailable()){let{created:d}=c(s);d&&(v.text="Initialized test memory database (Dolt)...")}else v.text="Dolt not found \u2014 skipping memory database (brew install dolt)"}catch{}let w=e.template,I=w&&w!=="none"&&w!=="false";if(I){v.text=`Scaffolding workflow template: ${w}...`;try{let{writeTemplateFiles:c}=await Promise.resolve().then(()=>(Pe(),Ce));await c(s,w,{enableMemory:a})}catch(c){throw v.fail(`Failed to scaffold template: ${c.message}`),c}}else await U(b(s,".zibby"),{recursive:!0});v.text="Generating configuration files...";let A=_t(l,e,{memoryBackend:i});if(await S(b(s,".zibby.config.mjs"),A),await S(b(s,".env.example"),St(l,i)),l.apiKey&&l.apiKey.trim()){let c=b(s,".env"),m=l.apiKey.trim();if(P(c)){let d=await V(c,"utf8");/^ZIBBY_API_KEY=/m.test(d)?d=d.replace(/^ZIBBY_API_KEY=.*/m,`ZIBBY_API_KEY=${m}`):/^#\s*ZIBBY_API_KEY=/m.test(d)?d=d.replace(/^#\s*ZIBBY_API_KEY=.*/m,`ZIBBY_API_KEY=${m}`):d=`${d.trimEnd()}
44
120
 
45
121
  # Zibby Cloud Sync
46
- ZIBBY_API_KEY=${c}
47
- `,await h(s,i)}else await h(s,De(r,c,l))}if(r.agentKey&&g){let s=p(n,".env"),c=r.agentKey;if(P(s)){let i=await A(s,"utf8"),u=new RegExp(`^${g.envVar}=.*`,"m"),d=new RegExp(`^#\\s*${g.envVar}=.*`,"m");u.test(i)?i=i.replace(u,`${g.envVar}=${c}`):d.test(i)?i=i.replace(d,`${g.envVar}=${c}`):i=`${i.trimEnd()}
122
+ ZIBBY_API_KEY=${m}
123
+ `,await S(c,d)}else await S(c,$t(l,m,i))}if(l.agentKey&&h){let c=b(s,".env"),m=l.agentKey;if(P(c)){let d=await V(c,"utf8"),y=new RegExp(`^${h.envVar}=.*`,"m"),g=new RegExp(`^#\\s*${h.envVar}=.*`,"m");y.test(d)?d=d.replace(y,`${h.envVar}=${m}`):g.test(d)?d=d.replace(g,`${h.envVar}=${m}`):d=`${d.trimEnd()}
48
124
 
49
125
  # AI Agent Key
50
- ${g.envVar}=${c}
51
- `,await h(s,i)}}if(y){let s=Le(m,r,{memoryBackend:l});await h(p(n,"package.json"),s)}if(!P(p(n,".gitignore"))){let s=Ne();await h(p(n,".gitignore"),s)}if(!P(p(n,"playwright.config.js"))){let s=Ze("on");await h(p(n,"playwright.config.js"),s)}if(!P(p(n,"test-specs/examples/example-domain.txt"))){let s=Ve();await h(p(n,"test-specs/examples/example-domain.txt"),s)}let B=pe(Re,"../../../../examples/.zibby/commands");if(P(B)){let s=Me(B).filter(c=>c.toLowerCase().endsWith(".md"));for(let c of s){let i=p(n,".zibby/commands",c);if(e.force||!P(i)){let u=await A(p(B,c),"utf-8");await h(i,u)}}}if(!P(p(n,".zibby/commands/example.md"))){let s=Ge();await h(p(n,".zibby/commands/example.md"),s)}if(y){let s=He(m,r);await h(p(n,"README.md"),s)}if(C.succeed(y?"Project created!":"Zibby initialized!"),y&&!e.skipInstall){let s=I("Installing dependencies...").start();await new Promise((c,i)=>{R("npm",["install"],{cwd:n,stdio:"pipe"}).on("close",d=>{d===0?(s.succeed("Dependencies installed!"),c()):(s.fail("Failed to install dependencies"),i(new Error("npm install failed")))})})}else if(!y){let s=["@zibby/cli","@zibby/core"],c=[];for(let i of s)try{de(p(n,"package.json")).resolve(`${i}/package.json`)}catch{c.push(i)}if(c.length>0){let i=ue("../../package.json"),u=c.map(d=>d==="@zibby/cli"?`${d}@latest`:d==="@zibby/core"?`${d}@${i.dependencies?.["@zibby/core"]||"latest"}`:d);if(e.skipInstall)console.log(o.yellow(`
52
- Missing required Zibby dependencies in this project:`)),console.log(o.white(` ${c.join(", ")}`)),console.log(o.gray("Install them manually to avoid runtime errors:")),console.log(o.white(` npm install --save-dev ${u.join(" ")}
53
- `));else{let d=I(`Installing ${u.join(", ")}...`).start();await new Promise(z=>{R("npm",["install","--save-dev",...u],{cwd:n,stdio:"pipe"}).on("close",_=>z(_??1))})===0?d.succeed("Installed missing Zibby dependencies"):(d.warn("Could not auto-install Zibby dependencies"),console.log(o.gray("Run this manually:")),console.log(o.white(` npm install --save-dev ${u.join(" ")}
54
- `)))}}}if(!y&&a&&l==="mem0"&&(console.log(o.yellow(`
55
- Using mem0 backend requires mem0ai in your project dependencies.`)),console.log(o.gray("Run this manually in your project when ready:")),console.log(o.white(` npm install mem0ai
56
- `))),!e.skipInstall){let s=I("Installing Playwright browsers...").start();await new Promise(c=>{let i=R("npx",["playwright","install","chromium"],{cwd:n,stdio:"pipe"}),u="";i.stdout.on("data",d=>{u+=d.toString()}),i.stderr.on("data",d=>{u+=d.toString()}),i.on("close",d=>{d===0?(u.includes("already installed")||u.includes("up to date")?s.succeed("Playwright browsers already installed"):s.succeed("Playwright browsers installed!"),c()):(s.warn("Could not verify Playwright browsers"),console.log(o.yellow(`
57
- \u26A0\uFE0F If tests fail, run: npx playwright install
58
- `)),c())})})}if(r.agent==="cursor"&&!e.skipInstall){let s=I("Checking cursor-agent CLI...").start();try{L("cursor-agent --version",{encoding:"utf-8",timeout:5e3,stdio:"pipe"}),s.succeed("cursor-agent CLI already installed")}catch{s.text="Installing cursor-agent CLI...";try{await new Promise((c,i)=>{R("bash",["-c","curl https://cursor.com/install -fsS | bash"],{stdio:"pipe"}).on("close",d=>{if(d===0){let b=p(k(),".local","bin");process.env.PATH.includes(b)||(process.env.PATH=`${b}:${process.env.PATH}`),s.succeed("cursor-agent CLI installed!"),c()}else i(new Error("cursor-agent install failed"))})})}catch{s.fail("Could not install cursor-agent CLI"),console.log(o.yellow(` Install manually: curl https://cursor.com/install -fsS | bash
59
- `))}}}if(r.agent==="codex"&&!e.skipInstall){let s=I("Checking Codex CLI...").start();try{L("codex --version",{encoding:"utf-8",timeout:5e3,stdio:"pipe"}),s.succeed("Codex CLI already installed")}catch{s.text="Installing Codex CLI...";try{await new Promise((c,i)=>{R("npm",["install","-g","@openai/codex"],{stdio:"pipe"}).on("close",d=>{d===0?(s.succeed("Codex CLI installed!"),c()):i(new Error("npm install -g @openai/codex failed"))})})}catch{s.fail("Could not install Codex CLI"),console.log(o.yellow(` Install manually: npm install -g @openai/codex
60
- `))}}}if(r.agent==="gemini"&&!e.skipInstall){let s=I("Checking Gemini CLI...").start();try{L("gemini --version",{encoding:"utf-8",timeout:5e3,stdio:"pipe"}),s.succeed("Gemini CLI already installed")}catch{s.text="Installing Gemini CLI...";try{await new Promise((i,u)=>{R("npm",["install","-g","@google/gemini-cli"],{stdio:"pipe"}).on("close",b=>{b===0?(s.succeed("Gemini CLI installed!"),i()):u(new Error("npm install -g @google/gemini-cli failed"))})})}catch{s.fail("Could not install Gemini CLI"),console.log(o.yellow(` Install manually: npm install -g @google/gemini-cli
61
- `))}}let c=I("Configuring Gemini MCP servers...").start();try{let i=p(k(),".gemini"),u=p(i,"settings.json");P(i)||await M(i,{recursive:!0});let d={mcpServers:{}};if(P(u))try{let j=await A(u,"utf-8");d=JSON.parse(j),d.mcpServers||(d.mcpServers={})}catch{}let b;try{let{createRequire:j}=await import("module");b=j(import.meta.url).resolve("@zibby/mcp-browser/bin/mcp-browser-zibby.js")}catch{b="@playwright/mcp"}let z=r.browserMode!=="headless",Y=b==="@playwright/mcp"?["-y","@playwright/mcp","--isolated","--viewport-size=1280x720","--output-dir","test-results"]:[b,"--isolated","--viewport-size=1280x720","--output-dir=test-results"];z||Y.push("--headless"),d.mcpServers["playwright-official"]={command:b==="@playwright/mcp"?"npx":"node",args:Y},await h(u,`${JSON.stringify(d,null,2)}
62
- `,"utf-8");let _="Gemini MCP configured";z?_+=" (headed mode - visible browser)":_+=" (headless mode - hidden browser)",c.succeed(_)}catch(i){c.fail("MCP setup failed"),console.log(o.yellow(" You may need to configure ~/.gemini/settings.json manually")),console.log(o.gray(` Error: ${i.message}
63
- `))}}if(r.agent==="cursor"&&r.setupMcp){let s=I("Setting up Playwright MCP...").start();try{let{setupPlaywrightMcpCommand:c}=await Promise.resolve().then(()=>(ce(),le)),i=r.cloudSync||!1,u=r.browserMode!=="headless";await c({headed:u,cloudSync:i,viewport:{width:1280,height:720}});let d="Playwright MCP configured";u?d+=" (headed mode - visible browser)":d+=" (headless mode - hidden browser)",i&&(d+=" + Zibby MCP (cloud sync)"),s.succeed(d),i&&!(r.apiKey&&r.apiKey.trim())&&console.log(o.gray(`
126
+ ${h.envVar}=${m}
127
+ `,await S(c,d)}}if(u){let c=Et(p,l,{memoryBackend:i});await S(b(s,"package.json"),c)}if(!P(b(s,".gitignore"))){let c=zt();await S(b(s,".gitignore"),c)}if(t){if(!P(b(s,"playwright.config.js"))){let c=Rt("on");await S(b(s,"playwright.config.js"),c)}if(!P(b(s,"test-specs/examples/example-domain.txt"))){let c=Ot();await S(b(s,"test-specs/examples/example-domain.txt"),c)}}let x=fo(Ct,"../../../../examples/.zibby/commands");if(P(x)){let c=bt(x).filter(m=>m.toLowerCase().endsWith(".md"));for(let m of c){let d=b(s,".zibby/commands",m);if(e.force||!P(d)){let y=await V(b(x,m),"utf-8");await S(d,y)}}}if(!P(b(s,".zibby/commands/example.md"))){let c=Tt();await S(b(s,".zibby/commands/example.md"),c)}if(u){let c=Kt(p,l);await S(b(s,"README.md"),c)}try{let{validateMemorySyncConfig:c,applyMemorySyncConfig:m}=await Promise.resolve().then(()=>(Ee(),$e)),d=b(s,".zibby.config.mjs"),y=null;if(P(d))try{y=(await import(`file://${d}?t=${Date.now()}`)).default?.memorySync}catch{}let g=c(y);if(g.ok&&g.kind!=="noop"){let E=await import("@zibby/ui-memory").catch(()=>null),{getSessionToken:Z}=await Promise.resolve().then(()=>(ie(),re)),R=await m({cwd:s,projectId:l.projectId,block:y,memoryApi:E,getSessionToken:Z,hostedSetup:async({cwd:j,projectId:W})=>{let{memoryRemoteUseHostedCommand:be}=await Promise.resolve().then(()=>(no(),to));await be({cwd:j,projectId:W})},logger:{info:()=>{},warn:()=>{},error:()=>{}}});R.action==="hosted"?console.log(r.green(" \u2713 Hosted memory-sync configured from .zibby.config.mjs")):R.action==="byo"?console.log(r.green(` \u2713 Memory remote configured from .zibby.config.mjs \u2192 ${R.remote}`)):R.action==="pending-login"?(console.log(r.yellow(` \u26A0 memorySync.remote = "hosted" but you're not logged in.`)),console.log(r.gray(" Run `zibby login` then `zibby memory remote use --hosted` to finish."))):R.action==="error"&&console.log(r.yellow(` \u26A0 memorySync setup skipped: ${R.reason}`))}else g.ok||console.log(r.yellow(` \u26A0 memorySync config invalid: ${g.error}`))}catch(c){console.log(r.yellow(` \u26A0 memorySync auto-apply failed: ${c.message}`))}if(v.succeed(u?"Project created!":"Zibby initialized!"),I||(console.log(""),console.log(r.gray(" No workflow template installed. Add one when ready:")),console.log(r.gray(" zibby template list # see available")),console.log(r.gray(" zibby template add browser-test-automation # for `zibby test`")),console.log(r.gray(" Or pass `-t <name>` to a future `zibby init` to do both at once.")),console.log("")),u&&!e.skipInstall){let c=T("Installing dependencies...").start();await new Promise((m,d)=>{G("npm",["install"],{cwd:s,stdio:"pipe"}).on("close",g=>{g===0?(c.succeed("Dependencies installed!"),m()):(c.fail("Failed to install dependencies"),d(new Error("npm install failed")))})})}else if(!u){let c=["@zibby/cli","@zibby/core"],m=[];for(let d of c)try{ho(b(s,"package.json")).resolve(`${d}/package.json`)}catch{m.push(d)}if(m.length>0){let d=bo("../../package.json"),y=m.map(g=>g==="@zibby/cli"?`${g}@latest`:g==="@zibby/core"?`${g}@${d.dependencies?.["@zibby/core"]||"latest"}`:g);if(e.skipInstall)console.log(r.yellow(`
128
+ Missing required Zibby dependencies in this project:`)),console.log(r.white(` ${m.join(", ")}`)),console.log(r.gray("Install them manually to avoid runtime errors:")),console.log(r.white(` npm install --save-dev ${y.join(" ")}
129
+ `));else{let g=T(`Installing ${y.join(", ")}...`).start();await new Promise(Z=>{G("npm",["install","--save-dev",...y],{cwd:s,stdio:"pipe"}).on("close",j=>Z(j??1))})===0?g.succeed("Installed missing Zibby dependencies"):(g.warn("Could not auto-install Zibby dependencies"),console.log(r.gray("Run this manually:")),console.log(r.white(` npm install --save-dev ${y.join(" ")}
130
+ `)))}}}if(!u&&a&&i==="mem0"&&(console.log(r.yellow(`
131
+ Using mem0 backend requires mem0ai in your project dependencies.`)),console.log(r.gray("Run this manually in your project when ready:")),console.log(r.white(` npm install mem0ai
132
+ `))),!e.skipInstall&&t){let c=T("Installing Playwright browsers...").start();await new Promise(m=>{let d=G("npx",["playwright","install","chromium"],{cwd:s,stdio:"pipe"}),y="";d.stdout.on("data",g=>{y+=g.toString()}),d.stderr.on("data",g=>{y+=g.toString()}),d.on("close",g=>{g===0?(y.includes("already installed")||y.includes("up to date")?c.succeed("Playwright browsers already installed"):c.succeed("Playwright browsers installed!"),m()):(c.warn("Could not verify Playwright browsers"),console.log(r.yellow(`
133
+ If tests fail, run: npx playwright install
134
+ `)),m())})})}if(l.agent==="cursor"&&!e.skipInstall){let c=T("Checking cursor-agent CLI...").start();try{X("cursor-agent --version",{encoding:"utf-8",timeout:5e3,stdio:"pipe"}),c.succeed("cursor-agent CLI already installed")}catch{c.text="Installing cursor-agent CLI...";try{await new Promise((m,d)=>{G("bash",["-c","curl https://cursor.com/install -fsS | bash"],{stdio:"pipe"}).on("close",g=>{if(g===0){let E=b(K(),".local","bin");process.env.PATH.includes(E)||(process.env.PATH=`${E}:${process.env.PATH}`),c.succeed("cursor-agent CLI installed!"),m()}else d(new Error("cursor-agent install failed"))})})}catch{c.fail("Could not install cursor-agent CLI"),console.log(r.yellow(` Install manually: curl https://cursor.com/install -fsS | bash
135
+ `))}}}if(l.agent==="codex"&&!e.skipInstall){let c=T("Checking Codex CLI...").start();try{X("codex --version",{encoding:"utf-8",timeout:5e3,stdio:"pipe"}),c.succeed("Codex CLI already installed")}catch{c.text="Installing Codex CLI...";try{await new Promise((m,d)=>{G("npm",["install","-g","@openai/codex"],{stdio:"pipe"}).on("close",g=>{g===0?(c.succeed("Codex CLI installed!"),m()):d(new Error("npm install -g @openai/codex failed"))})})}catch{c.fail("Could not install Codex CLI"),console.log(r.yellow(` Install manually: npm install -g @openai/codex
136
+ `))}}}if(l.agent==="gemini"&&!e.skipInstall){let c=T("Checking Gemini CLI...").start();try{X("gemini --version",{encoding:"utf-8",timeout:5e3,stdio:"pipe"}),c.succeed("Gemini CLI already installed")}catch{c.text="Installing Gemini CLI...";try{await new Promise((m,d)=>{G("npm",["install","-g","@google/gemini-cli"],{stdio:"pipe"}).on("close",g=>{g===0?(c.succeed("Gemini CLI installed!"),m()):d(new Error("npm install -g @google/gemini-cli failed"))})})}catch{c.fail("Could not install Gemini CLI"),console.log(r.yellow(` Install manually: npm install -g @google/gemini-cli
137
+ `))}}if(t){let m=T("Configuring Gemini MCP servers...").start();try{let d=b(K(),".gemini"),y=b(d,"settings.json");P(d)||await U(d,{recursive:!0});let g={mcpServers:{}};if(P(y))try{let W=await V(y,"utf-8");g=JSON.parse(W),g.mcpServers||(g.mcpServers={})}catch{}let E;try{let{createRequire:W}=await import("module");E=W(import.meta.url).resolve("@zibby/mcp-browser/bin/mcp-browser-zibby.js")}catch{E="@playwright/mcp"}let Z=l.browserMode!=="headless",R=E==="@playwright/mcp"?["-y","@playwright/mcp","--isolated","--viewport-size=1280x720","--output-dir","test-results"]:[E,"--isolated","--viewport-size=1280x720","--output-dir=test-results"];Z||R.push("--headless"),g.mcpServers["playwright-official"]={command:E==="@playwright/mcp"?"npx":"node",args:R},await S(y,`${JSON.stringify(g,null,2)}
138
+ `,"utf-8");let j="Gemini MCP configured";Z?j+=" (headed mode - visible browser)":j+=" (headless mode - hidden browser)",m.succeed(j)}catch(d){m.fail("MCP setup failed"),console.log(r.yellow(" You may need to configure ~/.gemini/settings.json manually")),console.log(r.gray(` Error: ${d.message}
139
+ `))}}}if(l.agent==="cursor"&&l.setupMcp&&t){let c=T("Setting up Playwright MCP...").start();try{let{setupPlaywrightMcpCommand:m}=await Promise.resolve().then(()=>(yo(),go)),d=l.cloudSync||!1,y=l.browserMode!=="headless";await m({headed:y,cloudSync:d,viewport:{width:1280,height:720}});let g="Playwright MCP configured";y?g+=" (headed mode - visible browser)":g+=" (headless mode - hidden browser)",d&&(g+=" + Zibby MCP (cloud sync)"),c.succeed(g),d&&!(l.apiKey&&l.apiKey.trim())&&console.log(r.gray(`
64
140
  Copy .env.example to .env and set ZIBBY_API_KEY to enable uploads
65
- `))}catch(c){s.fail("MCP setup script failed"),console.log(o.yellow(" Check if MCP is already configured:")),console.log(o.gray(' \u2022 Open Cursor settings \u2192 Check "playwright-official" MCP')),console.log(o.gray(" \u2022 Run: cursor-agent mcp list")),console.log(o.gray(` \u2022 Or run manually: zibby setup-playwright
66
- `)),console.log(o.gray(` Error: ${c.message}
67
- `))}}console.log(o.bold.green(`
68
- \u{1F389} All set!
69
- `)),console.log(o.cyan("Start the Zibby Chat Agent:")),y&&console.log(o.white(` cd ${t}`)),console.log(o.white(` zibby
70
- `)),console.log(o.cyan("Or run a test directly:")),console.log(o.white(` zibby run test-specs/examples/example-domain.txt
71
- `)),console.log(o.cyan("Next steps:"));let E=1;console.log(o.white(` ${E++}. cp .env.example .env ${o.gray("# then add your API keys")}`)),a&&console.log(o.white(` ${E++}. Set ${o.bold("ZIBBY_MEMORY_BACKEND")} in .env ${o.gray(`# currently: ${l}`)}`)),console.log(o.white(` ${E++}. Type ${o.bold("zibby")} to chat with the AI testing assistant`)),console.log(o.white(` ${E++}. Write test specs in test-specs/`)),console.log(o.white(` ${E++}. Run: npx zibby run <spec-file>
72
- `))}catch(f){C.fail("Failed to create project"),console.error(o.red(`
73
- \u274C Error: ${f.message}
74
- `)),process.exit(1)}}function je(t,e={},a={}){let l=["dolt","mem0"].includes(String(a.memoryBackend||"").toLowerCase())?String(a.memoryBackend).toLowerCase():"dolt",n={claude:`
141
+ `))}catch(m){c.fail("MCP setup script failed"),console.log(r.yellow(" Check if MCP is already configured:")),console.log(r.gray(' \u2022 Open Cursor settings \u2192 Check "playwright-official" MCP')),console.log(r.gray(" \u2022 Run: cursor-agent mcp list")),console.log(r.gray(` \u2022 Or run manually: zibby setup-playwright
142
+ `)),console.log(r.gray(` Error: ${m.message}
143
+ `))}}console.log(r.bold.green(`
144
+ All set!
145
+ `)),u&&(console.log(r.cyan("Get into the project:")),console.log(r.white(` cd ${o}
146
+ `))),t?(console.log(r.cyan("Run a test:")),console.log(r.white(` zibby test test-specs/examples/example-domain.txt
147
+ `)),console.log(r.cyan("Cloud features (optional):")),console.log(r.white(` zibby login ${r.gray("# unlock workflow deploy, hosted memory, etc.")}`)),console.log(""),console.log(r.cyan("Next steps:")),console.log(r.white(` 1. cp .env.example .env ${r.gray("# then add your API keys")}`)),console.log(r.white(` 2. Write test specs in ${r.bold("test-specs/")}`)),console.log(r.white(` 3. Run: ${r.bold("zibby test <spec-file>")}`)),console.log(r.white(` 4. Or chat: ${r.bold("zibby")}
148
+ `))):(console.log(r.cyan("Start the Zibby chat agent:")),console.log(r.white(` zibby
149
+ `)),console.log(r.cyan("Add a workflow when ready:")),console.log(r.white(` zibby template list ${r.gray("# see available")}`)),console.log(r.white(` zibby template add browser-test-automation ${r.gray("# scaffold for `zibby test`")}`)),console.log(r.white(` zibby workflow new my-pipeline ${r.gray("# or write your own")}
150
+ `)),console.log(r.cyan("Cloud features (optional):")),console.log(r.white(` zibby login ${r.gray("# unlock workflow deploy, hosted memory, etc.")}`)),console.log(""),console.log(r.cyan("Next steps:")),console.log(r.white(` 1. cp .env.example .env ${r.gray("# then add your API keys")}`)),console.log(r.white(` 2. Run ${r.bold("zibby")} to chat, or scaffold a workflow above
151
+ `)))}catch(w){v.fail("Failed to create project"),console.error(r.red(`
152
+ Error: ${w.message}
153
+ `)),process.exit(1)}}function _t(o,e={},t={}){let a=["dolt","mem0"].includes(String(t.memoryBackend||"").toLowerCase())?String(t.memoryBackend).toLowerCase():"dolt",i={claude:`
75
154
  claude: {
76
155
  model: 'auto', // Options: 'auto', 'sonnet-4.6', 'opus-4.6', 'sonnet-4.5', 'opus-4.5'
77
156
  maxTokens: 4096,
@@ -84,13 +163,13 @@ Using mem0 backend requires mem0ai in your project dependencies.`)),console.log(
84
163
  },`,gemini:`
85
164
  gemini: {
86
165
  model: 'gemini-2.5-pro', // Options: 'auto', 'gemini-2.5-pro', 'gemini-2.5-flash'
87
- },`},m=t.agent,y=Object.entries(n).filter(([r])=>r!==m).map(([,r])=>r.split(`
88
- `).map(w=>w.trim()?` // ${w.trimStart()}`:w).join(`
166
+ },`},s=o.agent,p=Object.entries(i).filter(([u])=>u!==s).map(([,u])=>u.split(`
167
+ `).map(l=>l.trim()?` // ${l.trimStart()}`:l).join(`
89
168
  `)).join(`
90
169
  `);return`export default {
91
170
  // AI agent settings
92
- agent: {${n[m]}
93
- ${y}
171
+ agent: {${i[s]}
172
+ ${p}
94
173
  strictMode: false,
95
174
  },
96
175
 
@@ -98,12 +177,31 @@ ${y}
98
177
  // and workflow config. Runtime strategies attach MCP per run (no global Gemini settings mutation).
99
178
  browser: {
100
179
  mcp: 'playwright',
101
- headless: ${t.browserMode==="headless"},
180
+ headless: ${o.browserMode==="headless"},
102
181
  },
103
182
 
104
183
  // Chat memory backend adapter (dolt | mem0)
105
184
  memory: {
106
- backend: '${l}',
185
+ backend: '${a}',
186
+ },
187
+
188
+ // UI-test memory remote sync \u2014 declarative team configuration.
189
+ //
190
+ // Commit this block to git so every teammate cloning the repo
191
+ // gets the same remote on their first \`zibby init\`. Without it,
192
+ // remote setup is ad-hoc per machine via \`zibby memory remote add\`
193
+ // and not committed (Dolt stores remote config in .dolt/config,
194
+ // which is gitignored alongside the rest of memory).
195
+ //
196
+ // Set \`remote\` to one of:
197
+ // null \u2014 no sync (default; team-sync feature off)
198
+ // 'hosted' \u2014 Zibby-managed S3, requires \`zibby login\`
199
+ // 'aws://[bucket]/path' \u2014 your own S3 bucket
200
+ // 'gs://bucket/path' \u2014 your own GCS bucket
201
+ // 'https://doltremoteapi/...' \u2014 DoltHub or compatible
202
+ // 'file:///abs/path' \u2014 shared NFS / Dropbox folder
203
+ memorySync: {
204
+ remote: null,
107
205
  },
108
206
 
109
207
  // Advanced: Override models per node (optional)
@@ -117,7 +215,7 @@ ${y}
117
215
  specs: 'test-specs', // Where your .txt test specs are
118
216
  generated: 'tests', // Where generated .spec.js files go
119
217
  output: '.zibby/output', // Where workflow execution results are saved (default: .zibby/output)
120
- workflows: '${t.workflowsPath||".zibby/workflows"}', // Where custom workflows are stored
218
+ workflows: '${o.workflowsPath||".zibby/workflows"}', // Where custom workflows are stored
121
219
  // sessionPrefix: 'run', // Optional: prefix for session folders (e.g., run_1772788458045)
122
220
  },
123
221
 
@@ -152,13 +250,13 @@ ${y}
152
250
  },
153
251
 
154
252
  // Cloud sync - auto-upload test results & videos (requires ZIBBY_API_KEY in .env)
155
- cloudSync: ${t.cloudSync||!1}
253
+ cloudSync: ${o.cloudSync||!1}
156
254
  };
157
- `}function Oe(t,e="dolt"){return`# Zibby Test Automation - Environment Variables
255
+ `}function St(o,e="dolt"){return`# Zibby Test Automation - Environment Variables
158
256
 
159
257
  # AI Provider Keys
160
258
  ${{claude:"ANTHROPIC_API_KEY=sk-ant-your_key_here",cursor:`# Cursor Agent uses cursor-agent CLI \u2014 no API key needed
161
- # Install: curl https://cursor.com/install -fsS | bash`,codex:"OPENAI_API_KEY=sk-your_key_here",gemini:"GEMINI_API_KEY=your_key_here"}[t.agent]||""}
259
+ # Install: curl https://cursor.com/install -fsS | bash`,codex:"OPENAI_API_KEY=sk-your_key_here",gemini:"GEMINI_API_KEY=your_key_here"}[o.agent]||""}
162
260
 
163
261
  # Zibby Cloud Sync (for uploading test results & videos)
164
262
  # Get your API key from: https://zibby.dev/settings/tokens
@@ -171,10 +269,10 @@ ${{claude:"ANTHROPIC_API_KEY=sk-ant-your_key_here",cursor:`# Cursor Agent uses c
171
269
 
172
270
  # Chat memory backend
173
271
  ZIBBY_MEMORY_BACKEND=${e}
174
- `}function De(t,e,a="dolt"){return`# Zibby Test Automation - Environment Variables
272
+ `}function $t(o,e,t="dolt"){return`# Zibby Test Automation - Environment Variables
175
273
 
176
274
  # AI Provider Keys
177
- ${{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"}[t.agent]||""}
275
+ ${{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"}[o.agent]||""}
178
276
 
179
277
  # Zibby Cloud Sync
180
278
  ZIBBY_API_KEY=${e}
@@ -185,8 +283,8 @@ ZIBBY_API_KEY=${e}
185
283
  # ZIBBY_MEMORY_COMPACT_EVERY=1500 # Auto-compact every N runs (0 to disable)
186
284
 
187
285
  # Chat memory backend
188
- ZIBBY_MEMORY_BACKEND=${a}
189
- `}function Le(t,e,a={}){let n={"@zibby/cli":"latest","@zibby/core":ue("../../package.json").dependencies?.["@zibby/core"]||"latest"};return a.memoryBackend==="mem0"&&(n.mem0ai="^2.4.6"),JSON.stringify({name:t,version:"1.0.0",type:"module",private:!0,scripts:{"test:spec":"zibby run",test:"playwright test","test:headed":"playwright test --headed"},dependencies:n,devDependencies:{"@playwright/test":"^1.49.0",dotenv:"^17.2.3"}},null,2)}function Ne(){return`# Dependencies
286
+ ZIBBY_MEMORY_BACKEND=${t}
287
+ `}function Et(o,e,t={}){let i={"@zibby/cli":"latest","@zibby/core":bo("../../package.json").dependencies?.["@zibby/core"]||"latest"};return t.memoryBackend==="mem0"&&(i.mem0ai="^2.4.6"),JSON.stringify({name:o,version:"1.0.0",type:"module",private:!0,scripts:{"test:spec":"zibby run",test:"playwright test","test:headed":"playwright test --headed"},dependencies:i,devDependencies:{"@playwright/test":"^1.49.0",dotenv:"^17.2.3"}},null,2)}function zt(){return`# Dependencies
190
288
  node_modules/
191
289
 
192
290
  # Test artifacts
@@ -214,7 +312,7 @@ Thumbs.db
214
312
  # Zibby memory (Dolt DB synced separately via dolt remote, not git)
215
313
  .zibby/memory/
216
314
  .zibby/memory-context.md
217
- `}function Ze(t="off",e=null){return`import { defineConfig} from '@playwright/test';
315
+ `}function Rt(o="off",e=null){return`import { defineConfig} from '@playwright/test';
218
316
 
219
317
  export default defineConfig({
220
318
  testDir: './tests',
@@ -236,7 +334,7 @@ ${e?` outputDir: '${e}',
236
334
  ['list']
237
335
  ],
238
336
  });
239
- `}function Ve(){return`Test Specification: Example Domain Navigation
337
+ `}function Ot(){return`Test Specification: Example Domain Navigation
240
338
  ==============================================
241
339
 
242
340
  Application: Example Domain
@@ -273,7 +371,7 @@ Notes:
273
371
  - Uses a stable, public domain (example.com) maintained by IANA
274
372
  - No authentication required
275
373
  - Suitable for CI/CD smoke testing
276
- `}function Ge(){return`# Example command template
374
+ `}function Tt(){return`# Example command template
277
375
 
278
376
  Use this command when the user asks for a concise testing task breakdown.
279
377
 
@@ -284,7 +382,7 @@ Required output format:
284
382
  4. Expected result
285
383
 
286
384
  Keep the response actionable and short.
287
- `}function He(t,e){return`# ${t}
385
+ `}function Kt(o,e){return`# ${o}
288
386
 
289
387
  AI-powered test automation with Zibby.
290
388
 
@@ -355,7 +453,7 @@ Edit \`.zibby.config.mjs\` to customize:
355
453
  ## Project Structure
356
454
 
357
455
  \`\`\`
358
- ${t}/
456
+ ${o}/
359
457
  \u251C\u2500\u2500 .zibby/
360
458
  \u2502 \u251C\u2500\u2500 graph.mjs # Workflow definition
361
459
  \u2502 \u251C\u2500\u2500 nodes/ # Custom nodes
@@ -373,4 +471,4 @@ ${t}/
373
471
 
374
472
  - Documentation: https://docs.zibby.dev
375
473
  - Examples: https://github.com/zibby/examples
376
- `}export{je as generateConfig,ft as initCommand};
474
+ `}export{_t as generateConfig,yn as initCommand};