skill4agent 1.0.2 → 1.0.3

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": "skill4agent",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "CLI tool for installing agent skills",
5
5
  "main": "dist/main.js",
6
6
  "bin": {
package/src/api.ts DELETED
@@ -1,111 +0,0 @@
1
- import axios from 'axios';
2
- import fs from 'fs-extra';
3
- import os from 'os';
4
- import path from 'path';
5
-
6
- const API_BASE = 'https://skill4agent.com/api';
7
-
8
- export interface SkillInfo {
9
- skillName: string;
10
- name: string;
11
- nameCn: string;
12
- description: string;
13
- descriptionCn: string;
14
- descriptionTranslated: string;
15
- category: {
16
- nameCn: string;
17
- nameEn: string;
18
- } | null;
19
- tags: string;
20
- tagsCn: string;
21
- originalLanguage: string;
22
- hasTranslation: boolean;
23
- hasScript: boolean;
24
- scriptCount: number;
25
- scriptCheckResult: string;
26
- hasDownloaded: boolean;
27
- downloadStatus: string;
28
- totalInstalls: number;
29
- trending24h: number;
30
- }
31
-
32
- export async function downloadSkill(
33
- topSource: string,
34
- skillName: string,
35
- type: 'original' | 'translated' = 'original'
36
- ): Promise<string> {
37
- const url = `${API_BASE}/download?top_source=${encodeURIComponent(topSource)}&skill_name=${encodeURIComponent(skillName)}&type=${type}`;
38
-
39
- const response = await axios.get(url, {
40
- responseType: 'arraybuffer',
41
- });
42
-
43
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill4agent-'));
44
- const fileName = `${skillName}.zip`;
45
- const filePath = path.join(tempDir, fileName);
46
-
47
- fs.writeFileSync(filePath, Buffer.from(response.data));
48
-
49
- return filePath;
50
- }
51
-
52
- export async function getSkillInfo(topSource: string, skillName: string): Promise<{ skill: SkillInfo | null; sourceExists: boolean }> {
53
- try {
54
- const url = `${API_BASE}/skills/info?top_source=${encodeURIComponent(topSource)}&skill_name=${encodeURIComponent(skillName)}`;
55
- const response = await axios.get(url);
56
-
57
- if (response.status === 404) {
58
- return { skill: null, sourceExists: false };
59
- }
60
-
61
- const skill = response.data.data;
62
- if (!skill) {
63
- return { skill: null, sourceExists: true };
64
- }
65
-
66
- return {
67
- skill: {
68
- skillName: skill.skillName,
69
- name: skill.name,
70
- nameCn: skill.nameCn,
71
- description: skill.description,
72
- descriptionCn: skill.descriptionCn,
73
- descriptionTranslated: skill.descriptionTranslated,
74
- category: skill.category,
75
- tags: skill.tags,
76
- tagsCn: skill.tagsCn,
77
- originalLanguage: skill.originalLanguage,
78
- hasTranslation: skill.hasTranslation,
79
- hasScript: skill.hasScript,
80
- scriptCount: skill.scriptCount,
81
- scriptCheckResult: skill.scriptCheckResult,
82
- hasDownloaded: skill.hasDownloaded,
83
- downloadStatus: skill.downloadStatus,
84
- totalInstalls: skill.totalInstalls,
85
- trending24h: skill.trending24h,
86
- },
87
- sourceExists: true,
88
- };
89
- } catch (error: any) {
90
- if (error.response?.status === 404) {
91
- return { skill: null, sourceExists: false };
92
- }
93
- return { skill: null, sourceExists: false };
94
- }
95
- }
96
-
97
- export function getDownloadUrl(topSource: string, skillName: string, type: 'original' | 'translated' = 'original'): string {
98
- return `${API_BASE}/download?top_source=${encodeURIComponent(topSource)}&skill_name=${encodeURIComponent(skillName)}&type=${type}`;
99
- }
100
-
101
- export async function incrementInstallCount(topSource: string, skillName: string): Promise<void> {
102
- try {
103
- const url = `${API_BASE}/skills/install`;
104
- await axios.post(url, {
105
- top_source: topSource,
106
- skill_name: skillName,
107
- });
108
- } catch (error) {
109
- // 静默失败,不影响安装流程
110
- }
111
- }
@@ -1,314 +0,0 @@
1
- import chalk from 'chalk';
2
- import fs from 'fs-extra';
3
- import inquirer from 'inquirer';
4
- import os from 'os';
5
- import path from 'path';
6
- import { extractZip } from '../utils';
7
- import { UNIVERSAL_AGENTS, OTHER_AGENTS, UNIVERSAL_PATH, getAgentDisplayPath } from '../tools';
8
- import { downloadSkill, getSkillInfo, incrementInstallCount, SkillInfo } from '../api';
9
-
10
- function getAgentName(id: string): string {
11
- const agent = [...UNIVERSAL_AGENTS, ...OTHER_AGENTS].find(a => a.id === id);
12
- return agent?.name || id;
13
- }
14
-
15
- async function promptTypeSelection(skillInfo: SkillInfo): Promise<'original' | 'translated'> {
16
- const isOriginalEnglish = skillInfo.originalLanguage === 'en';
17
- const originalName = isOriginalEnglish ? 'English' : 'Chinese';
18
- const translatedName = isOriginalEnglish ? 'Chinese' : 'English';
19
-
20
- if (!skillInfo.hasTranslation) {
21
- console.log(chalk.yellow(`\nℹ️ This skill does not have a ${translatedName} translation yet.`));
22
- console.log(chalk.gray(` Installing ${originalName} version...\n`));
23
- return 'original';
24
- }
25
-
26
- const { type } = await inquirer.prompt({
27
- type: 'list',
28
- name: 'type',
29
- message: `Select version for "${skillInfo.name}"`,
30
- choices: [
31
- {
32
- name: `${originalName} (Original)`,
33
- value: 'original',
34
- },
35
- {
36
- name: `${translatedName} (Translation)`,
37
- value: 'translated',
38
- },
39
- ],
40
- default: 'original',
41
- });
42
-
43
- return type;
44
- }
45
-
46
- async function promptScopeSelection(): Promise<'project' | 'global'> {
47
- const { scope } = await inquirer.prompt({
48
- type: 'list',
49
- name: 'scope',
50
- message: 'Installation scope',
51
- choices: [
52
- {
53
- name: 'Project (Install in current directory (committed with your project))',
54
- value: 'project',
55
- },
56
- {
57
- name: 'Global (Install in home directory (available across all projects))',
58
- value: 'global',
59
- },
60
- ],
61
- default: 'project',
62
- });
63
-
64
- return scope;
65
- }
66
-
67
- async function promptAgentSelection(isGlobal: boolean): Promise<string[]> {
68
- const universalNames = UNIVERSAL_AGENTS.map(a => a.name).join(', ');
69
- const universalDisplayPath = getAgentDisplayPath(UNIVERSAL_AGENTS[0].id, isGlobal);
70
-
71
- const otherAgentChoices = OTHER_AGENTS.map(agent => ({
72
- name: `${agent.name} (${getAgentDisplayPath(agent.id, isGlobal)})`,
73
- value: agent.id,
74
- }));
75
-
76
- console.log(chalk.green(`✓ Universal (${universalDisplayPath}): ${universalNames} is always included`));
77
-
78
- const { selectedOtherAgents } = await inquirer.prompt({
79
- type: 'checkbox',
80
- name: 'selectedOtherAgents',
81
- message: 'Select additional agents:',
82
- pageSize: 12,
83
- loop: false,
84
- choices: otherAgentChoices,
85
- });
86
-
87
- const selectedNames = (selectedOtherAgents as string[]).map(id =>
88
- OTHER_AGENTS.find(a => a.id === id)?.name || id
89
- );
90
- const displayNames = selectedNames.length > 0
91
- ? ['Universal', ...selectedNames].join(', ')
92
- : 'Universal';
93
- console.log(chalk.green(`✓ Selected: ${displayNames}\n`));
94
-
95
- const universalAgentIds = UNIVERSAL_AGENTS.map(a => a.id);
96
- return [...universalAgentIds, ...(selectedOtherAgents as string[])];
97
- }
98
-
99
- async function promptMethodSelection(): Promise<'symlink' | 'copy'> {
100
- const { method } = await inquirer.prompt({
101
- type: 'list',
102
- name: 'method',
103
- message: 'Installation method',
104
- choices: [
105
- {
106
- name: 'Symlink (Recommended) (Single source of truth, easy updates)',
107
- value: 'symlink',
108
- },
109
- {
110
- name: 'Copy to all agents (Independent copies for each agent)',
111
- value: 'copy',
112
- },
113
- ],
114
- default: 'symlink',
115
- });
116
-
117
- return method;
118
- }
119
-
120
- function displaySummary(
121
- skillName: string,
122
- source: string,
123
- typeDisplay: string,
124
- scope: string,
125
- agents: string[],
126
- method: string
127
- ): void {
128
- const universalAgentIds = UNIVERSAL_AGENTS.map(a => a.id);
129
- const hasUniversal = agents.some(id => universalAgentIds.includes(id));
130
- const otherAgents = agents.filter(id => !universalAgentIds.includes(id));
131
- const otherAgentNames = otherAgents.map(id => getAgentName(id));
132
-
133
- const agentDisplay = hasUniversal
134
- ? ['Universal', ...otherAgentNames].join(', ')
135
- : otherAgentNames.join(', ');
136
- const agentCount = (hasUniversal ? 1 : 0) + otherAgentNames.length;
137
-
138
- console.log(chalk.blue('\n📊 Installation Summary'));
139
- console.log(chalk.gray('─'.repeat(50)));
140
- console.log(`Skill: ${chalk.white(skillName)}`);
141
- console.log(`Source: ${source}`);
142
- console.log(`Type: ${typeDisplay}`);
143
- console.log(`Scope: ${scope === 'global' ? 'Global' : 'Project'}`);
144
- console.log(`Agents (${agentCount}): ${agentDisplay}`);
145
- console.log(`Method: ${method === 'symlink' ? 'Symlink (Recommended)' : 'Copy'}`);
146
- console.log(chalk.gray('─'.repeat(50)));
147
- }
148
-
149
- async function promptConfirmation(): Promise<boolean> {
150
- const { confirm } = await inquirer.prompt({
151
- type: 'confirm',
152
- name: 'confirm',
153
- message: 'Proceed with installation?',
154
- default: true,
155
- });
156
-
157
- return confirm;
158
- }
159
-
160
- export async function add(topSource: string, skillName: string): Promise<void> {
161
- console.log(chalk.blue(`\n📦 Installing skill: ${skillName}`));
162
- console.log(chalk.gray(` Source: ${topSource}\n`));
163
-
164
- let result: { skill: SkillInfo | null; sourceExists: boolean };
165
- try {
166
- result = await getSkillInfo(topSource, skillName);
167
- } catch (error: any) {
168
- console.log(chalk.red(`\n❌ Skill "${skillName}" not found in source "${topSource}".`));
169
- console.log(chalk.gray(` Please check the source repository and skill name.\n`));
170
- return;
171
- }
172
-
173
- if (!result.skill) {
174
- console.log(chalk.red(`\n❌ Skill "${skillName}" not found in source "${topSource}".`));
175
- console.log(chalk.gray(` Please check the source repository and skill name.\n`));
176
- return;
177
- }
178
-
179
- const skillInfo = result.skill;
180
-
181
- console.log(chalk.blue(`\n📦 Skill: ${chalk.white(skillInfo.name)}`));
182
- console.log(chalk.gray(` Category: ${skillInfo.category?.nameEn || 'N/A'} | Installs: ${skillInfo.totalInstalls}`));
183
-
184
- if (skillInfo.tags) {
185
- console.log(chalk.gray(` Tags: ${skillInfo.tags}`));
186
- }
187
-
188
- if (!skillInfo.hasScript) {
189
- console.log(chalk.gray(` 📜 Scripts: No scripts`));
190
- } else {
191
- const statusText = skillInfo.scriptCheckResult === 'safe' ? '✅ Check passed' : '⚠️ Needs attention';
192
- console.log(chalk.gray(` 📜 Scripts: ${skillInfo.scriptCount} script(s) - ${statusText}`));
193
- }
194
-
195
- console.log(chalk.gray(` ${skillInfo.hasTranslation ? '✅' : '❌'} Translation available\n`));
196
-
197
- const type = await promptTypeSelection(skillInfo);
198
-
199
- const isOriginalEnglish = skillInfo.originalLanguage === 'en';
200
- const typeDisplay = type === 'original'
201
- ? (isOriginalEnglish ? 'English' : 'Chinese')
202
- : (isOriginalEnglish ? 'Chinese' : 'English');
203
- console.log(chalk.gray(` Type: ${typeDisplay}\n`));
204
-
205
- const scope = await promptScopeSelection();
206
- const isGlobal = scope === 'global';
207
-
208
- const selectedAgentIds = await promptAgentSelection(isGlobal);
209
- if (selectedAgentIds.length === 0) {
210
- console.log(chalk.yellow('\n⚠️ No agents selected. Installation cancelled.'));
211
- return;
212
- }
213
-
214
- const installMethod = await promptMethodSelection();
215
-
216
- displaySummary(skillName, topSource, typeDisplay, scope, selectedAgentIds, installMethod);
217
-
218
- const confirmed = await promptConfirmation();
219
- if (!confirmed) {
220
- console.log(chalk.yellow('\n⚠️ Installation cancelled.'));
221
- return;
222
- }
223
-
224
- const basePath = isGlobal ? os.homedir() : process.cwd();
225
-
226
- let tempZip: string;
227
- try {
228
- tempZip = await downloadSkill(topSource, skillName, type);
229
- } catch (error: any) {
230
- if (error.response?.status === 404) {
231
- console.log(chalk.red(`\n❌ Failed to download skill "${skillName}".`));
232
- console.log(chalk.gray(` The skill may not exist or the download link is invalid.\n`));
233
- return;
234
- }
235
- console.log(chalk.red(`\n❌ Download failed: ${error.message}`));
236
- return;
237
- }
238
-
239
- if (installMethod === 'symlink') {
240
- const universalFullPath = path.join(basePath, UNIVERSAL_PATH);
241
- fs.ensureDirSync(universalFullPath);
242
- const skillDir = path.join(universalFullPath, skillName);
243
-
244
- if (fs.existsSync(skillDir)) {
245
- console.log(chalk.yellow(`\n⚠️ Skill "${skillName}" already exists. Overwriting...`));
246
- fs.removeSync(skillDir);
247
- }
248
-
249
- await extractZip(tempZip, universalFullPath);
250
- fs.removeSync(tempZip);
251
-
252
- console.log(chalk.green(`✅ Installed to: ${skillDir}`));
253
-
254
- const otherAgentIds = selectedAgentIds.filter(id => !UNIVERSAL_AGENTS.some(a => a.id === id));
255
-
256
- for (const agentId of otherAgentIds) {
257
- const agent = OTHER_AGENTS.find(a => a.id === agentId);
258
- if (!agent) continue;
259
- const effectivePath = isGlobal && agent.globalPath ? agent.globalPath : agent.path;
260
- const agentPath = path.join(basePath, effectivePath);
261
- fs.ensureDirSync(agentPath);
262
- const destDir = path.join(agentPath, skillName);
263
- if (fs.existsSync(destDir)) {
264
- fs.removeSync(destDir);
265
- }
266
-
267
- if (isGlobal) {
268
- fs.symlinkSync(skillDir, destDir);
269
- } else {
270
- const relativePath = path.relative(agentPath, skillDir);
271
- fs.symlinkSync(relativePath, destDir);
272
- }
273
-
274
- console.log(chalk.green(`✅ Linked to: ${destDir}`));
275
- }
276
- } else {
277
- const universalFullPath = path.join(basePath, UNIVERSAL_PATH);
278
- fs.ensureDirSync(universalFullPath);
279
-
280
- if (fs.existsSync(path.join(universalFullPath, skillName))) {
281
- fs.removeSync(path.join(universalFullPath, skillName));
282
- }
283
-
284
- await extractZip(tempZip, universalFullPath);
285
- fs.removeSync(tempZip);
286
-
287
- console.log(chalk.green(`✅ Copied to: ${universalFullPath}`));
288
-
289
- let copiedCount = 0;
290
- const otherAgentIds = selectedAgentIds.filter(id => !UNIVERSAL_AGENTS.some(a => a.id === id));
291
-
292
- for (const agentId of otherAgentIds) {
293
- const agent = OTHER_AGENTS.find(a => a.id === agentId);
294
- if (!agent) continue;
295
- const effectivePath = isGlobal && agent.globalPath ? agent.globalPath : agent.path;
296
- const agentPath = path.join(basePath, effectivePath);
297
- fs.ensureDirSync(agentPath);
298
- const destDir = path.join(agentPath, skillName);
299
-
300
- if (fs.existsSync(destDir)) {
301
- fs.removeSync(destDir);
302
- }
303
-
304
- fs.copySync(path.join(universalFullPath, skillName), destDir);
305
- console.log(chalk.green(`✅ Copied to: ${destDir}`));
306
- copiedCount++;
307
- }
308
- }
309
-
310
- // 更新安装量
311
- await incrementInstallCount(topSource, skillName);
312
-
313
- console.log(chalk.green('\n🎉 Installation completed!\n'));
314
- }
@@ -1,189 +0,0 @@
1
- import chalk from 'chalk';
2
- import fs from 'fs-extra';
3
- import os from 'os';
4
- import path from 'path';
5
- import { extractZip } from '../utils';
6
- import { UNIVERSAL_PATH, getAgentDisplayPath } from '../tools';
7
- import { downloadSkill, getSkillInfo, incrementInstallCount } from '../api';
8
-
9
- interface InstallOptions {
10
- topSource: string;
11
- skillName: string;
12
- type: 'original' | 'translated';
13
- global: boolean;
14
- dirs: string[];
15
- method: 'symlink' | 'copy';
16
- }
17
-
18
- function getAgentNameFromPath(dirPath: string): string {
19
- const name = path.basename(dirPath);
20
- return name.charAt(0).toUpperCase() + name.slice(1);
21
- }
22
-
23
- function getAgentDisplayName(dirPath: string): string {
24
- const dirname = path.basename(path.dirname(dirPath));
25
- if (dirname === '.agents') return 'Universal';
26
- return dirname.charAt(0).toUpperCase() + dirname.slice(1);
27
- }
28
-
29
- function displaySummary(options: InstallOptions, skillInfo: any, typeDisplay: string, allDirs: string[]): void {
30
- const dirNames = allDirs.map(d => getAgentDisplayName(d));
31
- const dirCount = allDirs.length;
32
-
33
- console.log(chalk.blue('\n📊 Installation Summary'));
34
- console.log(chalk.gray('─'.repeat(50)));
35
- console.log(`Skill: ${chalk.white(skillInfo.name)}`);
36
- console.log(`Source: ${options.topSource}`);
37
- console.log(`Type: ${typeDisplay}`);
38
- console.log(`Scope: ${options.global ? 'Global' : 'Project'}`);
39
- console.log(`Dirs (${dirCount}): ${dirNames.join(', ')}`);
40
- console.log(`Method: ${options.method === 'symlink' ? 'Symlink (Recommended)' : 'Copy'}`);
41
- console.log(chalk.gray('─'.repeat(50)));
42
- }
43
-
44
- export async function install(options: InstallOptions): Promise<void> {
45
- const { topSource, skillName, type, global, dirs, method } = options;
46
-
47
- console.log(chalk.blue(`\n📦 Installing skill: ${skillName}`));
48
- console.log(chalk.gray(` Source: ${topSource}\n`));
49
-
50
- let result: { skill: any; sourceExists: boolean };
51
- try {
52
- result = await getSkillInfo(topSource, skillName);
53
- } catch (error: any) {
54
- console.log(chalk.red(`\n❌ Skill "${skillName}" not found in source "${topSource}".`));
55
- console.log(chalk.gray(` Please check the source repository and skill name.\n`));
56
- return;
57
- }
58
-
59
- if (!result.skill) {
60
- console.log(chalk.red(`\n❌ Skill "${skillName}" not found in source "${topSource}".`));
61
- console.log(chalk.gray(` Please check the source repository and skill name.\n`));
62
- return;
63
- }
64
-
65
- const skillInfo = result.skill;
66
-
67
- console.log(chalk.blue(`\n📦 Skill: ${chalk.white(skillInfo.name)}`));
68
- console.log(chalk.gray(` Category: ${skillInfo.category?.nameEn || 'N/A'} | Installs: ${skillInfo.totalInstalls}`));
69
-
70
- if (skillInfo.tags) {
71
- console.log(chalk.gray(` Tags: ${skillInfo.tags}`));
72
- }
73
-
74
- if (!skillInfo.hasScript) {
75
- console.log(chalk.gray(` 📜 Scripts: No scripts`));
76
- } else {
77
- const statusText = skillInfo.scriptCheckResult === 'safe' ? '✅ Check passed' : '⚠️ Needs attention';
78
- console.log(chalk.gray(` 📜 Scripts: ${skillInfo.scriptCount} script(s) - ${statusText}`));
79
- }
80
-
81
- console.log(chalk.gray(` ${skillInfo.hasTranslation ? '✅' : '❌'} Translation available\n`));
82
-
83
- let finalType = type;
84
- const isOriginalEnglish = skillInfo.originalLanguage === 'en';
85
-
86
- if (type === 'translated' && !skillInfo.hasTranslation) {
87
- console.log(chalk.yellow(`⚠️ Translation not available. Using original (${isOriginalEnglish ? 'English' : 'Chinese'}) version.\n`));
88
- finalType = 'original';
89
- }
90
-
91
- const typeDisplay = finalType === 'original'
92
- ? (isOriginalEnglish ? 'English' : 'Chinese')
93
- : (isOriginalEnglish ? 'Chinese' : 'English');
94
- console.log(chalk.gray(` Type: ${typeDisplay}\n`));
95
-
96
- const isGlobal = global;
97
- const basePath = isGlobal ? os.homedir() : process.cwd();
98
-
99
- const allDirs = [UNIVERSAL_PATH, ...dirs.map((d: string) => d.endsWith('/skills') ? d : `${d}/skills`)];
100
- const dirNames = allDirs.map(d => getAgentDisplayName(d));
101
- console.log(chalk.green(`✓ Directories: ${dirNames.join(', ')}`));
102
-
103
- if (allDirs.length === 0) {
104
- console.log(chalk.yellow('\n⚠️ No directories selected. Installation cancelled.'));
105
- return;
106
- }
107
-
108
- displaySummary({ topSource, skillName, type: finalType, global, dirs, method }, skillInfo, typeDisplay, allDirs);
109
-
110
- let tempZip: string;
111
- try {
112
- tempZip = await downloadSkill(topSource, skillName, finalType);
113
- } catch (error: any) {
114
- if (error.response?.status === 404) {
115
- console.log(chalk.red(`\n❌ Failed to download skill "${skillName}".`));
116
- console.log(chalk.gray(` The skill may not exist or the download link is invalid.\n`));
117
- return;
118
- }
119
- console.log(chalk.red(`\n❌ Download failed: ${error.message}`));
120
- return;
121
- }
122
-
123
- if (method === 'symlink') {
124
- const universalFullPath = path.join(basePath, UNIVERSAL_PATH);
125
- fs.ensureDirSync(universalFullPath);
126
- const skillDir = path.join(universalFullPath, skillName);
127
-
128
- if (fs.existsSync(skillDir)) {
129
- console.log(chalk.yellow(`\n⚠️ Skill "${skillName}" already exists. Overwriting...`));
130
- fs.removeSync(skillDir);
131
- }
132
-
133
- await extractZip(tempZip, universalFullPath);
134
- fs.removeSync(tempZip);
135
-
136
- console.log(chalk.green(`✅ Installed to: ${skillDir}`));
137
-
138
- for (const dir of dirs) {
139
- const fullDir = dir.endsWith('/skills') ? dir : `${dir}/skills`;
140
- const dirPath = path.join(basePath, fullDir);
141
- fs.ensureDirSync(dirPath);
142
- const destDir = path.join(dirPath, skillName);
143
- if (fs.existsSync(destDir)) {
144
- fs.removeSync(destDir);
145
- }
146
-
147
- if (isGlobal) {
148
- fs.symlinkSync(skillDir, destDir);
149
- } else {
150
- const relativePath = path.relative(dirPath, skillDir);
151
- fs.symlinkSync(relativePath, destDir);
152
- }
153
-
154
- console.log(chalk.green(`✅ Linked to: ${destDir}`));
155
- }
156
- } else {
157
- const universalFullPath = path.join(basePath, UNIVERSAL_PATH);
158
- const skillDir = path.join(universalFullPath, skillName);
159
- fs.ensureDirSync(universalFullPath);
160
-
161
- if (fs.existsSync(skillDir)) {
162
- fs.removeSync(skillDir);
163
- }
164
-
165
- await extractZip(tempZip, universalFullPath);
166
- fs.removeSync(tempZip);
167
-
168
- console.log(chalk.green(`✅ Copied to: ${skillDir}`));
169
-
170
- for (const dir of dirs) {
171
- const fullDir = dir.endsWith('/skills') ? dir : `${dir}/skills`;
172
- const dirPath = path.join(basePath, fullDir);
173
- fs.ensureDirSync(dirPath);
174
- const destDir = path.join(dirPath, skillName);
175
-
176
- if (fs.existsSync(destDir)) {
177
- fs.removeSync(destDir);
178
- }
179
-
180
- fs.copySync(skillDir, destDir);
181
- console.log(chalk.green(`✅ Copied to: ${destDir}`));
182
- }
183
- }
184
-
185
- // 更新安装量
186
- await incrementInstallCount(topSource, skillName);
187
-
188
- console.log(chalk.green('\n🎉 Installation completed!\n'));
189
- }
@@ -1,15 +0,0 @@
1
- export async function list(): Promise<void> {
2
- console.log('list command');
3
- }
4
-
5
- export async function search(query: string): Promise<void> {
6
- console.log('search command', query);
7
- }
8
-
9
- export async function update(skillName?: string): Promise<void> {
10
- console.log('update command', skillName);
11
- }
12
-
13
- export async function uninstall(skillName: string): Promise<void> {
14
- console.log('uninstall command', skillName);
15
- }
package/src/main.ts DELETED
@@ -1,78 +0,0 @@
1
- import chalk from 'chalk';
2
- import { Command } from 'commander';
3
- import { install } from './commands/install';
4
- import { add } from './commands/add';
5
- import { list, search, update, uninstall } from './commands/list';
6
-
7
- const program = new Command();
8
-
9
- program
10
- .name('skill4agent')
11
- .description('CLI tool for installing and managing agent skills')
12
- .version('1.0.0');
13
-
14
- program
15
- .command('add <top_source> <skill_name>')
16
- .description('Interactive installation with guided prompts')
17
- .action(async (topSource: string, skillName: string) => {
18
- await add(topSource, skillName);
19
- });
20
-
21
- program
22
- .command('install <top_source> <skill_name>')
23
- .description('Non-interactive installation with command-line options')
24
- .option('--type <type>', 'Package type: original or translated', 'original')
25
- .option('--global', 'Install to global storage')
26
- .option('--dirs <dirs>', 'Additional directories (comma-separated): .trae,.cursor,.qwen')
27
- .option('--method <method>', 'Installation method: symlink or copy', 'symlink')
28
- .action(async (topSource: string, skillName: string, options: any) => {
29
- if (options.type && !['original', 'translated'].includes(options.type)) {
30
- console.log(chalk.red('\n❌ Invalid --type value. Must be "original" or "translated".\n'));
31
- process.exit(1);
32
- }
33
-
34
- if (options.method && !['symlink', 'copy'].includes(options.method)) {
35
- console.log(chalk.red('\n❌ Invalid --method value. Must be "symlink" or "copy".\n'));
36
- process.exit(1);
37
- }
38
-
39
- const dirsArray = options.dirs
40
- ? options.dirs.split(',').map((a: string) => a.trim()).filter((a: string) => a.length > 0)
41
- : [];
42
-
43
- await install({
44
- topSource,
45
- skillName,
46
- type: options.type || 'original',
47
- global: !!options.global,
48
- dirs: dirsArray,
49
- method: options.method || 'symlink',
50
- });
51
- });
52
-
53
- program
54
- .command('list')
55
- .description('List installed skills')
56
- .action(list);
57
-
58
- program
59
- .command('search <query>')
60
- .description('Search for skills')
61
- .action(search);
62
-
63
- program
64
- .command('update [skill_name]')
65
- .description('Update installed skills')
66
- .action(update);
67
-
68
- program
69
- .command('uninstall <skill_name>')
70
- .description('Uninstall a skill')
71
- .action(uninstall);
72
-
73
- program.parse();
74
-
75
- process.on('unhandledRejection', (reason: any) => {
76
- console.error(chalk.red('Error:'), reason);
77
- process.exit(1);
78
- });
package/src/tools.ts DELETED
@@ -1,111 +0,0 @@
1
- import fs from 'fs';
2
- import os from 'os';
3
- import path from 'path';
4
-
5
- export interface Agent {
6
- id: string;
7
- name: string;
8
- path: string;
9
- universal: boolean;
10
- globalPath?: string;
11
- }
12
-
13
- export const UNIVERSAL_AGENTS: Agent[] = [
14
- { id: 'amp', name: 'Amp', path: '.agents/skills', universal: true },
15
- { id: 'codex', name: 'Codex', path: '.agents/skills', universal: true },
16
- { id: 'gemini-cli', name: 'Gemini CLI', path: '.agents/skills', universal: true },
17
- { id: 'github-copilot', name: 'GitHub Copilot', path: '.agents/skills', universal: true },
18
- { id: 'kimi-code-cli', name: 'Kimi Code CLI', path: '.agents/skills', universal: true },
19
- { id: 'opencode', name: 'OpenCode', path: '.agents/skills', universal: true },
20
- ];
21
-
22
- export const UNIVERSAL_PATH = '.agents/skills';
23
-
24
- export const OTHER_AGENTS: Agent[] = [
25
- { id: 'antigravity', name: 'Antigravity', path: '.agent/skills', universal: false },
26
- { id: 'augment', name: 'Augment', path: '.augment/rules', universal: false },
27
- { id: 'claude-code', name: 'Claude Code', path: '.claude/skills', universal: false },
28
- { id: 'openclaw', name: 'OpenClaw', path: 'skills', universal: false },
29
- { id: 'cline', name: 'Cline', path: '.cline/skills', universal: false },
30
- { id: 'codebuddy', name: 'CodeBuddy', path: '.codebuddy/skills', universal: false },
31
- { id: 'command-code', name: 'Command Code', path: '.commandcode/skills', universal: false },
32
- { id: 'continue', name: 'Continue', path: '.continue/skills', universal: false },
33
- { id: 'crush', name: 'Crush', path: '.crush/skills', universal: false },
34
- { id: 'cursor', name: 'Cursor', path: '.cursor/skills', universal: false },
35
- { id: 'droid', name: 'Droid', path: '.factory/skills', universal: false },
36
- { id: 'goose', name: 'Goose', path: '.goose/skills', universal: false },
37
- { id: 'junie', name: 'Junie', path: '.junie/skills', universal: false },
38
- { id: 'iflow-cli', name: 'iFlow CLI', path: '.iflow/skills', universal: false },
39
- { id: 'kilo-code', name: 'Kilo Code', path: '.kilocode/skills', universal: false },
40
- { id: 'kiro-cli', name: 'Kiro CLI', path: '.kiro/skills', universal: false },
41
- { id: 'kode', name: 'Kode', path: '.kode/skills', universal: false },
42
- { id: 'mcpjam', name: 'MCPJam', path: '.mcpjam/skills', universal: false },
43
- { id: 'mistral-vibe', name: 'Mistral Vibe', path: '.vibe/skills', universal: false },
44
- { id: 'mux', name: 'Mux', path: '.mux/skills', universal: false },
45
- { id: 'openhands', name: 'OpenHands', path: '.openhands/skills', universal: false },
46
- { id: 'pi', name: 'Pi', path: '.pi/skills', universal: false },
47
- { id: 'qoder', name: 'Qoder', path: '.qoder/skills', universal: false },
48
- { id: 'qwen-code', name: 'Qwen Code', path: '.qwen/skills', universal: false },
49
- { id: 'roo-code', name: 'Roo Code', path: '.roo/skills', universal: false },
50
- { id: 'trae', name: 'Trae', path: '.trae/skills', universal: false },
51
- { id: 'trae-cn', name: 'Trae CN', path: '.trae/skills', globalPath: '.trae-cn/skills', universal: false },
52
- { id: 'windsurf', name: 'Windsurf', path: '.windsurf/skills', universal: false },
53
- { id: 'zencoder', name: 'Zencoder', path: '.zencoder/skills', universal: false },
54
- { id: 'neovate', name: 'Neovate', path: '.neovate/skills', universal: false },
55
- { id: 'pochi', name: 'Pochi', path: '.pochi/skills', universal: false },
56
- { id: 'adal', name: 'AdaL', path: '.adal/skills', universal: false },
57
- ];
58
-
59
- export function getGlobalStoragePath(): string {
60
- const platform = os.platform();
61
- const homeDir = os.homedir();
62
-
63
- switch (platform) {
64
- case 'win32':
65
- return path.join(process.env.LOCALAPPDATA || path.join(homeDir, 'AppData', 'Local'), 'skill4agent', 'skills');
66
- case 'linux':
67
- return path.join(process.env.XDG_DATA_HOME || path.join(homeDir, '.local', 'share'), 'skill4agent', 'skills');
68
- case 'darwin':
69
- default:
70
- return path.join(homeDir, '.skill4agent', 'skills');
71
- }
72
- }
73
-
74
- export function getAgentPath(agentId: string, isGlobal: boolean): string | null {
75
- const allAgents = [...UNIVERSAL_AGENTS, ...OTHER_AGENTS];
76
- const agent = allAgents.find(a => a.id === agentId);
77
- if (!agent) return null;
78
-
79
- const effectivePath = isGlobal && agent.globalPath ? agent.globalPath : agent.path;
80
-
81
- if (isGlobal) {
82
- return path.join(os.homedir(), effectivePath);
83
- } else {
84
- return path.resolve(process.cwd(), effectivePath);
85
- }
86
- }
87
-
88
- export function checkAgentExists(agentPath: string): boolean {
89
- const parentDir = path.dirname(agentPath);
90
- return fs.existsSync(parentDir);
91
- }
92
-
93
- export function getAllAgents(): Agent[] {
94
- return [...UNIVERSAL_AGENTS, ...OTHER_AGENTS];
95
- }
96
-
97
- export function getAgentDisplayPath(agentId: string, isGlobal: boolean): string {
98
- const allAgents = [...UNIVERSAL_AGENTS, ...OTHER_AGENTS];
99
- const agent = allAgents.find(a => a.id === agentId);
100
- if (!agent) return 'unknown';
101
-
102
- const effectivePath = isGlobal && agent.globalPath ? agent.globalPath : agent.path;
103
-
104
- if (isGlobal) {
105
- const homeDir = os.homedir();
106
- const fullPath = path.join(homeDir, effectivePath);
107
- return fullPath.replace(os.homedir(), '~');
108
- } else {
109
- return effectivePath;
110
- }
111
- }
package/src/utils.ts DELETED
@@ -1,28 +0,0 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
3
-
4
- export async function extractZip(zipPath: string, destDir: string): Promise<void> {
5
- const AdmZip = require('adm-zip');
6
- const zip = new AdmZip(zipPath);
7
- zip.extractAllTo(destDir, true);
8
- }
9
-
10
- export function formatSize(bytes: number): string {
11
- if (bytes < 1024) return bytes + ' B';
12
- if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB';
13
- return (bytes / (1024 * 1024)).toFixed(1) + ' MB';
14
- }
15
-
16
- export function getSkillDirFromZip(zipPath: string): string | null {
17
- const AdmZip = require('adm-zip');
18
- const zip = new AdmZip(zipPath);
19
- const entries = zip.getEntries();
20
-
21
- for (const entry of entries) {
22
- const parts = entry.entryName.split('/');
23
- if (parts.length > 1 && parts[0] !== '__MACOSX') {
24
- return parts[0];
25
- }
26
- }
27
- return null;
28
- }
package/tsconfig.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "commonjs",
5
- "lib": ["ES2020"],
6
- "outDir": "./dist",
7
- "rootDir": "./src",
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "declaration": true,
14
- "declarationMap": true,
15
- "sourceMap": true
16
- },
17
- "include": ["src/**/*"],
18
- "exclude": ["node_modules", "dist"]
19
- }