@zibby/cli 0.5.3 → 0.5.5

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 CHANGED
@@ -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(b),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"),v(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(I),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: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(P),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 A({...e,viewport:o})}),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(x),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("set <provider> <token>").description("Paste-token shortcut. e.g. zibby creds set claude sk-ant-oat01-... (auto-detects oauth vs api)").option("--type <kind>","Force credential kind: oauth | api (skips auto-detect)").action(async(e,o,t)=>{const{setCmd:r}=await import("../commands/creds.js");await r(e,o,t),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("-t, --template <name>","Scaffold from a template (see `zibby template list`). Future: also accepts npm package / git URL identifiers.").option("--skip-install","Skip running `npm install` in the new workflow folder").option("--skip-init-check","Skip the first-run init prompt that fires when ~/.zibby/config.json is missing (CI/scripted setups)").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)",s,[]).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)",s,[]).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).",y).option("--ai-agent <agent>","Per-workflow AI agent override (claude | cursor | codex | gemini). Falls back to the project default when omitted.").action(async(e,o)=>{if(o.dedicatedIp){const{dedicatedEgressCommand:r}=await import("../commands/workflows/dedicated-egress.js");return r(o.dedicatedIp,o.project)}o.aiAgent&&!["claude","cursor","codex","gemini"].includes(o.aiAgent)&&(console.error(chalk.red(`Invalid --ai-agent: ${o.aiAgent}. Must be one of: claude, cursor, codex, gemini.`)),process.exit(1));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)",s,[]).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("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 h=n.command("template").description("Manage workflow templates in this project");h.command("list").description("List available workflow templates").action(async()=>{const{templateListCommand:e}=await import("../commands/template.js");return e()}),h.command("add",{hidden:!0}).argument("<name>","Template name (see `zibby template list`)").description("(deprecated \u2014 `zibby test` auto-installs the template) Copy a template into .zibby/, overwriting existing files").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 c=n.command("memory").description("Test memory database \u2014 version-controlled knowledge from runs");c.command("stats").description("Show memory database statistics").action(async()=>{const{memoryStatsCommand:e}=await import("../commands/memory.js");return e()}),c.command("init").description("Initialize the memory database (Dolt)").action(async()=>{const{memoryInitCommand:e}=await import("../commands/memory.js");return e()}),c.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)}),c.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)}),c.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 m=c.command("remote").description("Configure a remote so the team shares cross-spec memory");m.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)}),m.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)}),m.command("info").description("Show the configured memory remote (if any)").action(async()=>{const{memoryRemoteInfoCommand:e}=await import("../commands/memory.js");return e()}),m.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)}),c.command("pull").description("Pull latest team memory from the configured remote").action(async()=>{const{memoryPullCommand:e}=await import("../commands/memory.js");return e()}),c.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 J=n.command("agents").description("Manage Claude/Cursor/Codex helper files for working with Zibby workflows");J.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:r}=await import("../commands/workflows/agent-helpers.js");if(e){const l=["claude","cursor","codex","all","none"];l.includes(e)||(console.error(`Unknown agent "${e}". Valid: ${l.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 r(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("-t, --template <name>","Scaffold from a template (see `zibby template list`). Future: also accepts npm package / git URL identifiers.").option("--skip-install","Skip running `npm install` in the new workflow folder").option("--skip-init-check","Skip the first-run init prompt that fires when ~/.zibby/config.json is missing (CI/scripted setups)").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)",s,[]).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)",s,[]).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).",y).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)",s,[]).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 deployed workflow back to local (edit it, then re-deploy with `zibby workflow deploy`)").option("--dest <path>","Destination directory (default: ./workflows/<name> when run inside a .zibby project)").option("--force","Overwrite without prompting; bypass uuid-mismatch guard").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o)=>{const{downloadWorkflowCommand:t}=await import("../commands/workflows/download.js");return t(e,o)}),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("validate <name>").description("Static-check a local workflow (.zibby/workflows/<name>/). Catches schema/topology/skill errors in ~30ms before you run anything.").option("--verbose","Print stack traces on graph.mjs import errors").action(async(e,o)=>{const{validateCommand:t}=await import("../commands/workflows/validate.js");return t(e,o)}),a.command("schedule <uuid> [action] [cron]").description(`Manage a workflow's cron schedule. Actions: get (default) | set <cron> | clear. Cron is Unix 5-field, e.g. "0 9 * * 1-5".`).option("--tz <iana>","IANA timezone for the schedule (default: UTC)").option("-p, --param <key=value>","Fixed input param for every scheduled run (repeatable)",s,[]).option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o,t,r)=>{const{scheduleCommand:l}=await import("../commands/workflows/schedule.js");return l(e,o,t,r)}),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 u=a.command("env").description("Manage per-workflow encrypted env vars (set ANTHROPIC_API_KEY, DATABASE_URL, etc. per workflow)");u.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)}),u.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:r}=await import("../commands/workflows/env.js");return r(e,o,t)}),u.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:r}=await import("../commands/workflows/env.js");return r(e,o,t)}),u.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)",s,[]).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 N=n.command("project").description("Manage Zibby projects");N.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 G=n.command("run-queue").description("Parallel capacity \u2014 on-disk wait queue (see parallel.waitWhenAtCapacity in .zibby.config.mjs)");G.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)});const H=n.command("mcp").description("Manage the Zibby Remote MCP integration in your AI agent");H.command("install").description("Auto-configure Zibby MCP into your AI agent (Claude Code/Desktop, Cursor, Codex, Gemini)").option("--agent <name>","claude-code | claude-desktop | cursor | codex | gemini").option("--all","Install for every supported agent on this machine").option("--token <pat>","Use this PAT (zby_pat_\u2026) instead of minting one via session. Also reads ZIBBY_PAT env var.").option("--force","Overwrite the existing zibby block even if unchanged").action(async e=>{const{mcpInstallCommand:o}=await import("../commands/mcp.js");await o(e),process.exit(0)});const p=n.command("app").description("Manage Zibby Managed Apps \u2014 templates, deploy, list, status, destroy");p.command("templates").description("List the app catalog (n8n, grafana, gas-town, \u2026)").action(async e=>{const{appTemplatesCommand:o}=await import("../commands/app.js");return o(e)}),p.command("list").description("List deployed app instances (use --project to scope to one project)").option("--project <id>","Project ID \u2014 defaults to all instances under your account").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async e=>{const{appListCommand:o}=await import("../commands/app.js");return o(e)}),p.command("deploy [appType]").description('Deploy an app \u2014 either from the catalog (e.g. `zibby app deploy grafana --project <id>`) or a free-form install described by --goal (e.g. `zibby app deploy --goal "Install n8n at /n8n on port 5678, persist data in /data" --project <id>`). Pass exactly one of <appType> OR --goal. Catalog deploys are curated by Zibby; goal-based deploys are user-directed installs where you (not Zibby) choose what gets installed and accept the license terms of whatever you install.').option("--project <id>","Project ID (interactive prompt if not provided)").option("--goal <text>",'Free-form natural-language description of what to install (mutually exclusive with <appType>). The agent-ops bootstrap follows the description \u2014 e.g. "install n8n on port 5678 with sqlite persistence". You are responsible for the license terms of any software you install via this path.').option("--name <name>","Instance display name (defaults to appType, or first line of --goal)").option("--provider <name>",'Agent provider \u2014 "claude" (default) or "codex"').option("--arch <name>",`CPU architecture \u2014 "x86_64" or "arm64" (default = catalog's first listed arch; arm64 is ~20% greener at the same price)`).option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o)=>{const{appDeployCommand:t}=await import("../commands/app.js");return t(e,o)}),p.command("status <instanceId>").description("Show one instance: status, resources, public URL").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o)=>{const{appStatusCommand:t}=await import("../commands/app.js");return t(e,o)}),p.command("destroy <instanceId>").description("Stop + remove an app instance (interactive confirm unless --yes)").option("-y, --yes","Skip the confirmation prompt").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o)=>{const{appDestroyCommand:t}=await import("../commands/app.js");return t(e,o)}),p.command("upgrade <instanceId>").description("Roll the agent-ops container image without destroying the instance (EFS data preserved)").option("--version <tag>","Pin to a specific agent-ops version (e.g. 0.1.16). Defaults to whatever AppsFleet base task def says.").option("-y, --yes","Skip the confirmation prompt").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o)=>{const{appUpgradeCommand:t}=await import("../commands/app.js");return t(e,o)}),p.command("update-credential <instanceId>").description("Rotate the per-instance Claude credential to whatever's currently in your workspace-credentials. EFS preserved; task restarts ~30s.").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o)=>{const{appUpdateCredentialCommand:t}=await import("../commands/app.js");return t(e,o)}),p.command("logs <instanceId>").description("Show recent logs from an app instance (use -t to tail; polls every 3s)").option("-t, --follow","Tail mode \u2014 poll every 3s and print new lines as they arrive (Ctrl+C to stop)").option("--lines <n>","Max lines per fetch (default 200, max 5000)").option("--json","Print raw JSON lines (one per line) instead of parsed summary").option("--verbose","Print the full line including JSON body (default: parsed `<time> <msg>` summary)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o)=>{const{appLogsCommand:t}=await import("../commands/app.js");return t(e,o)}),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(b),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"),v(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(I),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: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(P),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 A({...e,viewport:o})}),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(x),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("set <provider> <token>").description("Paste-token shortcut. e.g. zibby creds set claude sk-ant-oat01-... (auto-detects oauth vs api)").option("--type <kind>","Force credential kind: oauth | api (skips auto-detect)").action(async(e,o,t)=>{const{setCmd:r}=await import("../commands/creds.js");await r(e,o,t),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("-t, --template <name>","Scaffold from a template (see `zibby template list`). Future: also accepts npm package / git URL identifiers.").option("--skip-install","Skip running `npm install` in the new workflow folder").option("--skip-init-check","Skip the first-run init prompt that fires when ~/.zibby/config.json is missing (CI/scripted setups)").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)",s,[]).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)",s,[]).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).",y).option("--ai-agent <agent>","Per-workflow AI agent override (claude | cursor | codex | gemini). Falls back to the project default when omitted.").action(async(e,o)=>{if(o.dedicatedIp){const{dedicatedEgressCommand:r}=await import("../commands/workflows/dedicated-egress.js");return r(o.dedicatedIp,o.project)}o.aiAgent&&!["claude","cursor","codex","gemini"].includes(o.aiAgent)&&(console.error(chalk.red(`Invalid --ai-agent: ${o.aiAgent}. Must be one of: claude, cursor, codex, gemini.`)),process.exit(1));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)",s,[]).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("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 h=n.command("template").description("Manage workflow templates in this project");h.command("list").description("List available workflow templates").action(async()=>{const{templateListCommand:e}=await import("../commands/template.js");return e()}),h.command("add",{hidden:!0}).argument("<name>","Template name (see `zibby template list`)").description("(deprecated \u2014 `zibby test` auto-installs the template) Copy a template into .zibby/, overwriting existing files").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 c=n.command("memory").description("Test memory database \u2014 version-controlled knowledge from runs");c.command("stats").description("Show memory database statistics").action(async()=>{const{memoryStatsCommand:e}=await import("../commands/memory.js");return e()}),c.command("init").description("Initialize the memory database (Dolt)").action(async()=>{const{memoryInitCommand:e}=await import("../commands/memory.js");return e()}),c.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)}),c.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)}),c.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 m=c.command("remote").description("Configure a remote so the team shares cross-spec memory");m.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)}),m.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)}),m.command("info").description("Show the configured memory remote (if any)").action(async()=>{const{memoryRemoteInfoCommand:e}=await import("../commands/memory.js");return e()}),m.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)}),c.command("pull").description("Pull latest team memory from the configured remote").action(async()=>{const{memoryPullCommand:e}=await import("../commands/memory.js");return e()}),c.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 J=n.command("agents").description("Manage Claude/Cursor/Codex helper files for working with Zibby workflows");J.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:r}=await import("../commands/workflows/agent-helpers.js");if(e){const l=["claude","cursor","codex","all","none"];l.includes(e)||(console.error(`Unknown agent "${e}". Valid: ${l.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 r(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("-t, --template <name>","Scaffold from a template (see `zibby template list`). Future: also accepts npm package / git URL identifiers.").option("--skip-install","Skip running `npm install` in the new workflow folder").option("--skip-init-check","Skip the first-run init prompt that fires when ~/.zibby/config.json is missing (CI/scripted setups)").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)",s,[]).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)",s,[]).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).",y).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)",s,[]).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 deployed workflow back to local (edit it, then re-deploy with `zibby workflow deploy`)").option("--dest <path>","Destination directory (default: ./workflows/<name> when run inside a .zibby project)").option("--force","Overwrite without prompting; bypass uuid-mismatch guard").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o)=>{const{downloadWorkflowCommand:t}=await import("../commands/workflows/download.js");return t(e,o)}),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("validate <name>").description("Static-check a local workflow (.zibby/workflows/<name>/). Catches schema/topology/skill errors in ~30ms before you run anything.").option("--verbose","Print stack traces on graph.mjs import errors").action(async(e,o)=>{const{validateCommand:t}=await import("../commands/workflows/validate.js");return t(e,o)}),a.command("schedule <uuid> [action] [cron]").description(`Manage a workflow's cron schedule. Actions: get (default) | set <cron> | clear. Cron is Unix 5-field, e.g. "0 9 * * 1-5".`).option("--tz <iana>","IANA timezone for the schedule (default: UTC)").option("-p, --param <key=value>","Fixed input param for every scheduled run (repeatable)",s,[]).option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o,t,r)=>{const{scheduleCommand:l}=await import("../commands/workflows/schedule.js");return l(e,o,t,r)}),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 u=a.command("env").description("Manage per-workflow encrypted env vars (set ANTHROPIC_API_KEY, DATABASE_URL, etc. per workflow)");u.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)}),u.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:r}=await import("../commands/workflows/env.js");return r(e,o,t)}),u.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:r}=await import("../commands/workflows/env.js");return r(e,o,t)}),u.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)",s,[]).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 N=n.command("project").description("Manage Zibby projects");N.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 G=n.command("run-queue").description("Parallel capacity \u2014 on-disk wait queue (see parallel.waitWhenAtCapacity in .zibby.config.mjs)");G.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)});const H=n.command("mcp").description("Manage the Zibby Remote MCP integration in your AI agent");H.command("install").description("Auto-configure Zibby MCP into your AI agent (Claude Code/Desktop, Cursor, Codex, Gemini)").option("--agent <name>","claude-code | claude-desktop | cursor | codex | gemini").option("--all","Install for every supported agent on this machine").option("--token <pat>","Use this PAT (zby_pat_\u2026) instead of minting one via session. Also reads ZIBBY_PAT env var.").option("--force","Overwrite the existing zibby block even if unchanged").action(async e=>{const{mcpInstallCommand:o}=await import("../commands/mcp.js");await o(e),process.exit(0)});const p=n.command("app").description("Manage Zibby Managed Apps \u2014 templates, deploy, list, status, destroy");p.command("templates").description("List the app catalog (n8n, grafana, gas-town, \u2026)").action(async e=>{const{appTemplatesCommand:o}=await import("../commands/app.js");return o(e)}),p.command("list").description("List deployed app instances (use --project to scope to one project)").option("--project <id>","Project ID \u2014 defaults to all instances under your account").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async e=>{const{appListCommand:o}=await import("../commands/app.js");return o(e)}),p.command("deploy [appType]").description('Deploy an app \u2014 either from the catalog (e.g. `zibby app deploy grafana --project <id>`) or a free-form install described by --goal (e.g. `zibby app deploy --goal "Install n8n at /n8n on port 5678, persist data in /data" --project <id>`). Pass exactly one of <appType> OR --goal. Catalog deploys are curated by Zibby; goal-based deploys are user-directed installs where you (not Zibby) choose what gets installed and accept the license terms of whatever you install.').option("--project <id>","Project ID (interactive prompt if not provided)").option("--goal <text>",'Free-form natural-language description of what to install (mutually exclusive with <appType>). The agent-ops bootstrap follows the description \u2014 e.g. "install n8n on port 5678 with sqlite persistence". You are responsible for the license terms of any software you install via this path.').option("--name <name>","Instance display name (defaults to appType, or first line of --goal)").option("--provider <name>",'Agent provider \u2014 "claude" (default) or "codex"').option("--arch <name>",`CPU architecture \u2014 "x86_64" or "arm64" (default = catalog's first listed arch; arm64 is ~20% greener at the same price)`).option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o)=>{const{appDeployCommand:t}=await import("../commands/app.js");return t(e,o)}),p.command("status <instanceId>").description("Show one instance: status, resources, public URL").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o)=>{const{appStatusCommand:t}=await import("../commands/app.js");return t(e,o)}),p.command("destroy <instanceId>").description("Stop + remove an app instance (interactive confirm unless --yes)").option("-y, --yes","Skip the confirmation prompt").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o)=>{const{appDestroyCommand:t}=await import("../commands/app.js");return t(e,o)}),p.command("upgrade <instanceId>").description("Roll the agent-ops container image without destroying the instance (EFS data preserved)").option("--version <tag>","Pin to a specific agent-ops version (e.g. 0.1.16). Defaults to whatever AppsFleet base task def says.").option("-y, --yes","Skip the confirmation prompt").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o)=>{const{appUpgradeCommand:t}=await import("../commands/app.js");return t(e,o)}),p.command("update-credential <instanceId>").description("Rotate the per-instance Claude credential to whatever's currently in your workspace-credentials. EFS preserved; task restarts ~30s.").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o)=>{const{appUpdateCredentialCommand:t}=await import("../commands/app.js");return t(e,o)}),p.command("logs <instanceId>").description("Show recent logs from an app instance (use -t to tail; polls every 3s)").option("-t, --follow","Tail mode \u2014 poll every 3s and print new lines as they arrive (Ctrl+C to stop)").option("--lines <n>","Max lines per fetch (default 200, max 5000)").option("--service <name>","For multi-container apps: limit logs to one service (e.g. `db`, `web`, `agent-ops`). Defaults to interleaved across all containers.").option("--json","Print raw JSON lines (one per line) instead of parsed summary").option("--verbose","Print the full line including JSON body (default: parsed `<time> <msg>` summary)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(e,o)=>{const{appLogsCommand:t}=await import("../commands/app.js");return t(e,o)}),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();
@@ -1,27 +1,27 @@
1
- import a from"chalk";import h from"ora";import C from"inquirer";import ge from"dotenv";import{existsSync as ae,readFileSync as le}from"fs";import{join as pe}from"path";import k from"chalk";import{confirm as ue}from"@inquirer/prompts";import u from"chalk";import S from"ora";import{spawn as re}from"child_process";var $={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://api-prod.zibby.app",frontendUrl:process.env.ZIBBY_PROD_FRONTEND_URL||"https://studio.zibby.dev",description:"Production environment"}};function x(){let e;if(process.env.ZIBBY_API_URL)e=process.env.ZIBBY_API_URL;else{let o=process.env.ZIBBY_ENV||"prod";$[o]?e=$[o].apiUrl:e=$.prod.apiUrl}try{let o=new URL(e);return o.protocol!=="http:"&&o.protocol!=="https:"?(console.error(`\u26A0\uFE0F Invalid API URL protocol: ${o.protocol} (only http/https allowed)`),$.prod.apiUrl):e}catch{return console.error(`\u26A0\uFE0F Invalid API URL: ${e}`),$.prod.apiUrl}}import{existsSync as N,mkdirSync as Q,readFileSync as X,writeFileSync as ee}from"fs";import{homedir as _}from"os";import{join as U}from"path";function O(){return process.env.ZIBBY_CONFIG_DIR||U(_(),".zibby")}function z(){return U(O(),"config.json")}var oe=U(_(),".zibby"),we=U(oe,"config.json");function te(){let e=O();N(e)||Q(e,{recursive:!0})}function m(){try{let e=z();if(N(e)){let o=X(e,"utf-8");return JSON.parse(o)}}catch{}return{}}function I(e){te(),ee(z(),JSON.stringify(e,null,2))}function B(){return m().sessionToken||null}function L(e){let o=m();o.sessionToken=e,I(o)}function D(){return m().user||null}function M(e){let o=m();o.user=e,I(o)}function F(e){let o=m();o.proxyUrl=e,I(o)}function Y(e){let o=m();o.mem0ProxyUrl=e,I(o)}function Z(e){let o=m();o.projects=e,I(o)}import{existsSync as $e,mkdirSync as xe,readFileSync as Ie,writeFileSync as Ue,unlinkSync as Ae}from"fs";import{resolve as Se}from"path";import{homedir as ke}from"os";function ne(e){let o=process.platform;try{let r,i;return o==="darwin"?(r="open",i=[e]):o==="win32"?(r="cmd",i=["/c","start","",e]):(r="xdg-open",i=[e]),re(r,i,{detached:!0,stdio:"ignore"}).unref(),!0}catch{return!1}}function se(){let e=B(),o=D();return e&&o?{loggedIn:!0,user:o,token:e}:{loggedIn:!1}}async function J(){try{console.log(u.cyan(`
1
+ import c from"chalk";import h from"ora";import C from"inquirer";import ge from"dotenv";import{existsSync as ce,readFileSync as le}from"fs";import{join as pe}from"path";import k from"chalk";import{confirm as ue}from"@inquirer/prompts";import u from"chalk";import T from"ora";import{spawn as ne}from"child_process";var b={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://api-prod.zibby.app",frontendUrl:process.env.ZIBBY_PROD_FRONTEND_URL||"https://studio.zibby.dev",description:"Production environment"}};function x(){let e;if(process.env.ZIBBY_API_URL)e=process.env.ZIBBY_API_URL;else{let o=process.env.ZIBBY_ENV||"prod";b[o]?e=b[o].apiUrl:e=b.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)`),b.prod.apiUrl):e}catch{return console.error(`\u26A0\uFE0F Invalid API URL: ${e}`),b.prod.apiUrl}}import{existsSync as N,mkdirSync as Q,readFileSync as X,writeFileSync as ee}from"fs";import{homedir as _}from"os";import{join as I}from"path";function O(){return process.env.ZIBBY_CONFIG_DIR||I(_(),".zibby")}function z(){return I(O(),"config.json")}var oe=I(_(),".zibby"),we=I(oe,"config.json");function te(){let e=O();N(e)||Q(e,{recursive:!0})}function m(){try{let e=z();if(N(e)){let o=X(e,"utf-8");return JSON.parse(o)}}catch{}return{}}function A(e){te(),ee(z(),JSON.stringify(e,null,2))}function B(){return m().sessionToken||null}function L(e){let o=m();o.sessionToken=e,A(o)}function D(){return m().user||null}function M(e){let o=m();o.user=e,A(o)}function F(e){let o=m();o.proxyUrl=e,A(o)}function Y(e){let o=m();o.mem0ProxyUrl=e,A(o)}function Z(e){let o=m();o.projects=e,A(o)}import{existsSync as be,mkdirSync as xe,readFileSync as Ae,writeFileSync as Ie,unlinkSync as Ue}from"fs";import{resolve as Te}from"path";import{homedir as ke}from"os";function re(e){let o=process.platform;try{let r,i;return o==="darwin"?(r="open",i=[e]):o==="win32"?(r="cmd",i=["/c","start","",e]):(r="xdg-open",i=[e]),ne(r,i,{detached:!0,stdio:"ignore"}).unref(),!0}catch{return!1}}function se(){let e=B(),o=D();return e&&o?{loggedIn:!0,user:o,token:e}:{loggedIn:!1}}async function J(){try{console.log(u.cyan(`
2
2
  \u{1F510} Initiating login...
3
3
  `));let e=se();if(e.loggedIn){console.log(u.green("\u2705 Already logged in!")),console.log(u.gray(`User: ${e.user.email}`)),console.log(u.gray(`Name: ${e.user.name}
4
- `));let{createInterface:o}=await import("readline"),r=o({input:process.stdin,output:process.stdout});return new Promise((i,t)=>{let s=()=>{r.close(),process.stdin.isTTY&&process.stdin.setRawMode(!1)},n=()=>{console.log(u.yellow(`
4
+ `));let{createInterface:o}=await import("readline"),r=o({input:process.stdin,output:process.stdout});return new Promise((i,t)=>{let a=()=>{r.close(),process.stdin.isTTY&&process.stdin.setRawMode(!1)},s=()=>{console.log(u.yellow(`
5
5
 
6
6
  \u26A0\uFE0F Login cancelled
7
- `)),s(),process.exit(0)};process.on("SIGINT",n),r.question(u.yellow("Continue with this session? (Y/n): "),async l=>{process.removeListener("SIGINT",n),s();try{if(l.toLowerCase()==="n"||l.toLowerCase()==="no"){console.log(u.gray(`Starting new login...
8
- `));let c=await V();i(c)}else console.log(u.green(`Using existing session.
9
- `)),i({success:!0,...e})}catch(c){t(c)}})})}return await V()}catch(e){return console.error(u.red(`
10
- \u274C Login failed:`,e.message)),{success:!1,error:e.message}}}async function ie(e){let o=x();try{let r=await fetch(`${o}/projects`,{headers:{Authorization:`Bearer ${e}`}});if(r.ok){let t=((await r.json()).projects||[]).map(s=>({name:s.name,projectId:s.projectId,apiToken:s.apiToken}));return Z(t),t}}catch(r){console.log(u.gray(`\u26A0\uFE0F Could not fetch projects: ${r.message}`))}return[]}async function V(){let e=x(),o=S("Requesting login code...").start(),r=await fetch(`${e}/cli/login/initiate`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!r.ok){o.fail("Failed to request login code");let b=await r.json();throw new Error(b.error||"Failed to initiate login")}let{deviceCode:i,userCode:t,verificationUrl:s,expiresIn:n,interval:l}=await r.json();o.succeed("Login code generated"),console.log(""),console.log(u.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(u.cyan("\u2551")+u.white.bold(" Complete login in your browser ")+u.cyan("\u2551")),console.log(u.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(u.white("Opening browser to login page...")),console.log(u.gray(`Code expires in ${Math.floor(n/60)} minutes`)),console.log(""),await ne(s)||(console.log(u.yellow("\u26A0\uFE0F Could not open browser automatically.")),console.log(u.white("Please open this URL manually: ")+u.blue(s)),console.log(""));let p=S("Waiting for authorization...").start(),f=(l||3)*1e3,g=Math.floor(n/(l||3)),v=0,P=!1,R=()=>{P=!0,p.stop(),console.log(u.yellow(`
7
+ `)),a(),process.exit(0)};process.on("SIGINT",s),r.question(u.yellow("Continue with this session? (Y/n): "),async l=>{process.removeListener("SIGINT",s),a();try{if(l.toLowerCase()==="n"||l.toLowerCase()==="no"){console.log(u.gray(`Starting new login...
8
+ `));let n=await V();i(n)}else console.log(u.green(`Using existing session.
9
+ `)),i({success:!0,...e})}catch(n){t(n)}})})}return await V()}catch(e){return console.error(u.red(`
10
+ \u274C Login failed:`,e.message)),{success:!1,error:e.message}}}async function ie(e){let o=x();try{let r=await fetch(`${o}/projects`,{headers:{Authorization:`Bearer ${e}`}});if(r.ok){let t=((await r.json()).projects||[]).map(a=>({name:a.name,projectId:a.projectId,apiToken:a.apiToken}));return Z(t),t}}catch(r){console.log(u.gray(`\u26A0\uFE0F Could not fetch projects: ${r.message}`))}return[]}async function V(){let e=x(),o=T("Requesting login code...").start(),r=await fetch(`${e}/cli/login/initiate`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!r.ok){o.fail("Failed to request login code");let $=await r.json();throw new Error($.error||"Failed to initiate login")}let{deviceCode:i,userCode:t,verificationUrl:a,expiresIn:s,interval:l}=await r.json();o.succeed("Login code generated"),console.log(""),console.log(u.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(u.cyan("\u2551")+u.white.bold(" Complete login in your browser ")+u.cyan("\u2551")),console.log(u.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(u.white("Opening browser to login page...")),console.log(u.gray(`Code expires in ${Math.floor(s/60)} minutes`)),console.log(""),await re(a)||(console.log(u.yellow("\u26A0\uFE0F Could not open browser automatically.")),console.log(u.white("Please open this URL manually: ")+u.blue(a)),console.log(""));let p=T("Waiting for authorization...").start(),g=(l||3)*1e3,d=Math.floor(s/(l||3)),v=0,E=!1,P=()=>{E=!0,p.stop(),console.log(u.yellow(`
11
11
 
12
12
  \u26A0\uFE0F Login cancelled
13
- `)),process.exit(0)};process.on("SIGINT",R);try{for(;v<g&&!P;){await ce(f),v++;let b=await fetch(`${e}/cli/login/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:i})});if(b.status===202)continue;if(!b.ok){p.fail("Authorization failed");let T=await b.json();throw new Error(T.error||"Authorization failed")}let d=await b.json();if(d.status==="authorized"){p.succeed(u.white("Authorization successful!")),L(d.token),M(d.user),d.proxyUrl&&F(d.proxyUrl),d.mem0ProxyUrl&&Y(d.mem0ProxyUrl),console.log(""),console.log(u.gray(`User: ${d.user.email}`));let T=S("Fetching projects...").start(),E=await ie(d.token);return T.succeed(`Fetched ${E.length} project${E.length!==1?"s":""}`),console.log(u.gray(`Session saved to: ~/.zibby/config.json
14
- `)),{success:!0,loggedIn:!0,user:d.user,token:d.token}}if(d.status==="denied")throw p.fail("Authorization denied"),new Error("User denied authorization")}throw p.fail("Login timeout"),new Error("Login timed out - please try again")}finally{process.removeListener("SIGINT",R)}}function ce(e){return new Promise(o=>setTimeout(o,e))}function G(){try{let e=process.env.HOME||process.env.USERPROFILE;if(!e)return null;let o=pe(e,".zibby","config.json");return ae(o)&&JSON.parse(le(o,"utf-8")).sessionToken||null}catch{return null}}function j(){console.log(`
13
+ `)),process.exit(0)};process.on("SIGINT",P);try{for(;v<d&&!E;){await ae(g),v++;let $=await fetch(`${e}/cli/login/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:i})});if($.status===202)continue;if(!$.ok){p.fail("Authorization failed");let S=await $.json();throw new Error(S.error||"Authorization failed")}let f=await $.json();if(f.status==="authorized"){p.succeed(u.white("Authorization successful!")),L(f.token),M(f.user),f.proxyUrl&&F(f.proxyUrl),f.mem0ProxyUrl&&Y(f.mem0ProxyUrl),console.log(""),console.log(u.gray(`User: ${f.user.email}`));let S=T("Fetching projects...").start(),R=await ie(f.token);return S.succeed(`Fetched ${R.length} project${R.length!==1?"s":""}`),console.log(u.gray(`Session saved to: ~/.zibby/config.json
14
+ `)),{success:!0,loggedIn:!0,user:f.user,token:f.token}}if(f.status==="denied")throw p.fail("Authorization denied"),new Error("User denied authorization")}throw p.fail("Login timeout"),new Error("Login timed out - please try again")}finally{process.removeListener("SIGINT",P)}}function ae(e){return new Promise(o=>setTimeout(o,e))}function G(){try{let e=process.env.HOME||process.env.USERPROFILE;if(!e)return null;let o=pe(e,".zibby","config.json");return ce(o)&&JSON.parse(le(o,"utf-8")).sessionToken||null}catch{return null}}function j(){console.log(`
15
15
  Not authenticated.`),console.log(` Run ${k.cyan("zibby login")} or set ${k.cyan("ZIBBY_API_KEY")} in your environment.
16
16
  `)}async function K(e={}){let o=e.apiKey||process.env.ZIBBY_API_KEY||null,r=G();if(r||o)return{sessionToken:r,apiKey:o};if(!process.stdin.isTTY){if(e.optional)return{sessionToken:null,apiKey:null};j(),process.exit(1)}console.log(k.yellow(`
17
- Not logged in.`));let i;try{i=await ue({message:"Open browser to log in now?",default:!0})}catch{i=!1}if(!i){if(e.optional)return{sessionToken:null,apiKey:null};j(),process.exit(1)}if(await J(),r=G(),!r){if(e.optional)return{sessionToken:null,apiKey:null};j(),process.exit(1)}return{sessionToken:r,apiKey:null}}ge.config();async function w(e){let{sessionToken:o,apiKey:r}=await K({apiKey:e?.apiKey}),i=o||r;return i||(console.error(a.red("Not authenticated. Run `zibby login` or set ZIBBY_API_KEY.")),process.exit(1)),{"Content-Type":"application/json",Authorization:`Bearer ${i}`}}async function y(e,o,{quiet:r=!1}={}){let t=`${x()}${e}`,s=await fetch(t,o),n=await s.text(),l=null;try{l=n?JSON.parse(n):null}catch{l={raw:n}}if(!s.ok){let c=l?.error||l?.message||`HTTP ${s.status}`;r||(l?.code==="CLAUDE_CREDENTIAL_REQUIRED"?(console.error(a.red("\xD7 Connect your Claude Code subscription first.")),console.error(""),console.error(a.white(" Run:")),console.error(a.cyan(" claude setup-token # mints a long-lived OAuth token")),console.error(a.cyan(" zibby creds set claude <token>")),console.error(""),console.error(a.gray(" Or paste an Anthropic API key:")),console.error(a.cyan(" zibby creds set claude sk-ant-api03-...")),console.error("")):l?.code==="OPENAI_CREDENTIAL_REQUIRED"?(console.error(a.red("\xD7 Connect your OpenAI API key to deploy with Codex.")),console.error(""),console.error(a.white(" Run:")),console.error(a.cyan(" zibby creds set openai sk-...")),console.error(""),console.error(a.gray(" Mint one at: https://platform.openai.com/api-keys")),console.error(a.gray(" Or paste at: https://zibby.dev/integrations")),console.error("")):(console.error(a.red(`\xD7 ${c}`)),l?.detail&&console.error(a.gray(` ${l.detail}`))));let p=new Error(c);throw p.status=s.status,p.body=l,p.code=l?.code||null,p}return l}function H(e){return" "+e.map(o=>"\u2500".repeat(o)).join(" ")}function A(e,o){return" "+e.map((r,i)=>String(r??"").padEnd(o[i])).join(" ")}async function Qe(e={}){let o=h("Loading app catalog\u2026").start();try{let r=await y("/apps/catalog",{method:"GET"});o.stop();let i=Array.isArray(r?.items)?r.items:[];if(i.length===0)return console.log(`
17
+ Not logged in.`));let i;try{i=await ue({message:"Open browser to log in now?",default:!0})}catch{i=!1}if(!i){if(e.optional)return{sessionToken:null,apiKey:null};j(),process.exit(1)}if(await J(),r=G(),!r){if(e.optional)return{sessionToken:null,apiKey:null};j(),process.exit(1)}return{sessionToken:r,apiKey:null}}ge.config();async function w(e){let{sessionToken:o,apiKey:r}=await K({apiKey:e?.apiKey}),i=o||r;return i||(console.error(c.red("Not authenticated. Run `zibby login` or set ZIBBY_API_KEY.")),process.exit(1)),{"Content-Type":"application/json",Authorization:`Bearer ${i}`}}async function y(e,o,{quiet:r=!1}={}){let t=`${x()}${e}`,a=await fetch(t,o),s=await a.text(),l=null;try{l=s?JSON.parse(s):null}catch{l={raw:s}}if(!a.ok){let n=l?.error||l?.message||`HTTP ${a.status}`;r||(l?.code==="CLAUDE_CREDENTIAL_REQUIRED"?(console.error(c.red("\xD7 Connect your Claude Code subscription first.")),console.error(""),console.error(c.white(" Run:")),console.error(c.cyan(" claude setup-token # mints a long-lived OAuth token")),console.error(c.cyan(" zibby creds set claude <token>")),console.error(""),console.error(c.gray(" Or paste an Anthropic API key:")),console.error(c.cyan(" zibby creds set claude sk-ant-api03-...")),console.error("")):l?.code==="OPENAI_CREDENTIAL_REQUIRED"?(console.error(c.red("\xD7 Connect your OpenAI API key to deploy with Codex.")),console.error(""),console.error(c.white(" Run:")),console.error(c.cyan(" zibby creds set openai sk-...")),console.error(""),console.error(c.gray(" Mint one at: https://platform.openai.com/api-keys")),console.error(c.gray(" Or paste at: https://zibby.dev/integrations")),console.error("")):(console.error(c.red(`\xD7 ${n}`)),l?.detail&&console.error(c.gray(` ${l.detail}`))));let p=new Error(n);throw p.status=a.status,p.body=l,p.code=l?.code||null,p}return l}function q(e){return" "+e.map(o=>"\u2500".repeat(o)).join(" ")}function U(e,o){return" "+e.map((r,i)=>String(r??"").padEnd(o[i])).join(" ")}async function Qe(e={}){let o=h("Loading app catalog\u2026").start();try{let r=await y("/apps/catalog",{method:"GET"});o.stop();let i=Array.isArray(r?.items)?r.items:[];if(i.length===0)return console.log(`
18
18
  No apps available in the catalog.
19
- `),[];if(e.quiet)return i;let t=i.map(n=>({appType:String(n.appType||""),version:`v${n.appVersion||n.app?.version||"?"}`,tier:String(n.pricing?.tier||"standard"),arch:Array.isArray(n.architectures)&&n.architectures.length?n.architectures.join(","):"x86_64",tagline:(n.tagline||"").slice(0,40)})),s=[Math.max(7,...t.map(n=>n.appType.length)),Math.max(7,...t.map(n=>n.version.length)),Math.max(4,...t.map(n=>n.tier.length)),Math.max(13,...t.map(n=>n.arch.length)),Math.max(7,...t.map(n=>n.tagline.length))];console.log(`
19
+ `),[];if(e.quiet)return i;let t=i.map(s=>({appType:String(s.appType||""),version:`v${s.appVersion||s.app?.version||"?"}`,tier:String(s.pricing?.tier||"standard"),arch:Array.isArray(s.architectures)&&s.architectures.length?s.architectures.join(","):"x86_64",tagline:(s.tagline||"").slice(0,40)})),a=[Math.max(7,...t.map(s=>s.appType.length)),Math.max(7,...t.map(s=>s.version.length)),Math.max(4,...t.map(s=>s.tier.length)),Math.max(13,...t.map(s=>s.arch.length)),Math.max(7,...t.map(s=>s.tagline.length))];console.log(`
20
20
  App Catalog (${i.length})
21
- `),console.log(A(["AppType","Version","Tier","Architectures","Tagline"],s)),console.log(H(s));for(let n of t)console.log(A([n.appType,n.version,n.tier,n.arch,n.tagline],s));return console.log(""),console.log(" Deploy with: zibby app deploy <appType> --project <projectId>"),console.log(" ARM64 (~20% greener, same price): zibby app deploy <appType> --project <id> --arch arm64"),console.log(""),i}catch(r){o.fail("Failed to load catalog"),r.status&&console.error(` HTTP ${r.status}`),process.exit(1)}}async function Xe(e={}){let o=await w(e),r=h("Fetching deployed apps\u2026").start();try{let i=e.project?`?projectId=${encodeURIComponent(e.project)}`:"",t=await y(`/apps${i}`,{method:"GET",headers:o});r.stop();let s=Array.isArray(t?.apps)?t.apps:[];if(e.quiet)return s;if(s.length===0)return console.log(`
21
+ `),console.log(U(["AppType","Version","Tier","Architectures","Tagline"],a)),console.log(q(a));for(let s of t)console.log(U([s.appType,s.version,s.tier,s.arch,s.tagline],a));return console.log(""),console.log(" Deploy with: zibby app deploy <appType> --project <projectId>"),console.log(" ARM64 (~20% greener, same price): zibby app deploy <appType> --project <id> --arch arm64"),console.log(""),i}catch(r){o.fail("Failed to load catalog"),r.status&&console.error(` HTTP ${r.status}`),process.exit(1)}}async function Xe(e={}){let o=await w(e),r=h("Fetching deployed apps\u2026").start();try{let i=e.project?`?projectId=${encodeURIComponent(e.project)}`:"",t=await y(`/apps${i}`,{method:"GET",headers:o});r.stop();let a=Array.isArray(t?.apps)?t.apps:[];if(e.quiet)return a;if(a.length===0)return console.log(`
22
22
  No apps deployed.`),console.log(` Deploy one with: zibby app deploy <appType> --project <projectId>
23
- `),[];let n=s.map(c=>({instance:(c.instanceId||"").slice(0,12),name:String(c.name||c.appType||"\u2014").slice(0,22),app:`${c.appType}${c.appVersion?` v${c.appVersion}`:""}`,arch:String(c.architecture||"\u2014"),status:String(c.status||"unknown"),project:String(c.projectId||"\u2014").slice(0,36)})),l=[Math.max(8,...n.map(c=>c.instance.length)),Math.max(4,...n.map(c=>c.name.length)),Math.max(3,...n.map(c=>c.app.length)),Math.max(4,...n.map(c=>c.arch.length)),Math.max(6,...n.map(c=>c.status.length)),Math.max(7,...n.map(c=>c.project.length))];console.log(`
24
- Deployed Apps (${s.length})
25
- `),console.log(A(["Instance","Name","App","Arch","Status","Project"],l)),console.log(H(l));for(let c of n)console.log(A([c.instance,c.name,c.app,c.arch,c.status,c.project],l));return console.log(""),s}catch{r.fail("Failed to list apps"),process.exit(1)}}async function de(e){let o=h("Fetching projects\u2026").start(),r=await y("/projects",{method:"GET",headers:e});o.stop();let i=Array.isArray(r)?r:r?.projects||r?.data||[];i.length||(console.error(a.red("No projects found. Create one in the dashboard first.")),process.exit(1));let{projectId:t}=await C.prompt([{type:"list",name:"projectId",message:"Which project should this app deploy into?",choices:i.map(s=>({name:`${s.name||"Unnamed"} (${s.projectId||s.id})`,value:s.projectId||s.id}))}]);return t}async function eo(e,o={}){let r=o.goal;e&&r&&(console.error(a.red("Pass either appType (catalog id) OR --goal (free-form description), not both.")),process.exit(1)),!e&&!r&&(console.error(a.red("Missing target.")),console.error(a.gray(" Pass appType to deploy from catalog (see `zibby app templates`)")),console.error(a.gray(' OR --goal "<description>" to describe a custom install.')),process.exit(1));let i=await w(o),t=o.project;t||(t=await de(i));let s=r?{goal:r,projectId:t}:{appType:e,projectId:t};o.name&&(s.name=o.name),o.provider&&(o.provider!=="claude"&&o.provider!=="codex"&&(console.error(a.red(`Unknown --provider: ${o.provider}`)),console.error(a.gray(" Pick claude (Anthropic) or codex (OpenAI).")),process.exit(1)),s.provider=o.provider),o.arch&&(o.arch!=="x86_64"&&o.arch!=="arm64"&&(console.error(a.red(`Unknown --arch: ${o.arch}`)),console.error(a.gray(" Pick x86_64 (Intel/AMD) or arm64 (Graviton, ~20% greener at the same price).")),process.exit(1)),s.architecture=o.arch);let n=[];o.provider&&n.push(o.provider),o.arch&&n.push(o.arch);let l=e||(r.length>60?`${r.slice(0,60).trim()}\u2026`:r),c=h(`Deploying ${l}${n.length?` (${n.join(", ")})`:""}\u2026`).start();try{let p=await y("/apps/deploy",{method:"POST",headers:i,body:JSON.stringify(s)});c.succeed(`Deployed ${l}`);let f=p?.instanceId,g=p?.url||(p?.subdomain?`https://${p.subdomain}`:null);return console.log(),f&&console.log(` instanceId: ${f}`),g&&console.log(` public URL: ${g}`),p?.architecture&&console.log(` architecture: ${p.architecture}`),f&&(console.log(),console.log(` Watch status: zibby app status ${f}`)),console.log(),p}catch(p){c.fail(`Deploy failed: ${p.message}`),process.exit(1)}}async function oo(e,o={}){e||(console.error(a.red("Missing <instanceId>.")),process.exit(1));let r=await w(o),i=h(`Fetching ${e}\u2026`).start();try{let t=await y(`/apps/${encodeURIComponent(e)}`,{method:"GET",headers:r});if(i.stop(),o.quiet)return t;let s=t.url||(t.subdomain?`https://${t.subdomain}`:null);if(console.log(),console.log(` ${t.name||t.appType||e}`),console.log(),console.log(` status ${t.status||"unknown"}`),typeof t.runningCount=="number"&&console.log(` running ${t.runningCount} / ${t.desiredCount??1}`),console.log(` app ${t.appType}${t.appVersion?` v${t.appVersion}`:""}`),t.resources?.cpu&&t.resources?.memory){let n=(t.resources.cpu/1024).toFixed(2),l=(t.resources.memory/1024).toFixed(2);console.log(` resources ${n} vCPU \xB7 ${l} GB RAM`)}return t.architecture&&console.log(` arch ${t.architecture}`),t.projectId&&console.log(` project ${t.projectId}`),s&&console.log(` public URL ${s}`),t.createdAt&&console.log(` created ${t.createdAt}`),console.log(),t}catch(t){i.fail(`Could not fetch ${e}`),t.status===404&&console.error(a.gray(" Instance not found \u2014 it may have been destroyed.")),process.exit(1)}}async function to(e,o={}){e||(console.error(a.red("Missing <instanceId>.")),process.exit(1));let r=await w(o);if(!o.yes){let{confirm:t}=await C.prompt([{type:"confirm",name:"confirm",message:`Destroy app ${e}? The running task will be stopped.`,default:!1}]);if(!t){console.log(a.gray("Aborted."));return}}let i=h(`Destroying ${e}\u2026`).start();try{await y(`/apps/${encodeURIComponent(e)}`,{method:"DELETE",headers:r,body:JSON.stringify({confirm:!0})}),i.succeed(`Destroyed ${e}`)}catch(t){i.fail(`Destroy failed: ${t.message}`),process.exit(1)}}async function ro(e,o={}){e||(console.error(a.red("Missing <instanceId>.")),process.exit(1));let r=await w(o);if(!o.yes){let{confirm:s}=await C.prompt([{type:"confirm",name:"confirm",message:o.version?`Upgrade ${e} to ghcr.io/zibbyhq/agent-ops:${o.version}? EFS data is preserved.`:`Upgrade ${e} to the latest base image? EFS data is preserved.`,default:!0}]);if(!s){console.log(a.gray("Aborted."));return}}let i=o.version?`?version=${encodeURIComponent(o.version)}`:"",t=h(`Upgrading ${e}\u2026`).start();try{let s=await y(`/apps/${encodeURIComponent(e)}/upgrade${i}`,{method:"POST",headers:r});t.succeed(`Upgrade rolling out for ${e}`),console.log(),console.log(` taskDefinitionArn: ${s?.taskDefinitionArn||"\u2014"}`),s?.imageOverride&&console.log(` image: ${s.imageOverride}`),console.log(),console.log(a.gray(" ECS rolls the service: new task pulls image, then swaps over. EFS data preserved.")),console.log(a.gray(` Watch: zibby app status ${e}`)),console.log()}catch(s){t.fail(`Upgrade failed: ${s.message}`),process.exit(1)}}async function no(e,o={}){e||(console.error(a.red("Missing <instanceId>.")),process.exit(1));let r=await w(o),i=h(`Rotating Claude credential on ${e}\u2026`).start();try{let t=await y(`/apps/${encodeURIComponent(e)}/credentials`,{method:"POST",headers:r,body:"{}"});i.succeed(`Credential update rolling out for ${e}`),console.log(),console.log(` mode ${t?.mode||"\u2014"}`),console.log(` taskDefinitionArn ${t?.taskDefinitionArn||"\u2014"}`),console.log(),console.log(a.gray(" ECS rolls the service: new task pulls the new env, swaps over once healthy.")),console.log(a.gray(` Watch: zibby app status ${e}`)),console.log()}catch(t){i.fail(`Credential update failed: ${t.message}`),process.exit(1)}}var W=3e3;function q(e,o={}){if(o.verbose)return e;let r=e.indexOf(" ");if(r<0)return e;let i=e.slice(0,r),t=e.slice(r+2),s=i.length>=19?i.slice(11,19):i;try{let n=JSON.parse(t),l=(n.level||"INFO").padEnd(4),c=n.msg||n.message||"",p=Object.entries(n).filter(([g])=>!["time","level","msg","message"].includes(g)).filter(([,g])=>g!==""&&g!==null&&g!==void 0).map(([g,v])=>`${g}=${typeof v=="string"?v:JSON.stringify(v)}`).join(" "),f=l.startsWith("ERR")||l.startsWith("FAIL")?a.red:l.startsWith("WARN")?a.yellow:a.gray;return`${a.dim(s)} ${f(l)} ${c}${p?" "+a.dim(p):""}`}catch{return`${a.dim(s)} ${t}`}}async function so(e,o={}){e||(console.error(a.red("Missing <instanceId>.")),process.exit(1));let r=await w(o),i=Math.min(Math.max(Number(o.lines)||200,1),5e3),t=async()=>await y(`/apps/${encodeURIComponent(e)}/logs?lines=${i}`,{method:"GET",headers:r});if(!o.follow){try{let l=await t(),c=Array.isArray(l?.lines)?l.lines:[];if(o.json)for(let p of c)console.log(p);else{c.length===0&&console.log(a.gray(" (no log events in window)"));for(let p of c)console.log(q(p,o))}}catch(l){console.error(a.red(`\xD7 ${l.message}`)),process.exit(1)}return}let s=new Set;console.log(a.gray(`Tailing logs for ${e} \u2014 Ctrl+C to stop
26
- `));let n=!1;for(process.on("SIGINT",()=>{n=!0,console.log(a.gray(`
27
- Stopped.`)),process.exit(0)});!n;){try{let l=await t(),c=Array.isArray(l?.lines)?l.lines:[];for(let p of c)s.has(p)||(s.add(p),console.log(o.json?p:q(p,o)));if(s.size>i*2){let p=Array.from(s).slice(-i);s.clear(),p.forEach(f=>s.add(f))}}catch(l){console.error(a.red(` \xD7 ${l.message} \u2014 retrying in ${W/1e3}s`))}await new Promise(l=>setTimeout(l,W))}}export{eo as appDeployCommand,to as appDestroyCommand,Xe as appListCommand,so as appLogsCommand,oo as appStatusCommand,Qe as appTemplatesCommand,no as appUpdateCredentialCommand,ro as appUpgradeCommand};
23
+ `),[];let s=a.map(n=>({instance:(n.instanceId||"").slice(0,12),name:String(n.name||n.appType||"\u2014").slice(0,22),app:`${n.appType}${n.appVersion?` v${n.appVersion}`:""}`,arch:String(n.architecture||"\u2014"),status:String(n.status||"unknown"),project:String(n.projectId||"\u2014").slice(0,36)})),l=[Math.max(8,...s.map(n=>n.instance.length)),Math.max(4,...s.map(n=>n.name.length)),Math.max(3,...s.map(n=>n.app.length)),Math.max(4,...s.map(n=>n.arch.length)),Math.max(6,...s.map(n=>n.status.length)),Math.max(7,...s.map(n=>n.project.length))];console.log(`
24
+ Deployed Apps (${a.length})
25
+ `),console.log(U(["Instance","Name","App","Arch","Status","Project"],l)),console.log(q(l));for(let n of s)console.log(U([n.instance,n.name,n.app,n.arch,n.status,n.project],l));return console.log(""),a}catch{r.fail("Failed to list apps"),process.exit(1)}}async function de(e){let o=h("Fetching projects\u2026").start(),r=await y("/projects",{method:"GET",headers:e});o.stop();let i=Array.isArray(r)?r:r?.projects||r?.data||[];i.length||(console.error(c.red("No projects found. Create one in the dashboard first.")),process.exit(1));let{projectId:t}=await C.prompt([{type:"list",name:"projectId",message:"Which project should this app deploy into?",choices:i.map(a=>({name:`${a.name||"Unnamed"} (${a.projectId||a.id})`,value:a.projectId||a.id}))}]);return t}async function eo(e,o={}){let r=o.goal;e&&r&&(console.error(c.red("Pass either appType (catalog id) OR --goal (free-form description), not both.")),process.exit(1)),!e&&!r&&(console.error(c.red("Missing target.")),console.error(c.gray(" Pass appType to deploy from catalog (see `zibby app templates`)")),console.error(c.gray(' OR --goal "<description>" to describe a custom install.')),process.exit(1));let i=await w(o),t=o.project;t||(t=await de(i));let a=r?{goal:r,projectId:t}:{appType:e,projectId:t};o.name&&(a.name=o.name),o.provider&&(o.provider!=="claude"&&o.provider!=="codex"&&(console.error(c.red(`Unknown --provider: ${o.provider}`)),console.error(c.gray(" Pick claude (Anthropic) or codex (OpenAI).")),process.exit(1)),a.provider=o.provider),o.arch&&(o.arch!=="x86_64"&&o.arch!=="arm64"&&(console.error(c.red(`Unknown --arch: ${o.arch}`)),console.error(c.gray(" Pick x86_64 (Intel/AMD) or arm64 (Graviton, ~20% greener at the same price).")),process.exit(1)),a.architecture=o.arch);let s=[];o.provider&&s.push(o.provider),o.arch&&s.push(o.arch);let l=e||(r.length>60?`${r.slice(0,60).trim()}\u2026`:r),n=h(`Deploying ${l}${s.length?` (${s.join(", ")})`:""}\u2026`).start();try{let p=await y("/apps/deploy",{method:"POST",headers:i,body:JSON.stringify(a)});n.succeed(`Deployed ${l}`);let g=p?.instanceId,d=p?.url||(p?.subdomain?`https://${p.subdomain}`:null);return console.log(),g&&console.log(` instanceId: ${g}`),d&&console.log(` public URL: ${d}`),p?.architecture&&console.log(` architecture: ${p.architecture}`),g&&(console.log(),console.log(` Watch status: zibby app status ${g}`)),console.log(),p}catch(p){n.fail(`Deploy failed: ${p.message}`),process.exit(1)}}async function oo(e,o={}){e||(console.error(c.red("Missing <instanceId>.")),process.exit(1));let r=await w(o),i=h(`Fetching ${e}\u2026`).start();try{let t=await y(`/apps/${encodeURIComponent(e)}`,{method:"GET",headers:r});if(i.stop(),o.quiet)return t;let a=t.url||(t.subdomain?`https://${t.subdomain}`:null);if(console.log(),console.log(` ${t.name||t.appType||e}`),console.log(),console.log(` status ${t.status||"unknown"}`),typeof t.runningCount=="number"&&console.log(` running ${t.runningCount} / ${t.desiredCount??1}`),console.log(` app ${t.appType}${t.appVersion?` v${t.appVersion}`:""}`),t.resources?.cpu&&t.resources?.memory){let s=(t.resources.cpu/1024).toFixed(2),l=(t.resources.memory/1024).toFixed(2);console.log(` resources ${s} vCPU \xB7 ${l} GB RAM`)}if(t.architecture&&console.log(` arch ${t.architecture}`),t.projectId&&console.log(` project ${t.projectId}`),a&&console.log(` public URL ${a}`),t.createdAt&&console.log(` created ${t.createdAt}`),Array.isArray(t.containers)&&t.containers.length>1){console.log(),console.log(" services");let s=t.containers.map(n=>[n.name||"?",n.lastStatus||"\u2014",n.healthStatus||"\u2014",n.exitCode!==null&&n.exitCode!==void 0?String(n.exitCode):"\u2014"]),l=[Math.max(7,...s.map(n=>n[0].length)),Math.max(6,...s.map(n=>n[1].length)),Math.max(6,...s.map(n=>n[2].length))];console.log(` ${"NAME".padEnd(l[0])} ${"STATUS".padEnd(l[1])} ${"HEALTH".padEnd(l[2])} EXIT`);for(let n of s)console.log(` ${n[0].padEnd(l[0])} ${n[1].padEnd(l[1])} ${n[2].padEnd(l[2])} ${n[3]}`)}return console.log(),t}catch(t){i.fail(`Could not fetch ${e}`),t.status===404&&console.error(c.gray(" Instance not found \u2014 it may have been destroyed.")),process.exit(1)}}async function to(e,o={}){e||(console.error(c.red("Missing <instanceId>.")),process.exit(1));let r=await w(o);if(!o.yes){let{confirm:t}=await C.prompt([{type:"confirm",name:"confirm",message:`Destroy app ${e}? The running task will be stopped.`,default:!1}]);if(!t){console.log(c.gray("Aborted."));return}}let i=h(`Destroying ${e}\u2026`).start();try{await y(`/apps/${encodeURIComponent(e)}`,{method:"DELETE",headers:r,body:JSON.stringify({confirm:!0})}),i.succeed(`Destroyed ${e}`)}catch(t){i.fail(`Destroy failed: ${t.message}`),process.exit(1)}}async function no(e,o={}){e||(console.error(c.red("Missing <instanceId>.")),process.exit(1));let r=await w(o);if(!o.yes){let{confirm:a}=await C.prompt([{type:"confirm",name:"confirm",message:o.version?`Upgrade ${e} to ghcr.io/zibbyhq/agent-ops:${o.version}? EFS data is preserved.`:`Upgrade ${e} to the latest base image? EFS data is preserved.`,default:!0}]);if(!a){console.log(c.gray("Aborted."));return}}let i=o.version?`?version=${encodeURIComponent(o.version)}`:"",t=h(`Upgrading ${e}\u2026`).start();try{let a=await y(`/apps/${encodeURIComponent(e)}/upgrade${i}`,{method:"POST",headers:r});t.succeed(`Upgrade rolling out for ${e}`),console.log(),console.log(` taskDefinitionArn: ${a?.taskDefinitionArn||"\u2014"}`),a?.imageOverride&&console.log(` image: ${a.imageOverride}`),console.log(),console.log(c.gray(" ECS rolls the service: new task pulls image, then swaps over. EFS data preserved.")),console.log(c.gray(` Watch: zibby app status ${e}`)),console.log()}catch(a){t.fail(`Upgrade failed: ${a.message}`),process.exit(1)}}async function ro(e,o={}){e||(console.error(c.red("Missing <instanceId>.")),process.exit(1));let r=await w(o),i=h(`Rotating Claude credential on ${e}\u2026`).start();try{let t=await y(`/apps/${encodeURIComponent(e)}/credentials`,{method:"POST",headers:r,body:"{}"});i.succeed(`Credential update rolling out for ${e}`),console.log(),console.log(` mode ${t?.mode||"\u2014"}`),console.log(` taskDefinitionArn ${t?.taskDefinitionArn||"\u2014"}`),console.log(),console.log(c.gray(" ECS rolls the service: new task pulls the new env, swaps over once healthy.")),console.log(c.gray(` Watch: zibby app status ${e}`)),console.log()}catch(t){i.fail(`Credential update failed: ${t.message}`),process.exit(1)}}var H=3e3;function W(e,o={}){if(o.verbose)return e;let r=e.indexOf(" ");if(r<0)return e;let i=e.slice(0,r),t=e.slice(r+2),a=i.length>=19?i.slice(11,19):i;try{let s=JSON.parse(t),l=(s.level||"INFO").padEnd(4),n=s.msg||s.message||"",p=Object.entries(s).filter(([d])=>!["time","level","msg","message"].includes(d)).filter(([,d])=>d!==""&&d!==null&&d!==void 0).map(([d,v])=>`${d}=${typeof v=="string"?v:JSON.stringify(v)}`).join(" "),g=l.startsWith("ERR")||l.startsWith("FAIL")?c.red:l.startsWith("WARN")?c.yellow:c.gray;return`${c.dim(a)} ${g(l)} ${n}${p?" "+c.dim(p):""}`}catch{return`${c.dim(a)} ${t}`}}async function so(e,o={}){e||(console.error(c.red("Missing <instanceId>.")),process.exit(1));let r=await w(o),i=Math.min(Math.max(Number(o.lines)||200,1),5e3),t=o.service?`&container=${encodeURIComponent(String(o.service))}`:"",a=async()=>await y(`/apps/${encodeURIComponent(e)}/logs?lines=${i}${t}`,{method:"GET",headers:r});if(!o.follow){try{let n=await a(),p=Array.isArray(n?.lines)?n.lines:[];if(o.json)for(let g of p)console.log(g);else{p.length===0&&console.log(c.gray(" (no log events in window)"));for(let g of p)console.log(W(g,o))}}catch(n){console.error(c.red(`\xD7 ${n.message}`)),process.exit(1)}return}let s=new Set;console.log(c.gray(`Tailing logs for ${e} \u2014 Ctrl+C to stop
26
+ `));let l=!1;for(process.on("SIGINT",()=>{l=!0,console.log(c.gray(`
27
+ Stopped.`)),process.exit(0)});!l;){try{let n=await a(),p=Array.isArray(n?.lines)?n.lines:[];for(let g of p)s.has(g)||(s.add(g),console.log(o.json?g:W(g,o)));if(s.size>i*2){let g=Array.from(s).slice(-i);s.clear(),g.forEach(d=>s.add(d))}}catch(n){console.error(c.red(` \xD7 ${n.message} \u2014 retrying in ${H/1e3}s`))}await new Promise(n=>setTimeout(n,H))}}export{eo as appDeployCommand,to as appDestroyCommand,Xe as appListCommand,so as appLogsCommand,oo as appStatusCommand,Qe as appTemplatesCommand,ro as appUpdateCredentialCommand,no as appUpgradeCommand};
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zibby/cli",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "Zibby CLI - Test automation generator and runner",
5
5
  "type": "module",
6
6
  "bin": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zibby/cli",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "Zibby CLI - Test automation generator and runner",
5
5
  "type": "module",
6
6
  "bin": {