@zibby/cli 0.5.8 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/bin/zibby.js +3 -3
  2. package/dist/commands/app-run.js +19 -0
  3. package/dist/commands/app-solo.js +19 -0
  4. package/dist/commands/app.js +22 -20
  5. package/dist/commands/init.js +100 -95
  6. package/dist/commands/workflows/generate.js +156 -151
  7. package/dist/config/soloTiers.js +1 -0
  8. package/dist/config/warmPool.js +1 -0
  9. package/dist/lib/api-client.js +17 -0
  10. package/dist/lib/find-app-link.js +2 -0
  11. package/dist/lib/framework-commands.js +1 -0
  12. package/dist/package.json +2 -2
  13. package/dist/templates/.claude/CLAUDE.md +318 -10
  14. package/dist/templates/.claude/agents/zibby-test-author.md +87 -0
  15. package/dist/templates/.claude/agents/zibby-workflow-builder.md +101 -0
  16. package/dist/templates/.claude/commands/{add-node.md → zibby-add-node.md} +1 -1
  17. package/dist/templates/.claude/commands/{add-skill.md → zibby-add-skill.md} +1 -1
  18. package/dist/templates/.claude/commands/zibby-app-destroy.md +60 -0
  19. package/dist/templates/.claude/commands/zibby-app-list.md +80 -0
  20. package/dist/templates/.claude/commands/zibby-app-logs.md +60 -0
  21. package/dist/templates/.claude/commands/zibby-app-status.md +53 -0
  22. package/dist/templates/.claude/commands/zibby-app-upgrade.md +67 -0
  23. package/dist/templates/.claude/commands/zibby-debug.md +67 -0
  24. package/dist/templates/.claude/commands/zibby-delete.md +37 -0
  25. package/dist/templates/.claude/commands/zibby-deploy-app.md +92 -0
  26. package/dist/templates/.claude/commands/zibby-deploy.md +87 -0
  27. package/dist/templates/.claude/commands/zibby-list.md +30 -0
  28. package/dist/templates/.claude/commands/zibby-login.md +68 -0
  29. package/dist/templates/.claude/commands/zibby-mcp-install.md +93 -0
  30. package/dist/templates/.claude/commands/zibby-memory-cost.md +39 -0
  31. package/dist/templates/.claude/commands/zibby-memory-pull.md +47 -0
  32. package/dist/templates/.claude/commands/zibby-memory-remote-use-hosted.md +61 -0
  33. package/dist/templates/.claude/commands/zibby-memory-stats.md +38 -0
  34. package/{templates/.claude/commands/new-workflow.md → dist/templates/.claude/commands/zibby-new-workflow.md} +1 -1
  35. package/dist/templates/.claude/commands/zibby-set-auth.md +85 -0
  36. package/dist/templates/.claude/commands/zibby-static-ip.md +70 -0
  37. package/dist/templates/.claude/commands/zibby-status.md +54 -0
  38. package/dist/templates/.claude/commands/zibby-tail.md +53 -0
  39. package/dist/templates/.claude/commands/zibby-test-debug.md +59 -0
  40. package/dist/templates/.claude/commands/zibby-test-generate.md +39 -0
  41. package/dist/templates/.claude/commands/zibby-test-run.md +49 -0
  42. package/dist/templates/.claude/commands/zibby-test-write.md +46 -0
  43. package/dist/templates/.claude/commands/zibby-trigger.md +56 -0
  44. package/{templates/.claude/commands/validate-workflow.md → dist/templates/.claude/commands/zibby-validate-workflow.md} +1 -1
  45. package/dist/templates/.cursor/rules/zibby.mdc +127 -0
  46. package/dist/templates/AGENTS.md +248 -0
  47. package/dist/utils/managed-block.js +6 -0
  48. package/package.json +2 -2
  49. package/templates/.claude/CLAUDE.md +318 -10
  50. package/templates/.claude/agents/zibby-test-author.md +87 -0
  51. package/templates/.claude/agents/zibby-workflow-builder.md +101 -0
  52. package/templates/.claude/commands/{add-node.md → zibby-add-node.md} +1 -1
  53. package/templates/.claude/commands/{add-skill.md → zibby-add-skill.md} +1 -1
  54. package/templates/.claude/commands/zibby-app-destroy.md +60 -0
  55. package/templates/.claude/commands/zibby-app-list.md +80 -0
  56. package/templates/.claude/commands/zibby-app-logs.md +60 -0
  57. package/templates/.claude/commands/zibby-app-status.md +53 -0
  58. package/templates/.claude/commands/zibby-app-upgrade.md +67 -0
  59. package/templates/.claude/commands/zibby-debug.md +67 -0
  60. package/templates/.claude/commands/zibby-delete.md +37 -0
  61. package/templates/.claude/commands/zibby-deploy-app.md +92 -0
  62. package/templates/.claude/commands/zibby-deploy.md +87 -0
  63. package/templates/.claude/commands/zibby-list.md +30 -0
  64. package/templates/.claude/commands/zibby-login.md +68 -0
  65. package/templates/.claude/commands/zibby-mcp-install.md +93 -0
  66. package/templates/.claude/commands/zibby-memory-cost.md +39 -0
  67. package/templates/.claude/commands/zibby-memory-pull.md +47 -0
  68. package/templates/.claude/commands/zibby-memory-remote-use-hosted.md +61 -0
  69. package/templates/.claude/commands/zibby-memory-stats.md +38 -0
  70. package/{dist/templates/.claude/commands/new-workflow.md → templates/.claude/commands/zibby-new-workflow.md} +1 -1
  71. package/templates/.claude/commands/zibby-set-auth.md +85 -0
  72. package/templates/.claude/commands/zibby-static-ip.md +70 -0
  73. package/templates/.claude/commands/zibby-status.md +54 -0
  74. package/templates/.claude/commands/zibby-tail.md +53 -0
  75. package/templates/.claude/commands/zibby-test-debug.md +59 -0
  76. package/templates/.claude/commands/zibby-test-generate.md +39 -0
  77. package/templates/.claude/commands/zibby-test-run.md +49 -0
  78. package/templates/.claude/commands/zibby-test-write.md +46 -0
  79. package/templates/.claude/commands/zibby-trigger.md +56 -0
  80. package/{dist/templates/.claude/commands/validate-workflow.md → templates/.claude/commands/zibby-validate-workflow.md} +1 -1
  81. package/templates/.cursor/rules/zibby.mdc +127 -0
  82. package/templates/AGENTS.md +248 -0
@@ -0,0 +1,49 @@
1
+ <!-- zibby-template-version: 4 -->
2
+ # /zibby-test-run — execute a Zibby test spec
3
+
4
+ You are helping the user run an existing test spec through Zibby. A spec is a `.txt` file describing what to test in plain language; Zibby's runner turns it into a Playwright execution and produces a video + JSON results.
5
+
6
+ Canonical docs: **https://docs.zibby.app/tests/running**
7
+
8
+ ## Steps
9
+
10
+ 1. **Identify the spec.** Most projects keep specs under `test-specs/` (configurable in `.zibby.config.mjs` `paths.specs`). If user named one, use it. Otherwise list what's there and ask:
11
+ ```
12
+ ls test-specs/
13
+ ```
14
+
15
+ 2. **Run it.** From the project root:
16
+ ```
17
+ Bash(zibby test test-specs/<name>.txt)
18
+ ```
19
+ For a quick inline test without writing a spec file:
20
+ ```
21
+ Bash(zibby test "go to example.com and check that the title contains Example")
22
+ ```
23
+
24
+ 3. **Output to expect.** Zibby streams the run live — agent thinking, browser actions, assertion results, final pass/fail. Generated `.spec.js` lands in `tests/<name>.spec.js` (configurable via `paths.generated`). Video + traces under `test-results/`.
25
+
26
+ 4. **If running headless / CI:**
27
+ ```
28
+ Bash(zibby test test-specs/<name>.txt --headless)
29
+ ```
30
+
31
+ 5. **If running a specific node only** (advanced — re-execute one phase of a prior session):
32
+ ```
33
+ Bash(zibby test --node execute_live --session last)
34
+ ```
35
+
36
+ ## Useful flags
37
+
38
+ - `--agent claude|cursor|codex|gemini` — override the configured agent for this run
39
+ - `--workflow QuickSmokeWorkflow` — use a non-default workflow for the run
40
+ - `--verbose` / `--debug` — escalate log levels
41
+ - `-m, --mem` — enable test memory (Dolt-backed knowledge from prior runs)
42
+ - `--sync` / `--no-sync` — force / skip cloud upload regardless of config
43
+ - `--sources <ids> --execution <id>` — run cloud-stored test cases from a specific execution (comma-separated IDs)
44
+
45
+ ## Common failure modes
46
+
47
+ - **"No spec found"** — path is relative to project root, not cwd. Check `paths.specs` in `.zibby.config.mjs`.
48
+ - **"Browser crashed"** — usually the playwright browser cache is stale. Drop `--headless` once (default is headed) so you can see what's happening, then re-add `--headless` once it's healthy.
49
+ - **MCP errors during `execute_live`** — the agent's MCP tool config may need refreshing. See `/zibby-test-debug`.
@@ -0,0 +1,46 @@
1
+ <!-- zibby-template-version: 4 -->
2
+ # /zibby-test-write — author a new Zibby test spec
3
+
4
+ You are helping the user write a new test spec. Specs are plain-language `.txt` files in `test-specs/` (configurable via `.zibby.config.mjs` `paths.specs`). Zibby's runner converts them to Playwright at execution time.
5
+
6
+ Canonical docs: **https://docs.zibby.app/tests/specs**
7
+
8
+ ## Spec format (informal but conventional)
9
+
10
+ A spec is mostly imperative English with one action per line. Common shape:
11
+
12
+ ```
13
+ Title: <one-line summary>
14
+
15
+ Setup:
16
+ - Open <url>
17
+ - Log in as <user>
18
+
19
+ Steps:
20
+ - Click <element>
21
+ - Type <value> into <field>
22
+ - Wait for <state>
23
+
24
+ Verify:
25
+ - <assertion>
26
+ - <assertion>
27
+ ```
28
+
29
+ Zibby tolerates loose phrasing — what matters is being unambiguous about WHICH element and WHAT value. Use stable selectors (visible text, ARIA labels) over CSS class names.
30
+
31
+ ## Steps for this command
32
+
33
+ 1. **Ask the user what they want to test.** What's the user flow? What are they verifying? What URL?
34
+ 2. **Find a similar existing spec to mirror.** `ls test-specs/` and read 1-2 to match the project's conventions.
35
+ 3. **Write the spec to `test-specs/<kebab-case-name>.txt`** using `Write` tool.
36
+ 4. **Offer to run it immediately** with `/zibby-test-run` (or just `Bash(zibby test test-specs/<name>.txt)`).
37
+
38
+ ## Naming conventions
39
+
40
+ - kebab-case: `login-with-sso.txt`, `cart-checkout-happy-path.txt`
41
+ - Group by feature: `users-create.txt`, `users-edit.txt`, `users-delete.txt`
42
+ - Avoid ambiguous names like `test1.txt`
43
+
44
+ ## When the spec is complex
45
+
46
+ For multi-page flows or many assertions, split into multiple specs and run them as a collection. Don't pile everything into one spec — Playwright errors are easier to localize when each spec is one user goal.
@@ -0,0 +1,56 @@
1
+ <!-- zibby-template-version: 4 -->
2
+ # /zibby-trigger — run a deployed Zibby workflow
3
+
4
+ You are helping the user trigger a deployed workflow execution.
5
+
6
+ A trigger creates a new ECS Fargate task that loads the workflow's bundle, runs the graph, and writes status + logs as it goes.
7
+
8
+ Canonical docs: **https://docs.zibby.app/cloud/triggering**
9
+
10
+ ## Steps
11
+
12
+ 1. **Get the workflow UUID.** The user should provide it; if not, run `zibby workflow list` to discover it. UUIDs are stable across deploys (the same workflow always has the same UUID; only the bundle version changes).
13
+
14
+ 2. **Construct the input.** Workflows take a JSON input that nodes can read via `ctx.input`. Ask the user what input the workflow expects (or read `workflow.json`'s `inputSchema` if present).
15
+
16
+ 3. **Run the trigger.** Three ways to pass input — they merge with this **precedence (highest → lowest)**:
17
+ 1. `-p key=value` (repeatable) — wins over everything; great for shell-friendly tweaks on top of a base payload
18
+ 2. `--input '<json>'` — full JSON payload as a string
19
+ 3. `--input-file path.json` — full JSON/YAML payload from a file (lowest precedence; `-p` and `--input` override individual keys)
20
+
21
+ ```
22
+ zibby workflow trigger <uuid> --input '{"key":"value"}'
23
+ zibby workflow trigger <uuid> -p ticket=ENG-1234 -p priority=high
24
+ zibby workflow trigger <uuid> --input-file payload.json -p priority=urgent # mix
25
+ ```
26
+
27
+ Same flag surface as `zibby workflow run` (local) — flip the verb and the same call shape goes from local to remote.
28
+
29
+ 4. **Tail the logs immediately:**
30
+ ```
31
+ zibby workflow logs <uuid> -t
32
+ ```
33
+ This streams live output. The tail auto-attaches to all currently-running executions of the workflow (docker-compose-style), so back-to-back triggers interleave naturally.
34
+
35
+ 5. **Watch for completion.** Workflow runs typically end with one of:
36
+ - `✓ Workflow completed` — success, status `completed`
37
+ - `Error: Node 'X' failed` — a node threw; status `failed`
38
+ - silent timeout — task killed by ECS; status stays `running` then becomes a zombie. Trigger again.
39
+
40
+ ## Idempotency
41
+
42
+ Use `--idempotency-key <key>` to prevent duplicate runs from a retry-prone caller:
43
+ ```
44
+ zibby workflow trigger <uuid> --input '{}' --idempotency-key job-2026-05-04-001
45
+ ```
46
+ Same key + same input within ~24h = same execution returned (no new run).
47
+
48
+ ## Multiple inputs / batch
49
+
50
+ There's no built-in batch trigger — script it from your shell:
51
+ ```
52
+ for ticket in ENG-1 ENG-2 ENG-3; do
53
+ zibby workflow trigger <uuid> -p ticket=$ticket
54
+ done
55
+ zibby workflow logs <uuid> -t # tail will show all 3 interleaved
56
+ ```
@@ -3,7 +3,7 @@ description: Statically validate a Zibby workflow + run it locally with sample i
3
3
  argument-hint: <workflow-name> [optional input as key=value pairs]
4
4
  ---
5
5
 
6
- # /validate-workflow
6
+ # /zibby-validate-workflow
7
7
 
8
8
  The user wants to verify a workflow works before deploying.
9
9
 
@@ -0,0 +1,127 @@
1
+ ---
2
+ description: Build, test, deploy, and operate on Zibby — workflows + hosted apps + tests
3
+ globs:
4
+ - "**/.zibby/workflows/**"
5
+ - "**/workflows/**"
6
+ - ".zibby.config.mjs"
7
+ - "**/workflow.json"
8
+ - "**/graph.mjs"
9
+ - "test-specs/**"
10
+ - ".zibby/memory/**"
11
+ - "AGENTS.md"
12
+ alwaysApply: false
13
+ ---
14
+
15
+ # Zibby — workflows + apps + tests
16
+
17
+ This project uses **Zibby**. Two production surfaces share `.zibby.config.mjs`:
18
+
19
+ 1. **Workflows** — graphs of AI-agent steps in a Fargate sandbox.
20
+ 2. **Apps** — long-running hosted SaaS instances (n8n, grafana, …).
21
+
22
+ Plus **Tests** — plain-language `.txt` specs converted to Playwright runs.
23
+
24
+ See `.claude/CLAUDE.md` for the long-form. `AGENTS.md` has the cross-IDE
25
+ recipes. Canonical docs: https://docs.zibby.app.
26
+
27
+ ## Workflows — common dev loop
28
+
29
+ ```
30
+ zibby workflow new <name> # scaffold (workflows/<name>/ by default)
31
+ zibby workflow run <name> # one-shot LOCAL run (preferred for dev loop)
32
+ zibby workflow validate <name> # static check (graph topology, schemas)
33
+ zibby workflow deploy <name> # build + push to cloud → UUID
34
+ zibby workflow trigger <uuid> # remote run
35
+ zibby workflow logs <uuid> -t # tail live logs (background-run this in chat)
36
+ zibby workflow list # local + cloud
37
+ zibby workflow delete <uuid>
38
+ ```
39
+
40
+ File layout (workflows/<name>/):
41
+ ```
42
+ workflow.json # name, entryClass, triggers, defaultAgent
43
+ graph.mjs # class extends WorkflowAgent, buildGraph() returns WorkflowGraph
44
+ nodes/*.mjs # { name, outputSchema (Zod), prompt|execute }
45
+ state.js # OPTIONAL — Zod schema for caller-provided inputs (-p)
46
+ package.json # @zibby/core + zod
47
+ ```
48
+
49
+ Each node's output goes to `state[nodeName]`. Read downstream as
50
+ `state.previousNode.field`. Initial input (`-p key=value`) is top-level
51
+ in state (`state.key`). Loops route back via `addConditionalEdges`;
52
+ counter state lives in the looping node's own outputSchema.
53
+
54
+ `run` and `trigger` share input flags: `-p key=value` (highest, repeatable),
55
+ `--input '<json>'`, `--input-file path.json` (lowest).
56
+
57
+ ## Apps — common deploy + operate loop
58
+
59
+ ```
60
+ zibby app templates # browse catalog
61
+ zibby app deploy <appType> --project <id> # catalog deploy (~2-3 min)
62
+ zibby app deploy --goal "<text>" --project <id> # goal-mode (LLM bootstrap, 5-30 min)
63
+ zibby app list
64
+ zibby app status <instanceId>
65
+ zibby app logs <instanceId> [-t] [--service <name>]
66
+ zibby app upgrade <instanceId> --version vX.Y.Z # agent-ops base image
67
+ zibby app set-auth <instanceId> --auth-type basic --auth-user admin --auth-password ...
68
+ zibby app set-auth <instanceId> --off # remove auth sidecar
69
+ zibby app destroy <instanceId> --yes # PERMANENT — wipes EFS
70
+ ```
71
+
72
+ **Catalog vs goal-mode** — catalog uses a baked task def, goal-mode runs
73
+ an autonomous `agent-ops` install loop. Use catalog when the app is in
74
+ `zibby app templates`; goal-mode for anything else.
75
+
76
+ Goal-mode flags: `--provider claude|codex`, `--model <id>`,
77
+ `--anthropic-token sk-ant-...` (per-deploy override), `--max-turns N`
78
+ (default 25, bump to 60-100 for heavy installs), `--timeout-min N`
79
+ (default 20, bump to 30-45 for heavy installs).
80
+
81
+ **Auth** — every app gets a public `*.apps.zibby.app` URL. Set
82
+ `--auth-type basic|token` at deploy time (or via `zibby app set-auth`
83
+ after). `none` is only safe if the app has its own login. Generate
84
+ credentials with `openssl rand -hex 16` (basic password) / `-hex 32`
85
+ (token). Never log credentials.
86
+
87
+ **Multi-service entries** — `wordpress` (wordpress + mysql), `mattermost`
88
+ (mattermost + postgres), `gas-town` (web + worker + scheduler). Use
89
+ `--service <name>` to tail one service; `app status` lists `services[]`.
90
+
91
+ ## Auth + login
92
+
93
+ ```
94
+ zibby login # browser OAuth → ~/.zibby/session.json
95
+ zibby status # current auth + workspace + project + agent creds
96
+ ```
97
+
98
+ Headless / CI: `export ZIBBY_API_KEY=zby_xxx` (PAT from https://zibby.dev/settings/api-keys). Env wins over session.
99
+
100
+ ## Agent's job: decide workflow vs app
101
+
102
+ | User wants… | Use |
103
+ |---|---|
104
+ | Schedule / event-driven LLM automation | **Workflow** |
105
+ | Long-running hosted web service | **App** |
106
+ | Bootstrap an arbitrary OSS thing | **App goal-mode** |
107
+ | Sub-second interactive UI | Neither (Lambda / own backend) |
108
+
109
+ Always ask before:
110
+ - `zibby workflow deploy` (cloud cost)
111
+ - `zibby app deploy` (per-minute billing starts immediately)
112
+ - `zibby app destroy` (irreversible, EFS wiped)
113
+ - Any `--anthropic-token` paste (credentials in chat history leak)
114
+
115
+ ## How to invoke the CLI
116
+
117
+ `zibby` on PATH (preferred) or `./.zibby/bin/zibby` as a fallback shim
118
+ that always exists in this project. Don't use `npx @zibby/cli` — not
119
+ always published.
120
+
121
+ ## Canonical docs (always prefer over these notes)
122
+
123
+ - Workflows: https://docs.zibby.app/workflows
124
+ - Apps: https://docs.zibby.app/apps
125
+ - agent-ops daemon: https://docs.zibby.app/apps/agent-ops
126
+ - CLI: https://docs.zibby.app/cli
127
+ - MCP: https://docs.zibby.app/cli/mcp
@@ -0,0 +1,248 @@
1
+ <!-- BEGIN ZIBBY — managed by `zibby init`, do not edit between markers -->
2
+ # Zibby integration
3
+
4
+ This project uses **Zibby** (https://zibby.dev). Zibby is two surfaces
5
+ sharing one account, one CLI, one Studio:
6
+
7
+ 1. **Workflows** — graphs of AI-agent-driven steps that run inside an
8
+ ECS Fargate sandbox in Zibby Cloud. For event-driven automation
9
+ that needs an LLM in the loop.
10
+ 2. **Apps** — long-running hosted SaaS instances (n8n, Grafana,
11
+ Outline, …) on Zibby's Fargate fleet, with an `agent-ops` sidecar.
12
+ Pick from a catalog or describe a goal in natural language.
13
+
14
+ For deeper detail, see `.claude/CLAUDE.md` in this repo (canonical
15
+ reference) or https://docs.zibby.app.
16
+
17
+ ---
18
+
19
+ ## CLI quick reference
20
+
21
+ Use `zibby` on PATH (preferred) or `./.zibby/bin/zibby` as a fallback
22
+ shim in this repo. Never fall back to `npx @zibby/cli`.
23
+
24
+ ### Auth + context
25
+
26
+ ```bash
27
+ zibby login # browser OAuth → ~/.zibby/session.json
28
+ zibby status # current auth + workspace + project + agent creds
29
+ zibby logout # clear session
30
+ zibby list # list projects in this workspace
31
+ zibby project use <id> # switch default project
32
+ ```
33
+
34
+ For headless / CI: `export ZIBBY_API_KEY=zby_xxx` (PAT from https://zibby.dev/settings/api-keys). Env var beats session token.
35
+
36
+ ### Workflows
37
+
38
+ ```bash
39
+ zibby workflow new <name> # scaffold .zibby/workflows/<name>/
40
+ zibby workflow run <name> -p k=v # one-shot LOCAL run (preferred for dev loop)
41
+ zibby workflow validate <name> # static check (graph topology, schemas, skills)
42
+ zibby workflow deploy <name> # build + push to Zibby Cloud → UUID
43
+ zibby workflow trigger <uuid> -p .. # remote run
44
+ zibby workflow logs <uuid> -t # tail live logs
45
+ zibby workflow schedule <uuid> set "0 9 * * 1-5" # 5-field Unix cron
46
+ zibby workflow list # local + cloud
47
+ zibby workflow delete <uuid> # remove a deployed workflow
48
+ ```
49
+
50
+ Workflow file layout:
51
+ ```
52
+ <paths.workflows or workflows>/<name>/
53
+ ├── workflow.json name, entryClass, triggers, defaultAgent
54
+ ├── graph.mjs class extends WorkflowAgent — buildGraph() returns WorkflowGraph
55
+ ├── nodes/*.mjs one node per file: name, outputSchema (Zod), prompt|execute
56
+ ├── state.js OPTIONAL — Zod schema for caller-provided inputs
57
+ └── package.json @zibby/core + zod
58
+ ```
59
+
60
+ Node shape:
61
+ ```js
62
+ import { z } from 'zod';
63
+ export const planNode = {
64
+ name: 'plan',
65
+ agent: 'claude', // optional override; defaults to workflow's defaultAgent
66
+ outputSchema: z.object({ steps: z.array(z.string()) }),
67
+ prompt: (state) => `Plan: ${state.userRequest}`,
68
+ // OR for deterministic work:
69
+ // execute: async (state) => ({ steps: [...] }),
70
+ };
71
+ ```
72
+
73
+ Graph wiring:
74
+ ```js
75
+ import { WorkflowAgent, WorkflowGraph } from '@zibby/core';
76
+ export class MyWorkflow extends WorkflowAgent {
77
+ buildGraph() {
78
+ const graph = new WorkflowGraph();
79
+ graph.addNode('plan', planNode);
80
+ graph.addNode('act', actNode);
81
+ graph.addEdge('plan', 'act');
82
+ graph.addEdge('act', 'END');
83
+ graph.setEntryPoint('plan');
84
+ return graph;
85
+ }
86
+ }
87
+ ```
88
+
89
+ **Each node's output goes to `state[nodeName]`.** Read it in downstream
90
+ nodes via `state.plan.steps`. Initial input from `-p key=value` is at
91
+ the TOP of state (`state.key`), not nested under `input`.
92
+
93
+ Loops: route back to an earlier node via `addConditionalEdges`. Counter
94
+ state lives in the looping node's own outputSchema (`state.check?.attempts`).
95
+
96
+ ### Apps
97
+
98
+ ```bash
99
+ zibby app templates # browse the catalog
100
+ zibby app deploy <appType> --project <id> [--name "..."] [--auth-type basic|token|none ...]
101
+ zibby app deploy --goal "<text>" --project <id> # goal-mode (LLM bootstrap)
102
+ zibby app list [--project <id>]
103
+ zibby app status <instanceId>
104
+ zibby app logs <instanceId> [-t] [--service <name>]
105
+ zibby app upgrade <instanceId> --version vX.Y.Z # agent-ops base image bump
106
+ zibby app set-auth <instanceId> --auth-type basic --auth-user admin --auth-password ...
107
+ zibby app set-auth <instanceId> --off # disable Caddy auth sidecar
108
+ zibby app destroy <instanceId> --yes # PERMANENT — wipes EFS
109
+ ```
110
+
111
+ Two deploy paths:
112
+ - **Catalog** (`zibby app deploy <appType>`) — deterministic, baked task
113
+ def, 2-3 min cold start.
114
+ - **Goal-mode** (`zibby app deploy --goal "..."`) — LLM bootstrap via
115
+ `agent-ops`, 5-30 min cold start.
116
+
117
+ Goal-mode flags worth knowing: `--provider claude|codex`, `--model <id>`,
118
+ `--anthropic-token sk-ant-oat01-...` (per-deploy Claude credential override),
119
+ `--max-turns N` (default 25, heavy installs need 60-100), `--timeout-min N`
120
+ (default 20, heavy installs need 30-45).
121
+
122
+ Auth: every app gets a public `https://<id>.apps.zibby.app` URL. Lock it
123
+ down with `--auth-type basic|token`. Generate creds via `openssl rand -hex`.
124
+ Use `--auth-type none` (or omit) only if the app has its own login.
125
+
126
+ ---
127
+
128
+ ## Recipe: "create a workflow that does X"
129
+
130
+ 1. **Sketch the graph.** 2-5 nodes. LLM (judgement) vs custom-code
131
+ (deterministic shell / HTTP / parse). Linear or conditional?
132
+ 2. `zibby workflow new <name>` — scaffold.
133
+ 3. Edit `workflow.json`, `nodes/*.mjs`, `graph.mjs`. Every node has a
134
+ Zod `outputSchema`. Default agent: `claude`.
135
+ 4. `zibby workflow validate <name>` — fix reported issues.
136
+ 5. `zibby workflow run <name> -p ...` — realistic input. Read the
137
+ timeline. If a node fails, the `raw` field shows what the model
138
+ returned vs what the schema expected.
139
+ 6. Iterate prompts. The user shouldn't need to.
140
+ 7. Ask before `zibby workflow deploy` — cloud costs.
141
+
142
+ ## Recipe: "deploy a hosted X"
143
+
144
+ 1. **Catalog or goal?** Check `zibby app templates`. Catalog if X
145
+ is listed; else goal-mode.
146
+ 2. **Which project?** `zibby status` for current; `zibby list` to
147
+ pick.
148
+ 3. **What auth?** Ask before running. `basic` for browser tools,
149
+ `token` for APIs, `none` only for apps with their own login.
150
+ Generate creds with `openssl rand -hex 16` (basic) / `-hex 32`
151
+ (token).
152
+ 4. **Run deploy.** Capture the `instanceId`.
153
+ 5. **Tail logs while it boots** (`zibby app logs <id> -t` in background).
154
+ 6. **Verify status reaches `running`.** Tell the user URL + creds.
155
+
156
+ ## Recipe: "my workflow / app is broken"
157
+
158
+ For workflows:
159
+ 1. `zibby workflow list` — did the deploy succeed? Is `bundleStatus`
160
+ ready?
161
+ 2. `zibby workflow trigger <uuid>` — did it accept?
162
+ 3. `zibby workflow logs <uuid> -t` — did the task start? Did a node
163
+ fail? Read the `Prompt sent to LLM` + `Response` blocks for agent
164
+ errors.
165
+
166
+ For apps:
167
+ 1. `zibby app status <id>` — read the status. `failed` → reason field.
168
+ Stuck `pending` → wait 5 min, then escalate to logs.
169
+ 2. `zibby app logs <id> [--service agent-ops]` — supervisor trail +
170
+ container stderr.
171
+ 3. Decide: restart, env-fix, or destroy + redeploy. Never destroy
172
+ without confirming EFS data loss.
173
+
174
+ ## Recipe: "set an env var for production"
175
+
176
+ For a workflow:
177
+ ```bash
178
+ # next trigger picks it up; existing executions unaffected
179
+ ```
180
+
181
+ For an app:
182
+ ```bash
183
+ ```
184
+
185
+ Workflow env wins over project secrets. App env applies at task-start;
186
+ restart to apply changes.
187
+
188
+ ## Recipe: "rotate the auth on a hosted app"
189
+
190
+ ```bash
191
+ zibby app set-auth <instanceId> --auth-type basic \
192
+ --auth-user admin \
193
+ --auth-password $(openssl rand -hex 16)
194
+ ```
195
+
196
+ Caddy reloads in ~5s. Old creds stop working immediately. No
197
+ container restart. Tell the user to save the new password before they
198
+ log out.
199
+
200
+ ## Recipe: "wire the Zibby MCP into my IDE"
201
+
202
+ ```bash
203
+ zibby mcp install --ide claude --scope project # or --ide cursor / codex
204
+ # reload the IDE; agent can now call zibby_workflow_* / zibby_app_* tools directly
205
+ ```
206
+
207
+ For headless / shared configs, pass `--pat zby_xxx` instead of using
208
+ the session token.
209
+
210
+ ---
211
+
212
+ ## Slash commands available in this repo
213
+
214
+ Every Zibby slash command starts with `/zibby-`:
215
+
216
+ **Workflows:** `/zibby-new-workflow`, `/zibby-add-node`, `/zibby-add-skill`,
217
+ `/zibby-validate-workflow`, `/zibby-deploy`, `/zibby-trigger`,
218
+ `/zibby-list`, `/zibby-tail`, `/zibby-debug`, `/zibby-delete`,
219
+ `/zibby-static-ip`, `/zibby-workflow-env`
220
+
221
+ **Apps:** `/zibby-deploy-app`, `/zibby-app-list`, `/zibby-app-status`,
222
+ `/zibby-app-logs`, `/zibby-app-restart`, `/zibby-app-upgrade`,
223
+ `/zibby-app-destroy`, `/zibby-set-auth`, `/zibby-app-env`
224
+
225
+ **Tests + memory:** `/zibby-test-write`, `/zibby-test-run`,
226
+ `/zibby-test-debug`, `/zibby-test-generate`, `/zibby-memory-stats`,
227
+ `/zibby-memory-cost`, `/zibby-memory-pull`,
228
+ `/zibby-memory-remote-use-hosted`
229
+
230
+ **Auth + setup:** `/zibby-login`, `/zibby-status`, `/zibby-mcp-install`
231
+
232
+ Each slash command is a self-contained recipe — invoke it and the
233
+ agent follows the steps inside. Live files: `.claude/commands/zibby-*.md`.
234
+
235
+ ---
236
+
237
+ ## Canonical docs
238
+
239
+ Single source of truth — when in doubt, fetch:
240
+
241
+ - Workflows: https://docs.zibby.app/workflows
242
+ - Apps: https://docs.zibby.app/apps
243
+ - agent-ops daemon: https://docs.zibby.app/apps/agent-ops
244
+ - CLI reference: https://docs.zibby.app/cli
245
+ - MCP server: https://docs.zibby.app/cli/mcp
246
+
247
+ These notes are a snapshot. Docs are kept current.
248
+ <!-- END ZIBBY -->