@yosai/cli 0.2.1-test.10 → 0.2.1-test.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.
@@ -1,7 +1,7 @@
1
1
  import { register } from '../cli.js';
2
2
  import { UsageError } from '../errors.js';
3
3
  import { print } from '../output.js';
4
- import { BUILTIN_SKILLS, detectSkillTargets, installSkillsTo } from '../skill-sync.js';
4
+ import { detectSkillTargets, installSkillsTo } from '../skill-sync.js';
5
5
  register({
6
6
  name: 'skill install',
7
7
  description: '安装内置 YOS Skill 到 Agent 技能目录',
@@ -15,8 +15,8 @@ register({
15
15
  if (targets.length === 0) {
16
16
  throw new UsageError('未发现已安装的 Agent 技能目录', '请用 --target <dir> 指定(如 ~/.claude/skills)');
17
17
  }
18
- installSkillsTo(targets);
19
- print(`已安装 ${BUILTIN_SKILLS.length} 个 Skill 到:\n${targets.join('\n')}`);
18
+ const skills = installSkillsTo(targets);
19
+ print(`已安装 ${skills.length} 个 Skill 到:\n${targets.join('\n')}`);
20
20
  print('提示:重启 Agent 工具以确保 Skill 加载');
21
21
  },
22
22
  });
@@ -98,7 +98,13 @@ function syncSkills() {
98
98
  print('未记录 Skill 安装目录,跳过 Skill 同步(需要时执行 yos skill install)');
99
99
  return;
100
100
  }
101
- installSkillsTo(dirs);
101
+ try {
102
+ installSkillsTo(dirs);
103
+ }
104
+ catch (error) {
105
+ const reason = error instanceof Error ? error.message : String(error);
106
+ throw new BusinessError(`Skill 同步失败:${reason}`, '可执行 yos skill install 手动重试');
107
+ }
102
108
  print(`已重同步 Skill:${dirs.join(', ')}`);
103
109
  }
104
110
  function firstLine(text) {
@@ -1,17 +1,24 @@
1
- import { cpSync, existsSync, mkdirSync } from 'node:fs';
1
+ import { cpSync, existsSync, mkdirSync, readdirSync, rmSync } from 'node:fs';
2
2
  import { homedir } from 'node:os';
3
3
  import { dirname, join } from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
5
  import { readPackageMeta } from './npm-meta.js';
6
6
  import { updateConfig } from './config.js';
7
7
  import { saveVersionState } from './version-state.js';
8
- export const BUILTIN_SKILLS = ['yos', 'yos-shared', 'yos-knowledge', 'yos-doc', 'yos-sheet', 'yos-retrieval', 'yos-transcript', 'yos-support', 'yos-install'];
8
+ const DEPRECATED_SKILLS = ['yos-doc-sheet'];
9
9
  const AGENT_SKILL_DIRS = ['.claude/skills', '.workbuddy/skills', '.cursor/skills', '.codex/skills', '.qoder/skills', '.qoder-cn/skills', '.agents/skills'];
10
10
  export function skillsSourceDir() {
11
11
  const here = dirname(fileURLToPath(import.meta.url));
12
12
  const distCandidate = join(here, 'skills');
13
13
  return existsSync(distCandidate) ? distCandidate : join(here, '..', 'src', 'skills');
14
14
  }
15
+ export function listSourceSkills() {
16
+ const source = skillsSourceDir();
17
+ return readdirSync(source, { withFileTypes: true })
18
+ .filter((entry) => entry.isDirectory() && existsSync(join(source, entry.name, 'SKILL.md')))
19
+ .map((entry) => entry.name)
20
+ .sort();
21
+ }
15
22
  export function detectSkillTargets() {
16
23
  return AGENT_SKILL_DIRS
17
24
  .map((rel) => join(homedir(), rel))
@@ -19,16 +26,21 @@ export function detectSkillTargets() {
19
26
  }
20
27
  export function installSkillsTo(targets) {
21
28
  const source = skillsSourceDir();
29
+ const skills = listSourceSkills();
22
30
  for (const target of targets) {
23
- for (const skill of BUILTIN_SKILLS) {
31
+ for (const skill of skills) {
24
32
  const skillTarget = join(target, skill);
25
33
  mkdirSync(skillTarget, { recursive: true });
26
34
  cpSync(join(source, skill), skillTarget, { recursive: true });
27
35
  }
36
+ for (const deprecated of DEPRECATED_SKILLS) {
37
+ rmSync(join(target, deprecated), { recursive: true, force: true });
38
+ }
28
39
  }
29
40
  updateConfig({ installedSkillDirs: targets });
30
41
  const meta = readPackageMeta();
31
42
  if (meta) {
32
43
  saveVersionState(meta.version);
33
44
  }
45
+ return skills;
34
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yosai/cli",
3
- "version": "0.2.1-test.10",
3
+ "version": "0.2.1-test.11",
4
4
  "description": "YOS 能力的 Agent 执行入口:工具调用、知识库管理与文件上传",
5
5
  "type": "module",
6
6
  "bin": {