@codemcp/agentskills-core 0.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/LICENSE +19 -0
- package/dist/__tests__/package-config.test.d.ts +2 -0
- package/dist/__tests__/package-config.test.d.ts.map +1 -0
- package/dist/__tests__/package-config.test.js +251 -0
- package/dist/__tests__/package-config.test.js.map +1 -0
- package/dist/__tests__/parser.test.d.ts +2 -0
- package/dist/__tests__/parser.test.d.ts.map +1 -0
- package/dist/__tests__/parser.test.js +613 -0
- package/dist/__tests__/parser.test.js.map +1 -0
- package/dist/__tests__/registry.test.d.ts +2 -0
- package/dist/__tests__/registry.test.d.ts.map +1 -0
- package/dist/__tests__/registry.test.js +415 -0
- package/dist/__tests__/registry.test.js.map +1 -0
- package/dist/__tests__/skill-installer.test.d.ts +2 -0
- package/dist/__tests__/skill-installer.test.d.ts.map +1 -0
- package/dist/__tests__/skill-installer.test.js +229 -0
- package/dist/__tests__/skill-installer.test.js.map +1 -0
- package/dist/__tests__/validator.test.d.ts +2 -0
- package/dist/__tests__/validator.test.d.ts.map +1 -0
- package/dist/__tests__/validator.test.js +284 -0
- package/dist/__tests__/validator.test.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/installer.d.ts +89 -0
- package/dist/installer.d.ts.map +1 -0
- package/dist/installer.js +469 -0
- package/dist/installer.js.map +1 -0
- package/dist/package-config.d.ts +52 -0
- package/dist/package-config.d.ts.map +1 -0
- package/dist/package-config.js +267 -0
- package/dist/package-config.js.map +1 -0
- package/dist/parser.d.ts +59 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +154 -0
- package/dist/parser.js.map +1 -0
- package/dist/registry.d.ts +72 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +180 -0
- package/dist/registry.js.map +1 -0
- package/dist/types.d.ts +202 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/dist/validator.d.ts +27 -0
- package/dist/validator.d.ts.map +1 -0
- package/dist/validator.js +165 -0
- package/dist/validator.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SkillInstaller Component
|
|
3
|
+
*
|
|
4
|
+
* Responsibility: Install Agent Skills from various sources (GitHub, Git URLs,
|
|
5
|
+
* local directories, tarballs, npm packages).
|
|
6
|
+
*
|
|
7
|
+
* Uses pacote library for downloading and extracting packages, supports caching,
|
|
8
|
+
* generates lock files for reproducible installations.
|
|
9
|
+
*/
|
|
10
|
+
import type { InstallResult, InstallAllResult, SkillManifest, SkillLockFile } from "./types.js";
|
|
11
|
+
/**
|
|
12
|
+
* SkillInstaller class for installing Agent Skills from various sources
|
|
13
|
+
*/
|
|
14
|
+
export declare class SkillInstaller {
|
|
15
|
+
private readonly skillsDir;
|
|
16
|
+
private readonly cacheDir?;
|
|
17
|
+
/**
|
|
18
|
+
* Create a new SkillInstaller instance
|
|
19
|
+
*
|
|
20
|
+
* @param skillsDir - Directory where skills will be installed
|
|
21
|
+
* @param cacheDir - Optional cache directory for downloads
|
|
22
|
+
* @throws Error if skillsDir is empty
|
|
23
|
+
*/
|
|
24
|
+
constructor(skillsDir: string, cacheDir?: string);
|
|
25
|
+
/**
|
|
26
|
+
* Install a skill from a spec (GitHub, Git URL, local path, tarball, npm)
|
|
27
|
+
*
|
|
28
|
+
* @param name - Name for the installed skill (directory name)
|
|
29
|
+
* @param spec - Package spec (e.g., "github:user/repo#tag", "file:./path", "https://...")
|
|
30
|
+
* @returns InstallResult with success/failure information
|
|
31
|
+
*/
|
|
32
|
+
install(name: string, spec: string): Promise<InstallResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Install multiple skills in parallel
|
|
35
|
+
*
|
|
36
|
+
* @param skills - Record of skill names to package specs
|
|
37
|
+
* @returns InstallAllResult with success/failure information
|
|
38
|
+
*/
|
|
39
|
+
installAll(skills: Record<string, string>): Promise<InstallAllResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Generate a lock file from installation results
|
|
42
|
+
*
|
|
43
|
+
* @param installed - Record of successfully installed skills
|
|
44
|
+
*/
|
|
45
|
+
generateLockFile(installed: Record<string, InstallResult>): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Read the lock file
|
|
48
|
+
*
|
|
49
|
+
* @returns SkillLockFile or null if file doesn't exist or is invalid
|
|
50
|
+
*/
|
|
51
|
+
readLockFile(): Promise<SkillLockFile | null>;
|
|
52
|
+
/**
|
|
53
|
+
* Get manifest without installing (dry-run)
|
|
54
|
+
*
|
|
55
|
+
* @param spec - Package spec
|
|
56
|
+
* @returns SkillManifest
|
|
57
|
+
* @throws Error if spec is invalid or SKILL.md is missing
|
|
58
|
+
*/
|
|
59
|
+
getManifest(spec: string): Promise<SkillManifest>;
|
|
60
|
+
/**
|
|
61
|
+
* Copy local directory to install path
|
|
62
|
+
*/
|
|
63
|
+
private copyLocalDirectory;
|
|
64
|
+
/**
|
|
65
|
+
* Recursively copy directory, excluding .agentskills and node_modules
|
|
66
|
+
*/
|
|
67
|
+
private copyDir;
|
|
68
|
+
/**
|
|
69
|
+
* Extract manifest from installed package
|
|
70
|
+
*/
|
|
71
|
+
private extractManifest;
|
|
72
|
+
/**
|
|
73
|
+
* Extract version from spec or metadata
|
|
74
|
+
*/
|
|
75
|
+
private extractVersion;
|
|
76
|
+
/**
|
|
77
|
+
* Validate if spec is in a supported format
|
|
78
|
+
*/
|
|
79
|
+
private isValidSpec;
|
|
80
|
+
/**
|
|
81
|
+
* Create a failure result
|
|
82
|
+
*/
|
|
83
|
+
private createFailure;
|
|
84
|
+
/**
|
|
85
|
+
* Handle installation errors and map to appropriate error codes
|
|
86
|
+
*/
|
|
87
|
+
private handleInstallError;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=installer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../src/installer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,aAAa,EAEd,MAAM,YAAY,CAAC;AAGpB;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAS;IAEnC;;;;;;OAMG;gBACS,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAQhD;;;;;;OAMG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAmIjE;;;;;OAKG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA2B3E;;;;OAIG;IACG,gBAAgB,CACpB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GACvC,OAAO,CAAC,IAAI,CAAC;IAyBhB;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAYnD;;;;;;OAMG;IACG,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAkDvD;;OAEG;YACW,kBAAkB;IAoChC;;OAEG;YACW,OAAO;IAyBrB;;OAEG;YACW,eAAe;IA4C7B;;OAEG;IACH,OAAO,CAAC,cAAc;IAyBtB;;OAEG;IACH,OAAO,CAAC,WAAW;IAoCnB;;OAEG;IACH,OAAO,CAAC,aAAa;IAiBrB;;OAEG;IACH,OAAO,CAAC,kBAAkB;CA8F3B"}
|
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SkillInstaller Component
|
|
3
|
+
*
|
|
4
|
+
* Responsibility: Install Agent Skills from various sources (GitHub, Git URLs,
|
|
5
|
+
* local directories, tarballs, npm packages).
|
|
6
|
+
*
|
|
7
|
+
* Uses pacote library for downloading and extracting packages, supports caching,
|
|
8
|
+
* generates lock files for reproducible installations.
|
|
9
|
+
*/
|
|
10
|
+
import { promises as fs } from "fs";
|
|
11
|
+
import { join, dirname, resolve } from "path";
|
|
12
|
+
import * as pacote from "pacote";
|
|
13
|
+
import { parseSkillContent } from "./parser.js";
|
|
14
|
+
/**
|
|
15
|
+
* SkillInstaller class for installing Agent Skills from various sources
|
|
16
|
+
*/
|
|
17
|
+
export class SkillInstaller {
|
|
18
|
+
skillsDir;
|
|
19
|
+
cacheDir;
|
|
20
|
+
/**
|
|
21
|
+
* Create a new SkillInstaller instance
|
|
22
|
+
*
|
|
23
|
+
* @param skillsDir - Directory where skills will be installed
|
|
24
|
+
* @param cacheDir - Optional cache directory for downloads
|
|
25
|
+
* @throws Error if skillsDir is empty
|
|
26
|
+
*/
|
|
27
|
+
constructor(skillsDir, cacheDir) {
|
|
28
|
+
if (!skillsDir || skillsDir.trim().length === 0) {
|
|
29
|
+
throw new Error("Skills directory is required");
|
|
30
|
+
}
|
|
31
|
+
this.skillsDir = skillsDir;
|
|
32
|
+
this.cacheDir = cacheDir;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Install a skill from a spec (GitHub, Git URL, local path, tarball, npm)
|
|
36
|
+
*
|
|
37
|
+
* @param name - Name for the installed skill (directory name)
|
|
38
|
+
* @param spec - Package spec (e.g., "github:user/repo#tag", "file:./path", "https://...")
|
|
39
|
+
* @returns InstallResult with success/failure information
|
|
40
|
+
*/
|
|
41
|
+
async install(name, spec) {
|
|
42
|
+
// Validate inputs
|
|
43
|
+
if (!name || name.trim().length === 0) {
|
|
44
|
+
throw new Error("Skill name is required");
|
|
45
|
+
}
|
|
46
|
+
if (!spec || spec.trim().length === 0) {
|
|
47
|
+
return this.createFailure(name, spec, "INVALID_SPEC", "Package spec is required");
|
|
48
|
+
}
|
|
49
|
+
// Validate spec format
|
|
50
|
+
if (!this.isValidSpec(spec)) {
|
|
51
|
+
return this.createFailure(name, spec, "INVALID_SPEC", "invalid package spec format");
|
|
52
|
+
}
|
|
53
|
+
const installPath = join(this.skillsDir, name);
|
|
54
|
+
try {
|
|
55
|
+
// Clean existing directory if it exists
|
|
56
|
+
try {
|
|
57
|
+
await fs.rm(installPath, { recursive: true, force: true });
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// Ignore if directory doesn't exist
|
|
61
|
+
}
|
|
62
|
+
// Ensure parent directory exists
|
|
63
|
+
await fs.mkdir(this.skillsDir, { recursive: true });
|
|
64
|
+
// Extract package using pacote
|
|
65
|
+
const opts = {};
|
|
66
|
+
if (this.cacheDir) {
|
|
67
|
+
opts.cache = this.cacheDir;
|
|
68
|
+
}
|
|
69
|
+
// Handle local directory differently - use direct copy instead of pacote
|
|
70
|
+
if (spec.startsWith("file:")) {
|
|
71
|
+
await this.copyLocalDirectory(spec, installPath);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// Use pacote.extract to download and extract the package
|
|
75
|
+
await pacote.extract(spec, installPath, opts);
|
|
76
|
+
}
|
|
77
|
+
// Verify SKILL.md exists
|
|
78
|
+
const skillMdPath = join(installPath, "SKILL.md");
|
|
79
|
+
try {
|
|
80
|
+
await fs.access(skillMdPath);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
await fs.rm(installPath, { recursive: true, force: true });
|
|
84
|
+
return this.createFailure(name, spec, "MISSING_SKILL_MD", "SKILL.md file not found in package");
|
|
85
|
+
}
|
|
86
|
+
// Extract manifest from SKILL.md
|
|
87
|
+
const manifest = await this.extractManifest(installPath);
|
|
88
|
+
if (!manifest) {
|
|
89
|
+
await fs.rm(installPath, { recursive: true, force: true });
|
|
90
|
+
return this.createFailure(name, spec, "INVALID_SKILL_FORMAT", "Failed to extract valid skill metadata from SKILL.md");
|
|
91
|
+
}
|
|
92
|
+
// Get package metadata for integrity and version
|
|
93
|
+
let resolvedVersion;
|
|
94
|
+
let integrity;
|
|
95
|
+
if (spec.startsWith("file:")) {
|
|
96
|
+
// For local files, use a hash of the path or timestamp
|
|
97
|
+
resolvedVersion = "local";
|
|
98
|
+
integrity = `file:${installPath}`;
|
|
99
|
+
// Try to get version from package.json
|
|
100
|
+
try {
|
|
101
|
+
const packageJsonPath = join(installPath, "package.json");
|
|
102
|
+
const packageJsonContent = await fs.readFile(packageJsonPath, "utf-8");
|
|
103
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
104
|
+
if (packageJson.version) {
|
|
105
|
+
resolvedVersion = packageJson.version;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
// package.json is optional for local files
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
const metadata = await pacote.manifest(spec, opts);
|
|
114
|
+
resolvedVersion = this.extractVersion(spec, metadata);
|
|
115
|
+
integrity = metadata._integrity || metadata.dist?.integrity || "";
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
success: true,
|
|
119
|
+
name,
|
|
120
|
+
spec,
|
|
121
|
+
resolvedVersion,
|
|
122
|
+
integrity,
|
|
123
|
+
installPath,
|
|
124
|
+
manifest
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
// Clean up on error
|
|
129
|
+
try {
|
|
130
|
+
await fs.rm(installPath, { recursive: true, force: true });
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
// Ignore cleanup errors
|
|
134
|
+
}
|
|
135
|
+
return this.handleInstallError(name, spec, error);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Install multiple skills in parallel
|
|
140
|
+
*
|
|
141
|
+
* @param skills - Record of skill names to package specs
|
|
142
|
+
* @returns InstallAllResult with success/failure information
|
|
143
|
+
*/
|
|
144
|
+
async installAll(skills) {
|
|
145
|
+
const results = {};
|
|
146
|
+
const installed = new Set();
|
|
147
|
+
const failed = new Set();
|
|
148
|
+
// Install all skills in parallel
|
|
149
|
+
const installPromises = Object.entries(skills).map(async ([name, spec]) => {
|
|
150
|
+
const result = await this.install(name, spec);
|
|
151
|
+
results[name] = result;
|
|
152
|
+
if (result.success) {
|
|
153
|
+
installed.add(name);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
failed.add(name);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
await Promise.all(installPromises);
|
|
160
|
+
return {
|
|
161
|
+
success: failed.size === 0,
|
|
162
|
+
installed,
|
|
163
|
+
failed,
|
|
164
|
+
results
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Generate a lock file from installation results
|
|
169
|
+
*
|
|
170
|
+
* @param installed - Record of successfully installed skills
|
|
171
|
+
*/
|
|
172
|
+
async generateLockFile(installed) {
|
|
173
|
+
const lockFile = {
|
|
174
|
+
version: "1.0",
|
|
175
|
+
generated: new Date().toISOString(),
|
|
176
|
+
skills: {}
|
|
177
|
+
};
|
|
178
|
+
for (const [name, result] of Object.entries(installed)) {
|
|
179
|
+
if (result.success) {
|
|
180
|
+
lockFile.skills[name] = {
|
|
181
|
+
spec: result.spec,
|
|
182
|
+
resolvedVersion: result.resolvedVersion,
|
|
183
|
+
integrity: result.integrity
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const lockFilePath = join(dirname(this.skillsDir), "skills-lock.json");
|
|
188
|
+
await fs.writeFile(lockFilePath, JSON.stringify(lockFile, null, 2), "utf-8");
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Read the lock file
|
|
192
|
+
*
|
|
193
|
+
* @returns SkillLockFile or null if file doesn't exist or is invalid
|
|
194
|
+
*/
|
|
195
|
+
async readLockFile() {
|
|
196
|
+
const lockFilePath = join(dirname(this.skillsDir), "skills-lock.json");
|
|
197
|
+
try {
|
|
198
|
+
const content = await fs.readFile(lockFilePath, "utf-8");
|
|
199
|
+
const lockFile = JSON.parse(content);
|
|
200
|
+
return lockFile;
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Get manifest without installing (dry-run)
|
|
208
|
+
*
|
|
209
|
+
* @param spec - Package spec
|
|
210
|
+
* @returns SkillManifest
|
|
211
|
+
* @throws Error if spec is invalid or SKILL.md is missing
|
|
212
|
+
*/
|
|
213
|
+
async getManifest(spec) {
|
|
214
|
+
if (!this.isValidSpec(spec)) {
|
|
215
|
+
throw new Error("Invalid package spec format");
|
|
216
|
+
}
|
|
217
|
+
// Create a temporary directory for extraction
|
|
218
|
+
const tempDir = join(this.cacheDir || this.skillsDir, `.temp-${Date.now()}`);
|
|
219
|
+
try {
|
|
220
|
+
await fs.mkdir(tempDir, { recursive: true });
|
|
221
|
+
// Extract to temp directory
|
|
222
|
+
if (spec.startsWith("file:")) {
|
|
223
|
+
await this.copyLocalDirectory(spec, tempDir);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
const opts = {};
|
|
227
|
+
if (this.cacheDir) {
|
|
228
|
+
opts.cache = this.cacheDir;
|
|
229
|
+
}
|
|
230
|
+
await pacote.extract(spec, tempDir, opts);
|
|
231
|
+
}
|
|
232
|
+
// Verify SKILL.md exists
|
|
233
|
+
const skillMdPath = join(tempDir, "SKILL.md");
|
|
234
|
+
try {
|
|
235
|
+
await fs.access(skillMdPath);
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
throw new Error("SKILL.md file not found in package");
|
|
239
|
+
}
|
|
240
|
+
// Extract and return manifest
|
|
241
|
+
const manifest = await this.extractManifest(tempDir);
|
|
242
|
+
if (!manifest) {
|
|
243
|
+
throw new Error("Failed to extract valid skill metadata from SKILL.md");
|
|
244
|
+
}
|
|
245
|
+
return manifest;
|
|
246
|
+
}
|
|
247
|
+
finally {
|
|
248
|
+
// Clean up temp directory
|
|
249
|
+
try {
|
|
250
|
+
await fs.rm(tempDir, { recursive: true, force: true });
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
// Ignore cleanup errors
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Copy local directory to install path
|
|
259
|
+
*/
|
|
260
|
+
async copyLocalDirectory(spec, installPath) {
|
|
261
|
+
// Remove "file:" prefix and resolve path
|
|
262
|
+
let sourcePath = spec.substring(5); // Remove "file:"
|
|
263
|
+
// Handle file:// protocol
|
|
264
|
+
if (sourcePath.startsWith("//")) {
|
|
265
|
+
sourcePath = sourcePath.substring(2);
|
|
266
|
+
}
|
|
267
|
+
// Expand tilde to home directory
|
|
268
|
+
if (sourcePath.startsWith("~/")) {
|
|
269
|
+
const os = await import("os");
|
|
270
|
+
sourcePath = join(os.homedir(), sourcePath.substring(2));
|
|
271
|
+
}
|
|
272
|
+
// Resolve relative paths
|
|
273
|
+
sourcePath = resolve(sourcePath);
|
|
274
|
+
// Verify source exists
|
|
275
|
+
try {
|
|
276
|
+
const stat = await fs.stat(sourcePath);
|
|
277
|
+
if (!stat.isDirectory()) {
|
|
278
|
+
throw new Error(`Source is not a directory: ${sourcePath}`);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
catch {
|
|
282
|
+
throw new Error(`Local path not found: ${sourcePath}`);
|
|
283
|
+
}
|
|
284
|
+
// Copy directory recursively
|
|
285
|
+
await fs.mkdir(installPath, { recursive: true });
|
|
286
|
+
await this.copyDir(sourcePath, installPath);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Recursively copy directory, excluding .agentskills and node_modules
|
|
290
|
+
*/
|
|
291
|
+
async copyDir(src, dest) {
|
|
292
|
+
const entries = await fs.readdir(src, { withFileTypes: true });
|
|
293
|
+
for (const entry of entries) {
|
|
294
|
+
// Skip .agentskills, node_modules, and hidden directories
|
|
295
|
+
if (entry.name === ".agentskills" ||
|
|
296
|
+
entry.name === "node_modules" ||
|
|
297
|
+
entry.name.startsWith(".")) {
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
const srcPath = join(src, entry.name);
|
|
301
|
+
const destPath = join(dest, entry.name);
|
|
302
|
+
if (entry.isDirectory()) {
|
|
303
|
+
await fs.mkdir(destPath, { recursive: true });
|
|
304
|
+
await this.copyDir(srcPath, destPath);
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
await fs.copyFile(srcPath, destPath);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Extract manifest from installed package
|
|
313
|
+
*/
|
|
314
|
+
async extractManifest(installPath) {
|
|
315
|
+
try {
|
|
316
|
+
// Read SKILL.md
|
|
317
|
+
const skillMdPath = join(installPath, "SKILL.md");
|
|
318
|
+
const skillContent = await fs.readFile(skillMdPath, "utf-8");
|
|
319
|
+
// Parse SKILL.md
|
|
320
|
+
const parseResult = parseSkillContent(skillContent);
|
|
321
|
+
if (!parseResult.success) {
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
const { metadata } = parseResult.skill;
|
|
325
|
+
// Try to read package.json for additional metadata
|
|
326
|
+
let packageName;
|
|
327
|
+
let version;
|
|
328
|
+
try {
|
|
329
|
+
const packageJsonPath = join(installPath, "package.json");
|
|
330
|
+
const packageJsonContent = await fs.readFile(packageJsonPath, "utf-8");
|
|
331
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
332
|
+
packageName = packageJson.name;
|
|
333
|
+
version = packageJson.version;
|
|
334
|
+
}
|
|
335
|
+
catch {
|
|
336
|
+
// package.json is optional
|
|
337
|
+
}
|
|
338
|
+
return {
|
|
339
|
+
name: metadata.name,
|
|
340
|
+
description: metadata.description,
|
|
341
|
+
license: metadata.license,
|
|
342
|
+
compatibility: metadata.compatibility,
|
|
343
|
+
packageName,
|
|
344
|
+
version,
|
|
345
|
+
metadata: metadata.metadata
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
catch {
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Extract version from spec or metadata
|
|
354
|
+
*/
|
|
355
|
+
extractVersion(spec, metadata) {
|
|
356
|
+
// Try to extract from spec first
|
|
357
|
+
const hashIndex = spec.indexOf("#");
|
|
358
|
+
if (hashIndex !== -1) {
|
|
359
|
+
return spec.substring(hashIndex + 1);
|
|
360
|
+
}
|
|
361
|
+
// Try to extract from metadata
|
|
362
|
+
if (typeof metadata.version === "string") {
|
|
363
|
+
return metadata.version;
|
|
364
|
+
}
|
|
365
|
+
if (typeof metadata.gitHead === "string") {
|
|
366
|
+
return metadata.gitHead.substring(0, 7);
|
|
367
|
+
}
|
|
368
|
+
// Default to "latest" or branch name
|
|
369
|
+
return typeof metadata._resolved === "string"
|
|
370
|
+
? metadata._resolved
|
|
371
|
+
: "latest";
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Validate if spec is in a supported format
|
|
375
|
+
*/
|
|
376
|
+
isValidSpec(spec) {
|
|
377
|
+
if (!spec || spec.trim().length === 0) {
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
// Check for valid formats
|
|
381
|
+
const validPrefixes = [
|
|
382
|
+
"github:",
|
|
383
|
+
"git+https://",
|
|
384
|
+
"git+ssh://",
|
|
385
|
+
"file:",
|
|
386
|
+
"http://",
|
|
387
|
+
"https://",
|
|
388
|
+
"@" // npm scoped packages
|
|
389
|
+
];
|
|
390
|
+
// Check if it starts with any valid prefix
|
|
391
|
+
const hasValidPrefix = validPrefixes.some((prefix) => spec.startsWith(prefix));
|
|
392
|
+
// Also allow npm package names (with or without version)
|
|
393
|
+
// Must start with @scope/ or be a valid package name with optional @version
|
|
394
|
+
// Npm packages cannot contain "format" or similar non-package words
|
|
395
|
+
const isScopedPackage = /^@[a-z0-9-]+\/[a-z0-9-]+(@.+)?$/.test(spec);
|
|
396
|
+
// Valid npm package: no spaces, starts with letter or @, contains only valid chars
|
|
397
|
+
const isNpmPackage = /^[a-z][a-z0-9-]*(@[\w.-~]+)?$/.test(spec);
|
|
398
|
+
// Reject obvious non-packages (containing spaces, invalid keywords, etc.)
|
|
399
|
+
if (spec.includes(" ") || spec.includes("invalid")) {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
return hasValidPrefix || isScopedPackage || isNpmPackage;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Create a failure result
|
|
406
|
+
*/
|
|
407
|
+
createFailure(name, spec, code, message) {
|
|
408
|
+
return {
|
|
409
|
+
success: false,
|
|
410
|
+
name,
|
|
411
|
+
spec,
|
|
412
|
+
error: {
|
|
413
|
+
code,
|
|
414
|
+
message
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Handle installation errors and map to appropriate error codes
|
|
420
|
+
*/
|
|
421
|
+
handleInstallError(name, spec, error) {
|
|
422
|
+
const err = error;
|
|
423
|
+
const message = err.message || "Unknown error";
|
|
424
|
+
// Network errors
|
|
425
|
+
if (err.code === "ENOTFOUND" ||
|
|
426
|
+
err.code === "ETIMEDOUT" ||
|
|
427
|
+
err.code === "ECONNREFUSED" ||
|
|
428
|
+
message.toLowerCase().includes("network") ||
|
|
429
|
+
message.includes("getaddrinfo")) {
|
|
430
|
+
return this.createFailure(name, spec, "NETWORK_ERROR", message);
|
|
431
|
+
}
|
|
432
|
+
// 404 errors
|
|
433
|
+
if (err.statusCode === 404 || message.includes("404")) {
|
|
434
|
+
return this.createFailure(name, spec, "INSTALL_FAILED", "Package not found (404)");
|
|
435
|
+
}
|
|
436
|
+
// Repository/reference not found errors
|
|
437
|
+
if (message.toLowerCase().includes("not found") ||
|
|
438
|
+
message.includes("does not exist") ||
|
|
439
|
+
message.includes("Could not find") ||
|
|
440
|
+
message.includes("Repository not found") ||
|
|
441
|
+
message.includes("unknown revision") ||
|
|
442
|
+
message.includes("couldn't find remote ref")) {
|
|
443
|
+
// Check if it's a reference error
|
|
444
|
+
if (message.includes("reference") ||
|
|
445
|
+
message.includes("ref") ||
|
|
446
|
+
message.includes("revision") ||
|
|
447
|
+
message.includes("branch") ||
|
|
448
|
+
message.includes("tag")) {
|
|
449
|
+
return this.createFailure(name, spec, "INSTALL_FAILED", "Git reference not found");
|
|
450
|
+
}
|
|
451
|
+
return this.createFailure(name, spec, "INSTALL_FAILED", "Repository or package not found");
|
|
452
|
+
}
|
|
453
|
+
// Git errors
|
|
454
|
+
if (message.includes("git error") || message.includes("fatal:")) {
|
|
455
|
+
return this.createFailure(name, spec, "INSTALL_FAILED", "Git error: repository or reference not found");
|
|
456
|
+
}
|
|
457
|
+
// Permission errors
|
|
458
|
+
if (err.code === "EACCES" || err.code === "EPERM") {
|
|
459
|
+
return this.createFailure(name, spec, "PERMISSION_ERROR", "Permission denied - permission error");
|
|
460
|
+
}
|
|
461
|
+
// File not found for local paths
|
|
462
|
+
if (err.code === "ENOENT" && spec.startsWith("file:")) {
|
|
463
|
+
return this.createFailure(name, spec, "INSTALL_FAILED", "Local path not found");
|
|
464
|
+
}
|
|
465
|
+
// Generic install failure
|
|
466
|
+
return this.createFailure(name, spec, "INSTALL_FAILED", message);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
//# sourceMappingURL=installer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installer.js","sourceRoot":"","sources":["../src/installer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAQjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD;;GAEG;AACH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,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;CACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { PackageConfig } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* PackageConfigManager - Manages package.json configuration for agent skills
|
|
4
|
+
*
|
|
5
|
+
* Responsibilities:
|
|
6
|
+
* - Read package.json from a directory
|
|
7
|
+
* - Parse `agentskills` field (skill dependencies)
|
|
8
|
+
* - Parse `agentskillsConfig` field (configuration settings)
|
|
9
|
+
* - Provide defaults when package.json doesn't exist
|
|
10
|
+
* - Provide defaults when fields are missing
|
|
11
|
+
* - Validate configuration structure
|
|
12
|
+
* - Save/update skills in package.json
|
|
13
|
+
*/
|
|
14
|
+
export declare class PackageConfigManager {
|
|
15
|
+
private projectRoot;
|
|
16
|
+
private packageJsonPath;
|
|
17
|
+
constructor(projectRoot: string);
|
|
18
|
+
/**
|
|
19
|
+
* Get default configuration with empty skills and standard defaults
|
|
20
|
+
*/
|
|
21
|
+
getDefaultConfig(): PackageConfig;
|
|
22
|
+
/**
|
|
23
|
+
* Load configuration from package.json
|
|
24
|
+
* Returns defaults if package.json doesn't exist
|
|
25
|
+
*/
|
|
26
|
+
loadConfig(): Promise<PackageConfig>;
|
|
27
|
+
/**
|
|
28
|
+
* Validate and extract skills from package.json
|
|
29
|
+
*/
|
|
30
|
+
private validateAndExtractSkills;
|
|
31
|
+
/**
|
|
32
|
+
* Validate and extract config from package.json
|
|
33
|
+
*/
|
|
34
|
+
private validateAndExtractConfig;
|
|
35
|
+
/**
|
|
36
|
+
* Save skills to package.json
|
|
37
|
+
* Creates package.json if it doesn't exist
|
|
38
|
+
* Preserves other fields
|
|
39
|
+
*/
|
|
40
|
+
saveSkills(skills: Record<string, string>): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Add a single skill to package.json
|
|
43
|
+
* Updates existing skill if name already exists
|
|
44
|
+
*/
|
|
45
|
+
addSkill(name: string, spec: string): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Remove a skill from package.json
|
|
48
|
+
* Does not error if skill doesn't exist or file doesn't exist
|
|
49
|
+
*/
|
|
50
|
+
removeSkill(name: string): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=package-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-config.d.ts","sourceRoot":"","sources":["../src/package-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,eAAe,CAAS;gBAEpB,WAAW,EAAE,MAAM;IAQ/B;;OAEG;IACH,gBAAgB,IAAI,aAAa;IAejC;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC;IA+C1C;;OAEG;IACH,OAAO,CAAC,wBAAwB;IA4BhC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAkFhC;;;;OAIG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAiC/D;;;OAGG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA8CzD;;;OAGG;IACG,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CA+B/C"}
|