@sokeai/cli 1.0.15 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/install.js +51 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sokeai/cli",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "授客AI官方CLI工具 - 支持AI Agent Skills",
5
5
  "bin": {
6
6
  "soke-cli": "scripts/run.js"
@@ -38,9 +38,12 @@ function copyDirRecursive(srcDir, destDir) {
38
38
  }
39
39
  }
40
40
 
41
- function detectSokeclawWorkspaceSkillsDir() {
41
+ function detectSokeclawWorkspaceSkillsDirs() {
42
42
  const homeDir = os.homedir();
43
- const defaultSkillsDir = path.join(
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
- if (!fs.existsSync(workclawConfigPath)) return defaultSkillsDir;
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
- try {
56
- const configText = fs.readFileSync(workclawConfigPath, 'utf8');
57
- const config = JSON.parse(configText);
58
- const workspaceDir = config?.defaults?.agents?.openaiAgents?.main?.workspace;
59
- if (typeof workspaceDir === 'string' && workspaceDir.length > 0) {
60
- return path.join(workspaceDir, 'skills');
61
- }
62
- } catch (_) {}
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 defaultSkillsDir;
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 sokeclawSkillsDir = detectSokeclawWorkspaceSkillsDir();
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
- for (const skillName of skillNames) {
84
- const src = path.join(packagedSkillsDir, skillName);
85
- const dest = path.join(sokeclawSkillsDir, skillName);
86
- if (fs.existsSync(src)) {
87
- copyDirRecursive(src, dest);
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
  }