@coze/cli 0.0.4 → 0.1.0-alpha.391559
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 +217 -16
- package/bin/main +21 -0
- package/lib/cli.js +41195 -0
- package/lib/index-lMSqm5Bi.js +20896 -0
- package/lib/send-message.worker.js +52 -0
- package/package.json +60 -51
- package/LICENSE +0 -21
- 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/README.md
CHANGED
|
@@ -1,40 +1,241 @@
|
|
|
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
|
|
8
12
|
|
|
9
13
|
```bash
|
|
10
|
-
|
|
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 --message "Build an intelligent assistant" --type web
|
|
11
27
|
```
|
|
12
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>
|
|
13
39
|
|
|
14
|
-
#
|
|
40
|
+
# Check current login status
|
|
41
|
+
coze auth status
|
|
15
42
|
|
|
16
|
-
|
|
43
|
+
# Logout
|
|
44
|
+
coze auth logout
|
|
45
|
+
```
|
|
17
46
|
|
|
18
|
-
|
|
47
|
+
You can also authenticate via environment variables for CI/CD pipelines:
|
|
19
48
|
|
|
20
49
|
```bash
|
|
21
|
-
|
|
50
|
+
export COZE_API_TOKEN=<YOUR_PAT>
|
|
22
51
|
```
|
|
23
52
|
|
|
24
|
-
|
|
53
|
+
## Commands
|
|
54
|
+
|
|
55
|
+
### `coze auth` — Authentication
|
|
56
|
+
|
|
57
|
+
| Command | Description |
|
|
58
|
+
|---|---|
|
|
59
|
+
| `coze auth login --oauth` | Interactive login via browser |
|
|
60
|
+
| `coze auth login --token <PAT>` | Login with a Personal Access Token |
|
|
61
|
+
| `coze auth status` | Check current login status |
|
|
62
|
+
| `coze auth logout` | Logout and clear stored credentials |
|
|
63
|
+
|
|
64
|
+
### `coze organization` — Organization Management
|
|
65
|
+
|
|
66
|
+
| Command | Description |
|
|
67
|
+
|---|---|
|
|
68
|
+
| `coze organization list` | List all accessible organizations |
|
|
69
|
+
| `coze organization use <org_id>` | Set the default organization |
|
|
70
|
+
|
|
71
|
+
Alias: `coze org`
|
|
25
72
|
|
|
26
|
-
|
|
73
|
+
### `coze space` — Workspace Management
|
|
27
74
|
|
|
28
|
-
|
|
75
|
+
| Command | Description |
|
|
76
|
+
|---|---|
|
|
77
|
+
| `coze space list` | List all spaces under the current organization |
|
|
78
|
+
| `coze space use <space_id>` | Set the default workspace |
|
|
79
|
+
|
|
80
|
+
### `coze code` — Coze Coding
|
|
81
|
+
|
|
82
|
+
#### Project
|
|
83
|
+
|
|
84
|
+
| Command | Description |
|
|
85
|
+
|---|---|
|
|
86
|
+
| `coze code project create` | Create a new project from natural language description |
|
|
87
|
+
| `coze code project list` | List all projects |
|
|
88
|
+
| `coze code project get <id>` | Get project details |
|
|
89
|
+
| `coze code project delete <id>` | Delete a project |
|
|
29
90
|
|
|
30
91
|
```bash
|
|
31
|
-
|
|
92
|
+
# Create an Agent project
|
|
93
|
+
coze code project create --message "Create a customer service bot" --type agent
|
|
94
|
+
|
|
95
|
+
# Supported types: agent, workflow, app, skill, web, miniprogram, assistant
|
|
32
96
|
```
|
|
33
97
|
|
|
34
|
-
|
|
98
|
+
#### Message
|
|
35
99
|
|
|
36
|
-
|
|
100
|
+
| Command | Description |
|
|
101
|
+
|---|---|
|
|
102
|
+
| `coze code message send [message]` | Send a prompt message to a project chat |
|
|
103
|
+
| `coze code message status` | Check message status |
|
|
104
|
+
| `coze code message cancel` | Cancel an ongoing message |
|
|
37
105
|
|
|
38
106
|
```bash
|
|
39
|
-
|
|
107
|
+
# Send a message to a project
|
|
108
|
+
coze code message send "Fix the login bug" --project-id 123456
|
|
109
|
+
|
|
110
|
+
# Pipe context via stdin
|
|
111
|
+
cat error.log | coze code message send "Analyze this error" --project-id 123456
|
|
40
112
|
```
|
|
113
|
+
|
|
114
|
+
#### Deploy
|
|
115
|
+
|
|
116
|
+
| Command | Description |
|
|
117
|
+
|---|---|
|
|
118
|
+
| `coze code deploy <projectId>` | Deploy a project to production |
|
|
119
|
+
| `coze code deploy <projectId> --wait` | Deploy and wait for completion |
|
|
120
|
+
| `coze code deploy status <projectId>` | Check deployment status |
|
|
121
|
+
|
|
122
|
+
#### Environment Variables
|
|
123
|
+
|
|
124
|
+
| Command | Description |
|
|
125
|
+
|---|---|
|
|
126
|
+
| `coze code env list` | List environment variables |
|
|
127
|
+
| `coze code env set <key> <value>` | Set an environment variable |
|
|
128
|
+
| `coze code env delete <key>` | Delete an environment variable |
|
|
129
|
+
|
|
130
|
+
#### Domain
|
|
131
|
+
|
|
132
|
+
| Command | Description |
|
|
133
|
+
|---|---|
|
|
134
|
+
| `coze code domain list` | List custom domains |
|
|
135
|
+
| `coze code domain add <domain>` | Add a custom domain |
|
|
136
|
+
| `coze code domain remove <domain>` | Remove a custom domain |
|
|
137
|
+
|
|
138
|
+
#### Skill
|
|
139
|
+
|
|
140
|
+
| Command | Description |
|
|
141
|
+
|---|---|
|
|
142
|
+
| `coze code skill list` | List skills |
|
|
143
|
+
| `coze code skill add` | Add a skill |
|
|
144
|
+
| `coze code skill remove` | Remove a skill |
|
|
145
|
+
|
|
146
|
+
#### Preview
|
|
147
|
+
|
|
148
|
+
| Command | Description |
|
|
149
|
+
|---|---|
|
|
150
|
+
| `coze code preview` | Preview the project |
|
|
151
|
+
|
|
152
|
+
### `coze generate` — Media Generation
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Generate an image
|
|
156
|
+
coze generate image "A sunset over the mountains"
|
|
157
|
+
|
|
158
|
+
# Generate audio
|
|
159
|
+
coze generate audio "Hello, welcome to Coze"
|
|
160
|
+
|
|
161
|
+
# Generate a video
|
|
162
|
+
coze generate video "A cat playing piano"
|
|
163
|
+
|
|
164
|
+
# Save to a specific directory
|
|
165
|
+
coze generate image "A logo design" --output-path ./assets
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### `coze file` — File Operations
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# Upload a file
|
|
172
|
+
coze file upload ./document.pdf
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### `coze config` — Configuration
|
|
176
|
+
|
|
177
|
+
Configuration is stored in `~/.coze/config.json` (global) and `.cozerc.json` (project-level).
|
|
178
|
+
|
|
179
|
+
| Command | Description |
|
|
180
|
+
|---|---|
|
|
181
|
+
| `coze config list` | List all configuration items with sources |
|
|
182
|
+
| `coze config get <key>` | Get a configuration value |
|
|
183
|
+
| `coze config set <key> <value>` | Set a configuration value |
|
|
184
|
+
| `coze config delete <key>` | Delete a configuration item |
|
|
185
|
+
|
|
186
|
+
### `coze completion` — Shell Autocompletion
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# Set up shell autocompletion
|
|
190
|
+
coze completion --setup
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Global Options
|
|
194
|
+
|
|
195
|
+
| Option | Description |
|
|
196
|
+
|---|---|
|
|
197
|
+
| `-h, --help` | Show help |
|
|
198
|
+
| `-v, --version` | Show version |
|
|
199
|
+
| `--format <fmt>` | Output format: `json` or `text` (default: `text`) |
|
|
200
|
+
| `--no-color` | Disable ANSI color output |
|
|
201
|
+
| `--config <path>` | Use a custom configuration file |
|
|
202
|
+
| `--org-id <id>` | Override the default Organization ID |
|
|
203
|
+
| `--space-id <id>` | Override the default Space ID |
|
|
204
|
+
| `--verbose` | Enable verbose logging |
|
|
205
|
+
| `--debug` | Enable debug mode |
|
|
206
|
+
| `--log-file <path>` | Write logs to a file |
|
|
207
|
+
|
|
208
|
+
## Configuration
|
|
209
|
+
|
|
210
|
+
The CLI reads configuration from multiple sources with the following priority (highest to lowest):
|
|
211
|
+
|
|
212
|
+
1. **Environment variables**
|
|
213
|
+
2. **Command-line `--config` file**
|
|
214
|
+
3. **Project-level config** (`.cozerc.json` in current directory)
|
|
215
|
+
4. **Global config** (`~/.coze/config.json`)
|
|
216
|
+
5. **Built-in defaults**
|
|
217
|
+
|
|
218
|
+
### Environment Variables
|
|
219
|
+
|
|
220
|
+
| Variable | Description |
|
|
221
|
+
|---|---|
|
|
222
|
+
| `COZE_API_TOKEN` | Personal Access Token for authentication |
|
|
223
|
+
| `COZE_ORG_ID` | Default Organization ID |
|
|
224
|
+
| `COZE_ENTERPRISE_ID` | Default Enterprise ID |
|
|
225
|
+
| `COZE_SPACE_ID` | Default Space ID |
|
|
226
|
+
|
|
227
|
+
## CI/CD Usage
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
# Authenticate with a PAT
|
|
231
|
+
export COZE_API_TOKEN=<YOUR_PAT>
|
|
232
|
+
export COZE_ORG_ID=<ORG_ID>
|
|
233
|
+
export COZE_SPACE_ID=<SPACE_ID>
|
|
234
|
+
|
|
235
|
+
# Deploy a project
|
|
236
|
+
coze code deploy <projectId> --wait --format json
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## License
|
|
240
|
+
|
|
241
|
+
MIT
|
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');
|