@coolclaw/coolclaw-skills 1.0.6 → 1.0.7
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/dist/install.js
CHANGED
|
@@ -17,6 +17,14 @@ import { fileURLToPath } from "url";
|
|
|
17
17
|
var SKILL_SET_DIR = "coolclaw";
|
|
18
18
|
var META_FILENAME = "_meta.json";
|
|
19
19
|
function getOpenClawHome() {
|
|
20
|
+
if (process.env.OPENCLAW_HOME) {
|
|
21
|
+
return path.resolve(process.env.OPENCLAW_HOME);
|
|
22
|
+
}
|
|
23
|
+
const cwdParts = path.resolve(process.cwd()).split(path.sep);
|
|
24
|
+
const workspaceIndex = cwdParts.lastIndexOf("workspace");
|
|
25
|
+
if (workspaceIndex > 0) {
|
|
26
|
+
return cwdParts.slice(0, workspaceIndex).join(path.sep) || path.sep;
|
|
27
|
+
}
|
|
20
28
|
if (process.platform === "win32") {
|
|
21
29
|
const appData = process.env.APPDATA || path.join(homedir(), "AppData", "Roaming");
|
|
22
30
|
return path.join(appData, "openclaw");
|
package/package.json
CHANGED
|
@@ -84,10 +84,35 @@ npx -y @coolclaw/coolclaw-cli@latest upgrade
|
|
|
84
84
|
```bash
|
|
85
85
|
openclaw plugins update @coolclaw/coolclaw
|
|
86
86
|
|
|
87
|
+
# 先解析实际 OpenClaw Home:环境变量优先,其次从当前 workspace 反推,最后用平台默认路径。
|
|
88
|
+
if [ -z "$OPENCLAW_HOME" ]; then
|
|
89
|
+
CWD_REAL="$(pwd -P)"
|
|
90
|
+
case "$CWD_REAL" in
|
|
91
|
+
*/workspace|*/workspace/*) OPENCLAW_HOME="${CWD_REAL%%/workspace*}" ;;
|
|
92
|
+
esac
|
|
93
|
+
fi
|
|
94
|
+
OPENCLAW_HOME="${OPENCLAW_HOME:-$HOME/.openclaw}"
|
|
95
|
+
|
|
96
|
+
# 优先使用 OpenClaw 5.x projects 布局中的实际安装目录。
|
|
97
|
+
PLUGIN_SRC=""
|
|
98
|
+
for pkg in "$OPENCLAW_HOME"/npm/projects/*/node_modules/@coolclaw/coolclaw/package.json; do
|
|
99
|
+
if [ -f "$pkg" ]; then
|
|
100
|
+
PLUGIN_SRC="$(dirname "$pkg")"
|
|
101
|
+
break
|
|
102
|
+
fi
|
|
103
|
+
done
|
|
104
|
+
|
|
105
|
+
# 若不存在,再尝试旧版 npm/node_modules 布局。
|
|
106
|
+
if [ -z "$PLUGIN_SRC" ] && [ -d "$OPENCLAW_HOME/npm/node_modules/@coolclaw/coolclaw" ]; then
|
|
107
|
+
PLUGIN_SRC="$OPENCLAW_HOME/npm/node_modules/@coolclaw/coolclaw"
|
|
108
|
+
fi
|
|
109
|
+
|
|
110
|
+
test -n "$PLUGIN_SRC"
|
|
111
|
+
|
|
87
112
|
rsync -a --delete \
|
|
88
113
|
--exclude=node_modules \
|
|
89
|
-
"
|
|
90
|
-
"
|
|
114
|
+
"$PLUGIN_SRC/" \
|
|
115
|
+
"$OPENCLAW_HOME/extensions/coolclaw/"
|
|
91
116
|
```
|
|
92
117
|
|
|
93
118
|
没有 `rsync` 时,只复制插件目录中除 `node_modules` 以外的内容到 `<OPENCLAW_HOME>/extensions/coolclaw/`。
|
|
@@ -230,6 +255,8 @@ openclaw gateway restart
|
|
|
230
255
|
|
|
231
256
|
## 路径约定
|
|
232
257
|
|
|
258
|
+
`<OPENCLAW_HOME>` 必须先按以下顺序解析:已设置的 `OPENCLAW_HOME` 环境变量 → 当前工作目录若位于 `<OPENCLAW_HOME>/workspace` 则反推父目录 → 平台默认路径。
|
|
259
|
+
|
|
233
260
|
| 平台 | COOLCLAW_CONFIG_DIR | OPENCLAW_HOME |
|
|
234
261
|
|------|---------------------|---------------|
|
|
235
262
|
| macOS / Linux | `~/.config/coolclaw` | `~/.openclaw` |
|
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
- Token 文件:`<COOLCLAW_CONFIG_DIR>/agent_token_<agentId>.txt`
|
|
25
25
|
- OpenClaw 配置:`<OPENCLAW_HOME>/openclaw.json`
|
|
26
26
|
|
|
27
|
+
`<OPENCLAW_HOME>` 必须先按以下顺序解析:已设置的 `OPENCLAW_HOME` 环境变量 → 当前工作目录若位于 `<OPENCLAW_HOME>/workspace` 则反推父目录 → 平台默认路径。
|
|
28
|
+
|
|
27
29
|
| 平台 | COOLCLAW_CONFIG_DIR | OPENCLAW_HOME |
|
|
28
30
|
|------|---------------------|---------------|
|
|
29
31
|
| macOS / Linux | `~/.config/coolclaw` | `~/.openclaw` |
|
|
@@ -131,7 +133,7 @@ npx -y @coolclaw/coolclaw-cli@latest install
|
|
|
131
133
|
|
|
132
134
|
> Windows CMD 用 `npx.cmd ...`;PowerShell 直接 `npx`。CLI 只做 OpenClaw 版本检测 + `openclaw plugins install @coolclaw/coolclaw` + 必要的 5.x `extensions/` 镜像 + 刷新 registry,**不**注册、**不**重启 gateway。
|
|
133
135
|
>
|
|
134
|
-
> 5.x 布局下 `plugins install` 会写入 `<OPENCLAW_HOME>/npm/node_modules/@coolclaw/coolclaw
|
|
136
|
+
> 5.x 布局下 `plugins install` 会写入 `<OPENCLAW_HOME>/npm/` 下的 npm 安装目录;不同 OpenClaw 版本可能是 `<OPENCLAW_HOME>/npm/node_modules/@coolclaw/coolclaw/`,也可能是 `<OPENCLAW_HOME>/npm/projects/<project>/node_modules/@coolclaw/coolclaw/`。部分 OpenClaw channel discovery 路径仍依赖 `<OPENCLAW_HOME>/extensions/coolclaw/` 发现 channel。必须依赖 `coolclaw-cli` 的幂等镜像逻辑同步到 `extensions/`,且排除 `node_modules`,避免 OpenClaw peer auto-symlink 触发 self-copy。
|
|
135
137
|
|
|
136
138
|
安装失败 → 把 CLI stderr 原样给用户并停止。成功 → 进入 Step 4。
|
|
137
139
|
|
|
@@ -144,7 +146,7 @@ npx -y @coolclaw/coolclaw-cli@latest install
|
|
|
144
146
|
做版本检测:
|
|
145
147
|
|
|
146
148
|
1. **本机版本**:先 `openclaw plugins list --json`,从输出中找 id `coolclaw` 或 `@coolclaw/coolclaw` 取 `version`。命令不被支持时 fallback 读以下任一 `package.json`(优先用文件读能力):
|
|
147
|
-
- 5.x
|
|
149
|
+
- 5.x:优先检查 `<OPENCLAW_HOME>/extensions/coolclaw/package.json`(这是当前实际加载与版本展示路径);若需要确认 npm 安装缓存,再检查 `<OPENCLAW_HOME>/npm/projects/*/node_modules/@coolclaw/coolclaw/package.json` 或 `<OPENCLAW_HOME>/npm/node_modules/@coolclaw/coolclaw/package.json`
|
|
148
150
|
- 4.x:`<OPENCLAW_HOME>/extensions/coolclaw/package.json`
|
|
149
151
|
2. **registry 最新版**:`npm view @coolclaw/coolclaw version`。
|
|
150
152
|
3. 任一查询失败 → 跳过比较,按“已是最新”分支处理,不阻塞流程。
|
|
@@ -167,12 +169,36 @@ openclaw plugins update @coolclaw/coolclaw
|
|
|
167
169
|
>
|
|
168
170
|
> 老 binding/token 不受影响。
|
|
169
171
|
|
|
170
|
-
升级成功后**必做:5.x 布局兜底**:`plugins update` 在 5.x 只更新 `<OPENCLAW_HOME>/npm
|
|
171
|
-
|
|
172
|
-
- 检查 `<OPENCLAW_HOME>/npm/node_modules/@coolclaw/coolclaw
|
|
173
|
-
-
|
|
174
|
-
-
|
|
175
|
-
|
|
172
|
+
升级成功后**必做:5.x 布局兜底**:`plugins update` 在 5.x 只更新 `<OPENCLAW_HOME>/npm/` 下的实际 npm 安装目录,不一定会同步到部分 OpenClaw channel discovery 路径所需的 `<OPENCLAW_HOME>/extensions/coolclaw/`,导致后续 channel 发现或手动恢复路径仍可能拿到旧代码。
|
|
173
|
+
|
|
174
|
+
- 检查 npm 安装源目录是否存在:优先 `<OPENCLAW_HOME>/npm/projects/*/node_modules/@coolclaw/coolclaw/`,再尝试 `<OPENCLAW_HOME>/npm/node_modules/@coolclaw/coolclaw/`。
|
|
175
|
+
- 找到源目录后镜像到 `<OPENCLAW_HOME>/extensions/coolclaw/`,**必须排除 `node_modules`**,避免 OpenClaw peer auto-symlink 触发 `Cannot copy X to a subdirectory of self`。
|
|
176
|
+
- macOS / Linux 推荐:
|
|
177
|
+
```bash
|
|
178
|
+
# 先解析实际 OpenClaw Home:环境变量优先,其次从当前 workspace 反推,最后用平台默认路径。
|
|
179
|
+
if [ -z "$OPENCLAW_HOME" ]; then
|
|
180
|
+
CWD_REAL="$(pwd -P)"
|
|
181
|
+
case "$CWD_REAL" in
|
|
182
|
+
*/workspace|*/workspace/*) OPENCLAW_HOME="${CWD_REAL%%/workspace*}" ;;
|
|
183
|
+
esac
|
|
184
|
+
fi
|
|
185
|
+
OPENCLAW_HOME="${OPENCLAW_HOME:-$HOME/.openclaw}"
|
|
186
|
+
|
|
187
|
+
PLUGIN_SRC=""
|
|
188
|
+
for pkg in "$OPENCLAW_HOME"/npm/projects/*/node_modules/@coolclaw/coolclaw/package.json; do
|
|
189
|
+
if [ -f "$pkg" ]; then
|
|
190
|
+
PLUGIN_SRC="$(dirname "$pkg")"
|
|
191
|
+
break
|
|
192
|
+
fi
|
|
193
|
+
done
|
|
194
|
+
if [ -z "$PLUGIN_SRC" ] && [ -d "$OPENCLAW_HOME/npm/node_modules/@coolclaw/coolclaw" ]; then
|
|
195
|
+
PLUGIN_SRC="$OPENCLAW_HOME/npm/node_modules/@coolclaw/coolclaw"
|
|
196
|
+
fi
|
|
197
|
+
test -n "$PLUGIN_SRC"
|
|
198
|
+
rsync -a --delete --exclude=node_modules "$PLUGIN_SRC/" "$OPENCLAW_HOME/extensions/coolclaw/"
|
|
199
|
+
```
|
|
200
|
+
- 无 `rsync` 时:只复制源目录第一层中非 `node_modules` 的文件/目录。
|
|
201
|
+
- Windows PowerShell:优先从 `<OPENCLAW_HOME>\npm\projects\*\node_modules\@coolclaw\coolclaw` 找源目录,再执行 `robocopy "<PLUGIN_SRC>" "<OPENCLAW_HOME>\extensions\coolclaw" /E /XD node_modules`。
|
|
176
202
|
- 不存在(4.x 布局,`update` 直接改 extensions/)→ 跳过。
|
|
177
203
|
- 同步失败 → 告知用户「插件文件已更新但 extensions/ 同步失败,可能仍加载旧版本,请手动重装」并停止。
|
|
178
204
|
|