@zibby/cli 0.4.5 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/zibby.js +3 -3
- package/dist/commands/workflows/deploy.js +43 -43
- package/dist/package.json +2 -2
- package/package.json +2 -2
package/dist/bin/zibby.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
process.stdout.on("error",
|
|
3
|
-
`),
|
|
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 k}from"commander";import{initCommand as h}from"../commands/init.js";import{runCommand as b}from"../commands/run.js";import{videoCommand as v}from"../commands/video.js";import{uploadCommand as C}from"../commands/upload.js";import{ciSetupCommand as I}from"../commands/ci-setup.js";import{setupPlaywrightMcpCommand as P,setupCiCommand as S,testWithVideoCommand as A}from"../commands/setup-scripts.js";import{readFileSync as j}from"fs";import{fileURLToPath as B}from"url";import{dirname as x,join as _}from"path";import{bootstrapAgentEnv as D}from"../utils/agent-credentials.js";const E=B(import.meta.url),z=x(E),u=JSON.parse(j(_(z,"../package.json"),"utf-8"));function c(o,e){return e.push(o),e}function f(o){if(o===void 0||o===!0||o==="")return 1;const e=parseInt(o,10);if(!Number.isFinite(e)||e<1||e>5)throw new Error(`--warm must be an integer 1-5 (got "${o}"). Omit the flag to disable warm pool.`);return e}const w=`zibby v${u.version}`,i=process.argv.slice(2),R=i.includes("-h")||i.includes("--help"),Z=i.includes("-v")||i.includes("-V")||i.includes("--version");Z&&(console.log(w),process.exit(0));const y=i[0],O=i[1],Y=["logs","uninstall"],L=y==="workflow"&&O==="list";!Y.includes(y)&&!L&&console.log(`${w}
|
|
3
|
+
`),D(process.cwd());const M=i[0]==="chat",U=["--verbose","--agent","--stream","-s"],W=i.length>0&&i.every(o=>U.includes(o)||i[i.indexOf(o)-1]==="--agent"),J=i.length===0||M||W;if(J&&!R){const o={},e=i.indexOf("--agent");e!==-1&&i[e+1]&&(o.agent=i[e+1]),i.includes("--verbose")&&(o.verbose=!0),(i.includes("--stream")||i.includes("-s"))&&(o.stream=!0);const{chatCommand:t}=await import("../commands/chat.js");await t(o),process.exit(0)}const n=new k;n.name("zibby").description("Zibby \u2014 the cloud pipeline for Claude Code, Cursor, Codex, and Gemini. Compose them into structured workflows with schema-enforced handoff.").version(u.version,"-V, --version"),n.configureHelp({visibleCommands:()=>[]}),n.addHelpText("after",`
|
|
4
4
|
Workflow (the platform):
|
|
5
5
|
workflow new <name> Scaffold a new workflow at .zibby/workflows/<name>/
|
|
6
6
|
workflow run <name> Run a workflow locally (one-shot, mirrors trigger flags)
|
|
@@ -45,4 +45,4 @@ Examples:
|
|
|
45
45
|
|
|
46
46
|
Docs: https://docs.zibby.app
|
|
47
47
|
GitHub: https://github.com/ZibbyHQ/zibby-agent
|
|
48
|
-
`),n.command("init").description("Initialize a Zibby project (config + credentials only \u2014 pass -t <name> to also scaffold a workflow template)").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("-t, --template <name>","Workflow template to scaffold into .zibby/ (see `zibby template list`). Default: none \u2014 init only sets up config and credentials.").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").option("--agent-key <key>","Agent API key (non-interactive). For Claude this is the per-token API key").option("--agent-oauth-token <token>","Claude OAuth subscription token (non-interactive). Saves to ~/.zibby/config.json").action(k),n.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((e,o)=>(o.debug?process.env.ZIBBY_DEBUG="true":o.verbose&&(process.env.ZIBBY_VERBOSE="true"),h(e,o))),n.command("implement").description("Implement a Jira ticket using AI agent (runs in ECS container)").action(async(...e)=>{const{implementCommand:o}=await import("../commands/implement.js");return o(...e)}),n.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(...e)=>{const{analyzeCommand:o}=await import("../commands/analyze-graph.js");return o(...e)}),n.command("video").description("Organize test videos next to test files").action(b),n.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(v),n.command("login").description("Log in to Zibby (opens browser for authentication)").action(async()=>{const{loginCli:e}=await import("../auth/cli-login.js");await e(),process.exit(0)}),n.command("logout").description("Log out from Zibby (clears saved session)").action(async()=>{const{logoutCli:e}=await import("../auth/cli-login.js");e(),process.exit(0)}),n.command("status").description("Show current authentication status and token details").option("--json","Output in JSON format (for scripts)").action(async e=>{const{showLoginStatus:o}=await import("../auth/cli-login.js");await o(e),process.exit(0)}),n.command("list").description("List your projects and API tokens").action(async()=>{const{listProjectsCommand:e}=await import("../commands/list-projects.js");await e()}),n.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(C),n.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(e=>{const o={width:parseInt(e.viewportWidth,10)||1280,height:parseInt(e.viewportHeight,10)||720};return I({...e,viewport:o})}),n.command("setup-ci-full").description("Complete CI/CD setup from scratch").action(P),n.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(S),n.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 e=>{const{generateCommand:o}=await import("../commands/generate.js");return o(e)}),n.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 e=>{const{studioCommand:o}=await import("../commands/studio.js");return o(e)});const d=n.command("creds").description("Manage credentials Zibby has stored for your workspace (KMS-encrypted)");d.command("list").description("List credentials stored for your workspace (masked)").action(async()=>{const{listCmd:e}=await import("../commands/creds.js");await e(),process.exit(0)}),d.command("sync").description("Re-read ~/.zibby/credentials.env and upload any new tokens").action(async()=>{const{syncCmd:e}=await import("../commands/creds.js");await e(),process.exit(0)}),d.command("remove <type> <index>").description("Remove a stored credential. e.g. zibby creds remove oauth 0").action(async(e,o)=>{const{removeCmd:t}=await import("../commands/creds.js");await t(e,o),process.exit(0)});const W=n.command("g").description("Generate scaffolds");W.command("workflow [name]").description("Scaffold a new custom workflow in .zibby/workflows/<name>/ (auto-generates name if omitted)").option("--skip-install","Skip running `npm install` in the new workflow folder").option("--agent-helpers [list]",'Install agent helpers (Claude Code / Cursor slash commands). List = comma-separated, e.g. "claude" or "claude,cursor". Bare flag defaults to claude.').option("--no-agent-helpers","Skip agent helpers even if .zibby.config.mjs says install").option("--agent <agent>","(legacy) Set up agent helpers: claude | cursor | codex | all | none. Prefer --agent-helpers.").option("--force-agents","Overwrite user-edited agent helper files (use with --agent-helpers)").action(async(e,o)=>{const{generateWorkflowCommand:t}=await import("../commands/workflows/generate.js");return t(e,o)}),n.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(e,o)=>{const{startWorkflowCommand:t}=await import("../commands/workflows/start.js");return t(e,o)}),n.command("run <workflow-name>").description("Run a workflow locally \u2014 one-shot (alias of `zibby workflow run`)").option("-p, --param <key=value>","Input param (repeatable)",c,[]).option("--input <json>","Input as JSON string").option("--input-file <path>","Input as JSON file").action(async(e,o)=>{const{runLocalWorkflowCommand:t}=await import("../commands/workflows/run-local.js");return t(e,o)}),n.command("deploy [workflow-name]").description("Deploy a custom workflow to Zibby Cloud (interactive selection if workflow-name not provided)").option("--project <id>","Project ID (interactive prompt if not provided, or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--dedicated-ip <action>","Manage dedicated egress IP addon: enable | status | disable | use | unuse").option("--env <path>","Path to a .env file to sync into per-workflow env vars after deploy (repeatable)",c,[]).option("--verbose","Show raw CodeBuild logs during the bundle build").option("--no-creds-check","Skip the project secrets sanity check (CI/CD when the secret is provisioned out-of-band)").option("--force","Deploy even if the source checksum matches the last deployed version (bypasses the unchanged check)").action(async(e,o)=>{if(o.dedicatedIp){const{dedicatedEgressCommand:s}=await import("../commands/workflows/dedicated-egress.js");return s(o.dedicatedIp,o.project)}const{deployWorkflowCommand:t}=await import("../commands/workflows/deploy.js");return t(e,o)}),n.command("trigger [uuid]").description("Trigger a deployed workflow by UUID (interactive selection if not provided). Get UUIDs from `zibby workflow list`.").option("--project <id>","Project ID (interactive prompt if not provided, or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("-p, --param <key=value>","Input param (repeatable, e.g. -p url=https://x.com -p count=5)",c,[]).option("--input <json>",`Input as JSON string \u2014 overridden by --param (e.g. '{"key":"value"}')`).option("--input-file <path>","Input as JSON/YAML file \u2014 lowest precedence").option("--idempotency-key <key>","Idempotency key to prevent duplicate executions").option("-t, --follow","Stream logs in real-time after triggering (no need to run `logs -t` separately)").action(async(e,o)=>{const{triggerWorkflowCommand:t}=await import("../commands/workflows/trigger.js");return t(e,o)}),n.command("logs [jobId]").description("Fetch and display logs from a workflow execution (use -t to stream in real-time)").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--workflow <name>","Workflow name (fetches the latest run)").option("--all","Show interleaved logs from all runs (requires --workflow)").option("-t, --follow","Stream logs in real-time (like Heroku logs -t)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--lines <n>","Max log lines per fetch (default: 500)").action(async(e,o)=>{const{logsCommand:t}=await import("../commands/workflows/logs.js");return t(e,o)}),n.command("run-workflow").description("Run a deployed workflow from S3 sources (used by ECS containers)").action(async()=>{const{runWorkflowCommand:e}=await import("../commands/workflows/run.js");return e()});const y=n.command("template").description("Manage workflow templates in this project");y.command("list").description("List available workflow templates").action(async()=>{const{templateListCommand:e}=await import("../commands/template.js");return e()}),y.command("add").argument("<name>","Template name (see `zibby template list`)").description("Copy a workflow template into this project's .zibby/ (overwrites existing files = doubles as update)").option("--skip-memory","Strip SKILLS.MEMORY from copied execute-live.mjs (browser-test only)").action(async(e,o)=>{const{templateAddCommand:t}=await import("../commands/template.js");return t(e,{enableMemory:!o.skipMemory})});const r=n.command("memory").description("Test memory database \u2014 version-controlled knowledge from runs");r.command("stats").description("Show memory database statistics").action(async()=>{const{memoryStatsCommand:e}=await import("../commands/memory.js");return e()}),r.command("init").description("Initialize the memory database (Dolt)").action(async()=>{const{memoryInitCommand:e}=await import("../commands/memory.js");return e()}),r.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 e=>{const{memoryCompactCommand:o}=await import("../commands/memory.js");return o(e)}),r.command("reset").description("Wipe the memory database").option("-f, --force","Confirm reset").action(async e=>{const{memoryResetCommand:o}=await import("../commands/memory.js");return o(e)}),r.command("cost").description("Show real LLM token usage from past runs (input/output/cache)").action(async()=>{const{memoryCostCommand:e}=await import("../commands/memory.js");return e()});const l=r.command("remote").description("Configure a remote so the team shares cross-spec memory");l.command("add").argument("<url>","Remote URL: aws://, gs://, https://, file:///").option("--name <name>","Remote name (default: origin)","origin").description("Point the local memory DB at a shared remote (S3/GCS/DoltHub/filesystem)").action(async(e,o)=>{const{memoryRemoteAddCommand:t}=await import("../commands/memory.js");return t(e,o)}),l.command("use").description("Switch to a managed remote backend. Currently: --hosted (Zibby-managed S3, signed-in users only).").option("--hosted","Use Zibby-managed S3 (allocates a tenant-scoped prefix per-project)").option("--project-id <id>","Override the projectId from .zibby.config.mjs").action(async e=>{e.hosted||(console.log("Pass --hosted. (Other backends will be added later.)"),process.exit(1));const{memoryRemoteUseHostedCommand:o}=await import("../commands/memory.js");return o(e)}),l.command("info").description("Show the configured memory remote (if any)").action(async()=>{const{memoryRemoteInfoCommand:e}=await import("../commands/memory.js");return e()}),l.command("remove").argument("[name]","Remote name (default: origin)").description("Remove a configured memory remote (memory becomes local-only)").action(async e=>{const{memoryRemoteRemoveCommand:o}=await import("../commands/memory.js");return o(e)}),r.command("pull").description("Pull latest team memory from the configured remote").action(async()=>{const{memoryPullCommand:e}=await import("../commands/memory.js");return e()}),r.command("push").description("Push local memory to the configured remote (auto-runs after passing tests)").action(async()=>{const{memoryPushCommand:e}=await import("../commands/memory.js");return e()});const T=n.command("agents").description("Manage Claude/Cursor/Codex helper files for working with Zibby workflows");T.command("add [agent]").description("Add agent helpers (claude | cursor | codex | all). Prompts if no agent given.").option("--force","Overwrite user-edited helper files").action(async(e,o)=>{const{runAgentHelpers:t,addAgent:s}=await import("../commands/workflows/agent-helpers.js");if(e){const m=["claude","cursor","codex","all","none"];m.includes(e)||(console.error(`Unknown agent "${e}". Valid: ${m.join(", ")}`),process.exit(1)),e==="none"?await t({forcedAgents:["none"],force:o.force===!0}):e==="all"?await t({forcedAgents:["claude","cursor","codex"],force:o.force===!0}):await s(e,{force:o.force===!0})}else await t({forcedAgents:void 0,force:o.force===!0,forcePrompt:!0})});const a=n.command("workflow").description("Manage workflow graphs \u2014 new, start, deploy, trigger, logs, list, download, delete");a.command("new [name]").description("Scaffold a new custom workflow (alias of `zibby g workflow`)").option("--skip-install","Skip running `npm install` in the new workflow folder").option("--agent-helpers [list]",'Install agent helpers (Claude Code / Cursor slash commands). List = comma-separated, e.g. "claude" or "claude,cursor". Bare flag defaults to claude.').option("--no-agent-helpers","Skip agent helpers even if .zibby.config.mjs says install").option("--agent <agent>","(legacy) Set up agent helpers: claude | cursor | codex | all | none. Prefer --agent-helpers.").option("--force-agents","Overwrite user-edited agent helper files (use with --agent-helpers)").action(async(e,o)=>{const{generateWorkflowCommand:t}=await import("../commands/workflows/generate.js");return t(e,o)}),a.command("run <workflow-name>").description("Run a workflow locally \u2014 one-shot, same input flags as `workflow trigger`").option("-p, --param <key=value>","Input param (repeatable, e.g. -p url=https://x.com -p count=5)",c,[]).option("--input <json>",`Input as JSON string \u2014 overridden by --param (e.g. '{"key":"value"}')`).option("--input-file <path>","Input as JSON file \u2014 lowest precedence").action(async(e,o)=>{const{runLocalWorkflowCommand:t}=await import("../commands/workflows/run-local.js");return t(e,o)}),a.command("start <workflow-name>").description("Start a long-lived local dev server (Studio integration). Prefer `workflow run` for one-shots.").option("-p, --port <port>","Port for the workflow server (default: 3848)").action(async(e,o)=>{const{startWorkflowCommand:t}=await import("../commands/workflows/start.js");return t(e,o)}),a.command("deploy [workflow-name]").description("Deploy a workflow to Zibby Cloud (alias of `zibby deploy`)").option("--project <id>","Project ID (interactive prompt if not provided, or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--env <path>","Path to a .env file to sync into per-workflow env vars after deploy (repeatable)",c,[]).option("--verbose","Show raw CodeBuild logs during the bundle build").option("--no-creds-check","Skip the project secrets sanity check (CI/CD when the secret is provisioned out-of-band)").option("--force","Deploy even if the source checksum matches the last deployed version (bypasses the unchanged check)").action(async(e,o)=>{const{deployWorkflowCommand:t}=await import("../commands/workflows/deploy.js");return t(e,o)}),a.command("trigger [uuid]").description("Trigger a deployed workflow by UUID (alias of `zibby trigger`)").option("--project <id>","Project ID (interactive prompt if not provided, or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("-p, --param <key=value>","Input param (repeatable, e.g. -p url=https://x.com -p count=5)",c,[]).option("--input <json>",`Input as JSON string \u2014 overridden by --param (e.g. '{"key":"value"}')`).option("--input-file <path>","Input as JSON/YAML file \u2014 lowest precedence").option("--idempotency-key <key>","Idempotency key to prevent duplicate executions").option("-t, --follow","Stream logs in real-time after triggering (no need to run `logs -t` separately)").action(async(e,o)=>{const{triggerWorkflowCommand:t}=await import("../commands/workflows/trigger.js");return t(e,o)}),a.command("logs [jobId]").description("Tail logs from a workflow execution (alias of `zibby logs`)").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--workflow <name>","Workflow name (fetches the latest run)").option("--all","Show interleaved logs from all runs (requires --workflow)").option("-t, --follow","Stream logs in real-time (like Heroku logs -t)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--lines <n>","Max log lines per fetch (default: 500)").action(async(e,o)=>{const{logsCommand:t}=await import("../commands/workflows/logs.js");return t(e,o)}),a.command("download [uuid]").description("Download a workflow from Zibby Cloud to .zibby/workflows/<name>/. Pass a UUID (from `zibby workflow list`) for custom workflows, or use --type for built-ins.").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--type <type>","Built-in workflow type: analysis, implementation, run_test (alternative to positional <uuid>)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--output <dir>","Output directory base (default: .zibby/workflows)").option("--include-default","Download the built-in default graph if no custom one exists").action(async(e,o)=>{const{workflowDownloadCommand:t}=await import("../commands/workflow.js");return t({...o,uuid:e})}),a.command("list").description("List all workflows (local + remote if credentials available)").option("--local-only","Show only local workflows").option("--remote-only","Show only remote workflows (requires --project)").option("--project <id>","Project ID (optional, uses ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async e=>{if(e.remoteOnly){const{workflowListCommand:t}=await import("../commands/workflow.js");return t(e)}if(e.localOnly){const{listLocalWorkflowsCommand:t}=await import("../commands/workflows/list.js");return t(e)}const{listAllWorkflowsCommand:o}=await import("../commands/workflows/list.js");return o(e)}),a.command("delete <uuid>").description("Delete a deployed workflow by UUID").action(async e=>{const{deleteWorkflowCommand:o}=await import("../commands/workflows/delete.js");return o(e,{})});const p=a.command("env").description("Manage per-workflow encrypted env vars (set ANTHROPIC_API_KEY, DATABASE_URL, etc. per workflow)");p.command("list <uuid>").description("List env var key names for a workflow (values never returned)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o)=>{const{listEnvCommand:t}=await import("../commands/workflows/env.js");return t(e,o)}),p.command("set <uuid> <kv>").description("Set or update one env var: zibby workflow env set <uuid> KEY=value").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o,t)=>{const{setEnvCommand:s}=await import("../commands/workflows/env.js");return s(e,o,t)}),p.command("unset <uuid> <key>").description("Remove one env var from a workflow").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o,t)=>{const{unsetEnvCommand:s}=await import("../commands/workflows/env.js");return s(e,o,t)}),p.command("push <uuid>").description("Bulk-replace env from one or more .env files (later files override). Removes any keys not in the new map.").option("--file <path>","Path to a .env file (repeatable, e.g. --file .env --file .env.prod)",c,[]).option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o)=>{const{pushEnvCommand:t}=await import("../commands/workflows/env.js");return t(e,o)});const K=n.command("project").description("Manage Zibby projects");K.command("list").description("List all projects").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async e=>{const{projectListCommand:o}=await import("../commands/project.js");return o(e)});const N=n.command("run-queue").description("Parallel capacity \u2014 on-disk wait queue (see parallel.waitWhenAtCapacity in .zibby.config.mjs)");N.command("list").description("List CLI processes waiting for a run slot").option("--config <path>","Path to config file",".zibby.config.mjs").action(async e=>{const{runCapacityQueueListCommand:o}=await import("../commands/run-capacity-queue-cli.js");await o(e),process.exit(0)}),n.command("uninstall").description("Remove all Zibby data: global CLI, ~/.zibby, Cursor MCP config, Studio, and current project").option("--dry-run","Show what would be deleted without deleting").option("--deep","Also remove npx cache dirs containing zibby").action(async e=>{const{uninstallCommand:o}=await import("../commands/uninstall.js");await o(e),process.exit(0)}),n.parse();
|
|
48
|
+
`),n.command("init").description("Initialize a Zibby project (config + credentials only \u2014 pass -t <name> to also scaffold a workflow template)").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("-t, --template <name>","Workflow template to scaffold into .zibby/ (see `zibby template list`). Default: none \u2014 init only sets up config and credentials.").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").option("--agent-key <key>","Agent API key (non-interactive). For Claude this is the per-token API key").option("--agent-oauth-token <token>","Claude OAuth subscription token (non-interactive). Saves to ~/.zibby/config.json").action(h),n.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,e)=>(e.debug?process.env.ZIBBY_DEBUG="true":e.verbose&&(process.env.ZIBBY_VERBOSE="true"),b(o,e))),n.command("implement").description("Implement a Jira ticket using AI agent (runs in ECS container)").action(async(...o)=>{const{implementCommand:e}=await import("../commands/implement.js");return e(...o)}),n.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:e}=await import("../commands/analyze-graph.js");return e(...o)}),n.command("video").description("Organize test videos next to test files").action(v),n.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(C),n.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)}),n.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)}),n.command("status").description("Show current authentication status and token details").option("--json","Output in JSON format (for scripts)").action(async o=>{const{showLoginStatus:e}=await import("../auth/cli-login.js");await e(o),process.exit(0)}),n.command("list").description("List your projects and API tokens").action(async()=>{const{listProjectsCommand:o}=await import("../commands/list-projects.js");await o()}),n.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(I),n.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 e={width:parseInt(o.viewportWidth,10)||1280,height:parseInt(o.viewportHeight,10)||720};return P({...o,viewport:e})}),n.command("setup-ci-full").description("Complete CI/CD setup from scratch").action(S),n.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(A),n.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:e}=await import("../commands/generate.js");return e(o)}),n.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:e}=await import("../commands/studio.js");return e(o)});const d=n.command("creds").description("Manage credentials Zibby has stored for your workspace (KMS-encrypted)");d.command("list").description("List credentials stored for your workspace (masked)").action(async()=>{const{listCmd:o}=await import("../commands/creds.js");await o(),process.exit(0)}),d.command("sync").description("Re-read ~/.zibby/credentials.env and upload any new tokens").action(async()=>{const{syncCmd:o}=await import("../commands/creds.js");await o(),process.exit(0)}),d.command("remove <type> <index>").description("Remove a stored credential. e.g. zibby creds remove oauth 0").action(async(o,e)=>{const{removeCmd:t}=await import("../commands/creds.js");await t(o,e),process.exit(0)});const T=n.command("g").description("Generate scaffolds");T.command("workflow [name]").description("Scaffold a new custom workflow in .zibby/workflows/<name>/ (auto-generates name if omitted)").option("--skip-install","Skip running `npm install` in the new workflow folder").option("--agent-helpers [list]",'Install agent helpers (Claude Code / Cursor slash commands). List = comma-separated, e.g. "claude" or "claude,cursor". Bare flag defaults to claude.').option("--no-agent-helpers","Skip agent helpers even if .zibby.config.mjs says install").option("--agent <agent>","(legacy) Set up agent helpers: claude | cursor | codex | all | none. Prefer --agent-helpers.").option("--force-agents","Overwrite user-edited agent helper files (use with --agent-helpers)").action(async(o,e)=>{const{generateWorkflowCommand:t}=await import("../commands/workflows/generate.js");return t(o,e)}),n.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,e)=>{const{startWorkflowCommand:t}=await import("../commands/workflows/start.js");return t(o,e)}),n.command("run <workflow-name>").description("Run a workflow locally \u2014 one-shot (alias of `zibby workflow run`)").option("-p, --param <key=value>","Input param (repeatable)",c,[]).option("--input <json>","Input as JSON string").option("--input-file <path>","Input as JSON file").action(async(o,e)=>{const{runLocalWorkflowCommand:t}=await import("../commands/workflows/run-local.js");return t(o,e)}),n.command("deploy [workflow-name]").description("Deploy a custom workflow to Zibby Cloud (interactive selection if workflow-name not provided)").option("--project <id>","Project ID (interactive prompt if not provided, or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--dedicated-ip <action>","Manage dedicated egress IP addon: enable | status | disable | use | unuse").option("--env <path>","Path to a .env file to sync into per-workflow env vars after deploy (repeatable)",c,[]).option("--verbose","Show raw CodeBuild logs during the bundle build").option("--no-creds-check","Skip the project secrets sanity check (CI/CD when the secret is provisioned out-of-band)").option("--force","Deploy even if the source checksum matches the last deployed version (bypasses the unchanged check)").option("--warm [count]","Enable warm-pool execution for this workflow (default 1, max 5). Skips ~60s Fargate cold-start by routing triggers to a per-account pool of always-on tasks. Pricing applies (paid feature).",f).action(async(o,e)=>{if(e.dedicatedIp){const{dedicatedEgressCommand:s}=await import("../commands/workflows/dedicated-egress.js");return s(e.dedicatedIp,e.project)}const{deployWorkflowCommand:t}=await import("../commands/workflows/deploy.js");return t(o,e)}),n.command("trigger [uuid]").description("Trigger a deployed workflow by UUID (interactive selection if not provided). Get UUIDs from `zibby workflow list`.").option("--project <id>","Project ID (interactive prompt if not provided, or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("-p, --param <key=value>","Input param (repeatable, e.g. -p url=https://x.com -p count=5)",c,[]).option("--input <json>",`Input as JSON string \u2014 overridden by --param (e.g. '{"key":"value"}')`).option("--input-file <path>","Input as JSON/YAML file \u2014 lowest precedence").option("--idempotency-key <key>","Idempotency key to prevent duplicate executions").option("-t, --follow","Stream logs in real-time after triggering (no need to run `logs -t` separately)").action(async(o,e)=>{const{triggerWorkflowCommand:t}=await import("../commands/workflows/trigger.js");return t(o,e)}),n.command("logs [jobId]").description("Fetch and display logs from a workflow execution (use -t to stream in real-time)").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--workflow <name>","Workflow name (fetches the latest run)").option("--all","Show interleaved logs from all runs (requires --workflow)").option("-t, --follow","Stream logs in real-time (like Heroku logs -t)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--lines <n>","Max log lines per fetch (default: 500)").action(async(o,e)=>{const{logsCommand:t}=await import("../commands/workflows/logs.js");return t(o,e)}),n.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 g=n.command("template").description("Manage workflow templates in this project");g.command("list").description("List available workflow templates").action(async()=>{const{templateListCommand:o}=await import("../commands/template.js");return o()}),g.command("add").argument("<name>","Template name (see `zibby template list`)").description("Copy a workflow template into this project's .zibby/ (overwrites existing files = doubles as update)").option("--skip-memory","Strip SKILLS.MEMORY from copied execute-live.mjs (browser-test only)").action(async(o,e)=>{const{templateAddCommand:t}=await import("../commands/template.js");return t(o,{enableMemory:!e.skipMemory})});const a=n.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:e}=await import("../commands/memory.js");return e(o)}),a.command("reset").description("Wipe the memory database").option("-f, --force","Confirm reset").action(async o=>{const{memoryResetCommand:e}=await import("../commands/memory.js");return e(o)}),a.command("cost").description("Show real LLM token usage from past runs (input/output/cache)").action(async()=>{const{memoryCostCommand:o}=await import("../commands/memory.js");return o()});const l=a.command("remote").description("Configure a remote so the team shares cross-spec memory");l.command("add").argument("<url>","Remote URL: aws://, gs://, https://, file:///").option("--name <name>","Remote name (default: origin)","origin").description("Point the local memory DB at a shared remote (S3/GCS/DoltHub/filesystem)").action(async(o,e)=>{const{memoryRemoteAddCommand:t}=await import("../commands/memory.js");return t(o,e)}),l.command("use").description("Switch to a managed remote backend. Currently: --hosted (Zibby-managed S3, signed-in users only).").option("--hosted","Use Zibby-managed S3 (allocates a tenant-scoped prefix per-project)").option("--project-id <id>","Override the projectId from .zibby.config.mjs").action(async o=>{o.hosted||(console.log("Pass --hosted. (Other backends will be added later.)"),process.exit(1));const{memoryRemoteUseHostedCommand:e}=await import("../commands/memory.js");return e(o)}),l.command("info").description("Show the configured memory remote (if any)").action(async()=>{const{memoryRemoteInfoCommand:o}=await import("../commands/memory.js");return o()}),l.command("remove").argument("[name]","Remote name (default: origin)").description("Remove a configured memory remote (memory becomes local-only)").action(async o=>{const{memoryRemoteRemoveCommand:e}=await import("../commands/memory.js");return e(o)}),a.command("pull").description("Pull latest team memory from the configured remote").action(async()=>{const{memoryPullCommand:o}=await import("../commands/memory.js");return o()}),a.command("push").description("Push local memory to the configured remote (auto-runs after passing tests)").action(async()=>{const{memoryPushCommand:o}=await import("../commands/memory.js");return o()});const F=n.command("agents").description("Manage Claude/Cursor/Codex helper files for working with Zibby workflows");F.command("add [agent]").description("Add agent helpers (claude | cursor | codex | all). Prompts if no agent given.").option("--force","Overwrite user-edited helper files").action(async(o,e)=>{const{runAgentHelpers:t,addAgent:s}=await import("../commands/workflows/agent-helpers.js");if(o){const m=["claude","cursor","codex","all","none"];m.includes(o)||(console.error(`Unknown agent "${o}". Valid: ${m.join(", ")}`),process.exit(1)),o==="none"?await t({forcedAgents:["none"],force:e.force===!0}):o==="all"?await t({forcedAgents:["claude","cursor","codex"],force:e.force===!0}):await s(o,{force:e.force===!0})}else await t({forcedAgents:void 0,force:e.force===!0,forcePrompt:!0})});const r=n.command("workflow").description("Manage workflow graphs \u2014 new, start, deploy, trigger, logs, list, download, delete");r.command("new [name]").description("Scaffold a new custom workflow (alias of `zibby g workflow`)").option("--skip-install","Skip running `npm install` in the new workflow folder").option("--agent-helpers [list]",'Install agent helpers (Claude Code / Cursor slash commands). List = comma-separated, e.g. "claude" or "claude,cursor". Bare flag defaults to claude.').option("--no-agent-helpers","Skip agent helpers even if .zibby.config.mjs says install").option("--agent <agent>","(legacy) Set up agent helpers: claude | cursor | codex | all | none. Prefer --agent-helpers.").option("--force-agents","Overwrite user-edited agent helper files (use with --agent-helpers)").action(async(o,e)=>{const{generateWorkflowCommand:t}=await import("../commands/workflows/generate.js");return t(o,e)}),r.command("run <workflow-name>").description("Run a workflow locally \u2014 one-shot, same input flags as `workflow trigger`").option("-p, --param <key=value>","Input param (repeatable, e.g. -p url=https://x.com -p count=5)",c,[]).option("--input <json>",`Input as JSON string \u2014 overridden by --param (e.g. '{"key":"value"}')`).option("--input-file <path>","Input as JSON file \u2014 lowest precedence").action(async(o,e)=>{const{runLocalWorkflowCommand:t}=await import("../commands/workflows/run-local.js");return t(o,e)}),r.command("start <workflow-name>").description("Start a long-lived local dev server (Studio integration). Prefer `workflow run` for one-shots.").option("-p, --port <port>","Port for the workflow server (default: 3848)").action(async(o,e)=>{const{startWorkflowCommand:t}=await import("../commands/workflows/start.js");return t(o,e)}),r.command("deploy [workflow-name]").description("Deploy a workflow to Zibby Cloud (alias of `zibby deploy`)").option("--project <id>","Project ID (interactive prompt if not provided, or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--env <path>","Path to a .env file to sync into per-workflow env vars after deploy (repeatable)",c,[]).option("--verbose","Show raw CodeBuild logs during the bundle build").option("--no-creds-check","Skip the project secrets sanity check (CI/CD when the secret is provisioned out-of-band)").option("--force","Deploy even if the source checksum matches the last deployed version (bypasses the unchanged check)").option("--warm [count]","Enable warm-pool execution for this workflow (default 1, max 5). Skips ~60s Fargate cold-start by routing triggers to a per-account pool of always-on tasks. Pricing applies (paid feature).",f).action(async(o,e)=>{const{deployWorkflowCommand:t}=await import("../commands/workflows/deploy.js");return t(o,e)}),r.command("trigger [uuid]").description("Trigger a deployed workflow by UUID (alias of `zibby trigger`)").option("--project <id>","Project ID (interactive prompt if not provided, or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("-p, --param <key=value>","Input param (repeatable, e.g. -p url=https://x.com -p count=5)",c,[]).option("--input <json>",`Input as JSON string \u2014 overridden by --param (e.g. '{"key":"value"}')`).option("--input-file <path>","Input as JSON/YAML file \u2014 lowest precedence").option("--idempotency-key <key>","Idempotency key to prevent duplicate executions").option("-t, --follow","Stream logs in real-time after triggering (no need to run `logs -t` separately)").action(async(o,e)=>{const{triggerWorkflowCommand:t}=await import("../commands/workflows/trigger.js");return t(o,e)}),r.command("logs [jobId]").description("Tail logs from a workflow execution (alias of `zibby logs`)").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--workflow <name>","Workflow name (fetches the latest run)").option("--all","Show interleaved logs from all runs (requires --workflow)").option("-t, --follow","Stream logs in real-time (like Heroku logs -t)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--lines <n>","Max log lines per fetch (default: 500)").action(async(o,e)=>{const{logsCommand:t}=await import("../commands/workflows/logs.js");return t(o,e)}),r.command("download [uuid]").description("Download a workflow from Zibby Cloud to .zibby/workflows/<name>/. Pass a UUID (from `zibby workflow list`) for custom workflows, or use --type for built-ins.").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--type <type>","Built-in workflow type: analysis, implementation, run_test (alternative to positional <uuid>)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--output <dir>","Output directory base (default: .zibby/workflows)").option("--include-default","Download the built-in default graph if no custom one exists").action(async(o,e)=>{const{workflowDownloadCommand:t}=await import("../commands/workflow.js");return t({...e,uuid:o})}),r.command("list").description("List all workflows (local + remote if credentials available)").option("--local-only","Show only local workflows").option("--remote-only","Show only remote workflows (requires --project)").option("--project <id>","Project ID (optional, uses ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async o=>{if(o.remoteOnly){const{workflowListCommand:t}=await import("../commands/workflow.js");return t(o)}if(o.localOnly){const{listLocalWorkflowsCommand:t}=await import("../commands/workflows/list.js");return t(o)}const{listAllWorkflowsCommand:e}=await import("../commands/workflows/list.js");return e(o)}),r.command("delete <uuid>").description("Delete a deployed workflow by UUID").action(async o=>{const{deleteWorkflowCommand:e}=await import("../commands/workflows/delete.js");return e(o,{})});const p=r.command("env").description("Manage per-workflow encrypted env vars (set ANTHROPIC_API_KEY, DATABASE_URL, etc. per workflow)");p.command("list <uuid>").description("List env var key names for a workflow (values never returned)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(o,e)=>{const{listEnvCommand:t}=await import("../commands/workflows/env.js");return t(o,e)}),p.command("set <uuid> <kv>").description("Set or update one env var: zibby workflow env set <uuid> KEY=value").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(o,e,t)=>{const{setEnvCommand:s}=await import("../commands/workflows/env.js");return s(o,e,t)}),p.command("unset <uuid> <key>").description("Remove one env var from a workflow").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(o,e,t)=>{const{unsetEnvCommand:s}=await import("../commands/workflows/env.js");return s(o,e,t)}),p.command("push <uuid>").description("Bulk-replace env from one or more .env files (later files override). Removes any keys not in the new map.").option("--file <path>","Path to a .env file (repeatable, e.g. --file .env --file .env.prod)",c,[]).option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(o,e)=>{const{pushEnvCommand:t}=await import("../commands/workflows/env.js");return t(o,e)});const K=n.command("project").description("Manage Zibby projects");K.command("list").description("List all projects").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async o=>{const{projectListCommand:e}=await import("../commands/project.js");return e(o)});const N=n.command("run-queue").description("Parallel capacity \u2014 on-disk wait queue (see parallel.waitWhenAtCapacity in .zibby.config.mjs)");N.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:e}=await import("../commands/run-capacity-queue-cli.js");await e(o),process.exit(0)}),n.command("uninstall").description("Remove all Zibby data: global CLI, ~/.zibby, Cursor MCP config, Studio, and current project").option("--dry-run","Show what would be deleted without deleting").option("--deep","Also remove npx cache dirs containing zibby").action(async o=>{const{uninstallCommand:e}=await import("../commands/uninstall.js");await e(o),process.exit(0)}),n.parse();
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Ao=Object.defineProperty;var L=(e,o)=>()=>(e&&(o=e(e=0)),o);var _e=(e,o)=>{for(var t in o)Ao(e,t,{get:o[t],enumerable:!0})};function T(){let e;if(process.env.ZIBBY_API_URL)e=process.env.ZIBBY_API_URL;else{let o=process.env.ZIBBY_ENV||"prod";H[o]?e=H[o].apiUrl:e=H.prod.apiUrl}try{let o=new URL(e);return o.protocol!=="http:"&&o.protocol!=="https:"?(console.error(`\u26A0\uFE0F Invalid API URL protocol: ${o.protocol} (only http/https allowed)`),H.prod.apiUrl):e}catch{return console.error(`\u26A0\uFE0F Invalid API URL: ${e}`),H.prod.apiUrl}}var H,W=L(()=>{H={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"}}});import{existsSync as Ne,mkdirSync as Lo,readFileSync as No,writeFileSync as Bo}from"fs";import{homedir as Be}from"os";import{join as q}from"path";function ze(){return process.env.ZIBBY_CONFIG_DIR||q(Be(),".zibby")}function Ke(){return q(ze(),"config.json")}function Ko(){let e=ze();Ne(e)||Lo(e,{recursive:!0})}function B(){try{let e=Ke();if(Ne(e)){let o=No(e,"utf-8");return JSON.parse(o)}}catch{}return{}}function M(e){Ko(),Bo(Ke(),JSON.stringify(e,null,2))}function Re(){return B().sessionToken||null}function De(e){let o=B();o.sessionToken=e,M(o)}function Ye(){return B().user||null}function Fe(e){let o=B();o.user=e,M(o)}function Ge(e){let o=B();o.proxyUrl=e,M(o)}function He(e){let o=B();o.mem0ProxyUrl=e,M(o)}function Me(e){let o=B();o.projects=e,M(o)}var zo,Dt,Ve=L(()=>{zo=q(Be(),".zibby"),Dt=q(zo,"config.json")});import{existsSync as Gt,mkdirSync as Ht,readFileSync as Mt,writeFileSync as Vt,unlinkSync as Jt}from"fs";import{resolve as Wt}from"path";import{homedir as Xt}from"os";var Je=L(()=>{});import y from"chalk";import pe from"ora";import{spawn as Ro}from"child_process";function Do(e){let o=process.platform;try{let t,n;return o==="darwin"?(t="open",n=[e]):o==="win32"?(t="cmd",n=["/c","start","",e]):(t="xdg-open",n=[e]),Ro(t,n,{detached:!0,stdio:"ignore"}).unref(),!0}catch{return!1}}function Yo(){let e=Re(),o=Ye();return e&&o?{loggedIn:!0,user:o,token:e}:{loggedIn:!1}}async function We(){try{console.log(y.cyan(`
|
|
2
2
|
\u{1F510} Initiating login...
|
|
3
|
-
`));let e=Yo();if(e.loggedIn){console.log(
|
|
4
|
-
`));let{createInterface:o}=await import("readline"),t=o({input:process.stdin,output:process.stdout});return new Promise((n,r)=>{let i=()=>{t.close(),process.stdin.isTTY&&process.stdin.setRawMode(!1)},s=()=>{console.log(
|
|
3
|
+
`));let e=Yo();if(e.loggedIn){console.log(y.green("\u2705 Already logged in!")),console.log(y.gray(`User: ${e.user.email}`)),console.log(y.gray(`Name: ${e.user.name}
|
|
4
|
+
`));let{createInterface:o}=await import("readline"),t=o({input:process.stdin,output:process.stdout});return new Promise((n,r)=>{let i=()=>{t.close(),process.stdin.isTTY&&process.stdin.setRawMode(!1)},s=()=>{console.log(y.yellow(`
|
|
5
5
|
|
|
6
6
|
\u26A0\uFE0F Login cancelled
|
|
7
|
-
`)),i(),process.exit(0)};process.on("SIGINT",s),t.question(
|
|
8
|
-
`));let u=await Ze();n(u)}else console.log(
|
|
9
|
-
`)),n({success:!0,...e})}catch(u){r(u)}})})}return await Ze()}catch(e){return console.error(
|
|
10
|
-
\u274C Login failed:`,e.message)),{success:!1,error:e.message}}}async function Fo(e){let o=T();try{let t=await fetch(`${o}/projects`,{headers:{Authorization:`Bearer ${e}`}});if(t.ok){let r=((await t.json()).projects||[]).map(i=>({name:i.name,projectId:i.projectId,apiToken:i.apiToken}));return Me(r),r}}catch(t){console.log(
|
|
7
|
+
`)),i(),process.exit(0)};process.on("SIGINT",s),t.question(y.yellow("Continue with this session? (Y/n): "),async c=>{process.removeListener("SIGINT",s),i();try{if(c.toLowerCase()==="n"||c.toLowerCase()==="no"){console.log(y.gray(`Starting new login...
|
|
8
|
+
`));let u=await Ze();n(u)}else console.log(y.green(`Using existing session.
|
|
9
|
+
`)),n({success:!0,...e})}catch(u){r(u)}})})}return await Ze()}catch(e){return console.error(y.red(`
|
|
10
|
+
\u274C Login failed:`,e.message)),{success:!1,error:e.message}}}async function Fo(e){let o=T();try{let t=await fetch(`${o}/projects`,{headers:{Authorization:`Bearer ${e}`}});if(t.ok){let r=((await t.json()).projects||[]).map(i=>({name:i.name,projectId:i.projectId,apiToken:i.apiToken}));return Me(r),r}}catch(t){console.log(y.gray(`\u26A0\uFE0F Could not fetch projects: ${t.message}`))}return[]}async function Ze(){let e=T(),o=pe("Requesting login code...").start(),t=await fetch(`${e}/cli/login/initiate`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok){o.fail("Failed to request login code");let k=await t.json();throw new Error(k.error||"Failed to initiate login")}let{deviceCode:n,userCode:r,verificationUrl:i,expiresIn:s,interval:c}=await t.json();o.succeed("Login code generated"),console.log(""),console.log(y.cyan("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(y.cyan("\u2551")+y.white.bold(" Complete login in your browser ")+y.cyan("\u2551")),console.log(y.cyan("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log(""),console.log(y.white("Opening browser to login page...")),console.log(y.gray(`Code expires in ${Math.floor(s/60)} minutes`)),console.log(""),await Do(i)||(console.log(y.yellow("\u26A0\uFE0F Could not open browser automatically.")),console.log(y.white("Please open this URL manually: ")+y.blue(i)),console.log(""));let l=pe("Waiting for authorization...").start(),d=(c||3)*1e3,E=Math.floor(s/(c||3)),v=0,h=!1,$=()=>{h=!0,l.stop(),console.log(y.yellow(`
|
|
11
11
|
|
|
12
12
|
\u26A0\uFE0F Login cancelled
|
|
13
|
-
`)),process.exit(0)};process.on("SIGINT"
|
|
14
|
-
`)),{success:!0,loggedIn:!0,user:a.user,token:a.token}}if(a.status==="denied")throw l.fail("Authorization denied"),new Error("User denied authorization")}throw l.fail("Login timeout"),new Error("Login timed out - please try again")}finally{process.removeListener("SIGINT"
|
|
13
|
+
`)),process.exit(0)};process.on("SIGINT",$);try{for(;v<E&&!h;){await Go(d),v++;let k=await fetch(`${e}/cli/login/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:n})});if(k.status===202)continue;if(!k.ok){l.fail("Authorization failed");let p=await k.json();throw new Error(p.error||"Authorization failed")}let a=await k.json();if(a.status==="authorized"){l.succeed(y.white("Authorization successful!")),De(a.token),Fe(a.user),a.proxyUrl&&Ge(a.proxyUrl),a.mem0ProxyUrl&&He(a.mem0ProxyUrl),console.log(""),console.log(y.gray(`User: ${a.user.email}`));let p=pe("Fetching projects...").start(),x=await Fo(a.token);return p.succeed(`Fetched ${x.length} project${x.length!==1?"s":""}`),console.log(y.gray(`Session saved to: ~/.zibby/config.json
|
|
14
|
+
`)),{success:!0,loggedIn:!0,user:a.user,token:a.token}}if(a.status==="denied")throw l.fail("Authorization denied"),new Error("User denied authorization")}throw l.fail("Login timeout"),new Error("Login timed out - please try again")}finally{process.removeListener("SIGINT",$)}}function Go(e){return new Promise(o=>setTimeout(o,e))}var qe=L(()=>{W();Ve();Je()});import{existsSync as Ho,readFileSync as Mo}from"fs";import{join as Vo}from"path";import ge from"chalk";import{confirm as Jo}from"@inquirer/prompts";function Xe(){try{let e=process.env.HOME||process.env.USERPROFILE;if(!e)return null;let o=Vo(e,".zibby","config.json");return Ho(o)&&JSON.parse(Mo(o,"utf-8")).sessionToken||null}catch{return null}}function de(){console.log(`
|
|
15
15
|
Not authenticated.`),console.log(` Run ${ge.cyan("zibby login")} or set ${ge.cyan("ZIBBY_API_KEY")} in your environment.
|
|
16
|
-
`)}async function
|
|
17
|
-
Not logged in.`));let n;try{n=await Jo({message:"Open browser to log in now?",default:!0})}catch{n=!1}if(!n){if(e.optional)return{sessionToken:null,apiKey:null};de(),process.exit(1)}if(await We(),t=Xe(),!t){if(e.optional)return{sessionToken:null,apiKey:null};de(),process.exit(1)}return{sessionToken:t,apiKey:null}}var ye=L(()=>{qe()});import{existsSync as Zo,readFileSync as Wo,writeFileSync as mn,mkdirSync as wn}from"fs";import{join as qo}from"path";import{homedir as Xo}from"os";function Qo(){return qo(Xo(),".zibby","config.json")}function he(){try{let e=Qo();return Zo(e)?JSON.parse(Wo(e,"utf-8")):{}}catch{return{}}}var
|
|
18
|
-
`)}var me,ke=L(()=>{me=/^[A-Z_][A-Z0-9_]*$/});var lo={};_e(lo,{pickLocalUpload:()=>io,readDeployedUuid:()=>so,readFullClaudeOauthBlob:()=>no,readLocalUpload:()=>co,resolveAgentAuthChoice:()=>ro,resolveCheckResult:()=>ao,resolveWorkflowAgent:()=>ve,runCloudCredsCheck:()=>mt,writeTempEnvBag:()
|
|
16
|
+
`)}async function X(e={}){let o=e.apiKey||process.env.ZIBBY_API_KEY||null,t=Xe();if(t||o)return{sessionToken:t,apiKey:o};if(!process.stdin.isTTY){if(e.optional)return{sessionToken:null,apiKey:null};de(),process.exit(1)}console.log(ge.yellow(`
|
|
17
|
+
Not logged in.`));let n;try{n=await Jo({message:"Open browser to log in now?",default:!0})}catch{n=!1}if(!n){if(e.optional)return{sessionToken:null,apiKey:null};de(),process.exit(1)}if(await We(),t=Xe(),!t){if(e.optional)return{sessionToken:null,apiKey:null};de(),process.exit(1)}return{sessionToken:t,apiKey:null}}var ye=L(()=>{qe()});import{existsSync as Zo,readFileSync as Wo,writeFileSync as mn,mkdirSync as wn}from"fs";import{join as qo}from"path";import{homedir as Xo}from"os";function Qo(){return qo(Xo(),".zibby","config.json")}function he(){try{let e=Qo();return Zo(e)?JSON.parse(Wo(e,"utf-8")):{}}catch{return{}}}var Q,Qe=L(()=>{Q={cursor:{envVar:"CURSOR_API_KEY",label:"Cursor API Key",url:"https://cursor.com/settings"},claude:{envVar:"ANTHROPIC_API_KEY",label:"Anthropic API Key",url:"https://console.anthropic.com/settings/keys"},codex:{envVar:"OPENAI_API_KEY",label:"OpenAI API Key",url:"https://platform.openai.com/api-keys"},gemini:{envVar:"GEMINI_API_KEY",label:"Gemini API Key",url:"https://aistudio.google.com/app/apikey"}}});import{readFileSync as et,existsSync as ot}from"fs";import tt from"dotenv";function ee(e){return typeof e=="string"&&me.test(e)}function eo(e){if(typeof e!="string"||e.length===0)throw new Error("Expected KEY=value, got empty argument");let o=e.indexOf("=");if(o<=0)throw new Error(`Expected KEY=value, got "${e}" \u2014 missing '=' or empty key`);let t=e.slice(0,o),n=e.slice(o+1);if(!ee(t))throw new Error(`Invalid env var name "${t}" \u2014 must match ${me} (uppercase letters, digits, underscores; can't start with a digit)`);return{key:t,value:n}}function V(e){if(!Array.isArray(e)||e.length===0)return{};let o={};for(let t of e){if(!ot(t))throw new Error(`--env file not found: ${t}`);let n=tt.parse(et(t,"utf-8"));for(let[r,i]of Object.entries(n)){if(!ee(r))throw new Error(`Invalid env var name "${r}" in ${t} \u2014 must match ${me} (uppercase letters, digits, underscores; can't start with a digit)`);o[r]=i}}return o}function N(e,o,t){let n=String(e).replace(/\/+$/,"");return t?`${n}/workflows/${o}/env/${encodeURIComponent(t)}`:`${n}/workflows/${o}/env`}function we(e){return!Array.isArray(e)||e.length===0?"No env vars set on this workflow.":[...e].sort().map(t=>` ${t}`).join(`
|
|
18
|
+
`)}var me,ke=L(()=>{me=/^[A-Z_][A-Z0-9_]*$/});var lo={};_e(lo,{pickLocalUpload:()=>io,readDeployedUuid:()=>so,readFullClaudeOauthBlob:()=>no,readLocalUpload:()=>co,resolveAgentAuthChoice:()=>ro,resolveCheckResult:()=>ao,resolveWorkflowAgent:()=>ve,runCloudCredsCheck:()=>mt,writeTempEnvBag:()=>$e,writeTempEnvFile:()=>yt});import m from"chalk";import nt from"inquirer";import{execSync as rt}from"node:child_process";import{existsSync as oo,readFileSync as to,writeFileSync as st,chmodSync as it,unlinkSync as ct}from"node:fs";import{homedir as at,tmpdir as lt}from"node:os";import{join as be}from"node:path";import{randomBytes as ut}from"node:crypto";function no(){if(process.platform==="darwin")try{let e=rt('security find-generic-password -s "Claude Code-credentials" -w',{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim();if(e){let o=JSON.parse(e);if(o?.claudeAiOauth?.accessToken)return o.claudeAiOauth}}catch{}try{let e=be(at(),".claude",".credentials.json");return oo(e)&&JSON.parse(to(e,"utf-8"))?.claudeAiOauth||null}catch{return null}}function ro(e){let o=ve(e);if(!o)return null;let t=e?.agent;if(!t||typeof t!="object")return null;let n=t[o];if(n&&typeof n=="object"&&typeof n.auth=="string"){let r=n.auth.toLowerCase();if(r==="oauth"||r==="api")return r}return null}function ve(e){if(!e||typeof e!="object")return null;let o=e.agent;if(!o)return null;if(typeof o=="string")return Q[o]?o:null;if(typeof o=="object"){if(typeof o.provider=="string"&&Q[o.provider])return o.provider;for(let t of Object.keys(o))if(Q[t])return t}return null}function so(e){if(!e)return null;let o=be(e,".zibby-deploy.json");if(!oo(o))return null;try{let t=JSON.parse(to(o,"utf-8"));if(typeof t?.uuid=="string"&&t.uuid)return t.uuid}catch{}return null}function io(e,o,t){let r=(pt[e]||[]).slice().sort((i,s)=>t&&i.kind===t&&s.kind!==t?-1:t&&s.kind===t&&i.kind!==t?1:0);for(let i of r){let s=o?.[i.localVar];if(typeof s=="string"&&s.trim())return{...i,value:s.trim()}}return null}function co(e,o,{readConfig:t=he}={}){let n=t()||{},r=n.agentKeys&&typeof n.agentKeys=="object"?n.agentKeys:{};return io(e,r,o)}async function dt({apiUrl:e,sessionToken:o,uuid:t,fetchImpl:n}){let r=await n(N(e,t),{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`}});if(!r.ok)throw new Error(`GET /workflows/${t}/env \u2192 HTTP ${r.status}`);let i=await r.json();return Array.isArray(i?.keys)?i.keys:[]}function gt(e,o){if(!e?.length)return!1;try{let t=V(e);return o.some(n=>Object.prototype.hasOwnProperty.call(t,n)&&typeof t[n]=="string"&&t[n].trim().length>0)}catch{return!1}}async function ao({workflowAgent:e,workflowUuid:o,authChoice:t,envFiles:n=[],sessionToken:r,apiUrl:i,fetchImpl:s=globalThis.fetch,readConfig:c=he}){if(!e)return{status:"error",detail:"workflowAgent unresolved (no agent in .zibby.config.mjs)"};let u=ft[e];if(!u)return{status:"error",detail:`unknown agent: ${e}`};if(!r||!i)return{status:"error",detail:"missing sessionToken or apiUrl"};if(o)try{let d=await dt({apiUrl:i,sessionToken:r,uuid:o,fetchImpl:s}),E=u.find(v=>d.includes(v));if(E)return{status:"ok-already-set",acceptedVars:u,matchedVar:E}}catch(d){if(!/HTTP 404/.test(d.message))return{status:"error",detail:d.message}}if(gt(n,u))return{status:"ok-via-env-flag",acceptedVars:u};let l=co(e,t,{readConfig:c});return l?{status:"mismatch-can-upload",acceptedVars:u,candidate:l}:{status:"mismatch-no-local",acceptedVars:u}}function yt({uploadAs:e,value:o}){return $e({[e]:o})}function $e(e){let o=be(lt(),`zibby-creds-${ut(8).toString("hex")}.env`),t=Object.entries(e).map(([r,i])=>{let s=String(i);return/[\s"'={}[\]:,]/.test(s)?`${r}='${s.replace(/'/g,"'\\''")}'`:`${r}=${s}`});st(o,`${t.join(`
|
|
19
19
|
`)}
|
|
20
|
-
`,"utf-8");try{it(o,384)}catch{}let n=()=>{try{ct(o)}catch{}};return process.on("exit",n),process.on("SIGINT",()=>{n(),process.exit(130)}),o}function ht({workflowAgent:e,acceptedVars:o,projectId:t,log:n}){n(
|
|
20
|
+
`,"utf-8");try{it(o,384)}catch{}let n=()=>{try{ct(o)}catch{}};return process.on("exit",n),process.on("SIGINT",()=>{n(),process.exit(130)}),o}function ht({workflowAgent:e,acceptedVars:o,projectId:t,log:n}){n(m.red(` \u2716 No local ${e} credentials found to upload.`)),n(m.red(` Cloud Fargate needs ${o.join(" or ")} in this workflow's env.`)),n(""),n(m.yellow(" Pick one:")),e==="claude"?(n(m.yellow(" A. Set up Claude OAuth (no API costs):")),n(m.gray(" 1. claude (the CLI from @anthropic-ai/claude-code) \u2192 log in, quit")),n(m.gray(" 2. zibby init -f # picks up the token")),n(m.gray(" 3. zibby workflow deploy <name> # we'll upload it")),n(m.yellow(" B. Buy a Claude API key (pay-per-token):")),n(m.gray(" https://console.anthropic.com/settings/keys")),n(m.gray(" zibby workflow env set <uuid> ANTHROPIC_API_KEY=sk-ant-..."))):(n(m.yellow(` A. Get an API key for ${e}:`)),n(m.gray(` zibby workflow env set <uuid> ${o[0]}=<your-key>`))),n(m.yellow(" C. Skip this gate (deploy WILL fail at trigger time):")),n(m.gray(" zibby workflow deploy <name> --no-creds-check")),n(m.gray(" (or set the project-level key at")),n(m.gray(` https://studio.zibby.dev/projects/${t}/settings)`)),n("")}async function mt({userConfig:e,workflowDir:o,projectId:t,sessionToken:n,apiUrl:r,deployOptions:i,fetchImpl:s,readConfig:c,prompt:u,log:l=console.log,writeTempBag:d=$e,readFullBlob:E=no}){let v=ve(e);if(!v)return{proceed:!0};let h=ro(e),$=so(o),k=Array.isArray(i?.env)?i.env:[],a=await ao({workflowAgent:v,workflowUuid:$,authChoice:h,envFiles:k,sessionToken:n,apiUrl:r,fetchImpl:s,readConfig:c});switch(a.status){case"ok-already-set":return{proceed:!0};case"ok-via-env-flag":return{proceed:!0};case"mismatch-can-upload":{let{candidate:p}=a,x=u||(async({message:P})=>{let{proceed:Y}=await nt.prompt([{type:"confirm",name:"proceed",message:P,default:!0}]);return Y}),R=p.kind==="oauth"?"OAuth token":"API key",O=`Cloud workflow has no ${v} credentials. Upload your local ${R} (${p.uploadAs})?`,S;try{S=await x({message:O})}catch{S=!1}if(!S)return l(m.yellow(` \u26A0 Deploying without ${p.uploadAs} on the workflow.`)),l(m.yellow(" Trigger will fail until you set it manually:")),l(m.gray(` zibby workflow env set <uuid> ${p.uploadAs}=<your-token>`)),{proceed:!0};let j,_="";if(v==="claude"&&p.kind==="oauth"){let P=E();P&&P.accessToken?(j={CLAUDE_CODE_CREDENTIALS_JSON:JSON.stringify({claudeAiOauth:P}),CLAUDE_CODE_OAUTH_TOKEN:P.accessToken},_=" (full Keychain blob \u2014 accessToken + refreshToken + expiresAt + scopes)"):j={CLAUDE_CODE_OAUTH_TOKEN:p.value}}else j={[p.uploadAs]:p.value};let D=d(j);return i&&(Array.isArray(i.env)||(i.env=[]),i.env.push(D)),l(m.green(` \u2713 Will upload ${R}${_} to workflow env after deploy.`)),{proceed:!0,addedEnvFile:D}}case"mismatch-no-local":return ht({workflowAgent:v,acceptedVars:a.acceptedVars,projectId:t,log:l}),{proceed:!1};default:return l(m.gray(` (skipped cloud-creds sanity check: ${a.detail||"unknown error"})`)),{proceed:!0}}}var ft,pt,uo=L(()=>{Qe();ke();ft={claude:["ANTHROPIC_API_KEY","CLAUDE_CODE_OAUTH_TOKEN"],cursor:["CURSOR_API_KEY"],codex:["OPENAI_API_KEY"],gemini:["GOOGLE_API_KEY"]};pt={claude:[{localVar:"ANTHROPIC_API_KEY",uploadAs:"ANTHROPIC_API_KEY",kind:"api"},{localVar:"CLAUDE_CODE_OAUTH_TOKEN",uploadAs:"CLAUDE_CODE_OAUTH_TOKEN",kind:"oauth"}],cursor:[{localVar:"CURSOR_API_KEY",uploadAs:"CURSOR_API_KEY",kind:"api"}],codex:[{localVar:"OPENAI_API_KEY",uploadAs:"OPENAI_API_KEY",kind:"api"}],gemini:[{localVar:"GEMINI_API_KEY",uploadAs:"GOOGLE_API_KEY",kind:"api"},{localVar:"GOOGLE_API_KEY",uploadAs:"GOOGLE_API_KEY",kind:"api"}]}});var fo={};_e(fo,{listEnvCommand:()=>wt,pushEnvCommand:()=>vt,setEnvCommand:()=>kt,syncEnvFromFiles:()=>$t,unsetEnvCommand:()=>bt});import b from"chalk";import oe from"ora";async function te(e){let{sessionToken:o,apiKey:t}=await X({apiKey:e.apiKey}),n=o||t;return n||(console.log(b.red("\n Not authenticated \u2014 run `zibby login` or pass --api-key.\n")),process.exit(1)),{authToken:n,apiUrl:T()}}async function ne(e,o,t,n,r){let i={method:e,headers:{Authorization:`Bearer ${t}`,...n?{"Content-Type":"application/json"}:{}},...n?{body:JSON.stringify(n)}:{}},s;try{s=await fetch(o,i)}catch(u){r&&r.fail(`Network error: ${u.message}`),process.exit(1)}let c;try{c=await s.json()}catch{c={}}return s.ok||(r?r.fail(c.error||c.message||`HTTP ${s.status}`):console.log(b.red(`
|
|
21
21
|
${c.error||c.message||`HTTP ${s.status}`}
|
|
22
|
-
`)),process.exit(1)),c}async function wt(e,o={}){e||(console.log(
|
|
23
|
-
Workflow UUID is required`)),console.log(
|
|
24
|
-
`)),process.exit(1));let{authToken:t,apiUrl:n}=await
|
|
25
|
-
Last updated: ${i.envUpdatedAt}`)),console.log("")}async function kt(e,o,t={}){(!e||!o)&&(console.log(
|
|
26
|
-
Both UUID and KEY=value are required`)),console.log(
|
|
27
|
-
`)),process.exit(1));let n,r;try{({key:n,value:r}=eo(o))}catch(d){console.log(
|
|
22
|
+
`)),process.exit(1)),c}async function wt(e,o={}){e||(console.log(b.red(`
|
|
23
|
+
Workflow UUID is required`)),console.log(b.gray(` Usage: zibby workflow env list <uuid>
|
|
24
|
+
`)),process.exit(1));let{authToken:t,apiUrl:n}=await te(o),r=oe(`Fetching env keys for ${e}...`).start(),i=await ne("GET",N(n,e),t,null,r),s=i.keys||[];r.succeed(`${s.length} env var${s.length===1?"":"s"} on workflow ${e}`),console.log(""),console.log(we(s)),i.envUpdatedAt&&console.log(b.gray(`
|
|
25
|
+
Last updated: ${i.envUpdatedAt}`)),console.log("")}async function kt(e,o,t={}){(!e||!o)&&(console.log(b.red(`
|
|
26
|
+
Both UUID and KEY=value are required`)),console.log(b.gray(` Usage: zibby workflow env set <uuid> KEY=value
|
|
27
|
+
`)),process.exit(1));let n,r;try{({key:n,value:r}=eo(o))}catch(d){console.log(b.red(`
|
|
28
28
|
${d.message}
|
|
29
|
-
`)),process.exit(1)}let{authToken:i,apiUrl:s}=await
|
|
30
|
-
Both UUID and KEY are required`)),console.log(
|
|
31
|
-
`)),process.exit(1)),
|
|
29
|
+
`)),process.exit(1)}let{authToken:i,apiUrl:s}=await te(t),c=oe(`Setting ${n} on workflow ${e}...`).start(),l=((await ne("PATCH",N(s,e,n),i,{value:r},c)).keys||[]).length;c.succeed(`Set ${b.cyan(n)} (workflow now has ${l} env var${l===1?"":"s"})`)}async function bt(e,o,t={}){(!e||!o)&&(console.log(b.red(`
|
|
30
|
+
Both UUID and KEY are required`)),console.log(b.gray(` Usage: zibby workflow env unset <uuid> KEY
|
|
31
|
+
`)),process.exit(1)),ee(o)||(console.log(b.red(`
|
|
32
32
|
Invalid env var name "${o}"
|
|
33
|
-
`)),process.exit(1));let{authToken:n,apiUrl:r}=await
|
|
34
|
-
Workflow UUID is required`)),console.log(
|
|
35
|
-
`)),process.exit(1));let t=Array.isArray(o.file)?o.file:o.file?[o.file]:[];t.length===0&&(console.log(
|
|
36
|
-
At least one --file is required`)),console.log(
|
|
37
|
-
`)),process.exit(1));let n;try{n=
|
|
33
|
+
`)),process.exit(1));let{authToken:n,apiUrl:r}=await te(t),i=oe(`Unsetting ${o} on workflow ${e}...`).start(),s=await ne("DELETE",N(r,e,o),n,null,i),c=(s.keys||[]).length;s.removed?i.succeed(`Unset ${b.cyan(o)} (workflow now has ${c} env var${c===1?"":"s"})`):i.warn(`Key ${b.cyan(o)} was not set on workflow ${e} \u2014 nothing to do`)}async function vt(e,o={}){e||(console.log(b.red(`
|
|
34
|
+
Workflow UUID is required`)),console.log(b.gray(` Usage: zibby workflow env push <uuid> --file .env [--file .env.prod]
|
|
35
|
+
`)),process.exit(1));let t=Array.isArray(o.file)?o.file:o.file?[o.file]:[];t.length===0&&(console.log(b.red(`
|
|
36
|
+
At least one --file is required`)),console.log(b.gray(` Usage: zibby workflow env push <uuid> --file .env
|
|
37
|
+
`)),process.exit(1));let n;try{n=V(t)}catch(u){console.log(b.red(`
|
|
38
38
|
${u.message}
|
|
39
|
-
`)),process.exit(1)}let r=Object.keys(n);r.length===0&&(console.log(
|
|
39
|
+
`)),process.exit(1)}let r=Object.keys(n);r.length===0&&(console.log(b.yellow(`
|
|
40
40
|
No env vars found in ${t.join(", ")} \u2014 nothing to push.
|
|
41
|
-
`)),process.exit(0));let{authToken:i,apiUrl:s}=await
|
|
41
|
+
`)),process.exit(0));let{authToken:i,apiUrl:s}=await te(o),c=oe(`Pushing ${r.length} env var${r.length===1?"":"s"} to ${e}...`).start();await ne("PUT",N(s,e),i,{env:n},c),c.succeed(`Pushed ${r.length} env var${r.length===1?"":"s"} from ${t.join(", ")}`),console.log(""),console.log(we(r)),console.log("")}async function $t({uuid:e,files:o,authToken:t,apiUrl:n,spinner:r}){let i=V(o),s=Object.keys(i);if(s.length===0)return{count:0,files:o};let c=N(n,e),u={method:"PUT",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({env:i})},l=await fetch(c,u);if(!l.ok){let d=await l.json().catch(()=>({}));throw new Error(`Env push failed: ${d.error||d.message||`HTTP ${l.status}`}`)}return r&&(r.text=`Synced ${s.length} env var${s.length===1?"":"s"} to workflow`),{count:s.length,files:o}}var po=L(()=>{ye();W();ke()});import{existsSync as U,readFileSync as Ae,writeFileSync as At}from"fs";import{join as I}from"path";import w from"chalk";import re from"ora";import Et from"dotenv";import{select as go}from"@inquirer/prompts";import{existsSync as Eo}from"fs";import{join as xo}from"path";import{pathToFileURL as jo}from"url";async function Se(e){let o=xo(e,".zibby.config.mjs");if(!Eo(o))throw new Error(".zibby.config.mjs not found");try{let t=await import(jo(o).href);return t.default||t}catch(t){throw new Error(`Failed to load .zibby.config.mjs: ${t.message}`,{cause:t})}}W();import{createHash as Ue}from"crypto";import{readFileSync as Io,readdirSync as _o,statSync as ae,existsSync as So}from"fs";import{join as le,sep as Uo}from"path";function Pe(e){let o=Po(e);o.sort((n,r)=>n.rel<r.rel?-1:n.rel>r.rel?1:0);let t=Ue("sha256");for(let{rel:n,abs:r}of o){let i=Ue("sha256").update(Io(r)).digest("hex");t.update(`${n}
|
|
42
42
|
${i}
|
|
43
|
-
`)}return t.digest("hex")}function Po(e){let o=new Set(["node_modules",".git","dist",".zibby"]),t=new Set(["graph.mjs","package.json","package-lock.json","workflow.json","zibby.config.json","zibby.config.mjs"]),n=new Set([".zibby-deploy.json",".DS_Store"]),r=[];if(!So(e))return r;function i(s,c){let u=c.split("/").pop();n.has(u)||(t.has(u)||/\.(mjs|js)$/.test(u))&&r.push({rel:c,abs:s})}for(let s of ue(e)){let c=le(e,s),u;try{u=ae(c)}catch{continue}u.isFile()&&i(c,s)}for(let s of ue(e)){if(o.has(s))continue;let c=le(e,s),u;try{u=ae(c)}catch{continue}if(u.isDirectory())for(let l of ue(c)){let d=le(c,l)
|
|
44
|
-
`);continue}
|
|
45
|
-
`)}if(i.text=fe({elapsedMs:Date.now()-c,phase:l,step:d})
|
|
43
|
+
`)}return t.digest("hex")}function Po(e){let o=new Set(["node_modules",".git","dist",".zibby"]),t=new Set(["graph.mjs","package.json","package-lock.json","workflow.json","zibby.config.json","zibby.config.mjs"]),n=new Set([".zibby-deploy.json",".DS_Store"]),r=[];if(!So(e))return r;function i(s,c){let u=c.split("/").pop();n.has(u)||(t.has(u)||/\.(mjs|js)$/.test(u))&&r.push({rel:c,abs:s})}for(let s of ue(e)){let c=le(e,s),u;try{u=ae(c)}catch{continue}u.isFile()&&i(c,s)}for(let s of ue(e)){if(o.has(s))continue;let c=le(e,s),u;try{u=ae(c)}catch{continue}if(u.isDirectory())for(let l of ue(c)){let d=le(c,l),E;try{E=ae(d)}catch{continue}if(!E.isFile())continue;let v=`${s}/${l}`.split(Uo).join("/");i(d,v)}}return r}function ue(e){try{return _o(e)}catch{return[]}}function Te(e,o){return e?.uuid||e?.workflowUuid||o?.uuid||null}var To=4;function fe({elapsedMs:e,phase:o,step:t}){let r=` \u2014 ${Math.max(0,Math.floor(e/1e3))}s`;return t?`Building bundle on Zibby Cloud... [${t.n}/${To}] ${t.label}${r}`:o?`Building bundle on Zibby Cloud... (${o.toLowerCase()})${r}`:`Building bundle on Zibby Cloud...${r}`}var Oo=/\[(\d+)\/\d+\]\s+(.+?)\s*\.{0,3}\s*$/;function Oe(e){if(!e)return null;let o=Oo.exec(e);if(!o)return null;let t=parseInt(o[1],10);return!Number.isInteger(t)||t<1?null:{n:t,label:o[2].trim()}}function Ce(){let e=!1;return function(t){if(!t)return!0;let n=t.replace(/\s+$/,"");if(e)return/^\s*"\s*$/.test(n)&&(e=!1),!0;if(!Co(t))return!1;let r=n.replace(/^\[Container\]\s+\d{4}\/\d{2}\/\d{2}\s+\d{2}:\d{2}:\d{2}\.\d+\s*/,"");return r.startsWith("Running command ")&&(r.match(/"/g)||[]).length%2===1&&(e=!0),!0}}function Co(e){if(!e)return!0;let t=e.trim().replace(/^\[Container\]\s+\d{4}\/\d{2}\/\d{2}\s+\d{2}:\d{2}:\d{2}\.\d+\s*/,"");return!!(/^Phase complete:/.test(t)||/^Phase context status code:/.test(t)||/^Entering phase /.test(t)||/^Running command /.test(t)||/^Phase is /.test(t)||/^Waiting for /.test(t)||/^Registering with agent$/.test(t)||/^Running on CodeBuild /.test(t)||/^Phases found in YAML:/.test(t)||/^CODEBUILD_SRC_DIR=/.test(t)||/^YAML location is /.test(t)||/^Processing environment variables$/.test(t)||/^Moving to directory /.test(t)||/^Cache is not defined /.test(t)||/^Skip cache due to:/.test(t)||/^\s*INSTALL: \d+ commands?$/.test(t)||/^\s*BUILD: \d+ commands?$/.test(t)||/^Set report auto-discover timeout/.test(t)||/^Expanding /.test(t)||/^Assembling file list$/.test(t)||/^No matching auto-discover/.test(t)||/^Report auto-discover/.test(t)||t==="")}function Le({uuid:e,name:o,projectId:t,result:n,existingManifest:r=null,now:i=()=>new Date().toISOString()}){let s=n?.version??(r?.version??0)+1;return{uuid:e,name:o,projectId:t,version:s,deployedAt:i()}}ye();Et.config();async function xt({apiUrl:e,projectId:o,workflowName:t,buildId:n,authToken:r,spinner:i,verbose:s}){let c=Date.now(),u,l=null,d=null,E=Ce(),v=setInterval(()=>{i.text=fe({elapsedMs:Date.now()-c,phase:l,step:d})},1e3);try{for(;;){let h=new URL(`${e}/projects/${o}/workflows/${t}/build/${n}`);u&&h.searchParams.set("logsToken",u);let $;try{let k=await fetch(h,{headers:{Authorization:`Bearer ${r}`}});if(!k.ok)throw new Error(`HTTP ${k.status}`);$=await k.json()}catch{await new Promise(a=>setTimeout(a,2e3));continue}$.phase&&$.phase!==l&&(l=$.phase),$.nextLogsToken&&$.nextLogsToken!==u&&(u=$.nextLogsToken);for(let k of $.logEvents||[]){let a=String(k.m||"").trimEnd();if(!a)continue;let p=Oe(a);if(p&&(d=p),s){process.stdout.write(` ${a}
|
|
44
|
+
`);continue}E(a)||p||process.stdout.write(` ${a}
|
|
45
|
+
`)}if(i.text=fe({elapsedMs:Date.now()-c,phase:l,step:d}),$.done){let k=(Date.now()-c)/1e3;return{status:$.status,elapsedSec:k,lastPhase:l}}await new Promise(k=>setTimeout(k,2e3))}}finally{clearInterval(v)}}async function jt(e,o){let t=T(),n=re("Fetching projects...").start();try{let r=o||e,i=await fetch(`${t}/projects`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`}});i.ok||(n.fail("Failed to fetch projects"),process.exit(1));let s=await i.json();Array.isArray(s)||(s.projects&&Array.isArray(s.projects)?s=s.projects:s.data&&Array.isArray(s.data)?s=s.data:(n.fail("Unexpected response format"),process.exit(1))),(!s||s.length===0)&&(n.fail("No projects found"),process.exit(1)),n.succeed(`Found ${s.length} project${s.length===1?"":"s"}`),console.log("");let c=s.map(l=>{let d=l.projectId||l.id||l._id||"unknown";return{name:`${l.name||l.projectName||"Unnamed"} (${d})`,value:d}});return await go({message:"Select a project to deploy to:",choices:c})}catch(r){n.fail(`Error: ${r.message}`),process.exit(1)}}async function Zn(e,o={}){let t=process.cwd(),n=".zibby/workflows",r=null;try{r=await Se(t),n=r?.paths?.workflows||".zibby/workflows"}catch{}if(e){let a=I(t,n,e);U(a)||(console.log(`
|
|
46
46
|
Error: Workflow not found: ${n}/${e}/`),console.log(" Run `zibby workflow list` to see local workflows,"),console.log(` or scaffold a new one: zibby workflow new ${e}
|
|
47
|
-
`),process.exit(1))}else{let a=
|
|
47
|
+
`),process.exit(1))}else{let a=I(t,n);U(a)||(console.log(`
|
|
48
48
|
Error: No workflows found in ${n}/`),console.log(` Create one with: zibby workflow new <name>
|
|
49
|
-
`),process.exit(1));let{readdir:p,stat:
|
|
49
|
+
`),process.exit(1));let{readdir:p,stat:x}=await import("fs/promises"),R=await p(a),O=[];for(let S of R){let j=I(a,S);if(!(await x(j)).isDirectory())continue;(U(I(j,"graph.mjs"))||U(I(j,"graph.js")))&&O.push(S)}O.length===0&&(console.log(`
|
|
50
50
|
Error: No workflows found in ${n}/`),console.log(` Create one with: zibby workflow new <name>
|
|
51
|
-
`),process.exit(1)),console.log(""),e=await go({message:"Select a workflow to deploy:",choices:O.map(S=>({name:S,value:S}))})}let{sessionToken:i,apiKey:s}=await
|
|
52
|
-
Error: graph.mjs not found in ${n}/${e}/`),process.exit(1));let
|
|
51
|
+
`),process.exit(1)),console.log(""),e=await go({message:"Select a workflow to deploy:",choices:O.map(S=>({name:S,value:S}))})}let{sessionToken:i,apiKey:s}=await X({apiKey:o.apiKey}),c=o.project||process.env.ZIBBY_PROJECT_ID;c||(console.log(""),c=await jt(s,i));let u=i||s,l=I(t,n,e),d=I(l,"graph.mjs"),E=I(l,"workflow.json");U(d)||(console.log(`
|
|
52
|
+
Error: graph.mjs not found in ${n}/${e}/`),process.exit(1));let v=(()=>{try{return Pe(l)}catch(a){return console.log(w.gray(` (checksum skipped: ${a.message})`)),null}})();if(!o.force&&v)try{let a=T(),p=await fetch(`${a}/projects/${c}/workflows/${e}`,{headers:{Authorization:`Bearer ${u}`}});if(p.ok){let x=await p.json();if(x&&x.sourceChecksum===v){console.log(""),console.log(` ${w.green("\u2713")} ${e} unchanged \u2014 skipping deploy (use --force to override)`),console.log("");return}}}catch(a){console.log(w.gray(` (checksum lookup failed: ${a.message} \u2014 proceeding with deploy)`))}if(o.credsCheck!==!1)try{let{runCloudCredsCheck:a}=await Promise.resolve().then(()=>(uo(),lo));(await a({userConfig:r,workflowDir:l,projectId:c,sessionToken:u,apiUrl:T(),deployOptions:o})).proceed||(console.log(""),process.exit(1))}catch(a){console.log(w.gray(` (creds-check skipped: ${a.message})`))}console.log(`
|
|
53
53
|
Deploying Workflow
|
|
54
|
-
`),console.log(" ".padEnd(60,"-")),console.log(` Workflow: ${e}`),console.log(` Project: ${c}`),console.log(" ".padEnd(60,"-")),console.log("");let
|
|
55
|
-
`),process.exit(1)}let yo=await
|
|
56
|
-
`),process.exit(1)}
|
|
57
|
-
`)
|
|
58
|
-
`,"utf-8")}catch(
|
|
59
|
-
`)}}catch(
|
|
60
|
-
`))}}console.log(""),C&&console.log(` UUID: ${C}`),console.log(""),console.log(" Next steps:"),console.log(` zibby workflow run ${e} Run locally`),C&&console.log(` zibby workflow trigger ${C} Run in cloud`),console.log(" zibby workflow list View all workflows"),console.log("")}catch(a){
|
|
54
|
+
`),console.log(" ".padEnd(60,"-")),console.log(` Workflow: ${e}`),console.log(` Project: ${c}`),console.log(" ".padEnd(60,"-")),console.log("");let h=re("Validating workflow...").start(),$=Ae(d,"utf-8");if($.includes("@zibby/core")||$.includes("@zibby/skills")){let a=I(l,"package.json");U(a)||(h.fail("Missing package.json"),console.log(""),console.log(w.red(" \u2717 graph.mjs imports @zibby packages but no package.json found")),console.log(""),console.log(w.yellow(" Create package.json with:")),console.log(""),console.log(w.gray(" {")),console.log(w.gray(' "type": "module",')),console.log(w.gray(' "dependencies": {')),console.log(w.gray(' "@zibby/core": "workspace:*"')),console.log(w.gray(" }")),console.log(w.gray(" }")),console.log(""),process.exit(1));let p=JSON.parse(Ae(a,"utf-8"));!{...p.dependencies,...p.devDependencies}["@zibby/core"]&&$.includes("@zibby/core")&&(h.fail("Missing @zibby/core dependency"),console.log(""),console.log(w.red(" \u2717 graph.mjs imports @zibby/core but it's not in package.json")),console.log(""),console.log(w.yellow(" Add to package.json dependencies:")),console.log(w.gray(' "@zibby/core": "workspace:*"')),console.log(""),process.exit(1))}h.text="Loading workflow graph...";try{let{pathToFileURL:a}=await import("url"),p=await import(a(d).href),x;if(p.default)if(typeof p.default=="function"){let f=p.default.prototype;f&&f.buildGraph?x=new p.default:x=p.default()}else h.fail("graph.mjs must export a class or factory function"),process.exit(1);else{let f=Object.values(p).find(g=>g.prototype&&g.prototype.buildGraph);f?x=new f:(h.fail("graph.mjs must export a WorkflowAgent class or factory function"),process.exit(1))}let O=x.buildGraph().serialize(),{readdir:S,readFile:j}=await import("fs/promises"),_={};h.text="Packaging workflow sources...";let D=await j(d,"utf-8");if(_["graph.mjs"]=D,U(E)){let f=await j(E,"utf-8");_["workflow.json"]=f}let P=I(l,"nodes");if(U(P)){let f=await S(P);for(let g of f)if(g.endsWith(".mjs")||g.endsWith(".js")){let A=I(P,g),G=await j(A,"utf-8");_[`nodes/${g}`]=G}}let Y=I(l,"package.json");if(U(Y)){let f=await j(Y,"utf-8");_["package.json"]=f,h.text="Including package.json for dependencies..."}let Ee=I(l,"package-lock.json");if(U(Ee)){let f=await j(Ee,"utf-8");_["package-lock.json"]=f}r&&typeof r=="object"&&(_["zibby.config.json"]=JSON.stringify(r,null,2)),h.text=`Uploading to cloud (${O.nodes.size||Object.keys(O.nodes||{}).length} nodes, ${Object.keys(_).length} files)...`;let F=T(),xe=JSON.stringify({format:1,sources:_}),je=Buffer.byteLength(xe,"utf8"),J=await fetch(`${F}/projects/${c}/workflows/${e}/sources/presign`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify({contentLength:je})});if(!J.ok){let f=await J.json().catch(()=>({}));h.fail("Deploy failed (presign)"),console.log(` Error: ${f.error||f.message||J.statusText}
|
|
55
|
+
`),process.exit(1)}let yo=await J.json(),{uploadUrl:ho,key:mo,headers:wo}=yo,se=await fetch(ho,{method:"PUT",headers:{...wo||{},"Content-Length":String(je)},body:xe});if(!se.ok){let f=await se.text().catch(()=>"");h.fail("Deploy failed (S3 upload)"),console.log(` S3 PUT failed: ${se.status} ${f.slice(0,200)}
|
|
56
|
+
`),process.exit(1)}h.text="Saving workflow definition...";let z=await fetch(`${F}/projects/${c}/workflows/${e}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify({graph:O,sourcesStagingKey:mo,isDefault:!1,...v?{sourceChecksum:v}:{},...typeof o.warm=="number"?{warmEnabled:!0,warmCount:o.warm}:o.warm===!1?{warmEnabled:!1,warmCount:0}:{}})});if(!z.ok){let f=await z.json().catch(()=>({})),g=f.message||f.error||z.statusText;if(h.fail(`Deploy failed (${z.status})`),console.log(""),z.status===402){let A=g.match(/(https?:\/\/\S+)/),G=A?g.replace(A[0],"").replace(/Upgrade at\s*$/i,"").trim():g;console.log(` \u{1F4B3} ${w.yellow("Payment required")}`),console.log(""),console.log(` ${G}`),A&&(console.log(""),console.log(` Upgrade: ${w.cyan(A[0])}`)),console.log("")}else console.log(` Error: ${g}
|
|
57
|
+
`);process.exit(1)}let ie=await z.json(),Z=I(l,".zibby-deploy.json"),ce=U(Z)?(()=>{try{return JSON.parse(Ae(Z,"utf-8"))}catch{return null}})():null,C=Te(ie,ce);if(C){let f=Le({uuid:C,name:e,projectId:c,result:ie,existingManifest:ce});try{At(Z,`${JSON.stringify(f,null,2)}
|
|
58
|
+
`,"utf-8")}catch(g){console.log(` Warning: failed to write ${Z}: ${g.message}`)}}let ko=ce?"Updated":"Deployed";if(h.succeed(`${ko} ${e} (v${ie.version||1})`),typeof o.warm=="number"?console.log(` ${w.cyan("\u25CF")} Warm pool: ${o.warm} task${o.warm===1?"":"s"} (paid feature \u2014 provisioning may take ~60s)`):o.warm===!1&&console.log(` ${w.gray("\u25CB")} Warm pool: disabled (workflow uses default cold-start path)`),!(o.noWait===!0||process.env.ZIBBY_DEPLOY_NO_BUNDLE==="1")){console.log("");let f=re("Building bundle on Zibby Cloud...").start();try{let g=await fetch(`${F}/projects/${c}/workflows/${e}/build`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`}});if(g.ok){let A=await g.json(),{buildId:G}=A,bo=o.verbose===!0||process.env.ZIBBY_DEPLOY_VERBOSE==="1",{status:Ie,elapsedSec:vo,lastPhase:$o}=await xt({apiUrl:F,projectId:c,workflowName:e,buildId:G,authToken:u,spinner:f,verbose:bo});Ie==="SUCCEEDED"?f.succeed(`Bundle ready (${vo.toFixed(1)}s) \u2014 runtime npm install eliminated`):f.warn(`Bundle build ${Ie} at phase ${$o||"unknown"} \u2014 workflow will fall back to runtime install`)}else{let A=await g.json().catch(()=>({}));f.warn(`Bundle build skipped: ${A.error||A.message||g.statusText}`),console.log(` Workflow will use slower runtime install path until next deploy.
|
|
59
|
+
`)}}catch(g){f.warn(`Bundle build error: ${g.message}`)}}let K=Array.isArray(o.env)?o.env:o.env?[o.env]:[];if(K.length>0)if(!C)console.log(w.yellow(" Skipping --env sync: deploy did not return a workflow UUID."));else{console.log("");let f=re(`Syncing env from ${K.join(", ")}...`).start();try{let{syncEnvFromFiles:g}=await Promise.resolve().then(()=>(po(),fo)),{count:A}=await g({uuid:C,files:K,authToken:u,apiUrl:F,spinner:f});A===0?f.warn(`No env vars found in ${K.join(", ")} \u2014 workflow env unchanged.`):f.succeed(`Synced ${A} env var${A===1?"":"s"} from ${K.join(", ")}`)}catch(g){f.fail(`Env sync failed: ${g.message}`),console.log(w.gray(` Re-run after fixing: zibby workflow env push ${C} ${K.map(A=>`--file ${A}`).join(" ")}
|
|
60
|
+
`))}}console.log(""),C&&console.log(` UUID: ${C}`),console.log(""),console.log(" Next steps:"),console.log(` zibby workflow run ${e} Run locally`),C&&console.log(` zibby workflow trigger ${C} Run in cloud`),console.log(" zibby workflow list View all workflows"),console.log("")}catch(a){h.fail("Deploy failed"),console.log(` Error: ${a.message}
|
|
61
61
|
`),process.exit(1)}}export{Zn as deployWorkflowCommand};
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zibby/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "Zibby CLI - Test automation generator and runner",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "node ../scripts/build.mjs --extra-dirs bin",
|
|
11
|
-
"test": "vitest run test/auth*.test.js test/two-layer-auth.test.js test/trigger-params.test.js test/trigger-helpers.test.js test/deploy-helpers.test.js test/deploy-bundles-user-config.test.js test/deploy-skip-unchanged.test.js test/run-loads-user-config.test.js test/env-helpers.test.js test/env-cli.test.js test/chat-agents.test.js test/chat-agents-api.test.js test/chat-agents-picker.test.js test/chat-sandbox-attach.test.js test/credentials-file.test.js test/credentials-api.test.js test/credentials-loader.test.js test/cli-namespace-consistency.test.js test/cli-workflow-subcommands.test.js test/run-bundle-core-import.test.js test/start-respects-config.test.js test/sse-backoff.test.js test/sse-reconnect-loop.test.js test/run-helpers.test.js test/run-banner.test.js test/run-banner-e2e.test.js test/sse-parser.test.js test/cloud-creds-check.test.js",
|
|
11
|
+
"test": "vitest run test/auth*.test.js test/two-layer-auth.test.js test/trigger-params.test.js test/trigger-helpers.test.js test/deploy-helpers.test.js test/deploy-bundles-user-config.test.js test/deploy-skip-unchanged.test.js test/deploy-warm-flag.test.js test/deploy-402-formatter.test.js test/run-loads-user-config.test.js test/env-helpers.test.js test/env-cli.test.js test/chat-agents.test.js test/chat-agents-api.test.js test/chat-agents-picker.test.js test/chat-sandbox-attach.test.js test/credentials-file.test.js test/credentials-api.test.js test/credentials-loader.test.js test/cli-namespace-consistency.test.js test/cli-workflow-subcommands.test.js test/run-bundle-core-import.test.js test/start-respects-config.test.js test/sse-backoff.test.js test/sse-reconnect-loop.test.js test/run-helpers.test.js test/run-banner.test.js test/run-banner-e2e.test.js test/sse-parser.test.js test/cloud-creds-check.test.js",
|
|
12
12
|
"test:unit": "vitest run src/",
|
|
13
13
|
"test:auth": "vitest run test/auth*.test.js test/two-layer-auth.test.js",
|
|
14
14
|
"lint": "eslint .",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zibby/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "Zibby CLI - Test automation generator and runner",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "node ../scripts/build.mjs --extra-dirs bin",
|
|
11
|
-
"test": "vitest run test/auth*.test.js test/two-layer-auth.test.js test/trigger-params.test.js test/trigger-helpers.test.js test/deploy-helpers.test.js test/deploy-bundles-user-config.test.js test/deploy-skip-unchanged.test.js test/run-loads-user-config.test.js test/env-helpers.test.js test/env-cli.test.js test/chat-agents.test.js test/chat-agents-api.test.js test/chat-agents-picker.test.js test/chat-sandbox-attach.test.js test/credentials-file.test.js test/credentials-api.test.js test/credentials-loader.test.js test/cli-namespace-consistency.test.js test/cli-workflow-subcommands.test.js test/run-bundle-core-import.test.js test/start-respects-config.test.js test/sse-backoff.test.js test/sse-reconnect-loop.test.js test/run-helpers.test.js test/run-banner.test.js test/run-banner-e2e.test.js test/sse-parser.test.js test/cloud-creds-check.test.js",
|
|
11
|
+
"test": "vitest run test/auth*.test.js test/two-layer-auth.test.js test/trigger-params.test.js test/trigger-helpers.test.js test/deploy-helpers.test.js test/deploy-bundles-user-config.test.js test/deploy-skip-unchanged.test.js test/deploy-warm-flag.test.js test/deploy-402-formatter.test.js test/run-loads-user-config.test.js test/env-helpers.test.js test/env-cli.test.js test/chat-agents.test.js test/chat-agents-api.test.js test/chat-agents-picker.test.js test/chat-sandbox-attach.test.js test/credentials-file.test.js test/credentials-api.test.js test/credentials-loader.test.js test/cli-namespace-consistency.test.js test/cli-workflow-subcommands.test.js test/run-bundle-core-import.test.js test/start-respects-config.test.js test/sse-backoff.test.js test/sse-reconnect-loop.test.js test/run-helpers.test.js test/run-banner.test.js test/run-banner-e2e.test.js test/sse-parser.test.js test/cloud-creds-check.test.js",
|
|
12
12
|
"test:unit": "vitest run src/",
|
|
13
13
|
"test:auth": "vitest run test/auth*.test.js test/two-layer-auth.test.js",
|
|
14
14
|
"lint": "eslint .",
|