@coze/cli 0.0.3 → 0.1.0-alpha.09fbab
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/LICENSE.md +1 -1
- package/README.md +479 -16
- package/THIRD-PARTY-LICENSES.md +31 -0
- package/bin/main +21 -0
- package/lib/cli.js +41642 -0
- package/lib/index-SwtgDxQR.js +25171 -0
- package/lib/send-message.worker.js +52 -0
- package/package.json +55 -46
- package/bin.mjs +0 -2
- package/dist/cli.d.ts +0 -1
- package/dist/cli.mjs +0 -1
- package/dist/commands/base.d.ts +0 -15
- package/dist/commands/login.d.ts +0 -6
- package/dist/commands/logout.d.ts +0 -8
- package/dist/helpers/constants.d.ts +0 -10
- package/dist/helpers/logger.d.ts +0 -7
- package/dist/helpers/package.d.ts +0 -8
- package/dist/helpers/request.d.ts +0 -3
- package/dist/helpers/types.d.ts +0 -16
- package/dist/index.d.ts +0 -1
- package/dist/index.mjs +0 -1
- package/dist/npm.d.ts +0 -28
- package/dist/oauth.d.ts +0 -9
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,40 +1,503 @@
|
|
|
1
|
-
# coze-cli
|
|
1
|
+
# @coze/coding-cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Coze Coding CLI — A command-line tool for interacting with [Coze](https://www.coze.cn) services. Manage organizations, workspaces, projects, deployments, and generate media — all from your terminal.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @coze/coding-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# 1. Login to your Coze account
|
|
15
|
+
coze auth login --oauth
|
|
16
|
+
|
|
17
|
+
# 2. Select your organization
|
|
18
|
+
coze organization list
|
|
19
|
+
coze organization use <org_id>
|
|
20
|
+
|
|
21
|
+
# 3. Select your workspace
|
|
22
|
+
coze space list
|
|
23
|
+
coze space use <space_id>
|
|
24
|
+
|
|
25
|
+
# 4. Start using Coze Coding
|
|
26
|
+
coze code project create -m "Build an intelligent assistant" --type web
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Authentication
|
|
30
|
+
|
|
31
|
+
Before using most commands, you need to authenticate with Coze.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Interactive login via browser (recommended)
|
|
35
|
+
coze auth login --oauth
|
|
36
|
+
|
|
37
|
+
# Non-interactive login with Personal Access Token (for CI/CD)
|
|
38
|
+
coze auth login --token <YOUR_PAT>
|
|
39
|
+
|
|
40
|
+
# Check current login status
|
|
41
|
+
coze auth status
|
|
42
|
+
|
|
43
|
+
# Check status in JSON format
|
|
44
|
+
coze auth status --format json
|
|
45
|
+
|
|
46
|
+
# Logout and clear credentials
|
|
47
|
+
coze auth logout
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
You can also authenticate via environment variables for CI/CD pipelines:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
export COZE_API_TOKEN=<YOUR_PAT>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Commands
|
|
57
|
+
|
|
58
|
+
### `coze auth` — Authentication
|
|
59
|
+
|
|
60
|
+
Manage the full authentication lifecycle. Supports interactive OAuth login via browser and non-interactive login via Personal Access Token (PAT) for CI/CD pipelines.
|
|
61
|
+
|
|
62
|
+
| Command | Description |
|
|
63
|
+
|---|---|
|
|
64
|
+
| `coze auth login --oauth` | Interactive login via browser |
|
|
65
|
+
| `coze auth login --token <PAT>` | Login with a Personal Access Token |
|
|
66
|
+
| `coze auth status` | Check current login status and credential validity |
|
|
67
|
+
| `coze auth logout` | Logout and clear stored credentials |
|
|
68
|
+
|
|
69
|
+
### `coze organization` — Organization Management
|
|
70
|
+
|
|
71
|
+
View and switch organizations to set the default Organization ID for subsequent commands.
|
|
72
|
+
|
|
73
|
+
| Command | Description |
|
|
74
|
+
|---|---|
|
|
75
|
+
| `coze organization list` | List all accessible organizations and their enterprises |
|
|
76
|
+
| `coze organization use <org_id>` | Set the default organization (auto-saves Enterprise ID) |
|
|
77
|
+
|
|
78
|
+
Alias: `coze org`
|
|
79
|
+
|
|
80
|
+
### `coze space` — Workspace Management
|
|
81
|
+
|
|
82
|
+
View and switch workspaces to set the default Space ID for subsequent commands.
|
|
83
|
+
|
|
84
|
+
| Command | Description |
|
|
85
|
+
|---|---|
|
|
86
|
+
| `coze space list` | List all spaces under the current organization |
|
|
87
|
+
| `coze space use <space_id>` | Set the default workspace |
|
|
88
|
+
|
|
89
|
+
### `coze code` — Coze Coding
|
|
90
|
+
|
|
91
|
+
#### Project
|
|
92
|
+
|
|
93
|
+
Manage Coze Coding projects. Supports creating, viewing, listing, and deleting projects across various types.
|
|
94
|
+
|
|
95
|
+
| Command | Description |
|
|
96
|
+
|---|---|
|
|
97
|
+
| `coze code project create` | Create a new project from natural language description |
|
|
98
|
+
| `coze code project list` | List all projects in the current space |
|
|
99
|
+
| `coze code project get <projectId>` | Get project details |
|
|
100
|
+
| `coze code project delete <projectId>` | Delete a project (irreversible) |
|
|
101
|
+
|
|
102
|
+
Alias: `coze code proj`
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Create a Web project
|
|
106
|
+
coze code project create -m "Create a chatbot" --type web
|
|
107
|
+
|
|
108
|
+
# Create and wait for the initial build to complete
|
|
109
|
+
coze code project create -m "Create a data dashboard" --type app --wait
|
|
110
|
+
|
|
111
|
+
# List projects with filters
|
|
112
|
+
coze code project list --type agent --type workflow
|
|
113
|
+
coze code project list --name "customer service"
|
|
114
|
+
coze code project list --size 20 --has-published true
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**`project create` options:**
|
|
118
|
+
|
|
119
|
+
| Option | Description |
|
|
120
|
+
|---|---|
|
|
121
|
+
| `-m, --message <message>` | **(required)** Project description in natural language |
|
|
122
|
+
| `--type <type>` | **(required)** Project type: `web` \| `app` |
|
|
123
|
+
| `--wait` | Wait for project creation to complete |
|
|
124
|
+
| `--org-id <orgId>` | Organization ID (reads from context if omitted) |
|
|
125
|
+
| `--space-id <spaceId>` | Space ID (reads from context if omitted) |
|
|
126
|
+
|
|
127
|
+
**`project list` options:**
|
|
128
|
+
|
|
129
|
+
| Option | Description |
|
|
130
|
+
|---|---|
|
|
131
|
+
| `--size <size>` | Number of projects to return (default: 10) |
|
|
132
|
+
| `--cursor-id <cursorId>` | Cursor for pagination |
|
|
133
|
+
| `--type <type>` | Filter by type (can pass multiple times): `agent` \| `workflow` \| `webapp` \| `app` \| `web` \| `miniprogram` \| `assistant` |
|
|
134
|
+
| `--name <name>` | Filter by project name |
|
|
135
|
+
| `--has-published <bool>` | Filter by publish status |
|
|
136
|
+
| `--search-scope <n>` | Created by (0=All, 1=CreatedByMe, 2=AllWithCollaborator) |
|
|
137
|
+
| `--folder-id <id>` | Filter by folder |
|
|
138
|
+
| `--order-type <n>` | Sort type (0=descending, 1=ascending) |
|
|
139
|
+
| `--is-fav-filter <bool>` | Filter favorites only |
|
|
140
|
+
|
|
141
|
+
#### Message
|
|
142
|
+
|
|
143
|
+
Send and manage chat messages in Coze Coding projects. The project ID is specified on the `message` parent command and shared by all subcommands.
|
|
144
|
+
|
|
145
|
+
| Command | Description |
|
|
146
|
+
|---|---|
|
|
147
|
+
| `coze code message send [message]` | Send a prompt message to a project chat |
|
|
148
|
+
| `coze code message status` | Query message status and get result when completed |
|
|
149
|
+
| `coze code message cancel` | Cancel an ongoing message |
|
|
8
150
|
|
|
9
151
|
```bash
|
|
10
|
-
|
|
152
|
+
# Send a message to a project
|
|
153
|
+
coze code message send "Fix the login bug" -p 123456
|
|
154
|
+
|
|
155
|
+
# Mention local files with @ syntax for upload as context
|
|
156
|
+
coze code message send "Refactor @src/utils.ts to use async/await" -p 123456
|
|
157
|
+
|
|
158
|
+
# Mention multiple files
|
|
159
|
+
coze code message send "Compare @src/old.ts and @src/new.ts" -p 123456
|
|
160
|
+
|
|
161
|
+
# Pipe context via stdin
|
|
162
|
+
cat error.log | coze code message send "Analyze this error" -p 123456
|
|
163
|
+
|
|
164
|
+
# Check message status (auto-fetches result when completed)
|
|
165
|
+
coze code message status -p 123456
|
|
166
|
+
|
|
167
|
+
# Cancel an ongoing message
|
|
168
|
+
coze code message cancel -p 123456
|
|
169
|
+
|
|
170
|
+
# Use environment variable for project ID
|
|
171
|
+
export COZE_PROJECT_ID=123456
|
|
172
|
+
coze code message send "Hello"
|
|
11
173
|
```
|
|
12
174
|
|
|
175
|
+
**`message` options (shared by all subcommands):**
|
|
176
|
+
|
|
177
|
+
| Option | Description |
|
|
178
|
+
|---|---|
|
|
179
|
+
| `-p, --project-id <id>` | Coze project ID (or env `COZE_PROJECT_ID`) |
|
|
13
180
|
|
|
14
|
-
|
|
181
|
+
#### Deploy
|
|
15
182
|
|
|
16
|
-
|
|
183
|
+
Deploy projects to the production environment. Supports multiple project types including Agent, Workflow, Skill, Web, Mini-program, etc.
|
|
17
184
|
|
|
18
|
-
|
|
185
|
+
| Command | Description |
|
|
186
|
+
|---|---|
|
|
187
|
+
| `coze code deploy <projectId>` | Deploy a project to production |
|
|
188
|
+
| `coze code deploy <projectId> --wait` | Deploy and wait for completion |
|
|
189
|
+
| `coze code deploy status <projectId>` | Check deployment status |
|
|
19
190
|
|
|
20
191
|
```bash
|
|
21
|
-
|
|
192
|
+
# Deploy a project
|
|
193
|
+
coze code deploy <projectId>
|
|
194
|
+
|
|
195
|
+
# Deploy and wait for completion
|
|
196
|
+
coze code deploy <projectId> --wait
|
|
197
|
+
|
|
198
|
+
# Check latest deployment status
|
|
199
|
+
coze code deploy status <projectId>
|
|
200
|
+
|
|
201
|
+
# Check a specific deployment record
|
|
202
|
+
coze code deploy status <projectId> --deploy-id <deployHistoryId>
|
|
22
203
|
```
|
|
23
204
|
|
|
24
|
-
|
|
205
|
+
#### Environment Variables
|
|
25
206
|
|
|
26
|
-
|
|
207
|
+
Manage project environment variables (Secrets). Supports development and production environments.
|
|
27
208
|
|
|
28
|
-
|
|
209
|
+
| Command | Description |
|
|
210
|
+
|---|---|
|
|
211
|
+
| `coze code env list -p <projectId>` | List environment variables |
|
|
212
|
+
| `coze code env set <key> <value> -p <projectId>` | Set an environment variable |
|
|
213
|
+
| `coze code env delete <key> -p <projectId>` | Delete an environment variable |
|
|
29
214
|
|
|
30
215
|
```bash
|
|
31
|
-
|
|
216
|
+
# List dev environment variables (default)
|
|
217
|
+
coze code env list -p <projectId>
|
|
218
|
+
|
|
219
|
+
# List prod environment variables
|
|
220
|
+
coze code env list -p <projectId> --env prod
|
|
221
|
+
|
|
222
|
+
# Set an environment variable
|
|
223
|
+
coze code env set API_KEY sk-xxxxx -p <projectId>
|
|
224
|
+
|
|
225
|
+
# Delete an environment variable
|
|
226
|
+
coze code env delete API_KEY -p <projectId>
|
|
32
227
|
```
|
|
33
228
|
|
|
34
|
-
|
|
229
|
+
#### Domain
|
|
35
230
|
|
|
36
|
-
|
|
231
|
+
Manage custom domains for deployed projects.
|
|
232
|
+
|
|
233
|
+
| Command | Description |
|
|
234
|
+
|---|---|
|
|
235
|
+
| `coze code domain list <projectId>` | List all custom domains bound to the project |
|
|
236
|
+
| `coze code domain add <domain> -p <projectId>` | Add a custom domain |
|
|
237
|
+
| `coze code domain remove <domain> -p <projectId>` | Remove a custom domain |
|
|
238
|
+
|
|
239
|
+
#### Skill
|
|
240
|
+
|
|
241
|
+
Manage skills associated with a project to extend its capabilities.
|
|
242
|
+
|
|
243
|
+
| Command | Description |
|
|
244
|
+
|---|---|
|
|
245
|
+
| `coze code skill list <projectId>` | List all skills (shows installed status) |
|
|
246
|
+
| `coze code skill add <skillId> -p <projectId>` | Add a skill to the project |
|
|
247
|
+
| `coze code skill remove <skillId> -p <projectId>` | Remove a skill from the project |
|
|
248
|
+
|
|
249
|
+
#### Preview
|
|
250
|
+
|
|
251
|
+
Get the sandbox preview URL for a project.
|
|
252
|
+
|
|
253
|
+
| Command | Description |
|
|
254
|
+
|---|---|
|
|
255
|
+
| `coze code preview <projectId>` | Get the project preview URL |
|
|
37
256
|
|
|
38
257
|
```bash
|
|
39
|
-
|
|
258
|
+
# Get the preview URL (sandbox initialization takes 1-3 minutes)
|
|
259
|
+
coze code preview <projectId>
|
|
40
260
|
```
|
|
261
|
+
|
|
262
|
+
### `coze generate` — Media Generation
|
|
263
|
+
|
|
264
|
+
Generate images, audio, and video using Coze AI models. All `generate` subcommands support `--output-path <path>` to save generated media to disk.
|
|
265
|
+
|
|
266
|
+
#### Image Generation
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
# Generate an image from text
|
|
270
|
+
coze generate image "A sunset over the mountains"
|
|
271
|
+
|
|
272
|
+
# Save to a specific path
|
|
273
|
+
coze generate image "A logo design" --output-path ./assets
|
|
274
|
+
|
|
275
|
+
# Specify size (2K, 4K, or WIDTHxHEIGHT)
|
|
276
|
+
coze generate image "A futuristic city" --size 4K
|
|
277
|
+
|
|
278
|
+
# Disable watermark
|
|
279
|
+
coze generate image "A cat" --no-watermark
|
|
280
|
+
|
|
281
|
+
# Use reference image(s)
|
|
282
|
+
coze generate image "Similar style" --image https://example.com/ref.png
|
|
283
|
+
|
|
284
|
+
# Enable sequential (group) image generation
|
|
285
|
+
coze generate image "A storyboard" --sequential auto --max-images 5
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**`generate image` options:**
|
|
289
|
+
|
|
290
|
+
| Option | Default | Description |
|
|
291
|
+
|---|---|---|
|
|
292
|
+
| `--size <size>` | `2K` | Image size: `2K` \| `4K` \| `WIDTHxHEIGHT` |
|
|
293
|
+
| `--no-watermark` | enabled | Disable watermark |
|
|
294
|
+
| `--image <url>` | — | Reference image URL (repeatable) |
|
|
295
|
+
| `--response-format <fmt>` | `url` | Response format: `url` \| `b64_json` |
|
|
296
|
+
| `--optimize-prompt-mode <mode>` | `standard` | Prompt optimization mode |
|
|
297
|
+
| `--sequential <mode>` | `disabled` | Group image generation: `auto` \| `disabled` |
|
|
298
|
+
| `--max-images <n>` | `15` | Maximum group images (1–15) |
|
|
299
|
+
| `--output-path <path>` | — | Directory to save generated images |
|
|
300
|
+
|
|
301
|
+
#### Audio Generation (TTS)
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
# Basic text-to-speech
|
|
305
|
+
coze generate audio "Hello, welcome to Coze"
|
|
306
|
+
|
|
307
|
+
# Save to file
|
|
308
|
+
coze generate audio "Hello" --output-path ./audio.mp3
|
|
309
|
+
|
|
310
|
+
# Use SSML input
|
|
311
|
+
echo "<speak>Hello</speak>" | coze generate audio --ssml
|
|
312
|
+
|
|
313
|
+
# Custom speaker and format
|
|
314
|
+
coze generate audio "Hello" --speaker zh_female_xiaohe_uranus_bigtts --format ogg_opus
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
**`generate audio` options:**
|
|
318
|
+
|
|
319
|
+
| Option | Default | Description |
|
|
320
|
+
|---|---|---|
|
|
321
|
+
| `--speaker <speaker>` | `zh_female_xiaohe_uranus_bigtts` | Voice speaker |
|
|
322
|
+
| `--format <fmt>` | `mp3` | Audio format: `pcm` \| `mp3` \| `ogg_opus` |
|
|
323
|
+
| `--sample-rate <n>` | `24000` | Sample rate |
|
|
324
|
+
| `--speech-rate <n>` | `0` | Speech rate (-50 to 100) |
|
|
325
|
+
| `--loudness-rate <n>` | `0` | Loudness (-50 to 100) |
|
|
326
|
+
| `--ssml` | `false` | Treat input as SSML instead of plain text |
|
|
327
|
+
| `--output-path <path>` | — | Directory to save generated audio |
|
|
328
|
+
|
|
329
|
+
#### Video Generation
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
# Generate a video (waits for completion by default)
|
|
333
|
+
coze generate video "A cat playing piano"
|
|
334
|
+
|
|
335
|
+
# Save to a specific path
|
|
336
|
+
coze generate video "A dancing kitten" --output-path ./video.mp4
|
|
337
|
+
|
|
338
|
+
# Create task only, don't wait for completion
|
|
339
|
+
coze generate video "A dancing kitten" --no-wait
|
|
340
|
+
|
|
341
|
+
# Custom resolution and aspect ratio
|
|
342
|
+
coze generate video "A landscape" --resolution 1080p --ratio 16:9
|
|
343
|
+
|
|
344
|
+
# Use reference images
|
|
345
|
+
coze generate video "Animate this" --first-frame https://example.com/frame.png
|
|
346
|
+
coze generate video "In this style" --reference-image https://example.com/ref.png
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
**`generate video` options:**
|
|
350
|
+
|
|
351
|
+
| Option | Default | Description |
|
|
352
|
+
|---|---|---|
|
|
353
|
+
| `--model <model>` | `doubao-seedance-1-5-pro-251215` | Video generation model |
|
|
354
|
+
| `--resolution <res>` | `720p` | Resolution: `480p` \| `720p` \| `1080p` |
|
|
355
|
+
| `--ratio <ratio>` | `16:9` | Aspect ratio (e.g., `16:9`, `9:16`, `1:1`) |
|
|
356
|
+
| `--size <size>` | — | Derive ratio/resolution from `WIDTHxHEIGHT` |
|
|
357
|
+
| `--duration <seconds>` | `5` | Duration in seconds (4–12) |
|
|
358
|
+
| `--no-watermark` | enabled | Disable watermark |
|
|
359
|
+
| `--seed <seed>` | — | Random seed for reproducibility |
|
|
360
|
+
| `--camerafixed` | `false` | Fix camera position (reduce motion) |
|
|
361
|
+
| `--no-generate-audio` | generates audio | Do not generate accompanying audio |
|
|
362
|
+
| `--first-frame <url>` | — | First frame image URL |
|
|
363
|
+
| `--last-frame <url>` | — | Last frame image URL |
|
|
364
|
+
| `--reference-image <url>` | — | Reference image URL (repeatable) |
|
|
365
|
+
| `--return-last-frame` | `false` | Return last frame URL in output |
|
|
366
|
+
| `--no-wait` | waits | Only create task, don't poll for completion |
|
|
367
|
+
| `--poll-interval <ms>` | `2000` | Polling interval in milliseconds |
|
|
368
|
+
| `--poll-timeout <ms>` | `300000` | Polling timeout in milliseconds (5 min) |
|
|
369
|
+
| `--output-path <path>` | — | Directory to save generated video |
|
|
370
|
+
|
|
371
|
+
### `coze file` — File Operations
|
|
372
|
+
|
|
373
|
+
Upload local files to Coze for use as attachments or context in projects.
|
|
374
|
+
|
|
375
|
+
| Command | Description |
|
|
376
|
+
|---|---|
|
|
377
|
+
| `coze file upload <path>` | Upload a local file |
|
|
378
|
+
|
|
379
|
+
```bash
|
|
380
|
+
# Upload a file
|
|
381
|
+
coze file upload ./document.pdf
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### `coze config` — Configuration
|
|
385
|
+
|
|
386
|
+
Manage CLI configuration stored in `~/.coze/config.json` (global) and `.cozerc.json` (project-level).
|
|
387
|
+
|
|
388
|
+
| Command | Description |
|
|
389
|
+
|---|---|
|
|
390
|
+
| `coze config list` | List all configuration items with sources |
|
|
391
|
+
| `coze config get <keys...>` | Get one or more configuration values |
|
|
392
|
+
| `coze config set <key> <value>` | Set a configuration value |
|
|
393
|
+
| `coze config delete <keys...>` | Delete one or more configuration items |
|
|
394
|
+
|
|
395
|
+
```bash
|
|
396
|
+
# List all configurations with their sources (env, local, global, default)
|
|
397
|
+
coze config list
|
|
398
|
+
|
|
399
|
+
# Get a single config value
|
|
400
|
+
coze config get spaceId
|
|
401
|
+
|
|
402
|
+
# Get multiple config values
|
|
403
|
+
coze config get apiBaseUrl spaceId organizationId
|
|
404
|
+
|
|
405
|
+
# Set a configuration value
|
|
406
|
+
coze config set spaceId 123456789
|
|
407
|
+
|
|
408
|
+
# Delete configuration keys
|
|
409
|
+
coze config delete spaceId
|
|
410
|
+
coze config delete spaceId apiBaseUrl
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### `coze completion` — Shell Autocompletion
|
|
414
|
+
|
|
415
|
+
Set up or remove shell autocompletion for bash/zsh.
|
|
416
|
+
|
|
417
|
+
```bash
|
|
418
|
+
# Install shell completion script
|
|
419
|
+
coze completion --setup
|
|
420
|
+
|
|
421
|
+
# Remove shell completion script
|
|
422
|
+
coze completion --cleanup
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
## Global Options
|
|
426
|
+
|
|
427
|
+
| Option | Description |
|
|
428
|
+
|---|---|
|
|
429
|
+
| `-h, --help` | Show help |
|
|
430
|
+
| `-v, --version` | Show version |
|
|
431
|
+
| `--format <fmt>` | Output format: `json` or `text` (default: `json`) |
|
|
432
|
+
| `--no-color` | Disable ANSI color output |
|
|
433
|
+
| `--config <path>` | Use a custom configuration file |
|
|
434
|
+
| `--org-id <id>` | Override the default Organization ID |
|
|
435
|
+
| `--space-id <id>` | Override the default Space ID |
|
|
436
|
+
| `--verbose` | Enable verbose mode with detailed process information |
|
|
437
|
+
| `--debug` | Enable debug mode with all log output for diagnosing issues |
|
|
438
|
+
| `--log-file <path>` | Write logs to a file |
|
|
439
|
+
| `--man` | Show full manual information |
|
|
440
|
+
| `--schema` | Output the command's JSON Schema |
|
|
441
|
+
| `--commands` | Output the list of subcommands |
|
|
442
|
+
|
|
443
|
+
## Configuration
|
|
444
|
+
|
|
445
|
+
The CLI reads configuration from multiple sources with the following priority (highest to lowest):
|
|
446
|
+
|
|
447
|
+
1. **Environment variables**
|
|
448
|
+
2. **Command-line `--config` file**
|
|
449
|
+
3. **Project-level config** (`.cozerc.json` in current directory)
|
|
450
|
+
4. **Global config** (`~/.coze/config.json`)
|
|
451
|
+
5. **Built-in defaults**
|
|
452
|
+
|
|
453
|
+
### Environment Variables
|
|
454
|
+
|
|
455
|
+
| Variable | Description |
|
|
456
|
+
|---|---|
|
|
457
|
+
| `COZE_API_TOKEN` | Personal Access Token for authentication |
|
|
458
|
+
| `COZE_ORG_ID` | Default Organization ID |
|
|
459
|
+
| `COZE_ENTERPRISE_ID` | Default Enterprise ID |
|
|
460
|
+
| `COZE_SPACE_ID` | Default Space ID |
|
|
461
|
+
| `COZE_PROJECT_ID` | Default Project ID (used by `message` commands) |
|
|
462
|
+
|
|
463
|
+
## Exit Codes
|
|
464
|
+
|
|
465
|
+
| Code | Name | Description |
|
|
466
|
+
|---|---|---|
|
|
467
|
+
| `0` | `SUCCESS` | Command completed successfully |
|
|
468
|
+
| `1` | `GENERAL_ERROR` | General error |
|
|
469
|
+
| `2` | `AUTH_FAILED` | Authentication failed |
|
|
470
|
+
| `3` | `RESOURCE_NOT_FOUND` | Requested resource not found |
|
|
471
|
+
| `4` | `INVALID_ARGUMENT` | Invalid argument or option |
|
|
472
|
+
| `5` | `PERMISSION_DENIED` | Permission denied |
|
|
473
|
+
| `6` | `NETWORK_ERROR` | Network error |
|
|
474
|
+
| `7` | `SERVER_ERROR` | Server error |
|
|
475
|
+
| `8` | `TIMEOUT` | Operation timed out |
|
|
476
|
+
| `9` | `QUOTA_EXCEEDED` | Quota exceeded |
|
|
477
|
+
| `10` | `CONFLICT` | Resource conflict |
|
|
478
|
+
|
|
479
|
+
## CI/CD Usage
|
|
480
|
+
|
|
481
|
+
```bash
|
|
482
|
+
# Authenticate with a PAT
|
|
483
|
+
export COZE_API_TOKEN=<YOUR_PAT>
|
|
484
|
+
export COZE_ORG_ID=<ORG_ID>
|
|
485
|
+
export COZE_SPACE_ID=<SPACE_ID>
|
|
486
|
+
|
|
487
|
+
# Create a project and wait for completion
|
|
488
|
+
coze code project create -m "Build a chatbot" --type web --wait --format json
|
|
489
|
+
|
|
490
|
+
# Send a message to a project
|
|
491
|
+
export COZE_PROJECT_ID=<PROJECT_ID>
|
|
492
|
+
coze code message send "Fix the authentication module" --format json
|
|
493
|
+
|
|
494
|
+
# Deploy a project and wait for completion
|
|
495
|
+
coze code deploy <projectId> --wait --format json
|
|
496
|
+
|
|
497
|
+
# Check deployment status
|
|
498
|
+
coze code deploy status <projectId> --format json
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
## License
|
|
502
|
+
|
|
503
|
+
See the [LICENSE](LICENSE.md) file and [THIRD-PARTY-LICENSES](THIRD-PARTY-LICENSES.md) included in the package for full terms, conditions, and third-party notices.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @coze/cli THIRD-PARTY LICENSES
|
|
2
|
+
|
|
3
|
+
**Copyright (c) 2026 ByteDance Ltd. and/or its affiliates**
|
|
4
|
+
|
|
5
|
+
This project, **@coze/cli**, incorporates components from the open source projects listed below.
|
|
6
|
+
The original copyright notices and the licenses under which ByteDance received such components are set forth below.
|
|
7
|
+
|
|
8
|
+
## Open Source and Third-Party Components
|
|
9
|
+
|
|
10
|
+
| Component | License | URL |
|
|
11
|
+
| :--- | :--- | :--- |
|
|
12
|
+
| **chalk** | MIT | [Link](https://www.npmjs.com/package/chalk) |
|
|
13
|
+
| **commander** | MIT | [Link](https://www.npmjs.com/package/commander) |
|
|
14
|
+
| **form-data** | MIT | [Link](https://www.npmjs.com/package/form-data) |
|
|
15
|
+
| **http-proxy-agent** | MIT | [Link](https://www.npmjs.com/package/http-proxy-agent) |
|
|
16
|
+
| **https-proxy-agent** | MIT | [Link](https://www.npmjs.com/package/https-proxy-agent) |
|
|
17
|
+
| **lodash** | MIT | [Link](https://www.npmjs.com/package/lodash) |
|
|
18
|
+
| **mitt** | MIT | [Link](https://www.npmjs.com/package/mitt) |
|
|
19
|
+
| **omelette** | MIT | [Link](https://www.npmjs.com/package/omelette) |
|
|
20
|
+
| **undici** | MIT | [Link](https://www.npmjs.com/package/undici) |
|
|
21
|
+
| **@rollup/plugin-commonjs** | MIT | [Link](https://www.npmjs.com/package/@rollup/plugin-commonjs) |
|
|
22
|
+
| **@rollup/plugin-json** | MIT | [Link](https://www.npmjs.com/package/@rollup/plugin-json) |
|
|
23
|
+
| **@rollup/plugin-node-resolve** | MIT | [Link](https://www.npmjs.com/package/@rollup/plugin-node-resolve) |
|
|
24
|
+
| **@rollup/plugin-sucrase** | MIT | [Link](https://www.npmjs.com/package/@rollup/plugin-sucrase) |
|
|
25
|
+
| **@types/lodash** | MIT | [Link](https://www.npmjs.com/package/@types/lodash) |
|
|
26
|
+
| **@types/node** | MIT | [Link](https://www.npmjs.com/package/@types/node) |
|
|
27
|
+
| **@vitest/coverage-v8** | MIT | [Link](https://www.npmjs.com/package/@vitest/coverage-v8) |
|
|
28
|
+
| **rollup** | MIT | [Link](https://www.npmjs.com/package/rollup) |
|
|
29
|
+
| **sucrase** | MIT | [Link](https://www.npmjs.com/package/sucrase) |
|
|
30
|
+
| **tsx** | MIT | [Link](https://www.npmjs.com/package/tsx) |
|
|
31
|
+
| **vitest** | MIT | [Link](https://www.npmjs.com/package/vitest) |
|
package/bin/main
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const isCompletion = process.argv.includes('--compzsh') ||
|
|
4
|
+
process.argv.includes('--compbash') ||
|
|
5
|
+
process.argv.includes('--completion') ||
|
|
6
|
+
process.argv.includes('completion');
|
|
7
|
+
|
|
8
|
+
if (isCompletion) {
|
|
9
|
+
process.env.DOTENV_CONFIG_QUIET = 'true';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
process.env.NODE_ENV = 'production';
|
|
13
|
+
|
|
14
|
+
const isDebug = process.argv.includes('--debug');
|
|
15
|
+
|
|
16
|
+
// 如果不是 debug 模式,默认关闭 dotenv 的所有控制台输出
|
|
17
|
+
if (!isDebug) {
|
|
18
|
+
process.env.DOTENV_CONFIG_QUIET = 'true';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
require('../lib/cli.js');
|