@sokeai/cli 1.0.14 → 1.0.17
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/scripts/install.js +55 -33
package/package.json
CHANGED
package/scripts/install.js
CHANGED
|
@@ -38,9 +38,12 @@ function copyDirRecursive(srcDir, destDir) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
function
|
|
41
|
+
function detectSokeclawWorkspaceSkillsDirs() {
|
|
42
42
|
const homeDir = os.homedir();
|
|
43
|
-
const
|
|
43
|
+
const dirs = [];
|
|
44
|
+
|
|
45
|
+
// 1. Sokeclaw 默认工作区
|
|
46
|
+
const defaultSokeclawDir = path.join(
|
|
44
47
|
homeDir,
|
|
45
48
|
'.sokeclaw',
|
|
46
49
|
'openai-agents',
|
|
@@ -49,19 +52,41 @@ function detectSokeclawWorkspaceSkillsDir() {
|
|
|
49
52
|
'skills'
|
|
50
53
|
);
|
|
51
54
|
|
|
55
|
+
// 2. Zev 默认工作区 (Sokeclaw 可能会生成这个)
|
|
56
|
+
const defaultZevDir = path.join(
|
|
57
|
+
homeDir,
|
|
58
|
+
'.zev',
|
|
59
|
+
'openai-agents',
|
|
60
|
+
'workspaces',
|
|
61
|
+
'main',
|
|
62
|
+
'skills'
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
// 3. 从 workclaw.json 读取配置
|
|
52
66
|
const workclawConfigPath = path.join(homeDir, '.sokeclaw', 'workclaw.json');
|
|
53
|
-
|
|
67
|
+
let configuredDir = null;
|
|
68
|
+
if (fs.existsSync(workclawConfigPath)) {
|
|
69
|
+
try {
|
|
70
|
+
const configText = fs.readFileSync(workclawConfigPath, 'utf8');
|
|
71
|
+
const config = JSON.parse(configText);
|
|
72
|
+
const workspaceDir = config?.defaults?.agents?.openaiAgents?.main?.workspace;
|
|
73
|
+
if (typeof workspaceDir === 'string' && workspaceDir.length > 0) {
|
|
74
|
+
configuredDir = path.join(workspaceDir, 'skills');
|
|
75
|
+
}
|
|
76
|
+
} catch (_) {}
|
|
77
|
+
}
|
|
54
78
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
79
|
+
// 收集所有有效的潜在目录
|
|
80
|
+
if (configuredDir) {
|
|
81
|
+
dirs.push(configuredDir);
|
|
82
|
+
} else {
|
|
83
|
+
dirs.push(defaultSokeclawDir);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// 始终将 .zev 目录也加入同步列表
|
|
87
|
+
dirs.push(defaultZevDir);
|
|
63
88
|
|
|
64
|
-
return
|
|
89
|
+
return dirs;
|
|
65
90
|
}
|
|
66
91
|
|
|
67
92
|
function syncSkillsToSokeclawWorkspace() {
|
|
@@ -69,22 +94,21 @@ function syncSkillsToSokeclawWorkspace() {
|
|
|
69
94
|
const packagedSkillsDir = path.join(packageRoot, 'skills');
|
|
70
95
|
if (!fs.existsSync(packagedSkillsDir)) return;
|
|
71
96
|
|
|
72
|
-
const
|
|
73
|
-
const sokeclawRootDir = path.join(os.homedir(), '.sokeclaw');
|
|
74
|
-
if (!fs.existsSync(sokeclawRootDir)) return;
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
fs.mkdirSync(sokeclawSkillsDir, { recursive: true });
|
|
78
|
-
} catch (_) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
97
|
+
const targetDirs = detectSokeclawWorkspaceSkillsDirs();
|
|
82
98
|
const skillNames = ['soke-shared', 'soke-exam'];
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
99
|
+
|
|
100
|
+
for (const targetDir of targetDirs) {
|
|
101
|
+
try {
|
|
102
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
103
|
+
for (const skillName of skillNames) {
|
|
104
|
+
const src = path.join(packagedSkillsDir, skillName);
|
|
105
|
+
const dest = path.join(targetDir, skillName);
|
|
106
|
+
if (fs.existsSync(src)) {
|
|
107
|
+
copyDirRecursive(src, dest);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} catch (_) {
|
|
111
|
+
// 忽略单个目录的写入失败
|
|
88
112
|
}
|
|
89
113
|
}
|
|
90
114
|
}
|
|
@@ -278,13 +302,11 @@ async function maybeAssistGuiPath() {
|
|
|
278
302
|
const { spawn } = require('child_process');
|
|
279
303
|
const child = spawn(process.execPath, [runJsPath, 'setup-gui-env', '--silent'], {
|
|
280
304
|
stdio: 'ignore', // 静默执行,不污染 npm install 输出
|
|
281
|
-
detached: true
|
|
305
|
+
detached: true // 允许子进程独立于父进程运行
|
|
282
306
|
});
|
|
283
|
-
|
|
284
|
-
child.
|
|
285
|
-
|
|
286
|
-
// 避免卡住
|
|
287
|
-
setTimeout(() => resolve(), 3000);
|
|
307
|
+
// 断开与子进程的联系,让它在后台自己跑,不阻塞 npm 安装退出
|
|
308
|
+
child.unref();
|
|
309
|
+
resolve();
|
|
288
310
|
} catch (e) {
|
|
289
311
|
resolve();
|
|
290
312
|
}
|