@zibby/cli 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/auth/cli-login.js +7 -7
- package/dist/auth/ensure-auth.js +6 -6
- package/dist/bin/zibby.js +3 -3
- package/dist/commands/chat-agents.js +1 -0
- package/dist/commands/chat-sandbox-attach.js +5 -0
- package/dist/commands/chat.js +79 -69
- package/dist/commands/credentials-api.js +1 -0
- package/dist/commands/credentials-file.js +1 -0
- package/dist/commands/creds.js +1 -0
- package/dist/commands/init.js +83 -75
- package/dist/commands/list-projects.js +5 -5
- package/dist/commands/memory.js +28 -18
- package/dist/commands/project.js +3 -3
- package/dist/commands/run.js +52 -55
- package/dist/commands/studio.js +1 -1
- package/dist/commands/template.js +9 -0
- package/dist/commands/upload.js +4 -4
- package/dist/commands/workflow.js +23 -23
- package/dist/commands/workflows/dedicated-egress.js +6 -6
- package/dist/commands/workflows/delete.js +4 -4
- package/dist/commands/workflows/deploy.js +19 -19
- package/dist/commands/workflows/env.js +7 -7
- package/dist/commands/workflows/generate.js +13 -13
- package/dist/commands/workflows/list.js +6 -6
- package/dist/commands/workflows/run-local.js +15 -15
- package/dist/commands/workflows/start.js +16 -16
- package/dist/commands/workflows/trigger.js +7 -7
- package/dist/config/environments.js +1 -1
- package/dist/package.json +4 -4
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-static-ip.md +1 -1
- package/dist/utils/agent-credentials.js +4 -3
- package/dist/utils/credentials-loader.js +1 -0
- package/package.json +4 -4
package/dist/commands/init.js
CHANGED
|
@@ -1,77 +1,85 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
`)
|
|
4
|
-
|
|
1
|
+
var Ae=Object.defineProperty;var J=(t,e)=>()=>(t&&(e=t(t=0)),e);var X=(t,e)=>{for(var s in e)Ae(t,s,{get:e[s],enumerable:!0})};var ie={};X(ie,{templateAddCommand:()=>_e,templateListCommand:()=>Ee,writeTemplateFiles:()=>se});import{mkdir as ne,writeFile as B,readFile as Y}from"fs/promises";import{existsSync as F,readdirSync as Ie}from"fs";import{join as E}from"path";import v from"chalk";async function se(t,e,s={}){let a=s.enableMemory!==!1,{TemplateFactory:o}=await import("@zibby/core/templates"),{graphPath:d,nodesPath:y,readmePath:i,resultHandlerPath:h,template:f}=o.getTemplateFiles(e),w=E(t,".zibby");F(w)||await ne(w,{recursive:!0});let m=[];await B(E(w,"graph.mjs"),await Y(d,"utf-8")),m.push("graph.mjs"),h&&(await B(E(w,"result-handler.mjs"),await Y(h,"utf-8")),m.push("result-handler.mjs")),await B(E(w,"README.md"),await Y(i,"utf-8")),m.push("README.md");let A=E(w,"nodes");await ne(A,{recursive:!0});for(let b of Ie(y)){let r=await Y(E(y,b),"utf-8");!a&&b==="execute-live.mjs"&&(r=r.replace("skills: [SKILLS.BROWSER, SKILLS.MEMORY],","skills: [SKILLS.BROWSER],")),await B(E(A,b),r),m.push(`nodes/${b}`)}let k=E(f.path,"chat.mjs");return F(k)&&(await B(E(w,"chat.mjs"),await Y(k,"utf-8")),m.push("chat.mjs")),{template:f,copied:m}}async function Ee(){let{TemplateFactory:t}=await import("@zibby/core/templates"),e=t.listTemplates();console.log(""),console.log(v.bold.cyan(" Available templates")),console.log("");for(let s of e){let a=s.default?v.gray(" (default)"):"";if(console.log(` ${v.cyan(s.name)}${a}`),console.log(` ${v.white(s.displayName)}`),s.description&&console.log(` ${v.gray(s.description)}`),s.features&&s.features.length)for(let o of s.features)console.log(v.gray(` \u2022 ${o}`));console.log("")}console.log(v.gray(" Use: zibby template add <name> (or pass -t <name> to zibby init)")),console.log("")}async function _e(t,e={}){t||(console.log(v.red(`
|
|
2
|
+
Missing template name.
|
|
3
|
+
`)),console.log(v.gray(" Usage: zibby template add <name>")),console.log(v.gray(` See available templates: zibby template list
|
|
4
|
+
`)),process.exit(1));let s=e.cwd||process.cwd(),a=E(s,".zibby");F(a)||(console.log(v.yellow(`
|
|
5
|
+
No .zibby/ directory in ${s}.
|
|
6
|
+
`)),console.log(v.gray(" Run `zibby init` first to bootstrap the project.\n")),process.exit(1));let o;try{o=await se(s,t,{enableMemory:e.enableMemory!==!1})}catch(d){console.log(v.red(`
|
|
7
|
+
${d.message}
|
|
8
|
+
`)),console.log(v.gray(` See available templates: zibby template list
|
|
9
|
+
`)),process.exit(1)}console.log(""),console.log(v.green(` \u2713 Added template ${v.bold(o.template.name)}`)),console.log(v.gray(` ${o.copied.length} files written to ${a}/`));for(let d of o.copied)console.log(v.gray(` \u2022 ${d}`));console.log(""),console.log(v.gray(" Re-running `zibby template add <name>` overwrites existing files \u2014")),console.log(v.gray(" use this to refresh after `npm update @zibby/core`.")),console.log("")}var re=J(()=>{});var fe={};X(fe,{setupCiCommand:()=>je,setupPlaywrightMcpCommand:()=>ye,testWithVideoCommand:()=>Ne});import{spawn as U,execSync as W}from"child_process";import{join as $,dirname as q,resolve as ce}from"path";import{readFileSync as pe,writeFileSync as de,existsSync as K,mkdirSync as ue}from"fs";import{homedir as ge}from"os";import{createRequire as Se}from"module";import P from"chalk";function $e(){try{return q(V.resolve("@zibby/core/package.json"))}catch{return null}}function me(t){try{return W(`command -v ${t}`,{stdio:"pipe"}),!0}catch{return!1}}function Oe(){try{let t=V.resolve("@zibby/mcp-browser/bin/mcp-browser-zibby.js");if(K(t))return t}catch{}try{let t=V.resolve("@playwright/mcp/package.json"),e=q(t),s=JSON.parse(pe(t,"utf-8")),a=typeof s.bin=="string"?s.bin:s.bin?.["playwright-mcp"];if(a){let d=$(e,a);if(K(d))return d}let o=$(e,"cli.js");if(K(o))return o}catch{}return null}function ae(t,e,s={}){return new Promise((a,o)=>{let d=U(t,e,{stdio:"inherit",...s});d.on("close",y=>a(y??1)),d.on("error",o)})}async function Ke(t){return me("playwright")?await ae("playwright",["install","ffmpeg"],{cwd:t})===0:await ae("npx",["--yes","playwright","install","ffmpeg"],{cwd:t})===0}function Te({headed:t=!1,viewport:e=null}){let s=process.execPath,a=q(s),o=Oe(),d=Number(e?.width)||1280,y=Number(e?.height)||720,i=`${d}x${y}`,h=[];h.push(`--viewport-size=${i}`,"--output-dir=test-results"),t||h.push("--headless");let f;o?f={command:s,args:[o,...h],env:{PATH:`${a}:/usr/bin:/bin:/usr/sbin:/sbin`}}:f={command:"npx",args:["-y","@playwright/mcp",...h],env:{PATH:`${a}:/usr/bin:/bin:/usr/sbin:/sbin`}},f.description="Zibby MCP Browser - Playwright MCP with Zibby defaults";let w=$(ge(),".cursor"),m=$(w,"mcp.json");K(w)||ue(w,{recursive:!0});let A={mcpServers:{}};if(K(m))try{A=JSON.parse(pe(m,"utf-8")),(!A.mcpServers||typeof A.mcpServers!="object")&&(A.mcpServers={})}catch{A={mcpServers:{}}}A.mcpServers["playwright-official"]=f,de(m,`${JSON.stringify(A,null,2)}
|
|
10
|
+
`,"utf-8")}async function Me(){let t=$e();if(!t)return;let e=$(t,"scripts","patch-cursor-mcp.js");if(K(e))try{await new Promise((s,a)=>{let o=U(process.execPath,[e],{cwd:process.cwd(),stdio:"ignore"});o.on("close",d=>s(d??0)),o.on("error",a)})}catch{}}function ze(t){return ce(t).replace(/^\/+/,"").replace(/\//g,"-")}function Re(t){let e=String(t||""),s=e.split(`
|
|
11
|
+
`).find(d=>/playwright-official/i.test(d)&&/APPROVAL|🔑/i.test(d));if(s){let d=s.match(/=>\s*(\S+)/);if(d)return d[1]}let a=e.match(/playwright-official[^=]*=>\s*(\S+)/);if(a)return a[1];let o=e.match(/playwright-official-[a-f0-9]+/i);return o?o[0]:null}function Be(t,e){let s=ze(t),a=$(ge(),".cursor","projects",s);ue(a,{recursive:!0});let o=$(a,"mcp-approvals.json");return de(o,`${JSON.stringify([e],null,2)}
|
|
12
|
+
`,"utf-8"),o}function le(t){try{return W("cursor-agent mcp list",{cwd:t,encoding:"utf-8",stdio:["ignore","pipe","pipe"],env:process.env,maxBuffer:2*1024*1024})}catch(e){let s=e.stdout!=null?String(e.stdout):"",a=e.stderr!=null?String(e.stderr):"";return s+a}}function Ye(t){try{return W("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 ye(t={}){let e=!!t.headed,s=t.viewport||{width:1280,height:720};if(!process.execPath)throw new Error("Node.js runtime not found");let a=await Ke(process.cwd());console.log(a?P.gray(" \u2713 ffmpeg installed for Playwright video"):P.yellow(" \u26A0 Could not install ffmpeg (video may be unavailable)")),Te({headed:e,viewport:s}),await Me();let o=ce(process.cwd());if(me("cursor-agent")){le(o);let d=Ye(o);d&&console.log(P.gray(" \u2713 cursor-agent: mcp enable playwright-official"));let y=le(o),i=Re(y);if(i)try{let h=Be(o,i);console.log(P.gray(` \u2713 MCP auto-approval key saved (${h})`))}catch(h){console.log(P.yellow(` \u26A0 Could not write mcp-approvals.json: ${h.message}`))}else d||(console.log(P.yellow(" \u26A0 Could not auto-approve MCP (mcp enable failed and no approval key in cursor-agent output)")),console.log(P.gray(" Try: cursor-agent mcp enable playwright-official")))}else console.log(P.yellow(" \u26A0 cursor-agent not found; install it to use Cursor MCP tools"))}async function je(t){try{console.log(P.cyan(`
|
|
5
13
|
\u{1F680} Running CI setup...
|
|
6
|
-
`)),await
|
|
14
|
+
`)),await ye({headed:!1,cloudSync:!0,viewport:{width:1280,height:720}}),console.log(P.green(`
|
|
7
15
|
\u2705 CI/CD setup complete!
|
|
8
|
-
`))}catch(e){console.log(
|
|
16
|
+
`))}catch(e){console.log(P.red(`
|
|
9
17
|
\u274C Error: ${e.message}
|
|
10
|
-
`)),process.exit(1)}}async function
|
|
18
|
+
`)),process.exit(1)}}async function Ne(t,e){try{let s=["playwright","test",t||"tests/","--project=chromium"];e.headed&&s.push("--headed"),console.log(P.cyan(`
|
|
11
19
|
\u{1F3A5} Running tests with video recording...
|
|
12
|
-
`)),console.log(
|
|
20
|
+
`)),console.log(P.gray("\u2501".repeat(50)));let a=U("npx",s,{cwd:process.cwd(),stdio:"inherit"});a.on("close",o=>{o===0?console.log(P.green(`
|
|
13
21
|
\u2705 Tests complete!
|
|
14
|
-
`)):(console.log(
|
|
15
|
-
\u274C Tests failed with code ${
|
|
16
|
-
`)),process.exit(
|
|
17
|
-
\u274C Error: ${
|
|
18
|
-
`)),process.exit(1)})}catch(
|
|
19
|
-
\u274C Error: ${
|
|
20
|
-
`)),process.exit(1)}}var
|
|
21
|
-
`,"utf-8")}var
|
|
22
|
-
`));return}console.log(
|
|
23
|
-
|
|
24
|
-
`))):(console.log(
|
|
25
|
-
|
|
26
|
-
`)));return}if(t){console.log(
|
|
27
|
-
`));return}let
|
|
28
|
-
`));return}}let
|
|
22
|
+
`)):(console.log(P.red(`
|
|
23
|
+
\u274C Tests failed with code ${o}
|
|
24
|
+
`)),process.exit(o))}),a.on("error",o=>{console.log(P.red(`
|
|
25
|
+
\u274C Error: ${o.message}
|
|
26
|
+
`)),process.exit(1)})}catch(s){console.log(P.red(`
|
|
27
|
+
\u274C Error: ${s.message}
|
|
28
|
+
`)),process.exit(1)}}var V,he=J(()=>{V=Se(import.meta.url)});import{mkdir as T,writeFile as x,readFile as z}from"fs/promises";import{existsSync as C,readdirSync as Le,readFileSync as De}from"fs";import{join as g,resolve as be,dirname as Ze}from"path";import{homedir as S}from"os";import O from"inquirer";import n from"chalk";import _ from"ora";import{spawn as M,execSync as j}from"child_process";import{fileURLToPath as He}from"url";import{createRequire as we}from"module";import{existsSync as Pe,readFileSync as Ce,writeFileSync as xe,mkdirSync as ke}from"fs";import{join as Q}from"path";import{homedir as ee}from"os";var L={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 te(){return Q(ee(),".zibby","config.json")}function D(){try{let t=te();return Pe(t)?JSON.parse(Ce(t,"utf-8")):{}}catch{return{}}}function oe(t,e){let s=e?L[e]:null;s&&G(s.envVar,t)}function G(t,e){if(!t||typeof t!="string"||!e||typeof e!="string")return;let s=Q(ee(),".zibby");ke(s,{recursive:!0});let a=te(),o=D();(!o.agentKeys||typeof o.agentKeys!="object")&&(o.agentKeys={}),o.agentKeys[t]=String(e).trim(),delete o.agentApiKey,xe(a,`${JSON.stringify(o,null,2)}
|
|
29
|
+
`,"utf-8")}function Ge(){if(process.platform==="darwin")try{let t=j('security find-generic-password -s "Claude Code-credentials" -w',{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim();if(t){let e=JSON.parse(t);if(e?.claudeAiOauth?.accessToken)return e.claudeAiOauth}}catch{}try{let t=g(S(),".claude",".credentials.json");return C(t)&&JSON.parse(De(t,"utf-8"))?.claudeAiOauth||null}catch{return null}}async function Fe(){let t=Ge(),e=t?.accessToken||null,s=t?.subscriptionType?t.subscriptionType.charAt(0).toUpperCase()+t.subscriptionType.slice(1):null,a=process.platform==="darwin"?"macOS Keychain":"~/.claude/.credentials.json",o=process.env.ANTHROPIC_API_KEY||D().agentKeys?.ANTHROPIC_API_KEY;console.log(""),console.log(n.cyan(" Claude has two billing modes \u2014 choose which you have:")),console.log("");let d=e?s?`Subscription (OAuth) \u2014 Claude ${s} plan detected (${a}, ***${e.slice(-4)})`:`Subscription (OAuth) \u2014 auto-detected (${a}, ***${e.slice(-4)})`:"Subscription (OAuth) \u2014 Claude Pro / Max plan billing",{kind:y}=await O.prompt([{type:"select",name:"kind",message:"Which Claude credential do you want to use?",choices:[{name:d,value:"oauth"},{name:o?`API key \u2014 found one (***${o.slice(-4)}), pay-per-token billing`:"API key \u2014 pay-per-token billing via console.anthropic.com",value:"api"}],default:e?"oauth":o?"api":"oauth"}]);if(y==="skip")return{kind:"skip"};if(y==="oauth"){if(e)return{kind:"oauth",token:e,subscriptionType:t?.subscriptionType};console.log(""),console.log(n.gray(" How to get an OAuth subscription token:")),console.log(n.gray(" 1. Install claude: npm install -g @anthropic-ai/claude-code")),console.log(n.gray(" 2. Run: claude")),console.log(n.gray(" \u2192 log in via browser \u2192 quit when shell appears")),console.log(n.gray(" 3. Read your token:")),process.platform==="darwin"?(console.log(n.gray(' (macOS) security find-generic-password -s "Claude Code-credentials" -w')),console.log(n.gray(" | jq -r .claudeAiOauth.accessToken"))):console.log(n.gray(" cat ~/.claude/.credentials.json | jq -r .claudeAiOauth.accessToken")),console.log("");let{token:h}=await O.prompt([{type:"password",name:"token",message:"Paste OAuth token (or press Enter to skip):",mask:"*"}]);return h&&h.trim()?{kind:"oauth",token:h.trim()}:{kind:"skip"}}if(o)return{kind:"api",token:o};let{token:i}=await O.prompt([{type:"password",name:"token",message:"Paste Anthropic API key (from https://console.anthropic.com/settings/keys, or press Enter to skip):",mask:"*"}]);return i&&i.trim()?{kind:"api",token:i.trim()}:{kind:"skip"}}var Ve=He(import.meta.url),Ue=Ze(Ve),ve=we(import.meta.url);async function We(){try{let t=process.platform==="win32",e=j("npm config get prefix",{encoding:"utf-8"}).trim(),s=t?e:`${e}/bin`,a=s.replace(/^~/,S()),o=t?";":":";if(process.env.PATH.split(o).some(m=>{let A=m.replace(/^~/,S());return A===a||A===s}))return;if(process.env.CI||process.env.ZIBBY_CI||!process.stdin.isTTY){console.log(n.yellow("npm global bin not in PATH")),console.log(n.gray(` Location: ${a}`)),console.log(n.gray(` Add it manually: export PATH="${a}:$PATH"
|
|
30
|
+
`));return}console.log(n.yellow("npm global bin not in PATH")),console.log(n.gray(` Location: ${a}`)),console.log();let{shouldAddPath:i}=await O.prompt([{type:"confirm",name:"shouldAddPath",message:"Add npm global bin to your shell PATH automatically?",default:!0}]);if(!i){t?(console.log(n.gray(`
|
|
31
|
+
To add manually on Windows:`)),console.log(n.gray(' 1. Search "Environment Variables" in Start menu')),console.log(n.gray(' 2. Edit "Path" in User variables')),console.log(n.gray(` 3. Add: ${a}
|
|
32
|
+
`))):(console.log(n.gray(`
|
|
33
|
+
To add manually, run:`)),console.log(n.gray(` echo 'export PATH="${a}:$PATH"' >> ~/.zshrc`)),console.log(n.gray(` source ~/.zshrc
|
|
34
|
+
`)));return}if(t){console.log(n.yellow("Cannot auto-add PATH on Windows")),console.log(n.gray(" Please add manually:")),console.log(n.gray(' 1. Search "Environment Variables" in Start menu')),console.log(n.gray(' 2. Edit "Path" in User variables')),console.log(n.gray(` 3. Add: ${a}
|
|
35
|
+
`));return}let h=process.env.SHELL||"",f="";if(h.includes("zsh"))f=g(S(),".zshrc");else if(h.includes("bash"))f=C(g(S(),".bashrc"))?g(S(),".bashrc"):g(S(),".bash_profile");else{console.log(n.yellow(`Unknown shell: ${h}`)),console.log(n.gray(" Please add manually:")),console.log(n.gray(` export PATH="${a}:$PATH"`));return}if(C(f)){let m=await z(f,"utf-8");if(m.includes(a)||m.includes("npm")&&m.includes("global")&&m.includes("bin")){console.log(n.yellow(`PATH entry found in ${f} but not active`)),console.log(n.gray(` Run: source ${f}
|
|
36
|
+
`));return}}let w=`
|
|
29
37
|
# npm global bin (added by zibby)
|
|
30
|
-
export PATH="${
|
|
31
|
-
`;await
|
|
32
|
-
|
|
33
|
-
`))}catch{}}async function
|
|
34
|
-
|
|
35
|
-
`)
|
|
36
|
-
|
|
37
|
-
`)),process.exit(1)),!y&&
|
|
38
|
-
|
|
39
|
-
`)),console.log(
|
|
40
|
-
`)),process.exit(0)),e.force&&!y&&console.log(
|
|
38
|
+
export PATH="${a}:$PATH"
|
|
39
|
+
`;await x(f,(C(f)?await z(f,"utf-8"):"")+w),console.log(n.green(`Added to ${f}`)),console.log(n.yellow(`
|
|
40
|
+
Run this to activate in current session:`)),console.log(n.gray(` source ${f}
|
|
41
|
+
`))}catch{}}async function Kt(t,e){console.log(`
|
|
42
|
+
Zibby Test Automation
|
|
43
|
+
`);let s=!e.skipMemory,a=["dolt","mem0"].includes(String(e.memoryBackend||"").toLowerCase())?String(e.memoryBackend).toLowerCase():"dolt";await We();let o=t?be(process.cwd(),t):process.cwd(),d=t||"zibby-tests",y=!!t;y&&C(o)&&(console.log(n.red(`
|
|
44
|
+
Directory "${t}" already exists!
|
|
45
|
+
`)),process.exit(1)),!y&&C(g(o,".zibby.config.mjs"))&&!e.force&&(console.log(n.yellow(`
|
|
46
|
+
Zibby is already initialized in this directory!
|
|
47
|
+
`)),console.log(n.white("Config file found: .zibby.config.mjs")),console.log(n.gray(`Use --force or -f to reinitialize
|
|
48
|
+
`)),process.exit(0)),e.force&&!y&&console.log(n.cyan(`
|
|
41
49
|
Reinitializing Zibby configuration...
|
|
42
|
-
`));let
|
|
43
|
-
`)),
|
|
50
|
+
`));let i;if(e.agent&&(e.headed||e.headless))console.log(n.cyan(`Setting up with provided options...
|
|
51
|
+
`)),i={agent:e.agent,browserMode:e.headless?"headless":"headed",apiKey:e.apiKey||null,cloudSync:!!(e.cloudSync||e.apiKey)};else{if(e.agent)i={agent:e.agent};else{let{agent:b}=await O.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"}]);i={agent:b}}let m=L[i.agent],A=!(process.env.CI||process.env.ZIBBY_CI||!process.stdin.isTTY);if(i.agent==="claude"&&!e.agentKey&&A){let b=await Fe();b?.kind==="oauth"&&b.token?i.claudeOauthToken=b.token:b?.kind==="api"&&b.token&&(i.agentKey=b.token)}else if(m&&!e.agentKey&&A){let b=D(),r=process.env[m.envVar]||b.agentKeys?.[m.envVar],c=r?`***${r.slice(-4)}`:null,l=c?`${m.label} found (${c}). Press Enter to keep, or paste a new key:`:`Enter ${m.label} (from ${m.url}, or press Enter to skip):`,{agentKey:u}=await O.prompt([{type:"password",name:"agentKey",message:l,mask:"*"}]);u&&u.trim()&&(i.agentKey=u.trim())}let k=[];if(!e.headed&&!e.headless&&k.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||k.push({type:"input",name:"apiKey",message:"Enable cloud sync? Enter project ZIBBY_API_KEY (or press Enter to skip):"}),k.length>0){let b=await O.prompt(k);Object.assign(i,b)}i.browserMode=e.headless?"headless":e.headed?"headed":i.browserMode,i.apiKey=e.apiKey||i.apiKey,i.cloudSync=!!(e.cloudSync||e.apiKey||i.apiKey&&i.apiKey.trim())}e.agentKey&&(i.agentKey=e.agentKey),e.agentOauthToken&&i.agent==="claude"&&(i.claudeOauthToken=e.agentOauthToken);let f=L[i.agent];i.claudeOauthToken&&(G("CLAUDE_CODE_OAUTH_TOKEN",i.claudeOauthToken),console.log(n.gray(" Claude OAuth subscription token saved to ~/.zibby/config.json")),console.log(n.gray(" Used by: zibby test / chat / workflow run / workflow start"))),i.agentKey&&(oe(i.agentKey,i.agent),console.log(n.gray(" Agent API key saved to ~/.zibby/config.json"))),i.mcp="playwright",i.setupMcp=i.agent==="cursor";let w=_("Setting up Zibby...").start();try{if(y&&await T(o,{recursive:!0}),await T(g(o,"test-specs/examples"),{recursive:!0}),await T(g(o,"tests"),{recursive:!0}),await T(g(o,".zibby/output"),{recursive:!0}),await T(g(o,".zibby/commands"),{recursive:!0}),s&&a==="dolt")try{let{initMemory:r,DoltDB:c}=await import("@zibby/ui-memory");if(c.isAvailable()){let{created:l}=r(o);l&&(w.text="Initialized test memory database (Dolt)...")}else w.text="Dolt not found \u2014 skipping memory database (brew install dolt)"}catch{}w.text="Scaffolding workflow graph...";let m=e.template||"browser-test-automation";try{let{writeTemplateFiles:r}=await Promise.resolve().then(()=>(re(),ie));await r(o,m,{enableMemory:s})}catch(r){throw w.fail(`Failed to scaffold template: ${r.message}`),r}w.text="Generating configuration files...";let A=qe(i,e,{memoryBackend:a});if(await x(g(o,".zibby.config.mjs"),A),await x(g(o,".env.example"),Je(i,a)),i.apiKey&&i.apiKey.trim()){let r=g(o,".env"),c=i.apiKey.trim();if(C(r)){let l=await z(r,"utf8");/^ZIBBY_API_KEY=/m.test(l)?l=l.replace(/^ZIBBY_API_KEY=.*/m,`ZIBBY_API_KEY=${c}`):/^#\s*ZIBBY_API_KEY=/m.test(l)?l=l.replace(/^#\s*ZIBBY_API_KEY=.*/m,`ZIBBY_API_KEY=${c}`):l=`${l.trimEnd()}
|
|
44
52
|
|
|
45
53
|
# Zibby Cloud Sync
|
|
46
54
|
ZIBBY_API_KEY=${c}
|
|
47
|
-
`,await
|
|
55
|
+
`,await x(r,l)}else await x(r,Xe(i,c,a))}if(i.agentKey&&f){let r=g(o,".env"),c=i.agentKey;if(C(r)){let l=await z(r,"utf8"),u=new RegExp(`^${f.envVar}=.*`,"m"),p=new RegExp(`^#\\s*${f.envVar}=.*`,"m");u.test(l)?l=l.replace(u,`${f.envVar}=${c}`):p.test(l)?l=l.replace(p,`${f.envVar}=${c}`):l=`${l.trimEnd()}
|
|
48
56
|
|
|
49
57
|
# AI Agent Key
|
|
50
|
-
${
|
|
51
|
-
`,await
|
|
52
|
-
Missing required Zibby dependencies in this project:`)),console.log(
|
|
53
|
-
`));else{let
|
|
54
|
-
`)))}}}if(!y&&a
|
|
55
|
-
Using mem0 backend requires mem0ai in your project dependencies.`)),console.log(
|
|
56
|
-
`))),!e.skipInstall){let
|
|
57
|
-
|
|
58
|
-
`)),c())})})}if(
|
|
59
|
-
`))}}}if(
|
|
60
|
-
`))}}}if(
|
|
61
|
-
`))}}let c=
|
|
62
|
-
`,"utf-8");let
|
|
63
|
-
`))}}if(
|
|
58
|
+
${f.envVar}=${c}
|
|
59
|
+
`,await x(r,l)}}if(y){let r=Qe(d,i,{memoryBackend:a});await x(g(o,"package.json"),r)}if(!C(g(o,".gitignore"))){let r=et();await x(g(o,".gitignore"),r)}if(!C(g(o,"playwright.config.js"))){let r=tt("on");await x(g(o,"playwright.config.js"),r)}if(!C(g(o,"test-specs/examples/example-domain.txt"))){let r=ot();await x(g(o,"test-specs/examples/example-domain.txt"),r)}let k=be(Ue,"../../../../examples/.zibby/commands");if(C(k)){let r=Le(k).filter(c=>c.toLowerCase().endsWith(".md"));for(let c of r){let l=g(o,".zibby/commands",c);if(e.force||!C(l)){let u=await z(g(k,c),"utf-8");await x(l,u)}}}if(!C(g(o,".zibby/commands/example.md"))){let r=nt();await x(g(o,".zibby/commands/example.md"),r)}if(y){let r=st(d,i);await x(g(o,"README.md"),r)}if(w.succeed(y?"Project created!":"Zibby initialized!"),y&&!e.skipInstall){let r=_("Installing dependencies...").start();await new Promise((c,l)=>{M("npm",["install"],{cwd:o,stdio:"pipe"}).on("close",p=>{p===0?(r.succeed("Dependencies installed!"),c()):(r.fail("Failed to install dependencies"),l(new Error("npm install failed")))})})}else if(!y){let r=["@zibby/cli","@zibby/core"],c=[];for(let l of r)try{we(g(o,"package.json")).resolve(`${l}/package.json`)}catch{c.push(l)}if(c.length>0){let l=ve("../../package.json"),u=c.map(p=>p==="@zibby/cli"?`${p}@latest`:p==="@zibby/core"?`${p}@${l.dependencies?.["@zibby/core"]||"latest"}`:p);if(e.skipInstall)console.log(n.yellow(`
|
|
60
|
+
Missing required Zibby dependencies in this project:`)),console.log(n.white(` ${c.join(", ")}`)),console.log(n.gray("Install them manually to avoid runtime errors:")),console.log(n.white(` npm install --save-dev ${u.join(" ")}
|
|
61
|
+
`));else{let p=_(`Installing ${u.join(", ")}...`).start();await new Promise(N=>{M("npm",["install","--save-dev",...u],{cwd:o,stdio:"pipe"}).on("close",R=>N(R??1))})===0?p.succeed("Installed missing Zibby dependencies"):(p.warn("Could not auto-install Zibby dependencies"),console.log(n.gray("Run this manually:")),console.log(n.white(` npm install --save-dev ${u.join(" ")}
|
|
62
|
+
`)))}}}if(!y&&s&&a==="mem0"&&(console.log(n.yellow(`
|
|
63
|
+
Using mem0 backend requires mem0ai in your project dependencies.`)),console.log(n.gray("Run this manually in your project when ready:")),console.log(n.white(` npm install mem0ai
|
|
64
|
+
`))),!e.skipInstall){let r=_("Installing Playwright browsers...").start();await new Promise(c=>{let l=M("npx",["playwright","install","chromium"],{cwd:o,stdio:"pipe"}),u="";l.stdout.on("data",p=>{u+=p.toString()}),l.stderr.on("data",p=>{u+=p.toString()}),l.on("close",p=>{p===0?(u.includes("already installed")||u.includes("up to date")?r.succeed("Playwright browsers already installed"):r.succeed("Playwright browsers installed!"),c()):(r.warn("Could not verify Playwright browsers"),console.log(n.yellow(`
|
|
65
|
+
If tests fail, run: npx playwright install
|
|
66
|
+
`)),c())})})}if(i.agent==="cursor"&&!e.skipInstall){let r=_("Checking cursor-agent CLI...").start();try{j("cursor-agent --version",{encoding:"utf-8",timeout:5e3,stdio:"pipe"}),r.succeed("cursor-agent CLI already installed")}catch{r.text="Installing cursor-agent CLI...";try{await new Promise((c,l)=>{M("bash",["-c","curl https://cursor.com/install -fsS | bash"],{stdio:"pipe"}).on("close",p=>{if(p===0){let I=g(S(),".local","bin");process.env.PATH.includes(I)||(process.env.PATH=`${I}:${process.env.PATH}`),r.succeed("cursor-agent CLI installed!"),c()}else l(new Error("cursor-agent install failed"))})})}catch{r.fail("Could not install cursor-agent CLI"),console.log(n.yellow(` Install manually: curl https://cursor.com/install -fsS | bash
|
|
67
|
+
`))}}}if(i.agent==="codex"&&!e.skipInstall){let r=_("Checking Codex CLI...").start();try{j("codex --version",{encoding:"utf-8",timeout:5e3,stdio:"pipe"}),r.succeed("Codex CLI already installed")}catch{r.text="Installing Codex CLI...";try{await new Promise((c,l)=>{M("npm",["install","-g","@openai/codex"],{stdio:"pipe"}).on("close",p=>{p===0?(r.succeed("Codex CLI installed!"),c()):l(new Error("npm install -g @openai/codex failed"))})})}catch{r.fail("Could not install Codex CLI"),console.log(n.yellow(` Install manually: npm install -g @openai/codex
|
|
68
|
+
`))}}}if(i.agent==="gemini"&&!e.skipInstall){let r=_("Checking Gemini CLI...").start();try{j("gemini --version",{encoding:"utf-8",timeout:5e3,stdio:"pipe"}),r.succeed("Gemini CLI already installed")}catch{r.text="Installing Gemini CLI...";try{await new Promise((l,u)=>{M("npm",["install","-g","@google/gemini-cli"],{stdio:"pipe"}).on("close",I=>{I===0?(r.succeed("Gemini CLI installed!"),l()):u(new Error("npm install -g @google/gemini-cli failed"))})})}catch{r.fail("Could not install Gemini CLI"),console.log(n.yellow(` Install manually: npm install -g @google/gemini-cli
|
|
69
|
+
`))}}let c=_("Configuring Gemini MCP servers...").start();try{let l=g(S(),".gemini"),u=g(l,"settings.json");C(l)||await T(l,{recursive:!0});let p={mcpServers:{}};if(C(u))try{let H=await z(u,"utf-8");p=JSON.parse(H),p.mcpServers||(p.mcpServers={})}catch{}let I;try{let{createRequire:H}=await import("module");I=H(import.meta.url).resolve("@zibby/mcp-browser/bin/mcp-browser-zibby.js")}catch{I="@playwright/mcp"}let N=i.browserMode!=="headless",Z=I==="@playwright/mcp"?["-y","@playwright/mcp","--isolated","--viewport-size=1280x720","--output-dir","test-results"]:[I,"--isolated","--viewport-size=1280x720","--output-dir=test-results"];N||Z.push("--headless"),p.mcpServers["playwright-official"]={command:I==="@playwright/mcp"?"npx":"node",args:Z},await x(u,`${JSON.stringify(p,null,2)}
|
|
70
|
+
`,"utf-8");let R="Gemini MCP configured";N?R+=" (headed mode - visible browser)":R+=" (headless mode - hidden browser)",c.succeed(R)}catch(l){c.fail("MCP setup failed"),console.log(n.yellow(" You may need to configure ~/.gemini/settings.json manually")),console.log(n.gray(` Error: ${l.message}
|
|
71
|
+
`))}}if(i.agent==="cursor"&&i.setupMcp){let r=_("Setting up Playwright MCP...").start();try{let{setupPlaywrightMcpCommand:c}=await Promise.resolve().then(()=>(he(),fe)),l=i.cloudSync||!1,u=i.browserMode!=="headless";await c({headed:u,cloudSync:l,viewport:{width:1280,height:720}});let p="Playwright MCP configured";u?p+=" (headed mode - visible browser)":p+=" (headless mode - hidden browser)",l&&(p+=" + Zibby MCP (cloud sync)"),r.succeed(p),l&&!(i.apiKey&&i.apiKey.trim())&&console.log(n.gray(`
|
|
64
72
|
Copy .env.example to .env and set ZIBBY_API_KEY to enable uploads
|
|
65
|
-
`))}catch(c){
|
|
66
|
-
`)),console.log(
|
|
67
|
-
`))}}console.log(
|
|
68
|
-
|
|
69
|
-
`)),console.log(
|
|
70
|
-
`)),console.log(
|
|
71
|
-
`)),console.log(
|
|
72
|
-
`))}catch(
|
|
73
|
-
|
|
74
|
-
`)),process.exit(1)}}function
|
|
73
|
+
`))}catch(c){r.fail("MCP setup script failed"),console.log(n.yellow(" Check if MCP is already configured:")),console.log(n.gray(' \u2022 Open Cursor settings \u2192 Check "playwright-official" MCP')),console.log(n.gray(" \u2022 Run: cursor-agent mcp list")),console.log(n.gray(` \u2022 Or run manually: zibby setup-playwright
|
|
74
|
+
`)),console.log(n.gray(` Error: ${c.message}
|
|
75
|
+
`))}}console.log(n.bold.green(`
|
|
76
|
+
All set!
|
|
77
|
+
`)),console.log(n.cyan("Start the Zibby Chat Agent:")),y&&console.log(n.white(` cd ${t}`)),console.log(n.white(` zibby
|
|
78
|
+
`)),console.log(n.cyan("Or run a test directly:")),console.log(n.white(` zibby run test-specs/examples/example-domain.txt
|
|
79
|
+
`)),console.log(n.cyan("Next steps:"));let b=1;console.log(n.white(` ${b++}. cp .env.example .env ${n.gray("# then add your API keys")}`)),s&&console.log(n.white(` ${b++}. Set ${n.bold("ZIBBY_MEMORY_BACKEND")} in .env ${n.gray(`# currently: ${a}`)}`)),console.log(n.white(` ${b++}. Type ${n.bold("zibby")} to chat with the AI testing assistant`)),console.log(n.white(` ${b++}. Write test specs in test-specs/`)),console.log(n.white(` ${b++}. Run: npx zibby run <spec-file>
|
|
80
|
+
`))}catch(m){w.fail("Failed to create project"),console.error(n.red(`
|
|
81
|
+
Error: ${m.message}
|
|
82
|
+
`)),process.exit(1)}}function qe(t,e={},s={}){let a=["dolt","mem0"].includes(String(s.memoryBackend||"").toLowerCase())?String(s.memoryBackend).toLowerCase():"dolt",o={claude:`
|
|
75
83
|
claude: {
|
|
76
84
|
model: 'auto', // Options: 'auto', 'sonnet-4.6', 'opus-4.6', 'sonnet-4.5', 'opus-4.5'
|
|
77
85
|
maxTokens: 4096,
|
|
@@ -84,12 +92,12 @@ Using mem0 backend requires mem0ai in your project dependencies.`)),console.log(
|
|
|
84
92
|
},`,gemini:`
|
|
85
93
|
gemini: {
|
|
86
94
|
model: 'gemini-2.5-pro', // Options: 'auto', 'gemini-2.5-pro', 'gemini-2.5-flash'
|
|
87
|
-
},`},
|
|
88
|
-
`).map(
|
|
95
|
+
},`},d=t.agent,y=Object.entries(o).filter(([i])=>i!==d).map(([,i])=>i.split(`
|
|
96
|
+
`).map(h=>h.trim()?` // ${h.trimStart()}`:h).join(`
|
|
89
97
|
`)).join(`
|
|
90
98
|
`);return`export default {
|
|
91
99
|
// AI agent settings
|
|
92
|
-
agent: {${
|
|
100
|
+
agent: {${o[d]}
|
|
93
101
|
${y}
|
|
94
102
|
strictMode: false,
|
|
95
103
|
},
|
|
@@ -103,7 +111,7 @@ ${y}
|
|
|
103
111
|
|
|
104
112
|
// Chat memory backend adapter (dolt | mem0)
|
|
105
113
|
memory: {
|
|
106
|
-
backend: '${
|
|
114
|
+
backend: '${a}',
|
|
107
115
|
},
|
|
108
116
|
|
|
109
117
|
// Advanced: Override models per node (optional)
|
|
@@ -154,14 +162,14 @@ ${y}
|
|
|
154
162
|
// Cloud sync - auto-upload test results & videos (requires ZIBBY_API_KEY in .env)
|
|
155
163
|
cloudSync: ${t.cloudSync||!1}
|
|
156
164
|
};
|
|
157
|
-
`}function
|
|
165
|
+
`}function Je(t,e="dolt"){return`# Zibby Test Automation - Environment Variables
|
|
158
166
|
|
|
159
167
|
# AI Provider Keys
|
|
160
168
|
${{claude:"ANTHROPIC_API_KEY=sk-ant-your_key_here",cursor:`# Cursor Agent uses cursor-agent CLI \u2014 no API key needed
|
|
161
169
|
# 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]||""}
|
|
162
170
|
|
|
163
171
|
# Zibby Cloud Sync (for uploading test results & videos)
|
|
164
|
-
# Get your API key from: https://zibby.
|
|
172
|
+
# Get your API key from: https://zibby.dev/settings/tokens
|
|
165
173
|
# ZIBBY_API_KEY=zby_your_api_key_here
|
|
166
174
|
|
|
167
175
|
# Test Memory (Dolt DB) - Auto-compaction settings
|
|
@@ -171,7 +179,7 @@ ${{claude:"ANTHROPIC_API_KEY=sk-ant-your_key_here",cursor:`# Cursor Agent uses c
|
|
|
171
179
|
|
|
172
180
|
# Chat memory backend
|
|
173
181
|
ZIBBY_MEMORY_BACKEND=${e}
|
|
174
|
-
`}function
|
|
182
|
+
`}function Xe(t,e,s="dolt"){return`# Zibby Test Automation - Environment Variables
|
|
175
183
|
|
|
176
184
|
# AI Provider Keys
|
|
177
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"}[t.agent]||""}
|
|
@@ -185,8 +193,8 @@ ZIBBY_API_KEY=${e}
|
|
|
185
193
|
# ZIBBY_MEMORY_COMPACT_EVERY=1500 # Auto-compact every N runs (0 to disable)
|
|
186
194
|
|
|
187
195
|
# Chat memory backend
|
|
188
|
-
ZIBBY_MEMORY_BACKEND=${
|
|
189
|
-
`}function
|
|
196
|
+
ZIBBY_MEMORY_BACKEND=${s}
|
|
197
|
+
`}function Qe(t,e,s={}){let o={"@zibby/cli":"latest","@zibby/core":ve("../../package.json").dependencies?.["@zibby/core"]||"latest"};return s.memoryBackend==="mem0"&&(o.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:o,devDependencies:{"@playwright/test":"^1.49.0",dotenv:"^17.2.3"}},null,2)}function et(){return`# Dependencies
|
|
190
198
|
node_modules/
|
|
191
199
|
|
|
192
200
|
# Test artifacts
|
|
@@ -214,7 +222,7 @@ Thumbs.db
|
|
|
214
222
|
# Zibby memory (Dolt DB synced separately via dolt remote, not git)
|
|
215
223
|
.zibby/memory/
|
|
216
224
|
.zibby/memory-context.md
|
|
217
|
-
`}function
|
|
225
|
+
`}function tt(t="off",e=null){return`import { defineConfig} from '@playwright/test';
|
|
218
226
|
|
|
219
227
|
export default defineConfig({
|
|
220
228
|
testDir: './tests',
|
|
@@ -236,7 +244,7 @@ ${e?` outputDir: '${e}',
|
|
|
236
244
|
['list']
|
|
237
245
|
],
|
|
238
246
|
});
|
|
239
|
-
`}function
|
|
247
|
+
`}function ot(){return`Test Specification: Example Domain Navigation
|
|
240
248
|
==============================================
|
|
241
249
|
|
|
242
250
|
Application: Example Domain
|
|
@@ -273,7 +281,7 @@ Notes:
|
|
|
273
281
|
- Uses a stable, public domain (example.com) maintained by IANA
|
|
274
282
|
- No authentication required
|
|
275
283
|
- Suitable for CI/CD smoke testing
|
|
276
|
-
`}function
|
|
284
|
+
`}function nt(){return`# Example command template
|
|
277
285
|
|
|
278
286
|
Use this command when the user asks for a concise testing task breakdown.
|
|
279
287
|
|
|
@@ -284,7 +292,7 @@ Required output format:
|
|
|
284
292
|
4. Expected result
|
|
285
293
|
|
|
286
294
|
Keep the response actionable and short.
|
|
287
|
-
`}function
|
|
295
|
+
`}function st(t,e){return`# ${t}
|
|
288
296
|
|
|
289
297
|
AI-powered test automation with Zibby.
|
|
290
298
|
|
|
@@ -373,4 +381,4 @@ ${t}/
|
|
|
373
381
|
|
|
374
382
|
- Documentation: https://docs.zibby.dev
|
|
375
383
|
- Examples: https://github.com/zibby/examples
|
|
376
|
-
`}export{
|
|
384
|
+
`}export{qe as generateConfig,Kt as initCommand};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import s from"chalk";import C from"ora";var r={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.
|
|
1
|
+
import s from"chalk";import C from"ora";var r={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"}};function u(){let o;if(process.env.ZIBBY_API_URL)o=process.env.ZIBBY_API_URL;else{let n=process.env.ZIBBY_ENV||"prod";r[n]?o=r[n].apiUrl:o=r.prod.apiUrl}try{let n=new URL(o);return n.protocol!=="http:"&&n.protocol!=="https:"?(console.error(`\u26A0\uFE0F Invalid API URL protocol: ${n.protocol} (only http/https allowed)`),r.prod.apiUrl):o}catch{return console.error(`\u26A0\uFE0F Invalid API URL: ${o}`),r.prod.apiUrl}}import{existsSync as g,mkdirSync as A,readFileSync as E,writeFileSync as $}from"fs";import{homedir as U}from"os";import{join as i}from"path";function m(){return process.env.ZIBBY_CONFIG_DIR||i(U(),".zibby")}function I(){return i(m(),"config.json")}var L=i(U(),".zibby"),Z=i(L,"config.json");function T(){let o=m();g(o)||A(o,{recursive:!0})}function f(){try{let o=I();if(g(o)){let n=E(o,"utf-8");return JSON.parse(n)}}catch{}return{}}function k(o){T(),$(I(),JSON.stringify(o,null,2))}function h(){return f().sessionToken||null}function v(){return f().user||null}function y(o){let n=f();n.projects=o,k(n)}async function G(){let o=C("Fetching projects...").start();try{let n=h(),c=v();n||(o.fail("Not logged in"),console.log(s.yellow(`
|
|
2
2
|
Please log in first:`)),console.log(s.gray(` zibby login
|
|
3
3
|
`)),process.exit(1)),c&&(console.log(s.gray(`Logged in as: ${c.email}`)),c.account_id&&console.log(s.gray(`Account ID: ${c.account_id}
|
|
4
|
-
`)));let
|
|
5
|
-
No projects found`),console.log(`Create a project at: https://zibby.
|
|
6
|
-
`);return}let
|
|
4
|
+
`)));let _=u(),l=await fetch(`${_}/projects`,{headers:{Authorization:`Bearer ${n}`}});if(!l.ok){let e=await l.json().catch(()=>({}));throw new Error(e.error||"Failed to fetch projects")}let t=(await l.json()).projects||[],b=t.map(e=>({name:e.name,projectId:e.projectId,apiToken:e.apiToken}));if(y(b),o.stop(),t.length===0){console.log(`
|
|
5
|
+
No projects found`),console.log(`Create a project at: https://zibby.dev/projects
|
|
6
|
+
`);return}let j=e=>e&&e.length>8?`${e.substring(0,8)}\u2022\u2022\u2022\u2022`:e||"-",p=Math.max(4,...t.map(e=>e.name.length)),a=36,d=14,x=` ${"Name".padEnd(p)} ${"Project ID".padEnd(a)} ${"API Token".padEnd(d)}`,B=` ${"\u2500".repeat(p)} ${"\u2500".repeat(a)} ${"\u2500".repeat(d)}`;console.log(`
|
|
7
7
|
Your Projects (${t.length})
|
|
8
|
-
`),console.log(
|
|
8
|
+
`),console.log(x),console.log(B);for(let e of t){let P=e.name.padEnd(p),N=e.projectId.padEnd(a),R=j(e.apiToken).padEnd(d);console.log(` ${P} ${N} ${R}`)}console.log(""),console.log("\u{1F4A1} Use the Project ID with --project flag:"),console.log(` zibby run test-specs/login.txt --project <project-id> --sync
|
|
9
9
|
`)}catch(n){o.fail("Failed to fetch projects"),console.error(s.red(`
|
|
10
10
|
\u274C Error: ${n.message}
|
|
11
11
|
`)),process.exit(1)}}export{G as listProjectsCommand};
|
package/dist/commands/memory.js
CHANGED
|
@@ -1,39 +1,49 @@
|
|
|
1
1
|
import o from"chalk";var y=`
|
|
2
|
-
Install @zibby/memory and Dolt to enable test memory:
|
|
2
|
+
Install @zibby/ui-memory and Dolt to enable test memory:
|
|
3
3
|
|
|
4
|
-
npm install @zibby/memory # add the package
|
|
4
|
+
npm install @zibby/ui-memory # add the package
|
|
5
5
|
brew install dolt # macOS
|
|
6
6
|
# or: curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash
|
|
7
|
-
`;async function d(){try{return await import("@zibby/memory")}catch{return console.log(o.yellow(`
|
|
8
|
-
@zibby/memory is not installed.
|
|
9
|
-
`)),console.log(o.white(y)),null}}async function
|
|
7
|
+
`;async function d(){try{return await import("@zibby/ui-memory")}catch{return console.log(o.yellow(`
|
|
8
|
+
@zibby/ui-memory is not installed.
|
|
9
|
+
`)),console.log(o.white(y)),null}}async function p(){let t=await d();if(!t)return;let c=process.cwd(),n=t.getStats(c);if(!n.available){console.log(o.red(`
|
|
10
10
|
Dolt is not installed.
|
|
11
11
|
`)),console.log(o.white(" Install Dolt to enable test memory:")),console.log(o.gray(" brew install dolt # macOS")),console.log(o.gray(` curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash # Linux
|
|
12
|
-
`));return}if(!
|
|
12
|
+
`));return}if(!n.initialized){console.log(o.yellow(`
|
|
13
13
|
Memory database not initialized.
|
|
14
14
|
`)),console.log(o.white(" Run `zibby init` or `zibby memory init` to set it up.\n"));return}console.log(o.bold.cyan(`
|
|
15
15
|
Zibby Test Memory
|
|
16
|
-
`)),console.log(o.gray(` Dolt: ${
|
|
17
|
-
${a}`),console.log(o.white(" Recent runs:"));for(let
|
|
18
|
-
${a}`),console.log(o.white(" Top selectors:"));for(let
|
|
19
|
-
${a}`),console.log(o.white(" Recent commits:"));let
|
|
20
|
-
`).filter(
|
|
16
|
+
`)),console.log(o.gray(` Dolt: ${n.doltVersion}`));let a=o.gray(` ${"\u2500".repeat(40)}`);console.log(a);let s=n.counts;if(console.log(o.white(` Test runs: ${o.cyan(s.runs)} (${o.green(`${s.passed} passed`)}, ${s.failed>0?o.red(`${s.failed} failed`):o.gray(`${s.failed} failed`)})`)),console.log(o.white(` Selectors: ${o.cyan(s.selectors)} tracked`)),console.log(o.white(` Pages: ${o.cyan(s.pages)} discovered`)),console.log(o.white(` Transitions: ${o.cyan(s.transitions)} mapped`)),console.log(o.white(` Insights: ${o.cyan(s.insights||0)} saved`)),n.recentRuns.length>0){console.log(`
|
|
17
|
+
${a}`),console.log(o.white(" Recent runs:"));for(let e of n.recentRuns){let l=e.passed?o.green("\u2713"):o.red("\u2717"),g=e.duration_ms?o.gray(`${(e.duration_ms/1e3).toFixed(1)}s`):"";console.log(` ${l} ${o.white(e.spec_path)} ${g}`)}}if(n.topSelectors.length>0){console.log(`
|
|
18
|
+
${a}`),console.log(o.white(" Top selectors:"));for(let e of n.topSelectors){let l=e.success_count+e.failure_count,g=Math.round(e.success_count/l*100);console.log(` ${o.cyan(e.stable_id||"?")} \u2192 ${e.element_desc} (${g}%, ${l} uses)`)}}if(n.log){console.log(`
|
|
19
|
+
${a}`),console.log(o.white(" Recent commits:"));let e=n.log.split(`
|
|
20
|
+
`).filter(l=>l.startsWith("commit")||l.trim().startsWith("run ")).slice(0,10);for(let l of e)console.log(o.gray(` ${l.trim()}`))}console.log("")}async function f(t){let c=await d();if(!c)return;let n=process.cwd();if(!t.force){console.log(o.yellow(`
|
|
21
21
|
This will permanently delete the memory database.
|
|
22
22
|
`)),console.log(o.white(` Run with --force to confirm: zibby memory reset --force
|
|
23
|
-
`));return}let a=
|
|
23
|
+
`));return}let a=c.resetMemory(n);console.log(a?o.green(`
|
|
24
24
|
Memory database reset.
|
|
25
25
|
`):o.gray(`
|
|
26
26
|
No memory database found.
|
|
27
|
-
`))}async function b(
|
|
27
|
+
`))}async function b(t){let c=await d();if(!c)return;let n=process.cwd(),a=c.getStats(n);if(!a.initialized){console.log(o.yellow(`
|
|
28
28
|
Memory database not initialized.
|
|
29
|
-
`));return}let
|
|
30
|
-
Compacting memory (keep last ${
|
|
29
|
+
`));return}let s=t.maxRuns||50,e=t.maxAge||90;console.log(o.white(`
|
|
30
|
+
Compacting memory (keep last ${s} runs/spec, prune data older than ${e}d)...`));let l=a.counts;if(c.compactMemory(n,{maxRuns:s,maxAgeDays:e}).pruned){let u=c.getStats(n).counts,r=m=>l[m]-u[m];console.log(o.green(" Done.")),r("runs")>0&&console.log(o.gray(` Pruned ${r("runs")} old runs`)),r("selectors")>0&&console.log(o.gray(` Pruned ${r("selectors")} stale selectors`)),r("insights")>0&&console.log(o.gray(` Pruned ${r("insights")} old insights`)),r("transitions")>0&&console.log(o.gray(` Pruned ${r("transitions")} stale transitions`)),console.log(o.gray(` Dolt GC completed
|
|
31
31
|
`))}else console.log(o.gray(` Nothing to compact.
|
|
32
|
-
`))}async function
|
|
32
|
+
`))}async function $(){let t=await d();if(!t)return;let c=process.cwd(),n=t.getCostStats(c);if(!n){console.log(o.yellow(`
|
|
33
|
+
Memory database not initialized.
|
|
34
|
+
`)),console.log(o.white(" Run `zibby memory init` first.\n"));return}if(n.available===!1){console.log(o.yellow(`
|
|
35
|
+
No usage data yet${n.reason?` (${n.reason})`:""}.
|
|
36
|
+
`)),console.log(o.gray(" Run `zibby test <spec>` once to populate. Token counts come from")),console.log(o.gray(` the LLM SDK and are written to .zibby/output/sessions/<id>/execute_live/usage.json.
|
|
37
|
+
`));return}console.log(o.bold.cyan(`
|
|
38
|
+
Zibby \u2014 LLM Cost Report
|
|
39
|
+
`));let a=o.gray(` ${"\u2500".repeat(60)}`),s=n.totals;if(console.log(a),console.log(o.white(` Runs with usage data: ${o.cyan(s.runs)}`)),console.log(o.white(` Total input tokens: ${o.cyan(i(s.input))}`)),console.log(o.white(` Total output tokens: ${o.cyan(i(s.output))}`)),console.log(o.white(` Total cache reads: ${o.cyan(i(s.cache_read))} ${o.gray("(billed at ~10% of normal input rate)")}`)),console.log(o.white(` Total cache creation: ${o.cyan(i(s.cache_creation))} ${o.gray("(billed at ~125% of normal input rate)")}`)),n.by_domain.length>0){console.log(`
|
|
40
|
+
${a}`),console.log(o.white(" By domain:"));for(let e of n.by_domain.slice(0,10)){let l=e.runs>0?Math.round((e.input+e.output)/e.runs):0;console.log(` ${o.cyan(e.domain.padEnd(30))} ${o.gray(`${e.runs} runs \xB7 ~${i(l)}/run avg`)}`)}}if(n.by_spec.length>0){console.log(`
|
|
41
|
+
${a}`),console.log(o.white(" By spec:"));for(let e of n.by_spec.slice(0,10)){let l=e.runs>0?Math.round((e.input+e.output)/e.runs):0;console.log(` ${o.cyan(String(e.spec_path).padEnd(40))} ${o.gray(`${e.runs} runs \xB7 ~${i(l)}/run avg`)}`)}}if(n.recent.length>0){console.log(`
|
|
42
|
+
${a}`),console.log(o.white(" Last 10 runs:"));for(let e of n.recent.slice(0,10)){let l=e.passed?o.green("\u2713"):o.red("\u2717"),g=(e.input_tokens||0)+(e.output_tokens||0),u=(e.cache_read_tokens||0)>0?o.gray(` \xB7 cache read ${i(e.cache_read_tokens)}`):"";console.log(` ${l} ${o.gray(e.run_at.slice(0,16))} ${o.cyan(i(g).padStart(8))} ${o.white(e.spec_path||"")}${u}`)}}console.log("")}function i(t){return t==null?"\u2014":t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(1)}K`:`${(t/1e6).toFixed(2)}M`}async function w(){let t=await d();if(!t)return;let c=process.cwd();if(!t.DoltDB.isAvailable()){console.log(o.red(`
|
|
33
43
|
Dolt is not installed.
|
|
34
44
|
`)),console.log(o.white(" Install Dolt:")),console.log(o.gray(" brew install dolt # macOS")),console.log(o.gray(` curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash # Linux
|
|
35
|
-
`));return}let{created:
|
|
45
|
+
`));return}let{created:n,available:a}=t.initMemory(c);n?console.log(o.green(`
|
|
36
46
|
Memory database initialized at .zibby/memory/
|
|
37
47
|
`)):a&&console.log(o.gray(`
|
|
38
48
|
Memory database already initialized.
|
|
39
|
-
`))}export{b as memoryCompactCommand,
|
|
49
|
+
`))}export{b as memoryCompactCommand,$ as memoryCostCommand,w as memoryInitCommand,f as memoryResetCommand,p as memoryStatsCommand};
|
package/dist/commands/project.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import a from"dotenv";var s={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.
|
|
1
|
+
import a from"dotenv";var s={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"}};function c(){let r;if(process.env.ZIBBY_API_URL)r=process.env.ZIBBY_API_URL;else{let e=process.env.ZIBBY_ENV||"prod";s[e]?r=s[e].apiUrl:r=s.prod.apiUrl}try{let e=new URL(r);return e.protocol!=="http:"&&e.protocol!=="https:"?(console.error(`\u26A0\uFE0F Invalid API URL protocol: ${e.protocol} (only http/https allowed)`),s.prod.apiUrl):r}catch{return console.error(`\u26A0\uFE0F Invalid API URL: ${r}`),s.prod.apiUrl}}a.config();function d(r){let e=r.apiKey||process.env.ZIBBY_API_KEY;return e||(console.log(`
|
|
2
2
|
Error: API key is required`),console.log(` Set ZIBBY_API_KEY environment variable or use --api-key flag
|
|
3
|
-
`),process.exit(1)),{apiKey:e}}async function
|
|
3
|
+
`),process.exit(1)),{apiKey:e}}async function v(r={}){let{apiKey:e}=d(r),p=c();try{let t=await fetch(`${p}/projects`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`}});if(!t.ok){let n=await t.json().catch(()=>({}));console.log(`
|
|
4
4
|
Error: ${n.message||t.statusText}
|
|
5
5
|
`),process.exit(1)}let o=await t.json();if(Array.isArray(o)||(o.projects&&Array.isArray(o.projects)?o=o.projects:o.data&&Array.isArray(o.data)?o=o.data:(console.log(`
|
|
6
6
|
Error: Unexpected response format
|
|
@@ -12,4 +12,4 @@ import a from"dotenv";var s={local:{name:"Local Development",apiUrl:"http://loca
|
|
|
12
12
|
Total: ${o.length} project${o.length===1?"":"s"}
|
|
13
13
|
`)}catch(t){console.log(`
|
|
14
14
|
Error: ${t.message}
|
|
15
|
-
`),process.exit(1)}}export{
|
|
15
|
+
`),process.exit(1)}}export{v as projectListCommand};
|