@coze/cli 0.2.0 → 0.3.1

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 (42) hide show
  1. package/README.md +408 -45
  2. package/bin/postinstall.js +77 -0
  3. package/lib/cli.js +3 -3
  4. package/lib/fetch-client-CgQGE-CR.js +1 -0
  5. package/lib/index-DN7-Fdfx.js +1 -0
  6. package/lib/send-message.worker.js +1 -1
  7. package/lib/session-task-refresh.worker.js +1 -1
  8. package/lib/task-worker-Bt8hYeP2.js +1 -0
  9. package/package.json +15 -8
  10. package/skills/manifest.json +25 -0
  11. package/skills/using-coze-cli/SKILL.md +447 -0
  12. package/skills/using-coze-cli/coze-claw/MODULE.md +189 -0
  13. package/skills/using-coze-cli/coze-claw/references/coze-claw-agent-routing.md +45 -0
  14. package/skills/using-coze-cli/coze-claw/references/coze-claw-artifacts.md +52 -0
  15. package/skills/using-coze-cli/coze-claw/references/coze-claw-async-followup.md +266 -0
  16. package/skills/using-coze-cli/coze-claw/references/coze-claw-message.md +176 -0
  17. package/skills/using-coze-cli/coze-claw/references/coze-claw-podcast.md +73 -0
  18. package/skills/using-coze-cli/coze-claw/references/coze-claw-ppt.md +78 -0
  19. package/skills/using-coze-cli/coze-claw/references/coze-claw-progress.md +112 -0
  20. package/skills/using-coze-cli/coze-claw/references/coze-claw-session.md +144 -0
  21. package/skills/using-coze-cli/coze-code/MODULE.md +326 -0
  22. package/skills/using-coze-cli/coze-code/references/coze-code-db.md +544 -0
  23. package/skills/using-coze-cli/coze-code/references/coze-code-deploy.md +258 -0
  24. package/skills/using-coze-cli/coze-code/references/coze-code-domain.md +73 -0
  25. package/skills/using-coze-cli/coze-code/references/coze-code-env.md +82 -0
  26. package/skills/using-coze-cli/coze-code/references/coze-code-git.md +189 -0
  27. package/skills/using-coze-cli/coze-code/references/coze-code-message.md +240 -0
  28. package/skills/using-coze-cli/coze-code/references/coze-code-model.md +51 -0
  29. package/skills/using-coze-cli/coze-code/references/coze-code-preview.md +33 -0
  30. package/skills/using-coze-cli/coze-code/references/coze-code-project.md +222 -0
  31. package/skills/using-coze-cli/coze-code/references/coze-code-repo.md +296 -0
  32. package/skills/using-coze-cli/coze-code/references/coze-code-skill.md +121 -0
  33. package/skills/using-coze-cli/coze-code/references/coze-code-tools.md +47 -0
  34. package/skills/using-coze-cli/coze-file/MODULE.md +46 -0
  35. package/skills/using-coze-cli/coze-file/references/coze-file-upload.md +59 -0
  36. package/skills/using-coze-cli/coze-generate/MODULE.md +84 -0
  37. package/skills/using-coze-cli/coze-generate/references/coze-generate-audio.md +105 -0
  38. package/skills/using-coze-cli/coze-generate/references/coze-generate-image.md +80 -0
  39. package/skills/using-coze-cli/coze-generate/references/coze-generate-video.md +124 -0
  40. package/lib/fetch-client-CWYDGe9Z.js +0 -1
  41. package/lib/index-BC9PFu7i.js +0 -1
  42. package/lib/task-worker-CxZeBKqU.js +0 -1
package/README.md CHANGED
@@ -8,6 +8,12 @@ Coze CLI — A command-line tool for interacting with [Coze](https://www.coze.cn
8
8
  npm install -g @coze/cli
9
9
  ```
10
10
 
11
+ After installation the CLI silently runs `coze self skill install`, which installs the bundled skills to your local AI agents (Claude Code, Trae, Comate, ...). If that step is skipped or fails, run it manually:
12
+
13
+ ```bash
14
+ coze self skill install
15
+ ```
16
+
11
17
  ## Quick Start
12
18
 
13
19
  ```bash
@@ -31,7 +37,7 @@ coze code project create --message "Build an intelligent assistant" --type web
31
37
  Before using most commands, you need to authenticate with Coze.
32
38
 
33
39
  ```bash
34
- # Interactive login via browser (recommended)
40
+ # Interactive login via browser
35
41
  coze auth login
36
42
 
37
43
  # Check current login status
@@ -52,7 +58,7 @@ Manage the full authentication lifecycle. Supports interactive OAuth login via b
52
58
 
53
59
  | Command | Description |
54
60
  | ------------------ | -------------------------------------------------- |
55
- | `coze auth login` | Interactive login via browser |
61
+ | `coze auth login` | Interactive login via browser (OAuth) |
56
62
  | `coze auth status` | Check current login status and credential validity |
57
63
  | `coze auth logout` | Logout and clear stored credentials |
58
64
 
@@ -65,6 +71,7 @@ View and switch organizations to set the default Organization ID for subsequent
65
71
  | `coze organization list` | List all accessible organizations and their enterprises |
66
72
  | `coze organization use <org_id>` | Set the default organization (auto-saves Enterprise ID) |
67
73
  | `coze organization use` | Switch to personal account (clears Organization and Enterprise) |
74
+ | `coze organization unset` | Clear the organization context (same as `use` with no org_id). `reset` is an alias for `unset`, and `org` is an alias for `organization`, so `coze org unset` / `coze org reset` also work |
68
75
 
69
76
  Alias: `coze org`
70
77
 
@@ -91,6 +98,8 @@ Manage Coze Coding projects. Supports creating, viewing, listing, and deleting p
91
98
  | `coze code project list` | List all projects in the current space |
92
99
  | `coze code project get <projectId>` | Get project details |
93
100
  | `coze code project delete <projectId>` | Delete a project (irreversible) |
101
+ | `coze code project import` | Import a project from GitHub repo or local zip file |
102
+ | `coze code project db list -p <projectId>` | List the project's database tables |
94
103
 
95
104
  Alias: `coze code proj`
96
105
 
@@ -109,13 +118,17 @@ coze code project list --size 20 --has-published
109
118
 
110
119
  **`project create`** **options:**
111
120
 
112
- | Option | Description |
113
- | ---------------------- | ------------------------------------------------------ |
114
- | `--message <message>` | **(required)** Project description in natural language |
115
- | `--type <type>` | **(required)** Project type: `web` \| `app` |
116
- | `--wait` | Wait for project creation to complete |
117
- | `--org-id <orgId>` | Organization ID (reads from context if omitted) |
118
- | `--space-id <spaceId>` | Space ID (reads from context if omitted) |
121
+ | Option | Description |
122
+ | ------------------------ | ----------------------------------------------------------------------------------------------------- |
123
+ | `--message <message>` | **(required)** Project description/requirements in natural language |
124
+ | `--type <type>` | **(required)** Project type: `agent` \| `workflow` \| `app` \| `skill` \| `web` \| `miniprogram` \| `assistant` |
125
+ | `--wait` | Wait for project creation to complete (also waits for the first AI message response) |
126
+ | `--chat-mode <chatMode>` | Chat mode: `ask` \| `agent` \| `dangerous_confirm` \| `plan` |
127
+ | `--model-name <name>` | Model name for the project |
128
+ | `--tool-name <toolName>` | Tool name to enable (can be passed multiple times) |
129
+ | `--design` | Enable design wizard (auto-enabled when `--chat-mode` is `plan`) |
130
+ | `--org-id <orgId>` | Organization ID (reads from context if omitted) |
131
+ | `--space-id <spaceId>` | Space ID (reads from context if omitted) |
119
132
 
120
133
  **`project list`** **options:**
121
134
 
@@ -126,11 +139,25 @@ coze code project list --size 20 --has-published
126
139
  | `--type <type>` | Filter by type (can pass multiple times): `agent` \| `workflow` \| `webapp` \| `app` \| `web` \| `miniprogram` \| `assistant` |
127
140
  | `--name <name>` | Filter by project name |
128
141
  | `--has-published` | Filter by publish status |
129
- | `--search-scope <n>` | Created by (0=All, 1=CreatedByMe, 2=AllWithCollaborator) |
142
+ | `--search-scope <n>` | Created by (0=All, 1=CreateByMe, 2=AllWithCollaborator) |
130
143
  | `--folder-id <id>` | Filter by folder |
131
144
  | `--order-type <n>` | Sort type (0=descending, 1=ascending) |
132
145
  | `--order-by <n>` | Order by (0=updated\_at, 1=created\_at) |
133
- | `--is-fav-filter` | Filter favorites only |
146
+ | `--is-fav-filter` | Filter favorites only |
147
+
148
+ **`project import`** **options:**
149
+
150
+ | Option | Description |
151
+ | ----------------------- | ------------------------------------------------------------------- |
152
+ | `-s, --source <source>` | **(required)** Import source: `github` \| `local` |
153
+ | `-r, --repo <fullName>` | Remote repo full name, e.g. `user/repo` (required when source is `github`) |
154
+ | `-f, --file <path>` | Local zip file path, max 500MB (required when source is `local`) |
155
+
156
+ > Remote import requires prior OAuth authorization via `coze code git auth login`, and imported projects are automatically bound to the source repo.
157
+
158
+ **Output:** in JSON mode, prints `{ project_id, source, repo?, project_url }` (`repo` is only present for GitHub imports).
159
+
160
+ > After a successful import, the CLI automatically sends an initialization query to the project's default conversation in the background (same behavior as the Web client). Use `coze code message status -p <projectId>` to check its progress. If sending fails, the import result is not affected — the CLI prints a hint to send it manually.
134
161
 
135
162
  #### Message
136
163
 
@@ -141,19 +168,23 @@ Send and manage chat messages in Coze Coding projects. The project ID is specifi
141
168
  | `coze code message send [message]` | Send a prompt message to a project chat |
142
169
  | `coze code message status` | Query message status and get result when completed |
143
170
  | `coze code message cancel` | Cancel an ongoing message |
171
+ | `coze code message history` | View the conversation history of a project chat |
144
172
 
145
173
  ```bash
146
174
  # Send a message to a project
147
175
  coze code message send "Fix the login bug" -p 123456
148
176
 
177
+ # Wait for the chat response before returning
178
+ coze code message send "Fix the login bug" -p 123456 --wait
179
+
149
180
  # Mention local files with @ syntax for upload as context
150
181
  coze code message send "Refactor @src/utils.ts to use async/await" -p 123456
151
182
 
152
183
  # Mention multiple files
153
184
  coze code message send "Compare @src/old.ts and @src/new.ts" -p 123456
154
185
 
155
- # Pipe context via stdin
156
- cat error.log | coze code message send "Analyze this error" -p 123456
186
+ # Pipe additional context via stdin (the --stdin flag is required)
187
+ cat error.log | coze code message send "Analyze this error" --stdin -p 123456
157
188
 
158
189
  # Check message status (auto-fetches result when completed)
159
190
  coze code message status -p 123456
@@ -161,6 +192,9 @@ coze code message status -p 123456
161
192
  # Cancel an ongoing message
162
193
  coze code message cancel -p 123456
163
194
 
195
+ # View conversation history (paginate with --before / --after)
196
+ coze code message history -p 123456
197
+
164
198
  # Use environment variable for project ID
165
199
  export COZE_PROJECT_ID=123456
166
200
  coze code message send "Hello"
@@ -172,16 +206,31 @@ coze code message send "Hello"
172
206
  | ----------------------- | ------------------------------------------ |
173
207
  | `-p, --project-id <id>` | Coze project ID (or env `COZE_PROJECT_ID`) |
174
208
 
209
+ **`message send`** **options:**
210
+
211
+ | Option | Description |
212
+ | ---------- | ----------------------------------------------------------------- |
213
+ | `--wait` | Wait for the chat response before returning (otherwise sent in background) |
214
+ | `--stdin` | Read additional context from stdin (pipe input) |
215
+
216
+ **`message history`** **options:**
217
+
218
+ | Option | Description |
219
+ | ------------------- | ------------------------------------------------- |
220
+ | `--after <msg_id>` | Cursor for fetching newer messages |
221
+ | `--before <msg_id>` | Cursor for fetching older messages |
222
+
175
223
  #### Deploy
176
224
 
177
225
  Deploy projects to the production environment. Supports multiple project types including Agent, Workflow, Skill, Web, Mini-program, etc.
178
226
 
179
- | Command | Description |
180
- | -------------------------------------------- | ----------------------------------------- |
181
- | `coze code deploy <projectId>` | Deploy a project to production |
182
- | `coze code deploy <projectId> --wait` | Deploy and wait for completion |
183
- | `coze code deploy status <projectId>` | Check deployment status |
184
- | `coze code deploy status <projectId> --wait` | Check and wait for deployment to complete |
227
+ | Command | Description |
228
+ | -------------------------------------------- | ------------------------------------------------------ |
229
+ | `coze code deploy <projectId>` | Deploy a project to production |
230
+ | `coze code deploy <projectId> --wait` | Deploy and wait for completion |
231
+ | `coze code deploy status <projectId>` | Check deployment status |
232
+ | `coze code deploy list <projectId>` | List deployment history for a project |
233
+ | `coze code deploy fix <projectId>` | Fix a failed deployment by sending deploy logs to AI |
185
234
 
186
235
  ```bash
187
236
  # Deploy a project
@@ -190,16 +239,54 @@ coze code deploy <projectId>
190
239
  # Deploy and wait for completion
191
240
  coze code deploy <projectId> --wait
192
241
 
242
+ # Deploy a specific commit and sync database tables to production
243
+ coze code deploy <projectId> --commit-id <commitId> --table-name users --table-name orders
244
+
193
245
  # Check latest deployment status
194
246
  coze code deploy status <projectId>
195
247
 
196
248
  # Check a specific deployment record
197
249
  coze code deploy status <projectId> --deploy-id <deployHistoryId>
198
250
 
199
- # Check and wait for deployment to complete
200
- coze code deploy status <projectId> --wait
251
+ # List deployment history
252
+ coze code deploy list <projectId> --page-size 10
253
+
254
+ # Fix the latest failed deployment with AI
255
+ coze code deploy fix <projectId> --wait
201
256
  ```
202
257
 
258
+ **`deploy <projectId>`** **options:**
259
+
260
+ | Option | Description |
261
+ | ------------------------------- | ------------------------------------------------------------------------------------------------ |
262
+ | `--commit-id <commitId>` | Commit ID (queries the latest commit if omitted) |
263
+ | `--wait` | Wait for the deployment to complete (polling interval: 3 seconds) |
264
+ | `--table-name <tableName...>` | Database table name(s) to sync to production (variadic / repeatable) |
265
+ | `--encrypt-deploy <string>` | Pre-encrypted environment variable string (for Skill projects) |
266
+ | `--connector-id <connectorId>` | Connector ID for mini-program deployment channels, repeatable (e.g. `10000127` WeChat, `10000126` TikTok) |
267
+
268
+ **`deploy status <projectId>`** **options:**
269
+
270
+ | Option | Description |
271
+ | ----------------------- | ------------------------------------------------------- |
272
+ | `--deploy-id <deployId>` | Deployment history ID (queries the latest if omitted) |
273
+
274
+ > `deploy status` reuses the parent `deploy --wait` flag to poll until the deployment reaches a terminal state.
275
+
276
+ **`deploy list <projectId>`** **options:**
277
+
278
+ | Option | Description |
279
+ | --------------------------- | -------------------------------------- |
280
+ | `--page-size <pageSize>` | Number of records per page (default: 10) |
281
+ | `--page-token <pageToken>` | Page token for pagination |
282
+
283
+ **`deploy fix <projectId>`** **options:**
284
+
285
+ | Option | Description |
286
+ | ------------------------ | ----------------------------------------------------------- |
287
+ | `--deploy-id <deployId>` | Deployment history ID (queries the latest failed if omitted) |
288
+ | `--wait` | Wait for the fix message response |
289
+
203
290
  #### Environment Variables
204
291
 
205
292
  Manage project environment variables (Secrets). Supports development and production environments.
@@ -220,29 +307,47 @@ coze code env list -p <projectId> --env prod
220
307
  # Set an environment variable
221
308
  coze code env set API_KEY sk-xxxxx -p <projectId>
222
309
 
223
- # Delete an environment variable
310
+ # Delete an environment variable (operates on the dev environment)
224
311
  coze code env delete API_KEY -p <projectId>
225
312
  ```
226
313
 
314
+ > `env list` filters by `--env dev|prod` (default `dev`). `env delete` always targets the dev environment. `env set` is not yet supported for Skill projects.
315
+
227
316
  #### Domain
228
317
 
229
318
  Manage custom domains for deployed projects.
230
319
 
231
320
  | Command | Description |
232
321
  | ------------------------------------------------- | -------------------------------------------- |
233
- | `coze code domain list <projectId>` | List all custom domains bound to the project |
322
+ | `coze code domain list -p <projectId>` | List all custom domains bound to the project |
234
323
  | `coze code domain add <domain> -p <projectId>` | Add a custom domain |
235
324
  | `coze code domain remove <domain> -p <projectId>` | Remove a custom domain |
236
325
 
326
+ > `domain add` validates the format and accepts a single-level domain such as `example.com`.
327
+
237
328
  #### Skill
238
329
 
239
330
  Manage skills associated with a project to extend its capabilities.
240
331
 
241
- | Command | Description |
242
- | ------------------------------------------------- | ---------------------------------------- |
243
- | `coze code skill list -p <projectId>` | List all skills (shows installed status) |
244
- | `coze code skill add <skillId> -p <projectId>` | Add a skill to the project |
245
- | `coze code skill remove <skillId> -p <projectId>` | Remove a skill from the project |
332
+ | Command | Description |
333
+ | -------------------------------------------------- | ---------------------------------------------------------------- |
334
+ | `coze code skill list -p <projectId>` | List available skills (shows installed status) |
335
+ | `coze code skill add <skillId> -p <projectId>` | Add (mount) a skill to the project's default conversation |
336
+ | `coze code skill remove <skillId> -p <projectId>` | Remove (unmount) a skill from the default conversation |
337
+ | `coze code skill upload <filePath> -p <projectId>` | Upload a local `.skill` file as a personal skill |
338
+ | `coze code skill delete <skillId> -p <projectId>` | Permanently delete a personal skill (different from `remove`) |
339
+
340
+ > `add`/`remove` only mount or unmount a skill on the project's default conversation. `delete` permanently removes the personal skill itself. On naming conflict, `upload` auto-confirms an overwrite.
341
+
342
+ **`skill list`** **options:**
343
+
344
+ | Option | Description |
345
+ | ---------------------- | -------------------------------------------------- |
346
+ | `-p, --project-id <id>` | **(required)** Project ID |
347
+ | `--space-id <spaceId>` | Space ID (reads from config if omitted) |
348
+ | `--my` | List personal skills only |
349
+ | `--page <page>` | Page number (for personal skills, default: 1) |
350
+ | `--size <size>` | Page size (for personal skills, default: 20) |
246
351
 
247
352
  #### Preview
248
353
 
@@ -257,6 +362,259 @@ Get the sandbox preview URL for a project.
257
362
  coze code preview <projectId>
258
363
  ```
259
364
 
365
+ > Preview is available for Web/App project types. Agent, Automation, Skill, Mini-program, and Assistant projects are not previewable from the CLI — use the Web dashboard instead.
366
+
367
+ #### Git
368
+
369
+ Manage Git platform integrations including OAuth authorization and repository search. Use `--provider` to specify the Git service provider (default: github).
370
+
371
+ | Command | Description |
372
+ | -------------------------------- | ---------------------------------------------------- |
373
+ | `coze code git auth login` | Authorize a Git platform via OAuth (opens browser) |
374
+ | `coze code git auth status` | Check the current OAuth authorization status |
375
+ | `coze code git auth logout` | Revoke OAuth authorization for a Git platform |
376
+ | `coze code git search` | Search repositories on the authorized Git platform |
377
+
378
+ ```bash
379
+ # Authorize GitHub (default provider)
380
+ coze code git auth login
381
+
382
+ # Check authorization status
383
+ coze code git auth status
384
+
385
+ # Check authorization status in a pipeline
386
+ coze code git auth status --format json | jq .status
387
+
388
+ # Search repos by keyword
389
+ coze code git search --keyword react
390
+
391
+ # Paginated search
392
+ coze code git search -k react --page 2 --page-size 10
393
+
394
+ # Revoke authorization (interactive confirmation; use --force to skip)
395
+ coze code git auth logout
396
+ coze code git auth logout --force
397
+ ```
398
+
399
+ **`git`** **options (shared by subcommands):**
400
+
401
+ | Option | Description |
402
+ | ----------------------- | ----------------------------------------------------- |
403
+ | `--provider <provider>` | Git service provider: `github` / `gitlab` (default: `github`) |
404
+
405
+ > `git auth logout` prompts for confirmation in an interactive terminal. In JSON mode or non-interactive terminals, `--force` is required — otherwise the command fails with `E1000`.
406
+
407
+ #### Repo
408
+
409
+ Manage remote repository bindings and sync operations for Coze Coding projects.
410
+
411
+ | Command | Description |
412
+ | --------------------------------------------------- | ------------------------------------------------------- |
413
+ | `coze code repo create --name <name>` | Create a new repository on the remote Git platform |
414
+ | `coze code repo bind -p <projectId> -r <fullName>` | Bind a remote repository to a project |
415
+ | `coze code repo unbind -p <projectId>` | Unbind the remote repository from a project |
416
+ | `coze code repo push -p <projectId>` | Push local commits to the bound remote repository |
417
+ | `coze code repo pull -p <projectId>` | Pull remote changes from the bound repository |
418
+ | `coze code repo status -p <projectId>` | Show remote repository binding and sync status |
419
+
420
+ ```bash
421
+ # Create a private repository
422
+ coze code repo create --name my-app --private
423
+
424
+ # Bind a repo to a project
425
+ coze code repo bind -p <projectId> -r user/my-repo
426
+
427
+ # Check binding and sync status
428
+ coze code repo status -p <projectId>
429
+
430
+ # Push local changes to remote
431
+ coze code repo push -p <projectId>
432
+
433
+ # Pull remote changes (auto-resolve conflicts keeping local)
434
+ coze code repo pull -p <projectId> --conflict-strategy ours
435
+
436
+ # Unbind repository
437
+ coze code repo unbind -p <projectId> --force
438
+ ```
439
+
440
+ **`repo`** **options (shared by subcommands):**
441
+
442
+ | Option | Description |
443
+ | ----------------------- | ----------------------------------------------------- |
444
+ | `--provider <provider>` | Git service provider: `github` / `gitlab` (default: `github`) |
445
+
446
+ **`repo create`** **options:**
447
+
448
+ | Option | Description |
449
+ | ------------------- | --------------------------------------- |
450
+ | `-n, --name <name>` | **(required)** Repository name |
451
+ | `--private` | Create as private repository |
452
+
453
+ **`repo bind`** **options:**
454
+
455
+ | Option | Description |
456
+ | -------------------------------- | ------------------------------------------- |
457
+ | `-p, --project-id <projectId>` | **(required)** Project ID |
458
+ | `-r, --repo <fullName>` | **(required)** Remote repo (e.g. user/repo) |
459
+
460
+ **`repo pull`** **options:**
461
+
462
+ | Option | Description |
463
+ | ------------------------------------- | ------------------------------------------------------- |
464
+ | `-p, --project-id <projectId>` | **(required)** Project ID |
465
+ | `--conflict-strategy <strategy>` | Auto conflict resolution: `ours` / `theirs` |
466
+
467
+ **`repo push`** **options:**
468
+
469
+ | Option | Description |
470
+ | ------------------------------ | ------------------------- |
471
+ | `-p, --project-id <projectId>` | **(required)** Project ID |
472
+
473
+ **`repo status`** **options:**
474
+
475
+ | Option | Description |
476
+ | ------------------------------ | ------------------------- |
477
+ | `-p, --project-id <projectId>` | **(required)** Project ID |
478
+
479
+ **`repo unbind`** **options:**
480
+
481
+ | Option | Description |
482
+ | ------------------------------ | ------------------------------------ |
483
+ | `-p, --project-id <projectId>` | **(required)** Project ID |
484
+ | `--force` | Skip confirmation and unbind directly |
485
+
486
+ > Without `--force`, `repo unbind` prompts for confirmation in an interactive terminal. In JSON mode or non-interactive terminals, `--force` is required — otherwise the command fails with `E1000`.
487
+
488
+ > `repo push` and `repo pull` are placeholder implementations pending backend wiring — they currently report success without performing a real sync.
489
+
490
+ #### Database
491
+
492
+ Manage Supabase-backed databases in the current Coze space. Supports the full database lifecycle, SQL execution, TypeScript type generation, schema/data export, and point-in-time rollback. All `db` subcommands accept `--space-id <spaceId>` (reads from context if omitted).
493
+
494
+ | Command | Description |
495
+ | --------------------------------------------------- | ----------------------------------------------------- |
496
+ | `coze code db create` | Create a new database (name and credentials auto-generated) |
497
+ | `coze code db list` | List databases in the current space |
498
+ | `coze code db get --db-id <id>` | Get database details (connection URLs and credentials) |
499
+ | `coze code db query --db-id <id> --sql "<sql>"` | Execute SQL on a database |
500
+ | `coze code db gen-types --db-id <id>` | Generate TypeScript types from the database schema |
501
+ | `coze code db dump --db-id <id>` | Export database schema (DDL) or data as SQL |
502
+ | `coze code db rollback --db-id <id> --timestamp <ts> --confirm` | Roll back a database to a point in time (PITR) |
503
+ | `coze code db status --db-id <id>` | Get database status and restore/rollback info |
504
+ | `coze code db delete --db-id <id> --confirm` | Delete a database (irreversible) |
505
+
506
+ ```bash
507
+ # Create a database
508
+ coze code db create
509
+
510
+ # List databases (text mode auto-paginates; use --all in JSON mode)
511
+ coze code db list --all
512
+
513
+ # Execute SQL (read from --sql, --file, or stdin)
514
+ coze code db query --db-id <id> --sql "SELECT * FROM users LIMIT 10"
515
+
516
+ # Dangerous SQL (DROP/TRUNCATE/ALTER TABLE/DELETE or UPDATE without WHERE) requires --confirm
517
+ coze code db query --db-id <id> --sql "DROP TABLE old_data" --confirm
518
+
519
+ # Generate TS types (default output: types/database.ts)
520
+ coze code db gen-types --db-id <id> --include-schema public --include-schema auth
521
+
522
+ # Export schema only (default) or data only
523
+ coze code db dump --db-id <id> --output db/schema.sql
524
+ coze code db dump --db-id <id> --data-only
525
+
526
+ # Roll back to a timestamp (milliseconds), --confirm required
527
+ coze code db rollback --db-id <id> --timestamp 1713254400000 --confirm
528
+ ```
529
+
530
+ **`db query`** **options:**
531
+
532
+ | Option | Description |
533
+ | ------------------ | ---------------------------------------------------------------- |
534
+ | `--db-id <dbId>` | **(required)** Database ID |
535
+ | `--sql <sql>` | Inline SQL to execute |
536
+ | `--file <path>` | Read SQL from a file |
537
+ | `--confirm` | Confirm execution of dangerous SQL (required in JSON mode) |
538
+
539
+ > SQL is read from `--sql`, then `--file`, then stdin. Dangerous operations (`DROP`, `TRUNCATE`, `ALTER TABLE`, `DELETE`/`UPDATE` without `WHERE`) require `--confirm`; in JSON mode they error out without it, while text mode prompts interactively.
540
+
541
+ **`db list`** **options:**
542
+
543
+ | Option | Description |
544
+ | ------------------------ | --------------------------------------------------- |
545
+ | `--limit <limit>` | Number of databases per page, 1–100 (default: 20) |
546
+ | `--cursor <cursorId>` | Cursor for pagination |
547
+ | `--all` | Fetch all databases across pages |
548
+ | `--max-pages <maxPages>` | Max pages to fetch in text mode (default: 10) |
549
+
550
+ > In JSON mode, the output is a `{ databases, next_cursor_id }` object (without `--all` it contains a single page; with `--all` it aggregates all pages). In text mode, the output is an auto-paginated array of databases.
551
+
552
+ **`db gen-types`** **options:**
553
+
554
+ | Option | Description |
555
+ | ------------------------ | --------------------------------------------------------- |
556
+ | `--db-id <dbId>` | **(required)** Database ID |
557
+ | `--output <path>` | Output file path (default: `types/database.ts`) |
558
+ | `--include-schema <name>` | Schema name, repeatable (default: `public`) |
559
+
560
+ **`db dump`** **options:**
561
+
562
+ | Option | Description |
563
+ | ------------------------ | -------------------------------------------------------- |
564
+ | `--db-id <dbId>` | **(required)** Database ID |
565
+ | `--output <path>` | Output file path (default: `db/schema.sql`) |
566
+ | `--schema-only` | Export schema only (the default when neither flag is set) |
567
+ | `--data-only` | Export data only |
568
+ | `--include-schema <name>` | Schema name, repeatable (default: `public`) |
569
+
570
+ **`db rollback`** / **`db delete`** **options:**
571
+
572
+ | Option | Description |
573
+ | ----------------------- | ------------------------------------------------ |
574
+ | `--db-id <dbId>` | **(required)** Database ID |
575
+ | `--timestamp <ts>` | **(required, rollback only)** Target timestamp in milliseconds |
576
+ | `--confirm` | **(required)** Confirm the destructive operation |
577
+
578
+ #### Model
579
+
580
+ Manage the model used by a Coze Coding project's default conversation.
581
+
582
+ | Command | Description |
583
+ | --------------------------------------------------- | ----------------------------------------------- |
584
+ | `coze code model list -p <projectId>` | List available models (marks the active one) |
585
+ | `coze code model list --type <type>` | List available models for a project type |
586
+ | `coze code model set <modelName> -p <projectId>` | Set the model for the default conversation |
587
+
588
+ ```bash
589
+ # List available models for a project
590
+ coze code model list -p <projectId>
591
+
592
+ # List models by project type (when no project ID is available)
593
+ coze code model list --type web
594
+
595
+ # Set the conversation model
596
+ coze code model set doubao-dev-0213 -p <projectId>
597
+ ```
598
+
599
+ #### Tools
600
+
601
+ Manage the tools enabled on a project's default conversation (e.g. web search, image generation).
602
+
603
+ | Command | Description |
604
+ | ------------------------------------------------------ | ---------------------------------------------- |
605
+ | `coze code tools list -p <projectId>` | List available tools (shows enabled status) |
606
+ | `coze code tools enable <toolName> -p <projectId>` | Enable a tool on the default conversation |
607
+ | `coze code tools disable <toolName> -p <projectId>` | Disable a tool on the default conversation |
608
+
609
+ ```bash
610
+ # List available tools
611
+ coze code tools list -p <projectId>
612
+
613
+ # Enable / disable a tool
614
+ coze code tools enable enable_image_gen -p <projectId>
615
+ coze code tools disable enable_image_gen -p <projectId>
616
+ ```
617
+
260
618
  ### `coze generate` — Media Generation
261
619
 
262
620
  Generate images, audio, and video using Coze AI models. All `generate` subcommands support `--output-path <path>` to save generated media to disk.
@@ -294,6 +652,7 @@ coze generate image "A storyboard" --sequential auto --max-images 5
294
652
  | `--optimize-prompt-mode <mode>` | `standard` | Prompt optimization mode |
295
653
  | `--sequential <mode>` | `disabled` | Group image generation: `auto` \| `disabled` |
296
654
  | `--max-images <n>` | `15` | Maximum group images (1–15) |
655
+ | `--stdin` | `false` | Read prompt from stdin (pipe input) |
297
656
  | `--output-path <path>` | — | Directory to save generated images |
298
657
 
299
658
  #### Audio Generation (TTS)
@@ -322,6 +681,7 @@ coze generate audio "Hello" --speaker zh_female_xiaohe_uranus_bigtts --audio-for
322
681
  | `--speech-rate <n>` | `0` | Speech rate (-50 to 100) |
323
682
  | `--loudness-rate <n>` | `0` | Loudness (-50 to 100) |
324
683
  | `--ssml` | `false` | Treat input as SSML instead of plain text |
684
+ | `--stdin` | `false` | Read prompt from stdin (pipe input) |
325
685
  | `--uid <uid>` | `cli_user` | User UID |
326
686
  | `--output-path <path>` | — | Directory to save generated audio |
327
687
 
@@ -365,14 +725,15 @@ Use `coze generate video create` to submit generation tasks, and `coze generate
365
725
  | `--first-frame <url>` | — | First frame image URL |
366
726
  | `--last-frame <url>` | — | Last frame image URL |
367
727
  | `--return-last-frame` | `false` | Return last frame URL in output |
728
+ | `--stdin` | `false` | Read prompt from stdin (pipe input) |
368
729
  | `--wait` | `false` | Poll until completion instead of returning `taskId` immediately |
369
730
  | `--output-path <path>` | — | Directory to save generated video |
370
731
 
371
- **`generate video status`** **options:**
732
+ **`generate video status`** has no command-specific options. Use the global `--format json` flag to output the full response as JSON:
372
733
 
373
- | Option | Default | Description |
374
- | ------------------- | ------- | ------------------------------- |
375
- | `--output <format>` | `text` | Output format: `text` \| `json` |
734
+ ```bash
735
+ coze generate video status task_123 --format json
736
+ ```
376
737
 
377
738
  ### `coze file` — File Operations
378
739
 
@@ -448,6 +809,13 @@ coze upgrade --tag beta
448
809
  | `--force` | Force upgrade even if already on the latest version |
449
810
  | `--tag <tag>` | Specify the dist-tag to upgrade to (default: `latest`) |
450
811
 
812
+ ### Other Commands
813
+
814
+ | Command | Description |
815
+ | ------------ | ----------------------------------------------------------------- |
816
+ | `coze self` | Manage the Coze CLI itself (e.g. `coze self skill` installs CLI-bundled skills to your AI tools and keeps versions aligned) |
817
+ | `coze agent` | Agent-facing Coze APIs backed by Claw project endpoints |
818
+
451
819
  ## Global Options
452
820
 
453
821
  | Option | Description |
@@ -491,19 +859,14 @@ The CLI reads configuration from multiple sources with the following priority (h
491
859
 
492
860
  ## Exit Codes
493
861
 
494
- | Code | Name | Description |
495
- | ---- | -------------------- | ------------------------------ |
496
- | `0` | `SUCCESS` | Command completed successfully |
497
- | `1` | `GENERAL_ERROR` | General error |
498
- | `2` | `AUTH_FAILED` | Authentication failed |
499
- | `3` | `RESOURCE_NOT_FOUND` | Requested resource not found |
500
- | `4` | `INVALID_ARGUMENT` | Invalid argument or option |
501
- | `5` | `PERMISSION_DENIED` | Permission denied |
502
- | `6` | `NETWORK_ERROR` | Network error |
503
- | `7` | `SERVER_ERROR` | Server error |
504
- | `8` | `TIMEOUT` | Operation timed out |
505
- | `9` | `QUOTA_EXCEEDED` | Quota exceeded |
506
- | `10` | `CONFLICT` | Resource conflict |
862
+ | Code | Name | Description |
863
+ | ---- | ------------- | ----------------------------------------------------------- |
864
+ | `0` | `SUCCESS` | Command completed successfully |
865
+ | `1` | `FAILURE` | General failure (resource, quota, network, or server error) |
866
+ | `2` | `AUTH_ERROR` | Authentication error (`E2xxx` error codes) |
867
+ | `4` | `INPUT_ERROR` | Invalid argument or input (`E1xxx` error codes) |
868
+
869
+ > Business-level error codes — `E3xxx` (resource), `E4xxx` (quota), and `E5xxx` (network/server) — all exit with code `1`. Check the error `code` field in the JSON output (`--format json`) for the specific error code.
507
870
 
508
871
  ## License
509
872