@sokeai/cli 1.0.8 → 1.0.11

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sokeai/cli",
3
- "version": "1.0.8",
3
+ "version": "1.0.11",
4
4
  "description": "授客AI官方CLI工具 - 支持AI Agent Skills",
5
5
  "bin": {
6
6
  "soke-cli": "scripts/run.js"
@@ -88,6 +88,106 @@ function syncSkillsToSokeclawWorkspace() {
88
88
  }
89
89
  }
90
90
 
91
+ function upsertSkillRegistryEntry(registry, entry) {
92
+ if (!registry || typeof registry !== 'object') return;
93
+ if (!Array.isArray(registry.skills)) registry.skills = [];
94
+
95
+ const idx = registry.skills.findIndex((s) => s && s.id === entry.id);
96
+ if (idx >= 0) {
97
+ registry.skills[idx] = { ...registry.skills[idx], ...entry };
98
+ return;
99
+ }
100
+
101
+ registry.skills.push(entry);
102
+ }
103
+
104
+ function syncSkillsToWorkclawRegistry() {
105
+ const homeDir = os.homedir();
106
+ const workclawRootDir = path.join(homeDir, '.workclaw');
107
+ const workclawSkillsDir = path.join(workclawRootDir, 'skills');
108
+ const registryPath = path.join(workclawSkillsDir, 'registry.json');
109
+
110
+ if (!fs.existsSync(workclawRootDir)) return;
111
+ try {
112
+ fs.mkdirSync(workclawSkillsDir, { recursive: true });
113
+ } catch (_) {
114
+ return;
115
+ }
116
+
117
+ const packageRoot = path.join(__dirname, '..');
118
+ const packagedSkillsDir = path.join(packageRoot, 'skills');
119
+ if (!fs.existsSync(packagedSkillsDir)) return;
120
+
121
+ let registry;
122
+ try {
123
+ registry = JSON.parse(fs.readFileSync(registryPath, 'utf8'));
124
+ } catch (_) {
125
+ registry = { version: 1, migrations: {}, skills: [] };
126
+ }
127
+
128
+ if (registry.version == null) registry.version = 1;
129
+ if (!registry.migrations) registry.migrations = {};
130
+
131
+ const existingSkills = Array.isArray(registry.skills) ? registry.skills : [];
132
+ const existingInstallPaths = existingSkills
133
+ .map((s) => s?.install?.path)
134
+ .filter((p) => typeof p === 'string');
135
+
136
+ const workclawSkillInstallDir = workclawSkillsDir;
137
+
138
+ const defaultSourceType =
139
+ typeof existingSkills[0]?.source?.type === 'string' && existingSkills[0]?.source?.type
140
+ ? existingSkills[0].source.type
141
+ : 'local';
142
+
143
+ const skillNames = ['soke-shared', 'soke-exam'];
144
+ for (const skillName of skillNames) {
145
+ const src = path.join(packagedSkillsDir, skillName);
146
+ const dest = path.join(workclawSkillInstallDir, skillName);
147
+ if (fs.existsSync(src)) copyDirRecursive(src, dest);
148
+ }
149
+
150
+ upsertSkillRegistryEntry(registry, {
151
+ id: 'skill:soke-exam',
152
+ name: 'soke-exam',
153
+ displayName: '授客考试管理',
154
+ description: '授客考试管理:查询考试、考试分类、考试用户成绩、考试详情。',
155
+ source: { type: defaultSourceType, slug: '', url: '' },
156
+ install: {
157
+ path: path.join(workclawSkillInstallDir, 'soke-exam'),
158
+ installedAt: '',
159
+ updatedAt: '',
160
+ version: '1.0.0'
161
+ },
162
+ state: { enabled: true, health: 'ok', lastError: '' },
163
+ runtime: { supported: ['openclaw'], enabled: ['openclaw'], primary: 'openclaw' },
164
+ security: { riskLevel: 'normal', requiresApproval: false },
165
+ metadata: { emoji: '📝', homepage: '', requires: { bins: ['soke-cli'] } }
166
+ });
167
+
168
+ upsertSkillRegistryEntry(registry, {
169
+ id: 'skill:soke-shared',
170
+ name: 'soke-shared',
171
+ displayName: 'soke-shared 共享规则',
172
+ description: '授客CLI共享基础:配置、登录、权限管理、错误处理、安全规则。',
173
+ source: { type: defaultSourceType, slug: '', url: '' },
174
+ install: {
175
+ path: path.join(workclawSkillInstallDir, 'soke-shared'),
176
+ installedAt: '',
177
+ updatedAt: '',
178
+ version: '1.0.0'
179
+ },
180
+ state: { enabled: true, health: 'ok', lastError: '' },
181
+ runtime: { supported: ['openclaw'], enabled: ['openclaw'], primary: 'openclaw' },
182
+ security: { riskLevel: 'normal', requiresApproval: false },
183
+ metadata: { emoji: '🔧', homepage: '', requires: {} }
184
+ });
185
+
186
+ try {
187
+ fs.writeFileSync(registryPath, JSON.stringify(registry, null, 2));
188
+ } catch (_) {}
189
+ }
190
+
91
191
  // 平台映射
92
192
  const platformMap = {
93
193
  'darwin': 'darwin',
@@ -193,6 +293,10 @@ downloadFile(downloadURL, binaryPath)
193
293
  syncSkillsToSokeclawWorkspace();
194
294
  } catch (_) {}
195
295
 
296
+ try {
297
+ syncSkillsToWorkclawRegistry();
298
+ } catch (_) {}
299
+
196
300
  console.log('soke-cli 安装成功!');
197
301
  console.log(`二进制文件位置: ${binaryPath}`);
198
302
  console.log('\n使用方法:');
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  name: soke-exam
3
+ summary: 授客考试管理(考试列表/分类/考试用户成绩/详情),通过 soke-cli 查询
3
4
  version: 1.0.0
4
5
  description: "授客考试管理:查询考试、考试用户和成绩。查询考试列表、考试分类、考试用户成绩、考试详情。当用户需要查询考试成绩、查看考试列表、查询考试用户信息、查看考试分类时使用。"
5
6
  metadata:
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  name: soke-shared
3
+ summary: 授客CLI共享基础(配置/登录/权限/错误处理/安全规则)
3
4
  version: 1.0.0
4
5
  description: "授客CLI共享基础:应用配置初始化、认证登录(auth login)、权限管理、错误处理、安全规则。当用户需要第一次配置(soke-cli config init)、使用登录授权(soke-cli auth login)、遇到权限不足、或首次使用soke-cli时触发。"
5
6
  ---