skill4agent 1.0.2 → 1.0.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/.agents/skills/frontend-design/LICENSE.txt +0 -177
- package/.agents/skills/frontend-design/SKILL.md +0 -42
- package/src/api.ts +0 -111
- package/src/commands/add.ts +0 -314
- package/src/commands/install.ts +0 -189
- package/src/commands/list.ts +0 -15
- package/src/main.ts +0 -78
- package/src/tools.ts +0 -111
- package/src/utils.ts +0 -28
- package/tsconfig.json +0 -19
package/package.json
CHANGED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
Apache License
|
|
3
|
-
Version 2.0, January 2004
|
|
4
|
-
http://www.apache.org/licenses/
|
|
5
|
-
|
|
6
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
-
|
|
8
|
-
1. Definitions.
|
|
9
|
-
|
|
10
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
-
|
|
13
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
-
the copyright owner that is granting the License.
|
|
15
|
-
|
|
16
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
-
other entities that control, are controlled by, or are under common
|
|
18
|
-
control with that entity. For the purposes of this definition,
|
|
19
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
-
direction or management of such entity, whether by contract or
|
|
21
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
-
|
|
24
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
-
exercising permissions granted by this License.
|
|
26
|
-
|
|
27
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
-
including but not limited to software source code, documentation
|
|
29
|
-
source, and configuration files.
|
|
30
|
-
|
|
31
|
-
"Object" form shall mean any form resulting from mechanical
|
|
32
|
-
transformation or translation of a Source form, including but
|
|
33
|
-
not limited to compiled object code, generated documentation,
|
|
34
|
-
and conversions to other media types.
|
|
35
|
-
|
|
36
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
-
Object form, made available under the License, as indicated by a
|
|
38
|
-
copyright notice that is included in or attached to the work
|
|
39
|
-
(an example is provided in the Appendix below).
|
|
40
|
-
|
|
41
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
-
form, that is based on (or derived from) the Work and for which the
|
|
43
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
-
of this License, Derivative Works shall not include works that remain
|
|
46
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
-
the Work and Derivative Works thereof.
|
|
48
|
-
|
|
49
|
-
"Contribution" shall mean any work of authorship, including
|
|
50
|
-
the original version of the Work and any modifications or additions
|
|
51
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
-
means any form of electronic, verbal, or written communication sent
|
|
56
|
-
to the Licensor or its representatives, including but not limited to
|
|
57
|
-
communication on electronic mailing lists, source code control systems,
|
|
58
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
-
excluding communication that is conspicuously marked or otherwise
|
|
61
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
-
|
|
63
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
-
subsequently incorporated within the Work.
|
|
66
|
-
|
|
67
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
-
Work and such Derivative Works in Source or Object form.
|
|
73
|
-
|
|
74
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
-
(except as stated in this section) patent license to make, have made,
|
|
78
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
-
where such license applies only to those patent claims licensable
|
|
80
|
-
by such Contributor that are necessarily infringed by their
|
|
81
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
-
institute patent litigation against any entity (including a
|
|
84
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
-
or contributory patent infringement, then any patent licenses
|
|
87
|
-
granted to You under this License for that Work shall terminate
|
|
88
|
-
as of the date such litigation is filed.
|
|
89
|
-
|
|
90
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
-
modifications, and in Source or Object form, provided that You
|
|
93
|
-
meet the following conditions:
|
|
94
|
-
|
|
95
|
-
(a) You must give any other recipients of the Work or
|
|
96
|
-
Derivative Works a copy of this License; and
|
|
97
|
-
|
|
98
|
-
(b) You must cause any modified files to carry prominent notices
|
|
99
|
-
stating that You changed the files; and
|
|
100
|
-
|
|
101
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
-
that You distribute, all copyright, patent, trademark, and
|
|
103
|
-
attribution notices from the Source form of the Work,
|
|
104
|
-
excluding those notices that do not pertain to any part of
|
|
105
|
-
the Derivative Works; and
|
|
106
|
-
|
|
107
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
-
distribution, then any Derivative Works that You distribute must
|
|
109
|
-
include a readable copy of the attribution notices contained
|
|
110
|
-
within such NOTICE file, excluding those notices that do not
|
|
111
|
-
pertain to any part of the Derivative Works, in at least one
|
|
112
|
-
of the following places: within a NOTICE text file distributed
|
|
113
|
-
as part of the Derivative Works; within the Source form or
|
|
114
|
-
documentation, if provided along with the Derivative Works; or,
|
|
115
|
-
within a display generated by the Derivative Works, if and
|
|
116
|
-
wherever such third-party notices normally appear. The contents
|
|
117
|
-
of the NOTICE file are for informational purposes only and
|
|
118
|
-
do not modify the License. You may add Your own attribution
|
|
119
|
-
notices within Derivative Works that You distribute, alongside
|
|
120
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
-
that such additional attribution notices cannot be construed
|
|
122
|
-
as modifying the License.
|
|
123
|
-
|
|
124
|
-
You may add Your own copyright statement to Your modifications and
|
|
125
|
-
may provide additional or different license terms and conditions
|
|
126
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
-
the conditions stated in this License.
|
|
130
|
-
|
|
131
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
-
this License, without any additional terms or conditions.
|
|
135
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
-
the terms of any separate license agreement you may have executed
|
|
137
|
-
with Licensor regarding such Contributions.
|
|
138
|
-
|
|
139
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
-
except as required for reasonable and customary use in describing the
|
|
142
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
-
|
|
144
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
-
implied, including, without limitation, any warranties or conditions
|
|
149
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
-
appropriateness of using or redistributing the Work and assume any
|
|
152
|
-
risks associated with Your exercise of permissions under this License.
|
|
153
|
-
|
|
154
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
-
unless required by applicable law (such as deliberate and grossly
|
|
157
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
-
liable to You for damages, including any direct, indirect, special,
|
|
159
|
-
incidental, or consequential damages of any character arising as a
|
|
160
|
-
result of this License or out of the use or inability to use the
|
|
161
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
-
other commercial damages or losses), even if such Contributor
|
|
164
|
-
has been advised of the possibility of such damages.
|
|
165
|
-
|
|
166
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
-
or other liability obligations and/or rights consistent with this
|
|
170
|
-
License. However, in accepting such obligations, You may act only
|
|
171
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
-
defend, and hold each Contributor harmless for any liability
|
|
174
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
-
of your accepting any such warranty or additional liability.
|
|
176
|
-
|
|
177
|
-
END OF TERMS AND CONDITIONS
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: frontend-design
|
|
3
|
-
description: Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.
|
|
4
|
-
license: Complete terms in LICENSE.txt
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
This skill guides creation of distinctive, production-grade frontend interfaces that avoid generic "AI slop" aesthetics. Implement real working code with exceptional attention to aesthetic details and creative choices.
|
|
8
|
-
|
|
9
|
-
The user provides frontend requirements: a component, page, application, or interface to build. They may include context about the purpose, audience, or technical constraints.
|
|
10
|
-
|
|
11
|
-
## Design Thinking
|
|
12
|
-
|
|
13
|
-
Before coding, understand the context and commit to a BOLD aesthetic direction:
|
|
14
|
-
- **Purpose**: What problem does this interface solve? Who uses it?
|
|
15
|
-
- **Tone**: Pick an extreme: brutally minimal, maximalist chaos, retro-futuristic, organic/natural, luxury/refined, playful/toy-like, editorial/magazine, brutalist/raw, art deco/geometric, soft/pastel, industrial/utilitarian, etc. There are so many flavors to choose from. Use these for inspiration but design one that is true to the aesthetic direction.
|
|
16
|
-
- **Constraints**: Technical requirements (framework, performance, accessibility).
|
|
17
|
-
- **Differentiation**: What makes this UNFORGETTABLE? What's the one thing someone will remember?
|
|
18
|
-
|
|
19
|
-
**CRITICAL**: Choose a clear conceptual direction and execute it with precision. Bold maximalism and refined minimalism both work - the key is intentionality, not intensity.
|
|
20
|
-
|
|
21
|
-
Then implement working code (HTML/CSS/JS, React, Vue, etc.) that is:
|
|
22
|
-
- Production-grade and functional
|
|
23
|
-
- Visually striking and memorable
|
|
24
|
-
- Cohesive with a clear aesthetic point-of-view
|
|
25
|
-
- Meticulously refined in every detail
|
|
26
|
-
|
|
27
|
-
## Frontend Aesthetics Guidelines
|
|
28
|
-
|
|
29
|
-
Focus on:
|
|
30
|
-
- **Typography**: Choose fonts that are beautiful, unique, and interesting. Avoid generic fonts like Arial and Inter; opt instead for distinctive choices that elevate the frontend's aesthetics; unexpected, characterful font choices. Pair a distinctive display font with a refined body font.
|
|
31
|
-
- **Color & Theme**: Commit to a cohesive aesthetic. Use CSS variables for consistency. Dominant colors with sharp accents outperform timid, evenly-distributed palettes.
|
|
32
|
-
- **Motion**: Use animations for effects and micro-interactions. Prioritize CSS-only solutions for HTML. Use Motion library for React when available. Focus on high-impact moments: one well-orchestrated page load with staggered reveals (animation-delay) creates more delight than scattered micro-interactions. Use scroll-triggering and hover states that surprise.
|
|
33
|
-
- **Spatial Composition**: Unexpected layouts. Asymmetry. Overlap. Diagonal flow. Grid-breaking elements. Generous negative space OR controlled density.
|
|
34
|
-
- **Backgrounds & Visual Details**: Create atmosphere and depth rather than defaulting to solid colors. Add contextual effects and textures that match the overall aesthetic. Apply creative forms like gradient meshes, noise textures, geometric patterns, layered transparencies, dramatic shadows, decorative borders, custom cursors, and grain overlays.
|
|
35
|
-
|
|
36
|
-
NEVER use generic AI-generated aesthetics like overused font families (Inter, Roboto, Arial, system fonts), cliched color schemes (particularly purple gradients on white backgrounds), predictable layouts and component patterns, and cookie-cutter design that lacks context-specific character.
|
|
37
|
-
|
|
38
|
-
Interpret creatively and make unexpected choices that feel genuinely designed for the context. No design should be the same. Vary between light and dark themes, different fonts, different aesthetics. NEVER converge on common choices (Space Grotesk, for example) across generations.
|
|
39
|
-
|
|
40
|
-
**IMPORTANT**: Match implementation complexity to the aesthetic vision. Maximalist designs need elaborate code with extensive animations and effects. Minimalist or refined designs need restraint, precision, and careful attention to spacing, typography, and subtle details. Elegance comes from executing the vision well.
|
|
41
|
-
|
|
42
|
-
Remember: Claude is capable of extraordinary creative work. Don't hold back, show what can truly be created when thinking outside the box and committing fully to a distinctive vision.
|
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
|
-
}
|
package/src/commands/add.ts
DELETED
|
@@ -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
|
-
}
|
package/src/commands/install.ts
DELETED
|
@@ -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
|
-
}
|
package/src/commands/list.ts
DELETED
|
@@ -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
|
-
}
|