@yizhuan-cli/cli 0.1.10-beta.1 → 0.1.10

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/README.md CHANGED
@@ -7,13 +7,13 @@
7
7
  需要 Node.js 22 或更高版本。
8
8
 
9
9
  ```bash
10
- npm install -g @yizhuan-cli/cli@0.1.10-beta.1
10
+ npm install -g @yizhuan-cli/cli@0.1.10
11
11
  ```
12
12
 
13
13
  如果发布在私有 npm registry,请加上对应 registry:
14
14
 
15
15
  ```bash
16
- npm install -g @yizhuan-cli/cli@0.1.10-beta.1 --registry=https://your-private-registry.example
16
+ npm install -g @yizhuan-cli/cli@0.1.10 --registry=https://your-private-registry.example
17
17
  ```
18
18
 
19
19
  ## 配置
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yizhuan-cli/cli",
3
- "version": "0.1.10-beta.1",
3
+ "version": "0.1.10",
4
4
  "description": "易撰命令行工具,用于通过 API Key 查询易撰真实数据。",
5
5
  "private": false,
6
6
  "type": "module",
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "name": "yizhuan-cli",
4
- "version": "0.1.10-beta.1",
5
- "compatibleCliVersion": "0.1.10-beta.1",
6
- "source": "npm:@yizhuan-cli/cli@0.1.10-beta.1",
4
+ "version": "0.1.10",
5
+ "compatibleCliVersion": "0.1.10",
6
+ "source": "npm:@yizhuan-cli/cli@0.1.10",
7
7
  "digestAlgorithm": "sha256",
8
8
  "files": [
9
9
  {
package/src/doctor.js CHANGED
@@ -17,6 +17,7 @@ const STATUS_LABELS = {
17
17
 
18
18
  const CLI_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
19
19
  const PACKAGE_PATH = path.join(CLI_DIR, 'package.json')
20
+ const SKILLHUB_METADATA_FILE = '_meta.json'
20
21
 
21
22
  export function redactDiagnosticText(value) {
22
23
  return String(value).replace(/yz_cli_[A-Za-z0-9_-]+/g, 'yz_cli_***')
@@ -52,9 +53,9 @@ export function inspectLocalEnvironment(
52
53
  ? check('pass', 'node', `Node.js ${nodeVersion} 满足 >=${minimumNode}`)
53
54
  : check('fail', 'node', `Node.js ${nodeVersion} 不满足 ${packageJson.engines?.node || '版本要求'}`, `安装 Node.js ${minimumNode || 22} 或更高版本。`))
54
55
 
55
- checks.push(packageJson.version === '0.1.10-beta.1'
56
+ checks.push(packageJson.version === '0.1.10'
56
57
  ? check('pass', 'cli_version', `CLI ${packageJson.version}`)
57
- : check('fail', 'cli_version', `CLI 版本为 ${packageJson.version},预期 0.1.10-beta.1`, '安装 @yizhuan-cli/cli@0.1.10-beta.1。'))
58
+ : check('fail', 'cli_version', `CLI 版本为 ${packageJson.version},预期 0.1.10`, '安装 @yizhuan-cli/cli@0.1.10。'))
58
59
 
59
60
  if (!exists(configPath)) {
60
61
  checks.push(check('fail', 'config', `配置不存在:${configPath}`, '运行 yizhuan config init。'))
@@ -206,6 +207,68 @@ export function inspectSkill(
206
207
  }
207
208
  }
208
209
 
210
+ export function inspectSkillhubSkills(
211
+ args,
212
+ {
213
+ resolveTarget = resolveSkillTarget,
214
+ exists = fs.existsSync,
215
+ readDirectory = fs.readdirSync,
216
+ readFile = fs.readFileSync
217
+ } = {}
218
+ ) {
219
+ let resolved
220
+ try {
221
+ resolved = resolveTarget({ global: Boolean(args.global), host: args.host })
222
+ } catch (error) {
223
+ return check('warn', 'skillhub_skills', `无法确定 SkillHub Skill 位置:${error.message}`, '使用 doctor --host <name> 明确宿主。')
224
+ }
225
+
226
+ if (!exists(resolved.root)) {
227
+ return check('pass', 'skillhub_skills', `未检测到已安装的 SkillHub 易撰 Skill:${resolved.root}`)
228
+ }
229
+
230
+ const installed = []
231
+ const unversioned = []
232
+ let entries
233
+ try {
234
+ entries = readDirectory(resolved.root, { withFileTypes: true })
235
+ } catch (error) {
236
+ return check('warn', 'skillhub_skills', `无法读取 SkillHub Skill 目录:${error.message}`, '检查 Skill 目录权限。')
237
+ }
238
+
239
+ for (const entry of entries) {
240
+ if (!entry.isDirectory() || !entry.name.startsWith('yizhuan-') || entry.name === 'yizhuan-cli') continue
241
+ const skillPath = path.join(resolved.root, entry.name, 'SKILL.md')
242
+ if (!exists(skillPath)) continue
243
+ const metadataPath = path.join(resolved.root, entry.name, SKILLHUB_METADATA_FILE)
244
+ if (!exists(metadataPath)) {
245
+ unversioned.push(entry.name)
246
+ continue
247
+ }
248
+ try {
249
+ const metadata = JSON.parse(readFile(metadataPath, 'utf8'))
250
+ if (metadata.name !== entry.name || metadata.entrySkill !== 'SKILL.md') throw new Error('名称或入口不匹配')
251
+ compareVersions(metadata.version, metadata.version)
252
+ installed.push(`${metadata.name} ${metadata.version}`)
253
+ } catch (error) {
254
+ unversioned.push(`${entry.name}(元数据无效:${error.message})`)
255
+ }
256
+ }
257
+
258
+ if (unversioned.length > 0) {
259
+ const detected = installed.length > 0 ? `已识别 ${installed.join('、')};` : ''
260
+ return check(
261
+ 'warn',
262
+ 'skillhub_skills',
263
+ `${detected}以下 Skill 未记录商品版本:${unversioned.join('、')}`,
264
+ '从 SkillHub 重新安装对应 Skill 的最新下载包。'
265
+ )
266
+ }
267
+ return installed.length > 0
268
+ ? check('pass', 'skillhub_skills', `已安装 SkillHub Skill:${installed.join('、')}`)
269
+ : check('pass', 'skillhub_skills', `未检测到已安装的 SkillHub 易撰 Skill:${resolved.root}`)
270
+ }
271
+
209
272
  export async function runDoctorChecks(args, dependencies = {}) {
210
273
  const local = inspectLocalEnvironment(
211
274
  { configPath: dependencies.configPath, platform: dependencies.platform, nodeVersion: dependencies.nodeVersion },
@@ -223,6 +286,7 @@ export async function runDoctorChecks(args, dependencies = {}) {
223
286
  )
224
287
  }
225
288
  checks.push(inspectSkill(args, dependencies))
289
+ checks.push(inspectSkillhubSkills(args, dependencies))
226
290
  return checks
227
291
  }
228
292