@remixmate/cli 0.9.21 → 0.9.23
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 +30 -18
- package/README.zh-CN.md +25 -18
- package/dist/cli.js +11 -0
- package/dist/doctor.js +20 -1
- package/dist/install.d.ts +61 -0
- package/dist/install.js +429 -0
- package/dist/manifest.json +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,32 +11,44 @@ AI media generation skills for Claude Code / Codex.
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
npm install -g @remixmate/cli
|
|
15
|
-
remixmate --help
|
|
16
|
-
remixmate --list
|
|
14
|
+
npm install -g @remixmate/cli && remixmate install
|
|
17
15
|
```
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
`npm install` gives you the `remixmate` binary. `remixmate install` is what makes an
|
|
18
|
+
agent *discover* the skills on its own: it copies the bundled `skills/` into every
|
|
19
|
+
agent home it finds. All of these hosts read the same `SKILL.md` format, so one
|
|
20
|
+
`skills/` directory serves all of them:
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
| Host | User-level | Project-level | Override |
|
|
23
|
+
| --- | --- | --- | --- |
|
|
24
|
+
| Claude Code | `~/.claude/skills` | `./.claude/skills` | `CLAUDE_CONFIG_DIR` |
|
|
25
|
+
| Codex | `~/.codex/skills` | — | `CODEX_HOME` |
|
|
26
|
+
| WorkBuddy | `~/.workbuddy/skills` | `./.workbuddy/skills` | — |
|
|
27
|
+
| CodeBuddy | `~/.codebuddy/skills` | `./.codebuddy/skills` | — |
|
|
28
|
+
| Trae / TraeWork | — | `./.trae/skills` | — |
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
Trae CN and TraeWork CN share `~/.trae-cn` and only define a workspace location (`.trae/skills/<name>/`, per its own built-in
|
|
31
|
+
`skill-creator`), so it is installed per project — a plain `remixmate install` reports
|
|
32
|
+
it and tells you to re-run with `--project` inside the repo. Restart the agent
|
|
33
|
+
afterwards.
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
```bash
|
|
36
|
+
remixmate install --host workbuddy # only one host
|
|
37
|
+
remixmate install --project # ./<config-dir>/skills (not Codex — it has none)
|
|
38
|
+
remixmate install --dir <path> # explicit target, for a host not listed above
|
|
39
|
+
remixmate uninstall # remove exactly what was installed
|
|
31
40
|
```
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
The install is *managed*, not a `cp -R`: each skills directory gets a
|
|
43
|
+
`.remixmate-install.json` receipt recording the version and the skill list. That is
|
|
44
|
+
what lets a re-run upgrade in place, lets `uninstall` remove only our own directories,
|
|
45
|
+
and lets `remixmate doctor` warn when a global `npm update` has left the installed
|
|
46
|
+
copies behind. A same-named skill that this CLI did not install is never overwritten
|
|
47
|
+
without `--force`.
|
|
38
48
|
|
|
39
|
-
|
|
49
|
+
Without installing, the CLI still works — you just have to name it (`remixmate --list`,
|
|
50
|
+
or tell the agent to run `remixmate <skill> --help`). The agent will not reach for it
|
|
51
|
+
unprompted.
|
|
40
52
|
|
|
41
53
|
## Authentication
|
|
42
54
|
|
package/README.zh-CN.md
CHANGED
|
@@ -11,32 +11,39 @@
|
|
|
11
11
|
## 安装
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
npm install -g @remixmate/cli
|
|
15
|
-
remixmate --help
|
|
16
|
-
remixmate --list
|
|
14
|
+
npm install -g @remixmate/cli && remixmate install
|
|
17
15
|
```
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
`npm install` 装的是 `remixmate` 这个命令;`remixmate install` 才让 agent **自己发现**
|
|
18
|
+
这些 skill —— 它把内置的 `skills/` 铺进检测到的每个 agent 目录。下面这些宿主用的是
|
|
19
|
+
同一套 `SKILL.md` 格式,所以一份 `skills/` 全都能喂:
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
| 宿主 | 用户级 | 项目级 | 可用环境变量改位置 |
|
|
22
|
+
| --- | --- | --- | --- |
|
|
23
|
+
| Claude Code | `~/.claude/skills` | `./.claude/skills` | `CLAUDE_CONFIG_DIR` |
|
|
24
|
+
| Codex | `~/.codex/skills` | — | `CODEX_HOME` |
|
|
25
|
+
| WorkBuddy | `~/.workbuddy/skills` | `./.workbuddy/skills` | — |
|
|
26
|
+
| CodeBuddy | `~/.codebuddy/skills` | `./.codebuddy/skills` | — |
|
|
27
|
+
| Trae / TraeWork | — | `./.trae/skills` | — |
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
cp -R "$(npm root -g)/@remixmate/cli/skills/." .claude/skills/
|
|
29
|
+
Trae CN 与 TraeWork CN 共用 `~/.trae-cn`,且只定义了工作区位置(`.trae/skills/<name>/`,依据是它自带的 `skill-creator`),
|
|
30
|
+
所以只能按项目装 —— 直接跑 `remixmate install` 会提示你进项目目录加 `--project` 重跑。
|
|
31
|
+
装完重启 agent 生效。
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
```bash
|
|
34
|
+
remixmate install --host workbuddy # 只装某一个宿主
|
|
35
|
+
remixmate install --project # 装到 ./<配置目录>/skills(Codex 没有项目级目录)
|
|
36
|
+
remixmate install --dir <path> # 指定目录,用于上表之外的宿主
|
|
37
|
+
remixmate uninstall # 按装机记录精确卸载
|
|
31
38
|
```
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
> 当你需要 AI 媒体生成(图片 / 视频 / 语音 / 数字人 / 剪映导出)时,先运行 `remixmate <skill-id> --help` 查看参数,再用 `remixmate <skill-id> --json-output ...` 执行。可用技能:`remixmate --list`。
|
|
40
|
+
这里的安装是**受管**的,不是 `cp -R`:每个 skills 目录下会写一份
|
|
41
|
+
`.remixmate-install.json` 回执,记录版本与本次铺下去的 skill 名单。靠它,重跑即原地升级、
|
|
42
|
+
`uninstall` 只删自己装的目录、`remixmate doctor` 能在 `npm update -g` 之后提示铺出去的副本
|
|
43
|
+
已经落后。同名但不是本 CLI 装的 skill,不加 `--force` 绝不覆盖。
|
|
38
44
|
|
|
39
|
-
|
|
45
|
+
不装也能用,只是得点名(`remixmate --list`,或让 agent 去跑 `remixmate <skill> --help`);
|
|
46
|
+
agent 不会主动想到它。
|
|
40
47
|
|
|
41
48
|
## 认证
|
|
42
49
|
|
package/dist/cli.js
CHANGED
|
@@ -16,6 +16,7 @@ import { parseArgv } from './argv.js';
|
|
|
16
16
|
import { runSkill } from './runner.js';
|
|
17
17
|
import { runAuthCommand } from './auth/commands.js';
|
|
18
18
|
import { HOST_VERB, PROJECT_VERB, runHostCommand, runProjectCommand } from './project/commands.js';
|
|
19
|
+
import { INSTALL_VERB, UNINSTALL_VERB, runInstall, runUninstall } from './install.js';
|
|
19
20
|
import { runExec } from './exec.js';
|
|
20
21
|
import { authStatusLine, runDoctor } from './doctor.js';
|
|
21
22
|
import { padDisplay } from './text.js';
|
|
@@ -51,6 +52,8 @@ function printUsage() {
|
|
|
51
52
|
const skills = loadSkills(resolveBaseDir());
|
|
52
53
|
process.stdout.write('Usage:\n');
|
|
53
54
|
process.stdout.write(' remixmate --list List all skills\n');
|
|
55
|
+
process.stdout.write(' remixmate install [--host <h>] Install the skills into Claude Code / Codex\n');
|
|
56
|
+
process.stdout.write(' remixmate uninstall Remove skills installed by this CLI\n');
|
|
54
57
|
process.stdout.write(' remixmate doctor Diagnose environment, credentials, backend\n');
|
|
55
58
|
process.stdout.write(' remixmate login Authorize this CLI via the browser\n');
|
|
56
59
|
process.stdout.write(' remixmate login --start | --wait Non-blocking authorization (for agent hosts)\n');
|
|
@@ -128,6 +131,14 @@ async function main() {
|
|
|
128
131
|
await printAuthFooter();
|
|
129
132
|
process.exit(EXIT.OK);
|
|
130
133
|
}
|
|
134
|
+
// Host-install verbs, like the auth verbs, resolve before skill dispatch so a
|
|
135
|
+
// future skill named `install` could never shadow them.
|
|
136
|
+
if (argv[0] === INSTALL_VERB) {
|
|
137
|
+
process.exit(runInstall(argv.slice(1)));
|
|
138
|
+
}
|
|
139
|
+
if (argv[0] === UNINSTALL_VERB) {
|
|
140
|
+
process.exit(runUninstall(argv.slice(1)));
|
|
141
|
+
}
|
|
131
142
|
if (argv[0] === 'doctor') {
|
|
132
143
|
const code = await runDoctor({ skipNetwork: argv.includes('--offline') });
|
|
133
144
|
process.exit(code);
|
package/dist/doctor.js
CHANGED
|
@@ -20,6 +20,7 @@ import { listCredentials } from './auth/credential-store.js';
|
|
|
20
20
|
import { resolveTakeKey } from './project/host.js';
|
|
21
21
|
import { readBinding } from './project/store.js';
|
|
22
22
|
import { canAutoAuth, isHeadless } from './auth/environment.js';
|
|
23
|
+
import { installStates } from './install.js';
|
|
23
24
|
import { padDisplay } from './text.js';
|
|
24
25
|
/**
|
|
25
26
|
* Short auth status suitable for a footer. Never performs network I/O — a
|
|
@@ -100,6 +101,22 @@ export async function runDoctor(opts = {}) {
|
|
|
100
101
|
detail: playwright ?? '当前解释器下未安装 —— 仅 web-screenshot / web-record 需要,首次运行会自动装',
|
|
101
102
|
});
|
|
102
103
|
checks.push({ name: '后端地址', status: 'ok', detail: apiBaseUrl });
|
|
104
|
+
// 宿主安装状态。这套方案唯一的静默失败模式是漂移:`npm update -g` 只动包,不动
|
|
105
|
+
// 已经铺进 ~/.claude/skills、~/.codex/skills 的副本,用户会拿着旧 SKILL.md 打新
|
|
106
|
+
// 后端,而且第一个症状往往是某个参数「莫名其妙不认」。
|
|
107
|
+
for (const s of installStates()) {
|
|
108
|
+
checks.push({
|
|
109
|
+
// 只取宿主名的第一段(Claude Code → Claude)——检查名要留在 padDisplay 的
|
|
110
|
+
// 对齐宽度内,宿主目录已经写在 detail 里,不会有歧义。
|
|
111
|
+
name: `${s.label.split(' ')[0]} skill`,
|
|
112
|
+
status: s.installedVersion == null ? 'warn' : s.drifted ? 'warn' : 'ok',
|
|
113
|
+
detail: s.installedVersion == null
|
|
114
|
+
? `未安装 —— 该 agent 不会自动发现这些 skill(remixmate install 可安装到 ${s.skillsDir})`
|
|
115
|
+
: s.drifted
|
|
116
|
+
? `已装 ${s.installedVersion},当前包 ${s.currentVersion} → 运行 remixmate install 覆盖`
|
|
117
|
+
: `${s.installedVersion}(${s.skillsDir})`,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
103
120
|
// Where will this machine's renders land, and will repeated renders group?
|
|
104
121
|
// Both were previously invisible — the first sign of trouble was a finished
|
|
105
122
|
// video that appeared nowhere in the web app.
|
|
@@ -149,7 +166,9 @@ export async function runDoctor(opts = {}) {
|
|
|
149
166
|
if (!opts.skipNetwork)
|
|
150
167
|
checks.push(await checkBackend(apiBaseUrl));
|
|
151
168
|
for (const c of checks) {
|
|
152
|
-
|
|
169
|
+
// 16 而不是 14:宿主检查名最长是「WorkBuddy skill」,窄一格就会把那两行的
|
|
170
|
+
// detail 列顶出去,报告看起来像是漏了对齐。
|
|
171
|
+
process.stdout.write(`${ICON[c.status]} ${padDisplay(c.name, 16)}${c.detail}\n`);
|
|
153
172
|
}
|
|
154
173
|
const failed = checks.filter((c) => c.status === 'fail');
|
|
155
174
|
if (failed.length === 0) {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `remixmate install` / `remixmate uninstall` — 把包内 skills/ 铺进 agent 宿主。
|
|
3
|
+
*
|
|
4
|
+
* 为什么需要一条命令,而不是让站点给出 `cp -R "$(npm root -g)/…/skills/." ~/.claude/skills/`:
|
|
5
|
+
*
|
|
6
|
+
* 1. 目标已经不止一个。Claude Code 与 Codex 现在用同一套 SKILL.md 格式
|
|
7
|
+
* (Codex 装到 $CODEX_HOME/skills/<name>),手工 cp 的心智成本直接翻倍。
|
|
8
|
+
* 2. 拷贝出去的副本没有主人。`npm update -g` 之后包升了级、副本停在旧版;
|
|
9
|
+
* `npm uninstall -g` 之后副本原地变成孤儿。两种都是静默的 —— 本项目作者机器上
|
|
10
|
+
* 就留着一批 5 月建的、指向早已不存在路径的 skill 目录,没有任何东西负责清理。
|
|
11
|
+
*
|
|
12
|
+
* 所以这里的安装是**受管**的:每个宿主的 skills 目录下写一份装机回执
|
|
13
|
+
* (.remixmate-install.json),记下版本、来源与这次铺下去的 skill 名单。升级照名单
|
|
14
|
+
* 覆盖、卸载照名单删除、doctor 照名单比对版本 —— 三件事都不靠猜目录里哪些是我们的。
|
|
15
|
+
*
|
|
16
|
+
* 刻意不做的两件事:
|
|
17
|
+
* - 不挂 npm postinstall。`npm i -g` 时往 ~/.claude、~/.codex 写东西太越界,
|
|
18
|
+
* 且 `--ignore-scripts` 下会静默失效。安装必须是用户显式发起的动作。
|
|
19
|
+
* - 不用软链。指向 $(npm root -g) 看着优雅,但 node 版本管理器一切换路径就变,
|
|
20
|
+
* 全部断掉且极难排查。拷贝 + 回执 + doctor 漂移检查更稳。
|
|
21
|
+
*/
|
|
22
|
+
export declare const INSTALL_VERB = "install";
|
|
23
|
+
export declare const UNINSTALL_VERB = "uninstall";
|
|
24
|
+
export type HostId = 'claude' | 'codex' | 'workbuddy' | 'codebuddy' | 'trae';
|
|
25
|
+
interface Host {
|
|
26
|
+
id: HostId | 'custom';
|
|
27
|
+
label: string;
|
|
28
|
+
/** skill 的父目录 —— 安装写到 <skillsDir>/<skill-name>/。 */
|
|
29
|
+
skillsDir: string;
|
|
30
|
+
}
|
|
31
|
+
/** 已检测到、且**有用户级位置**的宿主。 */
|
|
32
|
+
export declare function detectHosts(): Host[];
|
|
33
|
+
/**
|
|
34
|
+
* 检测到了、但只能项目级安装的宿主(当前只有 Trae)。
|
|
35
|
+
*
|
|
36
|
+
* 单独拎出来是为了别把它们**静默**跳过:用户装了 Trae 却在全局 install 的输出里
|
|
37
|
+
* 完全看不到它,只会以为这个 CLI 不支持 —— 正是这次 WorkBuddy 的翻车方式。
|
|
38
|
+
*/
|
|
39
|
+
export declare function projectOnlyHosts(): HostId[];
|
|
40
|
+
export declare function installUsage(): void;
|
|
41
|
+
export declare function uninstallUsage(): void;
|
|
42
|
+
export declare function runInstall(argv: string[]): number;
|
|
43
|
+
export declare function runUninstall(argv: string[]): number;
|
|
44
|
+
export interface InstallState {
|
|
45
|
+
label: string;
|
|
46
|
+
skillsDir: string;
|
|
47
|
+
/** 回执里的版本;null = 该宿主下没有本 CLI 的安装。 */
|
|
48
|
+
installedVersion: string | null;
|
|
49
|
+
/** 当前包的版本,供报告直接引用。 */
|
|
50
|
+
currentVersion: string;
|
|
51
|
+
/** 回执版本与当前包版本不一致。 */
|
|
52
|
+
drifted: boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 供 doctor 使用:每个宿主的安装状态。
|
|
56
|
+
*
|
|
57
|
+
* 漂移是这套方案唯一的静默失败模式 —— `npm update -g` 只动包,不动铺出去的副本,
|
|
58
|
+
* 用户会拿着旧 SKILL.md 打新后端。doctor 是「为什么跑不起来」的统一入口,检查放这里。
|
|
59
|
+
*/
|
|
60
|
+
export declare function installStates(): InstallState[];
|
|
61
|
+
export {};
|
package/dist/install.js
ADDED
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `remixmate install` / `remixmate uninstall` — 把包内 skills/ 铺进 agent 宿主。
|
|
3
|
+
*
|
|
4
|
+
* 为什么需要一条命令,而不是让站点给出 `cp -R "$(npm root -g)/…/skills/." ~/.claude/skills/`:
|
|
5
|
+
*
|
|
6
|
+
* 1. 目标已经不止一个。Claude Code 与 Codex 现在用同一套 SKILL.md 格式
|
|
7
|
+
* (Codex 装到 $CODEX_HOME/skills/<name>),手工 cp 的心智成本直接翻倍。
|
|
8
|
+
* 2. 拷贝出去的副本没有主人。`npm update -g` 之后包升了级、副本停在旧版;
|
|
9
|
+
* `npm uninstall -g` 之后副本原地变成孤儿。两种都是静默的 —— 本项目作者机器上
|
|
10
|
+
* 就留着一批 5 月建的、指向早已不存在路径的 skill 目录,没有任何东西负责清理。
|
|
11
|
+
*
|
|
12
|
+
* 所以这里的安装是**受管**的:每个宿主的 skills 目录下写一份装机回执
|
|
13
|
+
* (.remixmate-install.json),记下版本、来源与这次铺下去的 skill 名单。升级照名单
|
|
14
|
+
* 覆盖、卸载照名单删除、doctor 照名单比对版本 —— 三件事都不靠猜目录里哪些是我们的。
|
|
15
|
+
*
|
|
16
|
+
* 刻意不做的两件事:
|
|
17
|
+
* - 不挂 npm postinstall。`npm i -g` 时往 ~/.claude、~/.codex 写东西太越界,
|
|
18
|
+
* 且 `--ignore-scripts` 下会静默失效。安装必须是用户显式发起的动作。
|
|
19
|
+
* - 不用软链。指向 $(npm root -g) 看着优雅,但 node 版本管理器一切换路径就变,
|
|
20
|
+
* 全部断掉且极难排查。拷贝 + 回执 + doctor 漂移检查更稳。
|
|
21
|
+
*/
|
|
22
|
+
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
23
|
+
import os from 'node:os';
|
|
24
|
+
import path from 'node:path';
|
|
25
|
+
import { fileURLToPath } from 'node:url';
|
|
26
|
+
import { SKILLS_DIR } from './registry.js';
|
|
27
|
+
import { EXIT } from './errors.js';
|
|
28
|
+
import { padDisplay } from './text.js';
|
|
29
|
+
export const INSTALL_VERB = 'install';
|
|
30
|
+
export const UNINSTALL_VERB = 'uninstall';
|
|
31
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
32
|
+
const PKG_ROOT = path.resolve(__dirname, '..');
|
|
33
|
+
/** 装机回执。升级 / 卸载 / 漂移检查都只认它。 */
|
|
34
|
+
const RECEIPT = '.remixmate-install.json';
|
|
35
|
+
const PACKAGE_NAME = '@remixmate/cli';
|
|
36
|
+
/**
|
|
37
|
+
* 支持的 agent 宿主。
|
|
38
|
+
*
|
|
39
|
+
* 共同点是 skill 的格式:`<某个目录>/skills/<name>/SKILL.md`,frontmatter 都是
|
|
40
|
+
* name + description —— 一份 skills/ 能喂给所有宿主。这张表记的是各家把那个「某个
|
|
41
|
+
* 目录」放在哪、能不能被环境变量改、有没有用户级 / 项目级。
|
|
42
|
+
*
|
|
43
|
+
* 每一条的依据:
|
|
44
|
+
* - Claude Code / Codex:各自的官方安装位置(Codex 见其内置 skill-installer,
|
|
45
|
+
* 原话是装到 $CODEX_HOME/skills)。
|
|
46
|
+
* - WorkBuddy / CodeBuddy:WorkBuddy 内置的 find-skills skill 给了两条路径,
|
|
47
|
+
* 它按 __CFBundleIdentifier 区分。这里不做那个区分 —— 检测到哪个装哪个,
|
|
48
|
+
* 两个都在就都装,比猜「当前跑在哪个客户端里」稳。
|
|
49
|
+
* - Trae:内置的 skill-creator skill 只给了一个位置 —— 工作区的
|
|
50
|
+
* `.trae/skills/<name>/`。注意它的应用数据目录叫 ~/.trae-cn(国内版),
|
|
51
|
+
* 跟 skill 目录名 .trae 不是一个东西,而且 ~/.trae-cn/skills 并不存在。
|
|
52
|
+
* 没有任何证据表明存在用户级位置,所以 userDirName 留空:Trae 只能项目级装。
|
|
53
|
+
*/
|
|
54
|
+
const HOSTS = [
|
|
55
|
+
{
|
|
56
|
+
id: 'claude',
|
|
57
|
+
label: 'Claude Code',
|
|
58
|
+
detectDirNames: ['.claude'],
|
|
59
|
+
homeEnv: 'CLAUDE_CONFIG_DIR',
|
|
60
|
+
userDirName: '.claude',
|
|
61
|
+
projectDirName: '.claude',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 'codex',
|
|
65
|
+
label: 'Codex',
|
|
66
|
+
detectDirNames: ['.codex'],
|
|
67
|
+
homeEnv: 'CODEX_HOME',
|
|
68
|
+
userDirName: '.codex',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'workbuddy',
|
|
72
|
+
label: 'WorkBuddy',
|
|
73
|
+
detectDirNames: ['.workbuddy'],
|
|
74
|
+
userDirName: '.workbuddy',
|
|
75
|
+
projectDirName: '.workbuddy',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: 'codebuddy',
|
|
79
|
+
label: 'CodeBuddy',
|
|
80
|
+
detectDirNames: ['.codebuddy'],
|
|
81
|
+
userDirName: '.codebuddy',
|
|
82
|
+
projectDirName: '.codebuddy',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: 'trae',
|
|
86
|
+
// Trae CN 与 TraeWork CN(安装出来叫 TRAE SOLO CN.app,bundle id cn.trae.solo.app)
|
|
87
|
+
// 共用 ~/.trae-cn —— 后者的内置 skill(dynamic-ui 等)就躺在那底下的
|
|
88
|
+
// builtin/*/skills/,所以一条 host 覆盖两个客户端。
|
|
89
|
+
label: 'Trae / TraeWork',
|
|
90
|
+
detectDirNames: ['.trae-cn', '.trae'],
|
|
91
|
+
projectDirName: '.trae',
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
const HOST_IDS = HOSTS.map((h) => h.id);
|
|
95
|
+
function spec(id) {
|
|
96
|
+
return HOSTS.find((h) => h.id === id);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 用户级 skills 目录;宿主没有用户级位置时返回 null。声明了环境变量的宿主要跟着
|
|
100
|
+
* 变量走 —— 否则把 CODEX_HOME 指到别处的用户会看到「未检测到 Codex」。
|
|
101
|
+
*/
|
|
102
|
+
function userSkillsDir(id) {
|
|
103
|
+
const h = spec(id);
|
|
104
|
+
if (!h.userDirName)
|
|
105
|
+
return null;
|
|
106
|
+
const override = h.homeEnv ? process.env[h.homeEnv] : undefined;
|
|
107
|
+
return path.join(override || path.join(os.homedir(), h.userDirName), 'skills');
|
|
108
|
+
}
|
|
109
|
+
/** 检测用的候选目录 —— 存在任意一个就算这台机器上装了这个 agent。 */
|
|
110
|
+
function detectDirs(id) {
|
|
111
|
+
const h = spec(id);
|
|
112
|
+
const override = h.homeEnv ? process.env[h.homeEnv] : undefined;
|
|
113
|
+
if (override)
|
|
114
|
+
return [override];
|
|
115
|
+
return h.detectDirNames.map((d) => path.join(os.homedir(), d));
|
|
116
|
+
}
|
|
117
|
+
function isInstalled(id) {
|
|
118
|
+
return detectDirs(id).some((d) => existsSync(d));
|
|
119
|
+
}
|
|
120
|
+
function hostOf(id) {
|
|
121
|
+
const dir = userSkillsDir(id);
|
|
122
|
+
return dir ? { id, label: spec(id).label, skillsDir: dir } : null;
|
|
123
|
+
}
|
|
124
|
+
/** 项目级安装目标:当前目录下的 ./<projectDirName>/skills。 */
|
|
125
|
+
function projectHostOf(id) {
|
|
126
|
+
const h = spec(id);
|
|
127
|
+
if (!h.projectDirName)
|
|
128
|
+
return null;
|
|
129
|
+
return {
|
|
130
|
+
id,
|
|
131
|
+
label: `${h.label}(项目级)`,
|
|
132
|
+
skillsDir: path.join(process.cwd(), h.projectDirName, 'skills'),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/** 已检测到、且**有用户级位置**的宿主。 */
|
|
136
|
+
export function detectHosts() {
|
|
137
|
+
return HOST_IDS.filter(isInstalled)
|
|
138
|
+
.map(hostOf)
|
|
139
|
+
.filter((h) => h !== null);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* 检测到了、但只能项目级安装的宿主(当前只有 Trae)。
|
|
143
|
+
*
|
|
144
|
+
* 单独拎出来是为了别把它们**静默**跳过:用户装了 Trae 却在全局 install 的输出里
|
|
145
|
+
* 完全看不到它,只会以为这个 CLI 不支持 —— 正是这次 WorkBuddy 的翻车方式。
|
|
146
|
+
*/
|
|
147
|
+
export function projectOnlyHosts() {
|
|
148
|
+
return HOST_IDS.filter((id) => isInstalled(id) && !spec(id).userDirName);
|
|
149
|
+
}
|
|
150
|
+
function packageVersion() {
|
|
151
|
+
try {
|
|
152
|
+
const raw = readFileSync(path.join(PKG_ROOT, 'package.json'), 'utf-8');
|
|
153
|
+
return JSON.parse(raw).version ?? 'unknown';
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
return 'unknown';
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* 包内可安装的 skill 名单。
|
|
161
|
+
*
|
|
162
|
+
* 用 SKILLS_DIR 而不是 resolveBaseDir():install 铺的永远是**本包自带**的那份,
|
|
163
|
+
* SKILL_BASE_DIR 是给 ab-agent 之类宿主在运行期改 skill 树用的,不该改变安装来源。
|
|
164
|
+
*/
|
|
165
|
+
function bundledSkills() {
|
|
166
|
+
if (!existsSync(SKILLS_DIR))
|
|
167
|
+
return [];
|
|
168
|
+
return readdirSync(SKILLS_DIR, { withFileTypes: true })
|
|
169
|
+
.filter((e) => e.isDirectory() && existsSync(path.join(SKILLS_DIR, e.name, 'SKILL.md')))
|
|
170
|
+
.map((e) => e.name)
|
|
171
|
+
.sort();
|
|
172
|
+
}
|
|
173
|
+
function readReceipt(skillsDir) {
|
|
174
|
+
const file = path.join(skillsDir, RECEIPT);
|
|
175
|
+
if (!existsSync(file))
|
|
176
|
+
return null;
|
|
177
|
+
try {
|
|
178
|
+
return JSON.parse(readFileSync(file, 'utf-8'));
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
// 回执损坏时按「没装过」处理:那样只会退化成需要 --force,而不是把用户的目录删错。
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const nonNull = (h) => h !== null;
|
|
186
|
+
function parseArgs(argv, verb) {
|
|
187
|
+
const out = { hosts: [], force: false, help: false };
|
|
188
|
+
const picked = [];
|
|
189
|
+
let all = false;
|
|
190
|
+
let dir = '';
|
|
191
|
+
let project = false;
|
|
192
|
+
for (let i = 0; i < argv.length; i++) {
|
|
193
|
+
const a = argv[i];
|
|
194
|
+
const eq = a.indexOf('=');
|
|
195
|
+
const key = eq > 0 ? a.slice(0, eq) : a;
|
|
196
|
+
const inline = eq > 0 ? a.slice(eq + 1) : null;
|
|
197
|
+
const next = () => inline ?? argv[++i] ?? '';
|
|
198
|
+
switch (key) {
|
|
199
|
+
case '--host': {
|
|
200
|
+
const v = next();
|
|
201
|
+
// `all` 是「所有**适用**的宿主」,不是「表里每一行」—— 展开成后者会让
|
|
202
|
+
// `--host all` 撞上 Trae 这种只有项目级的宿主而整条命令失败。
|
|
203
|
+
if (v === 'all')
|
|
204
|
+
all = true;
|
|
205
|
+
else if (HOST_IDS.includes(v))
|
|
206
|
+
picked.push(v);
|
|
207
|
+
else {
|
|
208
|
+
out.error = `未知参数: --host ${v}`;
|
|
209
|
+
return out;
|
|
210
|
+
}
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
case '--dir':
|
|
214
|
+
dir = next();
|
|
215
|
+
break;
|
|
216
|
+
case '--project':
|
|
217
|
+
project = true;
|
|
218
|
+
break;
|
|
219
|
+
case '--force':
|
|
220
|
+
out.force = true;
|
|
221
|
+
break;
|
|
222
|
+
case '-h':
|
|
223
|
+
case '--help':
|
|
224
|
+
out.help = true;
|
|
225
|
+
return out;
|
|
226
|
+
default:
|
|
227
|
+
out.error = `未知参数: ${a}`;
|
|
228
|
+
return out;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (dir) {
|
|
232
|
+
out.hosts = [{ id: 'custom', label: '自定义目录', skillsDir: path.resolve(dir) }];
|
|
233
|
+
return out;
|
|
234
|
+
}
|
|
235
|
+
if (project) {
|
|
236
|
+
// Codex 的官方安装位置只有 $CODEX_HOME/skills(见其内置 skill-installer),
|
|
237
|
+
// 没有项目级约定,不臆造一个 —— 点名 --host codex --project 直接报错,
|
|
238
|
+
// 不声不响装到一个宿主永远不会读的目录才是最糟的。
|
|
239
|
+
const chosen = all
|
|
240
|
+
? HOST_IDS.filter((id) => spec(id).projectDirName)
|
|
241
|
+
: picked.length > 0
|
|
242
|
+
? [...new Set(picked)]
|
|
243
|
+
: HOST_IDS.filter((id) => isInstalled(id) && spec(id).projectDirName);
|
|
244
|
+
const unsupported = chosen.filter((id) => !spec(id).projectDirName);
|
|
245
|
+
if (unsupported.length > 0) {
|
|
246
|
+
out.error = `${unsupported.map((id) => spec(id).label).join('、')} 没有项目级 skill 目录,不能和 --project 一起用`;
|
|
247
|
+
return out;
|
|
248
|
+
}
|
|
249
|
+
out.hosts = chosen.map(projectHostOf).filter(nonNull);
|
|
250
|
+
return out;
|
|
251
|
+
}
|
|
252
|
+
if (all) {
|
|
253
|
+
out.hosts = HOST_IDS.map(hostOf).filter(nonNull);
|
|
254
|
+
return out;
|
|
255
|
+
}
|
|
256
|
+
if (picked.length > 0) {
|
|
257
|
+
const chosen = [...new Set(picked)];
|
|
258
|
+
// 点名了一个只有项目级的宿主(Trae)却没给 --project:报错而不是默默装到别处。
|
|
259
|
+
const userless = chosen.filter((id) => !spec(id).userDirName);
|
|
260
|
+
if (userless.length > 0) {
|
|
261
|
+
out.error =
|
|
262
|
+
`${userless.map((id) => spec(id).label).join('、')} 只有项目级 skill 目录 —— ` +
|
|
263
|
+
'进到项目根目录后加 --project 重跑。';
|
|
264
|
+
return out;
|
|
265
|
+
}
|
|
266
|
+
out.hosts = chosen.map(hostOf).filter(nonNull);
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
// 卸载时不做检测:配置目录可能已经随 agent 一起被删掉,而我们铺出去的副本还在。
|
|
270
|
+
out.hosts = verb === UNINSTALL_VERB ? HOST_IDS.map(hostOf).filter(nonNull) : detectHosts();
|
|
271
|
+
}
|
|
272
|
+
return out;
|
|
273
|
+
}
|
|
274
|
+
export function installUsage() {
|
|
275
|
+
process.stdout.write('Usage: remixmate install [options]\n' +
|
|
276
|
+
'\n' +
|
|
277
|
+
'把本包自带的 skill 装进已检测到的 agent 宿主,让它们能自动发现这些能力。\n' +
|
|
278
|
+
'重复运行即升级。支持的宿主:\n' +
|
|
279
|
+
HOSTS.map((h) => ` ${padDisplay(h.label, 14)}${h.userDirName ? `~/${h.userDirName}/skills` : '(仅项目级)'}${h.projectDirName ? ` 项目级 ./${h.projectDirName}/skills` : ''}\n`).join('') +
|
|
280
|
+
'\n' +
|
|
281
|
+
'Options:\n' +
|
|
282
|
+
` --host <${HOST_IDS.join('|')}|all>\n` +
|
|
283
|
+
' 只装指定宿主(默认:装到所有检测到的宿主)\n' +
|
|
284
|
+
' --project 装到当前目录 ./<配置目录>/skills(Codex 不支持)\n' +
|
|
285
|
+
' --dir <path> 自定义 skills 父目录(覆盖上面两者)\n' +
|
|
286
|
+
' --force 覆盖同名的、非本 CLI 安装的 skill 目录\n');
|
|
287
|
+
}
|
|
288
|
+
export function uninstallUsage() {
|
|
289
|
+
process.stdout.write('Usage: remixmate uninstall [options]\n' +
|
|
290
|
+
'\n' +
|
|
291
|
+
'按装机回执删除本 CLI 装过的 skill —— 只删回执里列出的目录,不碰其它 skill。\n' +
|
|
292
|
+
'\n' +
|
|
293
|
+
'Options:\n' +
|
|
294
|
+
` --host <${HOST_IDS.join('|')}|all>\n` +
|
|
295
|
+
' 只卸载指定宿主(默认:所有宿主都查)\n' +
|
|
296
|
+
' --project 卸载当前目录 ./.claude/skills 下的安装\n' +
|
|
297
|
+
' --dir <path> 自定义 skills 父目录\n');
|
|
298
|
+
}
|
|
299
|
+
function installInto(host, names, version, force) {
|
|
300
|
+
const prev = readReceipt(host.skillsDir);
|
|
301
|
+
const owned = new Set(prev?.skills ?? []);
|
|
302
|
+
// 目录已存在、又不在上一次的回执里 —— 那是别人的 skill(同名很容易撞:gen-image
|
|
303
|
+
// 这种名字一点也不独特)。默认拒绝而不是覆盖,让用户显式 --force。
|
|
304
|
+
const conflicts = names.filter((n) => existsSync(path.join(host.skillsDir, n)) && !owned.has(n));
|
|
305
|
+
if (conflicts.length > 0 && !force) {
|
|
306
|
+
return (`${host.skillsDir} 下已存在同名目录,且不是本 CLI 装的:${conflicts.join('、')}\n` +
|
|
307
|
+
' 确认可以覆盖后加 --force 重跑。');
|
|
308
|
+
}
|
|
309
|
+
mkdirSync(host.skillsDir, { recursive: true });
|
|
310
|
+
// 上一版装过、这一版没有了的 skill(上游改名或下线)要一并清掉,否则宿主会一直
|
|
311
|
+
// 加载一个已经没有后端支撑的 SKILL.md。
|
|
312
|
+
for (const stale of owned) {
|
|
313
|
+
if (!names.includes(stale))
|
|
314
|
+
rmSync(path.join(host.skillsDir, stale), { recursive: true, force: true });
|
|
315
|
+
}
|
|
316
|
+
for (const name of names) {
|
|
317
|
+
const dest = path.join(host.skillsDir, name);
|
|
318
|
+
// 先删再拷:直接覆盖会把上一版多出来的文件留在原地,攒出一个既非旧版也非新版的目录。
|
|
319
|
+
rmSync(dest, { recursive: true, force: true });
|
|
320
|
+
cpSync(path.join(SKILLS_DIR, name), dest, { recursive: true });
|
|
321
|
+
}
|
|
322
|
+
const receipt = {
|
|
323
|
+
package: PACKAGE_NAME,
|
|
324
|
+
version,
|
|
325
|
+
installedAt: new Date().toISOString(),
|
|
326
|
+
source: SKILLS_DIR,
|
|
327
|
+
skills: names,
|
|
328
|
+
};
|
|
329
|
+
writeFileSync(path.join(host.skillsDir, RECEIPT), JSON.stringify(receipt, null, 2) + '\n', 'utf-8');
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
export function runInstall(argv) {
|
|
333
|
+
const opts = parseArgs(argv, INSTALL_VERB);
|
|
334
|
+
if (opts.help) {
|
|
335
|
+
installUsage();
|
|
336
|
+
return EXIT.OK;
|
|
337
|
+
}
|
|
338
|
+
if (opts.error) {
|
|
339
|
+
process.stderr.write(`❌ ${opts.error}\n`);
|
|
340
|
+
installUsage();
|
|
341
|
+
return EXIT.USAGE;
|
|
342
|
+
}
|
|
343
|
+
const names = bundledSkills();
|
|
344
|
+
if (names.length === 0) {
|
|
345
|
+
process.stderr.write(`❌ 包内没有可安装的 skill(${SKILLS_DIR})\n`);
|
|
346
|
+
return EXIT.ERROR;
|
|
347
|
+
}
|
|
348
|
+
const projectOnly = projectOnlyHosts();
|
|
349
|
+
if (opts.hosts.length === 0) {
|
|
350
|
+
// 只检测到项目级宿主(比如只装了 Trae)时,这不是「没检测到」,而是「装法不同」。
|
|
351
|
+
if (projectOnly.length > 0) {
|
|
352
|
+
process.stderr.write(`❌ 只检测到 ${projectOnly.map((id) => spec(id).label).join('、')},` +
|
|
353
|
+
'它只有项目级 skill 目录。\n' +
|
|
354
|
+
' 进到项目根目录后运行:remixmate install --project\n');
|
|
355
|
+
return EXIT.USAGE;
|
|
356
|
+
}
|
|
357
|
+
process.stderr.write('❌ 没有检测到任何 agent 宿主。找过这些位置:\n' +
|
|
358
|
+
HOST_IDS.map((id) => ` ${padDisplay(spec(id).label, 14)}${detectDirs(id).join('、')}\n`).join('') +
|
|
359
|
+
' 先把 agent 装好再重跑,或用 --dir <path> 指定目录。\n');
|
|
360
|
+
return EXIT.USAGE;
|
|
361
|
+
}
|
|
362
|
+
const version = packageVersion();
|
|
363
|
+
let failures = 0;
|
|
364
|
+
for (const host of opts.hosts) {
|
|
365
|
+
const err = installInto(host, names, version, opts.force);
|
|
366
|
+
if (err) {
|
|
367
|
+
failures += 1;
|
|
368
|
+
process.stderr.write(`❌ ${padDisplay(host.label, 16)}${err}\n`);
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
process.stdout.write(`✅ ${padDisplay(host.label, 16)}${host.skillsDir}(${names.length} 个 skill,${version})\n`);
|
|
372
|
+
}
|
|
373
|
+
if (failures > 0)
|
|
374
|
+
return EXIT.ERROR;
|
|
375
|
+
// 检测到了但这一轮装不了的宿主要说出来 —— 静默跳过会让用户以为不支持。
|
|
376
|
+
if (projectOnly.length > 0 && !opts.hosts.some((h) => projectOnly.includes(h.id))) {
|
|
377
|
+
process.stdout.write(`\nℹ️ 还检测到 ${projectOnly.map((id) => spec(id).label).join('、')},` +
|
|
378
|
+
'它只有项目级 skill 目录 —— 在项目根目录里运行 remixmate install --project 即可。\n');
|
|
379
|
+
}
|
|
380
|
+
process.stdout.write('\n重启 agent 后即可生效。升级后重跑 remixmate install 覆盖即可。\n');
|
|
381
|
+
return EXIT.OK;
|
|
382
|
+
}
|
|
383
|
+
export function runUninstall(argv) {
|
|
384
|
+
const opts = parseArgs(argv, UNINSTALL_VERB);
|
|
385
|
+
if (opts.help) {
|
|
386
|
+
uninstallUsage();
|
|
387
|
+
return EXIT.OK;
|
|
388
|
+
}
|
|
389
|
+
if (opts.error) {
|
|
390
|
+
process.stderr.write(`❌ ${opts.error}\n`);
|
|
391
|
+
uninstallUsage();
|
|
392
|
+
return EXIT.USAGE;
|
|
393
|
+
}
|
|
394
|
+
let removed = 0;
|
|
395
|
+
for (const host of opts.hosts) {
|
|
396
|
+
const receipt = readReceipt(host.skillsDir);
|
|
397
|
+
if (!receipt)
|
|
398
|
+
continue;
|
|
399
|
+
for (const name of receipt.skills) {
|
|
400
|
+
rmSync(path.join(host.skillsDir, name), { recursive: true, force: true });
|
|
401
|
+
}
|
|
402
|
+
rmSync(path.join(host.skillsDir, RECEIPT), { force: true });
|
|
403
|
+
removed += 1;
|
|
404
|
+
process.stdout.write(`✅ ${padDisplay(host.label, 16)}已移除 ${receipt.skills.length} 个 skill(${host.skillsDir})\n`);
|
|
405
|
+
}
|
|
406
|
+
if (removed === 0) {
|
|
407
|
+
process.stdout.write('没有找到本 CLI 的装机记录,无需卸载。\n');
|
|
408
|
+
}
|
|
409
|
+
return EXIT.OK;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* 供 doctor 使用:每个宿主的安装状态。
|
|
413
|
+
*
|
|
414
|
+
* 漂移是这套方案唯一的静默失败模式 —— `npm update -g` 只动包,不动铺出去的副本,
|
|
415
|
+
* 用户会拿着旧 SKILL.md 打新后端。doctor 是「为什么跑不起来」的统一入口,检查放这里。
|
|
416
|
+
*/
|
|
417
|
+
export function installStates() {
|
|
418
|
+
const current = packageVersion();
|
|
419
|
+
return detectHosts().map((h) => {
|
|
420
|
+
const receipt = readReceipt(h.skillsDir);
|
|
421
|
+
return {
|
|
422
|
+
label: h.label,
|
|
423
|
+
skillsDir: h.skillsDir,
|
|
424
|
+
installedVersion: receipt?.version ?? null,
|
|
425
|
+
currentVersion: current,
|
|
426
|
+
drifted: receipt != null && receipt.version !== current,
|
|
427
|
+
};
|
|
428
|
+
});
|
|
429
|
+
}
|
package/dist/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remixmate/cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.23",
|
|
4
4
|
"description": "AI media generation skills for Claude Code / Codex — 12 skills covering image, video, voice, digital human, web screenshot, web recording, script, template registry, rendering, Jianying export, and video deconstruction.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|