@coze/cli 0.2.0-alpha.2372ad → 0.2.0-alpha.7e254b
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 +67 -23
- package/bin/postinstall.js +77 -0
- package/lib/cli.js +3 -3
- package/lib/fetch-client-CgQGE-CR.js +1 -0
- package/lib/{index-DNmOe3vH.js → index-DN7-Fdfx.js} +1 -1
- package/lib/send-message.worker.js +1 -1
- package/lib/session-task-refresh.worker.js +1 -1
- package/lib/{task-worker-4JFWlT-Q.js → task-worker-Bt8hYeP2.js} +1 -1
- package/package.json +6 -8
- package/skills/manifest.json +6 -6
- package/skills/using-coze-cli/SKILL.md +25 -26
- package/skills/using-coze-cli/coze-claw/MODULE.md +1 -1
- package/skills/using-coze-cli/coze-code/MODULE.md +25 -8
- package/skills/using-coze-cli/coze-code/references/coze-code-db.md +11 -4
- package/skills/using-coze-cli/coze-code/references/coze-code-deploy.md +2 -2
- package/skills/using-coze-cli/coze-code/references/coze-code-domain.md +1 -1
- package/skills/using-coze-cli/coze-code/references/coze-code-git.md +11 -3
- package/skills/using-coze-cli/coze-code/references/coze-code-message.md +1 -1
- package/skills/using-coze-cli/coze-code/references/coze-code-project.md +25 -3
- package/skills/using-coze-cli/coze-code/references/coze-code-repo.md +18 -7
- package/skills/using-coze-cli/coze-code/references/coze-code-skill.md +4 -0
- package/skills/using-coze-cli/coze-file/MODULE.md +4 -4
- package/skills/using-coze-cli/coze-file/references/coze-file-upload.md +7 -7
- package/skills/using-coze-cli/coze-generate/MODULE.md +2 -2
- package/skills/using-coze-cli/coze-generate/references/coze-generate-audio.md +2 -2
- package/skills/using-coze-cli/coze-generate/references/coze-generate-image.md +5 -5
- package/skills/using-coze-cli/coze-generate/references/coze-generate-video.md +9 -10
- package/lib/fetch-client-DC0c3ox3.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
|
|
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
|
|
|
@@ -132,7 +139,7 @@ coze code project list --size 20 --has-published
|
|
|
132
139
|
| `--type <type>` | Filter by type (can pass multiple times): `agent` \| `workflow` \| `webapp` \| `app` \| `web` \| `miniprogram` \| `assistant` |
|
|
133
140
|
| `--name <name>` | Filter by project name |
|
|
134
141
|
| `--has-published` | Filter by publish status |
|
|
135
|
-
| `--search-scope <n>` | Created by (0=All, 1=
|
|
142
|
+
| `--search-scope <n>` | Created by (0=All, 1=CreateByMe, 2=AllWithCollaborator) |
|
|
136
143
|
| `--folder-id <id>` | Filter by folder |
|
|
137
144
|
| `--order-type <n>` | Sort type (0=descending, 1=ascending) |
|
|
138
145
|
| `--order-by <n>` | Order by (0=updated\_at, 1=created\_at) |
|
|
@@ -148,6 +155,10 @@ coze code project list --size 20 --has-published
|
|
|
148
155
|
|
|
149
156
|
> Remote import requires prior OAuth authorization via `coze code git auth login`, and imported projects are automatically bound to the source repo.
|
|
150
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.
|
|
161
|
+
|
|
151
162
|
#### Message
|
|
152
163
|
|
|
153
164
|
Send and manage chat messages in Coze Coding projects. The project ID is specified on the `message` parent command and shared by all subcommands.
|
|
@@ -371,14 +382,18 @@ coze code git auth login
|
|
|
371
382
|
# Check authorization status
|
|
372
383
|
coze code git auth status
|
|
373
384
|
|
|
385
|
+
# Check authorization status in a pipeline
|
|
386
|
+
coze code git auth status --format json | jq .status
|
|
387
|
+
|
|
374
388
|
# Search repos by keyword
|
|
375
389
|
coze code git search --keyword react
|
|
376
390
|
|
|
377
391
|
# Paginated search
|
|
378
392
|
coze code git search -k react --page 2 --page-size 10
|
|
379
393
|
|
|
380
|
-
# Revoke authorization
|
|
394
|
+
# Revoke authorization (interactive confirmation; use --force to skip)
|
|
381
395
|
coze code git auth logout
|
|
396
|
+
coze code git auth logout --force
|
|
382
397
|
```
|
|
383
398
|
|
|
384
399
|
**`git`** **options (shared by subcommands):**
|
|
@@ -387,6 +402,8 @@ coze code git auth logout
|
|
|
387
402
|
| ----------------------- | ----------------------------------------------------- |
|
|
388
403
|
| `--provider <provider>` | Git service provider: `github` / `gitlab` (default: `github`) |
|
|
389
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
|
+
|
|
390
407
|
#### Repo
|
|
391
408
|
|
|
392
409
|
Manage remote repository bindings and sync operations for Coze Coding projects.
|
|
@@ -420,6 +437,12 @@ coze code repo pull -p <projectId> --conflict-strategy ours
|
|
|
420
437
|
coze code repo unbind -p <projectId> --force
|
|
421
438
|
```
|
|
422
439
|
|
|
440
|
+
**`repo`** **options (shared by subcommands):**
|
|
441
|
+
|
|
442
|
+
| Option | Description |
|
|
443
|
+
| ----------------------- | ----------------------------------------------------- |
|
|
444
|
+
| `--provider <provider>` | Git service provider: `github` / `gitlab` (default: `github`) |
|
|
445
|
+
|
|
423
446
|
**`repo create`** **options:**
|
|
424
447
|
|
|
425
448
|
| Option | Description |
|
|
@@ -441,12 +464,26 @@ coze code repo unbind -p <projectId> --force
|
|
|
441
464
|
| `-p, --project-id <projectId>` | **(required)** Project ID |
|
|
442
465
|
| `--conflict-strategy <strategy>` | Auto conflict resolution: `ours` / `theirs` |
|
|
443
466
|
|
|
444
|
-
**`repo
|
|
467
|
+
**`repo push`** **options:**
|
|
445
468
|
|
|
446
469
|
| Option | Description |
|
|
447
470
|
| ------------------------------ | ------------------------- |
|
|
448
471
|
| `-p, --project-id <projectId>` | **(required)** Project ID |
|
|
449
|
-
|
|
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`.
|
|
450
487
|
|
|
451
488
|
> `repo push` and `repo pull` are placeholder implementations pending backend wiring — they currently report success without performing a real sync.
|
|
452
489
|
|
|
@@ -510,6 +547,8 @@ coze code db rollback --db-id <id> --timestamp 1713254400000 --confirm
|
|
|
510
547
|
| `--all` | Fetch all databases across pages |
|
|
511
548
|
| `--max-pages <maxPages>` | Max pages to fetch in text mode (default: 10) |
|
|
512
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
|
+
|
|
513
552
|
**`db gen-types`** **options:**
|
|
514
553
|
|
|
515
554
|
| Option | Description |
|
|
@@ -613,6 +652,7 @@ coze generate image "A storyboard" --sequential auto --max-images 5
|
|
|
613
652
|
| `--optimize-prompt-mode <mode>` | `standard` | Prompt optimization mode |
|
|
614
653
|
| `--sequential <mode>` | `disabled` | Group image generation: `auto` \| `disabled` |
|
|
615
654
|
| `--max-images <n>` | `15` | Maximum group images (1–15) |
|
|
655
|
+
| `--stdin` | `false` | Read prompt from stdin (pipe input) |
|
|
616
656
|
| `--output-path <path>` | — | Directory to save generated images |
|
|
617
657
|
|
|
618
658
|
#### Audio Generation (TTS)
|
|
@@ -641,6 +681,7 @@ coze generate audio "Hello" --speaker zh_female_xiaohe_uranus_bigtts --audio-for
|
|
|
641
681
|
| `--speech-rate <n>` | `0` | Speech rate (-50 to 100) |
|
|
642
682
|
| `--loudness-rate <n>` | `0` | Loudness (-50 to 100) |
|
|
643
683
|
| `--ssml` | `false` | Treat input as SSML instead of plain text |
|
|
684
|
+
| `--stdin` | `false` | Read prompt from stdin (pipe input) |
|
|
644
685
|
| `--uid <uid>` | `cli_user` | User UID |
|
|
645
686
|
| `--output-path <path>` | — | Directory to save generated audio |
|
|
646
687
|
|
|
@@ -684,14 +725,15 @@ Use `coze generate video create` to submit generation tasks, and `coze generate
|
|
|
684
725
|
| `--first-frame <url>` | — | First frame image URL |
|
|
685
726
|
| `--last-frame <url>` | — | Last frame image URL |
|
|
686
727
|
| `--return-last-frame` | `false` | Return last frame URL in output |
|
|
728
|
+
| `--stdin` | `false` | Read prompt from stdin (pipe input) |
|
|
687
729
|
| `--wait` | `false` | Poll until completion instead of returning `taskId` immediately |
|
|
688
730
|
| `--output-path <path>` | — | Directory to save generated video |
|
|
689
731
|
|
|
690
|
-
**`generate video status`**
|
|
732
|
+
**`generate video status`** has no command-specific options. Use the global `--format json` flag to output the full response as JSON:
|
|
691
733
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
734
|
+
```bash
|
|
735
|
+
coze generate video status task_123 --format json
|
|
736
|
+
```
|
|
695
737
|
|
|
696
738
|
### `coze file` — File Operations
|
|
697
739
|
|
|
@@ -767,6 +809,13 @@ coze upgrade --tag beta
|
|
|
767
809
|
| `--force` | Force upgrade even if already on the latest version |
|
|
768
810
|
| `--tag <tag>` | Specify the dist-tag to upgrade to (default: `latest`) |
|
|
769
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
|
+
|
|
770
819
|
## Global Options
|
|
771
820
|
|
|
772
821
|
| Option | Description |
|
|
@@ -810,19 +859,14 @@ The CLI reads configuration from multiple sources with the following priority (h
|
|
|
810
859
|
|
|
811
860
|
## Exit Codes
|
|
812
861
|
|
|
813
|
-
| Code | Name
|
|
814
|
-
| ---- |
|
|
815
|
-
| `0` | `SUCCESS`
|
|
816
|
-
| `1` | `
|
|
817
|
-
| `2` | `
|
|
818
|
-
| `
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
| `6` | `NETWORK_ERROR` | Network error |
|
|
822
|
-
| `7` | `SERVER_ERROR` | Server error |
|
|
823
|
-
| `8` | `TIMEOUT` | Operation timed out |
|
|
824
|
-
| `9` | `QUOTA_EXCEEDED` | Quota exceeded |
|
|
825
|
-
| `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.
|
|
826
870
|
|
|
827
871
|
## License
|
|
828
872
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// ABOUTME: npm postinstall 钩子:安装/升级后静默执行 `coze self skill install`,
|
|
3
|
+
// ABOUTME: 把 CLI 自带 skills 同步给本机 AI agents;失败则降级为提示,绝不阻断安装。
|
|
4
|
+
//
|
|
5
|
+
// 注意:npm >= 7 默认后台执行生命周期脚本并丢弃输出(需 --foreground-scripts
|
|
6
|
+
// 才展示),因此 npm 用户通常看不到本脚本的打印;pnpm、yarn classic 及旧版
|
|
7
|
+
// npm 会正常转发。同步失败时的兜底是运行时的 update-check 中间件:skills
|
|
8
|
+
// 缺失或与 CLI 版本不一致时,任何命令结束后都会提示 `coze self skill install`。
|
|
9
|
+
// 不要在这里检测 process.stdout.isTTY —— 包管理器执行脚本时 stdout 总是
|
|
10
|
+
// pipe,加了等于在所有包管理器下永久静默。
|
|
11
|
+
|
|
12
|
+
const SYNC_TIMEOUT_MS = 120000;
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
const { existsSync, readFileSync } = require('fs');
|
|
16
|
+
const { join } = require('path');
|
|
17
|
+
const { homedir } = require('os');
|
|
18
|
+
const { spawnSync } = require('child_process');
|
|
19
|
+
|
|
20
|
+
// CI 环境不执行同步(不可控环境不写家目录)
|
|
21
|
+
// 开发仓库内的安装(rush update / pnpm install)也跳过:发布包不含 src/
|
|
22
|
+
if (process.env.CI || existsSync(join(__dirname, '..', 'src'))) {
|
|
23
|
+
process.exit(0);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const useColor = !process.env.NO_COLOR;
|
|
27
|
+
const cyan = text => (useColor ? `[36m${text}[0m` : text);
|
|
28
|
+
|
|
29
|
+
// 通过包内 CLI 入口走真实的 `coze self skill install` 代码路径(skipAuth,纯本地:
|
|
30
|
+
// 释放 bundled skills 到 ~/.coze/cli/skills 并软链到已安装的 AI agents)。
|
|
31
|
+
// 用户改过的 skill 不会被覆盖(sync 默认不带 --force 即阻止)。
|
|
32
|
+
const result = spawnSync(
|
|
33
|
+
process.execPath,
|
|
34
|
+
[join(__dirname, 'main'), 'self', 'skill', 'install'],
|
|
35
|
+
{
|
|
36
|
+
stdio: 'ignore',
|
|
37
|
+
timeout: SYNC_TIMEOUT_MS,
|
|
38
|
+
env: { ...process.env, DOTENV_CONFIG_QUIET: 'true' },
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// sync 被用户改过的 skill 阻止时也会 exit 0(仅告警不写入),
|
|
43
|
+
// 因此用 lock 里的版本与包版本比对来确认是否真正同步成功
|
|
44
|
+
let synced = result.status === 0;
|
|
45
|
+
if (synced) {
|
|
46
|
+
try {
|
|
47
|
+
const lock = JSON.parse(
|
|
48
|
+
readFileSync(
|
|
49
|
+
join(homedir(), '.coze', 'cli', '.skill-lock.json'),
|
|
50
|
+
'utf8',
|
|
51
|
+
),
|
|
52
|
+
);
|
|
53
|
+
synced = lock.cliVersion === require('../package.json').version;
|
|
54
|
+
// eslint-disable-next-line @coze-arch/no-empty-catch -- unreadable lock means sync did not complete
|
|
55
|
+
} catch {
|
|
56
|
+
synced = false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (synced) {
|
|
61
|
+
process.stdout.write(
|
|
62
|
+
`\nCoze CLI installed. Bundled skills synced to your AI agents (run ${cyan(
|
|
63
|
+
'coze self skill status',
|
|
64
|
+
)} to inspect).\n\n`,
|
|
65
|
+
);
|
|
66
|
+
} else {
|
|
67
|
+
process.stdout.write(
|
|
68
|
+
`\nCoze CLI installed. Run ${cyan(
|
|
69
|
+
'coze self skill install',
|
|
70
|
+
)} to sync the bundled skills to your AI agents (Claude Code, Trae, Comate, ...).\n\n`,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
// eslint-disable-next-line @coze-arch/no-empty-catch -- postinstall sync is best-effort and must never block install
|
|
74
|
+
} catch {
|
|
75
|
+
// postinstall 同步失败不应阻断安装;运行时 update-check 会兜底提示
|
|
76
|
+
}
|
|
77
|
+
process.exit(0);
|