skillkit 1.0.0

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/dist/cli.js ADDED
@@ -0,0 +1,2124 @@
1
+ #!/usr/bin/env node
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __esm = (fn, res) => function __init() {
5
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
+ };
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+
12
+ // src/providers/base.ts
13
+ function parseShorthand(source) {
14
+ const cleaned = source.replace(/^\/+|\/+$/g, "");
15
+ const parts = cleaned.split("/");
16
+ if (parts.length < 2) {
17
+ return null;
18
+ }
19
+ const owner = parts[0];
20
+ const repo = parts[1];
21
+ const subpath = parts.length > 2 ? parts.slice(2).join("/") : void 0;
22
+ return { owner, repo, subpath };
23
+ }
24
+ function isLocalPath(source) {
25
+ return source.startsWith("/") || source.startsWith("./") || source.startsWith("../") || source.startsWith("~/") || source.startsWith(".");
26
+ }
27
+ function isGitUrl(source) {
28
+ return source.startsWith("git@") || source.startsWith("https://") || source.startsWith("http://") || source.startsWith("ssh://");
29
+ }
30
+ var init_base = __esm({
31
+ "src/providers/base.ts"() {
32
+ "use strict";
33
+ }
34
+ });
35
+
36
+ // src/core/types.ts
37
+ import { z } from "zod";
38
+ var AgentType, GitProvider, SkillFrontmatter, SkillMetadata, SkillLocation, Skill, SkillkitConfig;
39
+ var init_types = __esm({
40
+ "src/core/types.ts"() {
41
+ "use strict";
42
+ AgentType = z.enum([
43
+ "claude-code",
44
+ "codex",
45
+ "cursor",
46
+ "antigravity",
47
+ "opencode",
48
+ "gemini-cli",
49
+ "universal"
50
+ ]);
51
+ GitProvider = z.enum(["github", "gitlab", "bitbucket", "local"]);
52
+ SkillFrontmatter = z.object({
53
+ name: z.string().min(1).max(64).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/, "Skill name must be lowercase alphanumeric with hyphens, no leading/trailing/consecutive hyphens"),
54
+ description: z.string().min(1).max(1024),
55
+ license: z.string().optional(),
56
+ compatibility: z.string().max(500).optional(),
57
+ metadata: z.record(z.string()).optional(),
58
+ "allowed-tools": z.string().optional(),
59
+ version: z.string().optional(),
60
+ author: z.string().optional(),
61
+ tags: z.array(z.string()).optional(),
62
+ agents: z.array(AgentType).optional()
63
+ });
64
+ SkillMetadata = z.object({
65
+ name: z.string(),
66
+ description: z.string(),
67
+ source: z.string(),
68
+ sourceType: GitProvider,
69
+ subpath: z.string().optional(),
70
+ installedAt: z.string().datetime(),
71
+ updatedAt: z.string().datetime().optional(),
72
+ enabled: z.boolean().default(true),
73
+ version: z.string().optional(),
74
+ checksum: z.string().optional()
75
+ });
76
+ SkillLocation = z.enum(["project", "global"]);
77
+ Skill = z.object({
78
+ name: z.string(),
79
+ description: z.string(),
80
+ path: z.string(),
81
+ location: SkillLocation,
82
+ metadata: SkillMetadata.optional(),
83
+ enabled: z.boolean().default(true)
84
+ });
85
+ SkillkitConfig = z.object({
86
+ version: z.literal(1),
87
+ agent: AgentType.default("universal"),
88
+ skillsDir: z.string().optional(),
89
+ enabledSkills: z.array(z.string()).optional(),
90
+ disabledSkills: z.array(z.string()).optional(),
91
+ autoSync: z.boolean().default(true)
92
+ });
93
+ }
94
+ });
95
+
96
+ // src/core/skills.ts
97
+ import { existsSync, readdirSync, readFileSync } from "fs";
98
+ import { join, basename } from "path";
99
+ import { parse as parseYaml } from "yaml";
100
+ function discoverSkills(dir) {
101
+ const skills = [];
102
+ if (!existsSync(dir)) {
103
+ return skills;
104
+ }
105
+ const entries = readdirSync(dir, { withFileTypes: true });
106
+ for (const entry of entries) {
107
+ if (!entry.isDirectory()) continue;
108
+ const skillPath = join(dir, entry.name);
109
+ const skillMdPath = join(skillPath, "SKILL.md");
110
+ if (existsSync(skillMdPath)) {
111
+ const skill = parseSkill(skillPath);
112
+ if (skill) {
113
+ skills.push(skill);
114
+ }
115
+ }
116
+ }
117
+ return skills;
118
+ }
119
+ function parseSkill(skillPath, location = "project") {
120
+ const skillMdPath = join(skillPath, "SKILL.md");
121
+ if (!existsSync(skillMdPath)) {
122
+ return null;
123
+ }
124
+ try {
125
+ const content = readFileSync(skillMdPath, "utf-8");
126
+ const frontmatter = extractFrontmatter(content);
127
+ if (!frontmatter) {
128
+ const name = basename(skillPath);
129
+ return {
130
+ name,
131
+ description: "No description available",
132
+ path: skillPath,
133
+ location,
134
+ enabled: true
135
+ };
136
+ }
137
+ const parsed = SkillFrontmatter.safeParse(frontmatter);
138
+ if (!parsed.success) {
139
+ return {
140
+ name: frontmatter.name || basename(skillPath),
141
+ description: frontmatter.description || "No description available",
142
+ path: skillPath,
143
+ location,
144
+ enabled: true
145
+ };
146
+ }
147
+ const metadata = loadMetadata(skillPath);
148
+ return {
149
+ name: parsed.data.name,
150
+ description: parsed.data.description,
151
+ path: skillPath,
152
+ location,
153
+ metadata: metadata ?? void 0,
154
+ enabled: metadata?.enabled ?? true
155
+ };
156
+ } catch {
157
+ return null;
158
+ }
159
+ }
160
+ function extractFrontmatter(content) {
161
+ const match = content.match(/^---\s*\n([\s\S]*?)\n---/);
162
+ if (!match) {
163
+ return null;
164
+ }
165
+ try {
166
+ return parseYaml(match[1]);
167
+ } catch {
168
+ return null;
169
+ }
170
+ }
171
+ function loadMetadata(skillPath) {
172
+ const metadataPath = join(skillPath, ".skillkit.json");
173
+ if (!existsSync(metadataPath)) {
174
+ return null;
175
+ }
176
+ try {
177
+ const content = readFileSync(metadataPath, "utf-8");
178
+ const data = JSON.parse(content);
179
+ const parsed = SkillMetadata.safeParse(data);
180
+ return parsed.success ? parsed.data : null;
181
+ } catch {
182
+ return null;
183
+ }
184
+ }
185
+ function readSkillContent(skillPath) {
186
+ const skillMdPath = join(skillPath, "SKILL.md");
187
+ if (!existsSync(skillMdPath)) {
188
+ return null;
189
+ }
190
+ try {
191
+ return readFileSync(skillMdPath, "utf-8");
192
+ } catch {
193
+ return null;
194
+ }
195
+ }
196
+ function findSkill(name, searchDirs) {
197
+ for (const dir of searchDirs) {
198
+ if (!existsSync(dir)) continue;
199
+ const skillPath = join(dir, name);
200
+ if (existsSync(skillPath)) {
201
+ const location = dir.includes(process.cwd()) ? "project" : "global";
202
+ return parseSkill(skillPath, location);
203
+ }
204
+ }
205
+ return null;
206
+ }
207
+ function findAllSkills(searchDirs) {
208
+ const skills = [];
209
+ const seen = /* @__PURE__ */ new Set();
210
+ for (const dir of searchDirs) {
211
+ if (!existsSync(dir)) continue;
212
+ const location = dir.includes(process.cwd()) ? "project" : "global";
213
+ const discovered = discoverSkills(dir);
214
+ for (const skill of discovered) {
215
+ if (!seen.has(skill.name)) {
216
+ seen.add(skill.name);
217
+ skills.push({ ...skill, location });
218
+ }
219
+ }
220
+ }
221
+ return skills;
222
+ }
223
+ function validateSkill(skillPath) {
224
+ const errors = [];
225
+ const warnings = [];
226
+ const dirName = basename(skillPath);
227
+ const skillMdPath = join(skillPath, "SKILL.md");
228
+ if (!existsSync(skillMdPath)) {
229
+ errors.push("Missing SKILL.md file");
230
+ return { valid: false, errors };
231
+ }
232
+ const content = readFileSync(skillMdPath, "utf-8");
233
+ const frontmatter = extractFrontmatter(content);
234
+ if (!frontmatter) {
235
+ errors.push("Missing YAML frontmatter in SKILL.md");
236
+ return { valid: false, errors };
237
+ }
238
+ const parsed = SkillFrontmatter.safeParse(frontmatter);
239
+ if (!parsed.success) {
240
+ for (const issue of parsed.error.issues) {
241
+ errors.push(`${issue.path.join(".") || "frontmatter"}: ${issue.message}`);
242
+ }
243
+ }
244
+ if (parsed.success) {
245
+ const data = parsed.data;
246
+ if (data.name !== dirName) {
247
+ warnings.push(`name "${data.name}" does not match directory name "${dirName}"`);
248
+ }
249
+ if (data.description && data.description.length < 50) {
250
+ warnings.push("description is short; consider describing what the skill does AND when to use it");
251
+ }
252
+ }
253
+ const bodyContent = content.replace(/^---[\s\S]*?---\s*/, "");
254
+ const lineCount = bodyContent.split("\n").length;
255
+ if (lineCount > 500) {
256
+ warnings.push(`SKILL.md has ${lineCount} lines; consider moving detailed content to references/`);
257
+ }
258
+ return { valid: errors.length === 0, errors, warnings };
259
+ }
260
+ function isPathInside(child, parent) {
261
+ const relative = child.replace(parent, "");
262
+ return !relative.startsWith("..") && !relative.includes("/..");
263
+ }
264
+ var init_skills = __esm({
265
+ "src/core/skills.ts"() {
266
+ "use strict";
267
+ init_types();
268
+ }
269
+ });
270
+
271
+ // src/providers/github.ts
272
+ import { execSync } from "child_process";
273
+ import { existsSync as existsSync2, rmSync } from "fs";
274
+ import { join as join2, basename as basename2 } from "path";
275
+ import { tmpdir } from "os";
276
+ import { randomUUID } from "crypto";
277
+ var GitHubProvider;
278
+ var init_github = __esm({
279
+ "src/providers/github.ts"() {
280
+ "use strict";
281
+ init_base();
282
+ init_skills();
283
+ GitHubProvider = class {
284
+ type = "github";
285
+ name = "GitHub";
286
+ baseUrl = "https://github.com";
287
+ parseSource(source) {
288
+ if (source.startsWith("https://github.com/")) {
289
+ const path = source.replace("https://github.com/", "").replace(/\.git$/, "");
290
+ return parseShorthand(path);
291
+ }
292
+ if (source.startsWith("git@github.com:")) {
293
+ const path = source.replace("git@github.com:", "").replace(/\.git$/, "");
294
+ return parseShorthand(path);
295
+ }
296
+ if (!isGitUrl(source) && !source.includes(":")) {
297
+ return parseShorthand(source);
298
+ }
299
+ return null;
300
+ }
301
+ matches(source) {
302
+ return source.startsWith("https://github.com/") || source.startsWith("git@github.com:") || !isGitUrl(source) && !source.includes(":") && source.includes("/");
303
+ }
304
+ getCloneUrl(owner, repo) {
305
+ return `https://github.com/${owner}/${repo}.git`;
306
+ }
307
+ getSshUrl(owner, repo) {
308
+ return `git@github.com:${owner}/${repo}.git`;
309
+ }
310
+ async clone(source, _targetDir, options = {}) {
311
+ const parsed = this.parseSource(source);
312
+ if (!parsed) {
313
+ return { success: false, error: `Invalid GitHub source: ${source}` };
314
+ }
315
+ const { owner, repo, subpath } = parsed;
316
+ const cloneUrl = options.ssh ? this.getSshUrl(owner, repo) : this.getCloneUrl(owner, repo);
317
+ const tempDir = join2(tmpdir(), `skillkit-${randomUUID()}`);
318
+ try {
319
+ const args = ["clone"];
320
+ if (options.depth) {
321
+ args.push("--depth", String(options.depth));
322
+ }
323
+ if (options.branch) {
324
+ args.push("--branch", options.branch);
325
+ }
326
+ args.push(cloneUrl, tempDir);
327
+ execSync(`git ${args.join(" ")}`, {
328
+ stdio: ["pipe", "pipe", "pipe"],
329
+ encoding: "utf-8"
330
+ });
331
+ const searchDir = subpath ? join2(tempDir, subpath) : tempDir;
332
+ const skills = discoverSkills(searchDir);
333
+ return {
334
+ success: true,
335
+ path: searchDir,
336
+ tempRoot: tempDir,
337
+ skills: skills.map((s) => s.name),
338
+ discoveredSkills: skills.map((s) => ({
339
+ name: s.name,
340
+ dirName: basename2(s.path),
341
+ path: s.path
342
+ }))
343
+ };
344
+ } catch (error) {
345
+ if (existsSync2(tempDir)) {
346
+ rmSync(tempDir, { recursive: true, force: true });
347
+ }
348
+ const message = error instanceof Error ? error.message : String(error);
349
+ return { success: false, error: `Failed to clone: ${message}` };
350
+ }
351
+ }
352
+ };
353
+ }
354
+ });
355
+
356
+ // src/providers/gitlab.ts
357
+ import { execSync as execSync2 } from "child_process";
358
+ import { existsSync as existsSync3, rmSync as rmSync2 } from "fs";
359
+ import { join as join3, basename as basename3 } from "path";
360
+ import { tmpdir as tmpdir2 } from "os";
361
+ import { randomUUID as randomUUID2 } from "crypto";
362
+ var GitLabProvider;
363
+ var init_gitlab = __esm({
364
+ "src/providers/gitlab.ts"() {
365
+ "use strict";
366
+ init_base();
367
+ init_skills();
368
+ GitLabProvider = class {
369
+ type = "gitlab";
370
+ name = "GitLab";
371
+ baseUrl = "https://gitlab.com";
372
+ parseSource(source) {
373
+ if (source.startsWith("https://gitlab.com/")) {
374
+ const path = source.replace("https://gitlab.com/", "").replace(/\.git$/, "");
375
+ return parseShorthand(path);
376
+ }
377
+ if (source.startsWith("git@gitlab.com:")) {
378
+ const path = source.replace("git@gitlab.com:", "").replace(/\.git$/, "");
379
+ return parseShorthand(path);
380
+ }
381
+ if (source.startsWith("gitlab:")) {
382
+ return parseShorthand(source.replace("gitlab:", ""));
383
+ }
384
+ if (source.startsWith("gitlab.com/")) {
385
+ return parseShorthand(source.replace("gitlab.com/", ""));
386
+ }
387
+ return null;
388
+ }
389
+ matches(source) {
390
+ return source.startsWith("https://gitlab.com/") || source.startsWith("git@gitlab.com:") || source.startsWith("gitlab:") || source.startsWith("gitlab.com/");
391
+ }
392
+ getCloneUrl(owner, repo) {
393
+ return `https://gitlab.com/${owner}/${repo}.git`;
394
+ }
395
+ getSshUrl(owner, repo) {
396
+ return `git@gitlab.com:${owner}/${repo}.git`;
397
+ }
398
+ async clone(source, _targetDir, options = {}) {
399
+ const parsed = this.parseSource(source);
400
+ if (!parsed) {
401
+ return { success: false, error: `Invalid GitLab source: ${source}` };
402
+ }
403
+ const { owner, repo, subpath } = parsed;
404
+ const cloneUrl = options.ssh ? this.getSshUrl(owner, repo) : this.getCloneUrl(owner, repo);
405
+ const tempDir = join3(tmpdir2(), `skillkit-${randomUUID2()}`);
406
+ try {
407
+ const args = ["clone"];
408
+ if (options.depth) {
409
+ args.push("--depth", String(options.depth));
410
+ }
411
+ if (options.branch) {
412
+ args.push("--branch", options.branch);
413
+ }
414
+ args.push(cloneUrl, tempDir);
415
+ execSync2(`git ${args.join(" ")}`, {
416
+ stdio: ["pipe", "pipe", "pipe"],
417
+ encoding: "utf-8"
418
+ });
419
+ const searchDir = subpath ? join3(tempDir, subpath) : tempDir;
420
+ const skills = discoverSkills(searchDir);
421
+ return {
422
+ success: true,
423
+ path: searchDir,
424
+ tempRoot: tempDir,
425
+ skills: skills.map((s) => s.name),
426
+ discoveredSkills: skills.map((s) => ({
427
+ name: s.name,
428
+ dirName: basename3(s.path),
429
+ path: s.path
430
+ }))
431
+ };
432
+ } catch (error) {
433
+ if (existsSync3(tempDir)) {
434
+ rmSync2(tempDir, { recursive: true, force: true });
435
+ }
436
+ const message = error instanceof Error ? error.message : String(error);
437
+ return { success: false, error: `Failed to clone: ${message}` };
438
+ }
439
+ }
440
+ };
441
+ }
442
+ });
443
+
444
+ // src/providers/bitbucket.ts
445
+ import { execSync as execSync3 } from "child_process";
446
+ import { existsSync as existsSync4, rmSync as rmSync3 } from "fs";
447
+ import { join as join4, basename as basename4 } from "path";
448
+ import { tmpdir as tmpdir3 } from "os";
449
+ import { randomUUID as randomUUID3 } from "crypto";
450
+ var BitbucketProvider;
451
+ var init_bitbucket = __esm({
452
+ "src/providers/bitbucket.ts"() {
453
+ "use strict";
454
+ init_base();
455
+ init_skills();
456
+ BitbucketProvider = class {
457
+ type = "bitbucket";
458
+ name = "Bitbucket";
459
+ baseUrl = "https://bitbucket.org";
460
+ parseSource(source) {
461
+ if (source.startsWith("https://bitbucket.org/")) {
462
+ const path = source.replace("https://bitbucket.org/", "").replace(/\.git$/, "");
463
+ return parseShorthand(path);
464
+ }
465
+ if (source.startsWith("git@bitbucket.org:")) {
466
+ const path = source.replace("git@bitbucket.org:", "").replace(/\.git$/, "");
467
+ return parseShorthand(path);
468
+ }
469
+ if (source.startsWith("bitbucket:")) {
470
+ return parseShorthand(source.replace("bitbucket:", ""));
471
+ }
472
+ if (source.startsWith("bitbucket.org/")) {
473
+ return parseShorthand(source.replace("bitbucket.org/", ""));
474
+ }
475
+ return null;
476
+ }
477
+ matches(source) {
478
+ return source.startsWith("https://bitbucket.org/") || source.startsWith("git@bitbucket.org:") || source.startsWith("bitbucket:") || source.startsWith("bitbucket.org/");
479
+ }
480
+ getCloneUrl(owner, repo) {
481
+ return `https://bitbucket.org/${owner}/${repo}.git`;
482
+ }
483
+ getSshUrl(owner, repo) {
484
+ return `git@bitbucket.org:${owner}/${repo}.git`;
485
+ }
486
+ async clone(source, _targetDir, options = {}) {
487
+ const parsed = this.parseSource(source);
488
+ if (!parsed) {
489
+ return { success: false, error: `Invalid Bitbucket source: ${source}` };
490
+ }
491
+ const { owner, repo, subpath } = parsed;
492
+ const cloneUrl = options.ssh ? this.getSshUrl(owner, repo) : this.getCloneUrl(owner, repo);
493
+ const tempDir = join4(tmpdir3(), `skillkit-${randomUUID3()}`);
494
+ try {
495
+ const args = ["clone"];
496
+ if (options.depth) {
497
+ args.push("--depth", String(options.depth));
498
+ }
499
+ if (options.branch) {
500
+ args.push("--branch", options.branch);
501
+ }
502
+ args.push(cloneUrl, tempDir);
503
+ execSync3(`git ${args.join(" ")}`, {
504
+ stdio: ["pipe", "pipe", "pipe"],
505
+ encoding: "utf-8"
506
+ });
507
+ const searchDir = subpath ? join4(tempDir, subpath) : tempDir;
508
+ const skills = discoverSkills(searchDir);
509
+ return {
510
+ success: true,
511
+ path: searchDir,
512
+ tempRoot: tempDir,
513
+ skills: skills.map((s) => s.name),
514
+ discoveredSkills: skills.map((s) => ({
515
+ name: s.name,
516
+ dirName: basename4(s.path),
517
+ path: s.path
518
+ }))
519
+ };
520
+ } catch (error) {
521
+ if (existsSync4(tempDir)) {
522
+ rmSync3(tempDir, { recursive: true, force: true });
523
+ }
524
+ const message = error instanceof Error ? error.message : String(error);
525
+ return { success: false, error: `Failed to clone: ${message}` };
526
+ }
527
+ }
528
+ };
529
+ }
530
+ });
531
+
532
+ // src/providers/local.ts
533
+ import { existsSync as existsSync5, statSync, realpathSync } from "fs";
534
+ import { join as join5, resolve, basename as basename5 } from "path";
535
+ import { homedir } from "os";
536
+ var LocalProvider;
537
+ var init_local = __esm({
538
+ "src/providers/local.ts"() {
539
+ "use strict";
540
+ init_base();
541
+ init_skills();
542
+ LocalProvider = class {
543
+ type = "local";
544
+ name = "Local Filesystem";
545
+ baseUrl = "";
546
+ parseSource(source) {
547
+ if (!isLocalPath(source)) {
548
+ return null;
549
+ }
550
+ let expandedPath = source;
551
+ if (source.startsWith("~/")) {
552
+ expandedPath = join5(homedir(), source.slice(2));
553
+ }
554
+ const absolutePath = resolve(expandedPath);
555
+ const dirName = basename5(absolutePath);
556
+ return {
557
+ owner: "local",
558
+ repo: dirName,
559
+ subpath: absolutePath
560
+ };
561
+ }
562
+ matches(source) {
563
+ return isLocalPath(source);
564
+ }
565
+ getCloneUrl(_owner, _repo) {
566
+ return "";
567
+ }
568
+ getSshUrl(_owner, _repo) {
569
+ return "";
570
+ }
571
+ async clone(source, _targetDir, _options = {}) {
572
+ const parsed = this.parseSource(source);
573
+ if (!parsed || !parsed.subpath) {
574
+ return { success: false, error: `Invalid local path: ${source}` };
575
+ }
576
+ const sourcePath = parsed.subpath;
577
+ if (!existsSync5(sourcePath)) {
578
+ return { success: false, error: `Path does not exist: ${sourcePath}` };
579
+ }
580
+ const stats = statSync(sourcePath);
581
+ if (!stats.isDirectory()) {
582
+ return { success: false, error: `Path is not a directory: ${sourcePath}` };
583
+ }
584
+ try {
585
+ let actualPath = sourcePath;
586
+ try {
587
+ actualPath = realpathSync(sourcePath);
588
+ } catch {
589
+ }
590
+ const skills = discoverSkills(actualPath);
591
+ return {
592
+ success: true,
593
+ path: actualPath,
594
+ skills: skills.map((s) => s.name)
595
+ };
596
+ } catch (error) {
597
+ const message = error instanceof Error ? error.message : String(error);
598
+ return { success: false, error: `Failed to process local path: ${message}` };
599
+ }
600
+ }
601
+ };
602
+ }
603
+ });
604
+
605
+ // src/providers/index.ts
606
+ var providers_exports = {};
607
+ __export(providers_exports, {
608
+ BitbucketProvider: () => BitbucketProvider,
609
+ GitHubProvider: () => GitHubProvider,
610
+ GitLabProvider: () => GitLabProvider,
611
+ LocalProvider: () => LocalProvider,
612
+ detectProvider: () => detectProvider,
613
+ getAllProviders: () => getAllProviders,
614
+ getProvider: () => getProvider,
615
+ isGitUrl: () => isGitUrl,
616
+ isLocalPath: () => isLocalPath,
617
+ parseShorthand: () => parseShorthand,
618
+ parseSource: () => parseSource
619
+ });
620
+ function getProvider(type) {
621
+ return providers.find((p) => p.type === type);
622
+ }
623
+ function getAllProviders() {
624
+ return providers;
625
+ }
626
+ function detectProvider(source) {
627
+ return providers.find((p) => p.matches(source));
628
+ }
629
+ function parseSource(source) {
630
+ for (const provider of providers) {
631
+ if (provider.matches(source)) {
632
+ const parsed = provider.parseSource(source);
633
+ if (parsed) {
634
+ return { provider, ...parsed };
635
+ }
636
+ }
637
+ }
638
+ return null;
639
+ }
640
+ var providers;
641
+ var init_providers = __esm({
642
+ "src/providers/index.ts"() {
643
+ "use strict";
644
+ init_github();
645
+ init_gitlab();
646
+ init_bitbucket();
647
+ init_local();
648
+ init_base();
649
+ init_github();
650
+ init_gitlab();
651
+ init_bitbucket();
652
+ init_local();
653
+ providers = [
654
+ new LocalProvider(),
655
+ new GitLabProvider(),
656
+ new BitbucketProvider(),
657
+ new GitHubProvider()
658
+ ];
659
+ }
660
+ });
661
+
662
+ // src/cli.ts
663
+ import { Cli, Builtins } from "clipanion";
664
+
665
+ // src/commands/install.ts
666
+ init_providers();
667
+ import { existsSync as existsSync14, mkdirSync as mkdirSync2, cpSync, rmSync as rmSync4 } from "fs";
668
+ import { join as join14 } from "path";
669
+ import chalk from "chalk";
670
+ import ora from "ora";
671
+ import { Command, Option } from "clipanion";
672
+
673
+ // src/core/config.ts
674
+ init_types();
675
+ import { existsSync as existsSync13, readFileSync as readFileSync2, writeFileSync, mkdirSync } from "fs";
676
+ import { join as join13, dirname } from "path";
677
+ import { homedir as homedir7 } from "os";
678
+ import { parse as parseYaml2, stringify as stringifyYaml } from "yaml";
679
+
680
+ // src/agents/claude-code.ts
681
+ import { existsSync as existsSync6 } from "fs";
682
+ import { join as join6 } from "path";
683
+ import { homedir as homedir2 } from "os";
684
+
685
+ // src/agents/base.ts
686
+ function createSkillXml(skill) {
687
+ return `<skill>
688
+ <name>${skill.name}</name>
689
+ <description>${escapeXml(skill.description)}</description>
690
+ <location>${skill.location}</location>
691
+ </skill>`;
692
+ }
693
+ function escapeXml(text) {
694
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
695
+ }
696
+
697
+ // src/agents/claude-code.ts
698
+ var ClaudeCodeAdapter = class {
699
+ type = "claude-code";
700
+ name = "Claude Code";
701
+ skillsDir = ".claude/skills";
702
+ configFile = "AGENTS.md";
703
+ generateConfig(skills) {
704
+ const enabledSkills = skills.filter((s) => s.enabled);
705
+ if (enabledSkills.length === 0) {
706
+ return "";
707
+ }
708
+ const skillsXml = enabledSkills.map(createSkillXml).join("\n\n");
709
+ return `<skills_system priority="1">
710
+
711
+ ## Available Skills
712
+
713
+ <!-- SKILLS_TABLE_START -->
714
+ <usage>
715
+ When users ask you to perform tasks, check if any of the available skills below can help complete the task more effectively. Skills provide specialized capabilities and domain knowledge.
716
+
717
+ How to use skills:
718
+ - Invoke: \`skillkit read <skill-name>\` or \`npx skillkit read <skill-name>\`
719
+ - The skill content will load with detailed instructions on how to complete the task
720
+ - Base directory provided in output for resolving bundled resources (references/, scripts/, assets/)
721
+
722
+ Usage notes:
723
+ - Only use skills listed in <available_skills> below
724
+ - Do not invoke a skill that is already loaded in your context
725
+ - Each skill invocation is stateless
726
+ </usage>
727
+
728
+ <available_skills>
729
+
730
+ ${skillsXml}
731
+
732
+ </available_skills>
733
+ <!-- SKILLS_TABLE_END -->
734
+
735
+ </skills_system>`;
736
+ }
737
+ parseConfig(content) {
738
+ const skillNames = [];
739
+ const skillRegex = /<name>([^<]+)<\/name>/g;
740
+ let match;
741
+ while ((match = skillRegex.exec(content)) !== null) {
742
+ skillNames.push(match[1].trim());
743
+ }
744
+ return skillNames;
745
+ }
746
+ getInvokeCommand(skillName) {
747
+ return `skillkit read ${skillName}`;
748
+ }
749
+ async isDetected() {
750
+ const projectClaude = join6(process.cwd(), ".claude");
751
+ const globalClaude = join6(homedir2(), ".claude");
752
+ const claudeMd = join6(process.cwd(), "CLAUDE.md");
753
+ return existsSync6(projectClaude) || existsSync6(globalClaude) || existsSync6(claudeMd);
754
+ }
755
+ };
756
+
757
+ // src/agents/cursor.ts
758
+ import { existsSync as existsSync7 } from "fs";
759
+ import { join as join7 } from "path";
760
+ var CursorAdapter = class {
761
+ type = "cursor";
762
+ name = "Cursor";
763
+ skillsDir = ".cursor/skills";
764
+ configFile = ".cursorrules";
765
+ generateConfig(skills) {
766
+ const enabledSkills = skills.filter((s) => s.enabled);
767
+ if (enabledSkills.length === 0) {
768
+ return "";
769
+ }
770
+ const skillsList = enabledSkills.map((s) => `- **${s.name}**: ${s.description}`).join("\n");
771
+ const skillsXml = enabledSkills.map(createSkillXml).join("\n\n");
772
+ return `# Skills System
773
+
774
+ You have access to specialized skills that can help complete tasks. Use the skillkit CLI to load skill instructions when needed.
775
+
776
+ ## Available Skills
777
+
778
+ ${skillsList}
779
+
780
+ ## How to Use Skills
781
+
782
+ When a task matches a skill's description, load it with:
783
+ \`\`\`bash
784
+ skillkit read <skill-name>
785
+ \`\`\`
786
+
787
+ The skill will provide detailed instructions for completing the task.
788
+
789
+ <!-- SKILLS_DATA_START -->
790
+ ${skillsXml}
791
+ <!-- SKILLS_DATA_END -->
792
+ `;
793
+ }
794
+ parseConfig(content) {
795
+ const skillNames = [];
796
+ const skillRegex = /<name>([^<]+)<\/name>/g;
797
+ let match;
798
+ while ((match = skillRegex.exec(content)) !== null) {
799
+ skillNames.push(match[1].trim());
800
+ }
801
+ return skillNames;
802
+ }
803
+ getInvokeCommand(skillName) {
804
+ return `skillkit read ${skillName}`;
805
+ }
806
+ async isDetected() {
807
+ const cursorRules = join7(process.cwd(), ".cursorrules");
808
+ const cursorDir = join7(process.cwd(), ".cursor");
809
+ return existsSync7(cursorRules) || existsSync7(cursorDir);
810
+ }
811
+ };
812
+
813
+ // src/agents/codex.ts
814
+ import { existsSync as existsSync8 } from "fs";
815
+ import { join as join8 } from "path";
816
+ import { homedir as homedir3 } from "os";
817
+ var CodexAdapter = class {
818
+ type = "codex";
819
+ name = "OpenAI Codex CLI";
820
+ skillsDir = ".codex/skills";
821
+ configFile = "AGENTS.md";
822
+ generateConfig(skills) {
823
+ const enabledSkills = skills.filter((s) => s.enabled);
824
+ if (enabledSkills.length === 0) {
825
+ return "";
826
+ }
827
+ const skillsList = enabledSkills.map((s) => `| ${s.name} | ${s.description} | \`skillkit read ${s.name}\` |`).join("\n");
828
+ return `# Skills
829
+
830
+ You have access to specialized skills for completing complex tasks.
831
+
832
+ | Skill | Description | Command |
833
+ |-------|-------------|---------|
834
+ ${skillsList}
835
+
836
+ ## Usage
837
+
838
+ When a task matches a skill's capability, run the command to load detailed instructions:
839
+
840
+ \`\`\`bash
841
+ skillkit read <skill-name>
842
+ \`\`\`
843
+
844
+ Skills are loaded on-demand to keep context clean. Only load skills when relevant to the current task.
845
+ `;
846
+ }
847
+ parseConfig(content) {
848
+ const skillNames = [];
849
+ const tableRegex = /^\|\s*([a-z0-9-]+)\s*\|/gm;
850
+ let match;
851
+ while ((match = tableRegex.exec(content)) !== null) {
852
+ const name = match[1].trim();
853
+ if (name && name !== "Skill" && name !== "-------") {
854
+ skillNames.push(name);
855
+ }
856
+ }
857
+ return skillNames;
858
+ }
859
+ getInvokeCommand(skillName) {
860
+ return `skillkit read ${skillName}`;
861
+ }
862
+ async isDetected() {
863
+ const codexDir = join8(process.cwd(), ".codex");
864
+ const globalCodex = join8(homedir3(), ".codex");
865
+ return existsSync8(codexDir) || existsSync8(globalCodex);
866
+ }
867
+ };
868
+
869
+ // src/agents/gemini-cli.ts
870
+ import { existsSync as existsSync9 } from "fs";
871
+ import { join as join9 } from "path";
872
+ import { homedir as homedir4 } from "os";
873
+ var GeminiCliAdapter = class {
874
+ type = "gemini-cli";
875
+ name = "Gemini CLI";
876
+ skillsDir = ".gemini/skills";
877
+ configFile = "GEMINI.md";
878
+ generateConfig(skills) {
879
+ const enabledSkills = skills.filter((s) => s.enabled);
880
+ if (enabledSkills.length === 0) {
881
+ return "";
882
+ }
883
+ const skillsJson = enabledSkills.map((s) => ({
884
+ name: s.name,
885
+ description: s.description,
886
+ invoke: `skillkit read ${s.name}`,
887
+ location: s.location
888
+ }));
889
+ return `# Skills Configuration
890
+
891
+ You have access to specialized skills that extend your capabilities.
892
+
893
+ ## Available Skills
894
+
895
+ ${enabledSkills.map((s) => `### ${s.name}
896
+ ${s.description}
897
+
898
+ Invoke: \`skillkit read ${s.name}\``).join("\n\n")}
899
+
900
+ ## Skills Data
901
+
902
+ \`\`\`json
903
+ ${JSON.stringify(skillsJson, null, 2)}
904
+ \`\`\`
905
+
906
+ ## Usage Instructions
907
+
908
+ 1. When a task matches a skill's description, load it using the invoke command
909
+ 2. Skills provide step-by-step instructions for complex tasks
910
+ 3. Each skill is self-contained with its own resources
911
+ `;
912
+ }
913
+ parseConfig(content) {
914
+ const skillNames = [];
915
+ const jsonMatch = content.match(/```json\s*([\s\S]*?)```/);
916
+ if (jsonMatch) {
917
+ try {
918
+ const skills = JSON.parse(jsonMatch[1]);
919
+ if (Array.isArray(skills)) {
920
+ skills.forEach((s) => {
921
+ if (s.name) skillNames.push(s.name);
922
+ });
923
+ }
924
+ } catch {
925
+ }
926
+ }
927
+ if (skillNames.length === 0) {
928
+ const headerRegex = /^### ([a-z0-9-]+)$/gm;
929
+ let match;
930
+ while ((match = headerRegex.exec(content)) !== null) {
931
+ skillNames.push(match[1].trim());
932
+ }
933
+ }
934
+ return skillNames;
935
+ }
936
+ getInvokeCommand(skillName) {
937
+ return `skillkit read ${skillName}`;
938
+ }
939
+ async isDetected() {
940
+ const geminiMd = join9(process.cwd(), "GEMINI.md");
941
+ const geminiDir = join9(process.cwd(), ".gemini");
942
+ const globalGemini = join9(homedir4(), ".gemini");
943
+ return existsSync9(geminiMd) || existsSync9(geminiDir) || existsSync9(globalGemini);
944
+ }
945
+ };
946
+
947
+ // src/agents/opencode.ts
948
+ import { existsSync as existsSync10 } from "fs";
949
+ import { join as join10 } from "path";
950
+ import { homedir as homedir5 } from "os";
951
+ var OpenCodeAdapter = class {
952
+ type = "opencode";
953
+ name = "OpenCode";
954
+ skillsDir = ".opencode/skills";
955
+ configFile = "AGENTS.md";
956
+ generateConfig(skills) {
957
+ const enabledSkills = skills.filter((s) => s.enabled);
958
+ if (enabledSkills.length === 0) {
959
+ return "";
960
+ }
961
+ const skillsXml = enabledSkills.map(createSkillXml).join("\n\n");
962
+ return `<!-- SKILLKIT_START -->
963
+ # Skills
964
+
965
+ The following skills are available to help complete tasks:
966
+
967
+ <skills>
968
+ ${skillsXml}
969
+ </skills>
970
+
971
+ ## How to Use
972
+
973
+ When a task matches a skill's description:
974
+
975
+ \`\`\`bash
976
+ skillkit read <skill-name>
977
+ \`\`\`
978
+
979
+ This loads the skill's instructions into context.
980
+
981
+ <!-- SKILLKIT_END -->`;
982
+ }
983
+ parseConfig(content) {
984
+ const skillNames = [];
985
+ const skillRegex = /<name>([^<]+)<\/name>/g;
986
+ let match;
987
+ while ((match = skillRegex.exec(content)) !== null) {
988
+ skillNames.push(match[1].trim());
989
+ }
990
+ return skillNames;
991
+ }
992
+ getInvokeCommand(skillName) {
993
+ return `skillkit read ${skillName}`;
994
+ }
995
+ async isDetected() {
996
+ const opencodeDir = join10(process.cwd(), ".opencode");
997
+ const globalOpencode = join10(homedir5(), ".opencode");
998
+ return existsSync10(opencodeDir) || existsSync10(globalOpencode);
999
+ }
1000
+ };
1001
+
1002
+ // src/agents/antigravity.ts
1003
+ import { existsSync as existsSync11 } from "fs";
1004
+ import { join as join11 } from "path";
1005
+ import { homedir as homedir6 } from "os";
1006
+ var AntigravityAdapter = class {
1007
+ type = "antigravity";
1008
+ name = "Antigravity";
1009
+ skillsDir = ".antigravity/skills";
1010
+ configFile = "AGENTS.md";
1011
+ generateConfig(skills) {
1012
+ const enabledSkills = skills.filter((s) => s.enabled);
1013
+ if (enabledSkills.length === 0) {
1014
+ return "";
1015
+ }
1016
+ const skillsYaml = enabledSkills.map((s) => ` - name: ${s.name}
1017
+ description: "${s.description}"
1018
+ invoke: skillkit read ${s.name}`).join("\n");
1019
+ return `# Antigravity Skills Configuration
1020
+
1021
+ <!-- skills:
1022
+ ${skillsYaml}
1023
+ -->
1024
+
1025
+ ## Available Skills
1026
+
1027
+ ${enabledSkills.map((s) => `### ${s.name}
1028
+
1029
+ ${s.description}
1030
+
1031
+ **Usage:** \`skillkit read ${s.name}\`
1032
+ `).join("\n")}
1033
+
1034
+ ## How Skills Work
1035
+
1036
+ 1. Skills provide specialized knowledge for specific tasks
1037
+ 2. Load a skill when the current task matches its description
1038
+ 3. Skills are loaded on-demand to preserve context window
1039
+ `;
1040
+ }
1041
+ parseConfig(content) {
1042
+ const skillNames = [];
1043
+ const yamlMatch = content.match(/<!-- skills:\s*([\s\S]*?)-->/);
1044
+ if (yamlMatch) {
1045
+ const nameRegex = /name:\s*([a-z0-9-]+)/g;
1046
+ let match;
1047
+ while ((match = nameRegex.exec(yamlMatch[1])) !== null) {
1048
+ skillNames.push(match[1].trim());
1049
+ }
1050
+ }
1051
+ if (skillNames.length === 0) {
1052
+ const headerRegex = /^### ([a-z0-9-]+)$/gm;
1053
+ let match;
1054
+ while ((match = headerRegex.exec(content)) !== null) {
1055
+ skillNames.push(match[1].trim());
1056
+ }
1057
+ }
1058
+ return skillNames;
1059
+ }
1060
+ getInvokeCommand(skillName) {
1061
+ return `skillkit read ${skillName}`;
1062
+ }
1063
+ async isDetected() {
1064
+ const agDir = join11(process.cwd(), ".antigravity");
1065
+ const globalAg = join11(homedir6(), ".antigravity");
1066
+ return existsSync11(agDir) || existsSync11(globalAg);
1067
+ }
1068
+ };
1069
+
1070
+ // src/agents/universal.ts
1071
+ import { existsSync as existsSync12 } from "fs";
1072
+ import { join as join12 } from "path";
1073
+ var UniversalAdapter = class {
1074
+ type = "universal";
1075
+ name = "Universal (Any Agent)";
1076
+ skillsDir = ".agent/skills";
1077
+ configFile = "AGENTS.md";
1078
+ generateConfig(skills) {
1079
+ const enabledSkills = skills.filter((s) => s.enabled);
1080
+ if (enabledSkills.length === 0) {
1081
+ return "";
1082
+ }
1083
+ const skillsXml = enabledSkills.map(createSkillXml).join("\n\n");
1084
+ const skillsList = enabledSkills.map((s) => `- **${s.name}**: ${s.description}`).join("\n");
1085
+ return `# Skills System
1086
+
1087
+ <!-- SKILLKIT_SKILLS_START -->
1088
+
1089
+ ## Available Skills
1090
+
1091
+ ${skillsList}
1092
+
1093
+ ## How to Use Skills
1094
+
1095
+ When a task matches one of the available skills, load it to get detailed instructions:
1096
+
1097
+ \`\`\`bash
1098
+ skillkit read <skill-name>
1099
+ \`\`\`
1100
+
1101
+ Or with npx:
1102
+
1103
+ \`\`\`bash
1104
+ npx skillkit read <skill-name>
1105
+ \`\`\`
1106
+
1107
+ ## Skills Data
1108
+
1109
+ <skills_system>
1110
+ <usage>
1111
+ Skills provide specialized capabilities and domain knowledge.
1112
+ - Invoke: \`skillkit read <skill-name>\`
1113
+ - Base directory provided in output for resolving resources
1114
+ - Only use skills listed below
1115
+ - Each invocation is stateless
1116
+ </usage>
1117
+
1118
+ <available_skills>
1119
+
1120
+ ${skillsXml}
1121
+
1122
+ </available_skills>
1123
+ </skills_system>
1124
+
1125
+ <!-- SKILLKIT_SKILLS_END -->
1126
+ `;
1127
+ }
1128
+ parseConfig(content) {
1129
+ const skillNames = [];
1130
+ const skillRegex = /<name>([^<]+)<\/name>/g;
1131
+ let match;
1132
+ while ((match = skillRegex.exec(content)) !== null) {
1133
+ skillNames.push(match[1].trim());
1134
+ }
1135
+ if (skillNames.length === 0) {
1136
+ const listRegex = /^- \*\*([a-z0-9-]+)\*\*:/gm;
1137
+ while ((match = listRegex.exec(content)) !== null) {
1138
+ skillNames.push(match[1].trim());
1139
+ }
1140
+ }
1141
+ return skillNames;
1142
+ }
1143
+ getInvokeCommand(skillName) {
1144
+ return `skillkit read ${skillName}`;
1145
+ }
1146
+ async isDetected() {
1147
+ const agentDir = join12(process.cwd(), ".agent");
1148
+ const agentsMd = join12(process.cwd(), "AGENTS.md");
1149
+ return existsSync12(agentDir) || existsSync12(agentsMd);
1150
+ }
1151
+ };
1152
+
1153
+ // src/agents/index.ts
1154
+ var adapters = {
1155
+ "claude-code": new ClaudeCodeAdapter(),
1156
+ cursor: new CursorAdapter(),
1157
+ codex: new CodexAdapter(),
1158
+ "gemini-cli": new GeminiCliAdapter(),
1159
+ opencode: new OpenCodeAdapter(),
1160
+ antigravity: new AntigravityAdapter(),
1161
+ universal: new UniversalAdapter()
1162
+ };
1163
+ function getAdapter(type) {
1164
+ return adapters[type];
1165
+ }
1166
+ function getAllAdapters() {
1167
+ return Object.values(adapters);
1168
+ }
1169
+ async function detectAgent() {
1170
+ const checkOrder = [
1171
+ "claude-code",
1172
+ "cursor",
1173
+ "codex",
1174
+ "gemini-cli",
1175
+ "opencode",
1176
+ "antigravity",
1177
+ "universal"
1178
+ ];
1179
+ for (const type of checkOrder) {
1180
+ const adapter = adapters[type];
1181
+ if (await adapter.isDetected()) {
1182
+ return type;
1183
+ }
1184
+ }
1185
+ return "universal";
1186
+ }
1187
+
1188
+ // src/core/config.ts
1189
+ var CONFIG_FILE = "skillkit.yaml";
1190
+ var METADATA_FILE = ".skillkit.json";
1191
+ function getProjectConfigPath() {
1192
+ return join13(process.cwd(), CONFIG_FILE);
1193
+ }
1194
+ function getGlobalConfigPath() {
1195
+ return join13(homedir7(), ".config", "skillkit", CONFIG_FILE);
1196
+ }
1197
+ function loadConfig() {
1198
+ const projectPath = getProjectConfigPath();
1199
+ const globalPath = getGlobalConfigPath();
1200
+ if (existsSync13(projectPath)) {
1201
+ try {
1202
+ const content = readFileSync2(projectPath, "utf-8");
1203
+ const data = parseYaml2(content);
1204
+ const parsed = SkillkitConfig.safeParse(data);
1205
+ if (parsed.success) {
1206
+ return parsed.data;
1207
+ }
1208
+ } catch {
1209
+ }
1210
+ }
1211
+ if (existsSync13(globalPath)) {
1212
+ try {
1213
+ const content = readFileSync2(globalPath, "utf-8");
1214
+ const data = parseYaml2(content);
1215
+ const parsed = SkillkitConfig.safeParse(data);
1216
+ if (parsed.success) {
1217
+ return parsed.data;
1218
+ }
1219
+ } catch {
1220
+ }
1221
+ }
1222
+ return {
1223
+ version: 1,
1224
+ agent: "universal",
1225
+ autoSync: true
1226
+ };
1227
+ }
1228
+ function saveConfig(config, global = false) {
1229
+ const configPath = global ? getGlobalConfigPath() : getProjectConfigPath();
1230
+ const dir = dirname(configPath);
1231
+ if (!existsSync13(dir)) {
1232
+ mkdirSync(dir, { recursive: true });
1233
+ }
1234
+ const content = stringifyYaml(config);
1235
+ writeFileSync(configPath, content, "utf-8");
1236
+ }
1237
+ function getSearchDirs(agentType) {
1238
+ const type = agentType || loadConfig().agent;
1239
+ const adapter = getAdapter(type);
1240
+ const dirs = [];
1241
+ dirs.push(join13(process.cwd(), adapter.skillsDir));
1242
+ dirs.push(join13(process.cwd(), ".agent", "skills"));
1243
+ dirs.push(join13(homedir7(), adapter.skillsDir));
1244
+ dirs.push(join13(homedir7(), ".agent", "skills"));
1245
+ return dirs;
1246
+ }
1247
+ function getInstallDir(global = false, agentType) {
1248
+ const type = agentType || loadConfig().agent;
1249
+ const adapter = getAdapter(type);
1250
+ if (global) {
1251
+ return join13(homedir7(), adapter.skillsDir);
1252
+ }
1253
+ return join13(process.cwd(), adapter.skillsDir);
1254
+ }
1255
+ function getAgentConfigPath(agentType) {
1256
+ const type = agentType || loadConfig().agent;
1257
+ const adapter = getAdapter(type);
1258
+ return join13(process.cwd(), adapter.configFile);
1259
+ }
1260
+ function saveSkillMetadata(skillPath, metadata) {
1261
+ const metadataPath = join13(skillPath, METADATA_FILE);
1262
+ writeFileSync(metadataPath, JSON.stringify(metadata, null, 2), "utf-8");
1263
+ }
1264
+ function loadSkillMetadata(skillPath) {
1265
+ const metadataPath = join13(skillPath, METADATA_FILE);
1266
+ if (!existsSync13(metadataPath)) {
1267
+ return null;
1268
+ }
1269
+ try {
1270
+ const content = readFileSync2(metadataPath, "utf-8");
1271
+ return JSON.parse(content);
1272
+ } catch {
1273
+ return null;
1274
+ }
1275
+ }
1276
+ function setSkillEnabled(skillPath, enabled) {
1277
+ const metadata = loadSkillMetadata(skillPath);
1278
+ if (!metadata) {
1279
+ return false;
1280
+ }
1281
+ metadata.enabled = enabled;
1282
+ metadata.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1283
+ saveSkillMetadata(skillPath, metadata);
1284
+ return true;
1285
+ }
1286
+ async function initProject(agentType) {
1287
+ const type = agentType || await detectAgent();
1288
+ const adapter = getAdapter(type);
1289
+ const skillsDir = join13(process.cwd(), adapter.skillsDir);
1290
+ if (!existsSync13(skillsDir)) {
1291
+ mkdirSync(skillsDir, { recursive: true });
1292
+ }
1293
+ const config = {
1294
+ version: 1,
1295
+ agent: type,
1296
+ autoSync: true
1297
+ };
1298
+ saveConfig(config);
1299
+ const agentConfigPath = join13(process.cwd(), adapter.configFile);
1300
+ if (!existsSync13(agentConfigPath)) {
1301
+ writeFileSync(agentConfigPath, `# ${adapter.name} Configuration
1302
+
1303
+ `, "utf-8");
1304
+ }
1305
+ }
1306
+
1307
+ // src/commands/install.ts
1308
+ init_skills();
1309
+ var InstallCommand = class extends Command {
1310
+ static paths = [["install"], ["i"]];
1311
+ static usage = Command.Usage({
1312
+ description: "Install skills from GitHub, GitLab, Bitbucket, or local path",
1313
+ examples: [
1314
+ ["Install from GitHub", "$0 install owner/repo"],
1315
+ ["Install from GitLab", "$0 install gitlab:owner/repo"],
1316
+ ["Install from Bitbucket", "$0 install bitbucket:owner/repo"],
1317
+ ["Install specific skills (CI/CD)", "$0 install owner/repo --skills=pdf,xlsx"],
1318
+ ["Install all skills non-interactively", "$0 install owner/repo --all"],
1319
+ ["Install from local path", "$0 install ./my-skills"],
1320
+ ["Install globally", "$0 install owner/repo --global"]
1321
+ ]
1322
+ });
1323
+ source = Option.String({ required: true });
1324
+ skills = Option.String("--skills,-s", {
1325
+ description: "Comma-separated list of skills to install (non-interactive)"
1326
+ });
1327
+ all = Option.Boolean("--all,-a", false, {
1328
+ description: "Install all discovered skills (non-interactive)"
1329
+ });
1330
+ yes = Option.Boolean("--yes,-y", false, {
1331
+ description: "Skip confirmation prompts"
1332
+ });
1333
+ global = Option.Boolean("--global,-g", false, {
1334
+ description: "Install to global skills directory"
1335
+ });
1336
+ force = Option.Boolean("--force,-f", false, {
1337
+ description: "Overwrite existing skills"
1338
+ });
1339
+ provider = Option.String("--provider,-p", {
1340
+ description: "Force specific provider (github, gitlab, bitbucket)"
1341
+ });
1342
+ async execute() {
1343
+ const spinner = ora();
1344
+ try {
1345
+ let providerAdapter = detectProvider(this.source);
1346
+ if (this.provider) {
1347
+ const { getProvider: getProvider2 } = await Promise.resolve().then(() => (init_providers(), providers_exports));
1348
+ providerAdapter = getProvider2(this.provider);
1349
+ }
1350
+ if (!providerAdapter) {
1351
+ console.error(chalk.red(`Could not detect provider for: ${this.source}`));
1352
+ console.error(chalk.dim("Use --provider flag or specify source as:"));
1353
+ console.error(chalk.dim(" GitHub: owner/repo or https://github.com/owner/repo"));
1354
+ console.error(chalk.dim(" GitLab: gitlab:owner/repo or https://gitlab.com/owner/repo"));
1355
+ console.error(chalk.dim(" Bitbucket: bitbucket:owner/repo"));
1356
+ console.error(chalk.dim(" Local: ./path or ~/path"));
1357
+ return 1;
1358
+ }
1359
+ spinner.start(`Fetching from ${providerAdapter.name}...`);
1360
+ const result = await providerAdapter.clone(this.source, "", { depth: 1 });
1361
+ if (!result.success || !result.path) {
1362
+ spinner.fail(chalk.red(result.error || "Failed to fetch source"));
1363
+ return 1;
1364
+ }
1365
+ spinner.succeed(`Found ${result.skills?.length || 0} skill(s)`);
1366
+ const discoveredSkills = result.discoveredSkills || [];
1367
+ let skillsToInstall = discoveredSkills;
1368
+ if (this.skills) {
1369
+ const requestedSkills = this.skills.split(",").map((s) => s.trim());
1370
+ const available = discoveredSkills.map((s) => s.name);
1371
+ const notFound = requestedSkills.filter((s) => !available.includes(s));
1372
+ if (notFound.length > 0) {
1373
+ console.error(chalk.red(`Skills not found: ${notFound.join(", ")}`));
1374
+ console.error(chalk.dim(`Available: ${available.join(", ")}`));
1375
+ return 1;
1376
+ }
1377
+ skillsToInstall = discoveredSkills.filter((s) => requestedSkills.includes(s.name));
1378
+ } else if (this.all || this.yes) {
1379
+ skillsToInstall = discoveredSkills;
1380
+ } else {
1381
+ skillsToInstall = discoveredSkills;
1382
+ if (skillsToInstall.length > 0) {
1383
+ console.log(chalk.cyan("\nSkills to install:"));
1384
+ skillsToInstall.forEach((s) => console.log(chalk.dim(` - ${s.name}`)));
1385
+ console.log();
1386
+ }
1387
+ }
1388
+ if (skillsToInstall.length === 0) {
1389
+ console.log(chalk.yellow("No skills to install"));
1390
+ return 0;
1391
+ }
1392
+ const installDir = getInstallDir(this.global);
1393
+ if (!existsSync14(installDir)) {
1394
+ mkdirSync2(installDir, { recursive: true });
1395
+ }
1396
+ let installed = 0;
1397
+ for (const skill of skillsToInstall) {
1398
+ const skillName = skill.name;
1399
+ const sourcePath = skill.path;
1400
+ const targetPath = join14(installDir, skillName);
1401
+ if (existsSync14(targetPath) && !this.force) {
1402
+ console.log(chalk.yellow(` Skipping ${skillName} (already exists, use --force to overwrite)`));
1403
+ continue;
1404
+ }
1405
+ const securityRoot = result.tempRoot || result.path;
1406
+ if (!isPathInside(sourcePath, securityRoot)) {
1407
+ console.log(chalk.red(` Skipping ${skillName} (path traversal detected)`));
1408
+ continue;
1409
+ }
1410
+ spinner.start(`Installing ${skillName}...`);
1411
+ try {
1412
+ if (existsSync14(targetPath)) {
1413
+ rmSync4(targetPath, { recursive: true, force: true });
1414
+ }
1415
+ cpSync(sourcePath, targetPath, { recursive: true, dereference: true });
1416
+ const metadata = {
1417
+ name: skillName,
1418
+ description: "",
1419
+ source: this.source,
1420
+ sourceType: providerAdapter.type,
1421
+ subpath: skillName,
1422
+ installedAt: (/* @__PURE__ */ new Date()).toISOString(),
1423
+ enabled: true
1424
+ };
1425
+ saveSkillMetadata(targetPath, metadata);
1426
+ spinner.succeed(chalk.green(`Installed ${skillName}`));
1427
+ installed++;
1428
+ } catch (error) {
1429
+ spinner.fail(chalk.red(`Failed to install ${skillName}`));
1430
+ console.error(chalk.dim(error instanceof Error ? error.message : String(error)));
1431
+ }
1432
+ }
1433
+ const cleanupPath = result.tempRoot || result.path;
1434
+ if (!isLocalPath(this.source) && cleanupPath && existsSync14(cleanupPath)) {
1435
+ rmSync4(cleanupPath, { recursive: true, force: true });
1436
+ }
1437
+ console.log();
1438
+ console.log(chalk.green(`Installed ${installed} skill(s) to ${installDir}`));
1439
+ if (!this.yes) {
1440
+ console.log(chalk.dim("\nRun `skillkit sync` to update your agent config"));
1441
+ }
1442
+ return 0;
1443
+ } catch (error) {
1444
+ spinner.fail(chalk.red("Installation failed"));
1445
+ console.error(chalk.dim(error instanceof Error ? error.message : String(error)));
1446
+ return 1;
1447
+ }
1448
+ }
1449
+ };
1450
+
1451
+ // src/commands/sync.ts
1452
+ import { existsSync as existsSync15, readFileSync as readFileSync3, writeFileSync as writeFileSync2, mkdirSync as mkdirSync3 } from "fs";
1453
+ import { dirname as dirname2 } from "path";
1454
+ import chalk2 from "chalk";
1455
+ import { Command as Command2, Option as Option2 } from "clipanion";
1456
+ init_skills();
1457
+ var SyncCommand = class extends Command2 {
1458
+ static paths = [["sync"], ["s"]];
1459
+ static usage = Command2.Usage({
1460
+ description: "Sync skills to agent configuration file",
1461
+ examples: [
1462
+ ["Sync all enabled skills", "$0 sync"],
1463
+ ["Sync to specific file", "$0 sync --output AGENTS.md"],
1464
+ ["Sync for specific agent", "$0 sync --agent cursor"],
1465
+ ["Only sync enabled skills", "$0 sync --enabled-only"]
1466
+ ]
1467
+ });
1468
+ output = Option2.String("--output,-o", {
1469
+ description: "Output file path (default: agent-specific config file)"
1470
+ });
1471
+ agent = Option2.String("--agent,-a", {
1472
+ description: "Target agent type (claude-code, cursor, codex, etc.)"
1473
+ });
1474
+ enabledOnly = Option2.Boolean("--enabled-only,-e", true, {
1475
+ description: "Only include enabled skills (default: true)"
1476
+ });
1477
+ yes = Option2.Boolean("--yes,-y", false, {
1478
+ description: "Skip confirmation prompts"
1479
+ });
1480
+ async execute() {
1481
+ try {
1482
+ let agentType;
1483
+ if (this.agent) {
1484
+ agentType = this.agent;
1485
+ } else {
1486
+ const config2 = loadConfig();
1487
+ agentType = config2.agent || await detectAgent();
1488
+ }
1489
+ const adapter = getAdapter(agentType);
1490
+ const outputPath = this.output || getAgentConfigPath(agentType);
1491
+ const searchDirs = getSearchDirs(agentType);
1492
+ let skills = findAllSkills(searchDirs);
1493
+ if (this.enabledOnly) {
1494
+ skills = skills.filter((s) => s.enabled);
1495
+ }
1496
+ if (skills.length === 0) {
1497
+ console.log(chalk2.yellow("No skills found to sync"));
1498
+ console.log(chalk2.dim("Install skills with: skillkit install <source>"));
1499
+ return 0;
1500
+ }
1501
+ console.log(chalk2.cyan(`Syncing ${skills.length} skill(s) for ${adapter.name}:`));
1502
+ skills.forEach((s) => {
1503
+ const status = s.enabled ? chalk2.green("\u2713") : chalk2.dim("\u25CB");
1504
+ const location = s.location === "project" ? chalk2.blue("[project]") : chalk2.dim("[global]");
1505
+ console.log(` ${status} ${s.name} ${location}`);
1506
+ });
1507
+ console.log();
1508
+ const config = adapter.generateConfig(skills);
1509
+ if (!config) {
1510
+ console.log(chalk2.yellow("No configuration generated"));
1511
+ return 0;
1512
+ }
1513
+ let existingContent = "";
1514
+ if (existsSync15(outputPath)) {
1515
+ existingContent = readFileSync3(outputPath, "utf-8");
1516
+ }
1517
+ const newContent = updateConfigContent(existingContent, config, agentType);
1518
+ const dir = dirname2(outputPath);
1519
+ if (!existsSync15(dir)) {
1520
+ mkdirSync3(dir, { recursive: true });
1521
+ }
1522
+ writeFileSync2(outputPath, newContent, "utf-8");
1523
+ console.log(chalk2.green(`Synced to ${outputPath}`));
1524
+ console.log(chalk2.dim(`Agent: ${adapter.name}`));
1525
+ return 0;
1526
+ } catch (error) {
1527
+ console.error(chalk2.red("Sync failed"));
1528
+ console.error(chalk2.dim(error instanceof Error ? error.message : String(error)));
1529
+ return 1;
1530
+ }
1531
+ }
1532
+ };
1533
+ function updateConfigContent(existing, newConfig, agentType) {
1534
+ const markers = {
1535
+ "claude-code": {
1536
+ start: "<!-- SKILLS_TABLE_START -->",
1537
+ end: "<!-- SKILLS_TABLE_END -->"
1538
+ },
1539
+ cursor: {
1540
+ start: "<!-- SKILLS_DATA_START -->",
1541
+ end: "<!-- SKILLS_DATA_END -->"
1542
+ },
1543
+ universal: {
1544
+ start: "<!-- SKILLKIT_SKILLS_START -->",
1545
+ end: "<!-- SKILLKIT_SKILLS_END -->"
1546
+ }
1547
+ };
1548
+ const agentMarkers = markers[agentType] || markers.universal;
1549
+ const startIdx = existing.indexOf(agentMarkers.start);
1550
+ const endIdx = existing.indexOf(agentMarkers.end);
1551
+ if (startIdx !== -1 && endIdx !== -1) {
1552
+ return existing.slice(0, startIdx) + newConfig.slice(newConfig.indexOf(agentMarkers.start)) + existing.slice(endIdx + agentMarkers.end.length);
1553
+ }
1554
+ const genericStart = "<!-- SKILLKIT_SKILLS_START -->";
1555
+ const genericEnd = "<!-- SKILLKIT_SKILLS_END -->";
1556
+ const gStartIdx = existing.indexOf(genericStart);
1557
+ const gEndIdx = existing.indexOf(genericEnd);
1558
+ if (gStartIdx !== -1 && gEndIdx !== -1) {
1559
+ return existing.slice(0, gStartIdx) + newConfig + existing.slice(gEndIdx + genericEnd.length);
1560
+ }
1561
+ if (existing.trim()) {
1562
+ return existing + "\n\n" + newConfig;
1563
+ }
1564
+ return newConfig;
1565
+ }
1566
+
1567
+ // src/commands/read.ts
1568
+ import chalk3 from "chalk";
1569
+ import { Command as Command3, Option as Option3 } from "clipanion";
1570
+ init_skills();
1571
+ var ReadCommand = class extends Command3 {
1572
+ static paths = [["read"], ["r"]];
1573
+ static usage = Command3.Usage({
1574
+ description: "Read skill content for AI agent consumption",
1575
+ examples: [
1576
+ ["Read a single skill", "$0 read pdf"],
1577
+ ["Read multiple skills", "$0 read pdf,xlsx,docx"],
1578
+ ["Read with verbose output", "$0 read pdf --verbose"]
1579
+ ]
1580
+ });
1581
+ skills = Option3.String({ required: true });
1582
+ verbose = Option3.Boolean("--verbose,-v", false, {
1583
+ description: "Show additional information"
1584
+ });
1585
+ async execute() {
1586
+ const searchDirs = getSearchDirs();
1587
+ const skillNames = this.skills.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
1588
+ if (skillNames.length === 0) {
1589
+ console.error(chalk3.red("No skill names provided"));
1590
+ return 1;
1591
+ }
1592
+ let exitCode = 0;
1593
+ for (const skillName of skillNames) {
1594
+ const skill = findSkill(skillName, searchDirs);
1595
+ if (!skill) {
1596
+ console.error(chalk3.red(`Skill not found: ${skillName}`));
1597
+ console.error(chalk3.dim("Available directories:"));
1598
+ searchDirs.forEach((d) => console.error(chalk3.dim(` - ${d}`)));
1599
+ exitCode = 1;
1600
+ continue;
1601
+ }
1602
+ if (!skill.enabled) {
1603
+ console.error(chalk3.yellow(`Skill disabled: ${skillName}`));
1604
+ console.error(chalk3.dim("Enable with: skillkit enable " + skillName));
1605
+ exitCode = 1;
1606
+ continue;
1607
+ }
1608
+ const content = readSkillContent(skill.path);
1609
+ if (!content) {
1610
+ console.error(chalk3.red(`Could not read SKILL.md for: ${skillName}`));
1611
+ exitCode = 1;
1612
+ continue;
1613
+ }
1614
+ console.log(`Reading: ${skillName}`);
1615
+ console.log(`Base directory: ${skill.path}`);
1616
+ console.log();
1617
+ console.log(content);
1618
+ console.log();
1619
+ console.log(`Skill read: ${skillName}`);
1620
+ if (skillNames.length > 1 && skillName !== skillNames[skillNames.length - 1]) {
1621
+ console.log("\n---\n");
1622
+ }
1623
+ }
1624
+ return exitCode;
1625
+ }
1626
+ };
1627
+
1628
+ // src/commands/list.ts
1629
+ import chalk4 from "chalk";
1630
+ import { Command as Command4, Option as Option4 } from "clipanion";
1631
+ init_skills();
1632
+ var ListCommand = class extends Command4 {
1633
+ static paths = [["list"], ["ls"], ["l"]];
1634
+ static usage = Command4.Usage({
1635
+ description: "List all installed skills",
1636
+ examples: [
1637
+ ["List all skills", "$0 list"],
1638
+ ["Show only enabled skills", "$0 list --enabled"],
1639
+ ["Show JSON output", "$0 list --json"]
1640
+ ]
1641
+ });
1642
+ enabled = Option4.Boolean("--enabled,-e", false, {
1643
+ description: "Show only enabled skills"
1644
+ });
1645
+ disabled = Option4.Boolean("--disabled,-d", false, {
1646
+ description: "Show only disabled skills"
1647
+ });
1648
+ json = Option4.Boolean("--json,-j", false, {
1649
+ description: "Output as JSON"
1650
+ });
1651
+ async execute() {
1652
+ const searchDirs = getSearchDirs();
1653
+ let skills = findAllSkills(searchDirs);
1654
+ if (this.enabled) {
1655
+ skills = skills.filter((s) => s.enabled);
1656
+ } else if (this.disabled) {
1657
+ skills = skills.filter((s) => !s.enabled);
1658
+ }
1659
+ skills.sort((a, b) => {
1660
+ if (a.location !== b.location) {
1661
+ return a.location === "project" ? -1 : 1;
1662
+ }
1663
+ return a.name.localeCompare(b.name);
1664
+ });
1665
+ if (this.json) {
1666
+ console.log(JSON.stringify(skills, null, 2));
1667
+ return 0;
1668
+ }
1669
+ if (skills.length === 0) {
1670
+ console.log(chalk4.yellow("No skills installed"));
1671
+ console.log(chalk4.dim("Install skills with: skillkit install <source>"));
1672
+ return 0;
1673
+ }
1674
+ console.log(chalk4.cyan(`Installed skills (${skills.length}):
1675
+ `));
1676
+ const projectSkills = skills.filter((s) => s.location === "project");
1677
+ const globalSkills = skills.filter((s) => s.location === "global");
1678
+ if (projectSkills.length > 0) {
1679
+ console.log(chalk4.blue("Project skills:"));
1680
+ for (const skill of projectSkills) {
1681
+ printSkill(skill);
1682
+ }
1683
+ console.log();
1684
+ }
1685
+ if (globalSkills.length > 0) {
1686
+ console.log(chalk4.dim("Global skills:"));
1687
+ for (const skill of globalSkills) {
1688
+ printSkill(skill);
1689
+ }
1690
+ console.log();
1691
+ }
1692
+ const enabledCount = skills.filter((s) => s.enabled).length;
1693
+ const disabledCount = skills.length - enabledCount;
1694
+ console.log(
1695
+ chalk4.dim(
1696
+ `${projectSkills.length} project, ${globalSkills.length} global` + (disabledCount > 0 ? `, ${disabledCount} disabled` : "")
1697
+ )
1698
+ );
1699
+ return 0;
1700
+ }
1701
+ };
1702
+ function printSkill(skill) {
1703
+ const status = skill.enabled ? chalk4.green("\u2713") : chalk4.red("\u25CB");
1704
+ const name = skill.enabled ? skill.name : chalk4.dim(skill.name);
1705
+ const desc = chalk4.dim(truncate(skill.description, 50));
1706
+ console.log(` ${status} ${name}`);
1707
+ if (skill.description) {
1708
+ console.log(` ${desc}`);
1709
+ }
1710
+ }
1711
+ function truncate(str, maxLen) {
1712
+ if (str.length <= maxLen) return str;
1713
+ return str.slice(0, maxLen - 3) + "...";
1714
+ }
1715
+
1716
+ // src/commands/enable.ts
1717
+ import chalk5 from "chalk";
1718
+ import { Command as Command5, Option as Option5 } from "clipanion";
1719
+ init_skills();
1720
+ var EnableCommand = class extends Command5 {
1721
+ static paths = [["enable"]];
1722
+ static usage = Command5.Usage({
1723
+ description: "Enable one or more skills",
1724
+ examples: [
1725
+ ["Enable a skill", "$0 enable pdf"],
1726
+ ["Enable multiple skills", "$0 enable pdf xlsx docx"]
1727
+ ]
1728
+ });
1729
+ skills = Option5.Rest({ required: 1 });
1730
+ async execute() {
1731
+ const searchDirs = getSearchDirs();
1732
+ let success = 0;
1733
+ let failed = 0;
1734
+ for (const skillName of this.skills) {
1735
+ const skill = findSkill(skillName, searchDirs);
1736
+ if (!skill) {
1737
+ console.log(chalk5.red(`Skill not found: ${skillName}`));
1738
+ failed++;
1739
+ continue;
1740
+ }
1741
+ if (skill.enabled) {
1742
+ console.log(chalk5.dim(`Already enabled: ${skillName}`));
1743
+ continue;
1744
+ }
1745
+ const result = setSkillEnabled(skill.path, true);
1746
+ if (result) {
1747
+ console.log(chalk5.green(`Enabled: ${skillName}`));
1748
+ success++;
1749
+ } else {
1750
+ console.log(chalk5.red(`Failed to enable: ${skillName}`));
1751
+ failed++;
1752
+ }
1753
+ }
1754
+ if (success > 0) {
1755
+ console.log(chalk5.dim("\nRun `skillkit sync` to update your agent config"));
1756
+ }
1757
+ return failed > 0 ? 1 : 0;
1758
+ }
1759
+ };
1760
+ var DisableCommand = class extends Command5 {
1761
+ static paths = [["disable"]];
1762
+ static usage = Command5.Usage({
1763
+ description: "Disable one or more skills",
1764
+ examples: [
1765
+ ["Disable a skill", "$0 disable pdf"],
1766
+ ["Disable multiple skills", "$0 disable pdf xlsx docx"]
1767
+ ]
1768
+ });
1769
+ skills = Option5.Rest({ required: 1 });
1770
+ async execute() {
1771
+ const searchDirs = getSearchDirs();
1772
+ let success = 0;
1773
+ let failed = 0;
1774
+ for (const skillName of this.skills) {
1775
+ const skill = findSkill(skillName, searchDirs);
1776
+ if (!skill) {
1777
+ console.log(chalk5.red(`Skill not found: ${skillName}`));
1778
+ failed++;
1779
+ continue;
1780
+ }
1781
+ if (!skill.enabled) {
1782
+ console.log(chalk5.dim(`Already disabled: ${skillName}`));
1783
+ continue;
1784
+ }
1785
+ const result = setSkillEnabled(skill.path, false);
1786
+ if (result) {
1787
+ console.log(chalk5.yellow(`Disabled: ${skillName}`));
1788
+ success++;
1789
+ } else {
1790
+ console.log(chalk5.red(`Failed to disable: ${skillName}`));
1791
+ failed++;
1792
+ }
1793
+ }
1794
+ if (success > 0) {
1795
+ console.log(chalk5.dim("\nRun `skillkit sync` to update your agent config"));
1796
+ }
1797
+ return failed > 0 ? 1 : 0;
1798
+ }
1799
+ };
1800
+
1801
+ // src/commands/update.ts
1802
+ import { existsSync as existsSync16, rmSync as rmSync5, cpSync as cpSync2 } from "fs";
1803
+ import { join as join15 } from "path";
1804
+ import chalk6 from "chalk";
1805
+ import ora2 from "ora";
1806
+ import { Command as Command6, Option as Option6 } from "clipanion";
1807
+ init_skills();
1808
+ init_providers();
1809
+ var UpdateCommand = class extends Command6 {
1810
+ static paths = [["update"], ["u"]];
1811
+ static usage = Command6.Usage({
1812
+ description: "Update skills from their original sources",
1813
+ examples: [
1814
+ ["Update all skills", "$0 update"],
1815
+ ["Update specific skills", "$0 update pdf xlsx"],
1816
+ ["Force update (overwrite local changes)", "$0 update --force"]
1817
+ ]
1818
+ });
1819
+ skills = Option6.Rest();
1820
+ force = Option6.Boolean("--force,-f", false, {
1821
+ description: "Force update even if local changes exist"
1822
+ });
1823
+ async execute() {
1824
+ const spinner = ora2();
1825
+ const searchDirs = getSearchDirs();
1826
+ let skillsToUpdate;
1827
+ if (this.skills.length > 0) {
1828
+ skillsToUpdate = this.skills.map((name) => findSkill(name, searchDirs)).filter((s) => s !== null);
1829
+ const notFound = this.skills.filter((name) => !findSkill(name, searchDirs));
1830
+ if (notFound.length > 0) {
1831
+ console.log(chalk6.yellow(`Skills not found: ${notFound.join(", ")}`));
1832
+ }
1833
+ } else {
1834
+ skillsToUpdate = findAllSkills(searchDirs);
1835
+ }
1836
+ if (skillsToUpdate.length === 0) {
1837
+ console.log(chalk6.yellow("No skills to update"));
1838
+ return 0;
1839
+ }
1840
+ console.log(chalk6.cyan(`Updating ${skillsToUpdate.length} skill(s)...
1841
+ `));
1842
+ let updated = 0;
1843
+ let skipped = 0;
1844
+ let failed = 0;
1845
+ for (const skill of skillsToUpdate) {
1846
+ const metadata = loadSkillMetadata(skill.path);
1847
+ if (!metadata) {
1848
+ console.log(chalk6.dim(`Skipping ${skill.name} (no metadata, reinstall needed)`));
1849
+ skipped++;
1850
+ continue;
1851
+ }
1852
+ spinner.start(`Updating ${skill.name}...`);
1853
+ try {
1854
+ if (isLocalPath(metadata.source)) {
1855
+ const localPath = metadata.subpath ? join15(metadata.source, metadata.subpath) : metadata.source;
1856
+ if (!existsSync16(localPath)) {
1857
+ spinner.warn(chalk6.yellow(`${skill.name}: local source missing`));
1858
+ skipped++;
1859
+ continue;
1860
+ }
1861
+ const skillMdPath = join15(localPath, "SKILL.md");
1862
+ if (!existsSync16(skillMdPath)) {
1863
+ spinner.warn(chalk6.yellow(`${skill.name}: no SKILL.md at source`));
1864
+ skipped++;
1865
+ continue;
1866
+ }
1867
+ rmSync5(skill.path, { recursive: true, force: true });
1868
+ cpSync2(localPath, skill.path, { recursive: true, dereference: true });
1869
+ metadata.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1870
+ saveSkillMetadata(skill.path, metadata);
1871
+ spinner.succeed(chalk6.green(`Updated ${skill.name}`));
1872
+ updated++;
1873
+ } else {
1874
+ const provider = detectProvider(metadata.source);
1875
+ if (!provider) {
1876
+ spinner.warn(chalk6.yellow(`${skill.name}: unknown provider`));
1877
+ skipped++;
1878
+ continue;
1879
+ }
1880
+ const result = await provider.clone(metadata.source, "", { depth: 1 });
1881
+ if (!result.success || !result.path) {
1882
+ spinner.fail(chalk6.red(`${skill.name}: ${result.error || "clone failed"}`));
1883
+ failed++;
1884
+ continue;
1885
+ }
1886
+ const sourcePath = metadata.subpath ? join15(result.path, metadata.subpath) : result.path;
1887
+ const skillMdPath = join15(sourcePath, "SKILL.md");
1888
+ if (!existsSync16(skillMdPath)) {
1889
+ spinner.warn(chalk6.yellow(`${skill.name}: no SKILL.md in source`));
1890
+ rmSync5(result.path, { recursive: true, force: true });
1891
+ skipped++;
1892
+ continue;
1893
+ }
1894
+ rmSync5(skill.path, { recursive: true, force: true });
1895
+ cpSync2(sourcePath, skill.path, { recursive: true, dereference: true });
1896
+ rmSync5(result.path, { recursive: true, force: true });
1897
+ metadata.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1898
+ saveSkillMetadata(skill.path, metadata);
1899
+ spinner.succeed(chalk6.green(`Updated ${skill.name}`));
1900
+ updated++;
1901
+ }
1902
+ } catch (error) {
1903
+ spinner.fail(chalk6.red(`Failed to update ${skill.name}`));
1904
+ console.error(chalk6.dim(error instanceof Error ? error.message : String(error)));
1905
+ failed++;
1906
+ }
1907
+ }
1908
+ console.log();
1909
+ console.log(
1910
+ chalk6.cyan(
1911
+ `Updated: ${updated}, Skipped: ${skipped}, Failed: ${failed}`
1912
+ )
1913
+ );
1914
+ return failed > 0 ? 1 : 0;
1915
+ }
1916
+ };
1917
+
1918
+ // src/commands/remove.ts
1919
+ import { existsSync as existsSync17, rmSync as rmSync6 } from "fs";
1920
+ import chalk7 from "chalk";
1921
+ import { Command as Command7, Option as Option7 } from "clipanion";
1922
+ init_skills();
1923
+ var RemoveCommand = class extends Command7 {
1924
+ static paths = [["remove"], ["rm"], ["uninstall"]];
1925
+ static usage = Command7.Usage({
1926
+ description: "Remove installed skills",
1927
+ examples: [
1928
+ ["Remove a skill", "$0 remove pdf"],
1929
+ ["Remove multiple skills", "$0 remove pdf xlsx docx"],
1930
+ ["Force removal without confirmation", "$0 remove pdf --force"]
1931
+ ]
1932
+ });
1933
+ skills = Option7.Rest({ required: 1 });
1934
+ force = Option7.Boolean("--force,-f", false, {
1935
+ description: "Skip confirmation"
1936
+ });
1937
+ async execute() {
1938
+ const searchDirs = getSearchDirs();
1939
+ let removed = 0;
1940
+ let failed = 0;
1941
+ for (const skillName of this.skills) {
1942
+ const skill = findSkill(skillName, searchDirs);
1943
+ if (!skill) {
1944
+ console.log(chalk7.yellow(`Skill not found: ${skillName}`));
1945
+ continue;
1946
+ }
1947
+ if (!existsSync17(skill.path)) {
1948
+ console.log(chalk7.yellow(`Path not found: ${skill.path}`));
1949
+ continue;
1950
+ }
1951
+ try {
1952
+ rmSync6(skill.path, { recursive: true, force: true });
1953
+ console.log(chalk7.green(`Removed: ${skillName}`));
1954
+ removed++;
1955
+ } catch (error) {
1956
+ console.log(chalk7.red(`Failed to remove: ${skillName}`));
1957
+ console.error(chalk7.dim(error instanceof Error ? error.message : String(error)));
1958
+ failed++;
1959
+ }
1960
+ }
1961
+ if (removed > 0) {
1962
+ console.log(chalk7.dim("\nRun `skillkit sync` to update your agent config"));
1963
+ }
1964
+ return failed > 0 ? 1 : 0;
1965
+ }
1966
+ };
1967
+
1968
+ // src/commands/init.ts
1969
+ import chalk8 from "chalk";
1970
+ import { Command as Command8, Option as Option8 } from "clipanion";
1971
+ var InitCommand = class extends Command8 {
1972
+ static paths = [["init"]];
1973
+ static usage = Command8.Usage({
1974
+ description: "Initialize skillkit in a project",
1975
+ examples: [
1976
+ ["Auto-detect agent and initialize", "$0 init"],
1977
+ ["Initialize for specific agent", "$0 init --agent cursor"],
1978
+ ["List supported agents", "$0 init --list"]
1979
+ ]
1980
+ });
1981
+ agent = Option8.String("--agent,-a", {
1982
+ description: "Target agent type"
1983
+ });
1984
+ list = Option8.Boolean("--list,-l", false, {
1985
+ description: "List supported agents"
1986
+ });
1987
+ async execute() {
1988
+ if (this.list) {
1989
+ console.log(chalk8.cyan("Supported agents:\n"));
1990
+ const adapters2 = getAllAdapters();
1991
+ for (const adapter of adapters2) {
1992
+ console.log(` ${chalk8.green(adapter.type)}`);
1993
+ console.log(` Name: ${adapter.name}`);
1994
+ console.log(` Skills dir: ${adapter.skillsDir}`);
1995
+ console.log(` Config file: ${adapter.configFile}`);
1996
+ console.log();
1997
+ }
1998
+ return 0;
1999
+ }
2000
+ try {
2001
+ let agentType;
2002
+ if (this.agent) {
2003
+ agentType = this.agent;
2004
+ } else {
2005
+ console.log(chalk8.dim("Auto-detecting agent..."));
2006
+ agentType = await detectAgent();
2007
+ }
2008
+ const adapter = getAdapter(agentType);
2009
+ console.log(chalk8.cyan(`Initializing for ${adapter.name}...`));
2010
+ await initProject(agentType);
2011
+ console.log();
2012
+ console.log(chalk8.green("Initialized successfully!"));
2013
+ console.log();
2014
+ console.log(chalk8.dim("Created:"));
2015
+ console.log(chalk8.dim(` - ${adapter.skillsDir}/ (skills directory)`));
2016
+ console.log(chalk8.dim(` - skillkit.yaml (config file)`));
2017
+ console.log(chalk8.dim(` - ${adapter.configFile} (agent config)`));
2018
+ console.log();
2019
+ console.log(chalk8.cyan("Next steps:"));
2020
+ console.log(chalk8.dim(" 1. Install skills: skillkit install owner/repo"));
2021
+ console.log(chalk8.dim(" 2. Sync config: skillkit sync"));
2022
+ console.log(chalk8.dim(" 3. Use skills: skillkit read <skill-name>"));
2023
+ return 0;
2024
+ } catch (error) {
2025
+ console.error(chalk8.red("Initialization failed"));
2026
+ console.error(chalk8.dim(error instanceof Error ? error.message : String(error)));
2027
+ return 1;
2028
+ }
2029
+ }
2030
+ };
2031
+
2032
+ // src/commands/validate.ts
2033
+ init_skills();
2034
+ import { existsSync as existsSync18, readdirSync as readdirSync2 } from "fs";
2035
+ import { join as join16, basename as basename6 } from "path";
2036
+ import chalk9 from "chalk";
2037
+ import { Command as Command9, Option as Option9 } from "clipanion";
2038
+ var ValidateCommand = class extends Command9 {
2039
+ static paths = [["validate"], ["v"]];
2040
+ static usage = Command9.Usage({
2041
+ description: "Validate skill(s) against the Agent Skills specification (agentskills.io)",
2042
+ examples: [
2043
+ ["Validate a skill directory", "$0 validate ./my-skill"],
2044
+ ["Validate all skills in a directory", "$0 validate ./skills --all"]
2045
+ ]
2046
+ });
2047
+ skillPath = Option9.String({ required: true });
2048
+ all = Option9.Boolean("--all,-a", false, {
2049
+ description: "Validate all skills in the directory"
2050
+ });
2051
+ async execute() {
2052
+ const targetPath = this.skillPath;
2053
+ if (!existsSync18(targetPath)) {
2054
+ console.error(chalk9.red(`Path does not exist: ${targetPath}`));
2055
+ return 1;
2056
+ }
2057
+ const skillPaths = [];
2058
+ if (this.all) {
2059
+ const entries = readdirSync2(targetPath, { withFileTypes: true });
2060
+ for (const entry of entries) {
2061
+ if (entry.isDirectory()) {
2062
+ const skillPath = join16(targetPath, entry.name);
2063
+ if (existsSync18(join16(skillPath, "SKILL.md"))) {
2064
+ skillPaths.push(skillPath);
2065
+ }
2066
+ }
2067
+ }
2068
+ if (skillPaths.length === 0) {
2069
+ console.error(chalk9.yellow("No skills found in directory"));
2070
+ return 1;
2071
+ }
2072
+ } else {
2073
+ skillPaths.push(targetPath);
2074
+ }
2075
+ let hasErrors = false;
2076
+ for (const skillPath of skillPaths) {
2077
+ const skillName = basename6(skillPath);
2078
+ const result = validateSkill(skillPath);
2079
+ if (result.valid) {
2080
+ console.log(chalk9.green(`\u2713 ${skillName}`));
2081
+ if (result.warnings && result.warnings.length > 0) {
2082
+ result.warnings.forEach((w) => {
2083
+ console.log(chalk9.yellow(` \u26A0 ${w}`));
2084
+ });
2085
+ }
2086
+ } else {
2087
+ console.log(chalk9.red(`\u2717 ${skillName}`));
2088
+ result.errors.forEach((e) => {
2089
+ console.log(chalk9.red(` \u2022 ${e}`));
2090
+ });
2091
+ hasErrors = true;
2092
+ }
2093
+ }
2094
+ console.log();
2095
+ if (hasErrors) {
2096
+ console.log(chalk9.red("Validation failed"));
2097
+ console.log(chalk9.dim("See https://agentskills.io/specification for the complete format"));
2098
+ return 1;
2099
+ }
2100
+ console.log(chalk9.green(`Validated ${skillPaths.length} skill(s) successfully`));
2101
+ return 0;
2102
+ }
2103
+ };
2104
+
2105
+ // src/cli.ts
2106
+ var cli = new Cli({
2107
+ binaryLabel: "skillkit",
2108
+ binaryName: "skillkit",
2109
+ binaryVersion: "1.0.0"
2110
+ });
2111
+ cli.register(Builtins.HelpCommand);
2112
+ cli.register(Builtins.VersionCommand);
2113
+ cli.register(InstallCommand);
2114
+ cli.register(SyncCommand);
2115
+ cli.register(ReadCommand);
2116
+ cli.register(ListCommand);
2117
+ cli.register(EnableCommand);
2118
+ cli.register(DisableCommand);
2119
+ cli.register(UpdateCommand);
2120
+ cli.register(RemoveCommand);
2121
+ cli.register(InitCommand);
2122
+ cli.register(ValidateCommand);
2123
+ cli.runExit(process.argv.slice(2));
2124
+ //# sourceMappingURL=cli.js.map