@zibby/cli 0.1.87 → 0.1.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -848
- package/dist/bin/zibby.js +47 -2
- package/dist/commands/chat.js +1 -1
- package/dist/commands/workflow.js +19 -19
- package/dist/commands/workflows/agent-helpers.js +18 -0
- package/dist/commands/workflows/deploy-helpers.js +1 -1
- package/dist/commands/workflows/deploy.js +49 -26
- package/dist/commands/workflows/env-helpers.js +2 -0
- package/dist/commands/workflows/env.js +39 -0
- package/dist/commands/workflows/generate.js +48 -31
- package/dist/commands/workflows/input-helpers.js +7 -0
- package/dist/commands/workflows/list.js +2 -2
- package/dist/commands/workflows/logs.js +33 -33
- package/dist/commands/workflows/run-helpers.js +2 -0
- package/dist/commands/workflows/run-local.js +19 -0
- package/dist/commands/workflows/run.js +5 -7
- package/dist/commands/workflows/start.js +11 -11
- package/dist/commands/workflows/trigger.js +9 -9
- package/dist/package.json +4 -4
- package/dist/templates/zibby-workflow-claude/agents-md-block.md +113 -0
- package/dist/templates/zibby-workflow-claude/claude/agents/zibby-test-author.md +72 -0
- package/dist/templates/zibby-workflow-claude/claude/agents/zibby-workflow-builder.md +81 -0
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-add-node.md +75 -0
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-debug.md +67 -0
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-delete.md +37 -0
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-deploy.md +77 -0
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-list.md +30 -0
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-static-ip.md +68 -0
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-tail.md +53 -0
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-test-debug.md +59 -0
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-test-generate.md +39 -0
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-test-run.md +48 -0
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-test-write.md +46 -0
- package/dist/templates/zibby-workflow-claude/claude/commands/zibby-trigger.md +52 -0
- package/dist/templates/zibby-workflow-claude/claude/settings.json +10 -0
- package/dist/templates/zibby-workflow-claude/cursor/rules/zibby-workflows.mdc +56 -0
- package/dist/templates/zibby-workflow-claude/manifest.json +43 -0
- package/package.json +4 -4
package/dist/bin/zibby.js
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
process.stdout.on("error",o=>{o.code}),process.stderr.on("error",o=>{o.code}),process.env.DOTENV_CONFIG_QUIET="true";import"@zibby/skills";import{Command as
|
|
3
|
-
`),S(process.cwd());const Z=n[0]==="chat",Y=["--verbose","--agent","--stream","-s"],O=n.length>0&&n.every(o=>Y.includes(o)||n[n.indexOf(o)-1]==="--agent"),z=n.length===0||Z||O;if(z&&!j){const o={},e=n.indexOf("--agent");e!==-1&&n[e+1]&&(o.agent=n[e+1]),n.includes("--verbose")&&(o.verbose=!0),(n.includes("--stream")||n.includes("-s"))&&(o.stream=!0);const{chatCommand:i}=await import("../commands/chat.js");await i(o),process.exit(0)}const t=new m;t.name("zibby").description("Zibby Test Automation - AI-powered test generation").version(s.version,"-V, --version"),t.command("init").description("Initialize a new Zibby test project (like rails new)").argument("[project-name]","Project name (optional, uses current directory if not provided)").option("--agent <type>","Agent to use (claude, cursor, codex, gemini)").option("--memory-backend <backend>","Memory backend to configure (dolt, mem0)","dolt").option("--skip-install","Skip npm install").option("--skip-memory","Skip test memory setup during initialization").option("-f, --force","Force reinitialize (overwrite existing config)").option("--headed","Run MCP browser in headed mode (visible browser)").option("--headless","Run MCP browser in headless mode (hidden browser)").option("--api-key <key>","Zibby API key for cloud sync").option("--cloud-sync","Enable cloud sync and install Zibby MCP").action(u),t.command("test").description("Run a test specification").argument("[spec-path]","Path to test spec file or inline test description in quotes").option("--sources <ids>","Comma-separated test case IDs to fetch from cloud").option("--execution <id>","Execution ID containing the test cases (required with --sources)").option("--agent <type>","Agent to use (claude, cursor, codex, gemini) - overrides config").option("--workflow <name>","Workflow to use (e.g., QuickSmokeWorkflow, quick-smoke)").option("--headless","Run browser in headless mode").option("--node <name>","Run only a specific node (e.g., execute_live, generate_script)").option("--session <id>",'Use existing session (e.g., 1768974629717 or "last") - requires --node').option("--session-path <dir>","Use this session folder (absolute or relative to cwd); Studio pins artifacts here").option("--project <id>","Project ID (optional, auto-detected from ZIBBY_API_KEY)").option("--collection <id-or-name>","Collection ID or name (creates new if name doesn't exist)").option("--folder <path>","Folder path within collection (optional, requires --collection)").option("--sync","Force upload to cloud (overrides cloudSync: false)").option("--no-sync","Skip upload to cloud (overrides cloudSync: true)").option("--config <path>","Path to config file",".zibby.config.mjs").option("--auto-approve","Auto-approve MCP tools (for CI/CD)").option("-o, --open","Open test results in browser after completion").option("--verbose","Show info level logs").option("--debug","Show debug level logs (most verbose)").option("-m, --mem","Enable test memory (Dolt-backed knowledge from previous runs)").action((o,e)=>(e.debug?process.env.ZIBBY_DEBUG="true":e.verbose&&(process.env.ZIBBY_VERBOSE="true"),w(o,e))),t.command("implement").description("Implement a Jira ticket using AI agent (runs in ECS container)").action(async(...o)=>{const{implementCommand:e}=await import("../commands/implement.js");return e(...o)}),t.command("analyze").description("Analyze a Jira ticket against the codebase (runs in ECS container)").option("--workflow <path>","Path to a local workflow JSON file (e.g., .zibby/workflow-analysis.json)").action(async(...o)=>{const{analyzeCommand:e}=await import("../commands/analyze-graph.js");return e(...o)}),t.command("video").description("Organize test videos next to test files").action(f),t.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(y),t.command("login").description("Log in to Zibby (opens browser for authentication)").action(async()=>{const{loginCli:o}=await import("../auth/cli-login.js");await o(),process.exit(0)}),t.command("logout").description("Log out from Zibby (clears saved session)").action(async()=>{const{logoutCli:o}=await import("../auth/cli-login.js");o(),process.exit(0)}),t.command("status").description("Show current authentication status and token details").option("--json","Output in JSON format (for scripts)").action(async o=>{const{showLoginStatus:e}=await import("../auth/cli-login.js");await e(o),process.exit(0)}),t.command("list").description("List your projects and API tokens").action(async()=>{const{listProjectsCommand:o}=await import("../commands/list-projects.js");await o()}),t.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(g),t.command("setup-playwright").description("Setup official Playwright MCP (from cursor-agent-package)").option("--headed","Configure MCP in headed mode (visible browser)").option("--viewport-width <width>","Viewport width (default: 1280)","1280").option("--viewport-height <height>","Viewport height (default: 720)","720").action(o=>{const e={width:parseInt(o.viewportWidth,10)||1280,height:parseInt(o.viewportHeight,10)||720};return k({...o,viewport:e})}),t.command("setup-ci-full").description("Complete CI/CD setup from scratch").action(b),t.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(h),t.command("generate").description("Generate test specs from a ticket + codebase (local analysis using real AI agent)").option("-t, --ticket <key>","Jira ticket key (fetches automatically)").option("-i, --input <file>","Input file with ticket description/requirements").option("-d, --description <text>","Inline ticket description").option("--repo <path>","Path to the codebase (default: current directory)").option("--agent <type>","Agent to use (codex, claude, cursor, gemini)").option("--model <model>","Model override").option("-o, --output <dir>","Output directory for spec files (default: test-specs)").action(async o=>{const{generateCommand:e}=await import("../commands/generate.js");return e(o)}),t.command("studio").description("Launch Zibby Studio desktop (installs from CDN if needed). Uses this folder as the Zibby project.").option("-p, --port <port>","Port for the Studio API bridge (default: 3847)").option("--no-open","Start the API only; do not launch desktop app").option("--update","Force re-download of the latest Studio binary").action(async o=>{const{studioCommand:e}=await import("../commands/studio.js");return e(o)});const R=t.command("g").description("Generate scaffolds");R.command("workflow [name]").description("Scaffold a new custom workflow in .zibby/workflows/<name>/ (auto-generates name if omitted)").option("--skip-install","Skip running `npm install` in the new workflow folder").action(async(o,e)=>{const{generateWorkflowCommand:i}=await import("../commands/workflows/generate.js");return i(o,e)}),t.command("start <workflow-name>").description("Start a local dev server for a custom workflow").option("-p, --port <port>","Port for the workflow server (default: 3848)").action(async(o,e)=>{const{startWorkflowCommand:i}=await import("../commands/workflows/start.js");return i(o,e)}),t.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("--verbose","Show raw CodeBuild logs during the bundle build").action(async(o,e)=>{if(e.dedicatedIp){const{dedicatedEgressCommand:d}=await import("../commands/workflows/dedicated-egress.js");return d(e.dedicatedIp,e.project)}const{deployWorkflowCommand:i}=await import("../commands/workflows/deploy.js");return i(o,e)}),t.command("trigger [uuid]").description("Trigger a deployed workflow by UUID (interactive selection if not provided). Get UUIDs from `zibby workflow list`.").option("--project <id>","Project ID (interactive prompt if not provided, or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("-p, --param <key=value>","Input param (repeatable, e.g. -p url=https://x.com -p count=5)",c,[]).option("--input <json>",`Input as JSON string \u2014 overridden by --param (e.g. '{"key":"value"}')`).option("--input-file <path>","Input as JSON/YAML file \u2014 lowest precedence").option("--idempotency-key <key>","Idempotency key to prevent duplicate executions").action(async(o,e)=>{const{triggerWorkflowCommand:i}=await import("../commands/workflows/trigger.js");return i(o,e)}),t.command("logs [jobId]").description("Fetch and display logs from a workflow execution (use -t to stream in real-time)").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--workflow <name>","Workflow name (fetches the latest run)").option("--all","Show interleaved logs from all runs (requires --workflow)").option("-t, --follow","Stream logs in real-time (like Heroku logs -t)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--lines <n>","Max log lines per fetch (default: 500)").action(async(o,e)=>{const{logsCommand:i}=await import("../commands/workflows/logs.js");return i(o,e)}),t.command("run-workflow").description("Run a deployed workflow from S3 sources (used by ECS containers)").action(async()=>{const{runWorkflowCommand:o}=await import("../commands/workflows/run.js");return o()});const a=t.command("memory").description("Test memory database \u2014 version-controlled knowledge from runs");a.command("stats").description("Show memory database statistics").action(async()=>{const{memoryStatsCommand:o}=await import("../commands/memory.js");return o()}),a.command("init").description("Initialize the memory database (Dolt)").action(async()=>{const{memoryInitCommand:o}=await import("../commands/memory.js");return o()}),a.command("compact").description("Prune old data and run Dolt GC to reclaim storage").option("--max-runs <n>","Keep last N runs per spec (default: 50)",parseInt).option("--max-age <days>","Remove data older than N days (default: 90)",parseInt).action(async o=>{const{memoryCompactCommand:e}=await import("../commands/memory.js");return e(o)}),a.command("reset").description("Wipe the memory database").option("-f, --force","Confirm reset").action(async o=>{const{memoryResetCommand:e}=await import("../commands/memory.js");return e(o)});const r=t.command("workflow").description("Manage workflow graphs \u2014 new, start, deploy, trigger, logs, list, download, delete");r.command("new [name]").description("Scaffold a new custom workflow (alias of `zibby g workflow`)").option("--skip-install","Skip running `npm install` in the new workflow folder").action(async(o,e)=>{const{generateWorkflowCommand:i}=await import("../commands/workflows/generate.js");return i(o,e)}),r.command("start <workflow-name>").description("Start a local dev server for a workflow (alias of `zibby start`)").option("-p, --port <port>","Port for the workflow server (default: 3848)").action(async(o,e)=>{const{startWorkflowCommand:i}=await import("../commands/workflows/start.js");return i(o,e)}),r.command("deploy [workflow-name]").description("Deploy a workflow to Zibby Cloud (alias of `zibby deploy`)").option("--project <id>","Project ID (interactive prompt if not provided, or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--verbose","Show raw CodeBuild logs during the bundle build").action(async(o,e)=>{const{deployWorkflowCommand:i}=await import("../commands/workflows/deploy.js");return i(o,e)}),r.command("trigger [uuid]").description("Trigger a deployed workflow by UUID (alias of `zibby trigger`)").option("--project <id>","Project ID (interactive prompt if not provided, or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("-p, --param <key=value>","Input param (repeatable, e.g. -p url=https://x.com -p count=5)",c,[]).option("--input <json>",`Input as JSON string \u2014 overridden by --param (e.g. '{"key":"value"}')`).option("--input-file <path>","Input as JSON/YAML file \u2014 lowest precedence").option("--idempotency-key <key>","Idempotency key to prevent duplicate executions").action(async(o,e)=>{const{triggerWorkflowCommand:i}=await import("../commands/workflows/trigger.js");return i(o,e)}),r.command("logs [jobId]").description("Tail logs from a workflow execution (alias of `zibby logs`)").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--workflow <name>","Workflow name (fetches the latest run)").option("--all","Show interleaved logs from all runs (requires --workflow)").option("-t, --follow","Stream logs in real-time (like Heroku logs -t)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--lines <n>","Max log lines per fetch (default: 500)").action(async(o,e)=>{const{logsCommand:i}=await import("../commands/workflows/logs.js");return i(o,e)}),r.command("download [uuid]").description("Download a workflow from Zibby Cloud to .zibby/workflows/<name>/. Pass a UUID (from `zibby workflow list`) for custom workflows, or use --type for built-ins.").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--type <type>","Built-in workflow type: analysis, implementation, run_test (alternative to positional <uuid>)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--output <dir>","Output directory base (default: .zibby/workflows)").option("--include-default","Download the built-in default graph if no custom one exists").action(async(o,e)=>{const{workflowDownloadCommand:i}=await import("../commands/workflow.js");return i({...e,uuid:o})}),r.command("list").description("List all workflows (local + remote if credentials available)").option("--local-only","Show only local workflows").option("--remote-only","Show only remote workflows (requires --project)").option("--project <id>","Project ID (optional, uses ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async o=>{if(o.remoteOnly){const{workflowListCommand:i}=await import("../commands/workflow.js");return i(o)}if(o.localOnly){const{listLocalWorkflowsCommand:i}=await import("../commands/workflows/list.js");return i(o)}const{listAllWorkflowsCommand:e}=await import("../commands/workflows/list.js");return e(o)}),r.command("delete <uuid>").description("Delete a deployed workflow by UUID").action(async o=>{const{deleteWorkflowCommand:e}=await import("../commands/workflows/delete.js");return e(o,{})});const W=t.command("project").description("Manage Zibby projects");W.command("list").description("List all projects").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async o=>{const{projectListCommand:e}=await import("../commands/project.js");return e(o)});const J=t.command("run-queue").description("Parallel capacity \u2014 on-disk wait queue (see parallel.waitWhenAtCapacity in .zibby.config.mjs)");J.command("list").description("List CLI processes waiting for a run slot").option("--config <path>","Path to config file",".zibby.config.mjs").action(async o=>{const{runCapacityQueueListCommand:e}=await import("../commands/run-capacity-queue-cli.js");await e(o),process.exit(0)}),t.command("uninstall").description("Remove all Zibby data: global CLI, ~/.zibby, Cursor MCP config, Studio, and current project").option("--dry-run","Show what would be deleted without deleting").option("--deep","Also remove npx cache dirs containing zibby").action(async o=>{const{uninstallCommand:e}=await import("../commands/uninstall.js");await e(o),process.exit(0)}),t.parse();
|
|
2
|
+
process.stdout.on("error",o=>{o.code}),process.stderr.on("error",o=>{o.code}),process.env.DOTENV_CONFIG_QUIET="true";import"@zibby/skills";import{Command as w}from"commander";import{initCommand as f}from"../commands/init.js";import{runCommand as y}from"../commands/run.js";import{videoCommand as g}from"../commands/video.js";import{uploadCommand as k}from"../commands/upload.js";import{ciSetupCommand as h}from"../commands/ci-setup.js";import{setupPlaywrightMcpCommand as b,setupCiCommand as v,testWithVideoCommand as I}from"../commands/setup-scripts.js";import{readFileSync as C}from"fs";import{fileURLToPath as P}from"url";import{dirname as S,join as B}from"path";import{bootstrapAgentEnv as A}from"../utils/agent-credentials.js";const _=P(import.meta.url),j=S(_),d=JSON.parse(C(B(j,"../package.json"),"utf-8"));function s(o,e){return e.push(o),e}const m=`zibby v${d.version}`,i=process.argv.slice(2),x=i.includes("-h")||i.includes("--help"),E=i.includes("-v")||i.includes("-V")||i.includes("--version");E&&(console.log(m),process.exit(0));const u=i[0],D=i[1],Y=["logs","uninstall"],Z=u==="workflow"&&D==="list";!Y.includes(u)&&!Z&&console.log(`${m}
|
|
3
|
+
`),A(process.cwd());const O=i[0]==="chat",z=["--verbose","--agent","--stream","-s"],R=i.length>0&&i.every(o=>z.includes(o)||i[i.indexOf(o)-1]==="--agent"),J=i.length===0||O||R;if(J&&!x){const o={},e=i.indexOf("--agent");e!==-1&&i[e+1]&&(o.agent=i[e+1]),i.includes("--verbose")&&(o.verbose=!0),(i.includes("--stream")||i.includes("-s"))&&(o.stream=!0);const{chatCommand:t}=await import("../commands/chat.js");await t(o),process.exit(0)}const n=new w;n.name("zibby").description("Zibby \u2014 the cloud pipeline for Claude Code, Cursor, Codex, and Gemini. Compose them into structured workflows with schema-enforced handoff.").version(d.version,"-V, --version"),n.configureHelp({visibleCommands:()=>[]}),n.addHelpText("after",`
|
|
4
|
+
Workflow (the platform):
|
|
5
|
+
workflow new <name> Scaffold a new workflow at .zibby/workflows/<name>/
|
|
6
|
+
workflow run <name> Run a workflow locally (one-shot, mirrors trigger flags)
|
|
7
|
+
workflow list Show local + cloud workflows
|
|
8
|
+
workflow deploy <name> Build bundle + upload to cloud
|
|
9
|
+
workflow trigger <uuid> Trigger a deployed workflow remotely
|
|
10
|
+
workflow logs <uuid> [-t] Fetch (or tail) execution logs
|
|
11
|
+
workflow download <uuid> Pull a cloud workflow source locally
|
|
12
|
+
workflow delete <uuid> Destroy a cloud workflow
|
|
13
|
+
workflow start <name> Long-lived local dev server (Studio integration)
|
|
14
|
+
|
|
15
|
+
Built-in workflow recipes (vertical slices on top of the platform):
|
|
16
|
+
test <spec-path> Browser test workflow \u2014 agent drives the browser, generates Playwright + video
|
|
17
|
+
video Organize / regenerate verification videos for a test
|
|
18
|
+
analyze Analyze a Jira ticket against the codebase
|
|
19
|
+
generate Generate test specs from a ticket + codebase
|
|
20
|
+
|
|
21
|
+
Project + auth:
|
|
22
|
+
login Browser login \u2192 ~/.zibby/config.json
|
|
23
|
+
logout Clear saved session
|
|
24
|
+
status Show current auth + project context
|
|
25
|
+
list List your projects + API tokens
|
|
26
|
+
|
|
27
|
+
Studio + advanced:
|
|
28
|
+
studio Launch Zibby Studio desktop (replay & debug runs)
|
|
29
|
+
init [project] Bootstrap a Zibby project in a folder (legacy scaffold)
|
|
30
|
+
upload <spec-path> Upload existing test artifacts to cloud
|
|
31
|
+
ci-setup Patch Cursor Agent for CI/CD
|
|
32
|
+
setup-playwright Install official Playwright MCP
|
|
33
|
+
setup-ci-full Generate GitHub Actions yaml for the test recipe
|
|
34
|
+
test-video Run Playwright tests with video recording
|
|
35
|
+
g Generate scaffolds (alias for 'generate')
|
|
36
|
+
|
|
37
|
+
Examples:
|
|
38
|
+
$ zibby workflow new my-pipeline # scaffold a multi-agent CI/CD pipeline
|
|
39
|
+
$ zibby workflow run my-pipeline -p ticket=BUG-123 # run it locally with input
|
|
40
|
+
$ zibby workflow deploy my-pipeline # ship to cloud (returns UUID)
|
|
41
|
+
$ zibby workflow trigger <uuid> -p ticket=BUG-123 # trigger remotely with same flags
|
|
42
|
+
|
|
43
|
+
$ zibby test "go to example.com, verify title is 'Example Domain'"
|
|
44
|
+
# run the built-in browser-test recipe
|
|
45
|
+
|
|
46
|
+
Docs: https://docs.zibby.app
|
|
47
|
+
GitHub: https://github.com/ZibbyHQ/zibby-agent
|
|
48
|
+
`),n.command("init").description("Initialize a new Zibby test project (like rails new)").argument("[project-name]","Project name (optional, uses current directory if not provided)").option("--agent <type>","Agent to use (claude, cursor, codex, gemini)").option("--memory-backend <backend>","Memory backend to configure (dolt, mem0)","dolt").option("--skip-install","Skip npm install").option("--skip-memory","Skip test memory setup during initialization").option("-f, --force","Force reinitialize (overwrite existing config)").option("--headed","Run MCP browser in headed mode (visible browser)").option("--headless","Run MCP browser in headless mode (hidden browser)").option("--api-key <key>","Zibby API key for cloud sync").option("--cloud-sync","Enable cloud sync and install Zibby MCP").action(f),n.command("test").description("Run a test specification").argument("[spec-path]","Path to test spec file or inline test description in quotes").option("--sources <ids>","Comma-separated test case IDs to fetch from cloud").option("--execution <id>","Execution ID containing the test cases (required with --sources)").option("--agent <type>","Agent to use (claude, cursor, codex, gemini) - overrides config").option("--workflow <name>","Workflow to use (e.g., QuickSmokeWorkflow, quick-smoke)").option("--headless","Run browser in headless mode").option("--node <name>","Run only a specific node (e.g., execute_live, generate_script)").option("--session <id>",'Use existing session (e.g., 1768974629717 or "last") - requires --node').option("--session-path <dir>","Use this session folder (absolute or relative to cwd); Studio pins artifacts here").option("--project <id>","Project ID (optional, auto-detected from ZIBBY_API_KEY)").option("--collection <id-or-name>","Collection ID or name (creates new if name doesn't exist)").option("--folder <path>","Folder path within collection (optional, requires --collection)").option("--sync","Force upload to cloud (overrides cloudSync: false)").option("--no-sync","Skip upload to cloud (overrides cloudSync: true)").option("--config <path>","Path to config file",".zibby.config.mjs").option("--auto-approve","Auto-approve MCP tools (for CI/CD)").option("-o, --open","Open test results in browser after completion").option("--verbose","Show info level logs").option("--debug","Show debug level logs (most verbose)").option("-m, --mem","Enable test memory (Dolt-backed knowledge from previous runs)").action((o,e)=>(e.debug?process.env.ZIBBY_DEBUG="true":e.verbose&&(process.env.ZIBBY_VERBOSE="true"),y(o,e))),n.command("implement").description("Implement a Jira ticket using AI agent (runs in ECS container)").action(async(...o)=>{const{implementCommand:e}=await import("../commands/implement.js");return e(...o)}),n.command("analyze").description("Analyze a Jira ticket against the codebase (runs in ECS container)").option("--workflow <path>","Path to a local workflow JSON file (e.g., .zibby/workflow-analysis.json)").action(async(...o)=>{const{analyzeCommand:e}=await import("../commands/analyze-graph.js");return e(...o)}),n.command("video").description("Organize test videos next to test files").action(g),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(k),n.command("login").description("Log in to Zibby (opens browser for authentication)").action(async()=>{const{loginCli:o}=await import("../auth/cli-login.js");await o(),process.exit(0)}),n.command("logout").description("Log out from Zibby (clears saved session)").action(async()=>{const{logoutCli:o}=await import("../auth/cli-login.js");o(),process.exit(0)}),n.command("status").description("Show current authentication status and token details").option("--json","Output in JSON format (for scripts)").action(async o=>{const{showLoginStatus:e}=await import("../auth/cli-login.js");await e(o),process.exit(0)}),n.command("list").description("List your projects and API tokens").action(async()=>{const{listProjectsCommand:o}=await import("../commands/list-projects.js");await o()}),n.command("ci-setup").description("Setup Cursor Agent for CI/CD (patch and configure)").option("--get-keys","Get MCP approval keys").option("--save","Save approval keys to project").action(h),n.command("setup-playwright").description("Setup official Playwright MCP (from cursor-agent-package)").option("--headed","Configure MCP in headed mode (visible browser)").option("--viewport-width <width>","Viewport width (default: 1280)","1280").option("--viewport-height <height>","Viewport height (default: 720)","720").action(o=>{const e={width:parseInt(o.viewportWidth,10)||1280,height:parseInt(o.viewportHeight,10)||720};return b({...o,viewport:e})}),n.command("setup-ci-full").description("Complete CI/CD setup from scratch").action(v),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(I),n.command("generate").description("Generate test specs from a ticket + codebase (local analysis using real AI agent)").option("-t, --ticket <key>","Jira ticket key (fetches automatically)").option("-i, --input <file>","Input file with ticket description/requirements").option("-d, --description <text>","Inline ticket description").option("--repo <path>","Path to the codebase (default: current directory)").option("--agent <type>","Agent to use (codex, claude, cursor, gemini)").option("--model <model>","Model override").option("-o, --output <dir>","Output directory for spec files (default: test-specs)").action(async o=>{const{generateCommand:e}=await import("../commands/generate.js");return e(o)}),n.command("studio").description("Launch Zibby Studio desktop (installs from CDN if needed). Uses this folder as the Zibby project.").option("-p, --port <port>","Port for the Studio API bridge (default: 3847)").option("--no-open","Start the API only; do not launch desktop app").option("--update","Force re-download of the latest Studio binary").action(async o=>{const{studioCommand:e}=await import("../commands/studio.js");return e(o)});const U=n.command("g").description("Generate scaffolds");U.command("workflow [name]").description("Scaffold a new custom workflow in .zibby/workflows/<name>/ (auto-generates name if omitted)").option("--skip-install","Skip running `npm install` in the new workflow folder").option("--agent <agent>","Set up agent helpers without prompting: claude | cursor | codex | all | none").option("--force-agents","Overwrite user-edited agent helper files (use with --agent)").action(async(o,e)=>{const{generateWorkflowCommand:t}=await import("../commands/workflows/generate.js");return t(o,e)}),n.command("start <workflow-name>").description("Start a local dev server for a custom workflow").option("-p, --port <port>","Port for the workflow server (default: 3848)").action(async(o,e)=>{const{startWorkflowCommand:t}=await import("../commands/workflows/start.js");return t(o,e)}),n.command("run <workflow-name>").description("Run a workflow locally \u2014 one-shot (alias of `zibby workflow run`)").option("-p, --param <key=value>","Input param (repeatable)",s,[]).option("--input <json>","Input as JSON string").option("--input-file <path>","Input as JSON file").action(async(o,e)=>{const{runLocalWorkflowCommand:t}=await import("../commands/workflows/run-local.js");return t(o,e)}),n.command("deploy [workflow-name]").description("Deploy a custom workflow to Zibby Cloud (interactive selection if workflow-name not provided)").option("--project <id>","Project ID (interactive prompt if not provided, or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--dedicated-ip <action>","Manage dedicated egress IP addon: enable | status | disable | use | unuse").option("--env <path>","Path to a .env file to sync into per-workflow env vars after deploy (repeatable)",s,[]).option("--verbose","Show raw CodeBuild logs during the bundle build").action(async(o,e)=>{if(e.dedicatedIp){const{dedicatedEgressCommand:a}=await import("../commands/workflows/dedicated-egress.js");return a(e.dedicatedIp,e.project)}const{deployWorkflowCommand:t}=await import("../commands/workflows/deploy.js");return t(o,e)}),n.command("trigger [uuid]").description("Trigger a deployed workflow by UUID (interactive selection if not provided). Get UUIDs from `zibby workflow list`.").option("--project <id>","Project ID (interactive prompt if not provided, or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("-p, --param <key=value>","Input param (repeatable, e.g. -p url=https://x.com -p count=5)",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").action(async(o,e)=>{const{triggerWorkflowCommand:t}=await import("../commands/workflows/trigger.js");return t(o,e)}),n.command("logs [jobId]").description("Fetch and display logs from a workflow execution (use -t to stream in real-time)").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--workflow <name>","Workflow name (fetches the latest run)").option("--all","Show interleaved logs from all runs (requires --workflow)").option("-t, --follow","Stream logs in real-time (like Heroku logs -t)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--lines <n>","Max log lines per fetch (default: 500)").action(async(o,e)=>{const{logsCommand:t}=await import("../commands/workflows/logs.js");return t(o,e)}),n.command("run-workflow").description("Run a deployed workflow from S3 sources (used by ECS containers)").action(async()=>{const{runWorkflowCommand:o}=await import("../commands/workflows/run.js");return o()});const l=n.command("memory").description("Test memory database \u2014 version-controlled knowledge from runs");l.command("stats").description("Show memory database statistics").action(async()=>{const{memoryStatsCommand:o}=await import("../commands/memory.js");return o()}),l.command("init").description("Initialize the memory database (Dolt)").action(async()=>{const{memoryInitCommand:o}=await import("../commands/memory.js");return o()}),l.command("compact").description("Prune old data and run Dolt GC to reclaim storage").option("--max-runs <n>","Keep last N runs per spec (default: 50)",parseInt).option("--max-age <days>","Remove data older than N days (default: 90)",parseInt).action(async o=>{const{memoryCompactCommand:e}=await import("../commands/memory.js");return e(o)}),l.command("reset").description("Wipe the memory database").option("-f, --force","Confirm reset").action(async o=>{const{memoryResetCommand:e}=await import("../commands/memory.js");return e(o)});const L=n.command("agents").description("Manage Claude/Cursor/Codex helper files for working with Zibby workflows");L.command("add [agent]").description("Add agent helpers (claude | cursor | codex | all). Prompts if no agent given.").option("--force","Overwrite user-edited helper files").action(async(o,e)=>{const{runAgentHelpers:t,addAgent:a}=await import("../commands/workflows/agent-helpers.js");if(o){const p=["claude","cursor","codex","all","none"];p.includes(o)||(console.error(`Unknown agent "${o}". Valid: ${p.join(", ")}`),process.exit(1)),o==="none"?await t({forcedAgents:["none"],force:e.force===!0}):o==="all"?await t({forcedAgents:["claude","cursor","codex"],force:e.force===!0}):await a(o,{force:e.force===!0})}else await t({forcedAgents:void 0,force:e.force===!0,forcePrompt:!0})});const r=n.command("workflow").description("Manage workflow graphs \u2014 new, start, deploy, trigger, logs, list, download, delete");r.command("new [name]").description("Scaffold a new custom workflow (alias of `zibby g workflow`)").option("--skip-install","Skip running `npm install` in the new workflow folder").option("--agent <agent>","Set up agent helpers without prompting: claude | cursor | codex | all | none").option("--force-agents","Overwrite user-edited agent helper files (use with --agent)").action(async(o,e)=>{const{generateWorkflowCommand:t}=await import("../commands/workflows/generate.js");return t(o,e)}),r.command("run <workflow-name>").description("Run a workflow locally \u2014 one-shot, same input flags as `workflow trigger`").option("-p, --param <key=value>","Input param (repeatable, e.g. -p url=https://x.com -p count=5)",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(o,e)=>{const{runLocalWorkflowCommand:t}=await import("../commands/workflows/run-local.js");return t(o,e)}),r.command("start <workflow-name>").description("Start a long-lived local dev server (Studio integration). Prefer `workflow run` for one-shots.").option("-p, --port <port>","Port for the workflow server (default: 3848)").action(async(o,e)=>{const{startWorkflowCommand:t}=await import("../commands/workflows/start.js");return t(o,e)}),r.command("deploy [workflow-name]").description("Deploy a workflow to Zibby Cloud (alias of `zibby deploy`)").option("--project <id>","Project ID (interactive prompt if not provided, or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--env <path>","Path to a .env file to sync into per-workflow env vars after deploy (repeatable)",s,[]).option("--verbose","Show raw CodeBuild logs during the bundle build").action(async(o,e)=>{const{deployWorkflowCommand:t}=await import("../commands/workflows/deploy.js");return t(o,e)}),r.command("trigger [uuid]").description("Trigger a deployed workflow by UUID (alias of `zibby trigger`)").option("--project <id>","Project ID (interactive prompt if not provided, or ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("-p, --param <key=value>","Input param (repeatable, e.g. -p url=https://x.com -p count=5)",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").action(async(o,e)=>{const{triggerWorkflowCommand:t}=await import("../commands/workflows/trigger.js");return t(o,e)}),r.command("logs [jobId]").description("Tail logs from a workflow execution (alias of `zibby logs`)").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--workflow <name>","Workflow name (fetches the latest run)").option("--all","Show interleaved logs from all runs (requires --workflow)").option("-t, --follow","Stream logs in real-time (like Heroku logs -t)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--lines <n>","Max log lines per fetch (default: 500)").action(async(o,e)=>{const{logsCommand:t}=await import("../commands/workflows/logs.js");return t(o,e)}),r.command("download [uuid]").description("Download a workflow from Zibby Cloud to .zibby/workflows/<name>/. Pass a UUID (from `zibby workflow list`) for custom workflows, or use --type for built-ins.").option("--project <id>","Project ID (or ZIBBY_PROJECT_ID env)").option("--type <type>","Built-in workflow type: analysis, implementation, run_test (alternative to positional <uuid>)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").option("--output <dir>","Output directory base (default: .zibby/workflows)").option("--include-default","Download the built-in default graph if no custom one exists").action(async(o,e)=>{const{workflowDownloadCommand:t}=await import("../commands/workflow.js");return t({...e,uuid:o})}),r.command("list").description("List all workflows (local + remote if credentials available)").option("--local-only","Show only local workflows").option("--remote-only","Show only remote workflows (requires --project)").option("--project <id>","Project ID (optional, uses ZIBBY_PROJECT_ID env)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async o=>{if(o.remoteOnly){const{workflowListCommand:t}=await import("../commands/workflow.js");return t(o)}if(o.localOnly){const{listLocalWorkflowsCommand:t}=await import("../commands/workflows/list.js");return t(o)}const{listAllWorkflowsCommand:e}=await import("../commands/workflows/list.js");return e(o)}),r.command("delete <uuid>").description("Delete a deployed workflow by UUID").action(async o=>{const{deleteWorkflowCommand:e}=await import("../commands/workflows/delete.js");return e(o,{})});const c=r.command("env").description("Manage per-workflow encrypted env vars (set ANTHROPIC_API_KEY, DATABASE_URL, etc. per workflow)");c.command("list <uuid>").description("List env var key names for a workflow (values never returned)").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(o,e)=>{const{listEnvCommand:t}=await import("../commands/workflows/env.js");return t(o,e)}),c.command("set <uuid> <kv>").description("Set or update one env var: zibby workflow env set <uuid> KEY=value").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(o,e,t)=>{const{setEnvCommand:a}=await import("../commands/workflows/env.js");return a(o,e,t)}),c.command("unset <uuid> <key>").description("Remove one env var from a workflow").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async(o,e,t)=>{const{unsetEnvCommand:a}=await import("../commands/workflows/env.js");return a(o,e,t)}),c.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(o,e)=>{const{pushEnvCommand:t}=await import("../commands/workflows/env.js");return t(o,e)});const W=n.command("project").description("Manage Zibby projects");W.command("list").description("List all projects").option("--api-key <key>","API key (or ZIBBY_API_KEY env)").action(async o=>{const{projectListCommand:e}=await import("../commands/project.js");return e(o)});const M=n.command("run-queue").description("Parallel capacity \u2014 on-disk wait queue (see parallel.waitWhenAtCapacity in .zibby.config.mjs)");M.command("list").description("List CLI processes waiting for a run slot").option("--config <path>","Path to config file",".zibby.config.mjs").action(async o=>{const{runCapacityQueueListCommand:e}=await import("../commands/run-capacity-queue-cli.js");await e(o),process.exit(0)}),n.command("uninstall").description("Remove all Zibby data: global CLI, ~/.zibby, Cursor MCP config, Studio, and current project").option("--dry-run","Show what would be deleted without deleting").option("--deep","Also remove npx cache dirs containing zibby").action(async o=>{const{uninstallCommand:e}=await import("../commands/uninstall.js");await e(o),process.exit(0)}),n.parse();
|
package/dist/commands/chat.js
CHANGED
|
@@ -92,7 +92,7 @@ Use provided tools when external data/actions are required. Do not claim actions
|
|
|
92
92
|
- FIRST call get_skill_context("workflow-builder") to load the full framework reference.
|
|
93
93
|
- Conversation flow: ask about purpose \u2192 input data \u2192 processing steps \u2192 output format \u2192 conditional logic.
|
|
94
94
|
- Then call design_workflow to create a spec, review with user, then build_workflow to generate code.
|
|
95
|
-
- After building: remind user about \`zibby workflow
|
|
95
|
+
- After building: remind user about \`zibby workflow run <name>\` (run locally), \`zibby workflow deploy <name>\` (deploy), \`zibby workflow logs <uuid>\` (logs).
|
|
96
96
|
- Use list_workflows to show existing workflows, add_node to extend them, deploy_workflow to ship.`),B.includes("chat-memory"))try{let p=Pt("chat-memory");if(typeof p?.buildPromptContext=="function"){let I=Date.now(),S;st.data&&I-st.timestamp<M?(S=st.data,process.env.ZIBBY_VERBOSE==="true"&&i.pushSystem(o.gray("Using cached memory context"))):(S=await p.buildPromptContext({options:{workspace:t}},{}),st={data:S,timestamp:I},process.env.ZIBBY_VERBOSE==="true"&&i.pushSystem(o.gray("Refreshed memory context cache")));let T=String(S?.backend||"dolt");process.env.ZIBBY_VERBOSE==="true"&&(i.pushSystem(o.gray(`memory backend: ${T}`)),i.pushSystem(o.gray(`memory retrieval output: ${Yt(JSON.stringify(S?.debugPreview||{}),1400)}`)),S?.error&&i.pushSystem(o.yellow(`memory backend warning: ${S.error}`))),S?.promptContext&&(K+=`
|
|
97
97
|
|
|
98
98
|
${S.promptContext}`)}}catch(p){process.env.ZIBBY_VERBOSE==="true"&&i.pushSystem(o.yellow(`memory backend warning: ${String(p?.message||p)}`))}K=Ct(K,en);let an=co(N),Kt=lo([{role:"system",content:K},...an,{role:"user",content:Bt}]),Se=ae(Kt),un=Buffer.byteLength(JSON.stringify(Kt),"utf8");process.env.ZIBBY_VERBOSE==="true"&&i.pushSystem(o.gray(`payload estimate: ${Se} chars, ${un} bytes (~${Math.round(Se/4)} tokens)`)),N.push({role:"human",content:he});let St=i.enabled?(()=>{let p=()=>{};return p.setLabel=()=>{},p})():Ve(),ut=!0,Et=[],xe="",xt="",xo=50,ko=500,_o=3,vo=60,$o=500,Io=15,Ao=25,To=4,Po=new Set([".","!","?",",",";",":"]),pn=p=>{ut&&(St(),ut=!1),xt+=p},fn=(p,I)=>{if(!p){ut&&St.setLabel("thinking...");return}Et.push(p);let S=70,T=p;if(I&&typeof I=="object"){let v=Object.values(I).map(g=>typeof g=="string"?g:JSON.stringify(g)).join(", "),h=`${p}(${v})`;h.length<=S?T=h:T=`${p}(${v.slice(0,S-p.length-4)}...)`}T!==xe&&(xe=T,i.pushSystem(o.gray(`\u23BF ${T}`)),i.refreshPrompt({preserveInput:!0}),ut&&i.showAssistantLoading()),ut&&St.setLabel(T)},Xt=new AbortController;O=Xt;try{let p=await jn("",{state:{agentType:d,config:c,cwd:t,workspace:t}},{model:c?.agent?.assistant?.model||l.model||"auto",workspace:t,skills:B,activeSkills:B,config:c,timeout:l.timeout||3e5,messages:Kt,skipPromptFragments:!0,stream:!0,onToken:pn,onToolCall:fn,signal:Xt.signal});ut&&St();let I=typeof p=="string"?p:p?.structured?JSON.stringify(p.structured,null,2):p?.raw||String(p),S=xt&&xt.trim().length>0?xt.trim():I.trim(),T=po(S,Et)?S:fo(S);i.pushAssistant(T);let _=Et.length>0?`[tools used: ${Et.join(", ")}]
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import{readFileSync as Y,writeFileSync as U,existsSync as k,mkdirSync as x}from"fs";import{resolve as S,join as w}from"path";import o from"chalk";import v from"ora";import F from"dotenv";import L from"inquirer";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://account-api-prod.zibby.app",frontendUrl:process.env.ZIBBY_PROD_FRONTEND_URL||"https://studio.zibby.app",description:"Production environment"}};function I(){let
|
|
1
|
+
import{readFileSync as Y,writeFileSync as U,existsSync as k,mkdirSync as x}from"fs";import{resolve as S,join as w}from"path";import o from"chalk";import v from"ora";import F from"dotenv";import L from"inquirer";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://account-api-prod.zibby.app",frontendUrl:process.env.ZIBBY_PROD_FRONTEND_URL||"https://studio.zibby.app",description:"Production environment"}};function I(){let n;if(process.env.ZIBBY_API_URL)n=process.env.ZIBBY_API_URL;else{let e=process.env.ZIBBY_ENV||"prod";$[e]?n=$[e].apiUrl:n=$.prod.apiUrl}try{let e=new URL(n);return e.protocol!=="http:"&&e.protocol!=="https:"?(console.error(`\u26A0\uFE0F Invalid API URL protocol: ${e.protocol} (only http/https allowed)`),$.prod.apiUrl):n}catch{return console.error(`\u26A0\uFE0F Invalid API URL: ${n}`),$.prod.apiUrl}}function b(){let n=process.env.ZIBBY_ENV||"prod";return $[n]||$.prod}import{existsSync as z}from"fs";import{join as R}from"path";import{pathToFileURL as N}from"url";async function P(n){let e=R(n,".zibby.config.mjs");if(!z(e))throw new Error(".zibby.config.mjs not found");try{let t=await import(N(e).href);return t.default||t}catch(t){throw new Error(`Failed to load .zibby.config.mjs: ${t.message}`,{cause:t})}}import{validateGraphConfig as Z,generateWorkflowCode as O,generateNodeConfigsJson as K}from"@zibby/agent-workflow";import"@zibby/core/templates/register-nodes.js";F.config();async function J(n){let e=I(),t=v("Fetching projects...").start();try{let l=await fetch(`${e}/projects`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`}});l.ok||(t.fail("Failed to fetch projects"),process.exit(1));let r=await l.json();Array.isArray(r)||(r.projects&&Array.isArray(r.projects)?r=r.projects:r.data&&Array.isArray(r.data)?r=r.data:(t.fail("Unexpected response format"),process.exit(1))),(!r||r.length===0)&&(t.fail("No projects found"),process.exit(1)),t.stop();let p=r.map(a=>({name:`${a.name||"Unnamed"} (${a.id||"no-id"})`,value:a.id})),{projectId:c}=await L.prompt([{type:"list",name:"projectId",message:"Select a project:",choices:p}]);return c}catch(l){t.fail(`Error: ${l.message}`),process.exit(1)}}function B(n){let e=n.apiKey||process.env.ZIBBY_API_KEY;e||(console.log(o.red(`
|
|
2
2
|
ZIBBY_API_KEY not set`)),console.log(o.gray(` Add to .env: ZIBBY_API_KEY=zby_xxx
|
|
3
|
-
`)),process.exit(1));let n
|
|
3
|
+
`)),process.exit(1));let t=n.project||process.env.ZIBBY_PROJECT_ID;return t||(console.log(o.red(`
|
|
4
4
|
--project or ZIBBY_PROJECT_ID is required`)),console.log(o.gray(` Example: zibby workflow download --project <id> --type analysis
|
|
5
|
-
`)),process.exit(1)),{apiKey:e,projectId:
|
|
5
|
+
`)),process.exit(1)),{apiKey:e,projectId:t}}async function W(n){let e=n.apiKey||process.env.ZIBBY_API_KEY;e||(console.log(o.red(`
|
|
6
6
|
ZIBBY_API_KEY not set`)),console.log(o.gray(` Add to .env: ZIBBY_API_KEY=zby_xxx
|
|
7
|
-
`)),process.exit(1));let n
|
|
7
|
+
`)),process.exit(1));let t=n.project||process.env.ZIBBY_PROJECT_ID;return t||(t=await J(e)),{apiKey:e,projectId:t}}var _=["analysis","implementation","run_test"],G=/^[a-z][a-z0-9_-]{0,62}[a-z0-9]$/;function D(n){let e=n.type;return e||(console.log(o.red(`
|
|
8
8
|
--type is required`)),console.log(o.gray(` Built-in types: ${_.join(", ")}`)),console.log(o.gray(` Custom workflows: any lowercase slug (e.g., ticket-triage)
|
|
9
9
|
`)),process.exit(1)),!_.includes(e)&&!G.test(e)&&(console.log(o.red(`
|
|
10
10
|
Invalid workflow type: "${e}"`)),console.log(o.gray(` Built-in: ${_.join(", ")}`)),console.log(o.gray(` Custom: lowercase letters, digits, hyphens (2\u201364 chars)
|
|
11
|
-
`)),process.exit(1)),e}var V=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function q(
|
|
12
|
-
'${
|
|
13
|
-
`)),process.exit(1)),r=
|
|
14
|
-
Workflow with UUID '${
|
|
15
|
-
`)),process.exit(1)),
|
|
11
|
+
`)),process.exit(1)),e}var V=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function q(n,e){let t=I(),l={"Content-Type":"application/json",Authorization:`Bearer ${e}`},r=await fetch(`${t}/projects`,{method:"GET",headers:l});if(!r.ok)throw new Error(`Failed to list projects: HTTP ${r.status}`);let{projects:p=[]}=await r.json();for(let c of p){let a=await fetch(`${t}/projects/${c.projectId}/workflows`,{method:"GET",headers:l});if(!a.ok)continue;let s=await a.json(),d=(Array.isArray(s)?s:[]).find(i=>i.uuid===n);if(d){let i=d.workflowType||d.name;return{projectId:c.projectId,workflowType:i}}}return null}async function go(n){let e=b(),t,l,r;if(n.uuid){V.test(n.uuid)||(console.log(o.red(`
|
|
12
|
+
'${n.uuid}' is not a UUID.`)),console.log(o.gray(" Cloud workflows are identified by UUID. Run `zibby workflow list` to find yours,")),console.log(o.gray(` or use --type <built-in> for built-in workflow types.
|
|
13
|
+
`)),process.exit(1)),r=n.apiKey||process.env.ZIBBY_API_KEY,r||(r=B({...n,project:"pending"}).apiKey);let c=await q(n.uuid,r);c||(console.log(o.red(`
|
|
14
|
+
Workflow with UUID '${n.uuid}' not found in any of your projects.`)),console.log(o.gray(` Check: zibby workflow list
|
|
15
|
+
`)),process.exit(1)),t=c.projectId,l=c.workflowType}else{let c=B(n);r=c.apiKey,t=c.projectId,l=D(n)}console.log(o.bold.cyan(`
|
|
16
16
|
Zibby Workflow Download
|
|
17
|
-
`)),console.log(o.gray(" ".padEnd(52,"-"))),console.log(o.white(` Environment: ${o.cyan(e.name)}`)),console.log(o.white(` Project: ${o.cyan(
|
|
17
|
+
`)),console.log(o.gray(" ".padEnd(52,"-"))),console.log(o.white(` Environment: ${o.cyan(e.name)}`)),console.log(o.white(` Project: ${o.cyan(t)}`)),console.log(o.white(` Type: ${o.cyan(l)}`)),console.log(o.gray(" ".padEnd(52,"-")));let p=v(" Fetching workflow from cloud...").start();try{let c=I(),a=await fetch(`${c}/projects/${t}/workflows/${l}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`}});if(!a.ok){let i=await a.text();p.fail(` API error: ${a.status}`),console.log(o.red(` ${i}
|
|
18
18
|
`)),process.exit(1)}let s=await a.json();!s.graph&&s.isDefault?p.info(" No custom workflow saved -- downloading default graph"):p.succeed(` Fetched workflow (v${s.version||0})`);let d=s.graph||null;if(!d){console.log(o.yellow(`
|
|
19
19
|
No graph config available for this workflow.`)),console.log(o.gray(" The project is using the built-in default graph.")),console.log(o.gray(` Edit the graph in the UI first, or use --include-default to download the default.
|
|
20
|
-
`)),
|
|
20
|
+
`)),n.includeDefault||process.exit(0),p.start(" Fetching default graph...");let{getDefaultGraph:i}=await import("@zibby/core/templates/graphs/index.js"),g=i(l);return g||(p.fail(` No default graph found for type "${l}"`),process.exit(1)),C(l,{graph:g,version:0,isDefault:!0,projectId:t,workflowType:l,sources:null,uuid:null},n)}return C(l,{graph:d,version:s.version||0,isDefault:s.isDefault||!1,projectId:t,workflowType:l,sources:s.sources||null,uuid:s.uuid||s.workflowUuid||null},n)}catch(c){p.fail(" Download failed"),console.log(o.red(`
|
|
21
21
|
${c.message}
|
|
22
|
-
`)),process.exit(1)}}async function C(
|
|
23
|
-
`,"utf-8"),s.push("workflow.config.json")}if(e.uuid){let i={uuid:e.uuid,name:
|
|
24
|
-
`,"utf-8"),s.push(".zibby-deploy.json")}let d=`.zibby/workflows/${
|
|
25
|
-
Downloaded to ${o.bold(d)}`));for(let i of s)console.log(o.gray(` ${i}`));console.log(""),console.log(o.gray(` Version: ${e.version}`)),console.log(o.gray(` Nodes: ${e.graph.nodes?.length||0}`)),console.log(o.gray(` Edges: ${e.graph.edges?.length||0}`)),e.uuid&&console.log(o.gray(` UUID: ${e.uuid}`)),console.log(""),console.log(o.white(" Next steps:")),console.log(o.cyan(` cd ${d} && npm install `)+o.gray("Install workflow deps")),console.log(o.cyan(` zibby workflow
|
|
22
|
+
`)),process.exit(1)}}async function C(n,e,t){let l=process.cwd(),r=".zibby/workflows";if(!t.output)try{r=(await P(l))?.paths?.workflows||".zibby/workflows"}catch{}let p=t.output||w(l,r),c=w(p,n);k(c)||x(c,{recursive:!0});let a={projectId:e.projectId,workflowType:e.workflowType,version:e.version,isDefault:e.isDefault},s=[];if(e.sources&&typeof e.sources=="object"&&Object.keys(e.sources).length>0)for(let[i,g]of Object.entries(e.sources)){if(i.includes("..")||i.startsWith("/")){console.log(o.yellow(` \u26A0 Skipping unsafe source path: ${i}`));continue}let y=w(c,i),h=w(y,"..");k(h)||x(h,{recursive:!0}),U(y,g,"utf-8"),s.push(i)}else{let i=w(c,"graph.mjs");U(i,O(e.graph,a),"utf-8"),s.push("graph.mjs");let g=e.graph.nodeConfigs||{},y=K(g),h=w(c,"workflow.config.json");U(h,`${JSON.stringify(y,null,2)}
|
|
23
|
+
`,"utf-8"),s.push("workflow.config.json")}if(e.uuid){let i={uuid:e.uuid,name:n,projectId:e.projectId,version:e.version,downloadedAt:new Date().toISOString()};U(w(c,".zibby-deploy.json"),`${JSON.stringify(i,null,2)}
|
|
24
|
+
`,"utf-8"),s.push(".zibby-deploy.json")}let d=`.zibby/workflows/${n}/`;console.log(o.green(`
|
|
25
|
+
Downloaded to ${o.bold(d)}`));for(let i of s)console.log(o.gray(` ${i}`));console.log(""),console.log(o.gray(` Version: ${e.version}`)),console.log(o.gray(` Nodes: ${e.graph.nodes?.length||0}`)),console.log(o.gray(` Edges: ${e.graph.edges?.length||0}`)),e.uuid&&console.log(o.gray(` UUID: ${e.uuid}`)),console.log(""),console.log(o.white(" Next steps:")),console.log(o.cyan(` cd ${d} && npm install `)+o.gray("Install workflow deps")),console.log(o.cyan(` zibby workflow run ${n} `)+o.gray("Run locally")),console.log(o.cyan(` zibby workflow deploy ${n} `)+o.gray("Re-deploy after changes (same UUID)")),console.log("")}async function uo(n){let e=b(),{apiKey:t,projectId:l}=await W(n),r=D(n);console.log(o.bold.cyan(`
|
|
26
26
|
Zibby Workflow Upload
|
|
27
|
-
`)),console.log(o.gray(" ".padEnd(52,"-"))),console.log(o.white(` Environment: ${o.cyan(e.name)}`)),console.log(o.white(` Project: ${o.cyan(l)}`)),console.log(o.white(` Type: ${o.cyan(r)}`)),console.log(o.gray(" ".padEnd(52,"-")));let p=process.cwd(),c=w(p,".zibby",`workflow-${r}.json`),a=w(p,".zibby",`workflow-${r}.js`),s=
|
|
27
|
+
`)),console.log(o.gray(" ".padEnd(52,"-"))),console.log(o.white(` Environment: ${o.cyan(e.name)}`)),console.log(o.white(` Project: ${o.cyan(l)}`)),console.log(o.white(` Type: ${o.cyan(r)}`)),console.log(o.gray(" ".padEnd(52,"-")));let p=process.cwd(),c=w(p,".zibby",`workflow-${r}.json`),a=w(p,".zibby",`workflow-${r}.js`),s=n.file||(k(a)?a:c);k(s)||(console.log(o.red(`
|
|
28
28
|
File not found: ${s}`)),console.log(o.gray(` Download a workflow first: zibby workflow download --project <id> --type <type>
|
|
29
29
|
`)),process.exit(1));let d=s.endsWith(".js")||s.endsWith(".mjs"),i;if(d){let f=v(" Loading JS workflow module...").start();try{let{pathToFileURL:u}=await import("url"),m=await import(u(S(s)).href),j=m.buildGraph();i=j.serialize();let E=m.nodeConfigs||{};if(Object.keys(E).length>0)for(let[A,T]of Object.entries(E))i.nodeConfigs[A]={...T,...i.nodeConfigs[A]};f.succeed(` Loaded JS module (${j.nodes.size} nodes)`)}catch(u){f.fail(" Failed to load JS module"),console.log(o.red(`
|
|
30
30
|
${u.message}
|
|
@@ -35,14 +35,14 @@ import{readFileSync as Y,writeFileSync as U,existsSync as k,mkdirSync as x}from"
|
|
|
35
35
|
`)),process.exit(1)),console.log(o.gray(`
|
|
36
36
|
File: ${s}`)),console.log(o.gray(` Format: ${d?"JavaScript (serialized via graph.serialize())":"JSON"}`)),console.log(o.gray(` Nodes: ${i.nodes.length}`)),console.log(o.gray(` Edges: ${i.edges.length}`));let g=v(" Validating graph...").start(),y=Z(i);if(!y.valid){g.fail(" Graph validation failed"),console.log("");for(let f of y.errors)console.log(o.red(` ${f}`));console.log(o.gray(`
|
|
37
37
|
Fix the errors above and try again.
|
|
38
|
-
`)),process.exit(1)}g.succeed(" Graph is valid");let h=v(" Uploading to cloud...").start();try{let f=I(),u=await fetch(`${f}/projects/${l}/workflows/${r}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${
|
|
38
|
+
`)),process.exit(1)}g.succeed(" Graph is valid");let h=v(" Uploading to cloud...").start();try{let f=I(),u=await fetch(`${f}/projects/${l}/workflows/${r}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({graph:i})});if(!u.ok){let j=await u.text();h.fail(` API error: ${u.status}`),console.log(o.red(` ${j}
|
|
39
39
|
`)),process.exit(1)}let m=await u.json();h.succeed(` Uploaded successfully (v${m.version})`),console.log(o.green(`
|
|
40
40
|
Workflow "${r}" updated to version ${m.version}`)),console.log(o.gray(` Project: ${l}
|
|
41
41
|
`))}catch(f){h.fail(" Upload failed"),console.log(o.red(`
|
|
42
42
|
${f.message}
|
|
43
|
-
`)),process.exit(1)}}var M=["analysis","implementation","run_test"];async function wo(
|
|
43
|
+
`)),process.exit(1)}}var M=["analysis","implementation","run_test"];async function wo(n){let e=b(),{apiKey:t,projectId:l}=B(n);console.log(o.bold.cyan(`
|
|
44
44
|
Zibby Workflows
|
|
45
|
-
`));let r=v(" Fetching workflows...").start();try{let p=I(),c=[];for(let a of M){let s=await fetch(`${p}/projects/${l}/workflows/${a}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${
|
|
45
|
+
`));let r=v(" Fetching workflows...").start();try{let p=I(),c=[];for(let a of M){let s=await fetch(`${p}/projects/${l}/workflows/${a}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}});if(s.ok){let d=await s.json();c.push({type:a,version:d.version||0,isDefault:d.isDefault!==!1&&!d.graph,nodes:d.graph?.nodes?.length||0,updatedAt:d.updatedAt||null})}}r.succeed(` Fetched workflows
|
|
46
46
|
`),console.log(o.gray(" ".padEnd(70,"-"))),console.log(o.white(" Type".padEnd(20))+o.white("Version".padEnd(10))+o.white("Nodes".padEnd(10))+o.white("Status".padEnd(15))+o.white("Updated")),console.log(o.gray(" ".padEnd(70,"-")));for(let a of c){let s=a.isDefault?o.gray("default"):o.green("custom"),d=a.updatedAt?new Date(a.updatedAt).toLocaleDateString():o.gray("-");console.log(` ${o.cyan(a.type.padEnd(18))}${String(a.version).padEnd(10)}${String(a.nodes).padEnd(10)}${s.padEnd(15)}${d}`)}console.log(o.gray(" ".padEnd(70,"-"))),console.log("")}catch(p){r.fail(" Failed to fetch workflows"),console.log(o.red(`
|
|
47
47
|
${p.message}
|
|
48
48
|
`)),process.exit(1)}}export{go as workflowDownloadCommand,wo as workflowListCommand,uo as workflowUploadCommand};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{readFileSync as h,existsSync as d,mkdirSync as x,writeFileSync as y,statSync as I,chmodSync as T}from"fs";import{join as l,dirname as w}from"path";import{fileURLToPath as B}from"url";import{select as O}from"@inquirer/prompts";import p from"chalk";var E=w(B(import.meta.url)),A=l(E,"..","..","..","templates","zibby-workflow-claude"),N="<!-- BEGIN zibby-workflows",S="<!-- END zibby-workflows -->",$={claude:"Claude Code",cursor:"Cursor",codex:"Codex (AGENTS.md)"};function j(t){let e=process.argv[1];if(!e||!d(e))return null;let r=l(t,".zibby","bin"),n=l(r,"zibby");x(r,{recursive:!0});let o=`#!/bin/sh
|
|
2
|
+
# Auto-generated by 'zibby workflow generate'. Re-runs of generate update this path.
|
|
3
|
+
# Lets agents (Claude / Cursor / Codex) and CI scripts call zibby reliably even
|
|
4
|
+
# when the CLI isn't on PATH. Delete this file or .zibby/bin/ to disable.
|
|
5
|
+
exec node ${JSON.stringify(e)} "$@"
|
|
6
|
+
`;y(n,o);try{I(n)}catch{}try{T(n,493)}catch{}return n}function H(t){let e=[];return d(l(t,".claude"))&&e.push("claude"),(d(l(t,".cursor"))||d(l(t,".cursorrules")))&&e.push("cursor"),d(l(t,"AGENTS.md"))&&e.push("codex"),e}function L(){let t=l(A,"manifest.json");return JSON.parse(h(t,"utf8"))}function v(t){let e=t.match(/<!--\s*(?:BEGIN zibby-workflows\s+)?zibby-template-version:\s*(\d+)\s*-->/);return e?parseInt(e[1],10):null}function V(t,e,r){if(!d(t))return{write:!0,reason:"new"};if(r)return{write:!0,reason:"force"};let n=h(t,"utf8"),o=v(n),s=v(e);return o==null?{write:!1,reason:"user-edited (no version marker)"}:s==null?{write:!1,reason:"shipped file has no version (skipping for safety)"}:o>s?{write:!1,reason:`current version ${o} > shipped ${s}`}:{write:!0,reason:o===s?"same version, refresh":`upgrade ${o} \u2192 ${s}`}}function _(t,e){let r=`${e.trim()}
|
|
7
|
+
`;if(!d(t))return y(t,r),"created";let n=h(t,"utf8"),o=n.indexOf(N),s=n.indexOf(S);if(o!==-1&&s!==-1&&s>o){let i=n.slice(0,o),c=n.slice(s+S.length),a=i+r.trim()+c;return a===n?"unchanged":(y(t,a),"updated")}let u=n.endsWith(`
|
|
8
|
+
`)?`
|
|
9
|
+
`:`
|
|
10
|
+
|
|
11
|
+
`;return y(t,n+u+r),"appended"}function F(t,e,r,n){let o=r.agents[t];if(!o)return[];let s=[],u=i=>l(A,i.split("/").map(c=>c.startsWith(".")?c.slice(1):c).join("/"));for(let i of o.files||[]){let c=u(i);if(!d(c))continue;let a=h(c,"utf8"),m=l(e,i),f=V(m,a,n);f.write?(x(w(m),{recursive:!0}),y(m,a),s.push({path:i,action:"write",detail:f.reason})):s.push({path:i,action:"skip",detail:f.reason})}for(let i of o.writeOnceFiles||[]){let c=u(i);if(!d(c))continue;let a=l(e,i);if(d(a)){s.push({path:i,action:"skip",detail:"write-once: already exists, leaving alone"});continue}x(w(a),{recursive:!0}),y(a,h(c,"utf8")),s.push({path:i,action:"write",detail:"write-once: created"})}if(o.rootBlock){let i=l(A,o.rootBlock.source),c=h(i,"utf8"),a=l(e,o.rootBlock.target),m=_(a,c);s.push({path:o.rootBlock.target,action:m})}return s}function z(t){let e=t;for(let r=0;r<6;r++){if(d(l(e,".git"))||d(l(e,".zibby.config.mjs"))||d(l(e,"package.json")))return e;let n=w(e);if(n===e)break;e=n}return t}async function P(t){let e=l(t,".zibby.config.mjs");if(!d(e))return null;try{return((await import(`file://${e}?t=${Date.now()}`)).default||{}).agentHelpers||null}catch(r){return console.log(p.gray(` (couldn't parse .zibby.config.mjs agentHelpers section: ${r.message})`)),null}}function C(t,e){let r=l(t,".zibby.config.mjs");if(!d(r)){console.log(p.yellow(" \u26A0\uFE0F .zibby.config.mjs not found; agentHelpers state not persisted"));return}let n=h(r,"utf8"),o=` agentHelpers: {
|
|
12
|
+
templateVersion: ${e.templateVersion},
|
|
13
|
+
agents: ${JSON.stringify(e.agents)},
|
|
14
|
+
updatedAt: '${new Date().toISOString()}',
|
|
15
|
+
},
|
|
16
|
+
`,s=/\s*agentHelpers\s*:\s*\{[^}]*\}\s*,?\n?/m,u;if(s.test(n))u=n.replace(s,`
|
|
17
|
+
${o}`);else{let i=n.lastIndexOf("}");if(i===-1)return;let c=n.slice(0,i),a=c.replace(/\s+$/,"").slice(-1);u=c+(a&&a!==","&&a!=="{"?`,
|
|
18
|
+
`:"")+o+n.slice(i)}y(r,u)}async function G(t){let e=t[0]||"claude",r=[{name:`${$.claude}${t.includes("claude")?" (detected \u2014 recommended)":""}`,value:"claude"},{name:`${$.codex}${t.includes("codex")?" (detected)":""}`,value:"codex"},{name:`${$.cursor}${t.includes("cursor")?" (detected)":""}`,value:"cursor"},{name:"All of the above",value:"all"},{name:"Skip \u2014 I'll set up later",value:"none"}];if(e!=="claude"){let o=r.findIndex(s=>s.value===e);if(o>0){let[s]=r.splice(o,1);r.unshift(s)}}let n=await O({message:"Set up agent helpers (slash commands, sub-agents, context)?",choices:r,default:r[0].value});return n==="all"?["claude","cursor","codex"]:[n]}async function R(t={}){let{forcedAgents:e,force:r=!1,silent:n=!1}=t,o=t.projectRoot||z(process.cwd()),s=L(),u=await P(o),i,c=t&&t.forcePrompt===!0;if(e&&e.length>0)i=e;else if(!c&&u&&Array.isArray(u.agents)&&u.agents.length>0)i=u.agents;else{if(n)return;if(!process.stdin.isTTY)console.log(p.gray(" (non-TTY; defaulting agent helpers to Claude Code \u2014 pass --agent to override)")),i=["claude"];else{let f=H(o);try{i=await G(f)}catch{i=["none"]}}}if(i.length===1&&i[0]==="none"){C(o,{templateVersion:s.templateVersion,agents:["none"]}),n||console.log(p.gray(" Skipped agent helpers. Run `zibby agents add` later to set up."));return}let a=j(o),m=[];for(let f of i){if(!s.agents[f])continue;F(f,o,s,r).forEach(k=>m.push({...k,agent:f}))}if(C(o,{templateVersion:s.templateVersion,agents:i}),!n){let f=m.filter(g=>["write","created","updated","appended"].includes(g.action)),b=m.filter(g=>g.action==="skip"),k=m.filter(g=>g.action==="unchanged");if(f.length>0){console.log(p.green(` \u2713 Wrote ${f.length} agent helper file(s):`));for(let g of f)console.log(p.gray(` ${g.path} (${g.detail||g.action})`))}if(b.length>0){console.log(p.yellow(` \u26A0\uFE0F Skipped ${b.length} (use --force-claude to overwrite):`));for(let g of b)console.log(p.gray(` ${g.path} \u2014 ${g.detail}`))}f.length===0&&b.length===0&&k.length>0&&console.log(p.gray(` Agent helpers up to date (template v${s.templateVersion}).`)),console.log(p.gray(` agentHelpers: { agents: [${i.map(g=>`"${g}"`).join(", ")}] } saved to .zibby.config.mjs`)),a&&console.log(p.gray(` CLI shim: ${a} (agents fall back to ./.zibby/bin/zibby if zibby isn't on PATH)`)),i.includes("claude")&&console.log(p.gray(" \u2192 Run `claude` and try /zibby-add-node"))}}async function Y(t,e={}){let r=e.projectRoot||z(process.cwd()),n=await P(r),o=n&&Array.isArray(n.agents)?n.agents.filter(u=>u!=="none"):[],s=Array.from(new Set([...o,t]));await R({projectRoot:r,forcedAgents:s,force:e.force,silent:e.silent})}export{Y as addAgent,R as runAgentHelpers};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function l(e,r){return e?.uuid||e?.workflowUuid||r?.uuid||null}var o=4;function a({elapsedMs:e,phase:r,step:t}){let n=` \u2014 ${Math.max(0,Math.floor(e/1e3))}s`;return t?`Building bundle on Zibby Cloud... [${t.n}/${o}] ${t.label}${n}`:r?`Building bundle on Zibby Cloud... (${r.toLowerCase()})${n}`:`Building bundle on Zibby Cloud...${n}`}var d=/\[(\d+)\/\d+\]\s+(.+?)\s*\.{0,3}\s*$/;function c(e){if(!e)return null;let r=d.exec(e);if(!r)return null;let t=parseInt(r[1],10);return!Number.isInteger(t)||t<1?null:{n:t,label:r[2].trim()}}function m(){let e=!1;return function(t){if(!t)return!0;let u=t.replace(/\s+$/,"");if(e)return/^\s*"\s*$/.test(u)&&(e=!1),!0;if(!f(t))return!1;let n=u.replace(/^\[Container\]\s+\d{4}\/\d{2}\/\d{2}\s+\d{2}:\d{2}:\d{2}\.\d+\s*/,"");return n.startsWith("Running command ")&&(n.match(/"/g)||[]).length%2===1&&(e=!0),!0}}function f(e){if(!e)return!0;let t=e.trim().replace(/^\[Container\]\s+\d{4}\/\d{2}\/\d{2}\s+\d{2}:\d{2}:\d{2}\.\d+\s*/,"");return!!(/^Phase complete:/.test(t)||/^Phase context status code:/.test(t)||/^Entering phase /.test(t)||/^Running command /.test(t)||/^Phase is /.test(t)||/^Waiting for /.test(t)||/^Registering with agent$/.test(t)||/^Running on CodeBuild /.test(t)||/^Phases found in YAML:/.test(t)||/^CODEBUILD_SRC_DIR=/.test(t)||/^YAML location is /.test(t)||/^Processing environment variables$/.test(t)||/^Moving to directory /.test(t)||/^Cache is not defined /.test(t)||/^Skip cache due to:/.test(t)||/^\s*INSTALL: \d+ commands?$/.test(t)||/^\s*BUILD: \d+ commands?$/.test(t)||/^Set report auto-discover timeout/.test(t)||/^Expanding /.test(t)||/^Assembling file list$/.test(t)||/^No matching auto-discover/.test(t)||/^Report auto-discover/.test(t)||t==="")}function p({uuid:e,name:r,projectId:t,result:u,existingManifest:n=null,now:i=()=>new Date().toISOString()}){let s=u?.version??(n?.version??0)+1;return{uuid:e,name:r,projectId:t,version:s,deployedAt:i()}}export{o as BUNDLE_BUILD_TOTAL_STEPS,p as buildDeployManifest,a as formatBundleSpinnerText,f as isBundleNoiseLine,m as makeBundleLogFilter,c as parseBundleStepLine,l as pickCloudUuid};
|
|
@@ -1,34 +1,57 @@
|
|
|
1
|
-
|
|
1
|
+
var Xe=Object.defineProperty;var B=(e,o)=>()=>(e&&(o=e(e=0)),o);var Qe=(e,o)=>{for(var t in o)Xe(e,t,{get:o[t],enumerable:!0})};function I(){let e;if(process.env.ZIBBY_API_URL)e=process.env.ZIBBY_API_URL;else{let o=process.env.ZIBBY_ENV||"prod";O[o]?e=O[o].apiUrl:e=O.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)`),O.prod.apiUrl):e}catch{return console.error(`\u26A0\uFE0F Invalid API URL: ${e}`),O.prod.apiUrl}}var O,K=B(()=>{O={local:{name:"Local Development",apiUrl:"http://localhost:3001",accountApiUrl:"http://localhost:3001",frontendUrl:"http://localhost:3000",description:"Local backend running on port 3001"},prod:{name:"Production",apiUrl:process.env.ZIBBY_PROD_API_URL||"https://api-prod.zibby.app",accountApiUrl:process.env.ZIBBY_PROD_ACCOUNT_API_URL||"https://account-api-prod.zibby.app",frontendUrl:process.env.ZIBBY_PROD_FRONTEND_URL||"https://studio.zibby.app",description:"Production environment"}}});import{existsSync as $e,mkdirSync as io,readFileSync as lo,writeFileSync as co}from"fs";import{homedir as xe}from"os";import{join as Z}from"path";function je(){return process.env.ZIBBY_CONFIG_DIR||Z(xe(),".zibby")}function Ue(){return Z(je(),"config.json")}function uo(){let e=je();$e(e)||io(e,{recursive:!0})}function C(){try{let e=Ue();if($e(e)){let o=lo(e,"utf-8");return JSON.parse(o)}}catch{}return{}}function R(e){uo(),co(Ue(),JSON.stringify(e,null,2))}function Se(){return C().sessionToken||null}function Te(e){let o=C();o.sessionToken=e,R(o)}function Ie(){return C().user||null}function Ee(e){let o=C();o.user=e,R(o)}function Pe(e){let o=C();o.proxyUrl=e,R(o)}function Ae(e){let o=C();o.mem0ProxyUrl=e,R(o)}function Be(e){let o=C();o.projects=e,R(o)}var ao,Zo,Ce=B(()=>{ao=Z(xe(),".zibby"),Zo=Z(ao,"config.json")});import{existsSync as Vo,mkdirSync as Wo,readFileSync as Go,writeFileSync as Ho,unlinkSync as qo}from"fs";import{resolve as Qo}from"path";import{homedir as ot}from"os";var ze=B(()=>{});import p from"chalk";import ne from"ora";import{spawn as fo}from"child_process";function po(e){let o=process.platform;try{let t,n;return o==="darwin"?(t="open",n=[e]):o==="win32"?(t="cmd",n=["/c","start","",e]):(t="xdg-open",n=[e]),fo(t,n,{detached:!0,stdio:"ignore"}).unref(),!0}catch{return!1}}function go(){let e=Se(),o=Ie();return e&&o?{loggedIn:!0,user:o,token:e}:{loggedIn:!1}}async function Le(){try{console.log(p.cyan(`
|
|
2
2
|
\u{1F510} Initiating login...
|
|
3
|
-
`));let
|
|
4
|
-
`));let{createInterface:
|
|
3
|
+
`));let e=go();if(e.loggedIn){console.log(p.green("\u2705 Already logged in!")),console.log(p.gray(`User: ${e.user.email}`)),console.log(p.gray(`Name: ${e.user.name}
|
|
4
|
+
`));let{createInterface:o}=await import("readline"),t=o({input:process.stdin,output:process.stdout});return new Promise((n,r)=>{let i=()=>{t.close(),process.stdin.isTTY&&process.stdin.setRawMode(!1)},s=()=>{console.log(p.yellow(`
|
|
5
5
|
|
|
6
6
|
\u26A0\uFE0F Login cancelled
|
|
7
|
-
`)),
|
|
8
|
-
`));let g=await
|
|
9
|
-
`)),n({success:!0,...
|
|
10
|
-
\u274C Login failed:`,
|
|
7
|
+
`)),i(),process.exit(0)};process.on("SIGINT",s),t.question(p.yellow("Continue with this session? (Y/n): "),async l=>{process.removeListener("SIGINT",s),i();try{if(l.toLowerCase()==="n"||l.toLowerCase()==="no"){console.log(p.gray(`Starting new login...
|
|
8
|
+
`));let g=await _e();n(g)}else console.log(p.green(`Using existing session.
|
|
9
|
+
`)),n({success:!0,...e})}catch(g){r(g)}})})}return await _e()}catch(e){return console.error(p.red(`
|
|
10
|
+
\u274C Login failed:`,e.message)),{success:!1,error:e.message}}}async function yo(e){let o=I();try{let t=await fetch(`${o}/projects`,{headers:{Authorization:`Bearer ${e}`}});if(t.ok){let r=((await t.json()).projects||[]).map(i=>({name:i.name,projectId:i.projectId,apiToken:i.apiToken}));return Be(r),r}}catch(t){console.log(p.gray(`\u26A0\uFE0F Could not fetch projects: ${t.message}`))}return[]}async function _e(){let e=I(),o=ne("Requesting login code...").start(),t=await fetch(`${e}/cli/login/initiate`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok){o.fail("Failed to request login code");let f=await t.json();throw new Error(f.error||"Failed to initiate login")}let{deviceCode:n,userCode:r,verificationUrl:i,expiresIn:s,interval:l}=await t.json();o.succeed("Login code generated"),console.log(""),console.log(p.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(p.cyan("\u2551")+p.white.bold(" Complete login in your browser ")+p.cyan("\u2551")),console.log(p.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(p.white("Opening browser to login page...")),console.log(p.gray(`Code expires in ${Math.floor(s/60)} minutes`)),console.log(""),await po(i)||(console.log(p.yellow("\u26A0\uFE0F Could not open browser automatically.")),console.log(p.white("Please open this URL manually: ")+p.blue(i)),console.log(""));let a=ne("Waiting for authorization...").start(),w=(l||3)*1e3,E=Math.floor(s/(l||3)),h=0,j=!1,v=()=>{j=!0,a.stop(),console.log(p.yellow(`
|
|
11
11
|
|
|
12
12
|
\u26A0\uFE0F Login cancelled
|
|
13
|
-
`)),process.exit(0)};process.on("SIGINT",
|
|
14
|
-
`)),{success:!0,loggedIn:!0,user:
|
|
15
|
-
Not authenticated.`),console.log(` Run ${
|
|
16
|
-
`)}async function
|
|
17
|
-
Not logged in.`));let n;try{n=await
|
|
18
|
-
`);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
`)
|
|
13
|
+
`)),process.exit(0)};process.on("SIGINT",v);try{for(;h<E&&!j;){await ho(w),h++;let f=await fetch(`${e}/cli/login/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:n})});if(f.status===202)continue;if(!f.ok){a.fail("Authorization failed");let m=await f.json();throw new Error(m.error||"Authorization failed")}let u=await f.json();if(u.status==="authorized"){a.succeed(p.white("Authorization successful!")),Te(u.token),Ee(u.user),u.proxyUrl&&Pe(u.proxyUrl),u.mem0ProxyUrl&&Ae(u.mem0ProxyUrl),console.log(""),console.log(p.gray(`User: ${u.user.email}`));let m=ne("Fetching projects...").start(),L=await yo(u.token);return m.succeed(`Fetched ${L.length} project${L.length!==1?"s":""}`),console.log(p.gray(`Session saved to: ~/.zibby/config.json
|
|
14
|
+
`)),{success:!0,loggedIn:!0,user:u.user,token:u.token}}if(u.status==="denied")throw a.fail("Authorization denied"),new Error("User denied authorization")}throw a.fail("Login timeout"),new Error("Login timed out - please try again")}finally{process.removeListener("SIGINT",v)}}function ho(e){return new Promise(o=>setTimeout(o,e))}var De=B(()=>{K();Ce();ze()});import{existsSync as wo,readFileSync as mo}from"fs";import{join as vo}from"path";import se from"chalk";import{confirm as ko}from"@inquirer/prompts";function Oe(){try{let e=process.env.HOME||process.env.USERPROFILE;if(!e)return null;let o=vo(e,".zibby","config.json");return wo(o)&&JSON.parse(mo(o,"utf-8")).sessionToken||null}catch{return null}}function re(){console.log(`
|
|
15
|
+
Not authenticated.`),console.log(` Run ${se.cyan("zibby login")} or set ${se.cyan("ZIBBY_API_KEY")} in your environment.
|
|
16
|
+
`)}async function M(e={}){let o=e.apiKey||process.env.ZIBBY_API_KEY||null,t=Oe();if(t||o)return{sessionToken:t,apiKey:o};if(!process.stdin.isTTY){if(e.optional)return{sessionToken:null,apiKey:null};re(),process.exit(1)}console.log(se.yellow(`
|
|
17
|
+
Not logged in.`));let n;try{n=await ko({message:"Open browser to log in now?",default:!0})}catch{n=!1}if(!n){if(e.optional)return{sessionToken:null,apiKey:null};re(),process.exit(1)}if(await Le(),t=Oe(),!t){if(e.optional)return{sessionToken:null,apiKey:null};re(),process.exit(1)}return{sessionToken:t,apiKey:null}}var ie=B(()=>{De()});import{readFileSync as bo,existsSync as $o}from"fs";import xo from"dotenv";function J(e){return typeof e=="string"&&le.test(e)}function Re(e){if(typeof e!="string"||e.length===0)throw new Error("Expected KEY=value, got empty argument");let o=e.indexOf("=");if(o<=0)throw new Error(`Expected KEY=value, got "${e}" \u2014 missing '=' or empty key`);let t=e.slice(0,o),n=e.slice(o+1);if(!J(t))throw new Error(`Invalid env var name "${t}" \u2014 must match ${le} (uppercase letters, digits, underscores; can't start with a digit)`);return{key:t,value:n}}function ce(e){if(!Array.isArray(e)||e.length===0)return{};let o={};for(let t of e){if(!$o(t))throw new Error(`--env file not found: ${t}`);let n=xo.parse(bo(t,"utf-8"));for(let[r,i]of Object.entries(n)){if(!J(r))throw new Error(`Invalid env var name "${r}" in ${t} \u2014 must match ${le} (uppercase letters, digits, underscores; can't start with a digit)`);o[r]=i}}return o}function _(e,o,t){let n=String(e).replace(/\/+$/,"");return t?`${n}/workflows/${o}/env/${encodeURIComponent(t)}`:`${n}/workflows/${o}/env`}function ae(e){return!Array.isArray(e)||e.length===0?"No env vars set on this workflow.":[...e].sort().map(t=>` ${t}`).join(`
|
|
18
|
+
`)}var le,Ne=B(()=>{le=/^[A-Z_][A-Z0-9_]*$/});var Fe={};Qe(Fe,{listEnvCommand:()=>jo,pushEnvCommand:()=>To,setEnvCommand:()=>Uo,syncEnvFromFiles:()=>Io,unsetEnvCommand:()=>So});import y from"chalk";import V from"ora";async function W(e){let{sessionToken:o,apiKey:t}=await M({apiKey:e.apiKey}),n=o||t;return n||(console.log(y.red("\n Not authenticated \u2014 run `zibby login` or pass --api-key.\n")),process.exit(1)),{authToken:n,apiUrl:I()}}async function G(e,o,t,n,r){let i={method:e,headers:{Authorization:`Bearer ${t}`,...n?{"Content-Type":"application/json"}:{}},...n?{body:JSON.stringify(n)}:{}},s;try{s=await fetch(o,i)}catch(g){r&&r.fail(`Network error: ${g.message}`),process.exit(1)}let l;try{l=await s.json()}catch{l={}}return s.ok||(r?r.fail(l.error||l.message||`HTTP ${s.status}`):console.log(y.red(`
|
|
19
|
+
${l.error||l.message||`HTTP ${s.status}`}
|
|
20
|
+
`)),process.exit(1)),l}async function jo(e,o={}){e||(console.log(y.red(`
|
|
21
|
+
Workflow UUID is required`)),console.log(y.gray(` Usage: zibby workflow env list <uuid>
|
|
22
|
+
`)),process.exit(1));let{authToken:t,apiUrl:n}=await W(o),r=V(`Fetching env keys for ${e}...`).start(),i=await G("GET",_(n,e),t,null,r),s=i.keys||[];r.succeed(`${s.length} env var${s.length===1?"":"s"} on workflow ${e}`),console.log(""),console.log(ae(s)),i.envUpdatedAt&&console.log(y.gray(`
|
|
23
|
+
Last updated: ${i.envUpdatedAt}`)),console.log("")}async function Uo(e,o,t={}){(!e||!o)&&(console.log(y.red(`
|
|
24
|
+
Both UUID and KEY=value are required`)),console.log(y.gray(` Usage: zibby workflow env set <uuid> KEY=value
|
|
25
|
+
`)),process.exit(1));let n,r;try{({key:n,value:r}=Re(o))}catch(w){console.log(y.red(`
|
|
26
|
+
${w.message}
|
|
27
|
+
`)),process.exit(1)}let{authToken:i,apiUrl:s}=await W(t),l=V(`Setting ${n} on workflow ${e}...`).start(),a=((await G("PATCH",_(s,e,n),i,{value:r},l)).keys||[]).length;l.succeed(`Set ${y.cyan(n)} (workflow now has ${a} env var${a===1?"":"s"})`)}async function So(e,o,t={}){(!e||!o)&&(console.log(y.red(`
|
|
28
|
+
Both UUID and KEY are required`)),console.log(y.gray(` Usage: zibby workflow env unset <uuid> KEY
|
|
29
|
+
`)),process.exit(1)),J(o)||(console.log(y.red(`
|
|
30
|
+
Invalid env var name "${o}"
|
|
31
|
+
`)),process.exit(1));let{authToken:n,apiUrl:r}=await W(t),i=V(`Unsetting ${o} on workflow ${e}...`).start(),s=await G("DELETE",_(r,e,o),n,null,i),l=(s.keys||[]).length;s.removed?i.succeed(`Unset ${y.cyan(o)} (workflow now has ${l} env var${l===1?"":"s"})`):i.warn(`Key ${y.cyan(o)} was not set on workflow ${e} \u2014 nothing to do`)}async function To(e,o={}){e||(console.log(y.red(`
|
|
32
|
+
Workflow UUID is required`)),console.log(y.gray(` Usage: zibby workflow env push <uuid> --file .env [--file .env.prod]
|
|
33
|
+
`)),process.exit(1));let t=Array.isArray(o.file)?o.file:o.file?[o.file]:[];t.length===0&&(console.log(y.red(`
|
|
34
|
+
At least one --file is required`)),console.log(y.gray(` Usage: zibby workflow env push <uuid> --file .env
|
|
35
|
+
`)),process.exit(1));let n;try{n=ce(t)}catch(g){console.log(y.red(`
|
|
36
|
+
${g.message}
|
|
37
|
+
`)),process.exit(1)}let r=Object.keys(n);r.length===0&&(console.log(y.yellow(`
|
|
38
|
+
No env vars found in ${t.join(", ")} \u2014 nothing to push.
|
|
39
|
+
`)),process.exit(0));let{authToken:i,apiUrl:s}=await W(o),l=V(`Pushing ${r.length} env var${r.length===1?"":"s"} to ${e}...`).start();await G("PUT",_(s,e),i,{env:n},l),l.succeed(`Pushed ${r.length} env var${r.length===1?"":"s"} from ${t.join(", ")}`),console.log(""),console.log(ae(r)),console.log("")}async function Io({uuid:e,files:o,authToken:t,apiUrl:n,spinner:r}){let i=ce(o),s=Object.keys(i);if(s.length===0)return{count:0,files:o};let l=_(n,e),g={method:"PUT",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({env:i})},a=await fetch(l,g);if(!a.ok){let w=await a.json().catch(()=>({}));throw new Error(`Env push failed: ${w.error||w.message||`HTTP ${a.status}`}`)}return r&&(r.text=`Synced ${s.length} env var${s.length===1?"":"s"} to workflow`),{count:s.length,files:o}}var Ye=B(()=>{ie();K();Ne()});import{existsSync as x,readFileSync as ue,writeFileSync as Eo}from"fs";import{join as k}from"path";import b from"chalk";import H from"ora";import Po from"dotenv";import{select as Ke}from"@inquirer/prompts";import{existsSync as eo}from"fs";import{join as oo}from"path";import{pathToFileURL as to}from"url";async function we(e){let o=oo(e,".zibby.config.mjs");if(!eo(o))throw new Error(".zibby.config.mjs not found");try{let t=await import(to(o).href);return t.default||t}catch(t){throw new Error(`Failed to load .zibby.config.mjs: ${t.message}`,{cause:t})}}K();function me(e,o){return e?.uuid||e?.workflowUuid||o?.uuid||null}var no=4;function te({elapsedMs:e,phase:o,step:t}){let r=` \u2014 ${Math.max(0,Math.floor(e/1e3))}s`;return t?`Building bundle on Zibby Cloud... [${t.n}/${no}] ${t.label}${r}`:o?`Building bundle on Zibby Cloud... (${o.toLowerCase()})${r}`:`Building bundle on Zibby Cloud...${r}`}var ro=/\[(\d+)\/\d+\]\s+(.+?)\s*\.{0,3}\s*$/;function ve(e){if(!e)return null;let o=ro.exec(e);if(!o)return null;let t=parseInt(o[1],10);return!Number.isInteger(t)||t<1?null:{n:t,label:o[2].trim()}}function ke(){let e=!1;return function(t){if(!t)return!0;let n=t.replace(/\s+$/,"");if(e)return/^\s*"\s*$/.test(n)&&(e=!1),!0;if(!so(t))return!1;let r=n.replace(/^\[Container\]\s+\d{4}\/\d{2}\/\d{2}\s+\d{2}:\d{2}:\d{2}\.\d+\s*/,"");return r.startsWith("Running command ")&&(r.match(/"/g)||[]).length%2===1&&(e=!0),!0}}function so(e){if(!e)return!0;let t=e.trim().replace(/^\[Container\]\s+\d{4}\/\d{2}\/\d{2}\s+\d{2}:\d{2}:\d{2}\.\d+\s*/,"");return!!(/^Phase complete:/.test(t)||/^Phase context status code:/.test(t)||/^Entering phase /.test(t)||/^Running command /.test(t)||/^Phase is /.test(t)||/^Waiting for /.test(t)||/^Registering with agent$/.test(t)||/^Running on CodeBuild /.test(t)||/^Phases found in YAML:/.test(t)||/^CODEBUILD_SRC_DIR=/.test(t)||/^YAML location is /.test(t)||/^Processing environment variables$/.test(t)||/^Moving to directory /.test(t)||/^Cache is not defined /.test(t)||/^Skip cache due to:/.test(t)||/^\s*INSTALL: \d+ commands?$/.test(t)||/^\s*BUILD: \d+ commands?$/.test(t)||/^Set report auto-discover timeout/.test(t)||/^Expanding /.test(t)||/^Assembling file list$/.test(t)||/^No matching auto-discover/.test(t)||/^Report auto-discover/.test(t)||t==="")}function be({uuid:e,name:o,projectId:t,result:n,existingManifest:r=null,now:i=()=>new Date().toISOString()}){let s=n?.version??(r?.version??0)+1;return{uuid:e,name:o,projectId:t,version:s,deployedAt:i()}}ie();Po.config();async function Ao({apiUrl:e,projectId:o,workflowName:t,buildId:n,authToken:r,spinner:i,verbose:s}){let l=Date.now(),g,a=null,w=null,E=ke(),h=setInterval(()=>{i.text=te({elapsedMs:Date.now()-l,phase:a,step:w})},1e3);try{for(;;){let j=new URL(`${e}/projects/${o}/workflows/${t}/build/${n}`);g&&j.searchParams.set("logsToken",g);let v;try{let f=await fetch(j,{headers:{Authorization:`Bearer ${r}`}});if(!f.ok)throw new Error(`HTTP ${f.status}`);v=await f.json()}catch{await new Promise(u=>setTimeout(u,2e3));continue}v.phase&&v.phase!==a&&(a=v.phase),v.nextLogsToken&&v.nextLogsToken!==g&&(g=v.nextLogsToken);for(let f of v.logEvents||[]){let u=String(f.m||"").trimEnd();if(!u)continue;let m=ve(u);if(m&&(w=m),s){process.stdout.write(` ${u}
|
|
40
|
+
`);continue}E(u)||m||process.stdout.write(` ${u}
|
|
41
|
+
`)}if(i.text=te({elapsedMs:Date.now()-l,phase:a,step:w}),v.done){let f=(Date.now()-l)/1e3;return{status:v.status,elapsedSec:f,lastPhase:a}}await new Promise(f=>setTimeout(f,2e3))}}finally{clearInterval(h)}}async function Bo(e,o){let t=I(),n=H("Fetching projects...").start();try{let r=o||e,i=await fetch(`${t}/projects`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`}});i.ok||(n.fail("Failed to fetch projects"),process.exit(1));let s=await i.json();Array.isArray(s)||(s.projects&&Array.isArray(s.projects)?s=s.projects:s.data&&Array.isArray(s.data)?s=s.data:(n.fail("Unexpected response format"),process.exit(1))),(!s||s.length===0)&&(n.fail("No projects found"),process.exit(1)),n.succeed(`Found ${s.length} project${s.length===1?"":"s"}`),console.log("");let l=s.map(a=>{let w=a.projectId||a.id||a._id||"unknown";return{name:`${a.name||a.projectName||"Unnamed"} (${w})`,value:w}});return await Ke({message:"Select a project to deploy to:",choices:l})}catch(r){n.fail(`Error: ${r.message}`),process.exit(1)}}async function Lt(e,o={}){let t=process.cwd(),n=".zibby/workflows",r=null;try{r=await we(t),n=r?.paths?.workflows||".zibby/workflows"}catch{}if(e){let f=k(t,n,e);x(f)||(console.log(`
|
|
42
|
+
Error: Workflow not found: ${n}/${e}/`),console.log(" Run `zibby workflow list` to see local workflows,"),console.log(` or scaffold a new one: zibby workflow new ${e}
|
|
43
|
+
`),process.exit(1))}else{let f=k(t,n);x(f)||(console.log(`
|
|
22
44
|
Error: No workflows found in ${n}/`),console.log(` Create one with: zibby workflow new <name>
|
|
23
|
-
`),process.exit(1));let{readdir:
|
|
45
|
+
`),process.exit(1));let{readdir:u,stat:m}=await import("fs/promises"),L=await u(f),P=[];for(let A of L){let U=k(f,A);if(!(await m(U)).isDirectory())continue;(x(k(U,"graph.mjs"))||x(k(U,"graph.js")))&&P.push(A)}P.length===0&&(console.log(`
|
|
24
46
|
Error: No workflows found in ${n}/`),console.log(` Create one with: zibby workflow new <name>
|
|
25
|
-
`),process.exit(1)),console.log(""),
|
|
26
|
-
Error: graph.mjs not found in ${n}/${
|
|
47
|
+
`),process.exit(1)),console.log(""),e=await Ke({message:"Select a workflow to deploy:",choices:P.map(A=>({name:A,value:A}))})}let{sessionToken:i,apiKey:s}=await M({apiKey:o.apiKey}),l=o.project||process.env.ZIBBY_PROJECT_ID;l||(console.log(""),l=await Bo(s,i));let g=i||s,a=k(t,n,e),w=k(a,"graph.mjs"),E=k(a,"workflow.json");x(w)||(console.log(`
|
|
48
|
+
Error: graph.mjs not found in ${n}/${e}/`),process.exit(1)),console.log(`
|
|
27
49
|
Deploying Workflow
|
|
28
|
-
`),console.log(" ".padEnd(60,"-")),console.log(` Workflow: ${
|
|
29
|
-
`),process.exit(1)}let
|
|
30
|
-
`),process.exit(1)}
|
|
31
|
-
`),process.exit(1)}let
|
|
32
|
-
`,"utf-8")}catch(
|
|
33
|
-
`)}}catch(
|
|
34
|
-
`),
|
|
50
|
+
`),console.log(" ".padEnd(60,"-")),console.log(` Workflow: ${e}`),console.log(` Project: ${l}`),console.log(" ".padEnd(60,"-")),console.log("");let h=H("Validating workflow...").start(),j=ue(w,"utf-8");if(j.includes("@zibby/core")||j.includes("@zibby/skills")){let f=k(a,"package.json");x(f)||(h.fail("Missing package.json"),console.log(""),console.log(b.red(" \u2717 graph.mjs imports @zibby packages but no package.json found")),console.log(""),console.log(b.yellow(" Create package.json with:")),console.log(""),console.log(b.gray(" {")),console.log(b.gray(' "type": "module",')),console.log(b.gray(' "dependencies": {')),console.log(b.gray(' "@zibby/core": "workspace:*"')),console.log(b.gray(" }")),console.log(b.gray(" }")),console.log(""),process.exit(1));let u=JSON.parse(ue(f,"utf-8"));!{...u.dependencies,...u.devDependencies}["@zibby/core"]&&j.includes("@zibby/core")&&(h.fail("Missing @zibby/core dependency"),console.log(""),console.log(b.red(" \u2717 graph.mjs imports @zibby/core but it's not in package.json")),console.log(""),console.log(b.yellow(" Add to package.json dependencies:")),console.log(b.gray(' "@zibby/core": "workspace:*"')),console.log(""),process.exit(1))}h.text="Loading workflow graph...";try{let{pathToFileURL:f}=await import("url"),u=await import(f(w).href),m;if(u.default)if(typeof u.default=="function"){let c=u.default.prototype;c&&c.buildGraph?m=new u.default:m=u.default()}else h.fail("graph.mjs must export a class or factory function"),process.exit(1);else{let c=Object.values(u).find(d=>d.prototype&&d.prototype.buildGraph);c?m=new c:(h.fail("graph.mjs must export a WorkflowAgent class or factory function"),process.exit(1))}let P=m.buildGraph().serialize(),{readdir:A,readFile:U}=await import("fs/promises"),S={};h.text="Packaging workflow sources...";let fe=await U(w,"utf-8");if(S["graph.mjs"]=fe,x(E)){let c=await U(E,"utf-8");S["workflow.json"]=c}let q=k(a,"nodes");if(x(q)){let c=await A(q);for(let d of c)if(d.endsWith(".mjs")||d.endsWith(".js")){let $=k(q,d),oe=await U($,"utf-8");S[`nodes/${d}`]=oe}}let pe=k(a,"package.json");if(x(pe)){let c=await U(pe,"utf-8");S["package.json"]=c,h.text="Including package.json for dependencies..."}let ge=k(a,"package-lock.json");if(x(ge)){let c=await U(ge,"utf-8");S["package-lock.json"]=c}r&&typeof r=="object"&&(S["zibby.config.json"]=JSON.stringify(r,null,2)),h.text=`Uploading to cloud (${P.nodes.size||Object.keys(P.nodes||{}).length} nodes, ${Object.keys(S).length} files)...`;let D=I(),de=JSON.stringify({format:1,sources:S}),ye=Buffer.byteLength(de,"utf8"),N=await fetch(`${D}/projects/${l}/workflows/${e}/sources/presign`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({contentLength:ye})});if(!N.ok){let c=await N.json().catch(()=>({}));h.fail("Deploy failed (presign)"),console.log(` Error: ${c.error||c.message||N.statusText}
|
|
51
|
+
`),process.exit(1)}let Ze=await N.json(),{uploadUrl:Me,key:Je,headers:Ve}=Ze,X=await fetch(Me,{method:"PUT",headers:{...Ve||{},"Content-Length":String(ye)},body:de});if(!X.ok){let c=await X.text().catch(()=>"");h.fail("Deploy failed (S3 upload)"),console.log(` S3 PUT failed: ${X.status} ${c.slice(0,200)}
|
|
52
|
+
`),process.exit(1)}h.text="Saving workflow definition...";let F=await fetch(`${D}/projects/${l}/workflows/${e}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({graph:P,sourcesStagingKey:Je,isDefault:!1})});if(!F.ok){let c=await F.json().catch(()=>({}));h.fail("Deploy failed"),console.log(` Error: ${c.message||c.error||F.statusText}
|
|
53
|
+
`),process.exit(1)}let Q=await F.json(),Y=k(a,".zibby-deploy.json"),ee=x(Y)?(()=>{try{return JSON.parse(ue(Y,"utf-8"))}catch{return null}})():null,T=me(Q,ee);if(T){let c=be({uuid:T,name:e,projectId:l,result:Q,existingManifest:ee});try{Eo(Y,`${JSON.stringify(c,null,2)}
|
|
54
|
+
`,"utf-8")}catch(d){console.log(` Warning: failed to write ${Y}: ${d.message}`)}}let We=ee?"Updated":"Deployed";if(h.succeed(`${We} ${e} (v${Q.version||1})`),!(o.noWait===!0||process.env.ZIBBY_DEPLOY_NO_BUNDLE==="1")){console.log("");let c=H("Building bundle on Zibby Cloud...").start();try{let d=await fetch(`${D}/projects/${l}/workflows/${e}/build`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`}});if(d.ok){let $=await d.json(),{buildId:oe}=$,Ge=o.verbose===!0||process.env.ZIBBY_DEPLOY_VERBOSE==="1",{status:he,elapsedSec:He,lastPhase:qe}=await Ao({apiUrl:D,projectId:l,workflowName:e,buildId:oe,authToken:g,spinner:c,verbose:Ge});he==="SUCCEEDED"?c.succeed(`Bundle ready (${He.toFixed(1)}s) \u2014 runtime npm install eliminated`):c.warn(`Bundle build ${he} at phase ${qe||"unknown"} \u2014 workflow will fall back to runtime install`)}else{let $=await d.json().catch(()=>({}));c.warn(`Bundle build skipped: ${$.error||$.message||d.statusText}`),console.log(` Workflow will use slower runtime install path until next deploy.
|
|
55
|
+
`)}}catch(d){c.warn(`Bundle build error: ${d.message}`)}}let z=Array.isArray(o.env)?o.env:o.env?[o.env]:[];if(z.length>0)if(!T)console.log(b.yellow(" Skipping --env sync: deploy did not return a workflow UUID."));else{console.log("");let c=H(`Syncing env from ${z.join(", ")}...`).start();try{let{syncEnvFromFiles:d}=await Promise.resolve().then(()=>(Ye(),Fe)),{count:$}=await d({uuid:T,files:z,authToken:g,apiUrl:D,spinner:c});$===0?c.warn(`No env vars found in ${z.join(", ")} \u2014 workflow env unchanged.`):c.succeed(`Synced ${$} env var${$===1?"":"s"} from ${z.join(", ")}`)}catch(d){c.fail(`Env sync failed: ${d.message}`),console.log(b.gray(` Re-run after fixing: zibby workflow env push ${T} ${z.map($=>`--file ${$}`).join(" ")}
|
|
56
|
+
`))}}console.log(""),T&&console.log(` UUID: ${T}`),console.log(""),console.log(" Next steps:"),console.log(` zibby workflow run ${e} Run locally`),T&&console.log(` zibby workflow trigger ${T} Run in cloud`),console.log(" zibby workflow list View all workflows"),console.log("")}catch(f){h.fail("Deploy failed"),console.log(` Error: ${f.message}
|
|
57
|
+
`),process.exit(1)}}export{Lt as deployWorkflowCommand};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{readFileSync as a,existsSync as f}from"fs";import u from"dotenv";var i=/^[A-Z_][A-Z0-9_]*$/;function s(e){return typeof e=="string"&&i.test(e)}function d(e){if(typeof e!="string"||e.length===0)throw new Error("Expected KEY=value, got empty argument");let r=e.indexOf("=");if(r<=0)throw new Error(`Expected KEY=value, got "${e}" \u2014 missing '=' or empty key`);let t=e.slice(0,r),n=e.slice(r+1);if(!s(t))throw new Error(`Invalid env var name "${t}" \u2014 must match ${i} (uppercase letters, digits, underscores; can't start with a digit)`);return{key:t,value:n}}function v(e){if(!Array.isArray(e)||e.length===0)return{};let r={};for(let t of e){if(!f(t))throw new Error(`--env file not found: ${t}`);let n=u.parse(a(t,"utf-8"));for(let[o,c]of Object.entries(n)){if(!s(o))throw new Error(`Invalid env var name "${o}" in ${t} \u2014 must match ${i} (uppercase letters, digits, underscores; can't start with a digit)`);r[o]=c}}return r}function m(e,r,t){let n=String(e).replace(/\/+$/,"");return t?`${n}/workflows/${r}/env/${encodeURIComponent(t)}`:`${n}/workflows/${r}/env`}function w(e){return!Array.isArray(e)||e.length===0?"No env vars set on this workflow.":[...e].sort().map(t=>` ${t}`).join(`
|
|
2
|
+
`)}export{m as buildEnvUrl,w as formatEnvList,s as isValidEnvKey,v as parseDotenvFiles,d as parseKeyValueArg};
|