@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.
- package/README.md +408 -45
- package/bin/postinstall.js +77 -0
- package/lib/cli.js +3 -3
- package/lib/fetch-client-CgQGE-CR.js +1 -0
- package/lib/index-DN7-Fdfx.js +1 -0
- package/lib/send-message.worker.js +1 -1
- package/lib/session-task-refresh.worker.js +1 -1
- package/lib/task-worker-Bt8hYeP2.js +1 -0
- package/package.json +15 -8
- package/skills/manifest.json +25 -0
- package/skills/using-coze-cli/SKILL.md +447 -0
- package/skills/using-coze-cli/coze-claw/MODULE.md +189 -0
- package/skills/using-coze-cli/coze-claw/references/coze-claw-agent-routing.md +45 -0
- package/skills/using-coze-cli/coze-claw/references/coze-claw-artifacts.md +52 -0
- package/skills/using-coze-cli/coze-claw/references/coze-claw-async-followup.md +266 -0
- package/skills/using-coze-cli/coze-claw/references/coze-claw-message.md +176 -0
- package/skills/using-coze-cli/coze-claw/references/coze-claw-podcast.md +73 -0
- package/skills/using-coze-cli/coze-claw/references/coze-claw-ppt.md +78 -0
- package/skills/using-coze-cli/coze-claw/references/coze-claw-progress.md +112 -0
- package/skills/using-coze-cli/coze-claw/references/coze-claw-session.md +144 -0
- package/skills/using-coze-cli/coze-code/MODULE.md +326 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-db.md +544 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-deploy.md +258 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-domain.md +73 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-env.md +82 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-git.md +189 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-message.md +240 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-model.md +51 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-preview.md +33 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-project.md +222 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-repo.md +296 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-skill.md +121 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-tools.md +47 -0
- package/skills/using-coze-cli/coze-file/MODULE.md +46 -0
- package/skills/using-coze-cli/coze-file/references/coze-file-upload.md +59 -0
- package/skills/using-coze-cli/coze-generate/MODULE.md +84 -0
- package/skills/using-coze-cli/coze-generate/references/coze-generate-audio.md +105 -0
- package/skills/using-coze-cli/coze-generate/references/coze-generate-image.md +80 -0
- package/skills/using-coze-cli/coze-generate/references/coze-generate-video.md +124 -0
- package/lib/fetch-client-CWYDGe9Z.js +0 -1
- package/lib/index-BC9PFu7i.js +0 -1
- package/lib/task-worker-CxZeBKqU.js +0 -1
|
@@ -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);
|