@zibby/skills 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +2 -2
- package/dist/chat-memory.js +15 -15
- package/dist/core-tools.js +2 -2
- package/dist/function-skill.js +1 -1
- package/dist/git.js +2 -2
- package/dist/github.js +3 -3
- package/dist/index.js +646 -1
- package/dist/jira.js +6 -6
- package/dist/memory.js +4 -4
- package/dist/package.json +16 -11
- package/dist/sentry.js +2 -2
- package/dist/skill-installer.js +3 -3
- package/dist/slack.js +2 -2
- package/dist/test-runner.js +13 -13
- package/dist/workflow-builder.js +146 -82
- package/docs/analysis.md +109 -0
- package/docs/cli-reference.md +338 -0
- package/docs/cloning-repositories.md +285 -0
- package/docs/custom-workflows.md +358 -0
- package/docs/getting-started.md +108 -0
- package/docs/installation.md +127 -0
- package/docs/integrations/github.md +73 -0
- package/docs/integrations/jira.md +71 -0
- package/docs/intro.md +87 -0
- package/docs/packages/cli.md +238 -0
- package/docs/packages/core.md +256 -0
- package/docs/packages/mcp-browser.md +110 -0
- package/docs/packages/memory.md +223 -0
- package/docs/packages/skills.md +216 -0
- package/docs/reviewing-results.md +114 -0
- package/docs/running-tests.md +134 -0
- package/docs/triggering-workflows.md +552 -0
- package/docs/workflow-artifact-layout-evaluation.md +119 -0
- package/docs/workflow.md +558 -0
- package/package.json +7 -2
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 6
|
|
3
|
+
title: CLI Reference
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CLI Reference
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install -g @zibby/cli
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Commands
|
|
17
|
+
|
|
18
|
+
### `zibby test [spec-path]`
|
|
19
|
+
|
|
20
|
+
Run a test specification.
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Run a local test spec
|
|
24
|
+
zibby test test-specs/login.txt --agent cursor
|
|
25
|
+
|
|
26
|
+
# Run without any project setup
|
|
27
|
+
echo "Go to example.com" > test.txt && zibby test test.txt --agent cursor
|
|
28
|
+
|
|
29
|
+
# Run with cloud sync
|
|
30
|
+
zibby test test-specs/login.txt --sync
|
|
31
|
+
|
|
32
|
+
# Run test cases from cloud
|
|
33
|
+
zibby test --sources TC001,TC002 --execution abc123
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
| Flag | Description |
|
|
37
|
+
|---|---|
|
|
38
|
+
| `--agent <type>` | AI agent: `cursor`, `claude`, or `codex` |
|
|
39
|
+
| `--workflow <name>` | Workflow to use (e.g., `QuickSmokeWorkflow`, `quick-smoke`) |
|
|
40
|
+
| `--headless` | Run browser in headless mode |
|
|
41
|
+
| `--node <name>` | Run only a specific node (`preflight`, `execute_live`, `generate_script`) |
|
|
42
|
+
| `--session <id>` | Reuse an existing session (`last` for most recent) — requires `--node` |
|
|
43
|
+
| `--sources <ids>` | Comma-separated test case IDs to fetch from cloud |
|
|
44
|
+
| `--execution <id>` | Execution ID (required with `--sources`) |
|
|
45
|
+
| `--project <id>` | Project ID or API token (auto-detected from `ZIBBY_API_KEY`) |
|
|
46
|
+
| `--collection <id-or-name>` | Collection to organize the run into (creates if name is new) |
|
|
47
|
+
| `--folder <path>` | Folder within the collection |
|
|
48
|
+
| `--sync` | Force upload results to cloud |
|
|
49
|
+
| `--no-sync` | Skip cloud upload |
|
|
50
|
+
| `--config <path>` | Config file path (default: `.zibby.config.js`) |
|
|
51
|
+
| `--auto-approve` | Auto-approve MCP tool calls (for CI/CD) |
|
|
52
|
+
| `-o, --open` | Open results in browser after upload |
|
|
53
|
+
| `--verbose` | Show info-level logs |
|
|
54
|
+
| `--debug` | Show debug-level logs |
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
### `zibby init [project-name]`
|
|
59
|
+
|
|
60
|
+
Initialize a Zibby project with config and workflow files. **Optional** — `zibby test` works without it using the built-in workflow.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
zibby init
|
|
64
|
+
zibby init my-project --agent cursor --cloud-sync
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
| Flag | Description |
|
|
68
|
+
|---|---|
|
|
69
|
+
| `--agent <type>` | `cursor`, `claude`, or `codex` |
|
|
70
|
+
| `--cloud-sync` | Enable cloud sync |
|
|
71
|
+
| `--headless` | Headless browser mode |
|
|
72
|
+
| `--headed` | Headed browser mode |
|
|
73
|
+
| `--api-key <key>` | Zibby API key |
|
|
74
|
+
| `--skip-install` | Skip `npm install` |
|
|
75
|
+
| `-f, --force` | Overwrite existing config |
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
### `zibby login`
|
|
80
|
+
|
|
81
|
+
Authenticate with Zibby (opens browser for OAuth).
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
zibby login
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### `zibby logout`
|
|
90
|
+
|
|
91
|
+
Clear saved session.
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
zibby logout
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
### `zibby status`
|
|
100
|
+
|
|
101
|
+
Show current authentication status.
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
zibby status
|
|
105
|
+
zibby status --json
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
### `zibby list`
|
|
111
|
+
|
|
112
|
+
List your projects and API tokens.
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
zibby list
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
### `zibby upload <spec-path>`
|
|
121
|
+
|
|
122
|
+
Upload existing test artifacts to Zibby Cloud.
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
zibby upload test-specs/login.txt --collection "Auth Tests"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
| Flag | Description |
|
|
129
|
+
|---|---|
|
|
130
|
+
| `--project <id>` | Project ID (required) |
|
|
131
|
+
| `--collection <id-or-name>` | Collection to upload into |
|
|
132
|
+
| `--folder <path>` | Folder within collection |
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
### `zibby video`
|
|
137
|
+
|
|
138
|
+
Organize test videos — moves videos from `test-results/` to sit next to test files.
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
zibby video
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
### `zibby setup-playwright`
|
|
147
|
+
|
|
148
|
+
Configure the Playwright MCP server.
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
zibby setup-playwright
|
|
152
|
+
zibby setup-playwright --headed --viewport-width 1920 --viewport-height 1080
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
### `zibby ci-setup`
|
|
158
|
+
|
|
159
|
+
Configure Cursor Agent for CI/CD pipelines.
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
zibby ci-setup
|
|
163
|
+
zibby ci-setup --get-keys
|
|
164
|
+
zibby ci-setup --save
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
### `zibby g workflow [name]`
|
|
170
|
+
|
|
171
|
+
Scaffold a new custom workflow. Auto-generates a name if omitted.
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
zibby g workflow ticket-triage
|
|
175
|
+
zibby g workflow # auto-generates name
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
### `zibby start <workflow-name>`
|
|
181
|
+
|
|
182
|
+
Start a local dev server for testing a custom workflow.
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
zibby start ticket-triage
|
|
186
|
+
zibby start ticket-triage --port 3850
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
| Flag | Description |
|
|
190
|
+
|---|---|
|
|
191
|
+
| `-p, --port <port>` | Server port (default: 3848) |
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
### `zibby deploy <workflow-name>`
|
|
196
|
+
|
|
197
|
+
Deploy a custom workflow to Zibby Cloud. Returns the trigger URL and workflow UUID.
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
zibby deploy ticket-triage --project <id>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
| Flag | Description |
|
|
204
|
+
|---|---|
|
|
205
|
+
| `--project <id>` | Project ID (or `ZIBBY_PROJECT_ID` env) |
|
|
206
|
+
| `--api-key <key>` | API key (or `ZIBBY_API_KEY` env, or session token) |
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
### `zibby trigger <workflow-uuid>`
|
|
211
|
+
|
|
212
|
+
Trigger a deployed workflow by its UUID. The CLI automatically discovers the project.
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
# Trigger by UUID (project auto-discovered)
|
|
216
|
+
zibby trigger 562e48d7-ef67-4900-96b7-0d7b51a33405
|
|
217
|
+
|
|
218
|
+
# Trigger by UUID with input data
|
|
219
|
+
zibby trigger 562e48d7-ef67-4900-96b7-0d7b51a33405 \
|
|
220
|
+
--input '{"ticket":"JIRA-123"}'
|
|
221
|
+
|
|
222
|
+
# Trigger by name (requires project)
|
|
223
|
+
zibby trigger custom-flow --project <id>
|
|
224
|
+
|
|
225
|
+
# With idempotency key (prevents duplicate runs)
|
|
226
|
+
zibby trigger 562e48d7-ef67-4900-96b7-0d7b51a33405 \
|
|
227
|
+
--idempotency-key "daily-scan-2026-04-27"
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
| Flag | Description |
|
|
231
|
+
|---|---|
|
|
232
|
+
| `--input <json>` | Input data as JSON string |
|
|
233
|
+
| `--idempotency-key <key>` | Prevent duplicate executions (same key within 24h) |
|
|
234
|
+
| `--project <id>` | Project ID (only needed if triggering by workflow name) |
|
|
235
|
+
|
|
236
|
+
**After triggering, stream logs:**
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
zibby logs 562e48d7-ef67-4900-96b7-0d7b51a33405 -t
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
### `zibby logs <workflow-uuid>`
|
|
245
|
+
|
|
246
|
+
Fetch and display logs from a workflow's latest execution.
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
# Fetch logs for latest execution (simple, one-time fetch)
|
|
250
|
+
zibby logs 562e48d7-ef67-4900-96b7-0d7b51a33405
|
|
251
|
+
|
|
252
|
+
# Stream logs in real-time (like "heroku logs -t")
|
|
253
|
+
zibby logs 562e48d7-ef67-4900-96b7-0d7b51a33405 -t
|
|
254
|
+
|
|
255
|
+
# Stream logs by workflow name
|
|
256
|
+
zibby logs --workflow custom-flow --project <id> -t
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
| Flag | Description |
|
|
260
|
+
|---|---|
|
|
261
|
+
| `-t, --follow` | Stream logs in real-time via SSE (Server-Sent Events) |
|
|
262
|
+
| `--project <id>` | Project ID (optional, auto-discovered from workflow UUID) |
|
|
263
|
+
| `--workflow <name>` | Workflow name (fetches latest run) |
|
|
264
|
+
| `--all` | Interleaved logs from all runs (requires `--workflow`) |
|
|
265
|
+
| `--lines <n>` | Max log lines per fetch (default: 1000) |
|
|
266
|
+
|
|
267
|
+
**How it works:**
|
|
268
|
+
|
|
269
|
+
- **Without `-t`**: Fetches complete logs from CloudWatch (permanent storage) and exits. Perfect for historical logs and debugging old executions.
|
|
270
|
+
- **With `-t`**: Streams logs in real-time via SSE from DynamoDB hot cache (24h TTL). Only works for active/recent executions. Press Ctrl+C to stop.
|
|
271
|
+
|
|
272
|
+
**Architecture:**
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
CloudWatch Logs (permanent) ──────────> CLI (without -t)
|
|
276
|
+
│
|
|
277
|
+
└──> Kinesis ──> Lambda ──> DynamoDB (24h TTL) ──> SSE ──> CLI (with -t)
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
### `zibby workflow download`
|
|
283
|
+
|
|
284
|
+
Download a workflow graph from Zibby Cloud.
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
zibby workflow download --type run_test
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### `zibby workflow list`
|
|
291
|
+
|
|
292
|
+
List all workflows for a project.
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
zibby workflow list
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Environment Variables
|
|
301
|
+
|
|
302
|
+
| Variable | Description |
|
|
303
|
+
|---|---|
|
|
304
|
+
| `CURSOR_API_KEY` | Cursor agent API key (required in CI, optional locally) |
|
|
305
|
+
| `ANTHROPIC_API_KEY` | Claude agent API key |
|
|
306
|
+
| `OPENAI_API_KEY` | Codex agent API key |
|
|
307
|
+
| `ZIBBY_API_KEY` | Project API key for cloud sync (from dashboard Settings) |
|
|
308
|
+
| `ZIBBY_USER_TOKEN` | Personal Access Token for CI/CD uploads |
|
|
309
|
+
| `ZIBBY_ENV` | Environment override: `local`, `staging`, `prod` |
|
|
310
|
+
|
|
311
|
+
## Configuration File
|
|
312
|
+
|
|
313
|
+
`.zibby.config.js` in your project root (ESM):
|
|
314
|
+
|
|
315
|
+
```javascript
|
|
316
|
+
export default {
|
|
317
|
+
agent: {
|
|
318
|
+
cursor: { model: 'auto' },
|
|
319
|
+
// claude: { model: 'auto' },
|
|
320
|
+
// codex: { model: 'gpt-5.2-codex' },
|
|
321
|
+
},
|
|
322
|
+
|
|
323
|
+
paths: {
|
|
324
|
+
specs: 'test-specs',
|
|
325
|
+
generated: 'tests',
|
|
326
|
+
output: '.zibby/output',
|
|
327
|
+
},
|
|
328
|
+
|
|
329
|
+
context: {
|
|
330
|
+
filenames: ['CONTEXT.md', 'AGENTS.md'],
|
|
331
|
+
},
|
|
332
|
+
|
|
333
|
+
video: 'on',
|
|
334
|
+
viewport: { width: 1280, height: 720 },
|
|
335
|
+
playwrightArtifacts: true,
|
|
336
|
+
cloudSync: false,
|
|
337
|
+
};
|
|
338
|
+
```
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 8
|
|
3
|
+
title: Cloning Repositories
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Cloning Repositories in Custom Workflows
|
|
7
|
+
|
|
8
|
+
Custom workflows can clone your project's configured repositories (GitHub/GitLab) using the `cloneRepo()` helper function from `@zibby/core`.
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
When your workflow runs in the cloud, it has access to:
|
|
13
|
+
- All repositories configured in your project settings (GitHub/GitLab)
|
|
14
|
+
- Authenticated tokens for cloning (injected securely by the platform)
|
|
15
|
+
- A clean isolated container environment
|
|
16
|
+
|
|
17
|
+
The `cloneRepo()` function handles authentication, supports multiple repos, and works with both GitHub.com and self-hosted GitLab instances.
|
|
18
|
+
|
|
19
|
+
## Basic Usage
|
|
20
|
+
|
|
21
|
+
### Clone All Repositories
|
|
22
|
+
|
|
23
|
+
By default, `cloneRepo()` clones all repositories configured for your project:
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
// nodes/setup.mjs
|
|
27
|
+
import { cloneRepo, z } from '@zibby/core';
|
|
28
|
+
|
|
29
|
+
const SetupOutputSchema = z.object({
|
|
30
|
+
repoPaths: z.record(z.string()),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export const setupNode = {
|
|
34
|
+
name: 'setup',
|
|
35
|
+
|
|
36
|
+
async preProcess(state) {
|
|
37
|
+
// Clone all repos
|
|
38
|
+
const repoPaths = await cloneRepo();
|
|
39
|
+
|
|
40
|
+
// repoPaths = {
|
|
41
|
+
// 'myorg/backend': '/workspace/repos/myorg-backend',
|
|
42
|
+
// 'myorg/frontend': '/workspace/repos/myorg-frontend'
|
|
43
|
+
// }
|
|
44
|
+
|
|
45
|
+
return { repoPaths };
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
prompt: (state) => `Repositories cloned:
|
|
49
|
+
${JSON.stringify(state.setup.repoPaths, null, 2)}
|
|
50
|
+
|
|
51
|
+
Ready to analyze the codebase.`,
|
|
52
|
+
|
|
53
|
+
outputSchema: SetupOutputSchema,
|
|
54
|
+
};
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Clone Specific Repositories
|
|
58
|
+
|
|
59
|
+
If you only need certain repositories:
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
// Clone only backend repo
|
|
63
|
+
const repoPaths = await cloneRepo({
|
|
64
|
+
repos: ['myorg/backend']
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Using Cloned Repositories
|
|
69
|
+
|
|
70
|
+
Access the cloned code via the returned paths:
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
// nodes/analyze.mjs
|
|
74
|
+
import { z } from '@zibby/core';
|
|
75
|
+
|
|
76
|
+
const AnalyzeOutputSchema = z.object({
|
|
77
|
+
summary: z.string(),
|
|
78
|
+
files: z.array(z.string()),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export const analyzeNode = {
|
|
82
|
+
name: 'analyze',
|
|
83
|
+
|
|
84
|
+
prompt: (state) => `Analyze the codebase.
|
|
85
|
+
|
|
86
|
+
Repositories are cloned at:
|
|
87
|
+
${JSON.stringify(state.setup.repoPaths, null, 2)}
|
|
88
|
+
|
|
89
|
+
Use the Shell tool to:
|
|
90
|
+
1. List files in the repos (e.g., ls ${Object.values(state.setup.repoPaths)[0]})
|
|
91
|
+
2. Read important files (e.g., cat ${Object.values(state.setup.repoPaths)[0]}/README.md)
|
|
92
|
+
3. Run analysis commands (e.g., cd ${Object.values(state.setup.repoPaths)[0]} && npm audit)
|
|
93
|
+
|
|
94
|
+
Return a summary and list of key files.`,
|
|
95
|
+
|
|
96
|
+
outputSchema: AnalyzeOutputSchema,
|
|
97
|
+
};
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Configuration Options
|
|
101
|
+
|
|
102
|
+
```javascript
|
|
103
|
+
await cloneRepo({
|
|
104
|
+
// Clone specific repos only (default: all repos)
|
|
105
|
+
repos: ['myorg/backend', 'myorg/frontend'],
|
|
106
|
+
|
|
107
|
+
// Base directory for cloned repos (default: '/workspace/repos')
|
|
108
|
+
baseDir: '/workspace/repos',
|
|
109
|
+
|
|
110
|
+
// Clone depth - 1 for shallow clone, 0 for full history (default: 1)
|
|
111
|
+
depth: 1,
|
|
112
|
+
|
|
113
|
+
// Specific branch to clone (default: repo's default branch)
|
|
114
|
+
branch: 'develop',
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Return Value
|
|
119
|
+
|
|
120
|
+
`cloneRepo()` returns an object mapping repository names to their cloned paths:
|
|
121
|
+
|
|
122
|
+
```javascript
|
|
123
|
+
{
|
|
124
|
+
'myorg/backend': '/workspace/repos/myorg-backend',
|
|
125
|
+
'myorg/frontend': '/workspace/repos/myorg-frontend'
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
If a repository fails to clone, its value will be `null`:
|
|
130
|
+
|
|
131
|
+
```javascript
|
|
132
|
+
{
|
|
133
|
+
'myorg/backend': '/workspace/repos/myorg-backend',
|
|
134
|
+
'myorg/broken-repo': null // Failed to clone
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Complete Example Workflow
|
|
139
|
+
|
|
140
|
+
Here's a full workflow that clones repos and runs analysis:
|
|
141
|
+
|
|
142
|
+
```javascript
|
|
143
|
+
// graph.mjs
|
|
144
|
+
import { WorkflowAgent, WorkflowGraph } from '@zibby/core';
|
|
145
|
+
import { setupNode, analyzeNode, reportNode } from './nodes/index.mjs';
|
|
146
|
+
|
|
147
|
+
export class CodeAuditWorkflow extends WorkflowAgent {
|
|
148
|
+
buildGraph() {
|
|
149
|
+
const graph = new WorkflowGraph();
|
|
150
|
+
|
|
151
|
+
graph.addNode('setup', setupNode);
|
|
152
|
+
graph.addNode('analyze', analyzeNode);
|
|
153
|
+
graph.addNode('report', reportNode);
|
|
154
|
+
|
|
155
|
+
graph.setEntryPoint('setup');
|
|
156
|
+
graph.addEdge('setup', 'analyze');
|
|
157
|
+
graph.addEdge('analyze', 'report');
|
|
158
|
+
graph.addEdge('report', 'END');
|
|
159
|
+
|
|
160
|
+
return graph;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
```javascript
|
|
166
|
+
// nodes/setup.mjs
|
|
167
|
+
import { cloneRepo, z } from '@zibby/core';
|
|
168
|
+
|
|
169
|
+
export const setupNode = {
|
|
170
|
+
name: 'setup',
|
|
171
|
+
|
|
172
|
+
async preProcess(state) {
|
|
173
|
+
console.log('Cloning repositories...');
|
|
174
|
+
const repoPaths = await cloneRepo();
|
|
175
|
+
console.log('Cloned:', Object.keys(repoPaths).length, 'repositories');
|
|
176
|
+
return { repoPaths };
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
prompt: () => 'Repositories cloned successfully. Ready for analysis.',
|
|
180
|
+
|
|
181
|
+
outputSchema: z.object({
|
|
182
|
+
ready: z.boolean().default(true),
|
|
183
|
+
}),
|
|
184
|
+
};
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
```javascript
|
|
188
|
+
// nodes/analyze.mjs
|
|
189
|
+
import { z } from '@zibby/core';
|
|
190
|
+
|
|
191
|
+
export const analyzeNode = {
|
|
192
|
+
name: 'analyze',
|
|
193
|
+
|
|
194
|
+
prompt: (state) => {
|
|
195
|
+
const repoList = Object.entries(state.setup.repoPaths)
|
|
196
|
+
.map(([name, path]) => `- ${name}: ${path}`)
|
|
197
|
+
.join('\\n');
|
|
198
|
+
|
|
199
|
+
return `Analyze all cloned repositories for security issues.
|
|
200
|
+
|
|
201
|
+
Cloned repositories:
|
|
202
|
+
${repoList}
|
|
203
|
+
|
|
204
|
+
For each repository, use the Shell tool to:
|
|
205
|
+
1. Check for dependencies with known vulnerabilities (npm audit, pip check, etc.)
|
|
206
|
+
2. Search for common security issues (hardcoded secrets, SQL injection patterns, etc.)
|
|
207
|
+
3. Review package.json/requirements.txt for outdated dependencies
|
|
208
|
+
|
|
209
|
+
Return a comprehensive security audit report.`;
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
outputSchema: z.object({
|
|
213
|
+
findings: z.array(z.object({
|
|
214
|
+
severity: z.enum(['low', 'medium', 'high', 'critical']),
|
|
215
|
+
repo: z.string(),
|
|
216
|
+
description: z.string(),
|
|
217
|
+
file: z.string().optional(),
|
|
218
|
+
})),
|
|
219
|
+
summary: z.string(),
|
|
220
|
+
}),
|
|
221
|
+
};
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## How It Works
|
|
225
|
+
|
|
226
|
+
1. **Project Configuration**: You configure repositories in your project settings (Web UI)
|
|
227
|
+
2. **Secure Token Injection**: When the workflow runs, Zibby injects:
|
|
228
|
+
- `REPOS` env var (array of repo metadata with clone URLs)
|
|
229
|
+
- `GITHUB_TOKEN` and/or `GITLAB_TOKEN` (OAuth tokens for authentication)
|
|
230
|
+
3. **Authenticated Clone**: `cloneRepo()` constructs authenticated URLs and clones via `git clone`
|
|
231
|
+
4. **Isolation**: Each workflow run gets a fresh container with no cached state
|
|
232
|
+
|
|
233
|
+
## Supported Platforms
|
|
234
|
+
|
|
235
|
+
- **GitHub** (github.com)
|
|
236
|
+
- **GitLab** (gitlab.com)
|
|
237
|
+
- **Self-hosted GitLab** (custom instance URLs from project settings)
|
|
238
|
+
|
|
239
|
+
## Error Handling
|
|
240
|
+
|
|
241
|
+
`cloneRepo()` is resilient to failures:
|
|
242
|
+
|
|
243
|
+
```javascript
|
|
244
|
+
const repoPaths = await cloneRepo();
|
|
245
|
+
|
|
246
|
+
// Check for failures
|
|
247
|
+
for (const [repo, path] of Object.entries(repoPaths)) {
|
|
248
|
+
if (path === null) {
|
|
249
|
+
console.error(`Failed to clone ${repo}`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Continue with successfully cloned repos
|
|
254
|
+
const successfulRepos = Object.entries(repoPaths)
|
|
255
|
+
.filter(([_, path]) => path !== null);
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Common failure reasons:
|
|
259
|
+
- Missing/expired authentication tokens
|
|
260
|
+
- Repository doesn't exist or access denied
|
|
261
|
+
- Network issues
|
|
262
|
+
- Invalid clone URL
|
|
263
|
+
|
|
264
|
+
## Performance Tips
|
|
265
|
+
|
|
266
|
+
1. **Shallow Clones**: Use `depth: 1` (default) for faster cloning
|
|
267
|
+
2. **Specific Repos**: Only clone repos you need via the `repos` option
|
|
268
|
+
3. **Parallel Execution**: `cloneRepo()` clones all repos in parallel automatically
|
|
269
|
+
|
|
270
|
+
## Local Development
|
|
271
|
+
|
|
272
|
+
When running workflows locally (`zibby start`), you'll need to:
|
|
273
|
+
1. Set `REPOS` env var manually (JSON array)
|
|
274
|
+
2. Provide `GITHUB_TOKEN` or `GITLAB_TOKEN`
|
|
275
|
+
3. Ensure `git` is installed
|
|
276
|
+
|
|
277
|
+
Example for local testing:
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
export REPOS='[{"name":"myorg/backend","provider":"github","cloneUrl":"https://github.com/myorg/backend.git"}]'
|
|
281
|
+
export GITHUB_TOKEN="ghp_your_token"
|
|
282
|
+
zibby start my-workflow
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
In production (cloud), these are injected automatically.
|