@aiyiran/myclaw 1.0.90 → 1.0.91
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/package.json +1 -1
- package/patch-skill.js +30 -32
package/package.json
CHANGED
package/patch-skill.js
CHANGED
|
@@ -20,45 +20,43 @@ const path = require('path');
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* 探测 OpenClaw 的 skills 目录
|
|
23
|
+
* 优先使用 ~/.openclaw/skills/(标准路径),不存在则自动创建
|
|
23
24
|
*/
|
|
24
25
|
function findSkillsDir() {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
const
|
|
29
|
-
'/usr/lib/node_modules',
|
|
30
|
-
'/usr/local/lib/node_modules',
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
const { execSync } = require('child_process');
|
|
35
|
-
const prefix = execSync('npm config get prefix 2>/dev/null', { encoding: 'utf8' }).trim();
|
|
36
|
-
if (prefix) {
|
|
37
|
-
globalPaths.push(path.join(prefix, 'lib', 'node_modules'));
|
|
38
|
-
}
|
|
39
|
-
} catch {}
|
|
26
|
+
const os = require('os');
|
|
27
|
+
|
|
28
|
+
// 候选根目录(跟 find-config.js 一致的查找逻辑)
|
|
29
|
+
const openclawRoots = [];
|
|
40
30
|
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
// 1. 环境变量优先
|
|
32
|
+
if (process.env.OPENCLAW_HOME) {
|
|
33
|
+
openclawRoots.push(process.env.OPENCLAW_HOME);
|
|
43
34
|
}
|
|
44
35
|
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
candidates.push(path.join(pkgRoot, 'skills'));
|
|
53
|
-
candidates.push(path.join(path.dirname(pkgRoot), 'skills'));
|
|
54
|
-
}
|
|
55
|
-
} catch {}
|
|
36
|
+
// 2. 标准路径 ~/.openclaw/
|
|
37
|
+
openclawRoots.push(path.join(os.homedir(), '.openclaw'));
|
|
38
|
+
|
|
39
|
+
// 3. WSL 下 /root/.openclaw/
|
|
40
|
+
if (os.platform() === 'linux') {
|
|
41
|
+
openclawRoots.push(path.join('/root', '.openclaw'));
|
|
42
|
+
}
|
|
56
43
|
|
|
57
|
-
// 找到第一个存在的
|
|
58
|
-
for (const
|
|
44
|
+
// 找到第一个存在的 .openclaw 根目录
|
|
45
|
+
for (const root of openclawRoots) {
|
|
59
46
|
try {
|
|
60
|
-
if (fs.existsSync(
|
|
61
|
-
|
|
47
|
+
if (fs.existsSync(root) && fs.statSync(root).isDirectory()) {
|
|
48
|
+
const skillsDir = path.join(root, 'skills');
|
|
49
|
+
// 如果 skills 目录不存在,试探性创建
|
|
50
|
+
if (!fs.existsSync(skillsDir)) {
|
|
51
|
+
try {
|
|
52
|
+
fs.mkdirSync(skillsDir, { recursive: true });
|
|
53
|
+
console.log('[myclaw-skill] 📁 已创建 skills 目录: ' + skillsDir);
|
|
54
|
+
} catch (err) {
|
|
55
|
+
console.log('[myclaw-skill] ⚠️ 无法创建 skills 目录: ' + err.message);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return skillsDir;
|
|
62
60
|
}
|
|
63
61
|
} catch {}
|
|
64
62
|
}
|