bazaar.it 0.1.0 → 0.2.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.
- package/README.md +489 -3
- package/bin/baz.js +6 -1
- package/dist/commands/auth.d.ts +2 -0
- package/dist/commands/auth.js +109 -0
- package/dist/commands/capabilities.d.ts +2 -0
- package/dist/commands/capabilities.js +44 -0
- package/dist/commands/context.d.ts +13 -0
- package/dist/commands/context.js +498 -0
- package/dist/commands/export.d.ts +2 -0
- package/dist/commands/export.js +360 -0
- package/dist/commands/logs.d.ts +2 -0
- package/dist/commands/logs.js +180 -0
- package/dist/commands/loop.d.ts +2 -0
- package/dist/commands/loop.js +538 -0
- package/dist/commands/mcp.d.ts +2 -0
- package/dist/commands/mcp.js +143 -0
- package/dist/commands/media.d.ts +2 -0
- package/dist/commands/media.js +362 -0
- package/dist/commands/project.d.ts +2 -0
- package/dist/commands/project.js +786 -0
- package/dist/commands/prompt.d.ts +2 -0
- package/dist/commands/prompt.js +529 -0
- package/dist/commands/recipe.d.ts +15 -0
- package/dist/commands/recipe.js +607 -0
- package/dist/commands/review.d.ts +17 -0
- package/dist/commands/review.js +345 -0
- package/dist/commands/scenes.d.ts +2 -0
- package/dist/commands/scenes.js +481 -0
- package/dist/commands/share.d.ts +2 -0
- package/dist/commands/share.js +226 -0
- package/dist/commands/state.d.ts +2 -0
- package/dist/commands/state.js +171 -0
- package/dist/commands/status.d.ts +2 -0
- package/dist/commands/status.js +219 -0
- package/dist/commands/template.d.ts +2 -0
- package/dist/commands/template.js +123 -0
- package/dist/commands/verify.d.ts +2 -0
- package/dist/commands/verify.js +150 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +124 -0
- package/dist/lib/api.d.ts +186 -0
- package/dist/lib/api.js +717 -0
- package/dist/lib/banner.d.ts +12 -0
- package/dist/lib/banner.js +69 -0
- package/dist/lib/config.d.ts +33 -0
- package/dist/lib/config.js +99 -0
- package/dist/lib/output.d.ts +52 -0
- package/dist/lib/output.js +162 -0
- package/dist/lib/project-state.d.ts +52 -0
- package/dist/lib/project-state.js +178 -0
- package/dist/lib/sse.d.ts +168 -0
- package/dist/lib/sse.js +227 -0
- package/dist/lib/version.d.ts +1 -0
- package/dist/lib/version.js +3 -0
- package/dist/repl.d.ts +4 -0
- package/dist/repl.js +764 -0
- package/package.json +39 -5
package/README.md
CHANGED
|
@@ -1,5 +1,491 @@
|
|
|
1
|
-
#
|
|
1
|
+
# BAZ CLI
|
|
2
2
|
|
|
3
|
-
AI-powered
|
|
3
|
+
**AI-powered video generation from your terminal.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```
|
|
6
|
+
██████╗ █████╗ ███████╗
|
|
7
|
+
██╔══██╗██╔══██╗╚══███╔╝
|
|
8
|
+
██████╔╝███████║ ███╔╝
|
|
9
|
+
██╔══██╗██╔══██║ ███╔╝
|
|
10
|
+
██████╔╝██║ ██║███████╗
|
|
11
|
+
╚═════╝ ╚═╝ ╚═╝╚══════╝
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Programmatic access to Bazaar video generation for external agents, automation, and power users.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# From npm
|
|
20
|
+
npm install -g bazaar.it
|
|
21
|
+
|
|
22
|
+
# From repo (recommended for development)
|
|
23
|
+
cd cli
|
|
24
|
+
npm install
|
|
25
|
+
npm run build
|
|
26
|
+
|
|
27
|
+
# Link globally (optional)
|
|
28
|
+
npm link
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or run directly with tsx during development:
|
|
32
|
+
```bash
|
|
33
|
+
npx tsx src/index.ts <command>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# 1. Authenticate
|
|
40
|
+
baz auth login <your-api-key>
|
|
41
|
+
|
|
42
|
+
# 2. Set a project
|
|
43
|
+
baz project list
|
|
44
|
+
baz project create --name "My Video Project" --format landscape
|
|
45
|
+
baz project use <project-id>
|
|
46
|
+
|
|
47
|
+
# 3. Generate!
|
|
48
|
+
baz prompt "Create an intro scene with the text 'Hello World' in neon colors"
|
|
49
|
+
|
|
50
|
+
# Agent-friendly mode
|
|
51
|
+
export BAZ_AGENT=1
|
|
52
|
+
baz prompt "Create an intro scene with the text 'Hello World' in neon colors"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Interactive Mode (REPL)
|
|
56
|
+
|
|
57
|
+
Run `baz` without arguments to enter interactive mode:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
$ baz
|
|
61
|
+
|
|
62
|
+
██████╗ █████╗ ███████╗
|
|
63
|
+
██╔══██╗██╔══██╗╚══███╔╝
|
|
64
|
+
██████╔╝███████║ ███╔╝
|
|
65
|
+
██╔══██╗██╔══██║ ███╔╝
|
|
66
|
+
██████╔╝██║ ██║███████╗
|
|
67
|
+
╚═════╝ ╚═╝ ╚═╝╚══════╝
|
|
68
|
+
|
|
69
|
+
AI-powered video generation v0.1.0
|
|
70
|
+
─────────────────────────────────────
|
|
71
|
+
Type a command or prompt. Use 'help' for commands.
|
|
72
|
+
|
|
73
|
+
baz> project list
|
|
74
|
+
baz> prompt "Create an intro scene"
|
|
75
|
+
baz> exit
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Features:
|
|
79
|
+
- Tab completion for commands
|
|
80
|
+
- Persistent session state
|
|
81
|
+
- History navigation with arrow keys
|
|
82
|
+
- Commands work without `baz` prefix
|
|
83
|
+
|
|
84
|
+
## Commands
|
|
85
|
+
|
|
86
|
+
### Authentication
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Login with API key
|
|
90
|
+
baz auth login <api-key>
|
|
91
|
+
|
|
92
|
+
# Check authentication status
|
|
93
|
+
baz auth status
|
|
94
|
+
|
|
95
|
+
# Logout
|
|
96
|
+
baz auth logout
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Get an API Key:**
|
|
100
|
+
1. **For humans**: Generate at https://bazaar.it/settings/api-keys
|
|
101
|
+
2. **For service accounts**: Use the admin script:
|
|
102
|
+
```bash
|
|
103
|
+
npx tsx scripts/create-service-account.ts maya@bazaar.it "Maya Bot" "Maya CLI"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Projects
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# List your projects
|
|
110
|
+
baz project list
|
|
111
|
+
|
|
112
|
+
# Create a new project
|
|
113
|
+
baz project create --name "My Video Project"
|
|
114
|
+
baz project create --name "TikTok Hook" --format portrait
|
|
115
|
+
|
|
116
|
+
# Set active project (used by default for all commands)
|
|
117
|
+
baz project use <project-id>
|
|
118
|
+
|
|
119
|
+
# Show current project
|
|
120
|
+
baz project current
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Prompts
|
|
124
|
+
|
|
125
|
+
The main command for AI video generation:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Basic prompt
|
|
129
|
+
baz prompt "Create a 10 second intro with a blue gradient background"
|
|
130
|
+
|
|
131
|
+
# With images attached
|
|
132
|
+
baz prompt "Recreate this design" --image ./design.png --image ./logo.png
|
|
133
|
+
|
|
134
|
+
# With URL context (fetches and analyzes the URL)
|
|
135
|
+
baz prompt "Create a video based on this article" --url https://example.com/article
|
|
136
|
+
|
|
137
|
+
# Agent-max mode (more thorough, takes longer)
|
|
138
|
+
baz prompt "Complex animation sequence" --max
|
|
139
|
+
|
|
140
|
+
# Read prompt from file
|
|
141
|
+
baz prompt "Use the script" --file ./script.txt
|
|
142
|
+
|
|
143
|
+
# Show full agent response
|
|
144
|
+
baz prompt "Create something cool" --verbose
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Options:**
|
|
148
|
+
| Option | Description |
|
|
149
|
+
|--------|-------------|
|
|
150
|
+
| `--mode <mode>` | Generation mode: `agent` (default), `agent-max`, `multi-scene` |
|
|
151
|
+
| `--max` | Shorthand for `--mode agent-max` |
|
|
152
|
+
| `--file <path>` | Read prompt from a file |
|
|
153
|
+
| `--image <path>` | Attach image(s) — can use multiple times |
|
|
154
|
+
| `--url <url>` | Attach URL(s) for context — can use multiple times |
|
|
155
|
+
| `--verbose` | Show agent's full response text |
|
|
156
|
+
| `--no-stream` | Disable streaming output |
|
|
157
|
+
|
|
158
|
+
### Scenes
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# List all scenes in active project
|
|
162
|
+
baz scenes list
|
|
163
|
+
|
|
164
|
+
# Get scene details
|
|
165
|
+
baz scenes list
|
|
166
|
+
|
|
167
|
+
# Get scene TSX code
|
|
168
|
+
baz scenes code <scene-id>
|
|
169
|
+
|
|
170
|
+
# Get scene code
|
|
171
|
+
baz scenes code <scene-id>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Media Upload
|
|
175
|
+
|
|
176
|
+
Upload files to your project's media library:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Upload an image
|
|
180
|
+
baz media upload ./image.png
|
|
181
|
+
|
|
182
|
+
# Upload a video
|
|
183
|
+
baz media upload ./video.mp4
|
|
184
|
+
|
|
185
|
+
# Upload with custom name
|
|
186
|
+
baz media upload ./file.png --name "my-logo.png"
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**Supported formats:**
|
|
190
|
+
- **Images**: jpg, png, gif, webp, avif, heic (max 50MB)
|
|
191
|
+
- **Videos**: mp4, webm, mov, avi, mkv (max 2GB)
|
|
192
|
+
- **Audio**: mp3, wav, ogg, flac, aac, m4a (max 500MB)
|
|
193
|
+
|
|
194
|
+
### Export
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# Start export
|
|
198
|
+
baz export start
|
|
199
|
+
|
|
200
|
+
# Check export status
|
|
201
|
+
baz export status <job-id>
|
|
202
|
+
|
|
203
|
+
# Wait for completion
|
|
204
|
+
baz export status <job-id> --wait
|
|
205
|
+
|
|
206
|
+
# List recent exports
|
|
207
|
+
baz export list
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Status
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
# Show overall status (auth, project, timeline)
|
|
214
|
+
baz status
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### State & Verification
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# Snapshot state for agents/automation
|
|
221
|
+
baz state --json
|
|
222
|
+
|
|
223
|
+
# Structural validation (overlaps, invalid durations, compile errors)
|
|
224
|
+
baz project validate --json
|
|
225
|
+
|
|
226
|
+
# Criteria verification
|
|
227
|
+
baz verify --criteria "logo visible,CTA present,duration <= 60s" --json
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### MCP Manifest
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# MCP-style manifest for integrations
|
|
234
|
+
baz mcp
|
|
235
|
+
baz mcp schema
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Example output:
|
|
239
|
+
```
|
|
240
|
+
Project Status
|
|
241
|
+
────────────────────────────────────────────────────────────
|
|
242
|
+
|
|
243
|
+
Project: My Product Demo
|
|
244
|
+
ID: f0ba67dc...
|
|
245
|
+
|
|
246
|
+
┌─────────────────────────────────────────────────────────┐
|
|
247
|
+
│ Scenes: 5 Tracks: 2 Duration: 0:45 ✓ OK │
|
|
248
|
+
└─────────────────────────────────────────────────────────┘
|
|
249
|
+
|
|
250
|
+
Timeline:
|
|
251
|
+
Track 0 │▓▓▓▓Intro▓▓▓▓▓▓▓Main▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓Outro▓▓│
|
|
252
|
+
Track 1 │ ▓▓▓▓Logo▓▓▓▓ │
|
|
253
|
+
└──────────────────────────────────────────┘
|
|
254
|
+
0:00 0:22 0:45
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Logs (Beta)
|
|
258
|
+
|
|
259
|
+
Query runtime logs:
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
# Show recent logs
|
|
263
|
+
baz logs
|
|
264
|
+
|
|
265
|
+
# Show only errors
|
|
266
|
+
baz logs --errors
|
|
267
|
+
|
|
268
|
+
# Search logs
|
|
269
|
+
baz logs --search "error"
|
|
270
|
+
|
|
271
|
+
# Filter by API path
|
|
272
|
+
baz logs --path /api/generate-stream
|
|
273
|
+
|
|
274
|
+
# Custom time range
|
|
275
|
+
baz logs --since 24h --limit 100
|
|
276
|
+
|
|
277
|
+
# Filter by current project
|
|
278
|
+
baz logs --project
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## Agent Capabilities
|
|
282
|
+
|
|
283
|
+
The agent has access to the same tools as the web app:
|
|
284
|
+
|
|
285
|
+
### Scene Operations
|
|
286
|
+
- **Create scenes** — Add new scenes with animations, text, images
|
|
287
|
+
- **Edit scenes** — Modify existing scene code, styling, timing
|
|
288
|
+
- **Delete scenes** — Remove scenes from the project
|
|
289
|
+
- **Trim scenes** — Adjust start time and duration
|
|
290
|
+
|
|
291
|
+
### Media Generation
|
|
292
|
+
- **Generate images** — AI image generation (DALL-E, etc.)
|
|
293
|
+
- **Generate video** — AI video generation (Seedance, Veo 3)
|
|
294
|
+
- **Generate voiceover** — Text-to-speech with multiple voices
|
|
295
|
+
- **Generate music** — AI background music generation
|
|
296
|
+
- **Remove backgrounds** — Extract subjects from images
|
|
297
|
+
|
|
298
|
+
### Gathering Tools
|
|
299
|
+
- **Fetch URLs** — Extract content from web pages
|
|
300
|
+
- **Take screenshots** — Capture web pages as images
|
|
301
|
+
- **Summarize** — AI-powered content summarization
|
|
302
|
+
|
|
303
|
+
### Planning & Orchestration
|
|
304
|
+
- **Video plans** — Create multi-scene video outlines
|
|
305
|
+
- **Recipes** — Reusable templates for video generation
|
|
306
|
+
- **Workflows** — Multi-step automation pipelines
|
|
307
|
+
|
|
308
|
+
## Output Modes
|
|
309
|
+
|
|
310
|
+
### Streaming (default)
|
|
311
|
+
|
|
312
|
+
Shows real-time progress:
|
|
313
|
+
|
|
314
|
+
```
|
|
315
|
+
Mode: agent
|
|
316
|
+
Project: abc123
|
|
317
|
+
|
|
318
|
+
[2s] 🧠 Analyzing your request...
|
|
319
|
+
✔ [3s] 🧠 Analyzing your request...
|
|
320
|
+
[4s] 🎬 Creating scene
|
|
321
|
+
✔ [8s] 🎬 Creating scene
|
|
322
|
+
[8s] ✅ Created: "Intro Scene"
|
|
323
|
+
|
|
324
|
+
┌────────────────────────────────────────────────┐
|
|
325
|
+
│ ✓ Done! (1 scene in 15s) │
|
|
326
|
+
└────────────────────────────────────────────────┘
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### JSON Mode
|
|
330
|
+
|
|
331
|
+
For programmatic parsing:
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
baz prompt "..." --json
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
Returns:
|
|
338
|
+
```json
|
|
339
|
+
{
|
|
340
|
+
"success": true,
|
|
341
|
+
"scenesCreated": ["scene-id-1"],
|
|
342
|
+
"scenesUpdated": [],
|
|
343
|
+
"errors": [],
|
|
344
|
+
"elapsed": "15s",
|
|
345
|
+
"steps": 4
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## Global Options
|
|
350
|
+
|
|
351
|
+
```
|
|
352
|
+
--json Output as JSON (for scripting)
|
|
353
|
+
--verbose Show detailed output
|
|
354
|
+
--config <path> Custom config file path
|
|
355
|
+
--api-url <url> Override API URL
|
|
356
|
+
--project-id <id> Override active project
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
## Configuration
|
|
360
|
+
|
|
361
|
+
Config stored at `~/.bazaar/config.json`:
|
|
362
|
+
|
|
363
|
+
```json
|
|
364
|
+
{
|
|
365
|
+
"apiKey": "baz_...",
|
|
366
|
+
"apiUrl": "https://bazaar.it",
|
|
367
|
+
"activeProjectId": "abc123"
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
Environment variables override config file:
|
|
372
|
+
- `BAZ_API_KEY` — API key
|
|
373
|
+
- `BAZ_API_URL` — API URL
|
|
374
|
+
- `BAZ_PROJECT_ID` — Active project
|
|
375
|
+
- `BAZ_AGENT=1` — Agent auto-mode (default `--json`, `--compact`, `--events-only`, and `--stream-json` on prompt/loop)
|
|
376
|
+
|
|
377
|
+
## Examples
|
|
378
|
+
|
|
379
|
+
### URL to Video
|
|
380
|
+
|
|
381
|
+
```bash
|
|
382
|
+
# Turn any webpage into a video
|
|
383
|
+
baz prompt "Create a video summary of this article" \
|
|
384
|
+
--url https://example.com/blog/post
|
|
385
|
+
|
|
386
|
+
# Multiple URLs for comparison
|
|
387
|
+
baz prompt "Compare these products" \
|
|
388
|
+
--url https://example.com/product-a \
|
|
389
|
+
--url https://example.com/product-b
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### Batch Processing
|
|
393
|
+
|
|
394
|
+
```bash
|
|
395
|
+
# Generate and capture result
|
|
396
|
+
result=$(baz prompt "Create intro scene" --json)
|
|
397
|
+
scene_id=$(echo "$result" | jq -r '.scenesCreated[0]')
|
|
398
|
+
echo "Created scene: $scene_id"
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### CI/CD Integration
|
|
402
|
+
|
|
403
|
+
```bash
|
|
404
|
+
#!/bin/bash
|
|
405
|
+
set -e
|
|
406
|
+
|
|
407
|
+
export BAZ_API_KEY="$BAZAAR_API_KEY"
|
|
408
|
+
|
|
409
|
+
# Generate video from PR description
|
|
410
|
+
baz prompt "Create demo video: $PR_DESCRIPTION" --project-id "$PROJECT_ID"
|
|
411
|
+
|
|
412
|
+
# Export when ready
|
|
413
|
+
baz export --json > export-result.json
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### Complex Workflow
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
baz prompt "Create a 30 second promotional video for https://example.com \
|
|
420
|
+
including their logo, brand colors, and key messaging" --max
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
## Troubleshooting
|
|
424
|
+
|
|
425
|
+
### "Unauthorized" Error
|
|
426
|
+
|
|
427
|
+
```bash
|
|
428
|
+
baz auth status
|
|
429
|
+
baz auth login <api-key>
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
### "No active project"
|
|
433
|
+
|
|
434
|
+
```bash
|
|
435
|
+
baz project list
|
|
436
|
+
baz project use <project-id>
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### "Insufficient balance"
|
|
440
|
+
|
|
441
|
+
Check balance at https://bazaar.it/settings/billing
|
|
442
|
+
|
|
443
|
+
### Connection Issues
|
|
444
|
+
|
|
445
|
+
```bash
|
|
446
|
+
baz auth status --api-url https://bazaar.it
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
## Error Codes
|
|
450
|
+
|
|
451
|
+
| Code | Meaning |
|
|
452
|
+
|------|---------|
|
|
453
|
+
| `0` | Success |
|
|
454
|
+
| `10` | Transient error (retryable) |
|
|
455
|
+
| `11` | Resource/capacity error |
|
|
456
|
+
| `12` | Semantic/content-policy error |
|
|
457
|
+
| `13` | Authentication error |
|
|
458
|
+
| `64` | Input/not-found error |
|
|
459
|
+
| `65` | Validation error |
|
|
460
|
+
| `1` | Fatal/unclassified error |
|
|
461
|
+
|
|
462
|
+
## Development
|
|
463
|
+
|
|
464
|
+
```bash
|
|
465
|
+
npm run typecheck # Type check
|
|
466
|
+
npm run dev # Run in dev mode
|
|
467
|
+
npm run build # Build for production
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
## License
|
|
471
|
+
|
|
472
|
+
Copyright © 2024 Bazaar.it. All rights reserved.
|
|
473
|
+
### Capabilities
|
|
474
|
+
|
|
475
|
+
```bash
|
|
476
|
+
# Describe CLI capabilities (JSON for agents)
|
|
477
|
+
baz capabilities --json
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
### Loop (Basic OODA)
|
|
481
|
+
|
|
482
|
+
```bash
|
|
483
|
+
# Iterate prompt → review with optional requirements
|
|
484
|
+
baz loop "Create a 15s intro for Acme" --requirements "logo visible, CTA present"
|
|
485
|
+
|
|
486
|
+
# Use agent mode + NDJSON for bots
|
|
487
|
+
BAZ_AGENT=1 baz loop "Create a 15s intro" --requirements "logo visible, CTA present"
|
|
488
|
+
|
|
489
|
+
# Stop on failure and set a time budget
|
|
490
|
+
baz loop "Create a 15s intro" --requirements "logo visible" --stop-on-fail --budget 90s
|
|
491
|
+
```
|
package/bin/baz.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
// This is the entry point for the CLI
|
|
4
|
+
// When running in development, use: npx tsx cli/src/index.ts
|
|
5
|
+
// When built, this file runs the compiled JS
|
|
6
|
+
|
|
7
|
+
import('../dist/index.js');
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { loadConfig, saveConfig, hasAuth, getConfigPath } from '../lib/config.js';
|
|
4
|
+
import { success, error, info, output } from '../lib/output.js';
|
|
5
|
+
export const authCommand = new Command('auth')
|
|
6
|
+
.description('Manage authentication');
|
|
7
|
+
/**
|
|
8
|
+
* baz auth login
|
|
9
|
+
*/
|
|
10
|
+
authCommand
|
|
11
|
+
.command('login')
|
|
12
|
+
.description('Configure API key for authentication')
|
|
13
|
+
.argument('[api-key]', 'API key (or set BAZ_API_KEY env var)')
|
|
14
|
+
.action(async (apiKey) => {
|
|
15
|
+
// If no key provided, check environment
|
|
16
|
+
const key = apiKey || process.env.BAZ_API_KEY;
|
|
17
|
+
if (!key) {
|
|
18
|
+
console.log(chalk.cyan('Bazaar CLI Authentication'));
|
|
19
|
+
console.log();
|
|
20
|
+
console.log('To authenticate, you need an API key.');
|
|
21
|
+
console.log();
|
|
22
|
+
console.log('Options:');
|
|
23
|
+
console.log(' 1. Pass directly: baz auth login <your-api-key>');
|
|
24
|
+
console.log(' 2. Environment: export BAZ_API_KEY=<your-api-key>');
|
|
25
|
+
console.log();
|
|
26
|
+
console.log(chalk.gray('Get your API key at https://bazaar.it/api'));
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
// Validate key format
|
|
30
|
+
if (!key.startsWith('baz_sk_')) {
|
|
31
|
+
error('Invalid API key format', 'API keys should start with "baz_sk_"');
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
// Save to config first (needed for the validation request)
|
|
35
|
+
saveConfig({ apiKey: key });
|
|
36
|
+
// Validate key against server
|
|
37
|
+
const config = loadConfig();
|
|
38
|
+
try {
|
|
39
|
+
const url = `${config.apiUrl}/api/trpc/apiKey.list`;
|
|
40
|
+
const res = await fetch(url, {
|
|
41
|
+
method: 'GET',
|
|
42
|
+
headers: { 'x-api-key': key },
|
|
43
|
+
});
|
|
44
|
+
if (res.ok) {
|
|
45
|
+
success('Authenticated successfully');
|
|
46
|
+
console.log(` Key saved to ${chalk.gray(getConfigPath())}`);
|
|
47
|
+
}
|
|
48
|
+
else if (res.status === 401) {
|
|
49
|
+
saveConfig({ apiKey: undefined });
|
|
50
|
+
error('Invalid API key', 'The key was not recognized by the server. Check for typos or generate a new key.');
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// Non-auth error (500, network issue) — save key anyway, warn
|
|
55
|
+
info(`Key saved, but server returned ${res.status}. Run "baz auth status" to verify later.`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
// Network error — save key anyway, warn
|
|
60
|
+
info('Key saved, but could not reach the server to verify. Check your connection.');
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* baz auth status
|
|
65
|
+
*/
|
|
66
|
+
authCommand
|
|
67
|
+
.command('status')
|
|
68
|
+
.description('Show current authentication status')
|
|
69
|
+
.action(async (options, cmd) => {
|
|
70
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
71
|
+
const config = loadConfig({
|
|
72
|
+
configPath: globalOpts.config,
|
|
73
|
+
apiUrl: globalOpts.apiUrl,
|
|
74
|
+
});
|
|
75
|
+
const data = {
|
|
76
|
+
authenticated: hasAuth(config),
|
|
77
|
+
apiUrl: config.apiUrl,
|
|
78
|
+
activeProjectId: config.activeProjectId || null,
|
|
79
|
+
configFile: getConfigPath(),
|
|
80
|
+
};
|
|
81
|
+
if (globalOpts.json) {
|
|
82
|
+
output(data, { json: true });
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
console.log(chalk.cyan('Bazaar CLI Status'));
|
|
86
|
+
console.log();
|
|
87
|
+
if (hasAuth(config)) {
|
|
88
|
+
console.log(chalk.green('✓'), 'Authenticated');
|
|
89
|
+
console.log(` API Key: ${chalk.gray('baz_sk_****' + (config.apiKey?.slice(-4) || ''))}`);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
console.log(chalk.red('✗'), 'Not authenticated');
|
|
93
|
+
console.log(chalk.gray(' Run: baz auth login <api-key>'));
|
|
94
|
+
}
|
|
95
|
+
console.log();
|
|
96
|
+
console.log(`API URL: ${config.apiUrl}`);
|
|
97
|
+
console.log(`Active Project: ${config.activeProjectId || chalk.gray('none')}`);
|
|
98
|
+
console.log(`Config: ${getConfigPath()}`);
|
|
99
|
+
});
|
|
100
|
+
/**
|
|
101
|
+
* baz auth logout
|
|
102
|
+
*/
|
|
103
|
+
authCommand
|
|
104
|
+
.command('logout')
|
|
105
|
+
.description('Clear stored credentials')
|
|
106
|
+
.action(async () => {
|
|
107
|
+
saveConfig({ apiKey: undefined });
|
|
108
|
+
success('Logged out. API key removed from config.');
|
|
109
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { output } from '../lib/output.js';
|
|
3
|
+
import { CLI_VERSION } from '../lib/version.js';
|
|
4
|
+
const PROTOCOL_VERSION = '1.0';
|
|
5
|
+
export const capabilitiesCommand = new Command('capabilities')
|
|
6
|
+
.description('Describe CLI capabilities and protocol support')
|
|
7
|
+
.action(async (options, cmd) => {
|
|
8
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
9
|
+
const agentModeEnv = process.env.BAZ_AGENT === '1';
|
|
10
|
+
const jsonOutput = globalOpts.json || agentModeEnv;
|
|
11
|
+
const data = {
|
|
12
|
+
name: 'baz',
|
|
13
|
+
version: CLI_VERSION,
|
|
14
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
15
|
+
agentMode: agentModeEnv,
|
|
16
|
+
commands: [
|
|
17
|
+
'auth', 'project', 'prompt', 'scenes', 'export', 'media', 'logs',
|
|
18
|
+
'status', 'recipe', 'review', 'context', 'capabilities', 'loop',
|
|
19
|
+
'state', 'verify', 'mcp',
|
|
20
|
+
],
|
|
21
|
+
modes: ['agent', 'agent-max', 'multi-scene'],
|
|
22
|
+
outputs: {
|
|
23
|
+
json: true,
|
|
24
|
+
streamJson: true,
|
|
25
|
+
summary: true,
|
|
26
|
+
},
|
|
27
|
+
features: {
|
|
28
|
+
planOnly: true,
|
|
29
|
+
requirements: true,
|
|
30
|
+
reviewSummary: true,
|
|
31
|
+
stateSnapshot: true,
|
|
32
|
+
projectValidate: true,
|
|
33
|
+
verifyCriteria: true,
|
|
34
|
+
mcpManifest: true,
|
|
35
|
+
directCodeEdit: true,
|
|
36
|
+
loop: {
|
|
37
|
+
stopOnFail: true,
|
|
38
|
+
budget: true,
|
|
39
|
+
oodaEvents: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
output(data, { json: jsonOutput, compact: globalOpts.compact || agentModeEnv });
|
|
44
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Commands - Project context for agent handshake
|
|
3
|
+
*
|
|
4
|
+
* Store and retrieve flexible context for projects:
|
|
5
|
+
* - Goals, requirements, specs
|
|
6
|
+
* - Reference URLs, videos
|
|
7
|
+
* - Uploaded files (PDFs, images)
|
|
8
|
+
* - Any other context the agent needs
|
|
9
|
+
*
|
|
10
|
+
* The AI uses this context when generating content.
|
|
11
|
+
*/
|
|
12
|
+
import { Command } from 'commander';
|
|
13
|
+
export declare const contextCommand: Command;
|