joyskills-cli 0.2.2 → 0.2.4
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/src/commands/install.js +14 -8
package/package.json
CHANGED
package/src/commands/install.js
CHANGED
|
@@ -72,11 +72,12 @@ function detectSkillType(skillName) {
|
|
|
72
72
|
async function installPublicSkill(skillName, options, localManager, lockfileManager) {
|
|
73
73
|
console.log(`📦 Installing public skill: ${skillName}`);
|
|
74
74
|
|
|
75
|
-
const registryManager = require('../registry');
|
|
76
75
|
const tmpDir = `/tmp/joyskills-${Date.now()}`;
|
|
77
76
|
|
|
78
77
|
try {
|
|
79
|
-
// 1. 解析 skill
|
|
78
|
+
// 1. 解析 skill 名称
|
|
79
|
+
// anthropics/skills/pdf -> owner=anthropics, repo=skills, 相对路径=skills/pdf
|
|
80
|
+
// skillforge/code-review -> owner=skillforge, repo=code-review, 相对路径=code-review
|
|
80
81
|
const parts = skillName.split('/');
|
|
81
82
|
if (parts.length < 2) {
|
|
82
83
|
throw new Error(`Invalid skill name: ${skillName}. Expected format: owner/repo or owner/repo/path`);
|
|
@@ -84,7 +85,11 @@ async function installPublicSkill(skillName, options, localManager, lockfileMana
|
|
|
84
85
|
|
|
85
86
|
const owner = parts[0];
|
|
86
87
|
const repo = parts[1];
|
|
87
|
-
|
|
88
|
+
|
|
89
|
+
// 相对路径:如果有子路径,用 repo/subpath;否则用 repo
|
|
90
|
+
const relativePath = parts.length > 2
|
|
91
|
+
? `${repo}/${parts.slice(2).join('/')}` // anthropics/skills/pdf -> skills/pdf
|
|
92
|
+
: repo; // skillforge/code-review -> code-review
|
|
88
93
|
|
|
89
94
|
// 2. clone 仓库
|
|
90
95
|
const repoUrl = `https://github.com/${owner}/${repo}`;
|
|
@@ -96,17 +101,18 @@ async function installPublicSkill(skillName, options, localManager, lockfileMana
|
|
|
96
101
|
});
|
|
97
102
|
|
|
98
103
|
// 3. 寻找 SKILL.md
|
|
99
|
-
const skillSourceDir = path.join(tmpDir,
|
|
104
|
+
const skillSourceDir = path.join(tmpDir, relativePath);
|
|
100
105
|
const skillMdPath = path.join(skillSourceDir, 'SKILL.md');
|
|
101
106
|
|
|
102
107
|
if (!fs.existsSync(skillMdPath)) {
|
|
103
|
-
throw new Error(`SKILL.md not found at ${
|
|
108
|
+
throw new Error(`SKILL.md not found at ${relativePath}. Please check the skill path.`);
|
|
104
109
|
}
|
|
105
110
|
|
|
106
|
-
// 4.
|
|
111
|
+
// 4. 确定安装目标目录(只用最后一级目录名)
|
|
112
|
+
const skillDirName = parts[parts.length - 1]; // anthropics/skills/pdf -> pdf
|
|
107
113
|
const targetDir = options.global
|
|
108
|
-
? localManager.getGlobalSkillPath(
|
|
109
|
-
: localManager.getProjectSkillPath(
|
|
114
|
+
? localManager.getGlobalSkillPath(skillDirName)
|
|
115
|
+
: localManager.getProjectSkillPath(skillDirName);
|
|
110
116
|
|
|
111
117
|
const location = options.global ? 'global (~/.claude/skills)' : 'project (./.claude/skills)';
|
|
112
118
|
console.log(`📍 Location: ${location}`);
|