@zibby/cli 0.1.44 → 0.1.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/zibby.js +2 -1
- package/dist/commands/chat.js +1 -1
- package/dist/commands/init.js +21 -21
- package/dist/commands/setup-scripts.js +14 -12
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/bin/zibby.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
process.stdout.on("error",o=>{o.code}),process.stderr.on("error",o=>{o.code}),process.env.DOTENV_CONFIG_QUIET="true";import"@zibby/skills";import{Command as s}from"commander";import{initCommand as c}from"../commands/init.js";import{runCommand as d}from"../commands/run.js";import{videoCommand as p}from"../commands/video.js";import{uploadCommand as m}from"../commands/upload.js";import{ciSetupCommand as l}from"../commands/ci-setup.js";import{setupPlaywrightMcpCommand as u,setupCiCommand as f,testWithVideoCommand as w}from"../commands/setup-scripts.js";import{readFileSync as y}from"fs";import{fileURLToPath as g}from"url";import{dirname as h,join as k}from"path";const b=g(import.meta.url),C=h(b),I=JSON.parse(y(k(C,"../package.json"),"utf-8")),i=process.argv.slice(2),v=i.includes("-h")||i.includes("--help"),P=i.includes("-V")||i.includes("--version"),S=i[0]==="chat",_=["--verbose","-v","--agent","--stream","-s"],j=i.length>0&&i.every(o=>_.includes(o)||i[i.indexOf(o)-1]==="--agent"),D=i.length===0||S||j;if(D&&!v&&!P){const o={},t=i.indexOf("--agent");t!==-1&&i[t+1]&&(o.agent=i[t+1]),(i.includes("--verbose")||i.includes("-v"))&&(o.verbose=!0),(i.includes("--stream")||i.includes("-s"))&&(o.stream=!0);const{chatCommand:n}=await import("../commands/chat.js");await n(o),process.exit(0)}const e=new s;e.name("zibby").description("Zibby Test Automation - AI-powered test generation").version(I.version),e.command("init").description("Initialize a new Zibby test project (like rails new)").argument("[project-name]","Project name (optional, uses current directory if not provided)").option("--agent <type>","Agent to use (claude, cursor, codex, gemini)").option("--memory-backend <backend>","Memory backend to configure (dolt, mem0)","dolt").option("--skip-install","Skip npm install").option("--skip-memory","Skip test memory setup during initialization").option("-f, --force","Force reinitialize (overwrite existing config)").option("--headed","Run MCP browser in headed mode (visible browser)").option("--headless","Run MCP browser in headless mode (hidden browser)").option("--api-key <key>","Zibby API key for cloud sync").option("--cloud-sync","Enable cloud sync and install Zibby MCP").action(c),e.command("test").description("Run a test specification").argument("[spec-path]","Path to test spec file or inline test description in quotes").option("--sources <ids>","Comma-separated test case IDs to fetch from cloud").option("--execution <id>","Execution ID containing the test cases (required with --sources)").option("--agent <type>","Agent to use (claude, cursor, codex, gemini) - overrides config").option("--workflow <name>","Workflow to use (e.g., QuickSmokeWorkflow, quick-smoke)").option("--headless","Run browser in headless mode").option("--node <name>","Run only a specific node (e.g., execute_live, generate_script)").option("--session <id>",'Use existing session (e.g., 1768974629717 or "last") - requires --node').option("--session-path <dir>","Use this session folder (absolute or relative to cwd); Studio pins artifacts here").option("--project <id>","Project ID (optional, auto-detected from ZIBBY_API_KEY)").option("--collection <id-or-name>","Collection ID or name (creates new if name doesn't exist)").option("--folder <path>","Folder path within collection (optional, requires --collection)").option("--sync","Force upload to cloud (overrides cloudSync: false)").option("--no-sync","Skip upload to cloud (overrides cloudSync: true)").option("--config <path>","Path to config file",".zibby.config.mjs").option("--auto-approve","Auto-approve MCP tools (for CI/CD)").option("-o, --open","Open test results in browser after completion").option("--verbose","Show info level logs").option("--debug","Show debug level logs (most verbose)").option("-m, --mem","Enable test memory (Dolt-backed knowledge from previous runs)").action((o,t)=>(t.debug?process.env.ZIBBY_DEBUG="true":t.verbose&&(process.env.ZIBBY_VERBOSE="true"),d(o,t))),e.command("implement").description("Implement a Jira ticket using AI agent (runs in ECS container)").action(async(...o)=>{const{implementCommand:t}=await import("../commands/implement.js");return t(...o)}),e.command("analyze").description("Analyze a Jira ticket against the codebase (runs in ECS container)").option("--workflow <path>","Path to a local workflow JSON file (e.g., .zibby/workflow-analysis.json)").action(async(...o)=>{const{analyzeCommand:t}=await import("../commands/analyze-graph.js");return t(...o)}),e.command("video").description("Organize test videos next to test files").action(p),e.command("upload <spec-path>").description("Upload existing test artifacts to Zibby Cloud").option("--project <id>","Project ID (REQUIRED - use flag or ZIBBY_PROJECT_ID env)").option("--collection <id-or-name>","Collection ID or name (creates new if name doesn't exist)").option("--folder <path>","Folder path within collection (optional)").option("--agent <type>","Agent used (for metadata)").action(m),e.command("login").description("Log in to Zibby (opens browser for authentication)").action(async()=>{const{loginCli:o}=await import("../auth/cli-login.js");await o(),process.exit(0)}),e.command("logout").description("Log out from Zibby (clears saved session)").action(async()=>{const{logoutCli:o}=await import("../auth/cli-login.js");o(),process.exit(0)}),e.command("status").description("Show current authentication status and token details").option("--json","Output in JSON format (for scripts)").action(async o=>{const{showLoginStatus:t}=await import("../auth/cli-login.js");await t(o),process.exit(0)}),e.command("list").description("List your projects and API tokens").action(async()=>{const{listProjectsCommand:o}=await import("../commands/list-projects.js");await o()}),e.command("ci-setup").description("Setup Cursor Agent for CI/CD (patch and configure)").option("--get-keys","Get MCP approval keys").option("--save","Save approval keys to project").action(l),e.command("setup-playwright").description("Setup official Playwright MCP (from cursor-agent-package)").option("--headed","Configure MCP in headed mode (visible browser)").option("--viewport-width <width>","Viewport width (default: 1280)","1280").option("--viewport-height <height>","Viewport height (default: 720)","720").action(o=>{const t={width:parseInt(o.viewportWidth,10)||1280,height:parseInt(o.viewportHeight,10)||720};return u({...o,viewport:t})}),e.command("setup-ci-full").description("Complete CI/CD setup from scratch").action(f),e.command("test-video").description("Run Playwright tests with video recording").argument("[test-file]","Test file to run (default: tests/)").option("--headed","Run in headed mode (visible browser)").action(w),e.command("generate").description("Generate test specs from a ticket + codebase (local analysis using real AI agent)").option("-t, --ticket <key>","Jira ticket key (fetches automatically)").option("-i, --input <file>","Input file with ticket description/requirements").option("-d, --description <text>","Inline ticket description").option("--repo <path>","Path to the codebase (default: current directory)").option("--agent <type>","Agent to use (codex, claude, cursor, gemini)").option("--model <model>","Model override").option("-o, --output <dir>","Output directory for spec files (default: test-specs)").action(async o=>{const{generateCommand:t}=await import("../commands/generate.js");return t(o)}),e.command("studio").description("Launch Zibby Studio desktop (installs from CDN if needed). Uses this folder as the Zibby project.").option("-p, --port <port>","Port for the Studio API bridge (default: 3847)").option("--no-open","Start the API only; do not launch desktop app").option("--update","Force re-download of the latest Studio binary").action(async o=>{const{studioCommand:t}=await import("../commands/studio.js");return t(o)});const E=e.command("g").description("Generate scaffolds");E.command("workflow [name]").description("Scaffold a new custom workflow in .zibby/workflows/<name>/ (auto-generates name if omitted)").action(async o=>{const{generateWorkflowCommand:t}=await import("../commands/workflows/generate.js");return t(o)}),e.command("start <workflow-name>").description("Start a local dev server for a custom workflow").option("-p, --port <port>","Port for the workflow server (default: 3848)").action(async(o,t)=>{const{startWorkflowCommand:n}=await import("../commands/workflows/start.js");return n(o,t)}),e.command("deploy <workflow-name>").description("Deploy a custom workflow to Zibby Cloud").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(o,t)=>{const{deployWorkflowCommand:n}=await import("../commands/workflows/deploy.js");return n(o,t)}),e.command("logs [jobId]").description("Tail logs from a workflow job (use --workflow to auto-pick latest)").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--workflow <name>","Workflow name (tails the latest run)").option("--all","Show interleaved logs from all runs (requires --workflow)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--no-follow","Fetch logs once and exit (default: tail)").option("--lines <n>","Max log lines per fetch (default: 200)").action(async(o,t)=>{const{logsCommand:n}=await import("../commands/workflows/logs.js");return n(o,t)}),e.command("run-workflow").description("Run a deployed workflow from S3 sources (used by ECS containers)").action(async()=>{const{runWorkflowCommand:o}=await import("../commands/workflows/run.js");return o()});const a=e.command("memory").description("Test memory database \u2014 version-controlled knowledge from runs");a.command("stats").description("Show memory database statistics").action(async()=>{const{memoryStatsCommand:o}=await import("../commands/memory.js");return o()}),a.command("init").description("Initialize the memory database (Dolt)").action(async()=>{const{memoryInitCommand:o}=await import("../commands/memory.js");return o()}),a.command("compact").description("Prune old data and run Dolt GC to reclaim storage").option("--max-runs <n>","Keep last N runs per spec (default: 50)",parseInt).option("--max-age <days>","Remove data older than N days (default: 90)",parseInt).action(async o=>{const{memoryCompactCommand:t}=await import("../commands/memory.js");return t(o)}),a.command("reset").description("Wipe the memory database").option("-f, --force","Confirm reset").action(async o=>{const{memoryResetCommand:t}=await import("../commands/memory.js");return t(o)});const r=e.command("workflow").description("Manage workflow graphs (download, upload, list)");r.command("download").description("Download a workflow graph from Zibby Cloud to .zibby/").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--type <type>","Workflow type: analysis, implementation, run_test").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--output <dir>","Output directory (default: .zibby/)").option("--include-default","Download the built-in default graph if no custom one exists").action(async o=>{const{workflowDownloadCommand:t}=await import("../commands/workflow.js");return t(o)}),r.command("list").description("List all workflows for a project").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async o=>{const{workflowListCommand:t}=await import("../commands/workflow.js");return t(o)});const x=e.command("run-queue").description("Parallel capacity \u2014 on-disk wait queue (see parallel.waitWhenAtCapacity in .zibby.config.mjs)");x.command("list").description("List CLI processes waiting for a run slot").option("--config <path>","Path to config file",".zibby.config.mjs").action(async o=>{const{runCapacityQueueListCommand:t}=await import("../commands/run-capacity-queue-cli.js");await t(o),process.exit(0)}),e.parse();
|
|
2
|
+
process.stdout.on("error",o=>{o.code}),process.stderr.on("error",o=>{o.code}),process.env.DOTENV_CONFIG_QUIET="true";import"@zibby/skills";import{Command as d}from"commander";import{initCommand as p}from"../commands/init.js";import{runCommand as m}from"../commands/run.js";import{videoCommand as l}from"../commands/video.js";import{uploadCommand as u}from"../commands/upload.js";import{ciSetupCommand as f}from"../commands/ci-setup.js";import{setupPlaywrightMcpCommand as w,setupCiCommand as y,testWithVideoCommand as g}from"../commands/setup-scripts.js";import{readFileSync as h}from"fs";import{fileURLToPath as k}from"url";import{dirname as b,join as C}from"path";const v=k(import.meta.url),I=b(v),r=JSON.parse(h(C(I,"../package.json"),"utf-8")),s=`zibby v${r.version}`,i=process.argv.slice(2),P=i.includes("-h")||i.includes("--help"),S=i.includes("-v")||i.includes("-V")||i.includes("--version");S&&(console.log(s),process.exit(0)),console.log(`${s}
|
|
3
|
+
`);const _=i[0]==="chat",j=["--verbose","--agent","--stream","-s"],D=i.length>0&&i.every(o=>j.includes(o)||i[i.indexOf(o)-1]==="--agent"),x=i.length===0||_||D;if(x&&!P){const o={},t=i.indexOf("--agent");t!==-1&&i[t+1]&&(o.agent=i[t+1]),i.includes("--verbose")&&(o.verbose=!0),(i.includes("--stream")||i.includes("-s"))&&(o.stream=!0);const{chatCommand:n}=await import("../commands/chat.js");await n(o),process.exit(0)}const e=new d;e.name("zibby").description("Zibby Test Automation - AI-powered test generation").version(r.version,"-V, --version"),e.command("init").description("Initialize a new Zibby test project (like rails new)").argument("[project-name]","Project name (optional, uses current directory if not provided)").option("--agent <type>","Agent to use (claude, cursor, codex, gemini)").option("--memory-backend <backend>","Memory backend to configure (dolt, mem0)","dolt").option("--skip-install","Skip npm install").option("--skip-memory","Skip test memory setup during initialization").option("-f, --force","Force reinitialize (overwrite existing config)").option("--headed","Run MCP browser in headed mode (visible browser)").option("--headless","Run MCP browser in headless mode (hidden browser)").option("--api-key <key>","Zibby API key for cloud sync").option("--cloud-sync","Enable cloud sync and install Zibby MCP").action(p),e.command("test").description("Run a test specification").argument("[spec-path]","Path to test spec file or inline test description in quotes").option("--sources <ids>","Comma-separated test case IDs to fetch from cloud").option("--execution <id>","Execution ID containing the test cases (required with --sources)").option("--agent <type>","Agent to use (claude, cursor, codex, gemini) - overrides config").option("--workflow <name>","Workflow to use (e.g., QuickSmokeWorkflow, quick-smoke)").option("--headless","Run browser in headless mode").option("--node <name>","Run only a specific node (e.g., execute_live, generate_script)").option("--session <id>",'Use existing session (e.g., 1768974629717 or "last") - requires --node').option("--session-path <dir>","Use this session folder (absolute or relative to cwd); Studio pins artifacts here").option("--project <id>","Project ID (optional, auto-detected from ZIBBY_API_KEY)").option("--collection <id-or-name>","Collection ID or name (creates new if name doesn't exist)").option("--folder <path>","Folder path within collection (optional, requires --collection)").option("--sync","Force upload to cloud (overrides cloudSync: false)").option("--no-sync","Skip upload to cloud (overrides cloudSync: true)").option("--config <path>","Path to config file",".zibby.config.mjs").option("--auto-approve","Auto-approve MCP tools (for CI/CD)").option("-o, --open","Open test results in browser after completion").option("--verbose","Show info level logs").option("--debug","Show debug level logs (most verbose)").option("-m, --mem","Enable test memory (Dolt-backed knowledge from previous runs)").action((o,t)=>(t.debug?process.env.ZIBBY_DEBUG="true":t.verbose&&(process.env.ZIBBY_VERBOSE="true"),m(o,t))),e.command("implement").description("Implement a Jira ticket using AI agent (runs in ECS container)").action(async(...o)=>{const{implementCommand:t}=await import("../commands/implement.js");return t(...o)}),e.command("analyze").description("Analyze a Jira ticket against the codebase (runs in ECS container)").option("--workflow <path>","Path to a local workflow JSON file (e.g., .zibby/workflow-analysis.json)").action(async(...o)=>{const{analyzeCommand:t}=await import("../commands/analyze-graph.js");return t(...o)}),e.command("video").description("Organize test videos next to test files").action(l),e.command("upload <spec-path>").description("Upload existing test artifacts to Zibby Cloud").option("--project <id>","Project ID (REQUIRED - use flag or ZIBBY_PROJECT_ID env)").option("--collection <id-or-name>","Collection ID or name (creates new if name doesn't exist)").option("--folder <path>","Folder path within collection (optional)").option("--agent <type>","Agent used (for metadata)").action(u),e.command("login").description("Log in to Zibby (opens browser for authentication)").action(async()=>{const{loginCli:o}=await import("../auth/cli-login.js");await o(),process.exit(0)}),e.command("logout").description("Log out from Zibby (clears saved session)").action(async()=>{const{logoutCli:o}=await import("../auth/cli-login.js");o(),process.exit(0)}),e.command("status").description("Show current authentication status and token details").option("--json","Output in JSON format (for scripts)").action(async o=>{const{showLoginStatus:t}=await import("../auth/cli-login.js");await t(o),process.exit(0)}),e.command("list").description("List your projects and API tokens").action(async()=>{const{listProjectsCommand:o}=await import("../commands/list-projects.js");await o()}),e.command("ci-setup").description("Setup Cursor Agent for CI/CD (patch and configure)").option("--get-keys","Get MCP approval keys").option("--save","Save approval keys to project").action(f),e.command("setup-playwright").description("Setup official Playwright MCP (from cursor-agent-package)").option("--headed","Configure MCP in headed mode (visible browser)").option("--viewport-width <width>","Viewport width (default: 1280)","1280").option("--viewport-height <height>","Viewport height (default: 720)","720").action(o=>{const t={width:parseInt(o.viewportWidth,10)||1280,height:parseInt(o.viewportHeight,10)||720};return w({...o,viewport:t})}),e.command("setup-ci-full").description("Complete CI/CD setup from scratch").action(y),e.command("test-video").description("Run Playwright tests with video recording").argument("[test-file]","Test file to run (default: tests/)").option("--headed","Run in headed mode (visible browser)").action(g),e.command("generate").description("Generate test specs from a ticket + codebase (local analysis using real AI agent)").option("-t, --ticket <key>","Jira ticket key (fetches automatically)").option("-i, --input <file>","Input file with ticket description/requirements").option("-d, --description <text>","Inline ticket description").option("--repo <path>","Path to the codebase (default: current directory)").option("--agent <type>","Agent to use (codex, claude, cursor, gemini)").option("--model <model>","Model override").option("-o, --output <dir>","Output directory for spec files (default: test-specs)").action(async o=>{const{generateCommand:t}=await import("../commands/generate.js");return t(o)}),e.command("studio").description("Launch Zibby Studio desktop (installs from CDN if needed). Uses this folder as the Zibby project.").option("-p, --port <port>","Port for the Studio API bridge (default: 3847)").option("--no-open","Start the API only; do not launch desktop app").option("--update","Force re-download of the latest Studio binary").action(async o=>{const{studioCommand:t}=await import("../commands/studio.js");return t(o)});const E=e.command("g").description("Generate scaffolds");E.command("workflow [name]").description("Scaffold a new custom workflow in .zibby/workflows/<name>/ (auto-generates name if omitted)").action(async o=>{const{generateWorkflowCommand:t}=await import("../commands/workflows/generate.js");return t(o)}),e.command("start <workflow-name>").description("Start a local dev server for a custom workflow").option("-p, --port <port>","Port for the workflow server (default: 3848)").action(async(o,t)=>{const{startWorkflowCommand:n}=await import("../commands/workflows/start.js");return n(o,t)}),e.command("deploy <workflow-name>").description("Deploy a custom workflow to Zibby Cloud").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(o,t)=>{const{deployWorkflowCommand:n}=await import("../commands/workflows/deploy.js");return n(o,t)}),e.command("logs [jobId]").description("Tail logs from a workflow job (use --workflow to auto-pick latest)").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--workflow <name>","Workflow name (tails the latest run)").option("--all","Show interleaved logs from all runs (requires --workflow)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--no-follow","Fetch logs once and exit (default: tail)").option("--lines <n>","Max log lines per fetch (default: 200)").action(async(o,t)=>{const{logsCommand:n}=await import("../commands/workflows/logs.js");return n(o,t)}),e.command("run-workflow").description("Run a deployed workflow from S3 sources (used by ECS containers)").action(async()=>{const{runWorkflowCommand:o}=await import("../commands/workflows/run.js");return o()});const a=e.command("memory").description("Test memory database \u2014 version-controlled knowledge from runs");a.command("stats").description("Show memory database statistics").action(async()=>{const{memoryStatsCommand:o}=await import("../commands/memory.js");return o()}),a.command("init").description("Initialize the memory database (Dolt)").action(async()=>{const{memoryInitCommand:o}=await import("../commands/memory.js");return o()}),a.command("compact").description("Prune old data and run Dolt GC to reclaim storage").option("--max-runs <n>","Keep last N runs per spec (default: 50)",parseInt).option("--max-age <days>","Remove data older than N days (default: 90)",parseInt).action(async o=>{const{memoryCompactCommand:t}=await import("../commands/memory.js");return t(o)}),a.command("reset").description("Wipe the memory database").option("-f, --force","Confirm reset").action(async o=>{const{memoryResetCommand:t}=await import("../commands/memory.js");return t(o)});const c=e.command("workflow").description("Manage workflow graphs (download, upload, list)");c.command("download").description("Download a workflow graph from Zibby Cloud to .zibby/").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--type <type>","Workflow type: analysis, implementation, run_test").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--output <dir>","Output directory (default: .zibby/)").option("--include-default","Download the built-in default graph if no custom one exists").action(async o=>{const{workflowDownloadCommand:t}=await import("../commands/workflow.js");return t(o)}),c.command("list").description("List all workflows for a project").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async o=>{const{workflowListCommand:t}=await import("../commands/workflow.js");return t(o)});const B=e.command("run-queue").description("Parallel capacity \u2014 on-disk wait queue (see parallel.waitWhenAtCapacity in .zibby.config.mjs)");B.command("list").description("List CLI processes waiting for a run slot").option("--config <path>","Path to config file",".zibby.config.mjs").action(async o=>{const{runCapacityQueueListCommand:t}=await import("../commands/run-capacity-queue-cli.js");await t(o),process.exit(0)}),e.parse();
|
package/dist/commands/chat.js
CHANGED
|
@@ -3,7 +3,7 @@ import{invokeAgent as _e,getAgentStrategy as ve,getSkill as kt}from"@zibby/core"
|
|
|
3
3
|
|
|
4
4
|
${Ve(t)}`),r+=`
|
|
5
5
|
H: ${s}
|
|
6
|
-
AI:`,r}function Xe(o){const t=o.filter(s=>!process.env[s]);return{ok:t.length===0,missing:t}}function Qe(o){const t=mt(o,".zibby.config.mjs");if(!$t(t))return{};try{return import(t).then(s=>s.default||{})}catch{return{}}}async function ts(o){const t=mt(o,".zibby","chat.mjs");if($t(t)){const s=await import(t);return s.CHAT_CONFIG||s.default||{}}try{const s=await import("@zibby/core/templates/browser-test-automation/chat.mjs");return s.CHAT_CONFIG||s.default||{}}catch{return{systemPrompt:"You are Zibby, a friendly AI assistant for test automation.",skills:[]}}}function ue(o){try{const t=mt(o,".zibby","commands");return $t(t)?Te(t).filter(s=>s.toLowerCase().endsWith(".md")).sort((s,r)=>s.localeCompare(r)):[]}catch{return[]}}function es(o,t){const s=String(t||"").trim();if(!s.startsWith("/"))return s;const[r,...h]=s.split(/\s+/),k=h.join(" ").trim(),v=r.slice(1);if(!v)return s;const C=v.toLowerCase().endsWith(".md")?[v]:[v,`${v}.md`],I=mt(o,".zibby","commands"),U=C.find(R=>$t(Dt(I,R)));if(!U)return s;try{const R=oe(Dt(I,U),"utf-8").trim();return k?`${R}
|
|
6
|
+
AI:`,r}function Xe(o){const t=o.filter(s=>!process.env[s]);return{ok:t.length===0,missing:t}}function Qe(o){const t=mt(o,".zibby.config.mjs");if(!$t(t))return{};try{return import(t).then(s=>s.default||{})}catch{return{}}}async function ts(o){const t=mt(o,".zibby","chat.mjs");if($t(t))try{const s=await import(t);return s.CHAT_CONFIG||s.default||{}}catch(s){console.warn(`\u26A0\uFE0F Could not load ${t}: ${s.message}`),console.warn(' Falling back to built-in chat config. Run "zibby init -f" to regenerate.')}try{const s=await import("@zibby/core/templates/browser-test-automation/chat.mjs");return s.CHAT_CONFIG||s.default||{}}catch{return{systemPrompt:"You are Zibby, a friendly AI assistant for test automation.",skills:[]}}}function ue(o){try{const t=mt(o,".zibby","commands");return $t(t)?Te(t).filter(s=>s.toLowerCase().endsWith(".md")).sort((s,r)=>s.localeCompare(r)):[]}catch{return[]}}function es(o,t){const s=String(t||"").trim();if(!s.startsWith("/"))return s;const[r,...h]=s.split(/\s+/),k=h.join(" ").trim(),v=r.slice(1);if(!v)return s;const C=v.toLowerCase().endsWith(".md")?[v]:[v,`${v}.md`],I=mt(o,".zibby","commands"),U=C.find(R=>$t(Dt(I,R)));if(!U)return s;try{const R=oe(Dt(I,U),"utf-8").trim();return k?`${R}
|
|
7
7
|
|
|
8
8
|
${k}`:R}catch{return s}}function ss(o){const t=o.slice(-ie),s=[];let r=0;for(let h=t.length-1;h>=0;h--){const k=t[h],v=String(k?.content||""),C=k?.role==="human"?"user":"assistant",I=v.length;if(s.length>=6&&r+I>Ge)break;s.push({role:C,content:v}),r+=I}return s.reverse()}function xt(o,t){const s=String(o||"");return s.length<=t?s:`${s.slice(0,Math.max(0,t-24))}
|
|
9
9
|
|
package/dist/commands/init.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import{mkdir as
|
|
1
|
+
import{mkdir as E,writeFile as g,readFile as w}from"fs/promises";import{existsSync as f,readdirSync as Z}from"fs";import{join as i,resolve as L,dirname as N}from"path";import{homedir as C}from"os";import D from"inquirer";import e from"chalk";import v from"ora";import{spawn as S,execSync as Y}from"child_process";import{fileURLToPath as G}from"url";import{createRequire as O}from"module";const H=G(import.meta.url),F=N(H),j=O(import.meta.url);async function W(){try{const d=process.platform==="win32",n=Y("npm config get prefix",{encoding:"utf-8"}).trim(),y=d?n:`${n}/bin`,m=y.replace(/^~/,C()),a=d?";":":";if(process.env.PATH.split(a).some(I=>{const z=I.replace(/^~/,C());return z===m||z===y}))return;console.log(e.yellow("\u26A0\uFE0F npm global bin not in PATH")),console.log(e.gray(` Location: ${m}`)),console.log();const{shouldAddPath:s}=await D.prompt([{type:"confirm",name:"shouldAddPath",message:"Add npm global bin to your shell PATH automatically?",default:!0}]);if(!s){d?(console.log(e.gray(`
|
|
2
2
|
\u{1F4A1} To add manually on Windows:`)),console.log(e.gray(' 1. Search "Environment Variables" in Start menu')),console.log(e.gray(' 2. Edit "Path" in User variables')),console.log(e.gray(` 3. Add: ${m}
|
|
3
3
|
`))):(console.log(e.gray(`
|
|
4
4
|
\u{1F4A1} To add manually, run:`)),console.log(e.gray(` echo 'export PATH="${m}:$PATH"' >> ~/.zshrc`)),console.log(e.gray(` source ~/.zshrc
|
|
5
5
|
`)));return}if(d){console.log(e.yellow("\u26A0\uFE0F Cannot auto-add PATH on Windows")),console.log(e.gray(" Please add manually:")),console.log(e.gray(' 1. Search "Environment Variables" in Start menu')),console.log(e.gray(' 2. Edit "Path" in User variables')),console.log(e.gray(` 3. Add: ${m}
|
|
6
|
-
`));return}const
|
|
6
|
+
`));return}const x=process.env.SHELL||"";let p="";if(x.includes("zsh"))p=i(C(),".zshrc");else if(x.includes("bash"))p=f(i(C(),".bashrc"))?i(C(),".bashrc"):i(C(),".bash_profile");else{console.log(e.yellow(`\u26A0\uFE0F Unknown shell: ${x}`)),console.log(e.gray(" Please add manually:")),console.log(e.gray(` export PATH="${m}:$PATH"`));return}if(f(p)){const I=await w(p,"utf-8");if(I.includes(m)||I.includes("npm")&&I.includes("global")&&I.includes("bin")){console.log(e.yellow(`\u26A0\uFE0F PATH entry found in ${p} but not active`)),console.log(e.gray(` Run: source ${p}
|
|
7
7
|
`));return}}const b=`
|
|
8
8
|
# npm global bin (added by zibby)
|
|
9
9
|
export PATH="${m}:$PATH"
|
|
10
|
-
`;await
|
|
10
|
+
`;await g(p,(f(p)?await w(p,"utf-8"):"")+b),console.log(e.green(`\u2705 Added to ${p}`)),console.log(e.yellow(`
|
|
11
11
|
\u{1F4A1} Run this to activate in current session:`)),console.log(e.gray(` source ${p}
|
|
12
12
|
`))}catch{}}async function ue(d,n){console.log(e.bold.cyan(`
|
|
13
13
|
\u{1F3AD} Welcome to Zibby Test Automation!
|
|
14
|
-
`));const
|
|
14
|
+
`));const y=!n.skipMemory,m=["dolt","mem0"].includes(String(n.memoryBackend||"").toLowerCase())?String(n.memoryBackend).toLowerCase():"dolt";await W();const a=d?L(process.cwd(),d):process.cwd(),_=d||"zibby-tests",h=!!d;h&&f(a)&&(console.log(e.red(`
|
|
15
15
|
\u274C Directory "${d}" already exists!
|
|
16
16
|
`)),process.exit(1)),!h&&f(i(a,".zibby.config.mjs"))&&!n.force&&(console.log(e.yellow(`
|
|
17
17
|
\u26A0\uFE0F Zibby is already initialized in this directory!
|
|
@@ -19,23 +19,23 @@ export PATH="${m}:$PATH"
|
|
|
19
19
|
`)),process.exit(0)),n.force&&!h&&console.log(e.cyan(`
|
|
20
20
|
Reinitializing Zibby configuration...
|
|
21
21
|
`));let s;if(n.agent&&(n.headed||n.headless))console.log(e.cyan(`Setting up with provided options...
|
|
22
|
-
`)),s={agent:n.agent,browserMode:n.headless?"headless":"headed",apiKey:n.apiKey||null,cloudSync:!!(n.cloudSync||n.apiKey)};else{const b=[];n.agent||b.push({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"}),!n.headed&&!n.headless&&b.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"}),n.apiKey||b.push({type:"input",name:"apiKey",message:"Enable cloud sync? Enter project ZIBBY_API_KEY (or press Enter to skip):"}),s=b.length>0?await D.prompt(b):{},s.agent=n.agent||s.agent,s.browserMode=n.headless?"headless":n.headed?"headed":s.browserMode,s.apiKey=n.apiKey||s.apiKey,s.cloudSync=!!(n.cloudSync||n.apiKey||s.apiKey&&s.apiKey.trim())}s.mcp="playwright",s.setupMcp=s.agent==="cursor";const p=
|
|
22
|
+
`)),s={agent:n.agent,browserMode:n.headless?"headless":"headed",apiKey:n.apiKey||null,cloudSync:!!(n.cloudSync||n.apiKey)};else{const b=[];n.agent||b.push({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"}),!n.headed&&!n.headless&&b.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"}),n.apiKey||b.push({type:"input",name:"apiKey",message:"Enable cloud sync? Enter project ZIBBY_API_KEY (or press Enter to skip):"}),s=b.length>0?await D.prompt(b):{},s.agent=n.agent||s.agent,s.browserMode=n.headless?"headless":n.headed?"headed":s.browserMode,s.apiKey=n.apiKey||s.apiKey,s.cloudSync=!!(n.cloudSync||n.apiKey||s.apiKey&&s.apiKey.trim())}s.mcp="playwright",s.setupMcp=s.agent==="cursor";const p=v("Setting up Zibby...").start();try{if(h&&await E(a,{recursive:!0}),await E(i(a,"test-specs/examples"),{recursive:!0}),await E(i(a,"tests"),{recursive:!0}),await E(i(a,".zibby/output"),{recursive:!0}),await E(i(a,".zibby/commands"),{recursive:!0}),y&&m==="dolt")try{const{initMemory:t,DoltDB:r}=await import("@zibby/memory");if(r.isAvailable()){const{created:o}=t(a);o&&(p.text="Initialized test memory database (Dolt)...")}else p.text="Dolt not found \u2014 skipping memory database (brew install dolt)"}catch{}p.text="Scaffolding workflow graph...";const{TemplateFactory:b}=await import("@zibby/core/templates"),I=n.template||"browser-test-automation";try{const{graphPath:t,nodesPath:r,readmePath:o,resultHandlerPath:c,template:l}=b.getTemplateFiles(I),u=i(a,".zibby"),k=await w(t,"utf-8");if(await g(i(u,"graph.mjs"),k),c){const A=await w(c,"utf-8");await g(i(u,"result-handler.mjs"),A)}const B=await w(o,"utf-8");await g(i(u,"README.md"),B),await E(i(u,"nodes"),{recursive:!0});const{readdirSync:P}=await import("fs"),$=P(r);for(const A of $){let K=await w(i(r,A),"utf-8");!y&&A==="execute-live.mjs"&&(K=K.replace("skills: [SKILLS.BROWSER, SKILLS.MEMORY],","skills: [SKILLS.BROWSER],")),await g(i(u,"nodes",A),K)}const T=i(l.path,"chat.mjs");if(f(T)){const A=await w(T,"utf-8");await g(i(u,"chat.mjs"),A)}}catch(t){throw p.fail(`Failed to scaffold template: ${t.message}`),t}p.text="Generating configuration files...";const z=U(s,n,{memoryBackend:m});if(await g(i(a,".zibby.config.mjs"),z),await g(i(a,".env.example"),V(s,m)),s.apiKey&&s.apiKey.trim()){const t=i(a,".env"),r=s.apiKey.trim();if(f(t)){let o=await w(t,"utf8");/^ZIBBY_API_KEY=/m.test(o)?o=o.replace(/^ZIBBY_API_KEY=.*/m,`ZIBBY_API_KEY=${r}`):/^#\s*ZIBBY_API_KEY=/m.test(o)?o=o.replace(/^#\s*ZIBBY_API_KEY=.*/m,`ZIBBY_API_KEY=${r}`):o=`${o.trimEnd()}
|
|
23
23
|
|
|
24
24
|
# Zibby Cloud Sync
|
|
25
25
|
ZIBBY_API_KEY=${r}
|
|
26
|
-
`,await
|
|
26
|
+
`,await g(t,o)}else await g(t,q(s,r,m))}if(h){const t=X(_,s,{memoryBackend:m});await g(i(a,"package.json"),t)}if(!f(i(a,".gitignore"))){const t=J();await g(i(a,".gitignore"),t)}if(!f(i(a,"playwright.config.js"))){const t=Q("on");await g(i(a,"playwright.config.js"),t)}if(!f(i(a,"test-specs/examples/example-domain.txt"))){const t=ee();await g(i(a,"test-specs/examples/example-domain.txt"),t)}const R=L(F,"../../../../examples/.zibby/commands");if(f(R)){const t=Z(R).filter(r=>r.toLowerCase().endsWith(".md"));for(const r of t){const o=i(a,".zibby/commands",r);if(n.force||!f(o)){const c=await w(i(R,r),"utf-8");await g(o,c)}}}if(!f(i(a,".zibby/commands/example.md"))){const t=te();await g(i(a,".zibby/commands/example.md"),t)}if(h){const t=ne(_,s);await g(i(a,"README.md"),t)}if(p.succeed(h?"Project created!":"Zibby initialized!"),h&&!n.skipInstall){const t=v("Installing dependencies...").start();await new Promise((r,o)=>{S("npm",["install"],{cwd:a,stdio:"pipe"}).on("close",l=>{l===0?(t.succeed("Dependencies installed!"),r()):(t.fail("Failed to install dependencies"),o(new Error("npm install failed")))})})}else if(!h){const t=["@zibby/cli","@zibby/core"],r=[];for(const o of t)try{O(i(a,"package.json")).resolve(`${o}/package.json`)}catch{r.push(o)}if(r.length>0){const o=j("../../package.json"),c=r.map(l=>l==="@zibby/cli"?`${l}@latest`:l==="@zibby/core"?`${l}@${o.dependencies?.["@zibby/core"]||"^0.1.29"}`:l);if(n.skipInstall)console.log(e.yellow(`
|
|
27
27
|
Missing required Zibby dependencies in this project:`)),console.log(e.white(` ${r.join(", ")}`)),console.log(e.gray("Install them manually to avoid runtime errors:")),console.log(e.white(` npm install --save-dev ${c.join(" ")}
|
|
28
|
-
`));else{const l=
|
|
29
|
-
`)))}}}if(!h&&
|
|
28
|
+
`));else{const l=v(`Installing ${c.join(", ")}...`).start();await new Promise(k=>{S("npm",["install","--save-dev",...c],{cwd:a,stdio:"pipe"}).on("close",P=>k(P??1))})===0?l.succeed("Installed missing Zibby dependencies"):(l.warn("Could not auto-install Zibby dependencies"),console.log(e.gray("Run this manually:")),console.log(e.white(` npm install --save-dev ${c.join(" ")}
|
|
29
|
+
`)))}}}if(!h&&y&&m==="mem0"&&(console.log(e.yellow(`
|
|
30
30
|
Using mem0 backend requires mem0ai in your project dependencies.`)),console.log(e.gray("Run this manually in your project when ready:")),console.log(e.white(` npm install mem0ai
|
|
31
|
-
`))),!n.skipInstall){const t=
|
|
31
|
+
`))),!n.skipInstall){const t=v("Installing Playwright browsers...").start();await new Promise(r=>{const o=S("npx",["playwright","install","chromium"],{cwd:a,stdio:"pipe"});let c="";o.stdout.on("data",l=>{c+=l.toString()}),o.stderr.on("data",l=>{c+=l.toString()}),o.on("close",l=>{l===0?(c.includes("already installed")||c.includes("up to date")?t.succeed("Playwright browsers already installed"):t.succeed("Playwright browsers installed!"),r()):(t.warn("Could not verify Playwright browsers"),console.log(e.yellow(`
|
|
32
32
|
\u26A0\uFE0F If tests fail, run: npx playwright install
|
|
33
|
-
`)),r())})})}if(s.agent==="cursor"&&!n.skipInstall){const t=
|
|
34
|
-
`))}}}if(s.agent==="codex"&&!n.skipInstall){const t=
|
|
35
|
-
`))}}}if(s.agent==="gemini"&&!n.skipInstall){const t=
|
|
36
|
-
`))}}const r=
|
|
37
|
-
`,"utf-8");let
|
|
38
|
-
`))}}if(s.agent==="cursor"&&s.setupMcp){const t=
|
|
33
|
+
`)),r())})})}if(s.agent==="cursor"&&!n.skipInstall){const t=v("Checking cursor-agent CLI...").start();try{Y("cursor-agent --version",{encoding:"utf-8",timeout:5e3,stdio:"pipe"}),t.succeed("cursor-agent CLI already installed")}catch{t.text="Installing cursor-agent CLI...";try{await new Promise((r,o)=>{S("bash",["-c","curl https://cursor.com/install -fsS | bash"],{stdio:"pipe"}).on("close",l=>{if(l===0){const u=i(C(),".local","bin");process.env.PATH.includes(u)||(process.env.PATH=`${u}:${process.env.PATH}`),t.succeed("cursor-agent CLI installed!"),r()}else o(new Error("cursor-agent install failed"))})})}catch{t.fail("Could not install cursor-agent CLI"),console.log(e.yellow(` Install manually: curl https://cursor.com/install -fsS | bash
|
|
34
|
+
`))}}}if(s.agent==="codex"&&!n.skipInstall){const t=v("Checking Codex CLI...").start();try{Y("codex --version",{encoding:"utf-8",timeout:5e3,stdio:"pipe"}),t.succeed("Codex CLI already installed")}catch{t.text="Installing Codex CLI...";try{await new Promise((r,o)=>{S("npm",["install","-g","@openai/codex"],{stdio:"pipe"}).on("close",l=>{l===0?(t.succeed("Codex CLI installed!"),r()):o(new Error("npm install -g @openai/codex failed"))})})}catch{t.fail("Could not install Codex CLI"),console.log(e.yellow(` Install manually: npm install -g @openai/codex
|
|
35
|
+
`))}}}if(s.agent==="gemini"&&!n.skipInstall){const t=v("Checking Gemini CLI...").start();try{Y("gemini --version",{encoding:"utf-8",timeout:5e3,stdio:"pipe"}),t.succeed("Gemini CLI already installed")}catch{t.text="Installing Gemini CLI...";try{await new Promise((o,c)=>{S("npm",["install","-g","@google/gemini-cli"],{stdio:"pipe"}).on("close",u=>{u===0?(t.succeed("Gemini CLI installed!"),o()):c(new Error("npm install -g @google/gemini-cli failed"))})})}catch{t.fail("Could not install Gemini CLI"),console.log(e.yellow(` Install manually: npm install -g @google/gemini-cli
|
|
36
|
+
`))}}const r=v("Configuring Gemini MCP servers...").start();try{const o=i(C(),".gemini"),c=i(o,"settings.json");f(o)||await E(o,{recursive:!0});let l={mcpServers:{}};if(f(c))try{const $=await w(c,"utf-8");l=JSON.parse($),l.mcpServers||(l.mcpServers={})}catch{}let u;try{const{createRequire:$}=await import("module");u=$(import.meta.url).resolve("@zibby/mcp-browser/bin/mcp-browser-zibby.js")}catch{u="@playwright/mcp"}const k=s.browserMode!=="headless",B=u==="@playwright/mcp"?["-y","@playwright/mcp","--isolated","--save-video=1280x720","--viewport-size=1280x720","--output-dir","test-results"]:[u,"--isolated","--save-video=1280x720","--viewport-size=1280x720","--output-dir=test-results"];k||B.push("--headless"),l.mcpServers["playwright-official"]={command:u==="@playwright/mcp"?"npx":"node",args:B},await g(c,`${JSON.stringify(l,null,2)}
|
|
37
|
+
`,"utf-8");let P="Gemini MCP configured";k?P+=" (headed mode - visible browser)":P+=" (headless mode - hidden browser)",r.succeed(P)}catch(o){r.fail("MCP setup failed"),console.log(e.yellow(" You may need to configure ~/.gemini/settings.json manually")),console.log(e.gray(` Error: ${o.message}
|
|
38
|
+
`))}}if(s.agent==="cursor"&&s.setupMcp){const t=v("Setting up Playwright MCP...").start();try{const{setupPlaywrightMcpCommand:r}=await import("./setup-scripts.js"),o=s.cloudSync||!1,c=s.browserMode!=="headless";await r({headed:c,cloudSync:o,video:"on",viewport:{width:1280,height:720}});let l="Playwright MCP configured";c?l+=" (headed mode - visible browser)":l+=" (headless mode - hidden browser)",o&&(l+=" + Zibby MCP (cloud sync)"),t.succeed(l),o&&!(s.apiKey&&s.apiKey.trim())&&console.log(e.gray(`
|
|
39
39
|
Copy .env.example to .env and set ZIBBY_API_KEY to enable uploads
|
|
40
40
|
`))}catch(r){t.fail("MCP setup script failed"),console.log(e.yellow(" Check if MCP is already configured:")),console.log(e.gray(' \u2022 Open Cursor settings \u2192 Check "playwright-official" MCP')),console.log(e.gray(" \u2022 Run: cursor-agent mcp list")),console.log(e.gray(` \u2022 Or run manually: zibby setup-playwright
|
|
41
41
|
`)),console.log(e.gray(` Error: ${r.message}
|
|
@@ -43,10 +43,10 @@ Using mem0 backend requires mem0ai in your project dependencies.`)),console.log(
|
|
|
43
43
|
\u{1F389} All set!
|
|
44
44
|
`)),console.log(e.cyan("Start the Zibby Chat Agent:")),h&&console.log(e.white(` cd ${d}`)),console.log(e.white(` zibby
|
|
45
45
|
`)),console.log(e.cyan("Or run a test directly:")),console.log(e.white(` zibby run test-specs/examples/example-domain.txt
|
|
46
|
-
`)),console.log(e.cyan("Next steps:"));let M=1;console.log(e.white(` ${M++}. cp .env.example .env ${e.gray("# then add your API keys")}`)),
|
|
46
|
+
`)),console.log(e.cyan("Next steps:"));let M=1;console.log(e.white(` ${M++}. cp .env.example .env ${e.gray("# then add your API keys")}`)),y&&console.log(e.white(` ${M++}. Set ${e.bold("ZIBBY_MEMORY_BACKEND")} in .env ${e.gray(`# currently: ${m}`)}`)),console.log(e.white(` ${M++}. Type ${e.bold("zibby")} to chat with the AI testing assistant`)),console.log(e.white(` ${M++}. Write test specs in test-specs/`)),console.log(e.white(` ${M++}. Run: npx zibby run <spec-file>
|
|
47
47
|
`))}catch(b){p.fail("Failed to create project"),console.error(e.red(`
|
|
48
48
|
\u274C Error: ${b.message}
|
|
49
|
-
`)),process.exit(1)}}function U(d,n={},
|
|
49
|
+
`)),process.exit(1)}}function U(d,n={},y={}){const m=["dolt","mem0"].includes(String(y.memoryBackend||"").toLowerCase())?String(y.memoryBackend).toLowerCase():"dolt",a={claude:`
|
|
50
50
|
claude: {
|
|
51
51
|
model: 'auto', // Options: 'auto', 'sonnet-4.6', 'opus-4.6', 'sonnet-4.5', 'opus-4.5'
|
|
52
52
|
maxTokens: 4096,
|
|
@@ -60,7 +60,7 @@ Using mem0 backend requires mem0ai in your project dependencies.`)),console.log(
|
|
|
60
60
|
gemini: {
|
|
61
61
|
model: 'gemini-2.5-pro', // Options: 'auto', 'gemini-2.5-pro', 'gemini-2.5-flash'
|
|
62
62
|
},`},_=d.agent,h=Object.entries(a).filter(([s])=>s!==_).map(([,s])=>s.split(`
|
|
63
|
-
`).map(
|
|
63
|
+
`).map(x=>x.trim()?` // ${x.trimStart()}`:x).join(`
|
|
64
64
|
`)).join(`
|
|
65
65
|
`);return`export default {
|
|
66
66
|
// AI agent settings
|
|
@@ -145,7 +145,7 @@ ${{claude:"ANTHROPIC_API_KEY=sk-ant-your_key_here",cursor:`# Cursor Agent uses c
|
|
|
145
145
|
|
|
146
146
|
# Chat memory backend
|
|
147
147
|
ZIBBY_MEMORY_BACKEND=${n}
|
|
148
|
-
`}function q(d,n,
|
|
148
|
+
`}function q(d,n,y="dolt"){return`# Zibby Test Automation - Environment Variables
|
|
149
149
|
|
|
150
150
|
# AI Provider Keys
|
|
151
151
|
${{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"}[d.agent]||""}
|
|
@@ -159,8 +159,8 @@ ZIBBY_API_KEY=${n}
|
|
|
159
159
|
# ZIBBY_MEMORY_COMPACT_EVERY=1500 # Auto-compact every N runs (0 to disable)
|
|
160
160
|
|
|
161
161
|
# Chat memory backend
|
|
162
|
-
ZIBBY_MEMORY_BACKEND=${
|
|
163
|
-
`}function X(d,n,
|
|
162
|
+
ZIBBY_MEMORY_BACKEND=${y}
|
|
163
|
+
`}function X(d,n,y={}){const a={"@zibby/cli":"latest","@zibby/core":j("../../package.json").dependencies?.["@zibby/core"]||"^0.1.29"};return y.memoryBackend==="mem0"&&(a.mem0ai="^2.4.6"),JSON.stringify({name:d,version:"1.0.0",type:"module",private:!0,scripts:{"test:spec":"zibby run",test:"playwright test","test:headed":"playwright test --headed"},dependencies:a,devDependencies:{"@playwright/test":"^1.49.0",dotenv:"^17.2.3"}},null,2)}function J(){return`# Dependencies
|
|
164
164
|
node_modules/
|
|
165
165
|
|
|
166
166
|
# Test artifacts
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import{spawn as
|
|
2
|
-
`,"utf-8")}async function
|
|
1
|
+
import{spawn as y,execSync as w}from"child_process";import{join as l,dirname as v,resolve as P}from"path";import{readFileSync as C,writeFileSync as S,existsSync as u,mkdirSync as x}from"fs";import{homedir as j}from"os";import{createRequire as A}from"module";import c from"chalk";const b=A(import.meta.url);function B(){try{return v(b.resolve("@zibby/core/package.json"))}catch{return null}}function $(e){try{return w(`command -v ${e}`,{stdio:"pipe"}),!0}catch{return!1}}function E(){try{const e=b.resolve("@zibby/mcp-browser/bin/mcp-browser-zibby.js");if(u(e))return e}catch{}try{const e=b.resolve("@playwright/mcp/package.json"),r=v(e),o=JSON.parse(C(e,"utf-8")),n=typeof o.bin=="string"?o.bin:o.bin?.["playwright-mcp"];if(n){const s=l(r,n);if(u(s))return s}const t=l(r,"cli.js");if(u(t))return t}catch{}return null}function k(e,r,o={}){return new Promise((n,t)=>{const s=y(e,r,{stdio:"inherit",...o});s.on("close",p=>n(p??1)),s.on("error",t)})}async function N(e){return $("playwright")?await k("playwright",["install","ffmpeg"],{cwd:e})===0:await k("npx",["--yes","playwright","install","ffmpeg"],{cwd:e})===0}function O({headed:e=!1,video:r="on",viewport:o=null}){const n=process.execPath,t=v(n),s=E(),p=Number(o?.width)||1280,d=Number(o?.height)||720,f=`${p}x${d}`,i=[];r!=="off"&&i.push(`--save-video=${f}`),i.push(`--viewport-size=${f}`,"--output-dir=test-results"),e||i.push("--headless");let g;s?g={command:n,args:[s,...i],env:{PATH:`${t}:/usr/bin:/bin:/usr/sbin:/sbin`}}:g={command:"npx",args:["-y","@playwright/mcp",...i],env:{PATH:`${t}:/usr/bin:/bin:/usr/sbin:/sbin`}},g.description="Zibby MCP Browser - Playwright MCP with Zibby defaults";const h=l(j(),".cursor"),m=l(h,"mcp.json");u(h)||x(h,{recursive:!0});let a={mcpServers:{}};if(u(m))try{a=JSON.parse(C(m,"utf-8")),(!a.mcpServers||typeof a.mcpServers!="object")&&(a.mcpServers={})}catch{a={mcpServers:{}}}a.mcpServers["playwright-official"]=g,S(m,`${JSON.stringify(a,null,2)}
|
|
2
|
+
`,"utf-8")}async function R(){const e=B();if(!e)return;const r=l(e,"scripts","patch-cursor-mcp.js");if(u(r))try{await new Promise((o,n)=>{const t=y(process.execPath,[r],{cwd:process.cwd(),stdio:"ignore"});t.on("close",s=>o(s??0)),t.on("error",n)})}catch{}}function z(e){return P(e).replace(/^\/+/,"").replace(/\//g,"-")}function J(e){const r=String(e||""),o=r.split(`
|
|
3
|
+
`).find(s=>/playwright-official/i.test(s)&&/APPROVAL|🔑/i.test(s));if(o){const s=o.match(/=>\s*(\S+)/);if(s)return s[1]}const n=r.match(/playwright-official[^=]*=>\s*(\S+)/);if(n)return n[1];const t=r.match(/playwright-official-[a-f0-9]+/i);return t?t[0]:null}function T(e,r){const o=z(e),n=l(j(),".cursor","projects",o);x(n,{recursive:!0});const t=l(n,"mcp-approvals.json");return S(t,`${JSON.stringify([r],null,2)}
|
|
4
|
+
`,"utf-8"),t}function M(e){try{return w("cursor-agent mcp list",{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"],env:process.env,maxBuffer:2*1024*1024})}catch(r){const o=r.stdout!=null?String(r.stdout):"",n=r.stderr!=null?String(r.stderr):"";return o+n}}function D(e){try{return w("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 F(e={}){const r=!!e.headed,o=e.video||"on",n=e.viewport||{width:1280,height:720};if(!process.execPath)throw new Error("Node.js runtime not found");const t=await N(process.cwd());console.log(t?c.gray(" \u2713 ffmpeg installed for Playwright video"):c.yellow(" \u26A0 Could not install ffmpeg (video may be unavailable)")),O({headed:r,video:o,viewport:n}),await R();const s=P(process.cwd());if($("cursor-agent")){M(s);const p=D(s);p&&console.log(c.gray(" \u2713 cursor-agent: mcp enable playwright-official"));const d=M(s),f=J(d);if(f)try{const i=T(s,f);console.log(c.gray(` \u2713 MCP auto-approval key saved (${i})`))}catch(i){console.log(c.yellow(` \u26A0 Could not write mcp-approvals.json: ${i.message}`))}else p||(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 L(e){try{console.log(c.cyan(`
|
|
3
5
|
\u{1F680} Running CI setup...
|
|
4
|
-
`)),await
|
|
6
|
+
`)),await F({headed:!1,cloudSync:!0,video:"on",viewport:{width:1280,height:720}}),console.log(c.green(`
|
|
5
7
|
\u2705 CI/CD setup complete!
|
|
6
|
-
`))}catch(r){console.log(
|
|
8
|
+
`))}catch(r){console.log(c.red(`
|
|
7
9
|
\u274C Error: ${r.message}
|
|
8
|
-
`)),process.exit(1)}}async function
|
|
10
|
+
`)),process.exit(1)}}async function Z(e,r){try{const o=["playwright","test",e||"tests/","--project=chromium"];r.headed&&o.push("--headed"),console.log(c.cyan(`
|
|
9
11
|
\u{1F3A5} Running tests with video recording...
|
|
10
|
-
`)),console.log(
|
|
12
|
+
`)),console.log(c.gray("\u2501".repeat(50)));const n=y("npx",o,{cwd:process.cwd(),stdio:"inherit"});n.on("close",t=>{t===0?console.log(c.green(`
|
|
11
13
|
\u2705 Tests complete!
|
|
12
|
-
`)):(console.log(
|
|
13
|
-
\u274C Tests failed with code ${
|
|
14
|
-
`)),process.exit(
|
|
15
|
-
\u274C Error: ${
|
|
16
|
-
`)),process.exit(1)})}catch(o){console.log(
|
|
14
|
+
`)):(console.log(c.red(`
|
|
15
|
+
\u274C Tests failed with code ${t}
|
|
16
|
+
`)),process.exit(t))}),n.on("error",t=>{console.log(c.red(`
|
|
17
|
+
\u274C Error: ${t.message}
|
|
18
|
+
`)),process.exit(1)})}catch(o){console.log(c.red(`
|
|
17
19
|
\u274C Error: ${o.message}
|
|
18
|
-
`)),process.exit(1)}}export{
|
|
20
|
+
`)),process.exit(1)}}export{L as setupCiCommand,F as setupPlaywrightMcpCommand,Z as testWithVideoCommand};
|
package/dist/package.json
CHANGED