eskill 1.0.12 → 1.0.14
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/cli.js +10 -6
- package/lib/installer.js +46 -5
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -51,11 +51,12 @@ program
|
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
console.log(`\
|
|
54
|
+
console.log(`\n已安装的技能:\n`);
|
|
55
55
|
skills.forEach(skill => {
|
|
56
|
-
|
|
56
|
+
const authorInfo = skill.author ? ` (@${skill.author})` : '';
|
|
57
|
+
console.log(` • ${skill.name}${authorInfo}`);
|
|
57
58
|
});
|
|
58
|
-
console.log(
|
|
59
|
+
console.log(`\n总计: ${skills.length} 个技能\n`);
|
|
59
60
|
} catch (error) {
|
|
60
61
|
console.error(`错误: ${error.message}`);
|
|
61
62
|
process.exit(1);
|
|
@@ -115,7 +116,10 @@ program
|
|
|
115
116
|
process.exit(1);
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
|
|
119
|
+
// 从 API 返回的数据结构中提取技能和分页信息
|
|
120
|
+
const skills = result.data?.skills || result.data || result.skills || result.results || [];
|
|
121
|
+
const pagination = result.data?.pagination || result.pagination || {};
|
|
122
|
+
const total = pagination.total || result.total || skills.length;
|
|
119
123
|
|
|
120
124
|
// 确保 skills 是数组
|
|
121
125
|
if (!Array.isArray(skills)) {
|
|
@@ -127,8 +131,8 @@ program
|
|
|
127
131
|
console.log(formatSkillList(skills));
|
|
128
132
|
|
|
129
133
|
// 显示分页信息
|
|
130
|
-
if (
|
|
131
|
-
console.log(`总计: ${
|
|
134
|
+
if (total > 0) {
|
|
135
|
+
console.log(`总计: ${total} 个技能\n`);
|
|
132
136
|
}
|
|
133
137
|
|
|
134
138
|
// 显示安装提示
|
package/lib/installer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execSync } from 'child_process';
|
|
2
|
-
import { existsSync, mkdirSync, symlinkSync, rmSync, readdirSync } from 'fs';
|
|
2
|
+
import { existsSync, mkdirSync, symlinkSync, rmSync, readdirSync, writeFileSync, readFileSync } from 'fs';
|
|
3
3
|
import { join, basename, dirname } from 'path';
|
|
4
4
|
import { tmpdir } from 'os';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
@@ -24,6 +24,30 @@ function getSkillsStorageDir() {
|
|
|
24
24
|
return join(pkgDir, 'skills-storage');
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* 保存技能元数据
|
|
29
|
+
*/
|
|
30
|
+
function saveSkillMeta(skillPath, meta) {
|
|
31
|
+
const metaPath = join(skillPath, '.eskill-meta.json');
|
|
32
|
+
writeFileSync(metaPath, JSON.stringify(meta, null, 2));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 读取技能元数据
|
|
37
|
+
*/
|
|
38
|
+
function getSkillMeta(skillPath) {
|
|
39
|
+
const metaPath = join(skillPath, '.eskill-meta.json');
|
|
40
|
+
if (!existsSync(metaPath)) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const content = readFileSync(metaPath, 'utf-8');
|
|
45
|
+
return JSON.parse(content);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
27
51
|
/**
|
|
28
52
|
* 从 Git URL 安装技能
|
|
29
53
|
*/
|
|
@@ -105,6 +129,17 @@ export async function installFromGitUrl(gitUrl, options = {}) {
|
|
|
105
129
|
console.log(` 存储位置: eskill 包目录`);
|
|
106
130
|
console.log(` 说明: 卸载 eskill 时会自动删除所有技能`);
|
|
107
131
|
|
|
132
|
+
// 保存技能元数据(作者、Git URL 等)
|
|
133
|
+
saveSkillMeta(targetPath, {
|
|
134
|
+
name: skillName,
|
|
135
|
+
author: parsed.owner,
|
|
136
|
+
gitUrl: gitUrl,
|
|
137
|
+
platform: parsed.platform,
|
|
138
|
+
repo: parsed.repo,
|
|
139
|
+
branch: parsed.branch,
|
|
140
|
+
installedAt: new Date().toISOString()
|
|
141
|
+
});
|
|
142
|
+
|
|
108
143
|
return { success: true, path: targetPath };
|
|
109
144
|
} finally {
|
|
110
145
|
// 无论成功或失败,都清理临时目录
|
|
@@ -128,10 +163,16 @@ export function listSkills(agent = 'claude') {
|
|
|
128
163
|
// 读取目录中的技能
|
|
129
164
|
return readdirSync(skillDir, { withFileTypes: true })
|
|
130
165
|
.filter(dirent => dirent.isDirectory())
|
|
131
|
-
.map(dirent =>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
166
|
+
.map(dirent => {
|
|
167
|
+
const skillPath = join(skillDir, dirent.name);
|
|
168
|
+
const meta = getSkillMeta(skillPath);
|
|
169
|
+
return {
|
|
170
|
+
name: dirent.name,
|
|
171
|
+
path: skillPath,
|
|
172
|
+
author: meta?.author || null,
|
|
173
|
+
installedAt: meta?.installedAt || null
|
|
174
|
+
};
|
|
175
|
+
});
|
|
135
176
|
}
|
|
136
177
|
|
|
137
178
|
/**
|