@zibby/cli 0.3.0 → 0.4.1
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/README.md +117 -16
- package/dist/bin/zibby.js +3 -3
- package/dist/commands/init.js +184 -93
- package/dist/commands/memory.js +41 -23
- package/dist/commands/template.js +4 -4
- package/dist/commands/uninstall.js +15 -14
- package/dist/commands/workflows/agent-helpers.js +7 -7
- package/dist/commands/workflows/cloud-creds-check.js +2 -0
- package/dist/commands/workflows/deploy.js +47 -46
- package/dist/commands/workflows/generate.js +60 -37
- package/dist/commands/workflows/run-local.js +10 -10
- package/dist/commands/workflows/run.js +5 -5
- package/dist/commands/workflows/start.js +6 -6
- package/dist/package.json +4 -4
- package/dist/templates/zibby-workflow-claude/agents-md-block.md +65 -5
- package/dist/templates/zibby-workflow-claude/claude/agents/zibby-test-author.md +16 -1
- package/dist/templates/zibby-workflow-claude/claude/agents/zibby-workflow-builder.md +22 -2
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-add-node.md +1 -1
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-debug.md +1 -1
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-delete.md +1 -1
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-deploy.md +24 -14
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-list.md +2 -2
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-memory-cost.md +39 -0
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-memory-pull.md +47 -0
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-memory-remote-use-hosted.md +61 -0
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-memory-stats.md +38 -0
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-static-ip.md +8 -6
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-tail.md +1 -1
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-test-debug.md +2 -2
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-test-generate.md +1 -1
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-test-run.md +3 -2
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-test-write.md +1 -1
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-trigger.md +10 -6
- package/dist/templates/zibby-workflow-claude/cursor/rules/zibby-workflows.mdc +76 -13
- package/dist/templates/zibby-workflow-claude/manifest.json +5 -1
- package/dist/utils/apply-memory-sync-config.js +1 -0
- package/dist/utils/hosted-memory-sync.js +1 -0
- package/package.json +4 -4
package/dist/commands/init.js
CHANGED
|
@@ -1,104 +1,176 @@
|
|
|
1
|
-
var
|
|
1
|
+
var wo=Object.defineProperty;var N=(e,o)=>()=>(e&&(o=e(e=0)),o);var D=(e,o)=>{for(var t in o)wo(e,t,{get:o[t],enumerable:!0})};var Ce={};D(Ce,{templateAddCommand:()=>Po,templateListCommand:()=>Co,writeTemplateFiles:()=>Ie});import{mkdir as Ae,writeFile as q,readFile as J}from"fs/promises";import{existsSync as ne,readdirSync as Io}from"fs";import{join as O}from"path";import k from"chalk";async function Ie(e,o,t={}){let a=t.enableMemory!==!1,{TemplateFactory:r}=await import("@zibby/core/templates"),{graphPath:s,nodesPath:p,readmePath:u,resultHandlerPath:l,template:y}=r.getTemplateFiles(o),h=O(e,".zibby");ne(h)||await Ae(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 Ae(w,{recursive:!0});for(let I of Io(p)){let x=await J(O(p,I),"utf-8");!a&&I==="execute-live.mjs"&&(x=x.replace("skills: [SKILLS.BROWSER, SKILLS.MEMORY],","skills: [SKILLS.BROWSER],")),await q(O(w,I),x),v.push(`nodes/${I}`)}let A=O(y.path,"chat.mjs");return ne(A)&&(await q(O(h,"chat.mjs"),await J(A,"utf-8")),v.push("chat.mjs")),{template:y,copied:v}}async function Co(){let{TemplateFactory:e}=await import("@zibby/core/templates"),o=e.listTemplates();console.log(""),console.log(k.bold.cyan(" Available templates")),console.log("");for(let t of o){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(e,o={}){e||(console.log(k.red(`
|
|
2
2
|
Missing template name.
|
|
3
|
-
`)),console.log(
|
|
4
|
-
`)),process.exit(1));let
|
|
5
|
-
No .zibby/ directory in ${
|
|
6
|
-
`)),console.log(
|
|
7
|
-
${
|
|
8
|
-
`)),console.log(
|
|
9
|
-
`)),process.exit(1)}console.log(""),console.log(
|
|
10
|
-
|
|
11
|
-
`).
|
|
12
|
-
|
|
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=o.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 r;try{r=await Ie(t,e,{enableMemory:o.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(r.template.name)}`)),console.log(k.gray(` ${r.copied.length} files written to ${a}/`));for(let s of r.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 Se={};D(Se,{applyMemorySyncConfig:()=>So,validateMemorySyncConfig:()=>$e});function $e(e){if(!e||typeof e!="object")return{ok:!0,kind:"noop"};let o=e.remote;return _o.includes(o)?{ok:!0,kind:"noop"}:typeof o!="string"?{ok:!1,error:`memorySync.remote must be null or a string, got ${typeof o}`}:o===$o?{ok:!0,kind:"hosted"}:_e.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: ${_e.join(" / ")}.`}}async function So({cwd:e,projectId:o,block:t,memoryApi:a,hostedSetup:r,getSessionToken:s,logger:p=console}){let u=$e(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(e,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 r!="function")return{action:"error",reason:"hostedSetup function not provided"};try{return await r({cwd:e,projectId:o}),{action:"hosted"}}catch(l){return{action:"error",reason:`hosted setup failed: ${l.message}`}}}return{action:"error",reason:`unhandled kind: ${u.kind}`}}var _o,$o,_e,Ee=N(()=>{_o=[null,void 0,"","none","off",!1],$o="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:()=>S,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 e=Oe();ze(e)||Eo(e,{recursive:!0})}function S(){try{let e=Te();if(ze(e)){let o=zo(e,"utf-8");return JSON.parse(o)}}catch{}return{}}function M(e){To(),Ro(Te(),JSON.stringify(e,null,2))}function se(){return S().sessionToken||null}function Me(e){let o=S();o.sessionToken=e,M(o)}function Be(){return S().user||null}function je(e){let o=S();o.user=e,M(o)}function Ne(){return se()!==null}function De(){let e=S();delete e.sessionToken,delete e.user,delete e.mem0ProxyUrl,M(e)}function Le(){return S().proxyUrl||null}function Ue(e){let o=S();o.proxyUrl=e,M(o)}function Ye(){return S().mem0ProxyUrl||null}function Ze(e){let o=S();o.mem0ProxyUrl=e,M(o)}function He(){return S().projects||[]}function Fe(e){let o=S();o.projects=e,M(o)}var Ke,Oo,Ko,ie=N(()=>{Ke=oe(Re(),".zibby"),Oo=oe(Ke,"config.json");Ko={loadConfig:S,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 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 Bo(){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 jo(){let e=process.env.ZIBBY_ENV||"prod";return _[e]||_.prod}function No(){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 a=["zibby.dev","studio.zibby.dev","studio-staging.zibby.dev","zibby.app","studio.zibby.app","studio-staging.zibby.app"],r=o.hostname;if(!a.some(p=>r===p||r.endsWith(`.${p}`))&&!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 _,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(e){let o=ae(e,".zibby");return{dir:o,config:ae(o,Lo),creds:ae(o,Uo)}}function de(e){let{config:o}=H(e);if(!ce(o))return null;try{let t=JSON.parse(We(o,"utf-8"));return t.mode!=="hosted"?null:t}catch{return null}}function Yo(e){return!!de(e)}function Zo(e,o){let{dir:t,config:a}=H(e);qe(t,{recursive:!0}),le(a,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 Ho(e){let{config:o,creds:t}=H(e);for(let a of[o,t])if(ce(a))try{le(a,"")}catch{}}function ue(e){let{creds:o}=H(e);if(!ce(o))return null;try{let t=JSON.parse(We(o,"utf-8"));return!t?.accessKeyId||!t?.secretAccessKey||!t?.sessionToken?null:t}catch{return null}}function Xe(e,o){let{dir:t,creds:a}=H(e);qe(t,{recursive:!0}),le(a,JSON.stringify(o,null,2),"utf-8");try{Do(a,384)}catch{}}function Qe(e){return e?.expiration?new Date(e.expiration).getTime()-Date.now()<Je:!0}async function eo({cwd:e,projectId:o,apiUrl:t,sessionToken:a,fetch:r=globalThis.fetch}){if(!o)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 r(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({projectId:o})});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(e,{accessKeyId:u.accessKeyId,secretAccessKey:u.secretAccessKey,sessionToken:u.sessionToken,expiration:u.expiration||null,refreshedAt:new Date().toISOString()}),ue(e)}async function oo({cwd:e,apiUrl:o,sessionToken:t,fetch:a}){let r=de(e);if(!r)return null;let s=ue(e);return(!s||Qe(s))&&(s=await eo({cwd:e,projectId:r.projectId,apiUrl:o,sessionToken:t,fetch:a})),s}async function Fo({cwd:e,apiUrl:o,sessionToken:t,fetch:a}){let r=await oo({cwd:e,apiUrl:o,sessionToken:t,fetch:a});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 Lo,Uo,Je,Go,ge=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 e=await z();if(!e)return;let o=process.cwd(),t=e.getStats(o);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 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(`
|
|
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(e){let o=await z();if(!o)return;let t=process.cwd();if(!e.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=o.resetMemory(t);console.log(a?n.green(`
|
|
26
|
+
Memory database reset.
|
|
27
|
+
`):n.gray(`
|
|
28
|
+
No memory database found.
|
|
29
|
+
`))}async function Jo(e){let o=await z();if(!o)return;let t=process.cwd(),a=o.getStats(t);if(!a.initialized){console.log(n.yellow(`
|
|
30
|
+
Memory database not initialized.
|
|
31
|
+
`));return}let r=e.maxRuns||50,s=e.maxAge||90;console.log(n.white(`
|
|
32
|
+
Compacting memory (keep last ${r} runs/spec, prune data older than ${s}d)...`));let p=a.counts;if(o.compactMemory(t,{maxRuns:r,maxAgeDays:s}).pruned){let l=o.getStats(t).counts,y=h=>p[h]-l[h];console.log(n.green(" Done.")),y("runs")>0&&console.log(n.gray(` Pruned ${y("runs")} old runs`)),y("selectors")>0&&console.log(n.gray(` Pruned ${y("selectors")} stale selectors`)),y("insights")>0&&console.log(n.gray(` Pruned ${y("insights")} old insights`)),y("transitions")>0&&console.log(n.gray(` Pruned ${y("transitions")} stale transitions`)),console.log(n.gray(` Dolt GC completed
|
|
33
|
+
`))}else console.log(n.gray(` Nothing to compact.
|
|
34
|
+
`))}async function Xo(){let e=await z();if(!e)return;let o=process.cwd(),t=e.getCostStats(o);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)}`),r=t.totals;if(console.log(a),console.log(n.white(` Runs with usage data: ${n.cyan(r.runs)}`)),console.log(n.white(` Total input tokens: ${n.cyan(B(r.input))}`)),console.log(n.white(` Total output tokens: ${n.cyan(B(r.output))}`)),console.log(n.white(` Total cache reads: ${n.cyan(B(r.cache_read))} ${n.gray("(billed at ~10% of normal input rate)")}`)),console.log(n.white(` Total cache creation: ${n.cyan(B(r.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(e){return e==null?"\u2014":e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}K`:`${(e/1e6).toFixed(2)}M`}async function Qo(e,o={}){let t=await z();if(!t)return;e||(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(),r=o.name||"origin";if(!t.memoryRemoteAdd(a,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 et(){let e=await z();if(!e)return;let o=e.memoryRemoteInfo(process.cwd());if(console.log(""),!o){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(o.name||"origin")}: ${o.url||"(unknown)"}`),console.log("")}async function ot(e="origin"){let o=await z();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 tt(){let e=await z();if(!e)return;console.log(n.cyan(`
|
|
49
|
+
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.
|
|
50
|
+
`)):(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 nt(e={}){let o=await z();if(!o)return;let{join:t}=await import("path"),{existsSync:a}=await import("fs"),r=e.cwd||process.cwd(),s=e.projectId;if(!s){let A=t(r,".zibby.config.mjs");if(a(A))try{let x=(await import(`file://${A}?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(),y=u();y||(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 A=`${l.replace(/\/+$/,"")}/memory/sync-config?projectId=${encodeURIComponent(s)}`,I=await fetch(A,{headers:{Authorization:`Bearer ${y}`}});if(!I.ok){let x=await I.text().catch(()=>"");throw new Error(`backend returned ${I.status}: ${x||"no body"}`)}h=await I.json()}catch(A){console.log(n.red(`
|
|
56
|
+
Failed: ${A.message}
|
|
57
|
+
`)),process.exit(1)}let{writeConfig:v}=await Promise.resolve().then(()=>(ge(),pe));v(r,{projectId:s,bucket:h.bucket,prefix:h.prefix,doltUrl:h.doltUrl}),o.memoryRemoteAdd(r,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(()=>(ge(),pe));try{await w({cwd:r,projectId:s,apiUrl:l,sessionToken:y})}catch(A){console.log(n.yellow(`
|
|
59
|
+
Config saved, but initial credential fetch failed: ${A.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 e=await z();if(!e)return;console.log(n.cyan(`
|
|
61
|
+
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"}.
|
|
62
|
+
`))}async function rt(){let e=await z();if(!e)return;let o=process.cwd();if(!e.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}=e.initMemory(o);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 mo={};D(mo,{setupCiCommand:()=>ft,setupPlaywrightMcpCommand:()=>go,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(me.resolve("@zibby/core/package.json"))}catch{return null}}function po(e){try{return fe(`command -v ${e}`,{stdio:"pipe"}),!0}catch{return!1}}function lt(){try{let e=me.resolve("@zibby/mcp-browser/bin/mcp-browser-zibby.js");if(F(e))return e}catch{}try{let e=me.resolve("@playwright/mcp/package.json"),o=he(e),t=JSON.parse(ao(e,"utf-8")),a=typeof t.bin=="string"?t.bin:t.bin?.["playwright-mcp"];if(a){let s=L(o,a);if(F(s))return s}let r=L(o,"cli.js");if(F(r))return r}catch{}return null}function so(e,o,t={}){return new Promise((a,r)=>{let s=ye(e,o,{stdio:"inherit",...t});s.on("close",p=>a(p??1)),s.on("error",r)})}async function ct(e){return po("playwright")?await so("playwright",["install","ffmpeg"],{cwd:e})===0:await so("npx",["--yes","playwright","install","ffmpeg"],{cwd:e})===0}function dt({headed:e=!1,viewport:o=null}){let t=process.execPath,a=he(t),r=lt(),s=Number(o?.width)||1280,p=Number(o?.height)||720,u=`${s}x${p}`,l=[];l.push(`--viewport-size=${u}`,"--output-dir=test-results"),e||l.push("--headless");let y;r?y={command:t,args:[r,...l],env:{PATH:`${a}:/usr/bin:/bin:/usr/sbin:/sbin`}}:y={command:"npx",args:["-y","@playwright/mcp",...l],env:{PATH:`${a}:/usr/bin:/bin:/usr/sbin:/sbin`}},y.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"]=y,lo(v,`${JSON.stringify(w,null,2)}
|
|
76
|
+
`,"utf-8")}async function ut(){let e=at();if(!e)return;let o=L(e,"scripts","patch-cursor-mcp.js");if(F(o))try{await new Promise((t,a)=>{let r=ye(process.execPath,[o],{cwd:process.cwd(),stdio:"ignore"});r.on("close",s=>t(s??0)),r.on("error",a)})}catch{}}function pt(e){return io(e).replace(/^\/+/,"").replace(/\//g,"-")}function gt(e){let o=String(e||""),t=o.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=o.match(/playwright-official[^=]*=>\s*(\S+)/);if(a)return a[1];let r=o.match(/playwright-official-[a-f0-9]+/i);return r?r[0]:null}function mt(e,o){let t=pt(e),a=L(uo(),".cursor","projects",t);co(a,{recursive:!0});let r=L(a,"mcp-approvals.json");return lo(r,`${JSON.stringify([o],null,2)}
|
|
78
|
+
`,"utf-8"),r}function ro(e){try{return fe("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):"",a=o.stderr!=null?String(o.stderr):"";return t+a}}function yt(e){try{return fe("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 go(e={}){let o=!!e.headed,t=e.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:o,viewport:t}),await ut();let r=io(process.cwd());if(po("cursor-agent")){ro(r);let s=yt(r);s&&console.log(C.gray(" \u2713 cursor-agent: mcp enable playwright-official"));let p=ro(r),u=gt(p);if(u)try{let l=mt(r,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(e){try{console.log(C.cyan(`
|
|
13
79
|
\u{1F680} Running CI setup...
|
|
14
|
-
`)),await
|
|
80
|
+
`)),await go({headed:!1,cloudSync:!0,viewport:{width:1280,height:720}}),console.log(C.green(`
|
|
15
81
|
\u2705 CI/CD setup complete!
|
|
16
|
-
`))}catch(
|
|
17
|
-
\u274C Error: ${
|
|
18
|
-
`)),process.exit(1)}}async function
|
|
82
|
+
`))}catch(o){console.log(C.red(`
|
|
83
|
+
\u274C Error: ${o.message}
|
|
84
|
+
`)),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(`
|
|
19
85
|
\u{1F3A5} Running tests with video recording...
|
|
20
|
-
`)),console.log(
|
|
86
|
+
`)),console.log(C.gray("\u2501".repeat(50)));let a=ye("npx",t,{cwd:process.cwd(),stdio:"inherit"});a.on("close",r=>{r===0?console.log(C.green(`
|
|
21
87
|
\u2705 Tests complete!
|
|
22
|
-
`)):(console.log(
|
|
23
|
-
\u274C Tests failed with code ${
|
|
24
|
-
`)),process.exit(
|
|
25
|
-
\u274C Error: ${
|
|
26
|
-
`)),process.exit(1)})}catch(
|
|
27
|
-
\u274C Error: ${
|
|
28
|
-
`)),process.exit(1)}}var
|
|
29
|
-
`,"utf-8")}function
|
|
30
|
-
`));return}console.log(
|
|
31
|
-
To add manually on Windows:`)),console.log(
|
|
32
|
-
`))):(console.log(
|
|
33
|
-
To add manually, run:`)),console.log(
|
|
34
|
-
`)));return}if(
|
|
35
|
-
`));return}let
|
|
36
|
-
`));return}}let
|
|
88
|
+
`)):(console.log(C.red(`
|
|
89
|
+
\u274C Tests failed with code ${r}
|
|
90
|
+
`)),process.exit(r))}),a.on("error",r=>{console.log(C.red(`
|
|
91
|
+
\u274C Error: ${r.message}
|
|
92
|
+
`)),process.exit(1)})}catch(t){console.log(C.red(`
|
|
93
|
+
\u274C Error: ${t.message}
|
|
94
|
+
`)),process.exit(1)}}var me,yo=N(()=>{me=it(import.meta.url)});import{mkdir as U,writeFile as $,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 i 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 Ao}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 e=xe();return vo(e)?JSON.parse(xo(e,"utf-8")):{}}catch{return{}}}function ke(e,o){let t=o?Q[o]:null;t&&te(t.envVar,e)}function te(e,o){if(!e||typeof e!="string"||!o||typeof o!="string")return;let t=we(ve(),".zibby");Ao(t,{recursive:!0});let a=xe(),r=ee();(!r.agentKeys||typeof r.agentKeys!="object")&&(r.agentKeys={}),r.agentKeys[e]=String(o).trim(),delete r.agentApiKey,ko(a,`${JSON.stringify(r,null,2)}
|
|
95
|
+
`,"utf-8")}function kt(){if(process.platform==="darwin")try{let e=X('security find-generic-password -s "Claude Code-credentials" -w',{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim();if(e){let o=JSON.parse(e);if(o?.claudeAiOauth?.accessToken)return o.claudeAiOauth}}catch{}try{let e=b(K(),".claude",".credentials.json");return P(e)&&JSON.parse(wt(e,"utf-8"))?.claudeAiOauth||null}catch{return null}}async function At(){let e=kt(),o=e?.accessToken||null,t=e?.subscriptionType?e.subscriptionType.charAt(0).toUpperCase()+e.subscriptionType.slice(1):null,a=process.platform==="darwin"?"macOS Keychain":"~/.claude/.credentials.json",r=process.env.ANTHROPIC_API_KEY||ee().agentKeys?.ANTHROPIC_API_KEY;console.log(""),console.log(i.cyan(" Claude has two billing modes \u2014 choose which you have:")),console.log("");let s=o?t?`Subscription (OAuth) \u2014 Claude ${t} plan detected (${a}, ***${o.slice(-4)})`:`Subscription (OAuth) \u2014 auto-detected (${a}, ***${o.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:r?`API key \u2014 found one (***${r.slice(-4)}), pay-per-token billing`:"API key \u2014 pay-per-token billing via console.anthropic.com",value:"api"}],default:o?"oauth":r?"api":"oauth"}]);if(p==="skip")return{kind:"skip"};if(p==="oauth"){if(o)return{kind:"oauth",token:o,subscriptionType:e?.subscriptionType};console.log(""),console.log(i.gray(" How to get an OAuth subscription token:")),console.log(i.gray(" 1. Install claude: npm install -g @anthropic-ai/claude-code")),console.log(i.gray(" 2. Run: claude")),console.log(i.gray(" \u2192 log in via browser \u2192 quit when shell appears")),console.log(i.gray(" 3. Read your token:")),process.platform==="darwin"?(console.log(i.gray(' (macOS) security find-generic-password -s "Claude Code-credentials" -w')),console.log(i.gray(" | jq -r .claudeAiOauth.accessToken"))):console.log(i.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(r)return{kind:"api",token:r};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 It=xt(import.meta.url),Ct=vt(It),bo=ho(import.meta.url);async function Pt(){try{let e=process.platform==="win32",o=X("npm config get prefix",{encoding:"utf-8"}).trim(),t=e?o:`${o}/bin`,a=t.replace(/^~/,K()),r=e?";":":";if(process.env.PATH.split(r).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(i.yellow("npm global bin not in PATH")),console.log(i.gray(` Location: ${a}`)),console.log(i.gray(` Add it manually: export PATH="${a}:$PATH"
|
|
96
|
+
`));return}console.log(i.yellow("npm global bin not in PATH")),console.log(i.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){e?(console.log(i.gray(`
|
|
97
|
+
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: ${a}
|
|
98
|
+
`))):(console.log(i.gray(`
|
|
99
|
+
To add manually, run:`)),console.log(i.gray(` echo 'export PATH="${a}:$PATH"' >> ~/.zshrc`)),console.log(i.gray(` source ~/.zshrc
|
|
100
|
+
`)));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: ${a}
|
|
101
|
+
`));return}let l=process.env.SHELL||"",y="";if(l.includes("zsh"))y=b(K(),".zshrc");else if(l.includes("bash"))y=P(b(K(),".bashrc"))?b(K(),".bashrc"):b(K(),".bash_profile");else{console.log(i.yellow(`Unknown shell: ${l}`)),console.log(i.gray(" Please add manually:")),console.log(i.gray(` export PATH="${a}:$PATH"`));return}if(P(y)){let v=await V(y,"utf-8");if(v.includes(a)||v.includes("npm")&&v.includes("global")&&v.includes("bin")){console.log(i.yellow(`PATH entry found in ${y} but not active`)),console.log(i.gray(` Run: source ${y}
|
|
102
|
+
`));return}}let h=`
|
|
37
103
|
# npm global bin (added by zibby)
|
|
38
104
|
export PATH="${a}:$PATH"
|
|
39
|
-
`;await
|
|
40
|
-
Run this to activate in current session:`)),console.log(
|
|
41
|
-
`))}catch{}}async function
|
|
105
|
+
`;await $(y,(P(y)?await V(y,"utf-8"):"")+h),console.log(i.green(`Added to ${y}`)),console.log(i.yellow(`
|
|
106
|
+
Run this to activate in current session:`)),console.log(i.gray(` source ${y}
|
|
107
|
+
`))}catch{}}async function yn(e,o){let t=o.template==="browser-test-automation";console.log(t?`
|
|
42
108
|
Zibby Test Automation
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
`)
|
|
109
|
+
`:`
|
|
110
|
+
Zibby Project Init
|
|
111
|
+
`);let a=!o.skipMemory,r=["dolt","mem0"].includes(String(o.memoryBackend||"").toLowerCase())?String(o.memoryBackend).toLowerCase():"dolt";await Pt();let s=e?fo(process.cwd(),e):process.cwd(),p=e||"zibby-tests",u=!!e;u&&P(s)&&(console.log(i.red(`
|
|
112
|
+
Directory "${e}" already exists!
|
|
113
|
+
`)),process.exit(1)),!u&&P(b(s,".zibby.config.mjs"))&&!o.force&&(console.log(i.yellow(`
|
|
46
114
|
Zibby is already initialized in this directory!
|
|
47
|
-
`)),console.log(
|
|
48
|
-
`)),process.exit(0)),
|
|
115
|
+
`)),console.log(i.white("Config file found: .zibby.config.mjs")),console.log(i.gray(`Use --force or -f to reinitialize
|
|
116
|
+
`)),process.exit(0)),o.force&&!u&&console.log(i.cyan(`
|
|
49
117
|
Reinitializing Zibby configuration...
|
|
50
|
-
`));let
|
|
51
|
-
`)),
|
|
118
|
+
`));let l;if(o.agent&&(o.headed||o.headless))console.log(i.cyan(`Setting up with provided options...
|
|
119
|
+
`)),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: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],A=!(process.env.CI||process.env.ZIBBY_CI||!process.stdin.isTTY);if(l.agent==="claude"&&!o.agentKey&&A){let x=await At();x?.kind==="oauth"&&x.token?(l.claudeOauthToken=x.token,l.agentAuth="oauth"):x?.kind==="api"&&x.token&&(l.agentKey=x.token,l.agentAuth="api")}else if(w&&!o.agentKey&&A){let x=ee(),c=process.env[w.envVar]||x.agentKeys?.[w.envVar],g=c?`***${c.slice(-4)}`:null,d=g?`${w.label} found (${g}). Press Enter to keep, or paste a new key:`:`Enter ${w.label} (from ${w.url}, or press Enter to skip):`,{agentKey:f}=await Y.prompt([{type:"password",name:"agentKey",message:d,mask:"*"}]);f&&f.trim()&&(l.agentKey=f.trim(),l.agentAuth="api")}let I=[];if(t&&!o.headed&&!o.headless&&I.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&&I.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:"}),I.length>0){let x=await Y.prompt(I);Object.assign(l,x)}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 h=Q[l.agent];l.claudeOauthToken&&(te("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&&(ke(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 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&&r==="dolt")try{let{initMemory:c,DoltDB:g}=await import("@zibby/ui-memory");if(g.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=o.template,A=w&&w!=="none"&&w!=="false";if(A){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 I=_t(l,o,{memoryBackend:r});if(await $(b(s,".zibby.config.mjs"),I),await $(b(s,".env.example"),$t(l,r)),l.apiKey&&l.apiKey.trim()){let c=b(s,".env"),g=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=${g}`):/^#\s*ZIBBY_API_KEY=/m.test(d)?d=d.replace(/^#\s*ZIBBY_API_KEY=.*/m,`ZIBBY_API_KEY=${g}`):d=`${d.trimEnd()}
|
|
52
120
|
|
|
53
121
|
# Zibby Cloud Sync
|
|
54
|
-
ZIBBY_API_KEY=${
|
|
55
|
-
`,await
|
|
122
|
+
ZIBBY_API_KEY=${g}
|
|
123
|
+
`,await $(c,d)}else await $(c,St(l,g,r))}if(l.agentKey&&h){let c=b(s,".env"),g=l.agentKey;if(P(c)){let d=await V(c,"utf8"),f=new RegExp(`^${h.envVar}=.*`,"m"),m=new RegExp(`^#\\s*${h.envVar}=.*`,"m");f.test(d)?d=d.replace(f,`${h.envVar}=${g}`):m.test(d)?d=d.replace(m,`${h.envVar}=${g}`):d=`${d.trimEnd()}
|
|
56
124
|
|
|
57
125
|
# AI Agent Key
|
|
58
|
-
${
|
|
59
|
-
`,await
|
|
60
|
-
Missing required Zibby dependencies in this project:`)),console.log(
|
|
61
|
-
`));else{let
|
|
62
|
-
`)))}}}if(!
|
|
63
|
-
Using mem0 backend requires mem0ai in your project dependencies.`)),console.log(
|
|
64
|
-
`))),!
|
|
126
|
+
${h.envVar}=${g}
|
|
127
|
+
`,await $(c,d)}}if(u){let c=Et(p,l,{memoryBackend:r});await $(b(s,"package.json"),c)}if(!P(b(s,".gitignore"))){let c=zt();await $(b(s,".gitignore"),c)}if(t){if(!P(b(s,"playwright.config.js"))){let c=Rt("on");await $(b(s,"playwright.config.js"),c)}if(!P(b(s,"test-specs/examples/example-domain.txt"))){let c=Ot();await $(b(s,"test-specs/examples/example-domain.txt"),c)}}let x=fo(Ct,"../../../../examples/.zibby/commands");if(P(x)){let c=bt(x).filter(g=>g.toLowerCase().endsWith(".md"));for(let g of c){let d=b(s,".zibby/commands",g);if(o.force||!P(d)){let f=await V(b(x,g),"utf-8");await $(d,f)}}}if(!P(b(s,".zibby/commands/example.md"))){let c=Tt();await $(b(s,".zibby/commands/example.md"),c)}if(u){let c=Kt(p,l);await $(b(s,"README.md"),c)}try{let{validateMemorySyncConfig:c,applyMemorySyncConfig:g}=await Promise.resolve().then(()=>(Ee(),Se)),d=b(s,".zibby.config.mjs"),f=null;if(P(d))try{f=(await import(`file://${d}?t=${Date.now()}`)).default?.memorySync}catch{}let m=c(f);if(m.ok&&m.kind!=="noop"){let E=await import("@zibby/ui-memory").catch(()=>null),{getSessionToken:Z}=await Promise.resolve().then(()=>(ie(),re)),R=await g({cwd:s,projectId:l.projectId,block:f,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(i.green(" \u2713 Hosted memory-sync configured from .zibby.config.mjs")):R.action==="byo"?console.log(i.green(` \u2713 Memory remote configured from .zibby.config.mjs \u2192 ${R.remote}`)):R.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."))):R.action==="error"&&console.log(i.yellow(` \u26A0 memorySync setup skipped: ${R.reason}`))}else m.ok||console.log(i.yellow(` \u26A0 memorySync config invalid: ${m.error}`))}catch(c){console.log(i.yellow(` \u26A0 memorySync auto-apply failed: ${c.message}`))}if(v.succeed(u?"Project created!":"Zibby initialized!"),A||(console.log(""),console.log(i.gray(" No workflow template installed. Add one when ready:")),console.log(i.gray(" zibby template list # see available")),console.log(i.gray(" zibby template add browser-test-automation # for `zibby test`")),console.log(i.gray(" Or pass `-t <name>` to a future `zibby init` to do both at once.")),console.log("")),u&&!o.skipInstall){let c=T("Installing dependencies...").start();await new Promise((g,d)=>{G("npm",["install"],{cwd:s,stdio:"pipe"}).on("close",m=>{m===0?(c.succeed("Dependencies installed!"),g()):(c.fail("Failed to install dependencies"),d(new Error("npm install failed")))})})}else if(!u){let c=["@zibby/cli","@zibby/core"],g=[];for(let d of c)try{ho(b(s,"package.json")).resolve(`${d}/package.json`)}catch{g.push(d)}if(g.length>0){let d=bo("../../package.json"),f=g.map(m=>m==="@zibby/cli"?`${m}@latest`:m==="@zibby/core"?`${m}@${d.dependencies?.["@zibby/core"]||"latest"}`:m);if(o.skipInstall)console.log(i.yellow(`
|
|
128
|
+
Missing required Zibby dependencies in this project:`)),console.log(i.white(` ${g.join(", ")}`)),console.log(i.gray("Install them manually to avoid runtime errors:")),console.log(i.white(` npm install --save-dev ${f.join(" ")}
|
|
129
|
+
`));else{let m=T(`Installing ${f.join(", ")}...`).start();await new Promise(Z=>{G("npm",["install","--save-dev",...f],{cwd:s,stdio:"pipe"}).on("close",j=>Z(j??1))})===0?m.succeed("Installed missing Zibby dependencies"):(m.warn("Could not auto-install Zibby dependencies"),console.log(i.gray("Run this manually:")),console.log(i.white(` npm install --save-dev ${f.join(" ")}
|
|
130
|
+
`)))}}}if(!u&&a&&r==="mem0"&&(console.log(i.yellow(`
|
|
131
|
+
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
|
|
132
|
+
`))),!o.skipInstall&&t){let c=T("Installing Playwright browsers...").start();await new Promise(g=>{let d=G("npx",["playwright","install","chromium"],{cwd:s,stdio:"pipe"}),f="";d.stdout.on("data",m=>{f+=m.toString()}),d.stderr.on("data",m=>{f+=m.toString()}),d.on("close",m=>{m===0?(f.includes("already installed")||f.includes("up to date")?c.succeed("Playwright browsers already installed"):c.succeed("Playwright browsers installed!"),g()):(c.warn("Could not verify Playwright browsers"),console.log(i.yellow(`
|
|
65
133
|
If tests fail, run: npx playwright install
|
|
66
|
-
`)),
|
|
67
|
-
`))}}}if(
|
|
68
|
-
`))}}}if(
|
|
69
|
-
`))}}let
|
|
70
|
-
`,"utf-8");let
|
|
71
|
-
`))}}if(
|
|
134
|
+
`)),g())})})}if(l.agent==="cursor"&&!o.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((g,d)=>{G("bash",["-c","curl https://cursor.com/install -fsS | bash"],{stdio:"pipe"}).on("close",m=>{if(m===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!"),g()}else d(new Error("cursor-agent install failed"))})})}catch{c.fail("Could not install cursor-agent CLI"),console.log(i.yellow(` Install manually: curl https://cursor.com/install -fsS | bash
|
|
135
|
+
`))}}}if(l.agent==="codex"&&!o.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((g,d)=>{G("npm",["install","-g","@openai/codex"],{stdio:"pipe"}).on("close",m=>{m===0?(c.succeed("Codex CLI installed!"),g()):d(new Error("npm install -g @openai/codex failed"))})})}catch{c.fail("Could not install Codex CLI"),console.log(i.yellow(` Install manually: npm install -g @openai/codex
|
|
136
|
+
`))}}}if(l.agent==="gemini"&&!o.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((g,d)=>{G("npm",["install","-g","@google/gemini-cli"],{stdio:"pipe"}).on("close",m=>{m===0?(c.succeed("Gemini CLI installed!"),g()):d(new Error("npm install -g @google/gemini-cli failed"))})})}catch{c.fail("Could not install Gemini CLI"),console.log(i.yellow(` Install manually: npm install -g @google/gemini-cli
|
|
137
|
+
`))}}if(t){let g=T("Configuring Gemini MCP servers...").start();try{let d=b(K(),".gemini"),f=b(d,"settings.json");P(d)||await U(d,{recursive:!0});let m={mcpServers:{}};if(P(f))try{let W=await V(f,"utf-8");m=JSON.parse(W),m.mcpServers||(m.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"),m.mcpServers["playwright-official"]={command:E==="@playwright/mcp"?"npx":"node",args:R},await $(f,`${JSON.stringify(m,null,2)}
|
|
138
|
+
`,"utf-8");let j="Gemini MCP configured";Z?j+=" (headed mode - visible browser)":j+=" (headless mode - hidden browser)",g.succeed(j)}catch(d){g.fail("MCP setup failed"),console.log(i.yellow(" You may need to configure ~/.gemini/settings.json manually")),console.log(i.gray(` Error: ${d.message}
|
|
139
|
+
`))}}}if(l.agent==="cursor"&&l.setupMcp&&t){let c=T("Setting up Playwright MCP...").start();try{let{setupPlaywrightMcpCommand:g}=await Promise.resolve().then(()=>(yo(),mo)),d=l.cloudSync||!1,f=l.browserMode!=="headless";await g({headed:f,cloudSync:d,viewport:{width:1280,height:720}});let m="Playwright MCP configured";f?m+=" (headed mode - visible browser)":m+=" (headless mode - hidden browser)",d&&(m+=" + Zibby MCP (cloud sync)"),c.succeed(m),d&&!(l.apiKey&&l.apiKey.trim())&&console.log(i.gray(`
|
|
72
140
|
Copy .env.example to .env and set ZIBBY_API_KEY to enable uploads
|
|
73
|
-
`))}catch(
|
|
74
|
-
`)),console.log(
|
|
75
|
-
`))}}console.log(
|
|
141
|
+
`))}catch(g){c.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
|
|
142
|
+
`)),console.log(i.gray(` Error: ${g.message}
|
|
143
|
+
`))}}console.log(i.bold.green(`
|
|
76
144
|
All set!
|
|
77
|
-
`)),console.log(
|
|
78
|
-
`)),console.log(
|
|
79
|
-
`)),console.log(
|
|
80
|
-
`))
|
|
81
|
-
|
|
82
|
-
`)),
|
|
145
|
+
`)),u&&(console.log(i.cyan("Get into the project:")),console.log(i.white(` cd ${e}
|
|
146
|
+
`))),t?(console.log(i.cyan("Run a test:")),console.log(i.white(` zibby test test-specs/examples/example-domain.txt
|
|
147
|
+
`)),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")}
|
|
148
|
+
`))):(console.log(i.cyan("Start the Zibby chat agent:")),console.log(i.white(` zibby
|
|
149
|
+
`)),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 template add browser-test-automation ${i.gray("# scaffold for `zibby test`")}`)),console.log(i.white(` zibby workflow new my-pipeline ${i.gray("# or write your own")}
|
|
150
|
+
`)),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. Run ${i.bold("zibby")} to chat, or scaffold a workflow above
|
|
151
|
+
`)))}catch(w){v.fail("Failed to create project"),console.error(i.red(`
|
|
152
|
+
Error: ${w.message}
|
|
153
|
+
`)),process.exit(1)}}function _t(e,o={},t={}){let a=["dolt","mem0"].includes(String(t.memoryBackend||"").toLowerCase())?String(t.memoryBackend).toLowerCase():"dolt",r=e.agentAuth==="oauth"||e.agentAuth==="api"?`
|
|
154
|
+
auth: '${e.agentAuth}', // 'oauth' (subscription) or 'api' (pay-per-token); cloud needs 'api'`:"",s={claude:`
|
|
83
155
|
claude: {
|
|
84
156
|
model: 'auto', // Options: 'auto', 'sonnet-4.6', 'opus-4.6', 'sonnet-4.5', 'opus-4.5'
|
|
85
|
-
maxTokens: 4096
|
|
157
|
+
maxTokens: 4096,${e.agent==="claude"?r:""}
|
|
86
158
|
},`,cursor:`
|
|
87
159
|
cursor: {
|
|
88
|
-
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'
|
|
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"?r:""}
|
|
89
161
|
},`,codex:`
|
|
90
162
|
codex: {
|
|
91
|
-
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'
|
|
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"?r:""}
|
|
92
164
|
},`,gemini:`
|
|
93
165
|
gemini: {
|
|
94
|
-
model: 'gemini-2.5-pro', // Options: 'auto', 'gemini-2.5-pro', 'gemini-2.5-flash'
|
|
95
|
-
},`},
|
|
96
|
-
`).map(
|
|
166
|
+
model: 'gemini-2.5-pro', // Options: 'auto', 'gemini-2.5-pro', 'gemini-2.5-flash'${e.agent==="gemini"?r:""}
|
|
167
|
+
},`},p=e.agent,u=Object.entries(s).filter(([l])=>l!==p).map(([,l])=>l.split(`
|
|
168
|
+
`).map(y=>y.trim()?` // ${y.trimStart()}`:y).join(`
|
|
97
169
|
`)).join(`
|
|
98
170
|
`);return`export default {
|
|
99
171
|
// AI agent settings
|
|
100
|
-
agent: {${
|
|
101
|
-
${
|
|
172
|
+
agent: {${s[p]}
|
|
173
|
+
${u}
|
|
102
174
|
strictMode: false,
|
|
103
175
|
},
|
|
104
176
|
|
|
@@ -106,7 +178,7 @@ ${y}
|
|
|
106
178
|
// and workflow config. Runtime strategies attach MCP per run (no global Gemini settings mutation).
|
|
107
179
|
browser: {
|
|
108
180
|
mcp: 'playwright',
|
|
109
|
-
headless: ${
|
|
181
|
+
headless: ${e.browserMode==="headless"},
|
|
110
182
|
},
|
|
111
183
|
|
|
112
184
|
// Chat memory backend adapter (dolt | mem0)
|
|
@@ -114,6 +186,25 @@ ${y}
|
|
|
114
186
|
backend: '${a}',
|
|
115
187
|
},
|
|
116
188
|
|
|
189
|
+
// UI-test memory remote sync \u2014 declarative team configuration.
|
|
190
|
+
//
|
|
191
|
+
// Commit this block to git so every teammate cloning the repo
|
|
192
|
+
// gets the same remote on their first \`zibby init\`. Without it,
|
|
193
|
+
// remote setup is ad-hoc per machine via \`zibby memory remote add\`
|
|
194
|
+
// and not committed (Dolt stores remote config in .dolt/config,
|
|
195
|
+
// which is gitignored alongside the rest of memory).
|
|
196
|
+
//
|
|
197
|
+
// Set \`remote\` to one of:
|
|
198
|
+
// null \u2014 no sync (default; team-sync feature off)
|
|
199
|
+
// 'hosted' \u2014 Zibby-managed S3, requires \`zibby login\`
|
|
200
|
+
// 'aws://[bucket]/path' \u2014 your own S3 bucket
|
|
201
|
+
// 'gs://bucket/path' \u2014 your own GCS bucket
|
|
202
|
+
// 'https://doltremoteapi/...' \u2014 DoltHub or compatible
|
|
203
|
+
// 'file:///abs/path' \u2014 shared NFS / Dropbox folder
|
|
204
|
+
memorySync: {
|
|
205
|
+
remote: null,
|
|
206
|
+
},
|
|
207
|
+
|
|
117
208
|
// Advanced: Override models per node (optional)
|
|
118
209
|
// models: {
|
|
119
210
|
// default: 'auto', // Fallback for all nodes
|
|
@@ -125,7 +216,7 @@ ${y}
|
|
|
125
216
|
specs: 'test-specs', // Where your .txt test specs are
|
|
126
217
|
generated: 'tests', // Where generated .spec.js files go
|
|
127
218
|
output: '.zibby/output', // Where workflow execution results are saved (default: .zibby/output)
|
|
128
|
-
workflows: '${
|
|
219
|
+
workflows: '${e.workflowsPath||".zibby/workflows"}', // Where custom workflows are stored
|
|
129
220
|
// sessionPrefix: 'run', // Optional: prefix for session folders (e.g., run_1772788458045)
|
|
130
221
|
},
|
|
131
222
|
|
|
@@ -160,13 +251,13 @@ ${y}
|
|
|
160
251
|
},
|
|
161
252
|
|
|
162
253
|
// Cloud sync - auto-upload test results & videos (requires ZIBBY_API_KEY in .env)
|
|
163
|
-
cloudSync: ${
|
|
254
|
+
cloudSync: ${e.cloudSync||!1}
|
|
164
255
|
};
|
|
165
|
-
`}function
|
|
256
|
+
`}function $t(e,o="dolt"){return`# Zibby Test Automation - Environment Variables
|
|
166
257
|
|
|
167
258
|
# AI Provider Keys
|
|
168
259
|
${{claude:"ANTHROPIC_API_KEY=sk-ant-your_key_here",cursor:`# Cursor Agent uses cursor-agent CLI \u2014 no API key needed
|
|
169
|
-
# Install: curl https://cursor.com/install -fsS | bash`,codex:"OPENAI_API_KEY=sk-your_key_here",gemini:"GEMINI_API_KEY=your_key_here"}[
|
|
260
|
+
# Install: curl https://cursor.com/install -fsS | bash`,codex:"OPENAI_API_KEY=sk-your_key_here",gemini:"GEMINI_API_KEY=your_key_here"}[e.agent]||""}
|
|
170
261
|
|
|
171
262
|
# Zibby Cloud Sync (for uploading test results & videos)
|
|
172
263
|
# Get your API key from: https://zibby.dev/settings/tokens
|
|
@@ -178,14 +269,14 @@ ${{claude:"ANTHROPIC_API_KEY=sk-ant-your_key_here",cursor:`# Cursor Agent uses c
|
|
|
178
269
|
# ZIBBY_MEMORY_COMPACT_EVERY=1500 # Auto-compact every N runs (0 to disable)
|
|
179
270
|
|
|
180
271
|
# Chat memory backend
|
|
181
|
-
ZIBBY_MEMORY_BACKEND=${
|
|
182
|
-
`}function
|
|
272
|
+
ZIBBY_MEMORY_BACKEND=${o}
|
|
273
|
+
`}function St(e,o,t="dolt"){return`# Zibby Test Automation - Environment Variables
|
|
183
274
|
|
|
184
275
|
# AI Provider Keys
|
|
185
|
-
${{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"}[
|
|
276
|
+
${{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]||""}
|
|
186
277
|
|
|
187
278
|
# Zibby Cloud Sync
|
|
188
|
-
ZIBBY_API_KEY=${
|
|
279
|
+
ZIBBY_API_KEY=${o}
|
|
189
280
|
|
|
190
281
|
# Test Memory (Dolt DB) - Auto-compaction settings
|
|
191
282
|
# ZIBBY_MEMORY_MAX_RUNS=3000 # Max test runs to keep per spec
|
|
@@ -193,8 +284,8 @@ ZIBBY_API_KEY=${e}
|
|
|
193
284
|
# ZIBBY_MEMORY_COMPACT_EVERY=1500 # Auto-compact every N runs (0 to disable)
|
|
194
285
|
|
|
195
286
|
# Chat memory backend
|
|
196
|
-
ZIBBY_MEMORY_BACKEND=${
|
|
197
|
-
`}function
|
|
287
|
+
ZIBBY_MEMORY_BACKEND=${t}
|
|
288
|
+
`}function Et(e,o,t={}){let r={"@zibby/cli":"latest","@zibby/core":bo("../../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 zt(){return`# Dependencies
|
|
198
289
|
node_modules/
|
|
199
290
|
|
|
200
291
|
# Test artifacts
|
|
@@ -222,11 +313,11 @@ Thumbs.db
|
|
|
222
313
|
# Zibby memory (Dolt DB synced separately via dolt remote, not git)
|
|
223
314
|
.zibby/memory/
|
|
224
315
|
.zibby/memory-context.md
|
|
225
|
-
`}function
|
|
316
|
+
`}function Rt(e="off",o=null){return`import { defineConfig} from '@playwright/test';
|
|
226
317
|
|
|
227
318
|
export default defineConfig({
|
|
228
319
|
testDir: './tests',
|
|
229
|
-
${
|
|
320
|
+
${o?` outputDir: '${o}',
|
|
230
321
|
`:` outputDir: 'test-results/playwright', // Keep Playwright artifacts separate from Zibby workflow output
|
|
231
322
|
`} timeout: 30000,
|
|
232
323
|
retries: 0,
|
|
@@ -244,7 +335,7 @@ ${e?` outputDir: '${e}',
|
|
|
244
335
|
['list']
|
|
245
336
|
],
|
|
246
337
|
});
|
|
247
|
-
`}function
|
|
338
|
+
`}function Ot(){return`Test Specification: Example Domain Navigation
|
|
248
339
|
==============================================
|
|
249
340
|
|
|
250
341
|
Application: Example Domain
|
|
@@ -281,7 +372,7 @@ Notes:
|
|
|
281
372
|
- Uses a stable, public domain (example.com) maintained by IANA
|
|
282
373
|
- No authentication required
|
|
283
374
|
- Suitable for CI/CD smoke testing
|
|
284
|
-
`}function
|
|
375
|
+
`}function Tt(){return`# Example command template
|
|
285
376
|
|
|
286
377
|
Use this command when the user asks for a concise testing task breakdown.
|
|
287
378
|
|
|
@@ -292,7 +383,7 @@ Required output format:
|
|
|
292
383
|
4. Expected result
|
|
293
384
|
|
|
294
385
|
Keep the response actionable and short.
|
|
295
|
-
`}function
|
|
386
|
+
`}function Kt(e,o){return`# ${e}
|
|
296
387
|
|
|
297
388
|
AI-powered test automation with Zibby.
|
|
298
389
|
|
|
@@ -306,7 +397,7 @@ npm install
|
|
|
306
397
|
2. Configure environment:
|
|
307
398
|
\`\`\`bash
|
|
308
399
|
cp .env.example .env
|
|
309
|
-
# Edit .env and add your ${{claude:"ANTHROPIC_API_KEY",codex:"OPENAI_API_KEY",gemini:"GEMINI_API_KEY",cursor:"CURSOR_API_KEY (optional)"}[
|
|
400
|
+
# Edit .env and add your ${{claude:"ANTHROPIC_API_KEY",codex:"OPENAI_API_KEY",gemini:"GEMINI_API_KEY",cursor:"CURSOR_API_KEY (optional)"}[o.agent]}
|
|
310
401
|
\`\`\`
|
|
311
402
|
|
|
312
403
|
3. Run example test:
|
|
@@ -357,13 +448,13 @@ npx playwright test --ui
|
|
|
357
448
|
Edit \`.zibby.config.mjs\` to customize:
|
|
358
449
|
- Agent settings (model, temperature)
|
|
359
450
|
- Browser settings (headless, viewport)
|
|
360
|
-
- Cloud sync${
|
|
451
|
+
- Cloud sync${o.cloudSync?" (enabled)":" (disabled)"}
|
|
361
452
|
- Self-healing behavior
|
|
362
453
|
|
|
363
454
|
## Project Structure
|
|
364
455
|
|
|
365
456
|
\`\`\`
|
|
366
|
-
${
|
|
457
|
+
${e}/
|
|
367
458
|
\u251C\u2500\u2500 .zibby/
|
|
368
459
|
\u2502 \u251C\u2500\u2500 graph.mjs # Workflow definition
|
|
369
460
|
\u2502 \u251C\u2500\u2500 nodes/ # Custom nodes
|
|
@@ -381,4 +472,4 @@ ${t}/
|
|
|
381
472
|
|
|
382
473
|
- Documentation: https://docs.zibby.dev
|
|
383
474
|
- Examples: https://github.com/zibby/examples
|
|
384
|
-
`}export{
|
|
475
|
+
`}export{_t as generateConfig,yn as initCommand};
|